Ejemplo n.º 1
0
 public static function getNames()
 {
     $arr = Opportunity::model()->findAll();
     $names = array(0 => 'None');
     foreach ($arr as $opportunity) {
         $names[$opportunity->id] = $opportunity->name;
     }
     return $names;
 }
Ejemplo n.º 2
0
 /**
  * Get a data provider with contacts, opportunities, and accounts 
  */
 public function getStageMemberDataProviderMixed($workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, $modelType = '')
 {
     $dateRange = self::getDateRange();
     $expectedCloseDateDateRange = self::getDateRange('expectedCloseDateStart', 'expectedCloseDateEnd', 'expectedCloseDateRange');
     if (!is_numeric($workflowId) || !is_numeric($stage)) {
         return new CActiveDataProvider();
     }
     $records = array();
     $attrs = array();
     //        AuxLib::debugLogR ('$modelType = ');
     //        AuxLib::debugLogR ($modelType);
     //        AuxLib::debugLogR (gettype ( $modelType));
     //        AuxLib::debugLogR (strlen ($modelType));
     //        AuxLib::debugLogR ($modelType[0]);
     //        AuxLib::debugLogR ($modelType[1]);
     if (!empty($modelType)) {
         AuxLib::coerceToArray($modelType);
     }
     //        AuxLib::debugLogR ('$modelType = ');
     //        AuxLib::debugLogR ($modelType);
     // CActiveDataProviders are used for the purposes of reusing code.
     if (empty($modelType) || in_array('contacts', $modelType)) {
         $contactsDataProvider = $this->getStageMemberDataProvider('contacts', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
         $records['contacts'] = $contactsDataProvider->data;
         $attrs = array_merge($attrs, Contacts::model()->attributeNames());
     }
     if (empty($modelType) || in_array('opportunities', $modelType)) {
         $opportunitiesDataProvider = $this->getStageMemberDataProvider('opportunities', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
         $records['opportunities'] = $opportunitiesDataProvider->data;
         $attrs = array_merge($attrs, Opportunity::model()->attributeNames());
     }
     if (empty($modelType) || in_array('accounts', $modelType)) {
         $accountsDataProvider = $this->getStageMemberDataProvider('accounts', $workflowId, $dateRange, $expectedCloseDateDateRange, $stage, $users, false);
         $records['accounts'] = $accountsDataProvider->data;
         $attrs = array_merge($attrs, Accounts::model()->attributeNames());
     }
     // get union of attribute names
     $attrUnion = array_unique($attrs);
     $attrUnion[] = 'actionLastUpdated';
     // used to sort records
     $combinedRecords = Record::mergeMixedRecords($records, $attrUnion);
     /* 
     Sort records by the in descending order by the last time their associated workflow action 
     was updated. This allows Workflow stage listviews to be updated without reloading the 
     entire page. Every time a user drags a record from one stage to the next, placing that 
     record at the top of the target stage's list maintains the correct record ordering.
     */
     usort($combinedRecords, function ($a, $b) {
         if ($a['actionLastUpdated'] > $b['actionLastUpdated']) {
             return -1;
         } else {
             if ($a['actionLastUpdated'] < $b['actionLastUpdated']) {
                 return 1;
             } else {
                 return 0;
             }
         }
     });
     $dataProvider = new CArrayDataProvider($combinedRecords, array('pagination' => array('pageSize' => 20)));
     $dataProvider->pagination->route = '/workflow/workflow/view';
     $dataProvider->pagination->params = $_GET;
     unset($dataProvider->pagination->params['ajax']);
     return $dataProvider;
 }