Warning: Attempt to read property "id" on null in /srv/admin/php/page.product.php on line 40
Warning: Attempt to read property "title" on null in /srv/admin/php/page.product.php on line 40
Warning: Attempt to read property "sku" on null in /srv/admin/php/page.product.php on line 40
Warning: Attempt to read property "stock" on null in /srv/admin/php/page.product.php on line 40
Warning: Attempt to read property "id" on null in /srv/admin/php/page.product.php on line 41
Warning: Attempt to read property "line" on null in /srv/admin/php/page.product.php on line 41
Warning: Undefined array key "" in /srv/admin/php/page.product.php on line 41
Warning: Attempt to read property "line" on null in /srv/admin/php/page.product.php on line 41
Warning: Attempt to read property "variants" on null in /srv/admin/php/page.product.php on line 41
Error
GET /product/opslaan
current(): Argument #1 ($array) must be of type array, null given
current() page.product.php:41
page_product->view() pages.php:40
pages->route() app.php:24
app->controller() functions.php:116
phlo() phlo.php:23
phlo_app() phlo.php:8
phlo_app_jsonfile() app.php:5
- <?php
- // source: /srv/admin/page.product.phlo
- // phlo: 1.0
- class page_product extends obj {
- public $title = 'Product';
- public $type = 'record';
- public $obj = 'product';
- public function _lines(){
- return line::pair(columns: 'id,CONCAT(supplier, " ", title)');
- }
- public $filters = [
- '1' => ['title' => 'Toon retour% afgelopen maand', 'filter' => 'returnsPeriod="1month"'],
- '2' => ['title' => 'Toon retour% afgelopen 2 maanden', 'filter' => 'returnsPeriod="2month"'],
- '3' => ['title' => 'Toon retour% afgelopen 3 maanden', 'filter' => 'returnsPeriod="3month"'],
- '6' => ['title' => 'Toon retour% afgelopen 6 maanden', 'filter' => 'returnsPeriod="6month"'],
- '9' => ['title' => 'Toon retour% afgelopen 9 maanden', 'filter' => 'returnsPeriod="9month"'],
- '12' => ['title' => 'Toon retour% afgelopen 12 maanden', 'filter' => 'returnsPeriod="12month"'],
- ];
- public $actions = [
- '+ Maak nieuw product',
- '- Verwijder product',
- ];
- public function _buttons():string {
- return "<a class=\"async\" href=\"/product/opslaan\">Producttekst Opslaan</a>";
- }
- public function view($title, $product, $uri):string {
- $phloView = "<main class=\"admin-container\">\n".
- "\t<div class=\"admin-header\">\n".
- "\t\t<div class=\"header-content listing-table\">\n".
- "\t\t\t<h1>Product:<br><a class=\"async\" href=\"/product/$product->id\">$product->title</a> | <b>SKU:</b> <input name=\"sku\" type=\"text\" value=\"$product->sku\"> | <b>Voorraad:</b> $product->stock</h1>\n".
- "\t\t\t<h2><b>ID:</b> $product->id | <b>Lijn:</b> ".$this->lines[$product->line]." (line ID:".$product->line.") | <b>Inkoop:</b> € <input type=\"text\" name=\"priceCost\" size=\"2\" value=\"".(round(current($product->variants)->priceCost, 2) ?: void)."\">\n".
- "\t\t</div>\n".
- "\t</div>\n".
- "\t<table class=\"listing-table listing-products\">\n".
- "\t\t<tr data-id=\"$product->id\">\n".
- "\t\t\t<td class=\"center\" colspan=\"2\"><a class=\"async\" href=\"/product/$product->id\"><img src=\"".$product->image->src."\" alt=\"\"></a></td>\n".
- "\t\t\t<td class=\"channels\">\n".
- "\t\t\t\t<table class=\"channel\">\n".
- "\t\t\t\t\t<tr>\n".
- "\t\t\t\t\t\t<th>SKU</th>\n".
- "\t\t\t\t\t\t<th>Maat</th>\n".
- "\t\t\t\t\t\t<th>Min/Max lengte</th>\n";
- foreach (channels AS $channel){
- $phloView .= "\t\t\t\t\t\t<th>$channel<br>€ Van | € Voor</th>\n";
- }
- $phloView .= "\t\t\t\t\t\t<th>Stock</th>\n".
- "\t\t\t\t\t\t<th id=\"select_1_2_3_6_12_months\">Retour%<br>(avg: #averageReturn%)</th>\n".
- "\t\t\t\t\t</tr>\n";
- foreach (sortVariants($product->variants) AS $variant){
- $phloView .= "\t\t\t\t\t<tr>\n".
- "\t\t\t\t\t\t<td>".input(type: 'text', value: $variant->sku, size: 20)."</td>\n".
- "\t\t\t\t\t\t<td>".input(class: 'size', data_id: $variant->id, type: 'text', value: $variant->size, size: 1)."</td>\n".
- "\t\t\t\t\t\t<td>".input(class: 'minBody', data_id: $variant->id, type: 'text', value: $variant->minBody, size: 1).input(class: 'maxBody', data_id: $variant->id, type: 'text', value: $variant->maxBody, size: 1)."</td>\n";
- foreach ($variant->channels AS $channel){
- $phloView .= "\t\t\t\t\t\t<td>".input(type: 'text', value: $channel->priceOld, size: 1).input(type: 'text', value: $channel->price, size: 1)."</td>\n";
- }
- $phloView .= "\t\t\t\t\t\t<td>".input(type: 'text', value: loop($variant->stock, fn($stock) => $stock->level, '+') ?: 0, size: 1)."</td>\n".
- "\t\t\t\t\t\t<td id=\"classAlertIfAboveAverage\"%.alert>0%</td>\n".
- "\t\t\t\t\t</tr>\n";
- }
- $phloView .= "\t\t\t\t\t<tr>\n".
- "\t\t\t\t\t\t<td>EXAMPLE-DATA-1</td>\n".
- "\t\t\t\t\t\t<td>-</td>\n".
- "\t\t\t\t\t\t<td>-</td>\n".
- "\t\t\t\t\t\t<td>€ -</td>\n".
- "\t\t\t\t\t\t<td>€ -</td>\n".
- "\t\t\t\t\t\t<td>28</td>\n".
- "\t\t\t\t\t\t<td class=\"alert\">2.6%</td>\n".
- "\t\t\t\t\t</tr>\n".
- "\t\t\t\t\t<tr>\n".
- "\t\t\t\t\t\t<td>EXAMPLE-DATA-2</td>\n".
- "\t\t\t\t\t\t<td>-</td>\n".
- "\t\t\t\t\t\t<td>-</td>\n".
- "\t\t\t\t\t\t<td>€ -</td>\n".
- "\t\t\t\t\t\t<td>€ -</td>\n".
- "\t\t\t\t\t\t<td id=\"classAlertIfBelow5\" class=\"alert\">3</td>\n".
- "\t\t\t\t\t\t<td>1%</td>\n".
- "\t\t\t\t\t</tr>\n".
- "\t\t\t\t</table>\n".
- "\t\t\t</td>\n".
- "\t\t</tr>\n".
- "\t</table>\n".
- "\t<br>\n".
- "\t<div>\n".
- "\t\t<h2>Productbeschrijving:</h2>\n".
- "\t\t<textarea id=\"text\" class=\"form-input\" cols=\"80\" rows=\"20\" placeholder=\"Voer hier de productbeschrijving in...\">$product->text</textarea>\n".
- "\t</div>\n".
- "</main>";
- return $phloView;
- }
- public function channelLine($variant):string {
- $phloView = "<tr>\n".
- "\t<th>".input(type: 'text', value: $variant->sku, size: 10).input(class: 'size', data_id: $variant->id, type: 'text', value: $variant->size, size: 10).input(class: 'minBody', data_id: $variant->id, type: 'text', value: $variant->minBody, size: 3).input(class: 'maxBody', data_id: $variant->id, type: 'text', value: $variant->maxBody, size: 3)."</th>\n";
- foreach ($variant->channels AS $channel){
- $phloView .= "\t<td>".input(type: 'text', value: $channel->priceOld, size: 5).input(type: 'text', value: $channel->price, size: 5)."</td>\n";
- }
- $phloView .= "\t<td>".input(type: 'text', value: loop($variant->stock, fn($stock) => $stock->level, '+') ?: 0, size: 3)."</td>\n".
- "</tr>";
- return $phloView;
- }
- }