Beispiel #1
0
// Include initialisation file
include_once 'inc/core.php';
// Get parameters
$redirect = fRequest::get('redirect', 'string');
$consumable_id = fRequest::get('consumable_id', 'integer?');
$qty = fRequest::get('qty');
$cost = fRequest::get('cost', 'float?');
// Determine status - show page or update stock
if (fRequest::isPost() && $consumable_id != NULL) {
    // Increase stock
    try {
        // Get objects matching the printer/consumable
        $consumable = new Consumable($consumable_id);
        // Update cost if present
        if ($cost) {
            $consumable->setCost($cost);
            $consumable->store();
        }
        // Update consumable
        $updated = $consumable->increaseStockBy($qty);
        #die(var_export($updated));
        // Check status of installation
        if ($updated == FALSE) {
            fMessaging::create('error', $redirect, $consumable->err);
            fURL::redirect($redirect);
        } else {
            fMessaging::create('success', $redirect, sprintf('The consumable stock for %s has been updated.', $consumable->getName()));
            fURL::redirect($redirect);
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', $redirect, 'The requested object with ID ' . $id . ', could not be found.');