コード例 #1
0
    private void createChart(final DOM container, final HttpServletRequest request)
        throws SQLException {
      Label l = container().label();
      l.img(new URL("/images/payslip_small.png")).setAttr(Image.CLASS, "icon");
      l.text(t8("select.year")).style(CSS.WIDTH, "24%");
      container().br();

      yearField = container().<Integer>select();
      loadSlips();
      yearField.selectIndex(0).style(CSS.WIDTH, "24%");

      Div d = container().div();
      d.style(CSS.FLOAT, "right").style(CSS.MARGIN_TOP, "10px");

      d.label()
          .text(t8("paycost"))
          .style(CSS.COLOR, "white")
          .style(CSS.BACKGROUND_COLOR, "rgba(151,187,187, 1)");

      d.label(cx.t8("max.paybuffer"))
          .style(CSS.COLOR, "white")
          .style(CSS.BACKGROUND_COLOR, "rgba(151,205,187,1)")
          .style(CSS.MARGIN_LEFT, "10px");

      d.label()
          .text(t8("paybuffer"))
          .style(CSS.COLOR, "white")
          .style(CSS.BACKGROUND_COLOR, "rgba(151,187,205,1)")
          .style(CSS.MARGIN_LEFT, "10px");

      d.label()
          .text(t8("vacation.deduction"))
          .style(CSS.COLOR, "white")
          .style(CSS.BACKGROUND_COLOR, "rgba(205,187,151,1)")
          .style(CSS.MARGIN_LEFT, "10px");

      d.label()
          .text(t8("other.costs"))
          .style(CSS.COLOR, "white")
          .style(CSS.BACKGROUND_COLOR, "rgba(205,151,151, 1)")
          .style(CSS.MARGIN_LEFT, "10px");

      container().br().br().br();

      final String year = request.getParameter("year");
      if (year != null) {
        yearField.selectValue(year);
      }

      yearField.onChange(
          new Callback(Method.POST) {
            @Override
            public void onEvent() throws SQLException {
              redirect(new URL("/statistics/money-year?year=%s", yearField.selectedValue()));
            }
          });

      createCanvas(container);
    }
コード例 #2
0
ファイル: EmployeeListDoc.java プロジェクト: codr4life/im4ix
    @Override
    protected void createSearchBox(final DOM box) throws SQLException {
      Div showDiv = box.div();
      showDiv.style(CSS.FLOAT, "right");
      showDiv.label(cx().t8("show"));
      showDiv.br().br();

      Div showTypeDiv = showDiv.div();
      showTypeDiv.style(CSS.DISPLAY, "inline-block").style(CSS.MARGIN_RIGHT, "10px");

      showFixedBox = showTypeDiv.checkBox();
      showFixedBox.setChecked(true).setAttr(CheckBox.NAME, "show.type");
      showTypeDiv.label(t8("employmentType.FIXED"));
      showTypeDiv.br();

      showCommissionableBox = showTypeDiv.checkBox();
      showCommissionableBox.setChecked(true).setAttr(CheckBox.NAME, "show.type");
      showTypeDiv.label(t8("employmentType.COMMISSIONABLE"));
      showTypeDiv.br();

      showSubconsultantBox = showTypeDiv.checkBox();
      showSubconsultantBox.setChecked(true).setAttr(CheckBox.NAME, "show.type");
      showTypeDiv.label(t8("employmentType.SUBCONSULTANT"));

      Div showStateDiv = showDiv.div();
      showStateDiv.style(CSS.DISPLAY, "inline-block");

      showAvailableBox = showStateDiv.checkBox();
      showAvailableBox.setChecked(true).setAttr(CheckBox.NAME, "show.state");
      showStateDiv.label(t8("show.available"));
      showStateDiv.br();

      showBusyBox = showStateDiv.checkBox();
      showBusyBox.setChecked(true).setAttr(CheckBox.NAME, "show.state");
      showStateDiv.label(t8("show.busy"));
      showStateDiv.br();

      showInactiveBox = showStateDiv.checkBox();
      showInactiveBox.setAttr(CheckBox.NAME, "show.state");
      showStateDiv.label(t8("show.inactive"));

      box.iconLabel(url("/images/employee_small.png"), t8("employees.contact"))
          .style(CSS.MARGIN_RIGHT, "1%")
          .style(CSS.WIDTH, "24%");
      box.br();

      contactField = box.<Employee>select();
      contactField.style(CSS.WIDTH, "24%").style(CSS.MARGIN_RIGHT, "1%");
      loadContacts();
      contactField.selectValue("");

      box.br().br().br().br().br();
      contactField.setFocus();
    }
