Parcourir la source

Adjusted how the time fields were being scrubbed. This now happens with regex at the form validation for each time field.

Adam Day il y a 9 ans
Parent
commit
58b60a8e7d

+ 2 - 3
application/controllers/timesheetController.php

@@ -241,14 +241,13 @@ class timesheetController extends Staple_Controller
                             if($entry->save())
                             {
                                 //Return a new time form with success message
-                                $form = new insertTimeForm();
                                 $form->successMessage = array("<i class=\"fa fa-check\"></i> Entry saved for ".$data['date']."");
                                 $this->view->form = $form;
                             }
                             else
                             {
                                 //Return the same form with a warning message
-                                $message = "<i class=\"fa fa-warning\"></i> Cannot insert overlapping time entries. Please add a new entry or edit an already existing one.";
+                                $message = "<i class=\"fa fa-warning\"></i> Cannot insert overlapping time entries. If you are updating an already existing entry, remove that entry and submit a new one.";
                                 $form->errorMessage = array($message);
                                 $this->view->form = $form;
                             }
@@ -256,7 +255,7 @@ class timesheetController extends Staple_Controller
                         else
                         {
                             //Return the same form with error message.
-                            $form->errorMessage = array("<b>'Time In'</b> entry cannot be before <b>'Time Out'</b> entry.");
+                            $form->errorMessage = array("<i class='fa fa-warning'></i> <b>'Time In'</b> entry cannot be before <b>'Time Out'</b> entry.");
                             $this->view->form = $form;
                         }
                     }

+ 22 - 10
application/forms/layouts/editFormLayout.phtml

@@ -1,20 +1,32 @@
 <div class="row">
     <?php
-        if(count($this->message) > 0)
+    if(count($this->errorMessage) > 0)
+    {
+
+        echo "<div data-alert class=\"alert-box warning\">";
+        foreach($this->errorMessage as $message)
         {
-            echo "<div class=\"small-12 columns\">";
-            echo "<div data-alert class=\"alert-box alert\">";
-            foreach($this->message as $message)
-            {
-                echo $message;
-            }
-            echo "<a href=\"#\" class=\"close\">&times;</a></div>";
-            echo "</div>";
+            echo $message;
         }
-        echo $this->formstart();
+        echo "<a href=\"#\" class=\"close\">&times;</a></div>";
+
+    }
+
+    if(count($this->successMessage) > 0)
+    {
+
+        echo "<div data-alert class=\"alert-box success\">";
+        foreach($this->successMessage as $message)
+        {
+            echo $message;
+        }
+        echo "<a href=\"#\" class=\"close\">&times;</a></div>";
+
+    }
     ?>
 </div>
 <div class="row">
+    <?php echo $this->formstart(); ?>
     <div class="small-12 medium-4 columns">
         <?php echo $this->fields['date'] ?>
     </div>

+ 4 - 13
application/models/timeEntryModel.php

@@ -365,24 +365,15 @@
                         )";
 
                     $query = $this->db->query($sql);
-                    if($query === true)
+                    if ($query === true)
                     {
                         return true;
                     }
-                    else
-                    {
-                        return false;
-                    }
-                }
-                else
-                {
-                    return false;
                 }
 			}
 			else
 			{
-                //TODO Check for overlap
-                if($this->_overlap($inTime))
+                if($this->_overlap($inTime,$this->getId()))
                 {
                     //Update item
                     $sql = "UPDATE timeEntries SET
@@ -430,7 +421,7 @@
             }
         }
 
