Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sarun Mungthanya
SpnPatch-Laravel
Commits
9d47970b
Commit
9d47970b
authored
Nov 13, 2024
by
Chanon.u
Browse files
Add validate profile production on reference no
parent
6ef4272c
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/Http/Livewire/Pages/ManualResponse/ManualResponse.php
View file @
9d47970b
...
...
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Auth;
use
Livewire\Component
;
use
App\Http\Controllers\ManualResponse\GenXmlController
;
use
App\Http\Controllers\ManualResponse\SpnConfigController
;
use
App\Models\ConfListProfile
;
use
App\Models\ManualResponse\MasterMessages
;
use
App\Models\ManualResponse\MasterResponseTemplates
;
use
App\Models\ManualResponse\MasterDocTypes
;
...
...
@@ -144,6 +145,14 @@ class ManualResponse extends Component
public
function
generateAndUploadXml
()
{
$this
->
reGenerateXML
();
if
(
!
$this
->
validateBeforeSend
(
$this
->
xmlContent
)){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Profile production is not allowed.'
,
'status'
=>
'failed'
]);
return
;
}
// Generate XML file from string
$now
=
Carbon
::
now
();
...
...
@@ -231,4 +240,13 @@ class ManualResponse extends Component
]);
}
}
private
function
validateBeforeSend
(){
$referenceNo
=
$this
->
xmlData
[
'ReferenceNumber'
];
$profileProds
=
ConfListProfile
::
where
(
'type'
,
'PROD'
)
->
pluck
(
'name'
)
->
toArray
();
if
(
isset
(
$referenceNo
)
&&
in_array
(
substr
(
$referenceNo
,
0
,
1
),
$profileProds
)){
return
false
;
}
return
true
;
}
}
app/Models/ConfListProfile.php
0 → 100644
View file @
9d47970b
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
ConfListProfile
extends
Model
{
use
HasFactory
;
protected
$table
=
'conf_list_profiles'
;
protected
$fillable
=
[
'id'
,
'name'
,
'type'
,
'desc'
,
];
}
database/migrations/2024_11_13_083310_create_conf_list_profiles_table.php
0 → 100644
View file @
9d47970b
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\DB
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'conf_list_profiles'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'name'
);
$table
->
string
(
'type'
);
$table
->
string
(
'desc'
);
$table
->
timestamps
();
});
DB
::
table
(
'conf_list_profiles'
)
->
insert
([
[
'name'
=>
'D'
,
'type'
=>
'PROD'
,
'desc'
=>
''
],
[
'name'
=>
'P'
,
'type'
=>
'PROD'
,
'desc'
=>
''
],
[
'name'
=>
'Q'
,
'type'
=>
'PROD'
,
'desc'
=>
''
],
[
'name'
=>
'A'
,
'type'
=>
'TEST'
,
'desc'
=>
''
],
[
'name'
=>
'B'
,
'type'
=>
'TEST'
,
'desc'
=>
''
],
[
'name'
=>
'H'
,
'type'
=>
'TEST'
,
'desc'
=>
''
]
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'conf_list_profiles'
);
}
};
resources/js/app.js
View file @
9d47970b
...
...
@@ -30,11 +30,11 @@ import 'quill/dist/quill.snow.css';
import
flatpickr
from
'
flatpickr
'
;
import
Tom
from
'
tom-select/dist/js/tom-select.complete.min
'
;
import
"
@fortawesome/fontawesome-free/css/all.css
"
;
import
Prism
from
'
prismjs
'
;
import
'
prismjs/themes/prism.css
'
;
import
'
prismjs/components/prism-diff.min.js
'
;
import
'
prismjs/plugins/line-numbers/prism-line-numbers.css
'
;
import
'
prismjs/plugins/line-numbers/prism-line-numbers.js
'
;
//
import Prism from 'prismjs';
//
import 'prismjs/themes/prism.css';
//
import 'prismjs/components/prism-diff.min.js';
//
import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
//
import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
import
ClassicEditor
from
'
@ckeditor/ckeditor5-build-classic
'
;
// Helper Functions
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment