Beispiel #1
0
 /**
  *  Delete an order line
  *  @param      lineid		Id of line to delete
  *  @return     int         >0 if OK, 0 if nothing to do, <0 if KO
  */
 function deleteline($lineid)
 {
     global $user;
     if ($this->statut == 0) {
         $this->db->begin();
         $sql = "SELECT fk_product, qty";
         $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet";
         $sql .= " WHERE rowid = " . $lineid;
         $result = $this->db->query($sql);
         if ($result) {
             $obj = $this->db->fetch_object($result);
             if ($obj) {
                 $product = new Product($this->db);
                 $product->id = $obj->fk_product;
                 // Delete line
                 $line = new OrderLine($this->db);
                 // For triggers
                 $line->fetch($lineid);
                 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 = $this->db->lasterror();
                     return -1;
                 }
             } else {
                 $this->db->rollback();
                 return 0;
             }
         } else {
             $this->db->rollback();
             $this->error = $this->db->lasterror();
             return -1;
         }
     } else {
         return -1;
     }
 }