} catch (Exception $e) { $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red'); } break; case 'copy_device': // make a copy of this device (including all parts) try { $device->copy($copy_new_name, $copy_new_parent_id, $copy_recursive); $html->set_variable('refresh_navigation_frame', true, 'boolean'); } catch (Exception $e) { $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red'); } break; case 'export': try { $device_parts = $device->get_parts(); if ($export_only_missing) { foreach ($device_parts as $key => $devicepart) { $needed = $devicepart->get_mount_quantity() * $export_multiplier; $instock = $devicepart->get_part()->get_instock(); $mininstock = $devicepart->get_part()->get_mininstock(); if ($instock - $needed >= $mininstock) { unset($device_parts[$key]); } } } $download = isset($_REQUEST['export_download']); $export_string = export_parts($device_parts, 'deviceparts', $export_format_id, $download, 'deviceparts_' . $device->get_name(), array('export_quantity' => $export_multiplier)); } catch (Exception $e) { $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red'); }
$fatal_error = true; } } /******************************************************************************** * * Generate "Devices to order"-Table * *********************************************************************************/ if (!$fatal_error) { try { $order_devices = Device::get_order_devices($database, $current_user, $log); $order_devices_loop = array(); $row_odd = true; foreach ($order_devices as $device) { $too_less_parts = 0; foreach ($device->get_parts() as $devicepart) { $needed = $devicepart->get_mount_quantity() * $device->get_order_quantity(); $instock = $devicepart->get_part()->get_instock(); $mininstock = $devicepart->get_part()->get_mininstock(); if ($instock - $needed < $mininstock) { $too_less_parts++; } } $order_devices_loop[] = array('row_odd' => $row_odd, 'id' => $device->get_id(), 'name' => $device->get_name(), 'full_path' => $device->get_full_path(), 'order_quantity' => $device->get_order_quantity(), 'only_missing_parts' => $device->get_order_only_missing_parts(), 'parts_count' => $device->get_parts_count(), 'parts_count_to_order' => $too_less_parts); $row_odd = !$row_odd; } $html->set_loop('order_devices_loop', $order_devices_loop); } catch (Exception $e) { $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red'); $fatal_error = true; }