sell.qg.php
来自「PHP+IIS+MySQL开发物流管理系统」· PHP 代码 · 共 493 行 · 第 1/2 页
PHP
493 行
<?php
#[产品销售]
if($act == "sell")
{
if(empty($id))
{
#[不存在id时显示的]
Error("操作非法!","admin.php?file=product&act=list");
}
$rs = $DB->qgGetOne("SELECT * FROM ".$prefix."product WHERE id='".$id."'");
HtmlStartForm("admin.php?file=sell&act=sellok&id=".$id);
HtmlEchoMsg("产品名称:","<input type='text' name='pinming' id='pingming' value='".$rs["pinming"]."' class='short_input' > ");
HtmlEchoMsg("产品型号:",$rs["subject"]);
HtmlEchoMsg("内部型号:",$rs["neibu"]);
HtmlEchoMsg("产品编号:",$rs["number"]);
HtmlEchoMsg("产品单价:",$rs["price"]." 元");
HtmlEchoMsg("*销售部门:",RadioShop("shopid")." [选择销售部门]");
HtmlEchoMsg("*出售数量:","<input type='text' name='pcount' id='pcount' value='1' class='short_input' onkeyup='gettotal(this.form)'> 千克 ");
HtmlEchoMsg("*总售价:","<input type='text' name='price' id='price' value='".$rs["price"]."' class='short_input'> 元 ".ZheKo("price"));
echo "\n<script language='javascript' type='text/javascript'>\n";
echo "function gettotal(form){\n";
echo "form.price.value = form.pcount.value * ".$rs["price"].";\n";
echo "}\n</script>\n";
HtmlEchoMsg("*包装规格:","<input type='text' name='guige' id='guige' value='25' class='short_input' > KG/箱;");
HtmlEchoMsg("客户编号:","<input type='text' name='usernumber' id='usernumber' value='".@$_COOKIE["usercard"]."'> <img src='./admin/images/friends.gif' align='absmiddle' style='cursor: pointer;cursor: hand;' onclick=\"qgOpen('admin.php?file=open.user&act=list&form=form&input=usernumber','form','500','600')\"> <img src='./admin/images/cleanup.gif' border='0' align='absmiddle' title='清空会员卡' onclick=\"qinggan_cleanup('usernumber')\" style='cursor: pointer;cursor: hand;'> [如有会员卡,请输入会员卡号]");
#[时间]
HtmlEchoMsg("销售时间:","<input type='text' name='selldate' value='".date("Y-m-d H:i:s",$system_time)."'>");
HtmlEchoMsg("运费付款方式:","<input type='text' name='yunfei' value='由发货方付,由收货方付,代收款扣付' class='long_input'> ");
HtmlEchoMsg("收款方式:","<input type='text' name='shoukuan' value='代收货款,等通知放货,现收,其他' class='long_input'> ");
HtmlEchoMsg("备注:","<input type='text' name='note' class='long_input'> [不超过80个汉字]");
HtmlEchoMsg("",HtmlButton("提 交").HtmlButton("返 回","admin.php?file=product&act=list&cateid=".$rs["cateid"]));
}
elseif($act == "sellok")
{
if(empty($id))
{
Error("操作非法!","admin.php?file=product&act=list");
}
$shopid = intval($shopid);
if(empty($shopid))
{
$shopRS = $DB->qgGetOne("SELECT * FROM ".$prefix."shop WHERE ifdefault=1");
if(empty($shopRS))
{
Error("请管理员先设置默认店铺!","admin.php?file=shopset&act=list");
}
$shopid = $shopRS["id"];
}
setcookie("qgShopID",$shopid);#[将该信息写入cookie中,以便下一次调用]
$rs = $DB->qgGetOne("SELECT * FROM ".$prefix."product WHERE id='".$id."'");
$pcount = intval($pcount);
$price = SafeHtml($price);
settype($price,"float");
$selldate = strtotime($selldate);
$note = SafeHtml($note);
#[判断是否有会员卡号]
$userid = 0;
if($usernumber)
{
setcookie("usercard",$usernumber);
$userRS = $DB->qgGetOne("SELECT id FROM ".$prefix."user WHERE number='".$usernumber."'");
if($userRS)
{
$userid = $userRS["id"];
}
else
{
Error("该会员卡号不存在!请检查...","admin.php?file=sell&act=sell&id=".$id);
}
}
else
{
setcookie("usercard","");
}
$DB->qgQuery("INSERT INTO ".$prefix."o(proid,number,pinming,subject,neibu,pcount,guige,price,selldate,adminer,yunfei,shoukuan,note,shopid,userid) VALUES('".$id."','".$rs["number"]."','".$pinming."','".$rs["subject"]."','".$rs["neibu"]."','".$pcount."','".$guige."','".$price."','".$selldate."','".$_SESSION["admin"]["user"]."','".$yunfei."','".$shoukuan."','".$note."','".$shopid."','".$userid."')");
#[增加产品销售记录]
#[修复增加产品销售记录的错误]
$DB->qgQuery("UPDATE ".$prefix."product SET sellcount=sellcount+".$pcount." WHERE id='".$id."'");
Error("销售记录成功!","admin.php?file=product&act=list&cateid=".$rs["cateid"]);
}
elseif($act == "total")
{
if($_SESSION["admin"]["typer"] != "system" && $_SESSION["admin"]["typer"] != "manager")
{
Error("只有一般管理员或系统管理员才有此权限!","admin.php?file=index");
}
#[销售统计]
$msg = HtmlButton("总销售量","admin.php?file=sell&act=total&action=list");
$msg .= HtmlButton("我的售量","admin.php?file=sell&act=total&action=my");
$msg .= HtmlButton("今日统计","admin.php?file=sell&act=total&action=today");
$msg .= HtmlButton("昨日统计","admin.php?file=sell&act=total&action=yestoday");
$msg .= HtmlButton("本月销售","admin.php?file=sell&act=total&action=month");
$msg .= HtmlButton("上月销售","admin.php?file=sell&act=total&action=lastmonth");
$msg .= HtmlButton("今年销售","admin.php?file=sell&act=total&action=year");
$msg .= HtmlButton("去年销售","admin.php?file=sell&act=total&action=lastyear");
$msg .= HtmlButton("高级搜索","admin.php?file=sell&act=total&action=user");
HtmlEchoMsg($msg);
if($action == "today")
{
$s1 = mktime(0,0,0,date("m",$system_time),date("d",$system_time),date("Y",$system_time));
$s2 = mktime(0,0,0,date("m",$system_time),date("d",$system_time)+1,date("Y",$system_time));
$url = "admin.php?file=sell&act=total&action=list¬e=".$action."&startDate=".$s1."&endDate=".$s2;
header("Location:".$url);
}
elseif($action == "yestoday")
{
$s1 = mktime(0,0,0,date("m",$system_time),date("d",$system_time)-1,date("Y",$system_time));
$s2 = mktime(0,0,0,date("m",$system_time),date("d",$system_time),date("Y",$system_time));
$url = "admin.php?file=sell&act=total&action=list¬e=".$action."&startDate=".$s1."&endDate=".$s2;
header("Location:".$url);
}
elseif($action == "month")
{
$s1 = mktime(0,0,0,date("m",$system_time),1,date("Y",$system_time));
$s2 = mktime(0,0,0,date("m",$system_time)+1,1,date("Y",$system_time));
$url = "admin.php?file=sell&act=total&action=list¬e=".$action."&startDate=".$s1."&endDate=".$s2;
header("Location:".$url);
}
elseif($action == "lastmonth")
{
$s1 = mktime(0,0,0,date("m",$system_time)-1,1,date("Y",$system_time));
$s2 = mktime(0,0,0,date("m",$system_time),1,date("Y",$system_time));
$url = "admin.php?file=sell&act=total&action=list¬e=".$action."&startDate=".$s1."&endDate=".$s2;
header("Location:".$url);
}
elseif($action == "year")
{
$s1 = mktime(0,0,0,1,1,date("Y",$system_time));
$s2 = mktime(0,0,0,1,1,date("Y",$system_time)+1);
$url = "admin.php?file=sell&act=total&action=list¬e=".$action."&startDate=".$s1."&endDate=".$s2;
header("Location:".$url);
}
elseif($action == "lastyear")
{
$s1 = mktime(0,0,0,1,1,date("Y",$system_time)-1);
$s2 = mktime(0,0,0,1,1,date("Y",$system_time));
$url = "admin.php?file=sell&act=total&action=list¬e=".$action."&startDate=".$s1."&endDate=".$s2;
header("Location:".$url);
}
elseif($action == "my")
{
$url = "admin.php?file=sell&act=total&action=list¬e=".$action;
header("Location:".$url);
}
elseif($action == "user")
{
if(empty($seturl))
{
HtmlStartForm("admin.php?file=sell&act=total&action=user");
echo "<input type='hidden' name='seturl' value='ok'>";
HtmlEchoMsg("办事处:",RadioShop("shopid","",true));
HtmlEchoMsg("关键字:","<input type='text' name='keywords'>");
HtmlEchoMsg("客户编号:","<input type='text' name='knumber'>");
HtmlEchoMsg("员工账号:","<input type='text' name='kuser'> [查看员工的销售记录]");
HtmlEchoMsg("产品编号:","<input type='text' name='pnumber'>");
HtmlEchoMsg("时间:","<input type='text' name='startDate' onfocus='setday(this)'> - <input type='text' name='endDate' onfocus='setday(this)'>");
HtmlEchoMsg("","[时间格式:YYYY-mm-dd HH:ii:ss 或 YYYY-mm-dd]");
HtmlEchoMsg("",HtmlButton("查 询"));
HtmlEndForm();
}
else
{
$url = "admin.php?file=sell&act=total&action=list¬e=".$action;
if($startDate && $endDate)
{
$s1 = strtotime($startDate);
$s2 = strtotime($endDate);
if($s1 > $s2)
{
$s3 = $s2;
$s1 = $s2;
$s2 = $s3;
}
}
if($s1 && $s2)
{
$url .= "&startDate=".$s1."&endDate=".$s2;
}
if($shopid)
{
$url .= "&shopid=".$shopid;
}
if($keywords)
{
$url .= "&keywords=".rawurlencode($keywords);
}
if($knumber)
{
$url .= "&knumber=".rawurlencode($knumber);
}
if($pnumber)
{
$url.= "&pnumber=".rawurlencode($pnumber);
}
if($kuser)
{
$url .= "&kuser=".rawurlencode($kuser);
}
header("Location:".$url);
}
}
elseif($action == "list")
{
DeleteJs("admin.php?file=sell&act=delete&id=","是否要删除该销售,删除后是无法恢复的");
$msgArray = array("today"=>"今天","yestoday"=>"昨天","month"=>"本月","lastmonth"=>"上个月","year"=>"今年","lastyear"=>"去年","my"=>"我的");
$msg = $msgArray[$note] ? $msgArray[$note] : "";
if($kuser)
{
$kuser = rawurldecode($kuser);
$msg .= " <span style='color:red;'>".$kuser."</span> ";
}
HtmlEchoMsg($msg."产品销售列表");
$condition = "WHERE 1";
$urlext = "";
if($startDate && $endDate)
{
$condition .= " AND(o.selldate between ".$startDate." AND ".$endDate.")";
$urlext .= "&startDate=".$startDate."&endDate=".$endDate;
}
if($shopid)
{
$condition .= " AND o.shopid='".$shopid."'";
$urlext .= "&shopid=".$shopid;
}
if($keywords)
{
$keywords = rawurldecode($keywords);
$condition .= " AND o.subject LIKE '%".$keywords."%'";
$urlext .= "&keywords=".rawurlencode($keywords);
}
if($knumber)
{
#[获取会员编号所在ID]
$knumber = rawurldecode($knumber);
$userRS = $DB->qgGetAll("SELECT id FROM ".$prefix."user WHERE number LIKE '%".$knumber."%'");
if($userRS)
{
$userCount = count($userRS);
if($userCount>1)
{
$userIdArray =array();
foreach($userRS AS $key=>$value)
{
$userIdArray[$key] = "o.userid='".$value["id"]."'";
}
$condition .= " AND (".implode(" OR ",$userIdArray).")";
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?