/** * Returns all the users visible by the requesting user * * @param User $user * @return array */ static function getVisibleUsers(User $user) { if ($user->isMemberOfOwnerCompany()) { return self::findAll(array('order' => 'concat(`display_name`, `username`)')); } else { return $user->getCompany()->getUsers(); } }
/** * Add options to main menu * * @param Menu $menu * @param User $user * @return null */ function invoicing_handle_on_build_menu(&$menu, &$user) { $company = $user->getCompany(); if ($user->getSystemPermission('can_manage_invoices')) { $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('invoices'), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countOverdue())), 'main'); } else { if ($user->isCompanyManager($company)) { $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('people_company_invoices', array('company_id' => $user->getCompanyId())), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countByCompany($user->getCompany(), array(INVOICE_STATUS_ISSUED)))), 'main'); } } // if }
/** * Handle on_dashboard_important_section event * * @param NamedList $items * @param User $user * @return null */ function invoicing_handle_on_dashboard_important_section(&$items, &$user) { $company = $user->getCompany(); // if user can manage invoices, list overdue invoices for all companies if ($user->getSystemPermission('can_manage_invoices')) { // if it's administrator list only overdue invoices if (($admin_overdue_invoices = Invoices::countOverdue()) > 0) { $items->add('admin_overdue_invoices', array('label' => $admin_overdue_invoices > 1 ? lang('<strong>:count</strong> overdue invoices for all companies', array('count' => $admin_overdue_invoices)) : lang('<strong>:count</strong> overdue invoice for all companies', array('count' => $admin_overdue_invoices)), 'class' => 'adminoverdue_invoices', 'icon' => get_image_url('important.gif'), 'url' => assemble_url('invoices'))); } // if } // if // if user is company manager or can manage invoices show outstanding and overdue invoices for his company if ($user->isCompanyManager($company) || $user->getSystemPermission('can_manage_invoices')) { // // Outstanding Invoices // $issued_invoices_count = Invoices::countOutstanding($company); if ($issued_invoices_count > 0) { if ($issued_invoices_count == 1) { // if there is only one outstanding invoice, then link should open that very same invoice $issued_invoices = Invoices::findOutstanding($company, array(INVOICE_STATUS_ISSUED)); $link_url = $issued_invoices[0]->getCompanyViewUrl(); $label = lang('<strong>1</strong> outstanding invoice for your company'); } else { // if there is multuple outstanding invoices, then link should open company invoices pages $link_url = assemble_url('people_company_invoices', array('company_id' => $company->getId())); $label = lang('<strong>:count</strong> outstanding invoices for your company', array('count' => $issued_invoices_count)); } // if $items->add('issued_invoices', array('label' => $label, 'class' => 'issued_invoices', 'icon' => get_image_url('icon_small.gif', INVOICING_MODULE), 'url' => $link_url)); } // if // // Overdue Invoices // $overdue_invoices_count = Invoices::countOverdue($company); if ($overdue_invoices_count > 0) { if ($overdue_invoices_count == 1) { // if there is only one overdue invoice, then link should open that very same invoice $overdue_invoices = Invoices::findOverdue($company, array(INVOICE_STATUS_ISSUED)); $link_url = $overdue_invoices[0]->getCompanyViewUrl(); $label = lang('<strong>1</strong> overdue invoice for your company'); } else { // if there is multuple overdue invoices, then link should open company invoices pages $link_url = assemble_url('people_company_invoices', array('company_id' => $company->getId())); $label = lang('<strong>:count</strong> overdue invoices for your company', array('count' => $overdue_invoices)); } // if $items->add('overdue_invoices', array('label' => $label, 'class' => 'overdue_invoices', 'icon' => get_image_url('important.gif'), 'url' => $link_url)); } // if } // if }
<?php require_once "../../../utility/helper/Notification/NotificationHelper.php"; $mUser = new User(); $companyId = $mUser->getCompany(); $mCompany = new Company($companyId); $mNotiResourceList = array(); if ($companyId != -1) { $mNotificationList = $mCompany->getAllNotifications(); } else { $mNotificationList = $mUser->getAllNotifications(); } for ($i = 0; $i < sizeof($mNotificationList); $i++) { $noti = new Notification($mNotificationList[$i]); $temp = $noti->getResource(); if ($temp['priority'] != 1) { array_push($mNotiResourceList, $temp); } } echo json_encode($mNotiResourceList);
echo "<script>alert('Sorry, some error occured.');</script>"; //echo "<script>window.location.href = 'register.php'</script>"; //header('Location:register.php?error=1'); } break; case "nocompany": $mUser = new User(); if ($mUser->setIndividualAccount()) { header('Location:../user/'); } else { header('Location:register.php'); } break; case "update": $mUser = new User(); $mCompany = new Company($mUser->getCompany()); //$name = $_POST['name']; //$tin_number = $_POST['tin_number']; $address_1 = $_POST['address_1']; $address_2 = $_POST['address_2']; $landmark = $_POST['landmark']; $city = $_POST['city']; $state = $_POST['state']; $pincode = $_POST['pincode']; $email = $_POST['email']; $fax = $_POST['fax']; $phone = $_POST['phone']; $website = $_POST['website']; $description = ""; if ($mCompany->update($address_1, $address_2, $landmark, $city, $state, $pincode, $phone, $fax, $email, $website, $description)) { //echo 'changes completed..';
public function update($address_1, $address_2, $landmark, $city, $state, $pincode, $phone, $fax, $email, $website, $description) { // opening db connection $db = new Connection(); $conn = $db->connect(); $mUser = new User(); $comid = $mUser->getCompany(); $id = $mUser->getId(); $sql = "UPDATE `company` SET `address_1`='{$address_1}', `address_2`='{$address_2}', `landmark`='{$landmark}', `city`='{$city}', `state`='{$state}' , `pincode`='{$pincode}', `phone`='{$phone}', `fax`='{$fax}', `email`='{$email}', `website`='{$website}', `description`='{$description}' WHERE admin_user= '******' AND id='{$comid}'"; if (mysqli_query($conn, $sql)) { return true; } else { echo mysqli_error($conn); } }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once "../../framework/User.php"; require_once "../../framework/Vehicle.php"; require_once "../../framework/Company.php"; require_once "../../framework/Driver.php"; require_once "../../framework/Expense.php"; if (!isset($_SESSION['user'])) { header('Location:../user/login.php'); } $mUser = new User(); $mCompany = new Company($mUser->getCompany()); $mEmployeeList = $mCompany->getEmployeeList(); $mAlertList = $mUser->getAlerts(); $mMonthlyAlertList = $mUser->getMonthlyAlerts(); $mPendingExpenseList = $mUser->getPendingExpenseList(); $mAllVehicleList = $mUser->getVehicleList(); $mDeployedVehicleList = $mUser->getDeployedVehicleList(); $mWaitingVehicleList = $mUser->getWaitingVehicleList(); $mOnJobVehicleList = $mUser->getOnJobVehicleList(); $mDriverList = $mUser->getCurrentDriverList(); $mAvailableDriverList = $mUser->getAvailableDriverList(); ?> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>FindGaddi</title>
require_once '../../framework/User.php'; if (isset($_GET['action'])) { //die "p"; $action = $_GET['action']; } else { //die "a"; $action = ""; } $mUser = User::getCurrentUser(); switch ($action) { case "login": $username = $_POST['username']; $password = $_POST['password']; $rememberme = $_POST['rememberme']; if ($mUser->login($username, $password)) { $mUser = new User($username, $password, $mUser->getCompany()); if ($mUser->getActivatedState() == 1) { if ($rememberme) { $mUser->SetCookieforUser($username, $password, $mUser->getCompany()); } echo "Redirecting to dashboard."; echo "<script>window.location.href = 'index.php'</script>"; //header('Location:index.php'); } else { echo "<script>window.location.href = 'activate.php'</script>"; } } else { echo "<script>alert('Username or Password incorrect. Please try again.');</script>"; echo "<script>window.location.href = 'login.php'</script>"; //header('Location:login.php'); }
public static function addTimelineEvent($type, $vehicle, $driver, $employee, $addedBy, $action) { // opening db connection $db = new Connection(); $conn = $db->connect(); $today = date('Y-m-d'); $fgDate = $db->getTimeNow(); if ($vehicle != "") { $mVehicle = new Vehicle($vehicle); } if ($driver != "") { $mDriver = new Vehicle($driver); } if ($employee != "") { $mEmployee = new Vehicle($employee); } $mAddedBy = new User($addedBy); $companyId = $mAddedBy->getCompany(); $mCompany = new Company($companyId); $adminId = $mCompany->getAdmin(); $sql = "INSERT INTO `timeline` (`type`, `vehicle`, `driver`, `employee`, `company`, `admin`, `added_by`, `action`, `date_added`) VALUES ('{$type}', '{$vehicle}', '{$driver}', '{$employee}', '{$companyId}', '{$adminId}', '{$addedBy}', '{$action}', '{$fgDate}')"; //echo $sql; if (mysqli_query($conn, $sql)) { return true; } else { return false; } }
<?php if (!isset($mUser)) { require_once '/navigator/framework/User.php'; $mUser = new User(); } $companyId = $mUser->getCompany(); if ($companyId == 0) { header('Location:/navigator/ui/company/register.php'); } ?> <a href="/navigator/ui/user/">DASHBOARD</a> <?php if ($companyId != -1) { ?> <a href="/navigator/ui/job/">JOBS</a> <a href="/navigator/ui/order/">ORDERS</a> <a href="/navigator/ui/vehicle/">VEHICLES</a> <a href="/navigator/ui/driver/">DRIVERS</a> <a href="/navigator/ui/client/">CLIENTS</a> <?php } ?> <div style="float:right"> <?php echo $mUser->getUserName() . " ( " . $mUser->getCompany() . " )"; ?> <a href="/navigator/ui/user/action.php?action=logout" target="_top">Logout</a> <a href="/navigator/ui/user/setting/" target="_top">Settings</a>
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once "../../framework/User.php"; require_once "../../framework/Vehicle.php"; require_once "../../framework/Job.php"; require_once "../../framework/Driver.php"; require_once "../../framework/Company.php"; $mUser = new User(); $muCom = new Company($mUser->getCompany()); ?> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>FindGaddi</title> <!-- CSS --> <!-- Reset Stylesheet --> <link rel="stylesheet" href="../../res/reset.css" type="text/css" media="screen"> <!-- Main Stylesheet --> <link rel="stylesheet" href="../../res/style.css" type="text/css" media="screen"> <!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid --> <link rel="stylesheet" href="../../res/invalid.css" type="text/css" media="screen"> <!-- jQuery -->
function isCompanyAdmin() { $selfCompany = new Company(User::getCompany()); if ($this->id == $selfCompany->getAdmin()) { return true; } else { return false; } }