Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions ajax/editActivity.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
$activityDate = trim(urldecode($_POST['date']));
$activityHour = trim(urldecode($_POST['hour']));
$activityMinute = trim(urldecode($_POST['minute']));
$activityAMPM = trim(urldecode($_POST['ampm']));

$dateFormatFlag = $_SESSION['CATS']->isDateDMY()
? DATE_FORMAT_DDMMYY
Expand All @@ -99,19 +98,17 @@
$jobOrderID = -1;
}

/* Convert formatted time to UNIX timestamp. */
$time = strtotime(
sprintf('%02d:%02d %s', $activityHour, $activityMinute, $activityAMPM)
);
/* Convert time fields to a 'HH:MM:SS' string. */
$is24 = $_SESSION['CATS']->isTimeFormat24();
$activityAMPM = $is24 ? '' : trim(urldecode($_POST['ampm']));
$timeStr = DateUtility::normalizeActivityTime($activityHour, $activityMinute, $activityAMPM, $is24);
if ($timeStr === false)
{
die('Invalid time.');
}

/* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */
$date = sprintf(
'%s %s',
DateUtility::convert(
'-', $activityDate, $dateFormatFlag, DATE_FORMAT_YYYYMMDD
),
date('H:i:00', $time)
);
$date = DateUtility::convert('-', $activityDate, $dateFormatFlag, DATE_FORMAT_YYYYMMDD) . ' ' . $timeStr;

/* Save the new activity entry. */
$activityEntries = new ActivityEntries();
Expand Down
11 changes: 11 additions & 0 deletions installwizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,17 @@
</select>
</td>
</tr>
<tr>
<td>Please choose your preferred time format.</td>
</tr>
<tr>
<td>
<select id="timeFormat" name="timeFormat" style="width: 150px;" class="selectBox">
<option value="12" selected="selected">12-hour (1:30 PM)</option>
<option value="24">24-hour (13:30)</option>
</select>
</td>
</tr>
<tr>
<td>Please enter your default phone country calling code.</td>
</tr>
Expand Down
105 changes: 66 additions & 39 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,31 +296,46 @@
var userDateFormat = (typeof window.CATSUserDateFormat !== "undefined" ? window.CATSUserDateFormat : "MM-DD-YY");
dateSpan.innerHTML = DateInputForDOM("dateEditActivity" + activityID, true, userDateFormat, dateAndTime.substr(0,dateAndTime.indexOf(" ")), -1);

var timeString = dateAndTime.substr(dateAndTime.indexOf(" ")+2);
var hourString = timeString.substr(0,timeString.indexOf(":"));
var timeString = timeString.substr(timeString.indexOf(":")+1);
var minuteString = timeString.substr(0,timeString.indexOf(" "));
var timeString = timeString.substr(timeString.indexOf(" ")+1);
var amPmString = timeString.substr(0,timeString.indexOf(")"));

/* Time editor. */
/* Parse time from display string: strip date prefix and the opening "(". */
var timeSection = dateAndTime.substr(dateAndTime.indexOf("(") + 1);
var hourString, minuteString, amPmString;
if (window.CATSTimeFormat24)
{
/* 24-hour display: "(HH:MM)" */
hourString = timeSection.substr(0, timeSection.indexOf(":"));
minuteString = timeSection.substr(timeSection.indexOf(":") + 1, 2);
amPmString = "";
}
else
{
/* 12-hour display: "(H:MM AM)" or "(H:MM PM)" */
hourString = timeSection.substr(0, timeSection.indexOf(":"));
var rest = timeSection.substr(timeSection.indexOf(":") + 1);
minuteString = rest.substr(0, rest.indexOf(" "));
amPmString = rest.substr(rest.indexOf(" ") + 1, 2);
}

/* Time editor — hour select. */
var hourSelect = document.createElement("select");
hourSelect.setAttribute("id", "hourEditActivity" + activityID);
for (var i = 1; i<= 12; ++i)
var hourMin = window.CATSTimeFormat24 ? 0 : 1;
var hourMax = window.CATSTimeFormat24 ? 23 : 12;
for (var i = hourMin; i <= hourMax; ++i)
{
var hourSelectOption = document.createElement("option");
hourSelectOption.value = i;
hourSelectOption.innerHTML = i;
hourSelectOption.innerHTML = window.CATSTimeFormat24 ? (i < 10 ? '0' + i : '' + i) : i;
if (hourString * 1 == i)
{
hourSelectOption.selected = true;
}
hourSelect.appendChild(hourSelectOption);
}


