123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <?php
- class userModel extends Staple_Model
- {
- private $db;
- private $id;
- private $username;
- private $firstName;
- private $lastName;
- private $type;
- private $authLevel;
- private $supervisorId;
- private $batchId;
- private $pin;
- /**
- * @return mixed
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param mixed $id
- */
- public function setId($id)
- {
- $this->id = $id;
- }
- /**
- * @return mixed
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @param mixed $username
- */
- public function setUsername($username)
- {
- $this->username = $username;
- }
- /**
- * @return mixed
- */
- public function getFirstName()
- {
- return $this->firstName;
- }
- /**
- * @param mixed $firstName
- */
- public function setFirstName($firstName)
- {
- $this->firstName = $firstName;
- }
- /**
- * @return mixed
- */
- public function getLastName()
- {
- return $this->lastName;
- }
- /**
- * @param mixed $lastName
- */
- public function setLastName($lastName)
- {
- $this->lastName = $lastName;
- }
- /**
- * @return mixed
- */
- public function getType()
- {
- return $this->type;
- }
- /**
- * @param mixed $type
- */
- public function setType($type)
- {
- $this->type = $type;
- }
- /**
- * @return mixed
- */
- public function getAuthLevel()
- {
- return $this->authLevel;
- }
- /**
- * @param mixed $authLevel
- */
- public function setAuthLevel($authLevel)
- {
- $this->authLevel = $authLevel;
- }
- /**
- * @return mixed
- */
- public function getSupervisorId()
- {
- return $this->supervisorId;
- }
- /**
- * @param mixed $supervisorId
- */
- public function setSupervisorId($supervisorId)
- {
- $this->supervisorId = $supervisorId;
- }
- /**
- * @return mixed
- */
- public function getBatchId()
- {
- return $this->batchId;
- }
- /**
- * @param mixed $batchId
- */
- public function setBatchId($batchId)
- {
- $this->batchId = $batchId;
- }
- /**
- * @return mixed
- */
- public function getPin()
- {
- return $this->pin;
- }
- /**
- * @param mixed $pin
- */
- public function setPin($pin)
- {
- $this->pin = $pin;
- }
- function __construct()
- {
- $this->db = Staple_DB::get();
- $auth = Staple_Auth::get();
- $username = $auth->getAuthId();
- $sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type FROM accounts WHERE username = '".$this->db->real_escape_string($username)."'";
- if($this->db->query($sql)->fetch_row() > 0)
- {
- $query = $this->db->query($sql);
- $result = $query->fetch_assoc();
- $this->setid($result['id']);
- $this->setUsername($result['username']);
- $this->setFirstName($result['firstName']);
- $this->setLastName($result['lastName']);
- $this->setAuthLevel($result['authLevel']);
- $this->setBatchId($result['batchId']);
- $this->setSupervisorId($result['supervisorId']);
- $this->setType($result['type']);
- }
- else
- {
- return false;
- }
- }
- function userInfo($id)
- {
- $sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type, status FROM accounts WHERE id = '".$this->db->real_escape_string($id)."'";
- $query = $this->db->query($sql);
- $result = $query->fetch_assoc();
- return $result;
- }
- function listAll()
- {
- $sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type, status FROM accounts WHERE status = 1 ORDER BY lastName ASC, firstName ASC";
- if($this->db->query($sql)->num_rows > 0)
- {
- $query = $this->db->query($sql);
- while($result = $query->fetch_assoc())
- {
- $data[] = $result;
- }
- return $data;
- }
- }
- function listActive()
- {
- $sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type, status FROM accounts WHERE status = 1 ORDER BY lastName ASC, firstName ASC";
- if($this->db->query($sql)->num_rows > 0)
- {
- $query = $this->db->query($sql);
- while($result = $query->fetch_assoc())
- {
- $data[] = $result;
- }
- return $data;
- }
- }
- function listInactive()
- {
- $sql = "SELECT id, username, firstName, lastName, authLevel, batchId, supervisorId, type, status FROM accounts WHERE status = 0 ORDER BY type DESC, lastName ASC, firstName ASC";
- if($this->db->query($sql)->num_rows > 0)
- {
- $query = $this->db->query($sql);
- while($result = $query->fetch_assoc())
- {
- $data[] = $result;
- }
- return $data;
- }
- }
- }
- ?>
|