              [obi :as layout.obi]]
             [catalog.web.layout :as layout]
             [cemerick.friend :as friend]
-            [clj-time.core :as time.core]
+            [clj-time
+             [core :as time.core]
+             [format :as time.format]]
             [clojure
              [edn :as edn]
              [string :as string]]

(defmulti custom (fn [_ _ _ _ _ fmt _] fmt))

(defmethod custom :pdf [request year issue query customer fmt items]
  (let [temp-file (java.io.File/createTempFile "custom-catalog" ".pdf")]
    (-> items
        edn/read-string
        vubis/order
        (layout.fop/document :custom year issue nil nil :query query :customer customer)
        (layout.fop/generate-pdf! temp-file))
    (-> temp-file
        response/response
        (response/content-type "application/pdf"))))

(defmethod custom :grossdruck [request year issue query customer fmt items]
  (let [temp-file (java.io.File/createTempFile "custom-catalog" ".pdf")]
    (-> items
        edn/read-string
        vubis/order
        (layout.fop/document :custom-grossdruck year issue nil nil :query query :customer customer)
        (layout.fop/generate-pdf! temp-file))
    (-> temp-file
        response/response
        (response/content-type "application/pdf"))))

(defmethod custom :braille [request year issue query customer fmt items]
  (-> items
      edn/read-string
      vubis/order
      (layout.dtbook/dtbook {:query query :customer customer})
      response/response
      (response/content-type "application/xml")))


  [title year issue file-name]
  [:div.well
   [:h2 title]
   (download-button (download-url year issue file-name))])

(defn home
  ([request]
