コード例 #1
0
 public function show()
 {
     PHPWS_Core::initModClass('hms', 'HMS_Lottery.php');
     PHPWS_Core::initModClass('hms', 'LotteryApplication.php');
     $this->setTitle('Special Interest Group');
     javascript('jquery');
     $tpl = array();
     $groups = HMS_Lottery::getSpecialInterestGroupsMap();
     // If a group was selected
     if (!is_null($this->group) && $this->group != 'none') {
         $tpl['GROUP_PAGER'] = LotteryApplication::specialInterestPager($this->group, PHPWS_Settings::get('hms', 'lottery_term'));
         $tpl['GROUP'] = $groups[$this->group];
     }
     // Show the drop down box of groups
     $form = new PHPWS_Form('special_interest');
     $form->setMethod('get');
     $form->addDropBox('group', $groups);
     $form->setClass('group', 'form-control');
     $form->setMatch('group', $this->group);
     $cmd = CommandFactory::getCommand('ShowSpecialInterestGroupApproval');
     $cmd->initForm($form);
     $form->mergeTemplate($tpl);
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'hms', 'admin/special_interest_approval.tpl');
 }
コード例 #2
0
ファイル: SettingsView.php プロジェクト: HaldunA/phpwebsite
 public function show()
 {
     // Setup form
     $form = new \PHPWS_Form('addthis_settings');
     $form->setMethod('POST');
     // Hidden fields for directing this request after submission
     $form->addHidden('module', 'addthis');
     $form->addHidden('action', 'SaveSettings');
     // List of checkboxes and their labels for settings
     $settingList = array('enabled', 'fb_like_enabled', 'google_plus_enabled', 'share_bar_enabled');
     $settingLabels = array('Enabled', 'Facebook Like Enabled', 'Google+ Enabled', 'Share Bar Enabled');
     // Add checkboxes, set labels
     $form->addCheck('enabled_check', $settingList);
     $form->setLabel('enabled_check', $settingLabels);
     // If a setting is enabled, then check its box
     $toCheck = array();
     foreach ($this->settings->getAll() as $key => $value) {
         if ($value == 1) {
             $toCheck[] = $key;
         }
     }
     // NB: Have to set the checked elements all at once
     $form->setMatch('enabled_check', $toCheck);
     $form->addSubmit('submit', 'Submit');
     $tpl = $form->getTemplate();
     return \PHPWS_Template::process($tpl, 'addthis', 'settings.tpl');
 }
コード例 #3
0
ファイル: SettingsView.php プロジェクト: HaldunA/phpwebsite
 public function show()
 {
     // Setup form
     $form = new PHPWS_Form('likebox_settings');
     $form->setMethod('POST');
     // Hidden fields for directing this request after submission
     $form->addHidden('module', 'likebox');
     $form->addHidden('action', 'SaveSettings');
     // Enabled Checkbox
     $form->addCheck('enabled', 'enabled');
     $form->setLabel('enabled', 'Enabled');
     // URL
     $form->addText('fb_url', $this->settings->get('fb_url'));
     $form->setLabel('fb_url', 'Facebook Page URL:');
     // Width
     $form->addText('width', $this->settings->get('width'));
     $form->setLabel('width', 'Width');
     // Height
     $form->addText('height', $this->settings->get('height'));
     $form->setLabel('height', 'Height');
     // Show header bar i.e. "Find us on Facebook"
     $form->addCheck('small_header', 'small_header');
     $form->setLabel('small_header', 'Use Small header');
     // Show border
     $form->addCheck('hide_cover', 'hide_cover');
     $form->setLabel('hide_cover', 'Hide Cover Photo');
     // Show stream
     $form->addCheck('show_posts', 'show_posts');
     $form->setLabel('show_posts', 'Show Page Posts');
     // Show faces
     $form->addCheck('show_faces', 'show_faces');
     $form->setLabel('show_faces', 'Show Friend\'s faces');
     // Submit button
     $form->addSubmit('submit', 'Submit');
     $checkBoxes = array('enabled', 'small_header', 'hide_cover', 'show_posts', 'show_faces');
     foreach ($checkBoxes as $key) {
         $value = $this->settings->get($key);
         if (isset($value) && $value == 1) {
             $form->setMatch($key, $key);
         }
     }
     $tpl = $form->getTemplate();
     return PHPWS_Template::process($tpl, 'likebox', 'settings.tpl');
 }
コード例 #4
0
 public function getSearchBox()
 {
     static $id_count = 0;
     if ($id_count) {
         $id = 'search_list_' . $id_count;
     } else {
         $id = 'search_list';
         $id_count++;
     }
     $form = new PHPWS_Form($id);
     $form->setMethod('get');
     $values = $this->getLinkValues();
     unset($values['pager_search']);
     unset($values['go']);
     $form->addHidden($values);
     $form->addText('pager_c_search', $this->search);
     $form->setSize('pager_c_search', 20);
     if ($this->search_label) {
         $form->setLabel('pager_c_search', _('Search'));
     }
     if ($this->clear_button) {
         $form->addButton('clear', _('Clear'));
         $form->setExtra('clear', 'onclick="this.form.search_list_pager_c_search.value=\'\'"');
     }
     if ($this->search_button) {
         $form->addSubmit('go', _('Search'));
     }
     $template = $form->getTemplate();
     if (PHPWS_Error::isError($template)) {
         PHPWS_Error::log($template);
         return null;
     }
     return implode("\n", $template);
 }
