Index: workflow.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v
retrieving revision 1.54.2.6
diff -u -r1.54.2.6 workflow.module
--- workflow.module	2 Mar 2007 20:51:57 -0000	1.54.2.6
+++ workflow.module	10 Oct 2007 17:05:46 -0000
@@ -191,8 +191,19 @@
   $node->workflow = $form_values['workflow'];
   $node->workflow_comment = $form_values['workflow_comment'];
   $node->workflow_scheduled = $form_values['workflow_scheduled'];
-  $node->workflow_scheduled_date = $form_values['workflow_scheduled_date'];
-  $node->workflow_scheduled_hour = $form_values['workflow_scheduled_hour'];
+	
+	if (module_exists('jscalendar')) {
+		$timestamp=strtotime($form_values['workflow_scheduled_date_time']);
+		$node->workflow_scheduled_date['day'] = date("d",$timestamp);
+		$node->workflow_scheduled_date['month'] = date("m",$timestamp);
+		$node->workflow_scheduled_date['year'] = date("Y",$timestamp);
+		$node->workflow_scheduled_hour = date("H:i",$timestamp);
+		
+	}
+	else{	
+		$node->workflow_scheduled_date = $form_values['workflow_scheduled_date'];
+		$node->workflow_scheduled_hour = $form_values['workflow_scheduled_hour'];
+	}
   
   // call node save to make sure all saving properties run on this node
   node_save($node);
@@ -300,6 +311,17 @@
     case 'delete':
       db_query("DELETE FROM {workflow_node} WHERE nid = %d", $node->nid);
       break;
+	case 'submit':
+		if (module_exists('jscalendar')) {
+				$timestamp=strtotime($node->workflow_scheduled_date_time);
+			$node->workflow_scheduled_date['day'] = date("d",$timestamp);
+			$node->workflow_scheduled_date['month'] = date("m",$timestamp);
+			$node->workflow_scheduled_date['year'] = date("Y",$timestamp);
+			$node->workflow_scheduled_hour = date("H:i",$timestamp);
+			
+		}
+		break;
+		
   }
 }
 
@@ -332,34 +354,54 @@
     // HACK: using arg to see if we're on a node add page
     // i have to do this because current is never creation!
     // scheduling from transition is major bad news
-    if (arg(1) != 'add' && user_access('schedule workflow transitions')) {
-      $scheduled = $timestamp ? 1 : 0;
-      $timestamp = $scheduled ? $timestamp : time();
-
-      $form['workflow']['workflow_scheduled'] = array (
-        '#type' => 'radios',
-        '#title' => t('Schedule'),
-        '#options' => array (
-          t('Immediately'),
-          t('Schedule for state change at:'),
-        ),
-        '#default_value' => $scheduled,
-      );
-
-      $form['workflow']['workflow_scheduled_date'] = array (
-        '#type' => 'date',
-        '#default_value' => array('day' => format_date($timestamp, 'custom', 'j'),
-                              'month' => format_date($timestamp, 'custom', 'n'),
-                              'year' => format_date($timestamp, 'custom', 'Y')),
-      );
-  
-      $hours = format_date($timestamp, 'custom', 'H:i');
-      $form['workflow']['workflow_scheduled_hour'] = array (
-        '#type' => 'textfield',
-        '#description' => t('Please enter a time in 24 hour (eg. HH:MM) format. If no date is included, the default will be midnight on the specified date. The current time is: ') . format_date(time()),
-        '#default_value' => $scheduled ? $hours : NULL,
-      );
-    }
+		if (arg(1) != 'add' && user_access('schedule workflow transitions')) {
+			$scheduled = $timestamp ? 1 : 0;
+			$timestamp = $scheduled ? $timestamp : time();
+			
+			$form['workflow']['workflow_scheduled'] = array (
+					'#type' => 'radios',
+					'#title' => t('Schedule'),
+					'#options' => array (
+						t('Immediately'),
+						t('Schedule for state change at:'),
+						),
+					'#default_value' => $scheduled,
+					);
+			
+			if (module_exists('jscalendar')) {
+				// Show 24-hour clock for JScalendar
+				$form['#jscalendar_timeFormat'] = '24';
+				
+				$form['workflow']['workflow_scheduled_date_time'] = array(
+						'#type' => 'textfield', 
+						'#title' => t('Scheduled'), 
+						'#maxlength' => 25,
+						//we subtract the time zone to show the user the correct time they entered
+						//and below that we show the timezone to adjust this time by
+						//we store the adjusted timezone value in the database for cron
+						'#default_value' => date('Y-m-d H:i', $timestamp),
+						'#description' => t('Format: %time.', array('%time' => date('Y-m-d H:i:s'))),
+						'#attributes' => array('class' => 'jscalendar')
+						);
+				
+			}
+			else
+			{
+				$form['workflow']['workflow_scheduled_date'] = array (
+						'#type' => 'date',
+						'#default_value' => array('day' => format_date($timestamp, 'custom', 'j'),
+							'month' => format_date($timestamp, 'custom', 'n'),
+							'year' => format_date($timestamp, 'custom', 'Y')),
+						);
+				
+				$hours = format_date($timestamp, 'custom', 'H:i');
+				$form['workflow']['workflow_scheduled_hour'] = array (
+						'#type' => 'textfield',
+						'#description' => t('Please enter a time in 24 hour (eg. HH:MM) format. If no date is included, the default will be midnight on the specified date. The current time is: ') . format_date(time()),
+						'#default_value' => $scheduled ? $hours : NULL,
+						);
+			}
+		}
     
     $form['workflow']['workflow_comment'] = array(
       '#type' => 'textarea',
@@ -1834,6 +1876,29 @@
     ),
   );
   $tables[$table['name']] = $table;
+
+  $table = array(
+	'name' => 'workflow_scheduled_transition',
+    'provider' => 'workflow',
+    'join' => array(
+      'left' => array(
+        'table' => 'workflow_node',
+        'field' => 'nid',
+       ),
+       'right' => array(
+         'field' => 'nid',
+       ),
+     ),
+    "fields" => array(
+      'scheduled' => array(
+        'name' => t('Workflow: scheduled'),
+        'sortable' => true,
+        'handler' => views_handler_field_dates(),
+        'help' => t('Display the workflow scheduled date of the node.'),
+      ),
+    ),
+  );
+  $tables[$table['name']] = $table;
   
   $table = array(
     'name' => 'workflow_node_history',

