Parcourir la source

Updated weekly report to reflect if a user is a part time or full time employee. These updates include a threshold check. If a part time employee is getting close to 20 hours for a giving week the report indicates that. Another call out will occur when a part time user exceeds 20 hours in a given week.

Adam Day il y a 9 ans
Parent
commit
6071d38af5

+ 0 - 3
application/controllers/accountsController.php

@@ -17,9 +17,6 @@ class accountsController extends Staple_Controller
     public function index()
     {
         echo "Accounts";
-
-
-
     }
 }
 

+ 2 - 2
application/forms/weeklyReportForm.php

@@ -42,11 +42,11 @@ class weeklyReportForm extends Staple_Form
             {
                 if($user['supervisorId'] == $id)
                 {
-                    $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
+                    $data[$user['id']] = $user['lastName'].", ".$user['firstName']." (". $user['type'] .")";
                 }
                 elseif($authLevel >= 900)
                 {
-                    $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
+                    $data[$user['id']] = $user['lastName'].", ".$user['firstName']." (". $user['type'] .")";
                 }
             }
         }

+ 4 - 3
application/models/userModel.php

@@ -163,7 +163,7 @@
 			$this->db = Staple_DB::get();
 			$auth = Staple_Auth::get();
 			$username = $auth->getAuthId();
-			$sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId FROM accounts WHERE username = '".$this->db->real_escape_string($username)."'";
+			$sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type FROM accounts WHERE username = '".$this->db->real_escape_string($username)."'";
 
 			if($this->db->query($sql)->fetch_row() > 0)
 			{
@@ -177,6 +177,7 @@
 				$this->setAuthLevel($result['authLevel']);
 				$this->setBatchId($result['batchId']);
 				$this->setSupervisorId($result['supervisorId']);
+				$this->setType($result['type']);
 			}
 			else
 			{
@@ -186,7 +187,7 @@
 
 		function userInfo($id)
 		{
-			$sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId FROM accounts WHERE id = '".$this->db->real_escape_string($id)."'";
+			$sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type FROM accounts WHERE id = '".$this->db->real_escape_string($id)."'";
 			$query = $this->db->query($sql);
 			$result = $query->fetch_assoc();
 			return $result;
@@ -194,7 +195,7 @@
 
 		function listAll()
 		{
-			$sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId FROM accounts ORDER BY lastName ASC, firstName ASC";
+			$sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type FROM accounts ORDER BY type DESC, lastName ASC, firstName ASC";
 			if($this->db->query($sql)->num_rows > 0)
 			{
 				$query = $this->db->query($sql);

+ 1 - 0
application/models/weeklyReportModel.php

@@ -15,6 +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;
             ";

+ 45 - 2
application/views/reports/weekly.phtml

@@ -15,7 +15,18 @@
                     echo "
                         <div class='row'>
                             <div class='small-6 columns'>
-                                <h3>".$this->account['firstName']." ".$this->account['lastName']."</h3>
+                                <h3>".$this->account['firstName']." ".$this->account['lastName']." (";
+
+                                    if($this->account['type'] == "part")
+                                    {
+                                        echo "Part time";
+                                    }
+                                    else
+                                    {
+                                        echo "Full Time";
+                                    }
+
+                                echo")</h3>
                             </div>
                             <div class='small-6 columns'>
                                 <a class='button secondary radius right' href='".$this->link(array('reports','weekly'))."'>Back</a>
@@ -43,7 +54,39 @@
                                     <b>Start:</b> ".$entry['start']['dayName'].", ".$entry['start']['month']." ".$entry['start']['day']." ".$entry['start']['year']." <br>
                                     <b>End:</b> ".$entry['end']['dayName'].", ".$entry['end']['month']." ".$entry['end']['day']." ".$entry['end']['year']."
                                 </td>
-                                <td>".$entry['hoursWorked']."</td>
+                                <td>";
+
+                                    if($this->account['type'] == "part")
+                                    {
+                                        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>
+                                            ";
+                                        }
+                                        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>
+                                            ";
+                                        }
+                                        else
+                                        {
+                                            echo $entry['hoursWorked'];
+                                        }
+                                    }
+                                    else
+                                    {
+                                        echo $entry['hoursWorked'];
+                                    }
+
+                                echo "</td>
                             </tr>
                             ";
                             $i++;

+ 23 - 21
library/Staple/ExtendedDBAuthAdapter.class.php

@@ -132,37 +132,39 @@ class Staple_ExtendedDBAuthAdapter implements Staple_AuthAdapter
 		{
 			if (array_key_exists('pin', $cred))
 			{
-				$db = Staple_DB::get();
-				switch ($this->_settings['pwenctype'])
+				if($cred['pin'] != 0000)
 				{
-					case 'MD5':
-						$pass = md5($cred['pin']);
-						break;
-					case 'SHA1':
-						$pass = sha1($cred['pin']);
-						break;
-					default:
-						$pass = $cred['pin'];
-				}
+					$db = Staple_DB::get();
+					switch ($this->_settings['pwenctype'])
+					{
+						case 'MD5':
+							$pass = md5($cred['pin']);
+							break;
+						case 'SHA1':
+							$pass = sha1($cred['pin']);
+							break;
+						default:
+							$pass = $cred['pin'];
+					}
 
-				$sql = 'SELECT ' . $db->real_escape_string($this->_settings['pinfield']) . ',' . $db->real_escape_string($this->_settings['uidfield']) . '
+					$sql = 'SELECT ' . $db->real_escape_string($this->_settings['pinfield']) . ',' . $db->real_escape_string($this->_settings['uidfield']) . '
 FROM ' . $db->real_escape_string($this->_settings['authtable']) . '
 WHERE ' . $db->real_escape_string($this->_settings['pinfield']) . ' = ' .
-					'\'' . $db->real_escape_string($pass) . '\';';
+							'\'' . $db->real_escape_string($pass) . '\';';
 
-				if(($result = $db->query($sql)) !== false)
-				{
-					$myrow = $result->fetch_array();
-					//Secondary check to make sure the results did not differ from MySQL's response.
-					if($myrow[$this->_settings['pinfield']] == $pass)
+					if(($result = $db->query($sql)) !== false)
 					{
-						$this->uid = $myrow[$this->_settings['uidfield']];
-						return true;
+						$myrow = $result->fetch_array();
+						//Secondary check to make sure the results did not differ from MySQL's response.
+						if($myrow[$this->_settings['pinfield']] == $pass)
+						{
+							$this->uid = $myrow[$this->_settings['uidfield']];
+							return true;
+						}
 					}
 				}
 			}
 
-
 			if (array_key_exists('username', $cred) && array_key_exists('password', $cred))
 			{
 				$db = Staple_DB::get();