コード例 #5
0
ファイル: File_Manager.php プロジェクト: HaldunA/phpwebsite
 /**
  * View of files in current folder
  */
 public function folderContentView()
 {
     javascript('jquery');
     PHPWS_Core::initModClass('filecabinet', 'Image.php');
     javascript('confirm');
     // needed for deletion
     Layout::addStyle('filecabinet');
     if (empty($this->current_folder) || empty($this->folder_type)) {
         javascript('alert', array('content' => dgettext('filecabinet', 'Problem with opening browser page. Closing File Manager window.')));
         javascript('close_refresh', array('timeout' => 3, 'refresh' => 0));
         return;
     }
     $tpl = array();
     $this->folderIcons($tpl);
     if (Current_User::allow('filecabinet', 'edit_folders')) {
         $tpl['FOLDER_TITLE'] = $this->current_folder->editLink('title', $this->current_folder->module_created);
     } else {
         $tpl['FOLDER_TITLE'] =& $this->current_folder->title;
     }
     $img_dir = PHPWS_SOURCE_HTTP . 'mod/filecabinet/img/file_manager/';
     $image_string = '<img src="%s" title="%s" alt="%s" />';
     $link_info = $this->linkInfo();
     switch ($this->folder_type) {
         case IMAGE_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize image.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This image is larger than the %s x %s limit. Do you want to resize the image to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             $db = new PHPWS_DB('images');
             $class_name = 'PHPWS_Image';
             $file_type = FC_IMAGE;
             $altvars = $link_info;
             // check
             unset($altvars['mw']);
             unset($altvars['mh']);
             unset($altvars['fr']);
             $img1 = 'folder_random.png';
             $img2 = 'thumbnails.png';
             $img3 = 'lightbox.png';
             $img1_alt = dgettext('filecabinet', 'Random image icon');
             $img2_alt = dgettext('filecabinet', 'Thumbnail icon');
             $img3_alt = dgettext('filecabinet', 'Lightbox icon');
             if (!$this->reserved_folder) {
                 if ($this->current_folder->public_folder) {
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_IMAGE_RANDOM;
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     if (!$this->lock_type || in_array(FC_IMAGE_RANDOM, $this->lock_type)) {
                         $img1_title = dgettext('filecabinet', 'Show a random image from this folder');
                         $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                         $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                         if ($this->file_assoc->file_type == FC_IMAGE_RANDOM && $this->current_folder->id == $this->file_assoc->file_id) {
                             $tpl['ALT_HIGH1'] = ' alt-high';
                         }
                     } else {
                         $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                         $tpl['ALT1'] = $image1;
                         $tpl['ALT_HIGH1'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_FOLDER, $this->lock_type)) {
                         /** start new * */
                         if ($this->file_assoc->file_type == FC_IMAGE_FOLDER) {
                             $tpl['ALT_HIGH2'] = ' alt-high';
                         }
                         $img2_title = dgettext('filecabinet', 'Show block of thumbnails');
                         $image2 = sprintf($image_string, $img_dir . $img2, $img2_title, $img2_alt);
                         $form = new PHPWS_Form('carousel-options');
                         $form->setMethod('get');
                         $altvars['file_type'] = FC_IMAGE_FOLDER;
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8);
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Carousel direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return carousel_pick();">%s</a>', $image2);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT2'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/carousel_pick.tpl');
                     } else {
                         $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                         $tpl['ALT2'] = $image2;
                         $tpl['ALT_HIGH2'] = ' no-use';
                     }
                     if (!$this->lock_type || in_array(FC_IMAGE_LIGHTBOX, $this->lock_type)) {
                         /** start VV * */
                         if ($this->file_assoc->file_type == FC_IMAGE_LIGHTBOX) {
                             $tpl['ALT_HIGH3'] = ' alt-high';
                         }
                         $img3_title = dgettext('filecabinet', 'Show lightbox slideshow');
                         $image3 = sprintf($image_string, $img_dir . $img3, $img3_title, $img3_alt);
                         $altvars['file_type'] = FC_IMAGE_LIGHTBOX;
                         $form = new PHPWS_Form('lightbox-options');
                         $form->setMethod('get');
                         $form->addHidden($altvars);
                         $form->addHidden('module', 'filecabinet');
                         $form->addRadioAssoc('direction', array(0 => dgettext('filecabinet', 'Horizontal'), 1 => dgettext('filecabinet', 'Vertical')));
                         $match = $this->file_assoc->vertical;
                         $form->setMatch('direction', $match);
                         $num = array(3 => 3, 6 => 6, 9 => 9, 12 => 12, 15 => 15, 18 => 18, 21 => 21, 99 => 'unlimited');
                         $form->addSelect('num_visible', $num);
                         $form->setLabel('num_visible', dgettext('filecabinet', 'Number shown'));
                         $form->setMatch('num_visible', $this->file_assoc->num_visible);
                         $form->addSubmit('go', dgettext('filecabinet', 'Go'));
                         $subtpl = $form->getTemplate();
                         $subtpl['DIRECTION_DESC'] = dgettext('filecabinet', 'Thumbnail direction');
                         $subtpl['LINK'] = sprintf('<a href="#" onclick="return lightbox_pick();">%s</a>', $image3);
                         $subtpl['CANCEL'] = dgettext('filecabinet', 'Cancel');
                         $tpl['ALT3'] = PHPWS_Template::process($subtpl, 'filecabinet', 'file_manager/lightbox_pick.tpl');
                     } else {
                         $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                         $tpl['ALT3'] = $image3;
                         $tpl['ALT_HIGH3'] = ' no-use';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
                     $image3 = sprintf($image_string, $img_dir . $img3, $not_allowed, $img3_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                     $tpl['ALT2'] = $image2;
                     $tpl['ALT_HIGH2'] = ' no-use';
                     $tpl['ALT3'] = $image3;
                     $tpl['ALT_HIGH3'] = ' no-use';
                 }
             }
             break;
         case DOCUMENT_FOLDER:
             PHPWS_Core::initModClass('filecabinet', 'Document.php');
             $db = new PHPWS_DB('documents');
             $class_name = 'PHPWS_Document';
             $file_type = FC_DOCUMENT;
             $img1 = 'all_files.png';
             $img1_alt = dgettext('filecabinet', 'All files icon');
             if ($this->current_folder->public_folder) {
                 if (!$this->lock_type || in_array(FC_DOCUMENT_FOLDER, $this->lock_type)) {
                     $altvars = $link_info;
                     $altvars['id'] = $this->current_folder->id;
                     $altvars['fop'] = 'pick_file';
                     $altvars['file_type'] = FC_DOCUMENT_FOLDER;
                     $img1_title = dgettext('filecabinet', 'Show all files in the folder');
                     $image1 = sprintf($image_string, $img_dir . $img1, $img1_title, $img1_alt);
                     $tpl['ALT1'] = PHPWS_Text::secureLink($image1, 'filecabinet', $altvars);
                     if ($this->file_assoc->file_type == FC_DOCUMENT_FOLDER && $this->current_folder->id == $this->file_assoc->file_id) {
                         $tpl['ALT_HIGH1'] = ' alt-high';
                     }
                 } else {
                     $not_allowed = dgettext('filecabinet', 'Action not allowed');
                     $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                     $tpl['ALT1'] = $image1;
                     $tpl['ALT_HIGH1'] = ' no-use';
                 }
             } else {
                 $not_allowed = dgettext('filecabinet', 'Action not allowed - private folder');
                 $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
                 $tpl['ALT1'] = $image1;
                 $tpl['ALT_HIGH1'] = ' no-use';
             }
             break;
         case MULTIMEDIA_FOLDER:
             $js = $link_info;
             $js['authkey'] = Current_User::getAuthKey();
             $js['failure_message'] = dgettext('filecabinet', 'Unable to resize media.');
             $js['confirmation'] = sprintf(dgettext('filecabinet', 'This media is larger than the %s x %s limit. Do you want to resize the media to fit?'), $this->max_width, $this->max_height);
             javascriptMod('filecabinet', 'pick_file', $js);
             PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
             $db = new PHPWS_DB('multimedia');
             $class_name = 'PHPWS_Multimedia';
             $file_type = FC_MEDIA;
             //$tpl['ADD_EMBED'] = $this->current_folder->embedLink(true);
             break;
     }
     $db->addWhere('folder_id', $this->current_folder->id);
     $db->addOrder('title');
     $items = $db->getObjects($class_name);
     if ($items) {
         foreach ($items as $item) {
             $stpl = $item->managerTpl($this);
             $tpl['items'][] = $stpl;
         }
     } else {
         $not_allowed = dgettext('filecabinet', 'No files in folder');
         if (isset($tpl['ALT1'])) {
             $image1 = sprintf($image_string, $img_dir . $img1, $not_allowed, $img1_alt);
             $tpl['ALT1'] = $image1;
             $tpl['ALT_HIGH1'] = ' no-use';
         }
         if (isset($tpl['ALT2'])) {
             $image2 = sprintf($image_string, $img_dir . $img2, $not_allowed, $img2_alt);
             $tpl['ALT2'] = $image2;
             $tpl['ALT_HIGH2'] = ' no-use';
         }
     }
     if (Current_User::allow('filecabinet', 'edit_folders', $this->current_folder->id, 'folder')) {
         if ($this->force_upload_dimensions) {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true, $this->max_width, $this->max_height);
         } else {
             $tpl['ADD_FILE'] = $this->current_folder->uploadLink(true);
         }
     }
     $tpl['CLOSE'] = javascript('close_window');
     return PHPWS_Template::process($tpl, 'filecabinet', 'file_manager/folder_content_view.tpl');
 }
