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
220539c0
Commit
220539c0
authored
Nov 28, 2024
by
Chanon.u
Browse files
Merge remote-tracking branch 'origin/manual-response' into sprint1
parents
9785f0e1
1e3249a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/ManualResponse/SpnConfigController.php
View file @
220539c0
...
@@ -30,6 +30,14 @@ class SpnConfigController extends Controller
...
@@ -30,6 +30,14 @@ class SpnConfigController extends Controller
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
//dd($response, $error, $httpCode); //Debug response of cURL
//dd($response, $error, $httpCode); //Debug response of cURL
if
(
$error
)
{
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// Disable peer verification
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
false
);
// Disable host verification
$response
=
curl_exec
(
$ch
);
$error
=
curl_error
(
$ch
);
// Check for errors
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
}
curl_close
(
$ch
);
// Close the cURL handle
curl_close
(
$ch
);
// Close the cURL handle
if
(
$httpCode
==
'404'
){
if
(
$httpCode
==
'404'
){
...
...
app/Http/Livewire/Pages/ManualResponse/ManualResponse.php
View file @
220539c0
...
@@ -41,6 +41,8 @@ class ManualResponse extends Component
...
@@ -41,6 +41,8 @@ class ManualResponse extends Component
public
$disableLockData
=
true
;
public
$disableLockData
=
true
;
public
$structureXML
;
public
$structureXML
;
public
$disableDocType
=
false
;
protected
$rules
=
[
protected
$rules
=
[
'messageId'
=>
'required|string'
,
'messageId'
=>
'required|string'
,
'templateId'
=>
'required|string'
'templateId'
=>
'required|string'
...
@@ -78,9 +80,15 @@ class ManualResponse extends Component
...
@@ -78,9 +80,15 @@ class ManualResponse extends Component
$this
->
templateId
=
''
;
$this
->
templateId
=
''
;
$this
->
responseTemplates
=
[];
$this
->
responseTemplates
=
[];
$this
->
docTypes
=
[];
$this
->
docTypes
=
[];
$this
->
docType
=
''
;
$this
->
xmlData
=
[];
$this
->
xmlData
=
[];
$this
->
xmlContent
=
''
;
$this
->
xmlContent
=
''
;
$this
->
displayCustomizeDiv
=
false
;
$this
->
displayCustomizeDiv
=
false
;
if
(
$this
->
messageId
==
3
||
$this
->
messageId
==
4
){
$this
->
disableDocType
=
true
;
}
else
{
$this
->
disableDocType
=
false
;
}
}
}
public
function
updatedXmlTagInputList
()
public
function
updatedXmlTagInputList
()
...
@@ -196,7 +204,7 @@ class ManualResponse extends Component
...
@@ -196,7 +204,7 @@ class ManualResponse extends Component
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$postData
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$postData
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
$result
=
curl_exec
(
$ch
);
$error
=
curl_error
(
$ch
);
$error
=
curl_error
(
$ch
);
curl_close
(
$ch
);
curl_close
(
$ch
);
...
@@ -212,33 +220,30 @@ class ManualResponse extends Component
...
@@ -212,33 +220,30 @@ class ManualResponse extends Component
if
(
$error
)
{
if
(
$error
)
{
//Cannot send response to SPN
//Cannot send response to SPN
$
this
->
dispatchBrowserEvent
(
'open-modal'
,
[
$
alertMessage
=
$error
;
'name'
=
>
'
alert-modal'
,
$alertStatus
=
'
failed'
;
'message'
=>
'Cannot s
end
res
ponse to SPN'
,
}
elseif
(
!
$this
->
validateAfterS
end
(
$
res
ult
))
{
'status'
=>
'failed'
$alertMessage
=
'Unable to upload the file to SPN.<br>Please ensure the INBOX folder is properly set up before retrying.'
;
])
;
$alertStatus
=
'failed'
;
}
else
{
}
else
{
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
$alertMessage
=
'Send response successfully'
;
'name'
=>
'alert-modal'
,
$alertStatus
=
'success'
;
'message'
=>
'Send response successfully'
,
'status'
=>
'success'
]);
Storage
::
disk
(
'local'
)
->
delete
(
$filename
);
}
}
Storage
::
disk
(
'local'
)
->
delete
(
$filename
);
}
else
if
(
$spnConfig
!=
null
&&
$spnConfig
[
'success'
]
==
'false'
){
}
else
if
(
$spnConfig
!=
null
&&
$spnConfig
[
'success'
]
==
'false'
){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
$alertMessage
=
$spnConfig
[
'message'
];
'name'
=>
'alert-modal'
,
$alertStatus
=
'failed'
;
'message'
=>
$spnConfig
[
'message'
],
'status'
=>
'failed'
]);
}
else
{
}
else
{
//Cannot get UID/UCODE from SPN
//Cannot get UID/UCODE from SPN
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
$alertMessage
=
'Cannot connect to SPN'
;
'name'
=>
'alert-modal'
,
$alertStatus
=
'failed'
;
'message'
=>
'Cannot connect to SPN'
,
'status'
=>
'failed'
]);
}
}
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
$alertMessage
,
'status'
=>
$alertStatus
]);
}
}
private
function
validateBeforeSend
(){
private
function
validateBeforeSend
(){
...
@@ -249,4 +254,11 @@ class ManualResponse extends Component
...
@@ -249,4 +254,11 @@ class ManualResponse extends Component
}
}
return
true
;
return
true
;
}
}
private
function
validateAfterSend
(
$result
){
if
(
str_starts_with
(
$result
,
'Sorry, there was an error moving the file.'
)){
return
false
;
}
return
true
;
}
}
}
resources/views/components/modals/alert-modal.blade.php
View file @
220539c0
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
</
template
>
</
template
>
<
div
class
=
"mt-4"
>
<
div
class
=
"mt-4"
>
<
p
class
=
"mt-2"
x
-
text
=
"message"
></
p
>
<
p
class
=
"mt-2"
x
-
html
=
"message"
></
p
>
<
button
@
click
=
"showModal = false"
<
button
@
click
=
"showModal = false"
class
=
"btn mt-6 bg-gray-200 font-medium text-gray-700 hover:bg-gray-200-focus focus:bg-gray-200-focus active:bg-gray-200-focus/90"
>
class
=
"btn mt-6 bg-gray-200 font-medium text-gray-700 hover:bg-gray-200-focus focus:bg-gray-200-focus active:bg-gray-200-focus/90"
>
Close
Close
...
...
resources/views/livewire/pages/manual-response/manual-response-index.blade.php
View file @
220539c0
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
<span
class=
"relative mt-1.5 mb-0.1 flex"
>
<span
class=
"relative mt-1.5 mb-0.1 flex"
>
<select
<select
class=
"form-select h-9 w-full rounded-lg border border-slate-300 bg-white px-3 py-2 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:bg-navy-700 dark:hover:border-navy-400 dark:focus:border-accent"
class=
"form-select h-9 w-full rounded-lg border border-slate-300 bg-white px-3 py-2 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:bg-navy-700 dark:hover:border-navy-400 dark:focus:border-accent"
wire:model.defer=
"docType"
>
wire:model.defer=
"docType"
{{
$
disableDocType
?
'
disabled
'
:
''
}}
>
<option
value=
""
>
Select an option
</option>
<option
value=
""
>
Select an option
</option>
@foreach ($docTypes as $value => $label)
@foreach ($docTypes as $value => $label)
<option
value=
"{{ $value }}"
>
{{ $label }}
</option>
<option
value=
"{{ $value }}"
>
{{ $label }}
</option>
...
...
resources/views/livewire/pages/user/config-manual-response.blade.php
View file @
220539c0
...
@@ -19,12 +19,6 @@
...
@@ -19,12 +19,6 @@
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Username on SPN"
wire:model.defer=
"usernameSPN"
autocomplete=
"off"
>
placeholder=
"Username on SPN"
wire:model.defer=
"usernameSPN"
autocomplete=
"off"
>
</div>
</div>
<div
class=
"mb-2"
style=
"display: none;"
>
<label
for=
"first_name"
class=
"block text-sm font-medium text-gray-700"
>
Password: SPN
</label>
<input
type=
"password"
id=
"passwordSPN"
class=
"mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder=
"Password on SPN"
wire:model.defer=
"passwordSPN"
autocomplete=
"off"
>
</div>
<div
class=
"mb-2"
x-show=
"showPasswordField"
style=
"display: none;"
>
<div
class=
"mb-2"
x-show=
"showPasswordField"
style=
"display: none;"
>
<label
for=
"first_name"
class=
"block text-sm font-medium text-gray-700"
>
Password: SPN
</label>
<label
for=
"first_name"
class=
"block text-sm font-medium text-gray-700"
>
Password: SPN
</label>
<input
type=
"password"
id=
"passwordSPN"
<input
type=
"password"
id=
"passwordSPN"
...
@@ -35,7 +29,7 @@
...
@@ -35,7 +29,7 @@
<div
class=
"flex w-full mt-5"
>
<div
class=
"flex w-full mt-5"
>
<div
class=
"ml-auto flex space-x-2 w-3/4 justify-end"
>
<div
class=
"ml-auto flex space-x-2 w-3/4 justify-end"
>
<button
class=
"w-1/4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
type=
"button"
wire:click=
"backToMainList"
>
Back
</button>
<button
class=
"w-1/4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
type=
"button"
wire:click=
"backToMainList"
>
Back
</button>
<button
class=
"w-1/4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
type=
"button"
@
click=
"showPasswordField = !showPasswordField"
>
C
hange
Password
</button>
<button
class=
"w-1/4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
type=
"button"
@
click=
"showPasswordField = !showPasswordField"
>
C
onfig
Password
</button>
<button
class=
"w-1/4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
type=
"button"
wire:click=
"testConnection"
>
Test Connection
</button>
<button
class=
"w-1/4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400"
type=
"button"
wire:click=
"testConnection"
>
Test Connection
</button>
<button
class=
"w-1/4 py-2 bg-primary text-white rounded-md shadow-sm hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"
type=
"submit"
>
Save
</button>
<button
class=
"w-1/4 py-2 bg-primary text-white rounded-md shadow-sm hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary"
type=
"submit"
>
Save
</button>
</div>
</div>
...
...
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