New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature / Time Tracking v1-10-x #3231

Open
wants to merge 157 commits into
base: develop-next
from

Conversation

Projects
None yet
@robintoy
Copy link

robintoy commented Jun 23, 2016

Introduction

Time Feature to allow users to record the amount of time taken for each thread posted which can then be pulled together in a report so you know the actual time spent on a ticket.

Time can also be marked as billable along with assigning different classes / types of time like on-site or remote.

All the code to make this is done, unfortunately I do not know how to update the stream or database via your system yet. I have listed all required SQL below along with what files I have modified

Files modified

include/class.config.php
include/class.nav.php
include/class.thread.php
include/class.ticket.php
include/client/view.inc.php
include/i18n/en_US/help/tips/settings.tickettime.yaml
include/i18n/en_US/list.yaml
include/staff/org-view.inc.php
include/staff/settings-tickettime.inc.php
include/staff/templates/thread-entry.tmpl.php
include/staff/templates/ticket-print.tmpl.php
include/staff/ticket-view.inc.php
scp/org_bill.php
scp/settings.php
scp/tickets_bill.php
scp/tickets_cost.php

Database Modifications

Run the following commands in something like PHPMyAdmin or MySQL CLI

INSERT INTO  ost_list  ( name ,  name_plural ,  sort_mode ,  masks ,  type ,  notes ,  created ,  updated ) VALUES ('Time Type', 'Time Types', 'SortCol', '13', 'time-type', 'Time Spent plugin list, do not modify', NOW(), NOW());
INSERT INTO `ost_list_items` (`list_id`, `status`, `value`, `sort`)
SELECT ost_list.id, 1, 'Telephone', 1
FROM ost_list
WHERE `name`='Time Type';

INSERT INTO `ost_list_items` (`list_id`, `status`, `value`, `sort`)
SELECT ost_list.id, 1, 'Email', 2
FROM ost_list
WHERE `name`='Time Type';

INSERT INTO `ost_list_items` (`list_id`, `status`, `value`, `sort`)
SELECT ost_list.id, 1, 'Remote', 3
FROM ost_list
WHERE `name`='Time Type';

INSERT INTO `ost_list_items` (`list_id`, `status`, `value`, `sort`)
SELECT ost_list.id, 1, 'Workshop', 4
FROM ost_list
WHERE `name`='Time Type';

INSERT INTO `ost_list_items` (`list_id`, `status`, `value`, `sort`)
SELECT ost_list.id, 1, 'Onsite', 5
FROM ost_list
WHERE `name`='Time Type';
INSERT INTO  ost_config  (`namespace`, `key`, `value`, `updated`) VALUES
 ('core', 'isclienttime', 0, now()),
 ('core', 'isthreadtime', 0, now()),
 ('core', 'isthreadtimer', 0, now()),
 ('core', 'isthreadbill', 0, now()),
 ('core', 'isthreadbilldefault', 0, now()),
 ('core', 'istickethardware', 0, now());
ALTER TABLE  ost_thread_entry  ADD COLUMN  time_spent  INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER  type;

ALTER TABLE  ost_thread_entry  ADD COLUMN  time_type  INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER  time_spent;

ALTER TABLE  ost_thread_entry  ADD COLUMN  time_bill  INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER  time_type;

This is a mod that has been worked on for a long time through the v1-8-x up until now.

Been speaking with @greezybacon on this for a while to make sure it is ready for a pull.

Previous versions and conversations can be found: -
#1419
AND
StrobeTechnologiesLtd#5

robintoy added some commits Jun 23, 2016

Added V1-10-X time Tracking
Updated V1-10-rc2 to V1-10-rc3 and ready to pull
@robintoy

This comment has been minimized.

Copy link

robintoy commented Jun 24, 2016

@greezybacon now I have this done and submitted which part do you think would be best to look at next??

  • Expense Adding to a ticket
    OR
  • Enhancing the time to be able to mark tickets / threads as invoiced

