39 public static function getDefaultMetadata()
43 'title' =>
"eval:Zurmo::t('AccountAccountAffiliationsModule',
44 'AccountsModuleSingularLabel Affiliations', LabelUtil::getTranslationParamsForAllModules())",
49 array(
'type' =>
'CreateFromRelatedListLink',
50 'routeModuleId' =>
'eval:$this->moduleId',
51 'routeParameters' =>
'eval:$this->getCreateLinkRouteParametersForPrimaryAccount()',
52 'label' =>
'eval:$this->getSelectPrimaryAccountLinkLabel()',
54 array(
'type' =>
'CreateFromRelatedListLink',
55 'routeModuleId' =>
'eval:$this->moduleId',
56 'routeParameters' =>
'eval:$this->getCreateLinkRouteParametersForSecondaryAccount()',
57 'label' =>
'eval:$this->getSelectSecondaryAccountLinkLabel()',
63 array(
'type' =>
'EditLink'),
64 array(
'type' =>
'RelatedDeleteLink'),
67 'derivedAttributeTypes' => array(
68 'AccountAccountAffiliationOppositeModel',
70 'gridViewType' => RelatedListView::GRID_VIEW_TYPE_STACKED,
78 array(
'attributeName' =>
'null',
79 'type' =>
'AccountAccountAffiliationOppositeModel'),
97 $searchAttributeData = array();
98 $searchAttributeData[
'clauses'] = array(
100 'attributeName' =>
'primaryAccount',
101 'relatedAttributeName' =>
'id',
102 'operatorType' =>
'equals',
103 'value' => (
int)$this->params[
'relationModel']->
id,
106 'attributeName' =>
'secondaryAccount',
107 'relatedAttributeName' =>
'id',
108 'operatorType' =>
'equals',
109 'value' => (
int)$this->params[
'relationModel']->
id,
112 $searchAttributeData[
'structure'] =
'(1 or 2)';
113 return $searchAttributeData;
116 protected function getCreateLinkRouteParametersForPrimaryAccount()
119 'relationAttributeName' =>
'secondaryAccount',
120 'relationModelId' => $this->params[
'relationModel']->
id,
121 'relationModuleId' => $this->params[
'relationModuleId'],
122 'redirectUrl' => $this->params[
'redirectUrl'],
126 protected function getCreateLinkRouteParametersForSecondaryAccount()
129 'relationAttributeName' =>
'primaryAccount',
130 'relationModelId' => $this->params[
'relationModel']->
id,
131 'relationModuleId' => $this->params[
'relationModuleId'],
132 'redirectUrl' => $this->params[
'redirectUrl'],
136 protected function getSelectPrimaryAccountLinkLabel()
138 return AccountAccountAffiliationsModule::resolveAccountRelationLabel(
'Singular',
'primary');
141 protected function getSelectSecondaryAccountLinkLabel()
143 return AccountAccountAffiliationsModule::resolveAccountRelationLabel(
'Singular',
'secondary');
156 public static function getAllowedOnPortletViewClassNames()
158 return array(
'AccountDetailsAndRelationsView');
161 public static function getModuleClassName()
163 return 'AccountAccountAffiliationsModule';
166 protected function getEmptyText()
168 return Zurmo::t(
'AccountContactAffiliationsModule',
169 'No AccountsModuleSingularLowerCaseLabel affiliations found',
179 return 'AccountAccountAffiliationsRelatedList';
182 public function renderPortletHeadContent()
184 return $this->renderActionContent();
187 protected function renderActionContent()
191 if ($actionElementContent != null)
193 $content .=
'<div class="view-toolbar-container toolbar-mbmenu clearfix"><div class="view-toolbar">';
194 $content .= $actionElementContent;
195 $content .=
'</div></div>';
200 public function getOppositeModelListViewString()
202 return 'AccountAccountAffiliationsRelatedListView::' .
203 'resolveOpposingAccountLinkContent($data, ' . (int)$this->params[
"relationModel"]->
id .
')';
206 public static function resolveOpposingAccountLinkContent(
AccountAccountAffiliation $accountAccountAffiliation, $accountId)
208 assert(
'is_int($accountId)');
209 if ($accountAccountAffiliation->primaryAccount->id == $accountId)
211 $content = static::resolveAccountWithLinkContent($accountAccountAffiliation->secondaryAccount);
212 $content .=
' ' . $accountAccountAffiliation->
getAttributeLabel(
'secondaryAccount');
216 $content = static::resolveAccountWithLinkContent($accountAccountAffiliation->primaryAccount);
217 $content .=
' ' . $accountAccountAffiliation->
getAttributeLabel(
'primaryAccount');
230 $moduleClassName = $account->getModuleClassName();
231 $linkRoute =
'/' . $moduleClassName::getDirectoryName() .
'/default/details';
233 $moduleClassName, $linkRoute);
236 $linkContent = $link;
238 return ZurmoHtml::tag(
'div', array(), $linkContent);
static getTranslationParamsForAllModules()
static canCurrentUserPerformAction($actionType, $model)
static resolveLinkToModelForCurrentUser($attributeString, $model, $moduleClassName, $linkRoute, $offset=null, $additionalParams=array())
getAttributeLabel($attributeName)