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
O:/admin/php/page.product.php:41
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
  1. <?php
  2. // source: /srv/admin/page.product.phlo
  3. // phlo: 1.0
  4. class page_product extends obj {
  5. public $title = 'Product';
  6. public $type = 'record';
  7. public $obj = 'product';
  8. public function _lines(){
  9. return line::pair(columns: 'id,CONCAT(supplier, " ", title)');
  10. }
  11. public $filters = [
  12. '1' => ['title' => 'Toon retour% afgelopen maand', 'filter' => 'returnsPeriod="1month"'],
  13. '2' => ['title' => 'Toon retour% afgelopen 2 maanden', 'filter' => 'returnsPeriod="2month"'],
  14. '3' => ['title' => 'Toon retour% afgelopen 3 maanden', 'filter' => 'returnsPeriod="3month"'],
  15. '6' => ['title' => 'Toon retour% afgelopen 6 maanden', 'filter' => 'returnsPeriod="6month"'],
  16. '9' => ['title' => 'Toon retour% afgelopen 9 maanden', 'filter' => 'returnsPeriod="9month"'],
  17. '12' => ['title' => 'Toon retour% afgelopen 12 maanden', 'filter' => 'returnsPeriod="12month"'],
  18. ];
  19. public $actions = [
  20. '+ Maak nieuw product',
  21. '- Verwijder product',
  22. ];
  23. public function _buttons():string {
  24. return "<a class=\"async\" href=\"/product/opslaan\">Producttekst Opslaan</a>";
  25. }
  26. public function view($title, $product, $uri):string {
  27. $phloView = "<main class=\"admin-container\">\n".
  28. "\t<div class=\"admin-header\">\n".
  29. "\t\t<div class=\"header-content listing-table\">\n".
  30. "\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".
  31. "\t\t\t<h2><b>ID:</b> $product->id | <b>Lijn:</b> ".$this->lines[$product->line]." (line ID:".$product->line.") | <b>Inkoop:</b> &euro; <input type=\"text\" name=\"priceCost\" size=\"2\" value=\"".(round(current($product->variants)->priceCost, 2) ?: void)."\">\n".
  32. "\t\t</div>\n".
  33. "\t</div>\n".
  34. "\t<table class=\"listing-table listing-products\">\n".
  35. "\t\t<tr data-id=\"$product->id\">\n".
  36. "\t\t\t<td class=\"center\" colspan=\"2\"><a class=\"async\" href=\"/product/$product->id\"><img src=\"".$product->image->src."\" alt=\"\"></a></td>\n".
  37. "\t\t\t<td class=\"channels\">\n".
  38. "\t\t\t\t<table class=\"channel\">\n".
  39. "\t\t\t\t\t<tr>\n".
  40. "\t\t\t\t\t\t<th>SKU</th>\n".
  41. "\t\t\t\t\t\t<th>Maat</th>\n".
  42. "\t\t\t\t\t\t<th>Min/Max lengte</th>\n";
  43. foreach (channels AS $channel){
  44. $phloView .= "\t\t\t\t\t\t<th>$channel<br>€ Van | € Voor</th>\n";
  45. }
  46. $phloView .= "\t\t\t\t\t\t<th>Stock</th>\n".
  47. "\t\t\t\t\t\t<th id=\"select_1_2_3_6_12_months\">Retour%<br>(avg: #averageReturn%)</th>\n".
  48. "\t\t\t\t\t</tr>\n";
  49. foreach (sortVariants($product->variants) AS $variant){
  50. $phloView .= "\t\t\t\t\t<tr>\n".
  51. "\t\t\t\t\t\t<td>".input(type: 'text', value: $variant->sku, size: 20)."</td>\n".
  52. "\t\t\t\t\t\t<td>".input(class: 'size', data_id: $variant->id, type: 'text', value: $variant->size, size: 1)."</td>\n".
  53. "\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";
  54. foreach ($variant->channels AS $channel){
  55. $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";
  56. }
  57. $phloView .= "\t\t\t\t\t\t<td>".input(type: 'text', value: loop($variant->stock, fn($stock) => $stock->level, '+') ?: 0, size: 1)."</td>\n".
  58. "\t\t\t\t\t\t<td id=\"classAlertIfAboveAverage\"%.alert>0%</td>\n".
  59. "\t\t\t\t\t</tr>\n";
  60. }
  61. $phloView .= "\t\t\t\t\t<tr>\n".
  62. "\t\t\t\t\t\t<td>EXAMPLE-DATA-1</td>\n".
  63. "\t\t\t\t\t\t<td>-</td>\n".
  64. "\t\t\t\t\t\t<td>-</td>\n".
  65. "\t\t\t\t\t\t<td>&euro; -</td>\n".
  66. "\t\t\t\t\t\t<td>&euro; -</td>\n".
  67. "\t\t\t\t\t\t<td>28</td>\n".
  68. "\t\t\t\t\t\t<td class=\"alert\">2.6%</td>\n".
  69. "\t\t\t\t\t</tr>\n".
  70. "\t\t\t\t\t<tr>\n".
  71. "\t\t\t\t\t\t<td>EXAMPLE-DATA-2</td>\n".
  72. "\t\t\t\t\t\t<td>-</td>\n".
  73. "\t\t\t\t\t\t<td>-</td>\n".
  74. "\t\t\t\t\t\t<td>&euro; -</td>\n".
  75. "\t\t\t\t\t\t<td>&euro; -</td>\n".
  76. "\t\t\t\t\t\t<td id=\"classAlertIfBelow5\" class=\"alert\">3</td>\n".
  77. "\t\t\t\t\t\t<td>1%</td>\n".
  78. "\t\t\t\t\t</tr>\n".
  79. "\t\t\t\t</table>\n".
  80. "\t\t\t</td>\n".
  81. "\t\t</tr>\n".
  82. "\t</table>\n".
  83. "\t<br>\n".
  84. "\t<div>\n".
  85. "\t\t<h2>Productbeschrijving:</h2>\n".
  86. "\t\t<textarea id=\"text\" class=\"form-input\" cols=\"80\" rows=\"20\" placeholder=\"Voer hier de productbeschrijving in...\">$product->text</textarea>\n".
  87. "\t</div>\n".
  88. "</main>";
  89. return $phloView;
  90. }
  91. public function channelLine($variant):string {
  92. $phloView = "<tr>\n".
  93. "\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";
  94. foreach ($variant->channels AS $channel){
  95. $phloView .= "\t<td>".input(type: 'text', value: $channel->priceOld, size: 5).input(type: 'text', value: $channel->price, size: 5)."</td>\n";
  96. }
  97. $phloView .= "\t<td>".input(type: 'text', value: loop($variant->stock, fn($stock) => $stock->level, '+') ?: 0, size: 3)."</td>\n".
  98. "</tr>";
  99. return $phloView;
  100. }
  101. }