Skip to content

Commit 5436e77

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into develop
2 parents 70499b5 + 764b363 commit 5436e77

File tree

99 files changed

+2527
-1405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2527
-1405
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Bug Report
2+
description: File a bug report.
3+
title: "[Bug]: "
4+
projects: ["grokability/snipe-it"]
5+
type: bug
6+
body:
7+
- type: markdown
8+
attributes:
9+
value: |
10+
Thanks for taking the time to fill out this bug report! Most issues are documented in the [Snipe-IT repository's issues](https://github.com/grokability/snipe-it/issues) or in the official [Common Issues section of the Documentation](https://snipe-it.readme.io/docs/common-issues#/) and are due to the following:
11+
12+
- `.env` misconfiguration
13+
- [Server Permissions](https://snipe-it.readme.io/docs/debugging-permissions#/)
14+
- [Database Migrations](https://snipe-it.readme.io/docs/database-issues#run-migrations)
15+
16+
Please make sure you've checked these resources before submitting a new issue. If you find an existing issue, please add your context to it instead of opening a new issue. If your issue is more of a question, consider [opening a new discussion](https://github.com/grokability/snipe-it/discussions) or [pop by our Discord](https://discord.gg/yZFtShAcKk) instead of creating an issue.
17+
18+
**Please write your bug report in English.** You can use tools like [DeepL](https://www.deepl.com) or [Google Translate](https://translate.google.com/) to translate if necessary.
19+
20+
**If you choose to upload screenshots or videos (which we always encourage), please make sure they do not contain any sensitive information.**
21+
- type: input
22+
id: version
23+
attributes:
24+
label: Snipe-IT Version
25+
description: What version of Snipe-IT are you seeing this issue on? You can find the version number in the footer of any page in Snipe-IT.
26+
placeholder: ex. v8.3.1 - build 19577 (master)
27+
validations:
28+
required: true
29+
- type: input
30+
id: db-version
31+
attributes:
32+
label: MySQL/MariaDB version
33+
description: What database are you using, and what version?
34+
placeholder: ex. MySQL 5.7
35+
validations:
36+
required: true
37+
- type: dropdown
38+
id: install-method
39+
attributes:
40+
label: How did you install Snipe-IT?
41+
options:
42+
- Git install
43+
- Manual install (downloading zip/tar.gz)
44+
- Docker
45+
- install.sh
46+
- Hosted by Grokability
47+
- Other
48+
- Not sure
49+
validations:
50+
required: true
51+
- type: textarea
52+
id: what-happened
53+
attributes:
54+
label: What happened?
55+
description: Also tell us, what did you expect to happen?
56+
placeholder: Tell us what you see! (Be nice!)
57+
validations:
58+
required: true
59+
- type: dropdown
60+
id: browsers
61+
attributes:
62+
label: What browsers are you seeing the problem on?
63+
multiple: true
64+
options:
65+
- Firefox
66+
- Chrome
67+
- Safari
68+
- Microsoft Edge
69+
- Other
70+
- type: textarea
71+
id: server-logs
72+
attributes:
73+
label: Application log output
74+
description: Please copy and paste any relevant log output from `storage/logs/laravel.log`. This will be automatically formatted into code, so no need for backticks.
75+
render: shell
76+
- type: textarea
77+
id: browser-logs
78+
attributes:
79+
label: Browser console output
80+
description: Please copy and paste any relevant log output from your browser console. This will be automatically formatted into code, so no need for backticks.
81+
render: shell
82+
- type: checkboxes
83+
id: common-issues
84+
attributes:
85+
label: Common Issues
86+
description: Please make sure you have done the following before submitting your issue.
87+
options:
88+
- label: I have searched this repo for existing issues related to my issue (including closed issues)
89+
required: true
90+
- label: My APP_URL is set correctly in my .env file (including http or https and no trailing slash)
91+
required: true
92+
- label: I have searched the official Snipe-IT documentation and have checked the Common Issues documentation (where applicable)
93+
required: true
94+
- label: I have run database migrations (where applicable).
95+
required: true
96+
- label: I have attached screenshots and/or videos of the issue (where applicable)
97+
required: true
98+
- type: checkboxes
99+
id: terms
100+
attributes:
101+
label: Code of Conduct
102+
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/grokability/snipe-it/blob/master/CODE_OF_CONDUCT.md).
103+
options:
104+
- label: I agree to follow this project's Code of Conduct
105+
required: true
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Feature Request
2+
description: Request a new feature.
3+
title: "[Feature]: "
4+
projects: ["grokability/snipe-it"]
5+
type: feature
6+
body:
7+
- type: markdown
8+
attributes:
9+
value: |
10+
Thanks for taking the time to fill out this feature request! Please make sure to search the existing issues in this repository to see if your feature has already been requested, and feel free to add your context to any existing requests.
11+
12+
**Please write your issue in English.** You can use tools like [DeepL](https://www.deepl.com) or [Google Translate](https://translate.google.com/) to translate if necessary.
13+
14+
**If you choose to upload screenshots or videos (which we always encourage), please make sure they do not contain any sensitive information.**
15+
- type: input
16+
id: version
17+
attributes:
18+
label: Snipe-IT Version
19+
description: What version of Snipe-IT are you currently running? You can find the version number in the footer of any page in Snipe-IT.
20+
placeholder: ex. v8.3.1 - build 19577 (master)
21+
validations:
22+
required: true
23+
- type: textarea
24+
id: feature-description
25+
attributes:
26+
label: How can we help?
27+
description: Let us know in detail what feature you'd like to see added. While we can't promise to implement every feature request, we do read every one and take them into consideration when planning future releases.
28+
placeholder: Tell us what you'd like to see in Snipe-IT! (Be nice!)
29+
validations:
30+
required: true
31+
- type: checkboxes
32+
id: terms
33+
attributes:
34+
label: Code of Conduct
35+
description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/grokability/snipe-it/blob/master/CODE_OF_CONDUCT.md).
36+
options:
37+
- label: I agree to follow this project's Code of Conduct
38+
required: true

app/Console/Commands/SendExpirationAlerts.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Console\Commands;
44

5+
use App\Helpers\Helper;
56
use App\Mail\ExpiringAssetsMail;
67
use App\Mail\ExpiringLicenseMail;
78
use App\Models\Asset;
@@ -52,19 +53,35 @@ public function handle()
5253
->filter(fn($item) => !empty($item))
5354
->all();
5455
// Expiring Assets
55-
$assets = Asset::getExpiringWarrantee($alert_interval);
56+
$assets = Asset::getExpiringWarrantyOrEol($alert_interval);
5657

5758
if ($assets->count() > 0) {
58-
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
59+
5960
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
61+
62+
$this->table(
63+
['ID', 'Tag', 'Model', 'Model Number', 'EOL', 'EOL Months', 'Warranty Expires', 'Warranty Months'],
64+
$assets->map(fn($item) => ['ID' => $item->id, 'Tag' => $item->asset_tag, 'Model' => $item->model->name, 'Model Number' => $item->model->model_number, 'EOL' => $item->asset_eol_date, 'EOL Months' => $item->model->eol, 'Warranty Expires' => $item->warranty_expires, 'Warranty Months' => $item->warranty_months])
65+
);
6066
}
6167

6268
// Expiring licenses
6369
$licenses = License::getExpiringLicenses($alert_interval);
6470
if ($licenses->count() > 0) {
65-
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
6671
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
72+
73+
$this->table(
74+
['ID', 'Name', 'Expires', 'Termination Date'],
75+
$licenses->map(fn($item) => ['ID' => $item->id, 'Name' => $item->name, 'Expires' => $item->expiration_date, 'Termination Date' => $item->termination_date])
76+
);
6777
}
78+
79+
// Send a message even if the count is 0
80+
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
81+
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
82+
83+
84+
6885
} else {
6986
if ($settings->alert_email == '') {
7087
$this->error('Could not send email. No alert email configured in settings');

app/Helpers/Helper.php

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static function parseEscapedMarkedown($str = null)
9595
$Parsedown->setSafeMode(true);
9696

9797
if ($str) {
98-
return $Parsedown->text($str);
98+
return $Parsedown->text(strip_tags($str));
9999
}
100100
}
101101

@@ -105,7 +105,7 @@ public static function parseEscapedMarkedownInline($str = null)
105105
$Parsedown->setSafeMode(true);
106106

107107
if ($str) {
108-
return $Parsedown->line($str);
108+
return $Parsedown->line(strip_tags($str));
109109
}
110110
}
111111

@@ -435,6 +435,34 @@ public static function defaultChartColors(int $index = 0)
435435
return $colors[$index];
436436
}
437437

438+
/**
439+
* Check if a string has any RTL characters
440+
* @param $value
441+
* @return bool
442+
*/
443+
public static function hasRtl($string) {
444+
$rtlChar = '/[\x{0590}-\x{083F}]|[\x{08A0}-\x{08FF}]|[\x{FB1D}-\x{FDFF}]|[\x{FE70}-\x{FEFF}]/u';
445+
return preg_match($rtlChar, $string) != 0;
446+
}
447+
448+
// is chinese, japanese or korean language
449+
public static function isCjk($string) {
450+
return Helper::isChinese($string) || Helper::isJapanese($string) || Helper::isKorean($string);
451+
}
452+
453+
public static function isChinese($string) {
454+
return preg_match("/\p{Han}+/u", $string);
455+
}
456+
457+
public static function isJapanese($string) {
458+
return preg_match('/[\x{4E00}-\x{9FBF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}]/u', $string);
459+
}
460+
461+
public static function isKorean($string) {
462+
return preg_match('/[\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]/u', $string);
463+
}
464+
465+
438466
/**
439467
* Increases or decreases the brightness of a color by a percentage of the current brightness.
440468
*
@@ -748,7 +776,7 @@ public static function checkLowInventory()
748776
$consumables = Consumable::withCount('consumableAssignments as consumable_assignments_count')->whereNotNull('min_amt')->get();
749777
$accessories = Accessory::withCount('checkouts as checkouts_count')->whereNotNull('min_amt')->get();
750778
$components = Component::whereNotNull('min_amt')->get();
751-
$asset_models = AssetModel::where('min_amt', '>', 0)->with('assets')->get();
779+
$asset_models = AssetModel::where('min_amt', '>', 0)->get();
752780
$licenses = License::where('min_amt', '>', 0)->get();
753781

754782
$items_array = [];
@@ -811,13 +839,11 @@ public static function checkLowInventory()
811839
}
812840
}
813841

842+
foreach ($asset_models as $asset_model){
814843

815-
816-
817-
foreach ($asset_models as $asset_model) {
818-
819-
$total_owned = $asset_model->assets->count();
820-
$avail = $asset_model->assets->whereNull('assets.assigned_to')->count();
844+
$asset = new Asset();
845+
$total_owned = $asset->where('model_id', '=', $asset_model->id)->count();
846+
$avail = $asset->where('model_id', '=', $asset_model->id)->whereNull('assigned_to')->count();
821847

822848
if ($avail < ($asset_model->min_amt) + $alert_threshold) {
823849
if ($avail > 0) {

0 commit comments

Comments
 (0)