|
@@ -17,6 +17,14 @@ class accountModel extends Staple_Model
|
|
|
private $type;
|
|
|
private $status;
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getId()
|
|
|
+ {
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $id
|
|
|
*/
|
|
@@ -25,6 +33,14 @@ class accountModel extends Staple_Model
|
|
|
$this->id = $id;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getUsername()
|
|
|
+ {
|
|
|
+ return $this->username;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $username
|
|
|
*/
|
|
@@ -33,6 +49,14 @@ class accountModel extends Staple_Model
|
|
|
$this->username = $username;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getPassword()
|
|
|
+ {
|
|
|
+ return $this->password;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $password
|
|
|
*/
|
|
@@ -41,6 +65,14 @@ class accountModel extends Staple_Model
|
|
|
$this->password = $password;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getPin()
|
|
|
+ {
|
|
|
+ return $this->pin;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $pin
|
|
|
*/
|
|
@@ -49,6 +81,30 @@ class accountModel extends Staple_Model
|
|
|
$this->pin = $pin;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getTempPin()
|
|
|
+ {
|
|
|
+ return $this->tempPin;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param mixed $tempPin
|
|
|
+ */
|
|
|
+ public function setTempPin($tempPin)
|
|
|
+ {
|
|
|
+ $this->tempPin = $tempPin;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getFirstName()
|
|
|
+ {
|
|
|
+ return $this->firstName;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $firstName
|
|
|
*/
|
|
@@ -57,6 +113,14 @@ class accountModel extends Staple_Model
|
|
|
$this->firstName = $firstName;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getLastName()
|
|
|
+ {
|
|
|
+ return $this->lastName;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $lastName
|
|
|
*/
|
|
@@ -65,6 +129,14 @@ class accountModel extends Staple_Model
|
|
|
$this->lastName = $lastName;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getAuthLevel()
|
|
|
+ {
|
|
|
+ return $this->authLevel;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $authLevel
|
|
|
*/
|
|
@@ -73,6 +145,14 @@ class accountModel extends Staple_Model
|
|
|
$this->authLevel = $authLevel;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function getBatchId()
|
|
|
+ {
|
|
|
+ return $this->batchId;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param mixed $batchId
|
|
|
*/
|
|
@@ -82,51 +162,51 @@ class accountModel extends Staple_Model
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param mixed $supervisorId
|
|
|
+ * @return mixed
|
|
|
*/
|
|
|
- public function setSupervisorId($supervisorId)
|
|
|
+ public function getSupervisorId()
|
|
|
{
|
|
|
- $this->supervisorId = $supervisorId;
|
|
|
+ return $this->supervisorId;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param mixed $type
|
|
|
+ * @param mixed $supervisorId
|
|
|
*/
|
|
|
- public function setType($type)
|
|
|
+ public function setSupervisorId($supervisorId)
|
|
|
{
|
|
|
- $this->type = $type;
|
|
|
+ $this->supervisorId = $supervisorId;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param mixed $status
|
|
|
+ * @return mixed
|
|
|
*/
|
|
|
- public function setStatus($status)
|
|
|
+ public function getType()
|
|
|
{
|
|
|
- $this->status = $status;
|
|
|
+ return $this->type;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return mixed
|
|
|
+ * @param mixed $type
|
|
|
*/
|
|
|
- public function getTempPin()
|
|
|
+ public function setType($type)
|
|
|
{
|
|
|
- return $this->tempPin;
|
|
|
+ $this->type = $type;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function getFirstName()
|
|
|
+ public function getStatus()
|
|
|
{
|
|
|
- return $this->firstName;
|
|
|
+ return $this->status;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return mixed
|
|
|
+ * @param mixed $status
|
|
|
*/
|
|
|
- public function getLastName()
|
|
|
+ public function setStatus($status)
|
|
|
{
|
|
|
- return $this->lastName;
|
|
|
+ $this->status = $status;
|
|
|
}
|
|
|
|
|
|
function __construct()
|
|
@@ -135,12 +215,52 @@ class accountModel extends Staple_Model
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function load($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();
|
|
|
+
|
|
|
+ $data = array();
|
|
|
+
|
|
|
+ $data['id'] = $result['id'];
|
|
|
+ $data['username'] = $result['username'];
|
|
|
+ $data['firstName'] = $result['firstName'];
|
|
|
+ $data['lastName'] = $result['lastName'];
|
|
|
+ $data['level'] = $result['authLevel'];
|
|
|
+ $data['supervisor'] = $result['supervisorId'];
|
|
|
+ $data['type'] = $result['type'];
|
|
|
+ $data['status'] = $result['status'];
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
function save()
|
|
|
{
|
|
|
if(isset($this->id))
|
|
|
{
|
|
|
- //Edit user
|
|
|
+ //Check if username already exists
|
|
|
+ $sql = "SELECT username FROM accounts WHERE username = '".$this->db->real_escape_string($this->username)."' AND id <> '".$this->db->real_escape_string($this->id)."'";
|
|
|
+ $query = $this->db->query($sql);
|
|
|
+ if($query->num_rows == 0)
|
|
|
+ {
|
|
|
+ $sql = "
|
|
|
+ UPDATE accounts SET
|
|
|
+ username = '".$this->db->real_escape_string($this->username)."',
|
|
|
+ firstName = '".$this->db->real_escape_string($this->firstName)."',
|
|
|
+ lastName = '".$this->db->real_escape_string($this->lastName)."',
|
|
|
+ authLevel = '".$this->db->real_escape_string($this->authLevel)."',
|
|
|
+ supervisorId = '".$this->db->real_escape_string($this->supervisorId)."',
|
|
|
+ type = '".$this->db->real_escape_string($this->type)."',
|
|
|
+ status = '".$this->db->real_escape_string($this->status)."'
|
|
|
+ WHERE id = '".$this->db->real_escape_string($this->id)."'
|
|
|
+ ";
|
|
|
|
|
|
+ if($this->db->query($sql))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -184,7 +304,19 @@ class accountModel extends Staple_Model
|
|
|
|
|
|
if($this->db->query($sql))
|
|
|
{
|
|
|
+ $id = $this->db->insert_id;
|
|
|
+
|
|
|
$this->tempPin = $pin;
|
|
|
+
|
|
|
+ $account = new userModel();
|
|
|
+ $userInfo = $account->userInfo($id);
|
|
|
+
|
|
|
+ $audit = new auditModel();
|
|
|
+ $audit->setUserId($userInfo['id']);
|
|
|
+ $audit->setAction('New Account Created');
|
|
|
+ $audit->setItem($account->getUsername()." created account.");
|
|
|
+ $audit->save();
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -214,5 +346,27 @@ class accountModel extends Staple_Model
|
|
|
$this->generatePin();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ function resetPin($id)
|
|
|
+ {
|
|
|
+ $pin = $this->generatePin();
|
|
|
+ $this->tempPin = $pin;
|
|
|
+
|
|
|
+ $sql = "UPDATE accounts SET pin='".$this->db->real_escape_string(sha1($pin))."' WHERE id = '".$this->db->real_escape_string($id)."'";
|
|
|
+
|
|
|
+ if($this->db->query($sql))
|
|
|
+ {
|
|
|
+ $account = new userModel();
|
|
|
+ $userInfo = $account->userInfo($id);
|
|
|
+
|
|
|
+ $audit = new auditModel();
|
|
|
+ $audit->setUserId($userInfo['id']);
|
|
|
+ $audit->setAction('PIN Reset');
|
|
|
+ $audit->setItem($account->getUsername()." reset users PIN.");
|
|
|
+ $audit->save();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
?>
|