-        function _overlap($inTime)
+        function _overlap($inTime,$id = null)
         {
             $this->db = Staple_DB::get();
 
@@ -438,7 +429,7 @@
             $user = new userModel($auth->getAuthId());
             $userId = $user->getId();
 
-            $sql = "SELECT id FROM timeEntries WHERE '".$this->db->real_escape_string($inTime)."' >= inTime AND '".$this->db->real_escape_string($inTime)."' < outTime AND userId = '".$this->db->real_escape_string($userId)."'";
+            $sql = "SELECT id FROM timeEntries WHERE '".$this->db->real_escape_string($inTime)."' >= inTime AND '".$this->db->real_escape_string($inTime)."' < outTime AND id <> '".$this->db->real_escape_string($id)."' AND userId = '".$this->db->real_escape_string($userId)."'";
 
             if($this->db->query($sql)->num_rows > 0)
             {

+ 5 - 2
application/views/timesheet/edit.phtml

@@ -1,9 +1,12 @@
 <div class="section">
     <div class="row">
-        <div class="small-6 columns">
+        <div class="small-4 columns">
             <a class="button secondary radius" href="<?php echo $this->link(array('timesheet')) ?>"><i class="fa fa-chevron-left"></i> Back</a>
         </div>
-        <div class="small-6 columns text-right">
+        <div class="small-4 columns text-center">
+            <h2><i class="fa fa-edit"></i> Edit Entry</h2>
+        </div>
+        <div class="small-4 columns text-right">
             <a  class="button radius alert" href="#" data-reveal-id="confirm"><i class="fa fa-trash"> Remove</i></a>
         </div>
         <div class="small-12 columns">

+ 39 - 34
application/views/timesheet/index.phtml

@@ -18,13 +18,13 @@
                 ?>
             </ul>
         </div>
-    </div>
+    </div><!-- end row -->
 <?php
 
     if(count($this->timesheet->entries) > 0)
     {
         echo "
-            <div class=\"row\">
+            <div class=\"row\" style=\"margin-bottom:10px;\">
                 <div class=\"small-4 medium-2 columns\">
                     <b>Date</b>
                 </div>
@@ -43,54 +43,54 @@
                 <div class=\"small-4 medium-2 columns\">
                     <b>Code</b>
                 </div>
-                <hr>
-            </div>
+            </div><!-- end row -->
         ";
-        $date = null;
+        $date = 0;
+
         foreach($this->timesheet->entries as $entry)
         {
             if($date != $entry->date)
             {
                 echo "
-                    <div class=\"row\">
-                        <div class=\"small-12 columns\" style=\"padding:10px;\">
-                            <b>$entry->fullDate</b>
+                    <div class=\"row marker\" style=\"border-bottom:1px #ccc solid; background-color:#eaeaea; padding-top:15px; padding-bottom:15px;\"> \n
+                        <div class=\"small-12 columns timeTitle\" >
+                            <b>".$entry->fullDate."</b><i class=\"right fa fa-chevron-up\"></i>\n
                         </div>
-                    </div>
+                    </div> <!-- end row --> \n
                 ";
             }
 
             echo "
-            <div class=\"row\">
-                <div class=\"small-4 medium-2 columns\">";
+            <div class=\"row\" style=\"border-bottom:1px #ccc solid; padding:10px;\"> \n
+               <div class=\"small-4 medium-2 columns\"> \n";
 
                if($this->timesheet->getBatch() == $entry->batchId)
                {
-                    echo "<a href=\"".$this->link(array('timesheet','edit',$entry->id))."\"><i class=\"fa fa-edit\"></i> Edit</a>";
+                    echo "<a class=\"button radius tiny\" style=\"margin:0px; width:100%; left:-15px;\" href=\"".$this->link(array('timesheet','edit',$entry->id))."\"><i class=\"fa fa-edit\"></i> Edit</a> \n";
                }
                else
                {
-                   echo "<i class=\"fa fa-check green\"></i> Validated ";
+                   echo "<i class=\"fa fa-lock\"></i> Validated \n";
                }
 
             echo "
-                </div>
-                <div class=\"small-4 medium-2 columns\">
-                    <span data-tooltip aria-haspopup=\"true\" class=\"has-tip\" title=\"Entered as: ".$entry->inTime."\">".$entry->roundedInTime."</span>
-                </div>
-                <div class=\"small-4 medium-2 columns\">
-                    <span data-tooltip aria-haspopup=\"true\" class=\"has-tip\" title=\"Entered as: ".$entry->outTime."\">".$entry->roundedOutTime."</span>
-                </div>
-                <div class=\"small-4 medium-2 columns\">
-                    ".$entry->lessTime." Min.
-                </div>
-                <div class=\"small-4 medium-2 columns\">
-                    ".$entry->timeWorked." Hours
-                </div>
-                <div class=\"small-4 medium-2 columns\">
-                    ".$entry->codeName."
-                </div>
-            </div>
+                </div> \n
+                <div class=\"small-4 medium-2 columns\"> \n
+                    <span data-tooltip aria-haspopup=\"true\" class=\"has-tip\" title=\"Entered as: ".$entry->inTime."\">".$entry->roundedInTime."</span> \n
+                </div> \n
+                <div class=\"small-4 medium-2 columns\"> \n
+                    <span data-tooltip aria-haspopup=\"true\" class=\"has-tip\" title=\"Entered as: ".$entry->outTime."\">".$entry->roundedOutTime."</span> \n
+                </div> \n
+                <div class=\"small-4 medium-2 columns\"> \n
+                    ".$entry->lessTime." Min. \n
+                </div> \n
+                <div class=\"small-4 medium-2 columns\"> \n
+                    ".$entry->timeWorked." Hours \n
+                </div> \n
+                <div class=\"small-4 medium-2 columns\"> \n
+                    ".$entry->codeName." \n
+                </div> \n
+            </div> <!-- end row --> \n
             ";
 
             $date = $entry->date;
@@ -103,12 +103,11 @@
                 <div class=\"small-12 columns text-center\">
                     No time submitted.
                 </div>
-            </div>
+            </div><!-- end row -->
         ";
     }
-
 ?>
-</div>
+</div><!-- end section -->
 
 <div id="yearForm" class="reveal-modal small" data-reveal aria-labelledby="Change Year" aria-hidden="true" role="dialog">
     <h2 id="modalTitle">Select a Year</h2>
@@ -124,7 +123,7 @@
         <div class="small-2 columns text-right">
             <a class="button secondary small radius toggleTotals" href="#"><i class="fa fa-chevron-up"></i></a>
         </div>
-    </div>
+    </div> <!-- end row -->
     <div class="row">
         <div class="small-6 medium-4 large-3 columns totals">
             <b>Normal: </b> <?php echo $this->timesheet->normalWorked ?>
@@ -156,5 +155,11 @@
 
             $("#totals").slideToggle();
         });
+
+        $(".timeTitle").click(function() {
+            $(this).parent().nextUntil(".marker").slideToggle("slow");
+            $(this).find("i").toggleClass("fa-chevron-up fa-chevron-down")
+        });
+
     });
 </script>

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
public/style/app.css


Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
public/style/app.css.map


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

@@ -117,7 +117,7 @@ $include-html-global-classes: $include-html-classes;
 
 // We use these as default colors throughout
 // $primary-color: #008CBA;
-$primary-color: #374350;
+$primary-color: #315476;
 
  $secondary-color: #e7e7e7;
  $alert-color: #f04124;
@@ -372,7 +372,6 @@ $primary-color: #374350;
 // $anchor-text-decoration-hover: none;
 
 // $anchor-font-color: $primary-color;
-   $anchor-font-color: #79797e;
 // $anchor-font-color-hover: scale-color($anchor-font-color, $lightness: -14%);
 
 // We use these to style the <hr> element

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff