function populate() { $orders = new CustomerServiceCollection(new SInvoiceLine()); $customersales = $orders->getServiceHistory(); $db =& DB::Instance(); $types = array('ontime' => 'On Time', 'infull' => 'In Full', 'ontime_infull' => 'On Time / In Full'); $label = array(); $type_counter = 0; $sales_counter = 0; foreach ($types as $key => $title) { $data = array(); $sales_counter = 0; foreach ($customersales['previous'] as $period => $value) { $data['x'][] = $period; $data['y'][] = (double) number_format($value[$key . '%'], 2); $label[$type_counter][$sales_counter] = $title . ': ' . number_format($value[$key . '%'], 2); $sales_counter++; } $options['seriesList'][] = array('label' => $title, 'legendEntry' => TRUE, 'data' => $data, 'markers' => array('visible' => TRUE, 'type' => 'circle')); $type_counter++; } $options['type'] = 'line'; $options['identifier'] = __CLASS__; $options['labels'] = $label; $this->contents = json_encode($options); }
public function printFailureCodes() { // set options $options = array('type' => array('pdf' => '', 'xml' => '', 'csv' => ''), 'output' => array('print' => '', 'save' => '', 'email' => '', 'view' => ''), 'report' => 'cs_failure_codes', 'filename' => $this->generate_collection_name(TRUE)); // we use status in other print functions, however here we base it on if ajax print is or isn't set if (!$this->isPrinting()) { return $options; } $errors = array(); $s_data = $this->setSearch(); $customerservice = new CustomerServiceCollection($this->_templateobject); $sh = $customerservice->setSearch($s_data); $servicesummary = $customerservice->failureCodeSummary($sh); $count = 0; $data = array(); foreach ($servicesummary as $group => $detail) { foreach ($detail as $key => $fields) { if ($fields['description'] == ' - ') { $fields['description'] = 'No Failure Codes'; } if ($this->_data['print']['printtype'] === 'csv') { $data[$count] = $fields; } else { $data[$count]['data'] = $fields; } $count++; } } if ($this->_data['print']['printtype'] === 'csv') { // generate the csv and add it to the options array $options['csv_source'] = $this->generate_csv($this->_data['print'], $data, array('Failure Description', 'Count', 'Period')); } else { $extra['title'] = 'Customer Service Failure Code Summary '; $extra['cs_failure_codes'] = $data; // generate the xml and add it to the options array $options['xmlSource'] = $this->generateXML(array('extra' => $extra)); } // fire the print output, echo the output JSON for jQuery to handle echo $this->generate_output($this->_data['print'], $options); exit; }