All Data Structures Functions Variables Pages
LeadConvertView.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  class LeadConvertView extends GridView
38  {
39  protected $cssClasses = array('DetailsView');
40 
41  protected $controllerId;
42 
43  protected $moduleId;
44 
45  protected $convertToAccountSetting;
46 
47  protected $title;
48 
49  protected $modelId;
50 
51  public function __construct(
52  $controllerId,
53  $moduleId,
54  $modelId,
55  $title,
56  $selectAccountform,
57  $account,
58  $convertToAccountSetting,
59  $userCanCreateAccount
60  )
61  {
62  assert('$convertToAccountSetting != LeadsModule::CONVERT_NO_ACCOUNT');
63  assert('is_bool($userCanCreateAccount)');
64 
65  //if has errors, then show by default
66  if ($selectAccountform->hasErrors())
67  {
68  Yii::app()->clientScript->registerScript('leadConvert', "
69  $(document).ready(function()
70  {
71  $('#AccountConvertToView').hide();
72  $('#LeadConvertAccountSkipView').hide();
73  $('#account-skip-title').hide();
74  $('#account-create-title').hide();
75  }
76  );
77  ");
78  }
79  else
80  {
81  if ($userCanCreateAccount)
82  {
83  Yii::app()->clientScript->registerScript('leadConvert', "
84  $(document).ready(function()
85  {
86  $('#AccountSelectView').hide();
87  $('#LeadConvertAccountSkipView').hide();
88  $('#account-skip-title').hide();
89  $('#account-select-title').hide();
90  }
91  );
92  ");
93  }
94  else
95  {
96  Yii::app()->clientScript->registerScript('leadConvert', "
97  $(document).ready(function()
98  {
99  $('#account-create-title').hide();
100  $('#AccountConvertToView').hide();
101  $('#LeadConvertAccountSkipView').hide();
102  $('#account-skip-title').hide();
103  }
104  );
105  ");
106  }
107  }
108  if ($convertToAccountSetting == LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED)
109  {
110  $gridSize = 3;
111  }
112  else
113  {
114  $gridSize = 2;
115  }
116  $title = Zurmo::t('LeadsModule', 'LeadsModuleSingularLabel Conversion',
118  parent::__construct($gridSize, 1);
119 
126  $this->setView(new AccountSelectView($controllerId, $moduleId, $modelId, $selectAccountform), 0, 0);
127  $this->setView(new AccountConvertToView($controllerId, $moduleId, $account, $modelId), 1, 0);
128 
129  if ($convertToAccountSetting == LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED)
130  {
131  $this->setView(new LeadConvertAccountSkipView($controllerId, $moduleId, $modelId), 2, 0);
132  }
133 
134  $this->controllerId = $controllerId;
135  $this->moduleId = $moduleId;
136  $this->modelId = $modelId;
137  $this->convertToAccountSetting = $convertToAccountSetting;
138  $this->userCanCreateAccount = $userCanCreateAccount;
139  $this->title = $title;
140  }
141 
146  protected function renderContent()
147  {
148  Yii::app()->clientScript->registerScript('leadConvertActions', "
149  $('.account-select-link').click( function()
150  {
151  $('#AccountConvertToView').hide();
152  $('#LeadConvertAccountSkipView').hide();
153  $('#AccountSelectView').show();
154  $('#account-create-title').hide();
155  $('#account-skip-title').hide();
156  $('#account-select-title').show();
157  return false;
158  }
159  );
160  $('.account-create-link').click( function()
161  {
162  $('#AccountConvertToView').show();
163  $('#LeadConvertAccountSkipView').hide();
164  $('#AccountSelectView').hide();
165  $('#account-create-title').show();
166  $('#account-skip-title').hide();
167  $('#account-select-title').hide();
168  return false;
169  }
170  );
171  $('.account-skip-link').click( function()
172  {
173  $('#AccountConvertToView').hide();
174  $('#LeadConvertAccountSkipView').show();
175  $('#AccountSelectView').hide();
176  $('#account-create-title').hide();
177  $('#account-skip-title').show();
178  $('#account-select-title').hide();
179  return false;
180  }
181  );
182  ");
183  $createLink = ZurmoHtml::link(Zurmo::t('AccountsModule', 'Create AccountsModuleSingularLabel',
184  LabelUtil::getTranslationParamsForAllModules()), '#', array('class' => 'account-create-link'));
185  $selectLink = ZurmoHtml::link(Zurmo::t('LeadsModule', 'Select AccountsModuleSingularLabel',
186  LabelUtil::getTranslationParamsForAllModules()), '#', array('class' => 'account-select-link'));
187  $skipLink = ZurmoHtml::link(Zurmo::t('LeadsModule', 'Skip AccountsModuleSingularLabel',
188  LabelUtil::getTranslationParamsForAllModules()), '#', array('class' => 'account-skip-link'));
189  $content = $this->renderTitleContent();
190  $content .= '<div class="lead-conversion-actions">';
191  $content .= '<div id="account-select-title">';
192  if ($this->userCanCreateAccount)
193  {
194  $content .= $createLink . '&#160;' . Zurmo::t('Core', 'or') . '&#160;';
195  }
196  $content .= Zurmo::t('LeadsModule', 'Select AccountsModuleSingularLabel',
198 
199  if ($this->convertToAccountSetting == LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED)
200  {
201  $content .= Zurmo::t('Core', 'or') . '&#160;' . $skipLink;
202  }
203  $content .= '</div>';
204  $content .= '<div id="account-create-title">';
205  $content .= Zurmo::t('AccountsModule', 'Create AccountsModuleSingularLabel',
207  $content .= Zurmo::t('Core', 'or') . '&#160;' . $selectLink . '&#160;';
208  if ($this->convertToAccountSetting == LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED)
209  {
210  $content .= Zurmo::t('Core', 'or') . '&#160;' . $skipLink;
211  }
212  $content .= '</div>';
213  if ($this->convertToAccountSetting == LeadsModule::CONVERT_ACCOUNT_NOT_REQUIRED)
214  {
215  $content .= '<div id="account-skip-title">';
216  if ($this->userCanCreateAccount)
217  {
218  $content .= $createLink . '&#160;' . Zurmo::t('Core', 'or') . '&#160;';
219  }
220  $content .= $selectLink . '&#160;' . Zurmo::t('Core', 'or') . '&#160;';
221  $content .= Zurmo::t('LeadsModule', 'Skip AccountsModuleSingularLabel',
223  $content .= '</div>';
224  }
225  $content .= '</div>'; //this was missing..
226  $content = $content . ZurmoHtml::tag('div', array('class' => 'left-column full-width clearfix'), parent::renderContent());
227  return '<div class="wrapper">' . $content . '</div>';
228  }
229 
230  public function isUniqueToAPage()
231  {
232  return true;
233  }
234  }
235 ?>
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
__construct($controllerId, $moduleId, $modelId, $title, $selectAccountform, $account, $convertToAccountSetting, $userCanCreateAccount)
setView(View $view, $row, $column)
Definition: GridView.php:94
Generated on Tue May 26 2020 07:10:32