/** * @brief Compare function for "usort()" * * From php.net: The comparison function must return an integer less than, * equal to, or greater than zero if the first argument is considered * to be respectively less than, equal to, or greater than the second. * * @param Part $part_1 The Part Object #1 * @param Part $part_2 The Part Object #2 * * @retval integer */ static function usort_compare($part_1, $part_2) { if ($part_1->get_name() != $part_2->get_name()) { return strcasecmp($part_1->get_name(), $part_2->get_name()); } else { // names are identical, so we compare the description of the parts return strcasecmp($part_1->get_description(), $part_2->get_description()); } }
* * Set the rest of the HTML variables * *********************************************************************************/ $html->use_javascript(array('validatenumber', 'popup')); // global settings $html->set_variable('use_modal_popup', $config['popup']['modal'], 'boolean'); $html->set_variable('popup_width', $config['popup']['width'], 'integer'); $html->set_variable('popup_height', $config['popup']['height'], 'integer'); if (!$fatal_error) { try { // part attributes $html->set_variable('pid', $part->get_id(), 'integer'); $html->set_variable('name', $part->get_name(), 'string'); $html->set_variable('manufacturer_product_url', $part->get_manufacturer_product_url(), 'string'); $html->set_variable('description', $part->get_description(), 'string'); $html->set_variable('category_full_path', $part->get_category()->get_full_path(), 'string'); $html->set_variable('instock', $part->get_instock(), 'integer'); $html->set_variable('mininstock', $part->get_mininstock(), 'integer'); $html->set_variable('visible', $part->get_visible(), 'boolean'); $html->set_variable('comment', nl2br($part->get_comment()), 'string'); $html->set_variable('footprint_full_path', is_object($footprint) ? $footprint->get_full_path() : '-', 'string'); $html->set_variable('footprint_filename', is_object($footprint) ? str_replace(BASE, BASE_RELATIVE, $footprint->get_filename()) : '', 'string'); $html->set_variable('storelocation_full_path', is_object($storelocation) ? $storelocation->get_full_path() : '-', 'string'); $html->set_variable('storelocation_is_full', is_object($storelocation) ? $storelocation->get_is_full() : false, 'boolean'); $html->set_variable('manufacturer_full_path', is_object($manufacturer) ? $manufacturer->get_full_path() : '-', 'string'); $html->set_variable('category_full_path', is_object($category) ? $category->get_full_path() : '-', 'string'); $html->set_variable('auto_order_exists', $part->get_instock() < $part->get_mininstock(), 'boolean'); $html->set_variable('manual_order_exists', $part->get_manual_order() && $part->get_instock() >= $part->get_mininstock(), 'boolean'); // build orderdetails loop $orderdetails_loop = array();