function UpdateAll($ts_fee_id) { global $conn; global $ts_fee_project; $count = 0; $updated_rows = 1; while ($updated_rows > 0) { $sql_all = "SELECT ts_fee_id, ts_fee_commence, ts_fee_pre, ts_fee_time_end, ts_fee_pre_lag FROM intranet_timesheet_fees WHERE ts_fee_project = {$ts_fee_project} AND ts_fee_id != {$ts_fee_id} AND ts_fee_pre > 0 ORDER BY ts_fee_pre"; $result_all = mysql_query($sql_all, $conn) or die(mysql_error()); //echo "<p>$sql_all</p>"; while ($array_all = mysql_fetch_array($result_all)) { $ts_fee_id = $array_all['ts_fee_id']; $ts_fee_pre = $array_all['ts_fee_pre']; $ts_fee_pre_lag = $array_all['ts_fee_pre_lag']; //echo "<h3>ID: $ts_fee_id - $ts_fee_pre</h3>"; // Work out the conclusion of the previous linked stage $sql_previous = "SELECT ts_fee_id, ts_fee_commence, ts_fee_pre, ts_fee_time_end FROM intranet_timesheet_fees WHERE ts_fee_project = {$ts_fee_project} AND ts_fee_id = {$ts_fee_pre} LIMIT 1"; $result_previous = mysql_query($sql_previous, $conn) or die(mysql_error()); $array_previous = mysql_fetch_array($result_previous); $newdate = AssessDays($array_previous['ts_fee_commence']) + $array_previous['ts_fee_time_end'] + $ts_fee_pre_lag; $newdate = date("Y-n-j", $newdate); //echo "<p>$sql_previous</p>"; //echo "<p>New Start: " . $newdate . "</p>"; $sql_push = "UPDATE intranet_timesheet_fees SET ts_fee_commence = '{$newdate}' WHERE ts_fee_id = {$ts_fee_id} AND ts_fee_project = {$ts_fee_project}"; $result_push = mysql_query($sql_push, $conn) or die(mysql_error()); $updated_rows = mysql_affected_rows(); //if ($updated_rows == 0 && $user_usertype_current > 2) { echo "<p>[$count] " . $sql_push . "(Updated Rows: $updated_rows)</p>"; } else { echo "<p>[$count] " . $sql_push . "(Updated Rows: $updated_rows)</p>";} //echo "<p>$sql_push<br />Affected rows: " . $updated_rows . "</p>"; if ($_POST[datum] == 1) { $sql_datum = "UPDATE intranet_timesheet_fees SET ts_datum_commence = '{$newdate}' WHERE ts_fee_id = {$ts_fee_id} LIMIT 1"; $result_datum = mysql_query($sql_datum, $conn) or die(mysql_error()); } } $count++; if ($updated_rows == 0) { break; } // This is a horrible way of breaking the loop if necessary if ($count > 100) { break; } } }
echo "<h3>Date of fee stage commencement</h3>"; echo "<p><input type=\"date\" name=\"ts_fee_commence\" value=\"{$ts_fee_commence}\" /></p>"; echo "</fieldset>"; if ($ts_fee_id != "" && $proj_active == 1) { echo "<fieldset><legend>Change Project</legend><p>You can move this fee stage to another project here:</p>"; $data_project = $ts_fee_project; $result_data = "ts_fee_project"; include_once "dropdowns/inc_data_dropdown_projects.php"; } else { echo "<input type=\"hidden\" name=\"ts_fee_project\" value=\"{$ts_fee_project}\" />"; } echo "</fieldset>"; if ($ts_fee_id > 0) { echo "<fieldset><legend>Datum</legend>"; if ($ts_datum_commence != NULL) { echo "<p>Current Datum: " . TimeFormat(AssessDays($ts_datum_commence)) . " to " . TimeFormat(AssessDays($ts_datum_commence) + $ts_datum_length) . "</p>"; } if ($ts_datum_commence == NULL) { $checked = " checked=\"checked\" "; } else { unset($checked); } echo "<p><input type=\"checkbox\" value=\"1\" name=\"datum\" {$checked} /> Reset the datum to these new dates?</p>"; echo "</fieldset>"; } echo "<fieldset><legend>Change Project</legend>"; echo "<p>You can move this fee stage to another project by selecting it from below. Note that this will break any links with other fee stages in the current project.</p>"; $sql6 = "SELECT proj_num, proj_name, proj_id FROM intranet_projects WHERE proj_active = 1 ORDER BY proj_num DESC"; $result6 = mysql_query($sql6, $conn) or die(mysql_error()); echo "<select name=\"ts_fee_proj_change\">"; while ($array6 = mysql_fetch_array($result6)) {
$sql2 = "SELECT * FROM intranet_timesheet_invoice WHERE invoice_id = '{$ts_fee_invoice}' LIMIT 1"; $result2 = mysql_query($sql2, $conn) or die(mysql_error()); $array2 = mysql_fetch_array($result2); $invoice_id = $array2['invoice_id']; $invoice_ref = $array2['invoice_ref']; $invoice_date = $array2['invoice_date']; $proj_fee_total = $proj_value * ($proj_fee_percentage / 100); if ($ts_fee_percentage > 0) { $ts_fee_calc = $proj_fee_total * ($ts_fee_percentage / 100); } else { $ts_fee_calc = $ts_fee_value; } $fee_total = $fee_total + $ts_fee_calc; // This bit needs re-writing to cross out any completed stages // if ($proj_riba > $riba_order) { $highlight = $highlight."text-decoration: line-through;"; } $prog_begin = AssessDays($ts_fee_commence); if ($prog_begin > 0) { $prog_end = $prog_begin + $ts_fee_time_end; } else { $prog_begin = time(); } // Calculate the time we are through the stage if (time() > $prog_begin && time() < $prog_end) { $percent_complete = time() - $prog_begin; $percent_complete = $percent_complete / $ts_fee_time_end; } elseif (time() > $prog_end) { $percent_complete = 1; } else { $percent_complete = 0; } $percent_complete = $percent_complete * 100;
} //echo "<p>" . date("Y-m-d",$counter_time) . " (Weekend: " . $weekend . ", Bank Holiday: " . $bank_holiday . ", Existing: " . $existing_holiday . ")</p>"; if ($weekend == "no" and $bank_holiday == "no" and $holidays_existingholidays == "no") { $inserted = $inserted++; } if ($weekend == "no" and $bank_holiday == "no" and $holidays_existingholidays == "no" and $insert == "yes") { $sql_holidays = "INSERT INTO intranet_user_holidays (holiday_id, holiday_user, holiday_date, holiday_month, holiday_year, holiday_approved, holiday_timestamp, holiday_length, holiday_paid, holiday_datestamp, holiday_assigned) VALUES ( NULL, {$user}, " . date("j", $counter_time) . "," . date("n", $counter_time) . "," . date("Y", $counter_time) . ", NULL," . $counter_time . "," . $length . "," . $paid . ",'" . date("Y-m-d", $counter_time) . "','" . date("Y", $counter_time) . "')"; $result_holidays = mysql_query($sql_holidays, $conn); echo "<li>" . date("l j F Y", $counter_time) . " </li>"; } elseif ($weekend == "no" and $bank_holiday == "no" and $holidays_existingholidays == "no" and $insert != "yes") { echo "<li>" . date("l j F Y", $counter_time) . "</li>"; $inserted = $inserted++; } elseif ($bank_holiday == "yes") { echo "<li>" . date("l j F Y", $counter_time) . " is a bank holiday</li>"; } elseif ($holidays_existingholidays == "yes" && $weekend == "no") { echo "<li>" . Date("l j F Y", $counter_time) . " is already booked as holiday</li>"; } if ($weekend == "no" && $bank_holiday == "no" && $existing_holiday == "no") { $counter_days++; } $counter_time = $counter_time + 86400; } echo "</ul>"; //if ($inserted == 0) { echo "<p>No holidays requested.</p>"; } return $counter_days; } $holiday_begin = $_POST[holiday_day_start]; $time_begin = AssessDays($holiday_begin); $holiday_back = $_POST[holiday_day_back]; $time_back = AssessDays($holiday_back);
$condition_submitted = "- None -"; $background = " style=\"background: rgba(255,0,0,0.5);\" "; } if ($array_conditions['condition_submitted_ref']) { $condition_submitted = $condition_submitted . "<br />(Ref. " . $array_conditions['condition_submitted_ref'] . ")"; } if ($array_conditions['condition_submitted'] != "0000-00-00" && $array_conditions['condition_approved'] != "0000-00-00") { $background = " style=\"background: rgba(0,255,0,0.5);\" "; } if (!$background) { $background = " style=\"background: rgba(150,150,150,0.5);\" "; } if ($array_conditions['condition_decision_date'] == "0000-00-00") { $condition_decision_date = "- None -"; } else { $condition_decision_date = date("j M Y", AssessDays($array_conditions['condition_decision_date'])); } if ($array_conditions['company_name'] != NULL) { $company_name = $array_conditions['company_name']; } else { $company_name = $pref_practice; } echo "<tr id=\"{$showdetail}\"><td {$background}><a href=\"" . $array_conditions['condition_link'] . "\">" . $array_conditions['condition_ref'] . "</a></td><td {$background}><a href=\"index2.php?page=project_planningcondition_edit&proj_id={$proj_id}&condition_id=" . $array_conditions['condition_id'] . "\"><img src=\"images/button_edit.png\" alt=\"Edit Planning Condition\" /></a></td><td {$background}><a href=\"index2.php?page=project_planningcondition_list&proj_id={$proj_id}&showdetail=" . $array_conditions['condition_id'] . "#" . $array_conditions['condition_id'] . "\">" . $array_conditions['condition_number'] . "</a></td><td {$background}>" . $company_name . "</td><td {$background}>" . $array_conditions['condition_type'] . "</td><td {$background}>" . $condition_decision_date . "</td><td {$background}>" . $condition_submitted . "</td><td {$background}>" . $condition_approved . "</td></tr>"; if ($showdetail > 0 && $array_conditions['condition_text'] != NULL) { echo "<tr><td>Details:</td><td colspan=\"7\">" . nl2br($array_conditions['condition_text']) . "</td></tr>"; } if ($showdetail > 0 && $array_conditions['condition_note'] != NULL) { echo "<tr><td>Notes:</td><td colspan=\"7\"><span class=\"minitext\">" . nl2br($array_conditions['condition_note']) . "</span></td></tr>"; } } echo "</table>";
$pdf->SetFillColor(254, 240, 120); } elseif ($array_conditions['condition_type'] == "Pre-Occupation" && $array_conditions['condition_submitted'] != "0000-00-00") { $condition_submitted = date("j M Y", AssessDays($array_conditions['condition_submitted'])); $pdf->SetFillColor(255, 255, 120); } elseif ($array_conditions['condition_type'] == "Pre-Occupation" && $array_conditions['condition_submitted'] == "0000-00-00") { $condition_submitted = "- None -"; $pdf->SetFillColor(255, 255, 120); } else { $condition_submitted = "Not submitted"; $pdf->SetFillColor(254, 120, 120); } if ($array_conditions['condition_submitted'] != "0000-00-00" && $array_conditions['condition_approved'] != "0000-00-00") { $pdf->SetFillColor(200, 254, 150); } if ($array_conditions['condition_decision_date'] > 0) { $condition_decision_date = AssessDays($array_conditions['condition_decision_date']); } if ($array_conditions['condition_decision_date'] == "0000-00-00") { $condition_decision_date = "- None -"; } else { $condition_decision_date = "Approval Date: " . date("j M Y", $condition_decision_date); } if ($array_conditions['company_name'] != NULL) { $company_name = $array_conditions['company_name']; } elseif ($array_conditions['condition_type'] == "Informative Only") { unset($company_name); } else { $company_name = $pref_practice; } if ($current_ref != $array_conditions['condition_ref']) { $pdf->ln(10);
$pdf->Cell(0, 4, $cost_unassigned, 0, 1, L); $pdf->Cell(0, 1, '', 0, 1); } else { $pdf->Cell(0, 1, '', 0, 1); } // Now include the project checklist completion $pdf->Cell(13, 2, 'Checklist', 0, 0, R); Checklist($proj_id); } // This prints the fee stages // First establish the width of the fee stage bar $sql_fee_stage = "SELECT ts_fee_value, ts_fee_stage, ts_fee_commence, ts_fee_time_end FROM intranet_timesheet_fees WHERE ts_fee_id = {$ts_fee_id} AND ts_fee_prospect = 100 "; $result_fee_stage = mysql_query($sql_fee_stage, $conn) or die(mysql_error()); $array_fee_stage = mysql_fetch_array($result_fee_stage); $fee_stage = $array_fee_stage['ts_fee_value']; $fee_commence = AssessDays($array_fee_stage['ts_fee_commence']); $fee_time_end = $array_fee_stage['ts_fee_time_end'] + $fee_commence; if ($fee_commence < time() && $fee_time_end > time()) { //$percent_complete = (time() - $fee_commence) / ($fee_time_end); //$percent_complete = round ($percent_complete,0) . "%"; } else { //$percent_complete = $fee_time_end; } // Now establish the width of the timesheet hours to date for this fee stage only $sql_cost_total = " SELECT SUM(ts_cost_factored * (1 - user_prop_target)) FROM intranet_timesheet, intranet_user_details WHERE user_id = ts_user AND `ts_stage_fee` = {$ts_fee_id} AND `ts_project` = {$proj_id} = 100"; $result_cost_total = mysql_query($sql_cost_total, $conn) or die(mysql_error()); $array_cost_total = mysql_fetch_array($result_cost_total); $cost_total = $array_cost_total['SUM(ts_cost_factored * (1 - user_prop_target))']; $sql_cost_stage = " SELECT SUM(ts_cost_factored * (1 - user_prop_target)) FROM intranet_timesheet , intranet_user_details WHERE user_id = ts_user AND `ts_stage_fee` = {$ts_fee_id} AND `ts_project` = {$proj_id} "; $result_cost_stage = mysql_query($sql_cost_stage, $conn) or die(mysql_error()); $array_cost_stage = mysql_fetch_array($result_cost_stage);
<?php $issue_date = AssessDays($_POST[set_date]); $issue_set = time(); $total = 0; // Establish the two arrays from the submission page $array_contact_id = $_POST['contact_id']; $array_company_id = $_POST['company_id']; $array_issue_to = $_POST['issue_to']; $array_drawing = $_POST['drawing_id']; $array_revision = $_POST['revision_id']; $array_issued = $_POST['drawing_issued']; $issue_method = $_POST['issue_method']; $issue_format = $_POST['issue_format']; $issue_comment = $_POST['issue_comment']; $issue_project = $_POST['issue_project']; $issue_checked = $_POST['set_checked']; if ($_POST[issue_reason] == NULL) { $issue_reason = CleanUp($_POST[issue_revision_other]); } else { $issue_reason = $_POST[issue_reason]; } $issue_timestamp = time(); // First add the actual drawing set to the database $sql_set = "INSERT INTO intranet_drawings_issued_set (\n\t\t\t\t\tset_id,\n\t\t\t\t\tset_date,\n\t\t\t\t\tset_project,\n\t\t\t\t\tset_reason,\n\t\t\t\t\tset_user,\n\t\t\t\t\tset_comment,\n\t\t\t\t\tset_timestamp,\n\t\t\t\t\tset_method,\n\t\t\t\t\tset_format,\n\t\t\t\t\tset_checked\n\t\t\t\t\t) values (\n\t\t\t\t\t'NULL',\n\t\t\t\t\t'{$issue_date}',\n\t\t\t\t\t'{$issue_project}',\n\t\t\t\t\t'{$issue_reason}',\n\t\t\t\t\t'{$_COOKIE['user']}',\n\t\t\t\t\t'{$issue_comment}',\n\t\t\t\t\t'{$issue_timestamp}',\n\t\t\t\t\t'{$issue_method}',\n\t\t\t\t\t'{$issue_format}',\n\t\t\t\t\t'{$issue_checked}'\n\t\t\t\t\t)"; $result_set = mysql_query($sql_set, $conn) or die(mysql_error()); $issue_set = mysql_insert_id(); // Loop through each of the contacts selected $count = 0; while ($count < count($array_contact_id)) { $issue_contact = $array_contact_id[$count];
$bankholiday_timestamp = $array_bankholidays['bankholiday_timestamp']; echo "<p>The next Bank Holiday is <a href=\"index2.php?page=datebook_view_day&time={$bankholiday_timestamp}\">" . TimeFormat($bankholiday_timestamp) . ".</a></p>"; $sql_holiday = "SELECT user_holidays, user_user_added, user_user_ended FROM intranet_user_details WHERE user_id = {$user_id} AND holiday_paid = 1 LIMIT 1"; $result_holiday = mysql_query($sql_holiday, $conn); $array_holiday = mysql_fetch_array($result_holiday); $user_holidays = $array_holiday['user_holidays']; $user_user_added = $array_holiday['user_user_added']; $user_user_ended = $array_holiday['user_user_ended']; $beginning_of_year = mktime(0, 0, 0, 1, 1, $this_year); $end_of_year = mktime(0, 0, 0, 1, 1, $this_year + 1); echo "<h2>Holiday Request</h2>"; $holiday_remaining = UserHolidays($user_id, "yes"); if ($_POST[assess] == 1) { echo "<fieldset><legend>Confirm Holiday Request</legend>"; $holiday_day_start = AssessDays($_POST[holiday_day_start]); $holiday_day_back = AssessDays($_POST[holiday_day_back]); $holiday_count = CheckHolidays($holiday_day_start, $holiday_day_back, "no", $user_id, $_POST[holiday_length], $paid); $holiday_remaining = $holiday_remaining - $holiday_count; //echo "<p>This will leave you with " . $holiday_remaining . " remaining holidays this year.</p>"; echo "<p><form action=\"index2.php?page=holiday_request\" method=\"post\"><input type=\"hidden\" name=\"action\" value=\"holiday_request\" /><input type=\"hidden\" name=\"assess\" value=\"2\" /><input type=\"hidden\" value=\"{$time_begin}\" name=\"holiday_begin\" /><input type=\"hidden\" value=\"{$_POST['holiday_length']}\" name=\"holiday_length\" /><input type=\"hidden\" value=\"{$time_back}\" name=\"holiday_back\" /><input type=\"hidden\" value=\"{$user_id}\" name=\"user_id\" /><input type=\"hidden\" value=\"{$paid}\" name=\"paid\" /><input type=\"submit\" value=\"Confirm\" /></p>"; echo "</fieldset>"; } if ($_POST[assess] == 2) { echo "<fieldset><legend>Holiday Request Confirmed</legend>"; echo "<p>You have requested the following days holiday:</p>"; $holiday_count = CheckHolidays($_POST[holiday_begin], $_POST[holiday_back], "yes", $user_id, $_POST[holiday_length], $paid); $holiday_remaining = $user_holidays - $holiday_count; echo "<p>Please note that your holiday request cannot be confirmed until it has been approved in writing.</p><p><a href=\"pdf_holiday_request.php\">Please click here</a> to download the request form.</p>"; echo "</fieldset>"; } if ($_POST[assess] < 1) {
<?php if ($_POST[user_id] > 0) { $user_id = $_POST[user_id]; } else { $user_id = ""; } $user_user_added = AssessDays($_POST[user_user_added], 8); $user_user_ended = AssessDays($_POST[user_user_ended], 18); $user_address_county = addslashes($_POST[user_address_county]); $user_address_postcode = addslashes($_POST[user_address_postcode]); $user_address_town = addslashes($_POST[user_address_town]); $user_address_3 = addslashes($_POST[user_address_3]); $user_address_2 = addslashes($_POST[user_address_2]); $user_address_1 = addslashes($_POST[user_address_1]); $user_name_first = addslashes($_POST[user_name_first]); $user_name_second = addslashes($_POST[user_name_second]); $user_username = addslashes($_POST[user_username]); $user_email = addslashes($_POST[user_email]); $user_initials = addslashes($_POST[user_initials]); if ($user_id > 0) { if ($_POST[update_user_password] == "yes" && $_POST[update_user_password] != NULL) { $user_password = md5($_POST[user_password]); $update_password = "******"; } else { unset($update_password); } $sql = "UPDATE intranet_user_details SET\n\tuser_address_county = '{$user_address_county}',\n\tuser_address_postcode = '{$user_address_postcode}',\n\tuser_address_town = '{$user_address_town}',\n\tuser_address_3 = '{$user_address_3}',\n\tuser_address_2 = '{$user_address_2}',\n\tuser_address_1 = '{$user_address_1}',\n\tuser_name_first = '{$user_name_first}',\n\tuser_name_second = '{$user_name_second}',\n\tuser_num_extension = '{$_POST['user_num_extension']}',\n\tuser_num_mob = '{$_POST['user_num_mob']}',\n\tuser_num_home = '{$_POST['user_num_home']}',\n\tuser_email = '{$user_email}',\n\tuser_usertype = '{$_POST['user_usertype']}',\n\tuser_active = '{$_POST['user_active']}',\n\tuser_username = '******',\n\tuser_user_rate = '{$_POST['user_user_rate']}',\n\tuser_user_timesheet = '{$_POST['user_user_timesheet']}',\n\tuser_user_added = '{$user_user_added}',\n\tuser_user_ended = '{$user_user_ended}',\n\tuser_holidays = '{$_POST['user_holidays']}',\n\tuser_initials = '{$user_initials}',\n\tuser_prop_target = '{$_POST['user_prop_target']}',\n\tuser_user_timesheet = '{$_POST['user_user_timesheet']}',\n\tuser_timesheet_hours = '{$_POST['user_timesheet_hours']}'\n\t{$update_password}\n\tWHERE user_id = '{$user_id}' LIMIT 1"; $result = mysql_query($sql, $conn) or die(mysql_error()); } elseif ($user_id == NULL && $user_usertype_current > 3) { $user_password = md5($_POST[user_password]);
function Datum($start, $duration, $color_array) { global $current_time; global $pdf; global $colwidth; global $rowheight; $y = $pdf->GetY(); $y = $y - $rowheight; $pdf->SetY($y); $pdf->SetX(50); $pdf->SetLineWidth(0.3); $datum_start = BeginWeek(AssessDays($start)); if ($datum_start < $current_time) { $duration = $duration - ($current_time - $datum_start); } $duration = round($duration / 604800, 0) * $colwidth; if ($datum_start < $current_time) { $datum_start = 0; } else { $datum_start = $datum_start - $current_time; } $datum_start = round($datum_start / 604800, 0); $datum_start = $datum_start * $colwidth; if ($datum_start + $duration > 230) { $duration = 230 - $datum_start; } if ($datum_start > 0 && $datum_start < 230) { $pdf->Cell($datum_start, $rowheight, '', 0, 0, L, FALSE); } if ($color_array == NULL) { $pdf->SetDrawColor(100); } else { $pdf->SetDrawColor($color_array[0], $color_array[1], $color_array[2]); } if ($datum_start < 230 && $datum_start + $duration > 0) { $pdf->Cell($duration, $rowheight, '', T, 1, L, FALSE); } else { $pdf->Cell(0, $rowheight, '', 0, 1, L, FALSE); } $pdf->SetLineWidth(0.2); $pdf->SetX(10); }