function addHelpDeskTaskLog()
 {
     global $AppUI, $helpdesk_available;
     if ($helpdesk_available && $this->file_helpdesk_item != 0) {
         // create task log with information about the file that was uploaded
         $task_log = new CHDTaskLog();
         $task_log->task_log_help_desk_id = $this->_hditem->item_id;
         if ($this->_message != 'deleted') {
             $task_log->task_log_name = 'File ' . $this->file_name . ' uploaded';
         } else {
             $task_log->task_log_name = 'File ' . $this->file_name . ' deleted';
         }
         $task_log->task_log_description = $this->file_description;
         $task_log->task_log_creator = $AppUI->user_id;
         $date = new CDate();
         $task_log->task_log_date = $date->format(FMT_DATETIME_MYSQL);
         if ($msg = $task_log->store()) {
             $AppUI->setMsg($msg, UI_MSG_ERROR);
         }
     }
     return NULL;
 }
Exemple #2
0
 public function notify($notify)
 {
     global $w2Pconfig, $locale_char_set, $helpdesk_available;
     if ($notify == '1') {
         // if helpdesk_item is available send notification to assigned users
         if ($helpdesk_available && $this->file_helpdesk_item != 0) {
             $this->_hditem = new CHelpDeskItem();
             $this->_hditem->overrideDatabase($this->_query);
             $this->_hditem->load($this->file_helpdesk_item);
             $task_log = new CHDTaskLog();
             $task_log->overrideDatabase($this->_query);
             $task_log_help_desk_id = $this->_hditem->item_id;
             // send notifcation about new log entry
             // 2 = TASK_LOG
             $this->_hditem->notify(2, $task_log->task_log_id);
         }
         //if no project specified than we will not do anything
         if ($this->file_project != 0) {
             $this->_project = new CProject();
             $this->_project->overrideDatabase($this->_query);
             $this->_project->load($this->file_project);
             $mail = new w2p_Utilities_Mail();
             if ($this->file_task == 0) {
                 //notify all developers
                 $mail->Subject($this->_project->project_name . '::' . $this->file_name, $locale_char_set);
             } else {
                 //notify all assigned users
                 $this->_task = new CTask();
                 $this->_task->overrideDatabase($this->_query);
                 $this->_task->load($this->file_task);
                 $mail->Subject($this->_project->project_name . '::' . $this->_task->task_name . '::' . $this->file_name, $locale_char_set);
             }
             $emailManager = new w2p_Output_EmailManager($this->_AppUI);
             $body = $emailManager->getFileNotify($this);
             $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
             $q = $this->_getQuery();
             if (intval($this->_task->task_id) != 0) {
                 //preparing users array
                 $q->addTable('tasks', 't');
                 $q->addQuery('t.task_id, cc.contact_email as creator_email, cc.contact_first_name as
                         creator_first_name, cc.contact_last_name as creator_last_name,
                         oc.contact_email as owner_email, oc.contact_first_name as owner_first_name,
                         oc.contact_last_name as owner_last_name, a.user_id as assignee_id,
                         ac.contact_email as assignee_email, ac.contact_first_name as
                         assignee_first_name, ac.contact_last_name as assignee_last_name');
                 $q->addJoin('user_tasks', 'u', 'u.task_id = t.task_id');
                 $q->addJoin('users', 'o', 'o.user_id = t.task_owner');
                 $q->addJoin('contacts', 'oc', 'o.user_contact = oc.contact_id');
                 $q->addJoin('users', 'c', 'c.user_id = t.task_creator');
                 $q->addJoin('contacts', 'cc', 'c.user_contact = cc.contact_id');
                 $q->addJoin('users', 'a', 'a.user_id = u.user_id');
                 $q->addJoin('contacts', 'ac', 'a.user_contact = ac.contact_id');
                 $q->addWhere('t.task_id = ' . (int) $this->_task->task_id);
             } else {
                 //find project owner and notify him about new or modified file
                 $q->addTable('users', 'u');
                 $q->addTable('projects', 'p');
                 $q->addQuery('u.user_id, u.user_contact AS owner_contact_id');
                 $q->addWhere('p.project_owner = u.user_id');
                 $q->addWhere('p.project_id = ' . (int) $this->file_project);
             }
             $this->_users = $q->loadList();
             if (intval($this->_task->task_id) != 0) {
                 foreach ($this->_users as $row) {
                     if ($row['assignee_id'] != $this->_AppUI->user_id) {
                         if ($mail->ValidEmail($row['assignee_email'])) {
                             $mail->To($row['assignee_email'], true);
                             $mail->Send();
                         }
                     }
                 }
             } else {
                 //sending mail to project owner
                 foreach ($this->_users as $row) {
                     //there should be only one row
                     if ($row['user_id'] != $this->_AppUI->user_id) {
                         if ($mail->ValidEmail($row['owner_email'])) {
                             $mail->To($row['owner_email'], true);
                             $mail->Send();
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #3
0
 //first update the status on to current helpdesk item.
 $hditem = new CHelpDeskItem();
 $hditem->load($item_id);
 $new_status = dPgetParam($_POST, 'item_status', 0);
 if ($new_status != $hditem->item_status) {
     $status_log_id = $hditem->log_status(11, $AppUI->_('changed from') . " \"" . $AppUI->_($ist[$hditem->item_status]) . "\" " . $AppUI->_('to') . " \"" . $AppUI->_($ist[$new_status]) . "\"");
     $hditem->item_status = $new_status;
     if ($msg = $hditem->store()) {
         $AppUI->setMsg($msg, UI_MSG_ERROR);
         $AppUI->redirect();
     } else {
         $hditem->notify(STATUS_LOG, $status_log_id);
     }
 }
 //then create/update the task log
 $obj = new CHDTaskLog();
 if (!$obj->bind($_POST)) {
     $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
     $AppUI->redirect();
 }
 if ($obj->task_log_date) {
     $date = new CDate($obj->task_log_date);
     $obj->task_log_date = $date->format(FMT_DATETIME_MYSQL);
 }
 $AppUI->setMsg('Task Log');
 $obj->task_log_costcode = $obj->task_log_costcode;
 if ($msg = $obj->store()) {
     $AppUI->setMsg($msg, UI_MSG_ERROR);
     $AppUI->redirect();
 } else {
     $hditem->notify(TASK_LOG, $obj->task_log_id);
<?php

/* $Id: vw_log_update.php,v 1.12 2005/12/28 20:03:33 theideaman Exp $ */
global $AppUI, $hditem, $ist, $HELPDESK_CONFIG;
$item_id = dPgetParam($_GET, 'item_id', 0);
// check permissions
//$canEdit = !getDenyEdit( 'tasks', $item_id );
//if (!$canEdit) {
//	$AppUI->redirect( "m=public&a=access_denied" );
//}
$users = getAllowedUsers();
$task_log_id = intval(dPgetParam($_GET, 'task_log_id', 0));
$log = new CHDTaskLog();
if ($task_log_id) {
    $log->load($task_log_id);
    //Prevent users from editing other ppls timecards.
    $can_edit_task_logs = $HELPDESK_CONFIG['minimum_edit_level'] >= $AppUI->user_type;
    if (!$can_edit_task_logs) {
        if ($log->task_log_creator != $AppUI->user_id) {
            $AppUI->redirect("m=public&a=access_denied");
        }
    }
} else {
    $log->task_log_help_desk_id = $item_id;
    $log->task_log_name = $hditem['item_title'];
}
// Lets check cost codes
$q = new DBQuery();
$q->addTable('billingcode');
$q->addQuery('billingcode_id, billingcode_name');
$q->addWhere('billingcode_status=0');
     $status_log_id = $hditem->log_status_changes();
     if ($new_item) {
         $item_date = new CDate();
         $idate = $item_date->format(FMT_DATETIME_MYSQL);
         $hditem->item_created = $idate;
         $hditem->item_updated = $udate;
     } else {
         $hditem->item_updated = $udate;
     }
     if ($msg = $hditem->store()) {
         $AppUI->setMsg($msg, UI_MSG_ERROR);
     } else {
         if ($new_item) {
             $status_log_id = $hditem->log_status(0, $AppUI->_('Created'), $new_item);
             // Lets create a log for the item creation:
             $obj = new CHDTaskLog();
             $new_item_log = array('task_log_id' => 0, 'task_log_help_desk_id' => $hditem->item_id, 'task_log_creator' => $AppUI->user_id, 'task_log_name' => 'Item Created: ' . $_POST['item_title'], 'task_log_date' => $hditem->item_created, 'task_log_description' => $_POST['item_title'], 'task_log_hours' => $_POST['task_log_hours'], 'task_log_costcode' => $_POST['task_log_costcode']);
             if (!$obj->bind($new_item_log)) {
                 $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
                 $AppUI->redirect();
             }
             if ($msg = $obj->store()) {
                 $AppUI->setMsg($msg, UI_MSG_ERROR);
                 $AppUI->redirect();
             }
         }
         doWatchers(dPgetParam($_POST, 'watchers', 0), $hditem);
         $AppUI->setMsg($new_item ? $AppUI->_('Help Desk Item') . ' ' . $AppUI->_('added') : $AppUI->_('Help Desk Item') . ' ' . $AppUI->_('updated'), UI_MSG_OK, true);
         $AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
     }
 }