public function saveCtPhieuNhap(CtPhieuNhap $ct_phieu_nhap) { $data = array('id_san_pham' => $ct_phieu_nhap->getIdSanPham(), 'id_phieu_nhap' => $ct_phieu_nhap->getIdPhieuNhap(), 'gia_nhap' => $ct_phieu_nhap->getGiaNhap(), 'so_luong' => $ct_phieu_nhap->getSoLuong()); $id_ct_phieu_nhap = (int) $ct_phieu_nhap->getIdCtPhieuNhap(); if ($id_ct_phieu_nhap == 0) { $this->tableGateway->insert($data); } else { if ($this->getPhieuNhapByArrayConditionAndArrayColumn(array('id_ct_phieu_nhap' => $id_ct_phieu_nhap), array('id_san_pham'))) { $this->tableGateway->update($data, array('id_ct_phieu_nhap' => $id_ct_phieu_nhap)); } else { return false; } } return true; }