Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15453521
D9147.id21716.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9147.id21716.diff
View Options
diff --git a/src/applications/phrequent/controller/PhrequentTrackController.php b/src/applications/phrequent/controller/PhrequentTrackController.php
--- a/src/applications/phrequent/controller/PhrequentTrackController.php
+++ b/src/applications/phrequent/controller/PhrequentTrackController.php
@@ -15,18 +15,83 @@
$request = $this->getRequest();
$user = $request->getUser();
+ $phid = $this->phid;
+ $handle = id(new PhabricatorHandleQuery())
+ ->setViewer($user)
+ ->withPHIDs(array($phid))
+ ->executeOne();
+
if (!$this->isStartingTracking() &&
!$this->isStoppingTracking()) {
throw new Exception('Unrecognized verb: ' . $this->verb);
}
- if ($this->isStartingTracking()) {
- $this->startTracking($user, $this->phid);
- } else if ($this->isStoppingTracking()) {
- $this->stopTracking($user, $this->phid);
+ $verb_formatted = ucwords($this->verb);
+
+ $epoch_control = id(new AphrontFormDateControl())
+ ->setUser($user)
+ ->setName('epoch')
+ ->setLabel(pht('%s Time', $verb_formatted))
+ ->setValue(time());
+
+
+ $err = null;
+
+ if ($request->isDialogFormPost()) {
+ $timestamp = $epoch_control->readValueFromRequest($request);
+ $note = $request->getStr('note');
+
+ if ($timestamp < time()) {
+
+ if ($this->isStartingTracking()) {
+ $this->startTracking($user, $this->phid, $timestamp);
+ } else if ($this->isStoppingTracking()) {
+ $this->stopTracking($user, $this->phid, $timestamp, $note);
+ }
+ return id(new AphrontRedirectResponse());
+
+ } else {
+ $err = 'Future Date';
+ }
+ }
+
+ $dialog = new AphrontDialogView();
+ $dialog->setUser($user);
+
+ $dialog->settitle(pht('%s Tracking Time', $verb_formatted));
+
+ $form = new PHUIFormLayoutView();
+ $form
+ ->appendChild(hsprintf(
+ "<p>%s</p><br />",
+ pht('What time did you %s working?', $this->verb)));
+
+ if ($err === 'Future Date') {
+ $form
+ ->appendChild(hsprintf(
+ "<p style='color:red'>%s</p><br />",
+ pht('Error: The date you have entered has not occured yet, '.
+ 'please enter a valid date.')));
+ }
+
+ $form->appendChild($epoch_control);
+
+ if ($this->isStoppingTracking()) {
+ $form
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setLabel(pht('Note'))
+ ->setName('note'));
}
- return id(new AphrontRedirectResponse());
+ $dialog->appendChild($form);
+
+ $dialog->addCancelButton($handle->getURI());
+ $dialog->addSubmitButton(pht('%s Time', $verb_formatted));
+
+ return id(new AphrontDialogResponse())->setDialog($dialog);
+
+
}
private function isStartingTracking() {
@@ -37,15 +102,15 @@
return $this->verb === 'stop';
}
- private function startTracking($user, $phid) {
+ private function startTracking($user, $phid, $timestamp) {
$usertime = new PhrequentUserTime();
- $usertime->setDateStarted(time());
+ $usertime->setDateStarted($timestamp);
$usertime->setUserPHID($user->getPHID());
$usertime->setObjectPHID($phid);
$usertime->save();
}
- private function stopTracking($user, $phid) {
+ private function stopTracking($user, $phid, $timestamp, $note) {
if (!PhrequentUserTimeQuery::isUserTrackingObject($user, $phid)) {
// Don't do anything, it's not being tracked.
return;
@@ -57,13 +122,16 @@
queryfx(
$conn,
'UPDATE %T usertime '.
- 'SET usertime.dateEnded = UNIX_TIMESTAMP() '.
+ 'SET usertime.dateEnded = %s, '.
+ 'usertime.note = %s '.
'WHERE usertime.userPHID = %s '.
'AND usertime.objectPHID = %s '.
'AND usertime.dateEnded IS NULL '.
'ORDER BY usertime.dateStarted, usertime.id DESC '.
'LIMIT 1',
$usertime_dao->getTableName(),
+ $timestamp,
+ $note,
$user->getPHID(),
$phid);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 30, 12:25 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7669223
Default Alt Text
D9147.id21716.diff (3 KB)
Attached To
Mode
D9147: Added a popup to both start and end times with Phrequent allowing the user to edit their start/end times. Also added a field for notes on the stop time
Attached
Detach File
Event Timeline
Log In to Comment