bsw@1248: local id = param.get_id() bsw@1248: bsw@1248: local newsletter = {} bsw@1248: bsw@1248: if id then bsw@1248: newsletter = Newsletter:by_id(id) bsw@1248: end bsw@1248: bsw@1248: ui.titleAdmin(_"Newsletter") bsw@1248: bsw@1248: ui.form{ bsw@1248: attr = { class = "vertical section" }, bsw@1248: module = "admin", bsw@1248: action = "newsletter_update", bsw@1248: id = newsletter and newsletter.id, bsw@1248: record = newsletter, bsw@1248: routing = { bsw@1248: default = { bsw@1248: mode = "redirect", bsw@1248: modules = "admin", bsw@1248: view = "newsletter_list" bsw@1248: } bsw@1248: }, bsw@1248: content = function() bsw@1248: bsw@1248: ui.sectionHead( function() bsw@1248: ui.heading { level = 1, content = newsletter and (newsletter.subject) or _"New newsletter" } bsw@1248: end ) bsw@1248: bsw@1248: ui.sectionRow( function() bsw@1248: local units = { bsw@1248: { id = 0, name = _"All members" }, bsw@1248: { id = "_", name = _"" }, bsw@1248: } bsw@1248: for i, unit in ipairs(Unit:get_flattened_tree()) do bsw@1248: units[#units+1] = unit bsw@1248: end bsw@1248: ui.field.text{ label = _"Date", name = "published" } bsw@1248: ui.field.select{ bsw@1248: label = "Recipient", bsw@1248: name = "unit_id", bsw@1248: foreign_records = units, bsw@1248: foreign_id = "id", bsw@1248: foreign_name = "name", bsw@1248: disabled_records = { ["_"] = true }, bsw@1248: value = newsletter.unit_id bsw@1248: } bsw@1248: ui.field.boolean{ label = _"Override disable notifications?", name = "include_all_members" } bsw@1248: slot.put("
") bsw@1248: ui.field.text{ label = _"Subject", name = "subject" } bsw@1248: ui.field.text{ label = _"Content", name = "content", multiline = true, attr = { rows = "20" } } bsw@1248: bsw@1248: ui.submit{ text = _"create newsletter" } bsw@1248: slot.put(" ") bsw@1248: ui.link { module = "admin", view = "index", content = _"cancel" } bsw@1248: end ) bsw@1248: end bsw@1248: } bsw@1248: