Example #1
0
    public static function form(\Request $request, $active_tab)
    {
        javascript('jquery');
        \Form::requiredScript();
        if (!in_array($active_tab, array('contact-info', 'map', 'social'))) {
            $active_tab = 'contact-info';
        }
        $thumbnail_map = \Settings::get('contact', 'thumbnail_map');
        $contact_info = self::load();
        $values = self::getValues($contact_info);
        require PHPWS_SOURCE_DIR . 'mod/contact/config/states.php';
        $values['states'] =& $states;
        if (!empty($thumbnail_map)) {
            $values['thumbnail_map'] = "<img src='{$thumbnail_map}' />";
        } else {
            $values['thumbnail_map'] = null;
        }
        $js_social_links = ContactInfo\Social::getLinksAsJavascriptObject($values['social']);
        $js_string = <<<EOF
<script type='text/javascript'>var active_tab = '{$active_tab}';var thumbnail_map = '{$thumbnail_map}';var social_urls = {$js_social_links};</script>
EOF;
        \Layout::addJSHeader($js_string);
        $script = PHPWS_SOURCE_HTTP . 'mod/contact/javascript/contact.js';
        \Layout::addJSHeader("<script type='text/javascript' src='{$script}'></script>");
        \Layout::addJSHeader('<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>');
        $template = new \Template($values);
        $template->setModuleTemplate('contact', 'Contact_Info_Form.html');
        return $template->get();
    }
Example #2
0
 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 form(\Request $request, $active_tab, $data)
    {
        include_once PHPWS_SOURCE_DIR . "mod/systemsinventory/config/device_types.php";
        $vars = array();
        $req_vars = $request->getRequestVars();
        $vars['title'] = '';
        $system_id = NULL;
        $command = $data['command'];
        $action = NULL;
        if (!empty($data['action'])) {
            $action = $data['action'];
        }
        if ($command == "editProfiles") {
            $message = "Profile Saved!";
            $template_name = 'Edit_Profile.html';
        } else {
            $message = "System Saved!";
            $template_name = 'Add_System.html';
        }
        javascript('jquery');
        \Form::requiredScript();
        if (!in_array($active_tab, array('systems-pc', 'ipad', 'printer', 'camera', 'digital-sign', 'time-clock'))) {
            $active_tab = 'systems-pc';
        }
        $js_string = <<<EOF
\t  <script type='text/javascript'>var active_tab = '{$active_tab}';</script> 
EOF;
        \Layout::addJSHeader($js_string);
        $script = PHPWS_SOURCE_HTTP . 'mod/systemsinventory/javascript/systems.js';
        \Layout::addJSHeader("<script type='text/javascript' src='{$script}'></script>");
        if ($action == 'success') {
            $vars['message'] = $message;
            $vars['display'] = 'display: block;';
        } else {
            $vars['message'] = '';
            $vars['display'] = 'display: none;';
        }
        $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>';
        }
        $vars['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>';
        }
        $vars['departments'] = $dep_optons;
        $system_profiles = SystemDevice::getSystemProfiles();
        $profile_optons = $printer_profile_options = '<option value="1">Select Profile</opton>';
        if (!empty($system_profiles)) {
            foreach ($system_profiles as $val) {
                if ($val['device_type_id'] == PC) {
                    $profile_optons .= '<option value="' . $val['id'] . '">' . $val['profile_name'] . '</option>';
                } else {
                    $printer_profile_options .= '<option value="' . $val['id'] . '">' . $val['profile_name'] . '</option>';
                }
            }
        }
        $vars['profiles'] = $profile_optons;
        $vars['printer_profiles'] = $printer_profile_options;
        $vars['form_action'] = "./systemsinventory/system/" . $command;
        $template = new \Template($vars);
        $template->setModuleTemplate('systemsinventory', $template_name);
        return $template->get();
    }