-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoday.php
103 lines (89 loc) · 3.48 KB
/
today.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
// page meta settings
$page_title = 'Today';
$page_slug = '/today.php';
$page_lead = 'Today\'s time entries from your Harvest account with task details.';
// next/prev nav
$days_ago = $_GET["ago"];
if( $days_ago ) :
$prev_url = $page_slug . '?ago=' . ( $days_ago + 1 );
$next_url = ( $days_ago > 1 ) ? $page_slug . '?ago=' . ( $days_ago - 1 ) : $page_slug;
else :
$prev_url = $page_slug . '?ago=1';
$next_url = null;
endif;
// date stuff
// date_default_timezone_set($time_zone);
$today = ( $days_ago ) ? strtotime("-$days_ago day") : strtotime('now');
$day_of_year = date('z', $today);
$year = date('Y', $today);
require_once( dirname(__FILE__) . '/header.php' ); ?>
<div class="container py-5">
<div class="row">
<header class="col-sm">
<h1><?= $page_title ?></h1>
<?php
if( $page_lead )
echo "<p>$page_lead</p>";
if( $dashboard_url )
echo "<p><a href='$dashboard_url' target='_blank' class='btn btn-lg btn-info'>Harvest Dashboard</a></p>";
?>
</header><!-- .col -->
</div><!-- .row -->
</div><!-- .container -->
<div class="bg-light border-bottom border-top py-5">
<div class="container">
<div class="row">
<div class="col-sm">
<div class="row">
<nav class="btn-group mb-3 col-sm" role="group" aria-label="Next/Previous Navigation">
<a class="btn btn-link" href="<?= $prev_url ?>" title="Day before this">←</a>
<span class="btn"><h5 class="m-0"><?php echo date('D, M j', $today ); ?></h5></span>
<?php if( $next_url ) : ?>
<a class="btn btn-link" href="<?= $next_url ?>" Title="Day after this">→</a>
<?php endif; ?>
</nav>
</div>
<?php
// get harvest data
$result = $api->getDailyActivity( $day_of_year, $year );
if( $result->isSuccess() ) :
$total_hours = 0; ?>
<div class="row d-flex flex-wrap d-flex">
<?php foreach( $result->data->dayEntries as $entry ) : ?>
<div class="col-md-6 col-lg-4 mb-4">
<section class="card align-self-stretch">
<header class="card-header">
<h2 class="text-dark h4"><?php echo $entry->get( 'project' ); ?></h2>
<p class="text-dark m-0"><?php echo $entry->get( 'client' ); ?></p>
</header>
<div class="card-body">
<p class="text-dark">
<span class="display-4 text-primary"><?php echo $entry->get( 'hours' ); ?></span>
<small>hrs</small>
</p>
<p class="text-muted font-weight-light m-0">
<?php echo $entry->get( 'notes' ); ?>
</p>
</div>
</section>
</div>
<?php
// add $entry hours to daily total
$total_hours += $entry->get( 'hours' );
endforeach; ?>
</div><!-- .row -->
<div class="row">
<section class="mb-4 col-sm">
<h1 class="">Daily Total</h1>
<p class="">
<span class="display-4 text-primary"><?= $total_hours ?></span> <span>hrs</span>
</p>
</section>
</div><!-- .row -->
<?php endif; ?>
</div><!-- .col -->
</div><!-- .row -->
</div><!-- .container -->
</div><!-- .bg-light -->
<?php require_once( dirname(__FILE__) . '/footer.php' ); ?>