phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] tasks/class.base.php, 1.1.2.8


From: nomail
Subject: [Phpgroupware-cvs] tasks/class.base.php, 1.1.2.8
Date: Fri, 14 May 2004 07:54:28 +0200

Update of /tasks
Modified Files:
        Branch: proposal-branch
          class.base.php

date: 2004/05/14 05:54:28;  author: jengo;  state: Exp;  lines: +95 -35

Log Message:
More work on tasks, added in "start date" and "end date", plus some other small 
updates
=====================================================================
Index: tasks/class.base.php
diff -u tasks/class.base.php:1.1.2.7 tasks/class.base.php:1.1.2.8
--- tasks/class.base.php:1.1.2.7        Sat May  8 22:20:17 2004
+++ tasks/class.base.php        Fri May 14 05:54:28 2004
@@ -161,7 +161,7 @@
                                return false;
                        }
 
-                       return array
+                       $result = array
                        (
                                'id'             => 
$dbresult->fields['task_id'],
                                'dm_type'        => 
$dbresult->fields['task_dm_type'],
@@ -177,12 +177,30 @@
                                'subject'        => 
$dbresult->fields['task_subject'],
                                'description'    => 
$dbresult->fields['task_description'],
                                'priority'       => 
$this->_convert_priority($dbresult->fields['task_priority']),
-                               'priority_id'    => 
$dbresult->fields['task_priority'],
-                               'start'          => 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_start'])) . 
date(' h:i:s a',$dbresult->unixtimestamp($dbresult->fields['task_start'])),
-                               'end'            => 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_end'])) . date(' 
h:i:s a',$dbresult->unixtimestamp($dbresult->fields['task_end'])),
-                               'modified'       => 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_modified'])) . 
date(' h:i:s a',$dbresult->unixtimestamp($dbresult->fields['task_modified'])),
-                               'created'        => 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_created'])) . 
date(' h:i:s a',$dbresult->unixtimestamp($dbresult->fields['task_created']))
+                               'priority_id'    => 
$dbresult->fields['task_priority']
                        );
+
+                       if 
($dbresult->unixtimestamp($dbresult->fields['task_start']))
+                       {
+                               $result['start']   = 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_start']))
+                                       . date(' h:i:s 
a',$dbresult->unixtimestamp($dbresult->fields['task_start']));
+                       }
+                       else
+                       {
+                               $result['start'] = '';
+                       }
+
+                       if 
($dbresult->unixtimestamp($dbresult->fields['task_end']))
+                       {
+                               $result['end']   = 
strftime('%x',$dbresult->unixtimestamp($dbresult->fields['task_end']))
+                                       . date(' h:i:s 
a',$dbresult->unixtimestamp($dbresult->fields['task_end']));
+                       }
+                       else
+                       {
+                               $result['end'] = '';
+                       }
+
+                       return $result;
                }
 
                function start()
@@ -251,10 +269,10 @@
                        $args->set('start_time',NOTSET,'any');
                        $args->set('end_date',NOTSET,'any');
                        $args->set('end_time',NOTSET,'any');
-                       $args->set('status',NOTSET,'any');
+                       $args->set('status',0,'number');
                        $args->set('access',array('private','public'),'enum');
                        $args->set('dm_type',array('N','H','S'),'enum');
-                       $args->set('responsible',0,'any');
+                       $args->set('responsible','0','number');
                        $args = $args->get(func_get_args());
 
                        if ($args['form_submit'] == 'True')
@@ -282,6 +300,45 @@
                                        //$missing_fields                       
= true;
                                }
 
