PHP Method User::getCompany, codiad Code Examples

This page contains top rated real world PHP examples of method User::getCompany from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: Users.class.php Project: pnagaraju25/fengoffice
1
 /**
  * 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();
     }
 }
Example #2
Show file File: on_build_menu.php Project: NaszvadiG/activecollab_loc
0
/**
 * 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
}
Example #3
Show file File: on_dashboard_important_section.php Project: NaszvadiG/activecollab_loc
0
/**
 * 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
}
Example #4
Show file File: notification.php Project: rusty1909/Navigator
0
<?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);
Example #5
Show file File: action.php Project: rustydev19/Navigator
0
         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..';
Example #6
Show file File: Company.php Project: rusty1909/Navigator
0
 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= '{$id}' AND id='{$comid}'";
     if (mysqli_query($conn, $sql)) {
         return true;
     } else {
         echo mysqli_error($conn);
     }
 }
Example #7
Show file File: index.php Project: rusty1909/Navigator
0
$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>
	
	<!--                       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 -->
	<script type="text/javascript" src="../../res/jquery-1.js"></script>
	
	<!-- jQuery Configuration -->
	<script type="text/javascript" src="../../res/simpla.js"></script>
	
	<!-- Facebox jQuery Plugin -->
	<script type="text/javascript" src="../../res/facebox.js"></script>
	
	<!-- jQuery WYSIWYG Plugin -->
	<script type="text/javascript" src="../../res/jquery_002.js"></script>
	
	<!-- jQuery Datepicker Plugin -->
	<script type="text/javascript" src="../../res/jquery.htm"></script>
	<script type="text/javascript" src="../../res/jquery.js"></script>
	<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    <script src="http://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&key=AIzaSyBcmYGGYTH1hGEEr31Odpiou8thwx55f_o&sensor=false&libraries=places,geometry,drawing"></script>

	<!-- //Modal Box Functionality  -->
	<script>
	$(document).ready(function () {
		//$('#dialog').dialog(); 
		console.log("clicked");
		$('#dialog_link').click(function () {
			$('#dialog').dialog('open');
			return false;
		});
	});

	$(function(){
	var appendthis =  ("<div class='modal-overlay js-modal-close'></div>");

	  $('a[data-modal-id]').click(function(e) {
		e.preventDefault();
		$("body").append(appendthis);
		$(".modal-overlay").fadeTo(500, 0.7);
		//$(".js-modalbox").fadeIn(500);
		var modalBox = $(this).attr('data-modal-id');
		$('#'+modalBox).fadeIn($(this).data());
	  });  
	  

	$(".js-modal-close, .modal-overlay").click(function() {
	  $(".modal-box, .modal-overlay").fadeOut(500, function() {
		$(".modal-overlay").remove();
	  });
	});

	$(window).resize(function() {
	  $(".modal-box").css({
		top: ($(window).height() - $(".modal-box").outerHeight()) / 3,
		left: ($(window).width() - $(".modal-box").outerWidth()) / 2
	  });
	});
	 
	$(window).resize();
	 
	});
        
    function onDelete(id){
		if(confirm("You really want to delete this User?"))
			window.location.href = "action.php?action=delete&id="+id;
	}
        
	</script>

	<script>
	var bill_id;
	function fetchBillDetails(id){
		var data = "";
        jQuery.ajax({
            type: 'POST',
            url: 'action.php?action=billdetail&id='+id,
            cache: false,
            success: function(response){
				if(response == 0){
				}
				else {
					//alert(response)
					bill_id = id;
					var billDetail = JSON.parse(response);
					
					var vehicle_image = '../../res/vehicle_types/'+billDetail.vehicle.type+'.png';
					var vehicle_text = "<img height='18' width='18' src='"+vehicle_image+"'>&nbsp;&nbsp;<b><a href='../vehicle/detail.php?id="+billDetail.vehicle.id+"' style='text-transform:uppercase;vertical-align:2px;' class='js-modal-close'>"+billDetail.vehicle.number+"</a>";					
					document.getElementById("vehicle").innerHTML = vehicle_text;
					
					var driver_image = '../../res/driver_icon.png';
					var driver_text = "<img height='15' width='15' src='"+driver_image+"'>&nbsp;&nbsp;<b><a href='../driver/detail.php?id="+billDetail.driver.id+"' style='text-transform:uppercase;vertical-align:2px;' class='js-modal-close'>"+billDetail.driver.name+"</a>";
					document.getElementById("driver").innerHTML = driver_text;
					
					var bill_image_path = '../../res/bills/'+billDetail.vehicle.number+'/'+billDetail.filename+'.jpg';
					var bill_image_text = "<img width='100' src='"+bill_image_path+"'>";
					document.getElementById("bill_image").innerHTML = bill_image_text;
					
					var reason_image = '../../res/info.png';
					var reason_text = "<img height='18' width='18' src='"+reason_image+"'>&nbsp;&nbsp<b>"+billDetail.reason+"</b>";
					document.getElementById("reason").innerHTML = reason_text;
					
					var amount_image = '../../res/amount.png';
					document.getElementById("amount").innerHTML = "<img height='18' width='18' src='"+amount_image+"'>&nbsp;&nbsp<b>Rs."+billDetail.amount+"</b>";
					
					var calendar_image = '../../res/calendar.png';
					var date_added_text = "<img height='15' width='15' src='"+calendar_image+"'>&nbsp;&nbsp<b>"+billDetail.date_added+"</b>";
					document.getElementById("date_added").innerHTML = date_added_text;
					
					//document.getElementById("latlng").innerHTML = billDetail.location.lat+","+billDetail.location.lng;
					
					updateAddressView(billDetail.location.lat, billDetail.location.lng);
				}
            }
        });
	}
	
	function approveBill(isApproval) {
		jQuery.ajax({
            type: 'POST',
            url: 'action.php?action=billapproval&id='+bill_id+'&approval='+isApproval,
            cache: false,
            success: function(response){
				if(response == 0){
				}
				else {
					if(response=='success'){
						location.reload();
						if(isApproval==1){
							alert("Bill Approved!!!");
						} else {
							alert("Bill Rejected!!!");
						}
					} else{
						alert("some problem occurred");
					}
				}
            }
        });
	}
	
	function updateAddressView(latitude, longitude){
		var geocoder = new google.maps.Geocoder();
		var latlng = new google.maps.LatLng(latitude, longitude);
		geocoder.geocode({'location': latlng}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				if (results[1]) {
					var formatted_address = results[1].formatted_address;
					var calendar_image = '../../res/location_icon.png';
					document.getElementById("address").innerHTML = "<img height='15' width='15' src='"+calendar_image+"'>&nbsp;&nbsp<b>"+formatted_address+"<br>("+latitude+","+longitude+")</b>";
				} else {
					console.log('No results found');
				}
			} else {
				console.log('Geocoder failed due to: ' + status);
			}
		});
	}
	
	function fetchNotification(){
		//alert(id+" "+driver_id);
		var data = "";
        jQuery.ajax({
            type: 'POST',
            url: 'notification.php',
            cache: false,
            success: function(response){
				if(response == 0){
				}
				else {					
					var notiList = JSON.parse(response);
					for(var i=0; i<50 && i<notiList.length; i++){
						var image = "alert_ok";
						switch(notiList[i].type){
							case "expenses" : image = "alert_upload"; break;
							case "power_battery_plugged" : image = "alert_ok"; break;
							case "location" : image = "alert_location"; break;
							case "power_battery_low" :
							case "power_shutdown" :
							case "power_battery_unplugged" : image = "alert_high"; break;
							default : image = "alert_ok"; break;
						}
						data += "<tr style='background:#fff;border-bottom: 1px solid #ddd;'><td><img height='20' width='20' src='../../res/"+image+".png' title='Location' alt='Location'></td><td style='padding:10px;line-height:1em;'><span style='vertical-align:5px;'>"+notiList[i].string+"</span></td><td style='font-size:10px;padding-top:-10px'><span style='vertical-align:7px;'><b>"+notiList[i].time+"</b></span></td></tr>";
						//console.log(image);
					}
					//alert(data);
					document.getElementById("noti_body").innerHTML = data;
					//$("#noti_table").find("tbody").find('#main-content table').;
					data="";
				}
            }
        });
	}
	
	var notificationUpdates = setInterval(function(){ fetchNotification() }, 2000);
	</script>
</head>
  
	<body onload='fetchNotification()'><div id="body-wrapper"> <!-- Wrapper for the radial gradient background -->
		
	<?php 
include '../sidebar.php';
?>
		
		<div id="main-content"> <!-- Main Content Section with everything -->
			
			<noscript> <!-- Show a notification if the user has disabled javascript -->
				<div class="notification error png_bg">
					<div>
						Javascript is disabled or is not supported by your browser. Please <a href="http://browsehappy.com/" title="Upgrade to a better browser">upgrade</a> your browser or <a href="http://www.google.com/support/bin/answer.py?answer=23852" title="Enable Javascript in your browser">enable</a> Javascript to navigate the interface properly.
					</div>
				</div>
			</noscript>
			
			<div class="clear"></div> <!-- End .clear -->
			<div style="width:59%;height:88%;float:left">
				<div class="column-left" style="width:100%;height:50%">				
					<ul class="shortcut-buttons-set">
				
						<li><a class="shortcut-button" href="../vehicle/"><span>
							<b><span style="font-size:15px;border: none; display:block; padding: 0px;">VEHICLES</span></b>
							<img src="../../res/truck.png" alt="icon"><br>
							<b><span style="font-size:30px;border: none; display:block; padding: 0px;"><?php 
echo sizeof($mAllVehicleList);
?>
</span></b> registered<br>drivers<br><br>
							<b><?php 
echo sizeof($mOnJobVehicleList);
?>
</b> on-road<br><br>
							<b><?php 
echo sizeof($mWaitingVehicleList);
?>
</b> waiting<br>
						</span></a></li>
						
						<li><a class="shortcut-button" href="../driver/"><span>
							<b><span style="font-size:15px;border: none; display:block; padding: 0px;">DRIVERS</span></b>
							<img src="../../res/drivers.png" alt="icon"><br>
							<b><span style="font-size:30px;border: none; display:block; padding: 0px;"><?php 
echo sizeof($mDriverList);
?>
</span></b> registered<br>drivers<br><br>
							<b><?php 
echo sizeof($mAvailableDriverList);
?>
</b> available<br>
						</span></a></li>
						
						<li><a class="shortcut-button" href="<?php 
if ($mUser->getCompany() == -1) {
Example #8
Show file File: action.php Project: rustydev19/Navigator
0
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');
        }
        break;
    case "register":
Example #9
Show file File: Timeline.php Project: rusty1909/Navigator
0
 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;
     }
 }
Example #10
Show file File: header.php Project: rustydev19/Navigator
0
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>
</div>
<hr>
Example #11
Show file File: register.php Project: rusty1909/Navigator
0
<?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 -->
Example #12
Show file File: User.php Project: rusty1909/Navigator
0
 function isCompanyAdmin()
 {
     $selfCompany = new Company(User::getCompany());
     if ($this->id == $selfCompany->getAdmin()) {
         return true;
     } else {
         return false;
     }
 }