wbTeamPro Feature Request & Bug Tracker - wbTeamPro
View Issue Details
0010328wbTeamPro[All Projects] Featurespublic2017-01-30 09:312015-01-25 00:00
tagteam 
webuddha 
normalminoralways
Feedbackopen 
 
 
0010328: Import time logs from excel
Is there a way to create an import process to import the time logs from an excel spreadsheet. If it isnt something you want to add to the code can you just help me develop it on the side.
I have an excel spreadsheet attached. I can write the query to import into the database but I am not sure what fields I will need to add. Fields like projectid, etc.
I can do most of the work if you can just help me get started in the right direction I will google for the rest.
Thanks
No tags attached.
xls Time report 2014-01-01 - 2014-01-30.xls (41,472) 2014-01-29 20:26
https://tracker.holodyn.com/file_download.php?file_id=23&type=bug
Issue History
2014-01-29 20:26tagteamNew Issue
2014-01-29 20:26tagteam
2014-01-29 20:26tagteamFile Added: Time report 2014-01-01 - 2014-01-30.xls
2014-02-05 14:20webuddhaNote Added: 0010088
2014-02-05 14:20webuddhaAssigned To => webuddha
2014-02-05 14:20webuddhaStatusNew => Feedback
2014-02-05 14:21webuddhaNote Edited: 0010088bug_revision_view_page.php?bugnote_id=10088#r32
2014-02-05 14:23webuddhaNote Edited: 0010088bug_revision_view_page.php?bugnote_id=10088#r33

Notes
(0010088)
webuddha   
2014-02-05 14:20   
(edited on: 2014-02-05 14:23)
The import would be fairly simply if you are comfortable with SQL. You probably would want to read the CSV into a php script to parse each line and perform the formatted insert.

Parse CSV Line in PHP
http://php.net/manual/en/function.fgetcsv.php [^]

You could use the wbDatabase class provided with wbTeamPro for your database inserts.
http://billing.holodyn.com/knowledgebase/87/91-wbDatabase-Class-Reference.html [^]

You can alternatively create a plugin or use the API for manipulating the database.
http://billing.holodyn.com/knowledgebase/84/92-Plugins-Reference.html [^]
http://billing.holodyn.com/knowledgebase/85/93-Remote-API-Methods.html [^]

The timelog_elapsed is in seconds, dates are in a standard SQL format, the action_id and ticket_id should be set to ZERO '0' if not available.

INSERT INTO `tbladdon_wbteampro_timelog` (`timelog_id`, `project_id`, `action_id`, `ticket_id`, `owner_adminid`, `owner_userid`, `date_created`, `date_modified`, `timelog_note`, `timelog_start`, `timelog_stop`, `timelog_status`, `timelog_elapsed`, `timelog_billable`, `invoice_id`) VALUES
(NULL, {project_id}, 0, 0, {adminid}, NULL, '2014-02-05 00:00:00', '2014-02-05 00:00:00', 'Test', '2014-02-05 00:00:00', '2014-02-05 00:01:00', 'complete', 60, 1, 0),

CREATE TABLE IF NOT EXISTS `tbladdon_wbteampro_timelog` (
  `timelog_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `project_id` bigint(20) unsigned NOT NULL,
  `action_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `ticket_id` int(10) unsigned NOT NULL DEFAULT '0',
  `owner_adminid` int(10) unsigned DEFAULT NULL,
  `owner_userid` int(10) unsigned DEFAULT NULL,
  `date_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `timelog_note` text NOT NULL,
  `timelog_start` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `timelog_stop` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `timelog_status` enum('active','complete') NOT NULL DEFAULT 'active',
  `timelog_elapsed` int(10) unsigned NOT NULL DEFAULT '0',
  `timelog_billable` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `invoice_id` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`timelog_id`),
  KEY `project_id` (`project_id`),
  KEY `action_id` (`action_id`),
  KEY `owner_adminid` (`owner_adminid`),
  KEY `timelog_status` (`timelog_status`),
  KEY `owner_userid` (`owner_userid`),
  KEY `ticket_id` (`ticket_id`)
);