コード例 #1
0
ファイル: CompanysController.php プロジェクト: uzerpllp/uzerp
 public function view()
 {
     $company = $this->_templateobject;
     $companyidfield = $company->idField;
     $company->load($this->_data[$companyidfield], true);
     if (!$company->isLoaded()) {
         $flash = Flash::instance();
         $flash->addError('You do not have permission to view this contact.');
         sendTo($this->name, 'index', $this->_modules);
         return;
     }
     $companyid = $company->id;
     $partyid = $company->party_id;
     $sidebar = new SidebarController($this->view);
     // If we own it, we can do anything we like.
     $sidebar->addList('currently_viewing', array($company->name => array('tag' => $company->name, 'link' => array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view', $companyidfield => $company->{$companyidfield})), 'edit' => array('tag' => 'Edit', 'link' => array('module' => 'contacts', 'controller' => 'companys', 'action' => 'edit', $companyidfield => $company->{$companyidfield})), 'delete' => array('tag' => 'Delete', 'link' => array('module' => 'contacts', 'controller' => 'companys', 'action' => 'delete', $companyidfield => $companyid)), 'sharing' => array('tag' => 'Sharing', 'link' => array('module' => 'contacts', 'controller' => 'companys', 'action' => 'sharing', $companyidfield => $companyid, 'model' => 'Company'))));
     $sidebar->addList('related_items', array('branches' => array('tag' => 'Branches', 'link' => array('module' => 'contacts', 'controller' => 'companys', 'action' => 'viewbranches', 'parent_id' => $companyid), 'new' => array('module' => 'contacts', 'controller' => 'companys', 'action' => 'new', 'parent_id' => $companyid)), 'spacer', 'people' => array('tag' => 'People', 'link' => array('module' => 'contacts', 'controller' => 'persons', 'action' => 'viewcompany', 'company_id' => $companyid), 'new' => array('module' => 'contacts', 'controller' => 'persons', 'action' => 'new', 'company_id' => $companyid)), 'spacer', 'opportunities' => array('tag' => 'Opportunities', 'link' => array('module' => 'crm', 'controller' => 'opportunitys', 'action' => 'viewcompany', 'company_id' => $companyid), 'new' => array('module' => 'crm', 'controller' => 'opportunitys', 'action' => 'new', 'company_id' => $companyid)), 'activities' => array('tag' => 'Activities', 'link' => array('module' => 'crm', 'controller' => 'activitys', 'action' => 'viewcompany', 'company_id' => $companyid), 'new' => array('module' => 'crm', 'controller' => 'activitys', 'action' => 'new', 'company_id' => $companyid)), 'tickets' => array('tag' => 'Tickets', 'link' => array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'viewcompany', 'originator_company_id' => $companyid), 'new' => array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'new', 'originator_company_id' => $companyid)), 'spacer', 'projects' => array('tag' => 'Projects', 'link' => array('module' => 'projects', 'controller' => 'projects', 'action' => 'viewcompany', 'company_id' => $companyid), 'new' => array('module' => 'projects', 'controller' => 'projects', 'action' => 'new', 'company_id' => $companyid)), 'spacer', 'notes' => array('tag' => 'Notes', 'link' => array('module' => 'contacts', 'controller' => 'partynotes', 'action' => 'viewcompany', 'party_id' => $partyid), 'new' => array('module' => 'contacts', 'controller' => 'partynotes', 'action' => 'new', 'party_id' => $partyid)), 'spacer', 'attachments' => array('tag' => 'Attachments', 'link' => array('module' => 'contacts', 'controller' => 'companyattachments', 'action' => 'index', 'company_id' => $companyid), 'new' => array('module' => 'contacts', 'controller' => 'companyattachments', 'action' => 'new', 'data_model' => 'company', 'entity_id' => $companyid)), 'spacer', 'addresses' => array('tag' => 'Addresses', 'link' => array('module' => 'contacts', 'controller' => 'partyaddresss', 'action' => 'viewcompany', 'party_id' => $partyid), 'new' => array('module' => 'contacts', 'controller' => 'partyaddresss', 'action' => 'new', 'party_id' => $partyid)), 'spacer', 'phone' => array('tag' => 'Phone', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewcompany', 'party_id' => $partyid, 'type' => 'T'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $partyid, 'type' => 'T')), 'fax' => array('tag' => 'Fax', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewcompany', 'party_id' => $partyid, 'type' => 'F'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $partyid, 'type' => 'F')), 'email' => array('tag' => 'Email', 'link' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'viewcompany', 'party_id' => $partyid, 'type' => 'E'), 'new' => array('module' => 'contacts', 'controller' => 'partycontactmethods', 'action' => 'new', 'party_id' => $partyid, 'type' => 'E')), 'spacer', 'meetings' => array('tag' => 'Meetings', 'link' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'viewcompany', 'company_id' => $companyid), 'new' => array('module' => 'calendar', 'controller' => 'calendarevents', 'action' => 'new', 'company_id' => $companyid)), 'calls' => array('tag' => 'Calls', 'link' => array('module' => 'contacts', 'controller' => 'loggedcalls', 'action' => 'viewcompany', 'company_id' => $companyid), 'new' => array('module' => 'contacts', 'controller' => 'loggedcalls', 'action' => 'new', 'company_id' => $companyid))));
     $ao =& AccessObject::Instance(EGS_USERNAME);
     if ($ao->hasPermission('crm')) {
         $this->view->set('crm_access', true);
     }
     $category = DataObjectFactory::Factory('CompanyInCategories');
     $this->view->set('categories', implode(',', $category->getCategorynames($company->id)));
     $current_categories = $category->getCategoryID($company->{$company->idField});
     $ledger_category = DataObjectFactory::Factory('LedgerCategory');
     foreach ($ledger_category->getCompanyTypes($current_categories) as $model_name => $model_detail) {
         $do = DataObjectFactory::Factory($model_name);
         $do->loadBy('company_id', $company->{$company->idField});
         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', 'company_id' => $company->{$company->idField}))));
         }
     }
     if ($company instanceof Company) {
         $pl = new PreferencePageList('recently_viewed_companies' . EGS_COMPANY_ID);
         $pl->addPage(new Page(array('module' => 'contacts', 'controller' => $this->name, 'action' => 'view', $company->idField => $companyid), 'company', $company->name));
         $pl->save();
     }
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $this->view->set('page_title', $this->getPageName('Company'));
 }
