コード例 #1
0
ファイル: consumables.php プロジェクト: mrjwc/printmaster
    // Get list of models
    $models = Model::getSimple($db);
    // Get types
    if (feature('consumable_types')) {
        $types = Tag::get_by_type('consumable_type');
    }
    include 'views/consumables/addedit.php';
}
/**
 * Delete a consumable
 */
if ($action == 'delete') {
    // Get ID
    $id = fRequest::get('id', 'integer');
    try {
        $c = new Consumable($id);
        if (fRequest::isPost()) {
            $c->delete();
            fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully deleted.');
            fURL::redirect(fURL::get());
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.');
        fURL::redirect($manage_url);
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    } catch (fSQLException $e) {
        fMessaging::create('error', fURL::get(), 'Database error: ' . $e->getMessage());
    }
    include 'views/consumables/delete.php';
}
コード例 #2
0
ファイル: install.php プロジェクト: hibble/printmaster
along with Print Master.  If not, see <http://www.gnu.org/licenses/>.
*/
// Include initialisation file
include_once 'inc/init.php';
// Get action from query string
$action = fRequest::getValid('action', array('install'));
$redirect = fRequest::get('redirect', 'string');
// Get IDs
$consumable_id = fRequest::get('consumable_id', 'integer?');
$printer_id = fRequest::get('printer_id', 'integer?');
if ($action == 'install') {
    // Install consumable into printer
    try {
        // Get objects matching the printer/consumable
        $printer = new Printer($printer_id);
        $consumable = new Consumable($consumable_id);
        // Try to install it
        $installed = $consumable->installTo($printer);
        // Check status of installation
        if ($installed == FALSE) {
            fMessaging::create('error', $redirect, $consumable->err);
            fURL::redirect($redirect);
        } else {
            fMessaging::create('success', $redirect, sprintf('The consumable %s has been installed in to %s!', $consumable->getName(), $printer->getName()));
            fURL::redirect($redirect);
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', $redirect, 'The requested object with ID ' . $id . ', could not be found.');
        fURL::redirect($redirect);
    }
}
コード例 #3
0
ファイル: stock.php プロジェクト: mrjwc/printmaster
        // 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.');
        fURL::redirect($redirect);
    }
} else {
    // Get consumable object from ID
    if ($consumable_id != NULL) {
        $c = Consumable::getOne($consumable_id);
    }
    // No POSTed data, show form (based on request method)
    $view = fRequest::isAjax() ? 'ajax.php' : 'simple.php';
    include 'views/stock/' . $view;
}
コード例 #4
0
ファイル: install.php プロジェクト: mrjwc/printmaster
        $printer = new Printer($printer_id);
        if (!empty($consumable_ids)) {
            $errors = 0;
            foreach ($consumable_ids as $consumable_id) {
                // Get consumable and try to install it
                $consumable = new Consumable($consumable_id);
                if (!$consumable->installTo($printer)) {
                    $errors++;
                }
            }
            $installed = $errors === 0;
            $success = sprintf('%d consumables have been installed in to %s!', count($consumable_ids) - $errors, $printer->getName());
        } else {
            // Get consumable and try to install it
            $consumable = new Consumable($consumable_id);
            $installed = $consumable->installTo($printer);
            $success = sprintf('The consumable %s has been installed in to %s!', $consumable->getName(), $printer->getName());
        }
        // Check status of installation
        if ($installed == FALSE) {
            fMessaging::create('error', $redirect, $consumable->err);
            fURL::redirect($redirect);
        } else {
            fMessaging::create('success', $redirect, $success);
            fURL::redirect($redirect);
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', $redirect, 'The requested object with ID ' . $id . ', could not be found.');
        fURL::redirect($redirect);
    }
}