add dialog cetak mcu
This commit is contained in:
@@ -1,13 +1,24 @@
|
||||
package corporate_handlers
|
||||
|
||||
import (
|
||||
breadcrumadmin "cpone/component/breadcrumbadmin"
|
||||
navbarmenu "cpone/component/navbar"
|
||||
"cpone/component/pagination"
|
||||
sidebaruserprofile "cpone/component/sidebar_user_profile"
|
||||
"cpone/models"
|
||||
"cpone/services"
|
||||
"cpone/utils"
|
||||
corporate_patient "cpone/views/corporate/patient"
|
||||
"strconv"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/labstack/echo/v4"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type PatientService interface {
|
||||
GetDashboardPatientBreadcrumb(title string) (models.BreadCrumbV1, error)
|
||||
ListingData(search string, date string, patID string, corpId string, currentpage int, rowperpage int) ([]models.DashboardPatient, int, error)
|
||||
}
|
||||
|
||||
func NewPatientHandler(us PatientService) *PatientHandler {
|
||||
@@ -20,7 +31,174 @@ type PatientHandler struct {
|
||||
PatientService PatientService
|
||||
}
|
||||
|
||||
func (uh *PatientHandler) ShowPatient(c echo.Context) error {
|
||||
helo := corporate_patient.Show()
|
||||
return utils.View(c, helo)
|
||||
func (ph *PatientHandler) HandleShowPatient(c echo.Context) error {
|
||||
logger, _ := zap.NewProduction()
|
||||
title := "Nanda Arisu"
|
||||
|
||||
listID := utils.GenerateRandomID("listid")
|
||||
paginationID := utils.GenerateRandomID("paginationid")
|
||||
dialogID := utils.GenerateRandomID("dialogid")
|
||||
dialogBodyID := utils.GenerateRandomID("dialogbodyid")
|
||||
|
||||
user, err := services.GetUserLogin()
|
||||
if err != nil {
|
||||
defer logger.Sync()
|
||||
logger.Info("Error get user", zap.Any("error", err))
|
||||
return err
|
||||
}
|
||||
|
||||
dataBreadcrumb, err := ph.PatientService.GetDashboardPatientBreadcrumb(title)
|
||||
if err != nil {
|
||||
defer logger.Sync()
|
||||
logger.Info("Error breadcrumb", zap.Any("error", err))
|
||||
return err
|
||||
}
|
||||
defer logger.Sync()
|
||||
|
||||
navbaruser := navbarmenu.NavbarWithLogo(user)
|
||||
sidbaruser := sidebaruserprofile.Navbaruserprofile(user)
|
||||
breadcrumb := breadcrumadmin.MainBreadcrumbAdminV1(dataBreadcrumb)
|
||||
|
||||
listingdata, totalPage, err := ph.PatientService.ListingData("", "", "108", "40", 1, 5)
|
||||
if err != nil {
|
||||
defer logger.Sync()
|
||||
logger.Info("error get listing data", zap.Any("error", err), zap.Any("total", totalPage))
|
||||
return err
|
||||
}
|
||||
listingcomponent := corporate_patient.ListingData(listingdata,
|
||||
listID,
|
||||
"/corp/dashboard_pat/opencetak",
|
||||
"#"+dialogBodyID,
|
||||
"outerHTML",
|
||||
"#dialogID, #dialogBodyID",
|
||||
)
|
||||
|
||||
paginationcomponent := pagination.PaginationV3(
|
||||
totalPage,
|
||||
1,
|
||||
"/corp/dashboard_pat/changepage",
|
||||
paginationID,
|
||||
"#listID, #paginationID, #dialogID, #dialogBodyID",
|
||||
"#"+paginationID,
|
||||
"outerHTML", "", "",
|
||||
corporate_patient.BeforeRequestContent(),
|
||||
corporate_patient.AfterRequestContent(),
|
||||
)
|
||||
|
||||
dialogBody := corporate_patient.BodyDialogPat(
|
||||
dialogBodyID,
|
||||
corporate_patient.JSHideModal(""),
|
||||
)
|
||||
|
||||
dialogClose := corporate_patient.BtnClosePat(
|
||||
"/corp/dashboard_pat/closecetak",
|
||||
"#"+dialogBodyID,
|
||||
"outerHTML",
|
||||
"#"+dialogID,
|
||||
)
|
||||
|
||||
dialogCetak := corporate_patient.PatientDialogForm(
|
||||
"cetakdialog",
|
||||
"/corp/dashboard_pat/cetak",
|
||||
"#"+dialogBodyID,
|
||||
"outerHTML",
|
||||
"#listID, #paginationID, #dialogID, #dialogBodyID",
|
||||
dialogID,
|
||||
"Cetak",
|
||||
dialogBody,
|
||||
dialogClose,
|
||||
)
|
||||
|
||||
content := corporate_patient.DashboardPat(
|
||||
listID,
|
||||
paginationID,
|
||||
dialogID,
|
||||
dialogBodyID,
|
||||
breadcrumb,
|
||||
listingcomponent,
|
||||
paginationcomponent,
|
||||
dialogCetak,
|
||||
)
|
||||
css := corporate_patient.CSSDashboardPat()
|
||||
js := corporate_patient.JSDashboardPat()
|
||||
|
||||
view := corporate_patient.ShowDashboardPat(title, content, css, js, navbaruser, sidbaruser)
|
||||
return utils.View(c, view)
|
||||
}
|
||||
|
||||
func (ph *PatientHandler) HandleChangePage(c echo.Context) error {
|
||||
logger, _ := zap.NewProduction()
|
||||
|
||||
pageparam := c.QueryParam("page")
|
||||
listID := c.QueryParam("listID")
|
||||
paginationID := c.QueryParam("paginationID")
|
||||
dialogBodyID := c.QueryParam("dialogBodyID")
|
||||
|
||||
var retval []templ.Component
|
||||
page, err := strconv.Atoi(pageparam)
|
||||
if err != nil {
|
||||
defer logger.Sync()
|
||||
logger.Info("error convert page param")
|
||||
return err
|
||||
}
|
||||
|
||||
listData, totalPage, err := ph.PatientService.ListingData("", "", "108", "40", page, 5)
|
||||
if err != nil {
|
||||
defer logger.Sync()
|
||||
logger.Info("error get data listing")
|
||||
return err
|
||||
}
|
||||
listcomponent := corporate_patient.ListingData(listData,
|
||||
listID,
|
||||
"/corp/dashboard_pat/opencetak",
|
||||
"#"+dialogBodyID,
|
||||
"outerHTML",
|
||||
"#dialogID, #dialogBodyID",
|
||||
)
|
||||
|
||||
paginationcomponent := pagination.PaginationV3(
|
||||
totalPage,
|
||||
page,
|
||||
"/corp/dashboard_pat/changepage",
|
||||
paginationID,
|
||||
"#listID, #paginationID",
|
||||
"#"+paginationID,
|
||||
"outerHTML", "", "",
|
||||
corporate_patient.BeforeRequestContent(),
|
||||
corporate_patient.AfterRequestContent(),
|
||||
)
|
||||
|
||||
retval = append(retval, listcomponent)
|
||||
retval = append(retval, paginationcomponent)
|
||||
return utils.ViewMulti(c, retval)
|
||||
}
|
||||
|
||||
func (ph *PatientHandler) HandleOpenDialog(c echo.Context) error {
|
||||
logger, _ := zap.NewProduction()
|
||||
defer logger.Sync()
|
||||
|
||||
id := c.QueryParam("id")
|
||||
logger.Info("params", zap.Any("id", id))
|
||||
dialogID := c.QueryParam("dialogID")
|
||||
dialogBodyID := c.QueryParam("dialogBodyID")
|
||||
|
||||
dialogBody := corporate_patient.BodyDialogPat(
|
||||
dialogBodyID,
|
||||
corporate_patient.JSShowModal("#"+dialogID),
|
||||
)
|
||||
|
||||
return utils.View(c, dialogBody)
|
||||
}
|
||||
|
||||
func (ph *PatientHandler) HandleCloseDialog(c echo.Context) error {
|
||||
// logger, _ := zap.NewProduction()
|
||||
|
||||
dialogBodyID := c.QueryParam("dialogBodyID")
|
||||
|
||||
dialogBody := corporate_patient.BodyDialogPat(
|
||||
dialogBodyID,
|
||||
corporate_patient.JSHideModal(""),
|
||||
)
|
||||
|
||||
return utils.View(c, dialogBody)
|
||||
}
|
||||
|
||||
@@ -126,8 +126,16 @@ func SetupRoutesCorporate(app *echo.Echo, appStore db.AppStore) {
|
||||
corp.GET("/dashboard_pic/detail/:id/tabdaftarpeserta", daftarpesertaHandl.HandleShowTabDaftarPeserta)
|
||||
corp.GET("/dashboard_pic/detail/:id/tabdaftarpeserta/changepage", daftarpesertaHandl.HandlePagination)
|
||||
|
||||
patientHandler := corporate_handlers.NewPatientHandler(l)
|
||||
corp.GET("/patient", patientHandler.ShowPatient)
|
||||
patienServices := corporate_services.NewPatientServices(appStore)
|
||||
patientHandler := corporate_handlers.NewPatientHandler(patienServices)
|
||||
corp.GET("/dashboard_pat", patientHandler.HandleShowPatient)
|
||||
corp.GET("/dashboard_pat/changepage", patientHandler.HandleChangePage)
|
||||
corp.GET("/dashboard_pat/opencetak", patientHandler.HandleOpenDialog)
|
||||
corp.POST("/dashboard_pat/closecetak", patientHandler.HandleCloseDialog)
|
||||
|
||||
// dev.GET("/md/samplestation/openedit", devMDSampleStationHandlers.HandleOpenEditForm)
|
||||
// dev.POST("/md/samplestation/edit", devMDSampleStationHandlers.HandleEditMDSS)
|
||||
// dev.POST("/md/samplestation/closeeditform", devMDSampleStationHandlers.HandleCloseEditForm)
|
||||
}
|
||||
|
||||
func SetupRoutesClient(app *echo.Echo, appStore db.AppStore) {
|
||||
|
||||
Reference in New Issue
Block a user