@@ -2,6 +2,7 @@ package main
22
33import (
44 "database/sql"
5+ "edm/pkg/accs"
56 "encoding/json"
67 "fmt"
78 "log"
@@ -40,7 +41,7 @@ func unmarshalNonEmptyCompanyContacts(c string) (res CompanyContacts) {
4041 if c != "" {
4142 err := json .Unmarshal ([]byte (c ), & res )
4243 if err != nil {
43- log .Println (currentFunction ()+ ":" , err )
44+ log .Println (accs . CurrentFunction ()+ ":" , err )
4445 }
4546 }
4647 return res
@@ -255,6 +256,7 @@ func (u Unit) GiveHeadNameJob() (head string) {
255256// CompanyPage is passed into template
256257type CompanyPage struct {
257258 AppTitle string
259+ AppVersion string
258260 PageTitle string
259261 LoggedinID int
260262 UserConfig UserConfig
@@ -282,6 +284,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
282284
283285 var Page = CompanyPage {
284286 AppTitle : bs .text .AppTitle ,
287+ AppVersion : AppVersion ,
285288 LoggedinID : id ,
286289 Editable : false ,
287290 New : false ,
@@ -293,7 +296,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
293296 Page .Editable = true
294297 }
295298
296- TextID := getTextIDfromURL (r .URL .Path )
299+ TextID := accs . GetTextIDfromURL (r .URL .Path )
297300 IntID , _ := strconv .Atoi (TextID )
298301
299302 var created int
@@ -302,7 +305,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
302305 // Create or update code ==========================================================================
303306 if r .Method == "POST" && (r .FormValue ("createButton" ) != "" || r .FormValue ("updateButton" ) != "" ) {
304307 if Page .Editable == false {
305- throwAccessDenied (w , "writing company" , Page .LoggedinID , IntID )
308+ accs . ThrowAccessDenied (w , "writing company" , Page .LoggedinID , IntID )
306309 return
307310 }
308311 c := Company {
@@ -358,7 +361,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
358361 // Create or update Units =====================================================================
359362 if r .Method == "POST" && (r .FormValue ("createUnit" ) != "" || r .FormValue ("updateUnit" ) != "" ) {
360363 if Page .Editable == false {
361- throwAccessDenied (w , "writing unit" , Page .LoggedinID , IntID )
364+ accs . ThrowAccessDenied (w , "writing unit" , Page .LoggedinID , IntID )
362365 return
363366 }
364367 UnitIntID , _ := strconv .Atoi (r .FormValue ("unitID" ))
@@ -389,7 +392,7 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
389392 // Delete Unit ================+==========================
390393 if r .Method == "POST" && r .FormValue ("deleteUnit" ) != "" {
391394 if Page .Editable == false {
392- throwAccessDenied (w , "writing unit" , Page .LoggedinID , IntID )
395+ accs . ThrowAccessDenied (w , "writing unit" , Page .LoggedinID , IntID )
393396 return
394397 }
395398 UnitIntID , _ := strconv .Atoi (r .FormValue ("unitID" ))
@@ -414,13 +417,13 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
414417 Page .Company .ID = IntID
415418 err = Page .Company .load (bs .db , bs .dbt )
416419 if err != nil {
417- log .Println (currentFunction ()+ ":" , err )
420+ log .Println (accs . CurrentFunction ()+ ":" , err )
418421 http .NotFound (w , r )
419422 return
420423 }
421424 Page .Units , err = Page .Company .loadUnits (bs .db , bs .dbt )
422425 if err != nil {
423- log .Println (currentFunction ()+ ":" , err )
426+ log .Println (accs . CurrentFunction ()+ ":" , err )
424427 http .NotFound (w , r )
425428 return
426429 }
@@ -448,8 +451,8 @@ func (bs *BaseStruct) companyHandler(w http.ResponseWriter, r *http.Request) {
448451 // HTML output
449452 err = bs .templates .ExecuteTemplate (w , "company.tmpl" , Page )
450453 if err != nil {
451- log .Println (currentFunction ()+ ":" , err )
452- throwServerError (w , "executing company template" , Page .LoggedinID , Page .Company .ID )
454+ log .Println (accs . CurrentFunction ()+ ":" , err )
455+ accs . ThrowServerError (w , "executing company template" , Page .LoggedinID , Page .Company .ID )
453456 return
454457 }
455458
0 commit comments