FIX Assignement of event to create when created from view per user.
This commit is contained in:
parent
8432a2a0dd
commit
a9521b13f9
@ -71,8 +71,6 @@ $offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
|
|||||||
$remindertype = GETPOST('selectremindertype', 'aZ09');
|
$remindertype = GETPOST('selectremindertype', 'aZ09');
|
||||||
$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
|
$modelmail = GETPOST('actioncommsendmodel_mail', 'int');
|
||||||
|
|
||||||
//var_dump($_POST); exit;
|
|
||||||
|
|
||||||
$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'));
|
$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'));
|
||||||
$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'));
|
$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'));
|
||||||
|
|
||||||
@ -111,8 +109,6 @@ if ($id > 0 && $action != 'add') {
|
|||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
$extrafields->fetch_name_optionals_label($object->table_element);
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
//var_dump($_POST);
|
|
||||||
|
|
||||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
$hookmanager->initHooks(array('actioncard', 'globalcard'));
|
$hookmanager->initHooks(array('actioncard', 'globalcard'));
|
||||||
|
|
||||||
@ -144,7 +140,7 @@ if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned')
|
|||||||
{
|
{
|
||||||
if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]);
|
if ($val['id'] == $idtoremove || $val['id'] == -1) unset($tmpassigneduserids[$key]);
|
||||||
}
|
}
|
||||||
//var_dump($_POST['removedassigned']);exit;
|
|
||||||
$_SESSION['assignedtouser'] = json_encode($tmpassigneduserids);
|
$_SESSION['assignedtouser'] = json_encode($tmpassigneduserids);
|
||||||
$donotclearsession = 1;
|
$donotclearsession = 1;
|
||||||
if ($action == 'add') $action = 'create';
|
if ($action == 'add') $action = 'create';
|
||||||
@ -1076,18 +1072,21 @@ if ($action == 'create')
|
|||||||
$listofuserid = array();
|
$listofuserid = array();
|
||||||
$listofcontactid = array();
|
$listofcontactid = array();
|
||||||
$listofotherid = array();
|
$listofotherid = array();
|
||||||
|
|
||||||
if (empty($donotclearsession))
|
if (empty($donotclearsession))
|
||||||
{
|
{
|
||||||
$assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
|
$assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
|
||||||
if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first
|
if ($assignedtouser) $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first
|
||||||
$listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 1; // 1 by default at first init
|
//$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init
|
||||||
|
$listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init
|
||||||
$_SESSION['assignedtouser'] = json_encode($listofuserid);
|
$_SESSION['assignedtouser'] = json_encode($listofuserid);
|
||||||
} else {
|
} else {
|
||||||
if (!empty($_SESSION['assignedtouser']))
|
if (!empty($_SESSION['assignedtouser']))
|
||||||
{
|
{
|
||||||
$listofuserid = json_decode($_SESSION['assignedtouser'], true);
|
$listofuserid = json_decode($_SESSION['assignedtouser'], true);
|
||||||
}
|
}
|
||||||
$listofuserid[$user->id]['transparency'] = GETPOSTISSET('transparency') ?GETPOST('transparency', 'alpha') : 0; // 0 by default when refreshing
|
$firstelem = reset($listofuserid);
|
||||||
|
if (isset($listofuserid[$firstelem['id']])) $listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing
|
||||||
}
|
}
|
||||||
print '<div class="assignedtouser">';
|
print '<div class="assignedtouser">';
|
||||||
print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
|
print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
|
||||||
@ -1950,8 +1949,6 @@ if ($id > 0)
|
|||||||
/*
|
/*
|
||||||
if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
|
if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
|
||||||
{
|
{
|
||||||
//var_dump($object->userassigned);
|
|
||||||
//var_dump($listofuserid);
|
|
||||||
print '<div class="myavailability">';
|
print '<div class="myavailability">';
|
||||||
print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
|
print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user