예제 #1
0
 /**
  * Get summary of time for each person on each day of the week
  *
  * @return  void
  */
 public static function getTimeForWeeklyBar()
 {
     $records = Record::all();
     $records->select('user_id')->select('SUM(time)', 'time')->select('DATE_FORMAT(CONVERT_TZ(date, "+00:00", "' . Config::get('offset', '+00:00') . '"), "%Y-%m-%d")', 'day')->group('user_id')->group('day');
     $users = [User::get('id')];
     // Add extra users for proxies
     foreach (Proxy::whereEquals('proxy_id', User::get('id')) as $proxy) {
         $users[] = $proxy->user_id;
     }
     $records->whereIn('user_id', $users);
     // Get the day of the week
     $today = Date::of(Request::getVar('week', time()));
     $dateofToday = $today->format('Y-m-d');
     $dayOfWeek = $today->format('N') - 1;
     $records->having('day', '>=', Date::of(strtotime("{$dateofToday} - {$dayOfWeek}days"))->toLocal('Y-m-d'))->having('day', '<', Date::of(strtotime("{$dateofToday} + " . (7 - $dayOfWeek) . 'days'))->toLocal('Y-m-d'));
     $rows = $records->including('user')->rows();
     foreach ($rows as $row) {
         $row->set('user_name', $row->user->name);
     }
     echo json_encode($rows->toArray());
     exit;
 }
예제 #2
0
\Hubzero\Document\Assets::addSystemScript('jquery.flot.stack.min', 'flot');
\Hubzero\Document\Assets::addSystemScript('moment.min');
\Hubzero\Document\Assets::addSystemStylesheet('jquery.ui');
$this->css()->js();
HTML::behavior('core');
// Get the day of the week
$today = Date::of(Request::getVar('week', time()));
$dateofToday = $today->format('Y-m-d');
$dayOfWeek = $today->format('N') - 1;
$mon = Date::of(strtotime("{$dateofToday} - {$dayOfWeek}days"))->toLocal('n/j');
$sun = Date::of(strtotime("{$dateofToday} + " . (6 - $dayOfWeek) . 'days'))->toLocal('n/j');
// Build a list of people that should show up on the bar chart
// We do this because the list returned from the records query
// would not otherwise include folks that didn't enter any records
$people = [['name' => User::get('name'), 'user_id' => User::get('id')]];
foreach (Proxy::whereEquals('proxy_id', User::get('id')) as $proxy) {
    $people[] = ['name' => $proxy->user->name, 'user_id' => $proxy->user_id];
}
// Reverse sort them because the JS is going to reverse them again in processing
usort($people, function ($a, $b) {
    return strcmp($b['name'], $a['name']);
});
?>

<script>
	var persons = [
		<?php 
foreach ($people as $person) {
    ?>
			{name : "<?php 
    echo $person['name'];
예제 #3
0
    }
    ?>
			<?php 
}
?>
			<form action="<?php 
echo Route::url($this->base . '&task=save');
?>
" method="post">
				<div class="grouping" id="uname-group">
					<label for="user_id"><?php 
echo Lang::txt('COM_TIME_RECORDS_USER');
?>
:</label>
					<?php 
if (with($proxies = Proxy::whereEquals('proxy_id', User::get('id')))->total()) {
    ?>
						<select name="user_id" id="user_id">
							<option value="<?php 
    echo User::get('id');
    ?>
"><?php 
    echo User::get('name');
    ?>
</option>
							<?php 
    foreach ($proxies as $proxy) {
        ?>
								<option value="<?php 
        echo $proxy->user_id;
        ?>