瀏覽代碼

Updated dashboard and some styling.

Adam Day 9 年之前
父節點
當前提交
4b552ab100

+ 10 - 0
application/controllers/indexController.php

@@ -2,12 +2,14 @@
 class indexController extends Staple_Controller
 {
 	private $authLevel;
+	private $userId;
 
 	public function _start()
 	{
 		$auth = Staple_Auth::get();
 		$user = new userModel();
 		$this->authLevel = $user->getAuthLevel();
+		$this->userId = $user->getId();
 	}
 
 	public function index()
@@ -19,6 +21,14 @@ class indexController extends Staple_Controller
 
 		$timesheet = new timesheetModel(date('Y'),date('m'));
 		$this->view->timesheet = $timesheet;
+
+		$date = new DateTime();
+		$week = $date->format('W');
+		$year = $date->format('Y');
+
+		$report = new weeklyReportModel();
+
+		$this->view->week = $report->getWeekWorked($this->userId, $week, $year);
 	}
 }
 ?>

+ 1 - 1
application/forms/layouts/editFormLayout.phtml

@@ -25,7 +25,7 @@
     }
     ?>
 </div>
-<div class="row">
+<div class="row hide-for-print">
     <?php echo $this->formstart(); ?>
     <div class="small-12 medium-4 columns">
         <?php echo $this->fields['date'] ?>

+ 1 - 1
application/forms/layouts/insertFormLayout.phtml

@@ -1,4 +1,4 @@
-<div class="info">
+<div class="info hide-for-print">
     <div class="row" id="entryToggle">
         <div class="small-12 columns text-center">
             <p><br><a class="" href="#"><i id="entryToggleIcon" class="fa fa-chevron-circle-up"></i> <span id="entryToggleText">Hide</span></a></p>

+ 1 - 1
application/layouts/main.phtml

@@ -28,7 +28,7 @@
                 </h4>
             </div>
         </div>
-        <div class="contain-to-grid">
+        <div class="contain-to-grid hide-for-print">
         <nav class="top-bar" data-topbar role="navigation">
             <ul class="title-area">
                 <li class="name">

+ 17 - 6
application/models/timeEntryModel.php

@@ -476,8 +476,14 @@
             $user = new userModel($auth->getAuthId());
             $userId = $user->getId();
 
+            /*
             $dateString = strtotime(date("Y-m-d", $inTime));
             $nextDateString = $dateString + 86400;
+            */
+            $date = new DateTime();
+            $dateString = $inTime;
+            $nextDateString = $date->setTimestamp($inTime)->setTime(23,59,59);
+            $nextDateString = $nextDateString->format('U');
 
             //Find the earliest time for the given date.
             $sql = "
@@ -493,9 +499,16 @@
                 SELECT outTime FROM timeEntries WHERE outTime > '".$this->db->real_escape_string($dateString)."' AND outTime < '".$this->db->real_escape_string($nextDateString)."' AND userId = '".$this->db->real_escape_string($userId)."' ORDER BY outTime DESC LIMIT 1
             ";
 
-            $query = $this->db->query($sql);
-            $result = $query->fetch_assoc();
-            $lastOutTime = $result['outTime'];
+            if($this->db->query($sql)->num_rows > 0)
+            {
+                $query = $this->db->query($sql);
+                $result = $query->fetch_assoc();
+                $lastOutTime = $result['outTime'];
+            }
+            else
+            {
+                $lastOutTime = null;
+            }
 
             if($id == null)
             {
@@ -506,8 +519,6 @@
                 $sql = "SELECT inTime, outTime FROM timeEntries WHERE userId = '".$this->db->real_escape_string($userId)."' AND id <> '".$this->db->real_escape_string($id)."'";
             }
 
-
-
             $query = $this->db->query($sql);
             $data = array();
             while($result = $query->fetch_assoc())
@@ -535,7 +546,7 @@
 
                 if($inTime < $firstInTime && $outTime > $lastOutTime)
                 {
-                    $overlap++;
+                    //$overlap++;
                 }
             }
 

+ 30 - 6
application/models/weeklyReportModel.php

@@ -15,7 +15,7 @@ class weeklyReportModel extends Staple_Model
         for($i=1;$i<53;$i++)
         {
             $weeks[$i] = $this->getStartAndEndDate($i, $year);
-            
+
             $sql = "
               SELECT ROUND((TIME_TO_SEC(SEC_TO_TIME(SUM(outTime - inTime)-SUM(lessTime*60)))/3600)*4)/4 AS 'totalTime' FROM timeEntries WHERE inTime >= ".$weeks[$i]['start']['unix']." AND outTime <= ".$weeks[$i]['end']['unix']." AND userId = $uid;
             ";
@@ -27,13 +27,37 @@ class weeklyReportModel extends Staple_Model
                 $result = $query->fetch_assoc();
                 $total = $result['totalTime'];
             }
