ApplicantTest_ITALTHAI.jsp 37 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758
    <%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
    <%@page import="com.csc.library.utility.DHMConvert" %>
    <%@page import="java.util.ArrayList" %>
    <%@page import="java.util.Iterator" %>
    <%@page import="java.util.Vector" %>
    <%@page import="java.util.*" %>
    <%@page import="com.csc.library.report.ReportUDF" %>
    <%@page import="javax.servlet.jsp.jstl.sql.Result" %>
    <%@page import="java.io.FileOutputStream" %>
    <%@page import="java.io.OutputStream" %>
    <%@page import="java.io.ByteArrayOutputStream" %>
    <%@page import="java.net.URLDecoder" %>
    <%@page import="java.text.DecimalFormat" %>
    <%@page import="java.net.URLEncoder" %>
    <%@page import="java.util.HashMap" %>
    <%@page import="java.text.SimpleDateFormat" %>
    <%@page import="java.util.Locale" %>
    <%@page import="java.util.Date" %>
    <%@page import="java.util.GregorianCalendar" %>
    <%@page import="com.csc.library.database.DataSet" %>
    <%@page import="com.csc.library.session.InitialInquiry" %>
    <%@page import="com.csc.library.session.InitialRecord" %>
    <%@page import="com.csc.library.session.DbInquiry" %>
    <%@page import="com.csc.library.session.DbRecord" %>
    <%@page import="com.csc.library.entry.HelpEntry" %>
    <%@page import="com.itextpdf.text.*" %>
    <%@page import="com.itextpdf.text.pdf.*" %>
    <%@page import="java.io.ByteArrayOutputStream" %>
    <%@page import="com.csc.library.session.InitialEnvironment" %>
    <%@page import="java.io.File" %>
    <%@page import="org.json.JSONArray" %>
    <%@page import="org.json.JSONObject" %>
    <%@page import="com.csc.library.utilities.*" %>
    <%@ page import="com.csc.library.databean.Simmapplicantwithgson" %>
    <%@ page import="com.csc.library.database.MyHashMap" %>
    <%@ page import="com.csc.library.utilities.gsonmapping.*" %>
    <%-- AddFor Make Chart --%>
    <%@ page import="java.awt.Color" %>
    <%@ page import="java.awt.BasicStroke" %>
    <%@ page import="java.text.NumberFormat" %>
    <%@ page import="java.awt.image.BufferedImage" %>
    <%@ page import="javax.swing.JFrame" %>
    <%@ page import="org.jfree.chart.axis.NumberAxis" %>
    <%@ page import="org.jfree.chart.JFreeChart" %>
    <%@ page import="org.jfree.chart.ChartPanel" %>
    <%@ page import="org.jfree.chart.ChartFactory" %>
    <%@ page import="org.jfree.chart.axis.TickUnitSource" %>
    <%@ page import="org.jfree.chart.labels.StandardCategoryItemLabelGenerator" %>
    <%@ page import="org.jfree.chart.labels.StandardXYItemLabelGenerator" %>
    <%@ page import="org.jfree.chart.labels.CategoryItemLabelGenerator" %>
    <%@ page import="org.jfree.chart.labels.XYItemLabelGenerator" %>
    <%@ page import="org.jfree.chart.plot.XYPlot" %>
    <%@ page import="org.jfree.chart.plot.CategoryPlot" %>
    <%@ page import="org.jfree.chart.plot.PlotOrientation" %>
    <%@ page import="org.jfree.chart.renderer.xy.XYLineAndShapeRenderer" %>
    <%@ page import="org.jfree.chart.renderer.category.LineAndShapeRenderer" %>
    <%@ page import="org.jfree.ui.TextAnchor" %>
    <%@ page import="org.jfree.ui.ApplicationFrame" %>
    <%@ page import="org.jfree.ui.RefineryUtilities" %>
    <%@ page import="org.jfree.ui.RectangleInsets" %>
    <%@ page import="org.jfree.data.xy.DefaultXYDataset" %>
    <%@ page import="org.jfree.data.category.DefaultCategoryDataset" %>
    <%@ page import="org.jfree.data.xy.XYDataset" %>
    <%@ page import="org.jfree.data.xy.XYSeries" %>
    <%@ page import="org.jfree.data.xy.XYSeriesCollection" %> 
    <%@ page import="org.jfree.chart.renderer.xy.AbstractXYItemRenderer" %>
    <%@ page import="org.jfree.chart.renderer.category.StatisticalLineAndShapeRenderer" %>
    <%@ page import="org.jfree.data.statistics.DefaultStatisticalCategoryDataset" %>
    <%@ page import="javax.swing.JPanel" %>

    <jsp:useBean id="ApplicantTest_ITALTHAI" class="com.csc.library.system.Task" scope="page"/>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8"/>
    <title>Report</title>
    </head>
    <body>
  
    <%
    ApplicantTest_ITALTHAI.setChannel(request, response);
    HelpEntry screen = (HelpEntry) ApplicantTest_ITALTHAI.process("HelpEntry", "MAPPLICANTHELP");
    CheckNull chk = new CheckNull();

    String filter = "APPLICANTID = '" + chk.chkNullString(request.getParameter("appid")) + "'";
    //    filter = "1=2";

    screen.setMaxLine(1);
    screen.inq.setFilter(filter);
    screen.process();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();//72
    Document document = new Document(PageSize.A4, 25, 25, 20, 0);// Left,Right,Top,Down
    PdfWriter writer = null;
    float[] sizeColumn = new float[]{};
    writer = PdfWriter.getInstance(document, baos);

    document.open();
    document.addTitle("Document Title");
    
    // Setting Fonts
    BaseFont bfWithFontAWesome = BaseFont.createFont(application.getRealPath("fonts/FontAwesome.otf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    BaseFont bf = BaseFont.createFont(application.getRealPath("fonts/Cordia.ttf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
    BaseFont bfHead = BaseFont.createFont(application.getRealPath("fonts/Cordia.ttf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true);
    Font font = new Font(bf, 11);
    Font fontTopic = new Font(bfHead, 13);  
    Font fontHead = new Font(bfHead, 13, Font.BOLD);
    Font fontHeadWhiteColor = new Font(bfHead, 12, Font.BOLD, new BaseColor(255, 255, 255));
    fontHead.setStyle(Font.BOLD);
    Font fontContent = new Font(bfHead, 10);
    Font fontContent01 = new Font(bfHead, 9);
    Font fontBoldContent = new Font(bfHead, 11, Font.BOLD);
    Font fontTitle = new Font(bfHead, 20, Font.BOLD);
    fontTitle.setStyle(Font.BOLD);
    Font fontAwesome = new Font(bfWithFontAWesome, 10);
    //setfonts
    Font font_C18B = new Font(bfHead, 18, Font.BOLD);
    Font font_C16B = new Font(bfHead, 16, Font.BOLD);
    Font font_C13B = new Font(bfHead, 13,Font.BOLD);
    Font font_C13N = new Font(bfHead, 13);
    Font font_C12B = new Font(bfHead, 12,Font.BOLD);
    Font font_C12N = new Font(bfHead, 12);
    Font font_C10N = new Font(bfHead, 10);
    Font font_C08N = new Font(bfHead, 8);
    Font linebreak = new Font(bfHead, 1);
    // set vlign middle
    String[] text2 = new String[2];
    Phrase content = new Phrase(new Chunk("",linebreak));
    Float fontSize = content.getFont().getSize();
    Float capHeight = content.getFont().getBaseFont().getFontDescriptor(BaseFont.CAPHEIGHT, fontSize);

    boolean hasData = false;
    if (screen.getInquiry().recCount() > 0) {
      hasData = true;
      screen.nextRec();
      screen.referLangOn();
      DbInquiry dbinq = null;
      int i = 0;
      
      Simmapplicantwithgson simmapplicantwithgson = (Simmapplicantwithgson) screen.inq.getCurrentDbRecord();
    //----------------------------SETDATA Jobrouter ------------------------------------
      MyHashMap hashmap_jobrouter = new MyHashMap();
      int roundAnswer = 0;
 //    int roundID = 0;
      int roundLoop = 0;
      int jobexpkey =0 ;
      for ( jobexpkey = 0; jobexpkey < 40; jobexpkey++){
        hashmap_jobrouter.put("answer" + jobexpkey , "");
        hashmap_jobrouter.put("id" + jobexpkey , "");
        hashmap_jobrouter.put("value" + jobexpkey , "");
      }

      for (MapplicantJobrouter.JobRouter jobrouter : simmapplicantwithgson.mapplicantJobrouter.jobrouter){
        if(jobrouter.question != null){
          for (MapplicantJobrouter.JobRouter.Question question : jobrouter.question){

            hashmap_jobrouter.put("answer" + roundAnswer, question.ansgroup.answer);  
            if(question.ansgroup.choice != null){
              for (MapplicantJobrouter.JobRouter.Question.AnsGroup.Choice choice : question.ansgroup.choice){
                hashmap_jobrouter.put("id"+roundAnswer + roundLoop ,choice.id);
                hashmap_jobrouter.put("value"+roundAnswer + roundLoop, choice.value);
           //     roundID++; //start 0-39
                roundLoop++; //start 0-3 then loop 39 time
                  if(roundLoop == 4){
                    roundLoop = 0;
                  }
                }  
            }
            roundAnswer++;
          }
        }
      }
  //----------------------------Calulate JobRouter 40 Choice ----------------------------------------
      String DataValue[] = new String[40];
      String ChkValue[] = new String[40];
      int countchoice = 0;
      for(int countNum=0;countNum < 40;countNum++){
        for(int number=0;number < 4;number++){
     //  detail.addCell(getCellData(chk.chkNullString( " id"+hashmap_jobrouter.get("id"+countNum+number).toString(),"xx")+" / va "+chk.chkNullString(hashmap_jobrouter.get("value"+countNum+number).toString(),"xx"), font_C12N, "", "LEFT", "BOTTOM", 1, 1));
          if((hashmap_jobrouter.get("answer"+countNum).toString()).equals(hashmap_jobrouter.get("id"+countNum+number).toString())){
              DataValue[countNum] = hashmap_jobrouter.get("value"+countNum+number).toString();
            }     
            else if((hashmap_jobrouter.get("answer"+countNum).toString()).equals("-1")){
              //ให้มีเพื่อป้องกันไม่ให้เกิด Bug
            DataValue[countNum] = hashmap_jobrouter.get("value"+countNum+number).toString();
            }
          }
      }   
      for(int countNum = 0;countNum < 40;countNum++){
        if(DataValue[countNum].equals("1"))
          { hashmap_jobrouter.putToSum("D",1);}
        else if(DataValue[countNum].equals("2"))
          { hashmap_jobrouter.putToSum("I",1);}
        else if(DataValue[countNum].equals("3"))
          { hashmap_jobrouter.putToSum("S",1);}
        else if(DataValue[countNum].equals("4"))
          { hashmap_jobrouter.putToSum("C",1);}
          else if(DataValue[countNum].equals("-1"))
          {
            hashmap_jobrouter.putToSum("D",0);
            hashmap_jobrouter.putToSum("I",0);
            hashmap_jobrouter.putToSum("S",0);
            hashmap_jobrouter.putToSum("C",0);
          }
      }
      // Add Value Use for Chart
      int DValue = Integer.valueOf(hashmap_jobrouter.get("D").toString());
      int IValue = Integer.valueOf(hashmap_jobrouter.get("I").toString());
      int SValue = Integer.valueOf(hashmap_jobrouter.get("S").toString());
      int KValue = Integer.valueOf(hashmap_jobrouter.get("C").toString());

      //----- Start Chk data answer == "-1" if data = -1 set ALL VALUES IS 0 -----
      for(int countNum = 0;countNum < 40;countNum++){
          ChkValue[countNum] = hashmap_jobrouter.get("answer"+countNum).toString();
      }
      for(int countNum = 0;countNum < 40;countNum++){
        if(ChkValue[countNum].equalsIgnoreCase("-1")){
          DValue = 0;
          IValue = 0;
          SValue = 0;
          KValue = 0;
        }
      }
      //----- End Chk data answer == "-1" if data = -1 set ALL VALUES IS 0 -----
    //----------------------------END Calulate JobRouter 40 Choice ----------------------------------------

    //----------------------------End Jobrouter ----------------------------------------
    try {
      CscCalendar calendar = new CscCalendar();
      GregorianCalendar gc = new GregorianCalendar();
      boolean langthai = screen.getUProfile().get("lang").equalsIgnoreCase("THA");
      String reportname = "", printdate = "", printby = "", refer = "RTA2007";
      String reportname_label = "", printdate_label = "", prdate = "", refer_label = "";
      if (langthai) {
      reportname_label = "รายงาน :";
      reportname = "รายงานข้อมูลพนักงาน";
      printdate_label = "วันที่พิมพ์ :";
      prdate = calendar.getDDMMYYYY();
      printdate = "วัน" + calendar.getLongThiDOW() + "ที่ " + calendar.getDate() + " " + calendar.getThaiLongMonth() + " พ.ศ. " + calendar.getThaiYYYY() + " " + calendar.getHHMM() + " น.";
      printby = screen.getUProfile().get("tfullname");
      refer_label = "อ้างอิง #";
      } else {
      reportname_label = "Report Name :";
      reportname = "Personal Report";
      printdate_label = "Print Date :";
      printby = screen.getUProfile().get("efullname");
      refer_label = "Ref #";
    }
    // --------------- new line -----------------
      sizeColumn = new float[]{100.0f};
      PdfPTable detail = new PdfPTable(1);
      detail.setWidthPercentage(100);
      detail.setWidths(sizeColumn);
      setPaddingTop(1.0f);
      setPaddingLeft(3.5f);
      setPaddingRight(3.5f);
      setPaddingBottom(3.5f);

      String Fname = simmapplicantwithgson.mapplicantPersonal.fname.tha;
      String Lname = simmapplicantwithgson.mapplicantPersonal.lname.tha;
      String prefixid  = simmapplicantwithgson.mapplicantPersonal.prefixid;
      String prefixid2  = "";
      DbInquiry DBprefix = new InitialInquiry(screen.getUProfile()).getDbInquiry("mprefix");
      DBprefix.setFilter("prefixid = '" + prefixid + "'");
      DBprefix.refresh();
      while (DBprefix.next()) {
        prefixid2 = DBprefix.getString("tdesc");
      }

      detail.addCell(getCellData("ผลการทดสอบบุคลิกภาพ DISC", font_C18B, "NO", "CENTER", "MIDDLE", 1, 1));
      detail.addCell(getCellData(prefixid2 +" "+Fname+"  "+Lname, font_C18B, "NO", "CENTER", "MIDDLE", 1, 1));
      setPaddingBottom(0.5f);
      detail.addCell(getCellData(" ", linebreak, "NO", "CENTER", "MIDDLE", 1, 1));
      document.add(detail);

    // --------------- new line -----------------
      sizeColumn = new float[]{100.0f};
      detail = new PdfPTable(1);
      detail.setWidthPercentage(100);
      detail.setWidths(sizeColumn);
      PdfPCell cellDetail;
      setPaddingTop(2.0f);
      setPaddingLeft(3.5f);
      setPaddingRight(3.5f);
      setPaddingBottom(3.5f);
      //Make a Chart
      int width = 425;
      int height = 200;
      Image img = null;
/*// USE FOR createXYLineChart
      XYDataset dataset = createDataset();
      JFreeChart Jchart = createChart(dataset);
 */
      JFreeChart Jchart = generateBarChart(DValue,IValue,SValue,KValue);
      Jchart.setBackgroundPaint(Color.WHITE);
       //  Jchart.setVisible(true);
      BufferedImage bufferedImage = Jchart.createBufferedImage(width, height);
      Image image = Image.getInstance(writer, bufferedImage, 1.0f);
      image.setAlignment(Element.ALIGN_CENTER);
      document.add(image);
   
      // --------------- new line -----------------
          sizeColumn = new float[] {25.0f,25.0f,25.0f,25.0f}; 
          detail = new PdfPTable(4);
          detail.setWidthPercentage(100);
          detail.setWidths(sizeColumn);
          setPaddingTop(0.5f);
          setPaddingLeft(3.5f);
          setPaddingRight(3.5f);
          setPaddingBottom(0.5f);
      // Loop  check  answer
 /*     for(int countNum=0;countNum < 40;countNum++){
      detail.addCell(getCellData(hashmap_jobrouter.get("answer"+countNum).toString(), font_C10N, "", "LEFT", "BOTTOM", 1, 1));
      }
          detail.addCell(getCellData("======", font_C12N, "", "CENTER", "BOTTOM", 4, 1));

      for(int countNum=0;countNum < 40;countNum++){
          detail.addCell(getCellData(DataValue[countNum], font_C12N, "", "CENTER", "BOTTOM", 1, 1));
      }
 */     document.add(detail);
    // new Line-----------------------------------------------------------------------------
      sizeColumn = new float[] {25.0f,75.0f};
      detail = new PdfPTable(2);
      detail.setWidthPercentage(100);
      detail.setWidths(sizeColumn);
      setPaddingTop(0.5f);
      setPaddingLeft(3.5f);
      setPaddingRight(3.5f);
      setPaddingBottom(0.5f);

      
       //Check Score in Style Table//
     /*   detail.addCell(getCellData("D", font_C12N, "", "CENTER", "BOTTOM", 1, 1));
        detail.addCell(getCellData(hashmap_jobrouter.get("D").toString(), font_C12N, "", "CENTER", "BOTTOM", 1, 1));
        detail.addCell(getCellData("I", font_C12N, "", "CENTER", "BOTTOM", 1, 1));
        detail.addCell(getCellData(hashmap_jobrouter.get("I").toString(), font_C12N, "", "CENTER", "BOTTOM", 1, 1));
        detail.addCell(getCellData("S", font_C12N, "", "CENTER", "BOTTOM", 1, 1));
        detail.addCell(getCellData(hashmap_jobrouter.get("S").toString(), font_C12N, "", "CENTER", "BOTTOM", 1, 1));
        detail.addCell(getCellData("C", font_C12N, "", "CENTER", "BOTTOM", 1, 1));
     */   detail.addCell(getCellData(hashmap_jobrouter.get("C").toString(), font_C12N, "", "CENTER", "BOTTOM", 1, 1));
       document.add(detail);
    
      // new Line-----------------------------------------------------------------------------
      sizeColumn = new float[] {25.0f,75.0f};
      detail = new PdfPTable(2);
      detail.setWidthPercentage(77);
      detail.setWidths(sizeColumn);
      setPaddingTop(0.5f);
      setPaddingLeft(3.5f);
      setPaddingRight(3.5f);
      setPaddingBottom(2.5f);

      detail.addCell(getCellData("ประเภท", font_C16B, "", "CENTER", "BOTTOM", 1, 1, true));
      detail.addCell(getCellData("บุคลิกลักษณะ", font_C16B, "", "CENTER", "BOTTOM", 1, 1, true));
      setPaddingBottom(0.5f);
      detail.addCell(getCellData("D", font_C18B, "", "CENTER", "MIDDLE", 1, 10));
    
      Chunk ChuD = new Chunk("สิ่งที่คนสไตล์ D ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- การทำงานอย่างอิสระและมีอำนาจตัดสินใจในงานที่ได้รับมอบหมาย", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- มุ่งเน้นผลลัพธ์(Result Oriented) สูง", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- ชอบงานที่ท้าทาย ชอบเสี่ยง กล้าตัดสินใจ งานหรือกิจกรรมที่จะต้องการคนเข้า", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  ไปลุยแก้ปัญหาหรือจัดการให้เสร็จในภารกิจเฉพาะที่ต้องการให้เห็นผลเร็ว", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  หรือมีการแข่งขันสูงและมีเป้าหมาย หรือตัวชี้วัดผลสำเร็จที่ชัดเจน", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      ChuD = new Chunk("สิ่งที่คนสไตล์ D ไม่ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- การรู้สึกไม่ได้รับความไว้วางใจตลอดจนการเข้าไปแทรกแซงสิ่งที่เขาได้", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  ตัดสินใจสั่งการหรือดำเนินการไปแล้วโดยไม่มีเหตุผลที่สมควร", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(5.5f);
      detail.addCell(getCellData("- การทำงานหรือการตัดสินใจที่ล่าช้า, หลายขั้นตอน", font_C12N, "R_RB", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(0.5f);
      detail.addCell(getCellData("I", font_C18B, "", "CENTER", "MIDDLE", 1, 7));

      ChuD = new Chunk("สิ่งที่คนสไตล์ I ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- งานที่ต้องพบปะติดต่อผู้คน", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- งานที่ได้ใช้ความคิดสร้างสรรค์ หรืองานที่ต้องร่วมกันแก้ไขปัญหา", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      ChuD = new Chunk("สิ่งที่คนสไตล์ I ไม่ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- งานที่ต้องทำเป็นประจำ โดยเฉพาะงานที่ไม่ค่อยได้พบปะกับผู้คน หรือมี", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  กฎระเบียบมากๆ งานที่ต้องเข้าไปเกี่ยวกับความขัดแย้งของผู้คน", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(5.5f);
      detail.addCell(getCellData("- หลีกเลี่ยงงานที่ใช้รายละเอียด", font_C12N, "R_RB", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(0.5f);
      detail.addCell(getCellData("S", font_C18B, "", "CENTER", "MIDDLE", 1, 9));

      ChuD = new Chunk("สิ่งที่คนสไตล์ S ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- งานที่เป็นขั้นเป็นตอนชัดเจน, ชอบให้มีเวลาในการทำงานอย่างไม่เร่งรีบ(เพื่อมี", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  เวลาในการตัดสินใจอย่างรอบคอบ), ชอบทำอะไรที่ไม่เสี่ยง", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- ไม่ละเมิดกฎเกณฑ์", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- เป็นผู้รับฟังที่ดี  ให้ความสำคัญกับสัมพันธภาพ", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      ChuD = new Chunk("สิ่งที่คนสไตล์ S ไม่ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- บรรยากาศของความขัดแย้ง", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- การบีบบังคับให้ตัดสินใจแบบทันทีทันใด, การลัดขั้นตอน หรือการมีกฎเกณฑ์", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(5.5f);
      detail.addCell(getCellData(" ที่คลุมเครือ", font_C12N, "R_RB", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(0.5f);
      detail.addCell(getCellData("C", font_C18B, "", "CENTER", "MIDDLE", 1, 11));

      ChuD = new Chunk("สิ่งที่คนสไตล์ C ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- มีความละเอียดรอบคอบสูง,ชอบความเป็นระเบียบเรียบร้อยรวมถึง", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  ความถูกต้องของข้อมูลที่เชื่อถือและพิสูจน์ได้", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- มาตรฐานการทำงานสูง (หรือเรียกว่าเป็นพวก Perfectionism)", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      ChuD = new Chunk("สิ่งที่คนสไตล์ C ไม่ชอบ",font_C12N);
      ChuD.setUnderline(0.1f, -2f);
      content = new Phrase();
      content.add(ChuD);
      detail.addCell(getCellData2( content, "R_RIGHT", "LEFT", "MIDDLE",  1,  1) );
      detail.addCell(getCellData("- ความไม่เป็นระเบียบเรียบร้อย แล้วเป็นสไตล์ที่ชอบรับฟังหรือค้นหาข้อเท็จจริง", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  จากพยานหลักฐาน(หรือพยานวัตถุ) มากกว่าพยานบุคคล ดังนั้นจะอึดอัดใจ", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("  หากไม่มีข้อมูลรายละเอียดรองรับ  เพราะจะทำให้ตัดสินใจไม่ถูก", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- ไม่ชอบถูกวิพากษ์วิจารณ์ในตัวบุคคลและผลงาน", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      detail.addCell(getCellData("- ไม่ชอบงานที่ถูกเร่งรัดจนไม่มีเวลาตรวจสอบความถูกต้อง", font_C12N, "R_RIGHT", "LEFT", "BOTTOM", 1, 1));
      setPaddingBottom(5.5f);
      detail.addCell(getCellData("- ไม่ชอบเข้าสังคม ไม่ชอบการเป็นจุดเด่น", font_C12N, "R_RB", "LEFT", "BOTTOM", 1, 1));
      document.add(detail);
      // -----------------------------------------------------------------------------

      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        document.close();
      }
    }
 
    if (hasData) {
      OutputStream os = response.getOutputStream();
    // Create a reader
      PdfReader reader = new PdfReader(baos.toByteArray());
    // Create a stamper
      PdfStamper stamper = new PdfStamper(reader, baos);

    // Close the stamper
      stamper.close();
      reader.close();

      response.setHeader("Expires", "0");
      response.setHeader("Cache-Control", "must-revalidate, post-check=0 , pre-check=0");
      response.setHeader("Pragma", "public");

    // setting the content type
      response.setContentType("application/pdf");
    // the contentlength
      response.setContentLength(baos.size());
    // write ByteArrayOutputStream to the ServletOutputStream

      baos.writeTo(os);

      os.flush();
      os.close(); 
    }
    //PdfWriter.getInstance(document, baos);
    %>

    <%!
    Float padding = 0.0f;
    Float paddingtop = 0.0f;
    Float paddingbottom = 0.0f;
    Float paddingleft = 0.0f;
    Float paddingright = 0.0f;
    BaseColor basecolor = new BaseColor(235, 235, 224);

    private PdfPCell getCellData(String text, Font font, String noborder, String horalign, String veralign, int colspan, int rowspan) {
      return getCellData(text, font, noborder, horalign, veralign, colspan, rowspan, false);
    }
   
    //get call data
    private PdfPCell getCellData(String text, Font font, String noborder, String horalign, String veralign, int colspan, int rowspan, boolean bgcolor) {
      PdfPCell cellDetail = new PdfPCell(new Phrase(text, font));

      if (horalign.equalsIgnoreCase("LEFT")) {
        cellDetail.setHorizontalAlignment(Element.ALIGN_LEFT);
      } else if (horalign.equalsIgnoreCase("CENTER")) {
        cellDetail.setHorizontalAlignment(Element.ALIGN_CENTER);
      } else if (horalign.equalsIgnoreCase("RIGHT")) {
        cellDetail.setHorizontalAlignment(Element.ALIGN_RIGHT);
      }

      if (veralign.equalsIgnoreCase("TOP")) {
        cellDetail.setVerticalAlignment(Element.ALIGN_TOP);
      } else if (veralign.equalsIgnoreCase("MIDDLE")) {
        cellDetail.setVerticalAlignment(Element.ALIGN_MIDDLE);
      } else if (veralign.equalsIgnoreCase("BOTTOM")) {
        cellDetail.setVerticalAlignment(Element.ALIGN_BOTTOM);
      }

      if (padding > 0.0f) {
        cellDetail.setPadding(padding);
      }
      if (paddingtop > 0.0f) {
        cellDetail.setPaddingTop(paddingtop);
      }
      if (paddingbottom > 0.0f) {
        cellDetail.setPaddingBottom(paddingbottom);
      }
      if (paddingleft > 0.0f) {
        cellDetail.setPaddingLeft(paddingleft);
      }
      if (paddingright > 0.0f) {
        cellDetail.setPaddingRight(paddingright);
      }
      if (colspan > 0) {
        cellDetail.setColspan(colspan);
      }
      if (rowspan > 0) {
        cellDetail.setRowspan(rowspan);
      }
      if (noborder.equalsIgnoreCase("NO")) {
        cellDetail.setBorder(Rectangle.NO_BORDER);
      } 
      else if(noborder.equalsIgnoreCase("R_RB")){ 
            cellDetail.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM);
      } 
      else if(noborder.equalsIgnoreCase("R_TB")){ 
            cellDetail.setBorder(Rectangle.TOP | Rectangle.BOTTOM);
      } 
      else if(noborder.equalsIgnoreCase("R_BOTTOM")){ 
            cellDetail.setBorder(Rectangle.BOTTOM);
      }
      else if(noborder.equalsIgnoreCase("R_RIGHT")){ 
            cellDetail.setBorder(Rectangle.RIGHT);
      }
      else{

      }
      if (bgcolor) {
        cellDetail.setBackgroundColor(basecolor);
      } 
      return cellDetail;
    }
    //CellDeatail2 Use For Add Chunk(1row 2 Fonts Or Color)
    private PdfPCell getCellData2(Phrase content, String noborder, String horalign, String veralign, int colspan, int rowspan) {
      return getCellData2(content, noborder, horalign, veralign, colspan, rowspan, false);
    }
    private PdfPCell getCellData2(Phrase content, String noborder, String horalign, String veralign, int colspan, int rowspan, boolean bgcolor) {
        PdfPCell cellDetail2 = new PdfPCell(new Phrase(content));
     
      if (horalign.equalsIgnoreCase("LEFT")) {
        cellDetail2.setHorizontalAlignment(Element.ALIGN_LEFT);
      } else if (horalign.equalsIgnoreCase("CENTER")) {
        cellDetail2.setHorizontalAlignment(Element.ALIGN_CENTER);
      } else if (horalign.equalsIgnoreCase("RIGHT")) {
        cellDetail2.setHorizontalAlignment(Element.ALIGN_RIGHT);
      }

      if (veralign.equalsIgnoreCase("TOP")) {
        cellDetail2.setVerticalAlignment(Element.ALIGN_TOP);
      } else if (veralign.equalsIgnoreCase("MIDDLE")) {
        cellDetail2.setVerticalAlignment(Element.ALIGN_MIDDLE);
      } else if (veralign.equalsIgnoreCase("BOTTOM")) {
        cellDetail2.setVerticalAlignment(Element.ALIGN_BOTTOM);
      }

      if (padding > 0.0f) {
        cellDetail2.setPadding(padding);
      }
      if (paddingtop > 0.0f) {
        cellDetail2.setPaddingTop(paddingtop);
      }
      if (paddingbottom > 0.0f) {
        cellDetail2.setPaddingBottom(paddingbottom);
      }
      if (paddingleft > 0.0f) {
        cellDetail2.setPaddingLeft(paddingleft);
      }
      if (paddingright > 0.0f) {
        cellDetail2.setPaddingRight(paddingright);
      }
      if (colspan > 0) {
        cellDetail2.setColspan(colspan);
      }
      if (rowspan > 0) {
        cellDetail2.setRowspan(rowspan);
      }

      if (noborder.equalsIgnoreCase("NO")) {
        cellDetail2.setBorder(Rectangle.NO_BORDER);
      }
      else if(noborder.equalsIgnoreCase("R_RB")){ 
            cellDetail2.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM);
      } 
      else if(noborder.equalsIgnoreCase("R_BOTTOM")){ 
            cellDetail2.setBorder(Rectangle.BOTTOM);
      }
      else if(noborder.equalsIgnoreCase("R_RIGHT")){ 
            cellDetail2.setBorder(Rectangle.RIGHT);
      }
      else{

      }
      if (bgcolor) {
        cellDetail2.setBackgroundColor(basecolor);
      }
     
      return cellDetail2;
    }
    
    private void setPadding(Float padding) {
      this.padding = padding;
    }

    private void setPaddingTop(Float padding) {
      this.paddingtop = padding;
    }

    private void setPaddingBottom(Float padding) {
      this.paddingbottom = padding;
    }

    private void setPaddingLeft(Float padding) {
      this.paddingleft = padding;
    }

    private void setPaddingRight(Float padding) {
      this.paddingright = padding;
    }

    private void setBaseBackgroundColor(int r, int g, int b) {
      this.basecolor = new BaseColor(r, g, b);
    }
   // Add IMAGE IN PART
    private String getImagePath(String type, String subFolder, String imageFileName, String defaultFile) {
      InitialEnvironment inv = new InitialEnvironment("GLOBAL");
      String path = inv.getValue(type)+subFolder;
      if (!new File(path+imageFileName).exists() || imageFileName.equals("")){
        imageFileName = defaultFile;
      }
      return path+imageFileName;
    }

    public static JFreeChart generateBarChart(int DChart,int IChart,int SChart,int CChart) {
    //	DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
      DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
      dataSet.setValue(DChart, "Score", "D");
      dataSet.setValue(IChart, "Score", "I");
      dataSet.setValue(SChart, "Score", "S");
      dataSet.setValue(CChart, "Score", "C");

      JFreeChart chart = ChartFactory.createLineChart(
          "", // chart title
          "", // domain axis label
          "", // range axis label
      dataSet,  // initial series
      PlotOrientation.VERTICAL, // orientation
      false, // include legend
      true,  // tooltips?
      false);  // URLs? 
     
      CategoryPlot plot = (CategoryPlot) chart.getPlot();
      plot.setBackgroundPaint(Color.white);
      plot.setRangeGridlinePaint(Color.lightGray);
    
      // Range Axis Data Y
      NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
      rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
      rangeAxis.setUpperMargin(0.40);  // setUpperMargin
      rangeAxis.setAutoRangeIncludesZero(false); // setAutoRangeIncludesZero
       
      LineAndShapeRenderer renderer;
      renderer= (LineAndShapeRenderer) plot.getRenderer();
      plot.setRenderer(renderer);
      renderer.setBaseItemLabelsVisible(Boolean.TRUE);
      renderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator());//Set Show Score On line
      renderer.setShapesVisible(true);
      renderer.setDrawOutlines(true);
      renderer.setUseFillPaint(true);
      renderer.setPaint(Color.blue);
      renderer.setFillPaint(Color.blue); 
      renderer.setBaseStroke( new BasicStroke( 3 ) );
      renderer.setSeriesStroke( 0, new BasicStroke( 3 ) );
        
    // renderer.setUseOutlinePaint(true);
      return chart;
	  }
    
///////////////////////////////////////////////////////////////////
/* // HOW TO USE  createXYLineChart
    private static XYDataset createDataset() {
    XYSeries series1 = new XYSeries("First");
    series1.add(1.0, 1.0);
    series1.add(2.0, 4.0);
    series1.add(3.0, 3.0);
    series1.add(4.0, 5.0);
    series1.add(5.0, 5.0);
    series1.add(6.0, 7.0);
    series1.add(7.0, 7.0);
    series1.add(8.0, 8.0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    return dataset;
    }
    private static JFreeChart createChart(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(
    "", // chart title
    "", // x axis label
    "", // y axis label
    dataset, // data
    PlotOrientation.VERTICAL,
    false, // include legend
    true, // tooltips
    false // urls
    );
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
XYLineAndShapeRenderer renderer =
            new XYLineAndShapeRenderer(true, true);
        plot.setRenderer(renderer);
        renderer.setShapesVisible(true);
        renderer.setShapesFilled(true);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.
    NumberFormat format = NumberFormat.getNumberInstance();
        format.setMaximumFractionDigits(2);
        XYItemLabelGenerator generator =
        new StandardXYItemLabelGenerator(
        StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT,
        format, format);
        renderer.setBaseItemLabelGenerator(generator);
        renderer.setBaseItemLabelsVisible(true);
    return chart;
    }
*/
    %>
    </body>
    </html>