This page explanation:
You can edit the customer information.
This page function:
Edit
① Controller
Controller:/app/controller/customerController.php
<?php
class customer{
public function action_edit($targetId) {
//Retrieve one data from the database
$custmanageObj = ORM::for_table('customer')->where('id', $targetId)->find_one();
$last_name = $custmanageObj->last_name;
$first_name = $custmanageObj->first_name;
$furigana = $custmanageObj->furigana;
$birthday = $custmanageObj->birthday;
$gender = $custmanageObj->gender;
$blood = $custmanageObj->blood;
$note = $custmanageObj->note;
$targetId = $custmanageObj->id;
//include view
include_once(dirname(__FILE__) . "/../view/customer_edit.php");
}
}
?>
② View
<!--~~~-->
<form method='post' action='<?= SYSTEM_DIR ?>/customer/update/<?= $targetId; ?>' id="update-submit">
<button type="button" class="btn btn-success " id="update-btn">更新</button>
<button type="button" class="btn btn-danger" id="delete-btn" data-id = <?= $targetId;?>>削除</button>
<table>
<thead>
<tr>
<th>顧客氏名</th>
<th>ふりがな</th>
<th>生年月日</th>
<th>性別</th>
<th>血液型</th>
<th>備考</th>
</tr>
</thead>
<tbody>
<tr>
<td>
//↓Edit form. This input form is for writing edit data.
<input type="text" name="last_name" value="<?= $last_name;?>" required>
<input type="text" name="first_name" value="<?= $first_name;?>" required>
</td>
<td>
<input type="text" name="furigana" value="<?= $furigana; ?>" required>
</td>
<td>
<input type="date" name="birthday" value="<?= $birthday; ?>" required>
</td>
<td>
<select name="gender" required>
<option value="0" <?= $gender == 0 ? "selected" : "";?>>男</option>
<option value="1" <?= $gender == 1 ? "selected" : "";?>>女</option>
<option value="2" <?= $gender == 2 ? "selected" : "";?>>その他</option>
</select>
</td>
<td>
<select name="blood" required>
<option value="0" <?= $blood == 0 ? "selected" : "";?>>A</option>
<option value="1" <?= $blood == 1 ? "selected" : "";?>>B</option>
<option value="2" <?= $blood == 2 ? "selected" : "";?>>O</option>
<option value="3" <?= $blood == 3 ? "selected" : "";?>>AB</option>
</select>
</td>
<td>
<textarea name="note" id="" cols="30" rows="1" style="height:20px;" value="<?= $note; ?>"></textarea>
</td>
</tr>
</tbody>
</table>
</form>
<!--~~~-->