+                               //html_print_r($_POST);
+                               if (strlen($args['start_date']))
+                               {
+                                       $epoch_start_timestamp = 
$GLOBALS['phpgw']->prefs->_read_form_date($args['start_date'],$args['start_time']);
+                                       if (! $epoch_start_timestamp)
+                                       {
+                                               trigger_error(lang('invaild 
start date'),E_USER_WARNING);
+                                               // MARK FIELDS
+                                       }
+                                       else
+                                       {
+                                               $start_timestamp = 
$GLOBALS['phpgw']->db->dbtimestamp($epoch_start_timestamp);
+                                       }
+                               }
+                               else
+                               {
+                                       $start_timestamp       = 
$GLOBALS['phpgw']->db->dbtimestamp(0);
+                                       $epoch_start_timestamp = 0;
+                               }
+
+                               if (strlen($args['end_date']))
+                               {
+                                       $epoch_end_timestamp = 
$GLOBALS['phpgw']->prefs->_read_form_date($args['end_date'],$args['end_time']);
+                                       if (! $epoch_end_timestamp)
+                                       {
+                                               trigger_error(lang('invaild end 
date'),E_USER_WARNING);
+                                               // MARK FIELDS
+                                       }
+                                       else
+                                       {
+                                               $end_timestamp = 
$GLOBALS['phpgw']->db->dbtimestamp($epoch_end_timestamp);
+                                       }
+                               }
+                               else
+                               {
+                                       $end_timestamp       = 
$GLOBALS['phpgw']->db->dbtimestamp(0);
+                                       $epoch_end_timestamp = 0;
+                               }
+
                                if ($missing_fields)
                                {
                                        $GLOBALS['msgbox']->add(lang('You 
forgot to enter some of the required fields. The missing fields have been 
marked with a *'), 'notice');
@@ -289,14 +346,11 @@
                                }
                                else
                                {
-                                       $args['start']  = 
$GLOBALS['phpgw']->db->dbtimestamp(time());
-                                       $args['end']    = 
$GLOBALS['phpgw']->db->dbtimestamp(time());
-                                       $args['status'] = 0;
-
                                        $task_id  = 
$GLOBALS['phpgw']->db->genid('phpgw_tasks_seq');
                                        $dbresult = 
$GLOBALS['phpgw']->db->execute("
                                                INSERT INTO phpgw_tasks
-                                                       (task_id,
+                                               (
+                                                       task_id,
                                                        task_owner,
                                                        task_responsible,
                                                        task_subject,
@@ -307,24 +361,23 @@
                                                        task_end,
                                                        task_status,
                                                        task_access,
-                                                       task_dm_type,
-                                                       task_modified,
-                                                       task_created)
+                                                       task_dm_type
+                                               )
                                                VALUES
-                                                       ($task_id,
+                                               (
+                                                       $task_id,
                                                        " . 
$GLOBALS['phpgw_data']['user']['id'] . ",
                                                        " . 
$args['responsible'] . ",
                                                        '" . $args['subject'] . 
"',
                                                        " . $args['category'] . 
",
                                                        '" . 
$args['description'] . "',
                                                        " . $args['priority'] . 
",
-                                                       " . $args['start'] . ",
-                                                       " . $args['end'] . ",
+                                                       " . $start_timestamp . 
",
+                                                       " . $end_timestamp . ",
                                                        '" . $args['status'] . 
"',
                                                        '" . 
$args['task_access'] . "',
-                                                       'N',
-                                                       now(),
-                                                       now())");
+                                                       'N'
+                                               )");
 
                                        $history_data = array
                                        (
@@ -334,22 +387,29 @@
                                                'task_category'    => 
$args['category'],
                                                'task_description' => 
$args['description'],
                                                'task_priority'    => 
$args['priority'],
-                                               'task_start'       => 
$args['start'],
-                                               'task_end'         => 
$args['end'],
+                                               'task_start'       => 
$epoch_start_timestamp,
+                                               'task_end'         => 
$epoch_end_timestamp,
                                                'task_status'      => 
$args['status']
                                        );
 
-                                       $this->history = 
createObject('api_history');
-                                       $this->history->set('tasks.' . 
$task_id,$history_data,array());
-                                       $GLOBALS['msgbox']->add(lang('Task has 
been successfully created'),'notice');
-
-                                       if ($args['dm_type'] == 'D')
+                                       if 
($GLOBALS['phpgw']->db->affected_rows())
                                        {
-                                               
execMethod('api.datamine._set',array('location_from' => 
$args['datamine_location'], 'location_to' => 'tasks.base.' . $task_id));
+                                               $this->history = 
createObject('api_history');
+                                               $this->history->set('tasks.' . 
$task_id,$history_data,array());
+                                               
$GLOBALS['msgbox']->add(lang('Task has been successfully created'),'notice');
+       
+                                               if ($args['dm_type'] == 'D')
+                                               {
+                                                       
execMethod('api.datamine._set',array('location_from' => 
$args['datamine_location'], 'location_to' => 'tasks.base.' . $task_id));
+                                               }
+       
+                                               
unset($_SESSION['phpgw_session']['phpgw_data']['statecache']['tasks.base.create']);
+                                               return $this->view($task_id);
+                                       }
+                                       else
+                                       {
+                                               trigger_error(lang('There was a 
problem creating this task'),E_USER_WARNING);
                                        }
-
-                                       
unset($_SESSION['phpgw_session']['phpgw_data']['statecache']['tasks.base.create']);
-                                       return $this->view($task_id);
                                }
                        }
                        else
@@ -414,7 +474,7 @@
                                $result['responsible_user_list'][] = array
                                (
                                        'id'       => $user['account_id'],
-                                       'name'     => 
$GLOBALS['phpgw']->prefs->_display_account_fullname($user['account_lid'],$user['account_firstname'],$user['account_lastname'])
+                                       'name'     => '(U) ' . 
$GLOBALS['phpgw']->prefs->_display_account_fullname($user['account_lid'],$user['account_firstname'],$user['account_lastname'])
                                );
                        }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]