Debug multi contact on event.

Prepare also code to manage properties of attendees of event
This commit is contained in:
Laurent Destailleur 2017-11-22 14:42:47 +01:00
parent fd5cb736ce
commit adce4b5b7b
7 changed files with 228 additions and 106 deletions

View File

@ -325,7 +325,7 @@ if ($action == 'add')
reset($object->socpeopleassigned);
$object->contactid = key($object->socpeopleassigned);
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if ($ret < 0) $error++;
@ -708,6 +708,62 @@ if ($action == 'create')
else $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
print '</td></tr>';
$userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); // Dev in progress
if ($userepeatevent)
{
// Repeat
print '<tr><td>'.$langs->trans("RepeatEvent").'</td><td colspan="3">';
print '<input type="hidden" name="recurid" value="'.$object->recurid.'">';
$arrayrecurrulefreq=array(
'no'=>$langs->trans("No"),
'MONTHLY'=>$langs->trans("EveryMonth"),
'WEEKLY'=>$langs->trans("EveryWeek"),
//'DAYLY'=>$langs->trans("EveryDay")
);
$selectedrecurrulefreq='no';
$selectedrecurrulebymonthday='';
$selectedrecurrulebyday='';
if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i',$object->recurrule,$reg)) $selectedrecurrulefreq=$reg[1];
if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i',$object->recurrule,$reg)) $selectedrecurrulebymonthday=$reg[1];
if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i',$object->recurrule,$reg)) $selectedrecurrulebyday=$reg[1];
print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly');
// If recurrulefreq is MONTHLY
print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
print $langs->trans("DayOfMonth").': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.'">';
print '</div>';
// If recurrulefreq is WEEKLY
print '<div class="hidden marginrightonly inline-block repeateventBYDAY">';
print $langs->trans("DayOfWeek").': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.'">';
print '</div>';
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_repeat()
{
if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
{
jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
jQuery(".repeateventBYDAY").hide();
}
else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
{
jQuery(".repeateventBYMONTHDAY").hide();
jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
}
else
{
jQuery(".repeateventBYMONTHDAY").hide();
jQuery(".repeateventBYDAY").hide();
}
}
init_repeat();
jQuery("#recurrulefreq").change(function() {
init_repeat();
});
});
</script>';
print '</td></tr>';
}
// Status
print '<tr><td>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>';
print '<td>';
@ -725,7 +781,7 @@ if ($action == 'create')
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="minwidth100" value="'.(GETPOST('location')?GETPOST('location'):$object->location).'"></td></tr>';
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="soixantepercent" value="'.(GETPOST('location')?GETPOST('location'):$object->location).'"></td></tr>';
}
// Assigned to
@ -735,6 +791,7 @@ if ($action == 'create')
{
$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
$listofuserid[$user->id]['transparency']=GETPOSTISSET('transparency')?GETPOST('transparency','alpha'):1; // 1 by default at first init
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
@ -743,16 +800,17 @@ if ($action == 'create')
{
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
$listofuserid[$user->id]['transparency']=GETPOSTISSET('transparency')?GETPOST('transparency','alpha'):0; // 0 by default when refreshing
}
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
/*if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': <input id="transparency" type="checkbox" name="transparency"'.(((! isset($_GET['transparency']) && ! isset($_POST['transparency'])) || GETPOST('transparency'))?' checked':'').'> '.$langs->trans("Busy");
print '</div>';
}
}*/
print '</td></tr>';
// Realised by
@ -764,39 +822,43 @@ if ($action == 'create')
}
print '</table>';
print '<br><br>';
print '<br><hr><br>';
print '<table class="border" width="100%">';
// Related company
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ActionOnCompany").'</td><td>';
if (GETPOST('socid','int') > 0)
if ($conf->societe->enabled)
{
$societe = new Societe($db);
$societe->fetch(GETPOST('socid','int'));
print $societe->getNomUrl(1);
print '<input type="hidden" id="socid" name="socid" value="'.GETPOST('socid','int').'">';
}
else
{
$events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
//For external user force the company to user company
if (!empty($user->societe_id)) {
print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300');
} else {
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
// Related company
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ActionOnCompany").'</td><td>';
if (GETPOST('socid','int') > 0)
{
$societe = new Societe($db);
$societe->fetch(GETPOST('socid','int'));
print $societe->getNomUrl(1);
print '<input type="hidden" id="socid" name="socid" value="'.GETPOST('socid','int').'">';
}
else
{
$events=array();
$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
//For external user force the company to user company
if (!empty($user->societe_id)) {
print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300');
} else {
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
}
}
print '</td></tr>';
// Related contact
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
print $form->selectcontacts(GETPOST('socid','int'), GETPOST('socpeopleassigned', 'array'), 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid');
print '</td></tr>';
}
print '</td></tr>';
// Related contact
print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
echo $form->selectcontacts(GETPOST('socid','int'), GETPOST('socpeopleassigned', 'array'), 'socpeopleassigned[]', 1, '', '', 0, 'minwidth200',0, 0, array(), false, 'multiple', 'contactid');
print '</td></tr>';
// Project
if (! empty($conf->projet->enabled))
@ -804,7 +866,7 @@ if ($action == 'create')
// Projet associe
$langs->load("projects");
print '<tr><td>'.$langs->trans("Project").'</td><td>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td>';
$numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:-1),GETPOST("projectid")?GETPOST("projectid"):'','projectid');
if ($numproject==0)
@ -816,7 +878,7 @@ if ($action == 'create')
if (!empty($origin) && !empty($originid))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
print '<tr><td>'.$langs->trans("LinkedObject").'</td>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("LinkedObject").'</td>';
print '<td colspan="3">'.dolGetElementUrl($originid,$origin,1).'</td></tr>';
print '<input type="hidden" name="fk_element" size="10" value="'.GETPOST('originid').'">';
print '<input type="hidden" name="elementtype" size="10" value="'.GETPOST('origin').'">';
@ -830,7 +892,7 @@ if ($action == 'create')
}
// Priority
print '<tr><td class="nowrap">'.$langs->trans("Priority").'</td><td colspan="3">';
print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Priority").'</td><td colspan="3">';
print '<input type="text" name="priority" value="'.(GETPOST('priority')?GETPOST('priority'):($object->priority?$object->priority:'')).'" size="5">';
print '</td></tr>';
@ -981,7 +1043,7 @@ if ($id > 0)
}
// Title
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" class="minwidth100" value="'.$object->label.'"></td></tr>';
print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired"':'').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.'"></td></tr>';
// Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent?' checked':'').'></td></tr>';
@ -1018,13 +1080,13 @@ if ($id > 0)
if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i',$object->recurrule,$reg)) $selectedrecurrulefreq=$reg[1];
if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i',$object->recurrule,$reg)) $selectedrecurrulebymonthday=$reg[1];
if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i',$object->recurrule,$reg)) $selectedrecurrulebyday=$reg[1];
print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq);
print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly');
// If recurrulefreq is MONTHLY
print '<div class="repeateventBYMONTHDAY">';
print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
print $langs->trans("DayOfMonth").': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.'">';
print '</div>';
// If recurrulefreq is WEEKLY
print '<div class="repeateventBYDAY">';
print '<div class="hidden marginrightonly inline-block repeateventBYDAY">';
print $langs->trans("DayOfWeek").': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.'">';
print '</div>';
print '<script type="text/javascript" language="javascript">
@ -1033,13 +1095,13 @@ if ($id > 0)
{
if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
{
jQuery(".repeateventBYMONTHDAY").show();
jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
jQuery(".repeateventBYDAY").hide();
}
else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
{
jQuery(".repeateventBYMONTHDAY").hide();
jQuery(".repeateventBYDAY").show();
jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
}
else
{
@ -1065,43 +1127,48 @@ if ($id > 0)
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="minwidth100" value="'.$object->location.'"></td></tr>';
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="soixantepercent" value="'.$object->location.'"></td></tr>';
}
// Assigned to
print '<tr><td class="tdtop nowrap">'.$langs->trans("ActionAssignedTo").'</td><td colspan="3">';
$listofuserid=array();
if (empty($donotclearsession))
{
if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid,'transparency'=>$object->userassigned[$user->id]['transparency'],'answer_status'=>$object->userassigned[$user->id]['answer_status'],'mandatory'=>$object->userassigned[$user->id]['mandatory']); // Owner first
if (! empty($object->userassigned)) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
$tmplist1=$object->userassigned; $tmplist2=array();
foreach($tmplist1 as $key => $val)
{
if ($val['id'] && $val['id'] != $object->userownerid) $listofuserid[$val['id']]=$val;
}
}
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
$listofuserid=array(); // User assigned
if (empty($donotclearsession))
{
if ($object->userownerid > 0) $listofuserid[$object->userownerid]=array('id'=>$object->userownerid, 'type'=>'user', 'transparency'=>$object->userassigned[$user->id]['transparency'], 'answer_status'=>$object->userassigned[$user->id]['answer_status'], 'mandatory'=>$object->userassigned[$user->id]['mandatory']); // Owner first
if (! empty($object->userassigned)) // Now concat assigned users
{
// Restore array with key with same value than param 'id'
$tmplist1=$object->userassigned; $tmplist2=array();
foreach($tmplist1 as $key => $val)
{
if ($val['id'] && $val['id'] != $object->userownerid)
{
$listofuserid[$val['id']]=$val;
}
}
}
$_SESSION['assignedtouser']=json_encode($listofuserid);
}
else
{
if (!empty($_SESSION['assignedtouser']))
{
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
$listofcontactid=$object->socpeopleassigned; // Contact assigned (not used yet)
$listofotherid=$object->otherassigned; // Other undefined email (not used yet)
print '<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans("ActionAssignedTo").'</td><td colspan="3">';
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
/*if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': <input id="transparency" type="checkbox" name="transparency"'.($listofuserid[$user->id]['transparency']?' checked':'').'>'.$langs->trans("Busy");
print '</div>';
}
}*/
print '</td></tr>';
// Realised by
@ -1115,15 +1182,15 @@ if ($id > 0)
print '</table>';
print '<br><br>';
print '<br><hr><br>';
print '<table class="border" width="100%">';
if ($conf->societe->enabled)
{
// Related company
print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>';
// Related company
print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>';
print '<td>';
print '<div class="maxwidth200onsmartphone">';
$events=array(); // 'method'=parameter action of url, 'url'=url to call that return new list of contacts
@ -1137,7 +1204,7 @@ if ($id > 0)
// related contact
print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>';
print '<div class="maxwidth200onsmartphone">';
$form->select_contacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 0, 'minwidth200',0, 0, array(), false, 'multiple', 'contactid');
print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid');
print '</div>';
print '</td>';
print '</tr>';
@ -1334,9 +1401,12 @@ if ($id > 0)
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
$listofcontactid=array(); // not used yet
$listofotherid=array(); // not used yet
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
/*
if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
{
//var_dump($object->userassigned);
@ -1345,6 +1415,7 @@ if ($id > 0)
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 ' </td></tr>';
// Done by
@ -1383,30 +1454,30 @@ if ($id > 0)
// Related contact
print '<tr><td>'.$langs->trans("ActionOnContact").'</td>';
print '<td colspan="3">';
if (!empty($object->socpeopleassigned))
{
foreach ($object->socpeopleassigned as $cid => $Tab)
{
$contact = new Contact($db);
$result = $contact->fetch($cid);
if ($result < 0) dol_print_error($db,$contact->error);
if ($result > 0)
{
print $contact->getNomUrl(1).'&nbsp;';
print $contact->getNomUrl(1);
if ($object->type_code == 'AC_TEL')
{
if (!empty($contact->phone_pro)) print '('.dol_print_phone($contact->phone_pro).')';
print '<br />';
}
print '<div class="paddingright"></div>';
}
}
}
else
{
print '<span class="opacitymedium">'.$langs->trans("NoneOrSeveral").'</span>';
print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
}
print '</td></tr>';
}

View File

@ -113,8 +113,12 @@ class ActionComm extends CommonObject
var $userownerid; // Id of user owner = fk_user_action into table
var $userdoneid; // Id of user done (deprecated)
var $socpeopleassigned = array(); // Array of user ids
/**
var $socpeopleassigned = array(); // Array of contact ids
var $otherassigned = array(); // Array of other contact emails (not user, not contact)
/**
* Object user of owner
* @var User
* @deprecated
@ -354,18 +358,18 @@ class ActionComm extends CommonObject
{
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
$sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)";
$resql = $this->db->query($sql);
if (! $resql)
{
$error++;
$this->errors[]=$this->db->lasterror();
}
}
}
}
if (! $error)
{
$action='create';
@ -609,7 +613,7 @@ class ActionComm extends CommonObject
$this->fk_element = $obj->fk_element;
$this->elementtype = $obj->elementtype;
$this->fetchResources();
}
$this->db->free($resql);
@ -889,26 +893,26 @@ class ActionComm extends CommonObject
//var_dump($sql);exit;
}
}
if (!$error)
{
$sql ="DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources where fk_actioncomm = ".$this->id." AND element_type = 'socpeople'";
$resql = $this->db->query($sql);
if (!empty($this->socpeopleassigned))
{
foreach (array_keys($this->socpeopleassigned) as $id)
{
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
$sql.=" VALUES(".$this->id.", 'socpeople', ".$id.", 0, 0, 0)";
$resql = $this->db->query($sql);
if (! $resql)
{
$error++;
$this->errors[]=$this->db->lasterror();
}
}
}
}

View File

@ -224,15 +224,17 @@ if ($object->id > 0)
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
$listofcontactid=array(); // not used yet
$listofotherid=array(); // not used yet
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
/*if (in_array($user->id,array_keys($listofuserid)))
{
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 '</div>';
}
}*/
print ' </td></tr>';
print '</table>';

View File

@ -1274,7 +1274,7 @@ class Form
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param bool $options_only Return options only (for ajax treatment)
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
* @return int <0 if KO, Nb of contact in list if OK
* @deprected You can use selectcontacts directly (warning order of param was changed)
@ -1301,7 +1301,7 @@ class Form
* @param integer $showsoc Add company into label
* @param int $forcecombo Force to use combo box
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
* @return int <0 if KO, Nb of contact in list if OK
*/
@ -1639,7 +1639,7 @@ class Form
*
* @param string $action Value for $action
* @param string $htmlname Field name in form
* @param int $show_empty 0=liste sans valeur nulle, 1=ajoute valeur inconnue
* @param int $show_empty 0=list without the empty value, 1=add empty value
* @param array $exclude Array list of users id to exclude
* @param int $disabled If select list must be disabled
* @param array $include Array list of users id to include or 'hierarchy' to have only supervised users
@ -1648,12 +1648,16 @@ class Form
* @param int $maxlength Maximum length of string into list (0=no limit)
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
* @param string $morefilter Add more filters into sql request
* @param int $showproperties Show properties of each attendees
* @param array $listofuserid Array with properties of each user
* @param array $listofcontactid Array with properties of each contact
* @param array $listofother Array with properties of each other contact
* @return string HTML select string
* @see select_dolgroups
*/
function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='')
function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='', $showproperties=0, $listofuserid=array(), $listofcontactid=array(), $listofotherid=array())
{
global $conf,$user,$langs;
global $conf, $user, $langs;
$userstatic=new User($this->db);
$out='';
@ -1670,6 +1674,7 @@ class Form
$out.='<script type="text/javascript" language="javascript">jQuery(document).ready(function () { jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });})</script>';
$out.=$this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
$out.=' <input type="submit" class="button valignmiddle" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
$out.='<br>';
}
$assignedtouser=array();
if (!empty($_SESSION['assignedtouser']))
@ -1679,21 +1684,34 @@ class Form
$nbassignetouser=count($assignedtouser);
if ($nbassignetouser && $action != 'view') $out.='<br>';
if ($nbassignetouser) $out.='<div class="myavailability">';
if ($nbassignetouser) $out.='<ul class="attendees">';
$i=0; $ownerid=0;
foreach($assignedtouser as $key => $value)
{
if ($value['id'] == $ownerid) continue;
$out.='<li>';
$userstatic->fetch($value['id']);
$out.=$userstatic->getNomUrl(-1);
$out.= $userstatic->getNomUrl(-1);
if ($i == 0) { $ownerid = $value['id']; $out.=' ('.$langs->trans("Owner").')'; }
if ($nbassignetouser > 1 && $action != 'view') $out.=' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Remove"), 'delete', '', 0, 1).'" value="'.$userstatic->id.'" class="removedassigned" id="removedassigned_'.$userstatic->id.'" name="removedassigned_'.$userstatic->id.'">';
// Show my availability
if ($showproperties)
{
if ($user->id == $value['id'] && is_array($listofuserid) && count($listofuserid) && in_array($user->id, array_keys($listofuserid)))
{
$out.='<div class="myavailability inline-block">';
$out.='&nbsp;-&nbsp;<span class="opacitymedium">'.$langs->trans("MyAvailability").':</span> <input id="transparency" class="marginleftonly marginrightonly" '.($action == 'view'?'disabled':'').' type="checkbox" name="transparency"'.($listofuserid[$user->id]['transparency']?' checked':'').'>'.$langs->trans("Busy");
$out.='</div>';
}
}
//$out.=' '.($value['mandatory']?$langs->trans("Mandatory"):$langs->trans("Optional"));
//$out.=' '.($value['transparency']?$langs->trans("Busy"):$langs->trans("NotBusy"));
$out.='<br>';
$out.='</li>';
$i++;
}
if ($nbassignetouser) $out.='</div>';
if ($nbassignetouser) $out.='</ul>';
//$out.='</form>';
return $out;

