public function test_set_provider() { $grid = new org_openpsa_widgets_grid('test', 'local'); $this->assertNull($grid->get_provider()); $provider = new org_openpsa_widgets_grid_provider(array()); $grid->set_provider($provider); $this->assertEquals($provider, $grid->get_provider()); }
public static function add_head_elements_for_invoice_grid() { $invoices_url = org_openpsa_core_siteconfig::get_instance()->get_node_full_url('org.openpsa.invoices'); org_openpsa_widgets_grid::add_head_elements(); midcom::get('head')->add_jscript('var INVOICES_URL ="' . $invoices_url . 'invoice/process/";'); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/org.openpsa.invoices/invoices.js'); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_today($handler_id, array $args, array &$data) { $this->user = midcom::get('auth')->user->get_storage(); if ($handler_id == 'today') { $data['requested_time'] = date('Y-m-d'); } else { // TODO: Check format as YYYY-MM-DD via regexp $data['requested_time'] = $args[0]; } $this->_master->calculate_day($data['requested_time']); $this->_populate_toolbar(); $data['title'] = strftime($data['requested_time']); midcom::get('head')->set_pagetitle($data['title']); // Add the JS file for workingon widget midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/jQuery/jquery.epiclock.min.js"); midcom_helper_datamanager2_widget_autocomplete::add_head_elements(); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . "/org.openpsa.mypage/mypage.js"); $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.mypage/mypage.css"); $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.core/list.css"); //needed js/css-files for jqgrid org_openpsa_widgets_grid::add_head_elements(); //set the start-constraints for journal-entries $time_span = 7 * 24 * 60 * 60; //7 days $this->_request_data['journal_constraints'] = array(array('property' => 'metadata.creator', 'operator' => '=', 'value' => midcom::get('auth')->user->guid), array('property' => 'followUp', 'operator' => '<', 'value' => $this->_request_data['day_start'] + $time_span), array('property' => 'followUp', 'operator' => '>', 'value' => 0), array('property' => 'closed', 'operator' => '=', 'value' => false)); }
public function _on_handle($handler, $args) { // Pass topic to handlers $this->_request_data['directory'] = new org_openpsa_documents_directory($this->_topic->id); $this->_request_data['enable_versioning'] = $this->_config->get('enable_versioning'); // Always run in uncached mode midcom::get('cache')->content->no_cache(); org_openpsa_widgets_grid::add_head_elements(); org_openpsa_widgets_ui::enable_dynatree(); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_view($handler_id, array $args, array &$data) { midcom::get('auth')->require_user_do('org.openpsa.user:access', null, 'org_openpsa_user_interface'); $this->_group = new midcom_db_group($args[0]); $data['group'] = $this->_group; $data['view'] = midcom_helper_datamanager2_handler::get_view_controller($this, $this->_group); org_openpsa_widgets_tree::add_head_elements(); org_openpsa_widgets_grid::add_head_elements(); $this->add_breadcrumb('groups/', $this->_l10n->get('groups')); $this->add_breadcrumb('', $this->_group->get_label()); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/edit/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("edit"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/delete/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get("delete"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:delete'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/privileges/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("permissions"), MIDCOM_TOOLBAR_ICON => 'midgard.admin.asgard/permissions-16.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:privileges'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "group/notifications/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get("notification settings"), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock-discussion.png', MIDCOM_TOOLBAR_ENABLED => $this->_group->can_do('midgard:update'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "create/{$this->_group->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create person'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_person-new.png', MIDCOM_TOOLBAR_ENABLED => midcom::get('auth')->can_user_do('midgard:create', null, 'org_openpsa_contacts_person_dba'))); $this->bind_view_to_object($this->_group); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_generator($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); $this->_generator_load_redirect($args); $this->set_active_leaf($this->_topic->id . ':generator_invoices'); $this->_handler_generator_style(); $data['start'] = $data['query_data']['start']; $data['end'] = $data['query_data']['end']; if (!isset($data['query_data']['date_field']) || $data['query_data']['date_field'] == '') { $data['query_data']['date_field'] = $data['query']->get_parameter('midcom.helper.datamanager2', 'date_field'); } $data['date_field'] = $data['query_data']['date_field']; $data['invoices'] = array(); foreach ($data['query_data']['invoice_status'] as $status) { $data['invoices'][$status] = $this->_load_invoices($status); } org_openpsa_widgets_grid::add_head_elements(); }
/** * The handler for the list view * * @param mixed $handler_id the array key from the request array * @param array $args the arguments given to the handler * @param Array &$data The local request data. */ public function _handler_list($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); // List hours $qb = org_openpsa_projects_hour_report_dba::new_query_builder(); $mode = 'full'; //url for batch_handler $this->_request_data['action_target_url'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "hours/task/batch/"; switch ($handler_id) { case 'list_hours': $this->_master->add_list_filter($qb); $data['view_title'] = $data['l10n']->get('hour reports'); $data['breadcrumb_title'] = $data['view_title']; break; case 'list_hours_task': $this->_master->add_list_filter($qb); // Fallthrough // Fallthrough case 'list_hours_task_all': $task = new org_openpsa_projects_task_dba($args[0]); $qb->add_constraint('task', '=', $task->id); $mode = 'simple'; $data['view_title'] = sprintf($data['l10n']->get($handler_id . " %s"), $task->title); $data['breadcrumb_title'] = $task->get_label(); $siteconfig = org_openpsa_core_siteconfig::get_instance(); $projects_url = $siteconfig->get_node_full_url('org.openpsa.projects'); if ($projects_url) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $projects_url . "task/{$task->guid}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n->get('show task %s'), $task->title), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/jump-to.png', MIDCOM_TOOLBAR_ACCESSKEY => 'g')); } break; } $qb->add_order('date', 'DESC'); $data['hours'] = $qb->execute(); $this->_load_hour_data($data['hours']); $data['mode'] = $mode; $data['tasks'] = $this->tasks; $data['qb'] = $qb; org_openpsa_widgets_grid::add_head_elements(); midcom_helper_datamanager2_widget_autocomplete::add_head_elements(); org_openpsa_widgets_contact::add_head_elements(); midcom::get('head')->set_pagetitle($data['view_title']); $this->add_breadcrumb('', $data['breadcrumb_title']); }
/** * The handler for the index view. * * @param mixed $handler_id the array key from the request array * @param array $args the arguments given to the handler * @param Array &$data The local request data. */ public function _handler_index($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); if (isset($args[0])) { $data['requested_time'] = $args[0]; } else { $data['requested_time'] = date('Y-m-d'); } $date = new DateTime($data['requested_time']); $offset = $date->format('N') - 1; $date->modify('-' . $offset . ' days'); $data['week_start'] = (int) $date->format('U'); $date->modify('+7 days -1 second'); $data['week_end'] = (int) $date->format('U'); $date->modify('+1 day'); $next_week = $date->format('Y-m-d'); $date->modify('-14 days'); $previous_week = $date->format('Y-m-d'); $hours_mc = org_openpsa_projects_hour_report_dba::new_collector('metadata.deleted', false); $hours_mc->add_value_property('task'); $hours_mc->add_value_property('hours'); $hours_mc->add_value_property('date'); $hours_mc->add_value_property('person'); $this->_master->add_list_filter($hours_mc); $hours_mc->add_constraint('date', '>=', $data['week_start']); $hours_mc->add_constraint('date', '<=', $data['week_end']); $hours_mc->add_order('task'); $hours_mc->add_order('date'); $hours_mc->execute(); $data['rows'] = $this->_get_sorted_reports($hours_mc); $this->_populate_toolbar($previous_week, $next_week); org_openpsa_widgets_grid::add_head_elements(); $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.expenses/expenses.css"); $this->add_breadcrumb('', sprintf($this->_l10n->get("expenses in week %s"), strftime("%V %G", $this->_request_data['week_start']))); midcom::get('head')->set_pagetitle(sprintf($this->_l10n->get("expenses in week %s"), strftime("%V %G", $this->_request_data['week_start']))); }
/** * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_callback($handler_id, array $args, array &$data) { if ($this->_mode == 'read') { $this->_count_invoice_hours(); org_openpsa_widgets_grid::add_head_elements(); $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.core/list.css"); } }
/** * Add toolbar items * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_callback($handler_id, array $args, array &$data) { $this->add_stylesheet(MIDCOM_STATIC_URL . "/midcom.helper.datamanager2/legacy.css"); if ($handler_id == 'project') { org_openpsa_widgets_grid::add_head_elements(); org_openpsa_widgets_contact::add_head_elements(); midcom::get('head')->add_jsfile(MIDCOM_STATIC_URL . '/org.openpsa.core/filter.js'); midcom::get('head')->add_stylesheet(MIDCOM_STATIC_URL . '/org.openpsa.core/filter.css'); } }
private function _convert_to_localdata() { return "var " . $this->_grid->get_identifier() . '_entries = ' . json_encode($this->get_rows()) . ";\n"; }
public function _handler_list($handler_id, $args, &$data) { if (isset($args[0])) { $this->_output_mode = $args[0]; } //output_mode different from html means we just want the data if ($this->_output_mode != 'html') { $this->qb_journal_entries = org_openpsa_relatedto_journal_entry_dba::new_query_builder(); $this->qb_journal_entries->add_order('followUp'); $this->_prepare_journal_query(); //show the corresponding object of the entry $this->_request_data['show_object'] = true; $this->_request_data['show_closed'] = false; $this->_request_data['page'] = 1; if (array_key_exists('show_closed', $_POST)) { $this->_request_data['show_closed'] = true; } $this->_request_data['entries'] = $this->qb_journal_entries->execute(); //get the corresponding objects if ($this->_request_data['show_object'] == true && !empty($this->_request_data['entries'])) { $this->_request_data['linked_objects'] = array(); $this->_request_data['linked_raw_objects'] = array(); foreach ($this->_request_data['entries'] as $entry) { if (array_key_exists($entry->linkGuid, $this->_request_data['linked_objects'])) { continue; } //create reflector with linked object to get the right label try { $linked_object = midcom::get('dbfactory')->get_object_by_guid($entry->linkGuid); } catch (midcom_error $e) { $e->log(); continue; } $reflector = new midcom_helper_reflector($linked_object); $link_html = "<a href='" . midcom::get('permalinks')->create_permalink($linked_object->guid) . "'>" . $reflector->get_object_label($linked_object) . "</a>"; $this->_request_data['linked_objects'][$entry->linkGuid] = $link_html; $this->_request_data['linked_raw_objects'][$entry->linkGuid] = $reflector->get_object_label($linked_object); } } //url_prefix to build the links to the entries $this->_request_data['url_prefix'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "__mfa/org.openpsa.relatedto/journalentry/"; } else { //url where the xml-data can be loaded $this->_request_data['data_url'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "__mfa/org.openpsa.relatedto/journalentry/list/xml/"; //enable jqgrid for html-output org_openpsa_widgets_grid::add_head_elements(); } $this->_prepare_header(); }
/** * function that loads the necessary javascript & css files for jqgrid */ public static function add_head_elements() { if (self::$_head_elements_added) { return; } $version = midcom_baseclasses_components_configuration::get('org.openpsa.widgets', 'config')->get('jqgrid_version'); $jqgrid_path = '/org.openpsa.widgets/jquery.jqGrid-' . $version . '/'; $head = midcom::get('head'); //first enable jquery - just in case it isn't loaded $head->enable_jquery(); $head->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.core.min.js'); //needed js/css-files for jqgrid $lang = "en"; $language = midcom::get('i18n')->get_current_language(); if (file_exists(MIDCOM_STATIC_ROOT . $jqgrid_path . 'js/i18n/grid.locale-' . $language . '.js')) { $lang = $language; } $head->add_jsfile(MIDCOM_STATIC_URL . $jqgrid_path . 'js/i18n/grid.locale-' . $lang . '.js'); $head->add_jsfile(MIDCOM_STATIC_URL . $jqgrid_path . 'js/jquery.jqGrid.min.js'); org_openpsa_widgets_ui::add_head_elements(); $head->add_jsfile(MIDCOM_STATIC_URL . '/org.openpsa.widgets/jqGrid.custom.js'); $head->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.widget.min.js'); $head->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.mouse.min.js'); $head->add_jsfile(MIDCOM_JQUERY_UI_URL . '/ui/jquery.ui.resizable.min.js'); $head->add_stylesheet(MIDCOM_STATIC_URL . $jqgrid_path . 'css/ui.jqgrid.css'); $head->add_stylesheet(MIDCOM_STATIC_URL . '/org.openpsa.widgets/jqGrid.custom.css'); $head->add_jquery_ui_theme(); self::$_head_elements_added = true; }
<?php $grid_id = 'hours_week'; $time = $data['week_start']; $date_columns = array(); $grid = new org_openpsa_widgets_grid($grid_id, 'local'); $grid->set_column('task', $data['l10n']->get('task'), '', 'string')->set_column('person', $data['l10n']->get('person')); $date_tooltips = array(); $i = 4; while ($time < $data['week_end']) { $date_identifier = date('Y-m-d', $time); $grid->set_column($date_identifier, strftime('%a', $time), 'fixed: true, width: 40, formatter: "number", formatoptions: {defaultValue: ""}, sorttype: "float", summaryType: calculate_subtotal, align: "right"'); // Hop to next day $date_columns[] = $date_identifier; $date_tooltips[$i++] = date($data['l10n_midcom']->get('short date'), $time); $time = $time + 3600 * 24; } $grid->set_option('footerrow', true)->set_option('grouping', true)->set_option('groupingView', array('groupField' => array('task'), 'groupColumnShow' => array(false), 'groupText' => array('<strong>{0}</strong> ({1})'), 'groupOrder' => array('asc'), 'groupSummary' => array(true), 'showSummaryOnHide' => true)); ?> <div class="area"> <?php $data['qf']->render(); echo midcom::get('i18n')->get_string('group by', 'org.openpsa.core') . ': '; echo '<select id="chgrouping_' . $grid_id . '">'; echo '<option value="task">' . $data['l10n']->get('task') . "</option>\n"; echo '<option value="person">' . $data['l10n']->get('person') . "</option>\n"; echo '<option value="clear">' . midcom::get('i18n')->get_string('no grouping', 'org.openpsa.core') . "</option>\n"; echo '</select>'; ?> </div>
private function _handle_list($args) { $guidgroup_qb = org_openpsa_products_product_group_dba::new_query_builder(); $guidgroup_qb->add_constraint('guid', '=', $args[0]); $groups = $guidgroup_qb->execute(); if (count($groups) > 0) { $categories_qb = org_openpsa_products_product_group_dba::new_query_builder(); $categories_qb->add_constraint('id', '=', $groups[0]->up); $categories = $categories_qb->execute(); if (count($categories) > 0) { $this->_request_data['parent_category'] = $categories[0]->code; } } else { //do not set the parent category. The category is already a top category. } org_openpsa_widgets_grid::add_head_elements(); }
public function _handler_list_user($handler_id, array $args, array &$data) { midcom::get('auth')->require_valid_user(); $this->_request_data['view'] = 'grid'; $this->_request_data['view_identifier'] = 'my_tasks'; $siteconfig = org_openpsa_core_siteconfig::get_instance(); $this->_request_data['contacts_url'] = $siteconfig->get_node_full_url('org.openpsa.contacts'); //get possible priorities from schema $this->_get_priorities(); $this->_provider = new org_openpsa_widgets_grid_provider($this, 'local'); $resource_statuses = array(org_openpsa_projects_task_status_dba::PROPOSED, org_openpsa_projects_task_status_dba::ACCEPTED, org_openpsa_projects_task_status_dba::STARTED, org_openpsa_projects_task_status_dba::REOPENED, org_openpsa_projects_task_status_dba::COMPLETED); $task_statuses = array(org_openpsa_projects_task_status_dba::PROPOSED, org_openpsa_projects_task_status_dba::DECLINED, org_openpsa_projects_task_status_dba::COMPLETED, org_openpsa_projects_task_status_dba::ONHOLD); $mc = org_openpsa_projects_task_resource_dba::new_collector('person', midcom_connection::get_user()); $mc->add_constraint('orgOpenpsaObtype', '=', ORG_OPENPSA_OBTYPE_PROJECTRESOURCE); $mc->add_constraint('task.orgOpenpsaObtype', '=', ORG_OPENPSA_OBTYPE_TASK); $mc->add_constraint('task.status', 'IN', $resource_statuses); $resource_tasks = $mc->get_values('task'); $this->_qb = org_openpsa_projects_task_dba::new_query_builder(); $this->_qb->add_constraint('orgOpenpsaObtype', '=', ORG_OPENPSA_OBTYPE_TASK); $this->_qb->begin_group('OR'); if (!empty($resource_tasks)) { //Get active tasks where user is a resource $this->_qb->add_constraint('id', 'IN', $resource_tasks); } //Get relevant tasks where user is manager $this->_qb->begin_group('AND'); $this->_qb->add_constraint('manager', '=', midcom_connection::get_user()); $this->_qb->add_constraint('status', 'IN', $task_statuses); $this->_qb->end_group(); $this->_qb->end_group(); org_openpsa_widgets_grid::add_head_elements(); }
/** * Special helper for adding the supported operations from read into the toolbar. * * @param mixed $handler_id The ID of the handler. */ private function _populate_read_toolbar($handler_id) { if (!$this->_object->can_do('midgard:update')) { return; } if ($this->_object->status == org_openpsa_projects_task_status_dba::CLOSED) { // TODO: Make POST request $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/{$this->_object->guid}/reopen/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('reopen'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/folder-expanded.png')); } else { if ($this->_object->status_type == 'ongoing') { // TODO: Make POST request $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/{$this->_object->guid}/complete/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('mark completed'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new_task.png')); } } $siteconfig = org_openpsa_core_siteconfig::get_instance(); $expenses_url = $siteconfig->get_node_full_url('org.openpsa.expenses'); if ($expenses_url) { midcom_helper_datamanager2_widget_autocomplete::add_head_elements(); org_openpsa_widgets_grid::add_head_elements(); if ($this->_object->status < org_openpsa_projects_task_status_dba::CLOSED) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $expenses_url . "hours/create/hour_report/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get('hour report')), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_new-event.png')); } $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $expenses_url . "hours/task/all/{$this->_object->guid}", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('hour reports'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/scheduled_and_shown.png', MIDCOM_TOOLBAR_ACCESSKEY => 'h')); } org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_object->guid); }
/** * Helper function to add needed css & js files */ private function _prepare_output() { $this->_request_data['prefix'] = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); //load js/css for jqgrid org_openpsa_widgets_grid::add_head_elements(); $this->add_stylesheet(MIDCOM_STATIC_URL . "/org.openpsa.documents/layout.css"); org_openpsa_widgets_contact::add_head_elements(); $this->_populate_toolbar(); }