mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-09-08 11:34:04 -04:00
Further model checks, improved success result, made code style consistent (#598)
This commit is contained in:
1 parent
5d66b9fbfd
commit
6ad547049e
29 files changed
+132
-102
No files matched your search
@@ -89,26 +89,30 @@ class Supplier extends Person
|
||||
*/
|
||||
public function save_supplier(&$person_data, &$supplier_data, $supplier_id = FALSE)
|
||||
{
|
||||
$success = FALSE;
|
||||
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->trans_start();
|
||||
|
||||
if(parent::save($person_data,$supplier_id))
|
||||
{
|
||||
if(!$supplier_id or !$this->exists($supplier_id))
|
||||
if(!$supplier_id || !$this->exists($supplier_id))
|
||||
{
|
||||
$supplier_data['person_id'] = $person_data['person_id'];
|
||||
$this->db->insert('suppliers', $supplier_data);
|
||||
$success = $this->db->insert('suppliers', $supplier_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->where('person_id', $supplier_id);
|
||||
$this->db->update('suppliers', $supplier_data);
|
||||
$success = $this->db->update('suppliers', $supplier_data);
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_complete();
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
|
||||
return $this->db->trans_status();
|
||||
return $success;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user