/**
  *	Delete a subscription
  *
  *	@param	User	$user		User that delete
  *	@return	int					<0 if KO, 0 if not found, >0 if OK
  */
 function delete($user)
 {
     // It subscription is linked to a bank transaction, we get it
     if ($this->fk_bank) {
         require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
         $accountline = new AccountLine($this->db);
         $result = $accountline->fetch($this->fk_bank);
     }
     $this->db->begin();
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "cotisation WHERE rowid = " . $this->id;
     dol_syslog(get_class($this) . "::delete sql=" . $sql);
     $resql = $this->db->query($sql);
     if ($resql) {
         $num = $this->db->affected_rows($resql);
         if ($num) {
             require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
             $member = new Adherent($this->db);
             $result = $member->fetch($this->fk_adherent);
             $result = $member->update_end_date($user);
             if ($accountline->rowid > 0) {
                 $result = $accountline->delete($user);
                 // Return false if refused because line is conciliated
                 if ($result > 0) {
                     $this->db->commit();
                     return 1;
                 } else {
                     $this->error = $accountline->error;
                     $this->db->rollback();
                     return -1;
                 }
             } else {
                 $this->db->commit();
                 return 1;
             }
         } else {
             $this->db->commit();
             return 0;
         }
     } else {
         $this->error = $this->db->lasterror();
         $this->db->rollback();
         return -1;
     }
 }