public function view()
 {
     $newsletter = $this->_uses['Newsletter'];
     $newsletter->load($this->_data['id']) or sendBack();
     $sidebar = new SidebarController($this->view);
     $sidebar->addCurrentBox('currently_viewing', $newsletter->name, array('module' => 'crm', 'controller' => 'newsletters', 'action' => 'edit', 'id' => $newsletter->id));
     $sidebar->addList('related_items', array('views' => array('tag' => 'Views', 'link' => array('module' => 'crm', 'controller' => 'newsletters', 'action' => 'showviews', 'newsletter_id' => $newsletter->id)), 'clicks' => array('tag' => 'Clicks', 'link' => array('module' => 'crm', 'controller' => 'newsletters', 'action' => 'showclicks', 'newsletter_id' => $newsletter->id))));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
 public function view()
 {
     $flash = Flash::Instance();
     $event = $this->_uses['CalendarEvent'];
     $event->load($this->_data['id']);
     if ($event->private == 't' && $event->owner != EGS_USERNAME) {
         $flash->addError("Cannot view a private event");
         sendBack();
     }
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Actions', array('new_event' => array('link' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'new'), 'tag' => 'new_event')));
     if ($event->owner == EGS_USERNAME) {
         $sidebar->addCurrentBox('currently_viewing', $event->summary, array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'edit', 'id' => $event->id));
     }
     $sidebar->addList('calendar_views', array('new_event' => array('link' => array('module' => 'calendar'), 'tag' => 'View Calendar')));
     $sidebar->addList('related_items', array('attachments' => array('tag' => 'Attachments', 'link' => array('module' => 'calendar', 'controller' => 'calendareventattachments', 'action' => 'index', 'entity_id' => $event->id), 'new' => array('module' => 'calendar', 'controller' => 'calendareventattachments', 'action' => 'new', 'entity_id' => $event->id))));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Exemple #3
0
 public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $person = $this->_uses[$this->modeltype];
     $person_id = $person->{$person->idField};
     $party_id = $person->party_id;
     $company = DataObjectFactory::Factory('Company');
     $slcustomer = DataObjectFactory::Factory('SLCustomer');
     if ($person->isLoaded()) {
         $company->load($person->company_id);
         $slcustomer->loadBy('company_id', $person->company_id);
     }
     if (!$person->isLoaded()) {
         $flash = Flash::instance();
         $flash->addError('You do not have permission to view this person.');
         sendTo($this->name, 'index', $this->_modules);
         return;
     }
     $sidebar = new SidebarController($this->view);
     // Need loose coupling method - use person categories?
     $employee = DataObjectFactory::Factory('Employee');
     $employee->loadBy('person_id', $person_id);
     if ($employee->isLoaded()) {
         $sidebar->addList('currently_viewing', array('view' => array('tag' => 'view ' . $person->fullname, 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $person_id))));
     } else {
         $sidebar->addCurrentBox('currently_viewing', $person->fullname, array('module' => 'contacts', 'controller' => 'persons', 'id' => $person->id));
     }
     $items = array();
     $ao = AccessObject::Instance();
     if ($ao->hasPermission('crm')) {
         $items += array('opportunities' => array('tag' => 'Opportunities', 'link' => array('module' => 'crm', 'controller' => 'opportunitys', 'action' => 'viewperson', 'person_id' => $person_id), 'new' => array('module' => 'crm', 'controller' => 'opportunitys', 'action' => 'new', 'person_id' => $person_id)), 'activities' => array('tag' => 'Activities', 'link' => array('module' => 'crm', 'controller' => 'activitys', 'action' => 'viewperson', 'person_id' => $person_id), 'new' => array('module' => 'crm', 'controller' => 'activitys', 'action' => 'new', 'person_id' => $person_id)));
     }
     if ($ao->hasPermission('ticketing')) {
         $items += array('tickets' => array('tag' => 'Tickets', 'link' => array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'viewcompany', 'originator_person_id' => $person_id), 'new' => array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'new', 'originator_person_id' => $person_id)));
     }
     if (isModuleAdmin('projects')) {
         $items += array('resource_template' => array('tag' => 'Resource Template', 'link' => array('module' => 'projects', 'controller' => 'resourcetemplate', 'action' => 'viewperson', 'person_id' => $person_id), 'new' => array('module' => 'projects', 'controller' => 'resourcetemplate', 'action' => 'new', 'person_id' => $person_id)));
     }
     $items += array('spacer', 'notes' => array('tag' => 'Notes', 'link' => array('module' => 'contacts', 'controller' => 'partynotes', 'action' => 'viewperson', 'party_id' => $party_id), 'new' => array('module' => 'contacts', 'controller' => 'partynotes', 'action' => 'new', 'party_id' => $party_id)), 'spacer', 'attachments' => array('tag' => 'Attachments', 'link' => array('module' => 'contacts', 'controller' => 'personattachments', 'action' => 'index', 'person_id' => $person_id), 'new' => array('module' => 'contacts', 'controller' => 'personattachments', 'action' => 'new', 'data_model' => 'person', 'entity_id' => $person_id)), 'spacer', 'addresses' => array('tag' => 'Addresses', 'link' => array('module' => 'contacts', 'controller' => 'partyaddresss', 'action' => 'viewperson', 'party_id' => $party_id), 'new' => array('module' => 'contacts', 'controller' => 'partyaddresss', 'action' => 'new', 'party_id' => $party_id)), 'spacer', 'phone' => array('tag' => 'Phone', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewperson', 'party_id' => $party_id, 'type' => 'T'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $party_id, 'type' => 'T')), 'mobile' => array('tag' => 'Mobile', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewperson', 'party_id' => $party_id, 'type' => 'M'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $party_id, 'type' => 'M')), 'fax' => array('tag' => 'Fax', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewperson', 'party_id' => $party_id, 'type' => 'F'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $party_id, 'type' => 'F')), 'email' => array('tag' => 'Email', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewperson', 'party_id' => $party_id, 'type' => 'E'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $party_id, 'type' => 'E')), 'spacer', 'meetings' => array('tag' => 'Meetings', 'link' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'viewperson', 'person_id' => $person_id), 'new' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'new', 'person_id' => $person_id)), 'calls' => array('tag' => 'Calls', 'link' => array('module' => 'contacts', 'controller' => 'loggedcalls', 'action' => 'viewperson', 'person_id' => $person_id), 'new' => array('module' => 'contacts', 'controller' => 'loggedcalls', 'action' => 'new', 'person_id' => $person_id)));
     if ($slcustomer->isLoaded()) {
         $items += array('sorders' => array('tag' => 'Sales Orders/Quotes', 'link' => array('module' => 'sales_order', 'controller' => 'sorders', 'action' => 'viewperson', 'person_id' => $person_id), 'new' => array('module' => 'sales_order', 'controller' => 'sorders', 'action' => 'new', 'person_id' => $person_id, 'slmaster_id' => $slcustomer->id)));
     }
     $sidebar->addList('related_items', $items);
     $category = DataObjectFactory::Factory('peopleInCategories');
     $this->view->set('categories', implode(',', $category->getCategorynames($person_id)));
     $current_categories = $category->getCategoryID($person_id);
     $ledger_category = DataObjectFactory::Factory('LedgerCategory');
     foreach ($ledger_category->getPersonTypes($current_categories) as $model_name => $model_detail) {
         $do = DataObjectFactory::Factory($model_name);
         $do->loadBy('person_id', $person_id);
         if ($do->isLoaded()) {
             $sidebar->addList('related_items', array($model_name => array('tag' => $do->getTitle(), 'link' => array('module' => $model_detail['module'], 'controller' => $model_detail['controller'], 'action' => 'view', $do->idField => $do->{$do->idField}))));
         } else {
             $sidebar->addList('related_items', array($model_name => array('tag' => $do->getTitle(), 'new' => array('module' => $model_detail['module'], 'controller' => $model_detail['controller'], 'action' => 'new', 'person_id' => $person->{$person->idField}))));
         }
     }
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $category = DataObjectFactory::Factory('PeopleInCategories');
     $this->view->set('categories', implode(',', $category->getCategorynames($person_id)));
     if ($person instanceof Person) {
         $pl = new PreferencePageList('recently_viewed_people' . EGS_COMPANY_ID);
         $pl->addPage(new Page(array('module' => 'contacts', 'controller' => 'persons', 'action' => 'view', 'id' => $person_id), 'person', $person->firstname . ' ' . $person->surname));
         $pl->save();
     }
 }