protected function HandleRow($row) { if (!($this->handleaddresses || $this->handleformfields)) { return $row; } $row = parent::HandleRow($row); if ($this->handleaddresses) { $addresses = array(); if (count($row['customerAddresses'])) { $x = 0; foreach ($row['customerAddresses'] as $address) { $addresses[] = array_combine(array_keys($this->addr_cache[$x]), array_values($address)); $x++; } } // create empty addresses to fill up the array if (count($addresses) < $this->maxaddr) { $diff = $this->maxaddr - count($addresses); $start = $this->maxaddr - $diff; for ($x = $start; $x < $diff; $x++) { $addresses[] = $this->addr_cache[$x]; } } $merged = array(); foreach ($addresses as $address) { $merged = array_merge($merged, $address); } // position of the addresses in the row $position = $this->GetFieldPosition("customerAddresses"); // generate the keys $keys = array_keys($row); $addr_keys = array_keys($merged); array_splice($keys, $position, 1, $addr_keys); // insert the addresses into row array_splice($row, $position, 1, $merged); $row = array_combine($keys, $row); } return $row; }
/** * Iterates through the rows in the result and exports them. * Performs any formatting as defined in the fields and then does custom handling that might be required by each type. * */ public function ExportRows_Orders_Customer() { $where = $this->where; $vendorid = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId(); $dummy = $this->CreateDummyRow($this->fields); // 2011-06-20 johnny modify to export customer information if ($_GET['t'] == "orders") { $query = $this->GetQuery($this->ConstructFieldList(), $where, $vendorid); } else { // for export customer $query = ISC_ADMIN_EXPORTFILETYPE_CUSTOMERS::GetQuery($this->ConstructFieldList(), $where, $vendorid, true); } $this->result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($this->result)) { // map the data from the db row to the dummy row $new_row = $this->MapRow($row, $dummy); // perform any custom work on the row and write it the export method $new_row = $this->HandleRow($new_row); $new_row = $this->RemoveExtraFields($new_row); // format the data $this->FormatColumns($new_row); // 2011-06-20 johnny modify for export customer if (array_key_exists('isguest', $new_row)) { if ($new_row['isguest'] == 0) { $new_row['isguest'] = 'NO'; } else { $new_row['isguest'] = 'YES'; } } // write the row using the export method $this->exportmethod->WriteRow($new_row); } }