コード例 #6
0
ファイル: User.php プロジェクト: par-orillonsoft/phpwebsite
 public function schedulePick()
 {
     $schedules = $this->calendar->getScheduleList('brief');
     if (count($schedules) < 2) {
         return null;
     }
     $form = new PHPWS_Form('schedule_pick');
     $form->setMethod('get');
     $form->addHidden('module', 'calendar');
     $form->addHidden('view', $this->current_view);
     $form->addHidden('date', $this->calendar->current_date);
     $form->addSelect('sch_id', $schedules);
     $form->setMatch('sch_id', $this->calendar->schedule->id);
     $form->addSubmit('go', dgettext('calendar', 'Change schedule'));
     $tpl = $form->getTemplate();
     return $tpl['START_FORM'] . $tpl['SCH_ID'] . $tpl['GO'] . $tpl['END_FORM'];
 }
コード例 #7
0
 public function display()
 {
     // Set up search fields
     $form = new \PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'intern');
     $form->addHidden('action', 'results');
     $form->useRowRepeat();
     // Student name or Banner ID
     $form->addText('name');
     $form->setLabel('name', "Name or Banner ID");
     /***************
      * Course Info *
      ***************/
     $terms = Term::getTermsAssoc();
     $form->addSelect('term_select', $terms);
     $form->setLabel('term_select', 'Term');
     $form->setClass('term_select', 'form-control');
     $subjects = array('-1' => 'Select subject ') + Subject::getSubjects();
     $form->addSelect('course_subj', $subjects);
     $form->setLabel('course_subj', 'Subject');
     $form->setClass('course_subj', 'form-control');
     $form->addText('course_no');
     $form->setLabel('course_no', 'Course Number');
     $form->setSize('course_no', 6);
     $form->setMaxSize('course_no', 4);
     $form->setClass('course_no', 'form-control');
     $form->addText('course_sect');
     $form->setLabel('course_sect', 'Section');
     $form->setSize('course_sect', 6);
     $form->setMaxSize('course_sect', 4);
     $form->setClass('course_sect', 'form-control');
     /****************
      * Faculty Info *
      ****************/
     // Deity can search for any department. Other users are restricted.
     if (\Current_User::isDeity()) {
         $depts = Department::getDepartmentsAssoc();
     } else {
         $depts = Department::getDepartmentsAssocForUsername(\Current_User::getUsername());
     }
     $depts = array('-1' => 'Select Department') + $depts;
     $form->addSelect('dept', $depts);
     $form->setLabel('dept', 'Department');
     //$form->setClass('', 'form-control');
     $form->setClass('dept', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $form->setMatch('dept', $keys[1]);
     }
     // Student level radio button
     javascript('jquery');
     javascriptMod('intern', 'majorSelector', array('form_id' => $form->id));
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $form->addDropBox('student_major', $levels);
     $form->setLabel('student_major', 'Major / Program');
     $form->addCssClass('student_major', 'form-control');
     // Get the majors list
     $majorsList = MajorsProviderFactory::getProvider()->getMajors(Term::timeToTerm(time()));
     // Undergrad major drop down
     $undergradMajors = array('-1' => 'Select Undergraduate Major') + $majorsList->getUndergradMajorsAssoc();
     $form->addSelect('undergrad_major', $undergradMajors);
     $form->setMatch('undergrad_major', '-1');
     $form->setClass('undergrad_major', 'form-control');
     // Graduate major drop down
     $graduateMajors = array('-1' => 'Select Graduate Major') + $majorsList->getGraduateMajorsAssoc();
     $form->addSelect('graduate_major', $graduateMajors);
     $form->setMatch('graduate_major', '-1');
     $form->setClass('graduate_major', 'form-control');
     /*******************
      * Internship Type *
      *******************/
     // Handeled directly in the html template
     /************
      * Location *
      ************/
     // Campus Handeled directly in the html template
     // International vs Domestic - Handeled directly in the html template
     // State search
     /*******************
      * Workflow States *
      *******************/
     $workflowStates = WorkflowStateFactory::getStatesAssoc();
     unset($workflowStates['Intern\\WorkflowState\\CreationState']);
     // Remove this state, since it's not valid (internal only state for initial creation)
     $form->addCheckAssoc('workflow_state', $workflowStates);
     $form->addSubmit('submit', 'Search');
     // Javascript...
     javascriptMod('intern', 'resetSearch');
     return \PHPWS_Template::process($form->getTemplate(), 'intern', 'search.tpl');
 }
コード例 #8
0
 public function getPageDrop()
 {
     if (empty($this->total_pages)) {
         $page_list[1] = 1;
     } else {
         for ($i = 1; $i <= $this->total_pages; $i++) {
             $page_list[$i] = $i;
         }
     }
     $form = new PHPWS_Form('page_list');
     $form->setMethod('get');
     $values = $this->getLinkValues();
     $form->addHidden($values);
     $form->addSelect('change_page', $page_list);
     $form->setExtra('change_page', 'onchange="this.form.submit()"');
     $form->setMatch('change_page', $this->current_page);
     if (!function_exists('javascriptEnabled') || !javascriptEnabled()) {
         $form->addSubmit('go', _('Go'));
     }
     $template = $form->getTemplate();
     if (PHPWS_Error::isError($template)) {
         PHPWS_Error::log($template);
         return null;
     }
     return $template['START_FORM'] . $template['CHANGE_PAGE'] . $template['END_FORM'];
 }
