/** * Insert an Invoice * * ToDo: missing check foreign keys * * @see lib/Zend/Db/Table/Zend_Db_Table_Abstract::insert() */ public function insert($data) { $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); $pref_group = $SI_PREFERENCES->getPreferenceById($_POST['preference_id']); $auth_session = Zend_Registry::get('auth_session'); $data['domain_id'] = $auth_session->domain_id; $data['index_id'] = SimpleInvoices_Db_Table_Index::NEXT('invoice', $pref_group['index_group']); $result = parent::insert($data); $this->_last_inserted_id = $this->getAdapter()->lastInsertId($this->_name, 'id'); // Increment Index if inserted if ($result) { SimpleInvoices_Db_Table_Index::INCREMENT('invoice', $pref_group['index_group']); } return $result; }
public static function increment($node,$sub_node="") { $next = SimpleInvoices_Db_Table_Index::NEXT($node,$sub_node); global $db; global $auth_session; global $dbh; /* if ($sub_node !="") { $subnode = "and sub_node = ".$sub_node; } */ if ($next == 1) { $sql = "insert into ".TB_PREFIX."index (id, node, sub_node, domain_id) VALUES (:id, :node, :sub_node, :domain_id);"; } else { $sql ="update ".TB_PREFIX."index set id = :id where node = :node and domain_id = :domain_id and sub_node = :sub_node"; } $sth = $db->query($sql,':id',$next,':node',$node,':sub_node', $sub_node,':domain_id',$auth_session->domain_id) or die(htmlsafe(end($dbh->errorInfo()))); return $next; }
public function insert() { //insert in si)invoice global $dbh; global $db_server; global $auth_session; $SI_PREFERENCES = new SimpleInvoices_Db_Table_Preferences(); $sql = "INSERT INTO ".TB_PREFIX."invoices ( id, index_id, domain_id, biller_id, customer_id, type_id, preference_id, date, note, custom_field1, custom_field2, custom_field3, custom_field4, inv_status, ) VALUES ( NULL, :index_id, :domain_id, :biller_id, :customer_id, :type_id, :preference_id, :date, :note, :custom_field1, :custom_field2, :custom_field3, :custom_field4, NULL )"; $pref_group= $SI_PREFERENCES->getPreferenceById($this->preference_id); $sth= dbQuery($sql, ':index_id', SimpleInvoices_Db_Table_Index::NEXT('invoice',$pref_group[index_group],$this->biller_id), ':domain_id', $auth_session->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', $this->note, ':custom_field1', $this->custom_field1, ':custom_field2', $this->custom_field2, ':custom_field3', $this->custom_field3, ':custom_field4', $this->custom_field4 ); SimpleInvoices_Db_Table_Index::INCREMENT('invoice',$pref_group[index_group],$this->biller_id); //return $sth; return SimpleInvoices_Db_Table_Invoices::LAST_INSERT_ID(); //insert into si_invoice_items //insert into }