Prechádzať zdrojové kódy

Merge pull request #29 from advation/accounts

Accounts
Adam 9 rokov pred
rodič
commit
37387ef85b

+ 77 - 18
application/controllers/reportsController.php

@@ -27,24 +27,41 @@ class reportsController extends Staple_Controller
             $month = date('m');
         }
 
+        $date = new DateTime();
+        $date->setDate($year,$month,26);
+        $date->setTime(0,0,0);
+
+        $this->view->year = $date->format('Y');
+
+        $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');
+
+        $date->modify('+1 year');
+
+        $month = $date->format('m');
+        $this->view->month = $month;
+
+        $date->modify('-1 month');
+        $this->view->previousMonth = $date->format('m');
+        $date->modify('+2 month');
+        $this->view->nextMonth = $date->format('m');
+
         $report = new reportModel($year, $month);
         $this->view->report = $report->getTimesheets();
 
-        $timesheet = new timesheetModel($year, $month);
-        $this->view->nextMonth = $timesheet->getNextMonth();
-        $this->view->previousMonth = $timesheet->getPreviousMonth();
-        $this->view->year = $timesheet->getCurrentYear();
-        $yearForm = new changeYearForm();
-        $yearForm->setAction($this->_link(array('reports','changeyear')));
-        $this->view->yearForm = $yearForm;
-
         $this->view->accountLevel = $this->authLevel;
 
         $date = new DateTime();
         $date->setDate($year, $month, 1);
-        $this->view->month = $date->format('F');
+        $this->view->monthName = $date->format('F');
 
         $printTimeSheetForm = new printTimeSheetForm();
+        $printTimeSheetForm->setAction($this->_link(array("reports",$year,$month)));
         if($printTimeSheetForm->wasSubmitted())
         {
             $printTimeSheetForm->addData($_POST);
@@ -171,10 +188,8 @@ class reportsController extends Staple_Controller
         $this->view->year = $year;
         $this->view->month = date('F',$month);
 
-
         $timesheet = new timesheetModel($year, $month,$uid);
         $this->view->timesheet = $timesheet;
-
     }
 
     public function payperiod($year = null, $month = null)
@@ -186,22 +201,54 @@ class reportsController extends Staple_Controller
         if ($month == null) {
             $month = date('m');
         }
-        $this->view->year = $year;
 
         $date = new DateTime();
         $date->setDate($year,$month,26);
         $date->setTime(0,0,0);
-        $this->view->month = $date->format('m');
-        $date->modify('-1 month');
-        $this->view->previousMonth = $date->format('m');
+
+        $year = $date->format('Y');
+        $this->view->year = $year;
+
+        $nextYear = $date->modify('+1 year')->format('Y');
+        $this->view->nextYear = $nextYear;
+
+        $previousYear = $date->modify('-2 year')->format('Y');
+        $this->view->previousYear = $previousYear;
+
+        $month = $date->format('m');
+        $this->view->month = $month;
+
+        $nextMonth = $date->modify('+1 month')->format('m');
+        $this->view->nextMonth = $nextMonth;
+
+        $previousMonth = $date->modify('-2 month')->format('m');
+        $this->view->previousMonth = $previousMonth;
+
+        $date->setDate($year,$month,26);
+        $date->setTime(0,0,0);
+
+        $newDate = new DateTime();
+
+        switch($month)
+        {
+            case 1:
+                $newDate->setDate($previousYear,$previousMonth,26);
+                break;
+            default:
+                $newDate->setDate($year,$previousMonth,26);
+        }
+
+        $newDate->setTime(0,0,0);
 
         $date2 = new DateTime();
         $date2->setDate($year,$month,25);
-        $date2->setTime(24,0,0);
+        $date2->setTime(24,00,00);
+        $interval = date_diff($newDate,$date2);
 
-        $interval = date_diff($date,$date2);
+        $span = $interval->days;
+        $this->view->span = $span;
 
-        $this->view->span = $interval->days;
+        $this->view->date = $date->format("F Y");
 
         $reports = new reportModel($year, $month);
         $this->view->report = $reports->payPeriodTotals($year, $month);
@@ -259,9 +306,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 +338,7 @@ class reportsController extends Staple_Controller
 
         $codes = new codeModel();
         $this->view->codes = $codes->allCodes();
+
     }
 
     public function payrollprint($year = null, $month =  null)

+ 2 - 0
application/controllers/timesheetController.php

