protected function GetQuery($columns, $where, $vendorid) { $altwhere = ""; if ($where) { $altwhere = " WHERE " . $where; } $query = "\n\t\t\tSELECT\n\t\t\t\tMAX(addrcount) AS maxaddr\n\t\t\tFROM\n\t\t\t\t(\n\t\t\t\tSELECT\n\t\t\t\t\tCOUNT(shipid) AS addrcount\n\t\t\t\tFROM\n\t\t\t\t\t[|PREFIX|]customers c\n\t\t\t\t\tLEFT JOIN [|PREFIX|]customer_groups cg ON c.custgroupid = cg.customergroupid\n\t\t\t\t\tLEFT JOIN [|PREFIX|]shipping_addresses sa ON sa.shipcustomerid = c.customerid\n\t\t\t\t" . $altwhere . "\n\t\t\t\tGROUP BY\n\t\t\t\t\tc.customerid\n\t\t\t\t) AS addrquery\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $this->maxaddr = $row['maxaddr']; return parent::GetQuery($columns, $where, $vendorid); }
/** * 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); } }