diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 9a8c59b8533..f7ee9668206 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -716,15 +716,27 @@ if (empty($reshook) && $action == 'update') {
$datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
}
- if ($object->elementtype == 'ticket') {
+ if ($object->elementtype == 'ticket') { // code should be TICKET_MSG, TICKET_MSG_PRIVATE, TICKET_MSG_SENTBYMAIL, TICKET_MSG_PRIVATE_SENTBYMAIL
if ($private) {
- $object->type_code = 'TICKET_MSG_PRIVATE';
+ if ($object->code == 'TICKET_MSG') {
+ $object->code = 'TICKET_MSG_PRIVATE';
+ }
+ if ($object->code == 'TICKET_MSG_SENTBYMAIL') {
+ $object->code = 'TICKET_MSG_PRIVATE_SENTBYMAIL';
+ }
} else {
- $object->type_id = dol_getIdFromCode($db, 'AC_EMAIL', 'c_actioncomm');
+ if ($object->code == 'TICKET_MSG_PRIVATE') {
+ $object->code = 'TICKET_MSG';
+ }
+ if ($object->code == 'TICKET_MSG_PRIVATE_SENTBYMAIL') {
+ $object->code = 'TICKET_MSG_SENTBYMAIL';
+ }
}
+ // type_id and type_code is not modified
} else {
$object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
}
+
$object->label = GETPOST("label", "alphanohtml");
$object->datep = $datep;
$object->datef = $datef;
@@ -1315,11 +1327,6 @@ if ($action == 'create') {
// Date start
print '
| ';
- /*
- print ''.$langs->trans("DateActionStart").'';
- print ' - ';
- print ''.$langs->trans("DateActionEnd").'';
- */
print ' | ';
if (GETPOST("afaire") == 1) {
print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo"
@@ -1743,7 +1750,9 @@ if ($id > 0) {
// Private
if ($object->elementtype == 'ticket') {
- print ' |
| '.$langs->trans("PrivateEventMessage").' | code) ? ' checked' : '').'> |
';
+ print '| '.$langs->trans("MarkMessageAsPrivate");
+ print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help');
+ print ' | code) ? ' checked' : '').'> |
';
}
// Title
@@ -2207,18 +2216,13 @@ if ($id > 0) {
print '';
// Type
- if (!empty($conf->global->AGENDA_USE_EVENT_TYPE) && $object->elementtype != 'ticket') {
+ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
print '| '.$langs->trans("Type").' | ';
print $object->getTypePicto();
print $langs->trans("Action".$object->type_code);
print ' |
';
}
- // Private
- if ($object->elementtype == 'ticket') {
- print '| '.$langs->trans("PrivateEventMessage").' | '.yn(preg_match('/^TICKET_MSG_PRIVATE/', $object->code) ? 1 : 0, 3).' |
';
- }
-
// Full day event
print '| '.$langs->trans("EventOnFullDay").' | '.yn($object->fulldayevent ? 1 : 0, 3).' |
';
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index b3be88d6b8f..98f5d455cd0 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -1162,12 +1162,8 @@ class ActionComm extends CommonObject
$userownerid = ($this->userownerid ? $this->userownerid : 0);
$userdoneid = ($this->userdoneid ? $this->userdoneid : 0);
- $this->db->begin();
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm ";
- $sql .= " SET percent = '".$this->db->escape($this->percentage)."'";
+ // If a type_id is set, we must also have the type_code set
if ($this->type_id > 0) {
- $sql .= ", fk_action = ".(int) $this->type_id;
if (empty($this->type_code)) {
$cactioncomm = new CActionComm($this->db);
$result = $cactioncomm->fetch($this->type_id);
@@ -1176,7 +1172,18 @@ class ActionComm extends CommonObject
}
}
}
- $sql .= ", code = " . (isset($this->type_code)? "'".$this->db->escape($this->type_code) . "'":"null");
+
+ $code = $this->code;
+ if (empty($code)) {
+ $code = $this->type_code;
+ }
+
+ $this->db->begin();
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm";
+ $sql .= " SET percent = '".$this->db->escape($this->percentage)."'";
+ $sql .= ", fk_action = ".(int) $this->type_id;
+ $sql .= ", code = " . ($code ? "'".$this->db->escape($code)."'" : "null");
$sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null");
$sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null');
$sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null');
@@ -1207,7 +1214,7 @@ class ActionComm extends CommonObject
if (!empty($this->status)) {
$sql .= ", status=".($this->status ? (int) $this->status : 0);
}
- $sql .= " WHERE id=".$this->id;
+ $sql .= " WHERE id=".((int) $this->id);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
if ($this->db->query($sql)) {