modalLoaded = true; } public function mount($editId) { $this->licenseId = '1'; $this->loadData(); } public function loadData() { $license = ConfServerLicense::find($this->licenseId); if ($license) { $this->serverKey = $license->SNKEY; $this->teamId = $license->NBTEAM; $this->customerSize = $license->CUSTOMERSIZE; $this->customerType = $license->CUSTOMERTYPE; $this->company = $license->COMPANY; $this->branch = $license->BRANCH; $this->status = $license->STATUS; $this->licenseDate = $license->LICENSEDATE; $this->phpVersionId = $license->PHP_VERSION_ID; $this->currentVersion = $license->CUR_VERSION; $this->installDate = $license->INSTALL_DATE; $this->installVersion = $license->INSTALL_VERSION; $this->databaseType = $license->DATABASETYPE; $this->ownerType = $license->OWNERTYPE; $this->hscodeMethod = $license->HSCODEMETHOD; $this->customerUrl = $license->CUSTOMERURL; $this->contact = $license->CONTACT; $this->contactCustomerName = $license->CONTACTCUSTOMERNAME; if ($license && !empty($license->BACKUP_FEEDBACK)) { $compressedData = gzuncompress(base64_decode($license->BACKUP_FEEDBACK)); $this->backupFeedback = $compressedData; // $utf8Data = iconv('TIS-620', 'UTF-8', $compressedData); $this->info = null; eval('$this->info = ' . trim($compressedData) . ';'); $this->mappingList = $this->info['DATA']['conf_mapping']; foreach ($this->mappingList['mapConfig'] as $index => $config) { $this->mappingList['mapConfig'][$index] = base64_decode($config); } if ($this->info && isset($this->info['DATA']['conf_label_form'])) { $this->labelList = $this->info['DATA']['conf_label_form']; } if ($this->info && isset($this->info['DATA']['conf_ui'])) { $this->userInterfaceList = $this->info['DATA']['conf_ui']; } if ($this->info && isset($this->info['DATA']['conf_global'])) { $this->globalList = $this->info['DATA']['conf_global']; } } } $this->phpVersions = DB::table('master_php_ver') ->orderBy('id', 'asc') ->get(); $this->teams = DB::table('master_team') ->orderBy('id', 'asc') ->get(); $this->sizings = DB::table('master_size') ->orderBy('id', 'asc') ->get(); $this->customerTypes = DB::table('master_sizeType') ->orderBy('id', 'asc') ->get(); $this->dbTypes = DB::table('master_dbtype') ->orderBy('id', 'asc') ->get(); $this->ownerTypes = DB::table('conf_server_ownertype') ->orderBy('owntypeid', 'asc') ->get(); } public function updateLicense() { // dd( $this->teamId); $license = ConfServerLicense::find($this->licenseId); if ($license) { $license->update([ 'SNKEY' => $this->serverKey, 'NBTEAM' => $this->teamId, 'CUSTOMERSIZE' => $this->customerSize, 'CUSTOMERTYPE' => $this->customerType, 'COMPANY' => $this->company, 'BRANCH' => $this->branch, 'STATUS' => $this->status, 'LICENSEDATE' => $this->licenseDate, 'PHP_VERSION_ID' => $this->phpVersionId, 'CUR_VERSION' => $this->currentVersion, 'INSTALL_DATE' => $this->installDate, 'INSTALL_VERSION' => $this->installVersion, 'DATABASETYPE' => $this->databaseType, 'OWNERTYPE' => $this->ownerType, 'HSCODEMETHOD' => $this->hscodeMethod, 'CUSTOMERURL' => $this->customerUrl, 'CONTACT' => $this->contact, 'CONTACTCUSTOMERNAME' => $this->contactCustomerName, ]); $message = 'Server License updated successfully!'; $this->message = $message; // session()->flash('message', 'Server License updated successfully!'); } } public function loadPage($page) { $this->emit('menuChanged', $page); } public function updatedSelectDateOrg() { $this->loadOrganize(); } public function loadOrganize() { $this->tab = 'organize'; $license = ConfServerLicense::find($this->licenseId); $this->SNKEY = $license->SNKEY; $this->allDate = DB::table('conf_server_license_orgcontrol') ->select('id', 'createDate') ->where('SNKEY', $this->SNKEY) ->orderByDesc('id') ->get(); if (empty($this->selectDateOrg)) { if (isset($this->allDate)) { foreach ($this->allDate as $date) { $this->selectDateOrg = $date->id ?? ''; break; } } } $this->orgList = DB::table('conf_server_license_orglist') ->where('controlId', $this->selectDateOrg) ->orderBy('id') ->get() ->toArray(); foreach ($this->orgList as $orgData) { $profileList = DB::table('conf_server_license_orglist_profile') ->where('orglistId', $orgData->id) ->get(); $orgData->profileList = $profileList ? $profileList : ''; // Fetch document type by org $docTypeList = DB::table('conf_server_license_orglist_doctype as a') ->join('u01r_doctype as b', 'a.docType', '=', 'b.DTNAME') ->where('a.orglistId', $orgData->id) ->get(); $orgData->docTypeList = $docTypeList ? $docTypeList : ''; } } public function loadMapping() { $this->tab = 'csvMapping'; // if ($this->info && isset($this->info['DATA']['conf_mapping'])) { // $this->mappingList = $this->info['DATA']['conf_mapping']; // foreach ($this->mappingList['mapConfig'] as $index => $config) { // $this->mappingList['mapConfig'][$index] = base64_decode($config); // } // } } public function saveMapping() { $fieldList = ['mapId', 'mapName', 'mapType', 'mapTo', 'mapConfig']; $DATA = []; foreach ($fieldList as $field) { foreach ($this->mappingList[$field] as $index => $value) { if ($field == 'mapConfig') { $DATA[$field][] = base64_encode(iconv("UTF-8", "TIS-620", $value)); } else { $DATA[$field][] = htmlspecialchars_decode(iconv("UTF-8", "TIS-620", $value), ENT_QUOTES); } } } $this->info['DATA']['conf_mapping'] = $DATA; $newBackupFeedback = base64_encode(gzcompress(var_export($this->info, true))); $license = ConfServerLicense::find($this->licenseId); if ($license) { $updatedRows = $license->update(['BACKUP_FEEDBACK' => $newBackupFeedback]); if ($updatedRows > 0) { $message = 'Mapping data saved successfully!'; } else { $message = 'No changes were made.'; } } $this->loadMapping(); $message = 'CSV Mapping updated successfully!'; $this->message = $message; } public function loadPrintForm() { $this->tab = 'printForm'; // if ($this->info && isset($this->info['DATA']['conf_label_form'])) { // $this->labelList = $this->info['DATA']['conf_label_form']; // } } public function savePrintForm() { $fieldList = array('lid', 'form_name', 'l_name', 'l_value', 'x', 'y', 'parentId', 'editLayout', 'width', 'height', 'type', 'format'); $DATA = []; foreach ($fieldList as $field) { foreach ($this->mappingList[$field] as $index => $value) { $DATA[$field][] = htmlspecialchars_decode(iconv("UTF-8", "TIS-620", $value), ENT_QUOTES); } } $this->info['DATA']['conf_label_form'] = $DATA; $newBackupFeedback = base64_encode(gzcompress(var_export($this->info, true))); $license = ConfServerLicense::find($this->licenseId); if ($license) { $updatedRows = $license->update(['BACKUP_FEEDBACK' => $newBackupFeedback]); if ($updatedRows > 0) { $message = 'Print form saved successfully!'; } else { $message = 'No changes were made.'; } } $this->loadPrintForm(); $message = 'Print form updated successfully!'; $this->message = $message; } public function loadUserInterface() { $this->tab = 'userInterface'; // if ($this->info && isset($this->info['DATA']['conf_ui'])) { // $this->userInterfaceList = $this->info['DATA']['conf_ui']; // } } public function saveUserInterface() { $fieldList = array('pageCode', 'name', 'tname', 'required', 'type', 'spec', 'manual', 'user_note', 'js_before_focus', 'cannotImport', 'fname', 'reportFlag', 'reportOrderBy', 'reportCondition', 'reportTable', 'reportType', 'reportFormat', 'reportAlign', 'user_default'); $DATA = []; foreach ($fieldList as $field) { foreach ($this->userInterfaceList[$field] as $index => $value) { $DATA[$field][] = htmlspecialchars_decode(iconv("UTF-8", "TIS-620", $value), ENT_QUOTES); } } $this->info['DATA']['conf_ui'] = $DATA; $newBackupFeedback = base64_encode(gzcompress(var_export($this->info, true))); $license = ConfServerLicense::find($this->licenseId); if ($license) { $updatedRows = $license->update(['BACKUP_FEEDBACK' => $newBackupFeedback]); if ($updatedRows > 0) { $message = 'User Interface saved successfully!'; } else { $message = 'No changes were made.'; } } $this->loadPrintForm(); $message = 'User Interface updated successfully!'; $this->message = $message; } public function loadGlobal() { $this->tab = 'global'; // if ($this->info && isset($this->info['DATA']['conf_ui'])) { // $this->globalList = $this->info['DATA']['conf_ui']; // } $groupedData = []; $globalTemp = $this->globalList; foreach ($globalTemp['profilecode'] as $index => $profileCode) { if (isset($globalTemp['name'][$index]) && isset($globalTemp['value'][$index])) { if (!isset($groupedData[$profileCode])) { $groupedData[$profileCode] = []; } $groupedData[$profileCode][] = [ 'name' => $globalTemp['name'][$index], 'value' => $globalTemp['value'][$index], 'profilecode' => $profileCode ]; } } $this->globalListGroup = $groupedData; } public function saveGlobal() { $fieldList = array('name', 'value', 'profilecode'); $DATA = []; foreach ($this->globalListGroup as $profileCode => $profileData) { foreach ($profileData as $index => $item) { foreach ($fieldList as $field) { if (isset($item[$field])) { $DATA[$field][] = htmlspecialchars_decode(iconv("UTF-8", "TIS-620", $item[$field]), ENT_QUOTES); } } } } $this->info['DATA']['conf_global'] = $DATA; $newBackupFeedback = base64_encode(gzcompress(var_export($this->info, true))); $license = ConfServerLicense::find($this->licenseId); if ($license) { $updatedRows = $license->update(['BACKUP_FEEDBACK' => $newBackupFeedback]); if ($updatedRows > 0) { $message = 'Global saved successfully!'; } else { $message = 'No changes were made.'; } } $this->loadPrintForm(); $message = 'Global updated successfully!'; $this->message = $message; } public function render() { return view('livewire.pages.server-license.server-license-edit'); } }