table.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 |
<?php if(array_key_exists("v",$_GET)){ switch($_GET["v"]){ case "done": $stmt = $db->query("SELECT * FROM gaisaku WHERE kanryo_kubun = 1;"); $result = $stmt->fetchAll(); $stmt = $db->query("SELECT COUNT(*) FROM gaisaku WHERE kanryo_kubun = 1;"); $c = $stmt->fetchColumn(); break; case "hold": $stmt = $db->query("SELECT * FROM gaisaku WHERE kanryo_kubun = 2;"); $result = $stmt->fetchAll(); $stmt = $db->query("SELECT COUNT(*) FROM gaisaku WHERE kanryo_kubun = 2;"); $c = $stmt->fetchColumn(); break; case "none_draw": $stmt = $db->query("SELECT DISTINCT gaisaku.id, gaisaku.tokui_saki, gaisaku.katashiki, gaisaku.koban, gaisaku.suryo, gaisaku.seisaku_saki, gaisaku.kanryo_kubun, gaisaku.tanka, gaisaku.kingaku, gaisaku.saisyu_koushinbi, gaisaku.syukka_zuki, gaisaku_task.task FROM gaisaku LEFT JOIN gaisaku_task ON gaisaku.id = gaisaku_task.gaisaku_id AND gaisaku_task.task = '出図' WHERE (gaisaku_task.task != '出図' OR gaisaku_task.task IS NULL) AND kanryo_kubun IS NULL OR kanryo_kubun = 0"); $result = $stmt->fetchAll(); $stmt = $db->query("SELECT COUNT(DISTINCT gaisaku.ID) FROM gaisaku LEFT JOIN gaisaku_task ON gaisaku.id = gaisaku_task.gaisaku_id AND gaisaku_task.task = '出図' WHERE (gaisaku_task.task != '出図' OR gaisaku_task.task IS NULL) AND kanryo_kubun IS NULL OR kanryo_kubun = 0"); $c = $stmt->fetchColumn(); break; case "none_sup": $stmt = $db->query("SELECT * FROM gaisaku WHERE seisaku_saki = '' AND kanryo_kubun IS NULL OR kanryo_kubun = 0"); $result = $stmt->fetchAll(); $stmt = $db->query("SELECT COUNT(*) FROM gaisaku WHERE seisaku_saki = '' AND kanryo_kubun IS NULL OR kanryo_kubun = 0"); $c = $stmt->fetchColumn(); break; default: $stmt = $db->query("SELECT * FROM gaisaku WHERE kanryo_kubun IS NULL OR kanryo_kubun = 0"); $result = $stmt->fetchAll(); $stmt = $db->query("SELECT COUNT(*) FROM gaisaku WHERE kanryo_kubun IS NULL OR kanryo_kubun = 0"); $c = $stmt->fetchColumn(); } }else{ $stmt = $db->query("SELECT * FROM gaisaku WHERE kanryo_kubun IS NULL OR kanryo_kubun = 0"); $result = $stmt->fetchAll(); $stmt = $db->query("SELECT COUNT(*) FROM gaisaku WHERE kanryo_kubun IS NULL OR kanryo_kubun = 0"); $c = $stmt->fetchColumn(); } for($j = 0; $j < $c; $j++): ?> <table id="table_<?php echo $result[$j]["id"]; ?>" data-id="<?php echo $result[$j]["id"]; ?>"> <!-- tr 1 --> <tr> <th class="cap_1"> <p><?php echo $j + 1; ?></p> </th> <th class="cap_2"> <p>顧客</p> </th> <th class="cap_3"> <p>型式</p> </th> <th class="cap_4"> <p>工番</p> </th> <th class="cap_5"> <p>数量</p> </th> <th class="cap_6"> <p>製作先</p> </th> <th class="cap_7"> <p>単価</p> </th> <?php //タスク for($i=0; $i < $column; $i++){ echo '<th class="y_'; echo date("y",strtotime(" $start_day + $i day")); echo ' m_'; echo date("m",strtotime(" $start_day + $i day")); echo ' d_'; echo date("d",strtotime(" $start_day + $i day")); echo ' w_'; echo date("w",strtotime(" $start_day + $i day")); echo ' r_1'; echo '"'; echo 'data-date="'; echo date("Y-m-d",strtotime(" $start_day + $i day")); echo '">'; //日付見出 echo date("m/d",strtotime(" $start_day + $i day")); // echo '</th>'; } ?> </tr> <!-- tr 2 --> <tr> <td rowspan="3" class="val_1"> <p class="btn edit_btn">[編集]</p> </td> <td rowspan="3" class="val_2"> <p><?php echo $result[$j]["tokui_saki"]; ?></p> </td> <td rowspan="3" class="val_3"> <p><?php echo $result[$j]["katashiki"]; ?></p> </td> <td rowspan="3" class="val_4"> <p><?php echo $result[$j]["koban"]; ?></p> </td> <td rowspan="3" class="val_5"> <p><?php echo $result[$j]["suryo"]; ?></p> </td> <td rowspan="3" class="val_6"> <p><?php echo $result[$j]["seisaku_saki"]; ?></p> </td> <td rowspan="3" class="val_7"> <p><?php echo number_format($result[$j]["tanka"]); ?></p> <span><?php echo "(", number_format($result[$j]["tanka"] * $result[$j]["suryo"]), ")"; ?></span> </td> <?php //タスク for($i=0; $i < $column; $i++){ echo '<td class="y_'; echo date("y",strtotime(" $start_day + $i day")); echo ' m_'; echo date("m",strtotime(" $start_day + $i day")); echo ' d_'; echo date("d",strtotime(" $start_day + $i day")); echo ' w_'; echo date("w",strtotime(" $start_day + $i day")); echo ' r_2'; $date_id = $result[$j]["id"]; $date_value = date("Y-m-d",strtotime(" $start_day + $i day")); //タスクの範囲内かどうか判断 $stmt = $db->prepare("SELECT MAX(hizuke) FROM gaisaku_task WHERE gaisaku_id = ?"); $stmt->execute(array($date_id)); $date_max = $stmt->fetchAll(); $stmt = $db->prepare("SELECT MIN(hizuke) FROM gaisaku_task WHERE gaisaku_id = ?"); $stmt->execute(array($date_id)); $date_min = $stmt->fetchAll(); if($date_min[0][0] <= $date_value && $date_max[0][0] >= $date_value){ echo ' blk'; echo '"'; }else{ echo '"'; } echo 'data-date="'; echo date("Y-m-d",strtotime(" $start_day + $i day")); echo '"'; echo '></td>'; } ?> </tr> <!-- tr 3 --> <tr> <?php for($i=0; $i < $column; $i++){ echo '<td class="y_'; echo date("y",strtotime(" $start_day + $i day")); echo ' m_'; echo date("m",strtotime(" $start_day + $i day")); echo ' d_'; echo date("d",strtotime(" $start_day + $i day")); echo ' w_'; echo date("w",strtotime(" $start_day + $i day")); echo ' r_3'; echo '"'; echo 'data-date="'; echo date("Y-m-d",strtotime(" $start_day + $i day")); echo '">'; $date_id = $result[$j]["id"]; $date_value = date("Y-m-d",strtotime(" $start_day + $i day")); //タスク内容 $stmt = $db->prepare("SELECT task,kensa_komoku,hizuke FROM gaisaku_task WHERE gaisaku_id = ? AND hizuke = ?"); $stmt->execute(array($date_id,$date_value)); $date_result = $stmt->fetchAll(); foreach($date_result as $r){ echo $r["task"]; echo ($r["kensa_komoku"]) ? "(" . $r["kensa_komoku"] . ")" : ""; echo "<br>"; } echo '</td>'; } ?> </tr> <!-- tr 4 --> <tr> <?php for($i=0; $i < $column; $i++){ echo '<td class="y_'; echo date("y",strtotime(" $start_day + $i day")); echo ' m_'; echo date("m",strtotime(" $start_day + $i day")); echo ' d_'; echo date("d",strtotime(" $start_day + $i day")); echo ' w_'; echo date("w",strtotime(" $start_day + $i day")); echo ' r_4'; echo '"'; echo 'data-date="'; echo date("Y-m-d",strtotime(" $start_day + $i day")); echo '">'; // echo '<span class="btn tbl_btn">[ + ]</span>', '<span class="btn tbl_btn_remove">[ - ]</span>'; // echo '</td>'; } ?> </tr> </table> <?php endfor; ?> |
style.css
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 |
*{ font-family: "Meiryo"; font-size: 12px; } th.w_6{ color: blue; } th.w_0{ color: red; } th{ text-align: center; } .cap_1{ font-weight: bold; min-width: 40px; } .cap_2{ font-weight: bold; min-width: 150px; } .cap_3{ font-weight: bold; min-width: 200px; } .cap_4{ font-weight: bold; min-width: 100px; } .cap_5{ font-weight: bold; min-width: 40px; } .cap_6{ font-weight: bold; min-width: 150px; } .cap_7{ font-weight: bold; min-width: 100px; } .val_1{ text-align: center; } .val_2{ } .val_3{ } .val_4{ } .val_5{ text-align: right; } .val_6{ } .val_7{ text-align: right; } .r_1{ } .r_2{ height: 5px; } .r_3{ height: 30px; } .r_4{ text-align: center; } .r_4 > span{ font-size: 9px; } th, td { border: 1px solid #ccc; } table{ margin: 0 0 10px 0; } .frm { margin: 0 0 10px 0; } .frm > .btn, .frm > .down_btn { border: 1px solid #ccc; padding: 2px; } .btn{ color: blue; cursor: pointer; } .down_btn { color: #ccc; } body { padding:10px; } .blk { background-color: #1253A4; } .w_0, .w_1, .w_2, .w_3, .w_4, .w_5, .w_6 { min-width: 100px; } #save_div { display: none; margin: 0 0 10px 0; padding-bottom: 10px; border-bottom: 2px solid #1253A4; } #edit_div { background-color: white; display: none; width: 100%; padding: 10px 0 10px 10px; border-bottom: 2px solid #1253A4; top: 0px; left: 0px; position: fixed; z-index: 999; } input[type=text] { width: 10em; } #column_count { width: 3em; } |
save.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 |
<?php if( array_key_exists("do", $_POST) && array_key_exists("chk", $_POST) && array_key_exists("chk", $_SESSION) && $_POST["do"] == "save" && $_POST["chk"] == $_SESSION["chk"] ){ $stmt = $db->prepare("INSERT INTO gaisaku ( tokui_saki,katashiki,koban,suryo,seisaku_saki,tanka,kingaku,saisyu_koushinbi ) VALUES (?,?,?,?,?,?,0,now())"); $stmt->execute(array($_POST["kokyaku"],$_POST["katashiki"],$_POST["kouban"],$_POST["suryo"],$_POST["seisakusaki"],$_POST["tanka"])); $_SESSION["chk"] = uniqid(); header("Location: " . $_SERVER["SCRIPT_NAME"] . "?" . $_SERVER["QUERY_STRING"]); }else{ $_SESSION["chk"] = uniqid(); } ?> <div id="save_div"> <form method="POST"> <div class="frm"> 顧客:<input type="text" name="kokyaku" id="save_kokyaku"> 型式:<input type="text" name="katashiki" id="save_katashiki"> 工番:<input type="text" name="kouban" id="save_kouban"> 数量:<input type="text" name="suryo" id="save_suryo"> 製作先:<input type="text" name="seisakusaki" id="save_seisakusaki"> </div> 単価:<input type="text" name="tanka" id="save_tanka"> <input type="submit" value=" 登録 "> <input type="button" value=" 中止 " id="save_cancel_btn"> <input type="hidden" name="do" value="save"> <input type="hidden" name="chk" value="<?php echo $_SESSION["chk"]; ?>"> </form> </div> |
index.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 |
<?php exit(); session_start(); ini_set("display_errors",1); error_reporting(E_ALL); ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>外注工程管理表</title> <link rel="stylesheet" href="cssreset-min.css"> <link rel="stylesheet" href="style.css"> <script src="jquery-1.11.2.min.js"></script> </head> <body> <?php if(array_key_exists("s",$_GET) && $_GET["s"] != ""){ if(preg_match("/^[0-9]{8}$/", $_GET["s"])){ $start_day = substr($_GET["s"], 0, 4) . "-" . substr($_GET["s"], 4, 2) . "-" . substr($_GET["s"], 6, 2); }else{ $start_day = date("Y-m-d"); } }else{ $start_day = date("Y-m-d"); } if(array_key_exists("c",$_GET) && $_GET["c"] != ""){ if(preg_match("/^[0-9]+$/", $_GET["c"])){ $column = $_GET["c"]; }else{ $column = 14; } }else{ $column = 14; } include 'class.php'; $db = Db::con(); include 'edit.php'; include 'save.php'; ?> <div class="frm"> <input type="button" value=" 新規登録 " id="save_btn"> <span class="<?php if(!array_key_exists("v", $_GET)){ echo 'down_btn"'; }else{ echo 'btn" id="default_btn"'; } ?>> 通常 </span> <span class="<?php if(array_key_exists("v", $_GET) && $_GET["v"] == "none_draw"){ echo 'down_btn"'; }else{ echo 'btn" id="none_draw_btn"'; } ?>> 未出図依頼 </span> <span class="<?php if(array_key_exists("v", $_GET) && $_GET["v"] == "none_sup"){ echo 'down_btn"'; }else{ echo 'btn" id="none_sup_btn"'; } ?>> 製作先未決定 </span> <span class="<?php if(array_key_exists("v", $_GET) && $_GET["v"] == "done"){ echo 'down_btn"'; }else{ echo 'btn" id="done_btn"'; } ?>> 出荷済 </span> <span class="<?php if(array_key_exists("v", $_GET) && $_GET["v"] == "hold"){ echo 'down_btn"'; }else{ echo 'btn" id="hold_btn"'; } ?>> 保留 </span> </div> <div id="start" class="frm"> 列数:<input type="text" value="<?php echo $column ?>" id="column_count"> 日付: <!-- 年 --> <select id="start_y"> <option><?php echo date("Y",strtotime(" $start_day - 2 year")); ?></option> <option><?php echo date("Y",strtotime(" $start_day - 1 year")); ?></option> <option selected ><?php echo date("Y",strtotime(" $start_day + 0 year")); ?></option> <option><?php echo date("Y",strtotime(" $start_day + 1 year")); ?></option> <option><?php echo date("Y",strtotime(" $start_day + 2 year")); ?></option> </select> <!-- 月 --> <select id="start_m"> <?php for($i=1; $i <= 12; $i++){ if((int)date("m",strtotime("$start_day")) == $i){ if($i < 10){ $i = "0" . $i; } echo '<option selected>', $i, '</option>'; }else{ if($i < 10){ $i = "0" . $i; } echo '<option>', $i, '</option>'; } } ?> </select> <!-- 日 --> <select id="start_d"> <?php for($i=1; $i <= 31; $i++){ if((int)date("d",strtotime("$start_day")) == $i){ if($i < 10){ $i = "0" . $i; } echo '<option selected>', $i, '</option>'; }else{ if($i < 10){ $i = "0" . $i; } echo '<option>', $i, '</option>'; } } ?> </select> <input type="button" value=" 更新 " id="start_position"> <input type="button" value=" 本日 " id="today_position"> </div> <?php include 'table.php'; ?> <script> $(document).on("change","#task_select",function(){ if($("#task_select option:selected").text() == "検査"){ $("#task_select_val").removeAttr("disabled"); }else{ $("#task_select_val").attr("disabled", "disabled"); } }); $(document).on("click","#input_task_cancel_btn", function(){ $("#input_task_add").remove(); }); $(document).on("click","#input_task_add_btn", function(){ var task = $("#task_select option:selected").text(); var task_val = $("#task_select_val").val(); var id = $(this).prev().children("input[name=id]").val(); var ymd = $(this).prev().children("input[name=ymd]").val(); $.ajax({ type: "POST", url: "add_task.php", acync: false, data: { task: task, task_val: task_val, id: id, ymd: ymd }, dataType: 'html', success: function(data){ if (data === "false"){ alert("エラーが発生しました。処理は中断されました。"); return; } $("#input_task_add").remove(); window.location.reload(); },error: function(){ alert("エラーが発生しました。処理は中断されました。"); return; } }); }); //ダイアログを表示 $(document).on("click", ".tbl_btn", function(){ if(document.getElementById("input_task_add") != null){ return; } var id = $(this).parent().parent().parent().parent().data("id"); var ymd = $(this).parent().data("date"); var top = $(this).position().top; var left = $(this).position().left; var html = '<form class="frm">'+ 'タスク:<select id="task_select"><option>出図日</option><option>支給品手配</option><option>検査</option><option>納期</option></select> '+ '<input type="text" id="task_select_val" disabled="disabled">'+ '<input type="hidden" name="id" value="' + id + '">'+ '<input type="hidden" name="ymd" value="' + ymd + '">'+ '</form>'+ '<input type="button" value=" 登録 " id="input_task_add_btn"> <input type="button" value=" 中止 "id="input_task_cancel_btn">'; var e = $("<div>", { id: "input_task_add", html: html }); $("body").append(e); $("#input_task_add").css({ "background-color": "white", "position": "absolute", "z-index": "999", "border":"2px solid #1253A4", "padding": "10px", "width": "265px", "top": top, "left": left }); }); $(document).on("click", "#default_btn", function(){ var y = $("#start_y option:selected").text(); var m = $("#start_m option:selected").text(); var d = $("#start_d option:selected").text(); var start_day = y + m + d; var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?>" + "?s=" + start_day + "&c=" + count + ""; }); $(document).on("click", "#done_btn", function(){ var y = $("#start_y option:selected").text(); var m = $("#start_m option:selected").text(); var d = $("#start_d option:selected").text(); var start_day = y + m + d; var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?>" + "?v=done&s=" + start_day + "&c=" + count + ""; }); $(document).on("click", "#none_draw_btn", function(){ var y = $("#start_y option:selected").text(); var m = $("#start_m option:selected").text(); var d = $("#start_d option:selected").text(); var start_day = y + m + d; var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?>" + "?v=none_draw&s=" + start_day + "&c=" + count + ""; }); $(document).on("click", "#none_sup_btn", function(){ var y = $("#start_y option:selected").text(); var m = $("#start_m option:selected").text(); var d = $("#start_d option:selected").text(); var start_day = y + m + d; var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?>" + "?v=none_sup&s=" + start_day + "&c=" + count + ""; }); $(document).on("click", "#hold_btn", function(){ var y = $("#start_y option:selected").text(); var m = $("#start_m option:selected").text(); var d = $("#start_d option:selected").text(); var start_day = y + m + d; var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?>" + "?v=hold&s=" + start_day + "&c=" + count + ""; }); //更新 $(document).on("click", "#start_position", function(){ var y = $("#start_y option:selected").text(); var m = $("#start_m option:selected").text(); var d = $("#start_d option:selected").text(); var start_day = y + m + d; var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?><?php if(array_key_exists("v",$_GET) && $_GET["v"] != ""){ echo "?v=", $_GET["v"], "&"; }else{ echo "?"; } ?>s=" + start_day + "&c=" + count + ""; }); //本日 $(document).on("click", "#today_position", function(){ var count = $("#column_count").val(); window.location.href = "<?php echo $_SERVER['SCRIPT_NAME']; ?><?php if(array_key_exists("v",$_GET) && $_GET["v"] != ""){ echo "?v=", $_GET["v"], "&"; }else{ echo "?"; } ?>s=" + <?php echo date("Ymd"); ?> + "&c=" + count + ""; }); $(document).on("click","#save_btn",function(){ $("#edit_div").css("display","none"); $("#save_div").css("display","block"); }); //中止 $(document).on("click","#save_cancel_btn",function(){ $("#save_div").css("display","none"); }); $(document).on("click","#edit_cancel_btn",function(){ $("#edit_div").css("display","none"); }); $(document).on("click",".edit_btn",function(){ $("#save_div").css("display","none"); var id = $(this).parent().parent().parent().parent().data("id"); var kokyaku = $(this).parent().parent().find(".val_2").children("p").text(); var katashiki = $(this).parent().parent().find(".val_3").children("p").text(); var kouban = $(this).parent().parent().find(".val_4").children("p").text(); var suryo = $(this).parent().parent().find(".val_5").children("p").text(); var seisakusaki = $(this).parent().parent().find(".val_6").children("p").text(); var tanka = $(this).parent().parent().find(".val_7").children("p").text(); $("#edit_div").css("display","block"); //表示させているのはdata-idではなくループカウンタ $("#update_id").text($(this).parent().parent().parent().find(".cap_1").children("p").text()); $("#edit_id").val(id); $("#edit_kokyaku").val(kokyaku); $("#edit_katashiki").val(katashiki); $("#edit_kouban").val(kouban); $("#edit_suryo").val(suryo); $("#edit_seisakusaki").val(seisakusaki); $("#edit_tanka").val(tanka.replace(/,/g,"")); }); //更新・削除・出荷 $(document).on("click","#edit_update_btn, #edit_delete_btn, #edit_hide_btn, #edit_hide_cancel_btn, #edit_hold_btn, #edit_hold_cancel_btn",function(){ var condition = $(this).attr("id"); var id = $("#edit_id").val(); var kokyaku = $("#edit_kokyaku").val(); var katashiki = $("#edit_katashiki").val(); var kouban = $("#edit_kouban").val(); var suryo = $("#edit_suryo").val(); var seisakusaki = $("#edit_seisakusaki").val(); var tanka = $("#edit_tanka").val(); var y = $("#edit_year option:selected").text(); var m = $("#edit_month option:selected").text(); $.ajax({ type: "POST", url: "edit_condition.php", timeout: 3000, acync: false, data: { condition: condition, id: id, kokyaku: kokyaku, katashiki: katashiki, kouban: kouban, suryo: suryo, seisakusaki: seisakusaki, tanka: tanka, y: y, m: m }, dataType: "html", success: function(data){ if (data === "false"){ alert("エラーが発生しました。処理は中断されました。"); return; } alert(); $("#edit_div").css("display","none"); window.location.reload(); },error: function(){ alert("エラーが発生しました。処理は中断されました。"); return; } }); }); $(document).keydown(function(e){ if(e.keyCode === 27){ $("#edit_div").css("display","none"); $("#save_div").css("display","none"); $("#input_task_add").remove(); } }); </script> </body> </html> |
edit_condition.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 |
<?php if(!array_key_exists("condition",$_POST)) exit("false"); require_once("class.php"); $db = Db::con(); switch ($_POST["condition"]){ case "edit_hold_btn": $sql = "UPDATE gaisaku SET kanryo_kubun = 2 WHERE id = ?"; break; case "edit_hold_cancel_btn": $sql = "UPDATE gaisaku SET kanryo_kubun = NULL WHERE id= ?"; break; case "edit_update_btn": $sql = "UPDATE gaisaku SET tokui_saki = ?,katashiki = ?,koban = ?,suryo = ?,seisaku_saki = ?,tanka= ? WHERE id = ?"; break; case "edit_hide_btn": $sql = "UPDATE gaisaku SET kanryo_kubun = 1,syukka_zuki = ? WHERE id = ?"; break; case "edit_hide_cancel_btn": $sql = "UPDATE gaisaku SET kanryo_kubun = NULL, syukka_zuki = NULL WHERE id = ?"; break; case "edit_delete_btn": $sql = "DELETE FROM gaisaku WHERE id = ?"; break; } try{ $stmt = $db->prepare($sql); switch($_POST["condition"]){ case "edit_hold_btn": $stmt->execute(array($_POST["id"])); break; case "edit_hold_cancel_btn": $stmt->execute(array($_POST["id"])); break; case "edit_update_btn": $stmt->execute(array($_POST["id"],$_POST["kokyaku"],$_POST["katashiki"],$_POST["kouban"],$_POST["suryo"],$_POST["seisakusaki"],$_POST["tanka"])); break; case "edit_hide_btn": $stmt->execute(array($_POST["id"],$_POST["y"] . "-" . $_POST["m"] . "-01")); break; case "edit_hide_cancel_btn": $stmt->execute(array($_POST["id"])); break; case "edit_delete_btn": $stmt->execute(array($_POST["id"])); break; } } catch (PDOException $e) { echo "false"; } |
edit.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 |
<div id="edit_div"> <div class="frm"> 更新:[ <span id="update_id"></span> ] 顧客:<input type="text" name="kokyaku" id="edit_kokyaku"><input type="hidden" name="id" id="edit_id"> 型式:<input type="text" name="katashiki" id="edit_katashiki"> 工番:<input type="text" name="kouban" id="edit_kouban"> 数量:<input type="text" name="suryo" id="edit_suryo"> 製作先:<input type="text" name="seisakusaki" id="edit_seisakusaki"> </div> 単価:<input type="text" name="tanka" id="edit_tanka"> <input type="submit" value=" 更新 " id="edit_update_btn"> <input type="button" value=" 中止 " id="edit_cancel_btn"> <input type="button" value=" 削除 " id="edit_delete_btn"> <!--出荷--> <?php if(array_key_exists("v", $_GET) && $_GET["v"] == "done"): ?> <input type="button" value=" 出荷取消 " id="edit_hide_cancel_btn"> <?php else: ?> ( <select id="edit_year"> <option><?php echo date("Y",strtotime("- 1 year")); ?></option> <option selected ><?php echo date("Y"); ?></option> <option><?php echo date("Y",strtotime("+ 1 year")); ?></option> </select> <select id="edit_month"> <?php for($i=1; $i <= 12; $i++){ if((int)date("m",strtotime("$start_day")) == $i){ if($i < 10){ $i = "0" . $i; } echo '<option selected>', $i, '</option>'; }else{ if($i < 10){ $i = "0" . $i; } echo '<option>', $i, '</option>'; } } ?> </select> <input type="button" value=" 出荷 " id="edit_hide_btn"> ) <?php endif; ?> <!--保留--> <?php if(array_key_exists("v", $_GET) && $_GET["v"] == "hold"): ?> <input type="button" value=" 保留取消 " id="edit_hold_cancel_btn"> <?php else: ?> <input type="button" value=" 保留 " id="edit_hold_btn"> <?php endif; ?> </div> |
class.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 |
<?php class Db{ static public function con(){ try{ $db = new PDO("mysql:host=localhost;dbname=db;","id","pass"); $db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); return $db; //$d = new PDO('sqlite::memory:',null,null,array(PDO::ATTR_PERSISTENT=>true));//接続の永続化 } catch(PDOException $e) { exit("DB接続不具合"); } } } /* use okamura_post create table gaisaku ( id int not null auto_increment primary key, tokui_saki varchar(32), katashiki varchar(32), koban bigint, suryo int, seisaku_saki varchar(8), kanryo_kubun int, syukka_zuki date, tanka decimal(12), kingaku decimal(12), saisyu_koushinbi datetime ) default character set=utf8; create table gaisaku_task ( id int not null auto_increment primary key, gaisaku_id int, task varchar(32), kensa_komoku varchar(32), hizuke date ) default character set=utf8; */ |
add_task.php
1 2 3 4 5 6 7 8 9 |
<?php require_once("class.php"); $db = Db::con(); try{ $stmt = $db->prepare("INSERT INTO gaisaku_task (gaisaku_id,task,kensa_komoku,hizuke) VALUES (?,?,?,?)"); $stmt->execute(array($_POST["id"],$_POST["task"],$_POST["task_val"],$_POST["ymd"])); } catch (Exception $e) { echo "false"; } |