コード例 #9
0
 public static function manageUsers()
 {
     Layout::addStyle('users');
     PHPWS_Core::initCoreClass('DBPager.php');
     $form = new PHPWS_Form('group-search');
     $form->setMethod('get');
     $form->addHidden('module', 'users');
     $form->addHidden('action', 'admin');
     $form->addHidden('tab', 'manage_users');
     $form->addRadioAssoc('qgroup', array(dgettext('users', 'Not in group'), dgettext('users', 'In group')));
     if (isset($_GET['qgroup'])) {
         $qg =& $_GET['qgroup'];
     } else {
         $qg = 1;
     }
     $form->setMatch('qgroup', $qg);
     $db = new PHPWS_DB('users_groups');
     $db->addWhere('user_id', 0);
     $db->addColumn('id');
     $db->addColumn('name');
     $db->setIndexBy('id');
     $groups = $db->select('col');
     if (empty($groups)) {
         $groups[] = dgettext('users', '-- All --');
     } else {
         $groups = array(dgettext('users', '-- All --')) + $groups;
     }
     $form->addSelect('search_group', $groups);
     $form->addCssClass('search_group', 'form-control');
     if (isset($_GET['search_group'])) {
         $form->setMatch('search_group', $_GET['search_group']);
     }
     $form->addSubmit('group_sub', dgettext('users', 'Limit users by group'));
     $pageTags = $form->getTemplate();
     $pageTags['ACTIONS_LABEL'] = dgettext('users', 'Actions');
     if (PHPWS_Settings::get('users', 'allow_new_users') || Current_User::isDeity()) {
         $pageTags['NEW_USER'] = PHPWS_Text::secureLink(dgettext('users', 'Create new user'), 'users', array('action' => 'admin', 'command' => 'new_user'), null, dgettext('users', 'Create new user'), 'btn btn-success');
         $pageTags['NEW_USER_URI'] = PHPWS_Text::linkAddress('users', array('action' => 'admin', 'command' => 'new_user'));
     }
     $pager = new DBPager('users', 'PHPWS_User');
     $pager->setDefaultLimit(10);
     $pager->setModule('users');
     $pager->setTemplate('manager/users.tpl');
     $pager->setLink('index.php?module=users&amp;action=admin&amp;tab=manage_users&amp;authkey=' . Current_User::getAuthKey());
     $pager->addPageTags($pageTags);
     $pager->addRowTags('getUserTpl');
     $pager->addToggle(' class="bgcolor1"');
     $pager->addSortHeader('username', dgettext('users', 'Username'));
     $pager->addSortHeader('display_name', dgettext('users', 'Display'));
     $pager->addSortHeader('email', dgettext('users', 'Email'));
     $pager->addSortHeader('last_logged', dgettext('users', 'Last Logged'));
     $pager->addSortHeader('active', dgettext('users', 'Active'));
     $pager->setSearch('username', 'email', 'display_name');
     $pager->cacheQueries();
     if (!empty($_GET['search_group'])) {
         $search_group = (int) $_GET['search_group'];
         if (!empty($_GET['qgroup'])) {
             $pager->addWhere('users_members.group_id', $search_group, '=', 'and', 'g1');
             $pager->addWhere('users_groups.id', 'users_members.member_id', '=', 'and', 'g1');
             $pager->addWhere('users.id', 'users_groups.user_id', '=', 'and', 'g1');
         } else {
             $pager->db->addJoin('left', 'users', 'users_groups', 'id', 'user_id');
             $pager->db->addJoin('left', 'users_groups', 'users_members', 'id', 'member_id');
             $pager->db->addWhere('users_members.group_id', null, 'is null', null, 'g1');
             $pager->db->addWhere('users_members.group_id', $search_group, '!=', 'or', 'g1');
         }
     }
     $result = $pager->get();
     return $result;
 }
コード例 #10
0
ファイル: Forms.php プロジェクト: HaldunA/phpwebsite
 public function editSlots()
 {
     $this->signup->title = sprintf(dgettext('signup', 'Slot setup for %s'), $this->signup->sheet->title);
     $form = new PHPWS_Form('seach_users');
     $form->setMethod('get');
     $form->addHidden('module', 'signup');
     $form->addHidden('aop', 'edit_slots');
     $form->addHidden('sheet_id', $this->signup->sheet->id);
     if (!empty($_GET['search'])) {
         $search = $_GET['search'];
         $this->signup->message = dgettext('signup', 'The name you searched for is in these slots.');
     } else {
         $search = null;
     }
     $form->addText('search', $search);
     $form->setLabel('search', dgettext('signup', 'Search slots'));
     $tpl = $form->getTemplate();
     $vars['aop'] = 'edit_slot_popup';
     $vars['sheet_id'] = $this->signup->sheet->id;
     $vars['slot_id'] = 0;
     $js['address'] = PHPWS_Text::linkAddress('signup', $vars, true);
     $js['label'] = dgettext('signup', 'Add slot');
     $tpl['ADD_SLOT'] = javascript('open_window', $js);
     $vars['aop'] = 'reset_slot_order';
     $tpl['RESET'] = PHPWS_Text::secureLink(dgettext('signup', 'Reset order'), 'signup', $vars);
     $vars['aop'] = 'alpha_order';
     $tpl['ALPHA'] = PHPWS_Text::secureLink(dgettext('signup', 'Alphabetic order'), 'signup', $vars);
     $slots = $this->signup->sheet->getAllSlots(false, $search);
     if ($slots) {
         foreach ($slots as $slot) {
             $tpl['slot-list'][] = $slot->listTpl();
         }
     } else {
         $this->signup->message = dgettext('signup', 'No slots found.');
     }
     $this->signup->content = PHPWS_Template::process($tpl, 'signup', 'slot_setup.tpl');
 }
