function populate() { $customers = new SLCustomerCollection(); $customers->setParams(); $sh = new SearchHandler($customers, false); $sh->addConstraint(new Constraint('credit_limit', '<', '(outstanding_balance)')); $this->setSearchLimit($sh); $customers->load($sh); $this->contents = $customers; }
function populate() { $customers = new SLCustomerCollection(); $customers->setParams(); $sh = new SearchHandler($customers, false); $sh->addConstraint(new Constraint('account_status', '=', 'S')); $this->setSearchLimit($sh); $customers->load($sh); $this->contents = $customers; }
function populate() { $pl = new PageList('my_customers'); $customers = new SLCustomerCollection(new SLCustomer()); // Either get data from a function that returns a collection // $customers->getUnassignedCompanies(); // Or construct a collection from a sql query $db = DB::Instance(); $query = 'select id, * from slmaster where usercompanyid=' . EGS_COMPANY_ID . ' limit 10'; $results = $db->getAssoc($query); foreach ($results as $id => $row) { $customer = new SLCustomer(); $customer->_data = $row; $customer->load($id); $customer->id = $id; $customers->add($customer); } $pl->addFromCollection($customers, array('module' => 'sales_ledger', 'controller' => 'slcustomers', 'action' => 'view'), array('id'), '', 'name'); $this->contents = $pl->getPages()->toArray(); }
function populate() { $invoices = new SInvoiceCollection(); $pl = new PageList('overdue_accounts'); // TODO: this returns a collection; needs to return an array $invoices->getOverdueInvoices(); $customerlist = array(); foreach ($invoices as $invoice) { $customerlist[$invoice->slmaster_id] = $invoice->customer; } $customers = new SLCustomerCollection(); $customers->setParams(); $sh = new SearchHandler($customers, false); if (count($customerlist) > 0) { $sh->addConstraint(new Constraint('id', 'in', '(' . implode(',', array_keys($customerlist)) . ')')); } else { $sh->addConstraint(new Constraint('id', '=', '0')); } $this->setSearchLimit($sh); $customers->load($sh); $this->contents = $customers; }