diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 0e6a6c6fd10..237c55e7678 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -105,11 +105,11 @@ if (! empty($_POST['removedassigned']))
if (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))
{
// Add a new user
- if (GETPOST('affectedto') > 0)
+ if (GETPOST('assignedtouser') > 0)
{
$assignedtouser=array();
if (! empty($_SESSION['assignedtouser'])) $assignedtouser=dol_json_decode($_SESSION['assignedtouser'], true);
- $assignedtouser[GETPOST('affectedto')]=array('transparency'=>GETPOST('transparency'),'mandatory'=>1);
+ $assignedtouser[GETPOST('assignedtouser')]=array('transparency'=>GETPOST('transparency'),'mandatory'=>1);
$_SESSION['assignedtouser']=dol_json_encode($assignedtouser);
}
$donotclearsession=1;
@@ -647,11 +647,11 @@ if ($action == 'create')
print '
| '.$langs->trans("ActionAffectedTo").' | ';
if (empty($donotclearsession))
{
- $assignedtouser=GETPOST("affectedtouser")?GETPOST("affectedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id);
+ $assignedtouser=GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id);
$_SESSION['assignedtouser']=dol_json_encode(array($assignedtouser=>array('transparency'=>1,'mandatory'=>1)));
}
- print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'affectedto',1);
- //print $form->select_dolusers(GETPOST("affectedto")?GETPOST("affectedto"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id),'affectedto',1);
+ print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'assignedtouser',1);
+ //print $form->select_dolusers(GETPOST("assignedtouser")?GETPOST("assignedtouser"):(! empty($object->usertodo->id) && $object->usertodo->id > 0 ? $object->usertodo->id : $user->id),'affectedto',1);
print ' |
';
print '';
@@ -904,8 +904,8 @@ if ($id > 0)
if (is_object($object->usertodo)) $listofuserid[$object->usertodo->id]=array('id'=>$object->usertodo->id,'transparency'=>$object->transparency);
$_SESSION['assignedtouser']=dol_json_encode($listofuserid);
}
- print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'affectedto',1);
- //print $form->select_dolusers($object->usertodo->id>0?$object->usertodo->id:-1,'affectedto',1);
+ print $form->select_dolusers_forevent(($action=='create'?'add':'update'),'assignedtouser',1);
+ //print $form->select_dolusers($object->usertodo->id>0?$object->usertodo->id:-1,'assignedtouser',1);
print '';
print '
';
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 731d82dba2f..f1acf8c29b4 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -211,22 +211,43 @@ class ActionComm extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm","id");
- // Actions on extra fields (by external module or standard code)
- $hookmanager->initHooks(array('actioncommdao'));
- $parameters=array('actcomm'=>$this->id);
- $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if (empty($reshook))
+ // Now insert assignedusers
+ if (! $error)
+ {
+ foreach($this->userassigned as $key => $val)
+ {
+ $sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
+ $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", 0, ".$val['transparency'].", 0)";
+
+ $resql = $this->db->query($sql);
+ if (! $resql)
+ {
+ $error++;
+ $this->errors[]=$this->db->lasterror();
+ }
+ //var_dump($sql);exit;
+ }
+ }
+
+ if (! $error)
{
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
- {
- $result=$this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
+ // Actions on extra fields (by external module or standard code)
+ $hookmanager->initHooks(array('actioncommdao'));
+ $parameters=array('actcomm'=>$this->id);
+ $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if (empty($reshook))
+ {
+ if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ {
+ $result=$this->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
+ }
+ else if ($reshook < 0) $error++;
}
- else if ($reshook < 0) $error++;
if (! $error && ! $notrigger)
{
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index abd8b71a699..22f968e2b4a 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -656,7 +656,7 @@ jQuery(document).ready(function() {
if (ids == \'none\') /* No event */
{
/* alert(\'no event\'); */
- url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=create&affectedto="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER["PHP_SELF"].'?year='.$year.'&month='.$month.'&day='.$day).'"
+ url = "'.DOL_URL_ROOT.'/comm/action/card.php?action=create&assignedtouser="+userid+"&datep="+year+month+day+hour+min+"00&backtopage='.urlencode($_SERVER["PHP_SELF"].'?year='.$year.'&month='.$month.'&day='.$day).'"
window.location.href = url;
}
else if (ids.indexOf(",") > -1) /* There is several events */
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index dab26d32934..0ae4ee8bd22 100644
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -131,6 +131,8 @@ ALTER TABLE llx_user ADD COLUMN weeklyhours double(16,8);
ALTER TABLE llx_projet_task_time ADD COLUMN task_datehour datetime after task_date;
+ALTER TABLE llx_actioncomm_resources CHANGE COLUMN transparent transparency smallint default 1;
+
-- Localtaxes by thirds
ALTER TABLE llx_c_tva MODIFY COLUMN localtax1 varchar(10);
@@ -1071,11 +1073,11 @@ CREATE TABLE llx_fichinterdet_extrafields
ALTER TABLE llx_fichinterdet_extrafields ADD INDEX idx_ficheinterdet_extrafields (fk_object);
-CREATE TABLE IF NOT EXISTS llx_usergroup_extrafields (
+CREATE TABLE llx_usergroup_extrafields (
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp,
fk_object integer NOT NULL,
import_key varchar(14) -- import key
-) ENGINE=InnoDB ;
+) ENGINE=innodb;
ALTER TABLE llx_usergroup_extrafields ADD INDEX idx_usergroup_extrafields (fk_object);
diff --git a/htdocs/install/mysql/tables/llx_actioncomm_resources.sql b/htdocs/install/mysql/tables/llx_actioncomm_resources.sql
index bd48ad4f66d..484cd39fb82 100644
--- a/htdocs/install/mysql/tables/llx_actioncomm_resources.sql
+++ b/htdocs/install/mysql/tables/llx_actioncomm_resources.sql
@@ -23,10 +23,10 @@
create table llx_actioncomm_resources
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
- fk_actioncomm integer NOT NULL,
- element_type varchar(50) NOT NULL,
- fk_element integer NOT NULL,
+ fk_actioncomm integer NOT NULL, -- Id into llx_actioncomm
+ element_type varchar(50) NOT NULL, -- Type of resource ('user', 'resource')
+ fk_element integer NOT NULL, -- Id into table llx_user or llx_resource
answer_status varchar(50) NULL,
- mandatory smallint,
- transparent smallint
+ mandatory smallint,
+ transparency smallint default 1 -- Used to say if event is 1=OPAQUE=busy or 0=TRANSPARENT
) ENGINE=innodb;