public function get_row(midcom_core_dbaobject $invoice) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $number = $invoice->get_label(); $link_html = "<a href='{$prefix}invoice/{$invoice->guid}/'>" . $number . "</a>"; if ($number == "") { $number = "n/a"; } $entry['id'] = $invoice->id; $entry['index_number'] = $number; $entry['number'] = $link_html; if (!is_a($this->_customer, 'org_openpsa_contacts_group_dba')) { try { $customer = org_openpsa_contacts_group_dba::get_cached($invoice->customer); $entry['customer'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$customer->guid}/\">" . $customer->get_label() . "</a>"; } catch (midcom_error $e) { $entry['customer'] = ''; } } if (!is_a($this->_customer, 'org_openpsa_contacts_person_dba')) { try { $contact = org_openpsa_contacts_person_dba::get_cached($invoice->customerContact); $entry['contact'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$contact->guid}/\">" . $contact->get_label() . "</a>"; } catch (midcom_error $e) { $entry['contact'] = ''; } } if (!empty($this->_request_data['deliverable'])) { $constraints = array('invoice' => $invoice->id, 'deliverable' => $this->_request_data['deliverable']->id); $item_sum = org_openpsa_invoices_invoice_item_dba::get_sum($constraints); $this->_request_data['totals']['deliverable'] += $item_sum; $entry['index_item_sum'] = $item_sum; $entry['item_sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($item_sum / 100 * $invoice->vat + $item_sum) . '">' . org_openpsa_helpers::format_number($item_sum) . '</span>'; } $entry['index_sum'] = $invoice->sum; $entry['sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($invoice->sum / 100 * $invoice->vat + $invoice->sum) . '">' . org_openpsa_helpers::format_number($invoice->sum) . '</span>'; $entry['due'] = ''; if ($invoice->due > 0) { $entry['due'] = strftime('%Y-%m-%d', $invoice->due); } $colname = 'action'; if ($this->_list_type == 'paid') { $colname = 'paid'; } $entry[$colname] = $this->_master->render_invoice_actions($invoice); return $entry; }
public function get_customer() { try { $customer = org_openpsa_contacts_group_dba::get_cached($this->customer); } catch (midcom_error $e) { try { $customer = org_openpsa_contacts_person_dba::get_cached($this->customerContact); } catch (midcom_error $e) { $customer = null; $e->log(); } } return $customer; }
/** * * @param mixed $handler_id The ID of the handler. * @param array &$data The local request data. */ public function _show_group_memberships($handler_id, array &$data) { // This is most likely a dynamic_load if (count($data['memberships']) > 0) { midcom_show_style("show-person-groups-header"); foreach ($data['memberships'] as $member) { try { $data['group'] = org_openpsa_contacts_group_dba::get_cached($member->gid); if ($data['group']->orgOpenpsaObtype == org_openpsa_contacts_group_dba::MYCONTACTS) { continue; } } catch (midcom_error $e) { $e->log(); continue; } $data['member'] = $member; if ($member->extra == "") { $member->extra = $this->_l10n->get('<title>'); } $data['member_title'] = $member->extra; midcom_show_style("show-person-groups-item"); } midcom_show_style("show-person-groups-footer"); } else { midcom_show_style("show-person-groups-empty"); } }
/** * List customer contact's groups */ private function _populate_schema_customers_for_contact($contact_id) { $fields =& $this->_schemadb['default']->fields; $organizations = array(); $member_mc = org_openpsa_contacts_member_dba::new_collector('uid', $contact_id); $member_mc->add_constraint('gid.orgOpenpsaObtype', '>', org_openpsa_contacts_group_dba::MYCONTACTS); $groups = $member_mc->get_values('gid'); foreach ($groups as $group) { try { $organization = org_openpsa_contacts_group_dba::get_cached($group); $organizations[$organization->id] = $organization->official; } catch (midcom_error $e) { } } //Fill the customer field to DM $fields['customer']['type_config']['options'] = $organizations; }
} } try { $owner = org_openpsa_contacts_person_dba::get_cached($invoice->owner); $entry['owner'] = $owner->name; } catch (midcom_error $e) { $entry['owner'] = ''; $e->log(); } if ($invoice->{$data['date_field']} > 0) { $entry['date'] = strftime('%Y-%m-%d', $invoice->{$data['date_field']}); } else { $entry['date'] = ''; } try { $customer = org_openpsa_contacts_group_dba::get_cached($invoice->customer); $entry['index_customer'] = $customer->official; if ($data['invoices_url']) { $entry['customer'] = "<a href=\"{$data['invoices_url']}list/customer/all/{$customer->guid}/\" title=\"{$customer->name}: {$customer->official}\">{$customer->official}</a>"; } else { $entry['customer'] = $customer->official; } } catch (midcom_error $e) { $entry['customer'] = ''; $entry['index_customer'] = ''; } $entry['index_contact'] = ''; $entry['contact'] = ''; try { $contact = org_openpsa_contacts_person_dba::get_cached($invoice->customerContact); $entry['index_contact'] = $contact->rname;
private function _show_groups() { if (!$this->show_groups || empty($this->contact_details['id'])) { return; } $mc = org_openpsa_contacts_member_dba::new_collector('uid', $this->contact_details['id']); $mc->add_constraint('gid.orgOpenpsaObtype', '>=', org_openpsa_contacts_group_dba::ORGANIZATION); $mc->add_value_property('gid'); $mc->add_value_property('extra'); $mc->execute(); $memberships = $mc->list_keys(); if ($memberships) { foreach ($memberships as $guid => $empty) { try { $group = org_openpsa_contacts_group_dba::get_cached($mc->get_subkey($guid, 'gid')); } catch (midcom_error $e) { $e->log(); continue; } echo "<li class=\"org\">"; if ($mc->get_subkey($guid, 'extra')) { echo "<span class=\"title\">" . $mc->get_subkey($guid, 'extra') . "</span>, "; } if ($group->official) { $group_label = $group->official; } else { $group_label = $group->name; } if ($this->link_contacts) { if (!self::$_contacts_url) { $this->link_contacts = false; } else { $group_label = "<a href=\"" . self::$_contacts_url . "group/{$group->guid}/\">{$group_label}</a>"; } } echo "<span class=\"organization-name\">{$group_label}</span>"; echo "</li>\n"; } } }
private function _process_member($member) { $adder = array(); $adder['campaign_member'] = $member; try { $adder['person'] = org_openpsa_contacts_person_dba::get_cached($member->person); } catch (midcom_error $e) { $e->log(); return false; } $qb_memberships = midcom_db_member::new_query_builder(); $qb_memberships->add_constraint('uid', '=', $member->person); $memberships = $qb_memberships->execute_unchecked(); if (!is_array($memberships) || count($memberships) == 0) { return $adder; } switch ($this->membership_mode) { case 'all': foreach ($memberships as $k2 => $membership) { $adder['organization_member'] = $membership; try { $adder['organization'] = org_openpsa_contacts_group_dba::get_cached($membership->gid); } catch (midcom_error $e) { debug_add("Error fetching org_openpsa_contacts_group_dba #{$membership->gid}, skipping", MIDCOM_LOG_WARN); return false; } return $adder; } break; default: // Fall-trough intentional // Fall-trough intentional case 'first': // Fall-trough intentional // Fall-trough intentional case 'last': foreach ($memberships as $k2 => $membership) { $adder['organization_member'] = $membership; try { $adder['organization'] = org_openpsa_contacts_group_dba::get_cached($membership->gid); } catch (midcom_error $e) { debug_add("Error fetching org_openpsa_contacts_group_dba #{$membership->gid}, skipping", MIDCOM_LOG_WARN); return false; } // Get only first or last membership if ($this->membership_mode != 'last') { break; } } return $adder; break; } }
/** * Prepares user data for JSON display */ public function get_row(midcom_core_dbaobject $user) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $entry['id'] = $user->id; $lastname = trim($user->lastname); if (empty($lastname)) { $lastname = $this->_l10n->get('person') . ' #' . $user->id; } $entry['lastname'] = "<a href='" . $prefix . 'view/' . $user->guid . "/'>" . $lastname . "</a>"; $entry['index_lastname'] = $user->lastname; $entry['firstname'] = "<a href='" . $prefix . 'view/' . $user->guid . "/' >" . $user->firstname . "</a>"; $entry['index_firstname'] = $user->firstname; $account = new midcom_core_account($user); $entry['username'] = $account->get_username(); $entry['groups'] = array(); //get groups $mc_member = org_openpsa_contacts_member_dba::new_collector('uid', $user->id); $mc_member->add_constraint('gid.orgOpenpsaObtype', '<', org_openpsa_contacts_group_dba::MYCONTACTS); $mc_member->add_order('gid.official'); $mc_member->add_order('gid.name'); $gids = $mc_member->get_values('gid'); foreach ($gids as $gid) { try { $group = org_openpsa_contacts_group_dba::get_cached($gid); $entry['groups'][] = '<a href="' . $prefix . 'group/' . $group->guid . '/">' . $group->get_label() . '</a>'; } catch (midcom_error $e) { $e->log(); } } $entry['groups'] = implode(', ', $entry['groups']); return $entry; }
/** * * @param mixed $handler_id The ID of the handler. * @param array &$data The local request data. */ public function _show_uninvoiced($handler_id, array &$data) { $siteconfig = org_openpsa_core_siteconfig::get_instance(); $data['projects_url'] = $siteconfig->get_node_full_url('org.openpsa.projects'); midcom_show_style('show-projects-header'); foreach ($this->_customers as $customer_id => $tasks) { $data['customer'] = $customer_id; try { $customer = org_openpsa_contacts_group_dba::get_cached($customer_id); $data['customer_label'] = $customer->official; $data['disabled'] = ''; } catch (midcom_error $e) { $data['customer_label'] = $this->_l10n->get('no customer'); $data['disabled'] = ' disabled="disabled"'; } midcom_show_style('show-projects-customer-header'); $class = "even"; foreach ($tasks as $task) { $data['task'] = $task; if ($class == "even") { $class = ""; } else { $class = "even"; } $data['class'] = $class; $data['reported_hours'] = $task->reportedHours; try { $deliverable = new org_openpsa_sales_salesproject_deliverable_dba($task->agreement); $deliverable->calculate_price(false); $data['default_price'] = $deliverable->pricePerUnit; if ($deliverable->invoiceByActualUnits) { $data['invoiceable_units'] = $task->invoiceableHours; } else { $data['invoiceable_units'] = $task->plannedHours; } } catch (midcom_error $e) { $e->log(); if ($this->_config->get('default_hourly_price')) { $data['default_price'] = $this->_config->get('default_hourly_price'); $data['invoiceable_units'] = $task->invoiceableHours; } else { $data['default_price'] = ''; } } midcom_show_style('show-projects-customer-task'); } midcom_show_style('show-projects-customer-footer'); } midcom_show_style('show-projects-footer'); }
/** * Used by check_all_xxx() -method to walk the QB result and checking each against the rest */ private static function _check_all_arraywalk(&$arr1, $key1, &$params) { $finder =& $params['finder']; $ret =& $params['ret']; $objects =& $params['objects']; $p_method = "p_duplicate_{$params['mode']}"; if (!method_exists($finder, $p_method)) { debug_add("method {$p_method} is not valid, invalid mode string ??", MIDCOM_LOG_ERROR); return false; } foreach ($objects as $key2 => $arr2) { if ($arr1['guid'] == $arr2['guid']) { continue; } //we've already examined this combination from the other end if ($key2 < $key1) { if (isset($ret['p_map'][$arr2['guid']][$arr1['guid']]) && is_array($ret['p_map'][$arr2['guid']][$arr1['guid']])) { if (!isset($ret['p_map'][$arr1['guid']]) || !is_array($ret['p_map'][$arr1['guid']])) { $ret['p_map'][$arr1['guid']] = array(); } $ret['p_map'][$arr1['guid']][$arr2['guid']] = $ret['p_map'][$arr2['guid']][$arr1['guid']]; } continue; } $p_arr = $finder->{$p_method}($arr1, $arr2); if ($p_arr['p'] < $ret['threshold']) { continue; } if ($params['mode'] != 'person' && $params['mode'] != '') { //TODO: error reporting continue; } try { $obj1 = org_openpsa_contacts_group_dba::get_cached($arr1['guid']); $obj2 = org_openpsa_contacts_group_dba::get_cached($arr2['guid']); } catch (midcom_error $e) { $e->log(); continue; } if (!empty($obj1->guid) && $obj1->get_parameter('org.openpsa.contacts.duplicates:not_duplicate', $obj2->guid) || !empty($obj1->guid) && $obj2->get_parameter('org.openpsa.contacts.duplicates:not_duplicate', $obj1->guid)) { // Not-duplicate parameter found, returning zero probability continue; } $ret['objects'][$arr1['guid']] = $obj1; $ret['objects'][$arr2['guid']] = $obj2; if (!isset($ret['p_map'][$arr1['guid']]) || !is_array($ret['p_map'][$arr1['guid']])) { $ret['p_map'][$arr1['guid']] = array(); } $map =& $ret['p_map'][$arr1['guid']]; $map[$arr2['guid']] = $p_arr; } }
<?php $project =& $data['object']; $project->get_members(); $view = $data['object_view']; $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $nap = new midcom_helper_nav(); $node = $nap->get_node($nap->get_current_node()); ?> <div class="sidebar"> <?php try { $customer = org_openpsa_contacts_group_dba::get_cached($project->customer); echo "<h2>" . $data['l10n']->get('customer') . "</h2>\n"; $customer_html = $customer->official; $siteconfig = org_openpsa_core_siteconfig::get_instance(); $contacts_url = $siteconfig->get_node_full_url('org.openpsa.contacts'); if ($contacts_url) { $customer_html = '<a href="' . $contacts_url . '/group/' . $customer->guid . '/">' . $customer_html . "</a>\n"; } echo $customer_html; } catch (midcom_error $e) { } if ($project->manager) { echo "<h2>" . $data['l10n']->get('manager') . "</h2>\n"; $contact = org_openpsa_widgets_contact::get($project->manager); echo $contact->show_inline(); } else { if (count($project->resources) > 0) { echo "<h2>" . $data['l10n']->get('resources') . "</h2>\n"; foreach ($project->resources as $contact_id => $display) {