-
             $weeks[$i]['hoursWorked'] = $total;
         }
 
         return $weeks;
     }
 
+    function getWeekWorked($uid,$week,$year)
+    {
+        $week = $this->getStartAndEndDate($week, $year);
+
+        $sql = "
+              SELECT ROUND((TIME_TO_SEC(SEC_TO_TIME(SUM(outTime - inTime)-SUM(lessTime*60)))/3600)*4)/4 AS 'totalTime' FROM timeEntries WHERE inTime >= ".$week['start']['unix']." AND outTime <= ".$week['end']['unix']." AND userId = $uid;
+            ";
+
+        $total = 0;
+        if($this->db->query($sql)->num_rows > 0)
+        {
+            $query = $this->db->query($sql);
+            $result = $query->fetch_assoc();
+            $total = $result['totalTime'];
+        }
+
+        if($total == 0)
+        {
+            $total = "0";
+        }
+
+        $week['total'] = $total;
+        return $week;
+    }
+
     function getStartAndEndDate($week, $year)
     {
         $dto = new DateTime();
@@ -44,18 +68,18 @@ class weeklyReportModel extends Staple_Model
         $ret['year'] = $year;
 
         //Week Start
-        $dto->setTime(0,0,0);
+        $dto->setTime(24,0,0);
         $ret['start']['unix'] = $dto->format('U');
-        $ret['start']['formatted'] = $dto->format('Y-m-d h:i:s');
+        $ret['start']['formatted'] = $dto->format('Y-m-d');
         $ret['start']['dayName'] = $dto->format('l');
         $ret['start']['day'] = $dto->format('jS');
         $ret['start']['month'] = $dto->format('F');
         $ret['start']['year'] = $dto->format('Y');
 
         //Week End
-        $dto->modify('+5 days')->setTime(24,0,0);
+        $dto->modify('+5 days')->setTime(23,59,59);
         $ret['end']['unix'] = $dto->format('U');
-        $ret['end']['formatted'] = $dto->format('Y-m-d h:i:s');
+        $ret['end']['formatted'] = $dto->format('Y-m-d');
         $ret['end']['dayName'] = $dto->format('l');
         $ret['end']['day'] = $dto->format('jS');
         $ret['end']['month'] = $dto->format('F');

+ 44 - 50
application/views/index/index.phtml

@@ -16,55 +16,49 @@
         ";
     }
 ?>
-<div class="section">
-    <div class="row">
-        <div class="small-12 columns text-center">
-            <h2>Current Pay Period</h2>
-            <h3 class="subheader"><?php echo date('F') ?> <?php echo date('Y') ?></h3>
-        </div>
-    </div>
-    <div class="row">
-        <div class="small-12 columns">
-            <ul class="small-block-grid-3">
-                <li>
-                    <div class="card primary">
-                        <div class="title">Title</div>
-                        <div class="value">Value</div>
-                    </div>
-                </li>
-                <li>
-                    <div class="card">
-                        <div class="title">Title</div>
-                        <div class="value">Value</div>
-                    </div>
-                </li>
-                <li>
-                    <div class="card">
-                        <div class="title">Title</div>
-                        <div class="value">Value</div>
-                    </div>
-                </li>
-            </ul>
-        </div>
-    </div>
-    <div class="row">
-        <div class="small-12 columns text-center">
-            <ul class="button-group round">
-                <li><a class="button success" href="<?php echo $this->link(array("timesheet")) ?>"><i class="fa fa-plus"></i> New Time Entry</a></li>
-                <?php
-                    //Supervisor Level
-                    if($this->authLevel >= 500)
-                    {
-                        echo "<li><a class=\"button\" href=\"".$this->link(array("reports")) ."\"><i class=\"fa fa-file\"></i> View Reports</a></li>";
-                    }
+<div class="section info">
+        <?php
+        echo "
+            <div class=\"row\">
+                <div class='small-12 columns text-center'>
+                    <h2>Time submitted this week</h2>
+                    <p>".$this->week['start']['month']." ".$this->week['start']['day']." ".$this->week['year']." to ".$this->week['end']['month']." ".$this->week['end']['day']." ".$this->week['year']."</p>
+                </div>
+                <div class='small-12 columns text-center'>
+                    <h2>".$this->week['total']."</h2>
+                </div>
+            </div>
+        ";
+
+        echo "</div>";
+        echo "<div class='section'>";
 
