Pārlūkot izejas kodu

Fixed some issues with the admin reports.

Adam Day 9 gadi atpakaļ
vecāks
revīzija
07eee69555

+ 23 - 0
application/controllers/reportsController.php

@@ -191,9 +191,20 @@ class reportsController extends Staple_Controller
         $date = new DateTime();
         $date->setDate($year,$month,26);
         $date->setTime(0,0,0);
+
+        $this->view->date = $date->format("F Y");
+
+        $date->modify('+1 year');
+        $this->view->nextYear = $date->format('Y');
+
+        $date->modify('-2 year');
+        $this->view->previousYear = $date->format('Y');
+
         $this->view->month = $date->format('m');
         $date->modify('-1 month');
         $this->view->previousMonth = $date->format('m');
+        $date->modify('+2 month');
+        $this->view->nextMonth = $date->format('m');
 
         $date2 = new DateTime();
         $date2->setDate($year,$month,25);
@@ -259,9 +270,20 @@ class reportsController extends Staple_Controller
         $date = new DateTime();
         $date->setDate($year,$month,26);
         $date->setTime(0,0,0);
+
+        $this->view->date = $date->format("F Y");
+
+        $date->modify('+1 year');
+        $this->view->nextYear = $date->format('Y');
+
+        $date->modify('-2 year');
+        $this->view->previousYear = $date->format('Y');
+
         $this->view->month = $date->format('m');
         $date->modify('-1 month');
         $this->view->previousMonth = $date->format('m');
+        $date->modify('+2 month');
+        $this->view->nextMonth = $date->format('m');
 
         $date2 = new DateTime();
         $date2->setDate($year,$month,25);
@@ -280,6 +302,7 @@ class reportsController extends Staple_Controller
 
         $codes = new codeModel();
         $this->view->codes = $codes->allCodes();
+
     }
 
     public function payrollprint($year = null, $month =  null)

+ 2 - 2
application/forms/layouts/adminInsertFormLayout.phtml

@@ -1,7 +1,7 @@
 <div class="section">
     <div class="row">
-        <div class="small-12 columns text-center">
-            <h2>Admin Time Insert</h2>
+        <div class="small-12 columns">
+            <h2><i class="fa fa-plus"></i> Admin Time Insert</h2>
         </div>
     </div>
     <div id="entryForm">

+ 4 - 4
application/layouts/main.phtml

@@ -53,7 +53,7 @@
                     if($user->getAuthLevel() >= 500)
                     {
                         echo "
-                            <li><a href=\"".$this->link(array('reports')) ."\"><i class=\"fa fa-file\"></i> Staff Timesheet Reports</a></li>
+                            <li><a href=\"".$this->link(array('reports')) ."\"><i class=\"fa fa-file\"></i> Staff Timesheets</a></li>
                         ";
                     }
 
@@ -74,10 +74,10 @@
                                 </ul>
                             </li>
                             <li class=\"has-dropdown\">
-                                <a href=\"#\"><i class='fa fa-file'></i> Reports</a>
+                                <a href=\"#\"><i class='fa fa-file'></i> Admin Reports</a>
                                 <ul class=\"dropdown\">
-                                    <li><a href=\"".$this->link(array('reports','payroll'))."\"><i class=\"fa fa-usd\"></i> Payroll Report</a></li>
-                                    <li><a href=\"".$this->link(array('reports','payperiod'))."\"><i class=\"fa fa-clock-o\"></i> Pay Period Report</a></li>
+                                    <li><a href=\"".$this->link(array('reports','payroll'))."\"><i class=\"fa fa-file\"></i> Month Totals</a></li>
+                                    <li><a href=\"".$this->link(array('reports','payperiod'))."\"><i class=\"fa fa-file\"></i> Daily Totals</a></li>
                                 </ul>
                             </li>
                             ";

+ 18 - 3
application/views/reports/index.phtml

@@ -16,13 +16,28 @@
         </div>
         <div class="small-8 columns">
             <ul class="button-group round right">
