From 82674c1237e3920e982d3b457327b93a13cd4a2e Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 22 Apr 2021 09:31:45 +0300 Subject: [PATCH 01/47] Update DataController.php --- app/Http/Controllers/DataController.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/DataController.php b/app/Http/Controllers/DataController.php index 934c656..a4be5ca 100755 --- a/app/Http/Controllers/DataController.php +++ b/app/Http/Controllers/DataController.php @@ -175,12 +175,12 @@ public function vl_srl_results(Request $request) $results->where('partner', $partner->name); } if (!empty($request->county_id)) { - $partner = County::find($request->county_id); + $county = County::find($request->county_id); $results->where('county', $county->name); } if (!empty($request->sub_county_id)) { - $partner = SubCounty::find($request->sub_county_id); - $results->where('partner', $sub_county->name); + $sub_county = SubCounty::find($request->sub_county_id); + $results->where('sub_county', $sub_county->name); } if (!empty($request->code)) { $facility = Facility::where('code', $request->code)->first(); @@ -233,12 +233,12 @@ public function eid_srl_results(Request $request) $results->where('partner', $partner->name); } if (!empty($request->county_id)) { - $partner = County::find($request->county_id); + $county = County::find($request->county_id); $results->where('county', $county->name); } if (!empty($request->sub_county_id)) { - $partner = SubCounty::find($request->sub_county_id); - $results->where('partner', $sub_county->name); + $sub_county = SubCounty::find($request->sub_county_id); + $results->where('sub_county', $sub_county->name); } if (!empty($request->code)) { $facility = Facility::where('code', $request->code)->first(); @@ -293,12 +293,12 @@ public function hts_srl_results(Request $request) $results->where('partner', $partner->name); } if (!empty($request->county_id)) { - $partner = County::find($request->county_id); + $county = County::find($request->county_id); $results->where('county', $county->name); } if (!empty($request->sub_county_id)) { - $partner = SubCounty::find($request->sub_county_id); - $results->where('partner', $sub_county->name); + $sub_county = SubCounty::find($request->sub_county_id); + $results->where('sub_county', $sub_county->name); } if (!empty($request->code)) { $facility = Facility::where('code', $request->code)->first(); From b8e39bc5f2eaa510cfa3d1311bccb4fa51102881 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Apr 2021 14:21:55 +0300 Subject: [PATCH 02/47] terms for app --- app/Http/Controllers/TermsController.php | 16 +++ resources/views/data/terms.blade.php | 162 +++++++++++++++++++++++ routes/web.php | 1 + 3 files changed, 179 insertions(+) create mode 100644 app/Http/Controllers/TermsController.php create mode 100644 resources/views/data/terms.blade.php diff --git a/app/Http/Controllers/TermsController.php b/app/Http/Controllers/TermsController.php new file mode 100644 index 0000000..9e6c0e2 --- /dev/null +++ b/app/Http/Controllers/TermsController.php @@ -0,0 +1,16 @@ + + + + + + mLab Privacy Policy + + + + + + + +

mLab - TERMS AND CONDITIONS

+ +

These terms and conditions ("Agreement") set forth the general terms and conditions of your use of the mLab.mhealthkenya.co.ke website ("Website"), "mLab" mobile application ("Mobile Application") and any of their related products and services (collectively, "Services"). This Agreement is legally binding between you ("User", "you" or "your") and this Website operator and Mobile Application developer ("Operator", "we", "us" or "our"). By accessing and using the Services, you acknowledge that you have read, understood, and agree to be bound by the terms of this Agreement. If you are entering into this Agreement on behalf of a business or other legal entity, you represent that you have the authority to bind such entity to this Agreement, in which case the terms "User", "you" or "your" shall refer to such entity. If you do not have such authority, or if you do not agree with the terms of this Agreement, you must not accept this Agreement and may not access and use the Services. You acknowledge that this Agreement is a contract between you and the Operator, even though it is electronic and is not physically signed by you, and it governs your use of the Services.

+ +Accounts and membership + +

You must be at least 18 years of age to use the Services. By using the Services and by agreeing to this Agreement you warrant and represent that you are at least 18 years of age. If you create an account on the Services, you are responsible for maintaining the security of your account and you are fully responsible for all activities that occur under the account and any other actions taken in connection with it. We may, but have no obligation to, monitor and review new accounts before you may sign in and start using the Services. Providing false contact information of any kind may result in the termination of your account. You must immediately notify us of any unauthorized uses of your account or any other breaches of security. We will not be liable for any acts or omissions by you, including any damages of any kind incurred as a result of such acts or omissions. We may suspend, disable, or delete your account (or any part thereof) if we determine that you have violated any provision of this Agreement or that your conduct or content would tend to damage our reputation and goodwill. If we delete your account for the foregoing reasons, you may not re-register for our Services. We may block your email address and Internet protocol address to prevent further registration.

+ +Links to other resources + +

Although the Services may link to other resources (such as websites, mobile applications, etc.), we are not, directly or indirectly, implying any approval, association, sponsorship, endorsement, or affiliation with any linked resource, unless specifically stated herein. We are not responsible for examining or evaluating, and we do not warrant the offerings of, any businesses or individuals or the content of their resources. We do not assume any responsibility or liability for the actions, products, services, and content of any other third parties. You should carefully review the legal statements and other conditions of use of any resource which you access through a link on the Services. Your linking to any other off-site resources is at your own risk.

+ +Prohibited uses + +

In addition to other terms as set forth in the Agreement, you are prohibited from using the Services or Content: (a) for any unlawful purpose; (b) to solicit others to perform or participate in any unlawful acts; (c) to violate any international, federal, provincial or state regulations, rules, laws, or local ordinances; (d) to infringe upon or violate our intellectual property rights or the intellectual property rights of others; (e) to harass, abuse, insult, harm, defame, slander, disparage, intimidate, or discriminate based on gender, sexual orientation, religion, ethnicity, race, age, national origin, or disability; (f) to submit false or misleading information; (g) to upload or transmit viruses or any other type of malicious code that will or may be used in any way that will affect the functionality or operation of the Services, third party products and services, or the Internet; (h) to spam, phish, pharm, pretext, spider, crawl, or scrape; (i) for any obscene or immoral purpose; or (j) to interfere with or circumvent the security features of the Services, third party products and services, or the Internet. We reserve the right to terminate your use of the Services for violating any of the prohibited uses.

+ +Intellectual property rights + +

"Intellectual Property Rights" means all present and future rights conferred by statute, common law or equity in or in relation to any copyright and related rights, trademarks, designs, patents, inventions, goodwill and the right to sue for passing off, rights to inventions, rights to use, and all other intellectual property rights, in each case whether registered or unregistered and including all applications and rights to apply for and be granted, rights to claim priority from, such rights and all similar or equivalent rights or forms of protection and any other results of intellectual activity which subsist or will subsist now or in the future in any part of the world. This Agreement does not transfer to you any intellectual property owned by the Operator or third parties, and all rights, titles, and interests in and to such property will remain (as between the parties) solely with the Operator. All trademarks, service marks, graphics and logos used in connection with the Services, are trademarks or registered trademarks of the Operator or its licensors. Other trademarks, service marks, graphics and logos used in connection with the Services may be the trademarks of other third parties. Your use of the Services grants you no right or license to reproduce or otherwise use any of the Operator or third party trademarks.

+ +Limitation of liability + +

To the fullest extent permitted by applicable law, in no event will the Operator, its affiliates, directors, officers, employees, agents, suppliers or licensors be liable to any person for any indirect, incidental, special, punitive, cover or consequential damages (including, without limitation, damages for lost profits, revenue, sales, goodwill, use of content, impact on business, business interruption, loss of anticipated savings, loss of business opportunity) however caused, under any theory of liability, including, without limitation, contract, tort, warranty, breach of statutory duty, negligence or otherwise, even if the liable party has been advised as to the possibility of such damages or could have foreseen such damages. To the maximum extent permitted by applicable law, the aggregate liability of the Operator and its affiliates, officers, employees, agents, suppliers and licensors relating to the services will be limited to an amount greater of one dollar or any amounts actually paid in cash by you to the Operator for the prior one month period prior to the first event or occurrence giving rise to such liability. The limitations and exclusions also apply if this remedy does not fully compensate you for any losses or fails of its essential purpose.

+ +Indemnification + +

You agree to indemnify and hold the Operator and its affiliates, directors, officers, employees, agents, suppliers and licensors harmless from and against any liabilities, losses, damages or costs, including reasonable attorneys' fees, incurred in connection with or arising from any third party allegations, claims, actions, disputes, or demands asserted against any of them as a result of or relating to your Content, your use of the Services or any willful misconduct on your part.

+ +Severability + +

All rights and restrictions contained in this Agreement may be exercised and shall be applicable and binding only to the extent that they do not violate any applicable laws and are intended to be limited to the extent necessary so that they will not render this Agreement illegal, invalid or unenforceable. If any provision or portion of any provision of this Agreement shall be held to be illegal, invalid or unenforceable by a court of competent jurisdiction, it is the intention of the parties that the remaining provisions or portions thereof shall constitute their agreement with respect to the subject matter hereof, and all such remaining provisions or portions thereof shall remain in full force and effect.

+ +Dispute resolution + +

The formation, interpretation, and performance of this Agreement and any disputes arising out of it shall be governed by the substantive and procedural laws of Kenya without regard to its rules on conflicts or choice of law and, to the extent applicable, the laws of Kenya. The exclusive jurisdiction and venue for actions related to the subject matter hereof shall be the courts located in Kenya, and you hereby submit to the personal jurisdiction of such courts. You hereby waive any right to a jury trial in any proceeding arising out of or related to this Agreement. The United Nations Convention on Contracts for the International Sale of Goods does not apply to this Agreement.

+ +Changes and amendments + +

We reserve the right to modify this Agreement or its terms relating to the Services at any time, effective upon posting of an updated version of this Agreement on the Services. When we do, we will post a notification within the Services. Continued use of the Services after any such changes shall constitute your consent to such changes.

+ +Acceptance of these terms + +

You acknowledge that you have read this Agreement and agree to all its terms and conditions. By accessing and using the Services you agree to be bound by this Agreement. If you do not agree to abide by the terms of this Agreement, you are not authorized to access or use the Services.

+ +Contacting us + +

If you would like to contact us to understand more about this Agreement or wish to contact us concerning any matter relating to it, you may send an email to support.tech@mhealthkenya.org.

+ + + +

PRIVACY POLICY

+ +

This privacy policy ("Policy") describes how the personally identifiable information ("Personal Information") you may provide on the mLab.mhealthkenya.co.ke website ("Website"), "mLab" mobile application ("Mobile Application") and any of their related products and services (collectively, "Services") is collected, protected and used. It also describes the choices available to you regarding our use of your Personal Information and how you can access and update this information. This Policy is a legally binding agreement between you ("User", "you" or "your") and this Website operator and Mobile Application developer ("Operator", "we", "us" or "our"). By accessing and using the Services, you acknowledge that you have read, understood, and agree to be bound by the terms of this Policy.

+ +Automatic collection of information + +

Our top priority is customer data security and, as such, we exercise the no logs policy. We may process only minimal user data, only as much as it is absolutely necessary to maintain the Services. Information collected automatically is used only to identify potential cases of abuse and establish statistical information regarding the usage and traffic of the Services. This statistical information is not otherwise aggregated in such a way that would identify any particular user of the system.

+ +Collection of personal information + +

You can access and use the Services without telling us who you are or revealing any information by which someone could identify you as a specific, identifiable individual. If, however, you wish to use some of the features on the Services, you may be asked to provide certain Personal Information (for example, your name and e-mail address). We receive and store any information you knowingly provide to us when you create an account, or fill any online forms on the Services. When required, this information may include the following: + +

+ +Some of the information we collect is directly from you via the Services. However, we may also collect Personal Information about you from other sources such as public databases and our joint marketing partners. You can choose not to provide us with your Personal Information, but then you may not be able to take advantage of some of the features on the Services. Users who are uncertain about what information is mandatory are welcome to contact us.

+ +Use and processing of collected information + +

In order to make the Services available to you, or to meet a legal obligation, we need to collect and use certain Personal Information. If you do not provide the information that we request, we may not be able to provide you with the requested products or services. Any of the information we collect from you may be used for the following purposes: + +

+ +Processing your Personal Information depends on how you interact with the Services, where you are located in the world and if one of the following applies: (i) you have given your consent for one or more specific purposes; this, however, does not apply, whenever the processing of Personal Information is subject to European data protection law; (ii) provision of information is necessary for the performance of an agreement with you and/or for any pre-contractual obligations thereof; (iii) processing is necessary for compliance with a legal obligation to which you are subject; (iv) processing is related to a task that is carried out in the public interest or in the exercise of official authority vested in us; (v) processing is necessary for the purposes of the legitimate interests pursued by us or by a third party. + +Note that under some legislations we may be allowed to process information until you object to such processing (by opting out), without having to rely on consent or any other of the following legal bases below. In any case, we will be happy to clarify the specific legal basis that applies to the processing, and in particular whether the provision of Personal Information is a statutory or contractual requirement, or a requirement necessary to enter into a contract.

+ +Managing information + +

You are able to delete certain Personal Information we have about you. The Personal Information you can delete may change as the Services change. When you delete Personal Information, however, we may maintain a copy of the unrevised Personal Information in our records for the duration necessary to comply with our obligations to our affiliates and partners, and for the purposes described below. If you would like to delete your Personal Information or permanently delete your account, you can do so on the settings page of your account on the Services or simply by contacting us.

+ +Disclosure of information + +

Depending on the requested Services or as necessary to complete any transaction or provide any service you have requested, we may share your information with your consent with our trusted third parties that work with us, any other affiliates and subsidiaries we rely upon to assist in the operation of the Services available to you. We do not share Personal Information with unaffiliated third parties. These service providers are not authorized to use or disclose your information except as necessary to perform services on our behalf or comply with legal requirements. We may share your Personal Information for these purposes only with third parties whose privacy policies are consistent with ours or who agree to abide by our policies with respect to Personal Information. These third parties are given Personal Information they need only in order to perform their designated functions, and we do not authorize them to use or disclose Personal Information for their own marketing or other purposes. + + We will disclose any Personal Information we collect, use or receive if required or permitted by law, such as to comply with a subpoena, or similar legal process, and when we believe in good faith that disclosure is necessary to protect our rights, protect your safety or the safety of others, investigate fraud, or respond to a government request.

+ +Retention of information + +

We will retain and use your Personal Information for the period necessary to comply with our legal obligations, resolve disputes, and enforce our agreements unless a longer retention period is required or permitted by law. We may use any aggregated data derived from or incorporating your Personal Information after you update or delete it, but not in a manner that would identify you personally. Once the retention period expires, Personal Information shall be deleted. Therefore, the right to access, the right to erasure, the right to rectification and the right to data portability cannot be enforced after the expiration of the retention period.

+ +The rights of users + +

You may exercise certain rights regarding your information processed by us. In particular, you have the right to do the following: (i) you have the right to withdraw consent where you have previously given your consent to the processing of your information; (ii) you have the right to object to the processing of your information if the processing is carried out on a legal basis other than consent; (iii) you have the right to learn if information is being processed by us, obtain disclosure regarding certain aspects of the processing and obtain a copy of the information undergoing processing; (iv) you have the right to verify the accuracy of your information and ask for it to be updated or corrected; (v) you have the right, under certain circumstances, to restrict the processing of your information, in which case, we will not process your information for any purpose other than storing it; (vi) you have the right, under certain circumstances, to obtain the erasure of your Personal Information from us; (vii) you have the right to receive your information in a structured, commonly used and machine readable format and, if technically feasible, to have it transmitted to another controller without any hindrance. This provision is applicable provided that your information is processed by automated means and that the processing is based on your consent, on a contract which you are part of or on pre-contractual obligations thereof.

+ +Privacy of children + +

We do not knowingly collect any Personal Information from children under the age of 18. If you are under the age of 18, please do not submit any Personal Information through the Services. We encourage parents and legal guardians to monitor their children's Internet usage and to help enforce this Policy by instructing their children never to provide Personal Information through the Services without their permission. If you have reason to believe that a child under the age of 18 has provided Personal Information to us through the Services, please contact us. You must also be old enough to consent to the processing of your Personal Information in your country (in some countries we may allow your parent or guardian to do so on your behalf).

+ +Do Not Track signals + +

Some browsers incorporate a Do Not Track feature that signals to websites you visit that you do not want to have your online activity tracked. Tracking is not the same as using or collecting information in connection with a website. For these purposes, tracking refers to collecting personally identifiable information from consumers who use or visit a website or online service as they move across different websites over time. The Services do not track its visitors over time and across third party websites. However, some third party sites may keep track of your browsing activities when they serve you content, which enables them to tailor what they present to you.

+ +Links to other resources + +

The Services contain links to other resources that are not owned or controlled by us. Please be aware that we are not responsible for the privacy practices of such other resources or third parties. We encourage you to be aware when you leave the Services and to read the privacy statements of each and every resource that may collect Personal Information.

+ +Information security + +

We secure information you provide on computer servers in a controlled, secure environment, protected from unauthorized access, use, or disclosure. We maintain reasonable administrative, technical, and physical safeguards in an effort to protect against unauthorized access, use, modification, and disclosure of Personal Information in its control and custody. However, no data transmission over the Internet or wireless network can be guaranteed. Therefore, while we strive to protect your Personal Information, you acknowledge that (i) there are security and privacy limitations of the Internet which are beyond our control; (ii) the security, integrity, and privacy of any and all information and data exchanged between you and the Services cannot be guaranteed; and (iii) any such information and data may be viewed or tampered with in transit by a third party, despite best efforts.

+ +Data breach + +

In the event we become aware that the security of the Services has been compromised or users Personal Information has been disclosed to unrelated third parties as a result of external activity, including, but not limited to, security attacks or fraud, we reserve the right to take reasonably appropriate measures, including, but not limited to, investigation and reporting, as well as notification to and cooperation with law enforcement authorities. In the event of a data breach, we will make reasonable efforts to notify affected individuals if we believe that there is a reasonable risk of harm to the user as a result of the breach or if notice is otherwise required by law. When we do, we will send you an email.

+ +Changes and amendments + +

We reserve the right to modify this Policy or its terms relating to the Services from time to time in our discretion and will notify you of any material changes to the way in which we treat Personal Information. When we do, we will post a notification within the Services. We may also provide notice to you in other ways in our discretion, such as through contact information you have provided. Any updated version of this Policy will be effective immediately upon the posting of the revised Policy unless otherwise specified. Your continued use of the Services after the effective date of the revised Policy (or such other act specified at that time) will constitute your consent to those changes. However, we will not, without your consent, use your Personal Information in a manner materially different than what was stated at the time your Personal Information was collected.

+ +Acceptance of this policy + +

You acknowledge that you have read this Policy and agree to all its terms and conditions. By accessing and using the Services you agree to be bound by this Policy. If you do not agree to abide by the terms of this Policy, you are not authorized to access or use the Services.

+ +Contacting us + +

If you would like to contact us to understand more about this Policy or wish to contact us concerning any matter relating to individual rights and your Personal Information, you may send an email to support.tech@mhealthkenya.org.

+ +This document was last updated on March 8, 2021 + + + + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index e4b35a2..44461df 100755 --- a/routes/web.php +++ b/routes/web.php @@ -108,6 +108,7 @@ Route::get('/send/eid/to/lab', 'RemoteLoginController@SendEIDLab')->name('SendEIDLab'); Route::get('/send/hts/to/lab', 'RemoteLoginController@SendHTSLab')->name('SendHTSLab'); Route::get('/client/notify', 'UshauriController@notifyClients')->name('notifyClients'); +Route::get('/terms', 'TermsController@index')->name('terms'); // Auth::routes(); From afda3156e7eb4cecb3640d34980a98a94db5a6c6 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Apr 2021 14:25:13 +0300 Subject: [PATCH 03/47] Update TermsController.php --- app/Http/Controllers/TermsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermsController.php b/app/Http/Controllers/TermsController.php index 9e6c0e2..6ff74ba 100644 --- a/app/Http/Controllers/TermsController.php +++ b/app/Http/Controllers/TermsController.php @@ -7,7 +7,7 @@ use GuzzleHttp\Client; use App\Http\Controllers\SenderController; -class UshauriController extends Controller +class TermController extends Controller { public function index() { From 2b96494acc5f72c86425ca069d2d3bb85ffb3503 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 22 Apr 2021 14:28:27 +0300 Subject: [PATCH 04/47] Update TermsController.php --- app/Http/Controllers/TermsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermsController.php b/app/Http/Controllers/TermsController.php index 6ff74ba..45589e9 100644 --- a/app/Http/Controllers/TermsController.php +++ b/app/Http/Controllers/TermsController.php @@ -7,7 +7,7 @@ use GuzzleHttp\Client; use App\Http\Controllers\SenderController; -class TermController extends Controller +class TermsController extends Controller { public function index() { From 9d191fb8f29aef13de614d734161e03c4eb2bc1c Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Wed, 12 May 2021 09:59:23 +0300 Subject: [PATCH 05/47] Update highcharts_dashboard.blade.php --- resources/views/dashboard/highcharts_dashboard.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/dashboard/highcharts_dashboard.blade.php b/resources/views/dashboard/highcharts_dashboard.blade.php index 71a648f..4e6ce02 100644 --- a/resources/views/dashboard/highcharts_dashboard.blade.php +++ b/resources/views/dashboard/highcharts_dashboard.blade.php @@ -64,7 +64,7 @@ class="i-Filter">

All Results

-

+

@@ -862,4 +862,4 @@ function fetchJSON(url) { } - @endsection \ No newline at end of file + @endsection From ee9b4906318cdd467a8ddf1f3bad3cfda88edca3 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 19 Aug 2021 12:02:22 +0300 Subject: [PATCH 06/47] bug fix --- app/Http/Controllers/ILFacilityController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ILFacilityController.php b/app/Http/Controllers/ILFacilityController.php index 301d340..5a74157 100755 --- a/app/Http/Controllers/ILFacilityController.php +++ b/app/Http/Controllers/ILFacilityController.php @@ -38,7 +38,11 @@ public function addilfacility(Request $request) } else { $facility->phone_no = $request->code; } - $facility->internet = $request->internet; + if(!empty($request->internet) { + $facility->internet = 'Yes'; + } else { + $facility->internet = $request->internet; + } if ($facility->save()) { toastr()->success('IL Facility has been saved successfully!'); From 5712ca492c0187eb1864d7ea70270a711f11d4ed Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 19 Aug 2021 12:10:30 +0300 Subject: [PATCH 07/47] Update ILFacilityController.php --- app/Http/Controllers/ILFacilityController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ILFacilityController.php b/app/Http/Controllers/ILFacilityController.php index 5a74157..cd5c4d1 100755 --- a/app/Http/Controllers/ILFacilityController.php +++ b/app/Http/Controllers/ILFacilityController.php @@ -39,9 +39,9 @@ public function addilfacility(Request $request) $facility->phone_no = $request->code; } if(!empty($request->internet) { - $facility->internet = 'Yes'; - } else { $facility->internet = $request->internet; + } else { + $facility->internet = 'Yes'; } if ($facility->save()) { From 27981d70d69e3bf790449cd626ee79d47c8e86d3 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Tue, 31 Aug 2021 09:53:08 +0300 Subject: [PATCH 08/47] Uncommented srl header links --- resources/views/layouts/header-menu.blade.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/views/layouts/header-menu.blade.php b/resources/views/layouts/header-menu.blade.php index cb56d7f..7c21081 100755 --- a/resources/views/layouts/header-menu.blade.php +++ b/resources/views/layouts/header-menu.blade.php @@ -34,9 +34,9 @@ Viral Loads EID Results HTS Results - + HTS Remote Login Raw Data @@ -55,9 +55,9 @@ Viral Loads EID Results HTS Results - + HTS Remote Login Raw Data @@ -72,9 +72,9 @@ Viral Loads EID Results HTS Results - + HTS Remote Login Raw Data @@ -87,9 +87,9 @@ Viral Loads EID Results HTS Results - + HTS Remote Login @endif @@ -102,9 +102,9 @@ Viral Loads EID Results HTS Results Remote Login - + HTS Remote Login Raw Data @@ -158,4 +158,4 @@ - \ No newline at end of file + From 598decf113790bed916c353739db6808e0c68f51 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 2 Sep 2021 18:23:08 +0300 Subject: [PATCH 09/47] Update .env.example --- .env.example | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index cf70ed5..a1de937 100755 --- a/.env.example +++ b/.env.example @@ -6,11 +6,16 @@ APP_LOG_LEVEL=debug APP_URL=http://localhost DB_CONNECTION=pgsql -DB_HOST=41.204.187.154 +DB_HOST= DB_PORT=5432 -DB_DATABASE=mlab -DB_USERNAME=medyq_user -DB_PASSWORD=Qw3Rty123!!! +DB_DATABASE= +DB_USERNAME= +DB_PASSWORD= + +SRL_API_KEY='CHAI SAMPLE REMOTE LOGIN API KEY' +VL_RESULTS='CHAI RESULTS KEY' +AT_KEY='SMS KEY' +AT_SMSGT='SMS GATEWAY KEY' BROADCAST_DRIVER=log CACHE_DRIVER=file From 3666853dbccd920ffbc7da0df260a77a698bcf34 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 2 Sep 2021 18:23:30 +0300 Subject: [PATCH 10/47] Delete .env.save --- .env.save | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100755 .env.save diff --git a/.env.save b/.env.save deleted file mode 100755 index d5e62d5..0000000 --- a/.env.save +++ /dev/null @@ -1,35 +0,0 @@ -*oA1)=QQM/2yKC*(MT3W8^[Zq6?CAPP_NAME=MLAB -APP_ENV=production -APP_KEY=base64:j+bq/PbJPfkj+oFHkq029kEJsc8y5pTnstI4VnK7HgE= -APP_DEBUG=true -APP_LOG_LEVEL=debug -APP_URL=http://mlab.localhost - -DB_CONNECTION=pgsql -DB_HOST=192.168.50.2 -DB_PORT=5432 -DB_DATABASE=mlab -DB_USERNAME=medyq_user -DB_PASSWORD=Qw3Rty123!!! - -BROADCAST_DRIVER=log -CACHE_DRIVER=file -SESSION_DRIVER=file -SESSION_LIFETIME=120 -QUEUE_DRIVER=sync - -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -REDIS_PORT=6379 - -MAIL_DRIVER=smtp -MAIL_HOST=smtp.mailtrap.io -MAIL_PORT=2525 -MAIL_USERNAME=null -MAIL_PASSWORD=null -MAIL_ENCRYPTION=null - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_APP_CLUSTER=mt1 From 9e97ea87f76878a366b1a9a197ccb6cc8893895d Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 2 Sep 2021 18:23:45 +0300 Subject: [PATCH 11/47] Delete ..env.swp --- ..env.swp | Bin 1024 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ..env.swp diff --git a/..env.swp b/..env.swp deleted file mode 100644 index 714776097b170d63cf6dbb4b7708efa858368acb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{5u)iY*50tdqx7>e@q@-kDA1aUBZJ-mY>gF{?>gK;Q;3hS387U`Fl fm+R-|Bqr(WrRJ64S3fE{8UmvsK-CZkMK=uq@g)%A From c03da2aa39d7f17c2034e61f042d7f85e40fcaaa Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 2 Sep 2021 18:38:02 +0300 Subject: [PATCH 12/47] Create README.md --- README.md | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..10c24cf --- /dev/null +++ b/README.md @@ -0,0 +1,143 @@ +

+ + mLab + +

+ +# mLab Dashboard and API's + +### Features + +The has the following modules: +Patient results: this module allows for client appointment management and client enrollment. +Sub-functions in this module include: +-Sample remote login: for allowing login of samples into the system for the samples being sent to the labs +-HTS results transmission: for HIV results for non – conclusive tests +-Client messaging: for consent and message of clients on results availability to enhance linkage to care + +## Installation + +Please check the official laravel installation guide for server requirements before you start. [Official Documentation](https://laravel.com/docs/5.8/installation#installation) + +Alternative installation is possible without local dependencies relying on [Docker](#docker). + +Clone the repository + + git clone https://github.com/mHealthKenya/mLab.git + +Switch to the repo folder + + cd mLab + +Install all the dependencies using composer + + composer install + +Copy the example env file and make the required configuration changes in the .env file + + cp .env.example .env + +Generate a new application key + + php artisan key:generate + +Run the database migrations (**Set the database connection in .env before migrating**) + + php artisan migrate + +Start the local development server + + php artisan serve + +You can now access the server at http://localhost:8000 + +**TL;DR command list** + + git clone https://github.com/mHealthKenya/mLab.git + cd mLab + composer install + cp .env.example .env + php artisan key:generate + +**Make sure you set the correct database connection information before running the migrations** [Environment variables](#environment-variables) + + php artisan migrate + php artisan serve + +## Dependencies + +- [laravel-passport](https://github.com/laravel/passport) - For handling authentication +- [laravel-cors](https://github.com/barryvdh/laravel-cors) - For handling Cross-Origin Resource Sharing (CORS) +- [africastalking](https://github.com/AfricasTalkingLtd/africastalking-php) - For SMS + +## Folders + +- `app` - Contains all the Eloquent models +- `app/Http/Controllers` - Contains all the api controllers +- `app/Http/Middleware` - Contains the JWT auth middleware +- `app/Http/Controllers/VLResultsController.php` - Contains the functions implementing the vl and eid results module +- `app/Http/Controllers/HTSResultsController.php` - Contains the functions implementing the hts results module +- `app/Http/Controllers/RemoteLoginController.php` - Contains the functions implementing the sample remote login module +- `app/Http/Controllers/SendResultsController.php` - Contains the functions implementing the sending of results via the mobile application +- `app/Http/Controllers/TBResultsController.php` - Contains the functions implementing the TB results module +- `app/Http/Controllers/DataController.php` - Contains the functions and queries for the highcharts +- `config` - Contains all the application configuration files +- `database/factories` - Contains the model factory for all the models +- `database/migrations` - Contains all the database migrations +- `routes` - Contains all the api routes defined in api.php file +- `tests` - Contains all the application tests + +## Environment variables + +- `.env` - Environment variables can be set in this file + +***Note*** : You can quickly set the database information and other variables in this file and have the application fully working. + +---------- + +# Testing API + +Run the laravel development server + + php artisan serve + +The api can now be accessed at + + http://localhost:8000/api + +Request headers + +| **Required** | **Key** | **Value** | +|---------- |------------------ |------------------ | +| Yes | Content-Type | application/json | +| Yes | X-Requested-With | XMLHttpRequest | +| Optional | Authorization | Token {JWT} | + +Refer the [api specification](#api-specification) for more info. + +---------- + +# Authentication + +This applications uses Passport to handle authentication. The token is passed with each request using the `Authorization` header with `Token` scheme. The Passport authentication middleware handles the validation and authentication of the token. Please check the following sources to learn more about JWT. + +- https://github.com/laravel/passport/ + +---------- + +# Cross-Origin Resource Sharing (CORS) + +This applications has CORS enabled by default on all API endpoints. The default configuration allows requests from `http://localhost:3000` and `http://localhost:4200` to help speed up your frontend testing. The CORS allowed origins can be changed by setting them in the config file. Please check the following sources to learn more about CORS. + +- https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS +- https://en.wikipedia.org/wiki/Cross-origin_resource_sharing +- https://www.w3.org/TR/cors +## Dependencies + +- [laravel-cors](https://github.com/barryvdh/laravel-cors) - For handling Cross-Origin Resource Sharing (CORS) + +## License + +[![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=for-the-badge)](#) + +[![Open Source Love](https://badges.frapsoft.com/os/v2/open-source-200x33.png?v=103)](#) From 3e359dc0fdb676c7ae87edf7ecf9914cbd47c31c Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 2 Sep 2021 18:40:26 +0300 Subject: [PATCH 13/47] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 10c24cf..41ec6df 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@ ### Features -The has the following modules: -Patient results: this module allows for client appointment management and client enrollment. -Sub-functions in this module include: --Sample remote login: for allowing login of samples into the system for the samples being sent to the labs --HTS results transmission: for HIV results for non – conclusive tests --Client messaging: for consent and message of clients on results availability to enhance linkage to care +mLab has the following modules:
+Patient results: this module allows for client appointment management and client enrollment.
+Sub-functions in this module include:
+-Sample remote login: for allowing login of samples into the system for the samples being sent to the labs
+-HTS results transmission: for HIV results for non – conclusive tests
+-Client messaging: for consent and message of clients on results availability to enhance linkage to care
## Installation From 56ee89522b35ffd65c87ae027e0f8437370cc656 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Thu, 2 Sep 2021 19:05:30 +0300 Subject: [PATCH 14/47] updated readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 41ec6df..e845d27 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,8 @@ You can now access the server at http://localhost:8000 - `config` - Contains all the application configuration files - `database/factories` - Contains the model factory for all the models - `database/migrations` - Contains all the database migrations -- `routes` - Contains all the api routes defined in api.php file +- `routes/api` - Contains all the api routes +- `routes/web` - Contains all the dashboard routes - `tests` - Contains all the application tests ## Environment variables From 48d16c3952f57c5d19687de69b458650f5d66b36 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 6 Sep 2021 13:33:37 +0300 Subject: [PATCH 15/47] Create LICENSE.md --- LICENSE.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ + From 0fc49f248a2b6ee33a855ca543b0559507f155cd Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 6 Sep 2021 13:33:57 +0300 Subject: [PATCH 16/47] Update LICENSE.md --- LICENSE.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/LICENSE.md b/LICENSE.md index 8b13789..1e3e1ed 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1 +1,21 @@ +MIT License +Copyright (c) 2021 mHealth Kenya + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 83a6095e9517db53e71f2acdd99c5dc13484f1b8 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Tue, 7 Sep 2021 18:46:44 +0300 Subject: [PATCH 17/47] added migrations --- .../2014_10_12_000000_create_users_table.php | 13 ++++- ...19_03_21_085159_create_api_users_table.php | 5 ++ ...2021_05_17_170915_create_clients_table.php | 39 +++++++++++++ .../2021_05_17_172148_create_county_table.php | 33 +++++++++++ ..._172331_create_health_facilities_table.php | 43 ++++++++++++++ ..._05_17_172928_create_hts_results_table.php | 48 ++++++++++++++++ ...5_17_173629_create_il_facilities_table.php | 34 +++++++++++ .../2021_05_17_173840_create_inbox_table.php | 39 +++++++++++++ ..._17_174209_create_new_facilities_table.php | 54 ++++++++++++++++++ ...2021_05_17_175117_create_partner_table.php | 33 +++++++++++ ...2021_05_17_175241_create_results_table.php | 56 +++++++++++++++++++ ...021_05_17_180001_create_send_log_table.php | 37 ++++++++++++ ..._05_17_180449_create_sms_gateway_table.php | 36 ++++++++++++ ...2021_05_17_180948_create_srl_eid_table.php | 49 ++++++++++++++++ ...2021_05_17_181448_create_srl_hts_table.php | 53 ++++++++++++++++++ ...17_182626_create_srl_viral_loads_table.php | 45 +++++++++++++++ ...1_05_17_183356_create_sub_county_table.php | 34 +++++++++++ ...1_05_17_183609_create_tb_results_table.php | 47 ++++++++++++++++ 18 files changed, 695 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2021_05_17_170915_create_clients_table.php create mode 100644 database/migrations/2021_05_17_172148_create_county_table.php create mode 100644 database/migrations/2021_05_17_172331_create_health_facilities_table.php create mode 100644 database/migrations/2021_05_17_172928_create_hts_results_table.php create mode 100644 database/migrations/2021_05_17_173629_create_il_facilities_table.php create mode 100644 database/migrations/2021_05_17_173840_create_inbox_table.php create mode 100644 database/migrations/2021_05_17_174209_create_new_facilities_table.php create mode 100644 database/migrations/2021_05_17_175117_create_partner_table.php create mode 100644 database/migrations/2021_05_17_175241_create_results_table.php create mode 100644 database/migrations/2021_05_17_180001_create_send_log_table.php create mode 100644 database/migrations/2021_05_17_180449_create_sms_gateway_table.php create mode 100644 database/migrations/2021_05_17_180948_create_srl_eid_table.php create mode 100644 database/migrations/2021_05_17_181448_create_srl_hts_table.php create mode 100644 database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php create mode 100644 database/migrations/2021_05_17_183356_create_sub_county_table.php create mode 100644 database/migrations/2021_05_17_183609_create_tb_results_table.php diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 16a6108..f1f4f4f 100755 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -15,11 +15,18 @@ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); - $table->string('name'); + $table->string('f_name'); + $table->string('l_name'); $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); + $table->string('phone_no'); + $table->string('status'); + $table->string('county_id'); + $table->integer('partner_id'); + $table->integer('facility_id'); + $table->integer('user_level'); + $table->text('first_login'); $table->string('password'); - $table->rememberToken(); + $table->string('remember_token'); $table->timestamps(); }); } diff --git a/database/migrations/2019_03_21_085159_create_api_users_table.php b/database/migrations/2019_03_21_085159_create_api_users_table.php index 7024465..03c7509 100755 --- a/database/migrations/2019_03_21_085159_create_api_users_table.php +++ b/database/migrations/2019_03_21_085159_create_api_users_table.php @@ -15,6 +15,11 @@ public function up() { Schema::create('api_users', function (Blueprint $table) { $table->increments('id'); + $table->string('name'); + $table->string('email')->unique(); + $table->string('password'); + $table->string('status'); + $table->integer('user_level'); $table->timestamps(); }); } diff --git a/database/migrations/2021_05_17_170915_create_clients_table.php b/database/migrations/2021_05_17_170915_create_clients_table.php new file mode 100644 index 0000000..b5b5992 --- /dev/null +++ b/database/migrations/2021_05_17_170915_create_clients_table.php @@ -0,0 +1,39 @@ +increments('id'); + $table->string('f_name'); + $table->string('l_name'); + $table->string('ccc_number'); + $table->string('phone'); + $table->integer('facility_id'); + $table->integer('notification'); + $table->string('status'); + $table->string('remember_token'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('clients'); + } +} diff --git a/database/migrations/2021_05_17_172148_create_county_table.php b/database/migrations/2021_05_17_172148_create_county_table.php new file mode 100644 index 0000000..a5c1c21 --- /dev/null +++ b/database/migrations/2021_05_17_172148_create_county_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name'); + $table->string('status'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('county'); + } +} diff --git a/database/migrations/2021_05_17_172331_create_health_facilities_table.php b/database/migrations/2021_05_17_172331_create_health_facilities_table.php new file mode 100644 index 0000000..4ac6564 --- /dev/null +++ b/database/migrations/2021_05_17_172331_create_health_facilities_table.php @@ -0,0 +1,43 @@ +increments('id'); + $table->integer('code'); + $table->text('name'); + $table->string('keph_level'); + $table->string('facility_type'); + $table->string('Sub_County_ID'); + $table->string('partner_id'); + $table->string('mobile'); + $table->timestamp('modified'); + $table->string('lat'); + $table->string('lng'); + $table->string('active'); + $table->string('active_last_month'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('health_facilities'); + } +} diff --git a/database/migrations/2021_05_17_172928_create_hts_results_table.php b/database/migrations/2021_05_17_172928_create_hts_results_table.php new file mode 100644 index 0000000..f5d0cc0 --- /dev/null +++ b/database/migrations/2021_05_17_172928_create_hts_results_table.php @@ -0,0 +1,48 @@ +increments('id'); + $table->string('nhrl_lab_id'); + $table->string('patient_id'); + $table->string('age'); + $table->string('gender'); + $table->string('test'); + $table->string('result_value'); + $table->string('status'); + $table->string('component'); + $table->integer('mfl_code'); + $table->string('submit_date'); + $table->string('date_released'); + $table->integer('processed'); + $table->string('sample_id'); + $table->timestamp('date_sent'); + $table->timestamp('date_delivered'); + $table->timestamp('date_read'); + $table->integer('hts_result_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('hts_results'); + } +} diff --git a/database/migrations/2021_05_17_173629_create_il_facilities_table.php b/database/migrations/2021_05_17_173629_create_il_facilities_table.php new file mode 100644 index 0000000..3537abe --- /dev/null +++ b/database/migrations/2021_05_17_173629_create_il_facilities_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->integer('mfl_code'); + $table->string('phone_no'); + $table->string('internet'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('il_facilities'); + } +} diff --git a/database/migrations/2021_05_17_173840_create_inbox_table.php b/database/migrations/2021_05_17_173840_create_inbox_table.php new file mode 100644 index 0000000..1cd3e63 --- /dev/null +++ b/database/migrations/2021_05_17_173840_create_inbox_table.php @@ -0,0 +1,39 @@ +increments('id'); + $table->string('shortCode'); + $table->string('MSISDN'); + $table->text('message'); + $table->string('msgDateCreated'); + $table->string('createdOn'); + $table->string('message_id'); + $table->integer('processed'); + $table->string('LinkId'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('inbox'); + } +} diff --git a/database/migrations/2021_05_17_174209_create_new_facilities_table.php b/database/migrations/2021_05_17_174209_create_new_facilities_table.php new file mode 100644 index 0000000..3678ed7 --- /dev/null +++ b/database/migrations/2021_05_17_174209_create_new_facilities_table.php @@ -0,0 +1,54 @@ +increments('id'); + $table->integer('Code'); + $table->string('Name'); + $table->string('OfficialName'); + $table->string('Registration_number'); + $table->string('Keph level'); + $table->string('Facility_type'); + $table->string('Facility_type_category'); + $table->string('Owner'); + $table->string('Owner_type'); + $table->string('Regulatory_body'); + $table->string('Beds'); + $table->string('Cots'); + $table->string('County'); + $table->string('Sub_county'); + $table->string('Ward'); + $table->string('Operation status'); + $table->string('Open_whole_day'); + $table->string('Open_public_holidays'); + $table->string('Open_weekends'); + $table->string('Open_late_night'); + $table->string('Service_names'); + $table->string('Approved'); + $table->string('Public visible'); + $table->string('Closed'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('new_facilities'); + } +} diff --git a/database/migrations/2021_05_17_175117_create_partner_table.php b/database/migrations/2021_05_17_175117_create_partner_table.php new file mode 100644 index 0000000..b9b9c00 --- /dev/null +++ b/database/migrations/2021_05_17_175117_create_partner_table.php @@ -0,0 +1,33 @@ +increments('id'); + $table->string('name'); + $table->string('status'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('partner'); + } +} diff --git a/database/migrations/2021_05_17_175241_create_results_table.php b/database/migrations/2021_05_17_175241_create_results_table.php new file mode 100644 index 0000000..be63bac --- /dev/null +++ b/database/migrations/2021_05_17_175241_create_results_table.php @@ -0,0 +1,56 @@ +increments('id'); + $table->string('source'); + $table->string('result_id'); + $table->string('result_type'); + $table->string('request_id'); + $table->string('client_id'); + $table->string('age'); + $table->string('gender'); + $table->string('result_content'); + $table->string('units'); + $table->integer('data_key'); + $table->integer('mfl_code'); + $table->integer('lab_id'); + $table->string('cst'); + $table->string('cj'); + $table->string('csr'); + $table->string('date_collected'); + $table->string('lab_order_date'); + $table->integer('sys_code'); + $table->timestamp('date_sent'); + $table->timestamp('date_delivered'); + $table->timestamp('date_read'); + $table->integer('processed'); + $table->integer('il_send'); + $table->string('lab_name'); + $table->boolean('client_notified'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('results'); + } +} diff --git a/database/migrations/2021_05_17_180001_create_send_log_table.php b/database/migrations/2021_05_17_180001_create_send_log_table.php new file mode 100644 index 0000000..e5775c9 --- /dev/null +++ b/database/migrations/2021_05_17_180001_create_send_log_table.php @@ -0,0 +1,37 @@ +increments('send_log_id'); + $table->string('number'); + $table->text('message'); + $table->string('status'); + $table->string('statusCode'); + $table->string('messageId'); + $table->string('cost'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('send_log'); + } +} diff --git a/database/migrations/2021_05_17_180449_create_sms_gateway_table.php b/database/migrations/2021_05_17_180449_create_sms_gateway_table.php new file mode 100644 index 0000000..711b60e --- /dev/null +++ b/database/migrations/2021_05_17_180449_create_sms_gateway_table.php @@ -0,0 +1,36 @@ +increments('id'); + $table->integer('user_id'); + $table->string('phone_no'); + $table->string('message'); + $table->string('delivery_status'); + $table->string('cost'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('sms_gateway'); + } +} diff --git a/database/migrations/2021_05_17_180948_create_srl_eid_table.php b/database/migrations/2021_05_17_180948_create_srl_eid_table.php new file mode 100644 index 0000000..af700aa --- /dev/null +++ b/database/migrations/2021_05_17_180948_create_srl_eid_table.php @@ -0,0 +1,49 @@ +increments('id'); + $table->string('selected_sex'); + $table->string('selected_regimen'); + $table->string('selected_alive'); + $table->string('hein_number'); + $table->string('patient_name'); + $table->string('dob'); + $table->string('entry_point'); + $table->string('date_collected'); + $table->string('prophylaxis_code'); + $table->string('infant_feeding'); + $table->string('pcr'); + $table->string('alive_dead'); + $table->string('mother_age'); + $table->string('haart_date'); + $table->integer('processed'); + $table->integer('facility'); + $table->integer('lab_id'); + $table->integer('lab_name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('srl_eid'); + } +} diff --git a/database/migrations/2021_05_17_181448_create_srl_hts_table.php b/database/migrations/2021_05_17_181448_create_srl_hts_table.php new file mode 100644 index 0000000..9ab9388 --- /dev/null +++ b/database/migrations/2021_05_17_181448_create_srl_hts_table.php @@ -0,0 +1,53 @@ +increments('id'); + $table->string('sample_number'); + $table->string('client_name'); + $table->string('dob'); + $table->string('selected_sex'); + $table->string('telephone'); + $table->string('test_date'); + $table->string('selected_delivery_point'); + $table->string('selected_test_kit1'); + $table->string('lot_number1'); + $table->string('expiry_date1'); + $table->string('selected_test_kit2'); + $table->string('lot_number2'); + $table->string('expiry_date2'); + $table->string('selected_final_result'); + $table->string('sample_tester_name'); + $table->string('dbs_date'); + $table->string('dbs_dispatch_date'); + $table->string('requesting_provider'); + $table->integer('processed'); + $table->integer('facility'); + $table->integer('lab_id'); + $table->string('lab_name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('srl_hts'); + } +} diff --git a/database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php b/database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php new file mode 100644 index 0000000..c84a733 --- /dev/null +++ b/database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php @@ -0,0 +1,45 @@ +increments('id'); + $table->string('ccc_num'); + $table->string('patient_name'); + $table->string('dob'); + $table->string('date_collected'); + $table->string('art_start_date'); + $table->string('current_regimen'); + $table->string('date_art_regimen'); + $table->string('art_line'); + $table->string('justification_code'); + $table->string('selected_type'); + $table->string('selected_sex'); + $table->integer('processed'); + $table->integer('lab_id'); + $table->integer('lab_name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('srl_viral_loads'); + } +} diff --git a/database/migrations/2021_05_17_183356_create_sub_county_table.php b/database/migrations/2021_05_17_183356_create_sub_county_table.php new file mode 100644 index 0000000..edd91f9 --- /dev/null +++ b/database/migrations/2021_05_17_183356_create_sub_county_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('name'); + $table->integer('county_id'); + $table->string('status'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('sub_county'); + } +} diff --git a/database/migrations/2021_05_17_183609_create_tb_results_table.php b/database/migrations/2021_05_17_183609_create_tb_results_table.php new file mode 100644 index 0000000..e125fde --- /dev/null +++ b/database/migrations/2021_05_17_183609_create_tb_results_table.php @@ -0,0 +1,47 @@ +increments('tb_result_id'); + $table->string('sample_id'); + $table->string('patient_id'); + $table->string('age'); + $table->string('gender'); + $table->string('test1'); + $table->string('result_value1'); + $table->string('test2'); + $table->string('result_value2'); + $table->string('test3'); + $table->string('result_value3'); + $table->string('mfl_code'); + $table->string('login_date'); + $table->string('date_reviewed'); + $table->string('record_date'); + $table->string('testing_lab'); + $table->string('processed'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tb_results'); + } +} From cf9f5f91819180ee5c8266af47a1c45616fff02d Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Tue, 19 Oct 2021 20:02:49 +0300 Subject: [PATCH 18/47] Update SmsGatewayController.php --- app/Http/Controllers/SmsGatewayController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/SmsGatewayController.php b/app/Http/Controllers/SmsGatewayController.php index 7053754..7a7fc50 100644 --- a/app/Http/Controllers/SmsGatewayController.php +++ b/app/Http/Controllers/SmsGatewayController.php @@ -25,7 +25,7 @@ public function sender(Request $request) $sms = $AT->sms(); // Use the service $send = $sms->send([ - 'from' => '40146', + 'from' => '40149', 'to' => $phone, 'message' => $message ]); From b3d3fe503e73882da6fcfc131cee2d1727ba9672 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 25 Oct 2021 09:55:22 +0300 Subject: [PATCH 19/47] Update SmsGatewayController.php --- app/Http/Controllers/SmsGatewayController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/SmsGatewayController.php b/app/Http/Controllers/SmsGatewayController.php index 7a7fc50..dbf0d62 100644 --- a/app/Http/Controllers/SmsGatewayController.php +++ b/app/Http/Controllers/SmsGatewayController.php @@ -15,7 +15,7 @@ class SmsGatewayController extends Controller { public function sender(Request $request) { - $username = "mhealthuser"; + $username = "Ushauri_KE"; $apiKey = config('services.at_gt.key');; $AT = new AfricasTalking($username, $apiKey); From 876d3571db7b362ef23bafbd4b869e3bd6aae27c Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 25 Oct 2021 09:56:05 +0300 Subject: [PATCH 20/47] Update SenderController.php --- app/Http/Controllers/SenderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/SenderController.php b/app/Http/Controllers/SenderController.php index 1befd0a..cac298f 100755 --- a/app/Http/Controllers/SenderController.php +++ b/app/Http/Controllers/SenderController.php @@ -11,7 +11,7 @@ class SenderController extends Controller { public function send($to, $message) { - $username = "mhealthkenya"; + $username = "mLab_KE"; $apiKey = config('services.at.key'); $AT = new AfricasTalking($username, $apiKey); From 85f5aabc67e0009aca443828e9638b9fbd82ac5a Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Fri, 19 Nov 2021 20:43:05 +0300 Subject: [PATCH 21/47] added ccc validation --- app/Http/Controllers/ILFacilityController.php | 2 +- .../Controllers/SendResultsController.php | 3 ++ app/Http/Controllers/VLResultsController.php | 46 ++++++++++++++++--- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ILFacilityController.php b/app/Http/Controllers/ILFacilityController.php index cd5c4d1..33379d2 100755 --- a/app/Http/Controllers/ILFacilityController.php +++ b/app/Http/Controllers/ILFacilityController.php @@ -38,7 +38,7 @@ public function addilfacility(Request $request) } else { $facility->phone_no = $request->code; } - if(!empty($request->internet) { + if(!empty($request->internet)) { $facility->internet = $request->internet; } else { $facility->internet = 'Yes'; diff --git a/app/Http/Controllers/SendResultsController.php b/app/Http/Controllers/SendResultsController.php index 04e0efc..328a6bd 100644 --- a/app/Http/Controllers/SendResultsController.php +++ b/app/Http/Controllers/SendResultsController.php @@ -252,6 +252,9 @@ public function sendIL() $date = date('Y-m-d H:i:s', time()); $sender = new SenderController; + + // dont update if status failed + if ($sender->send($dest, $encr)) { $result->il_send = '1'; $result->processed = '1'; diff --git a/app/Http/Controllers/VLResultsController.php b/app/Http/Controllers/VLResultsController.php index 80fafb1..9e6cbc9 100755 --- a/app/Http/Controllers/VLResultsController.php +++ b/app/Http/Controllers/VLResultsController.php @@ -73,6 +73,7 @@ public function getResults() $yester = date('Y-m-d', strtotime("-31 days")); $curl = curl_init(); + // test 1 is VL $fields = array( 'test' => 1, 'facility_code' =>$a, @@ -112,14 +113,22 @@ public function getResults() foreach ($data as $dat) { + // check if result already exisits $res = Result::where('result_id', $dat->result_id)->where('source', 1)->first(); + //check if ccc has special character or letter or is decimal and replace with nothing + if (preg_match('#[^0-9]#', $dat->client_id)) { + $client_id = preg_replace('/[^a-z0-9 ]+/i','',$dat->client_id); + } else { + $client_id = $dat->client_id; + } + if (empty($res)) { $r = new Result; $r->source = $dat->source; $r->result_id = $dat->result_id; $r->result_type = $dat->result_type; - $r->client_id = $dat->client_id; + $r->client_id = $client_id; $r->age = $dat->age; $r->request_id = $dat->request_id; $r->result_content = $dat->result_content; @@ -186,13 +195,20 @@ public function getResults() foreach ($data as $dat) { $res = Result::where('result_id', $dat->result_id)->where('source', 1)->first(); - + + //check if ccc has special character or letter or is decimal and replace with nothing + if (preg_match('#[^0-9]#', $dat->client_id)) { + $client_id = preg_replace('/[^a-z0-9 ]+/i','',$dat->client_id); + } else { + $client_id = $dat->client_id; + } + if (empty($res)) { $r = new Result; $r->source = $dat->source; $r->result_id = $dat->result_id; $r->result_type = $dat->result_type; - $r->client_id = $dat->client_id; + $r->client_id = $client_id; $r->age = $dat->age; $r->request_id = $dat->request_id; $r->result_content = $dat->result_content; @@ -221,10 +237,11 @@ public function getResults() public function getEIDResults() { + //read results from the last month $today = date("Y-m-d"); $yester = date('Y-m-d', strtotime("-31 days")); - + // check for facilities using both app and IL $ilfs = ILFacility::all(); $mlabfs = Facility::whereNotNull('mobile')->whereNotNull('partner_id')->get(); @@ -251,6 +268,7 @@ public function getEIDResults() $a = implode(',', $results); $curl = curl_init(); + // test 2 is eid $fields = array( 'test' => 2, 'facility_code' =>$a, @@ -289,6 +307,8 @@ public function getEIDResults() echo "last_page: ".$objects->last_page.'
'; foreach ($data as $dat) { + + // check if result already exisits $res = Result::where('result_id', $dat->result_id)->where('source', 1)->first(); if (empty($res)) { @@ -300,11 +320,18 @@ public function getEIDResults() $cnt = $dat->result_content; } + //check if ccc has special character or letter or is decimal and replace with nothing + if (preg_match('#[^0-9]#', $dat->client_id)) { + $client_id = preg_replace('/[^a-z0-9 ]+/i','',$dat->client_id); + } else { + $client_id = $dat->client_id; + } + $r = new Result; $r->source = $dat->source; $r->result_id = $dat->result_id; $r->result_type = $dat->result_type; - $r->client_id = $dat->client_id; + $r->client_id = $client_id; $r->age = $dat->age; $r->request_id = $dat->request_id; $r->result_content = $cnt; @@ -380,12 +407,19 @@ public function getEIDResults() } else { $cnt = $dat->result_content; } + + //check if ccc has special character or letter or is decimal and replace with nothing + if (preg_match('#[^0-9]#', $dat->client_id)) { + $client_id = preg_replace('/[^a-z0-9 ]+/i','',$dat->client_id); + } else { + $client_id = $dat->client_id; + } $r = new Result; $r->source = $dat->source; $r->result_id = $dat->result_id; $r->result_type = $dat->result_type; - $r->client_id = $dat->client_id; + $r->client_id = $client_id; $r->age = $dat->age; $r->request_id = $dat->request_id; $r->result_content = $cnt; From 9e36c9b0268ee432c9b0b8a458ec7318bb307437 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Fri, 26 Nov 2021 00:32:17 +0300 Subject: [PATCH 22/47] sms partner breakdown --- app/Http/Controllers/SMSReportController.php | 119 +++++++++++ app/SMSData.php | 21 ++ resources/views/layouts/header-menu.blade.php | 3 +- resources/views/sms/sms.blade.php | 192 ++++++++++++++++++ routes/web.php | 6 + 5 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/SMSReportController.php create mode 100644 app/SMSData.php create mode 100644 resources/views/sms/sms.blade.php diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php new file mode 100644 index 0000000..1add453 --- /dev/null +++ b/app/Http/Controllers/SMSReportController.php @@ -0,0 +1,119 @@ +where('partner_id', Auth::user()->partner_id ) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 101 + // 101: Sent + $sent = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 101) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 500, 501, 502 + // 500: InternalServerError + // 501: GatewayError + // 502: RejectedByGateway + $failed = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 403) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 406 + // 406: UserInBlacklist + $blacklist = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 406) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + + $data["blacklist"] = $blacklist; + $data["failed"] = $failed; + $data["sent"] = $sent; + $data["cost"] = $cost; + + return $data; + + } + + public function get_filtered_data(Request $request){ + + $selected_dates = $request->daterange; + + $dates = explode('-', $selected_dates); + + $unformatted_startdate = trim($dates[0]); + $unformatted_enddate = trim($dates[1]); + + $start_date = Carbon::createFromFormat('m/d/Y', $unformatted_startdate)->format('Y-m-d'); + $end_date = Carbon::createFromFormat('m/d/Y', $unformatted_enddate)->format('Y-m-d'); + + $cost = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status,count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('created_at',[$start_date, $end_date] ) + ->groupBy('month', 'status') + ->get(); + + // status 101 + $sent = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('created_at',[$start_date, $end_date] ) + ->orWhere('status', '=', 101) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 500, 501, 502 + $failed = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('created_at',[$start_date, $end_date] ) + ->orWhere('status', '=', 403) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 406 + $blacklist = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 406) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + $data["blacklist"] = $blacklist; + $data["failed"] = $failed; + $data["sent"] = $sent; + $data["cost"] = $cost; + + return $data; + + } +} diff --git a/app/SMSData.php b/app/SMSData.php new file mode 100644 index 0000000..f9ca98e --- /dev/null +++ b/app/SMSData.php @@ -0,0 +1,21 @@ + @endif @if(Auth::user()->user_level == 2) -
+ diff --git a/resources/views/sms/sms.blade.php b/resources/views/sms/sms.blade.php new file mode 100644 index 0000000..d53ce6b --- /dev/null +++ b/resources/views/sms/sms.blade.php @@ -0,0 +1,192 @@ +@extends('layouts.master') +@section('page-css') + + +@endsection + +@section('main-content') +
+
+
+ {{ csrf_field() }} +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+
+
+ +
+ loader + +
+ +
+ + +@endsection + +@section('page-js') + + + + + + + + + + + + + + + + + + +@endsection + + + diff --git a/routes/web.php b/routes/web.php index 44461df..918ca20 100755 --- a/routes/web.php +++ b/routes/web.php @@ -92,6 +92,12 @@ Route::post('/get_dashboard_facilities', ['uses' => 'DashboardController@get_dashboard_facilities', 'as' => 'get_dashboard_facilities']); Route::post('/filter/dashboard', ['uses' => 'DashboardController@get_filtered_data', 'as' => 'filterDashboard']); Route::post('/filter/printers/dashboard', ['uses' => 'DashboardController@get_filtered_printers_data', 'as' => 'filterPrintersDashboard']); + + //SMS Routes + Route::get('/report/sms', ['uses' => 'SMSReportController@index', 'as' => 'sms_report']); + Route::get('/report/get_sms', ['uses' => 'SMSReportController@get_data', 'as' => 'sms_report_data']); + Route::post('/report/filtered_get_sms', ['uses' => 'SMSReportController@get_filtered_data', 'as' => 'sms_filtered_report_data']); + }); Route::get('/send/results', ['uses' => 'SendResultsController@sendVLEID', 'as' => 'sendvleid']); From 10098ef583557bea1f52d1e8a4b2df9f9ef3ad80 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Fri, 26 Nov 2021 19:15:14 +0300 Subject: [PATCH 23/47] super admin reports --- app/Http/Controllers/SMSReportController.php | 189 +++++++++++----- resources/views/layouts/header-menu.blade.php | 1 + resources/views/sms/adminsms.blade.php | 209 ++++++++++++++++++ .../{sms.blade.php => partnersms.blade.php} | 24 +- 4 files changed, 368 insertions(+), 55 deletions(-) create mode 100644 resources/views/sms/adminsms.blade.php rename resources/views/sms/{sms.blade.php => partnersms.blade.php} (88%) diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php index 1add453..fee2905 100644 --- a/app/Http/Controllers/SMSReportController.php +++ b/app/Http/Controllers/SMSReportController.php @@ -6,6 +6,7 @@ use App\SMSData; use DB; use Auth; +use App\Partner; use Illuminate\Support\Carbon; @@ -13,52 +14,97 @@ class SMSReportController extends Controller { public function index(){ - return view('sms.sms'); + if(Auth::user()->user_level == 1) { + + $partners = Partner::all(); + return view('sms.adminsms')->with('partners'); + } else if(Auth::user()->user_level == 2) { + return view('sms.partnersms'); + } } public function get_data(){ - $cost = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") - ->where('partner_id', Auth::user()->partner_id ) - ->groupBy('month', 'status') - ->orderBy('month', 'ASC') - ->get(); + if(Auth::user()->user_level == 1) { - // status 101 - // 101: Sent - $sent = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") - ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 101) - ->groupBy('month', 'status') - ->orderBy('month', 'ASC') + $total_sum = SMSData::selectRaw("sum(sum) as total")->get(); + + $cost = SMSData::selectRaw("partner_name, count(*) as y") + ->groupBy('partner_name' ) ->get(); - // status 500, 501, 502 - // 500: InternalServerError - // 501: GatewayError - // 502: RejectedByGateway - $failed = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + // status 101 + // 101: Sent + $sent = SMSData::selectRaw("partner_name, month, status , count(*) as y") + ->orWhere('status', '=', 101) + ->groupBy('month', 'partner_name', 'status') + ->get(); + + // status 500, 501, 502 + // 500: InternalServerError + // 501: GatewayError + // 502: RejectedByGateway + $failed = SMSData::selectRaw("partner_name, month, status , count(*) as y") + ->orWhere('status', '=', 403) + ->groupBy('month', 'partner_name', 'status') + ->get(); + + // status 406 + // 406: UserInBlacklist + $blacklist = SMSData::selectRaw("partner_name, month, status , count(*) as y") + ->orWhere('status', '=', 406) + ->groupBy('month', 'partner_name', 'status') + ->get(); + + } else if(Auth::user()->user_level == 2) { + + $total_sum = SMSData::selectRaw("sum(sum) as total") ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 403) - ->groupBy('month', 'status') - ->orderBy('month', 'ASC') ->get(); - // status 406 - // 406: UserInBlacklist - $blacklist = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + $cost = SMSData::selectRaw("month, status , count(*) as y") ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 406) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); + // status 101 + // 101: Sent + $sent = SMSData::selectRaw("month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 101) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 500, 501, 502 + // 500: InternalServerError + // 501: GatewayError + // 502: RejectedByGateway + $failed = SMSData::selectRaw("month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 403) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 406 + // 406: UserInBlacklist + $blacklist = SMSData::selectRaw("month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 406) + ->groupBy('month','status') + ->orderBy('month', 'ASC') + ->get(); + } + $data["blacklist"] = $blacklist; $data["failed"] = $failed; $data["sent"] = $sent; $data["cost"] = $cost; + $data["total_sum"] = $total_sum; return $data; @@ -76,42 +122,85 @@ public function get_filtered_data(Request $request){ $start_date = Carbon::createFromFormat('m/d/Y', $unformatted_startdate)->format('Y-m-d'); $end_date = Carbon::createFromFormat('m/d/Y', $unformatted_enddate)->format('Y-m-d'); - $cost = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status,count(*) as y") - ->where('partner_id', Auth::user()->partner_id ) - ->whereBetween('created_at',[$start_date, $end_date] ) - ->groupBy('month', 'status') - ->get(); + if(Auth::user()->user_level == 1) { - // status 101 - $sent = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") - ->where('partner_id', Auth::user()->partner_id ) - ->whereBetween('created_at',[$start_date, $end_date] ) - ->orWhere('status', '=', 101) - ->groupBy('month', 'status') - ->orderBy('month', 'ASC') + $total_sum = SMSData::selectRaw("sum(sum) as total") + ->whereBetween('month',[$start_date, $end_date] ) ->get(); - // status 500, 501, 502 - $failed = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") + $cost = SMSData::selectRaw("partner_name, month, status,count(*) as y") + ->whereBetween('month',[$start_date, $end_date] ) + ->groupBy('month','partner_name', 'status') + ->get(); + + // status 101 + $sent = SMSData::selectRaw("partner_name, month, status , count(*) as y") + ->whereBetween('month',[$start_date, $end_date] ) + ->orWhere('status', '=', 101) + ->groupBy('month', 'partner_name', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 500, 501, 502 + $failed = SMSData::selectRaw("partner_name, month, status , count(*) as y") + ->whereBetween('month',[$start_date, $end_date] ) + ->orWhere('status', '=', 403) + ->groupBy('month', 'partner_name', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 406 + $blacklist = SMSData::selectRaw("partner_name, month, status , count(*) as y") + ->orWhere('status', '=', 406) + ->groupBy('month', 'partner_name', 'status') + ->orderBy('month', 'ASC') + ->get(); + + } else if(Auth::user()->user_level == 2) { + + $total_sum = SMSData::selectRaw("sum(sum) as total") ->where('partner_id', Auth::user()->partner_id ) - ->whereBetween('created_at',[$start_date, $end_date] ) - ->orWhere('status', '=', 403) - ->groupBy('month', 'status') - ->orderBy('month', 'ASC') + ->whereBetween('month',[$start_date, $end_date] ) ->get(); - // status 406 - $blacklist = SMSData::selectRaw("to_char(created_at, 'YYYY-MM') as month, status , count(*) as y") - ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 406) - ->groupBy('month', 'status') - ->orderBy('month', 'ASC') - ->get(); + $cost = SMSData::selectRaw("month, status,count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('month',[$start_date, $end_date] ) + ->groupBy('month', 'status') + ->get(); + + // status 101 + $sent = SMSData::selectRaw("month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('month',[$start_date, $end_date] ) + ->orWhere('status', '=', 101) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 500, 501, 502 + $failed = SMSData::selectRaw("month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('month',[$start_date, $end_date] ) + ->orWhere('status', '=', 403) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 406 + $blacklist = SMSData::selectRaw("month, status , count(*) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->orWhere('status', '=', 406) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + } $data["blacklist"] = $blacklist; $data["failed"] = $failed; $data["sent"] = $sent; $data["cost"] = $cost; + $data["total_sum"] = $total_sum; return $data; diff --git a/resources/views/layouts/header-menu.blade.php b/resources/views/layouts/header-menu.blade.php index 1f5facd..2206251 100755 --- a/resources/views/layouts/header-menu.blade.php +++ b/resources/views/layouts/header-menu.blade.php @@ -37,6 +37,7 @@ VL Remote Login EID Remote Login HTS Remote Login + SMS Report Raw Data
diff --git a/resources/views/sms/adminsms.blade.php b/resources/views/sms/adminsms.blade.php new file mode 100644 index 0000000..47c05e5 --- /dev/null +++ b/resources/views/sms/adminsms.blade.php @@ -0,0 +1,209 @@ +@extends('layouts.master') +@section('page-css') + + +@endsection + +@section('main-content') +
+ +
+
+
+
Total Cost :
+

+
+
+
+ +
+
+ {{ csrf_field() }} +
+
+ + +
+
+ +
+
+ + +
+
+
+
+ +
+
+
+ +
+ loader + +
+ +
+ + +@endsection + +@section('page-js') + + + + + + + + + + + + + + + + + + +@endsection + + + diff --git a/resources/views/sms/sms.blade.php b/resources/views/sms/partnersms.blade.php similarity index 88% rename from resources/views/sms/sms.blade.php rename to resources/views/sms/partnersms.blade.php index d53ce6b..9fdb7b7 100644 --- a/resources/views/sms/sms.blade.php +++ b/resources/views/sms/partnersms.blade.php @@ -6,6 +6,16 @@ @section('main-content')
+ +
+
+
+
Total Cost :
+

+
+
+
+
{{ csrf_field() }} @@ -16,7 +26,7 @@
-
+
@@ -91,7 +101,7 @@ success: function(data) { console.log("report", data); smsrep(data.cost, data.blacklist, data.sent, data.failed); - + $("#smsTotal").html(parseFloat(data.total_sum[0].total).toFixed(2)) $("#dashboard_overlay").hide(); } }); @@ -112,6 +122,7 @@ url: "{{ route('sms_filtered_report_data') }}", success: function(data ) { smsrep(data.cost, data.blacklist, data.sent, data.failed); + $("#smsTotal").html(data.total_sum[0].total) console.log("filter", data) $("#dashboard_overlay").hide(); } @@ -143,14 +154,17 @@ function smsrep(data, data_b, data_s, data_f) { yAxis: { title: "SMS Expenditure" }, + labels: { + format: "{value:.2f}", // this stands for showing two decimal places + }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle' }, plotOptions: { - series: { - allowPointSelect: true + column: { + stacking: 'normal', } }, series: [{ @@ -164,7 +178,7 @@ function smsrep(data, data_b, data_s, data_f) { data: data_s }], tooltip: { - pointFormat: '{point.y} (sms)' + pointFormat: '{point.y} (KSH)', }, responsive: { rules: [{ From d8d1362c329f2f39b19f1d16380a9a9a10e31a36 Mon Sep 17 00:00:00 2001 From: server Date: Fri, 26 Nov 2021 16:19:34 +0000 Subject: [PATCH 24/47] perms --- .composer.json.swp | Bin LICENSE.md | 0 README.md | 0 app/Dashboard.php | 0 app/Http/Controllers/DashboardController.php | 0 app/Http/Controllers/NewRemoteLoginController.php | 0 app/Http/Controllers/SendResultsController.php | 0 app/Http/Controllers/SmsGatewayController.php | 0 app/Http/Controllers/TermsController.php | 0 app/Http/Controllers/UshauriController.php | 0 app/Printer.php | 0 app/SRLEIData.php | 0 app/SRLHTSData.php | 0 app/SRLVLData.php | 0 app/SmsGateway.php | 0 .../2021_05_17_170915_create_clients_table.php | 0 .../2021_05_17_172148_create_county_table.php | 0 ..._05_17_172331_create_health_facilities_table.php | 0 .../2021_05_17_172928_create_hts_results_table.php | 0 ...2021_05_17_173629_create_il_facilities_table.php | 0 .../2021_05_17_173840_create_inbox_table.php | 0 ...021_05_17_174209_create_new_facilities_table.php | 0 .../2021_05_17_175117_create_partner_table.php | 0 .../2021_05_17_175241_create_results_table.php | 0 .../2021_05_17_180001_create_send_log_table.php | 0 .../2021_05_17_180449_create_sms_gateway_table.php | 0 .../2021_05_17_180948_create_srl_eid_table.php | 0 .../2021_05_17_181448_create_srl_hts_table.php | 0 ...21_05_17_182626_create_srl_viral_loads_table.php | 0 .../2021_05_17_183356_create_sub_county_table.php | 0 .../2021_05_17_183609_create_tb_results_table.php | 0 logs/api.mhealthkenya.org-error.log | 0 logs/mlab.localhost.org-error.log | 0 logs/mlab.mhealthkenya.org-error.log | 0 public/images/loader.gif | Bin public/images/loader2.gif | Bin public/kenyan-counties.geojson | 0 resources/views/client/clients.blade.php | 0 .../views/dashboard/highcharts_dashboard.blade.php | 0 .../highcharts_printers_dashboard.blade.php | 0 resources/views/data/clients_filter.blade.php | 0 resources/views/data/eid_srl_filter.blade.php | 0 resources/views/data/eid_srl_results.blade.php | 0 resources/views/data/hts_filter.blade.php | 0 resources/views/data/hts_srl_filter.blade.php | 0 resources/views/data/hts_srl_results.blade.php | 0 resources/views/data/terms.blade.php | 0 resources/views/data/vl_srl_filter.blade.php | 0 resources/views/data/vl_srl_results.blade.php | 0 49 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .composer.json.swp mode change 100644 => 100755 LICENSE.md mode change 100644 => 100755 README.md mode change 100644 => 100755 app/Dashboard.php mode change 100644 => 100755 app/Http/Controllers/DashboardController.php mode change 100644 => 100755 app/Http/Controllers/NewRemoteLoginController.php mode change 100644 => 100755 app/Http/Controllers/SendResultsController.php mode change 100644 => 100755 app/Http/Controllers/SmsGatewayController.php mode change 100644 => 100755 app/Http/Controllers/TermsController.php mode change 100644 => 100755 app/Http/Controllers/UshauriController.php mode change 100644 => 100755 app/Printer.php mode change 100644 => 100755 app/SRLEIData.php mode change 100644 => 100755 app/SRLHTSData.php mode change 100644 => 100755 app/SRLVLData.php mode change 100644 => 100755 app/SmsGateway.php mode change 100644 => 100755 database/migrations/2021_05_17_170915_create_clients_table.php mode change 100644 => 100755 database/migrations/2021_05_17_172148_create_county_table.php mode change 100644 => 100755 database/migrations/2021_05_17_172331_create_health_facilities_table.php mode change 100644 => 100755 database/migrations/2021_05_17_172928_create_hts_results_table.php mode change 100644 => 100755 database/migrations/2021_05_17_173629_create_il_facilities_table.php mode change 100644 => 100755 database/migrations/2021_05_17_173840_create_inbox_table.php mode change 100644 => 100755 database/migrations/2021_05_17_174209_create_new_facilities_table.php mode change 100644 => 100755 database/migrations/2021_05_17_175117_create_partner_table.php mode change 100644 => 100755 database/migrations/2021_05_17_175241_create_results_table.php mode change 100644 => 100755 database/migrations/2021_05_17_180001_create_send_log_table.php mode change 100644 => 100755 database/migrations/2021_05_17_180449_create_sms_gateway_table.php mode change 100644 => 100755 database/migrations/2021_05_17_180948_create_srl_eid_table.php mode change 100644 => 100755 database/migrations/2021_05_17_181448_create_srl_hts_table.php mode change 100644 => 100755 database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php mode change 100644 => 100755 database/migrations/2021_05_17_183356_create_sub_county_table.php mode change 100644 => 100755 database/migrations/2021_05_17_183609_create_tb_results_table.php mode change 100644 => 100755 logs/api.mhealthkenya.org-error.log mode change 100644 => 100755 logs/mlab.localhost.org-error.log mode change 100644 => 100755 logs/mlab.mhealthkenya.org-error.log mode change 100644 => 100755 public/images/loader.gif mode change 100644 => 100755 public/images/loader2.gif mode change 100644 => 100755 public/kenyan-counties.geojson mode change 100644 => 100755 resources/views/client/clients.blade.php mode change 100644 => 100755 resources/views/dashboard/highcharts_dashboard.blade.php mode change 100644 => 100755 resources/views/dashboard/highcharts_printers_dashboard.blade.php mode change 100644 => 100755 resources/views/data/clients_filter.blade.php mode change 100644 => 100755 resources/views/data/eid_srl_filter.blade.php mode change 100644 => 100755 resources/views/data/eid_srl_results.blade.php mode change 100644 => 100755 resources/views/data/hts_filter.blade.php mode change 100644 => 100755 resources/views/data/hts_srl_filter.blade.php mode change 100644 => 100755 resources/views/data/hts_srl_results.blade.php mode change 100644 => 100755 resources/views/data/terms.blade.php mode change 100644 => 100755 resources/views/data/vl_srl_filter.blade.php mode change 100644 => 100755 resources/views/data/vl_srl_results.blade.php diff --git a/.composer.json.swp b/.composer.json.swp old mode 100644 new mode 100755 diff --git a/LICENSE.md b/LICENSE.md old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/app/Dashboard.php b/app/Dashboard.php old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/NewRemoteLoginController.php b/app/Http/Controllers/NewRemoteLoginController.php old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/SendResultsController.php b/app/Http/Controllers/SendResultsController.php old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/SmsGatewayController.php b/app/Http/Controllers/SmsGatewayController.php old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/TermsController.php b/app/Http/Controllers/TermsController.php old mode 100644 new mode 100755 diff --git a/app/Http/Controllers/UshauriController.php b/app/Http/Controllers/UshauriController.php old mode 100644 new mode 100755 diff --git a/app/Printer.php b/app/Printer.php old mode 100644 new mode 100755 diff --git a/app/SRLEIData.php b/app/SRLEIData.php old mode 100644 new mode 100755 diff --git a/app/SRLHTSData.php b/app/SRLHTSData.php old mode 100644 new mode 100755 diff --git a/app/SRLVLData.php b/app/SRLVLData.php old mode 100644 new mode 100755 diff --git a/app/SmsGateway.php b/app/SmsGateway.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_170915_create_clients_table.php b/database/migrations/2021_05_17_170915_create_clients_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_172148_create_county_table.php b/database/migrations/2021_05_17_172148_create_county_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_172331_create_health_facilities_table.php b/database/migrations/2021_05_17_172331_create_health_facilities_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_172928_create_hts_results_table.php b/database/migrations/2021_05_17_172928_create_hts_results_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_173629_create_il_facilities_table.php b/database/migrations/2021_05_17_173629_create_il_facilities_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_173840_create_inbox_table.php b/database/migrations/2021_05_17_173840_create_inbox_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_174209_create_new_facilities_table.php b/database/migrations/2021_05_17_174209_create_new_facilities_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_175117_create_partner_table.php b/database/migrations/2021_05_17_175117_create_partner_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_175241_create_results_table.php b/database/migrations/2021_05_17_175241_create_results_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_180001_create_send_log_table.php b/database/migrations/2021_05_17_180001_create_send_log_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_180449_create_sms_gateway_table.php b/database/migrations/2021_05_17_180449_create_sms_gateway_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_180948_create_srl_eid_table.php b/database/migrations/2021_05_17_180948_create_srl_eid_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_181448_create_srl_hts_table.php b/database/migrations/2021_05_17_181448_create_srl_hts_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php b/database/migrations/2021_05_17_182626_create_srl_viral_loads_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_183356_create_sub_county_table.php b/database/migrations/2021_05_17_183356_create_sub_county_table.php old mode 100644 new mode 100755 diff --git a/database/migrations/2021_05_17_183609_create_tb_results_table.php b/database/migrations/2021_05_17_183609_create_tb_results_table.php old mode 100644 new mode 100755 diff --git a/logs/api.mhealthkenya.org-error.log b/logs/api.mhealthkenya.org-error.log old mode 100644 new mode 100755 diff --git a/logs/mlab.localhost.org-error.log b/logs/mlab.localhost.org-error.log old mode 100644 new mode 100755 diff --git a/logs/mlab.mhealthkenya.org-error.log b/logs/mlab.mhealthkenya.org-error.log old mode 100644 new mode 100755 diff --git a/public/images/loader.gif b/public/images/loader.gif old mode 100644 new mode 100755 diff --git a/public/images/loader2.gif b/public/images/loader2.gif old mode 100644 new mode 100755 diff --git a/public/kenyan-counties.geojson b/public/kenyan-counties.geojson old mode 100644 new mode 100755 diff --git a/resources/views/client/clients.blade.php b/resources/views/client/clients.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/dashboard/highcharts_dashboard.blade.php b/resources/views/dashboard/highcharts_dashboard.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/dashboard/highcharts_printers_dashboard.blade.php b/resources/views/dashboard/highcharts_printers_dashboard.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/clients_filter.blade.php b/resources/views/data/clients_filter.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/eid_srl_filter.blade.php b/resources/views/data/eid_srl_filter.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/eid_srl_results.blade.php b/resources/views/data/eid_srl_results.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/hts_filter.blade.php b/resources/views/data/hts_filter.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/hts_srl_filter.blade.php b/resources/views/data/hts_srl_filter.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/hts_srl_results.blade.php b/resources/views/data/hts_srl_results.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/terms.blade.php b/resources/views/data/terms.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/vl_srl_filter.blade.php b/resources/views/data/vl_srl_filter.blade.php old mode 100644 new mode 100755 diff --git a/resources/views/data/vl_srl_results.blade.php b/resources/views/data/vl_srl_results.blade.php old mode 100644 new mode 100755 From 10d0666fcb34f6fc8ae7aac242330b4dcb2dfa8b Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Mon, 29 Nov 2021 15:45:52 +0300 Subject: [PATCH 25/47] rounding up sums --- app/Http/Controllers/SMSReportController.php | 64 +++++++++++--------- resources/views/sms/adminsms.blade.php | 2 +- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php index fee2905..9df4f82 100644 --- a/app/Http/Controllers/SMSReportController.php +++ b/app/Http/Controllers/SMSReportController.php @@ -30,40 +30,47 @@ public function get_data(){ $total_sum = SMSData::selectRaw("sum(sum) as total")->get(); - $cost = SMSData::selectRaw("partner_name, count(*) as y") - ->groupBy('partner_name' ) + $cost = SMSData::selectRaw("partner_name, CAST(sum(sum) as INTEGER) as total") + ->groupBy('partner_name') ->get(); // status 101 // 101: Sent - $sent = SMSData::selectRaw("partner_name, month, status , count(*) as y") + + return $sent_t = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") + ->orWhere('status', '=', 101) + ->groupBy('partner_name', 'status') + ->get(); + + $sent = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") ->orWhere('status', '=', 101) - ->groupBy('month', 'partner_name', 'status') + ->groupBy('partner_name', 'status') ->get(); // status 500, 501, 502 // 500: InternalServerError // 501: GatewayError // 502: RejectedByGateway - $failed = SMSData::selectRaw("partner_name, month, status , count(*) as y") + $failed = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") + ->where('status', '=', 500) ->orWhere('status', '=', 403) - ->groupBy('month', 'partner_name', 'status') + ->groupBy( 'partner_name', 'status') ->get(); // status 406 // 406: UserInBlacklist - $blacklist = SMSData::selectRaw("partner_name, month, status , count(*) as y") + $blacklist = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") ->orWhere('status', '=', 406) - ->groupBy('month', 'partner_name', 'status') + ->groupBy( 'partner_name', 'status') ->get(); } else if(Auth::user()->user_level == 2) { - $total_sum = SMSData::selectRaw("sum(sum) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum)as INTEGER) as total") ->where('partner_id', Auth::user()->partner_id ) ->get(); - $cost = SMSData::selectRaw("month, status , count(*) as y") + $cost = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->groupBy('month', 'status') ->orderBy('month', 'ASC') @@ -71,7 +78,7 @@ public function get_data(){ // status 101 // 101: Sent - $sent = SMSData::selectRaw("month, status , count(*) as y") + $sent = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->orWhere('status', '=', 101) ->groupBy('month', 'status') @@ -82,7 +89,7 @@ public function get_data(){ // 500: InternalServerError // 501: GatewayError // 502: RejectedByGateway - $failed = SMSData::selectRaw("month, status , count(*) as y") + $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->orWhere('status', '=', 403) ->groupBy('month', 'status') @@ -91,7 +98,7 @@ public function get_data(){ // status 406 // 406: UserInBlacklist - $blacklist = SMSData::selectRaw("month, status , count(*) as y") + $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->orWhere('status', '=', 406) ->groupBy('month','status') @@ -124,53 +131,50 @@ public function get_filtered_data(Request $request){ if(Auth::user()->user_level == 1) { - $total_sum = SMSData::selectRaw("sum(sum) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum)as INTEGER) as total") ->whereBetween('month',[$start_date, $end_date] ) ->get(); - $cost = SMSData::selectRaw("partner_name, month, status,count(*) as y") + $cost = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") ->whereBetween('month',[$start_date, $end_date] ) - ->groupBy('month','partner_name', 'status') + ->groupBy('partner_name') ->get(); // status 101 - $sent = SMSData::selectRaw("partner_name, month, status , count(*) as y") + $sent = SMSData::selectRaw("partner_name, status, CAST(sum(sum)as INTEGER) as y") ->whereBetween('month',[$start_date, $end_date] ) ->orWhere('status', '=', 101) - ->groupBy('month', 'partner_name', 'status') - ->orderBy('month', 'ASC') + ->groupBy('status', 'partner_name') ->get(); // status 500, 501, 502 - $failed = SMSData::selectRaw("partner_name, month, status , count(*) as y") + $failed = SMSData::selectRaw("partner_name, status, CAST(sum(sum)as INTEGER) as y") ->whereBetween('month',[$start_date, $end_date] ) ->orWhere('status', '=', 403) - ->groupBy('month', 'partner_name', 'status') - ->orderBy('month', 'ASC') + ->groupBy('status', 'partner_name') ->get(); // status 406 - $blacklist = SMSData::selectRaw("partner_name, month, status , count(*) as y") + $blacklist = SMSData::selectRaw("partner_name, status, CAST(sum(sum)as INTEGER) as y") ->orWhere('status', '=', 406) - ->groupBy('month', 'partner_name', 'status') - ->orderBy('month', 'ASC') + ->groupBy('status', 'partner_name') ->get(); } else if(Auth::user()->user_level == 2) { - $total_sum = SMSData::selectRaw("sum(sum) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum)as INTEGER) as total") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->get(); - $cost = SMSData::selectRaw("month, status,count(*) as y") + $cost = SMSData::selectRaw("month, status, CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->groupBy('month', 'status') ->get(); // status 101 - $sent = SMSData::selectRaw("month, status , count(*) as y") + $sent = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->orWhere('status', '=', 101) @@ -179,7 +183,7 @@ public function get_filtered_data(Request $request){ ->get(); // status 500, 501, 502 - $failed = SMSData::selectRaw("month, status , count(*) as y") + $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->orWhere('status', '=', 403) @@ -188,7 +192,7 @@ public function get_filtered_data(Request $request){ ->get(); // status 406 - $blacklist = SMSData::selectRaw("month, status , count(*) as y") + $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->orWhere('status', '=', 406) ->groupBy('month', 'status') diff --git a/resources/views/sms/adminsms.blade.php b/resources/views/sms/adminsms.blade.php index 47c05e5..a2dd276 100644 --- a/resources/views/sms/adminsms.blade.php +++ b/resources/views/sms/adminsms.blade.php @@ -36,7 +36,7 @@
-
+
From 83c6eb96273665352a5ce0b5e5c8bf5ef62b896b Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Tue, 30 Nov 2021 18:47:07 +0300 Subject: [PATCH 26/47] sms sum integer --- app/Http/Controllers/SMSReportController.php | 67 ++++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php index 9df4f82..6b6c1b0 100644 --- a/app/Http/Controllers/SMSReportController.php +++ b/app/Http/Controllers/SMSReportController.php @@ -36,51 +36,46 @@ public function get_data(){ // status 101 // 101: Sent - - return $sent_t = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") - ->orWhere('status', '=', 101) - ->groupBy('partner_name', 'status') - ->get(); - - $sent = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") - ->orWhere('status', '=', 101) - ->groupBy('partner_name', 'status') + $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + ->whereIn('status', ['101', '102']) + ->groupBy('partner_name') ->get(); // status 500, 501, 502 // 500: InternalServerError // 501: GatewayError // 502: RejectedByGateway - $failed = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") - ->where('status', '=', 500) - ->orWhere('status', '=', 403) - ->groupBy( 'partner_name', 'status') + $failed = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + ->where('status', '=', 403) + ->groupBy( 'partner_name') ->get(); // status 406 // 406: UserInBlacklist - $blacklist = SMSData::selectRaw("partner_name, status , CAST(sum(sum)as INTEGER) as y") - ->orWhere('status', '=', 406) - ->groupBy( 'partner_name', 'status') + $blacklist = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + ->where('status', '=', 406) + ->groupBy( 'partner_name') ->get(); } else if(Auth::user()->user_level == 2) { - $total_sum = SMSData::selectRaw("CAST(sum(sum)as INTEGER) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum) as INTEGER) as total") ->where('partner_id', Auth::user()->partner_id ) ->get(); - $cost = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $cost = SMSData::selectRaw("month, CAST(sum(sum) as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) - ->groupBy('month', 'status') + ->groupBy('month') ->orderBy('month', 'ASC') ->get(); // status 101 // 101: Sent - $sent = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $sent = SMSData::selectRaw("month, status, CAST(sum(sum) as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 101) + ->whereIn('status', ['101', '102']) + // ->where('status', '=', 101) + // ->orWhere('status', '=', 102) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); @@ -91,7 +86,7 @@ public function get_data(){ // 502: RejectedByGateway $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 403) + ->where('status', '=', 403) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); @@ -100,7 +95,7 @@ public function get_data(){ // 406: UserInBlacklist $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 406) + ->where('status', '=', 406) ->groupBy('month','status') ->orderBy('month', 'ASC') ->get(); @@ -141,23 +136,23 @@ public function get_filtered_data(Request $request){ ->get(); // status 101 - $sent = SMSData::selectRaw("partner_name, status, CAST(sum(sum)as INTEGER) as y") + $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") ->whereBetween('month',[$start_date, $end_date] ) - ->orWhere('status', '=', 101) - ->groupBy('status', 'partner_name') + ->whereIn('status', ['101', '102']) + ->groupBy( 'partner_name') ->get(); // status 500, 501, 502 - $failed = SMSData::selectRaw("partner_name, status, CAST(sum(sum)as INTEGER) as y") + $failed = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") ->whereBetween('month',[$start_date, $end_date] ) - ->orWhere('status', '=', 403) - ->groupBy('status', 'partner_name') + ->where('status', '=', 403) + ->groupBy('partner_name') ->get(); // status 406 - $blacklist = SMSData::selectRaw("partner_name, status, CAST(sum(sum)as INTEGER) as y") - ->orWhere('status', '=', 406) - ->groupBy('status', 'partner_name') + $blacklist = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + ->where('status', '=', 406) + ->groupBy('partner_name') ->get(); } else if(Auth::user()->user_level == 2) { @@ -177,7 +172,9 @@ public function get_filtered_data(Request $request){ $sent = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) - ->orWhere('status', '=', 101) + ->whereIn('status', ['101', '102']) + // ->where('status', '=', 101) + // ->where('status', '=', 102) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); @@ -186,7 +183,7 @@ public function get_filtered_data(Request $request){ $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) - ->orWhere('status', '=', 403) + ->where('status', '=', 403) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); @@ -194,7 +191,7 @@ public function get_filtered_data(Request $request){ // status 406 $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") ->where('partner_id', Auth::user()->partner_id ) - ->orWhere('status', '=', 406) + ->where('status', '=', 406) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); From 68bc983b3181f79a9c525b6871c1f9d0d55e9f14 Mon Sep 17 00:00:00 2001 From: CynthiaKamau Date: Wed, 5 Jan 2022 14:14:49 +0300 Subject: [PATCH 27/47] added queued sms --- app/Http/Controllers/SMSReportController.php | 82 +++++++++++++------- resources/views/sms/adminsms.blade.php | 52 ++++++------- resources/views/sms/partnersms.blade.php | 53 ++++++------- 3 files changed, 105 insertions(+), 82 deletions(-) diff --git a/app/Http/Controllers/SMSReportController.php b/app/Http/Controllers/SMSReportController.php index 6b6c1b0..46b5f74 100644 --- a/app/Http/Controllers/SMSReportController.php +++ b/app/Http/Controllers/SMSReportController.php @@ -30,14 +30,20 @@ public function get_data(){ $total_sum = SMSData::selectRaw("sum(sum) as total")->get(); - $cost = SMSData::selectRaw("partner_name, CAST(sum(sum) as INTEGER) as total") + $cost = SMSData::selectRaw("partner_name, CAST(sum(sum) as FLOAT) as total") ->groupBy('partner_name') ->get(); // status 101 // 101: Sent - $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") - ->whereIn('status', ['101', '102']) + $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") + ->where('status', '=', 101) + ->groupBy('partner_name') + ->get(); + + // 102: Queued + $queued = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") + ->where('status', '=', 102) ->groupBy('partner_name') ->get(); @@ -45,25 +51,25 @@ public function get_data(){ // 500: InternalServerError // 501: GatewayError // 502: RejectedByGateway - $failed = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + $failed = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") ->where('status', '=', 403) ->groupBy( 'partner_name') ->get(); // status 406 // 406: UserInBlacklist - $blacklist = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + $blacklist = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") ->where('status', '=', 406) ->groupBy( 'partner_name') ->get(); } else if(Auth::user()->user_level == 2) { - $total_sum = SMSData::selectRaw("CAST(sum(sum) as INTEGER) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum) as FLOAT) as total") ->where('partner_id', Auth::user()->partner_id ) ->get(); - $cost = SMSData::selectRaw("month, CAST(sum(sum) as INTEGER) as y") + $cost = SMSData::selectRaw("month, CAST(sum(sum) as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->groupBy('month') ->orderBy('month', 'ASC') @@ -71,11 +77,17 @@ public function get_data(){ // status 101 // 101: Sent - $sent = SMSData::selectRaw("month, status, CAST(sum(sum) as INTEGER) as y") + $sent = SMSData::selectRaw("month, status, CAST(sum(sum) as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) - ->whereIn('status', ['101', '102']) - // ->where('status', '=', 101) - // ->orWhere('status', '=', 102) + ->where('status', '=', 101) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // 102: Queued + $queued = SMSData::selectRaw("month, status, CAST(sum(sum) as FLOAT) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->where('status', '=', 102) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); @@ -84,7 +96,7 @@ public function get_data(){ // 500: InternalServerError // 501: GatewayError // 502: RejectedByGateway - $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->where('status', '=', 403) ->groupBy('month', 'status') @@ -93,7 +105,7 @@ public function get_data(){ // status 406 // 406: UserInBlacklist - $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->where('status', '=', 406) ->groupBy('month','status') @@ -104,6 +116,7 @@ public function get_data(){ $data["blacklist"] = $blacklist; $data["failed"] = $failed; + $data["queued"] = $queued; $data["sent"] = $sent; $data["cost"] = $cost; $data["total_sum"] = $total_sum; @@ -126,61 +139,75 @@ public function get_filtered_data(Request $request){ if(Auth::user()->user_level == 1) { - $total_sum = SMSData::selectRaw("CAST(sum(sum)as INTEGER) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum)as FLOAT) as total") ->whereBetween('month',[$start_date, $end_date] ) ->get(); - $cost = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + $cost = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") ->whereBetween('month',[$start_date, $end_date] ) ->groupBy('partner_name') ->get(); // status 101 - $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") + ->whereBetween('month',[$start_date, $end_date] ) + ->where('status', '=', 101) + ->groupBy( 'partner_name') + ->get(); + + // status 102 Queued + $sent = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") ->whereBetween('month',[$start_date, $end_date] ) - ->whereIn('status', ['101', '102']) + ->where('status', '=', 102) ->groupBy( 'partner_name') ->get(); // status 500, 501, 502 - $failed = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + $failed = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") ->whereBetween('month',[$start_date, $end_date] ) ->where('status', '=', 403) ->groupBy('partner_name') ->get(); // status 406 - $blacklist = SMSData::selectRaw("partner_name, CAST(sum(sum)as INTEGER) as y") + $blacklist = SMSData::selectRaw("partner_name, CAST(sum(sum)as FLOAT) as y") ->where('status', '=', 406) ->groupBy('partner_name') ->get(); } else if(Auth::user()->user_level == 2) { - $total_sum = SMSData::selectRaw("CAST(sum(sum)as INTEGER) as total") + $total_sum = SMSData::selectRaw("CAST(sum(sum)as FLOAT) as total") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->get(); - $cost = SMSData::selectRaw("month, status, CAST(sum(sum)as INTEGER) as y") + $cost = SMSData::selectRaw("month, status, CAST(sum(sum)as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->groupBy('month', 'status') ->get(); // status 101 - $sent = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $sent = SMSData::selectRaw("month, status , CAST(sum(sum)as FLOAT) as y") + ->where('partner_id', Auth::user()->partner_id ) + ->whereBetween('month',[$start_date, $end_date] ) + ->where('status', '=', 101) + ->groupBy('month', 'status') + ->orderBy('month', 'ASC') + ->get(); + + // status 102 queued + $queued = SMSData::selectRaw("month, status , CAST(sum(sum)as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) - ->whereIn('status', ['101', '102']) - // ->where('status', '=', 101) - // ->where('status', '=', 102) + ->where('status', '=', 102) ->groupBy('month', 'status') ->orderBy('month', 'ASC') ->get(); // status 500, 501, 502 - $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $failed = SMSData::selectRaw("month, status , CAST(sum(sum)as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->whereBetween('month',[$start_date, $end_date] ) ->where('status', '=', 403) @@ -189,7 +216,7 @@ public function get_filtered_data(Request $request){ ->get(); // status 406 - $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as INTEGER) as y") + $blacklist = SMSData::selectRaw("month, status , CAST(sum(sum)as FLOAT) as y") ->where('partner_id', Auth::user()->partner_id ) ->where('status', '=', 406) ->groupBy('month', 'status') @@ -200,6 +227,7 @@ public function get_filtered_data(Request $request){ $data["blacklist"] = $blacklist; $data["failed"] = $failed; $data["sent"] = $sent; + $data["queued"] = $queued; $data["cost"] = $cost; $data["total_sum"] = $total_sum; diff --git a/resources/views/sms/adminsms.blade.php b/resources/views/sms/adminsms.blade.php index a2dd276..16262a7 100644 --- a/resources/views/sms/adminsms.blade.php +++ b/resources/views/sms/adminsms.blade.php @@ -100,8 +100,8 @@ url: "{{ route('sms_report_data') }}", success: function(data) { console.log("report", data); - smsrep(data.cost, data.blacklist, data.sent, data.failed); - $("#smsTotal").html(parseFloat(data.total_sum[0].total).toFixed(2)) + smsrep(data.cost, data.blacklist, data.sent, data.failed, data.queued); + $("#smsTotal").html(Number(data.total_sum[0].total).toFixed(2)) $("#dashboard_overlay").hide(); } }); @@ -121,8 +121,8 @@ }, url: "{{ route('sms_filtered_report_data') }}", success: function(data ) { - smsrep(data.cost, data.blacklist, data.sent, data.failed); - $("#smsTotal").html(data.total_sum[0].total) + smsrep(data.cost, data.blacklist, data.sent, data.failed, data.queued); + $("#smsTotal").html(Number(data.total_sum[0].total).toFixed(2)) console.log("filter", data) $("#dashboard_overlay").hide(); } @@ -133,7 +133,9 @@ diff --git a/routes/api.php b/routes/api.php index 5ca7f19..63a90b6 100755 --- a/routes/api.php +++ b/routes/api.php @@ -32,9 +32,10 @@ Route::post('/get/il/viral_loads', 'SendResultsController@sendILInternet'); Route::post('/ushauri/get/results', 'UshauriController@getResults'); Route::get('/notify/clients', 'UshauriController@notifyClients'); +Route::get('/fetch/blacklist_users', 'SenderController@get_blacklist'); Route::middleware('auth:api')->group(function () { Route::post('/viral/loads', 'SendResultsController@ViralLoads'); - Route::post('/sms/gateway', 'SmsGatewayController@sender'); + Route::get('/sms/gateway', 'SmsGatewayController@sender'); }); From 997d348f7ae16833b98e8e0ab7ff53a417ca02ca Mon Sep 17 00:00:00 2001 From: andrinem Date: Thu, 10 Mar 2022 12:03:42 +0300 Subject: [PATCH 37/47] Include docker setup option --- docker-compose.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ nginx.dockerfile | 12 ++++++++++++ php.dockerfile | 26 ++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 docker-compose.yml create mode 100644 nginx.dockerfile create mode 100644 php.dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6217967 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +version: '3' + +networks: + development: + +services: + site: + build: + context: . + dockerfile: nginx.dockerfile + container_name: mlab-nginx + restart: always + ports: + - 8085:443 + volumes: + - ./src:/var/www/html:delegated + depends_on: + - php + - database + networks: + - development + + database: + image: postgres:13.1-alpine + container_name: mlab-database + restart: unless-stopped + tty: true + ports: + - 5430:5432 + environment: + - POSTGRES_USER=test + - POSTGRES_PASSWORD=test123 + - POSTGRES_DB=mlab + networks: + - development + + php: + build: + context: . + dockerfile: php.dockerfile + container_name: mlab-php + volumes: + - ./src:/var/www/html:delegated + networks: + - development + diff --git a/nginx.dockerfile b/nginx.dockerfile new file mode 100644 index 0000000..7eeacb3 --- /dev/null +++ b/nginx.dockerfile @@ -0,0 +1,12 @@ +FROM nginx:stable-alpine + +ADD ./nginx/nginx.conf /etc/nginx/nginx.conf +ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf +ADD ./nginx/ssl/spot.kenyahmis.org.crt /etc/nginx/spot.kenyahmis.org.crt +ADD ./nginx/ssl/kenyahmis.org.key /etc/nginx/kenyahmis.org.key + +RUN mkdir -p /var/www/html + +RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel + +RUN chown laravel:laravel /var/www/html diff --git a/php.dockerfile b/php.dockerfile new file mode 100644 index 0000000..df9e157 --- /dev/null +++ b/php.dockerfile @@ -0,0 +1,26 @@ +FROM php:7.2-fpm-alpine + +RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel + +RUN mkdir -p /var/www/html + + +RUN chown laravel:laravel /var/www/html +# Install selected extensions and other stuff +RUN apk update \ + && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \ + && pecl install redis \ + && apk --no-cache add \ + postgresql-dev \ + && apk del -f .build-deps + +WORKDIR /var/www/html/ + +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +COPY . . + +RUN docker-php-ext-install pdo pdo_pgsql + +RUN docker-php-ext-enable redis + From d1874dacde84b356c93b433f3c052cb6bcde1530 Mon Sep 17 00:00:00 2001 From: Lavatsaleo <77143585+Lavatsaleo@users.noreply.github.com> Date: Fri, 25 Mar 2022 07:36:56 +0300 Subject: [PATCH 38/47] Update README.md add docker set up --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 6cd3a40..ceab42e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,14 @@ You can now access the server at http://localhost:8000 - [laravel-cors](https://github.com/barryvdh/laravel-cors) - For handling Cross-Origin Resource Sharing (CORS) - [africastalking](https://github.com/AfricasTalkingLtd/africastalking-php) - For SMS + +## Docker set up + git clone https://github.com/palladiumkenya/mLab.git + cd mLab + docker-compose up -d + You can now access the server at http://localhost:8085 + + ## Folders - `app` - Contains all the Eloquent models From 4e8c24a775d888ccf54384d83f2175cb39d362e3 Mon Sep 17 00:00:00 2001 From: Lavatsaleo <77143585+Lavatsaleo@users.noreply.github.com> Date: Fri, 25 Mar 2022 07:38:46 +0300 Subject: [PATCH 39/47] add docker setup --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cd3a40..8ba6172 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,14 @@ You can now access the server at http://localhost:8000 php artisan migrate php artisan serve - + + +## Docker set up + git clone https://github.com/palladiumkenya/mLab.git + cd mLab + docker-compose up -d + You can now access the server at http://localhost:8085 + ## Dependencies - [laravel-passport](https://github.com/laravel/passport) - For handling authentication From 0667eda7dd229570921f776ef56b12026572a5f9 Mon Sep 17 00:00:00 2001 From: Lavatsaleo <77143585+Lavatsaleo@users.noreply.github.com> Date: Fri, 25 Mar 2022 13:47:25 +0300 Subject: [PATCH 40/47] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ceab42e..fe77140 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,8 @@ You can now access the server at http://localhost:8000 ## Docker set up - git clone https://github.com/palladiumkenya/mLab.git + + git clone https://github.com/palladiumkenya/mLab.git(clone cicd branch) cd mLab docker-compose up -d You can now access the server at http://localhost:8085 From 87827725791bf76d32b2770906882c269d8a75bf Mon Sep 17 00:00:00 2001 From: Lavatsaleo <77143585+Lavatsaleo@users.noreply.github.com> Date: Thu, 7 Apr 2022 11:15:10 +0300 Subject: [PATCH 41/47] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe77140..352f289 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ You can now access the server at http://localhost:8000 ## Docker set up - git clone https://github.com/palladiumkenya/mLab.git(clone cicd branch) + git clone https://github.com/palladiumkenya/mLab.git cd mLab docker-compose up -d You can now access the server at http://localhost:8085 From b26118d0dcd99c992aae1c7917d95f1fb59f899a Mon Sep 17 00:00:00 2001 From: Andrine Date: Tue, 19 Apr 2022 11:40:53 +0300 Subject: [PATCH 42/47] amend nginx dockerfile --- nginx.dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.dockerfile b/nginx.dockerfile index 7eeacb3..00d0227 100644 --- a/nginx.dockerfile +++ b/nginx.dockerfile @@ -2,8 +2,8 @@ FROM nginx:stable-alpine ADD ./nginx/nginx.conf /etc/nginx/nginx.conf ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf -ADD ./nginx/ssl/spot.kenyahmis.org.crt /etc/nginx/spot.kenyahmis.org.crt -ADD ./nginx/ssl/kenyahmis.org.key /etc/nginx/kenyahmis.org.key +ADD ./nginx/ssl/app.crt /etc/nginx/app.crt +ADD ./nginx/ssl/app.key /etc/nginx/app.key RUN mkdir -p /var/www/html From 28588471dad8ba65f2905d07fe7ad2573d691b1c Mon Sep 17 00:00:00 2001 From: andrineM <53934661+andrineM@users.noreply.github.com> Date: Thu, 21 Apr 2022 07:49:42 +0300 Subject: [PATCH 43/47] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 26e78e0..3dfc5db 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,10 @@ You can now access the server at http://localhost:8000 git clone https://github.com/palladiumkenya/mLab.git cd mLab - docker-compose up -d + cp .env.example .env + mkdir src + copy all files into src folder (excluding docker-compose.yml,nginx.dockerfile and php.dockerfile) + docker-compose --env-file ./src/.env up -d --build site You can now access the server at http://localhost:8085 From 3ed05033119cb07f5d70398723f8b76bf09416bb Mon Sep 17 00:00:00 2001 From: andrineM <53934661+andrineM@users.noreply.github.com> Date: Thu, 21 Apr 2022 07:52:23 +0300 Subject: [PATCH 44/47] Update README.md --- README.md | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3dfc5db..9b55668 100644 --- a/README.md +++ b/README.md @@ -64,19 +64,6 @@ You can now access the server at http://localhost:8000 php artisan migrate php artisan serve - -## Docker set up - git clone https://github.com/palladiumkenya/mLab.git - cd mLab - docker-compose up -d - You can now access the server at http://localhost:8085 - -## Dependencies - -- [laravel-passport](https://github.com/laravel/passport) - For handling authentication -- [laravel-cors](https://github.com/barryvdh/laravel-cors) - For handling Cross-Origin Resource Sharing (CORS) -- [africastalking](https://github.com/AfricasTalkingLtd/africastalking-php) - For SMS - ## Docker set up @@ -88,6 +75,12 @@ You can now access the server at http://localhost:8000 docker-compose --env-file ./src/.env up -d --build site You can now access the server at http://localhost:8085 +## Dependencies + +- [laravel-passport](https://github.com/laravel/passport) - For handling authentication +- [laravel-cors](https://github.com/barryvdh/laravel-cors) - For handling Cross-Origin Resource Sharing (CORS) +- [africastalking](https://github.com/AfricasTalkingLtd/africastalking-php) - For SMS + ## Folders From 52662245077e543b55777b8179e83cbdf8085483 Mon Sep 17 00:00:00 2001 From: Andrine Date: Thu, 21 Apr 2022 08:11:52 +0300 Subject: [PATCH 45/47] Include docker setup --- nginx.dockerfile | 3 +-- nginx/default.conf | 20 ++++++++++++++++++++ nginx/nginx.conf | 29 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 nginx/default.conf create mode 100644 nginx/nginx.conf diff --git a/nginx.dockerfile b/nginx.dockerfile index 00d0227..90c4efc 100644 --- a/nginx.dockerfile +++ b/nginx.dockerfile @@ -2,8 +2,7 @@ FROM nginx:stable-alpine ADD ./nginx/nginx.conf /etc/nginx/nginx.conf ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf -ADD ./nginx/ssl/app.crt /etc/nginx/app.crt -ADD ./nginx/ssl/app.key /etc/nginx/app.key + RUN mkdir -p /var/www/html diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..c8c2cf7 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,20 @@ +server { + listen 80; + index index.php index.html; + server_name _; + root /var/www/html/public; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } +} \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..060e502 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,29 @@ +user laravel; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} From f32b6ced5a5a162043bca60307eea820bd276ab9 Mon Sep 17 00:00:00 2001 From: andrineM <53934661+andrineM@users.noreply.github.com> Date: Thu, 21 Apr 2022 08:16:29 +0300 Subject: [PATCH 46/47] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b55668..9cfa4f0 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ You can now access the server at http://localhost:8000 cd mLab cp .env.example .env mkdir src - copy all files into src folder (excluding docker-compose.yml,nginx.dockerfile and php.dockerfile) + copy all files into src folder (excluding docker-compose.yml,nginx.dockerfile,php.dockerfile and nginx folder) docker-compose --env-file ./src/.env up -d --build site You can now access the server at http://localhost:8085 From 8dfe51f49a4aa97a1896bb6b770a5f7239aad031 Mon Sep 17 00:00:00 2001 From: Lavatsaleo <77143585+Lavatsaleo@users.noreply.github.com> Date: Fri, 6 May 2022 09:12:32 +0300 Subject: [PATCH 47/47] Create cicd_process.yml --- .github/workflows/cicd_process.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/cicd_process.yml diff --git a/.github/workflows/cicd_process.yml b/.github/workflows/cicd_process.yml new file mode 100644 index 0000000..b0452c8 --- /dev/null +++ b/.github/workflows/cicd_process.yml @@ -0,0 +1,27 @@ +name: deploy to test +on: + push: + branches: [ cicd ] +jobs: + + build: + name: Deploy + runs-on: ubuntu-latest + steps: + - name: executing remote connection + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.MLAB_HOST }} + username: ${{ secrets.MLAB_HOST_USERNAME }} + key: ${{ secrets.CICD_SECRET }} + port: ${{ secrets.MLAB_HOST_PORT }} + script: | + git config --global --add safe.directory /apps/github-workflows/mLab + cd /apps/github-workflows/mLab + git pull origin cicd + git status + + sudo cp -R /apps/dockerApps/mlabtestsite/nginx /apps/github-workflows/mLab + + docker-compose down + docker-compose up -d