<?php $product = Product::from_id(array_shift($request)); if (!$product) { die('unknown product'); } $packages = ProductPackage::selection(array('package' => $product->id)); $total = $product->value; ?> <table> <tr> <th>Namn</th> <td><?php echo $product->name; ?> </td> </tr> <tr> <th>Status</th> <td><?php echo $product->active ? 'Aktiv' : 'Inaktiv'; ?> </td> </tr> <tr> <th>Pris</th> <td><?php echo $product->price; ?> </td> </tr>
require "../../includes.php"; if (empty($_SESSION['login'])) { kick('login?kickback=' . htmlspecialchars(kickback_url())); } $db->autoCommit(false); $products = ClientData::post('product_id'); $counts = ClientData::post('product_count'); $money_diff = 0; $delivery = new Delivery(); $delivery->description = "Inventering"; $delivery->user = $_SESSION['login']; $delivery->commit(); foreach ($products as $i => $product_id) { // Create purchase $product = Product::from_id($product_id); $diff = $counts[$i] - $product->count; $money_diff += $diff * $product->value; $product->count = $counts[$i]; $product->commit(); $contents = new DeliveryContent(); $contents->cost = 0; $contents->delivery_id = $delivery->id; $contents->product_id = $product_id; $contents->count = $diff; var_dump($contents->count); $contents->commit(); } if ($money_diff != 0) { $from_account = Account::from_code_name('stock_diff'); $to_account = Account::from_code_name('stock');
<?php require "../../includes.php"; if (empty($_SESSION['login'])) { kick('login?kickback=' . htmlspecialchars(kickback_url("edit_product/" . ClientData::post('product')))); } $product = Product::from_id(ClientData::post('product')); $fields = array('name', 'active', 'price', 'value', 'ean', 'category_id', 'inventory_threshold'); foreach ($fields as $field) { $product->{$field} = ClientData::post($field); } $product->commit(); kick('product/' . $product->id);