/**
  * @param RedBeanModel $model
  * @return null
  */
 public static function getModuleClassNameByModel(RedBeanModel $model)
 {
     if (!LeadsUtil::isStateALead($model->state)) {
         return 'ContactsModule';
     }
     return 'LeadsModule';
 }
 protected static function resolveModuleClassName($attribute, ReportResultsRowData $data)
 {
     if (get_class($data->getModel($attribute)) == 'Contact' && LeadsUtil::isStateALead($data->getModel($attribute)->state)) {
         return 'LeadsModule';
     } else {
         return $data->getModel($attribute)->getModuleClassName();
     }
 }
 protected function makeNonEditableLinkUrl()
 {
     if (LeadsUtil::isStateALead($this->resolveState())) {
         $moduleId = 'leads';
     } else {
         $moduleId = static::$moduleId;
     }
     return Yii::app()->createUrl($moduleId . '/' . $this->controllerId . '/details/', array('id' => $this->model->{$this->attribute}->id));
 }
예제 #4
0
 /**
  * Special handling for modules that use 'states' for their models. Currently only the Contacts/Leads modules
  * have this characteristic. This method will need to be expanding to dynamically inspect the modules and
  * resolve the state information without needing a hard coded if clause asking if the module class name is
  * 'Contacts'.
  * @return string of the module directory name.
  */
 public static function resolveModuleClassNameByStateOfModel(RedBeanModel $model)
 {
     $modelClassName = get_class($model);
     $moduleClassName = $modelClassName::getModuleClassName();
     if ($moduleClassName == 'ContactsModule') {
         if (LeadsUtil::isStateALead($model->state)) {
             return 'LeadsModule';
         }
     }
     return $moduleClassName;
 }
 public function scoreOnSaveModel(CEvent $event)
 {
     if (Yii::app()->gameHelper->isScoringModelsOnSaveMuted()) {
         return;
     }
     if (!LeadsUtil::isStateALead($event->sender->state) && array_key_exists('state', $event->sender->originalAttributeValues) && $event->sender->originalAttributeValues['state'][1] > 0 && LeadsUtil::isStateALeadByStateName($event->sender->originalAttributeValues['state'][2])) {
         $this->scoreOnSaveWhereLeadIsConverted($event);
     } elseif (LeadsUtil::isStateALead($event->sender->state)) {
         $this->scoreOnSaveWhereStateIsLead($event);
     } else {
         parent::scoreOnSaveModel($event);
     }
 }
 /**
  * @param Contact $contact
  * @return string
  */
 protected static function resolveModuleClassName(Contact $contact)
 {
     if (LeadsUtil::isStateALead($contact->state)) {
         return 'LeadsModule';
     } else {
         return $contact->getModuleClassName();
     }
 }
 public function actionDelete($id)
 {
     $contact = Contact::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($contact);
     if (!LeadsUtil::isStateALead($contact->state)) {
         $urlParams = array('/contacts/' . $this->getId() . '/delete', 'id' => $contact->id);
         $this->redirect($urlParams);
     } else {
         $contact->delete();
         $this->redirect(array($this->getId() . '/index'));
     }
 }
 public static function getResolvedModuleIdForContactWebFormEntry(Contact $contact)
 {
     if (LeadsUtil::isStateALead($contact->state)) {
         return 'leads';
     }
     return 'contacts';
 }
 protected function renderGoToDetailsLink()
 {
     if ($this->haveGoToDetailsLink) {
         if (get_class($this->model) == 'User') {
             $link = Yii::app()->createUrl('users/default/details/', array('id' => $this->model->id));
         } elseif (LeadsUtil::isStateALead($this->model->state)) {
             $link = Yii::app()->createUrl('leads/default/details/', array('id' => $this->model->id));
         } else {
             $link = Yii::app()->createUrl('contacts/default/details/', array('id' => $this->model->id));
         }
         return ZurmoHtml::link(Zurmo::t('ZurmoModule', 'Go To Details'), $link, array('class' => 'simple-link', 'target' => '_blank'));
     }
 }
예제 #10
0
 public function testIsStateALead()
 {
     $allContactStates = ContactState::GetAll();
     $this->assertGreaterThan(1, count($allContactStates));
     foreach ($allContactStates as $contactState) {
         if ($contactState->id < ContactsUtil::getStartingStateId()) {
             $isStateALeadCorrect = true;
         } else {
             $isStateALeadCorrect = false;
         }
         $isStateALead = LeadsUtil::isStateALead($contactState);
         $this->assertEquals($isStateALead, $isStateALeadCorrect);
     }
 }
예제 #11
0
 /**
  * If contact is lead then just return companyName field
  * If contact is contact and do not have related account, return company name
  * If contact is contact and have related account, return account name
  * @param Contact $contact
  * @return string
  */
 public static function resolveCompanyNameForRelatedAccountName(Contact $contact)
 {
     if (LeadsUtil::isStateALead($contact->state) || !isset($contact->account) || $contact->account->id <= 0) {
         return $contact->companyName;
     } elseif (isset($contact->account) && $contact->account->id > 0) {
         try {
             $companyName = $contact->account->name;
         } catch (AccessDeniedSecurityException $e) {
             $companyName = $contact->companyName;
         }
         return $companyName;
     } else {
         return null;
     }
 }