-                <li><a class="button small secondary" href="<?php echo $this->link(array('reports',$this->year, $this->previousMonth))?> "><i class="fa fa-caret-left"></i> Previous</a></li>
-                <li><a class="button small secondary" href="<?php echo $this->link(array('reports',$this->year, $this->nextMonth))?> ">Next <i class="fa fa-caret-right"></i></a></li>
+                <?php
+
+                $year = $this->year;
+
+                if($this->month == 12)
+                {
+                    $year = $this->nextYear;
+                }
+
+                if($this->momth == 1)
+                {
+                    $year = $this->previousYear;
+                }
+
+
+                ?>
+                <li><a class="button small secondary" href="<?php echo $this->link(array('reports',$year, $this->previousMonth))?> "><i class="fa fa-caret-left"></i> Previous</a></li>
+                <li><a class="button small secondary" href="<?php echo $this->link(array('reports',$year, $this->nextMonth))?> ">Next <i class="fa fa-caret-right"></i></a></li>
                 <li><a class="button small secondary" data-reveal-id="yearForm" href="#"><i class="fa fa-calendar"></i> Change Year</a></li>
                 <li><a id="showAll" class="button small secondary" href="#"><i class="fa fa-eye"></i> Show All</a></li>
                 <li><a id="hideAll" class="button small secondary" href="#"><i class="fa fa-eye-slash"></i> Hide All</a></li>
             </ul>
-
         </div>
     </div>
     <div class="row">

+ 28 - 2
application/views/reports/payperiod.phtml

@@ -1,10 +1,36 @@
 <div class="section">
     <div class="row">
         <div class="small-6 columns">
-            <h2><i class="fa fa-file"></i> Pay Period Report</h2>
+            <h2><i class="fa fa-file"></i> Daily Totals <small><?php echo $this->date ?></small></h2>
         </div>
         <div class="small-6 columns text-right">
-            <a class="button radius" target="_blank" href="<?php echo $this->link(array('reports','payperiodprint',$this->year,$this->month)) ?>"><i class='fa fa-print'></i> Print</a>
+            <ul class="button-group round">
+                <li><a class="button small secondary" href="
+                    <?php
+                    switch ($this->month)
+                    {
+                        case 01:
+                            echo $this->link(array('reports','payperiod',$this->previousYear, $this->previousMonth));
+                            break;
+                        default:
+                            echo $this->link(array('reports','payperiod',$this->year, $this->previousMonth));
+                    }
+                    ?>
+                    "><i class="fa fa-caret-left"></i> Previous</a></li>
+                <li><a class="button small secondary" href="
+                    <?php
+                    switch ($this->month)
+                    {
+                        case 12:
+                            echo $this->link(array('reports','payperiod',$this->nextYear, $this->nextMonth));
+                            break;
+                        default:
+                            echo $this->link(array('reports','payperiod',$this->year, $this->nextMonth));
+                    }
+                    ?>
+                    ">Next <i class="fa fa-caret-right"></i></a></li>
+                <li><a class="button small" target="_blank" href="<?php echo $this->link(array('reports','payperiodprint',$this->year,$this->month)) ?>"><i class='fa fa-print'></i> Print</a></li>
+            </ul>
         </div>
     </div>
     <div class="row">

+ 39 - 22
application/views/reports/payroll.phtml

@@ -1,10 +1,36 @@
 <div class="section">
     <div class="row">
         <div class="small-6 columns">
-            <h2><i class="fa fa-file"></i> Payroll Report</h2>
+            <h2><i class="fa fa-file"></i> Month Totals <small><?php echo $this->date ?></small></h2>
         </div>
         <div class="small-6 columns text-right">
-            <a class="button radius" target="_blank" href="<?php echo $this->link(array('reports','payrollprint',$this->year,$this->month)) ?>"><i class='fa fa-print'></i> Print</a>
+            <ul class="button-group round">
+                <li><a class="button small secondary" href="
+                    <?php
+                        switch ($this->month)
+                        {
+                            case 01:
+                                echo $this->link(array('reports','payroll',$this->previousYear, $this->previousMonth));
+                                break;
+                            default:
+                                echo $this->link(array('reports','payroll',$this->year, $this->previousMonth));
+                        }
+                    ?>
+                    "><i class="fa fa-caret-left"></i> Previous</a></li>
+                <li><a class="button small secondary" href="
+                    <?php
+                        switch ($this->month)
+                        {
+                            case 12:
+                                echo $this->link(array('reports','payroll',$this->nextYear, $this->nextMonth));
+                                break;
+                            default:
+                                echo $this->link(array('reports','payroll',$this->year, $this->nextMonth));
+                        }
+                    ?>
+                    ">Next <i class="fa fa-caret-right"></i></a></li>
+                <li><a class="button small" target="_blank" href="<?php echo $this->link(array('reports','payrollprint',$this->year,$this->month)) ?>"><i class='fa fa-print'></i> Print</a></li>
+            </ul>
         </div>
     </div>
     <div class="row">
