Browse Source

Fixed small date calculation bug in the weekly report.

Adam Day 9 năm trước cách đây
mục cha
commit
d98f16a931

+ 41 - 9
application/controllers/reportsController.php

@@ -19,12 +19,28 @@ class reportsController extends Staple_Controller
 
     public function index($year = null, $month = null)
     {
-        if ($year == null) {
-            $year = date('Y');
+        if ($year == null)
+        {
+            $date = new DateTime();
+
+            if($date->format('d') >= 26)
+            {
+                $date->modify('+1 month');
+            }
+
+            $year = $date->format('Y');
         }
 
-        if ($month == null) {
-            $month = date('m');
+        if ($month == null)
+        {
+            $date = new DateTime();
+
+            if($date->format('d') >= 26)
+            {
+                $date->modify('+1 month');
+            }
+
+            $month = $date->format('m');
         }
 
         $date = new DateTime();
@@ -32,7 +48,6 @@ class reportsController extends Staple_Controller
         $date->setTime(0,0,0);
 
         $this->view->year = $date->format('Y');
-
         $this->view->date = $date->format("F Y");
 
         $date->modify('+1 year');
@@ -57,6 +72,11 @@ class reportsController extends Staple_Controller
         $this->view->accountLevel = $this->authLevel;
 
         $date = new DateTime();
+        if($date->format('d') >= 26)
+        {
+            $date->modify('+1 month');
+        }
+
         $date->setDate($year, $month, 1);
         $this->view->monthName = $date->format('F');
 
@@ -393,12 +413,24 @@ class reportsController extends Staple_Controller
 
     public function inactive($year = null, $month = null)
     {
-        if ($year == null) {
-            $year = date('Y');
+        if ($year == null)
+        {
+            $date = new DateTime('first day of this month');
+            if($date->format('d') >= 26)
+            {
+                $date->modify('+1 month');
+            }
+            $year = $date->format('Y');
         }
 
-        if ($month == null) {
-            $month = date('m');
+        if ($month == null)
+        {
+            $date = new DateTime('first day of this month');
+            if($date->format('d') >= 26)
+            {
+                $date->modify('+1 month');
+            }
+            $month = $date->format('m');
         }
 
         $date = new DateTime();

+ 1 - 1
application/models/weeklyReportModel.php

@@ -12,7 +12,7 @@ class weeklyReportModel extends Staple_Model
     {
         //Get an array of weeks
         $weeks = array();
-        for($i=1;$i<53;$i++)
+        for($i=1;$i<=53;$i++)
         {
             $weeks[$i] = $this->getStartAndEndDate($i, $year);
 

+ 24 - 24
application/views/reports/index.phtml

@@ -165,39 +165,39 @@
                 if(count($timesheet) > 0)
                 {
                 echo "</table>";
+                echo "
+                    <div class='row'>
+                        <div class='small-12 columns text-right'>";
 
-                echo "<div class=\"row\">";
-                        echo "<div class='small-12'>
-
-                        FORM GOES HERE
+                    echo"</div>
+                    </div>";
 
-                        </div>";
-                echo "</div>";
                 echo "<div class=\"row\">";
                 echo "<div class=\"small-6 medium-4 large-3 columns\">";
-                                        echo "<div class=\"card successBg\">
-                                            <div class=\"title\">Validated</div>
-                                            <div class=\"value\">".$totalValidated." <small>Hours</small></div>
-                                        </div>";
+                echo "<div class=\"card successBg\">
+                    <div class=\"title\">Validated</div>
+                    <div class=\"value\">".$totalValidated." <small>Hours</small></div>
+                </div>";
                 echo "</div>";
                 echo "<div class=\"small-6 medium-4 large-3 columns\">";
-                                        echo "<div class=\"card warning\">
-                                            <div class=\"title\">Not Validated</div>
-                                            <div class=\"value\">".$totalInvalid." <small>Hours</small></div>
-                                        </div>";
+                echo "<div class=\"card warning\">
+                    <div class=\"title\">Not Validated</div>
+                    <div class=\"value\">".$totalInvalid." <small>Hours</small></div>
+                </div>";
                 echo "</div>";
-                echo "<div class=\"small-6 medium-4 large-3 columns end\">";
-                                     echo "<div class=\"card\">
-                                            <div class=\"title\">Sick</div>
-                                            <div class=\"value\">".$totalSick." <small>Hours</small></div>
-                                        </div>";
+                echo "<div class=\"small-6 medium-4 large-3 columns\">";
+                echo "<div class=\"card\">
+                        <div class=\"title\">Sick</div>
+                        <div class=\"value\">".$totalSick." <small>Hours</small></div>
+                </div>";
                 echo "</div>";
-                echo "<div class=\"small-6 medium-4 large-3 columns end\">";
-                                        echo "<div class=\"card\">
-                                            <div class=\"title\">Vacation</div>
-                                            <div class=\"value\">".$totalVacation." <small>Hours</small></div>
-                                        </div>";
+                echo "<div class=\"small-6 medium-4 large-3 columns\">";
+                echo "<div class=\"card\">
+                    <div class=\"title\">Vacation</div>
+                    <div class=\"value\">".$totalVacation." <small>Hours</small></div>
+                </div>";
                 echo "</div>";
+
                 echo "</div>";
 
                 }