Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query cache #4

Open
wants to merge 190 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
09188c6
updated helpdesk contact
Ronald-pro Jan 18, 2022
2b33d9a
added sms report controller
Ronald-pro Jan 19, 2022
a105b28
added sms status analytics views
Ronald-pro Jan 20, 2022
827324a
set queries for cost calculation for each sms status
Ronald-pro Jan 21, 2022
a02e5a7
added sms analytic filters
Ronald-pro Jan 24, 2022
3be02ce
added filter by partner,county,subcounty,facility on sms analytics
Ronald-pro Jan 27, 2022
27ceb6f
optimized admin level queries
Ronald-pro Feb 7, 2022
0f00ca8
checking changes
Ronald-pro Feb 8, 2022
e09134d
added clinic on the tracing list
Ronald-pro Feb 8, 2022
1f118cd
added absentsubscribers column on the sms analytics
Ronald-pro Feb 8, 2022
74bee03
implemented partners sms deliverd analytics
Ronald-pro Feb 10, 2022
b728daf
added partners sms failed analytics
Ronald-pro Feb 10, 2022
d9a2ba1
added sms cost per partners analytics
Ronald-pro Feb 10, 2022
9e875a8
included counties sms cost analytics
Ronald-pro Feb 14, 2022
7782f8c
date filters for sms analytics
Ronald-pro Feb 14, 2022
dfe14fb
updated landing page filters
Ronald-pro Feb 14, 2022
ed7405e
fixed error on message extract
Ronald-pro Feb 21, 2022
c1ac01e
Populated facility user table with partner id
Ronald-pro Mar 3, 2022
b1c8504
all active clients count and distribution by gender
Ronald-pro Mar 18, 2022
daa1162
consented and nonconsented clients count and distribution by gender&age
Ronald-pro Mar 18, 2022
58721d9
added total appointment missed counts for each level
Ronald-pro Mar 21, 2022
6318e2d
rearrange the code base
Ronald-pro Mar 23, 2022
3b6e1b0
created queries missed appointment for missed,defaulted,ltfu
Ronald-pro Mar 28, 2022
20b334c
changes on user creation and added charts for main dashboard
Ronald-pro Apr 6, 2022
a56e74c
added date filter
Ronald-pro Apr 22, 2022
e9336b5
added date filters
Ronald-pro Apr 28, 2022
ace53f3
added filters
Ronald-pro Apr 28, 2022
299c4a4
adjustment on main dashboard and client dashboard filters
Ronald-pro Apr 30, 2022
b96ddf1
update readme
Ronald-pro May 3, 2022
2a29e6c
setup cicd github workflow
andrineM May 3, 2022
6d61d84
setup cicd github workflow
andrineM May 3, 2022
5987e67
setup cicd github workflow
andrineM May 3, 2022
a8961c7
setup cicd github workflow
andrineM May 4, 2022
4c03987
setup cicd github workflow
andrineM May 4, 2022
a8cd038
Include option to server instance with nginx
andrineM May 4, 2022
e4a8bf6
Include option to server instance with nginx
andrineM May 4, 2022
761466d
Include option to server instance with nginx
andrineM May 4, 2022
42f110e
Update README.md
kevlanyo May 4, 2022
d4dc9ca
Update Readme
Ronald-pro May 4, 2022
e1d01dc
Include option to server instance with nginx
andrineM May 4, 2022
df332d2
Include option to serve instance with nginx on https://prod.kenyahmis…
andrineM May 4, 2022
46b66a8
Merge pull request #1 from palladiumkenya/cicd
andrineM May 4, 2022
8f709fe
Include option to serve instance with nginx on https://prod.kenyahmis…
andrineM May 4, 2022
35b4a93
Merge pull request #2 from palladiumkenya/cicd
andrineM May 4, 2022
06e97cf
Revert "Include option to serve instance with nginx on https://prod.k…
andrineM May 4, 2022
81c3a26
Merge pull request #3 from palladiumkenya/revert-2-cicd
andrineM May 4, 2022
0ceface
Disable pseudo-tty allocation and include php artisan key:generate co…
andrineM May 4, 2022
cc971b7
Disable pseudo-tty allocation and include php artisan key:generate co…
andrineM May 4, 2022
b5ca9cd
Merge branch 'main' into cicd
andrineM May 4, 2022
1a9b95c
Merge pull request #4 from palladiumkenya/cicd
andrineM May 4, 2022
1bbba87
update client upload
Ronald-pro May 6, 2022
c63d706
refactor the filters
Ronald-pro May 10, 2022
cc3a0c7
added clients linelist
Ronald-pro May 13, 2022
fcac321
adjusted latest changes
Ronald-pro May 16, 2022
e5216dc
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro May 16, 2022
4407cad
updated changes
Ronald-pro May 23, 2022
bf7dd54
code clean up and rearrangment of side bars
Ronald-pro May 27, 2022
46953bc
changed datetime to date on client extract
Ronald-pro May 30, 2022
c14a0f4
added label of facility date filters
Ronald-pro May 30, 2022
f9dc0ba
updated client profile search based on UPN No
Ronald-pro May 30, 2022
e6e80e8
fixed bug on tracing cost
Ronald-pro Jun 6, 2022
98d4878
updated sms charts labels and disable future dates on date filter
Ronald-pro Jun 7, 2022
b120b8d
Added Spinner
victorwere Jun 8, 2022
ca14d26
updated cumulative numbers
Ronald-pro Jun 8, 2022
73bbc71
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro Jun 8, 2022
7dbf3c7
updated cumulative numbers and added downloadable script extract
Ronald-pro Jun 8, 2022
5ff9aeb
changed logos
Ronald-pro Jun 9, 2022
0cb5140
updated sms delivery status labels and removed untracked delivery status
kevlanyo Jun 9, 2022
acf8544
Merge branch 'main' into main
Ronald-pro Jun 9, 2022
69ba75e
Merge pull request #5 from kevlanyo/main
Ronald-pro Jun 9, 2022
d067dd8
changes update
Ronald-pro Jun 9, 2022
a71b5ee
updated client upload
Ronald-pro Jun 10, 2022
02c45a3
fixed bug on dsd reports
Ronald-pro Jun 10, 2022
2ff1db1
fixed bug on partner level no of registered facilities
Ronald-pro Jun 13, 2022
e71d4fe
fixed bug on dsd reports
Ronald-pro Jun 13, 2022
de5c62c
bug fix on filter by dsd and pmtc on registered facilities
Ronald-pro Jun 14, 2022
de4b0d1
change on filters
Ronald-pro Jun 14, 2022
1dbf93e
change on filters
Ronald-pro Jun 14, 2022
f936d5c
change on filters
Ronald-pro Jun 14, 2022
131f63a
started updates on hei profile
Ronald-pro Jun 17, 2022
05e97b7
fixed bug caregiver id
Ronald-pro Jun 17, 2022
b7c89c7
fixed breaking pmtct filter
Ronald-pro Jun 17, 2022
fca4279
completed inclusion of HEI profile search
Ronald-pro Jun 22, 2022
fb779f0
done with patient referral notifier
Ronald-pro Jul 5, 2022
1093deb
updated HEI number consistently on HEI records
Ronald-pro Jul 5, 2022
a041dc6
fixed bug on partner name disappears on user update
Ronald-pro Jul 7, 2022
4893abd
added HEI appointment linelist and integrated patient referral with s…
Ronald-pro Jul 7, 2022
22c7e92
refactored sms scheduler models and controller
kevlanyo Jul 7, 2022
c04e253
updated client referral
Ronald-pro Jul 8, 2022
2f24c11
Merge remote-tracking branch 'origin/sms-scheduler'
Ronald-pro Jul 8, 2022
fb7642e
hei appointment list for facility level only
Ronald-pro Jul 13, 2022
4ee7787
Added ENV variables for sms engine key and hostname
kevlanyo Jul 13, 2022
28383c7
Merge pull request #6 from palladiumkenya/sms-scheduler
cbrianbet Jul 13, 2022
f71537a
updated sms scheduler routes
kevlanyo Jul 13, 2022
747096d
added demographic on the client registration form
Ronald-pro Jul 13, 2022
20c57b9
updated client consent on KenyaEMR upload to No
Ronald-pro Jul 13, 2022
a43eb3f
changes on broadcast
Ronald-pro Jul 14, 2022
69f32d0
resolved merged conflict
Ronald-pro Jul 14, 2022
e97c0b8
updated dsd clients list and hei appointment list
Ronald-pro Jul 14, 2022
720e8df
disable inactive clients on update
Ronald-pro Jul 14, 2022
ff8b07e
logos update
Ronald-pro Jul 18, 2022
b601509
updated changes on patient referral
Ronald-pro Jul 21, 2022
8ed17ba
Update cicd_process.yml
Murithijoshua Jul 21, 2022
39ed7a6
Update cicd_process.yml
Murithijoshua Jul 21, 2022
f1be7b2
call only active groups on broadcast
Ronald-pro Jul 22, 2022
34ddd18
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro Jul 22, 2022
2b7ac43
created past and todays appointments table functions
Ronald-pro Jul 22, 2022
35359f5
updated patient referral with the gateway
Ronald-pro Jul 22, 2022
6ad25f0
updated patient referral
Ronald-pro Jul 22, 2022
28f9417
updated patient referral
Ronald-pro Jul 22, 2022
6a715f1
updated patient referral
Ronald-pro Jul 22, 2022
accb017
added new route - current appointments
kevlanyo Aug 1, 2022
0fc83f9
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
kevlanyo Aug 1, 2022
22a4d9b
added new calendar controller method and blade view
kevlanyo Aug 1, 2022
cf10cdf
Fixing composer install
Murithijoshua Aug 2, 2022
36de5a2
fixed bug on filtering registered facilities display wrong numbers
Ronald-pro Aug 11, 2022
0c3a919
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro Aug 11, 2022
62a8a92
Modify ClientOutgoing model and ScheduleSMSController to track appoin…
kevlanyo Aug 31, 2022
2aa245c
new dashboard distribution
Ronald-pro Aug 31, 2022
a79d0a3
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro Aug 31, 2022
e6d6cbe
data filters
Ronald-pro Aug 31, 2022
d4561b1
error fix
Ronald-pro Aug 31, 2022
35aa04c
cumulative data table
Ronald-pro Sep 1, 2022
ec4e561
added sms send counts and code clean up
Ronald-pro Sep 1, 2022
84b3005
added tracing outcome report
Ronald-pro Oct 22, 2022
01f29c7
edit of clients details
Ronald-pro Oct 26, 2022
515474a
fix pdf export on tracing outcome
Ronald-pro Oct 26, 2022
b509614
enabled client bulk upload at facility level
Ronald-pro Oct 26, 2022
c7de001
fixed broadcast UI
Ronald-pro Oct 31, 2022
031c0f6
fixed HEI List showing HEI as active and the HEI is TO,Deceased,Disch…
Ronald-pro Oct 31, 2022
6f8bfbf
fixed bug on appointments
Ronald-pro Nov 2, 2022
c1735d7
added user broadcast
Ronald-pro Nov 4, 2022
e2b72bf
resolved MHEAL 163:Issues of clients receiving messages with differen…
kevlanyo Nov 4, 2022
81b5cba
bug fix
Ronald-pro Nov 7, 2022
fe0d798
Update cicd_process.yml
WambuiPeris Nov 8, 2022
a6be292
Create Test deployment.yml
Murithijoshua Nov 9, 2022
83d56d7
Update README.md
Murithijoshua Nov 9, 2022
1e2388e
included honored and unscheduled on appointment calendar
Ronald-pro Nov 17, 2022
deb07df
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro Nov 17, 2022
ad47995
making appointment calendar downloadable
Ronald-pro Nov 17, 2022
c565776
Filtering messages sent to clients within a period from the list
Ronald-pro Nov 23, 2022
531e551
pmtct list fix
Ronald-pro Nov 24, 2022
64c8c5e
activation of county and subcounty
Ronald-pro Dec 2, 2022
d7c31a7
refine county and subcounty content view
Ronald-pro Dec 5, 2022
8dc2b71
populated not honored appointments on app calendar
Ronald-pro Dec 6, 2022
98e8d1e
added app summary table on app calendar
Ronald-pro Dec 8, 2022
40f6cb3
included upi no field on client lists
Ronald-pro Dec 8, 2022
d2731cc
upi dashboards views
Ronald-pro Dec 16, 2022
770297c
populated verified and not verified chart %
Ronald-pro Dec 16, 2022
b2ac9c9
sidebar for verification
Ronald-pro Dec 16, 2022
14b65d5
change on national verification list
Ronald-pro Dec 16, 2022
6046532
set limit on graphs y-axis
Ronald-pro Dec 16, 2022
8cec308
changes on upi dashboard
Ronald-pro Dec 16, 2022
4ccb435
appointment dashboard view
Ronald-pro Jan 9, 2023
f070b50
populated appointment trends cards
Ronald-pro Jan 26, 2023
3834abc
populated the appointment and missed appointment charts
Ronald-pro Jan 29, 2023
67348c5
alignment and data population on app charts
Ronald-pro Jan 31, 2023
9364566
Reducing timeouts on deployments
Murithijoshua Feb 1, 2023
076285d
Update cicd_process.yml
Murithijoshua Feb 1, 2023
706b6ff
changes on the app dashboard layout
Ronald-pro Feb 1, 2023
cee2c80
Merge branch 'main' of https://github.com/palladiumkenya/ushauri_dash…
Ronald-pro Feb 1, 2023
094e5fe
add some filters with ajax request
Ronald-pro Feb 2, 2023
0be5bd0
asynchronous data load
Ronald-pro Feb 6, 2023
052aa86
fixed error on getting undefined or null values
Ronald-pro Feb 7, 2023
1f53848
clean up on the data filters
Ronald-pro Feb 8, 2023
78847e3
labelling and added missing client info on the linelist
Ronald-pro Feb 8, 2023
ef5e50b
cards rearrangment,styling and other fixes
Ronald-pro Feb 9, 2023
060f182
disable inputs on the date filters
Ronald-pro Feb 10, 2023
2a4b0ce
percentage rounding
Ronald-pro Feb 10, 2023
b39c12a
fixed number count matching and additional styling clean up
Ronald-pro Feb 10, 2023
3f390ea
clean up on the font sizing
Ronald-pro Feb 13, 2023
0abbb72
code clean up
Ronald-pro Feb 15, 2023
ab22335
made facilities to be dependent on site type
Ronald-pro Feb 16, 2023
946f35c
fixed error on duplicate dates on messeges list
Ronald-pro Feb 21, 2023
d89dd15
added sms status on appointment calender list
Ronald-pro Feb 22, 2023
3fc679e
added sms status on appointment calender list
Ronald-pro Feb 23, 2023
17ce5b2
fixed error on app calendar
Ronald-pro Feb 23, 2023
4e0d6fb
commented auth error
Ronald-pro Feb 23, 2023
df644d6
refactored migration controller
Ronald-pro Mar 1, 2023
189fa9c
fixed future apps showing honored on the calendar
Ronald-pro Mar 1, 2023
bbf02e8
updated appointment on distinct client_id
Ronald-pro Mar 6, 2023
dcc887c
reverted iit to ltfu and cards single color code
Ronald-pro Mar 7, 2023
2fa1566
commented out previous app dashboards
Ronald-pro Mar 7, 2023
a533e61
added styling on cards progress circulars
Ronald-pro Mar 8, 2023
7b2f019
added missed rate by period graph
Ronald-pro Mar 9, 2023
9a1214b
change on missed rate by period
Ronald-pro Mar 10, 2023
2885589
changes
Ronald-pro Mar 12, 2023
f9cab46
Merge branch 'master' into main
cbrianbet Mar 13, 2023
cb9d704
Initial configuration for query caching
kevlanyo Mar 20, 2023
e68f743
Query cache updates in server side scripts
kevlanyo Mar 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

