function setDriver($driver) { //require_once '../framework/DBConnect.php'; // opening db connection $db = new Connection(); $conn = $db->connect(); $vehicle = new Vehicle($this->id); $prevDriver = $vehicle->getDriver(); if ($prevDriver == $driver) { return false; } $mUser = new User(); $sql = "UPDATE vehicle SET driver = '{$driver}' WHERE id = '{$this->id}'"; //print_r($sql); if (mysqli_query($conn, $sql)) { //print_r("<br>Record updated successfully"); if ($driver != 0) { $action = 1; //assigning driver } else { $action = -1; //removing driver $driver = $prevDriver; } return Timeline::addTimelineEvent("driver_allotment", $this->id, $driver, "", $mUser->getId(), $action); } else { //print_r("<br>Error updating record: " . mysqli_error($conn)); return false; } }
public static function addEmployee($name, $emp_id, $address_1, $address_2, $landmark, $city, $state, $pincode, $phone, $fax, $email, $website, $description) { $defaultPassword = '******'; if (!empty($_SESSION['user']['company'])) { //$retCode = User::add($name, '', $emp_id, $defaultPassword, $phone, $phone, $email, $address_1, $address_2, $landmark, $city, $state, $pincode, $_SESSION['user']['company']); if (User::add($name, '', $emp_id, $defaultPassword, $phone, $phone, $email, $address_1, $address_2, $landmark, $city, $state, $pincode, $_SESSION['user']['company'])) { User::activate(User::getIdByEmail($email)); $mEmployee = new User(User::getIdByEmail($email)); $mAddedBy = new User(); $mEmployee->SetAddedby($mAddedBy->getId()); Mailer::sendEmployeeAddedMessage($name, $emp_id, $email, $defaultPassword, $_SESSION['user']['company'], $mAddedBy->getFullname()); return Timeline::addTimelineEvent("staff_addition", "", "", $mEmployee->getId(), $mAddedBy->getId(), 1); return true; } return false; } else { return false; } }
function delete() { $db = new Connection(); $conn = $db->connect(); if ($this->id == User::getCurrentUser()) { return false; } $mUser = new User($this->id); $sql = "UPDATE user SET activated = '0' , status = '0' WHERE id = '{$this->id}'"; if (mysqli_query($conn, $sql)) { //echo "<br>".$mUser->getFullName()." ".$mUser->isCompanyAdmin(); if (!$mUser->isCompanyAdmin()) { $mAddedBy = User::getCurrentUser(); //echo "User delete staff"; return Timeline::addTimelineEvent("staff_addition", "", "", $this->getId(), $mAddedBy->getId(), -1); } else { return true; } } else { return false; } }