-                    //Administrator Level
-                    if($this->authLevel >= 900)
-                    {
-                        echo "<li><a class=\"button\" href=\"".$this->link(array("timesheet")) ."\"><i class=\"fa fa-users\"></i> Manage Users</a></li>";
-                    }
-                ?>
-            </ul>
-        </div>
+        if($this->timesheet->totals['Total Time'] > 0)
+        {
+            echo "
+            <div class=\"row\">
+                <div class=\"small-12 columns\">
+                    <h2>".date('F')." ".date('Y')." <small> Hours</small></h2>
+                </div>
+            </div>";
+        }
+
+        foreach($this->timesheet->totals as $key=>$value)
+        {
+            if($value > 0)
+            {
+                echo "
+                    <div class='row'>
+                        <div class='small-6 columns'>
+                            <h4>$key</h4>
+                        </div>
+                        <div class='small-6 columns'>
+                            <h4>$value</>
+                        </div>
+                    </div>
+                ";
+            }
+        }
+        ?>
     </div>
-</div>
+</div>

+ 7 - 13
application/views/reports/weekly.phtml

@@ -58,23 +58,17 @@
 
                                     if($this->account['type'] == "part")
                                     {
-                                        if($entry['hoursWorked'] >= 18 AND $entry['hoursWorked'] <= 20)
+                                        if($entry['hoursWorked'] >= 18 AND $entry['hoursWorked'] < 20)
                                         {
-                                            echo "
-                                                <span class='orange'>
-                                                    <p>WARNING: Approaching weekly limit of 20 hours.</p>
-                                                    <i class='fa fa-warning'></i> ".$entry['hoursWorked']."
-                                                </span>
-                                            ";
+                                            echo "<span class='orange'><i class='fa fa-flag'></i> Approaching weekly limit of 20 hours.</span> <b>".$entry['hoursWorked']."</b>";
+                                        }
+                                        elseif($entry['hoursWorked'] == 20)
+                                        {
+                                            echo "<span class='green'><i class='fa fa-flag'></i> At weekly limit of 20 hours.</span> <b>".$entry['hoursWorked']."</b>";
                                         }
                                         elseif($entry['hoursWorked'] >= 21)
                                         {
-                                            echo "
-                                                <span class='red'>
-                                                    <p>Warning: Exceeded weekly limit of 20 hours.</p>
-                                                    <i class='fa fa-warning'></i> ".$entry['hoursWorked']."
-                                                </span>
-                                            ";
+                                            echo "<span class='red'><i class='fa fa-warning'></i> Exceeded weekly limit of 20 hours.</span> <b>".$entry['hoursWorked']."</b>";
                                         }
                                         else
                                         {

+ 3 - 3
application/views/timesheet/index.phtml

@@ -4,7 +4,7 @@
         <div class="small-12 medium-4 text-left columns">
             <h3><i class="fa fa-calendar"></i> <?php echo $this->timesheet->currentMonthText ?> <a href="#" data-reveal-id="yearForm"><?php echo $this->timesheet->currentYear ?></a></h3>
         </div>
-        <div class="small-12 medium-8 text-right columns">
+        <div class="small-12 medium-8 text-right columns hide-for-print">
             <ul class="button-group round even-5 stack-for-small">
                 <li><a class="button small secondary" href="<?php echo $this->link(array('timesheet',$this->timesheet->currentYear,$this->timesheet->previousMonth)) ?>"><i class="fa fa-caret-left"></i> Prev.</a></li>
                 <li><a class="button small secondary" href="<?php echo $this->link(array('timesheet',$this->timesheet->currentYear,$this->timesheet->nextMonth)) ?>">Next <i class="fa fa-caret-right"></i></a></li>
@@ -22,7 +22,7 @@
 <?php
     echo "
         <div class=\"row\">
-            <div class=\"small-12 columns\">
+            <div class=\"small-12 columns hide-for-print\">
                 <ul class=\"inline-list right\">
                     <li><a id=\"hideAll\" href=\"#\"><i class=\"fa fa-eye-slash\"></i> Hide All</a></li>
                     <li><a id=\"showAll\" href=\"#\"><i class=\"fa fa-eye\"></i> Show All</a></li>
@@ -36,7 +36,7 @@
         echo "
             <div class=\"row\" style=\"margin-bottom:10px;\">
                 <div class=\"small-4 medium-2 columns\">
-                    <b>Date</b>
+                   &nbsp;
                 </div>
                 <div class=\"small-4 medium-2 columns\">
                     <b>Time In</b> <small>(Adjusted)</small>

File diff suppressed because it is too large
+ 0 - 0
public/style/app.css


File diff suppressed because it is too large
+ 0 - 0
public/style/app.css.map


+ 6 - 1
public/timetrackerStyle/scss/_settings.scss

@@ -126,7 +126,13 @@ $primary-color: #315476;
  $info-color: #cde0e8;
 
 //TimeTracker
+.blue {
+  color: $primary-color;
+}
 
+.grey {
+  color: #666;
+}
 .green {
   color:$success-color;
 }
@@ -244,7 +250,6 @@ $primary-color: #315476;
   padding:20px;
 }
 
-
 // We use these to control various global styles
 // $body-bg: $white;
 // $body-font-color: $jet;

Some files were not shown because too many files changed in this diff