Selaa lähdekoodia

Corrected a small bug when calculating the weeks start and end times.

Adam Day 9 vuotta sitten
vanhempi
commit
c26cc7e921

+ 13 - 0
application/forms/layouts/weeklyReportFormLayout.phtml

@@ -0,0 +1,13 @@
+<?php echo $this->formstart(); ?>
+    <div class="row">
+        <div class="small-6 columns">
+            <?php echo $this->fields['account'] ?>
+        </div>
+        <div class="small-6 columns">
+            <?php echo $this->fields['year'] ?>
+        </div>
+        <div class="small-12 columns">
+            <?php echo $this->fields['submit'] ?>
+        </div>
+    </div>
+<?php echo $this->formend(); ?>

+ 14 - 2
application/forms/weeklyReportForm.php

@@ -4,7 +4,7 @@ class weeklyReportForm extends Staple_Form
 {
     public function _start()
     {
-        //$this->setLayout('insertFormLayout');
+        $this->setLayout('weeklyReportFormLayout');
 
         $this->setName('weeklyReportForm')
             ->setAction($this->link(array('reports','weekly')));
@@ -17,6 +17,7 @@ class weeklyReportForm extends Staple_Form
 
         $year = new Staple_Form_FoundationTextElement('year','Year');
         $year->setRequired()
+            ->setValue(date('Y'))
             ->addValidator(new Staple_Form_Validate_Length(4,4))
             ->addValidator(new Staple_Form_Validate_Numeric());
 
@@ -28,6 +29,10 @@ class weeklyReportForm extends Staple_Form
 
     public function accounts($ids = null)
     {
+        $user = new userModel();
+        $id = $user->getId();
+        $authLevel = $user->getAuthLevel();
+
         $accounts = new userModel();
         $users = $accounts->listAll();
         $data = array();
@@ -35,7 +40,14 @@ class weeklyReportForm extends Staple_Form
         {
             foreach($users as $user)
             {
-                $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
+                if($user['supervisorId'] == $id)
+                {
+                    $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
+                }
+                elseif($authLevel >= 900)
+                {
+                    $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
+                }
             }
         }
         else

+ 1 - 1
application/models/weeklyReportModel.php

@@ -52,7 +52,7 @@ class weeklyReportModel extends Staple_Model
         $ret['start']['year'] = $dto->format('Y');
 
         //Week End
-        $dto->modify('+6 days')->setTime(24,0,0);
+        $dto->modify('+5 days')->setTime(24,0,0);
         $ret['end']['unix'] = $dto->format('U');
         $ret['end']['formatted'] = $dto->format('Y-m-d h:i:s');
         $ret['end']['dayName'] = $dto->format('l');

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

@@ -5,9 +5,13 @@
         </div>
     </div>
     <div class="row">
-        <div class="small-12 columns">
-            <ul class="button-group round right">
-                <li><a class="button small" href="<?php echo $this->link(array('reports','weekly')) ?>">Weekly Breakdown</a></li>
+        <div class="small-6 columns">
+            <ul class="button-group radius left">
+                <li><a class="button small" href="<?php echo $this->link(array('reports','weekly')) ?>">Week Report</a></li>
+            </ul>
+        </div>
+        <div class="small-6 columns">
+            <ul class="button-group radius right">
                 <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>

+ 13 - 6
application/views/reports/weekly.phtml

@@ -1,20 +1,27 @@
 <div class="section">
     <div class="row">
         <div class="small-12 columns">
-            <h2><i class="fa fa-file"></i> Weekly Breakdown Report</h2>
+            <h2><i class="fa fa-file"></i> Week Report</h2>
         </div>
     </div>
     <div class="row">
+        <div class="small-6 push-3 columns">
+            <?php echo $this->form; ?>
+        </div>
         <div class="small-12 columns">
             <?php
-
-                echo $this->form;
-
-                echo "<h3>".$this->account['firstName']." ".$this->account['lastName']."</h3>";
-
                 if(count($this->report) > 0)
                 {
                     echo "
+                        <div class='row'>
+                            <div class='small-6 columns'>
+                                <h3>".$this->account['firstName']." ".$this->account['lastName']."</h3>
+                            </div>
+                            <div class='small-6 columns'>
+                                <a class='button secondary radius right' href='".$this->link(array('reports','weekly'))."'>Back</a>
+                            </div>
+                        </div>
+
                     <table width=\"100%\">
                         <thead>
                         <tr>