~eventum-developers/eventum/trunk

« back to all changes in this revision

Viewing changes to lib/eventum/class.customer_stats_report.php

  • Committer: Bryan Alsdorf
  • Date: 2013-08-23 03:50:34 UTC
  • mto: (4033.1.168 eventum-skysql)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: bryan@montyprogram.com-20130823035034-7f5r3pt1xg0xnnhk
Initial commit of CRM migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
    function getData()
119
119
    {
120
120
        $data = array();
 
121
        $crm = CRM::getInstance($this->prj_id);
121
122
 
122
123
        // determine if this should be customer based or support level based.
123
124
        if ($this->isCustomerBased()) {
127
128
            $data[] = $this->getAllRow();
128
129
 
129
130
            foreach ($this->customers as $customer_id) {
130
 
                $details = Customer::getDetails($this->prj_id, $customer_id);
131
 
                $data[] = $this->getDataRow($details["customer_name"], array($customer_id));
 
131
                $customer = $crm->getCustomer($customer_id);
 
132
                $data[] = $this->getDataRow($customer->getName(), array($customer_id));
132
133
            }
133
134
        } else {
134
135
            // support level based
135
136
            if (count($this->levels) > 0) {
136
 
                $grouped_levels = Customer::getGroupedSupportLevels($this->prj_id);
 
137
                $grouped_levels = $crm->getGroupedSupportLevels();
137
138
                foreach ($this->levels as $level_name) {
138
139
                    if ($level_name == "Aggregate") {
139
140
                        // get "all" row of data
143
144
 
144
145
                    $support_options = array();
145
146
                    if ($this->exclude_expired_contracts) {
146
 
                        $support_options[] = CUSTOMER_EXCLUDE_EXPIRED;
 
147
                        $support_options[] = CRM_EXCLUDE_EXPIRED;
147
148
                    }
148
 
                    $customers = Customer::getListBySupportLevel($this->prj_id, $grouped_levels[$level_name], $support_options);
 
149
                    $customers = $crm->getCustomerIDsBySupportLevel($grouped_levels[$level_name], $support_options);
149
150
                    $data[] = $this->getDataRow($level_name, $customers);
150
151
                }
151
152
            }
185
186
     */
186
187
    function getAllRow()
187
188
    {
 
189
        $crm = CRM::getInstance($this->prj_id);
188
190
        $row = array(
189
191
            "title" =>  ev_gettext("Aggregate")
190
192
        );
191
193
 
192
194
        // get complete list of customers.
193
195
        $all_levels = array();
194
 
        $levels = Customer::getSupportLevelAssocList($this->prj_id);
 
196
        $levels = $crm->getSupportLevelAssocList();
195
197
        foreach ($levels as $level_id => $level_name) {
196
198
            $all_levels[] = $level_id;
197
199
        }
198
200
        if ($this->exclude_expired_contracts) {
199
 
            $support_option = CUSTOMER_EXCLUDE_EXPIRED;
 
201
            $support_option = CRM_EXCLUDE_EXPIRED;
200
202
        } else {
201
203
            $support_option = array();
202
204
        }
203
 
        $this->current_customers = Customer::getListBySupportLevel($this->prj_id, $all_levels, $support_option);
 
205
        $this->current_customers = $crm->getCustomerIDsBySupportLevel($all_levels, $support_option);
204
206
 
205
207
        // get customers
206
208
        $row["customer_counts"] = $this->getCustomerCounts("All");