public function __construct($id = 0, $child_or_projects_id = null)
 {
     $database = $_SESSION['database'];
     $this->id = $id;
     $this->tariffs = array();
     $this->listing = array();
     if ($id != 0) {
         // Get existing employee_role
         $id = $database->prepare_input($id);
         $employees_roles_query = $database->query("select employees_roles_start_date, employees_roles_end_date, roles_id, employees_id from " . TABLE_EMPLOYEES_ROLES . " where employees_roles_id = '" . (int) $id . "'");
         $employees_roles_result = $database->fetch_array($employees_roles_query);
         $this->fill(tep_datetouts(DATE_FORMAT_DATABASE, $employees_roles_result['employees_roles_start_date']), $employees_roles_result['employees_roles_end_date'] != '2099-12-31' ? tep_datetouts(DATE_FORMAT_DATABASE, $employees_roles_result['employees_roles_end_date']) : 0, $employees_roles_result['roles_id'], $employees_roles_result['employees_id']);
         // Retrieve specific tariff or all tariffs for this employee_role
         if (tep_not_null($child_or_projects_id)) {
             if (is_object($child_or_projects_id)) {
                 $this->tariffs[0] = $child_or_projects_id;
             }
         } else {
             $temp_tariff = new tariff();
             $this->tariffs = $temp_tariff->get_array($this->id);
         }
     } else {
         // We probably created an empty role object to retrieve the entire role listing
         $this->listing = $this->get_array($child_or_projects_id);
     }
 }
 public function __construct($id = 0, $role_object = null, $show_history = false)
 {
     $database = $_SESSION['database'];
     $this->id = $id;
     $this->roles = array();
     $this->listing = array();
     if ($id != 0) {
         $id = $database->prepare_input($id);
         $projects_query = $database->query("SELECT projects_name, projects_description, projects_customers_contact_name, projects_customers_reference, projects_start_date, projects_end_date, projects_calculated_hours, projects_calculated_hours_period, business_units_id, customers_id FROM " . TABLE_PROJECTS . " WHERE projects_id = '" . (int) $id . "';");
         $projects_result = $database->fetch_array($projects_query);
         if (tep_not_null($projects_result)) {
             // Project exists
             $this->fill($projects_result['projects_name'], $projects_result['projects_description'], $projects_result['projects_customers_contact_name'], $projects_result['projects_customers_reference'], tep_datetouts(DATE_FORMAT_DATABASE, $projects_result['projects_start_date']), $projects_result['projects_end_date'] != '2099-12-31' ? tep_datetouts(DATE_FORMAT_DATABASE, $projects_result['projects_end_date']) : 0, $projects_result['projects_calculated_hours'], $projects_result['projects_calculated_hours_period'], $projects_result['business_units_id'], $projects_result['customers_id']);
             // Retrieve specific role or all available roles for this project
             if (tep_not_null($role_object)) {
                 if (is_object($role_object)) {
                     $this->roles[sizeof($this->roles)] = $role_object;
                 }
             } else {
                 $temp_role = new role();
                 // Create a default role (id==0)
                 $this->roles = $temp_role->get_array($this->id);
             }
         }
     } else {
         // We probably created an empty project object to retrieve the entire project listing
         $this->listing = $this->get_array($show_history);
     }
 }
 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;
         }
     }
 }