/* Time editor — minute select. */
var minuteSelect = document.createElement("select");
minuteSelect.setAttribute("id", "minuteEditActivity" + activityID);
for (var i = 0; i<= 59; ++i)
for (var i = 0; i <= 59; ++i)

Check warning on line 338 in js/activity.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

js/activity.js#L338

'i' is already defined.

Check warning on line 338 in js/activity.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

js/activity.js#L338

'i' used outside of binding context.
{
var minuteSelectOption = document.createElement("option");
minuteSelectOption.value = i;
Expand All @@ -331,37 +346,45 @@
}
minuteSelect.appendChild(minuteSelectOption);
}

var AMPMSelect = document.createElement("select");
AMPMSelect.setAttribute("id", "ampmEditActivity" + activityID);

var AMPMSelectOptionAM = document.createElement("option");
AMPMSelectOptionAM.value = "AM";
AMPMSelectOptionAM.innerHTML = "AM";
if (amPmString == "AM")
{
AMPMSelectOptionAM.selected = true;
}
AMPMSelect.appendChild(AMPMSelectOptionAM);

var AMPMSelectOptionPM = document.createElement("option");
AMPMSelectOptionPM.value = "PM";
AMPMSelectOptionPM.innerHTML = "PM";
if (amPmString == "PM")

/* Time editor — AM/PM select (12-hour mode only). */
var AMPMSelect = null;
if (!window.CATSTimeFormat24)
{
AMPMSelectOptionPM.selected = true;
AMPMSelect = document.createElement("select");
AMPMSelect.setAttribute("id", "ampmEditActivity" + activityID);

var AMPMSelectOptionAM = document.createElement("option");
AMPMSelectOptionAM.value = "AM";
AMPMSelectOptionAM.innerHTML = "AM";
if (amPmString == "AM")
{
AMPMSelectOptionAM.selected = true;
}
AMPMSelect.appendChild(AMPMSelectOptionAM);

var AMPMSelectOptionPM = document.createElement("option");
AMPMSelectOptionPM.value = "PM";
AMPMSelectOptionPM.innerHTML = "PM";
if (amPmString == "PM")
{
AMPMSelectOptionPM.selected = true;
}
AMPMSelect.appendChild(AMPMSelectOptionPM);
}
AMPMSelect.appendChild(AMPMSelectOptionPM);


var dateTimeTable = document.createElement("table");
var dateTimeTableTr = document.createElement("tr");
var dateTimeTableTdLeft = document.createElement("td");
var dateTimeTableTdRight = document.createElement("td");

dateTimeTableTdLeft.appendChild(dateSpan);
dateTimeTableTdRight.appendChild(hourSelect);
dateTimeTableTdRight.appendChild(minuteSelect);
dateTimeTableTdRight.appendChild(AMPMSelect);

dateTimeTableTdLeft.appendChild(dateSpan);
dateTimeTableTdRight.appendChild(hourSelect);
dateTimeTableTdRight.appendChild(minuteSelect);
if (AMPMSelect)
{
dateTimeTableTdRight.appendChild(AMPMSelect);
}
dateTimeTableTr.appendChild(dateTimeTableTdLeft);
dateTimeTableTr.appendChild(dateTimeTableTdRight);
dateTimeTable.appendChild(dateTimeTableTr);
Expand Down Expand Up @@ -390,7 +413,7 @@
document.getElementById("dateEditActivity" + activityID).value,
document.getElementById("hourEditActivity" + activityID).value,
document.getElementById("minuteEditActivity" + activityID).value,
document.getElementById("ampmEditActivity" + activityID).value,
AMPMSelect ? AMPMSelect.value : "",
oldEditRow,
newEditRow,
activityID,
Expand Down Expand Up @@ -861,6 +884,10 @@