コード例 #11
0
ファイル: User.php プロジェクト: HaldunA/phpwebsite
 public static function searchPost()
 {
     if (isset($_GET['search'])) {
         $search_phrase = $_GET['search'];
     } else {
         $search_phrase = '';
     }
     $search_phrase = str_replace('+', ' ', $search_phrase);
     $search_phrase = Search::filterWords($search_phrase);
     if (isset($_GET['alternate']) && $_GET['alternate'] != 'local') {
         Search_User::sendToAlternate($_GET['alternate'], $search_phrase);
         exit;
     }
     // hi + keep search terms for further use (like hilite for js)
     $_SESSION['search']['search_phrase'] = $search_phrase;
     // hi /
     $form = new PHPWS_Form('search_for');
     $form->setMethod('get');
     $form->addHidden('module', 'search');
     $form->addHidden('user', 'search');
     $form->addSubmit(dgettext('search', 'Search'));
     $form->addText('search', $search_phrase);
     $form->setSize('search', 40);
     $form->setLabel('search', dgettext('search', 'Search for:'));
     $form->addCheck('exact_only', 1);
     $form->setLabel('exact_only', dgettext('search', 'Exact matches only'));
     if (isset($_GET['exact_only'])) {
         $exact_match = TRUE;
         $form->setMatch('exact_only', 1);
     } else {
         $exact_match = FALSE;
     }
     $mod_list = Search_User::getModList();
     $form->addSelect('mod_title', $mod_list);
     $form->setLabel('mod_title', dgettext('search', 'Module list'));
     if (isset($_GET['mod_title'])) {
         $form->setMatch('mod_title', $_GET['mod_title']);
     }
     Search_User::addAlternates($form);
     $template = $form->getTemplate();
     if (isset($_GET['mod_title']) && $_GET['mod_title'] != 'all') {
         $module = preg_replace('/\\W/', '', $_GET['mod_title']);
     } else {
         $module = NULL;
     }
     $template['SEARCH_LOCATION'] = dgettext('search', 'Search location');
     $template['ADVANCED_LABEL'] = dgettext('search', 'Advanced Search');
     $result = Search_User::getResults($search_phrase, $module, $exact_match);
     if (PHPWS_Error::isError($result)) {
         PHPWS_Error::log($result);
         $template['SEARCH_RESULTS'] = dgettext('search', 'A problem occurred during your search.');
     } elseif (empty($result)) {
         $template['SEARCH_RESULTS'] = dgettext('search', 'No results found.');
     } else {
         $template['SEARCH_RESULTS'] = $result;
     }
     $template['SEARCH_RESULTS_LABEL'] = dgettext('search', 'Search Results');
     $content = PHPWS_Template::process($template, 'search', 'search_page.tpl');
     Layout::add($content);
 }
コード例 #12
0
ファイル: Forms.php プロジェクト: HaldunA/phpwebsite
 public function getFolders($type)
 {
     javascript('jquery');
     $src = PHPWS_SOURCE_HTTP . 'mod/filecabinet/javascript/folder_options/folders.js';
     \Layout::addJSHeader("<script type='text/javascript' src='{$src}'></script>", 'folder-options');
     PHPWS_Core::initCoreClass('DBPager.php');
     $folder = new Folder();
     $folder->ftype = $type;
     $folder->loadDirectory();
     $pagetags['MODAL'] = $this->getModal();
     if (Current_User::allow('filecabinet')) {
         if (!is_dir($folder->_base_directory)) {
             $this->cabinet->message = dgettext('filecabinet', "Directory {$folder->_base_directory} does not exist.");
         } else {
             if (!is_writable($folder->_base_directory)) {
                 switch ($folder->ftype) {
                     case IMAGE_FOLDER:
                         $this->cabinet->message = dgettext('filecabinet', 'Your images directory is not writable.');
                         break;
                     case DOCUMENT_FOLDER:
                         $this->cabinet->message = dgettext('filecabinet', 'Your documents directory is not writable.');
                         break;
                     case MULTIMEDIA_FOLDER:
                         $this->cabinet->message = dgettext('filecabinet', 'Your multimedia directory is not writable.');
                         break;
                 }
             } else {
                 if (Current_User::allow('filecabinet', 'edit_folders')) {
                     $authkey = \Current_User::getAuthKey();
                     $pagetags['ADMIN_LINKS'] = "<button class='btn btn-success show-modal' data-operation='aop' data-command='add_folder' data-folder_id='0' data-ftype='{$folder->ftype}'><i class='fa fa-plus'></i> Add Folder</button>";
                     //$pagetags['ADMIN_LINKS'] = $folder->editLink();
                 }
             }
         }
     }
     switch ($folder->ftype) {
         case IMAGE_FOLDER:
             $aop = 'image';
             $table = 'images';
             break;
         case DOCUMENT_FOLDER:
             $aop = 'document';
             $table = 'documents';
             break;
         case MULTIMEDIA_FOLDER:
             $table = $aop = 'multimedia';
             break;
     }
     $pagetags['ITEM_LABEL'] = dgettext('filecabinet', 'Items');
     $form = new PHPWS_Form('folder-search');
     $form->setMethod('get');
     $form->addHidden('module', 'filecabinet');
     $form->addHidden('aop', $aop);
     $form->addHidden('ftype', $folder->ftype);
     $folder_search = isset($_GET['folder_search']) ? $_GET['folder_search'] : null;
     $form->addText('folder_search', $folder_search);
     $form->addSubmit(dgettext('filecabinet', 'Search folders for file'));
     $search_tpl = $form->getTemplate();
     $pagetags['FILE_SEARCH'] = $search_tpl['START_FORM'] . $search_tpl['FOLDER_SEARCH'] . $search_tpl['SUBMIT'] . $search_tpl['END_FORM'];
     $pager = new DBPager('folders', 'Folder');
     if (!empty($_GET['folder_search'])) {
         $pl = UTF8_MODE ? '\\pL' : null;
         $search = preg_replace("/[^\\w\\s\\-{$pl}]/", '', $_GET['folder_search']);
         if (!empty($search)) {
             $pager->addWhere("{$table}.file_name", $search, 'REGEXP', 'or', 'g1');
             $pager->addWhere("{$table}.title", $search, 'REGEXP', 'or', 'g1');
             $pager->addWhere('folders.id', "{$table}.folder_id");
         }
     }
     $pager->addSortHeader('title', dgettext('filecabinet', 'Title'));
     $pager->addSortHeader('public_folder', dgettext('filecabinet', 'Public'));
     $pager->setModule('filecabinet');
     $pager->setTemplate('Forms/folder_list.tpl');
     $pager->addPageTags($pagetags);
     $pager->addRowTags('rowTags');
     $pager->setEmptyMessage(dgettext('filecabinet', 'No folders found.'));
     $pager->addWhere('ftype', $type);
     $pager->setDefaultOrder('title');
     $pager->setAutoSort(false);
     $this->cabinet->content = $pager->get();
 }