コード例 #3
0
    private void createCanvas(final DOM container) throws SQLException {
      d = container.div();
      c = d.canvas();
      c.style(CSS.HEIGHT, "30em").style(CSS.MAX_WIDTH, "1160px");
      d.br();

      final int year = yearField.selectedObject();
      final Date startDate = cx.tz().newDate(year, 1, 1);
      final Date endDate = cx.tz().newDate(year, 12, 31);
      loadAssignments(startDate, endDate);

      final List<String> labels = new ArrayList<>();
      final List<BigDecimal> maxPayBuffers = new ArrayList<>();
      final List<BigDecimal> payCosts = new ArrayList<>();
      final List<BigDecimal> payBuffers = new ArrayList<>();
      final List<BigDecimal> vacationDeductions = new ArrayList<>();
      final List<BigDecimal> otherCosts = new ArrayList<>();

      try (Query.Result qr =
          PaySlip.table
              .query()
              .select(
                  PaySlip.table.START_DATE,
                  PaySlip.table.END_DATE,
                  PaySlip.table.GROSS_PAY,
                  PaySlip.table.GENERAL_PAYROLL_TAX,
                  PaySlip.table.OUTGOING_PAY_BUFFER,
                  PaySlip.table.INCOMING_PAY_BUFFER,
                  PaySlip.table.VACATION_DEDUCTION,
                  PaySlip.table.TOTAL_COST)
              .join(Employee.table, PaySlip.table.EMPLOYEE.joinCond())
              .join(Im4ixUser.table, Employee.table.USER.joinCond())
              .where(
                  Im4ixUser.table.primaryKey().eq(cx().currentUser()),
                  SQL.lte(PaySlip.table.START_DATE, endDate),
                  SQL.gte(PaySlip.table.END_DATE, startDate),
                  SQL.eq(PaySlip.table.IS_APPROVED, true))
              .orderBy(PaySlip.table.START_DATE)
              .exec(cx)) {
        while (qr.next()) {
          labels.add(String.format("'%s'", cx.formatDate(qr.getDate(PaySlip.table.START_DATE))));

          BigDecimal maxPay = BigDecimal.ZERO;
          for (Date d = qr.getDate(PaySlip.table.START_DATE);
              d.compareTo(qr.getDate(PaySlip.table.END_DATE)) <= 0;
              d = cx.tz().addDays(d, 1)) {
            final boolean isHoliday = cx.isHoliday(d);
            if (!isHoliday) {
              maxPay = maxPay.add(getMaxPayRate(d).multiply(BigDecimal.valueOf(8)));
            }
          }

          maxPayBuffers.add(maxPay);
          payCosts.add(
              qr.getBigDecimal(PaySlip.table.GROSS_PAY)
                  .add(qr.getBigDecimal(PaySlip.table.GENERAL_PAYROLL_TAX)));
          payBuffers.add(
              qr.getBigDecimal(PaySlip.table.OUTGOING_PAY_BUFFER)
                  .subtract(qr.getBigDecimal(PaySlip.table.INCOMING_PAY_BUFFER)));
          vacationDeductions.add(qr.getBigDecimal(PaySlip.table.VACATION_DEDUCTION));
          otherCosts.add(
              qr.getBigDecimal(PaySlip.table.TOTAL_COST)
                  .subtract(qr.getBigDecimal(PaySlip.table.GROSS_PAY))
                  .subtract(qr.getBigDecimal(PaySlip.table.GENERAL_PAYROLL_TAX))
                  .subtract(qr.getBigDecimal(PaySlip.table.VACATION_DEDUCTION)));
        }
      }

      final StringBuffer labelData = new StringBuffer();
      final StringBuffer maxPayBufferData = new StringBuffer();
      final StringBuffer payCostData = new StringBuffer();
      final StringBuffer payBufferData = new StringBuffer();
      final StringBuffer vacationDeductionData = new StringBuffer();
      final StringBuffer otherCostData = new StringBuffer();

      String sep = "";
      for (int i = 0; i < payCosts.size(); i++) {
        labelData.append(sep).append(labels.get(i));
        maxPayBufferData.append(sep).append(cx().formatDecimalRaw(maxPayBuffers.get(i)));
        payCostData.append(sep).append(cx().formatDecimalRaw(payCosts.get(i)));
        payBufferData.append(sep).append(cx().formatDecimalRaw(payBuffers.get(i)));
        vacationDeductionData.append(sep).append(cx().formatDecimalRaw(vacationDeductions.get(i)));
        otherCostData.append(sep).append(cx().formatDecimalRaw(otherCosts.get(i)));
        sep = ", ";
      }

      JS(String.format("var ctx = Coredom.tags[%d].getContext('2d');", c.id()));
      JS("var data = {");
      JS("labels: [");
      JS(labelData.toString());
      JS("],");
      JS("datasets: [");

      JS("{backgroundColor: 'rgba(151,187,187,1)', ");
      JS("data: [");
      JS(payCostData.toString());
      JS("]},");

      JS("{backgroundColor: 'rgba(151,205,187,1)', ");
      JS("data: [");
      JS(maxPayBufferData.toString());
      JS("]},");

      JS("{backgroundColor: 'rgba(151,187,205,1)', ");
      JS("data: [");
      JS(payBufferData.toString());
      JS("]},");

      JS("{backgroundColor: 'rgba(205,187,151,1)', ");
      JS("data: [");
      JS(vacationDeductionData.toString());
      JS("]},");

      JS("{backgroundColor: 'rgba(205,151,151,1)', ");
      JS("data: [");
      JS(otherCostData.toString());
      JS("]}]};");

      JS("document.Im4ix = {};");
      JS(
          "document.Im4ix.chart = new Chart(ctx, {type: 'bar', data: data, "
              + "options: {legend: {display: false}, scaleStepWidth: 1, scaleStartValue: 0, "
              + "scales: {xAxes:[{gridLines: {display: false}}], "
              + "yAxes:[{gridLines: {display: false}}]}, "
              + "animation: false, responsive: true, showTooltips: false}});");
    }