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
9785f0e1
Commit
9785f0e1
authored
Nov 13, 2024
by
Sarun Mungthanya
Browse files
Merge remote-tracking branch 'origin/manual-response' into sprint1
parents
6ba75bf3
6f9687de
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/ManualResponse/GenXmlController.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Http\Controllers\ManualResponse
;
use
App\Http\Controllers\Controller
;
use
App\Models\ManualResponse\MasterResponseTemplates
;
use
App\Models\ManualResponse\DeclarationRunning
;
use
Illuminate\Support\Facades\DB
;
use
SimpleXMLElement
;
use
DOMDocument
;
use
Carbon\Carbon
;
class
GenXmlController
extends
Controller
{
public
function
generateXML
(
$templateId
,
$documentType
,
$lockData
)
{
$template
=
MasterResponseTemplates
::
join
(
'mr_master_messages as mm'
,
'mr_master_response_templates.mid'
,
'='
,
'mm.id'
)
->
select
(
'mm.name as messageName'
,
'mr_master_response_templates.id as templateId'
,
'mr_master_response_templates.template'
)
->
where
(
'mr_master_response_templates.id'
,
$templateId
)
->
first
();
if
(
empty
(
$template
))
{
return
null
;
}
$json
=
json_decode
(
$template
[
'template'
],
true
);
if
(
$json
!=
null
){
return
$this
->
genXmlFromTemplate
(
$json
,
$documentType
,
$lockData
);
}
}
private
function
genXmlFromTemplate
(
$json
,
$documentType
=
'0'
,
$lockData
=
true
,
$xml
=
null
,
&
$xmlData
=
[])
{
if
(
$xml
===
null
)
{
$rootElement
=
$json
[
'root'
];
$namespace
=
$json
[
'namespace'
];
unset
(
$json
[
'root'
],
$json
[
'namespace'
]);
if
(
$namespace
!==
''
){
$xml
=
new
SimpleXMLElement
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?><
$rootElement
xmlns=
\"
$namespace
\"
></
$rootElement
>"
);
}
else
{
$xml
=
new
SimpleXMLElement
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?><
$rootElement
></
$rootElement
>"
);
}
}
foreach
(
$json
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
if
(
is_numeric
(
$key
))
{
$key
=
'item'
.
$key
;
// dealing with <0/>..<n/> issues
}
$new_object
=
$xml
->
addChild
(
$key
);
$this
->
genXmlFromTemplate
(
$value
,
$documentType
,
$lockData
,
$new_object
,
$xmlData
);
// Pass by reference
}
else
{
if
(
is_numeric
(
$key
))
{
$key
=
'item'
.
$key
;
// dealing with <0/>..<n/> issues
}
if
(
empty
(
$value
))
{
if
(
!
$lockData
&&
in_array
(
$key
,
[
'DeclarationNumber'
,
'DocumentNumber'
])
&&
$documentType
!==
null
){
$value
=
$this
->
generateDeclarationNo
(
$documentType
);
}
else
if
(
!
$lockData
&&
$key
==
'GoodsTransitionNumber'
){
$value
=
$this
->
generateGCLNo
();
}
if
(
in_array
(
$key
,
[
'AuditDateTime'
])){
$value
=
Carbon
::
now
()
->
setTimezone
(
'GMT+7'
)
->
format
(
'Y-m-d\TH:i:s'
);
}
$child
=
$xml
->
addChild
(
$key
);
$child
[
0
]
=
''
;
// Ensure closed tag for empty value
}
else
{
$xml
->
addChild
(
$key
,
htmlspecialchars
(
$value
));
}
$xmlData
[
$key
]
=
$value
;
// Collect all tags as editable
}
}
$xmlNoData
=
[];
foreach
(
$xmlData
as
$key
=>
$val
){
$xmlNoData
[
$key
]
=
''
;
}
//$this->updateXmlValues($this->formatXml($xml->asXML()), $xmlNoData)
return
[
'xmlContent'
=>
$this
->
formatXml
(
$xml
->
asXML
()),
'xmlWithData'
=>
$xmlData
,
'xmlNoData'
=>
$xmlNoData
];
}
//Convert short tag in case of value is empty to closed tag
private
function
formatXml
(
$xmlString
)
{
$dom
=
new
DOMDocument
(
'1.0'
,
'UTF-8'
);
$dom
->
preserveWhiteSpace
=
false
;
$dom
->
formatOutput
=
true
;
$dom
->
loadXML
(
$xmlString
);
// Ensure empty tags are closed
$xpath
=
new
\
DOMXPath
(
$dom
);
foreach
(
$xpath
->
query
(
'//*[not(*) and not(text())]'
)
as
$node
)
{
$node
->
nodeValue
=
''
;
// Set node value to empty string to ensure closed tag
}
return
$dom
->
saveXML
();
}
public
function
updateXmlValues
(
$xmlString
,
$tagsToUpdate
)
{
$dom
=
new
DOMDocument
(
'1.0'
,
'UTF-8'
);
$dom
->
loadXML
(
$xmlString
);
foreach
(
$tagsToUpdate
as
$tag
=>
$value
)
{
$nodes
=
$dom
->
getElementsByTagName
(
$tag
);
foreach
(
$nodes
as
$node
)
{
$node
->
nodeValue
=
htmlspecialchars
(
$value
);
}
}
return
$dom
->
saveXML
();
}
private
function
generateDeclarationNo
(
$documentType
)
{
$currentDate
=
Carbon
::
now
()
->
toDateString
();
$maxRunningNumber
=
999999
;
$running
=
DB
::
transaction
(
function
()
use
(
$currentDate
,
$maxRunningNumber
,
$documentType
)
{
$runningNumberRecord
=
DeclarationRunning
::
lockForUpdate
()
->
where
(
'document_type'
,
$documentType
)
->
first
();
if
(
$runningNumberRecord
)
{
if
(
$runningNumberRecord
->
last_updated_date
!==
$currentDate
)
{
// Reset the running number if the date has changed
$runningNumberRecord
->
running_number
=
1
;
$runningNumberRecord
->
last_updated_date
=
$currentDate
;
}
elseif
(
$runningNumberRecord
->
running_number
>=
$maxRunningNumber
)
{
// Reset the running number if it reaches the max value
$runningNumberRecord
->
running_number
=
1
;
}
else
{
// Increment the running number
$runningNumberRecord
->
running_number
+=
1
;
}
$runningNumberRecord
->
save
();
}
else
{
// Create a new record if none exists
$runningNumberRecord
=
DeclarationRunning
::
create
([
'running_number'
=>
1
,
'last_updated_date'
=>
$currentDate
,
'document_type'
=>
$documentType
,
]);
}
return
str_pad
(
$runningNumberRecord
->
running_number
,
6
,
'0'
,
STR_PAD_LEFT
);
});
$tmp_declarationNo
=
[
"A"
,
substr
(
$running
,
0
,
1
),
Carbon
::
now
()
->
format
(
'd'
),
$documentType
,
substr
(
Carbon
::
now
()
->
year
+
543
,
-
2
),
Carbon
::
now
()
->
format
(
'm'
),
substr
(
$running
,
-
5
)
];
return
implode
(
''
,
$tmp_declarationNo
);
}
function
generateGCLNo
(){
$currentDate
=
Carbon
::
now
()
->
toDateString
();
$maxRunningNumber
=
9999999
;
$running
=
DB
::
transaction
(
function
()
use
(
$currentDate
,
$maxRunningNumber
)
{
$runningNumberRecord
=
DeclarationRunning
::
lockForUpdate
()
->
where
(
'document_type'
,
"GCL"
)
->
first
();
if
(
$runningNumberRecord
)
{
if
(
$runningNumberRecord
->
last_updated_date
!==
$currentDate
)
{
// Reset the running number if the date has changed
$runningNumberRecord
->
running_number
=
1
;
$runningNumberRecord
->
last_updated_date
=
$currentDate
;
}
elseif
(
$runningNumberRecord
->
running_number
>=
$maxRunningNumber
)
{
// Reset the running number if it reaches the max value
$runningNumberRecord
->
running_number
=
1
;
}
else
{
// Increment the running number
$runningNumberRecord
->
running_number
+=
1
;
}
$runningNumberRecord
->
save
();
}
else
{
// Create a new record if none exists
$runningNumberRecord
=
DeclarationRunning
::
create
([
'running_number'
=>
1
,
'last_updated_date'
=>
$currentDate
,
'document_type'
=>
"GCL"
,
]);
}
return
str_pad
(
$runningNumberRecord
->
running_number
,
7
,
'0'
,
STR_PAD_LEFT
);
});
$tmp_GCLNo
=
[
substr
(
Carbon
::
now
()
->
year
+
543
,
-
2
),
Carbon
::
now
()
->
format
(
'm'
),
"A"
,
$running
];
return
implode
(
''
,
$tmp_GCLNo
);
}
}
app/Http/Controllers/ManualResponse/ManualResponseController.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Http\Controllers\ManualResponse
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
class
ManualResponseController
extends
Controller
{
public
function
index
()
{
//return view('manual-response/index');
$currentContent
=
'ManualResponse'
;
return
view
(
'.home'
,
compact
(
'currentContent'
));
}
}
app/Http/Controllers/ManualResponse/SpnConfigController.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Http\Controllers\ManualResponse
;
use
App\Models\ManualResponse\UsersConnectSpn
;
use
App\Http\Controllers\Controller
;
class
SpnConfigController
extends
Controller
{
public
function
init_connection
(
UsersConnectSpn
$user
)
{
$username
=
$user
->
username
;
$password
=
$user
->
password
;
$link
=
$user
->
link
;
// Initialize cURL
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
"
$link
/spn/login_api.php"
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
// Set the Authorization header for Basic Auth
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
[
'Authorization: Basic '
.
base64_encode
(
"
$username
:
$password
"
),
]);
// Execute cURL request
$response
=
curl_exec
(
$ch
);
$error
=
curl_error
(
$ch
);
// Check for errors
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
//dd($response, $error, $httpCode); //Debug response of cURL
curl_close
(
$ch
);
// Close the cURL handle
if
(
$httpCode
==
'404'
){
return
[
'success'
=>
'false'
,
'message'
=>
'This endpoint does not support this feature. Please contact support for upgrade options.'
];
}
if
(
$error
)
{
return
[
'success'
=>
'false'
,
'message'
=>
'cURL Error: '
.
$error
];
}
// Process the response
$decodedResponse
=
json_decode
(
$response
,
true
);
if
(
json_last_error
()
!==
JSON_ERROR_NONE
)
{
session
()
->
flash
(
'error'
,
'Invalid JSON response'
);
return
null
;
// Handle invalid JSON appropriately
}
return
$decodedResponse
;
// Return the decoded response
}
}
app/Http/Livewire/Pages/ManualResponse/ManualResponse.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Http\Livewire\Pages\ManualResponse
;
use
Illuminate\Support\Facades\Storage
;
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
;
use
App\Models\ManualResponse\TabManualResponseLog
;
use
App\Models\ManualResponse\UsersConnectSpn
;
use
Carbon\Carbon
;
use
CURLFile
;
class
ManualResponse
extends
Component
{
public
$displayCustomizeDiv
=
false
;
public
$messageTypes
=
[];
public
$messageId
;
public
$responseTemplates
=
[];
public
$templateId
;
public
$templateList
;
public
$docTypes
=
[];
public
$docType
;
public
$xmlContent
;
public
$xmlData
=
[];
public
$xmlWithData
=
[];
public
$activeLoader
=
false
;
public
$changeBtnColor
;
public
$lockData
;
public
$disableLockData
=
true
;
public
$structureXML
;
protected
$rules
=
[
'messageId'
=>
'required|string'
,
'templateId'
=>
'required|string'
];
protected
$messages
=
[
'messageId.required'
=>
'*Message cannot be empty.'
,
'templateId.required'
=>
'*Template cannot be empty.'
];
public
function
mount
()
{
$this
->
messageTypes
=
MasterMessages
::
pluck
(
'value'
,
'id'
)
->
toArray
();
$this
->
docTypes
=
MasterDocTypes
::
pluck
(
'name'
,
'code'
)
->
toArray
();
$this
->
changeBtnColor
=
"bg-[#A020F0] hover:bg-[#B34FEF] text-white font-bold"
;
$this
->
lockData
=
false
;
$this
->
disableLockData
=
true
;
}
public
function
render
()
{
if
(
$this
->
messageId
!=
''
)
{
$this
->
responseTemplates
=
MasterResponseTemplates
::
where
(
'mid'
,
$this
->
messageId
)
->
get
()
->
mapWithKeys
(
function
(
$record
)
{
$description
=
$record
->
description
!=
''
?
' '
.
' ('
.
$record
->
description
.
')'
:
''
;
return
[
$record
->
id
=>
$record
->
code
.
': '
.
$record
->
name
.
$description
];
})
->
toArray
();
$this
->
docTypes
=
MasterDocTypes
::
where
(
'mid'
,
$this
->
messageId
)
->
pluck
(
'name'
,
'code'
)
->
toArray
();
}
return
view
(
'livewire.pages.manual-response.manual-response-index'
);
}
public
function
updatedMessageId
()
{
$this
->
templateId
=
''
;
$this
->
responseTemplates
=
[];
$this
->
docTypes
=
[];
$this
->
xmlData
=
[];
$this
->
xmlContent
=
''
;
$this
->
displayCustomizeDiv
=
false
;
}
public
function
updatedXmlTagInputList
()
{
if
(
$this
->
xmlData
===
null
)
{
$this
->
xmlContent
=
''
;
}
}
public
function
gotoCustomize
()
{
$this
->
disableLockData
=
false
;
$tmp_xmlData
=
$this
->
xmlData
;
$this
->
xmlData
=
[];
$this
->
xmlContent
=
''
;
$this
->
validate
();
//Default documentType in case messsage is export/import
if
(
empty
(
$this
->
docType
)){
if
(
$this
->
messageId
==
1
){
$this
->
docType
=
1
;
}
else
if
(
$this
->
messageId
==
2
){
$this
->
docType
=
0
;
}
}
$xmlGenerator
=
new
GenXmlController
();
$xml
=
$xmlGenerator
->
generateXML
(
$this
->
templateId
,
$this
->
docType
,
$this
->
lockData
);
if
(
$xml
==
null
)
{
session
()
->
flash
(
'templateNotFound'
,
'Template is not found!'
);
}
else
{
$this
->
displayCustomizeDiv
=
true
;
$this
->
xmlContent
=
$xml
[
'xmlContent'
];
$this
->
xmlData
=
$xml
[
'xmlWithData'
];
if
(
$this
->
lockData
){
foreach
(
$this
->
xmlData
as
$key
=>
$val
){
if
(
isset
(
$tmp_xmlData
[
$key
])
&&
$key
!=
'Message'
){
$this
->
xmlData
[
$key
]
=
$tmp_xmlData
[
$key
];
}
}
}
$this
->
reGenerateXML
();
}
$this
->
changeBtnColor
=
"bg-slate-150 font-medium text-slate-800 hover:bg-slate-200 focus:bg-slate-200 active:bg-slate-200/80 rounded-md border border-[#e5e7eb] "
;
}
public
function
reGenerateXML
()
{
$xmlGenerator
=
new
GenXmlController
();
$xml
=
$xmlGenerator
->
updateXmlValues
(
$this
->
xmlContent
,
$this
->
xmlData
);
$this
->
xmlContent
=
$xml
;
}
public
function
mockUpXML
()
{
$this
->
xmlData
=
$this
->
xmlWithData
;
}
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
();
$filename
=
'manual_response_'
.
$now
->
format
(
'Ymd_His'
)
.
".xml"
;
Storage
::
disk
(
'local'
)
->
put
(
$filename
,
$this
->
xmlContent
);
$filePath
=
storage_path
(
'app/'
.
$filename
);
$currentUser
=
Auth
::
user
();
$userConnect
=
UsersConnectSpn
::
where
(
'uid'
,
$currentUser
->
id
)
->
first
();
if
(
!
isset
(
$userConnect
)){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'SPN config is not found!'
,
'status'
=>
'failed'
]);
return
;
}
$spnConfigController
=
new
SpnConfigController
();
$spnConfig
=
$spnConfigController
->
init_connection
(
$userConnect
);
if
(
$spnConfig
!=
null
&&
$spnConfig
[
'success'
]
==
'true'
){
$uid
=
$spnConfig
[
'uid'
];
$ucode
=
$spnConfig
[
'ucode'
];
$ch
=
curl_init
();
$cfile
=
new
CURLFile
(
$filePath
,
'application/xml'
,
$filename
);
$postData
=
[
'UID'
=>
$uid
,
'UCODE'
=>
$ucode
,
'SERVICENAME'
=>
'imcoreservice'
,
'ACTION'
=>
'get_response_customs'
,
'profilecode'
=>
''
,
'API_PLACE_FILE'
=>
'Y'
,
'file'
=>
$cfile
];
curl_setopt
(
$ch
,
CURLOPT_URL
,
$userConnect
->
link
.
"/IE5DEV.shippingnet/data_defaulttemplate.php"
);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$postData
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_exec
(
$ch
);
$error
=
curl_error
(
$ch
);
curl_close
(
$ch
);
TabManualResponseLog
::
create
([
'uid'
=>
$currentUser
->
id
,
'title'
=>
'Send Manual Response'
,
'detail'
=>
"Username: "
.
$userConnect
->
username
.
"
\n
Link: "
.
$userConnect
->
link
,
'xml_content'
=>
base64_encode
(
$this
->
xmlContent
),
'reference_number'
=>
$this
->
xmlData
[
'ReferenceNumber'
],
'declaration_number'
=>
$this
->
xmlData
[
'DeclarationNumber'
],
'link'
=>
$userConnect
->
link
]);
if
(
$error
)
{
//Cannot send response to SPN
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Cannot send response to SPN'
,
'status'
=>
'failed'
]);
}
else
{
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Send response successfully'
,
'status'
=>
'success'
]);
Storage
::
disk
(
'local'
)
->
delete
(
$filename
);
}
}
else
if
(
$spnConfig
!=
null
&&
$spnConfig
[
'success'
]
==
'false'
){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
$spnConfig
[
'message'
],
'status'
=>
'failed'
]);
}
else
{
//Cannot get UID/UCODE from SPN
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Cannot connect to SPN'
,
'status'
=>
'failed'
]);
}
}
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/Http/Livewire/Pages/User/ConfigManualResponse.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Http\Livewire\Pages\User
;
use
App\Models\User
;
use
App\Models\ManualResponse\UsersConnectSpn
;
use
App\Http\Controllers\ManualResponse\SpnConfigController
;
use
Livewire\Component
;
class
ConfigManualResponse
extends
Component
{
public
$editUserId
;
public
$editUsername
;
public
$usernameSPN
;
public
$passwordSPN
;
public
$linkSPN
;
public
$action
;
public
function
mount
(
$editUserId
)
{
$this
->
editUserId
=
$editUserId
;
$currentUser
=
User
::
find
(
$editUserId
);
$this
->
editUsername
=
$currentUser
->
first_name
;
$userConnectSpn
=
UsersConnectSpn
::
where
(
'uid'
,
$editUserId
)
->
first
();
if
(
$userConnectSpn
){
$this
->
usernameSPN
=
$userConnectSpn
->
username
;
$this
->
passwordSPN
=
""
;
$this
->
linkSPN
=
$userConnectSpn
->
link
;
}
}
public
function
updateConfig
()
{
if
(
empty
(
$this
->
usernameSPN
)){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Username must not be empty!'
,
'status'
=>
'warning'
]);
return
;
}
$userConnectSpn
=
UsersConnectSpn
::
where
(
'uid'
,
$this
->
editUserId
)
->
first
();
if
(
$userConnectSpn
){
if
(
!
empty
(
$this
->
passwordSPN
)){
$userConnectSpn
->
password
=
password_hash
(
$this
->
passwordSPN
,
PASSWORD_BCRYPT
);
}
$userConnectSpn
->
username
=
$this
->
usernameSPN
;
$userConnectSpn
->
link
=
$this
->
linkSPN
;
$userConnectSpn
->
save
();
}
else
{
UsersConnectSpn
::
create
([
'uid'
=>
$this
->
editUserId
,
'username'
=>
$this
->
usernameSPN
,
'password'
=>
''
,
"link"
=>
$this
->
linkSPN
]);
}
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Update config successfully'
,
'status'
=>
'success'
]);
}
public
function
render
()
{
return
view
(
'livewire.pages.user.config-manual-response'
);
}
public
function
backToMainList
()
{
//Use emitTo() to call function on specific component, (emit() will call function on every loaded compoment)
$this
->
emitTo
(
'pages.user.user-index'
,
'showUserList'
,
''
);
}
public
function
testConnection
()
{
//Use emitTo() to call function on specific component, (emit() will call function on every loaded compoment)
$userConnect
=
UsersConnectSpn
::
where
(
'uid'
,
$this
->
editUserId
)
->
first
();
if
(
!
isset
(
$userConnect
)){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'SPN config is not found!'
,
'status'
=>
'failed'
]);
return
;
}
$spnConfigController
=
new
SpnConfigController
();
$spnConfig
=
$spnConfigController
->
init_connection
(
$userConnect
);
if
(
$spnConfig
!=
null
&&
$spnConfig
[
'success'
]
==
'true'
){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Connect to SPN successfully'
,
'status'
=>
'success'
]);
}
else
if
(
$spnConfig
!=
null
&&
$spnConfig
[
'success'
]
==
'false'
){
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
$spnConfig
[
'message'
],
'status'
=>
'failed'
]);
}
else
{
//Cannot get UID/UCODE from SPN
$this
->
dispatchBrowserEvent
(
'open-modal'
,
[
'name'
=>
'alert-modal'
,
'message'
=>
'Cannot connect to SPN'
,
'status'
=>
'failed'
]);
}
}
}
app/Http/Livewire/Pages/User/UserIndex.php
View file @
9785f0e1
...
...
@@ -82,6 +82,17 @@ class UserIndex extends Component
$this
->
editUserId
=
$UserId
;
}
public
function
showConfigManualResponseForm
(
$UserId
)
{
if
(
!
Auth
::
user
()
->
hasPermissions
([
'edit-user'
]))
{
$this
->
showNoPermissionModal
=
TRUE
;
return
;
}
$this
->
action
=
'configManualResponse'
;
$this
->
editUserId
=
$UserId
;
}
public
function
hideMessage
()
{
$this
->
showMessage
=
false
;
...
...
app/Models/ConfListProfile.php
0 → 100644
View file @
9785f0e1
<?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'
,
];
}
app/Models/ManualResponse/DeclarationRunning.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Models\ManualResponse
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
DeclarationRunning
extends
Model
{
use
HasFactory
;
protected
$table
=
'mr_declaration_running'
;
protected
$fillable
=
[
'document_type'
,
'running_number'
,
'last_updated_date'
];
}
app/Models/ManualResponse/MasterDocTypes.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Models\ManualResponse
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
MasterDocTypes
extends
Model
{
use
HasFactory
;
protected
$table
=
'mr_master_doc_types'
;
}
app/Models/ManualResponse/MasterMessages.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Models\ManualResponse
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
MasterMessages
extends
Model
{
use
HasFactory
;
protected
$table
=
'mr_master_messages'
;
}
app/Models/ManualResponse/MasterResponseTemplates.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Models\ManualResponse
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
MasterResponseTemplates
extends
Model
{
use
HasFactory
;
protected
$table
=
'mr_master_response_templates'
;
}
app/Models/ManualResponse/TabManualResponseLog.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Models\ManualResponse
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
TabManualResponseLog
extends
Model
{
use
HasFactory
;
protected
$table
=
'mr_tab_manual_response_log'
;
protected
$fillable
=
[
'uid'
,
'title'
,
'detail'
,
'xml_content'
,
'reference_number'
,
'declaration_number'
,
'link'
,
];
}
app/Models/ManualResponse/UsersConnectSpn.php
0 → 100644
View file @
9785f0e1
<?php
namespace
App\Models\ManualResponse
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Model
;
class
UsersConnectSpn
extends
Model
{
use
HasFactory
;
protected
$table
=
'mr_users_connect_spn'
;
protected
$fillable
=
[
'uid'
,
'username'
,
'password'
,
'link'
,
];
protected
$hidden
=
[
'password'
];
}
database/migrations/2024_05_31_045136_create_master_messages.php
0 → 100644
View file @
9785f0e1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'mr_master_messages'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'name'
);
$table
->
string
(
'value'
);
$table
->
timestamps
();
});
DB
::
table
(
'mr_master_messages'
)
->
insert
([
[
'name'
=>
'export'
,
'value'
=>
'EXPORT'
,
],
[
'name'
=>
'import'
,
'value'
=>
'IMPORT'
,
],
[
'name'
=>
'gcl'
,
'value'
=>
'GCL'
,
],
[
'name'
=>
'short'
,
'value'
=>
'SHORT'
,
]
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mr_master_messages'
);
}
};
database/migrations/2024_05_31_045505_create_master_response_templates.php
0 → 100644
View file @
9785f0e1
This diff is collapsed.
Click to expand it.
database/migrations/2024_06_01_112857_create_declaration_runnings_table.php
0 → 100644
View file @
9785f0e1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'mr_declaration_running'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'document_type'
);
$table
->
integer
(
'running_number'
)
->
default
(
0
);
$table
->
date
(
'last_updated_date'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mr_declaration_runnings'
);
}
};
database/migrations/2024_06_03_042652_create_master_doc_types_table.php
0 → 100644
View file @
9785f0e1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'mr_master_doc_types'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedBigInteger
(
'mid'
);
$table
->
string
(
'code'
);
$table
->
string
(
'name'
);
$table
->
string
(
'mode'
);
$table
->
timestamps
();
$table
->
foreign
(
'mid'
)
->
references
(
'id'
)
->
on
(
'master_messages'
)
->
onDelete
(
'cascade'
);
});
DB
::
table
(
'mr_master_doc_types'
)
->
insert
([
[
'mid'
=>
'2'
,
'code'
=>
'0'
,
'name'
=>
'0-ใบขนสินค้าขาเข้า'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'2'
,
'name'
=>
'2-ใบขนสินค้าผ่านแดน (Transit)'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'3'
,
'name'
=>
'3-คำร้องขอรับของไปก่อน'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'5'
,
'name'
=>
'5-ใบขนสินค้าขาเข้าปากระวาง'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'8'
,
'name'
=>
'8-ใบขนสินค้าถ่ายลำ (Transhipment)'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'A'
,
'name'
=>
'A-ใบขนสินค้าขาเข้าโอนย้ายในประเทศ'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'C'
,
'name'
=>
'C-ใบขนสินค้าขาเข้าโอนย้ายจากเขตปลอดอากร'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'1'
,
'name'
=>
'1-ใบขนสินค้าขาออก'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'4'
,
'name'
=>
'4-คำร้องขอออกของไปก่อน'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'B'
,
'name'
=>
'B-ใบขนสินค้าขาออกโอนย้ายภายในประเทศ'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'D'
,
'name'
=>
'D-ใบขนสินค้าขาออกโอนย้ายเข้าเขตปลอดอากร'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'6'
,
'name'
=>
'6-ใบขนสินค้าพิเศษผ่านแดนขาออก'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'H'
,
'name'
=>
'H-คำร้องขอนำออกนอกเขตอารักขาศุลกากร'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'1'
,
'code'
=>
'Y'
,
'name'
=>
'Y-ใบขนสินค้าขาออกเร่งด่วน'
,
'mode'
=>
'EXDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'X'
,
'name'
=>
'X-ใบขนสินค้าขาเข้าเร่งด่วน'
,
'mode'
=>
'IMDECL'
],
[
'mid'
=>
'2'
,
'code'
=>
'P'
,
'name'
=>
'P-ใบขนสินค้าขาเข้าโอนย้ายชำระค่าภาษีอากร'
,
'mode'
=>
'IMDECL'
],
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mr_master_doc_types'
);
}
};
database/migrations/2024_07_16_080941_add_deleted_at_column_to_users_table.php
View file @
9785f0e1
...
...
@@ -14,7 +14,7 @@ return new class extends Migration
public
function
up
()
{
Schema
::
table
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
softDeletes
();
$table
->
softDeletes
();
});
}
...
...
@@ -26,7 +26,7 @@ return new class extends Migration
public
function
down
()
{
Schema
::
table
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
dropSoftDeletes
();
$table
->
dropSoftDeletes
();
});
}
};
database/migrations/2024_08_02_080655_create_users_connect_spn_table.php
0 → 100644
View file @
9785f0e1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'mr_users_connect_spn'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedBigInteger
(
'uid'
);
$table
->
string
(
'username'
);
$table
->
string
(
'password'
);
$table
->
string
(
'link'
);
$table
->
timestamps
();
$table
->
foreign
(
'uid'
)
->
references
(
'id'
)
->
on
(
'users'
)
->
onDelete
(
'cascade'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mr_users_connect_spn'
);
}
};
database/migrations/2024_08_05_085118_tab_manual_response_log.php
0 → 100644
View file @
9785f0e1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'mr_tab_manual_response_log'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedBigInteger
(
'uid'
);
$table
->
string
(
'title'
);
$table
->
string
(
'detail'
);
$table
->
text
(
'xml_content'
);
$table
->
string
(
'reference_number'
);
$table
->
string
(
'declaration_number'
);
$table
->
string
(
'link'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mr_tab_manual_response_log'
);
}
};
Prev
1
2
Next
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