소스 검색

Added notes to individual time entires. These notes can only be added by an Admin time insert action.

Adam Day 9 년 전
부모
커밋
28306c630c

+ 4 - 0
application/controllers/reportsController.php

@@ -38,6 +38,10 @@ class reportsController extends Staple_Controller
         $this->view->yearForm = $yearForm;
 
         $this->view->accountLevel = $this->authLevel;
+
+        $date = new DateTime();
+        $date->setDate($year, $month, 1);
+        $this->view->month = $date->format('F');
     }
 
     public function changeyear()

+ 4 - 4
application/controllers/timesheetController.php

@@ -155,7 +155,7 @@ class timesheetController extends Staple_Controller
                 }
                 else
                 {
-                    $this->view->message = "ERROR: Could not remove entry.";
+                    $this->view->message = "ERROR: Cannot remove entry.";
                 }
             }
             else
@@ -344,6 +344,7 @@ class timesheetController extends Staple_Controller
 
     }
 
+    /* TODO REMOVE
     public function unlocked()
     {
         $form = new unlockDatesForm();
@@ -354,9 +355,6 @@ class timesheetController extends Staple_Controller
             if($form->validate())
             {
                 $data = $form->exportFormData();
-                echo "<pre>";
-                print_r($data);
-                echo "</pre>";
             }
             else
             {
@@ -369,6 +367,7 @@ class timesheetController extends Staple_Controller
         }
 
     }
+    */
 
     public function admininsert()
     {
@@ -392,6 +391,7 @@ class timesheetController extends Staple_Controller
                     $entry->setLessTime($data['lessTime']);
                     $entry->setCodeId($data['code']);
                     $entry->setUserId($data['account']);
+                    $entry->setNote($data['note']);
 
                     //Save entry data to table.
                     if($entry->adminSave())

+ 2 - 0
application/forms/editTimeForm.php

@@ -17,11 +17,13 @@ class editTimeForm extends Staple_Form
         $inTime = new Staple_Form_FoundationTextElement('inTime','Time In');
         $inTime->setRequired()
             ->addValidator(new Staple_Form_Validate_Length('1','8'))
+            ->addValidator(new Staple_Form_Validate_Regex('/^(0|[0-9]|1[012]):[0-5][0-9] ?((a|p)m|(A|P)M)$/','Invalid time format. Expected format: h:mm am/pm.'))
             ->addAttrib('placeholder','h:mm am/pm');
 
         $outTime = new Staple_Form_FoundationTextElement('outTime','Time Out');
         $outTime->setRequired()
             ->addValidator(new Staple_Form_Validate_Length('1','8'))
+            ->addValidator(new Staple_Form_Validate_Regex('/^(0|[0-9]|1[012]):[0-5][0-9] ?((a|p)m|(A|P)M)$/','Invalid time format. Expected format: h:mm am/pm.'))
             ->addAttrib('placeholder','h:mm am/pm');;
 
         $lessTime = new Staple_Form_FoundationSelectElement('lessTime','Less Time');

+ 8 - 2
application/forms/insertTimeForm.php

@@ -94,13 +94,19 @@ class insertTimeForm extends Staple_Form
                 {
                     $this->setAction($this->link(array('timesheet','admininsert')));
                     $this->setLayout('adminInsertFormLayout');
-                    $account = new Staple_Form_FoundationSelectElement('account','Account');
 
+                    $account = new Staple_Form_FoundationSelectElement('account','Account');
                     $account->setRequired()
                         ->addOption('','Select an account')
                         ->addOptionsArray($this->accounts())
                         ->addValidator(new Staple_Form_Validate_InArray($this->accounts(1)));
-                    $this->addField($account);
+
+                    $note = new Staple_Form_FoundationTextElement('note','Note');
+                    $note->setRequired()
+                        ->addValidator(new Staple_Form_Validate_Length(1,5000))
+                        ->addFilter(new Staple_Form_Filter_Trim());
+
+                    $this->addField($account, $note);
                 }
             }
         }

+ 11 - 8
application/forms/layouts/adminInsertFormLayout.phtml

@@ -40,29 +40,32 @@
                    ?>
                 </div>
                 <div class="row">
