Пример #1
0
 public function saveSanPham(SanPham $san_pham)
 {
     $data = array('id_kho' => $san_pham->getIdKho(), 'id_don_vi_tinh' => $san_pham->getIdDonViTinh(), 'id_barcode' => $san_pham->getIdBarcode(), 'ma_san_pham' => $san_pham->getMaSanPham(), 'ma_vach' => $san_pham->getMaVach(), 'id_loai_san_pham' => $san_pham->getIdLoaiSanPham(), 'ten_san_pham' => $san_pham->getTenSanPham(), 'mo_ta' => $san_pham->getMoTa(), 'hinh_anh' => $san_pham->getHinhAnh(), 'nhan' => $san_pham->getNhan(), 'ton_kho' => $san_pham->getTonKho(), 'loai_gia' => $san_pham->getLoaiGia(), 'gia_nhap' => $san_pham->getGiaNhap(), 'gia_bia' => $san_pham->getGiaBia(), 'chiet_khau' => $san_pham->getChietKhau(), 'state' => $san_pham->getState(), 'user_id' => $san_pham->getUserId());
     $id_san_pham = (int) $san_pham->getIdSanPham();
     if ($id_san_pham == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getSanPhamByArrayConditionAndArrayColumn(array('id_san_pham' => $id_san_pham), array('ten_san_pham'))) {
             $this->tableGateway->update($data, array('id_san_pham' => $id_san_pham));
         } else {
             return false;
         }
     }
     return true;
 }