Example #1
0
 public function substitutePayrate($substituteid)
 {
     $payrate = '';
     $substitute = new Substitutes();
     $subs = $substitute->getById($substituteid);
     if ($subs) {
         $payrate = $subs->payrate;
     }
     return $payrate;
 }
Example #2
0
 public function substituteName($substituteid)
 {
     $substitutesModel = new Substitutes();
     $substitute = $substitutesModel->getById($substituteid);
     if (!$substitute) {
         $substituteName = "Not Set";
     } else {
         $substituteName = $substitute->lastname . ", " . $substitute->firstname;
     }
     return $substituteName;
 }
Example #3
0
function importRecords()
{
    $csvPath = APPLICATION_PATH . "/../data/imports.csv";
    $contents = file_get_contents($csvPath);
    $lines = explode("\n", $contents);
    $i = 0;
    $recordsModel = new Records();
    foreach ($lines as $line) {
        if ($i > 0) {
            $data = explode(",", $line);
            $substitutesModel = new Substitutes();
            $substitute = $substitutesModel->getBySecondaryId($data[13]);
            $locationsModel = new Locations();
            $location = $locationsModel->getByName($data[4]);
            $nameSegments = explode("|", $data[3]);
            $lastName = $nameSegments[0];
            $firstName = $nameSegments[1];
            $employeesModel = new Employees();
            $employee = $employeesModel->getByName($firstName, $lastName);
            if ($data[9] == 'FALSE' || $data[9] == FALSE) {
                $leaveForm = 0;
            } else {
                $leaveForm = 1;
            }
            if (!$substitute) {
                $subid = '129';
            } else {
                $subid = $substitute->id;
            }
            $recordData = array('date' => date('Y-m-d', strtotime($data[1])), 'employee' => @$employee->id, 'location' => @$location->id, 'substitute' => $subid, 'reason' => $data[6], 'notes' => $data[7], 'percent' => str_replace("%", "", $data[8]), 'leave_form' => $leaveForm, 'user' => 6, 'acct' => $data[14]);
            try {
                $recordsModel->insert($recordData);
            } catch (Exception $e) {
                echo $e->getMessage();
            }
            print_r($recordData);
        }
        $i++;
    }
}
Example #4
0
 public function editrecordsAction()
 {
     $recordsModel = new Records();
     $searchQuery = $this->getRequest()->getParam('search', false);
     $sort = $this->getRequest()->getParam('sort');
     $sorttype = $this->getRequest()->getParam('sorttype');
     $this->view->sort = $sort;
     $this->view->sorttype = $sorttype;
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if (!isset($data['method'])) {
             $id = $data['id'];
             unset($data['id']);
             if ($data['substitute'] == 129) {
                 $data['acct'] = '5-000-0-0000-0000-00000-0000-0';
             }
             $recordsModel->updateRecord($id, $data);
         } else {
             if ($data['method'] == 'remove') {
                 $recordsModel->deleteMultiple($data['ids']);
             }
             if ($data['method'] == 'skipToPage') {
                 $this->_redirect($this->view->url(array('page' => $data['gotopage'])));
             }
             if ($data['method'] == 'search') {
                 unset($data['method']);
                 $search = array();
                 if (trim($data['startdate']) != '') {
                     $startdate = date('Y-m-d', strtotime($data['startdate']));
                     $search['startdate'] = $startdate;
                 }
                 if (trim($data['enddate']) != '') {
                     $enddate = date('Y-m-d', strtotime($data['enddate']));
                     $search['enddate'] = $enddate;
                 }
                 if (trim($data['reason']) != '') {
                     $search['reason'] = $reason;
                 }
                 unset($data['startdate']);
                 unset($data['enddate']);
                 foreach ($data as $key => $value) {
                     if (trim($value) != '') {
                         $search[$key] = $value;
                     }
                 }
                 if (!empty($search)) {
                     $searchString = urlencode(base64_encode(serialize($search)));
                     $this->_redirect($this->view->url(array('search' => $searchString)));
                 }
             }
         }
     }
     $this->view->searchQuery = $searchQuery;
     $searchArray = unserialize(base64_decode(urldecode($searchQuery)));
     $this->view->search = (object) $searchArray;
     if ($this->_me->admin == 1) {
         $records = $recordsModel->getAll($sort, $sorttype, $searchArray);
     } else {
         $records = $recordsModel->getAllByLocation($this->_me->location, true, $searchArray);
     }
     $page = $this->_getParam('page', 1);
     $this->view->page = $page;
     $paginator = Zend_Paginator::factory($records);
     $paginator->setItemCountPerPage(20);
     $paginator->setCurrentPageNumber($page);
     $this->view->records = $paginator;
     $substitutesModel = new Substitutes();
     $this->view->substitutes = $substitutesModel->getAll();
     $locationsModel = new Locations();
     $this->view->locations = $locationsModel->getAll();
     $employeesModel = new Employees();
     if ($this->_me->admin == 1) {
         $this->view->employees = $employeesModel->getAll();
     } else {
         $this->view->employees = $employeesModel->getAllByLocation($this->_me->location);
     }
 }
Example #5
0
 public function substitutesAction()
 {
     $locationsModel = new Locations();
     $this->view->locations = $locationsModel->getAll();
     $substitutesModel = new Substitutes();
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if (@$data['method'] == 'create') {
             //CREATE NEW Location
             unset($data['method']);
             if ($data['firstname'] == '') {
                 $this->view->error = "Please Provide a Name for the New Substitute.";
                 $this->view->data = $data;
             } else {
                 if ($data['lastname'] == '') {
                     $this->view->error = "Please Provide a Name for the New Substitute.";
                     $this->view->data = $data;
                 } else {
                     if ($data['payrate'] == '') {
                         $this->view->error = "Please Provide a Payrate for the New Substitute.";
                         $this->view->data = $data;
                     } else {
                         $substitutesModel->insert($data);
                         $this->view->success = "New Substitute Created.";
                     }
                 }
             }
         }
         if (@$data['method'] == 'update') {
             //UPDATE Location
             unset($data['method']);
             $substitutesModel->updateRecord($data['id'], $data);
             $this->view->success = "Substitute Record Updated.";
         }
         if (@$data['method'] == 'delete') {
             //DELETE Location
             $where = "id=" . $data['id'];
             $substitutesModel->delete($where);
             $this->view->success = "Substitute Removed.";
         }
     }
     $term = $this->getRequest()->getParam('term', false);
     $substitutes = $substitutesModel->getAllTotal($term);
     $page = $this->_getParam('page', 1);
     $paginator = Zend_Paginator::factory($substitutes);
     $paginator->setItemCountPerPage(20);
     $paginator->setCurrentPageNumber($page);
     $this->view->substitutes = $paginator;
 }