Răsfoiți Sursa

Added timestamp to the timesheet report view

Adam Day 9 ani în urmă
părinte
comite
136e85562d

+ 4 - 0
application/controllers/reportsController.php

@@ -29,6 +29,10 @@ class reportsController extends Staple_Controller
         $report = new reportModel($year, $month);
         $this->view->report = $report->getTimesheets();
 
+        echo "<pre>";
+        print_r($this->view->report);
+        echo "</pre>";
+
         $timesheet = new timesheetModel($year, $month);
         $this->view->nextMonth = $timesheet->getNextMonth();
         $this->view->previousMonth = $timesheet->getPreviousMonth();

+ 4 - 1
application/models/reportModel.php

@@ -66,7 +66,6 @@ class reportModel extends Staple_Model
 
     function getTimesheet($userId, $year, $month)
     {
-
         $currentDate = new DateTime();
         $currentDate->setDate($year, $month, 1);
 
@@ -91,6 +90,7 @@ class reportModel extends Staple_Model
         {
             $data[$result['id']] = $this->calculateEntry($result['id']);
         }
+
         return $data;
     }
 
@@ -120,6 +120,8 @@ class reportModel extends Staple_Model
 
         $lessTime = $result['lessTime'];
 
+        $timestamp = $result['timestamp'];
+
         //Calculate Time Worked
         switch($result['lessTime'])
         {
@@ -166,6 +168,7 @@ class reportModel extends Staple_Model
         $data['lessTime'] = $lessTime;
         $data['timeWorked'] = $timeWorked;
         $data['code'] = $codeName;
+        $data['timestamp'] = $timestamp;
 
         //Get the user of the entry.
         $entry = new timeEntryModel($id);

+ 19 - 0
application/models/timeEntryModel.php

@@ -21,6 +21,7 @@
         private $timeWorked;
         private $batchId;
         private $userId;
+        private $timestamp;
 
         /**
          * @return mixed
@@ -294,6 +295,23 @@
             $this->userId = $userId;
         }
 
+        /**
+         * @return mixed
+         */
+        public function getTimestamp()
+        {
+            return $this->timestamp;
+        }
+
+        /**
+         * @param mixed $timestamp
+         */
+        public function setTimestamp($timestamp)
+        {
+            $this->timestamp = $timestamp;
+        }
+
+
 		function __construct($id = null)
 		{
             $this->db = Staple_DB::get();
@@ -371,6 +389,7 @@
                     $this->setCodeName($code->getName());
 
                     $this->setUserId($result['userId']);
+                    $this->setTimestamp($result['timestamp']);
 
                     return true;
                 }

+ 4 - 1
application/views/reports/index.phtml

@@ -44,6 +44,7 @@
                             <th>Less Time</th>
                             <th>Hours</th>
                             <th>Code</th>
+                            <th>Date Stamp</th>
                             <th>Validated</th>
                         </tr>
                         </thead>
@@ -64,7 +65,9 @@
                                <td>".date("g:i A",$entry['outTime'])."</td>
                                <td>".$entry['lessTime']." <small>Hours</small></td>
                                <td>".$entry['timeWorked']."</td>
-                               <td>".$entry['code']."</td><td><div class='text-center'>";
+                               <td>".$entry['code']."</td>
+                               <td>".$entry['timestamp']."</td>
+                               <td><div class='text-center'>";
 
                     if($entry['validated'] == 1)
                     {