Skip to content

Commit

Permalink
Merge pull request #20 from lacimarsik/lm/cashier-app-v1.01
Browse files Browse the repository at this point in the history
(Cashier app) V1.01
  • Loading branch information
lacimarsik committed Oct 8, 2018
2 parents 21d7cf4 + 564dade commit 24426a7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cashier_app_process.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// =============================
// CASHIER APP - V1.0 Process part
// CASHIER APP - V1.01 Process part

// Form part: cashier_app_process.php (in the theme folder)
// Summary part: cashier_app_process.php (in the theme folder)
Expand Down
12 changes: 12 additions & 0 deletions wp-content/themes/Parallax-One/cashier_app/cashier_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
padding-bottom: 10px;
}

.year-to-date {
padding: 20px;
margin: 20px auto;
background-color: #4487d5;
border-radius: 20px;
color: white;
font-size: 20px;
font-weight: bold;
width: 400px;
text-align: center;
}

.medium {
font-size: 1.2em;
}
Expand Down
2 changes: 1 addition & 1 deletion wp-content/themes/Parallax-One/cashier_app/cashier_app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// =============================
// CASHIER APP - V1.0 Javascript part
// CASHIER APP - V1.01 Javascript part

// Form part: cashier_app_process.php (in the theme folder)
// Process part: cashier_app_process.php (in the root folder)
Expand Down
15 changes: 11 additions & 4 deletions wp-content/themes/Parallax-One/cashier_app/cashier_app_form.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// =============================
// CASHIER APP - V1.0 Form part
// CASHIER APP - V1.01 Form part

