public function testCreate() { midcom::get('auth')->request_sudo('org.openpsa.relatedto'); $invoice = $this->create_object('org_openpsa_invoices_invoice_dba'); $salesproject = $this->create_object('org_openpsa_sales_salesproject_dba'); $relatedto = org_openpsa_relatedto_plugin::create($invoice, 'org.openpsa.invoices', $salesproject, 'org.openpsa.sales'); $this->assertTrue(is_a($relatedto, 'org_openpsa_relatedto_dba')); $this->register_object($relatedto); $this->assertEquals($relatedto->status, org_openpsa_relatedto_dba::CONFIRMED); $this->assertEquals($relatedto->fromGuid, $invoice->guid); $this->assertEquals($relatedto->fromComponent, 'org.openpsa.invoices'); $this->assertEquals($relatedto->fromClass, 'org_openpsa_invoices_invoice_dba'); $this->assertEquals($relatedto->toGuid, $salesproject->guid); $this->assertEquals($relatedto->toComponent, 'org.openpsa.sales'); $this->assertEquals($relatedto->toClass, 'org_openpsa_sales_salesproject_dba'); $relatedto2 = org_openpsa_relatedto_plugin::create($invoice, 'org.openpsa.invoices', $salesproject, 'org.openpsa.sales'); $this->assertEquals($relatedto2->guid, $relatedto->guid); $x = null; $stat = org_openpsa_relatedto_plugin::create($x, 'org.openpsa.invoices', $salesproject, 'org.openpsa.sales'); $this->assertFalse($stat); $stat = org_openpsa_relatedto_plugin::create($invoice, 'org.openpsa.invoices', $x, 'org.openpsa.sales'); $this->assertFalse($stat); $relatedto2 = org_openpsa_relatedto_plugin::create($invoice, 'org.openpsa.invoices', $salesproject, 'org.openpsa.sales', org_openpsa_relatedto_dba::NOTRELATED); $this->assertEquals($relatedto2->guid, $relatedto->guid); $this->assertEquals($relatedto2->status, org_openpsa_relatedto_dba::NOTRELATED); $stat = $relatedto->delete(); $this->assertTrue($stat); midcom::get('auth')->drop_sudo(); }
private function _populate_toolbar() { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('view'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_left.png', MIDCOM_TOOLBAR_ACCESSKEY => 'v')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "edit/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e', MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:update'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "delete/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n_midcom']->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ACCESSKEY => 'd', MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:delete'))); foreach (array_keys($this->_request_data['schemadb']) as $name) { if ($name == $this->_datamanager->schema->name) { // The page is already of this type, skip continue; } $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "change/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => sprintf($this->_l10n->get('change to %s'), $this->_l10n->get($this->_request_data['schemadb'][$name]->description)), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_refresh.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('change_to' => $name), MIDCOM_TOOLBAR_ENABLED => $this->_page->can_do('midgard:update'))); } $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "whatlinks/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('what links'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/jump-to.png')); if (midcom::get('auth')->user) { $user = midcom::get('auth')->user->get_storage(); if ($this->_page->parameter('net.nemein.wiki:watch', $user->guid)) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "subscribe/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('unsubscribe'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('unsubscribe' => 1))); } else { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "subscribe/{$this->_page->name}/", MIDCOM_TOOLBAR_LABEL => $this->_request_data['l10n']->get('subscribe'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('subscribe' => 1))); } } if ($this->_page->can_do('midgard:update')) { midcom::get('head')->add_link_head(array('rel' => 'alternate', 'type' => 'application/x-wiki', 'title' => $this->_request_data['l10n_midcom']->get('edit'), 'href' => midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . "edit/{$this->_page->name}/")); } if (midcom::get('componentloader')->is_installed('org.openpsa.relatedto')) { org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_page->guid); } $this->bind_view_to_object($this->_page, $this->_datamanager->schema->name); }
public function _on_watched_dba_create($object) { $ret = array(); //Check if we have data in session, if so use that. $session = new midcom_services_session('org.openpsa.relatedto'); if ($session->exists('relatedto2get_array')) { $relatedto_arr = $session->get('relatedto2get_array'); $session->remove('relatedto2get_array'); } else { $relatedto_arr = org_openpsa_relatedto_plugin::get2relatedto(); } foreach ($relatedto_arr as $k => $rel) { $ret[$k] = array('stat' => false, 'method' => false, 'obj' => false); $rel->fromClass = get_class($object); $rel->fromGuid = $object->guid; if (!$rel->id) { $ret[$k]['method'] = 'create'; $ret[$k]['stat'] = $rel->create(); } else { //In theory we should not ever hit this, but better to be sure. $ret[$k]['method'] = 'update'; $ret[$k]['stat'] = $rel->update(); } $ret[$k]['obj'] = $rel; } }
public static function setUpBeforeClass() { self::$_object_from = self::create_class_object('org_openpsa_invoices_invoice_dba'); self::$_object_to = self::create_class_object('org_openpsa_sales_salesproject_dba'); midcom::get('auth')->request_sudo('org.openpsa.relatedto'); self::$_relation = org_openpsa_relatedto_plugin::create(self::$_object_from, 'org.openpsa.invoices', self::$_object_to, 'org.openpsa.sales'); midcom::get('auth')->drop_sudo(); }
/** * Display possible available resources * * @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_resourcing($handler_id, array $args, array &$data) { $this->_task = new org_openpsa_projects_task_dba($args[0]); $this->_task->require_do('midgard:create'); if (array_key_exists('org_openpsa_projects_prospects', $_POST) && $_POST['save']) { foreach ($_POST['org_openpsa_projects_prospects'] as $prospect_guid => $slots) { try { $prospect = new org_openpsa_projects_task_resource_dba($prospect_guid); } catch (midcom_error $e) { continue; } $update_prospect = false; foreach ($slots as $slotdata) { if (!array_key_exists('used', $slotdata) || empty($slotdata['used'])) { // Slot not selected, skip continue; } $prospect->orgOpenpsaObtype = ORG_OPENPSA_OBTYPE_PROJECTRESOURCE; $update_prospect = true; // Create event from slot $event = new org_openpsa_calendar_event_dba(); $event->start = $slotdata['start']; $event->end = $slotdata['end']; $event->search_relatedtos = false; $event->title = sprintf($this->_l10n->get('work for task %s'), $this->_task->title); if (!$event->create()) { // TODO: error reporting continue; } $participant = new org_openpsa_calendar_event_member_dba(); $participant->orgOpenpsaObtype = ORG_OPENPSA_OBTYPE_EVENTPARTICIPANT; $participant->uid = $prospect->person; $participant->eid = $event->id; $participant->create(); // create relatedto if (!org_openpsa_relatedto_plugin::create($event, 'org.openpsa.calendar', $this->_task, 'org.openpsa.projects')) { // TODO: delete event ??? } } } if ($update_prospect) { if (!$prospect->update()) { // TODO: error handling } } return new midcom_response_relocate("task/{$this->_task->guid}/"); } else { if (!empty($_POST['cancel'])) { return new midcom_response_relocate("task/{$this->_task->guid}/"); } } $this->_prepare_request_data($handler_id); midcom::get('head')->set_pagetitle($this->_task->title); $this->bind_view_to_object($this->_task); org_openpsa_projects_viewer::add_breadcrumb_path($data['task'], $this); $this->add_breadcrumb("task/resourcing/{$this->_task->guid}/", $this->_l10n->get('resourcing')); }
/** * Special helper for adding the supported operations from read into the toolbar. * * @param mixed $handler_id The ID of the handler. */ private function _add_read_toolbar($handler_id) { // Add toolbar items $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "project/edit/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "task/new/project/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create task'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/new_task.png', MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'))); $siteconfig = org_openpsa_core_siteconfig::get_instance(); $sales_url = $siteconfig->get_node_full_url('org.openpsa.sales'); if (!empty($sales_url)) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $sales_url . "salesproject/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('salesproject', 'org.openpsa.sales'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/jump-to.png')); } org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_object->guid); }
/** * Function to process the notify date in the passed formdata of the datamanger * creates/edits/deletes the corresponding at_entry if needed * * @param array $formdata The Formdata of the datamanager containing the notify_date * @param org_openpsa_sales_salesproject_deliverable_dba $deliverable The current deliverable */ public function process_notify_date($formdata, org_openpsa_sales_salesproject_deliverable_dba $deliverable) { //check if there is already an at_entry $mc_entry = org_openpsa_relatedto_dba::new_collector('toGuid', $deliverable->guid); $mc_entry->add_constraint('fromClass', '=', 'midcom_services_at_entry_dba'); $mc_entry->add_constraint('toClass', '=', 'org_openpsa_sales_salesproject_deliverable_dba'); $mc_entry->add_constraint('toExtra', '=', 'notify_at_entry'); $entry_keys = $mc_entry->get_values('fromGuid'); //check date if (!$formdata['notify']->is_empty()) { $notification_entry = null; if (count($entry_keys) == 0) { $notification_entry = new midcom_services_at_entry_dba(); $notification_entry->create(); //relatedto from notifcation to deliverable org_openpsa_relatedto_plugin::create($notification_entry, 'midcom.services.at', $deliverable, 'org.openpsa.sales', false, array('toExtra' => 'notify_at_entry')); } else { //get guid of at_entry foreach ($entry_keys as $key => $entry) { //check if related at_entry exists try { $notification_entry = new midcom_services_at_entry_dba($entry); } catch (midcom_error $e) { //relatedto links to a non-existing at_entry - so create a new one an link to it $notification_entry = new midcom_services_at_entry_dba(); $notification_entry->create(); $relatedto = new org_openpsa_relatedto_dba($key); $relatedto->fromGuid = $notification_entry->guid; $relatedto->update(); } break; } } $notification_entry->start = $formdata['notify']->value->format('U'); $notification_entry->method = 'new_notification_message'; $notification_entry->component = 'org.openpsa.sales'; $notification_entry->arguments = array('deliverable' => $deliverable->guid); $notification_entry->update(); } else { //void date - so delete existing at_entrys for this notify_date foreach ($entry_keys as $key => $empty) { try { $notification_entry = new midcom_services_at_entry_dba($mc_entry->get_subkey($key, 'fromGuid')); //check if related at_entry exists & delete it $notification_entry->delete(); } catch (midcom_error $e) { $e->log(); } } } }
/** * Simple helper which references all important members to the request data listing * for usage within the style listing. */ private function _prepare_request_data() { $this->_request_data['product'] =& $this->_product; $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "product/edit/{$this->_product->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_product->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "product/delete/{$this->_product->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_product->can_do('midgard:delete'))); if ($this->_config->get('enable_productlinks') && $this->_request_data['is_linked_from'] != '') { $product_link_guid = $this->_request_data['is_linked_from']; $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "productlink/{$product_link_guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('view productlink'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/view.png', MIDCOM_TOOLBAR_ENABLED => $this->_product->can_do('midgard:update'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "productlink/edit/{$product_link_guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit productlink'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_product->can_do('midgard:update'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "productlink/delete/{$product_link_guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete productlink'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_product->can_do('midgard:delete'))); } if (midcom::get('componentloader')->is_installed('org.openpsa.relatedto')) { org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_product->guid); } }
public function testHandler_edit() { midcom::get('auth')->request_sudo('org.openpsa.sales'); $deliverable_attributes = array('salesproject' => self::$_salesproject->id); $deliverable = $this->create_object('org_openpsa_sales_salesproject_deliverable_dba', $deliverable_attributes); $deliverable->set_parameter('midcom.helper.datamanager2', 'schema_name', 'subscription'); $year = date('Y') + 1; $start = strtotime($year . '-10-15 00:00:00'); $at_parameters = array('arguments' => array('deliverable' => $deliverable->guid, 'cycle' => 1), 'start' => $start, 'component' => 'org.openpsa.sales', 'method' => 'new_subscription_cycle'); $at_entry = $this->create_object('midcom_services_at_entry_dba', $at_parameters); org_openpsa_relatedto_plugin::create($at_entry, 'midcom.services.at', $deliverable, 'org.openpsa.sales'); $data = $this->run_handler('org.openpsa.sales', array('deliverable', 'edit', $deliverable->guid)); $this->assertEquals('deliverable_edit', $data['handler_id']); $group = $data['controller']->formmanager->form->getElement('next_cycle'); $this->assertTrue($group instanceof HTML_Quickform_group, ' next cycle widget missing'); $elements = $group->getElements(); $this->assertEquals($year . '-10-15', $elements[0]->getValue()); midcom::get('auth')->drop_sudo(); }
/** * Generate "Send invoice" task */ function generate_invoicing_task($invoicer) { try { $invoice_sender = new midcom_db_person($invoicer); } catch (midcom_error $e) { return; } $config = midcom_baseclasses_components_configuration::get('org.openpsa.invoices', 'config'); $task = new org_openpsa_projects_task_dba(); $task->get_members(); $task->resources[$invoice_sender->id] = true; $task->manager = midcom_connection::get_user(); // TODO: Connect the customer as the contact? $task->orgOpenpsaObtype = ORG_OPENPSA_OBTYPE_TASK; $task->title = sprintf(midcom::get('i18n')->get_string('send invoice %s', 'org.openpsa.invoices'), sprintf($config->get('invoice_number_format'), sprintf($config->get('invoice_number_format'), $this->number))); // TODO: Store link to invoice into description $task->end = time() + 24 * 3600; if ($task->create()) { org_openpsa_relatedto_plugin::create($task, 'org.openpsa.projects', $this, 'org.openpsa.invoices'); midcom::get('uimessages')->add(midcom::get('i18n')->get_string('org.openpsa.invoices', 'org.openpsa.invoices'), sprintf(midcom::get('i18n')->get_string('created "%s" task to %s', 'org.openpsa.invoices'), $task->title, $invoice_sender->name), 'ok'); } }
/** * Helper that populates the toolbar */ private function _populate_toolbar() { if ($this->_salesproject->can_do('midgard:update')) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "salesproject/edit/{$this->_salesproject->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ACCESSKEY => 'e')); } /*if ($this->_salesproject->can_do('midgard:delete')) { $this->_view_toolbar->add_item(Array( MIDCOM_TOOLBAR_URL => "salesproject/delete/{$this->_salesproject->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', )); }*/ if (!empty($this->_request_data['projects_url'])) { $prefix = midcom::get()->get_page_prefix() . $this->_request_data['projects_url']; $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $prefix . "project/{$this->_salesproject->guid}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('org.openpsa.projects', 'org.openpsa.projects'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/jump-to.png')); } $relatedto_button_settings = org_openpsa_relatedto_plugin::common_toolbar_buttons_defaults(); $relatedto_button_settings['wikinote']['wikiword'] = str_replace('/', '-', sprintf($this->_l10n->get($this->_config->get('new_wikinote_wikiword_format')), $this->_request_data['salesproject']->title, date('Y-m-d H:i'))); unset($relatedto_button_settings['task']); org_openpsa_relatedto_plugin::common_node_toolbar_buttons($this->_view_toolbar, $this->_request_data['salesproject'], $this->_component, $relatedto_button_settings); $this->bind_view_to_object($this->_salesproject); }
private function _prepare_request_data() { org_openpsa_relatedto_plugin::add_header_files(); $object_url = midcom::get('permalinks')->create_permalink($this->_object->guid); if ($object_url) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => $object_url, MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('back'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_left.png')); } // Load "Create X" buttons for all the related info $relatedto_button_settings = org_openpsa_relatedto_plugin::common_toolbar_buttons_defaults(); $ref = midcom_helper_reflector::get($this->_object); $class_label = $ref->get_class_label(); $object_label = $ref->get_object_label($this->_object); $relatedto_button_settings['wikinote']['wikiword'] = str_replace('/', '-', sprintf(midcom::get('i18n')->get_string('notes for %s %s on %s', 'org.openpsa.relatedto'), $class_label, $object_label, strftime('%x %H:%M'))); org_openpsa_relatedto_plugin::common_node_toolbar_buttons($this->_view_toolbar, $this->_object, $this->_request_data['topic']->component, $relatedto_button_settings); org_openpsa_relatedto_plugin::add_journal_entry_button($this->_view_toolbar, $this->_object->guid); $this->_request_data['object'] =& $this->_object; $this->_request_data['show_title'] = false; if ($this->_mode == 'both' || $this->_mode == 'both-paged') { $this->_request_data['show_title'] = true; } if ($object_url) { $this->add_breadcrumb($object_url, $object_label); } $this->add_breadcrumb("", $this->_l10n->get('view related information')); }
/** * 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); }
/** * Handle the single event view * * @param String $handler_id Name of the request handler * @param array $args Variable arguments * @param array &$data Public request data, passed by reference */ public function _handler_event($handler_id, array $args, array &$data) { // We're using a popup here midcom::get()->skip_page_style = true; // Get the requested event object $this->_request_data['event'] = new org_openpsa_calendar_event_dba($args[0]); // Muck schema on private events if (!$this->_request_data['event']->can_do('org.openpsa.calendar:read')) { foreach ($this->_datamanager->_schemadb as $schemaname => $schema) { foreach ($this->_datamanager->_schemadb[$schemaname]->fields as $fieldname => $field) { switch ($fieldname) { case 'title': case 'start': case 'end': break; default: $this->_datamanager->_schemadb[$schemaname]->fields[$fieldname]['hidden'] = true; } } } } // Load the event to datamanager if (!$this->_datamanager->autoset_storage($data['event'])) { throw new midcom_error('Failed to load the event in datamanager'); } // Reload parent if needed if (array_key_exists('reload', $_GET)) { midcom::get('head')->add_jsonload('window.opener.location.reload();'); } // Add toolbar items if ($this->_request_data['view'] == 'default') { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'event/edit/' . $this->_request_data['event']->guid . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $data['event']->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'event/delete/' . $this->_request_data['event']->guid . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $data['event']->can_do('midgard:delete'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => 'javascript:window.print()', MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('print'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/printer.png', MIDCOM_TOOLBAR_OPTIONS => array('rel' => 'directlink'))); $relatedto_button_settings = null; if (midcom::get('auth')->user) { $user = midcom::get('auth')->user->get_storage(); $relatedto_button_settings = array('wikinote' => array('node' => false, 'wikiword' => str_replace('/', '-', sprintf($this->_l10n->get($this->_config->get('wiki_title_skeleton')), $this->_request_data['event']->title, strftime('%x'), $user->name)))); } org_openpsa_relatedto_plugin::common_node_toolbar_buttons($this->_view_toolbar, $this->_request_data['event'], $this->_component, $relatedto_button_settings); } }
private function _populate_read_toolbar($handler_id) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/edit/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'), MIDCOM_TOOLBAR_ACCESSKEY => 'e')); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/delete/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png', MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:delete'))); $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/items/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('edit invoice items'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png', MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'))); if (!$this->_object->sent) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/process/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('mark sent'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail-reply.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('action' => 'mark_sent', 'id' => $this->_object->id, 'relocate' => true), MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'))); } else { if (!$this->_object->paid) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/process/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('mark paid'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/ok.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('action' => 'mark_paid', 'id' => $this->_object->id, 'relocate' => true), MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'))); } } if (!$this->_object->paid && $this->_config->get('invoice_pdfbuilder_class')) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/pdf/{$this->_object->guid}/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('create pdf'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/attach.png')); // sending per email enabled in billing data? $billing_data = $this->_object->get_billing_data(); if (intval($billing_data->sendingoption) == 2) { $this->_view_toolbar->add_item(array(MIDCOM_TOOLBAR_URL => "invoice/process/", MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('mark sent_per_mail'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_mail-reply.png', MIDCOM_TOOLBAR_POST => true, MIDCOM_TOOLBAR_POST_HIDDENARGS => array('action' => 'send_by_mail', 'id' => $this->_object->id, 'relocate' => true), MIDCOM_TOOLBAR_ENABLED => $this->_object->can_do('midgard:update'))); } } org_openpsa_relatedto_plugin::add_button($this->_view_toolbar, $this->_object->guid); $this->_master->add_next_previous($this->_object, $this->_view_toolbar, 'invoice/'); }
/** * @todo Check if we already have an open task for this delivery? */ function create_task($start, $end, $title, $source_task = null) { $salesproject = org_openpsa_sales_salesproject_dba::get_cached($this->_deliverable->salesproject); $product = org_openpsa_products_product_dba::get_cached($this->_deliverable->product); // Check if we already have a project for the sales project $project = $salesproject->get_project(); // Create the task $task = new org_openpsa_projects_task_dba(); $task->agreement = $this->_deliverable->id; $task->customer = $salesproject->customer; $task->title = $title; $task->description = $this->_deliverable->description; $task->start = $start; $task->end = $end; $task->plannedHours = $this->_deliverable->plannedUnits; $task->manager = $salesproject->owner; if ($project) { $task->project = $project->id; $task->orgOpenpsaAccesstype = $project->orgOpenpsaAccesstype; $task->orgOpenpsaOwnerWg = $project->orgOpenpsaOwnerWg; } if (!empty($source_task)) { $task->priority = $source_task->priority; $task->manager = $source_task->manager; } // TODO: Figure out if we really want to keep this $task->hoursInvoiceableDefault = true; if ($task->create()) { $task->add_members('contacts', array_keys($salesproject->contacts)); if (!empty($source_task)) { $source_task->get_members(); $task->add_members('resources', array_keys($source_task->resources)); } org_openpsa_relatedto_plugin::create($task, 'org.openpsa.projects', $product, 'org.openpsa.products'); // Copy tags from deliverable so we can seek resources $tagger = new net_nemein_tag_handler(); $tagger->copy_tags($this->_deliverable, $task); midcom::get('uimessages')->add(midcom::get('i18n')->get_string('org.openpsa.sales', 'org.openpsa.sales'), sprintf(midcom::get('i18n')->get_string('created task "%s"', 'org.openpsa.sales'), $task->title), 'ok'); return $task; } else { throw new midcom_error("The task for this cycle could not be created. Last Midgard error was: " . midcom_connection::get_error_string()); } }
function create_hour_report(&$task, $person_id, &$from_object, $from_component) { if (!midcom::get('dbfactory')->is_a($task, 'org_openpsa_projects_task_dba')) { debug_add('given task is not really a task', MIDCOM_LOG_ERROR); return false; } if (empty($person_id)) { debug_add('person_id is "empty"', MIDCOM_LOG_ERROR); return false; } //TODO: this should probably have privileges like midgard:owner set to $person_id $hr = new org_openpsa_projects_hour_report_dba(); $hr->task = $task->id; $hr->person = $person_id; $hr->invoiceable = $task->hoursInvoiceableDefault; switch (true) { case midcom::get('dbfactory')->is_a($from_object, 'org_openpsa_calendar_event_dba'): $event =& $from_object; $hr->date = $event->start; $hr->hours = round(($event->end - $event->start) / 3600, 2); // TODO: Localize ? better indicator that this is indeed from event ?? $hr->description = "event: {$event->title} " . $event->format_timeframe() . ", {$event->location}\n"; $hr->description .= "\n{$event->description}\n"; break; default: debug_add("class '" . get_class($from_object) . "' not supported", MIDCOM_LOG_ERROR); return false; } debug_print_r("about to create hour_report", $hr); $stat = $hr->create(); if (!$stat) { debug_add("failed to create hour_report to task #{$task->id} for person #{$person_id}", MIDCOM_LOG_ERROR); return false; } debug_add("created hour_report #{$hr->id}"); // Create a relatedtolink from hour_report to the object it was created from org_openpsa_relatedto_plugin::create($hr, 'org.openpsa.projects', $from_object, $from_component); return true; }