Example #1
0
 public function __construct($id = 0, $employees_id = 0, $period = null)
 {
     $database = $_SESSION['database'];
     $this->id = $id;
     $this->listing = array();
     $this->isempty = true;
     if ($this->id != 0) {
         // Retrieve benefit by id
         $this->id = $database->prepare_input($this->id);
         $benefits_query = $database->query("select benefits_id, benefits_start_date, benefits_end_date, benefits_credit, benefits_granted, benefits_comment, employees_id, roles_id from " . TABLE_BENEFITS . " where benefits_id = '" . (int) $this->id . "'");
     } else {
         if ($employees_id != 0 && tep_not_null($period)) {
             // Benefit might exist but we do not know the id
             // Try to retrieve the benefit for the given employee and period
             $this->employees_id = $database->prepare_input($employees_id);
             $benefits_query = $database->query("SELECT * FROM " . VIEW_BENEFITS . " WHERE benefits_start_date <= '" . tep_periodenddate($period) . "'" . " AND benefits_end_date >= '" . tep_periodstartdate($period) . "'" . " AND employees_id = " . $employees_id . " AND roles_id = " . BENEFITS_LEAVE_ROLE . ";");
         } else {
             // We probably created an empty benefit object to retrieve the entire benefit listing
             $this->listing = $this->get_array($employees_id);
         }
     }
     if ($this->id != 0 || $employees_id != 0 && tep_not_null($period)) {
         $benefits_result = $database->fetch_array($benefits_query);
         if (tep_not_null($benefits_result)) {
             // Benefit exists
             $this->id = $benefits_result['benefits_id'];
             $this->fill(tep_datetouts(DATE_FORMAT_DATABASE, $benefits_result['benefits_start_date']), $benefits_result['benefits_end_date'] != '2099-12-31' ? tep_datetouts(DATE_FORMAT_DATABASE, $benefits_result['benefits_end_date']) : 0, $benefits_result['benefits_credit'], $benefits_result['benefits_granted'], $benefits_result['benefits_used'], $benefits_result['benefits_comment'], $benefits_result['employees_id'], $benefits_result['roles_id']);
             $this->isempty = false;
         }
     }
 }
Example #2
0
 public function __construct($id = 0, $employees_id = 0, $period = null, $include_activities = true, $sort_order = 'timesheets_start_date desc')
 {
     $database = $_SESSION['database'];
     $this->id = $id;
     $this->activities = array();
     $this->listing = array();
     if ($this->id != 0) {
         // Retrieve timesheet by id
         $this->id = $database->prepare_input($this->id);
         $timesheet_query = $database->query("select timesheets_id, timesheets_start_date, timesheets_end_date, timesheets_locked, employees_id from " . TABLE_TIMESHEETS . " where timesheets_id = '" . (int) $this->id . "'");
     } else {
         if ($employees_id != 0 && tep_not_null($period)) {
             // Timesheet might exist but we do not know the id
             // Try to retrieve the timesheet for the given employee and period
             $this->employees_id = $database->prepare_input($employees_id);
             $this->start_date = $database->prepare_input(tep_periodstartdate($period));
             $timesheet_query = $database->query("select timesheets_id, timesheets_start_date, timesheets_end_date, timesheets_locked, employees_id from " . TABLE_TIMESHEETS . " where employees_id = '" . (int) $this->employees_id . "' and timesheets_start_date = '" . $this->start_date . "'");
         } else {
             // We probably created an empty timesheet object to retrieve the entire timesheet listing for a given employee
             $this->listing = $this->get_array($employees_id, $sort_order);
             // When timesheets_id == 0, $sort_order determines the timesheet listing
         }
     }
     if ($this->id != 0 || $employees_id != 0 && tep_not_null($period)) {
         $timesheet_result = $database->fetch_array($timesheet_query);
         if (tep_not_null($timesheet_result)) {
             // Timesheet exists
             $this->id = $timesheet_result['timesheets_id'];
             $this->fill($timesheet_result['timesheets_start_date'], $timesheet_result['timesheets_end_date'], $timesheet_result['timesheets_locked'] == 1, $timesheet_result['employees_id']);
             // Retrieve all activities for this timesheet (if any exist)
             if ($include_activities) {
                 $this->activities = activity::get_array($this->id, $sort_order);
                 // When timesheets_id != 0 / employees_id and period are set, $sort_order determines the activity listing
             }
         } else {
             // Timesheet does not exist, fill a new one with the given values
             $this->fill(tep_periodstartdate($period), tep_periodenddate($period), false, $employees_id);
         }
     }
 }
