;;; Ystok Reporting Utility - Report board - Example file with defintions (rr:define-category cat1 () :title "Category 1") (rr:define-category cat2 () :title "Category 2") (rr:define-category cat12 (cat1 cat2) :title "Subcategory of 1 and 2") (rr:define-report list-of-reports-defined (:categories cat1 :format :pdf) :title "Sample list of all reports defined" :interval '(:start t :end t :range :today) ; not actually used but only printed :panes `((ywi:data-text-pane :title "Report subtitle:" :name :subtitle :data "Arbitrary text printed under the title") (ywi:data-option-pane :title "Report category:" :name :category :selected-item 3 :print-function rr:report-title :items ,ywi:+items-uninitialized+ :pane-args (:items rr::*categories*) ; categories are only known at run-time :help-key "Specify the category of reports listed") (ywi:data-list-panel :title "Selected reports:" :title-position :top :name :list :interaction :multiple-selection :print-function rr:report-title :pane-args (:items (funcall rr:report-list t) :nullable t :refresh t))) :help-key "Tabulate all the reports defined under the category specified.") (rr:define-report pdf-1-and-2-1 (:categories (cat1 cat2) :format :pdf) :title "Sample report categorized under 1 & 2" :interval '(nil ; optional default value :start t :end t :range :month) ;:history '((:MONTH . 2) (:WEEK . :THIS))) ;:start @2005-08-23 :end @2005-08-28 :panes '((ywi:data-text-pane :title "Text pane:" :name :text1 :data "value1") (ywi:data-option-pane :title "Option pane:" :name :option1 :items (1 2 3 4 5) :selected-item 3 :message "Message for the option pane") (ywi:data-list-panel :title "List panel:" :title-position :top :name :list1 :items ("item-1" #2="item-2" "item-3" "item-4"))) :default-initargs (list :list1 #2#)) (rr:define-report sample-tab-separated-12-1 (:categories cat12 :format :excel) :interval '(:end t :end-kind :week)) (defun list-of-reports-defined (face report format &key interval subtitle category list ; correspond to panes (operation :print) (pathname (merge-pathnames "list-of-reports-defined.pdf" (yl:get-folder-namestring :temp))) &allow-other-keys) (declare (optimize (speed 0) (space 3))) (let ((bounds (tt:compute-page-bounds :A4 :portrait)) (margins rr:*portrait-margins*)) (tt:with-quad (left-margin top-margin right-margin) margins (declare (ignore top-margin)) (let* ((embed-fonts (case operation ((:print :preview) (yl:thys-preference 'rr:embed-fonts)) (otherwise t))) (rr:*normal-font* (rr:require-cyr-font :arial nil embed-fonts)) (rr:*normal-font-size* 10) ;(normal-font-size object component)) (tt:*default-font* rr:*normal-font*) (tt:*default-font-size* rr:*normal-font-size*) (tt:*leading-ratio* 1.0) (page-width (aref bounds 2)) (width (- page-width left-margin right-margin)) (title (rr:report-title report)) (total 0) (selected 0) content) (tt:with-document (:title title :creator (rr:pdf-creator)) (tt:set-style (:color 0 :font rr:*normal-font* :font-size rr:*normal-font-size*)) (setq content (tt:compile-text () (tt:p (:h-align :fill :font-size 12) "Report: " title :hfill (tt:format-string "Time interval (unused): ~a" interval)) ;(lt:d-interval-princ-to-string begin end))) (tt:p () "Subtitle: " subtitle :eol (tt:format-string "Category: ~a" category)) (tt:table (:col-widths `(80 160 ,(- width 80 160 40 (* 1/2 (1+ 4)) (* 1 8)) 40) :splittable-p t ;:inline t :border 1/2 :padding 0 :cell-padding 1) (tt:header-row () (tt:cell () (tt:p (:h-align :center :font-size 8.0) "Name")) (tt:cell () (tt:p (:h-align :center :font-size 8.0) "Categories")) (tt:cell () (tt:p (:h-align :center :font-size 8.0) "Title")) (tt:cell () (tt:p (:h-align :center :font-size 8.0) "Selected"))) (dolist (report (rr:report-list category)) (tt:row () (tt:cell () (tt:p (:h-align :center) (tt:verbatim (string (slot-value report 'rr::name))))) (tt:cell () (tt:format-string "~{~s~^~%~}" (rr::categories report))) (tt:cell () (tt:output (rr:report-title report))) (tt:cell () (tt:p (:h-align :center) (tt:verbatim (if (member report list) (progn (incf selected) "+") "-"))))) (incf total))) (tt:p (:h-align :right :font-size 12) (tt:format-string "Total ~a Selected ~a" total selected)) )) (tt:draw-pages content :margins margins :break :after) (rr:pdf-write-document pathname :after operation :interface face) ) )))) ;(rr::direct-subcategories 'cat2) ;(setq r (rr::find-report 'list-of-reports-defined))