@@ -39,21 +65,12 @@
                     <tr>
                        <th style="width:150px;"></th>
                        <?php
-
                            foreach($this->codes as $code)
                            {
-                               if($code == 'Normal')
-                               {
-                                   echo "<th style='background-color:#d8ffd3;'>$code</th>";
-                               }
-                               else
-                               {
-                                   echo "<th>$code</th>";
-                               }
-
+                                echo "<th>$code</th>";
                            }
-
                        ?>
+                       <th>Total</th>
                     </tr>
                     </thead>
                     <tbody>
@@ -65,28 +82,23 @@
                         echo "<tr>";
                         echo "<td style='border-bottom:1px solid #ccc;'><b>$user</b></td>";
 
-                        //for($j=1;$j<=count($this->codes);$j++)
+                        $totals=0;
                         foreach($this->codes as $id=>$timeCode)
                         {
-                            if($timeCode == 'Normal')
-                            {
-                                echo "<td class='text-center' style='background-color:#d8ffd3; border-bottom:1px solid #ccc;'>";
-                            }
-                            else
-                            {
-                                echo "<td class='text-center' style='border-bottom:1px solid #ccc;'>";
-                            }
+                            echo "<td class='text-center' style='border-bottom:1px solid #ccc;'>";
                             $value = "-";
                             foreach ($codes as $code => $total)
                             {
                                 if($timeCode == $code)
                                 {
                                     $value = $total;
+                                    $totals = $totals + $total;
                                 }
                             }
                             echo $value;
                             echo "</td>";
                         }
+                        echo "<td class='text-center'><b>$totals</b></td>";
                         echo "</tr>";
                     }
                     ?>
@@ -95,4 +107,9 @@
             </div>
         </div>
     </div>
+</div>
+<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>
+    <?php echo $this->yearForm ?>
+    <a class="close-reveal-modal" aria-label="Close">&#215;</a>
 </div>

+ 7 - 23
application/views/reports/payrollprint.phtml

@@ -1,4 +1,3 @@
-
 <style>
     table {
         border:1px solid #ccc;
@@ -25,7 +24,7 @@
 </style>
 <table width="100%" style="border:0px; padding:0px; margin:0px;">
     <tr>
-        <td style="border:0px;"><h3><i class="fa fa-clock-o"></i> Payroll Report: <?php echo date("F",$this->month) ?> <?php echo $this->year ?></h3></td>
+        <td style="border:0px;"><h3><i class="fa fa-clock-o"></i> Month Totals: <?php echo date("F",strtotime($this->year."-".$this->month."-01")) ?> <?php echo $this->year ?></h3></td>
         <td style="border:0px;" class="text-right"><?php echo $this->startDate ?> - <?php echo $this->endDate ?></td>
     </tr>
 </table>
@@ -34,21 +33,12 @@
     <tr>
        <th style="width:150px;"></th>
        <?php
-
            foreach($this->codes as $code)
            {
-               if($code == 'Normal')
-               {
-                   echo "<th style='background-color:#d8ffd3;'>$code</th>";
-               }
-               else
-               {
-                   echo "<th>$code</th>";
-               }
-
+               echo "<th>$code</th>";
            }
-
        ?>
+        <th>Totals</th>
     </tr>
     </thead>
     <tbody>
@@ -56,32 +46,26 @@
 
     foreach($this->report as $user=>$codes)
     {
-
         echo "<tr>";
         echo "<td style='border-bottom:1px solid #ccc;'><b>$user</b></td>";
 
-        //for($j=1;$j<=count($this->codes);$j++)
+        $totals=0;
         foreach($this->codes as $id=>$timeCode)
         {
-            if($timeCode == 'Normal')
-            {
-                echo "<td class='text-center' style='background-color:#d8ffd3; border-bottom:1px solid #ccc;'>";
-            }
-            else
-            {
-                echo "<td class='text-center' style='border-bottom:1px solid #ccc;'>";
-            }
+            echo "<td class='text-center' style='border-bottom:1px solid #ccc;'>";
             $value = "-";
             foreach ($codes as $code => $total)
             {
                 if($timeCode == $code)
                 {
                     $value = $total;
+                    $totals = $totals + $total;
                 }
             }
             echo $value;
             echo "</td>";
         }
+        echo "<td class='text-center'><b>$totals</b></td>";
         echo "</tr>";
     }
     ?>