Example #1
0
 public function accounts($ids = null)
 {
     $user = new userModel();
     $id = $user->getId();
     $authLevel = $user->getAuthLevel();
     $accounts = new userModel();
     $users = $accounts->listAll();
     $data = array();
     if ($ids == null) {
         if ($user->getAuthLevel() >= 900) {
             $data['all'] = "All Accounts";
         }
         foreach ($users as $user) {
             if ($user['supervisorId'] == $id) {
                 $data[$user['id']] = $user['lastName'] . ", " . $user['firstName'] . " (" . $user['type'] . ")";
             } elseif ($authLevel >= 900) {
                 $data[$user['id']] = $user['lastName'] . ", " . $user['firstName'] . " (" . $user['type'] . ")";
             }
         }
     } else {
         $data[] = "all";
         foreach ($users as $user) {
             $data[] = $user['id'];
         }
     }
     return $data;
 }
 function accounts($ids = null)
 {
     $user = new userModel();
     $id = $user->getId();
     $authLevel = $user->getAuthLevel();
     $accounts = new userModel();
     $users = $accounts->listActive();
     $data = array();
     if ($ids == null) {
         if (count($users) > 0) {
             foreach ($users as $user) {
                 if ($user['type'] == 'part') {
                     $type = 'Part Time';
                 }
                 if ($user['type'] == 'full') {
                     $type = 'Full Time';
                 }
                 if ($user['supervisorId'] == $id) {
                     $data[$user['id']] = $user['lastName'] . ", " . $user['firstName'] . " ({$type})";
                 } elseif ($authLevel >= 900) {
                     $data[$user['id']] = $user['lastName'] . ", " . $user['firstName'] . " ({$type})";
                 }
             }
         }
     } else {
         if (count($users) > 0) {
             foreach ($users as $user) {
                 $data[] = $user['id'];
             }
         }
     }
     return $data;
 }
Example #3
0
 function getStaffIds($inactive = null)
 {
     $auth = Staple_Auth::get();
     $user = new userModel($auth->getAuthId());
     $userId = $user->getId();
     $authLevel = $user->getAuthLevel();
     $data = array();
     if ($authLevel >= 900) {
         if ($inactive == 1) {
             $sql = "\n                SELECT id, firstName, lastName FROM accounts WHERE status = 0 ORDER BY lastName ASC\n                ";
         } else {
             $sql = "\n                SELECT id, firstName, lastName FROM accounts WHERE status = 1 ORDER BY lastName ASC\n                ";
         }
     } else {
         if ($inactive == 1) {
             $sql = "\n                SELECT id, firstName, lastName FROM accounts WHERE status = 0 AND supervisorId = '" . $this->db->real_escape_string($userId) . "' ORDER BY lastName ASC\n                ";
         } else {
             $sql = "\n                SELECT id, firstName, lastName FROM accounts WHERE status = 1 AND supervisorId = '" . $this->db->real_escape_string($userId) . "' ORDER BY lastName ASC\n                ";
         }
     }
     $query = $this->db->query($sql);
     while ($result = $query->fetch_assoc()) {
         $data[$result['id']] = $result['lastName'] . ", " . $result['firstName'];
     }
     return $data;
 }
 public function _start()
 {
     $this->_setLayout('main');
     $auth = Staple_Auth::get();
     $user = new userModel();
     $user->userInfo($auth->getAuthId());
     $this->userId = $user->getId();
     $this->accountLevel = $user->getAuthLevel();
 }
 public function account()
 {
     $user = new userModel();
     if ($user->getAuthLevel() >= 500) {
         $form = new newMessageForm();
         $form->setAction($this->_link(array("messages", "account")));
         if ($form->wasSubmitted()) {
             $form->addData($_POST);
             if ($form->validate()) {
                 $data = $form->exportFormData();
                 if ($data['account'] == 'all') {
                     $message = new messageModel();
                     $message->setMessage($data['message']);
                     $message->setExpireDate($data['expireDate']);
                     $message->save();
                 } else {
                     $message = new privateMessageModel();
                     $message->setMessage($data['message']);
                     $message->setExpireDate($data['expireDate']);
                     $message->setUserId($data['account']);
                     $message->save();
                 }
                 $form = new newMessageForm();
                 $form->setAction($this->_link(array("messages", "account")));
                 $this->view->form = $form;
             } else {
                 $this->view->form = $form;
                 $this->layout->addScriptBlock('$(document).ready(function() { $("#newMessage").foundation("reveal", "open"); }); ');
             }
         } else {
             $this->view->form = $form;
         }
         $messages = new messagesModel();
         $this->view->messages = $messages;
     } else {
         header("location: " . $this->_link(array("messages", "account")) . "");
     }
 }
Example #6
0
 public function _start()
 {
     $user = new userModel();
     $this->authLevel = $user->getAuthLevel();
     $this->userId = $user->getId();
 }
Example #7
0
 function remove($id)
 {
     $this->db = Staple_DB::get();
     if ($id !== null) {
         $auth = Staple_Auth::get();
         $user = new userModel($auth->getAuthId());
         $userId = $user->getId();
         $accountLevel = $user->getAuthLevel();
         $entry = new timeEntryModel($id);
         $fullDate = $entry->getFullDate();
         $inTime = $entry->getInTime();
         $outTime = $entry->getOutTime();
         $effectedUserId = $entry->getUserId();
         $effectedUser = new userModel();
         $account = $effectedUser->userInfo($effectedUserId);
         //Check for admin account delete
         if ($accountLevel >= 900) {
             $sql = "DELETE FROM timeEntries WHERE id = '" . $this->db->real_escape_string($id) . "'";
             //AND userId <> '".$this->db->real_escape_string($userId)."'
             if ($this->db->query($sql)) {
                 $audit = new auditModel();
                 $audit->setUserId($account['id']);
                 $audit->setAction('Admin Entry Remove');
                 $audit->setItem($user->getUsername() . " removed entry for " . $fullDate . " In Time: " . $inTime . " Out Time: " . $outTime . "");
                 $audit->save();
                 return true;
             }
         } else {
             //Check if validated
             if ($this->validated($id)) {
                 $sql = "DELETE FROM timeEntries WHERE id = '" . $this->db->real_escape_string($id) . "' AND userId = '" . $this->db->real_escape_string($userId) . "'";
                 if ($this->db->query($sql)) {
                     return true;
                 }
             }
         }
     }
 }