Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
429
modules/storm/stormtimetracking/stormtimetracking.admin.inc
Normal file
429
modules/storm/stormtimetracking/stormtimetracking.admin.inc
Normal file
|
@ -0,0 +1,429 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormtimetracking_list() {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('SuiteDesk'), 'dashboard');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (array_key_exists('organization_nid', $_GET)) {
|
||||
if ($_SESSION['stormtimetracking_list_filter']['organization_nid'] != $_GET['organization_nid']) {
|
||||
$_SESSION['stormtimetracking_list_filter']['organization_nid'] = $_GET['organization_nid'];
|
||||
}
|
||||
unset($_SESSION['stormtimetracking_list_filter']['project_nid']);
|
||||
unset($_SESSION['stormtimetracking_list_filter']['task_nid']);
|
||||
unset($_SESSION['stormtimetracking_list_filter']['ticket_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('project_nid', $_GET)) {
|
||||
if ($_SESSION['stormtimetracking_list_filter']['project_nid'] != $_GET['project_nid']) {
|
||||
$_SESSION['stormtimetracking_list_filter']['project_nid'] = $_GET['project_nid'];
|
||||
}
|
||||
$p = node_load($_GET['project_nid']);
|
||||
$_SESSION['stormtimetracking_list_filter']['organization_nid'] = $p->organization_nid;
|
||||
|
||||
unset($_SESSION['stormtimetracking_list_filter']['task_nid']);
|
||||
unset($_SESSION['stormtimetracking_list_filter']['ticket_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('task_nid', $_GET)) {
|
||||
if ($_SESSION['stormtimetracking_list_filter']['task_nid'] != $_GET['task_nid']) {
|
||||
$_SESSION['stormtimetracking_list_filter']['task_nid'] = $_GET['task_nid'];
|
||||
}
|
||||
|
||||
$t = node_load($_GET['task_nid']);
|
||||
$_SESSION['stormtimetracking_list_filter']['organization_nid'] = $t->organization_nid;
|
||||
$_SESSION['stormtimetracking_list_filter']['project_nid'] = $t->project_nid;
|
||||
unset($_SESSION['stormtimetracking_list_filter']['ticket_nid']);
|
||||
}
|
||||
|
||||
if (array_key_exists('ticket_nid', $_GET)) {
|
||||
if ($_SESSION['stormtimetracking_list_filter']['ticket_nid'] != $_GET['ticket_nid']) {
|
||||
$_SESSION['stormtimetracking_list_filter']['ticket_nid'] = $_GET['ticket_nid'];
|
||||
}
|
||||
|
||||
$ti = node_load($_GET['ticket_nid']);
|
||||
$_SESSION['stormtimetracking_list_filter']['organization_nid'] = $ti->organization_nid;
|
||||
$_SESSION['stormtimetracking_list_filter']['project_nid'] = $ti->project_nid;
|
||||
$_SESSION['stormtimetracking_list_filter']['task_nid'] = $ti->task_nid;
|
||||
}
|
||||
|
||||
$i = new stdClass();
|
||||
$i->type = 'stormtimetracking';
|
||||
|
||||
$report_attrs = array(
|
||||
'onclick' => "storm_popup(this, 'timetracking_list_form_report', 'Timetrackings', 300, 150, 'stormtimetracking_list_form_report', 'l'); return false;",
|
||||
);
|
||||
|
||||
$header = array(
|
||||
array(
|
||||
'data' => t('Title') . ' / ' . t('Organization') . ' » ' . t('Project') . ' » ' . t('Detail'),
|
||||
'field' => 'n.title',
|
||||
),
|
||||
array(
|
||||
'data' => t('Date'),
|
||||
'field' => 'stt.trackingdate',
|
||||
'sort' => 'desc',
|
||||
),
|
||||
array(
|
||||
'data' => t('Duration'),
|
||||
'style' => 'text-align: right;'
|
||||
),
|
||||
array(
|
||||
'data' => storm_icon_l('report', '', t('Reports'), '', array(), $report_attrs) .' '. storm_icon_add_node($i, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
|
||||
$s = "SELECT n.*, stt.*, nre.format FROM {node} n
|
||||
INNER JOIN {stormtimetracking} stt ON n.vid=stt.vid
|
||||
INNER JOIN {node_revisions} AS nre ON n.vid = nre.vid
|
||||
WHERE n.status=1 AND n.type='stormtimetracking' ";
|
||||
|
||||
$s_duration = "SELECT SUM(billing_duration) FROM {stormtimetracking} stt INNER JOIN {node} n ON n.vid=stt.vid WHERE n.status=1 AND n.type='stormtimetracking' ";
|
||||
|
||||
$where = array();
|
||||
$args = array();
|
||||
$filterfields = array();
|
||||
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['organization_nid']) && $_SESSION['stormtimetracking_list_filter']['organization_nid'] != 0) {
|
||||
$where[] = 'stt.organization_nid=%d';
|
||||
$args[] = $_SESSION['stormtimetracking_list_filter']['organization_nid'];
|
||||
$filterfields[] = t('Organization');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['project_nid']) && $_SESSION['stormtimetracking_list_filter']['project_nid'] != 0) {
|
||||
$where[] = 'stt.project_nid=%d';
|
||||
$args[] = $_SESSION['stormtimetracking_list_filter']['project_nid'];
|
||||
$filterfields[] = t('Project');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['task_nid']) && $_SESSION['stormtimetracking_list_filter']['task_nid'] != 0) {
|
||||
$where[] = 'stt.task_nid=%d';
|
||||
$args[] = $_SESSION['stormtimetracking_list_filter']['task_nid'];
|
||||
$filterfields[] = t('Task');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['ticket_nid']) && $_SESSION['stormtimetracking_list_filter']['ticket_nid'] != 0) {
|
||||
$where[] = 'stt.ticket_nid=%d';
|
||||
$args[] = $_SESSION['stormtimetracking_list_filter']['ticket_nid'];
|
||||
$filterfields[] = t('Ticket');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['datefrom']) && $_SESSION['stormtimetracking_list_filter']['datefrom']['day'] != -1) {
|
||||
$datefrom = $_SESSION['stormtimetracking_list_filter']['datefrom'];
|
||||
$datefrom['hour'] = 0;
|
||||
$datefrom['minute'] = 0;
|
||||
$where[] = 'stt.trackingdate>=%d';
|
||||
$args[] = _storm_datetime_to_gmtimestamp($datefrom);
|
||||
$filterfields[] = t('Date');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['dateto']) && $_SESSION['stormtimetracking_list_filter']['dateto']['day'] != -1) {
|
||||
$dateto = $_SESSION['stormtimetracking_list_filter']['dateto'];
|
||||
$dateto['hour'] = 23;
|
||||
$dateto['minute'] = 59;
|
||||
$where[] = 'stt.trackingdate<=%d';
|
||||
$args[] = _storm_datetime_to_gmtimestamp($dateto);
|
||||
$filterfields[] = t('Date');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['billable']) && $_SESSION['stormtimetracking_list_filter']['billable'] != '-') {
|
||||
$where[] = 'stt.billable=%d';
|
||||
$args[] = $_SESSION['stormtimetracking_list_filter']['billable'];
|
||||
$filterfields[] = t('Billable');
|
||||
}
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['billed']) && $_SESSION['stormtimetracking_list_filter']['billed'] != '-') {
|
||||
$where[] = 'stt.billed=%d';
|
||||
$args[] = $_SESSION['stormtimetracking_list_filter']['billed'];
|
||||
$filterfields[] = t('Billed');
|
||||
}
|
||||
|
||||
$itemsperpage = isset($_SESSION['stormtimetracking_list_filter']['itemsperpage']) ? $_SESSION['stormtimetracking_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
|
||||
if (isset($_SESSION['stormtimetracking_list_filter']['user']) && $_SESSION['stormtimetracking_list_filter']['user'] != '') {
|
||||
$trackinguser = user_load(array('name' => $_SESSION['stormtimetracking_list_filter']['user']));
|
||||
if ($trackinguser === FALSE) $trackinguser->uid = -1;
|
||||
$where[] = 'n.uid=%d';
|
||||
$args[] = $trackinguser->uid;
|
||||
$filterfields[] = t('User');
|
||||
}
|
||||
|
||||
if (count($filterfields) == 0) {
|
||||
$filterdesc = t('Not filtered');
|
||||
}
|
||||
else {
|
||||
$filterdesc = t('Filtered by !fields', array('!fields' => implode(", ", array_unique($filterfields))));
|
||||
}
|
||||
$filterdesc .= ' | '. t('!items items per page', array('!items' => $itemsperpage));
|
||||
|
||||
$o = drupal_get_form('stormtimetracking_list_filter', $filterdesc);
|
||||
|
||||
$s = stormtimetracking_access_sql($s, $where);
|
||||
$s = db_rewrite_sql($s);
|
||||
|
||||
$tablesort = tablesort_sql($header);
|
||||
$r = pager_query($s . $tablesort, $itemsperpage, 0, NULL, $args);
|
||||
|
||||
$s_duration = stormtimetracking_access_sql($s_duration, $where);
|
||||
$s_duration = db_rewrite_sql($s_duration);
|
||||
$duration = db_result(db_query($s_duration, $args));
|
||||
|
||||
$_SESSION['stormtimetracking_list_filter']['sql'] = $s . $tablesort;
|
||||
$_SESSION['stormtimetracking_list_filter']['args'] = $args;
|
||||
|
||||
$timetrackings = array();
|
||||
while ($item = db_fetch_object($r)) {
|
||||
$timetrackings[] = $item;
|
||||
}
|
||||
|
||||
$o .= theme('stormtimetracking_list', $header, $timetrackings, $duration);
|
||||
$o .= theme('pager', NULL, $itemsperpage, 0);
|
||||
$o .= drupal_get_form('stormtimetracking_list_form_report');
|
||||
print theme('page', $o);
|
||||
}
|
||||
|
||||
function stormtimetracking_list_filter(&$form_state, $filterdesc = 'Filter') {
|
||||
$organization_nid = isset($_SESSION['stormtimetracking_list_filter']['organization_nid']) ? $_SESSION['stormtimetracking_list_filter']['organization_nid'] : 0;
|
||||
$project_nid = isset($_SESSION['stormtimetracking_list_filter']['project_nid']) ? $_SESSION['stormtimetracking_list_filter']['project_nid'] : 0 ;
|
||||
$task_nid = isset($_SESSION['stormtimetracking_list_filter']['task_nid']) ? $_SESSION['stormtimetracking_list_filter']['task_nid'] : 0;
|
||||
$ticket_nid = isset($_SESSION['stormtimetracking_list_filter']['ticket_nid']) ? $_SESSION['stormtimetracking_list_filter']['ticket_nid'] : 0;
|
||||
$itemsperpage = isset($_SESSION['stormtimetracking_list_filter']['itemsperpage']) ? $_SESSION['stormtimetracking_list_filter']['itemsperpage'] : variable_get('storm_default_items_per_page', 10);
|
||||
|
||||
$datefrom = isset($_SESSION['stormtimetracking_list_filter']['datefrom']) ? $_SESSION['stormtimetracking_list_filter']['datefrom'] : NULL;
|
||||
$dateto = isset($_SESSION['stormtimetracking_list_filter']['dateto']) ? $_SESSION['stormtimetracking_list_filter']['dateto'] : NULL ;
|
||||
|
||||
$trackinguser = isset($_SESSION['stormtimetracking_list_filter']['user']) ? $_SESSION['stormtimetracking_list_filter']['user'] : '';
|
||||
$billable = isset($_SESSION['stormtimetracking_list_filter']['billable']) ? $_SESSION['stormtimetracking_list_filter']['billable'] : '-';
|
||||
$billed = isset($_SESSION['stormtimetracking_list_filter']['billed']) ? $_SESSION['stormtimetracking_list_filter']['billed'] : '-';
|
||||
|
||||
$form = array();
|
||||
|
||||
$form['filter'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $filterdesc,
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#theme' => 'stormtimetracking_list_filter',
|
||||
);
|
||||
|
||||
$form['filter']['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => -20,
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormorganization} AS sor ON sor.vid=n.vid
|
||||
WHERE n.status=1 AND n.type='stormorganization' AND isactive=1 ORDER BY n.title";
|
||||
$s = stormorganization_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s);
|
||||
$organizations = array();
|
||||
while ($organization = db_fetch_object($r)) {
|
||||
$organizations[$organization->nid] = $organization->title;
|
||||
}
|
||||
$organizations = array(0 => t('All')) + $organizations;
|
||||
$form['filter']['group1']['organization_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Organization'),
|
||||
'#default_value' => $organization_nid,
|
||||
'#options' => $organizations,
|
||||
'#attributes' => array('onchange' => "stormticket_organization_project_task_tickets(this, 'edit-project-nid', 'edit-task-nid', 'edit-ticket-nid', true, '" . t('All') . "')"),
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormproject} AS spr ON spr.vid=n.vid
|
||||
WHERE n.status=1 AND spr.organization_nid=%d AND n.type='stormproject' ORDER BY n.title";
|
||||
$s = stormproject_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $organization_nid);
|
||||
$projects = array();
|
||||
while ($project = db_fetch_object($r)) {
|
||||
$projects[$project->nid] = $project->title;
|
||||
}
|
||||
$projects = array(0 => t('All')) + $projects;
|
||||
$form['filter']['group1']['project_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Project'),
|
||||
'#default_value' => $project_nid,
|
||||
'#options' => $projects,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#attributes' => array('onchange' => "stormticket_project_task_tickets(this, 'edit-organization-nid', 'edit-task-nid', 'edit-ticket-nid', true, '" . t('All') . "')"),
|
||||
);
|
||||
|
||||
$tree = _stormtask_get_tree($project_nid);
|
||||
$tasks = _stormtask_plain_tree($tree);
|
||||
$tasks = array(0 => t('All')) + $tasks;
|
||||
$form['filter']['group1']['task_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Task'),
|
||||
'#default_value' => $task_nid,
|
||||
'#options' => $tasks,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#attributes' => array('onchange' => "stormticket_task_tickets(this, 'edit-organization-nid', 'edit-project-nid', 'edit-ticket-nid', true, '" . t('All') . "')"),
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {node} AS n INNER JOIN {stormticket} AS sti
|
||||
ON sti.vid=n.vid WHERE n.status=1 AND n.type='stormticket' AND sti.organization_nid=%d AND sti.project_nid=%d AND sti.task_nid=%d ORDER BY title ";
|
||||
$s = stormticket_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $organization_nid, $project_nid, $task_nid);
|
||||
$tickets = array();
|
||||
while ($ticket = db_fetch_object($r)) {
|
||||
$tickets[$ticket->nid] = $ticket->title;
|
||||
}
|
||||
$tickets = array(0 => t('All')) + $tickets;
|
||||
$form['filter']['group1']['ticket_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Ticket'),
|
||||
'#default_value' => $ticket_nid,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#options' => $tickets,
|
||||
);
|
||||
|
||||
$form['filter']['group2'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => -19,
|
||||
);
|
||||
|
||||
$form['filter']['group2']['datefrom'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#title' => t('Date from'),
|
||||
'#withnull' => TRUE,
|
||||
'#default_value' => $datefrom,
|
||||
);
|
||||
|
||||
$form['filter']['group2']['dateto'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#title' => t('Date to'),
|
||||
'#withnull' => TRUE,
|
||||
'#default_value' => $dateto,
|
||||
);
|
||||
|
||||
$form['filter']['group2']['user'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('User'),
|
||||
'#size' => 25,
|
||||
'#default_value' => $trackinguser,
|
||||
'#autocomplete_path' => 'user/autocomplete',
|
||||
);
|
||||
|
||||
$form['filter']['group3'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
);
|
||||
|
||||
$form['filter']['group3']['billable'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Billable'),
|
||||
'#options' => array('-' => t('all'), '1' => t('billable'), '0' => t('not billable')),
|
||||
'#default_value' => $billable,
|
||||
);
|
||||
|
||||
$form['filter']['group3']['billed'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Billed'),
|
||||
'#options' => array('-' => t('all'), '1' => t('billed'), '0' => t('not billed')),
|
||||
'#default_value' => $billed,
|
||||
);
|
||||
|
||||
$form['filter']['group4'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#attributes' => array('class' => 'formgroup-submit'),
|
||||
);
|
||||
|
||||
$form['filter']['group4']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Filter'),
|
||||
'#submit' => array('stormtimetracking_list_filter_filter'),
|
||||
);
|
||||
|
||||
$form['filter']['group4']['reset'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Reset'),
|
||||
'#submit' => array('stormtimetracking_list_filter_reset'),
|
||||
);
|
||||
|
||||
$form['filter']['group4']['itemsperpage'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Items'),
|
||||
'#size' => 10,
|
||||
'#default_value' => $itemsperpage,
|
||||
'#prefix' => '<div class="container-inline">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormtimetracking_list_filter_filter($form, &$form_state) {
|
||||
$_SESSION['stormtimetracking_list_filter']['organization_nid'] = $form_state['values']['organization_nid'];
|
||||
$_SESSION['stormtimetracking_list_filter']['project_nid'] = $form_state['values']['project_nid'];
|
||||
$_SESSION['stormtimetracking_list_filter']['task_nid'] = $form_state['values']['task_nid'];
|
||||
$_SESSION['stormtimetracking_list_filter']['ticket_nid'] = $form_state['values']['ticket_nid'];
|
||||
$_SESSION['stormtimetracking_list_filter']['datefrom'] = $form_state['values']['datefrom'];
|
||||
$_SESSION['stormtimetracking_list_filter']['dateto'] = $form_state['values']['dateto'];
|
||||
$_SESSION['stormtimetracking_list_filter']['billable'] = $form_state['values']['billable'];
|
||||
$_SESSION['stormtimetracking_list_filter']['billed'] = $form_state['values']['billed'];
|
||||
$_SESSION['stormtimetracking_list_filter']['itemsperpage'] = $form_state['values']['itemsperpage'];
|
||||
$_SESSION['stormtimetracking_list_filter']['user'] = $form_state['values']['user'];
|
||||
}
|
||||
|
||||
function stormtimetracking_list_filter_reset($form, &$form_state) {
|
||||
unset($_SESSION['stormtimetracking_list_filter']);
|
||||
}
|
||||
|
||||
function stormtimetracking_list_form_report() {
|
||||
$form = array();
|
||||
$form['#prefix'] = '<div id="stormtimetracking_list_form_report" class="storm_list_form_report">';
|
||||
$form['report'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Reports'),
|
||||
'#options' => theme('stormtimetracking_list_form_report_reports'),
|
||||
);
|
||||
|
||||
if (module_exists('locale')) {
|
||||
$language_list = language_list();
|
||||
$languages = array();
|
||||
foreach ($language_list as $key => $lang) {
|
||||
$languages[$key] = $lang->name;
|
||||
}
|
||||
$form['language'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Language'),
|
||||
'#options' => $languages,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$form['language'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => 'en',
|
||||
);
|
||||
}
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Report'),
|
||||
);
|
||||
$form['#suffix'] = '</div>';
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormtimetracking_list_form_report_submit($form, &$form_state) {
|
||||
$report = $form_state['values']['report'];
|
||||
$language = $form_state['values']['language'];
|
||||
drupal_goto('timetrackings/report/'. $report .'/'. $language);
|
||||
}
|
||||
|
||||
function stormtimetracking_list_report($report, $language) {
|
||||
$timetrackings = array();
|
||||
|
||||
$s = $_SESSION['stormtimetracking_list_filter']['sql'];
|
||||
$args = $_SESSION['stormtimetracking_list_filter']['args'];
|
||||
|
||||
$r = db_query($s, $args);
|
||||
while ($t = db_fetch_object($r)) {
|
||||
$timetracking = node_load($t->nid);
|
||||
$timetrackings[] = $timetracking;
|
||||
}
|
||||
|
||||
print theme('stormtimetracking_list_report', $report, $language, $timetrackings);
|
||||
}
|
||||
|
15
modules/storm/stormtimetracking/stormtimetracking.info
Normal file
15
modules/storm/stormtimetracking/stormtimetracking.info
Normal file
|
@ -0,0 +1,15 @@
|
|||
name = Storm Timetracking
|
||||
description = "Allows recording of times worked based on project, task and/or ticket"
|
||||
dependencies[] = storm
|
||||
dependencies[] = stormorganization
|
||||
dependencies[] = stormproject
|
||||
dependencies[] = stormtask
|
||||
dependencies[] = stormticket
|
||||
package = Storm
|
||||
core = 6.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-05
|
||||
version = "6.x-2.2"
|
||||
core = "6.x"
|
||||
project = "storm"
|
||||
datestamp = "1375697500"
|
89
modules/storm/stormtimetracking/stormtimetracking.install
Normal file
89
modules/storm/stormtimetracking/stormtimetracking.install
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormtimetracking_install() {
|
||||
drupal_install_schema('stormtimetracking');
|
||||
variable_set('node_options_stormtimetracking', array('status'));
|
||||
}
|
||||
|
||||
function stormtimetracking_disable() {
|
||||
drupal_set_message(t('Nodes of type "Timetracking" have not been deleted on disabling SuiteDesk Timetracking. Please note that they will now have reduced functionality, and will not be protected by SuiteDesk Timetracking access controls.'), 'warning');
|
||||
}
|
||||
|
||||
function stormtimetracking_uninstall() {
|
||||
drupal_uninstall_schema('stormtimetracking');
|
||||
}
|
||||
|
||||
function stormtimetracking_schema() {
|
||||
$schema['stormtimetracking'] = array(
|
||||
'fields' => array(
|
||||
'vid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
||||
'organization_nid' => array('type' => 'int'),
|
||||
'organization_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'project_nid' => array('type' => 'int'),
|
||||
'project_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'task_nid' => array('type' => 'int'),
|
||||
'task_stepno' => array('type' => 'varchar', 'length' => 128),
|
||||
'task_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'ticket_nid' => array('type' => 'int'),
|
||||
'ticket_title' => array('type' => 'varchar', 'length' => 128),
|
||||
'trackingdate' => array('type' => 'int'),
|
||||
'timebegin' => array('type' => 'varchar', 'length' => 5),
|
||||
'timeend' => array('type' => 'varchar', 'length' => 5),
|
||||
'duration' => array('type' => 'float'),
|
||||
'billing_duration' => array('type' => 'float'),
|
||||
'billable' => array('type' => 'int'),
|
||||
'billed' => array('type' => 'int'),
|
||||
),
|
||||
'primary key' => array('vid'),
|
||||
'indexes' => array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'project_nid' => array('project_nid'),
|
||||
'task_nid' => array('task_nid'),
|
||||
'ticket_nid' => array('ticket_nid'),
|
||||
'trackingdate' => array('trackingdate'),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
function stormtimetracking_update_1() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormtimetracking', 'billable', array('type' => 'int'));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function stormtimetracking_update_6102() {
|
||||
$ret = array();
|
||||
db_add_field($ret, 'stormtimetracking', 'billed', array('type' => 'int'));
|
||||
db_change_field($ret, 'stormtimetracking', 'duration', 'billing_duration', array('type' => 'float'));
|
||||
db_add_field($ret, 'stormtimetracking', 'duration', array('type' => 'float'));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Improve primary keys and indexes
|
||||
*/
|
||||
function stormtimetracking_update_6201() {
|
||||
$return = array();
|
||||
db_drop_primary_key($return, 'stormtimetracking');
|
||||
db_add_primary_key($return, 'stormtimetracking', array('vid'));
|
||||
$indexes = array(
|
||||
'nid' => array('nid'),
|
||||
'organization_nid' => array('organization_nid'),
|
||||
'project_nid' => array('project_nid'),
|
||||
'task_nid' => array('task_nid'),
|
||||
'ticket_nid' => array('ticket_nid'),
|
||||
'trackingdate' => array('trackingdate'),
|
||||
);
|
||||
foreach ($indexes as $name => $fields) {
|
||||
db_add_index($return, 'stormtimetracking', $name, $fields);
|
||||
}
|
||||
return $return;
|
||||
}
|
809
modules/storm/stormtimetracking/stormtimetracking.module
Normal file
809
modules/storm/stormtimetracking/stormtimetracking.module
Normal file
|
@ -0,0 +1,809 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function stormtimetracking_help($path, $arg) {
|
||||
$o = '';
|
||||
|
||||
switch ($path) {
|
||||
case "admin/help#stormtimetracking":
|
||||
$o = '<p>'. t("Provides timetracking support for Storm") .'</p>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function stormtimetracking_perm() {
|
||||
return array(
|
||||
'Storm timetracking: access',
|
||||
'Storm timetracking: add',
|
||||
'Storm timetracking: delete all',
|
||||
'Storm timetracking: delete own',
|
||||
'Storm timetracking: delete of user organization',
|
||||
'Storm timetracking: edit all',
|
||||
'Storm timetracking: edit own',
|
||||
'Storm timetracking: edit of user organization',
|
||||
'Storm timetracking: view all',
|
||||
'Storm timetracking: view own',
|
||||
'Storm timetracking: view of user organization',
|
||||
'Storm timetracking: view if assigned to project',
|
||||
);
|
||||
}
|
||||
|
||||
function stormtimetracking_access($op, $node, $account = NULL) {
|
||||
if (empty($account)) {
|
||||
global $user;
|
||||
$account = $user;
|
||||
}
|
||||
|
||||
if ($op == 'create') {
|
||||
return user_access('Storm timetracking: add');
|
||||
}
|
||||
|
||||
if (is_numeric($node)) {
|
||||
$node = node_load($node);
|
||||
}
|
||||
|
||||
if (!isset($account->stormorganization_nid) && module_exists('stormperson')) {
|
||||
_stormperson_user_load($account);
|
||||
}
|
||||
|
||||
if ($op == 'delete') {
|
||||
if (user_access('Storm timetracking: delete all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: delete own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: delete of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'update') {
|
||||
if (user_access('Storm timetracking: edit all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: edit own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: edit of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($op == 'view') {
|
||||
if (user_access('Storm timetracking: view all')) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: view own') && ($account->uid == $node->uid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: view of user organization') && ($account->stormorganization_nid == $node->organization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (user_access('Storm timetracking: view if assigned to project') && module_exists('stormteam')) {
|
||||
$project = node_load($node->project_nid);
|
||||
if (stormteam_user_belongs_to_team($project->assigned_nid, $account->stormperson_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
elseif (stormteam_user_belongs_to_team($project->assigned_nid, $account->stormorganization_nid)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function stormtimetracking_access_sql($sql, $where = array()) {
|
||||
if (!user_access('Storm timetracking: view all')) {
|
||||
global $user;
|
||||
|
||||
$cond = '';
|
||||
$join = array();
|
||||
if (user_access('Storm timetracking: view own')) {
|
||||
$cond .= 'n.uid = ' . $user->uid;
|
||||
}
|
||||
if (user_access('Storm timetracking: view of user organization')) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'stt.organization_nid = ' . $user->stormorganization_nid;
|
||||
}
|
||||
if (user_access('Storm timetracking: view if assigned to project')) {
|
||||
$join[] = 'LEFT JOIN {node} npr ON npr.nid = stt.project_nid';
|
||||
$join[] = 'LEFT JOIN {stormproject} spr ON spr.vid = npr.vid';
|
||||
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'spr.assigned_nid = ' . $user->stormperson_nid;
|
||||
|
||||
if (module_exists('stormteam')) {
|
||||
// Load teams that the account belongs to:
|
||||
$belonged_teams = stormteam_user_return_teams();
|
||||
// Allow access if any of those teams is the one in question:
|
||||
foreach ($belonged_teams as $belonged_team) {
|
||||
$cond .= ' OR spr.assigned_nid = ' . $belonged_team;
|
||||
}
|
||||
}
|
||||
}
|
||||
$where[] = empty($cond) ? '0 = 1' : $cond;
|
||||
}
|
||||
|
||||
$where[] = "'storm_access' = 'storm_access'";
|
||||
return storm_rewrite_sql($sql, $where, $join);
|
||||
}
|
||||
|
||||
function stormtimetracking_storm_rewrite_where_sql($query, $primary_table, $account) {
|
||||
static $conds = array();
|
||||
|
||||
if (isset($conds[$primary_table][$account->uid])) {
|
||||
return $conds[$primary_table][$account->uid];
|
||||
}
|
||||
|
||||
$cond = '';
|
||||
if (!preg_match("/'storm_access' = 'storm_access'/", $query)) {
|
||||
if (user_access('Storm timetracking: view all', $account)) {
|
||||
return '';
|
||||
}
|
||||
$from = '{stormtimetracking} stt1';
|
||||
if (user_access('Storm timetracking: view own', $account)) {
|
||||
$cond .= "${primary_table}.uid = " . $account->uid;
|
||||
}
|
||||
if (user_access('Storm timetracking: view of user organization', $account)) {
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
# If function is called without viewing an organization, this variable
|
||||
# may not be set. These lines check for that and set the organization
|
||||
# node id to zero if not otherwise set.
|
||||
if (!isset($account->stormorganization_nid)) {
|
||||
$account->stormorganization_nid = 0;
|
||||
}
|
||||
$cond .= ' stt1.organization_nid = ' . $account->stormorganization_nid;
|
||||
}
|
||||
if (user_access('Storm timetracking: view if assigned to project')) {
|
||||
$from .= ' LEFT JOIN {node} npr1 ON npr1.nid = stt1.project_nid LEFT JOIN {stormproject} spr1 ON spr1.vid = npr1.vid';
|
||||
$cond .= !empty($cond) ? ' OR ' : '';
|
||||
$cond .= 'spr1.assigned_nid = ' . $account->stormperson_nid;
|
||||
|
||||
if (module_exists('stormteam')) {
|
||||
// Load teams that the account belongs to:
|
||||
$belonged_teams = stormteam_user_return_teams($account);
|
||||
// Allow access if any of those teams is the one in question:
|
||||
foreach ($belonged_teams as $belonged_team) {
|
||||
$cond .= ' OR spr1.assigned_nid = ' . $belonged_team;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cond) {
|
||||
$cond = " WHEN 'stormtimetracking' THEN (SELECT IF($cond, 1, 0) FROM ${from} WHERE stt1.vid = ${primary_table}.vid) ";
|
||||
}
|
||||
else {
|
||||
$cond = " WHEN 'stormtimetracking' THEN 0 ";
|
||||
}
|
||||
}
|
||||
$conds[$primary_table][$account->uid] = $cond;
|
||||
return $cond;
|
||||
}
|
||||
|
||||
function stormtimetracking_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['timetrackings'] = array(
|
||||
'title' => 'Timetrackings',
|
||||
'description' => 'SuiteDesk timetrackings',
|
||||
'page callback' => 'stormtimetracking_list',
|
||||
'access arguments' => array('Storm timetracking: access'),
|
||||
'type' => MENU_NORMAL_ITEM,
|
||||
'file' => 'stormtimetracking.admin.inc',
|
||||
'weight' => 6,
|
||||
);
|
||||
|
||||
$items['timetrackings/report/%/%'] = array(
|
||||
'title' => 'Timetrackings',
|
||||
'description' => 'SuiteDesk timetrackings',
|
||||
'page arguments' => array(3, 4),
|
||||
'page callback' => 'stormtimetracking_list_report',
|
||||
'access arguments' => array('Storm timetracking: access'),
|
||||
'type' => MENU_CALLBACK,
|
||||
'file' => 'stormtimetracking.admin.inc',
|
||||
);
|
||||
|
||||
$items['admin/settings/suitedesk/timetracking'] = array(
|
||||
'title' => 'SuiteDesk timetracking',
|
||||
'description' => 'SuiteDesk timetracking administration page',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('stormtimetracking_admin_settings'),
|
||||
'access arguments' => array('Storm: access administration pages'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function stormtimetracking_theme() {
|
||||
return array(
|
||||
'stormtimetracking_list' => array(
|
||||
'file' => 'stormtimetracking.theme.inc',
|
||||
'arguments' => array('header', 'tasks', 'duration'),
|
||||
),
|
||||
'stormtimetracking_view' => array(
|
||||
'file' => 'stormtimetracking.theme.inc',
|
||||
'arguments' => array('node', 'teaser', 'page'),
|
||||
),
|
||||
'stormtimetracking_list_form_report_reports' => array(
|
||||
'file' => 'stormtimetracking.theme.inc',
|
||||
),
|
||||
'stormtimetracking_list_report' => array(
|
||||
'file' => 'stormtimetracking.theme.inc',
|
||||
'arguments' => array('report', 'language', 'timetrackings'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormtimetracking_node_info() {
|
||||
return array(
|
||||
'stormtimetracking' => array(
|
||||
'name' => t('Timetracking'),
|
||||
'module' => 'stormtimetracking',
|
||||
'description' => t("A timetracking for Storm."),
|
||||
'title_label' => t("Title"),
|
||||
'body_label' => t("Description"),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function stormtimetracking_content_extra_fields($type_name) {
|
||||
if ($type_name == 'stormtimetracking') {
|
||||
return array(
|
||||
'group1' => array('label' => 'Organization/Project/Task/Ticket Group', 'weight' => -20),
|
||||
'group2' => array('label' => 'Date', 'weight' => -19),
|
||||
'group3' => array('label' => 'Time / Duration Group', 'weight' => -18),
|
||||
'group4' => array('label' => 'Billable / Billed Group', 'weight' => -17),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function stormtimetracking_stormorganization_change($organization_nid, $organization_title) {
|
||||
$s = "UPDATE {stormtimetracking} SET organization_title='%s' WHERE organization_nid=%d AND organization_title <> '%s'";
|
||||
db_query($s, $organization_title, $organization_nid, $organization_title);
|
||||
}
|
||||
|
||||
function stormtimetracking_stormproject_change($project_nid, $project_title) {
|
||||
$s = "UPDATE {stormtimetracking} SET project_title='%s' WHERE project_nid=%d AND project_title <> '%s'";
|
||||
db_query($s, $project_title, $project_nid, $project_title);
|
||||
}
|
||||
|
||||
function stormtimetracking_stormtask_change($task_nid, $task_title, $task_stepno) {
|
||||
$s = "UPDATE {stormtimetracking} SET task_title='%s', task_stepno='%s' WHERE task_nid=%d AND
|
||||
(task_title<>'%s' OR task_stepno<>'%s')";
|
||||
db_query($s, $task_title, $task_stepno, $task_nid, $task_title, $task_stepno);
|
||||
}
|
||||
|
||||
function stormtimetracking_stormticket_change($ticket_nid, $ticket_title) {
|
||||
$s = "UPDATE {stormtimetracking} SET ticket_title='%s' WHERE ticket_nid=%d AND ticket_title <> '%s'";
|
||||
db_query($s, $ticket_title, $ticket_nid, $ticket_title);
|
||||
}
|
||||
|
||||
function stormtimetracking_stormproject_change_hierarchy($project_nid, $organization_nid, $organization_title) {
|
||||
$s = "UPDATE {stormtimetracking} SET organization_nid=%d, organization_title='%s' WHERE project_nid=%d";
|
||||
db_query($s, $organization_nid, $organization_title, $project_nid);
|
||||
}
|
||||
|
||||
function stormtimetracking_stormtask_change_hierarchy($task_nid, $organization_nid, $organization_title, $project_nid, $project_title) {
|
||||
$s = "UPDATE {stormtimetracking} SET organization_nid=%d, organization_title='%s', project_nid=%d, project_title='%s' WHERE task_nid=%d";
|
||||
db_query($s, $organization_nid, $organization_title, $project_nid, $project_title, $task_nid);
|
||||
}
|
||||
|
||||
function stormtimetracking_stormticket_change_hierarchy($ticket_nid, $organization_nid, $organization_title, $project_nid, $project_title, $task_nid, $task_title) {
|
||||
$s = "UPDATE {stormtimetracking} SET organization_nid=%d, organization_title='%s', project_nid=%d, project_title='%s', task_nid=%d, task_title='%s' WHERE ticket_nid=%d";
|
||||
db_query($s, $organization_nid, $organization_title, $project_nid, $project_title, $task_nid, $task_title, $ticket_nid);
|
||||
}
|
||||
|
||||
function stormtimetracking_form(&$node) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('Storm'), 'storm');
|
||||
$breadcrumb[] = l(t('Timetrackings'), 'timetrackings');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
if (arg(1)=='add') {
|
||||
if (array_key_exists('organization_nid', $_GET) && !$node->organization_nid) {
|
||||
$node->organization_nid = $_GET['organization_nid'];
|
||||
}
|
||||
if (array_key_exists('project_nid', $_GET) && !$node->project_nid) {
|
||||
$node->project_nid = $_GET['project_nid'];
|
||||
$p = node_load($node->project_nid);
|
||||
$node->organization_nid = $p->organization_nid;
|
||||
if (!stormorganization_access('view', $node->organization_nid)) {
|
||||
drupal_set_message(t("You cannot add a timetracking for this project, as you do not have access to view the organization's profile"));
|
||||
drupal_goto('node/'. $node->project_nid);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('task_nid', $_GET) && !$node->task_nid) {
|
||||
$node->task_nid = $_GET['task_nid'];
|
||||
$t = node_load($node->task_nid);
|
||||
$node->organization_nid = $t->organization_nid;
|
||||
$node->project_nid = $t->project_nid;
|
||||
// $project_access deals with the case whereby the project could be blank, hence access rules not required
|
||||
$project_access = $node->project_nid ? stormproject_access('view', $node->project_nid) : TRUE;
|
||||
if (!stormorganization_access('view', $node->organization_nid) || !$project_access) {
|
||||
drupal_set_message(t("You cannot add a timetracking for this task, as you do not have access to view the both the organization and project's profile"));
|
||||
drupal_goto('node/'. $node->task_nid);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('ticket_nid', $_GET) && !$node->ticket_nid) {
|
||||
$node->ticket_nid = $_GET['ticket_nid'];
|
||||
$t = node_load($node->ticket_nid);
|
||||
$node->organization_nid = $t->organization_nid;
|
||||
$node->project_nid = $t->project_nid;
|
||||
$node->task_nid = $t->task_nid;
|
||||
// $project_access deals with the case whereby the project could be blank, hence access rules not required
|
||||
$project_access = $node->project_nid ? stormproject_access('view', $node->project_nid) : TRUE;
|
||||
$task_access = $node->task_nid ? stormtask_access('view', $node->task_nid) : TRUE;
|
||||
if (!stormorganization_access('view', $node->organization_nid) || !project_access || !task_access) {
|
||||
drupal_set_message(t("You cannot add a timetracking for this ticket, as you do not have access to view all of the organization, project and task's profile"));
|
||||
drupal_goto('node/'. $node->ticket_nid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['stormtimetracking_list_filter']['organization_nid']) && !$node->organization_nid) {
|
||||
$node->organization_nid = $_SESSION['stormtimetracking_list_filter']['organization_nid'];
|
||||
}
|
||||
if (!empty($_SESSION['stormtimetracking_list_filter']['project_nid']) && !$node->project_nid) {
|
||||
$node->project_nid = $_SESSION['stormtimetracking_list_filter']['project_nid'];
|
||||
}
|
||||
if (!empty($_SESSION['stormtimetracking_list_filter']['task_nid']) && !$node->task_nid) {
|
||||
$node->task_nid = $_SESSION['stormtimetracking_list_filter']['task_nid'];
|
||||
}
|
||||
if (!empty($_SESSION['stormtimetracking_list_filter']['ticket_nid']) && !$node->ticket_nid) {
|
||||
$node->ticket_nid = $_SESSION['stormtimetracking_list_filter']['ticket_nid'];
|
||||
}
|
||||
if (array_key_exists('organization_nid', $_GET)) $node->organization_nid = $_GET['organization_nid'];
|
||||
if (array_key_exists('project_nid', $_GET)) $node->project_nid = $_GET['project_nid'];
|
||||
if (array_key_exists('task_nid', $_GET)) $node->task_nid = $_GET['task_nid'];
|
||||
if (array_key_exists('ticket_nid', $_GET)) $node->ticket_nid = $_GET['ticket_nid'];
|
||||
|
||||
$node->trackingdate = time();
|
||||
|
||||
$today = _storm_gmtimestamp_without_time(time());
|
||||
$s = 'SELECT MAX(stt.timeend) FROM {node} n LEFT JOIN {stormtimetracking} stt ON n.nid=stt.nid
|
||||
WHERE stt.trackingdate>=%d AND stt.trackingdate<=%d AND n.uid=%d';
|
||||
$timebegin = db_result(db_query($s, $today, $today, $node->uid));
|
||||
$node->timebegin = $timebegin;
|
||||
$node->timeend = format_date(time(), 'custom', 'H:i');
|
||||
|
||||
$timebegin = _storm_strtotime($node->timebegin);
|
||||
$timeend = _storm_strtotime($node->timeend);
|
||||
if ($timeend['hour'] && $timebegin['hour']) {
|
||||
$node->duration = ($timeend['hour'] - $timebegin['hour'] + ($timeend['minute'] - $timebegin['minute']) / 60);
|
||||
}
|
||||
$node->billable = variable_get('stormtimetracking_billable_default', FALSE);
|
||||
}
|
||||
$s_org = "SELECT n.nid, n.title FROM {stormorganization} so INNER JOIN {node} n
|
||||
ON so.nid=n.nid WHERE n.status=1 AND (so.isactive=1 OR n.nid=%d) AND n.type='stormorganization' ORDER BY n.title";
|
||||
|
||||
$type = node_get_types('type', $node);
|
||||
|
||||
$form['#attributes']['class'] = 'stormcomponent_node_form';
|
||||
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => check_plain($type->title_label),
|
||||
'#required' => TRUE,
|
||||
'#default_value' => $node->title,
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'title') : -21,
|
||||
);
|
||||
|
||||
$form['group1'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$s_org = stormorganization_access_sql($s_org);
|
||||
$s_org = db_rewrite_sql($s_org);
|
||||
$r = db_query($s_org, isset($node->organization_nid) ? $node->organization_nid : -1);
|
||||
$organizations = array();
|
||||
while ($organization = db_fetch_object($r)) {
|
||||
$organizations[$organization->nid] = $organization->title;
|
||||
if (!isset($node->organization_nid)) $node->organization_nid = $organization->nid;
|
||||
}
|
||||
$form['group1']['organization_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Organization'),
|
||||
'#default_value' => $node->organization_nid,
|
||||
'#options' => $organizations,
|
||||
'#required' => TRUE,
|
||||
'#attributes' => array('onchange' => "stormticket_organization_project_task_tickets(this, 'edit-project-nid', 'edit-task-nid', 'edit-ticket-nid', true, '-')"),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$s = "SELECT n.nid, n.title FROM {stormproject} spr INNER JOIN {node} n ON spr.nid=n.nid WHERE spr.organization_nid=%d AND n.status=1 AND n.type='stormproject' ORDER BY n.title";
|
||||
$s = stormproject_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $node->organization_nid);
|
||||
$projects = array();
|
||||
while ($project = db_fetch_object($r)) {
|
||||
$projects[$project->nid] = $project->title;
|
||||
}
|
||||
$projects = array(0 => '-') + $projects;
|
||||
$form['group1']['project_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Project'),
|
||||
'#default_value' => isset($node->project_nid) ? $node->project_nid : 0,
|
||||
'#options' => $projects,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#attributes' => array('onchange' => "stormticket_project_task_tickets(this, 'edit-organization-nid', 'edit-task-nid', 'edit-ticket-nid', true, '-')"),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$tree = _stormtask_get_tree(isset($node->project_nid) ? $node->project_nid : 0);
|
||||
$tasks = _stormtask_plain_tree($tree);
|
||||
$tasks = array(0 => '-') + $tasks;
|
||||
$form['group1']['task_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Task'),
|
||||
'#default_value' => isset($node->task_nid) ? $node->task_nid : 0,
|
||||
'#options' => $tasks,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#attributes' => array('onchange' => "stormticket_task_tickets(this, 'edit-organization-nid', 'edit-project-nid', 'edit-ticket-nid', true, '-')"),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$tickets = array();
|
||||
$s = "SELECT n.nid, n.title FROM {stormticket} sti INNER JOIN {node} n ON sti.nid=n.nid WHERE n.status=1 AND n.type='stormticket' AND sti.organization_nid=%d AND sti.project_nid=%d AND sti.task_nid=%d ORDER BY n.title";
|
||||
$s = stormticket_access_sql($s);
|
||||
$s = db_rewrite_sql($s);
|
||||
$r = db_query($s, $node->organization_nid, isset($node->project_nid) ? $node->project_nid : -1, isset($node->task_nid) ? $node->task_nid : -1);
|
||||
while ($ticket = db_fetch_object($r)) {
|
||||
$tickets[$ticket->nid] = $ticket->title;
|
||||
}
|
||||
$form['group1']['ticket_nid'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Ticket'),
|
||||
'#default_value' => isset($node->ticket_nid) ? $node->ticket_nid : 0,
|
||||
'#options' => array(0 => '-') + $tickets,
|
||||
'#process' => array('storm_dependent_select_process'),
|
||||
'#weight' => 4,
|
||||
);
|
||||
|
||||
$form['group2'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
|
||||
);
|
||||
|
||||
$form['group2']['trackingdate'] = array(
|
||||
'#type' => 'dateext',
|
||||
'#title' => t('Date'),
|
||||
'#default_value' => $node->trackingdate,
|
||||
);
|
||||
|
||||
$form['group3'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
|
||||
);
|
||||
|
||||
$form['group3']['timebegin'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Time begin'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 5,
|
||||
'#default_value' => $node->timebegin,
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$form['group3']['timeend'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Time end'),
|
||||
'#size' => 5,
|
||||
'#maxlength' => 5,
|
||||
'#default_value' => $node->timeend,
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$form['group3']['duration'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Total duration'),
|
||||
'#default_value' => stormtimetracking_duration($node->duration),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 5,
|
||||
'#weight' => 3,
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
|
||||
$form['group3']['billing_duration'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Billing duration'),
|
||||
'#default_value' => sprintf("%01.2f", isset($node->billing_duration) ? $node->billing_duration : 0),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 5,
|
||||
'#weight' => 4,
|
||||
);
|
||||
|
||||
$form['group3']['billing_duration_time'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Duration'),
|
||||
'#default_value' => stormtimetracking_duration($node->billing_duration),
|
||||
'#size' => 10,
|
||||
'#maxlength' => 5,
|
||||
'#weight' => 5,
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
|
||||
$form['group4'] = array(
|
||||
'#type' => 'markup',
|
||||
'#theme' => 'storm_form_group',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -17,
|
||||
);
|
||||
|
||||
$form['group4']['billable'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Billable'),
|
||||
'#default_value' => isset($node->billable) ? $node->billable : TRUE,
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$form['group4']['billed'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Billed'),
|
||||
'#default_value' => isset($node->billed) ? $node->billed : FALSE,
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
if ($type->has_body) {
|
||||
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function stormtimetracking_insert($node) {
|
||||
_stormtimetracking_beforesave($node);
|
||||
|
||||
db_query("INSERT INTO {stormtimetracking}
|
||||
(vid, nid,
|
||||
organization_nid, organization_title, project_nid, project_title,
|
||||
task_nid, task_title, task_stepno, ticket_nid, ticket_title,
|
||||
trackingdate, timebegin, timeend, duration, billing_duration, billable, billed) VALUES
|
||||
(%d, %d,
|
||||
%d, '%s', %d, '%s',
|
||||
%d, '%s', '%s', %d, '%s',
|
||||
%d, '%s', '%s', %f, %f, %d, %d)",
|
||||
$node->vid, $node->nid,
|
||||
$node->organization_nid, $node->organization_title, $node->project_nid, $node->project_title,
|
||||
$node->task_nid, $node->task_title, $node->task_stepno, $node->ticket_nid, $node->ticket_title,
|
||||
$node->trackingdate, $node->timebegin, $node->timeend, $node->duration, $node->billing_duration, $node->billable, $node->billed);
|
||||
}
|
||||
|
||||
function stormtimetracking_update($node) {
|
||||
_stormtimetracking_beforesave($node);
|
||||
|
||||
// If this is a new revision, then it is actually an insert operation
|
||||
if ($node->revision) {
|
||||
stormtimetracking_insert($node);
|
||||
}
|
||||
else {
|
||||
db_query("UPDATE {stormtimetracking} SET
|
||||
organization_nid=%d, organization_title='%s', project_nid=%d, project_title='%s',
|
||||
task_nid=%d, task_title='%s', task_stepno='%s', ticket_nid=%d, ticket_title='%s',
|
||||
trackingdate=%d, timebegin='%s', timeend='%s', duration=%f, billing_duration=%f,
|
||||
billable=%d, billed=%d WHERE vid = %d",
|
||||
$node->organization_nid, $node->organization_title, $node->project_nid, $node->project_title,
|
||||
$node->task_nid, $node->task_title, $node->task_stepno, $node->ticket_nid, $node->ticket_title,
|
||||
$node->trackingdate, $node->timebegin, $node->timeend, $node->duration, $node->billing_duration,
|
||||
$node->billable, $node->billed, $node->vid);
|
||||
}
|
||||
}
|
||||
|
||||
function _stormtimetracking_beforesave(&$node) {
|
||||
$timebegin = _storm_strtotime($node->timebegin);
|
||||
$timeend = _storm_strtotime($node->timeend);
|
||||
|
||||
if (is_array($node->trackingdate)) {
|
||||
$node->trackingdate = _storm_datetime_to_gmtimestamp($node->trackingdate + $timebegin);
|
||||
}
|
||||
|
||||
$node->timebegin = _timetostr($timebegin);
|
||||
$node->timeend = _timetostr($timeend);
|
||||
|
||||
$node->duration = ($timeend['hour'] - $timebegin['hour'] + ($timeend['minute'] - $timebegin['minute']) / 60);
|
||||
if ($node->timeend < $node->timebegin) {
|
||||
$node->duration += 24;
|
||||
}
|
||||
|
||||
if (variable_get('stormtimetracking_auto_duration', TRUE)) {
|
||||
$node->billing_duration = $node->duration;
|
||||
}
|
||||
|
||||
$s = "SELECT n.title FROM {node} n INNER JOIN {stormorganization} o ON n.nid=o.nid WHERE type='stormorganization' AND n.nid=%d";
|
||||
$r = db_query($s, $node->organization_nid);
|
||||
$o = db_fetch_object($r);
|
||||
$node->organization_title = $o->title;
|
||||
|
||||
$s = "SELECT n.title, p.organization_title FROM {node} n INNER JOIN {stormproject} p ON n.nid=p.nid WHERE type='stormproject' AND n.nid=%d";
|
||||
$r = db_query($s, $node->project_nid);
|
||||
$p = db_fetch_object($r);
|
||||
$node->project_title = isset($p->title) ? $p->title : '';
|
||||
|
||||
$s = "SELECT title, stepno FROM {node} n INNER JOIN {stormtask} t ON n.nid=t.nid WHERE n.type='stormtask' AND n.nid=%d";
|
||||
$r = db_query($s, $node->task_nid);
|
||||
$ta = db_fetch_object($r);
|
||||
$node->task_title = isset($ta->title) ? $ta->title : '';
|
||||
$node->task_stepno = isset($ta->stepno) ? $ta->stepno : '';
|
||||
|
||||
$s = "SELECT title FROM {node} n INNER JOIN {stormticket} t ON n.nid=t.nid WHERE n.type='stormticket' AND n.nid=%d";
|
||||
$r = db_query($s, $node->ticket_nid);
|
||||
$ti = db_fetch_object($r);
|
||||
$node->ticket_title = isset($ti->title) ? $ti->title : '';
|
||||
}
|
||||
|
||||
function stormtimetracking_nodeapi(&$node, $op, $teaser, $page) {
|
||||
if ($node->type != 'stormtimetracking') {
|
||||
return;
|
||||
}
|
||||
switch ($op) {
|
||||
case 'delete revision':
|
||||
// Notice that we're matching a single revision based on the node's vid.
|
||||
db_query('DELETE FROM {stormtimetracking} WHERE vid = %d', $node->vid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function stormtimetracking_delete($node) {
|
||||
db_query('DELETE FROM {stormtimetracking} WHERE nid = %d', $node->nid);
|
||||
}
|
||||
|
||||
function stormtimetracking_load($node) {
|
||||
$additions = db_fetch_object(db_query('SELECT * FROM {stormtimetracking} WHERE vid = %d', $node->vid));
|
||||
return $additions;
|
||||
}
|
||||
|
||||
function stormtimetracking_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('Storm'), 'storm');
|
||||
$breadcrumb[] = l(t('Timetrackings'), 'timetrackings');
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
|
||||
return theme('stormtimetracking_view', $node, $teaser, $page);
|
||||
}
|
||||
|
||||
// CONVERT DECIMAL DURATION TO TIME DURATION
|
||||
function stormtimetracking_duration($duration) {
|
||||
if (empty($duration)) {
|
||||
return '';
|
||||
}
|
||||
$h = intval($duration);
|
||||
$m = round(($duration - $h) * 60);
|
||||
if ($h == 0 && $m == 0) {
|
||||
return '0h';
|
||||
}
|
||||
return ($h > 0 ? $h . 'h' : '') . ($m > 0 ? ($h > 0 ? ' ' : '') . $m . 'm' : '');
|
||||
}
|
||||
|
||||
// ADMIN SETTINGS
|
||||
function stormtimetracking_admin_settings() {
|
||||
$form = array();
|
||||
|
||||
$form['stormtimetracking_auto_duration'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Always set billing duration to duration value.'),
|
||||
'#default_value' => variable_get('stormtimetracking_auto_duration', TRUE),
|
||||
'#description' => t('When checked, Storm will set the billing duration equal to the duration each time the node is saved. The duration is always calculated from the start and end times.'),
|
||||
'#size' => 5,
|
||||
);
|
||||
|
||||
$form['stormtimetracking_billable_default'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Default Value for billable field.'),
|
||||
'#default_value' => variable_get('stormtimetracking_billable_default', FALSE),
|
||||
'#description' => t('When checked, Storm will set the timetracking to billable by default'),
|
||||
'#size' => 5,
|
||||
);
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
// INVOICE AUTO ADD HANDLER
|
||||
function stormtimetracking_storminvoice_auto_add($node, $invoice_nid = NULL) {
|
||||
if (!module_exists('storminvoice')) {
|
||||
drupal_set_message(t('This function should only be called from within Storm Invoice'));
|
||||
return;
|
||||
}
|
||||
elseif ($node->billed) {
|
||||
drupal_set_message(t('This timetracking has already been billed!'));
|
||||
return;
|
||||
}
|
||||
elseif (!$node->billable) {
|
||||
drupal_set_message(t('This timetracking is marked unbillable!'));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
global $user;
|
||||
|
||||
if (!$invoice_nid) {
|
||||
|
||||
$new_invoice = new StdClass;
|
||||
|
||||
// Code copied with edits from node form
|
||||
$new_invoice->requestdate = time();
|
||||
$new_invoice->duedate = $new_invoice->requestdate + (variable_get('storminvoice_payment_days', 30) * 86400);
|
||||
$new_invoice->number = storminvoice_get_invoice_number($new_invoice->requestdate);
|
||||
|
||||
$new_invoice->title = $node->title;
|
||||
$new_invoice->uid = $user->uid;
|
||||
$new_invoice->type = 'storminvoice';
|
||||
// $new_invoice->reference
|
||||
$new_invoice->organization_nid = $node->organization_nid;
|
||||
$new_invoice->organization_title = $node->organization_title;
|
||||
$new_invoice->project_nid = $node->project_nid;
|
||||
$new_invoice->project_title = $node->project_title;
|
||||
// $new_invoice->amount
|
||||
// $new_invoice->tax
|
||||
// $new_invoice->total
|
||||
// $new_invoice->totalcustomercurr
|
||||
// $new_invoice->taxexempt
|
||||
$new_invoice->src_nid = $node->nid;
|
||||
$new_invoice->src_vid = $node->vid;
|
||||
|
||||
node_save($new_invoice);
|
||||
$invoice_nid = $new_invoice->nid;
|
||||
}
|
||||
else {
|
||||
$new_invoice = node_load($invoice_nid);
|
||||
}
|
||||
|
||||
$rate_array = array('pricemode_used' => '', 'rate_to_use' => 0);
|
||||
|
||||
$rate_array = storminvoice_get_rate($node);
|
||||
|
||||
$count = count($new_invoice->items);
|
||||
|
||||
$new_invoice->items[$count]->description = storminvoice_get_item_desc($rate_array, $node);
|
||||
|
||||
$new_invoice->items[$count]->amount = storminvoice_get_item_amount($rate_array, $node);
|
||||
|
||||
// Tax percent simply uses default at the moment
|
||||
$new_invoice->items[$count]->tax1percent = variable_get('storm_tax1_percent', 20);
|
||||
// $new_invoice_item->items[$count]->tax1
|
||||
// $new_invoice_item->items[$count]->total
|
||||
$new_invoice->items[$count]->src_nid = $node->nid;
|
||||
$new_invoice->items[$count]->src_vid = $node->vid;
|
||||
|
||||
storm_taxation($new_invoice->items[$count]);
|
||||
storminvoice_update($new_invoice);
|
||||
}
|
||||
|
||||
// Mark timetracking as billed.
|
||||
db_query("UPDATE {stormtimetracking} SET billed=%d WHERE vid=%d", 1, $node->vid);
|
||||
|
||||
return $invoice_nid;
|
||||
}
|
||||
|
||||
// VIEWS HANDLER
|
||||
function stormtimetracking_views_api() {
|
||||
return array(
|
||||
'api' => 2,
|
||||
'path' => drupal_get_path('module', 'stormtimetracking'),
|
||||
);
|
||||
}
|
||||
|
||||
function stormtimetracking_storm_dashboard_links($type) {
|
||||
$links = array();
|
||||
if ($type == 'page' || $type == 'block') {
|
||||
$links[] = array(
|
||||
'theme' => 'storm_dashboard_link',
|
||||
'title' => t('Timetrackings'),
|
||||
'icon' => 'stormtimetracking-item',
|
||||
'path' => 'timetrackings',
|
||||
'params' => array(),
|
||||
'access_arguments' => 'Storm timetracking: access',
|
||||
'node_type' => 'stormtimetracking',
|
||||
'add_type' => 'stormtimetracking',
|
||||
'map' => array(),
|
||||
'weight' => 8,
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
182
modules/storm/stormtimetracking/stormtimetracking.test
Normal file
182
modules/storm/stormtimetracking/stormtimetracking.test
Normal file
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test definitions for the SuiteDesk Timetracking module.
|
||||
*/
|
||||
class StormtimetrackingTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('SuiteDesk Timetracking Functionality'),
|
||||
'description' => t('Test the functionality of the SuiteDesk Timetracking module'),
|
||||
'group' => 'Storm',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp('storm', 'stormorganization', 'stormproject', 'stormtask', 'stormticket', 'stormtimetracking', 'stormperson');
|
||||
}
|
||||
|
||||
public function testStormtimetrackingCreate() {
|
||||
// Create and login user
|
||||
$user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm ticket: add', 'Storm ticket: view all', 'Storm timetracking: add', 'Storm timetracking: view all'));
|
||||
$this->drupalLogin($user);
|
||||
|
||||
// Create organization and invoice
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$prj = array(
|
||||
'title' => $this->randomName(32),
|
||||
'organization_nid' => '1',
|
||||
);
|
||||
$task = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$ticket = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$timetracking = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$this->drupalPost('node/add/stormproject', $prj, t('Save'));
|
||||
$this->drupalPost('node/add/stormtask', $task, t('Save'));
|
||||
$this->drupalPost('node/add/stormticket', $ticket, t('Save'));
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking, t('Save'));
|
||||
|
||||
$this->assertText(t('Timetracking @title has been created.', array('@title' => $timetracking['title'])));;
|
||||
}
|
||||
|
||||
public function testStormtimetrackingList() {
|
||||
// Create and login user
|
||||
$userAll = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view all', 'Storm timetracking: edit all', 'Storm timetracking: delete all', 'Storm person: add'));
|
||||
$userOrg = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view of user organization', 'Storm timetracking: edit of user organization', 'Storm timetracking: delete of user organization'));
|
||||
$userOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view own', 'Storm timetracking: edit own', 'Storm timetracking: delete own'));
|
||||
$userViewAllEditOwn = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm timetracking: access', 'Storm timetracking: add', 'Storm timetracking: view all', 'Storm timetracking: edit own', 'Storm timetracking: delete own'));
|
||||
|
||||
$this->drupalLogin($userAll);
|
||||
|
||||
// Create organization
|
||||
$org = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org, t('Save'));
|
||||
$org = node_load(array('title' => $org['title']));
|
||||
|
||||
// Create organization
|
||||
$org2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormorganization', $org2, t('Save'));
|
||||
$org2 = node_load(array('title' => $org2['title']));
|
||||
|
||||
// Create stormperson with organization to userOrg
|
||||
$personOrg = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
'user_name' => $userOrg->name,
|
||||
);
|
||||
$this->drupalPost('node/add/stormperson', $personOrg, t('Save'));
|
||||
|
||||
// Create timetrackings
|
||||
$timetracking1 = array(
|
||||
'organization_nid' => $org->nid,
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
);
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking1, t('Save'));
|
||||
$timetracking1 = node_load(array('title' => $timetracking1['title']));
|
||||
|
||||
$this->drupalLogin($userOwn);
|
||||
$timetracking2 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking2, t('Save'));
|
||||
$timetracking2 = node_load(array('title' => $timetracking2['title']));
|
||||
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$timetracking3 = array(
|
||||
'title' => $this->randomName(32),
|
||||
'body' => $this->randomName(64),
|
||||
'organization_nid' => $org2->nid,
|
||||
);
|
||||
$this->drupalPost('node/add/stormtimetracking', $timetracking3, t('Save'));
|
||||
$timetracking3 = node_load(array('title' => $timetracking3['title']));
|
||||
|
||||
// Test for 'Storm timetracking: view all'
|
||||
$this->drupalLogin($userAll);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertLink($timetracking1->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertLink($timetracking3->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
// Test for 'Storm timetracking: view of user organization'
|
||||
$this->drupalLogin($userOrg);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertLink($timetracking1->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($timetracking3->title, 'The Timetracking does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
// Test for 'Storm timetracking: view own'
|
||||
$this->drupalLogin($userOwn);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertNoLink($timetracking1->title, 'The Timetracking does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
$this->assertNoLink($timetracking3->title, 'The Timetracking does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
|
||||
// Test for 'Storm timetracking: view all', 'Storm timetracking: edit own'
|
||||
$this->drupalLogin($userViewAllEditOwn);
|
||||
$this->drupalGet('timetrackings');
|
||||
|
||||
$this->assertLink($timetracking1->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking1->nid .'/delete', 'The Timetracking edit icon does not appear on the list');
|
||||
|
||||
$this->assertLink($timetracking2->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking2->nid .'/edit', 'The Timetracking edit icon does not appear on the list');
|
||||
$this->assertNoRaw('node/'. $timetracking2->nid .'/delete', 'The Timetracking delete icon does not appear on the list');
|
||||
|
||||
$this->assertLink($timetracking3->title, 0, 'The Timetracking appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/edit', 'The Timetracking edit icon appears on the list');
|
||||
$this->assertRaw('node/'. $timetracking3->nid .'/delete', 'The Timetracking delete icon appears on the list');
|
||||
|
||||
}
|
||||
}
|
251
modules/storm/stormtimetracking/stormtimetracking.theme.inc
Normal file
251
modules/storm/stormtimetracking/stormtimetracking.theme.inc
Normal file
|
@ -0,0 +1,251 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
function theme_stormtimetracking_list($header, $timetrackings, $billing_duration) {
|
||||
$rows = array();
|
||||
foreach ($timetrackings as $timetracking) {
|
||||
$rows[] = array(
|
||||
'<span class="timetracking-title">' . l($timetracking->title, 'node/'. $timetracking->nid) . theme('mark', node_mark($timetracking->nid, $timetracking->changed)) . '</span><br />' .
|
||||
l($timetracking->organization_title, 'node/'. $timetracking->organization_nid) .
|
||||
(!empty($timetracking->project_title) ? ' » ' . l($timetracking->project_title, 'node/'. $timetracking->project_nid) : '' ) .
|
||||
(!empty($timetracking->task_title) ? '<br />' . l($timetracking->task_title, 'node/'. $timetracking->task_nid) . ' (' . t('task') . ')' : '' ) .
|
||||
(!empty($timetracking->ticket_title) ? '<br />' . l($timetracking->ticket_title, 'node/'. $timetracking->ticket_nid) . ' (' . t('ticket') . ')' : '' ),
|
||||
format_date($timetracking->trackingdate, 'small'),
|
||||
array('data' => stormtimetracking_duration($timetracking->billing_duration), 'align' => 'right'),
|
||||
array(
|
||||
'data' => storm_icon_edit_node($timetracking, $_GET) .' '. storm_icon_delete_node($timetracking, $_GET),
|
||||
'class' => 'storm_list_operations',
|
||||
),
|
||||
);
|
||||
}
|
||||
$o = theme('table', $header, $rows, array('id' => 'stormtimetrackings'));
|
||||
$o .= '<span style="font-weight: bold;">'. t('Total duration') .' : '. stormtimetracking_duration($billing_duration) .'</span>';
|
||||
return $o;
|
||||
}
|
||||
|
||||
function theme_stormtimetracking_view($node, $teaser = FALSE, $page = FALSE) {
|
||||
drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');
|
||||
|
||||
$node = node_prepare($node, $teaser);
|
||||
$l_pos = 1; // Used to increase the link position number (see issue 814820)
|
||||
|
||||
$node->content['links'] = array(
|
||||
'#prefix' => '<div class="stormlinks"><dl>',
|
||||
'#suffix' => '</dl></div>',
|
||||
'#weight' => -25,
|
||||
);
|
||||
|
||||
// Code to create invoice auto_add link
|
||||
if (module_exists('storminvoice')) {
|
||||
|
||||
$node->content['links']['auto_invoice'] = array(
|
||||
'#prefix' => variable_get('storm_icons_display', TRUE) ? '<dt id="storminvoice-item" class="stormcomponent">' : '<dt class="stormcomponent">',
|
||||
'#suffix' => '</dt>',
|
||||
'#value' => theme('storminvoice_autoadd_links', $node->nid, $node->billable, $node->billed),
|
||||
'#weight' => $l_pos++,
|
||||
);
|
||||
}
|
||||
|
||||
$node->content['group1'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
|
||||
);
|
||||
|
||||
$node->content['group1']['organization'] = array(
|
||||
'#prefix' => '<div class="organization">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Organization'), l($node->organization_title, 'node/'. $node->organization_nid)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
|
||||
$node->content['group1']['project'] = array(
|
||||
'#prefix' => '<div class="project">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Project'), l($node->project_title, 'node/'. $node->project_nid)),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group1']['task'] = array(
|
||||
'#prefix' => '<div class="task">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Task'), l($node->task_title, 'node/'. $node->task_nid)),
|
||||
'#weight' => 3,
|
||||
);
|
||||
|
||||
$node->content['group1']['ticket'] = array(
|
||||
'#prefix' => '<div class="ticket">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Ticket'), l($node->ticket_title, 'node/'. $node->ticket_nid)),
|
||||
'#weight' => 4,
|
||||
);
|
||||
|
||||
$node->content['group2'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -19,
|
||||
);
|
||||
|
||||
$node->content['group2']['trackingdate'] = array(
|
||||
'#prefix' => '<div class="trackingdate">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Date'), empty($node->trackingdate) ? '' : substr(format_date($node->trackingdate, 'small'), 0, 10)),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group3'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
|
||||
);
|
||||
|
||||
$node->content['group3']['duration'] = array(
|
||||
'#prefix' => '<div class="duration">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Duration'), stormtimetracking_duration($node->billing_duration)),
|
||||
'#weight' => 2,
|
||||
);
|
||||
|
||||
$node->content['group_item'] = array(
|
||||
'#prefix' => '<div class="stormfields">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group_item') : -20,
|
||||
);
|
||||
$node->content['group_item']['author'] = array(
|
||||
'#prefix' => '<div class="author">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Submitted by'), theme('username', $node)),
|
||||
'#weight' => 1,
|
||||
);
|
||||
$node->content['group_item']['created'] = array(
|
||||
'#prefix' => '<div class="created">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Created'), format_date($node->created, 'small')),
|
||||
'#weight' => 2,
|
||||
);
|
||||
if ($node->changed != $node->created) {
|
||||
$node->content['group_item']['modified'] = array(
|
||||
'#prefix' => '<div class="modified">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Modified'), format_date($node->changed, 'small')),
|
||||
'#weight' => 3,
|
||||
);
|
||||
}
|
||||
|
||||
$node->content['body_field'] = array(
|
||||
'#prefix' => '<div class="stormbody">',
|
||||
'#suffix' => '</div>',
|
||||
'#value' => theme('storm_view_item', t('Notes'), $node->content['body']['#value']),
|
||||
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'body_field') : 0,
|
||||
);
|
||||
|
||||
unset($node->content['body']);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
function theme_stormtimetracking_list_form_report_reports() {
|
||||
$reports = array(
|
||||
'std' => t('Standard'),
|
||||
'for_organization' => t('For an organization'),
|
||||
'for_organization_w_task' => t('For an org. with tasks'),
|
||||
'for_project' => t('For a project'),
|
||||
);
|
||||
|
||||
return $reports;
|
||||
}
|
||||
|
||||
function theme_stormtimetracking_list_report($report, $language, $timetrackings) {
|
||||
switch ($report) {
|
||||
case 'std':
|
||||
$header = array(
|
||||
t('Organization', array(), $language),
|
||||
t('Project', array(), $language),
|
||||
t('Title', array(), $language),
|
||||
t('Date', array(), $language),
|
||||
t('Billing duration (hours)', array(), $language));
|
||||
$total_billing_duration = 0;
|
||||
foreach ($timetrackings as $timetracking) {
|
||||
$rows[] = array(
|
||||
check_plain($timetracking->organization_title),
|
||||
check_plain($timetracking->project_title),
|
||||
check_plain($timetracking->title),
|
||||
format_date($timetracking->trackingdate, 'small'),
|
||||
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
|
||||
);
|
||||
$total_billing_duration += $timetracking->billing_duration;
|
||||
}
|
||||
$title = '<h2>'. t('Timetrackings report', array(), $language) .'</h2><br />';
|
||||
break;
|
||||
case 'for_organization':
|
||||
$organization = node_load($_SESSION['stormtimetracking_list_filter']['organization_nid']);
|
||||
$header = array(
|
||||
t('Project', array(), $language),
|
||||
t('Title', array(), $language),
|
||||
t('Date', array(), $language),
|
||||
t('Billing duration (hours)', array(), $language));
|
||||
$total_billing_duration = 0;
|
||||
foreach ($timetrackings as $timetracking) {
|
||||
$rows[] = array(
|
||||
check_plain($timetracking->project_title),
|
||||
check_plain($timetracking->title),
|
||||
format_date($timetracking->trackingdate, 'small'),
|
||||
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
|
||||
);
|
||||
$total_billing_duration += $timetracking->billing_duration;
|
||||
}
|
||||
$title = '<h2>'. t('Timetrackings report', array(), $language) .'</h2><br />';
|
||||
$title .= t('Organization : @organization', array('@organization' => $organization->fullname), $language) .'<br />';
|
||||
break;
|
||||
case 'for_organization_w_task':
|
||||
$organization = node_load($_SESSION['stormtimetracking_list_filter']['organization_nid']);
|
||||
$header = array(
|
||||
t('Project', array(), $language),
|
||||
t('Task', array(), $language),
|
||||
t('Title', array(), $language),
|
||||
t('Date', array(), $language),
|
||||
t('Billing duration (hours)', array(), $language));
|
||||
$total_billing_duration = 0;
|
||||
foreach ($timetrackings as $timetracking) {
|
||||
$rows[] = array(
|
||||
check_plain($timetracking->project_title),
|
||||
check_plain($timetracking->task_title),
|
||||
check_plain($timetracking->title),
|
||||
format_date($timetracking->trackingdate, 'small'),
|
||||
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
|
||||
);
|
||||
$total_billing_duration += $timetracking->billing_duration;
|
||||
}
|
||||
$title = '<h2>'. t('Timetrackings report', array(), $language) .'</h2><br />';
|
||||
$title .= t('Organization : @organization', array('@organization' => $organization->fullname), $language) .'<br />';
|
||||
break;
|
||||
case 'for_project':
|
||||
$organization = node_load($_SESSION['stormtimetracking_list_filter']['organization_nid']);
|
||||
$project = node_load($_SESSION['stormtimetracking_list_filter']['project_nid']);
|
||||
|
||||
$header = array(
|
||||
t('Task', array(), $language),
|
||||
t('Title', array(), $language),
|
||||
t('Date', array(), $language),
|
||||
t('Duration (hours)', array(), $language));
|
||||
$total_billing_duration = 0;
|
||||
foreach ($timetrackings as $timetracking) {
|
||||
$rows[] = array(
|
||||
check_plain($timetracking->task_title),
|
||||
check_plain($timetracking->title),
|
||||
format_date($timetracking->trackingdate, 'small'),
|
||||
array('data' => sprintf('%.2f', $timetracking->billing_duration), 'align' => 'right'),
|
||||
);
|
||||
$total_billing_duration += $timetracking->billing_duration;
|
||||
}
|
||||
$title = '<h2>'. t('Timetrackings report', array(), $language) .'</h2><br />';
|
||||
$title .= t('Organization : @organization', array('@organization' => $organization->fullname), $language) .'<br />';
|
||||
$title .= t('Project : @project', array('@project' => $project->title), $language) .'<br />';
|
||||
break;
|
||||
}
|
||||
$footer = '<h3>'. t('Total billing duration : %total_billing_duration', array('%total_billing_duration' => format_plural($total_billing_duration, '1 hour', '@count hours', array(), $language)), $language) .'</h3>';
|
||||
return theme('storm_list_report', $header, $rows, $title, $footer);
|
||||
}
|
279
modules/storm/stormtimetracking/stormtimetracking.views.inc
Normal file
279
modules/storm/stormtimetracking/stormtimetracking.views.inc
Normal file
|
@ -0,0 +1,279 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Functions to expose SuiteDesk Timetracking Module data to the Views module.
|
||||
*/
|
||||
function stormtimetracking_views_data() {
|
||||
$data['stormtimetracking']['table']['group'] = 'SuiteDesk Timetracking';
|
||||
$data['stormtimetracking']['table']['join'] = array(
|
||||
'node' => array(
|
||||
'left_field' => 'vid',
|
||||
'field' => 'vid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['organization_nid'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('Timetracking -> Organization'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Timetracking -> Organization'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['organization_title'] = array(
|
||||
'title' => t('Organization'),
|
||||
'help' => t('SuiteDesk Timetracking Organization (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['project_nid'] = array(
|
||||
'title' => t('Project'),
|
||||
'help' => t('Timetracking -> Project'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Timetracking -> Project'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['project_title'] = array(
|
||||
'title' => t('Project'),
|
||||
'help' => t('SuiteDesk Timetracking Project (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['task_nid'] = array(
|
||||
'title' => t('Task'),
|
||||
'help' => t('Timetracking -> Task'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Timetracking -> Task'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['task_stepno'] = array(
|
||||
'title' => t('Task step number'),
|
||||
'help' => t('SuiteDesk Timetracking Task Step Number'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['task_title'] = array(
|
||||
'title' => t('Task'),
|
||||
'help' => t('SuiteDesk Timetracking Task (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['ticket_nid'] = array(
|
||||
'title' => t('Ticket'),
|
||||
'help' => t('Timetracking -> Ticket'),
|
||||
'relationship' => array(
|
||||
'base' => 'node',
|
||||
'field' => 'nid',
|
||||
'handler' => 'views_handler_relationship',
|
||||
'label' => t('Timetracking -> Ticket'),
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['ticket_title'] = array(
|
||||
'title' => t('Ticket'),
|
||||
'help' => t('SuiteDesk Timetracking Ticket (title only)'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['trackingdate'] = array(
|
||||
'title' => t('Tracking date'),
|
||||
'help' => t('SuiteDesk Timetracking Tracking Date'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
'handler' => 'views_handler_field_date',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['timebegin'] = array(
|
||||
'title' => t('Time begin'),
|
||||
'help' => t('SuiteDesk Timetracking Time Begin'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['timeend'] = array(
|
||||
'title' => t('Time end'),
|
||||
'help' => t('SuiteDesk Timetracking Time End'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['duration'] = array(
|
||||
'title' => t('Duration'),
|
||||
'help' => t('SuiteDesk Timetracking Duration'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['billing_duration'] = array(
|
||||
'title' => t('Billing duration'),
|
||||
'help' => t('SuiteDesk Timetracking Billing Duration'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['billable'] = array(
|
||||
'title' => t('Billable'),
|
||||
'help' => t('SuiteDesk Timetracking Billable'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['billed'] = array(
|
||||
'title' => t('Billed'),
|
||||
'help' => t('SuiteDesk Timetracking Billed'),
|
||||
'field' => array(
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['stormtimetracking']['operation'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Edit/Delete link'),
|
||||
'help' => t('Provide a simple link to edit and delete the node.'),
|
||||
'handler' => 'storm_handler_field_operation',
|
||||
'type' => 'stormtimetracking',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function stormtimetracking_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
'handlers' => array(
|
||||
'storm_handler_filter_attributes_domain' => array(
|
||||
'parent' => 'views_handler_filter_in_operator',
|
||||
),
|
||||
'storm_handler_field_operation' => array(
|
||||
'parent' => 'views_handler_field_node_link',
|
||||
'path' => drupal_get_path('module', 'storm'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function stormtimetracking_date_api_fields($field) {
|
||||
$values = array(
|
||||
'sql_type' => DATE_UNIX,
|
||||
'tz_handling' => 'site',
|
||||
'timezone_field' => '',
|
||||
'offset_field' => '',
|
||||
'related_fields' => array(),
|
||||
'granularity' => array('year', 'month', 'day'),
|
||||
);
|
||||
|
||||
switch ($field) {
|
||||
case 'stormtimetracking.trackingdate':
|
||||
return $values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function stormtimetracking_date_api_tables() {
|
||||
return array('stormtimetracking');
|
||||
}
|
Reference in a new issue