Skip to content

Commit

Permalink
Merge pull request #39 from Multiconecta/commit_conflict_correction
Browse files Browse the repository at this point in the history
Solve errors because of conflicted merges PRs #36, #37 and #38
  • Loading branch information
xacobofg committed Mar 28, 2019
2 parents 71f0b05 + 8644bea commit dac47bf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
21 changes: 9 additions & 12 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ function showForm() {
echo "<tr class='tab_bg_1'>";
echo "<td>" . __("Display actual time in closed task box ('Processing ticket' list)", "actualtime") . "</td><td>";
Dropdown::showYesNo('showtimerinbox', $this->showTimerInBox(), -1);
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1' name='optional$rand'>";
echo "<td>" . __("Automatically open new created tasks", "actualtime") . "</td><td>";
Dropdown::showYesNo('autoopennew', $this->autoOpenNew(), -1);
Expand Down Expand Up @@ -183,8 +186,6 @@ static function install(Migration $migration) {
`displayinfofor` smallint NOT NULL DEFAULT 0,
`showtimerpopup` boolean NOT NULL DEFAULT true,
`showtimerinbox` boolean NOT NULL DEFAULT true,
`enable` boolean NOT NULL DEFAULT true,
`showtimerpopup` boolean NOT NULL DEFAULT true,
`autoopennew` boolean NOT NULL DEFAULT false,
`autoopenrunning` boolean NOT NULL DEFAULT false,
PRIMARY KEY (`id`)
Expand All @@ -206,12 +207,13 @@ static function install(Migration $migration) {
[
'update' => 0,
'value' => 0,
'after' => 'enable'
'after' => 'id'
]
);
}

if (! isset($fields['showtimerpopup'])) {
// Add new field showtimerpopup
$migration->addField(
$table,
'showtimerpopup',
Expand All @@ -225,6 +227,7 @@ static function install(Migration $migration) {
}

if (! isset($fields['showtimerinbox'])) {
// Add new field showtimerinbox
$migration->addField(
$table,
'showtimerinbox',
Expand All @@ -236,6 +239,7 @@ static function install(Migration $migration) {
]
);
}

if (! $DB->fieldExists($table, 'autoopennew')) {
// Add new field autoopennew
$migration->addField(
Expand All @@ -249,6 +253,7 @@ static function install(Migration $migration) {
]
);
}

if (! $DB->fieldExists($table, 'autoopenrunning')) {
// Add new field autoopenrunning
$migration->addField(
Expand All @@ -262,15 +267,7 @@ static function install(Migration $migration) {
]
);
}
// Create default record (if it does not exist)
$reg = $DB->request($table);
if (! count($reg)) {
$DB->insert(
$table, [
'enable' => true
]
);
}

// Old not used field in version 1.1.1
if (isset($fields['enable'])) {
$migration->dropField(
Expand Down
23 changes: 11 additions & 12 deletions inc/task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static public function postForm($params) {
JAVASCRIPT;

// Only task user
$timercolor = 'black';
if ($buttons) {

$value1 = __('Start');
Expand All @@ -48,7 +49,6 @@ static public function postForm($params) {
$action2 = '';
$color2 = 'gray';
$disabled2 = 'disabled';
$timercolor = 'black';

if ($item->getField('state')==1) {

Expand Down Expand Up @@ -526,25 +526,29 @@ static function postShowItem($params) {
switch ($item->getType()) {
case 'TicketTask':

$config = new PluginActualtimeConfig;
$task_id = $item->getID();
$rand = mt_rand();
// Auto open needs to use correct item randomic number
$rand = $params['options']['rand'];

$config = new PluginActualtimeConfig;
// Show timer in closed task box in:
// Standard interface (always)
// or Helpdesk inteface (only if config allows)
if ((Session::getCurrentInterface() == "central")
|| $config->showInHelpdesk()) {
if ($config->showTimerInBox() &&
((Session::getCurrentInterface() == "central")
|| $config->showInHelpdesk())
) {

$time = self::totalEndTime($task_id);
$fa_icon = ($time > 0 ? ' fa-clock-o' : '');
$timercolor = (self::checkTimerActive($task_id) ? 'red' : 'black');
// Anchor to find correct span, even when user has no update
// right on status checkbox
echo "<div id='actualtime_anchor_$rand'></div>";
echo "<div id='actualtime_anchor_{$task_id}_{$rand}'></div>";
$script = <<<JAVASCRIPT
$(document).ready(function() {
if ($("[id^='actualtime_faclock_{$task_id}_']").length == 0) {
$("#actualtime_anchor_{$rand}").prev().find("span.state")
$("#actualtime_anchor_{$task_id}_{$rand}").prev().find("span.state")
.after("<i id='actualtime_faclock_{$task_id}_{$rand}' class='fa{$fa_icon}' style='color:{$timercolor}; padding:3px; vertical-align:middle;'></i><span id='actualtime_timer_{$task_id}_box_{$rand}' style='color:{$timercolor}; vertical-align:middle;'></span>");
if ($time > 0) {
actualtime_fillCurrentTime($task_id, $time);
Expand All @@ -554,11 +558,6 @@ static function postShowItem($params) {
JAVASCRIPT;
echo Html::scriptBlock($script);
}
break;
$config = new PluginActualtimeConfig;
$task_id = $item->getID();
// Auto open needs to use correct item randomic number
$rand = $params['options']['rand'];

// Verify if this is a new task just created now
$autoopennew = false;
Expand Down
6 changes: 0 additions & 6 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ function plugin_init_actualtime() {
$PLUGIN_HOOKS['post_show_tab']['actualtime'] = ['PluginActualtimeTask', 'postShowTab'];
}


if ($config->showTimerInBox()) {
// This hook is not needed if not showing closed task box timer
$PLUGIN_HOOKS['post_show_item']['actualtime'] = ['PluginActualtimeTask', 'postShowItem'];
}

if ($config->autoOpenNew()) {
// This hook is not needed if not opening new tasks automatically
$PLUGIN_HOOKS['item_add']['actualtime'] = ['TicketTask'=>'plugin_actualtime_item_add'];
Expand Down

0 comments on commit dac47bf

Please sign in to comment.