/** * Method to retreive an invoice * * This method will populate this * instance with the data from the * SureInvoice database for the * provided $id. * * This method will automatically populate * all of the associated line items for this * invoice. * * If the $id param is NULL the $id * of the current object will be used * as the ID to retreive. * * @param int|NULL $id ID of the company to retrieve or NULL to use $this->id * @access public * @global DBConn Database access object * @see getLastError() * @see _populateLines() * @return bool TRUE on success or FALSE on error */ function get($id = NULL){ global $db_conn; if(!isset($id)){ $id = $this->id; } if(!isset($id)){ $this->error = "SI_Invoice::get() : Invoice id not set\n"; return FALSE; } $Invoice = SI_Invoice::retrieveSet("WHERE id = $id", TRUE); if($Invoice === FALSE){ return FALSE; } if(isset($Invoice[0])){ $this->updateFromAssocArray($Invoice[0]); if($this->_populateLines() === FALSE) return FALSE; $this->stripSlashes(); }else{ $this->error = "SI_Invoice::get() : No data retrieved from query\n"; return FALSE; } return TRUE; }
print("\n"); } print("Writing output to $output_directory\n"); if(($start_date > 0 && $end_date == 0) || ($end_date > 0 && $start_date == 0)){ print("You must provide both a start and an end date\n"); exit(2); } if($start_date > 0){ print("Looking up invoices between ".date('m/d/Y', $start_date)." and ".date('m/d/Y', $end_date).".\n"); } $invoice = new SI_Invoice(); $invoices = $invoice->retrieveSet("WHERE `timestamp` BETWEEN $start_date AND $end_date"); if($invoices === FALSE){ print("Error retreiving list of invoices!\n"); print($invoice->getLastError()."\n"); exit(3); } print("Exporting ".count($invoices)." invoices.\n"); foreach($invoices as $invoice){ if(!is_array($invoice->_lines) || count($invoice->_lines) == 0){ print("Skipping invoice {$invoice->id}.\n"); continue; } $pdf_file = $invoice->getPDF(FALSE); if($pdf_file === FALSE){
$item_code = new SI_ItemCode(); $item_codes = $item_code->retrieveSet("WHERE updated_ts > $last_update_ts"); if($item_codes === FALSE){ $error_msg .= "Error getting item codes updated since ".date('m-d-Y', $last_update_ts); debug_message($item_code->getLastError()); } $account = new SI_Account(); $accounts = $account->retrieveSet("WHERE updated_ts > $last_update_ts"); if($accounts === FALSE){ $error_msg .= "Error getting accounts updated since ".date('m-d-Y', $last_update_ts); debug_message($account->getLastError()); } $invoice = new SI_Invoice(); $invoices = $invoice->retrieveSet("WHERE updated_ts > $last_update_ts"); if($invoices === FALSE){ $error_msg .= "Error getting invoices updated since ".date('m-d-Y', $last_update_ts); debug_message($invoice->getLastError()); } $payment = new SI_Payment(); $payments = $payment->retrieveSet("WHERE updated_ts > $last_update_ts"); if($payments === FALSE){ $error_msg .= "Error getting invoices updated since ".date('m-d-Y', $last_update_ts); debug_message($payment->getLastError()); } if(isset($_POST['save2'])){ $output = ''; if(isset($_POST['export_companies']) && is_array($_POST['export_companies'])){