Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tareko/Kitab-Al-Shifa
base: 814edc93d2
...
head fork: tareko/Kitab-Al-Shifa
compare: e4ffb22902
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 53 additions and 25 deletions.
  1. +39 −25 app/Controller/BillingsController.php
  2. +14 −0 app/View/Billings/index.ctp
View
64 app/Controller/BillingsController.php
@@ -12,37 +12,51 @@ 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']);
- }
-
+ // If query is received, then start all the DB magic
+ if (isset($this->request->query['id']) && isset($this->request->query['start_date']) && isset($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'];
+ // Figure out if start date and end date are in simple YYYY-MM-DD or as array
+ 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'];
+ }
+
+ //Set conditions
+ $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);
+
+
+ //Get all shifts worked
+ $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
*
*/
View
14 app/View/Billings/index.ctp
@@ -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

No commit comments for this range

Something went wrong with that request. Please try again.