View File

@ -300,15 +300,17 @@ else
$listofuserid=json_decode($_SESSION['assignedtouser'], true);
}
}
$listofcontactid=array(); // not used yet
$listofotherid=array(); // not used yet
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($act->datep != $act->datef)?1:0, $listofuserid, $listofcontactid, $listofotherid);
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
/*if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': '.(($act->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
print '</div>';
}
}*/
print ' </td></tr>';
print '</table>';

View File

@ -647,8 +647,17 @@ div.divsearchfield {
div.confirmmessage {
padding-top: 6px;
}
div.myavailability {
padding-top: 6px;
ul.attendees {
padding-top: 0;
padding-bottom: 0;
padding-left: 0;
margin-top: 0;
margin-bottom: 0;
}
ul.attendees li {
list-style-type: none;
padding-top:1px;
padding-bottom:1px;
}
.googlerefreshcal {
padding-top: 4px;
@ -666,6 +675,9 @@ div.myavailability {
.selectlimit, .marginrightonly {
margin-right: 10px !important;
}
.marginleftonly {
margin-left: 10px !important;
}
.selectlimit, .selectlimit:focus {
border-left: none !important;
border-top: none !important;

View File

@ -656,8 +656,18 @@ div.divsearchfield {
div.confirmmessage {
padding-top: 6px;
}
div.myavailability {
padding-top: 6px;
ul.attendees {
padding-top: 0;
padding-bottom: 0;
padding-left: 0;
margin-top: 0;
margin-bottom: 0;
}
ul.attendees li {
list-style-type: none;
}
input > ul.attendees {
margin-top: 6px;
}
.googlerefreshcal {
padding-top: 4px;
@ -675,6 +685,9 @@ div.myavailability {
.selectlimit, .marginrightonly {
margin-right: 10px !important;
}
.marginleftonly {
margin-left: 10px !important;
}
.selectlimit, .selectlimit:focus {
border-left: none !important;
border-top: none !important;