public function insert() { //insert in si_invoice global $db_server; $sql = "INSERT \n\t\t\t\tINTO\n\t\t\t" . TB_PREFIX . "invoices (\n\t\t\t\tid, \n\t\t \t\tindex_id,\n\t\t\t\tdomain_id,\n\t\t\t\tbiller_id, \n\t\t\t\tcustomer_id, \n\t\t\t\ttype_id,\n\t\t\t\tpreference_id, \n\t\t\t\tdate, \n\t\t\t\tnote,\n\t\t\t\tcustom_field1,\n\t\t\t\tcustom_field2,\n\t\t\t\tcustom_field3,\n\t\t\t\tcustom_field4\n\t\t\t)\n\t\t\tVALUES\n\t\t\t(\n\t\t\t\tNULL,\n\t\t\t\t:index_id,\n\t\t\t\t:domain_id,\n\t\t\t\t:biller_id,\n\t\t\t\t:customer_id,\n\t\t\t\t:type_id,\n\t\t\t\t:preference_id,\n\t\t\t\t:date,\n\t\t\t\t:note,\n\t\t\t\t:custom_field1,\n\t\t\t\t:custom_field2,\n\t\t\t\t:custom_field3,\n\t\t\t\t:custom_field4\n\t\t\t\t)"; $pref_group = getPreference($this->preference_id, $this->domain_id); $sth = dbQuery($sql, ':index_id', index::next('invoice', $pref_group['index_group'], $this->domain_id), ':domain_id', $this->domain_id, ':biller_id', $this->biller_id, ':customer_id', $this->customer_id, ':type_id', $this->type_id, ':preference_id', $this->preference_id, ':date', $this->date, ':note', trim($this->note), ':custom_field1', $this->custom_field1, ':custom_field2', $this->custom_field2, ':custom_field3', $this->custom_field3, ':custom_field4', $this->custom_field4); #index::increment('invoice',$pref_group['index_group'], $domain_id,$this->biller_id); index::increment('invoice', $pref_group['index_group'], $this->domain_id); return lastInsertID(); }
function updateInvoice($invoice_id, $domain_id = '') { // global $logger; global $db_server; $domain_id = domain_id::get($domain_id); $invoiceobj = new invoice(); $current_invoice = $invoiceobj->select($_POST['id']); $current_pref_group = getPreference($current_invoice['preference_id']); $new_pref_group = getPreference($_POST['preference_id']); $index_id = $current_invoice['index_id']; // $logger->log('Curent Index Group: '.$description, Zend_Log::INFO); // $logger->log('Description: '.$description, Zend_Log::INFO); if ($current_pref_group['index_group'] != $new_pref_group['index_group']) { $index_id = index::increment('invoice', $new_pref_group['index_group']); } if ($db_server == 'mysql' && !_invoice_check_fk($_POST['biller_id'], $_POST['customer_id'], $type, $_POST['preference_id'])) { return null; } $sql = "UPDATE\n\t\t\t" . TB_PREFIX . "invoices\n\t\tSET\n\t\t\tindex_id = :index_id,\n\t\t\tbiller_id = :biller_id,\n\t\t\tcustomer_id = :customer_id,\n\t\t\tpreference_id = :preference_id,\n\t\t\tdate = :date,\n\t\t\tnote = :note,\n\t\t\tcustom_field1 = :customField1,\n\t\t\tcustom_field2 = :customField2,\n\t\t\tcustom_field3 = :customField3,\n\t\t\tcustom_field4 = :customField4\n\t\tWHERE\n\t\t\tid = :invoice_id\n\t\tAND domain_id = :domain_id"; return dbQuery($sql, ':index_id', $index_id, ':biller_id', $_POST['biller_id'], ':customer_id', $_POST['customer_id'], ':preference_id', $_POST['preference_id'], ':date', $_POST['date'], ':note', trim($_POST['note']), ':customField1', $_POST['customField1'], ':customField2', $_POST['customField2'], ':customField3', $_POST['customField3'], ':customField4', $_POST['customField4'], ':invoice_id', $invoice_id, ':domain_id', $domain_id); }