This commit is contained in:
Laurent Destailleur 2023-02-22 14:29:36 +01:00
parent 884ecc9e87
commit e7546e6da1
3 changed files with 7 additions and 4 deletions

View File

@ -164,6 +164,7 @@ class FormTicket
print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.$this->action.'">';
print '<input type="hidden" name="trackid" value="'.$this->trackid.'">';
foreach ($this->param as $key => $value) {
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
}

View File

@ -266,7 +266,7 @@ if (empty($reshook)) {
if (!$error) {
// File transfer
$object->copyFilesForTicket();
$object->copyFilesForTicket(''); // trackid is forced to '' because files were uploaded when no id for ticket exists yet and trackid was ''
}
if (!$error) {
@ -689,6 +689,7 @@ if ($action == 'create' || $action == 'presend') {
print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
$formticket->trackid = ''; // TODO Use a unique key to avoid conflict in upload file feature
$formticket->withfromsocid = $socid ? $socid : $user->socid;
$formticket->withfromcontactid = $contactid ? $contactid : '';
$formticket->withtitletopic = 1;

View File

@ -2437,9 +2437,10 @@ class Ticket extends CommonObject
* Used for files linked into messages.
* Files may be renamed during copy to avoid overwriting existing files.
*
* @return array Array with final path/name/mime of files.
* @param string $forcetrackid Force trackid
* @return array Array with final path/name/mime of files.
*/
public function copyFilesForTicket()
public function copyFilesForTicket($forcetrackid = null)
{
global $conf;
@ -2454,7 +2455,7 @@ class Ticket extends CommonObject
$maxheightmini = 72;
$formmail = new FormMail($this->db);
$formmail->trackid = 'tic'.$this->id;
$formmail->trackid = (is_null($forcetrackid) ? 'tic'.$this->id : '');
$attachedfiles = $formmail->get_attached_files();
$filepath = $attachedfiles['paths'];