Beispiel #1
0
 public function setOpportunities($query)
 {
     $opportunity = new Opportunity();
     for ($i = 0; $i < count($query); $i++) {
         if ($query[$i]['name'] == 'id') {
             $opportunity->setId($query[$i]['value']);
         }
         if ($query[$i]['name'] == 'num_lmb_fact_c') {
             $opportunity->setnumfact($query[$i]['value']);
         }
         if ($query[$i]['name'] == 'sales_stage') {
             $opportunity->setSalesStage($query[$i]['value']);
         }
         //            if($query[$i]['name'] == 'pdf_lmb_fact_c')
         //            {
         //                $opportunity->set($query[$i]['value']);
         //            }
     }
 }
 public function __construct($arrayOpportunities)
 {
     // browse through list
     $collection = array();
     $this->minutes = array();
     if ($arrayOpportunities) {
         foreach ($arrayOpportunities['relationship_list'][0]['opportunities'] as $arrayOpportunity) {
             $opportunity = new Opportunity();
             $opportunity->setId($arrayOpportunity['id']);
             $opportunity->setCreatedAt(new \DateTime($arrayOpportunity['date_entered']));
             $opportunity->setClosedAt(new \DateTime($arrayOpportunity['date_closed']));
             $opportunity->setName($arrayOpportunity['name']);
             $opportunity->setAssignedUserName($arrayOpportunity['assigned_user_name']);
             $opportunity->setOpportunityType($arrayOpportunity['opportunity_type']);
             $opportunity->setCampaignName($arrayOpportunity['campaign_name']);
             $opportunity->setLeadSource($arrayOpportunity['lead_source']);
             $opportunity->setAmount($arrayOpportunity['amount']);
             $opportunity->setSalesStage($arrayOpportunity['sales_stage']);
             $opportunity->setTypeAffaireC($arrayOpportunity['type_affaire_c']);
             $opportunity->setnumfact($arrayOpportunity['num_lmb_fact_c']);
             $opportunity->setidLMB($arrayOpportunities['entry_list'][0]['name_value_list']['id_compte_lundi_matin_c']);
             $collection[$opportunity->getId()] = $opportunity;
             // Minutes by lead source
             $key = strtolower(substr(str_replace("2004_", "", $opportunity->getLeadSource()), 5));
             if (!array_key_exists($key, $this->minutes)) {
                 $this->minutes[$key] = 0;
             }
             $this->minutes[$key] += $opportunity->getMinutes();
         }
         // Sort accounts by name
         usort($collection, function ($a, $b) {
             return $a->getClosedAt() < $b->getClosedAt();
         });
     }
     // build ArrayObject using collection
     return parent::__construct($collection);
 }