以前作っていた在庫管理。お蔵入り版。
1つのファイルにHTML,CSS,JS,PHPを全て書き込んでいた。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
<!DOCTYPE html> <html lang="ja"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <meta charset="UTF-8"> <title>受注参照</title> <style> body{ font-family: Meiryo, sans-serif; font-size: 12px; } #view_tb{ border-collapse: collapse; font-size: 12px; } #view_tb td, #view_tb th{ border: 1px dotted #ccc; white-space: nowrap; padding: 1px; } #view_tb tr:hover{ background-color: #eef; } #frm{ margin-bottom: 10px; background-color: #eef; } #bk{ display: none; } #sav_tb td{ text-align: right; } .yen{ text-align: right; } .lnk{ cursor: pointer; color: blue; } </style> </head> <body> <a href="?view=受注一覧&offset=0" id="bk">戻る</a> <div id="header"> <?php require_once('config.php'); require_once('functions.php'); // 登録 // if( $_GET['save'] == "登録"){ $n = date("Y-m-d"); echo <<< HTML <form method="POST"> <table id="sav_tb"> <tr><td>区分:</td><td><input type="text" value="新規" disabled></td></tr> <tr><td>型式:</td><td><input type="text"></td></tr> <tr><td>工番(数値):</td><td><input type="text" value=0></td></tr> <tr><td>数量(数値):</td><td><input type="text" value=0></td></tr> <tr><td>納期:</td><td><input type="text" value="$n"></td></tr> <tr><td>得意先:</td><td><input type="text"></td></tr> <tr><td>単価(数値):</td><td><input type="text" value="0"></td></tr> <tr><td>金額(数値):</td><td><input type="text" value="0" disabled></td></tr> <tr><td>本社備考1:</td><td><input type="text"></td></tr> <tr><td>本社備考2:</td><td><input type="text"></td></tr> <tr><td>納期確定:</td><td><input type="text"></td></tr> <tr><td>更新日:</td><td><input type="text" value="$n" disabled></td></tr> <tr><td>作成日:</td><td><input type="text" value="$n" disabled></td></tr> <tr> <td></td> <td><span class="lnk" id="sv">[登録]</span> <span class="lnk" id="abt">[中止]</span></td> </tr> </table> </div><!-- header --> </form> <script> $(function(){ // 登録 // $(document).on('click', '#sv', function(){ var kubun = $("#sav_tb tr:nth-child(1) input").val(); var katashiki = $("#sav_tb tr:nth-child(2) input").val(); var kouban = parseInt($("#sav_tb tr:nth-child(3) input").val()); var suryo = parseInt($("#sav_tb tr:nth-child(4) input").val()); var nouki = $("#sav_tb tr:nth-child(5) input").val(); var tokuisaki = $("#sav_tb tr:nth-child(6) input").val(); var tanka = parseInt($("#sav_tb tr:nth-child(7) input").val()); var kingaku = parseInt($("#sav_tb tr:nth-child(8) input").val()); var honsyabikou1 = $("#sav_tb tr:nth-child(9) input").val(); var honsyabikou2 = $("#sav_tb tr:nth-child(10) input").val(); var noukikakutei = $("#sav_tb tr:nth-child(11) input").val(); var koushinbi = $("#sav_tb tr:nth-child(12) input").val(); var sakuseibi = $("#sav_tb tr:nth-child(13) input").val(); // nouki // if (nouki != ""){ nouki = nouki.replace(/\//g,"-"); var d = new Date(nouki); var mth = d.getMonth() + 1; if( 1 <= mth && 12 >= mth && 10 > mth ){ mth = '0' + mth; }else if( 1 <= mth && 12 >= mth ){ mth = mth; }else{ alert("納期を確認してください(YYYY-MM-DD)"); return; } var day = d.getDate(); if( 1 <= day && 31 >= day && 10 > day ){ day = '0' + day; }else if( 1 <= day && 31 >= day ){ day = day; }else{ alert("納期を確認してください(YYYY-MM-DD)"); return; } nouki = d.getFullYear() + "-" + mth + "-" + day; $("#sav_tb tr:nth-child(5) input").val(nouki); } // suryo tanka // if((!isNaN(suryo)) && (!isNaN(tanka))){ kingaku = suryo * tanka; $("#sav_tb tr:nth-child(8) input").val(kingaku); }else{ alert("数量と単価を確認してください"); return; } // kouban // if(isNaN(kouban)){ alert("工番を確認してください"); return; } if(confirm('登録しますか?')){ $.post('_save.php',{ kubun: kubun, katashiki: katashiki, kouban: kouban, suryo: suryo, nouki: nouki, tokuisaki: tokuisaki, tanka: tanka, kingaku: kingaku, honsyabikou1: honsyabikou1, honsyabikou2: honsyabikou2, noukikakutei: noukikakutei, koushinbi: koushinbi, sakuseibi: sakuseibi },function(){ location.href="?view=受注一覧&offset=0"; }); } }); // 中止 // $(document).on('click', '#abt', function(){ location.href="?view=受注一覧&offset=0"; }); }); </script> </body> </html> HTML; exit; } // 受注一覧 在庫一覧 // if( $_GET['view'] == "在庫一覧" ){ echo $_GET['view']; $sql = "select * from order_tb where (入庫 is not null) and (出庫 is null)"; $cntsql = "select count(*) from order_tb where (入庫 is not null) and (出庫 is null)"; if (array_key_exists('型',$_GET)){ $sql = $sql . " and (型式 like '%" . $_GET['型'] . "%')"; $cntsql = $cntsql . " and (型式 like '%" . $_GET['型'] . "%')"; } if (array_key_exists('工',$_GET)){ $sql = $sql . " and (工番 like '%" . $_GET['工'] . "%')"; $cntsql = $cntsql . " and (工番 like '%" . $_GET['工'] . "%')"; } if (array_key_exists('納',$_GET) && $_GET['納'] != ""){ $sql = $sql . " and (納期 like '%" . date("Y-m-d", strtotime($_GET['納'])) . "%')"; $cntsql = $cntsql . " and (納期 like '%" . date("Y-m-d", strtotime($_GET['納'])) . "%')"; } if (array_key_exists('得',$_GET)){ $sql = $sql . " and (得意先 like '%" . $_GET['得'] . "%')"; $cntsql = $cntsql . " and (得意先 like '%" . $_GET['得'] . "%')"; } if (array_key_exists('本',$_GET)){ $sql = $sql . " and ((本社備考1 like '%" . $_GET['本'] . "%')"; $sql = $sql . " or (本社備考2 like '%" . $_GET['本'] . "%'))"; $cntsql = $cntsql . " and ((本社備考1 like '%" . $_GET['本'] . "%')"; $cntsql = $cntsql . " or (本社備考2 like '%" . $_GET['本'] . "%'))"; } if (array_key_exists('更',$_GET) && $_GET['更'] != ""){ $sql = $sql . " and (更新日 like '%" . date("Y-m-d", strtotime($_GET['更'])) . "%')"; $cntsql = $cntsql . " and (更新日 like '%" . date("Y-m-d", strtotime($_GET['更'])) . "%')"; } if (array_key_exists('作',$_GET) && $_GET['作'] != ""){ $sql = $sql . " and (作成日 like '%" . date("Y-m-d", strtotime($_GET['作'])) . "%')"; $cntsql = $cntsql . " and (作成日 like '%" . date("Y-m-d", strtotime($_GET['作'])) . "%')"; } $sql = $sql . " limit " . $_GET['offset'] . ",100;"; $cntsql = $cntsql . ";"; }elseif( $_GET['view'] == "受注一覧" ){ echo $_GET['view']; $sql = "select * from order_tb where (id is not null)"; $cntsql = "select count(*) from order_tb where (id is not null)"; if (array_key_exists('型',$_GET)){ $sql = $sql . " and (型式 like '%" . $_GET['型'] . "%')"; $cntsql = $cntsql . " and (型式 like '%" . $_GET['型'] . "%')"; } if (array_key_exists('工',$_GET)){ $sql = $sql . " and (工番 like '%" . $_GET['工'] . "%')"; $cntsql = $cntsql . " and (工番 like '%" . $_GET['工'] . "%')"; } if (array_key_exists('納',$_GET) && $_GET['納'] != ""){ $sql = $sql . " and (納期 like '%" . date("Y-m-d", strtotime($_GET['納'])) . "%')"; $cntsql = $cntsql . " and (納期 like '%" . date("Y-m-d", strtotime($_GET['納'])) . "%')"; } if (array_key_exists('得',$_GET)){ $sql = $sql . " and (得意先 like '%" . $_GET['得'] . "%')"; $cntsql = $cntsql . " and (得意先 like '%" . $_GET['得'] . "%')"; } if (array_key_exists('本',$_GET)){ $sql = $sql . " and ((本社備考1 like '%" . $_GET['本'] . "%')"; $sql = $sql . " or (本社備考2 like '%" . $_GET['本'] . "%'))"; $cntsql = $cntsql . " and ((本社備考1 like '%" . $_GET['本'] . "%')"; $cntsql = $cntsql . " or (本社備考2 like '%" . $_GET['本'] . "%'))"; } if (array_key_exists('更',$_GET) && $_GET['更'] != ""){ $sql = $sql . " and (更新日 like '%" . date("Y-m-d", strtotime($_GET['更'])) . "%')"; $cntsql = $cntsql . " and (更新日 like '%" . date("Y-m-d", strtotime($_GET['更'])) . "%')"; } if (array_key_exists('作',$_GET) && $_GET['作'] != ""){ $sql = $sql . " and (作成日 like '%" . date("Y-m-d", strtotime($_GET['作'])) . "%')"; $cntsql = $cntsql . " and (作成日 like '%" . date("Y-m-d", strtotime($_GET['作'])) . "%')"; } $sql = $sql . " limit " . $_GET['offset'] . ",100;"; $cntsql = $cntsql . ";"; }else{ echo <<< HTML <a href="?view=受注一覧&offset=0">受注一覧(入出庫管理)</a> </div><!--header--> </body> </html> HTML; exit; } $db = con(); $rows = array(); $s = $db->query($cntsql); if (array_key_exists('型',$_GET)){ echo "(検索結果)"; } $cnt = $s->fetchColumn(); echo " " .$cnt . "件取得しました"; foreach($db->query($sql) as $row){ array_push($rows, $row); } ?> <form method="GET" id="frm"> <input type="submit" value="受注一覧" name="view"> <input type="submit" value="在庫一覧" name="view"> <input type="hidden" value="0" name="offset"> <?php if($_GET['offset'] > 0 && array_key_exists('型', $_GET)): ?> <a href="?view=<?php echo $_GET['view']; ?>&offset=<?php echo $_GET['offset'] - 100; ?> &型=<?php echo $_GET['型']; ?> &工=<?php echo $_GET['工']; ?> &納=<?php echo $_GET['納']; ?> &得=<?php echo $_GET['得']; ?> &本=<?php echo $_GET['本']; ?> &更=<?php echo $_GET['更']; ?> &作=<?php echo $_GET['作']; ?> ">前へ</a> <?php elseif($_GET['offset'] > 0): ?> <a href="?view=<?php echo $_GET['view']; ?>&offset=<?php echo $_GET['offset'] - 100; ?>">前へ</a> <?php else: ?> 前へ <?php endif; ?> <?php if($_GET['offset'] + 100 < $cnt && array_key_exists('型', $_GET)): ?> <a href="?view=<?php echo $_GET['view']; ?>&offset=<?php echo $_GET['offset'] + 100; ?> &型=<?php echo $_GET['型']; ?> &工=<?php echo $_GET['工']; ?> &納=<?php echo $_GET['納']; ?> &得=<?php echo $_GET['得']; ?> &本=<?php echo $_GET['本']; ?> &更=<?php echo $_GET['更']; ?> &作=<?php echo $_GET['作']; ?> ">次へ</a> <?php elseif($_GET['offset'] + 100 < $cnt): ?> <a href="?view=<?php echo $_GET['view']; ?>&offset=<?php echo $_GET['offset'] + 100; ?>">次へ</a> <?php else: ?> 次へ <?php endif; ?> <?php if($_GET['offset'] < (($cnt-1) - (($cnt-1) % 100)) && array_key_exists('型', $_GET)): ?> <a href="?view=<?php echo $_GET['view']; ?>&offset=<?php echo ($cnt-1) - (($cnt-1) % 100); ?> &型=<?php echo $_GET['型']; ?> &工=<?php echo $_GET['工']; ?> &納=<?php echo $_GET['納']; ?> &得=<?php echo $_GET['得']; ?> &本=<?php echo $_GET['本']; ?> &更=<?php echo $_GET['更']; ?> &作=<?php echo $_GET['作']; ?> ">最後へ</a> <?php elseif($_GET['offset'] < (($cnt-1) - (($cnt-1) % 100))): ?> <a href="?view=<?php echo $_GET['view']; ?>&offset=<?php echo ($cnt-1) - (($cnt-1) % 100); ?>">最後へ</a> <?php else: ?> 最後へ <?php endif; ?> (<?php echo $_GET['offset'] + 1; ?>から<?php echo $_GET['offset'] + 100; ?>まで) </form> <form method="GET" id="frm"> <input type="submit" value="登録" name="save"> <input type="button" id="csv" value="書出"> </form> <form method="GET" id="frm"> 型:<input type="text" value="<?php echo $_GET['型']; ?>" size="8" name="型"> 工:<input type="text" value="<?php echo $_GET['工']; ?>" size="8" name="工"> 納:<input type="text" value="<?php echo $_GET['納']; ?>" size="8" name="納" id="n"> 得:<input type="text" value="<?php echo $_GET['得']; ?>" size="8" name="得"> 本:<input type="text" value="<?php echo $_GET['本']; ?>" size="8" name="本"> 更:<input type="text" value="<?php echo $_GET['更']; ?>" size="8" name="更"> 作:<input type="text" value="<?php echo $_GET['作']; ?>" size="8" name="作"> <input type="hidden" value="<?php echo $_GET['view']; ?>" name="view"> <input type="hidden" value="0" name="offset"> <input type="submit" value="取得">: </form> </div><!-- header --> <div id="view"> <table id="view_tb"> <tr> <th>区分</th> <th>型式</th> <th>工番</th> <th>数量</th> <th>納期</th> <th>得意先</th> <th>単価</th> <th>金額</th> <th>本社備考1</th> <th>本社備考2</th> <th>納期確定</th> <th>更新日</th> <th>作成日</th> <th>入庫</th> <th>出庫</th> <th>入庫</th> <th>出庫</th> <th>入消</th> <th>出消</th> <th></th> <th>分割</th> <th>回数</th> <th>削除</th> </tr> <?php for($i = 0, $total = 0; $i < count($rows); $i++ ): ?> <tr id="r_<?php echo $rows[$i][0]; ?>" data-id="<?php echo $rows[$i][0]; ?>"> <td><?php echo $rows[$i][2]; ?></td> <td><?php echo $rows[$i][4]; ?></td> <td><?php echo $rows[$i][5]; ?></td> <td><?php echo $rows[$i][9]; ?></td> <td><?php echo $rows[$i][10]; ?></td> <td><?php echo $rows[$i][15]; ?></td> <td class="lnk yen" id="plice"><?php echo $rows[$i][16]; ?></td> <td class="yen"><?php echo $rows[$i][17]; ?></td> <td><?php echo $rows[$i][18]; ?></td> <td><?php echo $rows[$i][19]; ?></td> <td><?php echo $rows[$i][20]; ?></td> <td><?php echo $rows[$i][22]; ?></td> <td><?php echo $rows[$i][23]; ?></td> <td><?php echo $rows[$i][24]; ?></td> <td><?php echo $rows[$i][25]; ?></td> <td class="lnk" id="rcv">[入庫]</td> <td class="lnk" id="shp">[出庫]</td> <td class="lnk" id="d_rcv">[入消]</td> <td class="lnk" id="d_shp">[出消]</td> <td><input id="inp" type="text" size="1"></td> <td class="lnk" id="sp">[分割]</td> <td><?php echo $rows[$i][26]; ?></td> <td class="lnk" id="del">[削除]</td> </tr> <?php $total = $total + $rows[$i][17]; ?> <?php endfor; ?> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td class="yen"><?php echo number_format($total); ?></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> </div><!--view--> <script> $(function(){ // 削除 // $(document).on('click', '#del', function(){ if(confirm('削除しますか?')){ var id = $(this).parent().data('id'); $.post('_delete.php',{id: id},function(){ $('#r_' + id).fadeOut(300); location.reload(); }); } }); // 入庫 // $(document).on('click', '#rcv', function(){ if(confirm('入庫しますか?')){ var id = $(this).parent().data('id'); $.post('_rcv.php',{id: id},function(rs){ $('#r_' + id + " > td:nth-child(14)").text(rs); }); } }); // 出庫 // $(document).on('click', '#shp', function(){ if(confirm('出庫しますか?')){ var id = $(this).parent().data('id'); $.post('_shp.php',{id: id},function(rs){ $('#r_' + id + " > td:nth-child(15)").text(rs); }); } }); // 入消 // $(document).on('click', '#d_rcv', function(){ if(confirm('入庫を取消しますか?')){ var id = $(this).parent().data('id'); $.post('_d_rcv.php',{id: id},function(){ $('#r_' + id + " > td:nth-child(14)").text(""); }); } }); // 出消 // $(document).on('click', '#d_shp', function(){ if(confirm('出庫を取消しますか?')){ var id = $(this).parent().data('id'); $.post('_d_shp.php',{id: id},function(){ $('#r_' + id + " > td:nth-child(15)").text(""); }); } }); // 分割 // $(document).on('click', '#sp', function(){ var id = $(this).parent().data('id'); var num = parseInt($('#r_' + id + " > td:nth-child(4)").text()); var plice = parseInt($('#r_' + id + " > td:nth-child(7)").text()); var p_num = parseInt($('#r_' + id + ' input').val()); if(!isNaN(p_num) && num > p_num && p_num > 0){ if(confirm('受注数 ' + num + ' から ' + p_num + ' を別の行に複製します')){ num = num - p_num; $.post('_pull_num.php',{id: id, num: num, p_num: p_num, plice: plice},function(){ $('#r_' + id).fadeOut(300,function(){ location.reload(); }); }); } } }); // 単価 // $(document).on('click', '#plice',function(){ var id = $(this).parent().data('id'); var num = parseInt($('#r_' + id + " > td:nth-child(4)").text()); var plice = parseInt(prompt("単価を入力してください")); if(!isNaN(plice) && !isNaN(plice * num)){ $.post('_plice.php',{id: id, num: num, plice: plice},function(){ $('#r_' + id + " > td:nth-child(7)").text(plice); $('#r_' + id + " > td:nth-child(8)").text(plice * num); location.reload(); }); } }); // 書出 // var flg = true; $(document).on('click', '#csv',function(){ if(flg){ flg = false; $("#view_tb th:nth-child(n+16):nth-child(-n+21), td:nth-child(n+16):nth-child(-n+21)").remove(); $("#view_tb th:nth-last-child(1), td:nth-last-child(1)").remove(); $("#header").css("display","none"); $("#bk").css("display","inline"); } }); }); </script> </body> </html> |