As previously discussed the aim is to achieve the following: -

  • Time recording against each ticket (via threads)
  • 1/2 done - reports exist -- Be able to run reports and see what is needed to invoice based on billable thread actions and record once this has been billed to remove it from future reports.
  • Add Contract times based on the current time types to each organization
  • Improve the current billing reports to reduce the contractual times over the period and mark time over as billable in reports.
  • Add the ability to log expenses like hardware, materials etc used against a ticket in the same way tasks are.

robintoy added some commits Jun 24, 2016

Initial settings
Added new DB field with the following code: -
```SQL
ALTER TABLE  ost_thread_entry  ADD COLUMN  time_invoice  INT( 11 )
UNSIGNED NOT NULL DEFAULT '0' AFTER  time_bill;
```

and modified the tickets cost report to view the results.
@robintoy

This comment has been minimized.

Copy link

robintoy commented Jun 24, 2016

Hi @greezybacon just taken the jump to start invoicing for threads which is going well, but one report or function is got me a little stumped :(

I'm trying to add a ticket box to tickets_bill.php so you can say if this thread has been invoiced or not.
billingreport

billinginvoice

The code I have to display the checkboxes work but trying to allow on and off like in the settings menu is proving difficult... any pointers?

<td><input type="checkbox" name="invoiced[]" value="<?php echo $entry->id; ?>" <?php echo $entry->time_invoice?'checked="checked"':''; ?>></td>
@greezybacon

This comment has been minimized.

Copy link
Member

greezybacon commented Jun 24, 2016

Are you setting $entry->time_invoice when you process and save from the POST?

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jun 25, 2016

Hi @greezybacon
the $entry->time_invoice pulls the set values from the DB and switches it checked or not.

At the moment the information from the checkboxes are posted to an array called invoiced , but the main thing I cannot get my head around is that if you untick and submit then the information is not posted for us to cycle through and save the updated changed to the DB.

robintoy and others added some commits Jun 29, 2016

Bill / Invoiced Update Planned
I have worked out the issue with posting and collecting the information
for ticked and un-ticked check boxes.

What needs doing now is the actual code to save this information back to
the DB within the ISSET IF on about line 6
Updated ticket.autoreply.yaml
Updated to fix typo "information" on line 36
@d--j

This comment has been minimized.

Copy link
Contributor

d--j commented Jul 5, 2016

Hi @robintoy

I saw this and your question by accident – sorry to barge in like this.
You normally do this by adding a hidden input with the same name as the checkbox. If the checkbox is checked its value will be used. If it is not checked the value of the hidden field will be used. (That's the case because they both have the same name attribute, the checkbox overwrites the value of the hidden field in this case – so ordering of the hidden field and the checkbox does matter)

E.g.:

<td>
<input type="hidden"name="invoiced[<?php echo $entry->id; ?>]" value="0">
<input type="checkbox" name="invoiced[<?php echo $entry->id; ?>]" value="1" <?php echo $entry->time_invoice?'checked="checked"':''; ?>>
</td>

With that you will always have a complete $invoiced array that you can iterate over like this

foreach ($invoiced as $entry_id => $entry_was_invoiced) {
  if ($entry_was_invoiced) {
    // do something
  } else {
    // do something different
  }
}
Merge pull request #3251 from pengc99/patch-1
Updated ticket.autoreply.yaml
@egftechman

This comment has been minimized.

Copy link

egftechman commented Jul 11, 2016

I read this as the time tracking is being integrated into main osTicket branch? Won't have to apply patches anymore during upgrades?

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jul 11, 2016

That is the plan, but osTicket team gone quiet

@rbukovansky

This comment has been minimized.

Copy link
Contributor

rbukovansky commented Jul 12, 2016

@robintoy No worries, they will come back... But it seems to me, that @greezybacon is "the team" now and he is "over the head" in his normal work...

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jul 12, 2016

Hi @rbukovansky
It does seem that why but I have seen some actions and updates from @protich recently so hoping he likes the update as much as @greezybacon

It's all finished and working, just needs the big thumbs up!

And as you can see I'm working on advancing the other features and new parts for future releases already meaning it will do the same at the v1.9.14 version and a lot more.

@GMo888

This comment has been minimized.

Copy link

GMo888 commented Jul 22, 2016

Hello,
I have replace the 16 files, make the SQL modifications, but I have this error at the validation of a new ticket :
PHP Fatal error: Uncaught exception 'OrmException' with message 'ThreadEntry: time_spent: Field not defined' in public_html/test1/upload/include/class.orm.php:382\nStack trace:\n#0 public_html/test1/upload/include/class.orm.php(690): VerySimpleModel->get('time_spent', NULL)\n#1 public_html/test1/upload/include/class.orm.php(685): AnnotatedModel->get('time_spent')\n#2 public_html/test1/upload/include/staff/templates/thread-entry.tmpl.php(76): AnnotatedModel->__get('time_spent')\n#3 public_html/test1/upload/include/staff/templates/thread-entries.tmpl.php(52): include('/home/xxx/do...')\n#4 public_html/test1/upload/include/class.thread.php(256): include('/home/xxx/do...')\n#5 public_html/test1/upload/include/staff/ticket-view.inc.php( in public_html/test1/upload/include/class.orm.php on line 382, referer: xxx/test1/upload/scp/index.php

@kest874

This comment has been minimized.

Copy link
Contributor

kest874 commented Jul 22, 2016

@GMo888 Restart Apache and this issue should go away, the fields are cached, the restart rebuilds the cache.

@tonytuannguyen

This comment has been minimized.

Copy link

tonytuannguyen commented Aug 19, 2016

Is there a way to edit the time after it was submitted?

@Crammy

This comment has been minimized.

Copy link

Crammy commented Sep 14, 2016

Hi @robintoy,

Hmmm... I'm trying to update a live site with v1.9.7 to this pull. To ensure I have a working lab to test before I upgrade, I thought I would download via https://minhaskamal.github.io/DownGit/ but that didn't download your updated files. Not being a true github user, i'm a little stuck on seeing the new combined version you're working on. Any chance of some simple instructions on how to download / upgrade to this version?? Many thanks.

@robintoy

This comment has been minimized.

Copy link

robintoy commented Sep 15, 2016

Hi @Crammy

I have never used DownGit before and have no idea how it works.

If you click on the files changed part of this thread and download the files and install as listed above all should be ok.

If you have any issues please let me know.

@Crammy

This comment has been minimized.

Copy link

Crammy commented Sep 16, 2016

Hi @robintoy,

The upgrade process needs to include your SQL modifications from moving from 1.9 to 1.10. There is some major table name changes in the upgrade. It's interesting looking at the conversion of ticket_thread table to thread_entry which looses the time spent from a each helpdesk call. This prevents an in-place upgrade process.

I've had a look at the SQL calls for table modify/create and see one file '/include/upgrader/streams/core/36f6b328-5cd0a25a.patch.sql' for patching and the other 'setup/inc/streams/core/install-mysql.sql' for a fresh install.

The patch script (called from upgrade.php) creates a new table called thread_entry and then copies all the rows from ticker_thread and looses the time spent info.

Is this something you are already working on for an upgrade process?

@robintoy

This comment has been minimized.

Copy link

robintoy commented Sep 16, 2016

Hi @Crammy

so far this is something we have not looked at as it currently is just a mod waiting to be approved and added to the core as it really have picked up so much interest.

If you any information on the upgrade or would like to help we would be happy to include the code.

(Always take a full backup first) Other than this, at the moment I'd say duplicate your table, run the upgrade and then run a sql query to copy data from duplicated table to new table.

@robintoy

This comment has been minimized.

Copy link

robintoy commented Sep 16, 2016

Hi @greezybacon @protich

Am I correct in seeing that v1.10rc3 has been moved from develop-next to develop??

@Crammy

This comment has been minimized.

Copy link

Crammy commented Sep 21, 2016

@robintoy

Hi, I've fixed the upgrade script ''/include/upgrader/streams/core/36f6b328-5cd0a25a.patch.sql' to correctly migrate the data from the old table to the new keeping time spent. It also builds the options into the DB for the Time Mgmt settings side which are new in your updated code for 1.10. i.e. IsBillable.

The fresh install is another story. The core.sig is checked for a Hash which in code test code don't match 'setup/inc/streams/core/install-mysql.sql', so I have the updated 'install-mysql.sql' but its blocked on the core.sig check currently.

To move forward, how do you want me to update the file 36f...patch.sql? Can I do an offical update via github full client? Or do you want me to IM you the file? Can I ask @greezybacon @protich how I can include my modified 'install-mysql.sql' with a valid core.sig file? Is there any doc I can follow to build the right core.sig or pass over details to fall inline with the dev branch?

@robintoy

This comment has been minimized.

Copy link

robintoy commented Sep 21, 2016

Hi @Crammy

that is fab news!!!
If you branch from my GitHub Repo, make changes and publish I'll approve the changes which will hopefully get back into the core soon.

@pordeciralgo

This comment has been minimized.

Copy link

pordeciralgo commented Nov 21, 2016

Hi @robintoy

I'm sorry for this dumb question, buy I'm new to Github and osTicket. Where do I get the 16 modified files? Do I simply overwrite the ones from standard 1.10 osTicket install?

Thank you in advance

protich and others added some commits Aug 3, 2018

Merge pull request #4398 from JediKev/issue/select2-placeholder-bug-d…
…evelop

issue: Select2 Placeholder Bug
issue: Deleted Field Thread Events (template)
This addresses an issue introduced with `9ab2317` where the icon for the
event still shows even though we continued and didn’t return the event
description.
canned: Canned Response Select2 Height
This adds an enhancement to the Canned Response Select2 showing more options
within the list. The length is automatic and is based on how many Canned
Responses you have Enabled.

Limits:
- Height maxes out at 400px so it doesn’t run off the screen
Merge pull request #4397 from JediKev/issue/canned-resp-select2-height
canned: Canned Response Select2 Height
Merge pull request #4413 from JediKev/issue/deleted-thread-events
issue: Deleted Field Thread Events (template)
@ITRevolutionSupport

This comment has been minimized.

Copy link

ITRevolutionSupport commented Aug 8, 2018

Hello

Worked Osticket 1.10.4?

@robintoy

This comment has been minimized.

Copy link

robintoy commented Aug 8, 2018

Hi All,

extremely sorry for not getting back to you all on this but I have been working on other projects which including adding this mod to a dedicated hosted version.

I have just updated the code to v1.10.4 which I'm publishing now as it seems to be working.

On the regards to reports and other bits, this has not moved on at all as we have been contracted to work on the other platform. I see what we have though had this picked up by the osTicket team for integration into v1.11.x which is great news!

If a list can be put together of what is missing / needed I'll see what I can do; but no promises as time and money has meant tie is assigned else where.

Robin

@robintoy

This comment has been minimized.

Copy link

robintoy commented Aug 8, 2018

Our website now has the updated download listed here https://www.strobe-it.co.uk/payg/opensource/

@robintoy

This comment has been minimized.

Copy link

robintoy commented Aug 8, 2018

Just as a warning to all trying to upgrade, DO NOT re-run the SQL if you have done this once before else you will have to edit your tables to correct the data.

@azon2111

This comment has been minimized.

Copy link

azon2111 commented Aug 14, 2018

@robintoy The warning about upgrade. Is this assuming if you have installed any version of time tracking 1.10.x ? or just the previous release?

Thank you.

@aquilaxx

This comment has been minimized.

Copy link

aquilaxx commented Aug 22, 2018

@denverwinks

This comment has been minimized.

Copy link

denverwinks commented Aug 25, 2018

Hi @Crammy and @robintoy,

Where can I find the updated upgrade script that will move my existing time from 1.9.x to 1.10.4?

I have successfully upgraded my dev platform to 1.10.4, but haven't been successful in getting my existing time moved over.

I have had the same results using files from git, from osticket and from strobe-it.

Is this a query I can manually run after successful upgrade?

I appreciate any suggestions you may have.

Bill

@aquilaxx

This comment has been minimized.

Copy link

aquilaxx commented Sep 7, 2018

do anybody know if it works with the new release candidate?

@azon2111

This comment has been minimized.

Copy link

azon2111 commented Sep 14, 2018

do anybody know if it works with the new release candidate?

I understand that this is going to be integrated into 1.11 as core so not sure if you need plugin in the latest RC.

We are finishing up quite a few mods to this plugin now that are similar to what Robintoy is probably referring to in terms of contracted for other project similar to this.

We introduced Paid and more extensive billing including expenses, dynamic field for sum of other fields, reporting and a few other items. We also introduced a new tab inside ticket for time tracking, manual and editing entries and tied to SLA plan and auto expenses creation when opening a ticket or adding a report/form/etc. I am hoping to share a demo with the community in the next 30 days or so that I am hoping I can get help creating a fork and send merge requests. Happy to share the code with the community in hopes it can become core some day and make it easier on my team for updates.

@meinsteren

This comment has been minimized.

Copy link

meinsteren commented Nov 22, 2018

Hi everyone,
I have a problem saving changes to tickets_bill.php

Fatal error: Call to a member function getNumber() on null in C:\xampp\htdocs\ost_ticket\scp\tickets_bill.php on line 48

Serverinformationen

osTicket-Version v1.10.4 (035fd0a) —  Aktuell
Server-Software Apache/2.4.33 (Win32) OpenSSL/1.0.2n PHP/5.6.35
MySQL-Version 10.1.31
PHP-Version 5.6.35

@dku4lman

This comment has been minimized.

Copy link

dku4lman commented Jan 4, 2019

Hi everyone,,
I installed your mod in my osticket 1.10.1-0121 on a synology NAS, everything works fine so far.
Thanks for adding this great feature to osticket!
One thing where I have a problem ist printing a billing report from the ticket menu. Doesn't matter how much entries the ticket has, it only appears one row with informations on the billing report.
image

Maybe someone had the same problem and is able to help.
Thanks a lot and BR

Dirk

@GaGabi

This comment has been minimized.

Copy link

GaGabi commented Jan 11, 2019

Hi @dku4lman,

I had the same problem.
My resolution was:

Run the following command in something like PHPMyAdmin or MySQL CLI:

ALTER TABLE ost_thread_entry ADD COLUMN time_invoice INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER time_type

Gabor

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jan 11, 2019

Hi @azon21111

The warning is about people already having the mod installed and then upgrading.

There is not need to run it again.

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jan 11, 2019

This mod has not been tested with 10.11 rc1.

Being honest the next update will be on the next proper version not a RC.

If you want to mod the RC to include this I did try and mark all the additions in the code to make it easier to migrate etc.

Should be a simple copy and paste into same/similar place on RC code

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jan 11, 2019

People are more than welcome to fork and send updates back.

That is how opensource works!

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jan 11, 2019

Hi @GaGabi

Did I miss that command from the setup instructions?

@GaGabi

This comment has been minimized.

Copy link

GaGabi commented Jan 12, 2019

Hi @robintoy

Maybe it is missing. But I am new at github, I made things by hand on our osticket system, so I am not shure that all the modifications are made in my system that are in this mod, so maybe it is in some where. I am lazy, and hurry and not read all the posts here (sorry). I just made a try if it is helps for me or not. I am not sure that this is the proper way or not I did not tested it yet. I have a problem: when I hit the save on bill I have the following error message:

Fatal error: Call to a member function getNumber() on null in /var/www/html/scp/tickets_bill.php on line 48

So I am sure I did it in a wrong way, I will install it via git on a test vm and will try it again.

@robintoy

This comment has been minimized.

Copy link

robintoy commented Jan 12, 2019

Hi All,

I have just logged into our test system for this (sorry for delay but this SI no longer used in house), and I have the same error.

If I remember correctly that was a new part I was working on which might not have been finished or the code to save via SQL changed from v9 to V10 and I missed updating that page.

If I get t some time I'll see if I can fix.

@dku4lman

This comment has been minimized.

Copy link

dku4lman commented Jan 14, 2019

Hi @dku4lman,

I had the same problem.
My resolution was:

Run the following command in something like PHPMyAdmin or MySQL CLI:

ALTER TABLE ost_thread_entry ADD COLUMN time_invoice INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER time_type

Gabor

Hi @GaGabi,
this worked fine for me. Thanks a lot for this solution!

Dirk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment