adding summary
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
Yii::setAlias('@common', dirname(__DIR__));
|
||||
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
|
||||
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/api');
|
||||
Yii::setAlias('@api', dirname(dirname(__DIR__)) . '/api');
|
||||
Yii::setAlias('@console', dirname(dirname(__DIR__)) . '/console');
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
use common\components\PostmarkComponent;
|
||||
use common\components\GeminiApiComponent;
|
||||
use common\components\HubspotApiComponent;
|
||||
use yii\caching\FileCache;
|
||||
use yii\queue\db\Queue;
|
||||
|
||||
$params = array_merge(
|
||||
require __DIR__ . '/params.php',
|
||||
|
||||
@@ -92,17 +92,7 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
['status', 'default', 'value' => self::STATUS_ACTIVE],
|
||||
[['email'], 'email'],
|
||||
[['email'], 'unique'],
|
||||
[['sales_agent_id', 'created_at', 'updated_at'], 'integer'],
|
||||
[
|
||||
'sales_agent_id',
|
||||
'required',
|
||||
'when' => function ($model) {
|
||||
return $model->role === 'sales-agent';
|
||||
},
|
||||
'whenClient' => "function (attribute, value) {
|
||||
return $('#role').val() == 'sales-agent';
|
||||
}"
|
||||
],
|
||||
[['created_at', 'updated_at'], 'integer'],
|
||||
[
|
||||
'status',
|
||||
'in',
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"ext-json": "*",
|
||||
"cgsmith/yii2-flatpickr-widget": "~1.1",
|
||||
"donatj/phpuseragentparser": "^1.9",
|
||||
"firebase/php-jwt": "^6.11",
|
||||
"ramsey/uuid": "^4.7",
|
||||
"sentry/sentry": "^4.9",
|
||||
"twbs/bootstrap-icons": "^1.11",
|
||||
|
||||
65
composer.lock
generated
65
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "2aa71ca3104de10ae9406cd03e93cd1d",
|
||||
"content-hash": "b786f2c120f3e18850b5f0af38aa0a2c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bower-asset/bootstrap",
|
||||
@@ -412,6 +412,69 @@
|
||||
},
|
||||
"time": "2024-11-01T03:51:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
"version": "v6.11.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/firebase/php-jwt.git",
|
||||
"reference": "8f718f4dfc9c5d5f0c994cdfd103921b43592712"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/8f718f4dfc9c5d5f0c994cdfd103921b43592712",
|
||||
"reference": "8f718f4dfc9c5d5f0c994cdfd103921b43592712",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"guzzlehttp/guzzle": "^7.4",
|
||||
"phpspec/prophecy-phpunit": "^2.0",
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"psr/cache": "^2.0||^3.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-factory": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-sodium": "Support EdDSA (Ed25519) signatures",
|
||||
"paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Firebase\\JWT\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Neuman Vong",
|
||||
"email": "neuman+pear@twilio.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Anant Narayanan",
|
||||
"email": "anant@php.net",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
||||
"homepage": "https://github.com/firebase/php-jwt",
|
||||
"keywords": [
|
||||
"jwt",
|
||||
"php"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/firebase/php-jwt/issues",
|
||||
"source": "https://github.com/firebase/php-jwt/tree/v6.11.0"
|
||||
},
|
||||
"time": "2025-01-23T05:11:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.9.2",
|
||||
|
||||
@@ -41,9 +41,6 @@ return [
|
||||
],
|
||||
],
|
||||
'request' => [
|
||||
'parsers' => [
|
||||
'application/json' => 'yii\web\JsonParser',
|
||||
],
|
||||
'csrfParam' => '_csrf-frontend',
|
||||
],
|
||||
'session' => [
|
||||
|
||||
@@ -79,8 +79,23 @@ class MealController extends Controller
|
||||
public function actionSuccess($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
$startOfDay = strtotime('today midnight');
|
||||
$endOfDay = strtotime('tomorrow midnight') - 1;
|
||||
$today = Meal::find()
|
||||
->select([
|
||||
'SUM(calories) AS calories',
|
||||
'SUM(protein) AS protein',
|
||||
'SUM(fat) AS fat',
|
||||
'SUM(carbohydrates) AS carbohydrates',
|
||||
'SUM(fiber) AS fiber'
|
||||
])
|
||||
->where(['user_id' => Yii::$app->user->id])
|
||||
->andWhere(['between', 'created_at', $startOfDay, $endOfDay])
|
||||
->asArray()
|
||||
->one();
|
||||
$today = array_merge(['calories' => 0, 'protein' => 0, 'fat' => 0, 'carbohydrates' => 0, 'fiber' => 0], $today);
|
||||
|
||||
return $this->render('success', ['model' => $model]);
|
||||
return $this->render('success', ['model' => $model, 'today' => $today]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use common\models\Meal;
|
||||
use frontend\assets\ConfettiAsset;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
@@ -9,7 +8,6 @@ $this->title = Yii::$app->name;
|
||||
|
||||
ConfettiAsset::register($this);
|
||||
|
||||
|
||||
$this->registerJs("
|
||||
var end = Date.now() + (2 * 1000);
|
||||
var scalar = 2;
|
||||
@@ -57,24 +55,57 @@ var isMobile = window.innerWidth < 768; // Adjust as needed for tablets
|
||||
and your food. But also you. 🤖🍕
|
||||
</p>
|
||||
|
||||
<div class="card mx-auto p-3" style="max-width: 400px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 200;">
|
||||
<h4 class="mb-3 text-center">🍽️ <strong><?= $model->food_name ?></strong></h4>
|
||||
<div class="row">
|
||||
<div class="col-6 text-right">
|
||||
<p class="mb-0"><strong>🔥 Calories</strong></p>
|
||||
<p class="mb-0"><strong>🍗 Protein</strong></p>
|
||||
<p class="mb-0"><strong>🥑 Fat</strong></p>
|
||||
<p class="mb-0"><strong>🍞 Carbs</strong></p>
|
||||
<div class="container text-center mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<!-- Food Item Card -->
|
||||
<div class="col-md-6 d-flex">
|
||||
<div class="card p-3 w-100 h-100 d-flex flex-column" style="max-width: 400px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 200;">
|
||||
<h4 class="mb-3 text-center">🍽️ <strong><?= $model->food_name ?></strong></h4>
|
||||
<div class="row flex-grow-1">
|
||||
<div class="col-6 text-end">
|
||||
<p class="mb-0"><strong>🔥 Calories</strong></p>
|
||||
<p class="mb-0"><strong>🍗 Protein</strong></p>
|
||||
<p class="mb-0"><strong>🥑 Fat</strong></p>
|
||||
<p class="mb-0"><strong>🍞 Carbs</strong></p>
|
||||
<p class="mb-0"><strong>🌾 Fiber</strong></p>
|
||||
</div>
|
||||
<div class="col-6 text-start">
|
||||
<p class="mb-0"><?= $model->calories ?> kcal</p>
|
||||
<p class="mb-0"><?= $model->protein ?> g</p>
|
||||
<p class="mb-0"><?= $model->fat ?> g</p>
|
||||
<p class="mb-0"><?= $model->carbohydrates ?> g</p>
|
||||
<p class="mb-0"><?= $model->fiber ?> g</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<p class="mb-0"><?= $model->calories ?> kcal</p>
|
||||
<p class="mb-0"><?= $model->protein ?> g</p>
|
||||
<p class="mb-0"><?= $model->fat ?> g</p>
|
||||
<p class="mb-0"><?= $model->carbohydrates ?> g</p>
|
||||
<!-- Daily Totals Section -->
|
||||
<div class="col-md-6 d-flex mt-3 mt-md-0">
|
||||
<div class="card p-3 w-100 h-100 d-flex flex-column" style="max-width: 400px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
|
||||
<h4 class="card-title text-center">📊 <strong>Today So Far</strong></h4>
|
||||
<div class="row flex-grow-1">
|
||||
<div class="col-6 text-end">
|
||||
<p class="mb-0"><strong>🔥 Calories</strong></p>
|
||||
<p class="mb-0"><strong>🍗 Protein</strong></p>
|
||||
<p class="mb-0"><strong>🥑 Fat</strong></p>
|
||||
<p class="mb-0"><strong>🍞 Carbs</strong></p>
|
||||
<p class="mb-0"><strong>🌾 Fiber</strong></p>
|
||||
</div>
|
||||
<div class="col-6 text-start">
|
||||
<p class="mb-0"><?= $today['calories']; ?> kcal</p>
|
||||
<p class="mb-0"><?= $today['protein']; ?> g</p>
|
||||
<p class="mb-0"><?= $today['fat']; ?> g</p>
|
||||
<p class="mb-0"><?= $today['carbohydrates']; ?> g</p>
|
||||
<p class="mb-0"><?= $today['fiber']; ?> g</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="p-5 mb-4 bg-transparent rounded-3">
|
||||
<div class="container-fluid py-5 text-center">
|
||||
<p><a class="btn btn-lg btn-primary" href="/meal/upload" style="z-index: 200;">Feed me more data! 🍔</a></p>
|
||||
|
||||
Reference in New Issue
Block a user