Permalink
Browse files

A more usable interface in addition to the old one

  • Loading branch information...
1 parent 814edc9 commit 1942ed8543edcecdad50d9d46774bdbb9721f989 @tareko committed Dec 19, 2012
Showing with 48 additions and 26 deletions.
  1. +34 −26 app/Controller/BillingsController.php
  2. +14 −0 app/View/Billings/index.ctp
@@ -12,36 +12,44 @@ function index() {
$this->loadModel('BillingsItem');
$this->loadModel('Shift');
- if (!isset($this->request->query['id']) || !isset($this->request->query['start_date']) || !isset($this->request->query['end_date'])) {
- return $this->render();
- }
-
- $conditions = array();
- if (isset($this->request->query['id'])) {
- $conditions = $conditions + array('user_id' => $this->request->query['id']);
- }
- if (isset($this->request->query['start_date'])) {
- $conditions = $conditions + array('Shift.date >=' => $this->request->query['start_date']);
- }
- if (isset($this->request->query['end_date'])) {
- $conditions = $conditions + array('Shift.date <=' => $this->request->query['end_date']);
- }
-
-
- $shiftsWorked = $this->Shift->getShiftList($conditions);
- foreach($shiftsWorked as $shift) {
- $patientsSeen[$i] = $shift;
- $patientsPerShift = $this->BillingsItem->distinctPatientsPerShift($shift);
- if ($patientsPerShift) {
- $patientsSeen[$i]['Billing'] = $patientsPerShift['0'];
+ if (isset($this->request->query['id']) && isset($this->request->query['start_date']) && isset($this->request->query['end_date'])) {
+
+ if (isset($this->request->query['start_date']['year'])) {
+ $start_date = $this->request->query['start_date']['year'].'-'.$this->request->query['start_date']['month'].'-'.$this->request->query['start_date']['day'];
}
else {
- $patientsSeen[$i]['Billing']['count'] = 'Unavailable';
+ $start_date = $this->request->query['start_date'];
+ }
+
+ if (isset($this->request->query['end_date']['year'])) {
+ $end_date = $this->request->query['end_date']['year'].'-'.$this->request->query['end_date']['month'].'-'.$this->request->query['end_date']['day'];
+ }
+ else {
+ $end_date = $this->request->query['end_date'];
+ }
+
+ $conditions = array();
+ $conditions = $conditions + array('user_id' => $this->request->query['id']);
+ $conditions = $conditions + array('Shift.date >=' => $start_date);
+ $conditions = $conditions + array('Shift.date <=' => $end_date);
+
+
+ $shiftsWorked = $this->Shift->getShiftList($conditions);
+ foreach($shiftsWorked as $shift) {
+ $patientsSeen[$i] = $shift;
+ $patientsPerShift = $this->BillingsItem->distinctPatientsPerShift($shift);
+ if ($patientsPerShift) {
+ $patientsSeen[$i]['Billing'] = $patientsPerShift['0'];
+ }
+ else {
+ $patientsSeen[$i]['Billing']['count'] = 'Unavailable';
+ }
+ $i = $i + 1;
}
- $i = $i + 1;
}
- $this->set(compact('patientsSeen'));
- $this->render();
+ $userList = $this->Shift->User->getList(NULL, NULL, true);
+ $this->set(compact('patientsSeen', 'userList'));
+ $this->render();
}
/* Upload function
*
@@ -1,3 +1,17 @@
+<?php
+echo $this->Form->create('Billing', array('type' => 'get'));
+
+echo $this->Form->select('id', $userList);
+echo $this->Form->input('start_date', array(
+ 'type' => 'date',
+ 'dateFormat' => 'D-M-Y'));
+echo $this->Form->input('end_date', array(
+ 'type' => 'date',
+ 'dateFormat' => 'D-M-Y'));
+
+echo $this->Form->end('Submit');
+
+?>
<table>
<tr><th>Physician</th><th>Date</th><th>Location</th><th>Shift</th><th>Patients seen</th></tr>
<?php

0 comments on commit 1942ed8

Please sign in to comment.