2 3 include "inc/check_login.php";
4 include "inc/function.inc";
5 $id=mysql_link("storage","storage");//建立storage连接
6
7 $query="select * from admin where admin_id='$workid'";//定位仓库
8 $result=mysql_query($query,$id);
9 $info=mysql_fetch_array($result,MYSQL_ASSOC);
$stoid=$info['storage_id'];
?>
仓库管理
$query="select * from storage where storage_id='$stoid'";//定位仓库信息
$result=mysql_query($query,$id);
if(mysql_num_rows($result)<1){
echo "没有仓库".$stoid;
}else{
$info=mysql_fetch_array($result,MYSQL_ASSOC);
echo "仓库号:".$stoid." 总容量:".$info['storage_cap']." 剩余容量:".$info['storage_lcap']."
仓库地址:".$info['storage_add']." 仓库电话:".$info['storage_tele'];
if (!mysql_select_db("basicbase",$id)){
die ("Can\'t select_db : " . mysql_error());
}
//在basicbase中建立对应仓库货物视图,入库视图以及出库视图
//判断是否存在相关视图,没有的话就新建视图
$query="select * from ".$stoid."_inventory";
if(!mysql_query($query,$id)){
//创建inventory视图
$query="create view ".$stoid."_inventory as
select inventory.goods_id,name,number from inventory,systembase.goods where storage_id=".$stoid." and inventory.goods_id=systembase.goods.goods_id";
if(!mysql_query($query,$id)){
die ("Can\'t create_view_inventory : " . mysql_error());
}
//创建input视图
$query="create view ".$stoid."_input as
select input_id,goods_id,number,time from input where admin_id=".$workid;
if(!mysql_query($query,$id)){
die ("Can\'t create_view_input : " . mysql_error());
}
//创建output视图
$query="create view ".$stoid."_output as
select output_id,goods_id,number,time from output where admin_id=".$workid;
if(!mysql_query($query,$id)){
die ("Can\'t create_view_output : " . mysql_error());
}
}
$query="select * from ".$stoid."_inventory";
$result=mysql_query($query,$id);
if(mysql_num_rows($result)<1){
echo "
该仓库目前是空的";
}else{
$totalnum=mysql_num_rows($result);
$pagesize=7;
$page=$_GET["page"];
if(""==$page){
$page=1;
}
$begin=($page-1)*$pagesize;
$totalpage=ceil($totalnum/$pagesize);
echo "仓库中共有".$totalnum."种货物。";
echo "每页".$pagesize."种,共".$totalpage."页。
";
for($j=1;$j<=$totalpage;$j++){
echo "[".$j."] ";
}
echo "
";
$query="select *from ".$stoid."_inventory order by goods_id limit $begin,$pagesize";
$result=mysql_query($query,$id);
$datanum=mysql_num_rows($result);
//echo "货物id | 货物名称 | 货物数量 |
";
echo "货物id | 货物名称 | 货物数量 |
";
for($i=1;$i<=$datanum;$i++){
$info=mysql_fetch_array($result,MYSQL_ASSOC);
//echo "".$info['goods_id']." | ".$info['name']." | ".$info['number']." |
";
echo "".$info['goods_id']." | ".$info['name']." | ".$info['number']." |
";
}
}
}
mysql_close($id);
?>