@@ -96,12 +96,14 @@ class timesheetController extends Staple_Controller
         if($year == null)
         {
             $date = new DateTime();
+            $date->setTime(0,0,0);
             $year = $date->format('Y');
         }
 
         if($month == null)
         {
             $date = new DateTime();
+            $date->setTime(0,0,0);
             if($date->format("j") >= 26)
             {
                 $month = $date->modify('+1 month')->format('m');

+ 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">

+ 5 - 5
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>
                         ";
                     }
 
@@ -69,15 +69,15 @@
                                 <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 >
-                                    <li><a href=\"".$this->link(array('audit')) ."\" ><i class=\"fa fa-list-alt\" ></i > Audit Log</a ></li>
                                     <li><a href=\"".$this->link(array('reports','unlock'))."\"><i class=\"fa fa-unlock\"></i> Time Unlock</a></li>
                                 </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>
+                                    <li><a href=\"".$this->link(array('audit')) ."\" ><i class=\"fa fa-list-alt\" ></i > Audit Log</a ></li>
                                 </ul>
                             </li>
                             ";

+ 2 - 2
application/models/codeModel.php

@@ -105,11 +105,11 @@
 
 			if($type == 'part')
 			{
-				$sql = "SELECT id, name FROM timeCodes WHERE type = 'part' ORDER BY name ASC";
+				$sql = "SELECT id, name FROM timeCodes WHERE type = 'part' ORDER BY listOrder ASC";
 			}
 			else
 			{
-				$sql = "SELECT id, name FROM timeCodes WHERE 1 ORDER BY name ASC";
+				$sql = "SELECT id, name FROM timeCodes WHERE 1 ORDER BY listOrder ASC";
 			}
 
 			if($this->db->query($sql)->fetch_row() > 0)

+ 13 - 2
application/models/timesheetModel.php

@@ -319,19 +319,29 @@
 
 			//Current Dates
 			$currentDate = new DateTime();
+			$currentDate->setTime(0,0,0);
 			$currentDate->setDate($year, $month, 1);
 
+			//Just added for test. Might need to keep. Fixed the wrong
+			//$currentDate->setTime(0,0,0);
+
+
 			$this->currentYear = $currentDate->format('Y');
 			$this->currentMonth = $currentDate->format('m');
 			$this->currentMonthText = $currentDate->format('F');
+
+
 			$this->startDate = $currentDate->modify('-1 month +25 day')->format('Y-m-d');
 			$this->startDateTimeString = strtotime($this->startDate);
+
 			$currentDate->setDate($year, $month, 1);
-			$this->endDate = $currentDate->modify('+25 day')->format('Y-m-d');
+
+			$this->endDate = $currentDate->setTime(23,59.59)->modify('+25 day')->format('Y-m-d');
 			$this->endDateTimeString = strtotime($this->endDate);
 
 			//Previous Dates
 			$previousDate = new DateTime();
+			$previousDate->setTime(0,0,0);
 			$previousDate->setDate($year, $month, 1);
 			$previousDate->modify('-1 month');
 			$this->previousMonth = $previousDate->format('m');
@@ -342,6 +352,7 @@
 
 			//Future Dates
 			$furtureDate = new DateTime();
+			$furtureDate->setTime(23,59,59);
 			$furtureDate->setDate($year, $month, 1);
 			$furtureDate->modify('+1 month');
 			$this->nextMonth = $furtureDate->format('m');
@@ -447,7 +458,7 @@
 			}
 
 			//$sql = "SELECT ROUND((TIME_TO_SEC(SEC_TO_TIME(SUM(outTime - inTime)-SUM(lessTime*60)))/3600)*4)/4 AS 'totalTime' FROM timeEntries WHERE inTime > UNIX_TIMESTAMP('$startDate 00:00:00') AND outTime < UNIX_TIMESTAMP('$endDate 23:59:59') AND userId = $userId AND codeId = $code;";
-			$sql = "SELECT inTime, outTime, lessTime FROM timeEntries WHERE inTime > UNIX_TIMESTAMP('$startDate 00:00:00') AND outTime < UNIX_TIMESTAMP('$endDate 23:59:59') AND userId = $userId AND codeId = $code;";
+			$sql = "SELECT inTime, outTime, lessTime FROM timeEntries WHERE inTime > UNIX_TIMESTAMP('$startDate 00:00:00') AND outTime < UNIX_TIMESTAMP('$endDate 0:0:0') AND userId = $userId AND codeId = $code;";
 
 			if($this->db->query($sql)->fetch_row() > 0)
 			{

+ 2 - 0
application/models/userModel.php

@@ -205,6 +205,8 @@
 					$data[] = $result;
 				}
 				return $data;
+
+
 			}
 
 		}

+ 52 - 5
application/views/reports/index.phtml

@@ -4,7 +4,7 @@
             <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>
+            <h1 class="subheader"><?php echo $this->monthName ?> <?php echo $this->year?></h1>
         </div>
     </div>
     <div class="row">
@@ -16,13 +16,52 @@
         </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>
-                <li><a class="button small secondary" data-reveal-id="yearForm" href="#"><i class="fa fa-calendar"></i> Change Year</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
+                    switch ($this->month)
+                    {
+                        case 01:
+                            echo $this->link(array('reports',$this->previousYear, $this->previousMonth));
+                            break;
+                        default:
+                            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
+                    switch ($this->month)
+                    {
+                        case 12:
+                            echo $this->link(array('reports',$this->nextYear, $this->nextMonth));
+                            break;
+                        default:
+                            echo $this->link(array('reports',$this->year, $this->nextMonth));
+                    }
+                    ?>
+                    ">Next <i class="fa fa-caret-right"></i></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">
@@ -131,6 +170,14 @@
                 if(count($timesheet) > 0)
                 {
                 echo "</table>";
+
+                echo "<div class=\"row\">";
+                        echo "<div class='small-12'>
+
+                        FORM GOES HERE
+
+                        </div>";
+                echo "</div>";
                 echo "<div class=\"row\">";
                 echo "<div class=\"small-6 medium-4 large-3 columns\">";
                                         echo "<div class=\"card successBg\">

+ 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">

+ 40 - 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,24 +65,16 @@
                     <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>
+
                     <?php
 
                     foreach($this->report as $user=>$codes)
@@ -65,28 +83,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 +108,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>";
     }
     ?>