From 69ffbcac4474404c413aceaecc96117691fd801a Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Wed, 27 Jul 2016 21:40:10 +0200
Subject: Traits cannot have constants

---
 classes/Calculatable.php | 18 +++++++++---------
 classes/Offer.php        | 30 +++++++++++++++---------------
 2 files changed, 24 insertions(+), 24 deletions(-)

(limited to 'classes')

diff --git a/classes/Calculatable.php b/classes/Calculatable.php
index 086adc2..5d60704 100644
--- a/classes/Calculatable.php
+++ b/classes/Calculatable.php
@@ -22,15 +22,15 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+define('CALCULATABLE_SUBTOTAL', 1);
+define('CALCULATABLE_VAT', 2);
+define('CALCULATABLE_TOTAL', 3);
+
 /**
  * The calculatable trait, to be used by something of which subtotal, VAT and
  * total can be calculated
  */
 trait Calculatable {
-	const SUBTOTAL = 1;
-	const VAT = 2;
-	const TOTAL = 3;
-
 	/**
 	 * Calculate the subtotal
 	 *
@@ -61,7 +61,7 @@ trait Calculatable {
 	 * VAT: the sum of all the VAT from all the assignments
 	 * Total: the sum of subtotal and total
 	 *
-	 * @param int $what                     Any of Calculatable::SUBTOTAL, Calculatable::VAT and Calculatable::TOTAL
+	 * @param int $what                     Any of CALCULATABLE_SUBTOTAL, CALCULATABLE_VAT and CALCULATABLE_TOTAL
 	 * @param int $round                    How many decimals to round the result on
 	 * @param bool $format                  Whether to format the number nicely (for output) or not (for calculations)
 	 *
@@ -69,16 +69,16 @@ trait Calculatable {
 	 *
 	 * @return float|bool                   The calculated value rounded to $round decimals, or false on incorrect input
 	 */
-	public function calculate($what = self::TOTAL, $round = 2, $format = true) {
+	public function calculate($what = CALCULATABLE_TOTAL, $round = 2, $format = true) {
 		$return = 0;
 		switch ($what) {
-			case self::SUBTOTAL:
+			case CALCULATABLE_SUBTOTAL:
 				$return = $this->calculateSubtotal();
 				break;
-			case self::VAT:
+			case CALCULATABLE_VAT:
 				$return = $this->calculateVAT();
 				break;
-			case self::TOTAL:
+			case CALCULATABLE_TOTAL:
 				$return = $this->calculateTotal();
 				break;
 			default:
diff --git a/classes/Offer.php b/classes/Offer.php
index 0ef2881..e24154f 100644
--- a/classes/Offer.php
+++ b/classes/Offer.php
@@ -211,7 +211,7 @@ class Offer extends Model{
 	 *
 	 * Total: the sum of subtotal and total
 	 *
-	 * @param int $what                     Any of Calculatable::SUBTOTAL, Calculatable::VAT and Calculatable::TOTAL
+	 * @param int $what                     Any of CALCULATABLE_SUBTOTAL, CALCULATABLE_VAT and CALCULATABLE_TOTAL
 	 * @param int $round                    How many decimals to round the result on
 	 * @param bool $format                  Whether to format the number nicely (for output) or not (for calculations)
 	 *
@@ -219,28 +219,28 @@ class Offer extends Model{
 	 *
 	 * @return float|bool                   The calculated value rounded to $round decimals, or false on incorrect input
 	 */
-	public function calculate($what = Calculatable::TOTAL, $round = 2, $format = true) {
+	public function calculate($what = CALCULATABLE_TOTAL, $round = 2, $format = true) {
 		$return = 0;
 		switch ($what) {
-			case Calculatable::SUBTOTAL:
+			case CALCULATABLE_SUBTOTAL:
 				foreach ($this->getAssignments() as $assignment) {
-					$return += $assignment->calculate(Calculatable::SUBTOTAL, $round + 1, false);
+					$return += $assignment->calculate(CALCULATABLE_SUBTOTAL, $round + 1, false);
 				}
 				foreach ($this->getDiscounts() as $discount) {
-					$return += $discount->calculate(Calculatable::SUBTOTAL, $round + 1, false);
+					$return += $discount->calculate(CALCULATABLE_SUBTOTAL, $round + 1, false);
 				}
 				break;
-			case Calculatable::VAT:
+			case CALCULATABLE_VAT:
 				$assignments = $this->getAssignments();
 				foreach ($assignments as $assignment) {
-					$return += $assignment->calculate(Calculatable::VAT, $round + 1, false);
+					$return += $assignment->calculate(CALCULATABLE_VAT, $round + 1, false);
 				}
 				foreach ($this->getDiscounts() as $discount) {
-					$return += $discount->calculate(Calculatable::VAT, $round + 1, false);
+					$return += $discount->calculate(CALCULATABLE_VAT, $round + 1, false);
 				}
 				break;
-			case Calculatable::TOTAL:
-				$return = $this->calculate(Calculatable::SUBTOTAL, $round + 1, false) + $this->calculate(Calculatable::VAT, $round + 1, false);
+			case CALCULATABLE_TOTAL:
+				$return = $this->calculate(CALCULATABLE_SUBTOTAL, $round + 1, false) + $this->calculate(CALCULATABLE_VAT, $round + 1, false);
 				break;
 			default:
 				return false;
@@ -372,9 +372,9 @@ class Offer extends Model{
 		foreach ($this->getDiscounts() as $discount)
 			$list[] = array(
 				$discount->title,
-				$discount->calculate(Calculatable::SUBTOTAL),
+				$discount->calculate(CALCULATABLE_SUBTOTAL),
 				$discount->VAT_percentage . "%",
-				$discount->calculate(Calculatable::TOTAL)
+				$discount->calculate(CALCULATABLE_TOTAL)
 			);
 
 		$pdf = new Correspondence();
@@ -462,7 +462,7 @@ class Offer extends Model{
 		$pdf->SetFont('','B');
 		$pdf->Cell($width[1] + $width[2],7,$pdf->_('amount'));
 		$pdf->SetFont('','');
-		$pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(Calculatable::SUBTOTAL),'',0,'R');
+		$pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(CALCULATABLE_SUBTOTAL),'',0,'R');
 		$pdf->Ln();
 
 		foreach ($btw as $p => $m) {
@@ -479,7 +479,7 @@ class Offer extends Model{
 		$pdf->SetFont('','B');
 		$pdf->Cell($width[1] + $width[2],7,$pdf->_('total'));
 		$pdf->SetFont('','');
-		$pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(Calculatable::TOTAL),'T',0,'R');
+		$pdf->Cell($width[3],7,correspondence::valuta() . $this->calculate(CALCULATABLE_TOTAL),'T',0,'R');
 		$pdf->Ln();
 
 		// Footer
@@ -517,7 +517,7 @@ class Offer extends Model{
 		$pdf->Cell(17.5,5);
 		$pdf->Cell(40,5,$invoice_nr);
 		$pdf->Cell(17.5,5);
-		$pdf->Cell(40,5,correspondence::valuta() . $this->calculate(Calculatable::TOTAL));
+		$pdf->Cell(40,5,correspondence::valuta() . $this->calculate(CALCULATABLE_TOTAL));
 
 		$pdf->SetY($oldY + 14);
 
-- 
cgit v1.2.3