// Form part: cashier_app_process.php (in the theme folder)
// Process part: cashier_app_process.php (in the root folder)
Expand Down Expand Up @@ -74,12 +74,19 @@ function get_closest_lessons($connection_4w, $branch_id, $current_season, $nextl
$result = $connection_4w->query($sql);
while ($row = mysqli_fetch_assoc($result)) {
if ((date('l') == $row['day']) && (date('H:i:s') < $row['time'])) {
// if the lesson is today, and didn't yet start
// but do not save it if we want previous lessons
// if the lesson is today, and didn't yet start => use "this week"
// But let's skip it if we want "last" lessons
if ($nextlast == 'last') {
continue;
}
$day_as_string = strtolower($row['day']) . ' this week';
} else if (date('l') == $row['day']) {
// if the lesson is today, and is over already => "use this week"
// But let's skip it if we want "next" lessons
if ($nextlast == 'next') {
continue;
}
$day_as_string = strtolower($row['day']) . ' this week';
} else {
$day_as_string = $nextlast . ' ' . strtolower($row['day']);
}
Expand Down Expand Up @@ -195,7 +202,7 @@ function findTimezone($connection_4w, $branch_id) {
<a class="btn btn-default" href="<?php echo $summary_url; ?>">Summary</a>
<div class="cashier">
<br />
<link rel="stylesheet" href="../wp-content/themes/Parallax-One/cashier_app/cashier_app.css?ver=1.0">
<link rel="stylesheet" href="../wp-content/themes/Parallax-One/cashier_app/cashier_app.css?ver=1.01">
<form action="/cashier_app_process.php" id="cashier" method="post">
<p>Welcome, dear cashier. On this page you count the number of sold 1-time entries, vouchers, and how many people came on already-paid vouchers.</p>
<p>Please check the class, level, date and time.</p>
Expand Down
52 changes: 41 additions & 11 deletions wp-content/themes/Parallax-One/cashier_app/cashier_app_summary.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// =============================
// CASHIER APP - V1.0 Summary part
// CASHIER APP - V1.01 Summary part

// Form part: cashier_app_summary.php (in the theme folder)
// Process part: cashier_app_process.php (in the root folder)
Expand All @@ -10,9 +10,10 @@
// OUTLINE
// 1. FUNCTIONS
// 2. INITIALIZATION
// 3. ATTENDANCE
// 4. MONTHLY REVENUES
// 5. WRAP-UP
// 3. TOTAL REVENUES
// 4. ATTENDANCE
// 5. MONTHLY REVENUES
// 6. WRAP-UP
// =============================

require_once('wp-config.php');
Expand Down Expand Up @@ -157,6 +158,7 @@ function findTimezone($connection_4w, $branch_id) {
<script src="/wp-content/themes/Parallax-One/cashier_app/highcharts/js/modules/data.js"></script>
<script src="/wp-content/themes/Parallax-One/cashier_app/highcharts/js/modules/exporting.js"></script>
<link href="/wp-content/themes/Parallax-One/cashier_app/css/charts.css" rel="stylesheet" type='text/css' />
<link rel="stylesheet" href="../wp-content/themes/Parallax-One/cashier_app/cashier_app.css?ver=1.01">
<div class="content-wrap">
<div class="container">
<img src="../wp-content/themes/Parallax-One/cashier_app/img/Logo.jpg" style="width: 150px;" />
Expand All @@ -166,8 +168,36 @@ function findTimezone($connection_4w, $branch_id) {
<main id="main" class="site-main" role="main">
<?php


// =============================
// 3. TOTAL REVENUES
// =============================

$sql= 'SELECT sum(a.count * p.price) as money_made, p.currency FROM 4w_accounting a JOIN 4w_branch_prices p ON a.price_type_id = p.id JOIN 4w_branches b ON a.branch_id = b.id WHERE a.branch_id = ' . $branch_id . " AND a.season = '" . $current_season . "'";
$result = $connection_4w->query($sql);

?>
<?php
while ($row = mysqli_fetch_assoc($result)) { ?>
<div class="year-to-date">Revenues to date: <?php echo $row['money_made'] . ' ' . $row['currency']; ?>
<br /><br />
<?php

$messages = array("Great job!", "Keep on rocking!", "Saving the lives big time!", "That's awesome!");
if ($row['currency'] == 'CZK') {
array_push($messages, "That's " . round($row['money_made'] / 1200) . " families provided with clean water!");
}
if ($branch_id == 3) {
array_push($messages, "You rock, Prague!");
}
$random_keys = array_rand($messages);
echo $messages[$random_keys];
?></div>
<?php
}

// =============================
// 2. ATTENDANCE
// 4. ATTENDANCE
// =============================

$sql= "SELECT * FROM 4w_accounting a JOIN 4w_branch_prices p ON a.price_type_id = p.id JOIN 4w_branches b ON a.branch_id = b.id WHERE b.id = " . $branch_id . " AND a.date = '" . date('Y-m-d', $last_lesson[0]) . "' AND a.season = '" . $current_season . "'";
Expand All @@ -182,11 +212,11 @@ function findTimezone($connection_4w, $branch_id) {

if (date('Y-m-d', $last_lesson[0]) == date('Y-m-d')) {
?>
<h2 class="report-heading">Today</h2>
<h2 class="report-heading">Today's classes</h2>
<?php
} else {
?>
<h2 class="report-heading">Last class</h2>
<h2 class="report-heading">Last day's classes</h2>
<?php
}

Expand All @@ -199,7 +229,7 @@ function findTimezone($connection_4w, $branch_id) {
$total += intval($row['price']) * intval($row['count']);
$total_students += intval($row['count']);
echo '<tr>';
echo '<td><strong class="bold">' . $row['price_type'] . '</strong></td>';
echo '<td><strong class="bold">(' . $row['class_type'] . ' ' . $row['level'] . ') ' . $row['price_type'] . '</strong></td>';
echo '<td><span>' . $row['count'] . '</span></td>';
echo '<td><span>' . intval($row['price']) * intval($row['count']) . ' ' . $row['currency'] . '</span></td>';
echo '</tr>';
Expand All @@ -221,7 +251,7 @@ function findTimezone($connection_4w, $branch_id) {
<input class="submit-button" type="submit"
value="Edit last class (<?php echo $last_lesson[1] . ' ' . $last_lesson[2] . ')'; ?>">
</form>

<br />
<script type="text/javascript">
$(function() {
Highcharts.setOptions( {
Expand Down Expand Up @@ -430,7 +460,7 @@ function findTimezone($connection_4w, $branch_id) {
<?php

// =============================
// 3. MONTHLY REVENUES
// 5. MONTHLY REVENUES
// =============================

$sql= 'SELECT EXTRACT(YEAR_MONTH FROM a.date) as month, sum(case when p.student = 1 then (a.count * p.price) else 0 end) as students_money_made, sum(case when p.student = 0 then (a.count * p.price) else 0 end) as non_students_money_made, p.currency FROM 4w_accounting a JOIN 4w_branch_prices p ON a.price_type_id = p.id JOIN 4w_branches b ON a.branch_id = b.id WHERE a.branch_id = ' . $branch_id . " AND a.season = '" . $current_season . "' GROUP BY month ORDER BY month;";
Expand Down Expand Up @@ -614,7 +644,7 @@ function findTimezone($connection_4w, $branch_id) {
<?php

// =============================
// 4. WRAP-UP
// 6. WRAP-UP
// =============================

?>
Expand Down

0 comments on commit 24426a7

Please sign in to comment.