function tep_datetoperiod($format = null, $date = null)
{
    if (isset($format) && isset($date)) {
        return strftime('%Y-%m', tep_datetouts($format, $date));
    } else {
        return strftime('%Y-%m');
    }
}
 public function __construct($activity_id = 0)
 {
     $database = $_SESSION['database'];
     $this->activity_id = $activity_id;
     if ($this->activity_id != 0) {
         $this->activity_id = $database->prepare_input($this->activity_id);
         $activity_query = $database->query("SELECT activities_date, " . "tariffs_id, " . "activities_amount, " . "activities_travel_distance, " . "activities_travel_description, " . "activities_expenses, " . "activities_ticket_number, " . "activities_comment, " . "timesheets_id " . "FROM " . TABLE_ACTIVITIES . " " . "WHERE activities_id = '" . (int) $this->activity_id . "';");
         $activity_result = $database->fetch_array($activity_query);
         if (tep_not_null($activity_result)) {
             // Activity exists
             $this->fill(tep_datetouts('%Y-%m-%d', $activity_result['activities_date']), $activity_result['activities_amount'], $activity_result['tariffs_id'], $activity_result['activities_travel_distance'], $activity_result['activities_travel_description'], $activity_result['activities_expenses'], $activity_result['activities_ticket_number'], $activity_result['activities_comment'], $activity_result['timesheets_id']);
         }
     }
 }
 public function __construct($id = 0, $employees_roles_id = null)
 {
     $database = $_SESSION['database'];
     $this->id = $id;
     $this->listing = array();
     if ($id != 0) {
         $id = $database->prepare_input($id);
         $tariffs_query = $database->query("select tariffs_amount, tariffs_start_date, tariffs_end_date, units_id, employees_roles_id from " . TABLE_TARIFFS . " where tariffs_id = '" . (int) $id . "'");
         $tariffs_result = $database->fetch_array($tariffs_query);
         $this->fill($tariffs_result['tariffs_amount'], tep_datetouts(DATE_FORMAT_DATABASE, $tariffs_result['tariffs_start_date']), $tariffs_result['tariffs_end_date'] != '2099-12-31' ? tep_datetouts(DATE_FORMAT_DATABASE, $tariffs_result['tariffs_end_date']) : 0, $tariffs_result['units_id'], $tariffs_result['employees_roles_id']);
     } else {
         // We probably created an empty tariff object to retrieve the entire tariff listing
         $this->listing = $this->get_array($employees_roles_id);
     }
 }
                    // 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']);
                // Create a new table header
                $pdf->ConsolidatedProjectsTableHeader();
                $table_header_set = true;
                $total_amount = 0.0;
                $total_value = 0.0;
                $total_travel_distance = 0;
                $total_expenses = 0.0;
            }
            // And we're off creating the table contents
            $pdf->ConsolidatedProjectsTableContents(tep_datetouts('%Y-%m-%d', $employees_result['activities_date']), $employees_result['projects_name'], $employees_result['roles_name'], $employees_result['activities_amount'], $employees_result['units_name'], $employees_result['tariffs_amount'], $employees_result['total'], $employees_result['activities_travel_distance'], $employees_result['activities_expenses'], $employees_result['activities_ticket_number'], $employees_result['activities_comment']);
            $total_amount += $employees_result['activities_amount'];
            $total_value += $employees_result['total'];
            $total_travel_distance += $employees_result['activities_travel_distance'];
            $total_expenses += $employees_result['activities_expenses'];
        }
        if ($table_header_set) {
            // Create a footer for the last table
            $pdf->ConsolidatedProjectsTableFooter($total_amount, $total_value, $total_travel_distance, $total_expenses);
        }
        break;
    default:
        // *** Create pdf object ***
        $pdf = new PDF();
}
$pdf->Output($pdf->title . '.pdf', 'D');
Exemple #8
0
        $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>
                      <td class="projectListing-data"><?php 
        echo $project_array[$index]['projects_end_date'] != '2099-12-31' ? tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $project_array[$index]['projects_end_date'])) : BODY_TEXT_NOT_APPLICABLE;
        ?>
</td>
                      <td class="projectListing-data"><?php 
        echo $project_array[$index]['projects_calculated_hours'] != 0 ? $project_array[$index]['projects_calculated_hours'] : BODY_TEXT_NOT_APPLICABLE;
        ?>
</td>
                      <td class="projectListing-data"><?php 
        echo $project_array[$index]['projects_calculated_hours'] != 0 ? $PROJECTS_CALCULATED_HOURS_PERIOD[$project_array[$index]['projects_calculated_hours_period']] : BODY_TEXT_NOT_APPLICABLE;
        ?>
