Beispiel #1
0
 /**
  *	Delete line in database
  *
  *	@param		int		$rowid		Id of line to delete
  *	@return		int					<0 if KO, >0 if OK
  */
 function deleteline($rowid)
 {
     global $langs, $conf;
     dol_syslog(get_class($this) . "::deleteline rowid=" . $rowid, LOG_DEBUG);
     if (!$this->brouillon) {
         $this->error = 'ErrorBadStatus';
         return -1;
     }
     $this->db->begin();
     // Libere remise liee a ligne de facture
     $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe_remise_except';
     $sql .= ' SET fk_facture_line = NULL';
     $sql .= ' WHERE fk_facture_line = ' . $rowid;
     dol_syslog(get_class($this) . "::deleteline", LOG_DEBUG);
     $result = $this->db->query($sql);
     if (!$result) {
         $this->error = $this->db->error();
         $this->db->rollback();
         return -1;
     }
     $line = new FactureLigne($this->db);
     $line->context = $this->context;
     // For triggers
     $line->fetch($rowid);
     if ($line->delete() > 0) {
         $result = $this->update_price(1);
         if ($result > 0) {
             $this->db->commit();
             return 1;
         } else {
             $this->db->rollback();
             $this->error = $this->db->lasterror();
             return -1;
         }
     } else {
         $this->db->rollback();
         $this->error = $line->error;
         return -1;
     }
 }