Utilities::expenseRepeatIntervel()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 16
nc 5
nop 1
1
<?php
2
3
use Illuminate\Http\Request;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
use App\Http\Requests; 
5
use App\Member;
6
use App\Plan;
7
use App\Subscription;
8
use App\Setting;
9
use App\Sms_log;
10
use Carbon\Carbon;
11
12
class Utilities {
13
14
static function setActiveMenu($uri,$isParent = false)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
15
{
16
	$class = ($isParent) ? 'active open' : 'active';
17
    return \Request::is($uri) ? $class : '';
18
    //return \Request::is($uri);
19
}
20
21
// Get Setting
22
static function getSetting($key)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
{
24
	$settingValue = Setting::where('key','=',$key)->pluck('value');
25
	return $settingValue;
26
}
27
28
//get Settings
29
static function getSettings()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
{
31
	$settings = Setting::all();
32
	$settings_array = array();
33
34
	foreach ($settings as $setting) {
35
		$settings_array[$setting->key] = $setting->value;
36
	}
37
38
	return $settings_array;
39
}
40
41
42
//Follow up Status
43
static function getFollowUpStatus($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
44
{
45
	switch ($status) {
46
		case '1':
47
			return "Done"; 
48
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
49
50
	    default :
51
	        return "Pending";
52
	        break;
53
	}
54
}
55
56
//Follow up by
57
static function getFollowupBy($followUpBy)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
58
{
59
	switch ($followUpBy) {
60
		case '1':
61
			return "SMS";
62
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
63
64
		case '2':
65
			return "Personal";
66
			break;
67
68
	    default :
69
	        return "Call";
70
	        break;
71
	}
72
}
73
74
//FollowUp Status Icon bg
75
static function getIconBg($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
76
{
77
	switch ($status) {
78
		case '1':
79
			return "bg-blue-400 border-blue-700"; 
80
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
81
82
	    default :
83
	        return "bg-orange-400 border-orange-700";
84
	        break;
85
	}
86
}
87
88
89
90
//Followup Status Icon
91
static function getStatusIcon($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
92
{
93
	switch ($status) {
94
		case '1':
95
			return "fa fa-thumbs-up"; 
96
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
97
98
	    default :
99
	        return "fa fa-refresh";
100
	        break;
101
	}
102
}
103
104
105
// Aim for member & enquiry creation
106
static function getAim($aim)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
107
{
108
	switch ($aim) {
109
		case '1':
110
			return "Networking";
111
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
112
		
113
		case '2':
114
			return "Body Building";
115
			break;
116
117
		case '3':
118
			return "Fatloss";
119
			break;
120
121
		case '4':
122
			return "Weightgain";
123
			break;
124
125
		case '5':
126
			return "Others";
127
			break;
128
129
	    default :
130
	        return "Fitness";
131
	        break;
132
	}
133
}
134
135
136
// Invoice Labels
137
static function getInvoiceLabel($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
138
{
139
	switch ($status) {
140
		case '0':
141
			return "label label-danger";
142
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
143
		
144
		case '1':
145
			return "label label-success";
146
			break;
147
148
		case '3':
149
			return "label label-default";
150
			break;
151
152
	    default :
153
	        return "label label-primary";
154
	        break;
155
	}
156
}
157
158
// Expense alert repeat
159
static function expenseRepeatIntervel($repeat)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
160
{
161
	switch ($repeat) {
162
		case '0':
163
			return "Never Repeat";
164
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
165
		
166
		case '1':
167
			return "Every Day";
168
			break;
169
170
		case '2':
171
			return "Every Week";
172
			break;
173
174
		case '3':
175
			return "Every Month";
176
			break;
177
178
	    default :
179
	        return "Every Year";
180
	        break;
181
	}
182
}
183
184
//Paid Unpaid Labels
185
static function getPaidUnpaid($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
186
{
187
	switch ($status) {
188
		case '0':
189
			return "label label-danger";
190
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
191
192
	    default :
193
	        return "label label-primary";
194
	        break;
195
	}
196
}
197
198
//Active-Inactive Labels
199
static function getActiveInactive($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
200
{
201
	switch ($status) {
202
		case '0':
203
			return "label label-danger";
204
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
205
206
	    default :
207
	        return "label label-primary";
208
	        break;
209
	}
210
}
211
212
213
214
// Occupation of members
215
static function getOccupation($occupation)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
216
{
217
	switch ($occupation) {
218
		case '1':
219
			return "Housewife";
220
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
221
		
222
		case '2':
223
			return "Self Employed";
224
			break;
225
226
		case '3':
227
			return "Professional";
228
			break;
229
230
		case '4':
231
			return "Freelancer";
232
			break;
233
234
		case '5':
235
			return "Others";
236
			break;
237
238
	    default :
239
	        return "Student";
240
	        break;
241
	}
242
}
243
244
245
246
// Source for member & enquiry creation
247
static function getSource($source)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
248
{
249
	switch ($source) {
250
		case '1':
251
			return "Word of mouth";
252
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
253
		
254
		case '2':
255
			return "Others";
256
			break;
257
258
	    default :
259
	        return "Promotions";
260
	        break;
261
	}
262
}
263
264
265
// Member Status
266
static function getStatusValue($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
267
{
268
	switch ($status) {
269
		case '0':
270
			return "Inactive";
271
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
272
		
273
		case '2':
274
			return "Archived";
275
			break;
276
277
	    default :
278
	        return "Active";
279
	        break;
280
	}
281
}
282
283
// Enquiry Status
284
static function getEnquiryStatus($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
285
{
286
	switch ($status) {
287
		case '0':
288
			return "Lost";
289
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
290
		
291
		case '2':
292
			return "Member";
293
			break;
294
			
295
	    default :
296
	        return "Lead";
297
	        break;
298
	}
299
}
300
301
// Enquiry Label
302
static function getEnquiryLabel($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
303
{
304
	switch ($status) {
305
		case '0':
306
			return "label label-danger";
307
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
308
		
309
		case '2':
310
			return "label label-success";
311
			break;
312
313
	    default :
314
	        return "label label-primary";
315
	        break;
316
	}
317
}
318
319
// Set invoice status
320
static function setInvoiceStatus($amount_due,$invoice_total)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
321
{
322
	if($amount_due == 0)
323
    {
324
         $paymentStatus = \constPaymentStatus::Paid;
325
    } 
326
    elseif($amount_due > 0 && $amount_due < $invoice_total) 
327
    {
328
        $paymentStatus = \constPaymentStatus::Partial;
329
    }
330
    elseif($amount_due == $invoice_total) 
331
    {
332
        $paymentStatus = \constPaymentStatus::Unpaid;
333
    }
334
    else
335
    {
336
        $paymentStatus = \constPaymentStatus::Overpaid;
337
    }    
338
    return $paymentStatus;
339
}
340
341
342
// Invoice Status
343
static function getInvoiceStatus($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
344
{
345
	switch ($status) {
346
		case '1':
347
			return "Paid";
348
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
349
		
350
		case '2':
351
			return "Partial";
352
			break;
353
354
		case '3':
355
			return "Overpaid";
356
			break;
357
358
	    default :
359
	        return "Unpaid";
360
	        break;
361
	}
362
}
363
364
365
// Subcription Status
366
static function getSubscriptionStatus($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
367
{
368
	switch ($status) {
369
		case '0':
370
			return "Expired";
371
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
372
		
373
		case '2':
374
			return "Renewed";
375
			break;
376
377
		case '3':
378
			return "Cancelled";
379
			break;
380
381
	    default :
382
	        return "OnGoing";
383
	        break;
384
	}
385
}
386
387
388
// Subcription Label
389
static function getSubscriptionLabel($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
390
{
391
	switch ($status) {
392
		case '0':
393
			return "label label-danger";
394
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
395
		
396
		case '2':
397
			return "label label-success";
398
			break;
399
400
		case '3':
401
			return "label label-default";
402
			break;
403
404
	    default :
405
	        return "label label-primary";
406
	        break;
407
	}
408
}
409
410
411
// Payment Mode
412
static function getPaymentMode($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
413
{
414
	switch ($status) {
415
		case '0':
416
			return "Cheque";
417
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
418
419
	    default :
420
	        return "Cash";
421
	        break;
422
	}
423
}
424
425
// Cheque status
426
static function getChequeStatus($status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
427
{
428
	switch ($status) {
429
		case '1':
430
			return "Deposited";
431
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
432
433
		case '2':
434
			return "Cleared";
435
			break;
436
437
		case '3':
438
			return "Bounced";
439
			break;
440
441
		case '4':
442
			return "Reissued";
443
			break;
444
445
	    default :
446
	        return "Recieved";
447
	        break;
448
	}
449
}
450
451
// Get Gender
452
static function getGender($gender)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
453
{
454
	switch ($gender) 
455
	{
456
		case 'm':
457
			return "Male";
458
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
459
		
460
		case 'f':
461
			return "Female";
462
			break;
463
	}
464
}
465
466
467
//Get invoice display name type
468
static function getDisplay($display)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
469
{
470
	switch ($display) 
471
	{
472
		case 'gym_logo':
473
			return "Gym Logo";
474
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
475
		
476
		default:
477
			return "Gym Name";
478
			break;
479
	}
480
}
481
482
483
// Get Numbering mode 
484
static function getMode($mode)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
485
{
486
	switch ($mode) 
487
	{
488
		case '0':
489
			return "Manual";
490
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
491
		
492
		default :
493
			return "Automatic";
494
			break;
495
	}
496
}
497
498
static function getGreeting(){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
499
	//$time = date("H");
500
	$time = Carbon::now()->hour;
501
    /* If the time is less than 1200 hours, show good morning */
502
    if ($time < "12") {
503
        echo "Good morning";
504
    } else
505
    /* If the time is grater than or equal to 1200 hours, but less than 1700 hours, so good afternoon */
506
    if ($time >= "12" && $time < "17") {
507
        echo "Good afternoon";
508
    } else
509
    /* Should the time be between or equal to 1700 and 1900 hours, show good evening */
510
    if ($time >= "17" && $time < "22") {
511
        echo "Good evening";
512
    } else
513
    /* Finally, show good night if the time is greater than or equal to 2200 hours */
514
    if ($time >= "22") {
515
        echo "Good night";
516
    }
517
}
518
519
520
/**
521
*File Upload
522
**/
523
524
	static function uploadFile(Request $request, $prefix, $recordId, $upload_field, $upload_path)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $prefix is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

524
	static function uploadFile(Request $request, /** @scrutinizer ignore-unused */ $prefix, $recordId, $upload_field, $upload_path)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $recordId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

524
	static function uploadFile(Request $request, $prefix, /** @scrutinizer ignore-unused */ $recordId, $upload_field, $upload_path)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
525
		{		
526
		if ($request->hasFile($upload_field)) 
527
			{
528
				$file = $request->file($upload_field);
529
530
	            if ($file->isValid())
531
                {
532
                	File::delete(public_path('assets/img/gym/gym_logo.jpg'));
533
                	$fileName = "gym_logo.jpg";
534
                    $destinationPath = public_path($upload_path);
535
                    $request->file($upload_field)->move($destinationPath,$fileName);
536
                    Image::make($destinationPath."/".$fileName)->resize(600, null, function ($constraint) {
537
																					    $constraint->aspectRatio();
538
																					})->save();
539
                }
540
			}
541
		}
542
543
	static function registrationsTrend()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
544
	{
545
		// Get Financial date
546
		$startDate = new Carbon(Setting::where('key','=','financial_start')->pluck('value'));
547
		$data = array();
548
		
549
		for ($i=1; $i <= 12 ; $i++) { 
550
			//$members = member::registrations($startDate->month,$startDate->year); // Laravel Scoped Query Issue: Workaroud Needed
551
			$members = Member::whereMonth('created_at', '=', $startDate->month)->whereYear('created_at', '=',$startDate->year)->count();
552
			$data[] = array("month" => $startDate->format('Y-m'), "registrations" => $members);
553
			$startDate->addMonth();
554
		}
555
556
		return json_encode($data);
557
	}
558
559
560
	static function membersPerPlan()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
561
	{
562
		$data = array();
563
564
		$plans = Plan::onlyActive()->get();
565
566
		foreach ($plans as $plan) 
567
		{
568
			$subscriptions = Subscription::where('status','=',\constSubscription::onGoing)->where('plan_id','=',$plan->id)->count();
569
			$data[] = array('label' =>$plan->plan_name ,'value'=>$subscriptions);
570
		}
571
		return json_encode($data);		
572
	}
573
574
	// Checking logonutility gateway status
575
	static function smsGatewayStatus()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
576
	{
577
		try
578
		{
579
			$api_key = Utilities::getSetting('sms_api_key');
580
581
			$api_url = "http://logonutility.in/app/miscapi/".$api_key."/getBalance/true/";
582
583
			if(Utilities::isDomainAvailible($api_url))
584
	        {
585
	               return true;
586
	        }
587
	        else
588
	        {
589
	               return false;
590
	        }			
591
						
592
		}
593
		catch(Exception $e)
594
		{
595
			return false;
596
		}
597
	}
598
599
600
   // returns true, if domain is availible, false if not
601
   static function isDomainAvailible($domain)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
602
   {
603
       //check, if a valid url is provided
604
       if(!filter_var($domain, FILTER_VALIDATE_URL))
605
       {
606
               return false;
607
       }
608
609
       //initialize curl
610
       $curlInit = curl_init($domain);
611
       curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
612
       curl_setopt($curlInit,CURLOPT_HEADER,true);
613
       curl_setopt($curlInit,CURLOPT_NOBODY,true);
614
       curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);
615
616
       //get answer
617
       $response = curl_exec($curlInit);
618
619
       curl_close($curlInit);
620
621
       if ($response) return true;
622
623
       return false;
624
   }
625
626
627
	static function Sms($sender_id,$member_contact,$sms_text,$sms_status)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
628
	{
629
		$sms = Utilities::getSetting('sms');
630
		$gatewayStatus = Utilities::smsGatewayStatus();
631
632
		if ($sms && $sms_status) 
633
		{
634
			if($gatewayStatus)
0 ignored issues
show
introduced by
The condition $gatewayStatus can never be true.
Loading history...
635
			{
636
				$api_key = Utilities::getSetting('sms_api_key');
637
				$contacts = $member_contact;
638
				$from = $sender_id;
639
				$send_sms_text = urlencode($sms_text);
640
641
				//Transactional = 20 , Promo with sender id = 21 , only promotional = 18
642
				$api_url = "http://www.logonutility.in/app/smsapi/index.php?key=".$api_key."&campaign=1&routeid=20&type=text&contacts=".$contacts."&senderid=".$from."&msg=".$send_sms_text;
643
644
				//Submit to server
645
				$response = file_get_contents($api_url);
646
647
				if (str_contains($response,'SMS-SHOOT-ID')) 
648
				{
649
					//Log entry for SMS_log table
650
					$SmsLogData = array('shoot_id' => substr($response, strpos($response, "SMS-SHOOT-ID/") + 13),
651
										'number' => $member_contact,
652
										'message' => $sms_text,
653
										'sender_id' => $sender_id,
654
										'send_time' => Carbon::now(),
655
										'status' => 'NA');
656
657
					$SmsLog  = new Sms_log($SmsLogData);
658
					$SmsLog->save();
659
				}
660
				//Update SMS balance
661
				Utilities::smsBalance();
662
			}
663
			else
664
			{
665
				$SmsLogData = array('shoot_id' => '',
666
									'number' => $member_contact,
667
									'message' => $sms_text,
668
									'sender_id' => $sender_id,
669
									'send_time' => Carbon::now(),
670
									'status' => 'offline');
671
672
				$SmsLog  = new Sms_log($SmsLogData);
673
				$SmsLog->save();
674
			}
675
			
676
		}
677
	}
678
679
	static function retrySms($sender_id,$member_contact,$sms_text,$log)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
680
	{
681
		$gatewayStatus = Utilities::smsGatewayStatus();
682
683
		if($gatewayStatus)
0 ignored issues
show
introduced by
The condition $gatewayStatus can never be true.
Loading history...
684
		{
685
			$api_key = Utilities::getSetting('sms_api_key');
686
			$contacts = $member_contact;
687
			$from = $sender_id;
688
			$send_sms_text = urlencode($sms_text);
689
690
			//Transactional = 20 , Promo with sender id = 21 , only promotional = 18
691
			$api_url = "http://www.logonutility.in/app/smsapi/index.php?key=".$api_key."&campaign=1&routeid=21&type=text&contacts=".$contacts."&senderid=".$from."&msg=".$send_sms_text;
692
693
			//Submit to server
694
			$response = file_get_contents($api_url);
695
696
			if (str_contains($response,'SMS-SHOOT-ID')) 
697
			{
698
				//Log entry for SMS_log table
699
				$log->update(['shoot_id' => substr($response, strpos($response, "SMS-SHOOT-ID/") + 13),
700
							  'number' => $member_contact,
701
							  'message' => $sms_text,
702
							  'sender_id' => $sender_id,
703
							  'send_time' => Carbon::now(),
704
							  'status' => 'NA']);
705
				$log->save();
706
			}
707
			//Update SMS balance
708
			Utilities::smsBalance();
709
		}
710
	}
711
712
	static function smsBalance()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
713
	{
714
		$sms = Utilities::getSetting('sms');
715
		$gatewayStatus = Utilities::smsGatewayStatus();
716
717
		if($sms && $gatewayStatus)
0 ignored issues
show
introduced by
The condition $sms && $gatewayStatus can never be true.
Loading history...
718
		{
719
			$api_key = Utilities::getSetting('sms_api_key');
720
721
			$api_url = "http://logonutility.in/app/miscapi/".$api_key."/getBalance/true/";
722
723
			//Submit to server
724
725
			$credit_balance = file_get_contents($api_url);
726
			$balance = json_decode($credit_balance);
727
			Setting::where('key', '=','sms_balance')->update(['value' => $balance[0]->BALANCE]);
728
729
			// If balance turns zero turn off SMS
730
			if($balance[0]->BALANCE == 0)
731
			{
732
				Setting::where('key', '=','sms')->update(['value' => 0]);
733
			}
734
		}
735
	}
736
737
	static function smsStatusUpdate()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
738
	{
739
		$sms = Utilities::getSetting('sms');
740
		$gatewayStatus = Utilities::smsGatewayStatus();
741
742
		if($sms && $gatewayStatus)
0 ignored issues
show
introduced by
The condition $sms && $gatewayStatus can never be true.
Loading history...
743
		{
744
			$api_key = Utilities::getSetting('sms_api_key');
745
			
746
			// Retry Offline Msg
747
			$messages = Sms_log::where('status','offline')->get();
748
		
749
			foreach($messages as $message)
750
			{
751
				Utilities::retrySms($message->sender_id,$message->number,$message->message,$message);
752
			}
753
			
754
			
755
			// Update Status
756
			$messages = Sms_log::whereNotIn('status', ['Delivered','Failed','offline'])->get();
757
758
			foreach($messages as $message)
759
				{
760
					$sms_shoot_id = $message->shoot_id;				
761
					$api_url = "http://logonutility.in/app/miscapi/".$api_key."/getDLR/".$sms_shoot_id;
762
763
					//Submit to server
764
					$response = file_get_contents($api_url);
765
					
766
					
767
					$dlr_array = json_decode($response);
768
769
					//Update Status
770
					$message->status = $dlr_array[0]->DLR;
771
					$message->save();
772
				}
773
		}
774
				
775
	}
776
777
}
778
779
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...