</td>
                      <td class="projectListing-data"><?php 
        echo tep_number_db_to_user($project_array[$index]['projects_calculated_hours_used'], 2);
        ?>
</td>
                      <td class="projectListing-data"><?php 
 public function get_total_amount_per_day()
 {
     $total_amount_per_day = array();
     // Fill the array with zero-hours
     $last_day_of_the_month = (int) strftime('%d', tep_datetouts('%Y-%m-%d', $this->end_date));
     for ($day_index = 1; $day_index <= $last_day_of_the_month; $day_index++) {
         $total_amount_per_day[$day_index] = 0.0;
     }
     // Walk through the activities
     for ($activity_index = 0; $activity_index < sizeof($this->activities); $activity_index++) {
         $total_amount_per_day[(int) strftime('%d', $this->activities[$activity_index]->date)] += $this->activities[$activity_index]->amount;
     }
     return $total_amount_per_day;
 }
     }
     if ($_POST['projects_end_date'] != 0) {
         $_POST['projects_end_date_display'] = tep_strftime(DATE_FORMAT_SHORT, $_POST['projects_end_date']);
     } else {
         $_POST['projects_end_date_display'] = '';
     }
     break;
 case 'save_data':
     // When action==save_data: verify entered data and save if OK / set errorlevel when NOK
     //
     // First format dates (from display to uts)
     if (tep_not_null($_POST['projects_start_date_display'])) {
         $_POST['projects_start_date'] = tep_datetouts(DATE_FORMAT_SHORT, $_POST['projects_start_date_display']);
     }
     if (tep_not_null($_POST['projects_end_date_display'])) {
         $_POST['projects_end_date'] = tep_datetouts(DATE_FORMAT_SHORT, $_POST['projects_end_date_display']);
     } else {
         $_POST['projects_end_date'] = 0;
     }
     // Check for data format and required fields
     // change action when not everything is filled-in
     if ($_POST['projects_name'] == '') {
         $_POST['action'] = 'enter_data';
         $error_level = 1;
         // No projects_name
     } else {
         if ($_POST['projects_start_date_display'] == '') {
             $_POST['action'] = 'enter_data';
             $error_level = 2;
             // No projects_start_date
         } else {
                    <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">
Exemple #12
0
require 'includes/application_top.php';
// CSV class
require DIR_WS_CLASSES . 'csv.php';
// Check if user is logged in. If not, redirect to login page
if (!tep_not_null($_SESSION['employee'])) {
    tep_redirect(tep_href_link(FILENAME_LOGIN));
}
// Check if the user is allowed to view this page
if (!$_SESSION['employee']->profile->right['analysis']) {
    tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
// Create a CSV object
$csv = new CSV($_POST['action'] . '.csv', ';', '');
// Delimiters chosen to be ms-excel compatible
switch ($_POST['action']) {
    case 'export_activities':
        $database = $_SESSION['database'];
        $periodstartdate = $database->prepare_input(tep_periodstartdate($_POST['period']));
        $activities_query_string = 'SELECT cus.customers_id, cus.customers_name, cus.customers_id_external, ts.timesheets_start_date, ts.timesheets_end_date, pr.projects_name, bu.business_units_name, rl.roles_name, cat.categories_name, act.activities_date, emp.employees_id, emp.employees_fullname, act.activities_amount, units.units_name, tar.tariffs_amount, act.activities_travel_distance, act.activities_expenses, act.activities_ticket_number, 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_CATEGORIES . ' AS cat, ' . 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.categories_id = cat.categories_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 cus.customers_id, pr.projects_id, rl.roles_id, act.activities_date, emp.employees_id, units.units_id';
        $activities_query = $database->query($activities_query_string);
        $csv->addrow(array('customers_id', 'customers_name', 'customers_id_external', 'period_start_date', 'period_end_date', 'projects_name', 'business_units_name', 'roles_name', 'activities_date', 'employees_id', 'employees_fullname', 'amount', 'units_name', 'tariff', 'travel_distance', 'expenses', 'ticket_number', 'comment', 'categories_name'));
        while ($activities_result = $database->fetch_array($activities_query)) {
            $csv->addrow(array($activities_result['customers_id'], $activities_result['customers_name'], $activities_result['customers_id_external'], tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $activities_result['timesheets_start_date'])), tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $activities_result['timesheets_end_date'])), $activities_result['projects_name'], $activities_result['business_units_name'], $activities_result['roles_name'], tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $activities_result['activities_date'])), $activities_result['employees_id'], $activities_result['employees_fullname'], tep_number_db_to_user($activities_result['activities_amount'], 2), $activities_result['units_name'], tep_number_db_to_user($activities_result['tariffs_amount'], 2), $activities_result['activities_travel_distance'], tep_number_db_to_user($activities_result['activities_expenses'], 2), $activities_result['activities_ticket_number'], str_replace(";", ":", str_replace(array("\r\n", "\n", "\r"), "|", $activities_result['activities_comment'])), $activities_result['categories_name']));
        }
        break;
}
// Get the show on the road
$csv->output('D');
// <!-- application_bottom //-->
require DIR_WS_INCLUDES . 'application_bottom.php';
// <!-- application_bottom_eof //-->
                    <td align="right" class="infoBoxHeading">
                      <?php 
echo tep_image_submit('arrow_right.gif', TEXT_TIMEREGISTRATION_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', $_SESSION['timesheet']->start_date)) . '&nbsp;&nbsp;-&nbsp;&nbsp;' . tep_strftime(DATE_FORMAT_SHORT, tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->end_date));
?>
</td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td><?php 
echo tep_draw_separator('pixel_trans.gif', '100%', '20');
?>
</td>
          </tr>
          <tr>
            <?php 
if ($_SESSION['timesheet']->locked) {
         $_POST['tariffs_end_date_display'] = '';
     }
     break;
 case 'save_data':
     // When action==save_data: verify entered data and save if OK / set errorlevel when NOK
     //
     // Format tariff from display to database
     if (tep_not_null($_POST['tariffs_amount_display']) && $_SESSION['tariff']->validate_amount($_POST['tariffs_amount_display'])) {
         $_POST['tariffs_amount'] = $_SESSION['tariff']->format_amount($_POST['tariffs_amount_display']);
     }
     // Format dates (from display to uts)
     if (tep_not_null($_POST['tariffs_start_date_display']) && tep_testdate(DATE_FORMAT_SHORT, $_POST['tariffs_start_date_display'])) {
         $_POST['tariffs_start_date'] = tep_datetouts(DATE_FORMAT_SHORT, $_POST['tariffs_start_date_display']);
     }
     if (tep_not_null($_POST['tariffs_end_date_display']) && tep_testdate(DATE_FORMAT_SHORT, $_POST['tariffs_end_date_display'])) {
         $_POST['tariffs_end_date'] = tep_datetouts(DATE_FORMAT_SHORT, $_POST['tariffs_end_date_display']);
     } else {
         if (!tep_not_null($_POST['tariffs_end_date_display'])) {
             $_POST['tariffs_end_date'] = 0;
         }
     }
     // Check for data format and required fields
     // change action when not everything is filled-in
     if ($_POST['tariffs_amount_display'] == '') {
         $_POST['action'] = 'enter_data';
         $error_level = 1;
         // No tariffs_amount
     } else {
         if ($_POST['units_id'] == '') {
             $_POST['action'] = 'enter_data';
             $error_level = 2;
          <tr>
            <td><?php 
echo tep_draw_separator('pixel_trans.gif', '100%', '20');
?>
</td>
          </tr>
          <tr>
            <td align="center">
              <!-- large_calendar //-->
              <?php 
$calendar_start = (int) strftime('%Y%m%d', tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->start_date));
$calendar_end = (int) strftime('%Y%m%d', tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->end_date));
$today = (int) strftime('%Y%m%d');
// Determine start day index
$calendar_day_index = (int) strftime('%u', tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->start_date)) - 1;
$calendar_day = (int) strftime('%d', tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->start_date));
// Get the day totals
$total_amount_per_day = $_SESSION['timesheet']->get_total_amount_per_day();
?>

              <table border="0" cellspacing="0" cellpadding="2" class="calendar">
                <tr>
                  <?php 
