Browse Source

clean code (#26585)

* clean code

* Update commoninvoice.class.php

* Update commoninvoice.class.php
Frédéric FRANCE 1 year ago
parent
commit
79b4c0f1b9
1 changed files with 12 additions and 33 deletions
  1. 12 33
      htdocs/core/class/commoninvoice.class.php

+ 12 - 33
htdocs/core/class/commoninvoice.class.php

@@ -687,51 +687,30 @@ abstract class CommonInvoice extends CommonObject
 	 */
 	public function getSubtypeLabel($table = '')
 	{
+		$subtypeLabel = '';
 		if ($table === 'facture' || $table === 'facture_fourn') {
 			$sql = "SELECT s.label FROM " . MAIN_DB_PREFIX . $table . " AS f";
 			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_invoice_subtype AS s ON f.subtype = s.rowid";
 			$sql .= " WHERE f.ref = '".$this->db->escape($this->ref)."'";
-
-			$resql = $this->db->query($sql);
-
-			if ($resql) {
-				$subtypeLabel = '';
-
-				while ($obj = $this->db->fetch_object($resql)) {
-					$subtypeLabel = $obj->label;
-				}
-
-				if (!empty($subtypeLabel)) {
-					return $subtypeLabel;
-				}
-			} else {
-				dol_print_error($this->db);
-				return -1;
-			}
 		} elseif ($table === 'facture_rec' || $table === 'facture_fourn_rec') {
 			$sql = "SELECT s.label FROM " . MAIN_DB_PREFIX . $table . " AS f";
 			$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_invoice_subtype AS s ON f.subtype = s.rowid";
 			$sql .= " WHERE f.titre = '".$this->db->escape($this->titre)."'";
+		} else {
+			return -1;
+		}
 
-			$resql = $this->db->query($sql);
-
-			if ($resql) {
-				$subtypeLabel = '';
-
-				while ($obj = $this->db->fetch_object($resql)) {
-					$subtypeLabel = $obj->label;
-				}
-
-				if (!empty($subtypeLabel)) {
-					return $subtypeLabel;
-				}
-			} else {
-				dol_print_error($this->db);
-				return -1;
+		$resql = $this->db->query($sql);
+		if ($resql) {
+			while ($obj = $this->db->fetch_object($resql)) {
+				$subtypeLabel = $obj->label;
 			}
+		} else {
+			dol_print_error($this->db);
+			return -1;
 		}
 
-		return '';
+		return $subtypeLabel;
 	}
 
 	/**