SMS_SERVICE_HOST="https://domain-to-sms-service/api/sender"
SMS_SERVICE_KEY="sms-service-key"
39 changes: 39 additions & 0 deletions .github/workflows/Test deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: deploy to test instance
on:
push:
branches: [ main ]
jobs:

build:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: executing remote connection
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.CICD_SECRET }}
port: ${{ secrets.PORT }}
script: |
cd /apps/github-workflows/mhealth-apps/
sudo rm -rf ushauri_dashboard
sudo mkdir ushauri_dashboard
sudo chown -R cicd2:cicd2 ushauri_dashboard
git config --global --add safe.directory /apps/github-workflows/mhealth-apps/ushauri_dashboard/
cd ushauri_dashboard
git clone -b main https://github.com/palladiumkenya/ushauri_dashboard.git .
git status
cp /apps/configs/ushauri-dashboard/.env /apps/github-workflows/mhealth-apps/ushauri_dashboard/
cp /apps/configs/ushauri-dashboard/docker-compose.yml /apps/github-workflows/mhealth-apps/ushauri_dashboard/
cp /apps/configs/ushauri-dashboard/nginx.dockerfile /apps/github-workflows/mhealth-apps/ushauri_dashboard/
cp /apps/configs/ushauri-dashboard/php.dockerfile /apps/github-workflows/mhealth-apps/ushauri_dashboard/
cp -r /apps/configs/ushauri-dashboard/nginx /apps/github-workflows/mhealth-apps/ushauri_dashboard/
docker-compose down
docker-compose rm -f
docker-compose --env-file .env up -d --build site
# execute normal laravel commands
docker-compose exec -T php composer install --ignore-platform-reqs --no-dev
docker-compose exec -T php php artisan config:cache
docker-compose exec -T php php artisan view:cache
docker-compose exec -T php chmod -R 777 storage/
22 changes: 22 additions & 0 deletions .github/workflows/cicd_process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: deploy to test instance
on:
push:
branches: [ master ]
jobs:

build:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: executing remote connection
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USERNAME }}
key: ${{ secrets.PRODUCTION_SECRET }}
port: ${{ secrets.PRODUCTION_PORT }}
script: |

cd /var/www/ushauri_dashboard
git pull origin

82 changes: 41 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
# Getting started
[![deploy to test instance](https://github.com/palladiumkenya/ushauri_dashboard/actions/workflows/cicd_process.yml/badge.svg)](https://github.com/palladiumkenya/ushauri_dashboard/actions/workflows/cicd_process.yml)
## Installation
<hr>
Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/8.x/installation)

<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
</p>
Clone the repository

## About Laravel
git clone https://github.com/palladiumkenya/ushauri_dashboard

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
Switch to the repo folder
cd ushauri_dashboard

- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Install all the dependencies using composer

Laravel is accessible, powerful, and provides tools required for large, robust applications.
composer install

## Learning Laravel
Copy the example env file and make the required configuration changes in the .env file

Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
cp .env.example .env

If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
Start the local development server

## Laravel Sponsors
php artisan serve

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
You can now access the server at http://localhost:8000

### Premium Partners
**TL;DR command list**

- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- **[OP.GG](https://op.gg)**
git clone https://github.com/palladiumkenya/ushauri_dashboard
cd ushauri_dashboard
composer install
cp .env.example .env
php artisan serve

----------

## Contributing
# Code overview

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Folders

## Code of Conduct
- `app/Models` - Contains all the Eloquent models
- `app/Http/Controllers` - Contain all the data controllers
- `app/Http/Controllers/Auth` - Contains all the auth controllers
- `app/Http/Middleware` - Contains the JWT auth middleware
- `app/Http/Jobs` - Contains all the jobs handlers
- `config` - Contains all the application configuration files
- `database/factories` - Contains the model factory for all the models
- `database/seeds` - Contains the database seeder
- `resources` - Contains all the application views and styling files
- `routes` - Contains all the web routes defined in web.php file
- `tests` - Contains all the application tests

In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Environment variables

## Security Vulnerabilities
- `.env` - Environment variables can be set in this file

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
***Note*** : You can quickly set the database information and other variables in this file and have the application fully working.

## License
----------

The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
167 changes: 167 additions & 0 deletions app/Console/Commands/ClientReferral.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

namespace App\Console\Commands;

use AfricasTalking\SDK\AfricasTalking;

use App\Http\Controllers\SenderController;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use App\Models\Client;
use App\Models\Appointments;
use App\Models\Facility;
use App\Models\Ward;
use App\Models\Content;
use App\Models\ClientOutgoing;
use DB;
use Carbon\Carbon;

use function PHPUnit\Framework\isEmpty;

class ClientReferral extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'client:referral';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Notify Transfered Clients';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/

public function send_message($source, $destination, $msg)
{
$key = env('SMS_SERVICE_KEY', '');
$host = env('SMS_SERVICE_HOST', '');

$this->httpresponse = Http::withoutVerifying()
->withHeaders(['api-token' => "$key"])
->post("$host", [
'destination' => $destination,
'msg' => $msg,
'sender_id' => $destination,
'gateway' => $source,

]);

return json_decode($this->httpresponse->getBody(), true);
}

public function handle()
{
$client = Client::join('tbl_master_facility', 'tbl_client.mfl_code', '=', 'tbl_master_facility.code')
->leftJoin('tbl_ward', 'tbl_master_facility.Ward_id', '=', 'tbl_ward.id')
->join('tbl_appointment', 'tbl_client.id', '=', 'tbl_appointment.client_id')
->select(
'tbl_client.clinic_number',
'tbl_client.id as client_id',
'tbl_client.phone_no',
'tbl_client.client_type',
'tbl_client.f_name',
'tbl_client.language_id',
'tbl_master_facility.name as facility',
'tbl_ward.name as location',
DB::raw('(CASE WHEN tbl_appointment.appntmnt_date > CURDATE() THEN tbl_appointment.appntmnt_date
WHEN tbl_client.language_id = "1" THEN "huna siku ya cliniki"
ELSE "no appointment" END) as appointment_date')
)
->where('tbl_client.client_type', '=', 'Transfer')
->whereNotNull('tbl_client.phone_no')
->whereDate('tbl_client.updated_at', [now()->subMinutes(30), now()])
->groupBy('tbl_client.id')
->get();



foreach ($client as $value) {
$phone_no = $value->phone_no;
$client_id = $value->client_id;
$client_type = $value->client_type;
$client_name = $value->f_name;
$facility = $value->facility;
$location = $value->location;
$language = $value->language_id;
$appointment_date = $value->appointment_date;

$check_existence = ClientOutgoing::select('*')->where('message_type_id', '=', '2')
->where('clnt_usr_id', '=', $client_id)
->whereDate('created_at', '=', Carbon::Now())
->limit(1)->count();

if ($check_existence > 0) {
echo 'Message already sent to the client';
} else {
if (!empty($phone_no)) {

if ($language !== 2 || $language !== 1) {
$get_message = Content::select('*')->where('identifier', '=', '20')->where('language_id', '=', '2')->get();
} else {
$get_message = Content::select('*')->where('identifier', '=', '20')->where('language_id', '=', $language)->get();
}

foreach ($get_message as $value) {
$message = $value->content;
$content_id = $value->id;
$source = '40149';

$new_message = str_replace("XXX", $client_name, $message);
$facility_name = str_replace('FFF', $facility, $new_message);
$location_name = str_replace('LLL', $location, $facility_name);
$final_message = str_replace('YYY', $appointment_date, $location_name);

$save_outgoing = new ClientOutgoing;

$save_outgoing->destination = $phone_no;
$save_outgoing->msg = $final_message;
$save_outgoing->source = '40149';
$save_outgoing->responded = 'No';
$save_outgoing->status = 'Not Sent';
$save_outgoing->message_type_id = '2';
$save_outgoing->clnt_usr_id = $client_id;
$save_outgoing->recepient_type = 'Client';
$save_outgoing->content_id = $content_id;
// $save_outgoing->created_at = date("Y-m-d H:i:s");
$save_outgoing->created_by = '1';

if ($save_outgoing->save()) {
// $sender = new SenderController;
$sender = $this->send_message($source, $phone_no, $final_message);

echo json_encode($sender);
} else {
echo 'Could not send the message';
}
}
} else {
echo 'Can not send to an empty phone number';
}
}
}

dd("Clients : {$client}");


// return 0;
}
}
5 changes: 3 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//
'App\Console\Commands\ClientReferral',
];

/**
Expand All @@ -25,6 +25,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
$schedule->command('client:referral')->everyMinutes(30);
}

/**
Expand All @@ -34,7 +35,7 @@ protected function schedule(Schedule $schedule)
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');

require base_path('routes/console.php');
}
Expand Down
Loading