コード例 #2
0
ファイル: PersonsController.php プロジェクト: uzerpllp/uzerp
 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();
     }
 }
コード例 #3
0
ファイル: TasksController.php プロジェクト: uzerpllp/uzerp
 public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $task = $this->_uses[$this->modeltype];
     if (!$task->isLoaded()) {
         $flash = Flash::Instance();
         $flash->addError("The selected task does not exist");
         sendTo('tasks', 'index', array('projects'));
     }
     $sidebar = new SidebarController($this->view);
     //		$sidebar->addList(
     //			'Actions',
     //			array(
     //				'new_task'=>array(
     //					'link'=>array('modules'=>$this->_modules,'controller'=>$this->name,'action'=>'new'),
     //					'tag'=>'new_task'
     //				)
     //			)
     //		);
     $sidebar->addList('currently_viewing', array($task->name => array('tag' => $task->name, 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $task->id)), 'edit' => array('tag' => 'Edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $task->id)), 'delete' => array('tag' => 'Delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $task->id)), 'mark_as_complete' => array('tag' => 'Mark as Complete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'complete', 'id' => $task->id))));
     //		$sidebar->addList(
     //			'Calendars',
     //			array(
     //				'day_view'=>array(
     //					'link'=>array('module'=>'calendar','controller'=>'index','action'=>'dayview'),
     //					'tag'=>'day_view'
     //				),
     //				'week_view'=>array(
     //					'link'=>array('module'=>'calendar','controller'=>'index','action'=>'weekview'),
     //					'tag'=>'week_view'
     //				),
     //				'month_view'=>array(
     //					'link'=>array('module'=>'calendar','controller'=>'index','action'=>'monthview'),
     //					'tag'=>'month_view'
     //				)
     //			)
     //		);
     $this->sidebarRelatedItems($sidebar, $task);
     $sidebarlist['view_task_totals'] = array('tag' => 'view_task_totals', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'viewproject_totals', 'id' => $task->id));
     $sidebar->addList('related_items', $sidebarlist);
     // Need to add equipment hours for tasks that use equipment
     // This needs a link rule?
     //		$equipment_id = $task->equipment_id;
     //		if (isset($equipment_id)) {
     //			$related_items['equipmenthours'] = array(
     //				'tag'=>'Equipment Hours',
     //				'link'=>array('module'=>'projects','controller'=>'hours','action'=>'viewproject','project_id'=>$task->project_id),
     //				'new'=>array('module'=>'projects','controller'=>'hours','action'=>'newequipment','project_id'=>$task->project_id,'task_id'=>$task->id)
     //			);
     //		}
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     if ($task instanceof Task) {
         $pl = new PreferencePageList('recently_viewed_tasks');
         $pl->addPage(new Page(array('module' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $task->id), 'task', $task->name));
         $pl->save();
     }
 }
