Skip to content

Commit

Permalink
NEW Dolibarr can now re-open ticket upon customer reply on the same t…
Browse files Browse the repository at this point in the history
…icket via email#28303 (#28451)

* #28303

* #28303

* #28303
  • Loading branch information
alsoft10 authored Feb 28, 2024
1 parent 7391ad4 commit 648a58e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
43 changes: 31 additions & 12 deletions htdocs/emailcollector/class/emailcollector.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,7 @@ public function doCollectOneCollector($mode = 0)
//var_dump($alreadycreated);
//var_dump($operation['type']);
//var_dump($actioncomm);
//var_dump($objectemail);
//exit;

if ($errorforthisaction) {
Expand All @@ -2658,22 +2659,40 @@ public function doCollectOneCollector($mode = 0)
$errorforactions++;
$this->errors = $actioncomm->errors;
} else {
if (($fk_element_type == 'ticket') && (!empty($attachments))) {
// There is an attachment for the ticket -> store attachment
$ticket = New Ticket($this->db);
$ticket->fetch($fk_element_id);
$destdir = $conf->ticket->dir_output.'/'.$ticket->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
if ($fk_element_type == "ticket") {
if ($objectemail->status == Ticket::STATUS_CLOSED || $objectemail->status == Ticket::STATUS_CANCELED) {
if ($objectemail->fk_user_assign != null) {
$res = $objectemail->setStatut(Ticket::STATUS_ASSIGNED);
} else {
$res = $objectemail->setStatut(Ticket::STATUS_NOT_READ);
}

if ($res) {
$operationslog .= '<br>Ticket Re-Opened successfully -> ref='.$objectemail->ref;
} else {
$errorforactions++;
$this->error = 'Error while changing the tcket status -> ref='.$objectemail->ref;
$this->errors[] = $this->error;
}
}
if (getDolGlobalString('MAIN_IMAP_USE_PHPIMAP')) {
foreach ($attachments as $attachment) {
$attachment->save($destdir.'/');
if (!empty($attachments)) {
// There is an attachment for the ticket -> store attachment
$ticket = New Ticket($this->db);
$ticket->fetch($fk_element_id);
$destdir = $conf->ticket->dir_output.'/'.$ticket->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
if (getDolGlobalString('MAIN_IMAP_USE_PHPIMAP')) {
foreach ($attachments as $attachment) {
$attachment->save($destdir.'/');
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
}
}

$operationslog .= '<br>Event created -> id='.dol_escape_htmltag($actioncomm->id);
}
}
Expand Down
6 changes: 5 additions & 1 deletion htdocs/ticket/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,11 @@
if ($object->fetch(GETPOSTINT('id'), '', GETPOSTINT('track_id')) >= 0) {
// prevent browser refresh from reopening ticket several times
if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) {
$res = $object->setStatut(Ticket::STATUS_ASSIGNED);
if ($object->fk_user_assign != null) {
$res = $object->setStatut(Ticket::STATUS_ASSIGNED);
} else {
$res = $object->setStatut(Ticket::STATUS_NOT_READ);
}
if ($res) {
$url = 'card.php?track_id='.$object->track_id;
header("Location: ".$url);
Expand Down

0 comments on commit 648a58e

Please sign in to comment.