43 lines
2.1 KiB
PHP
43 lines
2.1 KiB
PHP
<script>
|
|
function addDevice(category, key, label) {
|
|
var categoryBox = document.getElementById(category + "Box");
|
|
var div = document.createElement("div");
|
|
var checkbox = document.createElement("input");
|
|
checkbox.setAttribute("type", "checkbox");
|
|
checkbox.setAttribute("name", category + '[]');
|
|
checkbox.setAttribute("value", key);
|
|
checkbox.setAttribute("checked", true);
|
|
checkbox.setAttribute("class", 'device');
|
|
div.appendChild(checkbox);
|
|
div.appendChild(document.createTextNode(label));
|
|
// console.log(div);
|
|
categoryBox.appendChild(div);
|
|
}
|
|
</script>
|
|
<table class="table table-bordered" style="width: auto;">
|
|
<tr>
|
|
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
|
<th style="background-color:silver; text-align:center;"><?= lang('Device.CATEGORY.' . $category) . " 선택" ?></th>
|
|
<?php endforeach ?>
|
|
</tr>
|
|
<tr>
|
|
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
|
<td id="<?= $category ?>Box">
|
|
<?php foreach ($cellDatas['selecteds'][$category] as $key => $productDevieceEntity) : ?>
|
|
<div><input type="checkbox" id="<?= $key ?>" name="<?= $category ?>[]" value="<?= $productDevieceEntity->device_uid ?>" checked class="device"><?= $cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getTitle() ?></div>
|
|
<?php endforeach ?>
|
|
</td>
|
|
<?php endforeach ?>
|
|
</tr>
|
|
<tr>
|
|
<?php foreach ($cellDatas['categorys'] as $category) : ?>
|
|
<td>
|
|
<?php foreach ($cellDatas['device']['options'][$category] as $key => $label) : ?>
|
|
<button type="button" class="device btn btn-light" data-bs-toggle="tooltip" data-bs-placement="bottom" title="<?= number_format($cellDatas['deviceEntitys'][$key]->getPrice()) ?>원" onClick="addDevice('<?= $category ?>','<?= $key ?>','<?= $label ?>')">
|
|
<?= $label ?>
|
|
</button>
|
|
<?php endforeach ?>
|
|
</td>
|
|
<?php endforeach ?>
|
|
</tr>
|
|
</table>
|