?? acc_gcbrzw.php
字號:
<?php
////////////////////////////////////////////////////////
// Author by Shuweich
// Date : 2007.11.18
// 建站支持: http://www.shuweich.net
// 作者: Shuweich
// QQ: 1502384
// ICQ: 190492112
// MSN: shuweich@hotmail.com
// E-mail: root@shuweich.net
// E-mail: shuweich@163.com
////////////////////////////////////////////////////////
// 模塊管理 by txdyz
// For 軋帳
////////////////////////////////////////////////////////
include_once '../../mainfile.php';
include_once 'head_inc.php';
include_once 'head_win.php';
## TRUNCATE TABLE Table_Name // 清空表文件
## 檢查庫存商品信息,若空則從公用商品信息表引入商品信息
$Squ = "select bybz from ".$xoopsDB->prefix("market_store")." where store_id='".$_REQUEST['s_id0']."' limit 0,1";
$ssp0 = $xoopsDB->fetchrow( $xoopsDB->query($Squ) );
$S_ID = substr($ssp0[0],23,1)=='7'?'696':$_REQUEST['s_id0'];
$que = "select sp_id from ".$xoopsDB->prefix("market_spkc")." where store_id='".$_REQUEST['s_id0']."'";
$rnm = $xoopsDB->getRowsNum( $xoopsDB->query($que) );
if ( $rnm < 1 ) {
$del = "delete from ".$xoopsDB->prefix("market_spkc");
$del.= " where store_id='".$_REQUEST['s_id0']."'";
$de0 = $xoopsDB->queryF($del);
$ins = "insert into ".$xoopsDB->prefix("market_spkc")." (sp_id,store_id,sp_code,sp_barcode) ";
$ins.= " select 0,'".$_REQUEST['s_id0']."',sp_code,sp_barcode from ".$xoopsDB->prefix("market_spinfo");
$ins.= " where store_id='".$S_ID."'";
$in0 = $xoopsDB->queryF($ins);
}
## 提取記帳數據
$que = "select sp_code,sp_barcode,zy,sum(xssl) hjsl,date_q from ";
$que .= $xoopsDB->prefix("market_mdseri");
$que .= " where store_id='".$_REQUEST['s_id0']."' and sp_code!='' and shbz!='2'";
$que .= " group by zy,sp_code";
$res = $xoopsDB->query($que);
## 商品庫存明細及商品庫存
while ( $row = $xoopsDB->fetchrow($res) ) {
## 借貸方交易分類
if ( array_search($row[2],$_Akc) ) {
$_mx_cols = 'jf'; ## 借記庫存
$fse = $row[3];
} elseif ( array_search($row[2],$_Skc) ) {
$_mx_cols = 'df'; ## 貸記庫存
$fse = 0 - $row[3];
} else {
echo "交易未定義!";
$_mx_cols = 'jd'; ## 未知交易,貸記庫存
$fse = 0 - $row[3];
}
## 登記單品庫存帳
## 若記錄不存在,則先插入
$din = "select store_id,sp_code from ".$xoopsDB->prefix("market_spkc");
$din .=" where store_id='".$_REQUEST['s_id0']."' and sp_code='".$row[0]."'";
$din = $xoopsDB->getRowsNum( $xoopsDB->query($din) );
if ( $din != 1 ) {
$del = "delete from ".$xoopsDB->prefix("market_spkc");
$del.= " where store_id='".$_REQUEST['s_id0']."' and sp_code='".$row[0]."'";
$de0 = $xoopsDB->queryF($del);
$ins = "insert into ".$xoopsDB->prefix("market_spkc")." (sp_id,store_id,sp_code,sp_barcode) ";
$ins.= " select 0,'".$_REQUEST['s_id0']."',sp_code,sp_barcode from ".$xoopsDB->prefix("market_spinfo");
$ins.= " where store_id='".$S_ID."' and sp_code='".$row[0]."'";
$in0 = $xoopsDB->queryF($ins);
}
## 庫存記帳
$upd = "update ".$xoopsDB->prefix("market_spkc");
## $upd.= " set sp_date=now(),jzzy='".$row[2]."',sp_kc=sp_kc+(".$fse."),rz_user_id='".$xoopsUser->getVar("uid")."' ";
$upd.= " set sp_date='".$row[4]."',jzzy='".$row[2]."',sp_kc=sp_kc+(".$fse."),rz_user_id='".$xoopsUser->getVar("uid")."' ";
$upd.= " where store_id='".$_REQUEST['s_id0']."' and sp_code='".$row[0]."'";
// echo "<hr /> update:".$upd;
$upd0 = $xoopsDB->queryF($upd);
## 登記單品庫存明細帳
$jy0 = "select store_id,sp_code,sp_kc from ".$xoopsDB->prefix("market_spkc")." where store_id='".$_REQUEST['s_id0']."' and sp_code='".$row[0]."'";
$jy9 = $xoopsDB->fetchrow( $xoopsDB->query($jy0) );
$ins = "insert into ".$xoopsDB->prefix("market_spkcmx");
$ins.= "(sp_id,store_id,sp_code,sp_barcode,sp_indate,sp_date,jzzy,".$_mx_cols.",sp_kc,rz_user_id) values (";
$ins.= "0,";
$ins.= "'".$_REQUEST['s_id0']."',";
$ins.= "'".$row[0]."',";
$ins.= "'".$row[1]."',";
$ins.= "'".$row[4]."',";
$ins.= "now(),";
$ins.= "'".$row[2]."',";
$ins.= "'".$row[3]."',";
$ins.= "'".$jy9[2]."',";
$ins.= $xoopsUser->getVar("uid");
$ins.= ")";
// echo "<hr /> insert:".$ins;
$ins0 = $xoopsDB->queryF($ins);
}
while ( list($dj,$jym)=each($_TXjy) ) {
## 登記現金日記總帳
## 上次結余
$_dj = explode(":",$dj); $_h = $_dj[0]; $_m = $_dj[1];
$que = "select jy from ".$xoopsDB->prefix("market_cash")." where store_id='".$_REQUEST['s_id0']."'";
$que .=" order by ca_id desc limit 0,1";
$zrjy = $xoopsDB->fetchrow( $xoopsDB->query($que) );
$zrjy[0] = floatval($zrjy[0]);
## 今日營業額
$que = "select sum(spzkj) xsje ";
$que.= " from ".$xoopsDB->prefix("market_mdseri");
$que.= " where store_id='".$_REQUEST['s_id0']."' and shbz!='2' and zy in (".$jym.")";
$yye = $xoopsDB->fetchrow( $xoopsDB->query($que) );
## 本次結余
$yye[0] = floatval($yye[0]);
if ( $yye[0] === 0.0 ) continue;
$jrjy = $zrjy[0] + $yye[0];
$ins = "insert into ".$xoopsDB->prefix("market_cash");
$ins .=" (ca_id,store_id,ca_date,ca_djh,ca_zy,jf,jy,ca_shbz,jz_user_id) values (";
$ins .="0,'".$_REQUEST['s_id0']."',now(),'".$_h."','".$_m."',".$yye[0].",".$jrjy.",'0',".$xoopsUser->getVar("uid").")";
$ins1 = $xoopsDB->queryF($ins);
}
## 將流水帳轉移到歷史流水帳表中,以備后查
$ins = "insert into ".$xoopsDB->prefix("market_mdseri_history");
$ins.= " select 0,store_id,sdbh,bdxh,date_q,now(),user_card,user_disc,sp_fl,sp_barcode,sp_code,zy,xssl,sj,spzkj,zkl,zke,mle,tach,rz_user_id,shbz,sh_user_id,oth_read from ".$xoopsDB->prefix("market_mdseri");
$ins.= " where store_id='".$_REQUEST['s_id0']."'";
$in0 = $xoopsDB->queryF($ins);
## 清本日流水帳
if ($in0 && $ins0 && $upd0 && $ins1 ) {
$del = "delete from ".$xoopsDB->prefix("market_mdseri");
$del.= " where store_id='".$_REQUEST['s_id0']."'";
$de0 = $xoopsDB->queryF($del);
}
if ( $de0 ) {
echo "<script language='javascript'><!--\n";
echo " alert('軋帳完畢,本店當日流水帳已經匯入歷史賬中!');\n";
echo " window.close();\n";
echo "</script>\n";
} else {
$msgg = '';
if ( !$in0 ) $msgg .= '流水帳轉存出錯,';
if ( !$ins0 ) $msgg .= '登記單品庫存帳出錯,';
if ( !$upd0 ) $msgg .= '登記單品庫存明細帳出錯,';
if ( !$ins1 ) $msgg .= '登記現金日記帳出錯,';
if ( !$de0 ) $msgg .= '清空流水帳出錯,';
$msgg = substr($msgg,0,-1)."!";
echo "<script language='javascript'><!--\n";
echo ' alert("軋帳失敗:\n'.$msgg.'");';
echo "\n window.close();\n";
echo "</script>\n";
}
include_once '../../footer.php';
?>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -