move customer-tickets to archive if customer gets deleted
This commit is contained in:
@@ -237,6 +237,25 @@ if($page == 'customers'
|
||||
inserttask('6', $result['loginname']);
|
||||
}
|
||||
|
||||
/*
|
||||
* move old tickets to archive
|
||||
*/
|
||||
$tickets = ticket::customerHasTickets($db, $id);
|
||||
if($tickets !== false && isset($tickets[0]))
|
||||
{
|
||||
foreach($tickets as $ticket)
|
||||
{
|
||||
$now = time();
|
||||
$mainticket = ticket::getInstanceOf($userinfo, $db, $settings, (int)$ticket);
|
||||
$mainticket->Set('lastchange', $now, true, true);
|
||||
$mainticket->Set('lastreplier', '1', true, true);
|
||||
$mainticket->Set('status', '3', true, true);
|
||||
$mainticket->Update();
|
||||
$mainticket->Archive();
|
||||
$log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
|
||||
}
|
||||
}
|
||||
|
||||
redirectTo($filename, Array('page' => $page, 's' => $s));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -99,7 +99,12 @@ if($page == 'tickets'
|
||||
$cid = $row['customerid'];
|
||||
$usr = $db->query_first('SELECT `firstname`, `name`, `loginname` FROM `' . TABLE_PANEL_CUSTOMERS . '`
|
||||
WHERE `customerid` = "' . (int)$cid . '"');
|
||||
$customer = $usr['firstname'] . " " . $usr['name'] . " (" . $usr['loginname'] . ")";
|
||||
|
||||
if(isset($usr['loginname'])) {
|
||||
$customer = $usr['firstname'] . " " . $usr['name'] . " (" . $usr['loginname'] . ")";
|
||||
} else {
|
||||
$customer = $lng['ticket']['nonexistingcustomer'];
|
||||
}
|
||||
eval("\$tickets.=\"" . getTemplate("ticket/tickets_customer") . "\";");
|
||||
}
|
||||
|
||||
@@ -626,7 +631,12 @@ elseif($page == 'archive'
|
||||
$cid = $ticket['customerid'];
|
||||
$usr = $db->query_first('SELECT `firstname`, `name`, `loginname` FROM `' . TABLE_PANEL_CUSTOMERS . '`
|
||||
WHERE `customerid` = "' . (int)$cid . '"');
|
||||
$customer = $usr['firstname'] . " " . $usr['name'] . " (" . $usr['loginname'] . ")";
|
||||
|
||||
if(isset($usr['loginname'])) {
|
||||
$customer = $usr['firstname'] . " " . $usr['name'] . " (" . $usr['loginname'] . ")";
|
||||
} else {
|
||||
$customer = $lng['ticket']['nonexistingcustomer'];
|
||||
}
|
||||
eval("\$tickets.=\"" . getTemplate("ticket/tickets_customer") . "\";");
|
||||
}
|
||||
|
||||
|
||||
@@ -625,6 +625,32 @@ class ticket
|
||||
return $str;
|
||||
}
|
||||
|
||||
/*
|
||||
* function customerHasTickets
|
||||
*
|
||||
* @param object mysql-db-object
|
||||
* @param int customer-id
|
||||
*
|
||||
* @return array/bool array of ticket-ids if customer has any, else false
|
||||
*/
|
||||
static public function customerHasTickets($_db = null, $_cid = 0)
|
||||
{
|
||||
if($_cid != 0)
|
||||
{
|
||||
$result = $_db->query('SELECT `id` FROM `' . TABLE_PANEL_TICKETS . '` WHERE `customer` ="'.(int)$_cid.'"');
|
||||
|
||||
$tickets = array();
|
||||
while($row = $_db->fetch_array($result))
|
||||
{
|
||||
$tickets[] = $row['id'];
|
||||
}
|
||||
|
||||
return $tickets;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a data-var
|
||||
*/
|
||||
|
||||
@@ -1287,5 +1287,6 @@ $lng['tasks']['rebuild_bindconfig'] = 'Rebuilding bind-configuration';
|
||||
$lng['tasks']['creating_ftpdir'] = 'Creating directory for new ftp-user';
|
||||
$lng['tasks']['deleting_customerfiles'] = 'Deleting customer-files %loginname%';
|
||||
$lng['tasks']['noneoutstanding'] = 'There are currently no outstanding tasks for Froxlor';
|
||||
$lng['ticket']['nonexistingcustomer'] = '(deleted customer)';
|
||||
|
||||
?>
|
||||
|
||||
@@ -1267,5 +1267,6 @@ $lng['tasks']['rebuild_bindconfig'] = 'Neuerstellung der Bind-Konfiguration';
|
||||
$lng['tasks']['creating_ftpdir'] = 'Erstelle Verzeichnis für neuen FTP-Benutzer';
|
||||
$lng['tasks']['deleting_customerfiles'] = 'Löschen von Kunden-Dateien %loginname%';
|
||||
$lng['tasks']['noneoutstanding'] = 'Zur Zeit gibt es keine ausstehenden Aufgaben für Froxlor';
|
||||
$lng['ticket']['nonexistingcustomer'] = '(gelöschter Kunde)';
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user