"") {
$sw = $_POST[searchword];
$strsqlwhere = " and sm.searchword like '%".$_POST[searchword]."%'";
$strsqlorderby = "shu.shozokuid,shu.shohincd,shu.shomi,shu.stockdate";
} elseif ( $_POST[shohincd] <> "") {
$strsqlwhere = " and sm.shohincd = '".$_POST[shohincd]."'";
$shohincd = $_POST[shohincd];
$strsqlorderby = "shu.route,shu.shozokuid,shu.shomi,shu.stockdate";
} else {
$strsqlorderby = "shu.shozokuid,shu.shohincd,shu.shomi,shu.stockdate";
}
//ブランド区分を入れる
$strsql ="Update cool_shukka as shu ,cool_shozokumaster as sho SET shu.brand = sho.brand WHERE shu.shozokuid = sho.shozokuid and shu.brand =''";
$result=@mysql_query($strsql,$my_con);
$strsqlall .= "ROW=".mysql_affected_rows()." ".$strsql."\n";
//1ページ数
$pageset = 100;
//注文日
if (($_GET[chgday] =="") and ($_POST[chgday] =="")){
$orderdate = 0;
} elseif ($_GET[chgday] <> ""){
$orderdate = $_GET[chgday];
} else {
$orderdate = $_POST[chgday]; //出荷作業日
}
//作業日
$operatedate = $orderdate;
//オプション
$codedata104 = dbselect("cname,code","`".$company."code`","codekind = 104 and code > 0","codeid",-1);
//業態料率
$codedata120 = dbselect("cname,code","`".$company."code`","codekind = 120","codeid",-1);
//不定貫
$codedata10 = dbselect("cname,code","`".$company."code`","codekind = 10","code",-1);
//流通型
if ($_POST[ryutu_type] == ""){
$ryutu_type = 2; //通過
} else {
$ryutu_type = (int)$_POST["ryutu_type"]; //1:在庫 2:通過
}
//店舗データ入れ替え
if($userdata[brand] <> "") {
$strsqlbrand = " and sho.brand in(".$userdata[brand].")";
$strsqlshozoku = dbselectin("SELECT shozokuid FROM `".$company."shozokumaster` as sho WHERE 1 $strsqlbrand"," and shu.shozokuid in ");
}
//商品データ
if ($userdata["supplyerid2"]<> ""){
// $strsql = "SELECT shohincd FROM `".$company."shohinmaster` WHERE makercode in (".$userdata["supplyerid2"].") ";
// $strsqlsm = dbselectin($strsql," and shohincd in ");
}
//サプライヤー
if ($_POST[maker] <> "") {
$strsqmaker = " and sm.makercode = '$_POST[maker]'";
}
if ($userdata["supplyerid2"] <> ""){
$strsqmaker .= " and sm.makercode in (".$userdata["supplyerid2"].") ";
}
//店舗・商品データ
$tenpodata = dbselect("shozokuname,shu.shozokuid","`".$company."shozokumaster` as sho INNER JOIN `".$company."shukka` as shu using (shozokuid)","shu.operatedate = DATE_ADD(CURDATE(),INTERVAL $orderdate DAY) $strsqlbrand $strsqlsm GROUP BY shu.shozokuid ","shu.shozokuid",-1);
Testecho($strsqldbselect);
$tenpodataall = dbselect("shozokuname,shozokuid","`".$company."shozokumaster` as sho","1 $strsqlbrand",-1,-1);
$shohindata = dbselect("concat(shohinmei,(case when zaiko = 1 then '' else ' 【非公開中】' end)),shu.shohincd","`".$company."shohinmaster` as sm INNER JOIN `".$company."shukka` as shu using (shohincd)","shu.operatedate = DATE_ADD(CURDATE(),INTERVAL $orderdate DAY) $strsqlshozoku $strsqmaker GROUP BY shu.shohincd ","sm.code,sm.zaiko desc,sm.shohincd",-1);
Testecho($strsqldbselect);
$shohindataall = dbselect("concat(cname,' ',shohinmei,(case when zaiko = 1 then ' ' else '【非公開中】' end),(case when makercode = 'waka' then ' 【一幸】' else '' end),makercode),shohincd","`".$company."shohinmaster` as sm INNER JOIN `".$company."code` as cd","sm.code = cd.code and codekind = 1 $strsqmaker","sm.code,zaiko desc,shohincd",-1);
Testecho($strsqldbselect);
//不定貫
if($_POST[futeikan] == "") {
$futeikan = 1;
} else {
$futeikan = $_POST[futeikan];
}
//業態
if ($_POST[gyotai]<>""){
$gyotaiid = $_POST[gyotai];
} else {
$gyotaiid = $gyotaidata[0][1];
}
$strsqlwhere .= "and shu.gyotaiid= '".$gyotaiid ."'";
//納品先
if ($_POST[tenpo]<>""){
$shozokuid = $_POST[tenpo];
$strsqlwhere .= " and shu.shozokuid = '$shozokuid'";
} elseif ($_GET[shotenp] <> "") {
$shozokuid = $_GET[shotenp];
$strsqlwhere .= " and shu.shozokuid = '$shozokuid'";
}
//変更処理
if (($_POST[allsubmit] == "update") or ($_POST[allsubmit] == "kakutei")){
if($_POST[allsubmit] == "kakutei") {
$flg = 2;
} else {
$flg = 1;
}
For ($y=0;$y< $_POST[row];$y++) {
$totalgram = 0;
if((int)$_POST{"fix".$y} == 1) {
//確定済みはメモのみ更新
$strsql = "UPDATE `".$company."shukka` set memoadd='".sqlinjection($_POST{"memoadd".$y},-1)."',updater='".$userdata["tid"]."' ";
$strsql .= " WHERE shukkaid = '".$_POST{"id".$y}."' limit 1";
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql); //debug
$result=@mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
} else {
//更新(出荷数量)
if ((Numchecker6403($_POST{"amount".$y})=="CHR") or (Numchecker6403($_POST{"price".$y})=="CHR")) {
//0.数値欄に文字が入れられたら何も更新しない。
$errmsg .= "数値以外の入力値がありましたので、更新できない商品がありました。No.".($y + 1)." [".$_POST{"shohincd".$y}."]
";$errcount++;
} else {
$strsql = "UPDATE `".$company."shukka` set shukkaqty='".$_POST{"amount".$y}."',memo3='".sqlinjection($_POST{"shohinname".$y},-1)."',memoadd='".sqlinjection($_POST{"memoadd".$y},-1)."',price_piece = '".$_POST{"price".$y}."',shukkaflg =".$flg.", updater='".$userdata["tid"]."' ";$okcount++;
$strsql .= " WHERE shukkaid = '".$_POST{"id".$y}."' limit 1";
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql); //debug
$result=@mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
//更新(重量)
if (sizeof($_POST{"gram".$y} > 0) and ($futeikan == 1)) {
$strsql = "DELETE FROM `".$company."shukkafuteikan` WHERE shukkaid='".$_POST{"id".$y}."'";
$result=@mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
for ($pi = 0; $pi < sizeof($_POST{"gram".$y}); $pi++) {
if (($_POST{"gram".$y}[$pi] <> "") and (Numchecker6403($_POST{"gram".$y}[$pi]) == "CHR")) {
//0.数値欄に文字が入れられたら何も更新しない。
$errmsg .= "数値以外の入力値がありましたので、更新できない商品がありました。No.".($y + 1)." [".$_POST{"shohincd".$y}."]
";$errcount++;
} elseif(Numchecker2($_POST{"gram".$y}[$pi]) > 0) {
$strsql = "INSERT INTO `".$company."shukkafuteikan`(shukkaid,gram,creater,createdate) VALUES('".$_POST{"id".$y}."','".$_POST{"gram".$y}[$pi]."','".$userdata["tid"]."',now())";$okcount++;
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
$totalgram += $_POST{"gram".$y}[$pi];
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
}
}
//出荷実績の不定貫合計重量TOTALGRAM更新、合計金額計算
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET totalgram = '".$totalgram."',shukkaflg =".$flg." ,price_total = truncate(".($totalgram * $_POST{"price".$y}).",0) WHERE shohin_kubun3 >= 0 and shukkaid= '".$_POST{"id".$y}."' and shu.shohincd = sm.shohincd ";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//出荷実績の不定貫だが、合計重量0は、確定できない
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET shukkaflg = 1 WHERE shukkaflg = 2 and shu.shohincd = sm.shohincd and sm.shohin_kubun3 = 1 and totalgram = 0 and shukkaid= '".$_POST{"id".$y}."'";
$result=mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
if(mysql_affected_rows() == 1) {
$errmsg .= "重量入力がないため、確定できない不定貫商品がありました。No.".($y + 1)." [".$_POST{"shohincd".$y}."]
";$errcount++;
}
//合計金額を計算(個数)
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET price_total = truncate(".($_POST{"amount".$y} * $_POST{"price".$y}).",0) WHERE shu.shohincd = sm.shohincd and ((sm.shohin_kubun3 = 0) or (sm.shohincd ='0' and totalgram = 0)) and shukkaid= '".$_POST{"id".$y}."'";
$result=mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
//業態料率計算 brand
/* for ($i = 0; $i < sizeof($codedata120); $i++) {
//不定貫
$strsql ="update cool_shukka as a ,
cool_shohinmaster as b ,
cool_shozokumaster as c
set price_piece2 = truncate(price_piece * ".$codedata120[$i][0].",0),
price_total2 = truncate(truncate(price_piece * ".$codedata120[$i][0].",0) * totalgram,0)
where a.shohincd = b.shohincd and shohin_kubun3 = 1 and a.shozokuid = c.shozokuid and a.operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and c.brand = ".$codedata120[$i][1]." and shukkaid= '".$_POST{"id".$y}."'";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//定貫
$strsql ="update cool_shukka as a ,
cool_shohinmaster as b ,
cool_shozokumaster as c
set price_piece2 = truncate(price_piece * ".$codedata120[$i][0].",0), price_total2 = truncate(truncate(price_piece * ".$codedata120[$i][0].",0) * shukkaqty,0)
where a.shohincd = b.shohincd and shohin_kubun3 = 0 and a.shozokuid = c.shozokuid and a.operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and c.brand = ".$codedata120[$i][1]." and shukkaid= '".$_POST{"id".$y}."'";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
*/
}
}
//出荷数ゼロは削除
$strsql = "DELETE FROM `".$company."shukka` WHERE shukkaqty = 0";
$result=mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
//アイテム追加
if($_POST["newitem"] <> "") {
$strsql = "INSERT INTO `".$company."shukka`
(`orderid`, `shozokuid`, `shohincd`, `centerid`,`picktimes`, `loccode`,`gyotaiid`, `stockdate`, `shomi`,`lotzan`, `waitingflg`, `orderqty`,`shukkaqty`, totalgram, `operatedate`, `shukkadate`, `deliverdate`, `creater`, `lotnum`,`price_piece`,`price_total`,memo,memo2) values(
0, '".$_POST["newshozokuid"]."', '".$_POST["newitem"]."', '".$_POST["center"]."',1, null,'".$_POST["gyotai"]."', null, null,null, 0,0, '".$_POST["amountnew"]."','".$_POST["gramnew"][0]."', DATE_ADD(CURDATE(),INTERVAL $operatedate DAY), DATE_ADD(CURDATE(),INTERVAL $operatedate DAY),DATE_ADD(CURDATE(),INTERVAL $operatedate DAY), '".$userdata["tid"]."', 0,'".$_POST["pricenew"]."',truncate(".($_POST["pricenew"] * $_POST["amountnew"]).",0) ,'', '".$_POST["option"]."')";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
$totalgram += $_POST{"gram".$y}[$pi];
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
$data = dbselect("max(shukkaid)","`".$company."shukka`","orderid = 0 and shozokuid ='".$_POST["newshozokuid"]."' and operatedate = DATE_ADD(CURDATE(),INTERVAL $orderdate DAY) ",-1,-1);
//価格更新・定かん
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shozokushohin` as ss SET cominprice_piece = nohinprice,price_piece = nohinprice,price_total = truncate(shukkaqty * nohinprice,0) WHERE shu.shohincd = ss.shohincd and shu.shozokuid = ss.shozokuid and shu.shukkaid = '".$data[0][0]."' and nohinprice > 0";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//紐付けにない場合はマスター価格から更新する
if (mysql_affected_rows() == 0) {
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as ss SET cominprice_piece = price_sell,price_piece = price_sell,price_total = truncate(shukkaqty * price_sell,0) WHERE shu.shohincd = ss.shohincd and shu.shukkaid = '".$data[0][0]."'";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
//不定貫
$totalgram = 0;
for ($pi = 0; $pi < 5; $pi++) {
if (($_POST{"gramnew"}[$pi] <> "") and (Numchecker6403($_POST{"gramnew"}[$pi]) == "CHR")) {
//0.数値欄に文字が入れられたら何も更新しない。
$errmsg .= "数値以外の入力値がありましたので、更新できない商品がありました。No.".($y + 1)." [".$_POST{"newitem".$y}."]
";$errcount++;
} elseif(Numchecker2($_POST{"gramnew"}[$pi]) > 0) {
$strsql = "INSERT INTO `".$company."shukkafuteikan`(shukkaid,gram,creater,createdate) VALUES('".$data[0][0]."','".$_POST{"gramnew"}[$pi]."','".$userdata["tid"]."',now())";$okcount++;
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
$totalgram += $_POST{"gramnew"}[$pi];
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
}
//出荷実績の不定貫合計重量TOTALGRAM更新、合計金額計算
if($totalgram > 0) {
$strsql = "UPDATE `".$company."shukka` SET totalgram = '".$totalgram."' ,price_total = truncate(".$totalgram." * price_piece,0) WHERE shukkaid= '".$data[0][0]."'";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
}
}
//全更新処理
if ($_POST[allsubmit] == "cancel") {
//フラグを処理解除へ
For ($y=0;$y< $_POST[row];$y++) {
$strsql = "UPDATE `".$company."shukka` set shukkaflg=1, updater='".$userdata["tid"]."' WHERE shukkaflg in(2,3) and shukkaid= '".$_POST{"id".$y}."' LIMIT 1";
$result=@mysql_query($strsql,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//注文メモ更新
$strsql = "UPDATE `".$company."ordermemo` SET kakutei = '0' WHERE shozokuid= '".$_POST{"shozoku".$y}."' and operatedate = DATE_ADD(CURDATE(),INTERVAL $orderdate DAY) LIMIT 1";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
}
//注文メモ更新 全部完了したらフラグを更新する
$strsql = "SELECT shozokuid,sum(case when shukkaflg>=2 then 1 else 0 end) as fixqty, count(shukkaid) as cnt FROM `".$company."shukka` as shu WHERE operatedate= DATE_ADD(CURDATE(),INTERVAL $orderdate DAY) and shukkaqty <>0 GROUP BY shozokuid ORDER BY shu.shozokuid";
$result=@mysql_query($strsql,$my_con);
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
while ($data = mysql_fetch_array($result)) {
$strsql = "INSERT INTO `".$company."ordermemo`(operatedate,centerid,kakutei,shozokuid) values (DATE_ADD(CURDATE(),INTERVAL $orderdate DAY),'c101',0,'".$data[shozokuid]."')";
$result2=mysql_query($strsql,$my_con);
// Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
$result2=mysql_query($strsql,$my_con);
if($data[cnt] == $data[fixqty]) {
//全て完了
$strsql = "UPDATE `".$company."ordermemo` SET kakutei = '1' WHERE shozokuid= '".$data[shozokuid]."' and operatedate = DATE_ADD(CURDATE(),INTERVAL $orderdate DAY)";
} else {
$strsql = "UPDATE `".$company."ordermemo` SET kakutei = '0' WHERE shozokuid= '".$data[shozokuid]."' and operatedate = DATE_ADD(CURDATE(),INTERVAL $orderdate DAY)";
}
$result2=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
// Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
if (($_POST[allsubmit] == "update") or ($_POST[allsubmit] == "kakutei")){
//出荷実績の定貫の合計金額計算
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET price_total = truncate(shukkaqty * price_piece,0) WHERE shohin_kubun3 = 0 and operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.shohincd = sm.shohincd";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//出荷実績の不定貫合計金額計算
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET price_total = truncate(totalgram * price_piece,0) WHERE shohin_kubun3 = 1
and operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.shohincd = sm.shohincd and shu.memo2 in (3,4) and shu.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//オプション加工
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET price_piece3 = 100, price_total3 = truncate(100 * totalgram,0) WHERE operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.shohincd = sm.shohincd and shu.memo2 in (3,4) and shu.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET price_piece3 = 200, price_total3 = truncate(200 * totalgram,0) WHERE operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.shohincd = sm.shohincd and shu.memo2 in (1,5) and shu.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
$strsql = "UPDATE `".$company."shukka` as shu,`".$company."shohinmaster` as sm SET price_piece3 = 150, price_total3 = truncate(150 * totalgram,0) WHERE operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.shohincd = sm.shohincd and shu.memo2 in (2) and shu.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//業態料率計算 brand 価格2
for ($i = 0; $i < sizeof($codedata120); $i++) {
//不定貫hohin_kubun3 = 1 //定貫shohin_kubun3 = 0
$strsql ="update cool_shukka as a ,
cool_shohinmaster as b ,
cool_shozokumaster as c
set price_piece2 = truncate(price_piece * ".$codedata120[$i][0].",0),
price_total2 = truncate(truncate(price_piece * ".$codedata120[$i][0].",0) * totalgram,0)
where a.shohincd = b.shohincd and shohin_kubun3 = 1 and a.shozokuid = c.shozokuid and a.operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and c.brand = ".$codedata120[$i][1]." and a.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//定貫
$strsql ="update cool_shukka as a ,
cool_shohinmaster as b ,
cool_shozokumaster as c
set price_piece2 = truncate(price_piece * ".$codedata120[$i][0].",0), price_total2 = truncate(truncate(price_piece * ".$codedata120[$i][0].",0) * shukkaqty,0)
where a.shohincd = b.shohincd and shohin_kubun3 = 0 and a.shozokuid = c.shozokuid and a.operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and c.brand = ".$codedata120[$i][1]." and a.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
//のりを不定貫hohin_kubun3 = 1 //定貫shohin_kubun3 = 0
$strsql ="update cool_shukka as shu ,
cool_shohinmaster as sm ,
cool_shozokushohin as ss
set shu.price_piece = nohinprice,
shu.price_total = truncate(nohinprice * totalgram,0) ,
price_piece2 = price_buy,
price_total2 = truncate(price_buy * totalgram,0)
where shu.shohincd = sm.shohincd and shohin_kubun3 = 1 and shu.shohincd = ss.shohincd and shu.shozokuid = ss.shozokuid and shu.operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.brand = 9 and shu.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//のりを定貫
$strsql ="update cool_shukka as shu ,
cool_shohinmaster as sm ,
cool_shozokushohin as ss
set shu.price_piece = nohinprice,
shu.price_total = truncate(nohinprice * shukkaqty,0) ,
price_piece2 = price_buy,
price_total2 = truncate(price_buy * shukkaqty,0)
where shu.shohincd = sm.shohincd and shohin_kubun3 = 0 and shu.shohincd = ss.shohincd and shu.shozokuid = ss.shozokuid and shu.operatedate = DATE_ADD(CURDATE(),INTERVAL $operatedate DAY) and shu.brand = 9 and shu.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//鮮魚の一幸はリクエスト商品は0ではなくて199001に更新する
$strsql ="update cool_shukka set memoadd = concat(memo3,ifnull(memoadd ,'')) ,shohincd='199001' where shohincd = '0' and brand>=30 and operatedate = curdate()";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//送料は同じ
$strsql ="update cool_shukka as a set price_piece2 = price_piece, price_total2 = price_total
where a.shohincd = 99999 and a.shukkaflg in (1,2)";
$result=mysql_query($strsql,$my_con);
$errcode =@mysql_errno();
Testecho ($y." ROW:".mysql_affected_rows()." ".$strsql."
"); #debug
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
}
//レコードの指定
if ($_POST[pagenum] == "") {
$page = 1;
} else {
$page = (int)$_POST[pagenum];
}
//表示順の指定
if ($_POST[order] == "") {
$order = 1;
} else {
$order = (int)$_POST[order];
}
//データ取得数
$limit = " LIMIT ".($pageset*($page - 1)).",$pageset";
//暫定処理
$strsql10 ="Update cool_shukka as shu ,cool_shozokumaster as sho SET shu.route = sho.route WHERE shu.shozokuid = sho.shozokuid and operatedate = curdate()";
$result=@mysql_query($strsql10,$my_con);
mysql_sql_log($strsql,mysql_affected_rows(),$_SERVER['SCRIPT_NAME'].":".__LINE__);
//検索用語
/*if ($shohincd <> "") {
$strsqlwhere .= " and shu.shohincd = '".$shohincd."'";
$strsqlorderby = "shu.route,shu.shozokuid,shu.shomi,shu.stockdate";
} else {
$strsqlorderby = "shu.shozokuid,shu.shohincd,shu.shomi,shu.stockdate";
}
*/
//センター
if ($_POST[center]<>""){
$centerid = $_POST[center];
} elseif ($_GET[center]<>""){
$centerid = $_GET[center];
} else {
$centerid = $centerdata[0][1];
}
$strsqlwhere .= " and shu.centerid = '".$centerid."'";
$strsqlwhere .= " and ((shu.shukkaqty <> 0 ) or (shu.shohincd = '0')) ";
//出荷データをメインに、外部接続でリストを取り出す
$strsql = "SELECT shukkaid,shukkaflg,shu.shohincd,sm.shohincd2,sm.shohincd3,shu.shozokuid,shu.shukkaqty,shu.centerid,shu.operatedate,shu.operatedate,makercode,shohinmei,sheet.orderqty,totalgram,shu.shomi,shu.stockdate,shu.lotnum,sm.shohin_kubun3,sm.kikaku,shu.cominprice_piece,shu.price_piece,shu.price_total,shu.price_piece2,shu.price_total2,shu.price_piece3,shu.price_total3,shu.memo2,shu.memo3,shu.memo,shu.memoadd ,shu.route FROM (
`".$company."shukka` AS shu INNER JOIN `".$company."shohinmaster` AS sm USING (shohincd)) LEFT JOIN `".$company."ordersheet` AS sheet on (shu.orderid=sheet.orderid) WHERE sm.ryutu_type = ".$ryutu_type." AND shu.operatedate=DATE_ADD(CURDATE(),INTERVAL $orderdate DAY) $strsqlwhere $strsqmaker $strsqlshozoku ORDER BY ".$strsqlorderby;
//全数
$result=@mysql_query($strsql,$my_con);
$maxrow=@mysql_num_rows($result);
$data=@mysql_fetch_array($result);
$updateflg = $data[shukkaflg]; //1:更新可 2:確定済み更新可 3:締め済み更新不可
//1ページ分
$strsql .= $limit;
$result=@mysql_query($strsql,$my_con);
$row=@mysql_num_rows($result);
?>
3) AND (($orderdate <-1) or ($updateflg > 2))) { //過去日or 締め済み訂正不可 ?>