$colindex = 0;
// First display weekdays on top
echo '<td class="calendar-heading" align="center">' . TEXT_CALENDAR_MONDAY . '</td>';
echo '<td class="calendar-heading" align="center">' . TEXT_CALENDAR_TUESDAY . '</td>';
echo '<td class="calendar-heading" align="center">' . TEXT_CALENDAR_WEDNESDAY . '</td>';
echo '<td class="calendar-heading" align="center">' . TEXT_CALENDAR_THURSDAY . '</td>';
echo '<td class="calendar-heading" align="center">' . TEXT_CALENDAR_FRIDAY . '</td>';
echo '<td class="calendar-heading" align="center">' . TEXT_CALENDAR_SATURDAY . '</td>';
     }
     if ($_POST['employees_roles_end_date'] != 0) {
         $_POST['employees_roles_end_date_display'] = tep_strftime(DATE_FORMAT_SHORT, $_POST['employees_roles_end_date']);
     } else {
         $_POST['employees_roles_end_date_display'] = '';
     }
     break;
 case 'save_data':
     // When action==save_data: verify entered data and save if OK / set errorlevel when NOK
     //
     // First format dates (from display to uts)
     if (tep_not_null($_POST['employees_roles_start_date_display'])) {
         $_POST['employees_roles_start_date'] = tep_datetouts(DATE_FORMAT_SHORT, $_POST['employees_roles_start_date_display']);
     }
     if (tep_not_null($_POST['employees_roles_end_date_display'])) {
         $_POST['employees_roles_end_date'] = tep_datetouts(DATE_FORMAT_SHORT, $_POST['employees_roles_end_date_display']);
     } else {
         $_POST['employees_roles_end_date'] = 0;
     }
     // Check for data format and required fields
     // change action when not everything is filled-in
     if ($_POST['roles_id'] == '') {
         $_POST['action'] = 'enter_data';
         $error_level = 1;
         // No roles_id
     } else {
         if ($_POST['employees_id'] == '') {
             $_POST['action'] = 'enter_data';
             $error_level = 2;
             // No employees_id
         } else {
for (; $colindex < $calendar_day_index; $colindex++) {
    ?>
        <td class="<?php 
    echo $colindex >= 0 && $colindex <= 4 ? 'calendar-notavailable' : 'calendar-notavailable';
    ?>
" align="center">&nbsp;</td>
      <?php 
}
for ($counter = $calendar_start; $counter <= $calendar_end; $counter++, $calendar_day++, $colindex++) {
    if ($colindex % 7 == 0) {
        ?>
          </tr>
          <tr>
        <?php 
    }
    echo tep_draw_form('select_day_' . $calendar_day, tep_href_link(FILENAME_TIMEREGISTRATION)) . tep_create_parameters(array('mPath' => '200', 'selected_date' => tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->start_date, $calendar_day - 1), 'action' => 'select_project'), array('period', 'sort_order', 'activity_id'), 'hidden_field');
    ?>
          <td class="<?php 
    echo $counter == $today ? 'calendar-today' : ($colindex % 7 >= 0 && $colindex % 7 <= 4 ? 'calendar-weekday' : 'calendar-weekend');
    ?>
" align="center">
            <?php 
    //echo '<a href=' . tep_href_link(FILENAME_TIMEREGISTRATION, tep_create_parameters(array('mPath'=>'21','selected_date'=>tep_datetouts('%Y-%m-%d', $_SESSION['timesheet']->start_date, $calendar_day - 1),'action'=>'select_project'), array('period', 'activity_id'))) . '>' . $calendar_day . '</a>';
    echo tep_href_submit($calendar_day);
    ?>
          </td>
        </form>
      <?php 
}
// Walk the rest of the cells to complete the current row
for ($restindex = $colindex % 7; $restindex > 0 && $restindex <= 6; $restindex++) {