MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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('list')); /** * Default action - show report of consumable installation */ if ($action == 'list') { // Set the users to be sortable by name or email, defaulting to name $sort = fCRUD::getSortColumn(array('events.date', 'models.name', 'printers.name', 'consumables.name')); // Set the sorting to default to ascending $dir = fCRUD::getSortDirection('desc'); // 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\tCAST(CONCAT(manufacturers.name, ' ', models.name) AS CHAR) AS model,\n\t\t\t\tprinters.name AS printer_name,\n\t\t\t\tprinters.ipaddress,\n\t\t\t\tconsumables.name AS consumable_name,\n\t\t\t\tconsumables.col_c, consumables.col_y, consumables.col_m, consumables.col_k, \n\t\t\t\tevents.*\n\t\t\tFROM events\n\t\t\tLEFT JOIN consumables ON events.consumable_id = consumables.id\n\t\t\tLEFT JOIN printers ON events.printer_id = printers.id\n\t\t\tLEFT JOIN models ON printers.model_id = models.id\n\t\t\tLEFT JOIN manufacturers ON models.manufacturer_id = manufacturers.id\n\t\t\t{where}\n\t\t\tORDER BY {$sort} {$dir}"; // Get potential printer ID $printer_id = fRequest::get('printer_id', 'integer?'); if ($printer_id == NULL) { $sql = str_replace('{where}', '', $sql); $events = $db->query($sql)->asObjects(); } else { $sql_where = 'WHERE events.printer_id = %i'; $sql = str_replace('{where}', $sql_where, $sql); $events = $db->query($sql, $printer_id)->asObjects();
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License 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 models */ if ($action == 'list') { // Set the users to be sortable by name or email, defaulting to name $sort = fCRUD::getSortColumn(array('models.name', 'models.colour', 'manufacturers.name', 'printer_count')); // 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 table, ordered by name $sql = "SELECT\n\t\t\t\tmodels.*,\n\t\t\t\tmanufacturers.name AS mfr_name,\n\t\t\t\tCOUNT(printers.id) AS printer_count\n\t\t\tFROM\n\t\t\t\tmodels\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 printers.model_id = models.id\n\t\t\tGROUP BY\n\t\t\t\tmodels.id\n\t\t\tORDER BY\n\t\t\t\t{$sort} {$dir}"; $models = $db->query($sql)->asObjects(); #$models = fRecordSet::build('Model', NULL, array('name' => 'asc')); #$models->precreateManufacturers(); // Include page to show table include 'views/models/index.php'; } /** * Add a new model */
GNU General Public License for more details. You should have received a copy of the GNU General Public License 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')); $model_id = fRequest::get('model_id', 'integer'); /** * Default action - show list of printers */ if ($action == 'list') { // Set the users to be sortable by name or email, defaulting to name $sort = fCRUD::getSortColumn(array('printers.name', 'models.name', 'printers.ipaddress', 'printers.server', 'printers.location', 'models.colour')); // 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(); // Filter $where = NULL; if ($model_id) { // Filter by model ID $where = ' AND printers.model_id = %i '; } // Get recordset object from tables $sql = "SELECT\n\t\t\t\tprinters.*,\n\t\t\t\tmanufacturers.name AS mfr_name,\n\t\t\t\tmodels.name AS model_name,\n\t\t\t\tmodels.colour,\n\t\t\t\tGROUP_CONCAT(CAST(CONCAT(manufacturers.name, ' ', models.name) AS CHAR) SEPARATOR ', ') AS model,\n\t\t\t\t(\n\t\t\t\t\tSELECT SUM(qty) FROM consumables\n\t\t\t\t\tLEFT JOIN consumables_models ON consumables.id = consumables_models.consumable_id\n\t\t\t\t\tWHERE consumables_models.model_id = printers.model_id\n\t\t\t\t) AS stock\n\t\t\tFROM printers\n\t\t\tLEFT JOIN models ON printers.model_id = models.id\n\t\t\tLEFT JOIN manufacturers ON models.manufacturer_id = manufacturers.id\n\t\t\tWHERE 1 = 1\n\t\t\t{$where}\n\t\t\tGROUP BY printers.id\n\t\t\tORDER BY {$sort} {$dir}"; $printers = $db->query($sql, $model_id)->asObjects(); #$consumables = fRecordSet::build('Consumable', NULL, array($sort => $dir)); #$models = fRecordSet::build('Model', NULL, array('name' => 'asc'));
<?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); }
<?php include 'inc/init.php'; fAuthorization::requireLoggedIn(); fRequest::overrideAction(); $action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); $check_type = fRequest::getValid('type', array('predictive', 'threshold')); $sort = fCRUD::getSortColumn(array('name', 'target', 'warn', 'error', 'status', 'timestamp', 'count', 'regression_type', 'sample', 'baseline', 'over_under', 'visibility', 'number_of_regressions')); $sort_dir = fCRUD::getSortDirection('asc'); $check_id = fRequest::get('check_id', 'integer'); $check_list_url = Check::makeURL('list', $check_type); $filter_group_id = fRequest::get('filter_group_id', 'integer'); if (empty($filter_group_id) || $filter_group_id < 0) { $filter_group_id = -1; } $breadcrumbs[] = array('name' => ucfirst($check_type) . ' Checks', 'url' => Check::makeURL('list', $check_type), 'active' => false); // --------------------------------- // 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) {