diff --git a/pm.css b/pm.css
index 44f2331..6bc2c6d 100644
--- a/pm.css
+++ b/pm.css
@@ -31,37 +31,6 @@ text-align: right;
white-space: nowrap;
}
-div.pm_popup {
-display:none;
-z-index: 100;
-border: 1px solid black;
-background-color: #fff;
-}
-
-div.pm_popup_inner {
-text-align: center;
-}
-
-div.pm_popup_inner form div div.form-item {
-margin: 0;
-}
-
-div.pm_popup_inner form div input.form-submit {
-margin: 5px 0 0 0;
-}
-
-div.pm_popup_title {
-float: left;
-text-align: center;
-color: #fff;
-width: 100%;
-background-color: #5294C1;
-}
-
-div.pm_popup_inner {
-clear: both;
-}
-
div.pm_quick_shortcuts {
clear: both;
}
@@ -89,10 +58,6 @@ font-weight: bold;
color: #ffffff;
}
-form.pmcomponent_node_form #edit-preview {
- display: none;
-}
-
tr.formgroup {
background-color: #ffffff !important;
border: none !important;
diff --git a/pm.install b/pm.install
index 78ee8e0..493ed85 100644
--- a/pm.install
+++ b/pm.install
@@ -10,8 +10,6 @@
function pm_install() {
variable_set('pm_icons_path', drupal_get_path('module', 'pm') . '/icons');
variable_set('pm_organization_nid', 0);
- variable_set('pm_yearsrangebegin', 2001);
- variable_set('pm_yearsrangeend', 2015);
// Set up billing status field.
field_create_field(array(
@@ -25,6 +23,26 @@ function pm_install() {
),
),
));
+
+ // Set up date fields.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pm_date_range',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 'hour',
+ 'minute' => 'minute',
+ 'second' => 0,
+ ),
+ 'tz_handling' => 'none',
+ 'timezone_db' => '',
+ 'todate' => 'optional',
+ ),
+ 'cardinality' => '1',
+ ));
}
/**
@@ -33,8 +51,6 @@ function pm_install() {
function pm_uninstall() {
variable_del('pm_icons_path');
variable_del('pm_organization_nid');
- variable_del('pm_yearsrangebegin');
- variable_del('pm_yearsrangeend');
drupal_uninstall_schema('pm');
}
@@ -87,3 +103,32 @@ function pm_update_7101() {
),
));
}
+
+/**
+ * Make date field available to PM content types.
+ */
+function pm_update_7102() {
+
+ // Set up date fields.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pm_date_range',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 'hour',
+ 'minute' => 'minute',
+ 'second' => 0,
+ ),
+ 'tz_handling' => 'none',
+ 'timezone_db' => '',
+ 'todate' => 'optional',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ variable_del('pm_yearsrangebegin');
+ variable_del('pm_yearsrangeend');
+}
diff --git a/pm.module b/pm.module
index f4ab358..8862438 100644
--- a/pm.module
+++ b/pm.module
@@ -2,15 +2,6 @@
/**
* @file
* Main module file for the Project Management module.
- * Basic Project Management module provides a dashboard and some API functions.
- * 1: Hooks (help, perm, init, menu, theme)
- * 2: Dashboard
- * 3: Admin Settings
- * 4: Date / time manipulation
- * 5: Taxation functions
- * 6: Project Management Icons
- * 7: SQL Functions
- * 8: Node form theming
*/
/**
@@ -443,34 +434,6 @@ function pm_admin_settings() {
'#element_validate' => array('pm_admin_settings_icons_path_validate'),
);
- $form['yearsrange'] = array(
- '#type' => 'fieldset',
- '#title' => t('Years range in dates'),
- '#collapsed' => TRUE,
- '#collapsible' => TRUE,
- '#weight' => $w++,
- );
-
- $form['yearsrange']['group0'] = array(
- '#type' => 'markup',
- '#theme' => 'pm_form_group',
- '#weight' => $w++,
- );
-
- $form['yearsrange']['group0']['pm_yearsrangebegin'] = array(
- '#type' => 'select',
- '#title' => t('Begin'),
- '#options' => drupal_map_assoc(range(1970, 2037)),
- '#default_value' => variable_get('pm_yearsrangebegin', 2001),
- );
-
- $form['yearsrange']['group0']['pm_yearsrangeend'] = array(
- '#type' => 'select',
- '#title' => t('End'),
- '#options' => drupal_map_assoc(range(1970, 2037)),
- '#default_value' => variable_get('pm_yearsrangeend', 2015),
- );
-
$form['taxation'] = array(
'#type' => 'fieldset',
'#title' => t('Taxation defaults'),
@@ -672,357 +635,6 @@ function pm_admin_settings_form_submit($form, $form_state) {
}
/**
- * Implements hook_elements().
- */
-function pm_elements() {
- $type['datetime'] = array(
- '#input' => TRUE,
- '#process' => array('pm_datetime_expand'),
- '#element_validate' => array('pm_datetime_validate'),
- '#default_value' => array(
- 'day' => format_date(time(), 'custom', 'j'),
- 'month' => format_date(time(), 'custom', 'n'),
- 'year' => format_date(time(), 'custom', 'Y'),
- 'hour' => format_date(time(), 'custom', 'H'),
- 'minute' => format_date(time(), 'custom', 'i'),
- ),
- );
- $type['dateext'] = array(
- '#input' => TRUE,
- '#process' => array('pm_dateext_expand'),
- '#element_validate' => array('pm_dateext_validate'),
- '#default_value' => time(),
- '#withnull' => FALSE,
- '#disable_date_popup' => FALSE,
- );
- return $type;
-}
-
-/**
- * Expands a date into individual elements.
- */
-function pm_datetime_expand($element) {
- if (empty($element['#value'])) {
- $element['#value'] = array(
- 'day' => format_date(time(), 'custom', 'j'),
- 'month' => format_date(time(), 'custom', 'n'),
- 'year' => format_date(time(), 'custom', 'Y'),
- 'hour' => format_date(time(), 'custom', 'H'),
- 'minute' => format_date(time(), 'custom', 'i'),
- );
- }
-
- $element['#tree'] = TRUE;
-
- // Determine the order of day, month, year in the site's chosen date format.
- $format = variable_get('date_format_short', 'm/d/Y - H:i');
- $sort = array();
- $sort['day'] = max(strpos($format, 'd'), strpos($format, 'j'));
- $sort['month'] = max(strpos($format, 'm'), strpos($format, 'M'));
- $sort['year'] = strpos($format, 'Y');
- $sort['hour'] = strpos($format, 'H');
- $sort['minute'] = strpos($format, 'i');
- asort($sort);
- $order = array_keys($sort);
-
- // Output multi-selector for date.
- foreach ($order as $type) {
- switch ($type) {
- case 'year':
- $options = drupal_map_assoc(range(variable_get('pm_yearsrangebegin', 2001), variable_get('pm_yearsrangeend', 2012)));
- break;
- case 'month':
- $options = drupal_map_assoc(range(1, 12), 'map_month');
- break;
- case 'day':
- $options = drupal_map_assoc(range(1, 31));
- break;
- case 'hour':
- $options = drupal_map_assoc(range(0, 23));
- break;
- case 'minute':
- $options = drupal_map_assoc(range(0, 59));
- break;
- }
- $parents = $element['#parents'];
- $parents[] = $type;
- $element[$type] = array(
- '#type' => 'select',
- '#value' => $element['#value'][$type],
- '#attributes' => $element['#attributes'],
- '#options' => $options,
- );
- }
- return $element;
-}
-
-/**
- * Validate form date elements.
- */
-function pm_datetime_validate($form) {
- if (!checkdate($form['#value']['month'], $form['#value']['day'], $form['#value']['year'])) {
- form_error($form, t('The specified date is invalid.'));
- }
-}
-
-/**
- * Expand form date elements into day, month, and year.
- */
-function pm_dateext_expand($element, $edit, $form_state, $form) {
- if (empty($element['#value'])) {
- if (!$element['#withnull']) {
- $element['#value'] = array(
- 'day' => format_date(time(), 'custom', 'j'),
- 'month' => format_date(time(), 'custom', 'n'),
- 'year' => format_date(time(), 'custom', 'Y'),
- );
- }
- else {
- $element['#value'] = array('day' => -1, 'month' => -1, 'year' => -1);
- }
- }
-
- $element['#tree'] = TRUE;
-
- // If date popup exists, we should use date popup,
- // but you can force to disable it by set disable_date_popup to true
- if (module_exists('date_popup') && (!isset($element['disable_date_popup']) || !$element['disable_date_popup'])) {
-
- // value is timestamp
- if (is_numeric($element['#value']) && $element['#value'] != 0) {
- $element['#value'] = array('popup' => format_date($element['#value'], 'custom', 'Y-m-d'));
- }
- // value is date array
- elseif (is_array($element['#value']) && !isset($element['#value']['popup']) && $element['#value']['day'] != -1) {
- $element['#value'] = array('popup' => sprintf("%04d-%02d-%02d", $element['#value']['year'], $element['#value']['month'], $element['#value']['day']));
- }
- elseif (is_numeric($element['#value']) || !isset($element['#value']['popup']) || (isset($element['#value']['day']) && $element['#value']['day'] == -1)) {
- $element['#value'] = array('popup' => '');
- }
-
- if (is_array($element['#value']['popup']) && isset($element['#value']['popup']['date'])) {
- $value = $element['#value']['popup']['date'];
- }
- else {
- $value = $element['#value']['popup'];
- }
-
- $current_year = date('Y');
- $begin = variable_get('pm_yearsrangebegin', 2001) - $current_year;
- if ($begin > 0) {
- $begin = '+' . $begin;
- }
- $end = variable_get('pm_yearsrangeend', 2015) - $current_year;
- if ($end > 0) {
- $end = '+' . $end;
- }
-
- $parents = $element['#parents'];
- $parents[] = 'popup';
- $element['popup'] = array(
- '#type' => 'date_popup',
- '#date_timezone' => date_default_timezone_name(),
- '#date_format' => "Y-m-d",
- '#date_year_range' => $begin . ':' . $end,
- '#default_value' => $value,
- '#attributes' => $element['#attributes'],
- '#withnull' => $element['#withnull'],
- );
- }
- // fallback - use select boxes to choose the date
- else {
-
- // its a timestamp, convert it to a date format
- if (is_numeric($element['#value']) && $element['#value'] != 0) {
- $element['#value'] = _pm_gmtimestamp_to_date($element['#value']);
- }
-
- // Determine the order of day, month, year in the site's chosen date format.
- $format = variable_get('date_format_short', 'm/d/Y - H:i');
- $sort = array();
- $sort['day'] = max(strpos($format, 'd'), strpos($format, 'j'));
- $sort['month'] = max(strpos($format, 'm'), strpos($format, 'M'));
- $sort['year'] = strpos($format, 'Y');
- asort($sort);
- $order = array_keys($sort);
-
- // Output multi-selector for date.
- foreach ($order as $type) {
- switch ($type) {
- case 'year':
- $options = drupal_map_assoc(range(variable_get('pm_yearsrangebegin', 2001), variable_get('pm_yearsrangeend', 2012)));
- break;
- case 'month':
- $options = drupal_map_assoc(range(1, 12), 'map_month');
- break;
- case 'day':
- $options = drupal_map_assoc(range(1, 31));
- break;
- }
- if ($element['#withnull']) {
- $options = array('-1' => '-') + $options;
- }
-
- if (empty($element['#attributes'])) {
- $element['#attributes'] = array();
- }
-
- $parents = $element['#parents'];
- $parents[] = $type;
- $element[$type] = array(
- '#type' => 'select',
- '#value' => isset($element['#value'][$type]) ? $element['#value'][$type] : NULL,
- '#options' => $options,
- '#attributes' => array_merge(array('onchange' => "pm_datext_tonull(this, '" . $element['#id'] . "')"), $element['#attributes']),
- );
- }
- }
- return $element;
-}
-
-/**
- * Validation for the dateext form element.
- */
-function pm_dateext_validate($element, &$form_state) {
- // value is a string, convert it back to array
- if (is_array($element['#value']) && isset($element['#value']['popup'])) {
- if (!$element['#withnull'] && empty($element['#value']['popup']['date'])) {
- form_set_error($element, t('Field %field is required.', array('%field' => !empty($element['#title']) ? $element['#title'] : '')));
- }
- if (preg_match('/(\d{4})-(\d{2})-(\d{2})/', $element['#value']['popup']['date'], $matches)) {
- $element['#value'] = array();
- $element['#value']['day'] = (int) $matches[3];
- $element['#value']['month'] = (int) $matches[2];
- $element['#value']['year'] = (int) $matches[1];
- }
- else {
- if (!$element['#withnull'] && !empty($element['#value']['popup']['date'])) {
- form_set_error($element, t('Wrong Format for Field %field. Format should be YYYY-MM-DD.', array('%field' => !empty($element['#title']) ? $element['#title'] : '')));
- }
- $element['#value'] = array('day' => -1, 'month' => -1, 'year' => -1);
- }
- form_set_value($element, $element['#value'], $form_state);
- }
-
- if ($element['#value']['day'] == -1 && !$element['#withnull']) {
- form_set_error($element, t('Field %field is required.', array('%field' => !empty($element['#title']) ? $element['#title'] : '')));
- }
- if ($element['#value']['day'] != -1 && !checkdate($element['#value']['month'], $element['#value']['day'], $element['#value']['year'])) {
- form_error($element, t('The specified date is invalid.'));
- }
- return $element;
-}
-
-/**
- * Converts a local timestamp to GMT.
- */
-function _timestamp_to_gm($timestamp, $timezone=NULL) {
- if (!isset($timezone)) {
- global $user;
- if (variable_get('configurable_timezones', 1) && $user->uid && drupal_strlen($user->timezone)) {
- $timezone = $user->timezone;
- }
- else {
- $timezone = variable_get('date_default_timezone', 0);
- }
- }
- $timestamp -= $timezone;
- return $timestamp;
-}
-
-/**
- * Converts a date to a GMT timestamp.
- */
-function _pm_date_to_gmtimestamp($date, $timezone=NULL) {
- if ($date['month'] == -1 || $date['year'] == -1 || $date['day'] == -1) {
- return NULL;
- }
- else {
- $gmttimestamp = gmmktime(0, 0, 0, intval($date['month']), intval($date['day']), intval($date['year']));
- return _timestamp_to_gm($gmttimestamp, $timezone);
- }
-}
-
-/**
- * Converts a datetime to a GMT timestamp.
- */
-function _pm_datetime_to_gmtimestamp($datetime, $timezone=NULL) {
- $gmttimestamp = gmmktime(intval($datetime['hour']), intval($datetime['minute']), 0, intval($datetime['month']),
- intval($datetime['day']), intval($datetime['year']));
- return _timestamp_to_gm($gmttimestamp, $timezone);
-}
-
-/**
- * Converts a GMT timestamp to a datetime.
- */
-function _pm_gmtimestamp_to_datetime($timestamp, $timezone=NULL) {
- $datetime = array(
- 'day' => format_date($timestamp, 'custom', 'j', $timezone),
- 'month' => format_date($timestamp, 'custom', 'n', $timezone),
- 'year' => format_date($timestamp, 'custom', 'Y', $timezone),
- 'hour' => (int)format_date($timestamp, 'custom', 'H', $timezone),
- 'minute' => (int)format_date($timestamp, 'custom', 'i', $timezone),
- );
- return $datetime;
-}
-
-/**
- * Converts a GMT timestamp to a date.
- */
-function _pm_gmtimestamp_to_date($timestamp, $timezone=NULL) {
- if ($timestamp) {
- $date = array(
- 'day' => format_date($timestamp, 'custom', 'j', $timezone),
- 'month' => format_date($timestamp, 'custom', 'n', $timezone),
- 'year' => format_date($timestamp, 'custom', 'Y', $timezone),
- );
- }
- else {
- $date = array(
- 'day' => -1,
- 'month' => -1,
- 'year' => -1,
- );
- }
-
- return $date;
-}
-
-/**
- * Converts a GMT Timestamp to a timestamp showing date only.
- */
-function _pm_gmtimestamp_without_time($timestamp, $timezone=NULL) {
- $date = _pm_gmtimestamp_to_date($timestamp, $timezone);
- $gmttimestamp = gmmktime(0, 0, 0, $date['month'], $date['day'], $date['year']);
- return _timestamp_to_gm($gmttimestamp, $timezone);
-}
-
-/**
- * Converts a string to a time array.
- */
-function _pm_strtotime($timestr='') {
- $timestr = drupal_substr($timestr, 0, 5);
- $time = array();
- $time['hour'] = 0;
- $time['minute'] = 0;
-
- $ar = explode(':', $timestr);
- if (is_array($ar)) {
- if (array_key_exists(0, $ar)) $time['hour'] = $ar[0];
- if (array_key_exists(1, $ar)) $time['minute'] = $ar[1];
- }
- return $time;
-}
-
-/**
- * Converts a time array to a string.
- */
-function _timetostr($time=array()) {
- $timestr = str_pad($time['hour'], 2, "0", STR_PAD_LEFT) . ':' . str_pad($time['minute'], 2, "0", STR_PAD_RIGHT);
- return $timestr;
-}
-
-/**
* Calculates taxation for Project Management nodes
*/
function pm_taxation(&$node) {
diff --git a/pmexpense/pmexpense.install b/pmexpense/pmexpense.install
index 92eafe3..17e0844 100644
--- a/pmexpense/pmexpense.install
+++ b/pmexpense/pmexpense.install
@@ -11,6 +11,42 @@ function pmexpense_install() {
variable_set('node_options_pmexpense', array('status'));
variable_set('node_permissions_pmexpense', 0);
+ // Expense date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pmexpense_date',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pmexpense_date',
+ 'bundle' => 'pmexpense',
+ 'label' => 'Expense Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
$attributes = array();
$attributes['Expense status'] = array(
@@ -60,6 +96,9 @@ function pmexpense_disable() {
drupal_set_message(t('Nodes of type "Expense" have not been deleted on disabling Project Management Expense. Please note that they will now have reduced functionality, and will not be protected by Project Management Expense access controls.'), 'warning');
}
+/**
+ * Implements hook_uninstall().
+ */
function pmexpense_uninstall() {
drupal_uninstall_schema('pmexpense');
@@ -68,6 +107,9 @@ function pmexpense_uninstall() {
->execute();
}
+/**
+ * Implements hook_schema().
+ */
function pmexpense_schema() {
$schema['pmexpense'] = array(
'fields' => array(
@@ -84,7 +126,6 @@ function pmexpense_schema() {
'ticket_title' => array('type' => 'varchar', 'length' => 128),
'provider_nid' => array('type' => 'int'),
'provider_title' => array('type' => 'varchar', 'length' => 128),
- 'expensedate' => array('type' => 'int'),
'expensestatus' => array('type' => 'varchar', 'length' => 128),
'amount' => array('type' => 'float'),
'tax1app' => array('type' => 'int'),
@@ -112,6 +153,9 @@ function pmexpense_schema() {
return $schema;
}
+/**
+ * Implements hook_update_last_removed().
+ */
function pmexpense_update_last_removed() {
return 6202;
}
@@ -144,3 +188,62 @@ function pmexpense_update_7101() {
function pmexpense_update_7102() {
node_access_needs_rebuild(TRUE);
}
+
+/**
+ * Convert Expense Date field to Field API.
+ */
+function pmexpense_update_7103() {
+ // Expense date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pmexpense_date',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pmexpense_date',
+ 'bundle' => 'pmexpense',
+ 'label' => 'Expense Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
+ // Migrate data.
+ $query = db_select('pmexpense', 'pmex');
+ $query->join('node', 'n', 'n.vid = pmex.vid');
+ $result = $query
+ ->fields('pmex', array('nid', 'vid', 'expensedate'))
+ ->execute();
+
+ foreach ($result as $record) {
+ $node = node_load($record->nid);
+
+ $node->pmexpense_date[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->expensedate);
+ field_attach_presave('node', $node);
+ field_attach_update('node', $node);
+ }
+
+ // Delete columns from existing database table.
+ db_drop_field('pmexpense', 'expensedate');
+}
diff --git a/pmexpense/pmexpense.module b/pmexpense/pmexpense.module
index 6f4abf3..647e9ea 100644
--- a/pmexpense/pmexpense.module
+++ b/pmexpense/pmexpense.module
@@ -1,7 +1,7 @@
-20,
),
'group2' => array(
- 'label' => 'Date/Provider Group',
- 'weight' => -19,
+ 'label' => 'Provider Group',
+ 'weight' => -18,
),
'group3' => array(
'label' => 'Amount',
- 'weight' => -18,
+ 'weight' => -17,
),
'group4' => array(
'label' => 'Tax Group',
- 'weight' => -17,
+ 'weight' => -16,
),
'group5' => array(
'label' => 'Billable / Billed Group',
- 'weight' => -16,
+ 'weight' => -15,
),
),
);
@@ -254,8 +254,6 @@ function pmexpense_form($node, $form_state) {
drupal_set_breadcrumb($breadcrumb);
if (arg(1) == 'add') {
- $node->expensedate = time();
-
if (array_key_exists('organization_nid', $_GET) && !$node->organization_nid) {
$node->organization_nid = $_GET['organization_nid'];
}
@@ -470,12 +468,6 @@ function pmexpense_form($node, $form_state) {
'#weight' => $info['group2']['weight'],
);
- $form['group2']['expensedate'] = array(
- '#type' => 'dateext',
- '#title' => t('Date'),
- '#default_value' => isset($node->expensedate) ? $node->expensedate : time(),
- );
-
$form['group2']['provider_title'] = array(
'#type' => 'textfield',
'#title' => t('Provider'),
@@ -620,7 +612,6 @@ function pmexpense_insert($node) {
'ticket_title' => (isset($node->ticket_title)) ? $node->ticket_title : NULL,
'provider_nid' => (isset($node->provider_nid)) ? $node->provider_nid : NULL,
'provider_title' => $node->provider_title,
- 'expensedate' => $node->expensedate,
'amount' => $node->amount,
'tax1app' => $node->tax1app,
'tax1percent' => $node->tax1percent,
@@ -658,7 +649,6 @@ function pmexpense_update($node) {
'ticket_title' => (isset($node->ticket_title)) ? $node->ticket_title : NULL,
'provider_nid' => (isset($node->provider_nid)) ? $node->provider_nid : NULL,
'provider_title' => $node->provider_title,
- 'expensedate' => $node->expensedate,
'amount' => $node->amount,
'tax1app' => $node->tax1app,
'tax1percent' => $node->tax1percent,
@@ -687,13 +677,6 @@ function _pmexpense_beforesave(&$node) {
$node->tax1percent = str_replace(',', '.', $node->tax1percent);
$node->tax2percent = str_replace(',', '.', $node->tax2percent);
- if (!!is_numeric($node->expensedate) && is_array($node->expensedate)) {
- $node->expensedate = _pm_date_to_gmtimestamp($node->expensedate);
- }
- elseif (!is_numeric($node->expensedate) && is_string($node->expensedate)) {
- $node->expensedate = strtotime($node->expensedate);
- }
-
pm_taxation($node);
$org_query = db_select('node', 'n');
diff --git a/pmexpense/pmexpense.theme.inc b/pmexpense/pmexpense.theme.inc
index eb1864b..e6a3a91 100644
--- a/pmexpense/pmexpense.theme.inc
+++ b/pmexpense/pmexpense.theme.inc
@@ -1,7 +1,7 @@
content['links'] = array(
'#prefix' => '
',
@@ -43,7 +42,7 @@ function theme_pmexpense_view($variables) {
}
$node->content['group1'] = array(
- '#prefix' => '',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
);
@@ -77,18 +76,11 @@ function theme_pmexpense_view($variables) {
);
$node->content['group2'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
);
- $node->content['group2']['expensedate'] = array(
- '#prefix' => '
',
- '#suffix' => '
',
- '#markup' => theme('pm_view_item', array('label' => t('Date'), 'value' => format_date($node->expensedate, 'custom', 'Y-m-d'))),
- '#weight' => 1,
- );
-
$node->content['group2']['provider'] = array(
'#prefix' => '
',
'#suffix' => '
',
@@ -97,7 +89,7 @@ function theme_pmexpense_view($variables) {
);
$node->content['group3'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
);
@@ -110,7 +102,7 @@ function theme_pmexpense_view($variables) {
);
$node->content['group4'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group4') : -17,
);
diff --git a/pmexpense/pmexpense.views.inc b/pmexpense/pmexpense.views.inc
index 849dc93..155322d 100644
--- a/pmexpense/pmexpense.views.inc
+++ b/pmexpense/pmexpense.views.inc
@@ -169,21 +169,6 @@ function pmexpense_views_data() {
),
);
- $data['pmexpense']['expensedate'] = array(
- 'title' => t('Date'),
- 'help' => t('Project Management Expense 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['pmexpense']['amount'] = array(
'title' => t('Amount'),
'help' => t('Project Management Expense Amount'),
diff --git a/pminvoice/pminvoice.install b/pminvoice/pminvoice.install
index 2941c8f..c838bf1 100644
--- a/pminvoice/pminvoice.install
+++ b/pminvoice/pminvoice.install
@@ -10,6 +10,114 @@ function pminvoice_install() {
variable_set('node_options_pminvoice', array('status'));
variable_set('node_options_pminvoiceitem', array('status'));
variable_set('node_permissions_pminvoice', 0);
+
+ // Request date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pminvoice_requestdate',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pminvoice_requestdate',
+ 'bundle' => 'pminvoice',
+ 'label' => 'Request Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
+ // Due date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pminvoice_duedate',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pminvoice_duedate',
+ 'bundle' => 'pminvoice',
+ 'label' => 'Due Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-17',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
+ // Payment date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pminvoice_paymentdate',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pminvoice_paymentdate',
+ 'bundle' => 'pminvoice',
+ 'label' => 'Payment Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-16',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
}
/**
@@ -48,9 +156,6 @@ function pminvoice_schema() {
'organization_title' => array('type' => 'varchar', 'length' => 128),
'project_nid' => array('type' => 'int'),
'project_title' => array('type' => 'varchar', 'length' => 128),
- 'requestdate' => array('type' => 'int'),
- 'duedate' => array('type' => 'int'),
- 'paymentdate' => array('type' => 'int'),
'amount' => array('type' => 'numeric', 'precision' => 19, 'scale' => 4),
'tax1' => array('type' => 'numeric', 'precision' => 19, 'scale' => 4),
'tax2' => array('type' => 'numeric', 'precision' => 19, 'scale' => 4),
@@ -176,3 +281,138 @@ function pminvoice_update_7102() {
'scale' => 4,
));
}
+
+/**
+ * Convert request date, due date and payment date to Field API.
+ */
+function pminvoice_update_7103() {
+ // Request date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pminvoice_requestdate',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pminvoice_requestdate',
+ 'bundle' => 'pminvoice',
+ 'label' => 'Request Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
+ // Due date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pminvoice_duedate',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pminvoice_duedate',
+ 'bundle' => 'pminvoice',
+ 'label' => 'Due Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-17',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
+ // Payment date field.
+ field_create_field(array(
+ 'type' => 'datetime',
+ 'field_name' => 'pminvoice_paymentdate',
+ 'settings' => array(
+ 'granularity' => array(
+ 'year' => 'year',
+ 'month' => 'month',
+ 'day' => 'day',
+ 'hour' => 0,
+ 'minute' => 0,
+ 'second' => 0,
+ ),
+ 'tz_handling' => '',
+ 'timezone_db' => '',
+ 'todate' => '',
+ ),
+ 'cardinality' => '1',
+ ));
+
+ field_create_instance(array(
+ 'field_name' => 'pminvoice_paymentdate',
+ 'bundle' => 'pminvoice',
+ 'label' => 'Payment Date',
+ 'required' => 1,
+ 'entity_type' => 'node',
+ 'widget' => array(
+ 'weight' => '-16',
+ 'type' => 'date_text',
+ 'active' => 1,
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ ),
+ ));
+
+ // Migrate data
+ $query = db_select('pminvoice', 'pmin');
+ $query->join('node', 'n', 'n.vid = pmin.vid');
+ $result = $query
+ ->fields('pmin', array('nid', 'vid', 'requestdate', 'duedate', 'paymentdate'))
+ ->execute();
+
+ foreach ($result as $record) {
+ $node = node_load($record->nid);
+
+ $node->pminvoice_requestdate[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->requestdate);
+ $node->pminvoice_duedate[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->duedate);
+ $node->pminvoice_paymentdate[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->paymentdate);
+ field_attach_presave('node', $node);
+ field_attach_update('node', $node);
+ }
+
+ // Delete columns from existing database table.
+ db_drop_field('pminvoice', 'requestdate');
+ db_drop_field('pminvoice', 'duedate');
+ db_drop_field('pminvoice', 'paymentdate');
+}
diff --git a/pminvoice/pminvoice.module b/pminvoice/pminvoice.module
index bca1a46..0856633 100644
--- a/pminvoice/pminvoice.module
+++ b/pminvoice/pminvoice.module
@@ -1,5 +1,4 @@
'Organization/Project/Reference Group',
'weight' => -19,
),
- 'group3' => array(
- 'label' => 'Date Group',
- 'weight' => -18,
- ),
'group4' => array(
'label' => 'Invoice Items',
- 'weight' => -16,
+ 'weight' => -15,
),
'group5' => array(
'label' => 'Price Group',
- 'weight' => -15,
+ 'weight' => -14,
),
),
);
@@ -247,10 +242,7 @@ function pminvoice_form(&$node, $form_state) {
drupal_set_breadcrumb($breadcrumb);
if (arg(1)=='add') {
- $node->requestdate = time();
- $node->duedate = $node->requestdate + (variable_get('pminvoice_payment_days', 30) * 86400);
- $node->number = pminvoice_get_invoice_number($node->requestdate);
- $node->paymentdate = NULL;
+ $node->number = pminvoice_get_invoice_number();
if (array_key_exists('organization_nid', $_GET) && !$node->organization_nid) {
$node->organization_nid = $_GET['organization_nid'];
@@ -374,33 +366,6 @@ function pminvoice_form(&$node, $form_state) {
'#size' => 40,
);
- $form['group3'] = array(
- '#type' => 'markup',
- '#theme' => 'pm_form_group',
- '#weight' => $info['group3']['weight'],
- );
-
- $form['group3']['requestdate'] = array(
- '#type' => 'dateext',
- '#withnull' => 'true',
- '#title' => t('Request date'),
- '#default_value' => $node->requestdate,
- );
-
- $form['group3']['duedate'] = array(
- '#type' => 'dateext',
- '#withnull' => 'true',
- '#title' => t('Due date'),
- '#default_value' => $node->duedate,
- );
-
- $form['group3']['paymentdate'] = array(
- '#type' => 'dateext',
- '#withnull' => 'true',
- '#title' => t('Payment date'),
- '#default_value' => $node->paymentdate,
- );
-
$form['group4'] = array(
'#type' => 'markup',
'#weight' => $info['group4']['weight'],
@@ -610,9 +575,6 @@ function pminvoice_insert($node) {
'organization_title' => $node->organization_title,
'project_nid' => $node->project_nid,
'project_title' => $node->project_title,
- 'requestdate' => $node->requestdate,
- 'duedate' => $node->duedate,
- 'paymentdate' => $node->paymentdate,
'taxexempt' => $node->taxexempt,
'src_nid' => $node->src_nid,
'src_vid' => $node->src_vid,
@@ -648,9 +610,6 @@ function pminvoice_update($node) {
'tax2' => $node->tax2,
'total' => $node->total,
'totalcustomercurr' => $node->totalcustomercurr,
- 'requestdate' => $node->requestdate,
- 'duedate' => $node->duedate,
- 'paymentdate' => $node->paymentdate,
'taxexempt' => $node->taxexempt,
'src_nid' => $node->src_nid,
'src_vid' => $node->src_vid,
@@ -680,10 +639,6 @@ function _pminvoice_beforesave(&$node) {
$node->total = floatval(str_replace(',', '.', $node->total));
$node->totalcustomercurr = floatval(str_replace(',', '.', $node->totalcustomercurr));
- if (is_array($node->requestdate)) $node->requestdate = _pm_date_to_gmtimestamp($node->requestdate);
- if (is_array($node->duedate)) $node->duedate = _pm_date_to_gmtimestamp($node->duedate);
- if (is_array($node->paymentdate)) $node->paymentdate = _pm_date_to_gmtimestamp($node->paymentdate);
-
$org_result = db_select('node', 'n')
->fields('n', array('title'))
->condition('n.type', 'pmorganization')
@@ -876,19 +831,11 @@ function pminvoice_view($node, $view_mode) {
}
/**
- * Admin settings form for pmproject module
+ * Admin settings form for pminvoice module
*/
function pminvoice_admin_settings() {
$form = array();
- $form['pminvoice_payment_days'] = array(
- '#type' => 'textfield',
- '#title' => t('Number of days for invoice payment'),
- '#default_value' => variable_get('pminvoice_payment_days', 30),
- '#description' => t('Default number of days for invoice payment'),
- '#size' => 5,
- );
-
$form['pminvoice_hours_per_day'] = array(
'#type' => 'textfield',
'#title' => t('Number of hours in a day'),
@@ -927,14 +874,6 @@ function pminvoice_admin_settings() {
'#size' => 50,
);
- $form['pminvoice_tcpdf_location'] = array(
- '#type' => 'textfield',
- '#title' => t('Location of tcpdf library'),
- '#default_value' => variable_get('pminvoice_tcpdf_location', t('sites/all/libraries/tcpdf')),
- '#description' => t('The directory that contains the !link (sites/all/libraries/tcpdf is recommended).', array('!link' => l(t('TCPDF library'), 'http://sourceforge.net/projects/tcpdf/files/'))),
- '#size' => 50,
- );
-
return system_settings_form($form);
}
@@ -968,8 +907,8 @@ function pminvoice_getitems($invoice_vid) {
* @return
* varchar text value of the calculated invoice number
*/
-function pminvoice_get_invoice_number($requestdate) {
- $date = getdate($requestdate);
+function pminvoice_get_invoice_number() {
+ $date = getdate();
$result = db_select('pminvoice', 'sin')
->fields('sin', array('number'))
@@ -1177,9 +1116,6 @@ function pminvoice_token_list($type='all') {
$tokens['node']['pminvoice-organization-title'] = t('Project Management Invoice: Organization Title.');
$tokens['node']['pminvoice-project-nid'] = t('Project Management Invoice: Project Node ID.');
$tokens['node']['pminvoice-project-title'] = t('Project Management Invoice: Project Title.');
- $tokens['node']['pminvoice-requestdate'] = t('Project Management Invoice: Request Date.');
- $tokens['node']['pminvoice-duedate'] = t('Project Management Invoice: Due Date.');
- $tokens['node']['pminvoice-paymentdate'] = t('Project Management Invoice: Payment Date.');
$tokens['node']['pminvoice-amount'] = t('Project Management Invoice: Amount.');
$tokens['node']['pminvoice-total'] = t('Project Management Invoice: Total.');
$tokens['node']['pminvoice-totalcustomer'] = t('Project Management Invoice: Total in customer currency.');
@@ -1207,9 +1143,6 @@ function pminvoice_token_values($type, $object = NULL) {
$values['pminvoice-organization-title'] = $node->organization_title;
$values['pminvoice-project-nid'] = $node->project_nid;
$values['pminvoice-project-title'] = $node->project_title;
- $values['pminvoice-requestdate'] = format_date($node->requestdate, 'medium', '', variable_get('date_default_timezone', NULL));
- $values['pminvoice-payment'] = format_date($node->paymentdate, 'medium', '', variable_get('date_default_timezone', NULL));
- $values['pminvoice-duedate'] = format_date($node->duedate, 'medium', '', variable_get('date_default_timezone', NULL));
$values['pminvoice-amount'] = $node->amount;
$values['pminvoice-total'] = $node->total;
$values['pminvoice-totalcustomer'] = $node->totalcustomer;
diff --git a/pminvoice/pminvoice.theme.inc b/pminvoice/pminvoice.theme.inc
index 9ca4dcf..92a3a9f 100644
--- a/pminvoice/pminvoice.theme.inc
+++ b/pminvoice/pminvoice.theme.inc
@@ -1,7 +1,7 @@
content['group1'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
);
@@ -39,7 +34,7 @@ function theme_pminvoice_view($variables) {
);
$node->content['group2'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
);
@@ -68,39 +63,16 @@ function theme_pminvoice_view($variables) {
}
$node->content['group3'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group3') : -18,
);
- $node->content['group3']['requestdate'] = array(
- '#prefix' => '
',
- '#suffix' => '
',
- '#markup' => theme('pm_view_item', array('label' => t('Request date'), 'value' => format_date($node->requestdate, 'custom', 'Y-m-d'))),
- '#weight' => 1,
- );
-
- $node->content['group3']['duedate'] = array(
- '#prefix' => '
',
- '#suffix' => '
',
- '#markup' => theme('pm_view_item', array('label' => t('Due date'), 'value' => format_date($node->duedate, 'custom', 'Y-m-d'))),
- '#weight' => 2,
- );
-
- if ($node->paymentdate) {
- $node->content['group3']['paymentdate'] = array(
- '#prefix' => '
',
- '#suffix' => '
',
- '#markup' => theme('pm_view_item', array('label' => t('Payment date'), 'value' => format_date($node->paymentdate, 'custom', 'Y-m-d'))),
- '#weight' => 3,
- );
- }
-
$status = 'open';
- if ($node->paymentdate) {
+ if ($node->pminvoice_paymentdate[LANGUAGE_NONE][0]['value']) {
$status = 'paid';
}
- elseif ($node->duedate < time()) {
+ elseif ($node->pminvoice_duedate[LANGUAGE_NONE][0]['value'] < time()) {
$status = 'overdue';
}
$node->content['group3']['status'] = array(
@@ -176,14 +148,14 @@ function theme_pminvoice_view($variables) {
}
$node->content['group4'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#markup' => theme('table', $header, $invoice_items),
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group4') : -17,
);
$node->content['group5'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group5') : -16,
);
diff --git a/pminvoice/pminvoice.views.inc b/pminvoice/pminvoice.views.inc
index e746775..78ef155 100644
--- a/pminvoice/pminvoice.views.inc
+++ b/pminvoice/pminvoice.views.inc
@@ -107,51 +107,6 @@ function pminvoice_views_data() {
),
);
- $data['pminvoice']['requestdate'] = array(
- 'title' => t('Request date'),
- 'help' => t('Project Management Invoice Request 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['pminvoice']['duedate'] = array(
- 'title' => t('Due date'),
- 'help' => t('Project Management Invoice Due 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['pminvoice']['paymentdate'] = array(
- 'title' => t('Payment date'),
- 'help' => t('Project Management Invoice Payment 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['pminvoice']['amount'] = array(
'title' => t('Amount'),
'help' => t('Project Management Invoice Amount'),
@@ -444,31 +399,3 @@ function pminvoice_views_handlers() {
);
}
-/**
- * Implements hook_date_api_fields().
- */
-function pminvoice_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 'pminvoice.paymentdate':
- case 'pminvoice.duedate':
- case 'pminvoice.requestdate':
- return $values;
- }
-
-}
-
-/**
- * Implements hook_date_api_tables().
- */
-function pminvoice_date_api_tables() {
- return array('pminvoice');
-}
diff --git a/pmproject/pmproject.install b/pmproject/pmproject.install
index 57529cb..c1f6061 100644
--- a/pmproject/pmproject.install
+++ b/pmproject/pmproject.install
@@ -18,6 +18,57 @@ function pmproject_install() {
$types = node_type_get_types();
node_add_body_field($types['pmproject'], 'Description');
+ // Add instance of date range field.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmproject',
+ ));
+
$attributes = array();
$attributes['Project status'] = array(
@@ -128,8 +179,6 @@ function pmproject_schema() {
'pricemode' => array('type' => 'varchar', 'length' => 100),
'price' => array('type' => 'float'),
'currency' => array('type' => 'varchar', 'length' => 100),
- 'datebegin' => array('type' => 'int', 'default' => 0),
- 'dateend' => array('type' => 'int', 'default' => 0),
'durationunit' => array('type' => 'varchar', 'length' => 100),
'duration' => array('type' => 'float', 'default' => 0),
'manager_nid' => array('type' => 'int'),
@@ -159,6 +208,18 @@ function pmproject_update_last_removed() {
}
/**
+ * Implements hook_update_dependencies().
+ */
+function pmproject_update_dependencies() {
+ // Ensure that billing status field is created before instance.
+ $dependencies['pmproject'][7103] = array(
+ 'pm' => 7102,
+ );
+
+ return $dependencies;
+}
+
+/**
* Adds Drupal 7 style body field to pm project node
*/
function pmproject_update_7100() {
@@ -185,3 +246,79 @@ function pmproject_update_7101() {
function pmproject_update_7102() {
node_access_needs_rebuild(TRUE);
}
+
+/**
+ * Add date range field to PM Project.
+ */
+function pmproject_update_7103() {
+ // Create field instance.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmproject',
+ ));
+
+ // Migrate data
+ $query = db_select('pmproject', 'pmpr');
+ $query->join('node', 'n', 'n.vid = pmpr.vid');
+ $result = $query
+ ->fields('pmpr', array('nid', 'vid', 'datebegin', 'dateend'))
+ ->execute();
+
+ foreach ($result as $record) {
+ $node = node_load($record->nid);
+
+ $node->pm_date_range[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->datebegin);
+ $node->pm_date_range[LANGUAGE_NONE][0]['value2'] = date('Y-m-d H:i:s', $record->dateend);
+ field_attach_presave('node', $node);
+ field_attach_update('node', $node);
+ }
+
+ // Delete columns from existing database table.
+ db_drop_field('pmproject', 'datebegin');
+ db_drop_field('pmproject', 'dateend');
+}
diff --git a/pmproject/pmproject.module b/pmproject/pmproject.module
index b9a24c1..1c6e081 100644
--- a/pmproject/pmproject.module
+++ b/pmproject/pmproject.module
@@ -1,5 +1,4 @@
-19,
),
'group3' => array(
- 'label' => 'Date/Duration Group',
- 'weight' => -18,
+ 'label' => 'Duration Group',
+ 'weight' => -17,
),
'group4' => array(
'label' => 'Price Group',
- 'weight' => -17,
+ 'weight' => -16,
),
'group5' => array(
'label' => 'Manager / Assigned to Group',
- 'weight' => -16,
+ 'weight' => -15,
),
'group6' => array(
'label' => 'Billable / Billed Group',
- 'weight' => -15,
+ 'weight' => -14,
),
),
);
@@ -246,10 +245,7 @@ function pmproject_form(&$node) {
drupal_set_breadcrumb($breadcrumb);
if (arg(1)=='add') {
- $node->datebegin = time();
- $node->dateend = time();
-
- if (array_key_exists('organization_nid', $_GET) && !$node->organization) {
+ if (array_key_exists('organization_nid', $_GET) && !isset($node->organization_nid)) {
$node->organization_nid = $_GET['organization_nid'];
}
if (isset($_SESSION['pmproject_list_filter']['organization_nid']) && !$node->organization_nid) {
@@ -355,20 +351,6 @@ function pmproject_form(&$node) {
'#weight' => $info['group3']['weight'],
);
- $form['group3']['datebegin'] = array(
- '#type' => 'dateext',
- '#title' => t('Date begin'),
- '#withnull' => TRUE,
- '#default_value' => $node->datebegin,
- );
-
- $form['group3']['dateend'] = array(
- '#type' => 'dateext',
- '#title' => t('Date end'),
- '#withnull' => TRUE,
- '#default_value' => $node->dateend,
- );
-
$durationunit_list = pm_attributes_bydomain('Duration unit');
$form['group3']['durationunit'] = array(
'#type' => 'select',
@@ -551,8 +533,6 @@ function pmproject_insert($node) {
'pricemode' => $node->pricemode,
'price' => $node->price,
'currency' => $node->currency,
- // 'datebegin' => $node->datebegin,
- // 'dateend' => $node->dateend,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'manager_nid' => $node->manager_nid,
@@ -617,8 +597,6 @@ function pmproject_update($node) {
'pricemode' => $node->pricemode,
'price' => $node->price,
'currency' => $node->currency,
- // 'datebegin' => $node->datebegin,
- // 'dateend' => $node->dateend,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'manager_nid' => $node->manager_nid,
@@ -650,20 +628,6 @@ function _pmproject_beforesave(&$node) {
if (!is_numeric($node->price)) {
$node->price = 0;
}
-
- if (is_array($node->datebegin)) {
- $node->datebegin = _pm_date_to_gmtimestamp($node->datebegin);
- }
- elseif (is_string($node->datebegin)) {
- $node->datebegin = strtotime($node->datebegin);
- }
-
- if (is_array($node->dateend)) {
- $node->dateend = _pm_date_to_gmtimestamp($node->dateend);
- }
- elseif (is_string($node->dateend)) {
- $node->dateend = strtotime($node->dateend);
- }
}
/**
@@ -858,8 +822,6 @@ function pmproject_token_list($type='all') {
$tokens['node']['pmproject-projectpriority'] = t('Project Management Project: Project Priority.');
$tokens['node']['pmproject-durationunit'] = t('Project Management Project: Project Duration Unit.');
$tokens['node']['pmproject-duration'] = t('Project Management Project: Project Duration.');
- $tokens['node']['pmproject-datebegin'] = t('Project Management Project: Project Begin Date.');
- $tokens['node']['pmproject-dateend'] = t('Project Management Project: Project End Date.');
$tokens['node']['pmproject-billable'] = t('Project Management Project: Project Billable.');
$tokens['node']['pmproject-billed'] = t('Project Management Project: Project Billed.');
$tokens['node']['pmproject-price'] = t('Project Management Project: Project Price.');
@@ -895,8 +857,6 @@ function pmproject_token_values($type, $object = NULL) {
$values['pmproject-projectcategory'] = $node->projectcategory;
$values['pmproject-durationunit'] = $node->durationunit;
$values['pmproject-duration'] = $node->duration;
- $values['pmproject-datebegin'] = format_date($node->datebegin, 'medium', '', variable_get('date_default_timezone', NULL));
- $values['pmproject-dateend'] = format_date($node->dateend, 'medium', '', variable_get('date_default_timezone', NULL));
$values['pmproject-price'] = $node->price;
$values['pmproject-pricemode'] = $node->pricemode;
$values['pmproject-billable'] = $node->billable;
diff --git a/pmproject/pmproject.theme.inc b/pmproject/pmproject.theme.inc
index 7c80598..8a25cc3 100644
--- a/pmproject/pmproject.theme.inc
+++ b/pmproject/pmproject.theme.inc
@@ -1,43 +1,15 @@
$project) {
- $rows[] = array(
- pm_icon('projectcategory_' . $project->projectcategory, pm_attribute_value('Project category', $project->projectcategory)),
- l($project->organization_title, 'node/' . $project->organization_nid),
- l($project->title, 'node/' . $project->nid) . theme('mark', array('type' => node_mark($project->nid, $project->changed))),
- pm_icon('status_' . $project->projectstatus, pm_attribute_value('Project status', $project->projectstatus)),
- pm_icon('priority_' . $project->projectpriority, pm_attribute_value('Project priority', $project->projectpriority)),
- array(
- 'data' => pm_icon_edit_node($project, $_GET) . ' ' . pm_icon_delete_node($project, $_GET),
- 'class' => 'pm_list_operations',
- ),
- );
- }
- return theme('table', array('header' => $header, 'rows' => $rows));
-}
-
-/**
* Provides HTML markup for a pmproject node view.
*/
function theme_pmproject_view($variables) {
$node = $variables['node'];
- drupal_add_css(drupal_get_path('module', 'pm') . '/pm-node.css');
-
$l_pos = 1; // Used to increase the link position number (see issue 814820)
$node->content['links'] = array(
@@ -64,9 +36,8 @@ function theme_pmproject_view($variables) {
);
}
-
$node->content['group1'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
);
@@ -79,7 +50,7 @@ function theme_pmproject_view($variables) {
);
$node->content['group2'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
);
@@ -106,7 +77,7 @@ function theme_pmproject_view($variables) {
);
$node->content['group5'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group5') : -16,
);
diff --git a/pmproject/pmproject.views.inc b/pmproject/pmproject.views.inc
index e933088..e1fc126 100644
--- a/pmproject/pmproject.views.inc
+++ b/pmproject/pmproject.views.inc
@@ -149,36 +149,6 @@ function pmproject_views_data() {
),
);
- $data['pmproject']['datebegin'] = array(
- 'title' => t('Date begin'),
- 'help' => t('Project Management Project Date Begin'),
- '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['pmproject']['dateend'] = array(
- 'title' => t('Date end'),
- 'help' => t('Project Management Project Date End'),
- '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['pmproject']['duration unit'] = array(
'title' => t('Duration unit'),
'help' => t('Project Management Project Duration Unit'),
@@ -331,37 +301,3 @@ function pmproject_views_handlers() {
),
);
}
-
-
-/**
- * Implements hook_date_api_fields().
- *
- * All modules that create custom fields that use the
- * 'views_handler_field_date' handler can provide
- * additional information here about the type of
- * date they create so the date can be used by
- * the Date API views date argument and date filter.
- */
-function pmproject_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', 'hour', 'minute', 'second'),
- );
-
- switch ($field) {
- case 'pmproject.datebegin':
- case 'pmproject.dateend':
- return $values;
- }
-}
-
-/**
- * Implement hook_date_api_tables().
- */
-function pmproject_date_api_tables() {
- return array('pmproject');
-}
diff --git a/pmtask/pmtask.install b/pmtask/pmtask.install
index 3d7b69f..007b018 100644
--- a/pmtask/pmtask.install
+++ b/pmtask/pmtask.install
@@ -18,6 +18,57 @@ function pmtask_install() {
$types = node_type_get_types();
node_add_body_field($types['pmtask'], 'Description');
+ // Add instance of date range field.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmtask',
+ ));
+
$attributes = array();
$attributes['Task status'] = array(
@@ -139,8 +190,6 @@ function pmtask_schema() {
'pricemode' => array('type' => 'varchar', 'length' => 100),
'price' => array('type' => 'float'),
'currency' => array('type' => 'varchar', 'length' => 100),
- 'datebegin' => array('type' => 'int', 'default' => 0),
- 'dateend' => array('type' => 'int', 'default' => 0),
'durationunit' => array('type' => 'varchar', 'length' => 100),
'duration' => array('type' => 'float', 'default' => 0),
'assigned_nid' => array('type' => 'int'),
@@ -169,6 +218,18 @@ function pmtask_update_last_removed() {
}
/**
+ * Implements hook_update_dependencies().
+ */
+function pmtask_update_dependencies() {
+ // Ensure that billing status field is created before instance.
+ $dependencies['pmtask'][7103] = array(
+ 'pm' => 7102,
+ );
+
+ return $dependencies;
+}
+
+/**
* Adds Drupal 7 style body field to Project Management Task nodes
*/
function pmtask_update_7100() {
@@ -198,3 +259,79 @@ function pmtask_update_7101() {
function pmtask_update_7102() {
node_access_needs_rebuild(TRUE);
}
+
+/**
+ * Add date range field to PM Task.
+ */
+function pmtask_update_7103() {
+ // Create field instance.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmtask',
+ ));
+
+ // Migrate data
+ $query = db_select('pmtask', 'pmta');
+ $query->join('node', 'n', 'n.vid = pmta.vid');
+ $result = $query
+ ->fields('pmta', array('nid', 'vid', 'datebegin', 'dateend'))
+ ->execute();
+
+ foreach ($result as $record) {
+ $node = node_load($record->nid);
+
+ $node->pm_date_range[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->datebegin);
+ $node->pm_date_range[LANGUAGE_NONE][0]['value2'] = date('Y-m-d H:i:s', $record->dateend);
+ field_attach_presave('node', $node);
+ field_attach_update('node', $node);
+ }
+
+ // Delete columns from existing database table.
+ db_drop_field('pmtask', 'datebegin');
+ db_drop_field('pmtask', 'dateend');
+}
diff --git a/pmtask/pmtask.module b/pmtask/pmtask.module
index 832a284..41618ca 100644
--- a/pmtask/pmtask.module
+++ b/pmtask/pmtask.module
@@ -175,20 +175,20 @@ function pmtask_field_extra_fields() {
'weight' => -18,
),
'group3' => array(
- 'label' => 'Date/Duration Group',
- 'weight' => -17,
+ 'label' => 'Duration Group',
+ 'weight' => -16,
),
'group4' => array(
'label' => 'Price Group',
- 'weight' => -16,
+ 'weight' => -15,
),
'group5' => array(
'label' => 'Assigned to',
- 'weight' => -15,
+ 'weight' => -14,
),
'group6' => array(
'label' => 'Billable / Billed Group',
- 'weight' => -14,
+ 'weight' => -13,
),
),
);
@@ -436,20 +436,6 @@ function pmtask_form(&$node, $form_state) {
'#weight' => $info['group3']['weight'],
);
- $form['group3']['datebegin'] = array(
- '#type' => 'dateext',
- '#title' => t('Date begin'),
- '#withnull' => TRUE,
- '#default_value' => isset($node->datebegin) ? $node->datebegin : time(),
- );
-
- $form['group3']['dateend'] = array(
- '#type' => 'dateext',
- '#title' => t('Date end'),
- '#withnull' => TRUE,
- '#default_value' => isset($node->dateend) ? $node->dateend : time(),
- );
-
$durationunit_list = pm_attributes_bydomain('Duration unit');
$form['group3']['durationunit'] = array(
'#type' => 'select',
@@ -577,8 +563,6 @@ function pmtask_insert($node) {
'project_title' => $node->project_title,
'parent_nid' => $node->parent_nid,
'weight' => $node->weight,
-// 'datebegin' => $node->datebegin,
-// 'dateend' => $node->dateend,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'pricemode' => $node->pricemode,
@@ -640,8 +624,6 @@ function pmtask_update($node) {
'project_title' => $node->project_title,
'parent_nid' => $node->parent_nid,
'weight' => $node->weight,
-// 'datebegin' => $node->datebegin,
-// 'dateend' => $node->dateend,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'pricemode' => $node->pricemode,
@@ -694,20 +676,6 @@ function _pmtask_beforesave(&$node) {
// Allow use of comma when inputting numerical values - str_replace with period decimal
$node->duration = floatval(str_replace(',', '.', $node->duration));
$node->price = floatval(str_replace(',', '.', $node->price));
-
- if (is_array($node->datebegin)) {
- $node->datebegin = _pm_date_to_gmtimestamp($node->datebegin);
- }
- else {
- $node->datebegin = strtotime($node->datebegin);
- }
-
- if (is_array($node->dateend)) {
- $node->dateend = _pm_date_to_gmtimestamp($node->dateend);
- }
- else {
- $node->dateend = strtotime($node->dateend);
- }
}
/**
@@ -977,8 +945,6 @@ function pmtask_token_list($type='all') {
$tokens['node']['pmtask-taskpriority'] = t('Project Management Task: Task Priority.');
$tokens['node']['pmtask-durationunit'] = t('Project Management Task: Task Duration Unit.');
$tokens['node']['pmtask-duration'] = t('Project Management Task: Task Duration.');
- $tokens['node']['pmtask-datebegin'] = t('Project Management Task: Task Begin Date.');
- $tokens['node']['pmtask-dateend'] = t('Project Management Task: Task End Date.');
$tokens['node']['pmtask-billable'] = t('Project Management Task: Task Billable.');
$tokens['node']['pmtask-billed'] = t('Project Management Task: Task Billed.');
$tokens['node']['pmtask-price'] = t('Project Management Task: Task Price.');
@@ -1010,8 +976,6 @@ function pmtask_token_values($type, $object = NULL) {
$values['pmtask-taskcategory'] = $node->taskcategory;
$values['pmtask-durationunit'] = $node->durationunit;
$values['pmtask-duration'] = $node->duration;
- $values['pmtask-datebegin'] = format_date($node->datebegin, 'medium', '', variable_get('date_default_timezone', NULL));
- $values['pmtask-dateend'] = format_date($node->dateend, 'medium', '', variable_get('date_default_timezone', NULL));
$values['pmtask-price'] = $node->price;
$values['pmtask-pricemode'] = $node->pricemode;
$values['pmtask-billable'] = $node->billable;
diff --git a/pmtask/pmtask.theme.inc b/pmtask/pmtask.theme.inc
index f79f1a8..dca1575 100644
--- a/pmtask/pmtask.theme.inc
+++ b/pmtask/pmtask.theme.inc
@@ -1,8 +1,7 @@
content['links'] = array(
@@ -38,7 +35,7 @@ function theme_pmtask_view($variables) {
}
$node->content['group1'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
);
@@ -65,7 +62,7 @@ function theme_pmtask_view($variables) {
);
$node->content['group2'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
);
@@ -92,7 +89,7 @@ function theme_pmtask_view($variables) {
);
$node->content['group5'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group5') : -16,
);
diff --git a/pmtask/pmtask.views.inc b/pmtask/pmtask.views.inc
index 239fbc0..da37ccf 100644
--- a/pmtask/pmtask.views.inc
+++ b/pmtask/pmtask.views.inc
@@ -222,36 +222,6 @@ function pmtask_views_data() {
),
);
- $data['pmtask']['datebegin'] = array(
- 'title' => t('Date begin'),
- 'help' => t('Project Management Task Date Begin'),
- '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['pmtask']['dateend'] = array(
- 'title' => t('Date end'),
- 'help' => t('Project Management Task Date End'),
- '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['pmtask']['durationunit'] = array(
'title' => t('Duration unit'),
'help' => t('Project Management Task Duration Unit'),
@@ -376,31 +346,3 @@ function pmtask_views_handlers() {
),
);
}
-
-/**
- * Implements hook_date_api_fields().
- */
-function pmtask_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', 'hour', 'minute', 'second'),
- );
-
- switch ($field) {
- case 'pmtask.datebegin':
- case 'pmtask.dateend':
- return $values;
- }
-
-}
-
-/**
- * Implement hook_date_api_tables().
- */
-function pmtask_date_api_tables() {
- return array('pmtask');
-}
diff --git a/pmticket/pmticket.install b/pmticket/pmticket.install
index 48a1be8..48823e6 100644
--- a/pmticket/pmticket.install
+++ b/pmticket/pmticket.install
@@ -18,6 +18,57 @@ function pmticket_install() {
$types = node_type_get_types();
node_add_body_field($types['pmticket'], 'Description');
+ // Add instance of date range field.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmticket',
+ ));
+
$attributes = array();
$attributes['Ticket status'] = array(
@@ -136,8 +187,6 @@ function pmticket_schema() {
'pricemode' => array('type' => 'varchar', 'length' => 100),
'price' => array('type' => 'float'),
'currency' => array('type' => 'varchar', 'length' => 100),
- 'datebegin' => array('type' => 'int', 'default' => 0),
- 'dateend' => array('type' => 'int', 'default' => 0),
'durationunit' => array('type' => 'varchar', 'length' => 100),
'duration' => array('type' => 'float', 'default' => 0),
'assigned_nid' => array('type' => 'int'),
@@ -166,6 +215,18 @@ function pmticket_update_last_removed() {
}
/**
+ * Implements hook_update_dependencies().
+ */
+function pmticket_update_dependencies() {
+ // Ensure that billing status field is created before instance.
+ $dependencies['pmticket'][7103] = array(
+ 'pm' => 7102,
+ );
+
+ return $dependencies;
+}
+
+/**
* Adds Drupal 7 style body field to Project Management Ticket nodes
*/
function pmticket_update_7100() {
@@ -193,3 +254,79 @@ function pmticket_update_7101() {
function pmticket_update_7102() {
node_access_needs_rebuild(TRUE);
}
+
+/**
+ * Add date range field to PM Ticket.
+ */
+function pmticket_update_7103() {
+ // Create field instance.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmticket',
+ ));
+
+ // Migrate data
+ $query = db_select('pmticket', 'pmti');
+ $query->join('node', 'n', 'n.vid = pmti.vid');
+ $result = $query
+ ->fields('pmti', array('nid', 'vid', 'datebegin', 'dateend'))
+ ->execute();
+
+ foreach ($result as $record) {
+ $node = node_load($record->nid);
+
+ $node->pm_date_range[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $record->datebegin);
+ $node->pm_date_range[LANGUAGE_NONE][0]['value2'] = date('Y-m-d H:i:s', $record->dateend);
+ field_attach_presave('node', $node);
+ field_attach_update('node', $node);
+ }
+
+ // Delete columns from existing database table.
+ db_drop_field('pmticket', 'datebegin');
+ db_drop_field('pmticket', 'dateend');
+}
diff --git a/pmticket/pmticket.module b/pmticket/pmticket.module
index e387bc4..1ee8eec 100644
--- a/pmticket/pmticket.module
+++ b/pmticket/pmticket.module
@@ -1,5 +1,4 @@
-19,
),
'group3' => array(
- 'label' => 'Date/Duration Group',
- 'weight' => -17,
+ 'label' => 'Duration Group',
+ 'weight' => -16,
),
'group4' => array(
'label' => 'Price Group',
- 'weight' => -16,
+ 'weight' => -15,
),
'group5' => array(
'label' => 'Assigned to',
- 'weight' => -15,
+ 'weight' => -14,
),
'group6' => array(
'label' => 'Billable / Billed Group',
- 'weight' => -14,
+ 'weight' => -13,
),
)
);
@@ -432,20 +431,6 @@ function pmticket_form(&$node, $form_state) {
'#weight' => $info['group3']['weight'],
);
- $form['group3']['datebegin'] = array(
- '#type' => 'dateext',
- '#title' => t('Date begin'),
- '#withnull' => TRUE,
- '#default_value' => isset($node->datebegin) ? $node->datebegin : NULL,
- );
-
- $form['group3']['dateend'] = array(
- '#type' => 'dateext',
- '#title' => t('Date end'),
- '#withnull' => TRUE,
- '#default_value' => isset($node->dateend) ? $node->dateend : NULL,
- );
-
$durationunits = pm_attributes_bydomain('Duration unit');
$form['group3']['durationunit'] = array(
'#type' => 'select',
@@ -567,8 +552,6 @@ function pmticket_insert($node) {
'ticketcategory' => $node->ticketcategory,
'ticketstatus' => $node->ticketstatus,
'ticketpriority' => $node->ticketpriority,
- // 'datebegin' => $node->datebegin,
- // 'dateend' => $node->dateend,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'pricemode' => $node->pricemode,
@@ -648,8 +631,6 @@ function pmticket_update($node) {
'ticketcategory' => $node->ticketcategory,
'ticketstatus' => $node->ticketstatus,
'ticketpriority' => $node->ticketpriority,
- // 'datebegin' => $node->datebegin,
- // 'dateend' => $node->dateend,
'durationunit' => $node->durationunit,
'duration' => $node->duration,
'pricemode' => $node->pricemode,
@@ -906,8 +887,6 @@ function pmticket_token_list($type='all') {
$tokens['node']['pmticket-ticketpriority'] = t('Project Management Ticket: Ticket Priority.');
$tokens['node']['pmticket-durationunit'] = t('Project Management Ticket: Ticket Duration Unit.');
$tokens['node']['pmticket-duration'] = t('Project Management Ticket: Ticket Duration.');
- $tokens['node']['pmticket-datebegin'] = t('Project Management Ticket: Ticket Begin Date.');
- $tokens['node']['pmticket-dateend'] = t('Project Management Ticket: Ticket End Date.');
$tokens['node']['pmticket-billable'] = t('Project Management Ticket: Ticket Billable.');
$tokens['node']['pmticket-billed'] = t('Project Management Ticket: Ticket Billed.');
$tokens['node']['pmticket-price'] = t('Project Management Ticket: Ticket Price.');
@@ -937,8 +916,6 @@ function pmticket_token_values($type, $object = NULL) {
$values['pmticket-ticketcategory'] = $node->ticketcategory;
$values['pmticket-durationunit'] = $node->durationunit;
$values['pmticket-duration'] = $node->duration;
- $values['pmticket-datebegin'] = format_date($node->datebegin, 'medium', '', variable_get('date_default_timezone', NULL));
- $values['pmticket-dateend'] = format_date($node->dateend, 'medium', '', variable_get('date_default_timezone', NULL));
$values['pmticket-price'] = $node->price;
$values['pmticket-pricemode'] = $node->pricemode;
$values['pmticket-billable'] = $node->billable;
diff --git a/pmticket/pmticket.theme.inc b/pmticket/pmticket.theme.inc
index 0a9bac7..813d214 100644
--- a/pmticket/pmticket.theme.inc
+++ b/pmticket/pmticket.theme.inc
@@ -1,49 +1,15 @@
nid = $ticket->nid;
- $n->uid = $ticket->uid;
- $n->organization_nid = $ticket->organization_nid;
- $n->type = 'pmticket';
-
- $rows[] = array(
- pm_icon('category_' . $ticket->ticketcategory, pm_attribute_value('Ticket category', $ticket->ticketcategory)),
- l($ticket->organization_title, 'node/' . $ticket->organization_nid),
- l($ticket->project_title, 'node/' . $ticket->project_nid),
- l($ticket->title, 'node/' . $ticket->nid) . theme('mark', array('type' => node_mark($ticket->nid, $ticket->changed))),
- format_date($ticket->created, 'small'),
- pm_icon('status_' . $ticket->ticketstatus, pm_attribute_value('Ticket status', $ticket->ticketstatus)),
- pm_icon('priority_' . $ticket->ticketpriority, pm_attribute_value('Ticket priority', $ticket->ticketpriority)),
- array(
- 'data' => pm_icon_edit_node($n, $_GET) . ' ' . pm_icon_delete_node($n, $_GET),
-// 'class' => 'pm_list_operations',
- ),
- );
- }
- return theme('table', array('header' => $header, 'rows' => $rows));
-}
-
-/**
* Provides HTML markup for a pmticket node view.
*/
function theme_pmticket_view($variables) {
$node = $variables['node'];
- drupal_add_css(drupal_get_path('module', 'pm') . '/pm-node.css');
-
$node->content['links'] = array(
'#prefix' => '
',
@@ -65,7 +31,7 @@ function theme_pmticket_view($variables) {
}
$node->content['group1'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group1') : -20,
);
@@ -92,7 +58,7 @@ function theme_pmticket_view($variables) {
);
$node->content['group2'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -19,
);
@@ -119,7 +85,7 @@ function theme_pmticket_view($variables) {
);
$node->content['group5'] = array(
- '#prefix' => '
',
+ '#prefix' => '
',
'#suffix' => '
',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group2') : -16,
);
diff --git a/pmticket/pmticket.views.inc b/pmticket/pmticket.views.inc
index 1c94c74..726d03e 100644
--- a/pmticket/pmticket.views.inc
+++ b/pmticket/pmticket.views.inc
@@ -154,21 +154,6 @@ function pmticket_views_data() {
),
);
- $data['pmticket']['datebegin'] = array(
- 'title' => t('Date begin'),
- 'help' => t('Project Management Ticket begin 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['pmticket']['dateend'] = array(
'title' => t('Date end'),
'help' => t('Project Management Ticket end date'),
@@ -305,31 +290,3 @@ function pmticket_views_handlers() {
),
);
}
-
-/**
- * Implements hook_date_api_fields().
- */
-function pmticket_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', 'hour', 'minute', 'second'),
- );
-
- switch ($field) {
- case 'pmticket.datebegin':
- case 'pmticket.dateend':
- return $values;
- }
-
-}
-
-/**
- * Implements hook_date_api_tables().
- */
-function pmticket_date_api_tables() {
- return array('pmticket');
-}
diff --git a/pmtimetracking/pmtimetracking.install b/pmtimetracking/pmtimetracking.install
index 2cf3c9f..fb103a5 100644
--- a/pmtimetracking/pmtimetracking.install
+++ b/pmtimetracking/pmtimetracking.install
@@ -14,6 +14,57 @@ function pmtimetracking_install() {
// Uncache node types
node_types_rebuild();
+ // Add instance of date range field.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmtimetracking',
+ ));
+
// Set up instance of billing status field.
field_create_instance(array(
'field_name' => 'pm_billing_status',
@@ -82,9 +133,6 @@ function pmtimetracking_schema() {
'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'),
),
@@ -95,7 +143,6 @@ function pmtimetracking_schema() {
'project_nid' => array('project_nid'),
'task_nid' => array('task_nid'),
'ticket_nid' => array('ticket_nid'),
- 'trackingdate' => array('trackingdate'),
),
);
@@ -118,6 +165,11 @@ function pmtimetracking_update_dependencies() {
'pm' => 7101,
);
+ // Ensure that date range field is created before instance.
+ $dependencies['pmtimetracking'][7105] = array(
+ 'pm' => 7102,
+ );
+
return $dependencies;
}
@@ -204,3 +256,83 @@ function pmtimetracking_update_7104() {
db_drop_field('pmtimetracking', 'billable');
db_drop_field('pmtimetracking', 'billed');
}
+
+/**
+ * Add date range field to PM Timetracking.
+ */
+function pmtimetracking_update_7105() {
+ // Create field instance.
+ field_create_instance(array(
+ 'field_name' => 'pm_date_range',
+ 'label' => 'Date Range',
+ 'widget' => array(
+ 'weight' => '-18',
+ 'type' => 'date_text',
+ 'module' => 'date',
+ 'active' => 1,
+ 'settings' => array(
+ 'input_format' => 'm/d/Y - H:i:s',
+ 'input_format_custom' => '',
+ 'year_range' => '-3:+3',
+ 'increment' => 15,
+ 'label_position' => 'above',
+ 'text_parts' => array(),
+ ),
+ ),
+ 'settings' => array(
+ 'default_value' => 'now',
+ 'default_value_code' => '',
+ 'default_value2' => 'same',
+ 'default_value_code2' => '',
+ 'user_register_form' => FALSE,
+ ),
+ 'display' => array(
+ 'default' => array(
+ 'label' => 'above',
+ 'type' => 'date_default',
+ 'settings' => array(
+ 'format_type' => 'long',
+ 'multiple_number' => '',
+ 'multiple_from' => '',
+ 'multiple_to' => '',
+ 'fromto' => 'both',
+ ),
+ 'module' => 'date',
+ 'weight' => 1,
+ ),
+ 'teaser' => array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ ),
+ ),
+ 'required' => 0,
+ 'entity_type' => 'node',
+ 'bundle' => 'pmtimetracking',
+ ));
+
+ // Migrate data
+ $query = db_select('pmtimetracking', 'pmtt');
+ $query->join('node', 'n', 'n.vid = pmtt.vid');
+ $result = $query
+ ->fields('pmtt', array('nid', 'vid', 'trackingdate', 'timebegin', 'timeend'))
+ ->execute();
+
+ foreach ($result as $record) {
+ $node = node_load($record->nid);
+
+ $datebegin = $record->trackingdate + strtotime($record->timebegin);
+ $dateend = $record->trackingdate + strtotime($record->timeend);
+
+ $node->pm_date_range[LANGUAGE_NONE][0]['value'] = date('Y-m-d H:i:s', $datebegin);
+ $node->pm_date_range[LANGUAGE_NONE][0]['value2'] = date('Y-m-d H:i:s', $dateend);
+ field_attach_presave('node', $node);
+ field_attach_update('node', $node);
+ }
+
+ // Delete columns from existing database table.
+ db_drop_field('pmtimetracking', 'trackingdate');
+ db_drop_field('pmtimetracking', 'timebegin');
+ db_drop_field('pmtimetracking', 'timeend');
+}
diff --git a/pmtimetracking/pmtimetracking.module b/pmtimetracking/pmtimetracking.module
index 14df62d..530f931 100644
--- a/pmtimetracking/pmtimetracking.module
+++ b/pmtimetracking/pmtimetracking.module
@@ -143,12 +143,8 @@ function pmtimetracking_field_extra_fields() {
'label' => 'Organization/Project/Task/Ticket Group',
'weight' => -20,
),
- 'group2' => array(
- 'label' => 'Date',
- 'weight' => -19,
- ),
'group3' => array(
- 'label' => 'Time / Duration Group',
+ 'label' => 'Duration Group',
'weight' => -18,
),
),
@@ -342,28 +338,6 @@ function pmtimetracking_form(&$node, $form_state) {
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'];
- // @todo This line of code causes timezone issues, which needs to be fixed as part of the move to Fields API.
- $node->trackingdate = time();
-
- $today = _pm_gmtimestamp_without_time(time());
-
- $query = db_select('node', 'n');
- $query->leftJoin('pmtimetracking', 'pmtt', 'n.nid = pmtt.nid');
- $query->condition('pmtt.trackingdate', time() - (60 * 60 * 24), '>=')
- ->condition('pmtt.trackingdate', time() , '<=')
- ->condition('n.uid', $node->uid , '=')
- ->addExpression('MAX(pmtt.timeend)', 'lastTimeEndToday');
- $query->addTag('node_access');
- $val = $query->execute();
- $timebegin = $val->fetchObject();
- $node->timebegin = $timebegin->lastTimeEndToday;
- $node->timeend = format_date(time(), 'custom', 'H:i');
-
- $timebegin = _pm_strtotime($node->timebegin);
- $timeend = _pm_strtotime($node->timeend);
- if ($timeend['hour'] && $timebegin['hour']) {
- $node->duration = ($timeend['hour'] - $timebegin['hour'] + ($timeend['minute'] - $timebegin['minute']) / 60);
- }
$node->billable = variable_get('pmtimetracking_billable_default', FALSE);
}
@@ -493,42 +467,12 @@ function pmtimetracking_form(&$node, $form_state) {
'#suffix' => '
',
);
- $form['group2'] = array(
- '#type' => 'markup',
- '#theme' => 'pm_form_group',
- '#weight' => $info['group2']['weight'],
- );
-
- $form['group2']['trackingdate'] = array(
- '#type' => 'dateext',
- '#title' => t('Date'),
- '#default_value' => $node->trackingdate,
- );
-
$form['group3'] = array(
'#type' => 'markup',
'#theme' => 'pm_form_group',
'#weight' => $info['group3']['weight'],
);
- $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,
- );
-
$duration = isset($node->duration) ? sprintf("%01.2f", $node->duration) : sprintf("%01.2f", 0);
$form['group3']['duration'] = array(
'#type' => 'textfield',
@@ -598,9 +542,6 @@ function pmtimetracking_insert($node) {
'task_stepno' => $node->task_stepno,
'ticket_nid' => $node->ticket_nid,
'ticket_title' => $node->ticket_title,
- 'trackingdate' => $node->trackingdate,
- 'timebegin' => $node->timebegin,
- 'timeend' => $node->timeend,
'duration' => $node->duration,
'billing_duration' => $node->billing_duration,
))
@@ -631,9 +572,6 @@ function pmtimetracking_update($node) {
'task_stepno' => $node->task_stepno,
'ticket_nid' => $node->ticket_nid,
'ticket_title' => $node->ticket_title,
- 'trackingdate' => $node->trackingdate,
- 'timebegin' => $node->timebegin,
- 'timeend' => $node->timeend,
'duration' => $node->duration,
'billing_duration' => $node->billing_duration,
'billable' => $node->billable,
@@ -648,20 +586,12 @@ function pmtimetracking_update($node) {
* Prepares pmtimetracking nodes for save operations.
*/
function _pmtimetracking_beforesave(&$node) {
- $timebegin = _pm_strtotime($node->timebegin);
- $timeend = _pm_strtotime($node->timeend);
-
- if (is_array($node->trackingdate)) {
- $node->trackingdate = _pm_datetime_to_gmtimestamp($node->trackingdate + $timebegin);
- }
-
- $node->timebegin = _timetostr($timebegin);
- $node->timeend = _timetostr($timeend);
-
+ // @todo Autoset duration field.
+ /*
$node->duration = ($timeend['hour'] - $timebegin['hour'] + ($timeend['minute'] - $timebegin['minute']) / 60);
if ($node->timeend < $node->timebegin) {
$node->duration += 24;
- }
+ }*/
if (variable_get('pmtimetracking_auto_duration', TRUE)) {
$node->billing_duration = $node->duration;
diff --git a/pmtimetracking/pmtimetracking.theme.inc b/pmtimetracking/pmtimetracking.theme.inc
index 6d319d3..5be2384 100644
--- a/pmtimetracking/pmtimetracking.theme.inc
+++ b/pmtimetracking/pmtimetracking.theme.inc
@@ -10,25 +10,6 @@
function theme_pmtimetracking_view($variables) {
$node = $variables['node'];
- $l_pos = 1; // Used to increase the link position number (see issue 814820)
-
- $node->content['links'] = array(
- '#prefix' => '
',
- '#weight' => -25,
- );
-
- // Code to create invoice auto_add link
- if (module_exists('pminvoice')) {
-
- $node->content['links']['auto_invoice'] = array(
- '#prefix' => variable_get('pm_icons_display', TRUE) ? '
- ' : '
- ',
- '#suffix' => '
',
- '#markup' => theme('pminvoice_autoadd_links', array($node->nid, $node->billable, $node->billed)),
- '#weight' => $l_pos++,
- );
- }
-
$node->content['group1'] = array(
'#prefix' => '',
'#suffix' => '
',
diff --git a/pmtimetracking/pmtimetracking.views.inc b/pmtimetracking/pmtimetracking.views.inc
index 8c30825..c1b35e3 100644
--- a/pmtimetracking/pmtimetracking.views.inc
+++ b/pmtimetracking/pmtimetracking.views.inc
@@ -141,43 +141,6 @@ function pmtimetracking_views_data() {
),
);
- $data['pmtimetracking']['trackingdate'] = array(
- 'title' => t('Tracking date'),
- 'help' => t('Project Management 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['pmtimetracking']['timebegin'] = array(
- 'title' => t('Time begin'),
- 'help' => t('Project Management Timetracking Time Begin'),
- 'field' => array(
- 'click sortable' => TRUE,
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
-
- $data['pmtimetracking']['timeend'] = array(
- 'title' => t('Time end'),
- 'help' => t('Project Management Timetracking Time End'),
- 'field' => array(
- 'click sortable' => TRUE,
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
-
$data['pmtimetracking']['duration'] = array(
'title' => t('Duration'),
'help' => t('Project Management Timetracking Duration'),
@@ -259,30 +222,3 @@ function pmtimetracking_views_handlers() {
),
);
}
-
-/**
- * Implements hook_date_api_fields().
- */
-function pmtimetracking_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 'pmtimetracking.trackingdate':
- return $values;
- }
-
-}
-
-/**
- * Implements hook_date_api_tables().
- */
-function pmtimetracking_date_api_tables() {
- return array('pmtimetracking');
-}