Example #1
0
    if ($config['db']['auto_update'] == true) {
        $update_log = $database->update();
        $html->set_variable('database_update_log', nl2br($update_log));
    }
}
/********************************************************************************
 *
 *   Show a warning if there are empty tables
 *       (categories, storelocations, footprints, suppliers)
 *
 *********************************************************************************/
if (!$fatal_error && !$database->is_update_required()) {
    $good = "✔ ";
    $bad = "✘ ";
    try {
        $missing_category = Category::get_count($database) == 0 ? $bad : $good;
        $missing_storelocation = Storelocation::get_count($database) == 0 ? $bad : $good;
        $missing_footprint = Footprint::get_count($database) == 0 ? $bad : $good;
        $missing_supplier = Supplier::get_count($database) == 0 ? $bad : $good;
        $display_warning = $missing_category == $bad || $missing_storelocation == $bad || $missing_footprint == $bad || $missing_supplier == $bad;
        $html->set_variable('missing_category', $missing_category);
        $html->set_variable('missing_storeloc', $missing_storelocation);
        $html->set_variable('missing_footprint', $missing_footprint);
        $html->set_variable('missing_supplier', $missing_supplier);
        $html->set_variable('display_warning', $display_warning, 'boolean');
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    }
}
/********************************************************************************
 *
Example #2
0
}
/********************************************************************************
 *
 *   Set all HTML variables
 *
 *********************************************************************************/
if (!$fatal_error) {
    try {
        $noprice_parts = Part::get_noprice_parts($database, $current_user, $log);
        $count_of_parts_with_price = Part::get_count($database) - count($noprice_parts);
        // :-)
        $html->set_variable('parts_count_with_prices', $count_of_parts_with_price, 'integer');
        $html->set_variable('parts_count_sum_value', Part::get_sum_price_instock($database, $current_user, $log, true), 'string');
        $html->set_variable('parts_count', Part::get_count($database), 'integer');
        $html->set_variable('parts_count_sum_instock', Part::get_sum_count_instock($database), 'integer');
        $html->set_variable('categories_count', Category::get_count($database), 'integer');
        $html->set_variable('footprint_count', Footprint::get_count($database), 'integer');
        $html->set_variable('location_count', Storelocation::get_count($database), 'integer');
        $html->set_variable('suppliers_count', Supplier::get_count($database), 'integer');
        $html->set_variable('manufacturers_count', Manufacturer::get_count($database), 'integer');
        $html->set_variable('devices_count', Device::get_count($database), 'integer');
        $html->set_variable('attachements_count', Attachement::get_count($database), 'integer');
        $html->set_variable('footprint_picture_count', count(find_all_files(BASE . '/img/footprints/', true)), 'integer');
        $html->set_variable('iclogos_picture_count', count(find_all_files(BASE . '/img/iclogos/', true)), 'integer');
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
        $fatal_error = true;
    }
}
/********************************************************************************
 *