document.getElementById("hour").disabled = disableTime;
document.getElementById("minute").disabled = disableTime;
document.getElementById("meridiem").disabled = disableTime;
var meridiem = document.getElementById("meridiem");
if (meridiem)
{
meridiem.disabled = disableTime;
}
document.getElementById("duration").disabled = disableTime;
}
4 changes: 3 additions & 1 deletion js/wizardIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@
// This is the localization page
var timeZone = document.getElementById("timeZone");
var dateFormat = document.getElementById("dateFormat");
var timeFormatEl = document.getElementById("timeFormat");
var timeFormat = timeFormatEl ? timeFormatEl.value : "12";
failAction = "alert(\"Unable to set your localization settings! Please try again.\");";
userActionSuccess = "funcNext();";
failAction = "";
userAction("Localization&timeZone=" + escape(timeZone.value) + "&dateFormat=" + escape(dateFormat.value));
userAction("Localization&timeZone=" + escape(timeZone.value) + "&dateFormat=" + escape(dateFormat.value) + "&timeFormat=" + escape(timeFormat));

Check warning on line 99 in js/wizardIntro.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

js/wizardIntro.js#L99

'userAction' was used before it was defined.
return false;
}

Expand Down
10 changes: 7 additions & 3 deletions lib/ActivityEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@
class ActivityEntries
{
private $_db;
private $_mysqlDateTimeFormat;


public function __construct()
{
$this->_db = DatabaseConnection::getInstance();

$is24 = (isset($_SESSION['CATS']) && $_SESSION['CATS']->isTimeFormat24());
$this->_mysqlDateTimeFormat = DateUtility::getMysqlDateTimeFormat($is24);

Check warning on line 74 in lib/ActivityEntries.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/ActivityEntries.php#L74

Avoid using static access to class 'DateUtility' in method '__construct'.
}


Expand Down Expand Up @@ -405,7 +409,7 @@
activity_type.short_description AS typeDescription,
activity.notes AS notes,
DATE_FORMAT(
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '" . $this->_mysqlDateTimeFormat . "'
) AS dateCreated,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
Expand Down Expand Up @@ -450,7 +454,7 @@
activity.joborder_id AS jobOrderID,
activity.notes AS notes,
DATE_FORMAT(
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '" . $this->_mysqlDateTimeFormat . "'
) AS dateCreated,
activity.date_occurred AS dateCreatedSort,
activity.type AS type,
Expand Down Expand Up @@ -503,7 +507,7 @@
activity.joborder_id AS jobOrderID,
activity.notes AS notes,
DATE_FORMAT(
activity.date_occurred, '%%m-%%d-%%y (%%h:%%i %%p)'
activity.date_occurred, '" . $this->_mysqlDateTimeFormat . "'
) AS dateCreated,
activity.date_occurred AS dateCreatedSort,
activity.type AS type,
Expand Down
4 changes: 2 additions & 2 deletions lib/Attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
directory_name AS directoryName,
md5_sum AS md5sum,
file_size_kb AS fileSizeKB,
DATE_FORMAT(date_created, '%%m-%%d-%%y (%%h:%%i:%%s %%p)') AS dateCreated
DATE_FORMAT(date_created, '" . DateUtility::getMysqlDateTimeSecondsFormat() . "') AS dateCreated

Check warning on line 490 in lib/Attachments.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Attachments.php#L490

Avoid using static access to class 'DateUtility' in method 'getAll'.
FROM
attachment
WHERE
Expand Down Expand Up @@ -550,7 +550,7 @@
directory_name AS directoryName,
md5_sum AS md5sum,
file_size_kb AS fileSizeKB,
DATE_FORMAT(date_created, '%%m-%%d-%%y (%%h:%%i:%%s %%p)') AS dateCreated
DATE_FORMAT(date_created, '" . DateUtility::getMysqlDateTimeSecondsFormat() . "') AS dateCreated
FROM
attachment
WHERE
Expand Down
10 changes: 5 additions & 5 deletions lib/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
calendar_event.date, '%%m-%%d-%%y'
) AS date,
DATE_FORMAT(
calendar_event.date, '%%h:%%i %%p'
calendar_event.date, '" . DateUtility::getMysqlTimeFormat() . "'

Check warning on line 112 in lib/Calendar.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Calendar.php#L112

Avoid using static access to class 'DateUtility' in method 'getEventArray'.
) AS time,
DATE_FORMAT(
calendar_event.date, '%%H'
Expand All @@ -119,7 +119,7 @@
) AS minute,
calendar_event.date AS dateSort,
DATE_FORMAT(
calendar_event.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
calendar_event.date_created, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 122 in lib/Calendar.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Calendar.php#L122

Avoid using static access to class 'DateUtility' in method 'getEventArray'.
) AS dateCreated,
calendar_event_type.calendar_event_type_id AS eventType,
calendar_event_type.short_description AS eventTypeDescription,
Expand Down Expand Up @@ -608,7 +608,7 @@
calendar_event.description AS description,
calendar_event.public AS public,
DATE_FORMAT(
calendar_event.date, '%%m-%%d-%%y (%%h:%%i %%p)'
calendar_event.date, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 611 in lib/Calendar.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Calendar.php#L611

Avoid using static access to class 'DateUtility' in method 'getUpcomingEventsByDataItem'.
) AS dateShow,
DATE_FORMAT(
calendar_event.date, '%%d'
Expand Down Expand Up @@ -705,7 +705,7 @@
calendar_event.date, '%%m-%%d-%%y'
) AS date,
DATE_FORMAT(
calendar_event.date, '%%h:%%i %%p'
calendar_event.date, '" . DateUtility::getMysqlTimeFormat() . "'
) AS time,
calendar_event.date AS dateSort,
entered_by_user.user_id AS userID,
Expand Down Expand Up @@ -752,7 +752,7 @@
calendar_event.date, '%%m-%%d-%%y'
) AS date,
DATE_FORMAT(
calendar_event.date, '%%h:%%i %%p'
calendar_event.date, '" . DateUtility::getMysqlTimeFormat() . "'
) AS time,
calendar_event.date AS dateSort,
entered_by_user.user_id AS userID,
Expand Down
4 changes: 2 additions & 2 deletions lib/Candidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@
candidate.is_hot AS isHot,
candidate.is_admin_hidden AS isAdminHidden,
DATE_FORMAT(
candidate.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
candidate.date_created, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 540 in lib/Candidates.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Candidates.php#L540

Avoid using static access to class 'DateUtility' in method 'get'.
) AS dateCreated,
DATE_FORMAT(
candidate.date_modified, '%%m-%%d-%%y (%%h:%%i %%p)'
candidate.date_modified, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 543 in lib/Candidates.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Candidates.php#L543

Avoid using static access to class 'DateUtility' in method 'get'.
) AS dateModified,
COUNT(
candidate_joborder.joborder_id
Expand Down
2 changes: 1 addition & 1 deletion lib/Companies.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
billing_contact.first_name, ' ', billing_contact.last_name
) AS billingContactFullName,
DATE_FORMAT(
company.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
company.date_created, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 377 in lib/Companies.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Companies.php#L377

Avoid using static access to class 'DateUtility' in method 'get'.
) AS dateCreated,
CONCAT(
entered_by_user.first_name, ' ', entered_by_user.last_name
Expand Down
6 changes: 3 additions & 3 deletions lib/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@
reportsToContact.title as reportsToTitle,
company_department.name AS department,
DATE_FORMAT(
contact.date_created, '%%m-%%d-%%y (%%h:%%i %%p)'
contact.date_created, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 531 in lib/Contacts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Contacts.php#L531

Avoid using static access to class 'DateUtility' in method 'get'.
) AS dateCreated,
DATE_FORMAT(
contact.date_modified, '%%m-%%d-%%y (%%h:%%i %%p)'
contact.date_modified, '" . DateUtility::getMysqlDateTimeFormat() . "'

Check warning on line 534 in lib/Contacts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Contacts.php#L534

Avoid using static access to class 'DateUtility' in method 'get'.
) AS dateModified,
company.name AS companyName,
company.is_hot AS isHotCompany,
Expand Down Expand Up @@ -659,7 +659,7 @@
contact.date_created, '%%m-%%d-%%y'
) AS dateCreated,
DATE_FORMAT(
contact.date_modified, '%%m-%%d-%%y (%%h:%%i %%p)'
contact.date_modified, '" . DateUtility::getMysqlDateTimeFormat() . "'
) AS dateModified,
owner_user.first_name AS ownerFirstName,
owner_user.last_name AS ownerLastName,
Expand Down
Loading
Loading