CakeProducts/templates/ProductSkus/add.php

79 lines
3.6 KiB
PHP

<?php
use function BenTools\CartesianProduct\combinations;
/**
* @var \App\View\AppView $this
* @var \App\Model\Entity\ProductSku $productSku
* @var \Cake\Collection\CollectionInterface|string[] $products
* @var array $optionMapping
* @var array $variantNameMapping
* @var array $toGetCartesianProductsFrom
*/
?>
<div class="row">
<aside class="column">
<div class="side-nav">
<h4 class="heading"><?= __('Actions') ?></h4>
<?= $this->Html->link(__('List Product SKUs'), ['action' => 'index'], ['class' => 'side-nav-item']) ?>
</div>
</aside>
<div class="column column-80">
<div class="productSkus form content">
<?= $this->Form->create($productSkus) ?>
<fieldset>
<legend><?= __('Add Product Skus') ?></legend>
<div id="product-skus-container" class="container">
<table class="table">
<thead>
<tr>
<th>Add?</th>
<th>SKU</th>
<th>Barcode</th>
<th>Price</th>
<th>Cost</th>
<?php
$cnt = 0;
foreach ($variantNameMapping as $singleVariantName) : ?>
<th><?= $singleVariantName; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php
$cnt = 0;
$labelFalse = ['label' => false];
foreach (combinations($toGetCartesianProductsFrom) as $c => $combination) : ?>
<tr>
<td><?= $this->Form->control($cnt . '.add', ['label' => false, 'type' => 'checkbox', 'checked' => true]); ?></td>
<td><?= $this->Form->control($cnt . '.sku', $labelFalse); ?></td>
<td><?= $this->Form->control($cnt . '.barcode', $labelFalse); ?></td>
<td><?= $this->Form->control($cnt . '.price', $labelFalse); ?></td>
<td><?= $this->Form->control($cnt . '.cost', $labelFalse); ?></td>
<?php
$variantCnt = 0;
foreach ($variantNameMapping as $singleVariantId => $singleVariantName) : ?>
<td>
<?= $this->Form->hidden($cnt . '.product_sku_variant_values.' . $variantCnt . '.product_category_variant_id', ['value' => $singleVariantId ?? null]); ?>
<?= $this->Form->hidden($cnt . '.product_sku_variant_values.' . $variantCnt . '.product_category_variant_option_id', ['value' => $combination[$singleVariantId] ?? null]); ?>
<?= $optionMapping[$combination[$singleVariantId]]; ?>
</td>
<?php
$variantCnt++;
endforeach; ?>
</tr>
<?php
$cnt++;
endforeach; ?>
</tbody>
</table>
</div>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
</div>
</div>
</div>