Skip to content

Commit

Permalink
Fixed date time entry for Action Forms.
Browse files Browse the repository at this point in the history
Updates #248
  • Loading branch information
inghamn committed Sep 15, 2016
1 parent 9f4c650 commit 5b6908f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crm/Controllers/TicketsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ public function recordAction()

if (isset($_POST['ticket_id'])) {
try {
$_POST['actionDate'] = \DateTime::createFromFormat(
DATE_FORMAT.' '.TIME_FORMAT,
$_POST['actionDate']['date'].' '.$_POST['actionDate']['time']
);
if (!$_POST['actionDate']) { throw new \Exception('invalidDate'); }

$history->handleUpdate($_POST);
$history->save();
$this->redirectToTicketView($ticket);
Expand Down
2 changes: 1 addition & 1 deletion crm/Models/TicketHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function setTicket(Ticket $o) { parent::setForeignKeyObject(__namespace_
public function handleUpdate($post)
{
$this->setAction_id ($post['action_id'] );
$this->setActionDate($post['actionDate']);
$this->setActionDate($post['actionDate']->format(ActiveRecord::MYSQL_DATETIME_FORMAT));
$this->setNotes ($post['notes'] );
$this->setEnteredByPerson($_SESSION['USER']);
$this->setActionPerson ($_SESSION['USER']);
Expand Down
12 changes: 10 additions & 2 deletions crm/blocks/html/tickets/actionForm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@
<?php
$helper = $this->template->getHelper('field');
echo $helper->field([
'name' => 'actionDate',
'id' => 'actionDate',
'name' => 'actionDate[date]',
'id' => 'actionDate_date',
'label' => $this->_('date'),
'type' => 'date',
'value' => $this->ticketHistory->getActionDate(DATE_FORMAT)
]);
echo $helper->field([
'name' => 'actionDate[time]',
'id' => 'actionDate_time',
'label' =>$this->_('time'),
'type' =>'time',
'value' =>$this->ticketHistory->getActionDate(TIME_FORMAT)
]);

echo $helper->field([
'name' => 'notes',
'id' => 'notes',
Expand Down
3 changes: 3 additions & 0 deletions crm/language/en_CA/LC_MESSAGES/labels.po
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ msgstr "Fields to display"
msgid "date"
msgstr "Date"

msgid "time"
msgstr "Time"

msgid "day"
msgid_plural "days"
msgstr[0] "Day"
Expand Down
3 changes: 3 additions & 0 deletions crm/language/en_US/LC_MESSAGES/labels.po
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ msgstr "Fields to display"
msgid "date"
msgstr "Date"

msgid "time"
msgstr "Time"

msgid "day"
msgid_plural "days"
msgstr[0] "Day"
Expand Down
3 changes: 3 additions & 0 deletions crm/language/fr_CA/LC_MESSAGES/labels.po
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ msgstr "Champs à afficher"
msgid "date"
msgstr "Date"

msgid "time"
msgstr "Temps"

msgid "day"
msgid_plural "days"
msgstr[0] "Jour"
Expand Down
3 changes: 3 additions & 0 deletions crm/language/nl_NL/LC_MESSAGES/labels.po
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ msgstr "Zichtbare velden"
msgid "date"
msgstr "Datum"

msgid "time"
msgstr "Tijd"

msgid "day"
msgid_plural "days"
msgstr[0] "Dag"
Expand Down
4 changes: 4 additions & 0 deletions crm/templates/html/helpers/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function field(array $params)
$params['attr']['placeholder'] = View::translateDateString(DATE_FORMAT);
$renderInput = 'input';
break;
case 'time':
$params['attr']['placeholder'] = View::translateDateString(TIME_FORMAT);
$renderInput = 'input';
break;

case 'select':
case 'textarea':
Expand Down

0 comments on commit 5b6908f

Please sign in to comment.