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;
         }
     }
 }
 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);
         }
     }
 }
         if ($_POST['show_signature']) {
             $pdf->InvoiceSignature();
         }
         // if ($_POST['show_signature'])
     }
     // if ($table_header_set)
     break;
 case 'report_consolidated_projects_per_employee':
     $database = $_SESSION['database'];
     // *** Create pdf object ***
     $pdf = new PDF('L');
     // The report should be landscape
     $pdf->SetTitle(REPORT_NAME_CONSOLIDATED_PROJECTS_PER_EMPLOYEE);
     $pdf->SetAuthor(TITLE);
     $pdf->AddPage();
     $periodstartdate = $database->prepare_input(tep_periodstartdate($_POST['period']));
     $employees_query_string = 'SELECT ts.timesheets_start_date, ts.timesheets_end_date, cus.customers_id, cus.customers_name, cus.customers_billing_show_logo, bu.business_units_image, bu.business_units_image_position, pr.projects_id, pr.projects_name, rl.roles_id, rl.roles_name, rl.roles_mandatory_ticket_entry, act.activities_date, emp.employees_id, emp.employees_fullname, act.activities_amount, units.units_id, units.units_name, tar.tariffs_amount, act.activities_travel_distance, act.activities_expenses, act.activities_ticket_number, act.activities_expenses + (act.activities_amount * tar.tariffs_amount) AS total, act.activities_comment ' . 'FROM ' . TABLE_TIMESHEETS . ' AS ts ' . 'INNER JOIN (' . TABLE_EMPLOYEES . ' AS emp, ' . TABLE_ACTIVITIES . ' AS act, ' . TABLE_UNITS . ', ' . TABLE_TARIFFS . ' AS tar, ' . TABLE_EMPLOYEES_ROLES . ' AS er, ' . TABLE_ROLES . ' AS rl, ' . TABLE_PROJECTS . ' AS pr, ' . TABLE_CUSTOMERS . ' AS cus, ' . TABLE_BUSINESS_UNITS . ' AS bu) ' . 'ON (ts.employees_id = emp.employees_id ' . 'AND act.timesheets_id = ts.timesheets_id ' . 'AND act.tariffs_id = tar.tariffs_id ' . 'AND units.units_id = tar.units_id ' . 'AND er.employees_roles_id = tar.employees_roles_id ' . 'AND rl.roles_id = er.roles_id ' . 'AND pr.projects_id = rl.projects_id ' . 'AND cus.customers_id = pr.customers_id ' . 'AND bu.business_units_id = pr.business_units_id) ' . 'WHERE ts.timesheets_start_date = "' . $periodstartdate . '" ' . 'ORDER BY emp.employees_id, act.activities_date, cus.customers_id, pr.projects_id, rl.roles_id, units.units_id';
     $employees_query = $database->query($employees_query_string);
     $employees_array = array();
     $employees_id = '';
     $table_header_set = false;
     while ($employees_result = $database->fetch_array($employees_query)) {
         if ($employees_id != $employees_result['employees_id']) {
             $employees_id = $employees_result['employees_id'];
             if ($table_header_set) {
                 // A previous table exists, create a footer for that one
                 $pdf->ConsolidatedProjectsTableFooter($total_amount, $total_value, $total_travel_distance, $total_expenses);
                 $pdf->AddPage();
             }
             // Create a new Employee header
             $pdf->ConsolidatedProjectsHeader(tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $employees_result['timesheets_start_date'])) . ' - ' . tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $employees_result['timesheets_end_date'])), '(' . $employees_result['employees_id'] . ') ' . $employees_result['employees_fullname']);
Exemple #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']));
        ?>
                    <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">