Example #3
0
    tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
switch ($_POST['action']) {
    case 'report_employees':
        // *** Create pdf object ***
        $pdf = new PDF('L');
        $pdf->SetTitle(REPORT_NAME_EMPLOYEES);
        $pdf->SetAuthor(TITLE);
        $pdf->AddPage();
        $pdf->SetFont('Arial', '', 12);
        $pdf->Cell(30, 6, REPORT_TEXT_DATE, 0, 0, 'L');
        $pdf->Cell(100, 6, tep_strftime(DATE_FORMAT_SHORT), 0, 0, 'L');
        $pdf->Ln();
        if ($_POST['show_timesheet_info'] || $_POST['show_travel_distance_and_expenses']) {
            $pdf->Cell(30, 6, REPORT_TEXT_PERIOD, 0, 0, 'L');
            $pdf->Cell(100, 6, $_POST['period'] . '  (' . tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', tep_periodstartdate($_POST['period']))) . ' - ' . tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', tep_periodenddate($_POST['period']))) . ')', 0, 0, 'L');
            $pdf->Ln();
        }
        $pdf->Ln(6);
        $employees_array = employee::get_array($_POST['show_all_employees']);
        $table_contents = array();
        $index = 0;
        // Set the header and orientation
        $table_header = array(REPORT_EMPLOYEES_ID, REPORT_EMPLOYEES_FULLNAME);
        $table_contents_orientation = array('R', 'L');
        $column_count = 2;
        if ($_POST['show_user_rights']) {
            // Add to header
            $table_header[$column_count] = REPORT_EMPLOYEES_LOGIN;
            $table_header[$column_count + 1] = REPORT_EMPLOYEES_PROJECTLISTING;
            $table_header[$column_count + 2] = REPORT_EMPLOYEES_TIMEREGISTRATION;
Example #4
0
</td>
                    <td class="projectListing-heading"><?php 
    echo TEXT_PROJECTS_CALCULATED_HOURS_PERIOD;
    ?>
</td>
                    <td class="projectListing-heading"><?php 
    echo TEXT_PROJECTS_HOURS_USED;
    ?>
</td>
                    <td class="projectListing-heading"><?php 
    echo TEXT_PROJECTS_HOURS_USED_PERCENTAGE;
    ?>
</td>
                  </tr>
                  <?php 
    $project_array = project::get_project_listing(tep_datetouts('%Y-%m-%d', tep_periodstartdate($_POST['period'])), tep_datetouts('%Y-%m-%d', tep_periodenddate($_POST['period'])));
    // Period end date in Unix timestamp
    for ($index = 0; $index < sizeof($project_array); $index++) {
        $projects_calculated_hours_used_percentage = $project_array[$index]['projects_calculated_hours'] != 0 ? round($project_array[$index]['projects_calculated_hours_used'] / $project_array[$index]['projects_calculated_hours'] * 100) . '%' : BODY_TEXT_NOT_APPLICABLE;
        ?>
                    <tr class="projectListing-<?php 
        echo $projects_calculated_hours_used_percentage >= 100 ? 'red' : ($projects_calculated_hours_used_percentage >= 75 ? 'orange' : 'green');
        ?>
">
                      <td class="projectListing-data"><?php 
        echo $project_array[$index]['projects_name'];
        ?>
</td>
                      <td class="projectListing-data"><?php 
        echo tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $project_array[$index]['projects_start_date']));
        ?>
Example #5
0
                    <td align="right" class="infoBoxHeading">
                      <?php 
echo tep_image_submit('arrow_right.gif', TEXT_ANALYSIS_FORWARD, '', DIR_WS_IMAGES);
?>
                    </td>
                  </form>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td align="center">
              <table border="0px" width="20%" cellspacing="0" cellpadding="3" class="infoBoxContents">
                <tr>
                  <td align="center" class="boxText"><?php 
echo tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', tep_periodstartdate($_POST['period']))) . '&nbsp;&nbsp;-&nbsp;&nbsp;' . tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', tep_periodenddate($_POST['period'])));
?>
</td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td><?php 
echo tep_draw_separator('pixel_trans.gif', '100%', '20');
?>
</td>
          </tr>
          <tr>
            <td>
              <table border="0" cellspacing="0" cellpadding="0">