<?php require_once 'php/init.php'; loadScripts(); $data = array("status" => "not set!"); if (Utils::isGET()) { $pm = new ProductManager(); $rows = $pm->listAdminProducts(); $html = ""; foreach ($rows as $row) { $sku = $row['SKU']; $title = $row['title']; $price = $row['item_price']; $desc = $row['description']; $qty = $row['qty']; $html .= "<tr>\n <td class='sku'><span>{$sku}</span></td>\n <td class='title'><span>{$title}</span></td>\n <td class='qty'><span>{$qty}</span></td>\n <td class='price'>\$<span>{$price}</span></td>\n <td><input id='d-{$sku}' class='delete' type='button' value='Delete'/></td>\n <td><input id='u-{$sku}' class='update' type='button' value='Update'/></td>\n </tr>"; } echo $html; return; } else { if (Utils::isPOST()) { // post means either to delete or add a user $parameters = new Parameters("POST"); $action = $parameters->getValue('action'); $sku = $parameters->getValue('SKU'); if ($action == 'delete' && !empty($sku)) { $um = new ProductManager(); $um->deleteProduct($sku); $data = array("status" => "success", "msg" => "Product '{$sku}' deleted."); echo json_encode($data, JSON_FORCE_OBJECT); return;