public function gerateBilling() { $order = null; $customers = $this->getUserID(); $structJsonArray = array(); foreach ($customers as $customer) { $structJson = new Json(); $structJson->setCustomerId($customer['zoho_books_contact_id']); $structJson->setDate(date('d-m-Y')); $invoices_per_costumer = $this->getUserInvoice($customer['zoho_books_contact_id']); //var_dump($invoices_per_costumer); foreach ($invoices_per_costumer as $invoice_each) { $item = new Item(); $order++; $item->setItemId("460000000027017"); $item->setProjectId(""); $item->setExpenseId(""); $item->setName("Print Services"); $item->setDescription($invoice_each['description']); $item->setItemOrder($order); $item->setRate($invoice_each['rate']); $item->setUnit("Nos"); $item->setQuantity(1.0); $item->setDiscount(0.0); $item->setTaxId("460000000027005"); $structJson->setLineItems($item); $item = null; } $structJson->setNotes("Thanks for your business."); $order = null; $structJsonArray[] = $structJson; $structJson = null; } return $structJsonArray; }