Skip to content
Open
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($siteID);
Expand Down
11 changes: 11 additions & 0 deletions installwizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,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 @@ function Activity_editEntry(activityID, dataItemID, dataItemType, sessionCookie)
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)
{
var minuteSelectOption = document.createElement("option");
minuteSelectOption.value = i;
Expand All @@ -331,37 +346,45 @@ function Activity_editEntry(activityID, dataItemID, dataItemType, sessionCookie)
}
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 @@ function Activity_editEntry(activityID, dataItemID, dataItemType, sessionCookie)
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 @@ function AS_onEventAllDayChange(allDayRadioID)

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 @@ -64,12 +64,16 @@
{
private $_db;
private $_siteID;
private $_mysqlDateTimeFormat;


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

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

Check warning on line 76 in lib/ActivityEntries.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/ActivityEntries.php#L76

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


Expand Down Expand Up @@ -430,7 +434,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 @@ -478,7 +482,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 @@ -534,7 +538,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 @@ -526,7 +526,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 529 in lib/Attachments.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Attachments.php#L529

Avoid using static access to class 'DateUtility' in method 'getAll'.
FROM
attachment
WHERE
Expand Down Expand Up @@ -592,7 +592,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 @@ -111,7 +111,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 114 in lib/Calendar.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Calendar.php#L114

Avoid using static access to class 'DateUtility' in method 'getEventArray'.
) AS time,
DATE_FORMAT(
calendar_event.date, '%%H'
Expand All @@ -121,7 +121,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 124 in lib/Calendar.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Calendar.php#L124

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 @@ -626,7 +626,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 629 in lib/Calendar.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Calendar.php#L629

Avoid using static access to class 'DateUtility' in method 'getUpcomingEventsByDataItem'.
) AS dateShow,
DATE_FORMAT(
calendar_event.date, '%%d'
Expand Down Expand Up @@ -726,7 +726,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 @@ -776,7 +776,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 @@ -494,10 +494,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 497 in lib/Candidates.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Candidates.php#L497

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 500 in lib/Candidates.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Candidates.php#L500

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 @@ -341,7 +341,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 344 in lib/Companies.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Companies.php#L344

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 @@ -461,10 +461,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 464 in lib/Contacts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Contacts.php#L464

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 467 in lib/Contacts.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

lib/Contacts.php#L467

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 @@ -601,7 +601,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