-                    <div class="small-12 medium-12 columns">
+                    <div class="small-6 medium-4 columns">
                         <?php echo $this->fields['account'] ?>
                     </div>
-                </div>
-                <div class="row">
                     <div class="small-6 medium-4 columns">
                         <?php echo $this->fields['date'] ?>
                     </div>
-                    <div class="small-6 medium-4 columns">
+                    <div class="small-6 medium-4 columns end">
                         <?php echo $this->fields['inTime'] ?>
                     </div>
+                </div>
+                <div class="row">
                     <div class="small-6 medium-4 columns">
                         <?php echo $this->fields['outTime'] ?>
                     </div>
-                </div>
-                <div class="row">
                     <div class="small-6 medium-4 columns">
                         <?php echo $this->fields['lessTime'] ?>
                     </div>
-                    <div class="small-6 medium-4 columns">
+                    <div class="small-6 medium-4 columns end">
                         <?php echo $this->fields['code'] ?>
                     </div>
-                    <div class="small-6 medium-4 columns">
+                </div>
+                <div class="row">
+                    <div class="small-6 medium-8 columns">
+                        <?php echo $this->fields['note'] ?>
+                    </div>
+                    <div class="small-6 medium-4 columns end">
                         <br>
                         <?php echo $this->fields['submit'] ?>
                     </div>

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

@@ -48,4 +48,29 @@
 
     </div>
     <?php echo $this->formend(); ?>
-</div>
+</div>
+<script>
+    <?php
+    $date = new DateTime();
+
+    if($date->format('d') > 25)
+    {
+        $date->modify('+1 month');
+    }
+    $maxDate = $date->setDate($date->format('Y'),$date->format('m'),25)->format('m/d/Y');
+    $minDate = $date->modify('-1 month +1 day');
+    $minDate = $date->format('m/d/Y');
+    ?>
+
+    $(document).ready(function() {
+        $(function() {
+            $( "#date" ).datepicker({
+                numberOfMonths:2,
+                minDate: "<?php echo $minDate ?>",
+                maxDate: "<?php echo $maxDate ?>",
+                showWeek: true,
+                showButtonPanel: true
+            });
+        });
+    });
+</script>

+ 8 - 7
application/layouts/main.phtml

@@ -41,30 +41,31 @@
             <section class="top-bar-section">
                 <!-- Right Nav Section -->
                 <ul class="left">
-                    <li><a href="<?php echo $this->link(array('index')) ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
-                    <li><a href="<?php echo $this->link(array('timesheet')) ?>"><i class="fa fa-clock-o"></i> Timesheet</a></li>
+                    <li><a href="<?php echo $this->link(array('index')) ?>"><i class="fa fa-dashboard"></i> Your Dashboard</a></li>
+                    <li><a href="<?php echo $this->link(array('timesheet')) ?>"><i class="fa fa-clock-o"></i> Your Timesheet</a></li>
+                </ul>
+
+                <!-- Right Nav Section -->
+                <ul class="right">
                     <?php
 
                     //Supervisor Accounts
                     if($user->getAuthLevel() >= 500)
                     {
                         echo "
-                            <li><a href=\"".$this->link(array('reports')) ."\"><i class=\"fa fa-file\"></i> Timesheet Reports</a></li>
+                            <li><a href=\"".$this->link(array('reports')) ."\"><i class=\"fa fa-file\"></i> Staff Timesheet Reports</a></li>
                         ";
                     }
 
                     ?>
-                </ul>
 