コード例 #13
0
ファイル: User.php プロジェクト: HaldunA/phpwebsite
 public function searchPanel()
 {
     $form = new \PHPWS_Form('search-properties');
     $form->addHidden('uop', 'search');
     $form->addHidden('module', 'properties');
     $form->setMethod('get');
     $form->addText('manager');
     $form->setSize('manager', 15);
     $form->addSubmit('manager_submit', 'Add');
     $form->addText('property_name');
     $form->setSize('property_name', 15);
     $form->addSubmit('property_name_submit', 'Add');
     $tpl = $form->getTemplate();
     //javascriptMod('properties', 'search');
     $vars['uop'] = 'search';
     $vars['d'] = 'any';
     $distances[] = \PHPWS_Text::moduleLink('Any', 'properties', $vars);
     $vars['d'] = '0';
     $distances[] = \PHPWS_Text::moduleLink('0 - 5 miles', 'properties', $vars);
     $vars['d'] = '5';
     $distances[] = \PHPWS_Text::moduleLink('5 - 10 miles', 'properties', $vars);
     $vars['d'] = '10';
     $distances[] = \PHPWS_Text::moduleLink('10 - 25 miles', 'properties', $vars);
     $vars['d'] = '25';
     $distances[] = \PHPWS_Text::moduleLink('Over 25 miles', 'properties', $vars);
     $tpl['DISTANCE_OPTIONS'] = '<ul><li>' . implode('</li><li>', $distances) . '</li></ul>';
     unset($vars['d']);
     $vars['a'] = UNDERGRAD;
     $age1 = \PHPWS_Text::moduleLink('Undergraduate', 'properties', $vars);
     $vars['a'] = GRAD_STUDENT;
     $age2 = \PHPWS_Text::moduleLink('Graduate', 'properties', $vars);
     $tpl['STUDENT_TYPE'] = $age1 . '<br />' . $age2;
     unset($vars['a']);
     $vars['p'] = 'any';
     $prices[] = \PHPWS_Text::moduleLink('Any', 'properties', $vars);
     $vars['p'] = '0-100';
     $prices[] = \PHPWS_Text::moduleLink('$100 and under', 'properties', $vars);
     $vars['p'] = '100-200';
     $prices[] = \PHPWS_Text::moduleLink('$100 to $200', 'properties', $vars);
     $vars['p'] = '200-300';
     $prices[] = \PHPWS_Text::moduleLink('$200 to $300', 'properties', $vars);
     $vars['p'] = '300-400';
     $prices[] = \PHPWS_Text::moduleLink('$300 to $400', 'properties', $vars);
     $vars['p'] = '400-500';
     $prices[] = \PHPWS_Text::moduleLink('$400 to $500', 'properties', $vars);
     $vars['p'] = '500-600';
     $prices[] = \PHPWS_Text::moduleLink('$500 to $600', 'properties', $vars);
     $vars['p'] = '600-750';
     $prices[] = \PHPWS_Text::moduleLink('$600 to $750', 'properties', $vars);
     $vars['p'] = '750-1000';
     $prices[] = \PHPWS_Text::moduleLink('$750 to $1000', 'properties', $vars);
     $vars['p'] = '1000-9999';
     $prices[] = \PHPWS_Text::moduleLink('$1000 and above', 'properties', $vars);
     $tpl['PRICE_OPTIONS'] = '<ul><li>' . implode('</li><li>', $prices) . '</li></ul>';
     unset($vars['p']);
     $vars['eff'] = '1';
     $rooms[] = \PHPWS_Text::moduleLink('One room efficiency', 'properties', $vars);
     unset($vars['eff']);
     $vars['beds'] = '1';
     $rooms[] = \PHPWS_Text::moduleLink('1+', 'properties', $vars);
     $vars['beds'] = '2';
     $rooms[] = \PHPWS_Text::moduleLink('2+', 'properties', $vars);
     $vars['beds'] = '3';
     $rooms[] = \PHPWS_Text::moduleLink('3+', 'properties', $vars);
     $vars['beds'] = '4';
     $rooms[] = \PHPWS_Text::moduleLink('4+', 'properties', $vars);
     $vars['beds'] = '5';
     $rooms[] = \PHPWS_Text::moduleLink('5+', 'properties', $vars);
     $tpl['BEDROOM_CHOICE'] = '<ul><li>' . implode('</li><li>', $rooms) . '</li></ul>';
     unset($vars['beds']);
     $vars['bath'] = '1';
     $bath[] = \PHPWS_Text::moduleLink('1+', 'properties', $vars);
     $vars['bath'] = '1.5';
     $bath[] = \PHPWS_Text::moduleLink('1 1/2+', 'properties', $vars);
     $vars['bath'] = '2';
     $bath[] = \PHPWS_Text::moduleLink('2+', 'properties', $vars);
     $vars['bath'] = '2.5';
     $bath[] = \PHPWS_Text::moduleLink('2 1/2+', 'properties', $vars);
     $vars['bath'] = '3';
     $bath[] = \PHPWS_Text::moduleLink('3+', 'properties', $vars);
     $vars['bath'] = '3.5';
     $bath[] = \PHPWS_Text::moduleLink('3 1/2+', 'properties', $vars);
     $tpl['BATHROOM_CHOICE'] = '<ul><li>' . implode('</li><li>', $bath) . '</li></ul>';
     unset($vars['bath']);
     $vars['sub'] = 1;
     $tpl['SUBLEASE'] = \PHPWS_Text::moduleLink('Sublease only', 'properties', $vars);
     unset($vars['sub']);
     $vars['nosub'] = 1;
     $tpl['NOSUB'] = \PHPWS_Text::moduleLink('No subleases', 'properties', $vars);
     unset($vars['nosub']);
     $features = null;
     $search = $this->loadSearchParameters();
     if (!isset($search['amenities']['ac'])) {
         $vars['amen'] = 'ac';
         $features[] = \PHPWS_Text::moduleLink('AppalCart', 'properties', $vars);
     }
     if (!isset($search['amenities']['ch'])) {
         $vars['amen'] = 'ch';
         $features[] = \PHPWS_Text::moduleLink('Clubhouse', 'properties', $vars);
     }
     if (!isset($search['amenities']['dish'])) {
         $vars['amen'] = 'dish';
         $features[] = \PHPWS_Text::moduleLink('Dishwasher', 'properties', $vars);
     }
     if (!isset($search['amenities']['furn'])) {
         $vars['amen'] = 'furn';
         $features[] = \PHPWS_Text::moduleLink('Furnished', 'properties', $vars);
     }
     if (!isset($search['amenities']['pet'])) {
         $vars['amen'] = 'pet';
         $features[] = \PHPWS_Text::moduleLink('Pet allowed', 'properties', $vars);
     }
     if (!isset($search['amenities']['tr'])) {
         $vars['amen'] = 'tr';
         $features[] = \PHPWS_Text::moduleLink('Trash pickup', 'properties', $vars);
     }
     if (!isset($search['amenities']['wo'])) {
         $vars['amen'] = 'wo';
         $features[] = \PHPWS_Text::moduleLink('Workout room', 'properties', $vars);
     }
     if (!isset($search['amenities']['wash'])) {
         $vars['amen'] = 'wash';
         $features[] = \PHPWS_Text::moduleLink('Washer/Dryer', 'properties', $vars);
     }
     if ($features) {
         $tpl['FEATURES'] = '<ul><li>' . implode('</li><li>', $features) . '</li></ul>';
     }
     $tpl['CRITERIA'] = $this->getCriteria();
     unset($vars['amen']);
     $vars['clear'] = 1;
     $tpl['CLEAR'] = \PHPWS_Text::moduleLink('Clear all criteria', 'properties', $vars, null, 'Clear all criteria', 'btn btn-danger');
     $content = \PHPWS_Template::process($tpl, 'properties', 'search.tpl');
     \Layout::add($content, 'properties', 'search_settings');
 }
