along with Print Master. If not, see <http://www.gnu.org/licenses/>. */ // Include initialisation file include_once 'inc/core.php'; // Get action from query string $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); /** * Default action - show list of consumables */ if ($action == 'list') { // Set the users to be sortable by name or email, defaulting to name $sort = fCRUD::getSortColumn(array('consumables.name', 'consumables.qty', 'consumables.cost')); // Set the sorting to default to ascending $dir = fCRUD::getSortDirection('asc'); // Redirect the user if one of the values was loaded from the session fCRUD::redirectWithLoadedValues(); // Get recordset object from tables $sql = "SELECT\n\t\t\t\tconsumables.*,\n\t\t\t\t( round( ( (consumables.qty) / (SELECT MAX(qty) FROM consumables) ) * 100 ) ) AS qty_percent,\n\t\t\t\tGROUP_CONCAT(DISTINCT CAST(CONCAT(manufacturers.name, ' ', models.name) AS CHAR) SEPARATOR ', ') AS model,\n\t\t\t\tCOUNT(printers.id) AS printer_count\n\t\t\tFROM\n\t\t\t\tconsumables\n\t\t\tLEFT JOIN\n\t\t\t\tconsumables_models\n\t\t\t\tON consumables.id = consumables_models.consumable_id\n\t\t\tLEFT JOIN\n\t\t\t\tmodels\n\t\t\t\tON consumables_models.model_id = models.id\n\t\t\tLEFT JOIN\n\t\t\t\tmanufacturers\n\t\t\t\tON models.manufacturer_id = manufacturers.id\n\t\t\tLEFT JOIN\n\t\t\t\tprinters\n\t\t\t\tON consumables_models.model_id = printers.model_id\n\t\t\tGROUP BY\n\t\t\t\tconsumables.id\n\t\t\tORDER BY\n\t\t\t\t{$sort} {$dir}"; $consumables = $db->query($sql)->asObjects(); #$consumables = fRecordSet::build('Consumable', NULL, array($sort => $dir)); #$models = fRecordSet::build('Model', NULL, array('name' => 'asc')); #$models->precreateManufacturers(); // Include page to show table include 'views/consumables/index.php'; } /** * Add a new consumable */ if ($action == 'add') { // Create new $c = new Consumable();
/** * Resets the configuration and data of the class * * @internal * * @return void */ public static function reset() { fSession::clear(__CLASS__ . '::'); self::$loaded_values = array(); self::$row_number = 1; self::$search_values = array(); self::$sort_column = NULL; self::$sort_direction = NULL; }
try { $checks->tossIfEmpty(); $affected = fMessaging::retrieve('affected', fURL::get()); ?> <a class="small btn primary" href="<?= Check::makeUrl('add');?>">Add Check</a> <table class="zebra-striped"> <thead> <tr> <th><?=fCRUD::printSortableColumn('name','Name'); ?></th> <th><?=fCRUD::printSortableColumn('target','Target'); ?></th> <th><?=fCRUD::printSortableColumn('warn','Warn'); ?></th> <th><?=fCRUD::printSortableColumn('error','Error'); ?></th> <th><?=fCRUD::printSortableColumn('sample','Sample'); ?></th> <th><?=fCRUD::printSortableColumn('baseline','Baseline'); ?></th> <th><?=fCRUD::printSortableColumn('over_under','Over/Under'); ?></th> <th><?=fCRUD::printSortableColumn('visiblity','Visibility'); ?></th> <th>Action</th> </tr></thead><tbody> <?php $first = TRUE; foreach ($checks as $check) { ?> <tr> <td><?='<a href="' . CheckResult::makeUrl('list',$check) . '">' . $check->prepareName(); ?></a></td> <td><?=$check->prepareTarget(); ?></td> <td><?=$check->prepareWarn(); ?></td> <td><?=$check->prepareError(); ?></td> <td><?=$check->prepareSample(); ?></td> <td><?=$check->prepareBaseline(); ?></td> <td><?=$over_under_array[$check->getOver_Under()]; ?></td> <td><?=$visibility_array[$check->getVisibility()]; ?></td>
?> </th> <th class="masterTooltip" title="Number of data points to use when calculating the moving average. Each data point spans one minute"><?php echo fCRUD::printSortableColumn('sample', 'Sample'); ?> </th> <th><?php echo fCRUD::printSortableColumn('baseline', 'Baseline'); ?> </th> <th class="masterTooltip" title="Over will trigger an alert when the value retrieved from Graphite is greater than the warning or error threshold. Under will trigger an alert when the value retrieved from Graphite is less than the warning or the error threshold"><?php echo fCRUD::printSortableColumn('over_under', 'Over/Under'); ?> </th> <th class="masterTooltip" title="Public checks can be subscribed to by any user while private checks remain hidden from other users"><?php echo fCRUD::printSortableColumn('visiblity', 'Visibility'); ?> </th> <th>Action</th> </tr></thead> <tbody> <?php $first = TRUE; foreach ($checks as $check) { ?> <tr> <td><?php echo '<a href="' . CheckResult::makeUrl('list', $check) . '">' . $check->prepareName(); ?> </a></td> <td style="max-width:300px; overflow:scroll;"><?php
<div class="grid_12"> <?php $tpl->place('menu'); ?> <br /> <table class="list"> <tr class="heading"> <th>Colour</th> <th><?php echo fCRUD::printSortableColumn('consumables.name', 'Name'); ?> </th> <th colspan="2"><?php echo fCRUD::printSortableColumn('consumables.qty', 'Quantity'); ?> </th> <th>Printer models</th> <th>Operations</th> </tr> <?php foreach ($consumables as $c) { echo '<tr>'; echo '<td style="width:100px;text-align:left;" class="col">'; if ($c->col_c) { printf($colour, '0066B3'); } if ($c->col_y) { printf($colour, 'FFCC00');
<tr class="heading"> <th filter="false">Colour</th> <th><?php echo fCRUD::printSortableColumn('consumables.name', 'Consumable'); ?> </th> <th><?php echo fCRUD::printSortableColumn('printers.name', 'Printer'); ?> </th> <th><?php echo fCRUD::printSortableColumn('models.name', 'Model'); ?> </th> <th filter="false"><?php echo fCRUD::printSortableColumn('events.date', 'Date'); ?> </th> </tr> </thead> <tbody> <?php foreach ($events as $e) { echo '<tr>'; /* $img = ($p->colour == 1) ? 'colour.png' : 'mono.png'; $txt = ($p->colour == 1) ? 'C' : 'M'; echo '<td style="width:48px;text-align:center;">'; echo '<span style="display:none;">' . $txt . '</span>'; echo '<img src="web/img/' . $img . '" width="16" height="16" />'; echo '</td>'; */
<thead> <tr class="heading"> <th><?php echo fCRUD::printSortableColumn('models.colour', 'Colour'); ?> </th> <th><?php echo fCRUD::printSortableColumn('manufacturers.name', 'Manufacturer'); ?> </th> <th><?php echo fCRUD::printSortableColumn('models.name', 'Name'); ?> </th> <th><?php echo fCRUD::printSortableColumn('printer_count', '# Printers'); ?> </th> <th>Operations</th> </tr> </thead> <tbody> <?php foreach ($models as $m) { echo '<tr>'; $img = $m->colour == 1 ? 'colour.png' : 'mono.png'; echo '<td style="width:48px;text-align:center;">'; echo '<img src="web/img/' . $img . '" width="16" height="16" />'; echo '</td>'; echo '<td>' . $m->mfr_name . '</td>';
?> </th> <th><?php echo fCRUD::printSortableColumn('models.name', 'Model'); ?> </th> <th><?php echo fCRUD::printSortableColumn('printers.ipaddress', 'IP Address'); ?> </th> <th filter-type="ddl"><?php echo fCRUD::printSortableColumn('printers.server', 'Print server'); ?> </th> <th><?php echo fCRUD::printSortableColumn('printers.location', 'Location'); ?> </th> <th filter="false">Operations</th> </tr> </thead> <tbody> <?php foreach ($printers as $p) { echo '<tr>'; $img = $p->colour == 1 ? 'colour.png' : 'mono.png'; $txt = $p->colour == 1 ? 'C' : 'M'; echo '<td style="width:48px;text-align:center;">'; echo '<span style="display:none;">' . $txt . '</span>'; echo '<img src="web/img/' . $img . '" width="16" height="16" />';
<?php include 'inc/init.php'; fAuthorization::requireLoggedIn(); $breadcrumbs[] = array('name' => 'Subscription', 'url' => Subscription::makeURL('list'), 'active' => true); $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); $sort = fCRUD::getSortColumn(array('name', 'status', 'method', 'state')); $sort_order = fCRUD::getSortDirection('asc'); $subscription_id = fRequest::get('subscription_id', 'integer'); $check_id = fRequest::get('check_id', 'integer'); $manage_url = $_SERVER['SCRIPT_NAME']; // --------------------------------- // if ('delete' == $action) { $class_name = 'Subscription'; try { $obj = new Subscription($subscription_id); $check = new Check($obj->getCheckId()); $delete_text = 'Are you sure you want to delete your subscription to <strong>' . $check->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); fMessaging::create('success', $manage_url, 'The subscription for ' . $check->getName() . ' was successfully deleted'); fURL::redirect($manage_url); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The subscription requested, ' . fHTML::encode($date) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php';
<?php include 'inc/init.php'; fAuthorization::requireLoggedIn(); fRequest::overrideAction(); $breadcrumbs[] = array('name' => 'Checks', 'url' => Check::makeUrl('list'), 'active' => false); $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); $sort = fCRUD::getSortColumn(array('name', 'target', 'warn', 'error', 'status', 'timestamp', 'count')); $sort_dir = fCRUD::getSortDirection('asc'); $check_id = fRequest::get('check_id', 'integer'); $check_list_url = Check::makeURL('list'); // --------------------------------- // if ('delete' == $action) { try { $obj = new Check($check_id); $delete_text = 'Are you sure you want to delete the check : <strong>' . $obj->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); // Do our own Subscription and CheckResult cleanup instead of using ORM $subscriptions = Subscription::findAll($check_id); foreach ($subscriptions as $subscription) { $subscription->delete(); } $check_results = CheckResult::findAll($check_id); foreach ($check_results as $check_result) { $check_result->delete(); } fMessaging::create('success', fURL::get(), 'The check ' . $obj->getName() . ' was successfully deleted'); fURL::redirect($check_list_url); }
echo fCRUD::printSortableColumn('printers.name', 'Printer'); ?> </th> <th><?php echo fCRUD::printSortableColumn('models.name', 'Model'); ?> </th> <th filter="false"><?php echo fCRUD::printSortableColumn('events.date', 'Date'); ?> </th> <?php if (feature('costs') || feature('chargeback')) { ?> <th class="right"><?php echo fCRUD::printSortableColumn('events.cost', 'Cost'); ?> </th> <?php } ?> </tr> </thead> <tbody> <?php $total_cost = 0; foreach ($events as $e) { // Add up total cost if ($e->cost) { $total_cost += $e->cost;
foreach ($meetups as $meetup) { ?> <tr class="<?php echo fCRUD::getRowClass($meetup->getDate()->__toString(), $affected); ?> "> <td class="<?php echo fCRUD::getColumnClass('date'); ?> "> <?php echo $meetup->prepareDate('F j, Y'); ?> </td> <td class="<?php echo fCRUD::getColumnClass('location'); ?> "> <?php echo $meetup->prepareVenue(); ?> - <?php echo $meetup->prepareCity(); ?> , <?php echo $meetup->prepareState(); ?> </td> <td class="actions">
$tpl->place('menu'); ?> <br /> <table class="list"> <tr class="heading"> <th><?php echo fCRUD::printSortableColumn('models.colour', 'Colour'); ?> </th> <th><?php echo fCRUD::printSortableColumn('manufacturers.name', 'Manufacturer'); ?> </th> <th><?php echo fCRUD::printSortableColumn('models.name', 'Name'); ?> </th> <th>Operations</th> </tr> <?php foreach ($models as $m) { echo '<tr>'; $img = $m->colour == 1 ? 'colour.png' : 'mono.png'; echo '<td style="width:48px;text-align:center;">'; echo '<img src="web/img/' . $img . '" width="16" height="16" />'; echo '</td>'; echo '<td>' . $m->mfr_name . '</td>'; echo '<td class="name">' . $m->name . '</td>'; echo '<td>';