-                <!-- Right Nav Section -->
-                <ul class="right">
                     <?php
                         //Administrative Accounts
                         if($user->getAuthLevel() >= 900)
                         {
                             echo "
                             <li class=\"has-dropdown\">
-                                <a href=\"#\">Admin Tools</a>
+                                <a href=\"#\"><i class='fa fa-gear'></i> Admin Tools</a>
                                 <ul class=\"dropdown\">
                                     <li><a href=\"".$this->link(array('accounts')) ."\"><i class=\"fa fa-users\"></i> Accounts</a></li>
                                     <li><a href=\"".$this->link(array('timesheet','admininsert'))."\" ><i class=\"fa fa-plus\" ></i > Admin Time Insert </a ></li >

+ 2 - 1
application/models/reportModel.php

@@ -119,8 +119,8 @@ class reportModel extends Staple_Model
         $outTimeDate = date("Y-m-d", $result['outTime']);
 
         $lessTime = $result['lessTime'];
-
         $timestamp = $result['timestamp'];
+        $note = $result['note'];
 
         //Calculate Time Worked
         switch($result['lessTime'])
@@ -169,6 +169,7 @@ class reportModel extends Staple_Model
         $data['timeWorked'] = $timeWorked;
         $data['code'] = $codeName;
         $data['timestamp'] = $timestamp;
+        $data['note'] = $note;
 
         //Get the user of the entry.
         $entry = new timeEntryModel($id);

+ 37 - 12
application/models/timeEntryModel.php

@@ -22,6 +22,7 @@
         private $batchId;
         private $userId;
         private $timestamp;
+        private $note;
 
         /**
          * @return mixed
@@ -311,6 +312,24 @@
             $this->timestamp = $timestamp;
         }
 
+        /**
+         * @return mixed
+         */
+        public function getNote()
+        {
+            return $this->note;
+        }
+
+        /**
+         * @param mixed $note
+         */
+        public function setNote($note)
+        {
+            $this->note = $note;
+        }
+
+
+
 
 		function __construct($id = null)
 		{
@@ -333,7 +352,7 @@
                     //Set inTime
                     $inTime = new DateTime();
                     $inTime->setTimestamp($result['inTime']);
-                    $this->setInTime($inTime->format('h:i A'));
+                    $this->setInTime($inTime->format('g:i A'));
                     $this->setInTimeRaw($result['inTime']);
                     $this->setRoundedInTime($this->nearestQuarterHour($result['inTime']));
                     $this->setInTimeDate(date("Y-m-d", $result['inTime']));
@@ -341,7 +360,7 @@
                     //Out Time
                     $outTime = new DateTime();
                     $outTime->setTimestamp($result['outTime']);
-                    $this->setOutTime($outTime->format('h:i A'));
+                    $this->setOutTime($outTime->format('g:i A'));
                     $this->setOutTimeRaw($result['outTime']);
                     $this->setRoundedOutTime($this->nearestQuarterHour($result['outTime']));
                     $this->setOutTimeDate(date("Y-m-d", $result['outTime']));
@@ -390,6 +409,7 @@
 
                     $this->setUserId($result['userId']);
                     $this->setTimestamp($result['timestamp']);
+                    $this->setNote($result['note']);
 
                     return true;
                 }
@@ -418,17 +438,21 @@
                 //Check for admin account delete
                 if($accountLevel >= 900)
                 {
-                    $sql = "DELETE FROM timeEntries WHERE id = '".$this->db->real_escape_string($id)."' AND userId <> '".$this->db->real_escape_string($userId)."'";
-
-                    if($this->db->query($sql))
+                    //Check for active admin account
+                    if($account['id'] != $user->getId())
                     {
-                        $audit = new auditModel();
-                        $audit->setUserId($account['id']);
-                        $audit->setAction('Admin Entry Remove');
-                        $audit->setItem($user->getUsername()." removed entry for ".$fullDate." In Time: ".$inTime." Out Time: ".$outTime."");
-                        $audit->save();
+                        $sql = "DELETE FROM timeEntries WHERE id = '".$this->db->real_escape_string($id)."' AND userId <> '".$this->db->real_escape_string($userId)."'";
 
-                        return true;
+                        if($this->db->query($sql))
+                        {
+                            $audit = new auditModel();
+                            $audit->setUserId($account['id']);
+                            $audit->setAction('Admin Entry Remove');
+                            $audit->setItem($user->getUsername()." removed entry for ".$fullDate." In Time: ".$inTime." Out Time: ".$outTime."");
+                            $audit->save();
+
+                            return true;
+                        }
                     }
                 }
                 else
@@ -671,13 +695,14 @@
 
                     $sql = "
                   INSERT INTO timeEntries
-                  (userId,inTime,outTime,lessTime,codeId,batchId)
+                  (userId,inTime,outTime,lessTime,codeId,note,batchId)
                   VALUES (
                   '".$this->db->real_escape_string($this->userId)."',
                   '".$this->db->real_escape_string($inTime)."',
                   '".$this->db->real_escape_string($outTime)."',
                   '".$this->db->real_escape_string($this->lessTime)."',
                   '".$this->db->real_escape_string($this->codeId)."',
+                  '".$this->db->real_escape_string($this->note)."',
                   '".$this->db->real_escape_string("ADMIN ADD")."'
                   )
                 ";

+ 27 - 9
application/views/reports/index.phtml

@@ -1,8 +1,11 @@
 <div class="section">
     <div class="row">
-        <div class="small-12 columns">
+        <div class="small-6 columns">
             <h1><i class="fa fa-file"></i> Reports</h1>
         </div>
+        <div class="small-6 columns text-right">
+            <h1 class="subheader"><?php echo $this->month ?> <?php echo $this->year?></h1>
+        </div>
     </div>
     <div class="row">
         <div class="small-4 columns">
@@ -45,8 +48,12 @@
                             <th>Hours</th>
                             <th>Code</th>
                             <th>Date Stamp</th>
-                            <th>Validated</th>
-                        </tr>
+                            <th>Validated</th>";
+                            if($this->accountLevel >= 900)
+                            {
+                                echo "<th>Action</th>";
+                            }
+                        echo"</tr>
                         </thead>
                     ";
                 }
