790 |
790 |
|
791 |
791 |
def pdf_task(params, coords, options={})
|
792 |
792 |
height = options[:height] || 2
|
|
793 |
|
793 |
794 |
# Renders the task bar, with progress and late
|
794 |
795 |
if coords[:bar_start] && coords[:bar_end]
|
795 |
|
params[:pdf].SetY(params[:top] + 1.5)
|
796 |
|
params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
|
|
796 |
top = params[:top] + 1.5
|
|
797 |
width = params[:subject_width] + coords[:bar_start]
|
|
798 |
|
|
799 |
length = coords[:bar_end] - coords[:bar_start]
|
|
800 |
if length <= 0
|
|
801 |
length = 1
|
|
802 |
end
|
|
803 |
params[:pdf].SetY(top)
|
|
804 |
params[:pdf].SetX(width)
|
797 |
805 |
params[:pdf].SetFillColor(200, 200, 200)
|
798 |
|
params[:pdf].RDMCell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1)
|
|
806 |
params[:pdf].RDMCell(length, height, "", 0, 0, "", 1)
|
|
807 |
|
799 |
808 |
if coords[:bar_late_end]
|
800 |
|
params[:pdf].SetY(params[:top] + 1.5)
|
801 |
|
params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
|
|
809 |
length = coords[:bar_late_end] - coords[:bar_start]
|
|
810 |
if length <= 0
|
|
811 |
length = 1
|
|
812 |
end
|
|
813 |
params[:pdf].SetY(top)
|
|
814 |
params[:pdf].SetX(width)
|
802 |
815 |
params[:pdf].SetFillColor(255, 100, 100)
|
803 |
|
params[:pdf].RDMCell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1)
|
|
816 |
params[:pdf].RDMCell(length, height, "", 0, 0, "", 1)
|
804 |
817 |
end
|
|
818 |
|
805 |
819 |
if coords[:bar_progress_end]
|
806 |
|
params[:pdf].SetY(params[:top] + 1.5)
|
807 |
|
params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
|
|
820 |
length = coords[:bar_progress_end] - coords[:bar_start]
|
|
821 |
if length <= 0
|
|
822 |
length = 1
|
|
823 |
end
|
|
824 |
params[:pdf].SetY(top)
|
|
825 |
params[:pdf].SetX(width)
|
808 |
826 |
params[:pdf].SetFillColor(90, 200, 90)
|
809 |
|
params[:pdf].RDMCell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1)
|
|
827 |
params[:pdf].RDMCell(length, height, "", 0, 0, "", 1)
|
810 |
828 |
end
|
811 |
829 |
end
|
|
830 |
|
812 |
831 |
# Renders the markers
|
813 |
832 |
if options[:markers]
|
814 |
833 |
if coords[:start]
|
... | ... | |
824 |
843 |
params[:pdf].RDMCell(2, 2, "", 0, 0, "", 1)
|
825 |
844 |
end
|
826 |
845 |
end
|
|
846 |
|
827 |
847 |
# Renders the label on the right
|
828 |
848 |
if options[:label]
|
829 |
849 |
params[:pdf].SetX(params[:subject_width] + (coords[:bar_end] || 0) + 5)
|
... | ... | |
837 |
857 |
if coords[:bar_start] && coords[:bar_end]
|
838 |
858 |
params[:image].fill('#aaa')
|
839 |
859 |
params[:image].rectangle(params[:subject_width] + coords[:bar_start],
|
840 |
|
params[:top],
|
841 |
|
params[:subject_width] + coords[:bar_end],
|
842 |
|
params[:top] - height)
|
|
860 |
params[:top],
|
|
861 |
params[:subject_width] + coords[:bar_end],
|
|
862 |
params[:top] - height)
|
843 |
863 |
if coords[:bar_late_end]
|
844 |
864 |
params[:image].fill('#f66')
|
845 |
865 |
params[:image].rectangle(params[:subject_width] + coords[:bar_start],
|
846 |
|
params[:top],
|
847 |
|
params[:subject_width] + coords[:bar_late_end],
|
848 |
|
params[:top] - height)
|
|
866 |
params[:top],
|
|
867 |
params[:subject_width] + coords[:bar_late_end],
|
|
868 |
params[:top] - height)
|
849 |
869 |
end
|
850 |
870 |
if coords[:bar_progress_end]
|
851 |
871 |
params[:image].fill('#00c600')
|
852 |
872 |
params[:image].rectangle(params[:subject_width] + coords[:bar_start],
|
853 |
|
params[:top],
|
854 |
|
params[:subject_width] + coords[:bar_progress_end],
|
855 |
|
params[:top] - height)
|
|
873 |
params[:top],
|
|
874 |
params[:subject_width] + coords[:bar_progress_end],
|
|
875 |
params[:top] - height)
|
856 |
876 |
end
|
857 |
877 |
end
|
858 |
878 |
# Renders the markers
|
... | ... | |
874 |
894 |
if options[:label]
|
875 |
895 |
params[:image].fill('black')
|
876 |
896 |
params[:image].text(params[:subject_width] + (coords[:bar_end] || 0) + 5,
|
877 |
|
params[:top] + 1,
|
878 |
|
options[:label])
|
|
897 |
params[:top] + 1,
|
|
898 |
options[:label])
|
879 |
899 |
end
|
880 |
900 |
end
|
881 |
901 |
end
|