public static function form(\Request $request, $command = null) { javascript('jquery'); \Form::requiredScript(); if (empty($command)) { $command = 'run_search'; } $system_locations = \systemsinventory\Factory\SystemDevice::getSystemLocations(); $location_options = '<option value="0">All</opton>'; foreach ($system_locations as $val) { $location_options .= '<option value="' . $val['id'] . '">' . $val['display_name'] . '</option>'; } $vars['locations'] = $location_options; $system_types = \systemsinventory\Factory\SystemDevice::getSystemTypes(); $type_options = '<option value="0">All</opton>'; foreach ($system_types as $val) { $type_options .= '<option value="' . $val['id'] . '">' . $val['description'] . '</option>'; } $vars['system_types'] = $type_options; $system_dep = \systemsinventory\Factory\SystemDevice::getSystemDepartments(); $dep_optons = '<option value="0">All</opton>'; foreach ($system_dep as $val) { $dep_optons .= '<option value="' . $val['id'] . '">' . $val['display_name'] . '</option>'; } $vars['departments'] = $dep_optons; $vars['form_action'] = "./systemsinventory/search/" . $command; $template = new \Template($vars); $template->setModuleTemplate('systemsinventory', 'Search_System.html'); return $template->get(); }
public static function editLocationsView($data, $request) { $vars = array(); $locations = SystemDevice::getSystemLocations(); $loc_options = ''; $loc_options .= '<option value="1">NONE</option>'; foreach ($locations as $val) { if ($val['id'] != 1) { $loc_options .= '<option value="' . $val['id'] . '">' . $val['display_name'] . '</option>'; } } $vars['locations'] = $loc_options; $script = PHPWS_SOURCE_HTTP . 'mod/systemsinventory/javascript/edit_loc.js'; \Layout::addLink("<script type='text/javascript' src='{$script}'></script>"); $vars['add'] = '<a href="#" class="btn btn-md btn-success" data-toggle="modal" data-target="#edit-location-modal"><i class="fa fa-plus"> </i>Add Location</a>'; \Pager::prepare(); $template = new \Template(); $template = new \Template($vars); $template->setModuleTemplate('systemsinventory', 'Edit_Locations.html'); return $template->get(); }
public static function getSystemDetails($system_id, $row_index) { include_once PHPWS_SOURCE_DIR . "mod/systemsinventory/config/device_types.php"; $device_details = array(); if (empty($system_id)) { throw new Exception("System ID invalid."); } // get the common device attributes $db = \Database::getDB(); $query = "SELECT * FROM systems_device WHERE id='{$system_id}'"; $pdo = $db->query($query); $result = $pdo->fetch(\PDO::FETCH_ASSOC); $device_type_id = $result['device_type_id']; $device_details = $result; // get the device specific attributes $table = SystemDevice::getSystemType($device_type_id); if (!empty($table)) { $device_table = $db->addTable($table); $device_table->addFieldConditional('device_id', $system_id); $device_result = $db->select(); $device_result = $device_result['0']; // set the specific device id so we can use it to save the device specific info later. $specific_device_id = $device_result['id']; unset($device_result['id']); $device_result['specific-device-id'] = $specific_device_id; //$device_attr = SystemDevice::getDeviceAttributes($device_type_id); $device_details = array_merge($device_details, $device_result); } $device_details['device-type-id'] = $device_type_id; $purchase_date = $device_details['purchase_date']; $device_details["purchase_date"] = date('Y-m-d', $purchase_date); $system_locations = SystemDevice::getSystemLocations(); $location_options = '<option value="1">Select Location</opton>'; foreach ($system_locations as $key => $val) { $location_options .= '<option value="' . $val['id'] . '">' . $val['display_name'] . '</option>'; } $device_details['locations'] = $location_options; $system_dep = SystemDevice::getSystemDepartments(); $dep_optons = '<option value="1">Select Department</opton>'; foreach ($system_dep as $val) { $dep_optons .= '<option value="' . $val['id'] . '">' . $val['display_name'] . '</option>'; } $device_details['departments'] = $dep_optons; $device_details['testarray'] = array("test1" => "test1", "test2" => "test2", "test3" => "test3"); $device_details['row_index'] = $row_index; return $device_details; }