@@ -60,13 +67,13 @@
                 {
                     echo "
                         <tr>
-                               <td>".$entry['date']."</td>
+                               <td>".date("l, F jS Y",strtotime($entry['date']))."</td>
                                <td>".date("g:i A",$entry['inTime'])."</td>
                                <td>".date("g:i A",$entry['outTime'])."</td>
                                <td>".$entry['lessTime']." <small>Hours</small></td>
                                <td>".$entry['timeWorked']."</td>
                                <td>".$entry['code']."</td>
-                               <td>".$entry['timestamp']."</td>
+                               <td>".date("M. jS Y @ G:i A",strtotime($entry['timestamp']))."</td>
                                <td><div class='text-center'>";
 
                     if($entry['validated'] == 1)
@@ -78,14 +85,25 @@
                         echo "<i class=\"fa fa-close red\"></i>";
                     }
 
+                    echo "</td>";
+
                     if($this->accountLevel >= 900)
                     {
-                        echo " | <a href=\"".$this->link(array('timesheet','remove',$key))."\"><i class=\"fa fa-trash\"></i></a>";
+                        echo "<td><a class='button tiny radius warning' href=\"".$this->link(array('timesheet','remove',$key))."\"><i class=\"fa fa-trash\"></i> Delete</a></td>";
                     }
 
-                    echo "</td>
-                        </tr>
-                    ";
+                    echo "</tr>";
+
+                    if(strlen($entry['note']) > 0)
+                    {
+                        echo "
+                            <tr>
+                                <td colspan='9'>
+                                    <b>Note:</b> ".$entry['note']."
+                                </td>
+                            </tr>
+                        ";
+                    }
 
                     if($entry['validated'] == 1)
                     {

+ 1 - 2
application/views/reports/unlock.phtml

@@ -6,8 +6,7 @@
     </div>
     <div class="row">
         <div class="small-12 columns">
-            <hr>
-            <h3>Current Pay Period Entry Unlock</h3>
+            <p>Unlocks validated entries for the current pay period.</p>
             <?php
                 if(count($this->accounts->timesheets) > 0)
                 {

+ 6 - 1
application/views/timesheet/index.phtml

@@ -85,7 +85,7 @@
             }
 
             echo "
-            <div class=\"row\" style=\"border-bottom:1px #ccc solid; padding:10px;\"> \n
+            <div class=\"row\" style=\"padding-top:5px;\"> \n
                <div class=\"small-4 medium-2 columns\"> \n";
                if($entry->batchId == "ADMIN ADD")
                {
@@ -120,6 +120,11 @@
                 <div class=\"small-4 medium-2 columns\"> \n
                     ".$entry->codeName." \n
                 </div> \n
+            </div>
+            <div class=\"row\" style='border-bottom:1px #a7a7a7 solid; '>
+                <div class=\"small-12 medium-10 medium-push-2 columns\"> \n
+                   ".$entry->note."
+                </div> \n
             </div> <!-- end row --> \n
             ";