   (let [onres (fn [json]
                 (accountant/navigate! "/khasragirdwani"))]
     (http-delete (str serverhost "khasragirdwanis/" id)  onres)))
-
 
 (defroute khasragirdwani-add-path "/khasragirdwani/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")

                        [:div])]])))


(defn cons-sub-onchange [id val data-set]
  (let [res (fn [json]
              (let [dt (getdata json)]
                (set-key-value :villages dt)))]
    (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
        (swap! data-set assoc id (js/parseInt val)))))

(defn cons-sub-sel-tag [id data data-set]
  [:select.form-control {:id id
                         :value (@data-set id)
                         :on-change #(cons-sub-onchange  id (-> % .-target .-value) data-set)}
   [:option {:value 0} "--Select--"]
   (for [d  data]
     ^{:key (.-id d) }
     [:option {:value (.-id d)} (.-subdivisionname d)])])

(defn cons-form-sub-sel [label id opt-data data-set]
  [:div.form-group
   [:label.col-sm-3.control-label label]
   [:div.col-sm-6 [cons-sub-sel-tag id opt-data data-set]]
   [:div.col-sm-3 [:div]]])


(defn cons-villages-sel-tag [id data data-set ]
  [:select.form-control {:id id
                         :value (@data-set id)
                         :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
   [:option {:value 0} "--Select--"]
   (for [d  data]
     ^{:key (.-id d) }
     [:option {:value (.-id d)} (.-villagename d)])])

(defn cons-form-villages-sel [label id opt-data data-set]
  [:div.form-group
   [:label.col-sm-3.control-label label]
   [:div.col-sm-6 [cons-villages-sel-tag id opt-data data-set]]
   [:div.col-sm-3 [:div]]])

(defn consolidation-form-cancel [event]
  (accountant/navigate! "/consolidation"))

(defn consolidation-template [doc-name data-set focus save-function]
  [:div.container

     [:div.form-horizontal
      [:div.box-body
       [revenue-input-int-row :serialnumber "Serial Number" "text" data-set focus]
       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
       [revenue-input-int-row :year "Year" "text" data-set focus]
       [revenue-input-row :racknumber "Rack Number" "text" data-set focus]
       [revenue-input-row :description "Description" "text" data-set focus]]
       [:div.box-footer
        [:div.col-sm-8.col-md-offset-5
         [button-tool-bar
          [button {:bs-style "success" :on-click save-function} "Save"]
          [button {:bs-style "danger" :on-click revenue-form-cancel } "Cancel"]]]
        ]]]]])


(defn revenue-add-form-onclick [data-set focus]