コード例 #14
0
ファイル: Admin.php プロジェクト: HaldunA/phpwebsite
 public static function ignore()
 {
     PHPWS_Core::initCoreClass('DBPager.php');
     $tpl['TITLE'] = dgettext('search', 'Ignored');
     PHPWS_Core::initModClass('search', 'Stats.php');
     $pager = new DBPager('search_stats', 'Search_Stats');
     $pager->setModule('search');
     $pager->setTemplate('ignore.tpl');
     $pager->addRowTags('getTplTags');
     $options['keyword'] = '';
     $options['delete_keyword'] = dgettext('search', 'Delete');
     // if entered in search box, remove
     $options['remove_ignore'] = dgettext('search', 'Allow');
     $form = new PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'search');
     $form->addSelect('command', $options);
     $template = $form->getTemplate();
     $js_vars['value'] = dgettext('search', 'Go');
     $js_vars['select_id'] = 'command';
     $js_vars['action_match'] = 'delete_keyword';
     $js_vars['message'] = dgettext('search', 'Are you sure you want to delete the checked item(s)?');
     $template['SUBMIT'] = javascript('select_confirm', $js_vars);
     $template['CHECK_ALL'] = javascript('check_all', array('checkbox_name' => 'keyword[]'));
     $template['KEYWORD_LABEL'] = dgettext('search', 'Keyword');
     $template['TOTAL_QUERY_LABEL'] = dgettext('search', 'Total queries');
     $template['LAST_CALL_DATE_LABEL'] = dgettext('search', 'Last called');
     $pager->addPageTags($template);
     $pager->addToggle('class="bgcolor1"');
     $pager->setSearch('keyword');
     $pager->addWhere('ignored', 1);
     $tpl['CONTENT'] = $pager->get();
     return $tpl;
 }
コード例 #15
0
 public static function display()
 {
     PHPWS_Core::initModClass('intern', 'Term.php');
     PHPWS_Core::initModClass('intern', 'Department.php');
     PHPWS_Core::initModClass('intern', 'Major.php');
     PHPWS_Core::initModClass('intern', 'GradProgram.php');
     PHPWS_Core::initModClass('intern', 'Internship.php');
     PHPWS_Core::initModClass('intern', 'Agency.php');
     PHPWS_Core::initModClass('intern', 'Subject.php');
     PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
     // Set up search fields
     $form = new PHPWS_Form();
     $form->setMethod('get');
     $form->addHidden('module', 'intern');
     $form->addHidden('action', 'results');
     $form->useRowRepeat();
     $form->addText('name');
     $form->setLabel('name', "Name or Banner ID");
     $terms = Term::getTermsAssoc();
     //$thisTerm = Term::timeToTerm(time());
     $form->addSelect('term_select', $terms);
     $form->setLabel('term_select', 'Term');
     $form->setClass('term_select', 'form-control');
     //$form->setMatch('term_select', $thisTerm);
     // Deity can search for any department. Other users are restricted.
     if (Current_User::isDeity()) {
         $depts = Department::getDepartmentsAssoc();
     } else {
         $depts = Department::getDepartmentsAssocForUsername(Current_User::getUsername());
     }
     $form->addSelect('dept', $depts);
     $form->setLabel('dept', 'Department');
     //$form->setClass('', 'form-control');
     $form->setClass('dept', 'form-control');
     // If the user only has one department, select it for them
     // sizeof($depts) == 2 because of the 'Select Deparmtnet' option
     if (sizeof($depts) == 2) {
         $keys = array_keys($depts);
         $form->setMatch('dept', $keys[1]);
     }
     // Student level radio button
     javascript('jquery');
     javascriptMod('intern', 'majorSelector', array('form_id' => $form->id));
     $levels = array('-1' => 'Any Level', 'ugrad' => 'Undergraduate', 'grad' => 'Graduate');
     $form->addSelect('student_level', $levels);
     $form->setLabel('student_level', 'Level');
     $form->setClass('student_level', 'form-control');
     // Student Major dummy box (gets replaced by dropdowns below using JS when student_level is selected)
     $levels = array('-1' => 'Choose student level first');
     $form->addDropBox('student_major', $levels);
     $form->setLabel('student_major', 'Major / Program');
     $form->addCssClass('student_major', 'form-control');
     // Undergrad major drop down
     if (isset($s)) {
         $majors = Major::getMajorsAssoc($s->ugrad_major);
     } else {
         $majors = Major::getMajorsAssoc();
     }
     $form->addSelect('ugrad_major', $majors);
     $form->setLabel('ugrad_major', 'Undergraduate Majors &amp; Certificate Programs');
     $form->setClass('ugrad_major', 'form-control');
     // Graduate major drop down
     if (isset($s)) {
         $progs = GradProgram::getGradProgsAssoc($s->grad_prog);
     } else {
         $progs = GradProgram::getGradProgsAssoc();
     }
     $form->addSelect('grad_prog', $progs);
     $form->setLabel('grad_prog', 'Graduate Majors &amp; Certificate Programs');
     $form->setClass('grad_prog', 'form-control');
     // Campus
     $campuses = array('main_campus' => 'Main Campus', 'distance_ed' => 'Distance Ed');
     $form->addRadioAssoc('campus', $campuses);
     /***************
      * Course Info *
      ***************/
     $subjects = Subject::getSubjects();
     $form->addSelect('course_subj', $subjects);
     $form->setLabel('course_subj', 'Subject');
     $form->setClass('course_subj', 'form-control');
     $form->addText('course_no');
     $form->setLabel('course_no', 'Course Number');
     $form->setSize('course_no', 6);
     $form->setMaxSize('course_no', 4);
     $form->setClass('course_no', 'form-control');
     $form->addText('course_sect');
     $form->setLabel('course_sect', 'Section');
     $form->setSize('course_sect', 6);
     $form->setMaxSize('course_sect', 4);
     $form->setClass('course_sect', 'form-control');
     // Internship types.
     $types = Internship::getTypesAssoc();
     $form->addRadioAssoc('type', $types);
     // Location
     $loc = array('domestic' => 'Domestic', 'internat' => 'International');
     $form->addRadioAssoc('loc', $loc);
     /* State search */
     $db = new PHPWS_DB('intern_state');
     $db->addWhere('active', 1);
     $db->addColumn('abbr');
     $db->addColumn('full_name');
     $db->setIndexBy('abbr');
     // get backwards because we flip it
     $db->addOrder('full_name desc');
     $states = $db->select('col');
     if (empty($states)) {
         NQ::simple('intern', INTERN_ERROR, 'The list of allowed US states for internship locations has not been configured. Please use the administrative options to <a href="index.php?module=intern&action=edit_states">add allowed states.</a>');
         NQ::close();
         PHPWS_Core::goBack();
     }
     $states[-1] = 'Select state';
     $states = array_reverse($states, true);
     $form->addSelect('state', $states);
     $form->setLabel('state', 'State');
     $form->setClass('state', 'form-control');
     /* Province search */
     $form->addText('prov');
     $form->setLabel('prov', 'Province/Territory');
     $form->setClass('prov', 'form-control');
     // Workflow states
     $workflowStates = WorkflowStateFactory::getStatesAssoc();
     unset($workflowStates['CreationState']);
     // Remove this state, since it's not valid (internal only state for initial creation)
     $form->addCheckAssoc('workflow_state', $workflowStates);
     unset($_REQUEST['module']);
     unset($_REQUEST['action']);
     unset($_REQUEST['submit']);
     //test($_REQUEST,1);
     $form->plugIn($_REQUEST);
     $form->addSubmit('submit', 'Search');
     // Javascript...
     javascript('jquery');
     javascriptMod('intern', 'resetSearch');
     return PHPWS_Template::process($form->getTemplate(), 'intern', 'search.tpl');
 }
コード例 #16
0
ファイル: Checkin_Admin.php プロジェクト: HaldunA/phpwebsite
 private function summaryReport()
 {
     javascript('datepicker');
     $form = new PHPWS_Form('report-date');
     $form->setMethod('get');
     $form->addHidden('module', 'checkin');
     $form->addHidden('aop', 'report');
     $form->addHidden('summary_report', 1);
     $form->addText('start_date', $_GET['start_date']);
     $form->setLabel('start_date', 'Start date');
     $form->setSize('start_date', 10);
     $form->setExtra('start_date', 'class="datepicker"');
     $form->addText('end_date', $_GET['end_date']);
     $form->setLabel('end_date', 'End date');
     $form->setSize('end_date', 10);
     $form->setExtra('end_date', 'class="datepicker"');
     if (!empty($_GET['visitor_name'])) {
         $name = trim(strip_tags($_GET['visitor_name']));
     } else {
         $name = null;
     }
     $form->addText('visitor_name', $name);
     $form->setLabel('visitor_name', 'Visitor name');
     $form->addSubmit(dgettext('checkin', 'Summary report'));
     $db = new PHPWS_DB('checkin_staff');
     $db->addColumn('checkin_staff.id');
     $db->addColumn('users.display_name');
     $db->addWhere('checkin_staff.user_id', 'users.id');
     $db->setIndexBy('id');
     $db->addOrder('users.display_name desc');
     $assigned = $db->select('col');
     $assigned[0] = dgettext('checkin', 'Show all');
     $assigned = array_reverse($assigned, true);
     $form->addSelect('assigned', $assigned);
     $form->setLabel('assigned', 'By staff');
     if (isset($_GET['assigned'])) {
         $staff_id = (int) $_GET['assigned'];
         $form->setMatch('assigned', $staff_id);
     } else {
         $staff_id = 0;
     }
     $tpl = $form->getTemplate();
     $start_date = strtotime($_GET['start_date']);
     $end_date = strtotime($_GET['end_date']);
     if (empty($start_date) || empty($end_date) || $start_date > $end_date) {
         $tpl['EMPTY'] = 'Please enter your date range again.';
     } else {
         $this->title = 'Visitors from ' . $_GET['start_date'] . ' to ' . $_GET['end_date'];
         $db = new PHPWS_DB('checkin_visitor');
         $db->addWhere('arrival_time', $start_date, '>=');
         $db->addWhere('arrival_time', $end_date, '<=');
         $db->addColumn('id');
         $db->addColumn('arrival_time');
         $db->addColumn('firstname');
         $db->addColumn('lastname');
         $db->addColumn('start_meeting');
         $db->addColumn('end_meeting');
         if ($staff_id) {
             $db->addWhere('assigned', $staff_id);
         }
         if (!empty($name)) {
             $name = strtolower($name);
             if (strlen($name) == 1) {
                 $db->addWhere('firstname', "{$name}%", 'like', 'and', 'name');
                 $db->addWhere('lastname', "{$name}%", 'like', 'or', 'name');
             } else {
                 $db->addWhere('firstname', "%{$name}%", 'like', 'and', 'name');
                 $db->addWhere('lastname', "%{$name}%", 'like', 'or', 'name');
             }
         }
         $result = $db->select();
         $total_visits = 0;
         $total_wait = 0;
         $total_meeting = 0;
         $total_days = 0;
         $incomplete_visits = 0;
         $current_day = null;
         foreach ($result as $visit) {
             extract($visit);
             $arrival_day = date('MdY', $arrival_time);
             if ($current_day != $arrival_day) {
                 $current_day = $arrival_day;
                 $total_days++;
             }
             $row = array();
             if (!$start_meeting || !$end_meeting) {
                 $incomplete_visits++;
                 continue;
             }
             $total_visits++;
             $twaited = $start_meeting - $arrival_time;
             $waited = Checkin::timeWaiting($twaited);
             if ($end_meeting) {
                 $tmeeting = $end_meeting - $start_meeting;
             }
             $meeting = Checkin::timeWaiting($tmeeting);
             $row['VISIT'] = $total_visits;
             $row['VISITOR'] = "{$firstname} {$lastname}";
             $row['DATE'] = date('g:ia m.d.Y', $arrival_time);
             $row['WAITED'] = $waited;
             $row['MEETING'] = $meeting;
             $tpl['rows'][] = $row;
             $total_wait += $twaited;
             $total_meeting += $tmeeting;
         }
         if ($total_visits) {
             $tpl['TOTAL_DAYS'] = $total_days;
             $tpl['TOTAL_VISITS'] = $total_visits;
             $tpl['AVG_VISITS'] = round($total_visits / $total_days, 1);
             $tpl['TOTAL_WAIT'] = Checkin::timeWaiting($total_wait);
             $tpl['TOTAL_MEETING'] = Checkin::timeWaiting($total_meeting);
             $tpl['AVG_WAIT'] = Checkin::timeWaiting(round($total_wait / $total_visits));
             $tpl['AVG_MEETING'] = Checkin::timeWaiting(round($total_meeting / $total_visits));
             $tpl['INCOMPLETE_MEETINGS'] = $incomplete_visits;
         } else {
             $tpl['EMPTY'] = 'No visits made in this date range.';
         }
     }
     $this->content = PHPWS_Template::process($tpl, 'checkin', 'summary_report.tpl');
 }