diff --git a/assets/asset-corporate-portal/css/sas.bundle.css b/assets/asset-corporate-portal/css/sas.bundle.css
index 9bbacf6..cc205b8 100644
--- a/assets/asset-corporate-portal/css/sas.bundle.css
+++ b/assets/asset-corporate-portal/css/sas.bundle.css
@@ -294,6 +294,56 @@ a.text-white:focus {
-webkit-box-shadow: 0 0 0 0.2rem rgba(84, 168, 255, 0.5);
box-shadow: 0 0 0 0.2rem rgba(84, 168, 255, 0.5);
}
+
+.btn-field {
+ color: var(--text-black);
+ background-color: var(--fieldbg) !important;
+ border-color: var(--fieldbg) !important;
+}
+.btn-field.btn-lg {
+ padding: 0.825rem 1.42rem !important;
+ font-size: 1.08rem !important;
+ line-height: 1.5 !important;
+ border-radius: 0.42rem !important;
+}
+.btn-field.btn-lg.rounded-lg {
+ padding: 0.825rem 1.42rem !important;
+ font-size: 1.08rem !important;
+ line-height: 1.5 !important;
+ border-radius: 0.85rem !important;
+}
+.btn-field:hover {
+ color: var(--text-black);
+ background-color: var(--fieldbg) !important;
+ border-color: var(--fieldbg) !important;
+}
+.btn-field:focus,
+.btn-field.focus {
+ color: var(--text-black);
+ background-color: var(--fieldbg) !important;
+ border-color: var(--fieldbg) !important;
+ -webkit-box-shadow: 0 0 0 0rem var(--fieldbg) !important;
+ box-shadow: 0 0 0 0rem var(--fieldbg) !important;
+}
+.btn-field.disabled,
+.btn-field:disabled {
+ color: var(--text-black);
+ background-color: var(--fieldbg) !important;
+ border-color: var(--fieldbg) !important;
+}
+.btn-field:not(:disabled):not(.disabled):active,
+.btn-field:not(:disabled):not(.disabled).active,
+.show > .btn-field.dropdown-toggle {
+ color: var(--text-black);
+ background-color: var(--fieldbg) !important;
+ border-color: var(--fieldbg) !important;
+}
+.btn-field:not(:disabled):not(.disabled):active:focus,
+.btn-field:not(:disabled):not(.disabled).active:focus,
+.show > .btn-field.dropdown-toggle:focus {
+ -webkit-box-shadow: 0 0 0 0rem var(--fieldbg) !important;
+ box-shadow: 0 0 0 0rem var(--fieldbg) !important;
+}
/* COBA CUSTOM BTN */
.btn-tosca {
color: #ffffff;
diff --git a/component/customdropdown/customdropdown.templ b/component/customdropdown/customdropdown.templ
index 45c17ee..5cdf603 100644
--- a/component/customdropdown/customdropdown.templ
+++ b/component/customdropdown/customdropdown.templ
@@ -60,3 +60,60 @@ templ MainCustomDropdownV1(name string, id string, hxTarget string, hxGet string
}
+
+templ CustomDropdownFilter(
+ idCmp string,
+ hxName string,
+ hxInclude string,
+ hxGet string,
+ hxSwap string,
+ hxTarget string,
+ hxTrigger string,
+ hxBeforeRequest templ.ComponentScript,
+ hxAfterRequest templ.ComponentScript,
+ listItem templ.Component) {
+
+}
+
+templ CustomDropdownForm(
+ inp models.CustomDropdownV2Prm) {
+
diff --git a/component/customtextfield/customtextfieldv2_templ.go b/component/customtextfield/customtextfieldv2_templ.go
index 2e5c7e5..1c41029 100644
--- a/component/customtextfield/customtextfieldv2_templ.go
+++ b/component/customtextfield/customtextfieldv2_templ.go
@@ -123,12 +123,12 @@ func CustomTextFieldv2(inp models.CustomTextFieldv2Prm) templ.Component {
return templ_7745c5c3_Err
}
if inp.ErrorMsg == "" {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" class=\"form-control bg-field border-0 h-auto py-6 px-6 rounded-lg\"")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" class=\"form-control bg-field border-0 form-control-lg bg-field rounded-lg\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" class=\"form-control bg-field border-1 h-auto py-6 px-6 rounded-lg is-invalid\"")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" class=\"form-control bg-field border-1 form-control-lg bg-field rounded-lg is-invalid\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/handlers/dev/md.bahan.handlers.go b/handlers/dev/md.bahan.handlers.go
new file mode 100644
index 0000000..9f6147d
--- /dev/null
+++ b/handlers/dev/md.bahan.handlers.go
@@ -0,0 +1,954 @@
+package dev_handlers
+
+import (
+ breadcrumadmin "cpone/component/breadcrumbadmin"
+ navbarmenu "cpone/component/navbar"
+ "cpone/component/pagination"
+ sidebaruserprofile "cpone/component/sidebar_user_profile"
+ customtoastv2 "cpone/component/toastbootstrap"
+ "cpone/models"
+ "cpone/services"
+ "cpone/utils"
+ dev_mdbahanview "cpone/views/dev/mdbahan"
+ "strconv"
+ "strings"
+
+ "github.com/a-h/templ"
+ "github.com/labstack/echo/v4"
+ "go.uber.org/zap"
+)
+
+type MdBahanServices interface {
+ GetListMdBahan(
+ search string,
+ stationID string,
+ currentPage int,
+ rowPerPage int) ([]models.Bahan, int, error)
+ GetMdBahanBreadCrumb(title string) (models.BreadCrumbV1, error)
+ GetListSampleStation(isFilter bool) ([]models.TmpSampleStation, error)
+ AddMdBahan(code string, name string, stationid string) (bool, error)
+ EditMdBahan(id string, code string, name string, stationid string) (bool, error)
+ GetMdBahanByID(id string) (models.Bahan, error)
+ DeleteMdBahan(id string) (bool, error)
+}
+
+func NewMdBahanHandler(us MdBahanServices) *MdBahanHandler {
+ return &MdBahanHandler{
+ MdBahanServices: us,
+ }
+}
+
+type MdBahanHandler struct {
+ MdBahanServices MdBahanServices
+}
+
+func (lh *MdBahanHandler) HandleShowMdBahanScreen(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+
+ dataMenu, err := services.GetMenu()
+ paginationID := utils.GenerateRandomID("paginationID")
+ modalAddID := utils.GenerateRandomID("modalAdd")
+ modalAddBodyID := utils.GenerateRandomID("modalAddbody")
+ modalEditID := utils.GenerateRandomID("modalEdit")
+ modalEditBodyID := utils.GenerateRandomID("modalEditbody")
+ modalDeleteID := utils.GenerateRandomID("modalDelete")
+ modalDeleteBodyID := utils.GenerateRandomID("modalDeletebody")
+ tableBahanID := utils.GenerateRandomID("BahanID")
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERROR BREADCRUMB DEV",
+ zap.Any("error", err),
+ )
+ return err
+ }
+
+ //get user login
+ dataUser, err := services.GetUserLogin()
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERROR BREADCRUMB DEV",
+ zap.Any("error", err),
+ )
+ return err
+ }
+ dataBreadCrumb, err := lh.MdBahanServices.GetMdBahanBreadCrumb("Bahan")
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERROR BREADCRUMB DEV",
+ zap.Any("error", err),
+ )
+ return err
+ }
+
+ //Breadcrumb component
+ breadcrumbComponent := breadcrumadmin.MainBreadcrumbAdminV1(dataBreadCrumb)
+ // navbar menu
+ navbarmenuComponent := navbarmenu.NavbarMenu(dataMenu)
+
+ // navbar user
+ navbaruserComponent := navbarmenu.Navbar(dataUser)
+
+ // sidebar
+ sidebaruserprofileComponent := sidebaruserprofile.Navbaruserprofile(dataUser)
+ bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan("", "0", 1, 5)
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("data", bahanList),
+ zap.Any("err", err),
+ zap.Any("totalPage", totalPage),
+ )
+ stationListFilter, err := lh.MdBahanServices.GetListSampleStation(true)
+ defer logger.Sync()
+ logger.Info("GET STATION LIST Filter",
+ zap.Any("err", err),
+ )
+ stationList, err := lh.MdBahanServices.GetListSampleStation(false)
+ defer logger.Sync()
+ logger.Info("GET STATION LIST ",
+ zap.Any("err", err),
+ )
+
+ //Bahan Table
+ // #dialogDeleteBodyID, #dialogDeleteID
+ mdBahanTable := dev_mdbahanview.TableBahan(
+ bahanList,
+ tableBahanID,
+ "/dev/md/bahan/openedit",
+ "#"+modalEditBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
+ "/dev/md/bahan/opendelete",
+ "#"+modalDeleteBodyID,
+ "outerHTML",
+ "#dialogDeleteBodyID, #dialogDeleteID, #dialogEditBodyID, #dialogEditID")
+
+ //FIlter table
+ mdBahanFilter := dev_mdbahanview.MdBahanFilter(
+ "/dev/md/bahan/filter",
+ "input changed delay:500ms",
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "outerHTML",
+ "#"+paginationID,
+ stationListFilter,
+ stationListFilter[0].T_SampleStationID,
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+
+ //Pagination
+
+ mdbahanPagination := pagination.PaginationV3(
+ totalPage, 1,
+ "/dev/md/bahan/pagination",
+ paginationID,
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "#"+paginationID,
+ "outerHTML",
+ "",
+ "",
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+ //Form Add
+ modalAddBody := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
+ },
+ modalAddBodyID,
+ dev_mdbahanview.JsShowModal(""),
+ )
+ modalAddAction := dev_mdbahanview.ActionFormBahan("/dev/md/bahan/closeaddform", "#"+modalAddBodyID, "outerHTML", "#"+modalAddID)
+ modalAddBtnCls := dev_mdbahanview.BtnCloseFormBahan("/dev/md/bahan/closeaddform", "#"+modalAddBodyID, "outerHTML", "#"+modalAddID)
+ modalAddBahan := dev_mdbahanview.BahanForm(models.BahanFormComponent{
+ IDComponent: "",
+ Link: "/dev/md/bahan/add",
+ HxTarget: "#" + modalAddBodyID,
+ HxSwap: "outerHTML",
+ HxInclude: "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage" + paginationID,
+ ModalID: modalAddID,
+ ModalTitle: "New-Bahan",
+ DialogBody: modalAddBody,
+ DialogAction: modalAddAction,
+ ButtonCLose: modalAddBtnCls,
+ })
+
+ //Form Edit
+ modalEditBody := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
+ },
+ modalEditBodyID,
+ dev_mdbahanview.JsShowModal(""),
+ )
+ modalEditAction := dev_mdbahanview.ActionFormBahan("/dev/md/bahan/closeeditform", "#"+modalEditBodyID, "outerHTML", "#"+modalEditID)
+ modalEditBtnCls := dev_mdbahanview.BtnCloseFormBahan("/dev/md/bahan/closeeditform", "#"+modalEditBodyID, "outerHTML", "#"+modalEditID)
+ modalEditBahan := dev_mdbahanview.BahanForm(models.BahanFormComponent{
+ IDComponent: "",
+ Link: "/dev/md/bahan/edit",
+ HxTarget: "#" + modalEditBodyID,
+ HxSwap: "outerHTML",
+ HxInclude: "#filter-name, #filter-station, #tableID, #paginationID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage" + paginationID,
+ ModalID: modalEditID,
+ ModalTitle: "Edit-Bahan",
+ DialogBody: modalEditBody,
+ DialogAction: modalEditAction,
+ ButtonCLose: modalEditBtnCls,
+ })
+
+ //Form Delete
+ modalDeleteBody := dev_mdbahanview.DeleteConfirmationBody(
+ "",
+ modalDeleteBodyID,
+ "Apakah anda yakin menghapus bahan berikut ?",
+ []string{"Kode", "Nama Bahan", "Sample Station"},
+ []string{"", "", ""}, dev_mdbahanview.JsShowModal(""))
+ modalDeleteAction := dev_mdbahanview.ActionFormBahanDelete("/dev/md/bahan/closedeleteform", "#"+modalDeleteBodyID, "outerHTML", "#"+modalDeleteID)
+ modalDeleteBtnCls := dev_mdbahanview.BtnCloseFormBahan("/dev/md/bahan/closedeleteform", "#"+modalDeleteBodyID, "outerHTML", "#"+modalDeleteID)
+ modalDeleteBahan := dev_mdbahanview.BahanForm(models.BahanFormComponent{
+ IDComponent: "",
+ Link: "/dev/md/bahan/delete",
+ HxTarget: "#" + modalDeleteBodyID,
+ HxSwap: "outerHTML",
+ HxInclude: "#filter-name, #filter-station, #tableID, #paginationID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage" + paginationID,
+ ModalID: modalDeleteID,
+ ModalTitle: "Delete-Bahan",
+ DialogBody: modalDeleteBody,
+ DialogAction: modalDeleteAction,
+ ButtonCLose: modalDeleteBtnCls,
+ })
+
+ mdBahanScreen := dev_mdbahanview.MdBahanScreen(
+ tableBahanID,
+ paginationID,
+ modalAddID,
+ modalAddBodyID,
+ modalEditID,
+ modalEditBodyID,
+ modalDeleteID,
+ modalDeleteBodyID,
+ breadcrumbComponent,
+ mdBahanTable,
+ mdBahanFilter,
+ mdbahanPagination,
+ modalAddBahan,
+ modalEditBahan,
+ modalDeleteBahan)
+ cssMdBahan := dev_mdbahanview.CssMdUserGroup()
+ jsMdBahan := dev_mdbahanview.JsMdBahan()
+
+ view := dev_mdbahanview.ShowMdBahanScreen(
+ "Md Bahan",
+ mdBahanScreen,
+ cssMdBahan,
+ jsMdBahan,
+ navbarmenuComponent,
+ navbaruserComponent,
+ sidebaruserprofileComponent)
+ return utils.View(c, view)
+}
+
+func (lh *MdBahanHandler) HandleFilterMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+ var retval []templ.Component
+ filtername := c.QueryParam("filtername")
+ filterstation := c.QueryParam("filterstation")
+ dialogEditBodyID := c.QueryParam("dialogEditBodyID")
+ dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID")
+ tableID := c.QueryParam("tableID")
+ paginationID := c.QueryParam("paginationID")
+ bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, 1, 5)
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("data", bahanList),
+ zap.Any("err", err),
+ zap.Any("totalPage", totalPage),
+ )
+ //Bahan Table
+
+ mdBahanTable := dev_mdbahanview.TableBahan(
+ bahanList,
+ tableID,
+ "/dev/md/bahan/openedit",
+ "#"+dialogEditBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
+ "/dev/md/bahan/opendelete",
+ "#"+dialogDeleteBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
+ //Pagination
+
+ mdbahanPagination := pagination.PaginationV3(
+ totalPage, 1,
+ "/dev/md/bahan/pagination",
+ paginationID,
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "#"+paginationID,
+ "outerHTML",
+ "",
+ "",
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+ retval = append(retval, mdBahanTable)
+ retval = append(retval, mdbahanPagination)
+ return utils.ViewMulti(c, retval)
+}
+func (lh *MdBahanHandler) HandlePaginationMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+ var retval []templ.Component
+ pageparam := c.QueryParam("page")
+
+ filtername := c.QueryParam("filtername")
+ filterstation := c.QueryParam("filterstation")
+ tableID := c.QueryParam("tableID")
+ dialogEditBodyID := c.QueryParam("dialogEditBodyID")
+ dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID")
+ paginationID := c.QueryParam("paginationID")
+ page, err := strconv.Atoi(pageparam)
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERROR CONVERT PAGE PARAM",
+ zap.Any("page", page),
+ zap.Any("error ", err),
+ )
+ return err
+ }
+ bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, page, 5)
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("data", bahanList),
+ zap.Any("err", err),
+ zap.Any("totalPage", totalPage),
+ )
+ //Bahan Table
+
+ mdBahanTable := dev_mdbahanview.TableBahan(
+ bahanList,
+ tableID,
+ "/dev/md/bahan/openedit",
+ "#"+dialogEditBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
+ "/dev/md/bahan/opendelete",
+ "#"+dialogDeleteBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
+ //Pagination
+
+ mdbahanPagination := pagination.PaginationV3(
+ totalPage, page,
+ "/dev/md/bahan/pagination",
+ paginationID,
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "#"+paginationID,
+ "outerHTML",
+ "",
+ "",
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+ retval = append(retval, mdBahanTable)
+ retval = append(retval, mdbahanPagination)
+ return utils.ViewMulti(c, retval)
+}
+func (lh *MdBahanHandler) HandleCloseFormAddMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+ stationList, err := lh.MdBahanServices.GetListSampleStation(false)
+ defer logger.Sync()
+ logger.Info("GET DATA STATIOn",
+ zap.Any("err", err),
+ )
+ dialogAddBodyID := c.FormValue("dialogAddBodyID")
+ dialogAddID := c.FormValue("dialogAddID")
+
+ modalAddBody := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
+ },
+ dialogAddBodyID,
+ dev_mdbahanview.JsHideModal("#"+dialogAddID),
+ )
+ return utils.View(c, modalAddBody)
+}
+func (lh *MdBahanHandler) HandleAddMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+
+ code := c.FormValue("kodebahan")
+ name := c.FormValue("namabahan")
+ stationIDPrm := c.FormValue("stationid")
+ tableID := c.FormValue("tableID")
+ paginationID := c.FormValue("paginationID")
+ filtername := c.FormValue("filtername")
+ filterstation := c.FormValue("filterstation")
+ currPagePrm := c.FormValue("currpage" + paginationID)
+ dialogAddBodyID := c.FormValue("dialogAddBodyID")
+ // searchID := c.FormValue("searchID")
+ dialogAddID := c.FormValue("dialogAddID")
+ dialogEditBodyID := c.FormValue("dialogEditBodyID")
+ dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
+ currPage, err := strconv.Atoi(currPagePrm)
+ if err != nil {
+ return err
+ }
+ stationID, err := strconv.Atoi(stationIDPrm)
+ if err != nil {
+ return err
+ }
+ formValidation := ""
+ codeValidation := ""
+ nameValidation := ""
+ stationValidation := ""
+
+ if strings.TrimSpace(code) == "" {
+ formValidation = "Code bahan tidak boleh kosong"
+ codeValidation = "Code bahan tidak boleh kosong"
+ nameValidation = ""
+ stationValidation = ""
+ }
+ if strings.TrimSpace(name) == "" {
+ formValidation = "Nama bahan tidak boleh kosong"
+ codeValidation = ""
+ stationValidation = ""
+ nameValidation = "Nama bahan tidak boleh kosong"
+ }
+ if stationID == 0 {
+ formValidation = "Pilih salah satu station"
+ codeValidation = ""
+ nameValidation = ""
+ stationValidation = "Pilih salah satu station"
+ }
+ if strings.TrimSpace(code) == "" && strings.TrimSpace(name) == "" {
+ formValidation = "Code,nama, dan station bahan tidak boleh kosong"
+ codeValidation = "Code bahan tidak boleh kosong"
+ stationValidation = "Pilih salah satu station"
+ nameValidation = "Nama bahan tidak boleh kosong"
+
+ }
+ stationList, err := lh.MdBahanServices.GetListSampleStation(false)
+ defer logger.Sync()
+ logger.Info("GET DATA STATIOn",
+ zap.Any("err", err),
+ )
+ if formValidation != "" || codeValidation != "" || nameValidation != "" || stationValidation != "" {
+ newForm := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Value: code,
+ ErrorMsg: codeValidation,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ ErrorMsg: nameValidation,
+ Value: name,
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ErrorMsg: stationValidation,
+ ListItem: dev_mdbahanview.ListItemStation(stationList, stationID),
+ },
+ dialogAddBodyID,
+ dev_mdbahanview.JsShowModal(""),
+ )
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
+ }
+ _, err = lh.MdBahanServices.AddMdBahan(code, name, stationIDPrm)
+ if err != nil {
+ newForm := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Value: code,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Value: name,
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, int(stationID)),
+ },
+ dialogAddBodyID,
+ dev_mdbahanview.JsShowModal(""),
+ )
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Gagal", err.Error(), "danger"), newForm})
+ }
+
+ bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, currPage, 5)
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("data", bahanList),
+ zap.Any("err", err),
+ zap.Any("totalPage", totalPage),
+ )
+ //Bahan Table
+ mdBahanTable := dev_mdbahanview.TableBahan(
+ bahanList,
+ tableID,
+ "/dev/md/bahan/openedit",
+ "#"+dialogEditBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
+ "/dev/md/bahan/opendelete",
+ "#"+dialogDeleteBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
+
+ //Pagination
+
+ mdbahanPagination := pagination.PaginationV3(
+ totalPage, currPage,
+ "/dev/md/bahan/pagination",
+ paginationID,
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "#"+paginationID,
+ "outerHTML",
+ "",
+ "true",
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+ //Form Add
+ modalAddBody := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
+ },
+ dialogAddBodyID,
+ dev_mdbahanview.JsHideModal("#"+dialogAddID),
+ )
+
+ toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success add bahan ", "success")
+ retval := []templ.Component{toastSuccess, mdBahanTable, mdbahanPagination, modalAddBody}
+ // time.Sleep(20 * time.Second)
+ return utils.ViewMulti(c, retval)
+}
+func (lh *MdBahanHandler) HandleOpenEditMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+
+ id := c.QueryParam("id")
+ dialogEditID := c.QueryParam("dialogEditID")
+ dialogEditBodyID := c.QueryParam("dialogEditBodyID")
+ stationList, err := lh.MdBahanServices.GetListSampleStation(false)
+ defer logger.Sync()
+ logger.Info("GET DATA STATION",
+ zap.Any("err", err),
+ )
+ dataBahan, err := lh.MdBahanServices.GetMdBahanByID(id)
+ if err != nil {
+ newForm := dev_mdbahanview.BodyFormBahan(
+ id,
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, dataBahan.T_BahanT_SampleStationID),
+ },
+ dialogEditBodyID,
+ dev_mdbahanview.JsHideModal(""),
+ )
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get data bahan error", "danger"), newForm})
+ }
+ newForm := dev_mdbahanview.BodyFormBahan(
+ id,
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Value: dataBahan.T_BahanCode,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Value: dataBahan.T_BahanName,
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, dataBahan.T_BahanT_SampleStationID),
+ },
+ dialogEditBodyID,
+ dev_mdbahanview.JsShowModal("#"+dialogEditID),
+ )
+ return utils.View(c, newForm)
+}
+func (lh *MdBahanHandler) HandleCloseFormEditMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+ stationList, err := lh.MdBahanServices.GetListSampleStation(false)
+ dialogEditID := c.FormValue("dialogEditID")
+ dialogEditBodyID := c.FormValue("dialogEditBodyID")
+ defer logger.Sync()
+ logger.Info("GET DATA STATION",
+ zap.Any("err", err),
+ zap.Any("dialogeditbodyid", dialogEditBodyID),
+ )
+
+ modalAddBody := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
+ },
+ dialogEditBodyID,
+ dev_mdbahanview.JsHideModal("#"+dialogEditID),
+ )
+ return utils.View(c, modalAddBody)
+}
+func (lh *MdBahanHandler) HandleEditMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+
+ code := c.FormValue("kodebahan")
+ name := c.FormValue("namabahan")
+ id := c.FormValue("bahanid")
+ stationIDPrm := c.FormValue("stationid")
+ tableID := c.FormValue("tableID")
+ paginationID := c.FormValue("paginationID")
+ filtername := c.FormValue("filtername")
+ filterstation := c.FormValue("filterstation")
+ currPagePrm := c.FormValue("currpage" + paginationID)
+ // dialogAddBodyID := c.FormValue("dialogAddBodyID")
+ // searchID := c.FormValue("searchID")
+ dialogEditID := c.FormValue("dialogEditID")
+ dialogEditBodyID := c.FormValue("dialogEditBodyID")
+ dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
+ currPage, err := strconv.Atoi(currPagePrm)
+ if err != nil {
+ return err
+ }
+ stationID, err := strconv.Atoi(stationIDPrm)
+ if err != nil {
+ return err
+ }
+ formValidation := ""
+ codeValidation := ""
+ nameValidation := ""
+ stationValidation := ""
+
+ if strings.TrimSpace(code) == "" {
+ formValidation = "Code bahan tidak boleh kosong"
+ codeValidation = "Code bahan tidak boleh kosong"
+ nameValidation = ""
+ stationValidation = ""
+ }
+ if strings.TrimSpace(name) == "" {
+ formValidation = "Nama bahan tidak boleh kosong"
+ codeValidation = ""
+ stationValidation = ""
+ nameValidation = "Nama bahan tidak boleh kosong"
+ }
+ if stationID == 0 {
+ formValidation = "Pilih salah satu station"
+ codeValidation = ""
+ nameValidation = ""
+ stationValidation = "Pilih salah satu station"
+ }
+ if strings.TrimSpace(code) == "" && strings.TrimSpace(name) == "" {
+ formValidation = "Code,nama, dan station bahan tidak boleh kosong"
+ codeValidation = "Code bahan tidak boleh kosong"
+ stationValidation = "Pilih salah satu station"
+ nameValidation = "Nama bahan tidak boleh kosong"
+
+ }
+ stationList, err := lh.MdBahanServices.GetListSampleStation(false)
+ defer logger.Sync()
+ logger.Info("GET DATA STATIOn",
+ zap.Any("err", err),
+ )
+ if formValidation != "" || codeValidation != "" || nameValidation != "" || stationValidation != "" {
+ newForm := dev_mdbahanview.BodyFormBahan(
+ id,
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Value: code,
+ ErrorMsg: codeValidation,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ ErrorMsg: nameValidation,
+ Value: name,
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ErrorMsg: stationValidation,
+ ListItem: dev_mdbahanview.ListItemStation(stationList, stationID),
+ },
+ dialogEditBodyID,
+ dev_mdbahanview.JsShowModal(""),
+ )
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Warning", formValidation, "warning"), newForm})
+ }
+ _, err = lh.MdBahanServices.EditMdBahan(id, code, name, stationIDPrm)
+ if err != nil {
+ newForm := dev_mdbahanview.BodyFormBahan(
+ id,
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Value: code,
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Value: name,
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, int(stationID)),
+ },
+ dialogEditBodyID,
+ dev_mdbahanview.JsShowModal(""),
+ )
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Gagal", err.Error(), "danger"), newForm})
+ }
+
+ bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, currPage, 5)
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("data", bahanList),
+ zap.Any("err", err),
+ zap.Any("totalPage", totalPage),
+ )
+ //Bahan Table
+ mdBahanTable := dev_mdbahanview.TableBahan(
+ bahanList,
+ tableID,
+ "/dev/md/bahan/openedit",
+ "#"+dialogEditBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
+ "/dev/md/bahan/opendelete",
+ "#"+dialogDeleteBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
+
+ //Pagination
+
+ mdbahanPagination := pagination.PaginationV3(
+ totalPage, currPage,
+ "/dev/md/bahan/pagination",
+ paginationID,
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "#"+paginationID,
+ "outerHTML",
+ "",
+ "true",
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+ //Form Add
+ modalAddBody := dev_mdbahanview.BodyFormBahan(
+ "",
+ models.CustomTextFieldv2Prm{Label: "Kode Bahan",
+ Name: "kodebahan",
+ Placeholder: "Kode Bahan",
+ Type: "text"},
+ models.CustomTextFieldv2Prm{Label: "Nama Bahan",
+ Name: "namabahan",
+ Placeholder: "Nama Bahan",
+ Type: "text"},
+ models.CustomDropdownV2Prm{
+ Name: "stationid",
+ Label: "Sample Station",
+ ListItem: dev_mdbahanview.ListItemStation(stationList, 0),
+ },
+ dialogEditBodyID,
+ dev_mdbahanview.JsHideModal("#"+dialogEditID),
+ )
+
+ toastSuccess := customtoastv2.CustomToastV2Show("Success", "Success edit bahan ", "success")
+ retval := []templ.Component{toastSuccess, mdBahanTable, mdbahanPagination, modalAddBody}
+ // time.Sleep(20 * time.Second)
+ return utils.ViewMulti(c, retval)
+}
+func (lh *MdBahanHandler) HandleOpenDeleteMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+
+ id := c.QueryParam("id")
+ dialogDeleteID := c.QueryParam("dialogDeleteID")
+ dialogDeleteBodyID := c.QueryParam("dialogDeleteBodyID")
+
+ dataBahan, err := lh.MdBahanServices.GetMdBahanByID(id)
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("err", err),
+ )
+ newForm := dev_mdbahanview.DeleteConfirmationBody(
+ "",
+ dialogDeleteBodyID,
+ "Apakah anda yakin menghapus bahan berikut ?",
+ []string{"Kode", "Nama Bahan", "Sample Station"},
+ []string{"", "", ""}, dev_mdbahanview.JsShowModal(""))
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get data bahan error", "danger"), newForm})
+ }
+ newForm := dev_mdbahanview.DeleteConfirmationBody(
+ strconv.Itoa(dataBahan.T_BahanID),
+ dialogDeleteBodyID,
+ "Apakah anda yakin menghapus bahan berikut ?",
+ []string{"Kode", "Nama Bahan", "Sample Station"},
+ []string{dataBahan.T_BahanCode, dataBahan.T_BahanName, dataBahan.T_SampleStationName}, dev_mdbahanview.JsShowModal("#"+dialogDeleteID))
+ return utils.View(c, newForm)
+}
+func (lh *MdBahanHandler) HandleCloseDeleteMdBahan(c echo.Context) error {
+
+ dialogDeleteID := c.FormValue("dialogDeleteID")
+ dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
+ newForm := dev_mdbahanview.DeleteConfirmationBody(
+ "",
+ dialogDeleteBodyID,
+ "Apakah anda yakin menghapus bahan berikut ?",
+ []string{"Kode", "Nama Bahan", "Sample Station"},
+ []string{"", "", ""}, dev_mdbahanview.JsHideModal("#"+dialogDeleteID))
+ return utils.View(c, newForm)
+}
+
+func (lh *MdBahanHandler) HandleDeleteMdBahan(c echo.Context) error {
+ logger, _ := zap.NewProduction()
+
+ id := c.FormValue("bahanid")
+
+ tableID := c.FormValue("tableID")
+ paginationID := c.FormValue("paginationID")
+ filtername := c.FormValue("filtername")
+ filterstation := c.FormValue("filterstation")
+ currPagePrm := c.FormValue("currpage" + paginationID)
+ // dialogAddBodyID := c.FormValue("dialogAddBodyID")
+ // searchID := c.FormValue("searchID")
+ dialogDeleteID := c.FormValue("dialogDeleteID")
+ dialogEditBodyID := c.FormValue("dialogEditBodyID")
+ dialogDeleteBodyID := c.FormValue("dialogDeleteBodyID")
+ currPage, err := strconv.Atoi(currPagePrm)
+ if err != nil {
+ return err
+ }
+
+ _, err = lh.MdBahanServices.DeleteMdBahan(id)
+ if err != nil {
+ defer logger.Sync()
+ logger.Info("ERR DELETE MD BAHAN",
+ zap.Any("err", err),
+ )
+ newForm := dev_mdbahanview.DeleteConfirmationBody(
+ "",
+ dialogDeleteBodyID,
+ "Apakah anda yakin menghapus bahan berikut ?",
+ []string{"Kode", "Nama Bahan", "Sample Station"},
+ []string{"", "", ""}, dev_mdbahanview.JsShowModal(""))
+ return utils.ViewMulti(c, []templ.Component{customtoastv2.CustomToastV2Show("Error", "Get data bahan error", "danger"), newForm})
+ }
+ bahanList, totalPage, err := lh.MdBahanServices.GetListMdBahan(filtername, filterstation, currPage, 5)
+ defer logger.Sync()
+ logger.Info("GET DATA BAHAN",
+ zap.Any("data", bahanList),
+ zap.Any("err", err),
+ zap.Any("totalPage", totalPage),
+ )
+ //Bahan Table
+ mdBahanTable := dev_mdbahanview.TableBahan(
+ bahanList,
+ tableID,
+ "/dev/md/bahan/openedit",
+ "#"+dialogEditBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID",
+ "/dev/md/bahan/opendelete",
+ "#"+dialogDeleteBodyID,
+ "outerHTML",
+ "#dialogEditBodyID, #dialogEditID, #dialogDeleteBodyID, #dialogDeleteID")
+
+ //Pagination
+
+ mdbahanPagination := pagination.PaginationV3(
+ totalPage, currPage,
+ "/dev/md/bahan/pagination",
+ paginationID,
+ "#filter-name, #filter-station, #tableID, #paginationID, #dialogAddID, #dialogAddBodyID, #dialogEditID, #dialogEditBodyID, #dialogDeleteBodyID, #dialogDeleteID, #currpage"+paginationID,
+ "#"+paginationID,
+ "outerHTML",
+ "",
+ "true",
+ dev_mdbahanview.BeforeRequestContent(),
+ dev_mdbahanview.AfterRequestContent(),
+ )
+
+ toastSuccess := customtoastv2.CustomToastV2Show("Success", "Berhasil hapus bahan", "success")
+ newForm := dev_mdbahanview.DeleteConfirmationBody(
+ "",
+ dialogDeleteBodyID,
+ "Apakah anda yakin menghapus bahan berikut ?",
+ []string{"Kode", "Nama Bahan", "Sample Station"},
+ []string{"", "", ""}, dev_mdbahanview.JsHideModal("#"+dialogDeleteID))
+ return utils.ViewMulti(c, []templ.Component{toastSuccess, mdBahanTable, mdbahanPagination, newForm})
+}
diff --git a/handlers/routes.go b/handlers/routes.go
index d1b13b1..ed82786 100644
--- a/handlers/routes.go
+++ b/handlers/routes.go
@@ -291,4 +291,18 @@ func SetupRoutesDev(app *echo.Echo, appStore db.AppStore) {
dev.GET("/md/groupresultv2/opendelete", devMdGRhandlers.HandleOpenDeleteForm)
dev.POST("/md/groupresultv2/closedeleteform", devMdGRhandlers.HandleCloseFormDelete)
dev.POST("/md/groupresultv2/delete", devMdGRhandlers.HandleDeleteUserGroup)
+ //MD BAHAN
+ devMdBahanServices := dev_services.NewMdBahanServices(appStore)
+ devMdBahanHandlers := dev_handlers.NewMdBahanHandler(devMdBahanServices)
+ dev.GET("/md/bahan", devMdBahanHandlers.HandleShowMdBahanScreen)
+ dev.GET("/md/bahan/filter", devMdBahanHandlers.HandleFilterMdBahan)
+ dev.GET("/md/bahan/pagination", devMdBahanHandlers.HandlePaginationMdBahan)
+ dev.POST("/md/bahan/add", devMdBahanHandlers.HandleAddMdBahan)
+ dev.POST("/md/bahan/closeaddform", devMdBahanHandlers.HandleCloseFormAddMdBahan)
+ dev.GET("/md/bahan/openedit", devMdBahanHandlers.HandleOpenEditMdBahan)
+ dev.POST("/md/bahan/closeeditform", devMdBahanHandlers.HandleCloseFormEditMdBahan)
+ dev.POST("/md/bahan/edit", devMdBahanHandlers.HandleEditMdBahan)
+ dev.GET("/md/bahan/opendelete", devMdBahanHandlers.HandleOpenDeleteMdBahan)
+ dev.POST("/md/bahan/closedeleteform", devMdBahanHandlers.HandleCloseDeleteMdBahan)
+ dev.POST("/md/bahan/delete", devMdBahanHandlers.HandleDeleteMdBahan)
}
diff --git a/models/bahan.models.go b/models/bahan.models.go
new file mode 100644
index 0000000..5e12ec2
--- /dev/null
+++ b/models/bahan.models.go
@@ -0,0 +1,38 @@
+package models
+
+import "github.com/a-h/templ"
+
+type Bahan struct {
+ T_BahanID int `db:"T_BahanID"`
+ T_BahanT_SampleStationID int `db:"T_BahanT_SampleStationID"`
+ T_SampleStationID int `db:"T_SampleStationID"`
+ T_SampleStationName string `db:"T_SampleStationName"`
+ T_BahanCode string `db:"T_BahanCode"`
+ T_BahanName string `db:"T_BahanName"`
+ T_BahanLangName string `db:"T_BahanLangName"`
+ T_BahanIsActive string `db:"T_BahanIsActive"`
+ T_BahanCreated string `db:"T_BahanCreated"`
+ T_BahanCreatedUserID string `db:"T_BahanCreatedUserID"`
+ T_BahanLastUpdated string `db:"T_BahanLastUpdated"`
+ T_BahanLastUpdatedUserID string `db:"T_BahanLastUpdatedUserID"`
+ T_BahanDeleted string `db:"T_BahanDeleted"`
+ T_BahanDeletedUserID string `db:"T_BahanDeletedUserID"`
+}
+
+type TmpSampleStation struct {
+ T_SampleStationID int `db:"T_SampleStationID"`
+ T_SampleStationName string `db:"T_SampleStationName"`
+}
+
+type BahanFormComponent struct {
+ IDComponent string
+ Link string
+ HxTarget string
+ HxSwap string
+ HxInclude string
+ ModalID string
+ ModalTitle string
+ DialogBody templ.Component
+ DialogAction templ.Component
+ ButtonCLose templ.Component
+}
diff --git a/models/customdropdown.models.go b/models/customdropdown.models.go
index 7bc3001..9e2dbe0 100644
--- a/models/customdropdown.models.go
+++ b/models/customdropdown.models.go
@@ -1,5 +1,7 @@
package models
+import "github.com/a-h/templ"
+
// name string, id string, hxTarget string, hxGet string, hxIndicator string, hxTrigger string, hxInclude string,
type CustomDropdownv1Prm struct {
@@ -16,3 +18,19 @@ type CustomDropdownv1Prm struct {
ErrorMsg string `default:""`
ID string
}
+type CustomDropdownV2Prm struct {
+ HxTarget string `default:"hxTarget"`
+ HxGet string `default:"hxGet"`
+ HxIndicator string `default:"hxIndicator"`
+ HxInclude string `default:"hxInclude"`
+ HxTrigger string `default:"hxTrigger"`
+ HxSwap string `default:"HxSwap"`
+ Label string `default:"Label"`
+ Name string `default:"name"`
+ Placeholder string `default:"Placeholder"`
+ // Type string `default:"text"`
+ // Value string `default:""`
+ ErrorMsg string `default:""`
+ ID string
+ ListItem templ.Component
+}
diff --git a/services/dev/md.bahan.services.go b/services/dev/md.bahan.services.go
new file mode 100644
index 0000000..3e697bd
--- /dev/null
+++ b/services/dev/md.bahan.services.go
@@ -0,0 +1,251 @@
+package dev_services
+
+import (
+ "cpone/db"
+ "cpone/models"
+ dbx "cpone/package/database"
+ "fmt"
+ "math"
+ "strings"
+
+ "go.uber.org/zap"
+)
+
+func NewMdBahanServices(uStore db.AppStore) *MdBahanServices {
+
+ return &MdBahanServices{
+
+ MdBahanStore: uStore,
+ }
+}
+
+type MdBahanServices struct {
+ MdBahanStore db.AppStore
+}
+
+func (su *MdBahanServices) GetListMdBahan(
+ search string,
+ stationID string,
+ currentPage int,
+ rowPerPage int) ([]models.Bahan, int, error) {
+ var bahanList []models.Bahan
+ var totalData int
+ offset := (currentPage - 1) * rowPerPage
+ prm := "%" + strings.TrimSpace(search) + "%"
+ filterStation := ""
+ if stationID != "0" {
+ filterStation = "AND T_BahanT_SampleStationID = " + stationID
+
+ }
+ querytotal := `
+ SELECT COUNT(*) FROM
+ t_bahan
+ JOIN
+ t_samplestation
+ ON T_BahanT_SampleStationID = T_SampleStationID
+ AND T_BahanIsActive = 'Y'
+ AND T_SampleStationIsActive = 'Y'
+ WHERE (T_BahanName LIKE ? OR T_BahanCode LIKE ? )
+
+ ` + filterStation
+ if err := dbx.Handlex.Get(&totalData, querytotal, prm, prm); err != nil {
+ return nil, 0, fmt.Errorf("error querying database: %v", err)
+ }
+ query := `
+ SELECT t_bahan.*,
+ T_SampleStationName,
+ T_SampleStationID FROM
+ t_bahan
+ JOIN
+ t_samplestation
+ ON T_BahanT_SampleStationID = T_SampleStationID
+ AND T_BahanIsActive = 'Y'
+ AND T_SampleStationIsActive = 'Y'
+ WHERE (T_BahanName LIKE ? OR T_BahanCode LIKE ? )
+ ` + filterStation + `
+ LIMIT ? OFFSET ?
+ `
+
+ if err := dbx.Handlex.Select(&bahanList, query, prm, prm, rowPerPage, offset); err != nil {
+ return nil, 0, fmt.Errorf("error querying database: %v", err)
+ }
+ totalPage := int(math.Ceil(float64(totalData) / float64(rowPerPage)))
+
+ return bahanList, totalPage, nil
+
+}
+
+func (su *MdBahanServices) GetMdBahanBreadCrumb(title string) (models.BreadCrumbV1, error) {
+
+ ret := models.BreadCrumbV1{
+ Title: "Master Bahan",
+ Item: []models.ItemBreadCrumbV1{
+ {
+ Item: "Dashboard",
+ Url: "/dev/dashboard",
+ },
+ {
+ Item: "Master",
+ Url: "/dev/master",
+ },
+ {
+ Item: "Bahan",
+ Url: "",
+ },
+ },
+ }
+
+ return ret, nil
+}
+func (su *MdBahanServices) GetListSampleStation(isFilter bool) ([]models.TmpSampleStation, error) {
+ var stationList []models.TmpSampleStation
+ query := `
+ SELECT
+ T_SampleStationID,
+ T_SampleStationName
+ FROM
+ t_samplestation
+ WHERE T_SampleStationIsActive = 'Y'
+ `
+
+ if err := dbx.Handlex.Select(&stationList, query); err != nil {
+ return nil, fmt.Errorf("error querying database: %v", err)
+ }
+ if isFilter {
+ stationList = append(
+ []models.TmpSampleStation{{T_SampleStationID: 0, T_SampleStationName: "Semua"}}, stationList...)
+ }
+
+ return stationList, nil
+}
+func (su *MdBahanServices) AddMdBahan(code string, name string, stationid string) (bool, error) {
+ logger, _ := zap.NewProduction()
+ var datacek []models.Bahan
+ qryCek := `SELECT T_BahanCode FROM t_bahan WHERE T_BahanCode = ? AND T_BahanIsActive = 'Y'`
+ err := dbx.Handlex.Select(&datacek, qryCek, code)
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error cek data by code",
+ zap.String("code", code),
+ zap.Any("datacek", datacek),
+ )
+ return false, fmt.Errorf("query cek failed")
+ }
+ if len(datacek) > 0 {
+ defer logger.Sync()
+ logger.Error("Code already taken by another data",
+ zap.String("code", code),
+ )
+ return false, fmt.Errorf("code sudah dipakai")
+ }
+ query := `
+ INSERT INTO t_bahan(
+ T_BahanT_SampleStationID,
+ T_BahanCode,
+ T_BahanName,
+ T_BahanCreated,
+ T_BahanCreatedUserID)
+ VALUES(?,?,?, NOW(), 1)
+
+ `
+ rst := dbx.Handlex.MustExec(query, stationid, code, name)
+ _, err = rst.LastInsertId()
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error Insert t bahan",
+ zap.Any("code", err),
+ )
+ return false, fmt.Errorf("insert data failed")
+ }
+
+ return true, nil
+}
+func (ug *MdBahanServices) GetMdBahanByID(id string) (models.Bahan, error) {
+ logger, _ := zap.NewProduction()
+
+ var data models.Bahan
+ err := dbx.Handlex.Get(&data,
+ `SELECT t_bahan.*,
+ T_SampleStationID,
+ T_SampleStationName
+ FROM t_bahan
+ JOIN
+ t_samplestation
+ ON T_BahanT_SampleStationID = T_SampleStationID
+ AND T_BahanIsActive = 'Y'
+ AND T_SampleStationIsActive = 'Y'
+ WHERE T_BahanID = ? `, id)
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error get data bahan by id vs",
+ zap.String("ID", id),
+ zap.Error(err),
+ )
+ return data, fmt.Errorf("get bahan failed")
+ }
+ return data, nil
+}
+func (su *MdBahanServices) EditMdBahan(id string, code string, name string, stationid string) (bool, error) {
+ logger, _ := zap.NewProduction()
+ var datacek []models.Bahan
+ qryCek := `SELECT T_BahanCode FROM t_bahan WHERE T_BahanCode = ? AND T_BahanIsActive = 'Y' AND T_BahanID <> ?`
+ err := dbx.Handlex.Select(&datacek, qryCek, code, id)
+
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error cek data by code",
+ zap.String("code", code),
+ zap.Any("datacek", datacek),
+ )
+ return false, fmt.Errorf("query cek failed")
+ }
+ if len(datacek) > 0 {
+ defer logger.Sync()
+ logger.Error("Code already taken by another data",
+ zap.String("code", code),
+ )
+ return false, fmt.Errorf("code sudah dipakai")
+ }
+ query := `
+ UPDATE t_bahan SET
+ T_BahanCode = ?,
+ T_BahanName = ?,
+ T_BahanT_SampleStationID = ?
+ WHERE T_BahanID = ?
+ `
+ rst := dbx.Handlex.MustExec(query, code, name, stationid, id)
+ _, err = rst.LastInsertId()
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error edit t bahan",
+ zap.Any("code", err),
+ )
+ return false, fmt.Errorf("edit data failed")
+ }
+
+ return true, nil
+}
+func (su *MdBahanServices) DeleteMdBahan(id string) (bool, error) {
+ logger, _ := zap.NewProduction()
+
+ query := `
+ UPDATE t_bahan
+ SET T_BahanIsActive = 'N',
+ T_BahanDeleted = NOW(),
+ T_BahanDeletedUserID = '1'
+ WHERE T_BahanID = ?
+ `
+ rst := dbx.Handlex.MustExec(query, id)
+ _, err := rst.LastInsertId()
+ if err != nil {
+ defer logger.Sync()
+ logger.Error("Error edit t bahan",
+ zap.Any("code", err),
+ )
+ return false, fmt.Errorf("edit data failed")
+ }
+
+ return true, nil
+}
diff --git a/views/dev/mdbahan/mdbahan.templ b/views/dev/mdbahan/mdbahan.templ
new file mode 100644
index 0000000..030f8dd
--- /dev/null
+++ b/views/dev/mdbahan/mdbahan.templ
@@ -0,0 +1,265 @@
+package dev_mdbahanview
+
+import "cpone/layout"
+import "cpone/models"
+import "cpone/component/customtextfield"
+import "cpone/component/customdropdown"
+import "strconv"
+
+templ MdBahanScreen(
+ tableID string,
+ paginationID string,
+ dialogAddID string,
+ dialogAddBodyID string,
+ dialogEditID string,
+ dialogEditBodyID string,
+ dialogDeleteID string,
+ dialogDeleteBodyID string,
+ breadcrumb templ.Component,
+ tablecontent templ.Component,
+ filterComponent templ.Component,
+ pagination templ.Component,
+ dialogAddCmp templ.Component,
+ dialogEditCmp templ.Component,
+ dialogDeleteCmp templ.Component,
+) {
+
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddID",
+ Name: "dialogAddID",
+ Type: "hidden",
+ Value: dialogAddID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddBodyID",
+ Name: "dialogAddBodyID",
+ Type: "hidden",
+ Value: dialogAddBodyID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditID",
+ Name: "dialogEditID",
+ Type: "hidden",
+ Value: dialogEditID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditBodyID",
+ Name: "dialogEditBodyID",
+ Type: "hidden",
+ Value: dialogEditBodyID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteID",
+ Name: "dialogDeleteID",
+ Type: "hidden",
+ Value: dialogDeleteID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteBodyID",
+ Name: "dialogDeleteBodyID",
+ Type: "hidden",
+ Value: dialogDeleteBodyID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
+ Name: "tableID",
+ Type: "hidden",
+ Value: tableID})
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "paginationID",
+ Name: "paginationID",
+ Type: "hidden",
+ Value: paginationID})
+
+
+ @breadcrumb
+
+
+
+ @filterComponent
+ @tablecontent
+ @pagination
+
+
+
+ @dialogAddCmp
+ @dialogEditCmp
+ @dialogDeleteCmp
+
+}
+
+templ CssMdUserGroup() {
+}
+
+templ JsMdBahan() {
+
+}
+
+script BeforeRequestContent() {
+ const loadingParent = document.getElementById("loading-parent");
+ const loadingChild = document.getElementById("loading-child");
+ const loadingSpinner = document.getElementById("loading-spinner");
+
+ loadingParent.classList.add("overlay");
+ loadingParent.classList.add("overlay-block");
+ loadingChild.classList.add("overlay-layer");
+ loadingSpinner.classList.remove("d-none");
+}
+
+script AfterRequestContent() {
+ const loadingParent = document.getElementById("loading-parent");
+ const loadingChild = document.getElementById("loading-child");
+ const loadingSpinner = document.getElementById("loading-spinner");
+
+ loadingParent.classList.remove("overlay");
+ loadingParent.classList.remove("overlay-block");
+ loadingChild.classList.remove("overlay-layer");
+ loadingSpinner.classList.add("d-none");
+}
+
+templ MdBahanFilter(
+ hxGet string,
+ hxTrigger string,
+ hxInclude string,
+ hxSwap string,
+ hxTarget string,
+ dataStation []models.TmpSampleStation,
+ selectedIdStation int,
+ hxBeforeRequest templ.ComponentScript,
+ hxAfterRequest templ.ComponentScript,
+) {
+
+
+
+
+
+
+ @customdropdown.CustomDropdownFilter("filter-station",
+ "filterstation",
+ hxInclude,
+ hxGet,
+ hxSwap,
+ hxTarget,
+ "change",
+ hxBeforeRequest,
+ hxAfterRequest, ListItemStation(dataStation, selectedIdStation))
+
+
+
+}
+
+templ ListItemStation(
+ dataStation []models.TmpSampleStation,
+ selectedIdStation int) {
+ for _, v := range dataStation {
+ if v.T_SampleStationID == selectedIdStation {
+
+ } else {
+
+ }
+ }
+}
+
+templ ShowMdBahanScreen(title string, cmp templ.Component, css templ.Component, js templ.Component,
+ navbarmenu templ.Component,
+ navbaruser templ.Component,
+ userprofile templ.Component) {
+ @layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile) {
+ @cmp
+ }
+}
diff --git a/views/dev/mdbahan/mdbahan_templ.go b/views/dev/mdbahan/mdbahan_templ.go
new file mode 100644
index 0000000..d4cd45b
--- /dev/null
+++ b/views/dev/mdbahan/mdbahan_templ.go
@@ -0,0 +1,531 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.663
+package dev_mdbahanview
+
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
+import "github.com/a-h/templ"
+import "context"
+import "io"
+import "bytes"
+
+import "cpone/layout"
+import "cpone/models"
+import "cpone/component/customtextfield"
+import "cpone/component/customdropdown"
+import "strconv"
+
+func MdBahanScreen(
+ tableID string,
+ paginationID string,
+ dialogAddID string,
+ dialogAddBodyID string,
+ dialogEditID string,
+ dialogEditBodyID string,
+ dialogDeleteID string,
+ dialogDeleteBodyID string,
+ breadcrumb templ.Component,
+ tablecontent templ.Component,
+ filterComponent templ.Component,
+ pagination templ.Component,
+ dialogAddCmp templ.Component,
+ dialogEditCmp templ.Component,
+ dialogDeleteCmp templ.Component,
+) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddID",
+ Name: "dialogAddID",
+ Type: "hidden",
+ Value: dialogAddID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogAddBodyID",
+ Name: "dialogAddBodyID",
+ Type: "hidden",
+ Value: dialogAddBodyID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditID",
+ Name: "dialogEditID",
+ Type: "hidden",
+ Value: dialogEditID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogEditBodyID",
+ Name: "dialogEditBodyID",
+ Type: "hidden",
+ Value: dialogEditBodyID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteID",
+ Name: "dialogDeleteID",
+ Type: "hidden",
+ Value: dialogDeleteID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "dialogDeleteBodyID",
+ Name: "dialogDeleteBodyID",
+ Type: "hidden",
+ Value: dialogDeleteBodyID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "tableID",
+ Name: "tableID",
+ Type: "hidden",
+ Value: tableID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{ID: "paginationID",
+ Name: "paginationID",
+ Type: "hidden",
+ Value: paginationID}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = breadcrumb.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = filterComponent.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = tablecontent.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = pagination.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = dialogAddCmp.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = dialogEditCmp.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = dialogDeleteCmp.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func CssMdUserGroup() templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var4 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var4 == nil {
+ templ_7745c5c3_Var4 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func JsMdBahan() templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var5 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var5 == nil {
+ templ_7745c5c3_Var5 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func BeforeRequestContent() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_BeforeRequestContent_911f`,
+ Function: `function __templ_BeforeRequestContent_911f(){const loadingParent = document.getElementById("loading-parent");
+ const loadingChild = document.getElementById("loading-child");
+ const loadingSpinner = document.getElementById("loading-spinner");
+
+ loadingParent.classList.add("overlay");
+ loadingParent.classList.add("overlay-block");
+ loadingChild.classList.add("overlay-layer");
+ loadingSpinner.classList.remove("d-none");
+}`,
+ Call: templ.SafeScript(`__templ_BeforeRequestContent_911f`),
+ CallInline: templ.SafeScriptInline(`__templ_BeforeRequestContent_911f`),
+ }
+}
+
+func AfterRequestContent() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_AfterRequestContent_6cc0`,
+ Function: `function __templ_AfterRequestContent_6cc0(){const loadingParent = document.getElementById("loading-parent");
+ const loadingChild = document.getElementById("loading-child");
+ const loadingSpinner = document.getElementById("loading-spinner");
+
+ loadingParent.classList.remove("overlay");
+ loadingParent.classList.remove("overlay-block");
+ loadingChild.classList.remove("overlay-layer");
+ loadingSpinner.classList.add("d-none");
+}`,
+ Call: templ.SafeScript(`__templ_AfterRequestContent_6cc0`),
+ CallInline: templ.SafeScriptInline(`__templ_AfterRequestContent_6cc0`),
+ }
+}
+
+func MdBahanFilter(
+ hxGet string,
+ hxTrigger string,
+ hxInclude string,
+ hxSwap string,
+ hxTarget string,
+ dataStation []models.TmpSampleStation,
+ selectedIdStation int,
+ hxBeforeRequest templ.ComponentScript,
+ hxAfterRequest templ.ComponentScript,
+) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var6 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var6 == nil {
+ templ_7745c5c3_Var6 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxBeforeRequest, hxAfterRequest)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customdropdown.CustomDropdownFilter("filter-station",
+ "filterstation",
+ hxInclude,
+ hxGet,
+ hxSwap,
+ hxTarget,
+ "change",
+ hxBeforeRequest,
+ hxAfterRequest, ListItemStation(dataStation, selectedIdStation)).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func ListItemStation(
+ dataStation []models.TmpSampleStation,
+ selectedIdStation int) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var14 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var14 == nil {
+ templ_7745c5c3_Var14 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ for _, v := range dataStation {
+ if v.T_SampleStationID == selectedIdStation {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func ShowMdBahanScreen(title string, cmp templ.Component, css templ.Component, js templ.Component,
+ navbarmenu templ.Component,
+ navbaruser templ.Component,
+ userprofile templ.Component) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var19 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var19 == nil {
+ templ_7745c5c3_Var19 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Var20 := templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ templ_7745c5c3_Err = cmp.Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
+ }
+ return templ_7745c5c3_Err
+ })
+ templ_7745c5c3_Err = layout.CorporateLayout(title, css, js, navbarmenu, navbaruser, userprofile).Render(templ.WithChildren(ctx, templ_7745c5c3_Var20), templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
diff --git a/views/dev/mdbahan/mdbahanformmodal.templ b/views/dev/mdbahan/mdbahanformmodal.templ
new file mode 100644
index 0000000..584ce3c
--- /dev/null
+++ b/views/dev/mdbahan/mdbahanformmodal.templ
@@ -0,0 +1,189 @@
+package dev_mdbahanview
+
+import "cpone/models"
+import "cpone/component/modal"
+import "cpone/component/customtextfield"
+import "cpone/component/customdropdown"
+
+templ BahanForm(data models.BahanFormComponent) {
+
+
+
+}
+
+script HandleFormBeforeRequest() {
+ console.log("handle disable btn add");
+ const btnActCancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+ for (let i = 0; i < btnActCancel.length; i++) {
+ btnActCancel[i].setAttribute('disabled', 'true');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].setAttribute('disabled', 'true');
+
+ }
+}
+
+script HandleFormAfterRequest() {
+ console.log("handle enable btn add");
+
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}
+
+templ BodyFormBahan(inputId string,
+ inputCode models.CustomTextFieldv2Prm,
+ inputName models.CustomTextFieldv2Prm,
+ inputStation models.CustomDropdownV2Prm,
+ componentID string,
+ hxOnLoad templ.ComponentScript) {
+
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId})
+ @customtextfield.CustomTextFieldv2(
+ inputCode)
+ @customtextfield.CustomTextFieldv2(
+ inputName)
+ @customdropdown.CustomDropdownForm(inputStation)
+
+}
+
+script JsHideModal(modalID string) {
+ $(modalID).modal('hide')
+}
+
+script JsShowModal(modalID string) {
+ $(modalID).modal('show')
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}
+
+templ ActionFormBahan(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+
+
+
+}
+
+templ BtnCloseFormBahan(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+}
+
+templ DeleteConfirmationBody(inputId string,
+ componentID string,
+ message string,
+ datHeader []string,
+ dataText []string,
+ hxOnLoad templ.ComponentScript) {
+
+
{ message }
+
+
+
+ for _, v := range datHeader {
+
{ v }
+ }
+
+
+ for _, v := range dataText {
+
+ { v }
+
+ }
+
+
+
+ @customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId})
+
+}
+
+templ ActionFormBahanDelete(LinkClose string, targetClose string, hxSwapClose string, modalID string) {
+
+
+
+
+}
diff --git a/views/dev/mdbahan/mdbahanformmodal_templ.go b/views/dev/mdbahan/mdbahanformmodal_templ.go
new file mode 100644
index 0000000..9670711
--- /dev/null
+++ b/views/dev/mdbahan/mdbahanformmodal_templ.go
@@ -0,0 +1,654 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.663
+package dev_mdbahanview
+
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
+import "github.com/a-h/templ"
+import "context"
+import "io"
+import "bytes"
+
+import "cpone/models"
+import "cpone/component/modal"
+import "cpone/component/customtextfield"
+import "cpone/component/customdropdown"
+
+func BahanForm(data models.BahanFormComponent) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleFormBeforeRequest(), HandleFormAfterRequest())
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func HandleFormBeforeRequest() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleFormBeforeRequest_2922`,
+ Function: `function __templ_HandleFormBeforeRequest_2922(){console.log("handle disable btn add");
+ const btnActCancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+ for (let i = 0; i < btnActCancel.length; i++) {
+ btnActCancel[i].setAttribute('disabled', 'true');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].setAttribute('disabled', 'true');
+
+ }
+}`,
+ Call: templ.SafeScript(`__templ_HandleFormBeforeRequest_2922`),
+ CallInline: templ.SafeScriptInline(`__templ_HandleFormBeforeRequest_2922`),
+ }
+}
+
+func HandleFormAfterRequest() templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleFormAfterRequest_956b`,
+ Function: `function __templ_HandleFormAfterRequest_956b(){console.log("handle enable btn add");
+
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}`,
+ Call: templ.SafeScript(`__templ_HandleFormAfterRequest_956b`),
+ CallInline: templ.SafeScriptInline(`__templ_HandleFormAfterRequest_956b`),
+ }
+}
+
+func BodyFormBahan(inputId string,
+ inputCode models.CustomTextFieldv2Prm,
+ inputName models.CustomTextFieldv2Prm,
+ inputStation models.CustomDropdownV2Prm,
+ componentID string,
+ hxOnLoad templ.ComponentScript) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var9 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var9 == nil {
+ templ_7745c5c3_Var9 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxOnLoad)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(
+ inputCode).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(
+ inputName).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customdropdown.CustomDropdownForm(inputStation).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func JsHideModal(modalID string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_JsHideModal_da6c`,
+ Function: `function __templ_JsHideModal_da6c(modalID){$(modalID).modal('hide')
+}`,
+ Call: templ.SafeScript(`__templ_JsHideModal_da6c`, modalID),
+ CallInline: templ.SafeScriptInline(`__templ_JsHideModal_da6c`, modalID),
+ }
+}
+
+func JsShowModal(modalID string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_JsShowModal_b74d`,
+ Function: `function __templ_JsShowModal_b74d(modalID){$(modalID).modal('show')
+ const btnactcancel = document.querySelectorAll('.btnactcancel');
+ const btnactsavedata = document.querySelectorAll('.btnactsavedata');
+
+
+ for (let i = 0; i < btnactcancel.length; i++) {
+ btnactcancel[i].removeAttribute('disabled');
+
+ }
+ for (let i = 0; i < btnactsavedata.length; i++) {
+ btnactsavedata[i].removeAttribute('disabled');
+
+ }
+}`,
+ Call: templ.SafeScript(`__templ_JsShowModal_b74d`, modalID),
+ CallInline: templ.SafeScriptInline(`__templ_JsShowModal_b74d`, modalID),
+ }
+}
+
+func ActionFormBahan(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var12 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var12 == nil {
+ templ_7745c5c3_Var12 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModal(modalID))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func BtnCloseFormBahan(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var17 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var17 == nil {
+ templ_7745c5c3_Var17 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModal(modalID))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func DeleteConfirmationBody(inputId string,
+ componentID string,
+ message string,
+ datHeader []string,
+ dataText []string,
+ hxOnLoad templ.ComponentScript) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var22 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var22 == nil {
+ templ_7745c5c3_Var22 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, hxOnLoad)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var25 string
+ templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(message)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 145, Col: 14}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ for _, v := range datHeader {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var26 string
+ templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(v)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 150, Col: 68}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ for _, v := range dataText {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var27 string
+ templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(v)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahanformmodal.templ`, Line: 156, Col: 10}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = customtextfield.CustomTextFieldv2(models.CustomTextFieldv2Prm{Name: "bahanid", ID: "bahanID", Type: "hidden", Value: inputId}).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func ActionFormBahanDelete(LinkClose string, targetClose string, hxSwapClose string, modalID string) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var28 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var28 == nil {
+ templ_7745c5c3_Var28 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, JsHideModal(modalID))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
diff --git a/views/dev/mdbahan/mdbahantable.templ b/views/dev/mdbahan/mdbahantable.templ
new file mode 100644
index 0000000..b5bf1d0
--- /dev/null
+++ b/views/dev/mdbahan/mdbahantable.templ
@@ -0,0 +1,130 @@
+package dev_mdbahanview
+
+import "cpone/component/table"
+import "cpone/models"
+import "strconv"
+
+templ TableBahan(data []models.Bahan,
+ tableID string,
+ hxGetEdit string,
+ hxTargetEdit string,
+ hxSwapEdit string,
+ hxIncludeEdit string,
+ hxGetDelete string,
+ hxTargetDelete string,
+ hxSwapDelete string,
+ hxIncludeDelete string,
+) {
+
+ @tablecomponent.TableV3([]string{"KODE", "NAMA BAHAN", "SAMPLE STATION", "AKSI"},
+ []string{"20%", "30%", "30%", "20%"},
+ RowBahan(data,
+ hxGetEdit,
+ hxTargetEdit,
+ hxSwapEdit,
+ hxIncludeEdit,
+ hxGetDelete,
+ hxTargetDelete,
+ hxSwapDelete,
+ hxIncludeDelete,
+ ))
+
+}
+
+templ RowBahan(data []models.Bahan,
+ hxGetEdit string,
+ hxTargetEdit string,
+ hxSwapEdit string,
+ hxIncludeEdit string,
+ hxGetDelete string,
+ hxTargetDelete string,
+ hxSwapDelete string,
+ hxIncludeDelete string,
+) {
+ if len(data) == 0 {
+
+ | Data Tidak Ditemukan |
+
+ }
+ for _, v := range data {
+
+ | { v.T_BahanCode } |
+ { v.T_BahanName } |
+ { v.T_SampleStationName } |
+
+ @TableAction(v.T_BahanID,
+ hxGetEdit,
+ hxTargetEdit,
+ hxSwapEdit,
+ hxIncludeEdit,
+ hxGetDelete,
+ hxTargetDelete,
+ hxSwapDelete,
+ hxIncludeDelete,
+ )
+ |
+
+ }
+}
+
+templ TableAction(
+ id int,
+ hxGetEdit string,
+ hxTargetEdit string,
+ hxSwapEdit string,
+ hxIncludeEdit string,
+ hxGetDelete string,
+ hxTargetDelete string,
+ hxSwapDelete string,
+ hxIncludeDelete string,
+
+) {
+
+}
+
+script HandleBeforeRequestRow(id string) {
+ var cusid_ele = document.getElementsByClassName('btnactbhn');
+ for (var i = 0; i < cusid_ele.length; ++i) {
+ var item = cusid_ele[i];
+ item.classList.add('disabled');
+ }
+ console.log(id)
+}
+
+script HandleAfterRequestRow(id string) {
+ var cusid_ele = document.getElementsByClassName('btnactbhn');
+ for (var i = 0; i < cusid_ele.length; ++i) {
+ var item = cusid_ele[i];
+ item.classList.remove('disabled');
+ }
+ console.log(id)
+}
diff --git a/views/dev/mdbahan/mdbahantable_templ.go b/views/dev/mdbahan/mdbahantable_templ.go
new file mode 100644
index 0000000..7c5bb03
--- /dev/null
+++ b/views/dev/mdbahan/mdbahantable_templ.go
@@ -0,0 +1,451 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.663
+package dev_mdbahanview
+
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
+import "github.com/a-h/templ"
+import "context"
+import "io"
+import "bytes"
+
+import "cpone/component/table"
+import "cpone/models"
+import "strconv"
+
+func TableBahan(data []models.Bahan,
+ tableID string,
+ hxGetEdit string,
+ hxTargetEdit string,
+ hxSwapEdit string,
+ hxIncludeEdit string,
+ hxGetDelete string,
+ hxTargetDelete string,
+ hxSwapDelete string,
+ hxIncludeDelete string,
+) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = tablecomponent.TableV3([]string{"KODE", "NAMA BAHAN", "SAMPLE STATION", "AKSI"},
+ []string{"20%", "30%", "30%", "20%"},
+ RowBahan(data,
+ hxGetEdit,
+ hxTargetEdit,
+ hxSwapEdit,
+ hxIncludeEdit,
+ hxGetDelete,
+ hxTargetDelete,
+ hxSwapDelete,
+ hxIncludeDelete,
+ )).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func RowBahan(data []models.Bahan,
+ hxGetEdit string,
+ hxTargetEdit string,
+ hxSwapEdit string,
+ hxIncludeEdit string,
+ hxGetDelete string,
+ hxTargetDelete string,
+ hxSwapDelete string,
+ hxIncludeDelete string,
+) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var3 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var3 == nil {
+ templ_7745c5c3_Var3 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ if len(data) == 0 {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
| Data Tidak Ditemukan |
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ for _, v := range data {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
| ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_BahanCode)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahantable.templ`, Line: 51, Col: 22}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" | ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var5 string
+ templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_BahanName)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahantable.templ`, Line: 52, Col: 22}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" | ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var6 string
+ templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(v.T_SampleStationName)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `views\dev\mdbahan\mdbahantable.templ`, Line: 53, Col: 30}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" | ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = TableAction(v.T_BahanID,
+ hxGetEdit,
+ hxTargetEdit,
+ hxSwapEdit,
+ hxIncludeEdit,
+ hxGetDelete,
+ hxTargetDelete,
+ hxSwapDelete,
+ hxIncludeDelete,
+ ).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" |
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func TableAction(
+ id int,
+ hxGetEdit string,
+ hxTargetEdit string,
+ hxSwapEdit string,
+ hxIncludeEdit string,
+ hxGetDelete string,
+ hxTargetDelete string,
+ hxSwapDelete string,
+ hxIncludeDelete string,
+
+) templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var7 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var7 == nil {
+ templ_7745c5c3_Var7 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleBeforeRequestRow(strconv.Itoa(id)), HandleAfterRequestRow(strconv.Itoa(id)))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Edit\r ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.RenderScriptItems(ctx, templ_7745c5c3_Buffer, HandleBeforeRequestRow(strconv.Itoa(id)), HandleAfterRequestRow(strconv.Itoa(id)))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Hapus\r")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func HandleBeforeRequestRow(id string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleBeforeRequestRow_7d4f`,
+ Function: `function __templ_HandleBeforeRequestRow_7d4f(id){var cusid_ele = document.getElementsByClassName('btnactbhn');
+ for (var i = 0; i < cusid_ele.length; ++i) {
+ var item = cusid_ele[i];
+ item.classList.add('disabled');
+ }
+ console.log(id)
+}`,
+ Call: templ.SafeScript(`__templ_HandleBeforeRequestRow_7d4f`, id),
+ CallInline: templ.SafeScriptInline(`__templ_HandleBeforeRequestRow_7d4f`, id),
+ }
+}
+
+func HandleAfterRequestRow(id string) templ.ComponentScript {
+ return templ.ComponentScript{
+ Name: `__templ_HandleAfterRequestRow_ce9e`,
+ Function: `function __templ_HandleAfterRequestRow_ce9e(id){var cusid_ele = document.getElementsByClassName('btnactbhn');
+ for (var i = 0; i < cusid_ele.length; ++i) {
+ var item = cusid_ele[i];
+ item.classList.remove('disabled');
+ }
+ console.log(id)
+}`,
+ Call: templ.SafeScript(`__templ_HandleAfterRequestRow_ce9e`, id),
+ CallInline: templ.SafeScriptInline(`__templ_HandleAfterRequestRow_ce9e`, id),
+ }
+}