コード例 #4
0
ファイル: ProjectsController.php プロジェクト: uzerpllp/uzerp
 public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $project = $this->_uses[$this->modeltype];
     $db =& DB::Instance();
     $query = 'select id from projectsoverview where id =' . $db->qstr($project->id) . ' AND usernameaccess=' . $db->qstr(EGS_USERNAME);
     $has_permission = $db->GetCol($query);
     if ($has_permission === false && !isModuleAdmin() && $project->owner != EGS_USERNAME) {
         $flash = Flash::Instance();
         $flash->addError('You do not have permission to view that project');
         sendTo($this->name, 'index', $this->_modules);
     }
     $viewing_sidebar = array($project->name => array('tag' => $project->name, 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $project->id)), 'edit' => array('tag' => 'Edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $project->id)), 'delete' => array('tag' => 'Delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $project->id)), 'mark_as_complete' => array('tag' => 'Mark as Complete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'complete', 'id' => $project->id)), 'time-shift' => array('tag' => 'time-shift', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'timeshift', 'id' => $project->id)));
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Actions', array('view' => array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index'), 'tag' => 'view_projects'), 'new' => array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new'), 'tag' => 'new_project')));
     $sidebar->addList('currently_viewing', $viewing_sidebar);
     $this->sidebarRelatedItems($sidebar, $project);
     $sidebarlist['view_project_totals'] = array('tag' => 'view_project_totals', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'viewproject_totals', 'id' => $project->id));
     $sidebar->addList('related_items', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     if ($project instanceof Project) {
         $pl = new PreferencePageList('recently_viewed_projects');
         $pl->addPage(new Page(array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', 'id' => $project->id), 'task', $project->name));
         $pl->save();
     }
 }
コード例 #5
0
ファイル: LeadsController.php プロジェクト: uzerpllp/uzerp
 public function converttoaccount()
 {
     $company = $this->_uses['Lead'];
     if (isset($this->_data['Lead']) && isset($this->_data['Lead'][$company->idField])) {
         $id = $this->_data['Lead'][$company->idField];
         $data = $this->_data['Lead'];
     } elseif (isset($this->_data[$company->idField])) {
         $id = $this->_data[$company->idField];
     } else {
         $flash = Flash::Instance();
         $flash->addError('Select a Lead to convert');
         sendTo('leads', 'index', array('contacts'));
     }
     $company->load($id);
     if (!$company->isLoaded()) {
         $flash = Flash::instance();
         $flash->addError('You do not have permission to edit this lead.');
         sendTo($this->name, 'index', $this->_modules);
         return;
     }
     $pl = new PreferencePageList('recently_viewed_leads' . EGS_COMPANY_ID);
     $pl->removePage(new Page(array('module' => 'contacts', 'controller' => 'leads', 'action' => 'view', 'id' => $company->id), 'company', $company->name));
     $pl->save();
     $pl = new PreferencePageList('recently_viewed_companies' . EGS_COMPANY_ID);
     $pl->addPage(new Page(array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view', 'id' => $company->id), 'company', $company->name));
     $pl->save();
     $system_prefs = SystemPreferences::instance();
     $autoGenerate = $system_prefs->getPreferenceValue('auto-account-numbering', 'contacts');
     if (!(empty($autoGenerate) || $autoGenerate === 'off')) {
         $company->update($id, array('is_lead', 'accountnumber'), array('false', $company->createAccountNumber()));
         sendTo('companys', 'view', array('contacts'), array('id' => $company->id));
     } else {
         if (isset($data['accountnumber'])) {
             $company->update($id, array('is_lead', 'accountnumber'), array('false', $data['accountnumber']));
             sendTo('companys', 'view', array('contacts'), array('id' => $company->id));
         } else {
             parent::_new();
         }
     }
 }