New : action to clone ticket (#36231)
This commit is contained in:
parent
96707ab431
commit
bd2183ac7c
2 changed files with 24 additions and 1 deletions
|
|
@ -491,6 +491,19 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_clone' && GETPOST('confirm', 'alpha') == "yes" && $permissiontoadd) {
|
||||
if ($object->fetch(GETPOSTINT('id'), '', GETPOST('track_id', 'alpha')) >= 0) {
|
||||
$newid = $object->createFromClone($user, $object->id);
|
||||
if ($newid > 0) {
|
||||
header("Location: " . DOL_URL_ROOT . "/ticket/card.php?id=".$newid);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $permissiontodelete) {
|
||||
if ($object->fetch(GETPOSTINT('id'), '', GETPOST('track_id', 'alpha')) >= 0) {
|
||||
if ($object->delete($user) > 0) {
|
||||
|
|
@ -774,7 +787,7 @@ if ($action == 'create' || $action == 'presend') {
|
|||
$formticket->showForm(0, 'edit', 0, null, $action, $object);
|
||||
|
||||
print dol_get_fiche_end();
|
||||
} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'addlinkbyref', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status'])) {
|
||||
} elseif (empty($action) || in_array($action, ['builddoc', 'view', 'addlink', 'addlinkbyref', 'dellink', 'presend', 'presend_addmessage', 'close', 'abandon', 'clone', 'delete', 'editcustomer', 'progression', 'categories', 'reopen', 'edit_contrat', 'editsubject', 'edit_extras', 'update_extras', 'edit_extrafields', 'set_extrafields', 'classify', 'sel_contract', 'edit_message_init', 'set_status'])) {
|
||||
if (!empty($res) && $res > 0) {
|
||||
// or for unauthorized internals users
|
||||
if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) {
|
||||
|
|
@ -826,6 +839,10 @@ if ($action == 'create' || $action == 'presend') {
|
|||
//var_dump($url_page_current . "?track_id=" . $object->track_id);
|
||||
$formconfirm = $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".$new_status, $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->labelStatusShort[$new_status])), "confirm_set_status", '', '', 1);
|
||||
}
|
||||
// Clone confirmation
|
||||
if ($action == 'clone') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', '', 'yes', 1);
|
||||
}
|
||||
|
||||
// Call Hook formConfirm
|
||||
$parameters = array('formConfirm' => $formconfirm);
|
||||
|
|
@ -1511,6 +1528,11 @@ if ($action == 'create' || $action == 'presend') {
|
|||
print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoedit);
|
||||
}
|
||||
|
||||
// Clone
|
||||
if ($permissiontoadd) {
|
||||
print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&token='.newToken(), '', $permissiontoadd);
|
||||
}
|
||||
|
||||
// Delete ticket
|
||||
if ($user->hasRight('ticket', 'delete') && !$user->socid) {
|
||||
print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&track_id='.$object->track_id, '');
|
||||
|
|
|
|||
|
|
@ -1277,6 +1277,7 @@ class Ticket extends CommonObject
|
|||
$object->status = 0;
|
||||
$object->ref = $object->getDefaultRef();
|
||||
$object->track_id = generate_random_id(16);
|
||||
$object->progress = 0;
|
||||
|
||||
// Create clone
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
|
|
|
|||
Loading…
Reference in a new issue