Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
PersonCardViewLayout.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
37 
42  {
43  public function __construct($model, $haveGoToDetailsLink = false)
44  {
45  assert('$model instanceof Item');
46  assert('is_bool($haveGoToDetailsLink)');
47  $this->model = $model;
48  $this->haveGoToDetailsLink = $haveGoToDetailsLink;
49  }
50 
51  protected function renderFrontOfCardContent()
52  {
53  $content = $this->resolveAvatarContent();
54  $content .= $this->resolveNameContent();
55  $content .= $this->resolveBackOfCardLinkContent();
56  $content .= $this->resolveJobTitleContent();
57  $content .= $this->resolveDepartmentAndAccountContent();
58  $content .= $this->resolveGenderAndAgeContent();
59  $content .= $this->resolveSocialConnectorsContent();
60  $content .= $this->resolvePhoneAndEmailContent();
61  $content .= $this->resolveAddressContent();
62  return $content;
63  }
64 
65  protected function resolveAvatarContent()
66  {
67  $content = Yii::app()->dataEnhancer->getPersonAvatar($this->model);
68  if ($content == null)
69  {
70  $htmlOptions = array('class' => 'gravatar', 'width' => '100', 'height' => '100');
71  $url = Yii::app()->theme->baseUrl . '/images/offline_user.png';
72  $content = ZurmoHtml::image($url, strval($this->model), $htmlOptions);
73  }
74  return $content;
75  }
76 
77  protected function resolveNameContent()
78  {
79  $element = new DropDownElement($this->model, 'title', null);
80  $element->nonEditableTemplate = '{content}';
81  $starLink = null;
82  $spanContent = null;
83  if (StarredUtil::modelHasStarredInterface($this->model))
84  {
85  $starLink = StarredUtil::getToggleStarStatusLink($this->model, null);
86  }
87  $salutation = $element->render();
88  if ($salutation != null)
89  {
90  $spanContent = ZurmoHtml::tag('span', array('class' => 'salutation'), $element->render());
91  }
92  return ZurmoHtml::tag('h2', array(), $spanContent . strval($this->model) . $starLink . $this->renderGoToDetailsLink());
93  }
94 
95  protected function renderGoToDetailsLink()
96  {
97  if ($this->haveGoToDetailsLink)
98  {
99  if (get_class($this->model) == 'User')
100  {
101  $link = Yii::app()->createUrl('users/default/details/', array('id' => $this->model->id));
102  }
103  elseif (LeadsUtil::isStateALead($this->model->state))
104  {
105  $link = Yii::app()->createUrl('leads/default/details/', array('id' => $this->model->id));
106  }
107  else
108  {
109  $link = Yii::app()->createUrl('contacts/default/details/', array('id' => $this->model->id));
110  }
111  return ZurmoHtml::link(Zurmo::t('ZurmoModule', 'Go To Details'), $link, array('class' => 'simple-link', 'target' => '_blank'));
112  }
113  }
114 
115  protected function resolveBackOfCardLinkContent()
116  {
117  if (Yii::app()->dataEnhancer->personHasBackOfCard($this->model))
118  {
119  static::registerBackOfCardScript();
120  $spanContent = ZurmoHtml::tag('span', array('class' => 'show'), Yii::app()->dataEnhancer->getPersonBackOfCardLabel());
121  $spanContent .= ZurmoHtml::tag('span', array(), Yii::app()->dataEnhancer->getPersonBackOfCardCloseLabel());
122  $content = ZurmoHtml::link($spanContent, '#', array('class' => 'toggle-back-of-card-link mini-button clearfix'));
123  return $content;
124  }
125  }
126 
127  protected function resolveJobTitleContent()
128  {
129  if ($this->model->jobTitle != null)
130  {
131  $content = ZurmoHtml::tag('h3', array('class' => 'position'), $this->model->jobTitle);
132  return $content;
133  }
134  }
135 
136  protected function resolveDepartmentAndAccountContent()
137  {
138  $departmentAndAccountContent = null;
139  if ($this->model->department != null)
140  {
141  $departmentAndAccountContent = $this->model->department;
142  }
143  if ($this->model instanceof Contact && $this->model->account->id > 0)
144  {
145  if ($departmentAndAccountContent != null)
146  {
147  $departmentAndAccountContent .= ' / ';
148  }
149  $departmentAndAccountContent .= static:: resolveAccountContentByUser($this->model->account, Yii::app()->user->userModel);
150  }
151  elseif ($this->model instanceof Contact)
152  {
153  if ($departmentAndAccountContent != null && $this->model->companyName != null)
154  {
155  $departmentAndAccountContent .= ' / ' . $this->model->companyName;
156  }
157  elseif ($departmentAndAccountContent == null && $this->model->companyName != null)
158  {
159  $departmentAndAccountContent = $this->model->companyName;
160  }
161  }
162  if ($departmentAndAccountContent != null)
163  {
164  return ZurmoHtml::tag('h4', array('class' => 'position'), $departmentAndAccountContent);
165  }
166  }
167 
168  protected function resolveGenderAndAgeContent()
169  {
170  $demographicContent = Yii::app()->dataEnhancer->getPersonDemographicViewContent($this->model);
171  if ($demographicContent != null)
172  {
173  return ZurmoHtml::tag('div', array('class' => 'demographic-details'), $demographicContent);
174  }
175  }
176 
177  protected function resolveSocialConnectorsContent()
178  {
179  $socialContent = Yii::app()->dataEnhancer->getPersonSocialNetworksViewContent($this->model);
180  if ($socialContent != null)
181  {
182  return ZurmoHtml::tag('div', array('class' => 'social-details'), $socialContent);
183  }
184  }
185 
186  protected function resolvePhoneAndEmailContent()
187  {
188  $content = null;
189  if ($this->model->officePhone != null)
190  {
191  $content .= Yii::app()->phoneHelper->resolvePersonCardViewOfficePhoneNumberContent($this->model->officePhone,
192  $this->model);
193  }
194  if ($this->model->mobilePhone != null)
195  {
196  $content .= Yii::app()->phoneHelper->resolvePersonCardViewMobilePhoneNumberContent($this->model->mobilePhone,
197  $this->model);
198  }
199  if ($this->model->primaryEmail->emailAddress != null)
200  {
202  $this->model->primaryEmail->emailAddress, $this->model);
203  $content .= ZurmoHtml::tag('span', array('class' => 'icon-email'), $emailContent);
204  }
205  if ($content != null)
206  {
207  return ZurmoHtml::tag('div', array('class' => 'contact-details'), $content);
208  }
209  }
210 
211  protected function resolveAddressContent()
212  {
213  $element = new AddressElement($this->model, 'primaryAddress', null);
214  $element->breakLines = false;
215  $element->nonEditableTemplate = '{content}';
216  return ZurmoHtml::tag('div', array('class' => 'address'), $element->render());
217  }
218 
219  protected function renderBackOfCardContent()
220  {
221  $backOfCardContent = Yii::app()->dataEnhancer->getPersonBackOfCardViewContent($this->model);
222  if ($backOfCardContent != null)
223  {
224  return ZurmoHtml::tag('div', array('class' => 'back-of-card clearfix'), $backOfCardContent);
225  }
226  }
227 
228  protected static function registerBackOfCardScript()
229  {
230  $script = "
231  $('.toggle-back-of-card-link').click(function()
232  {
233  $('span', this).slideToggle();
234  $('.back-of-card').slideToggle();
235  return false;
236  });";
237  Yii::app()->getClientScript()->registerScript('backOfCardScript', $script);
238  }
239 
240  protected static function resolveAccountContentByUser(Account $account, User $user)
241  {
242  $userCanAccess = RightsUtil::canUserAccessModule('AccountsModule', $user);
243  $userCanReadItem = ActionSecurityUtil::canUserPerformAction('Details', $account, $user);
244  if ($userCanAccess && $userCanReadItem)
245  {
246  return ZurmoHtml::link(Yii::app()->format->text($account), Yii::app()->createUrl('accounts/default/details/',
247  array('id' => $account->id)));
248  }
249  elseif (!$userCanAccess && $userCanReadItem)
250  {
251  return strval($account);
252  }
253  else
254  {
255  return;
256  }
257  }
258  }
259 ?>
static renderEmailAddressAsMailToOrModalLinkStringContent($emailAddress, RedBeanModel $model)
Definition: User.php:37
static isStateALead(ContactState $state)
Definition: LeadsUtil.php:234
static canUserAccessModule($moduleClassName, $user)
Definition: RightsUtil.php:103
static canUserPerformAction($actionType, $model, $user)
Generated on Tue Jul 7 2020 07:10:38
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.