"all") and ($_POST[maker]<>"")){
$strsqlmaker = " and makercode = '".$_POST[maker]."'";
$makerid = $_POST[maker];
}
//処理日
$norundata = dbselect("operatedate","`".$company."status`","gyotaiid='".$userdata[gyotaiid]."' and picktimes = 1 and status < 6 and operatedate < DATE_ADD(CURDATE(),INTERVAL 3 DAY) and centerid ='".$centerid."'","operatedate","1");
$executedate = $norundata[0][0];
if($norundata[0][0] == "") {
$executedate = date("Y-m-d",strtotime ("+1 day"));
}
//更新処理
if ($_POST[update] <> ""){
$errcount = 0; //エラーカウント
$okcount = 0; //OKカウント
$errmsg = ""; //エラーメッセージ
For ($y=0;$y<((int)$_POST[rownum]);$y++) {
if ($_POST{"lot".$y} == "") break;
//ロケーション実存確認https://byzqrudj.securesites.com/abu/3000.php#fragment-3
/* $strlocation=$_POST{"location".$y};$strlocationmsg="";
if($strlocation<>"") {
$loccheck =locationcheck($strlocation); //0:実在しない 1:実在
if ($loccheck==0) {
$strlocationmsg = $_POST{"shohin".$y}." ロケーション[".$strlocation."]が実在しません
";
$strlocation = "[ERROR]".$strlocation;
}
} else {
$loccheck = -1; //-1:対象外
}*/
if(($_POST{"amount".$y} == 0) and ($_POST{"arrangeid".$y} == 0)) {
//更新しない 新規で数量も0
} elseif(($_POST{"amount".$y} <> 0) and ($_POST{"arrange".$y} == 0)) {
//データ不備で更新しない
$errcount++;
$errmsg .="事由が指定されていないため登録できませんでした。
";
} elseif(($_POST{"maxarrange".$y} + $_POST{"amount".$y}) < 0) {
//有効在庫数を上回る調整数
$errcount++;
$errmsg .="有効在庫数を超える調整数のため登録できませんでした。
";
} else {
if($_POST{"amount".$y}==0) {
$arrangekubun=0;
$biko ="";
} else {
$arrangekubun=$_POST{"arrange".$y};
$biko = Eucjp($_POST{"biko".$y});
}
$strsql = "UPDATE `".$company."stockdata` SET arrangeqty='".(int)$_POST{"amount".$y}."',nonreserveqty = ".((int)$_POST{"nonreserveqty".$y} - (int)$_POST{"amountold".$y} + (int)$_POST{"amount".$y}).",updater='".$userdata["tid"]."', biko='".$biko."' ,arrangekubun='".$arrangekubun."',arrangeid = 0 where lotnum='".$_POST{"lot".$y}."' limit 1";
$result=mysql_query($strsql,$my_con);
Testecho($y." = ".$strsql); #debug
$errcode =mysql_errno();
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
if($errcode==1062) { //賞味期限重複のため、数を足す
Testecho ("A.更新 1062");
$errcount++;
} elseif($errcode==0) {
if(mysql_affected_rows()==1) { $okcount++; }
Testecho ("A.更新 OK 0");
} else {
Testecho ("A.更新 ERROR");
$errcount++;
$errmsg .= "ERROR=".$errcode;
}
//$strsql = "DELETE FROM `".$company."stockarrange` WHERE arrangeid='".(int)$_POST{"arrangeid".$y}."'";
$strsql = "DELETE FROM `".$company."stockarrange` WHERE lotnum='".$_POST{"lot".$y}."' and arrangedate = '".$executedate."'";
$result=mysql_query($strsql,$my_con);
Testecho($y." = ".$strsql); #debug
$errcode =mysql_errno();
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
if($_POST{"amount".$y} <> 0) {
$strsql = "INSERT INTO `".$company."stockarrange` (lotnum,shohincd,centerid,stockdate,shomi,arrangeqty,arrangekubun,biko,arrangedate,creater) SELECT lotnum,shohincd,centerid,stockdate,shomi,arrangeqty,arrangekubun,biko,'".$executedate."','".$userdata["tid"]."' FROM `".$company."stockdata` WHERE lotnum='".(int)$_POST{"lot".$y}."'";
$result=mysql_query($strsql,$my_con);
Testecho($y." = ".$strsql); #debug
$errcode =mysql_errno();
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
// $sadata = dbselect("arrangeid","`".$company."stockarrange`",-1,"updatetime desc","1");
// $strsql = "UPDATE `".$company."stockdata` SET arrangeid='".$sadata[0][0]."' where lotnum='".$_POST{"lot".$y}."' limit 1";
$strsql = "UPDATE `".$company."stockdata` SET arrangeid = LAST_INSERT_ID() where lotnum='".$_POST{"lot".$y}."' limit 1";
$result=mysql_query($strsql,$my_con);
Testecho($y." = ".$strsqldbselect." ".$strsql); #debug
$errcode =mysql_errno();
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
}
}
}
//START POST時以外は検索しない
if ($centerid<>"") {
//1ページ数
$pageset = 20;
//レコードの指定
if ($_POST[pagenum] == "") {
$page = 1;
} else {
$page = (int)$_POST[pagenum];
}
//データ取得数
$limit = " LIMIT ".($pageset*($page - 1)).",$pageset";
//検索処理
$sw = Eucjp($_POST[searchword]);
$sw = str_replace(" ","",$sw); //空白除く
$sw = mb_convert_kana($sw,'KV'); //全て全角へ変換
//検索用語のWHERE句
$strsql = "";
if ($sw<>"") {
$strsqljoin = " and sm.searchword like '%".$sw."%'";
} else {
$strsqljoin = "";
}
$strsqljoin .= " and validflg=1";
$strsql = "SELECT lotnum, sd.shohincd, sd.centerid, stockdate, sd.shomi, nonreserveqty,arrangeqty, sd.location, nonreserveqty ,stockqty ,sd.arrangekubun,biko,sm.shohinmei,sm.makercode,sd.arrangeid,sm.shomiflg,sm.zaiko FROM `".$company."stockdata` AS sd INNER JOIN `".$company."shohinmaster` AS sm USING(shohincd) WHERE ryutu_type = 1 ".$strsqljoin.$strsqlmaker." AND centerid='".$centerid."' order by shohincd,shomi,stockdate";
//全数
$resultall=@mysql_query($strsql,$my_con);
$maxrow=@mysql_num_rows($resultall);
//1ページ分
$strsql .= $limit;
$result=@mysql_query($strsql,$my_con);
$row=@mysql_num_rows($result);
}
?>