szollosil 1 年間 前
コミット
e520afa5cf

+ 206 - 0
comm/action/class/agendaplus.class.php

@@ -0,0 +1,206 @@
+<?php
+class AgendaPlus
+{
+
+    public $db;
+
+    public $addedFilters = ['eventdetails', 'eventproduct', 'eventlocation'];
+
+    public function __construct()
+    {
+        global $db;
+        $this->db = $db;
+    }
+
+    /**
+     * Show filter form in agenda view
+     *
+     * @param	Form	$form			Form object
+     * @param	int		$canedit		Can edit filter fields
+     * @param	int		$status			Status
+     * @param 	int		$year			Year
+     * @param 	int		$month			Month
+     * @param 	int		$day			Day
+     * @param 	int		$showbirthday	Show birthday
+     * @param 	string	$filtera		Filter on create by user
+     * @param 	string	$filtert		Filter on assigned to user
+     * @param 	string	$eventdetails	Filter on eventdetails
+     * @param 	string	$eventproduct	Filter on eventproduct
+     * @param 	string	$eventlocation	Filter on eventlocation
+     * @param 	string	$filterd		Filter of done by user
+     * @param 	int		$pid			Product id
+     * @param 	int		$socid			Third party id
+     * @param	string	$action			Action string
+     * @param	array	$showextcals	Array with list of external calendars (used to show links to select calendar), or -1 to show no legend
+     * @param	string|array	$actioncode		Preselected value(s) of actioncode for filter on event type
+     * @param	int		$usergroupid	Id of group to filter on users
+     * @param	string	$excludetype	A type to exclude ('systemauto', 'system', '')
+     * @param	int   	$resourceid	    Preselected value of resource for filter on resource
+     * @return	void
+     */
+    function new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $eventdetails, $eventproduct, $eventlocation, $filterd, $pid, $socid, $action, $showextcals = array(), $actioncode = '', $usergroupid = '', $excludetype = '', $resourceid = 0)
+    {
+        global $conf, $user, $langs, $db, $hookmanager;
+        global $begin_h, $end_h, $begin_d, $end_d;
+        global $massaction;
+
+        $langs->load("companies");
+
+        include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
+        $formactions = new FormActions($db);
+
+        // Filters
+        //print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
+        print '<input type="hidden" name="token" value="' . newToken() . '">';
+        print '<input type="hidden" name="year" value="' . ((int) $year) . '">';
+        print '<input type="hidden" name="month" value="' . ((int) $month) . '">';
+        print '<input type="hidden" name="day" value="' . ((int) $day) . '">';
+        if ($massaction != 'predelete' && $massaction != 'preaffecttag') {        // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
+            print '<input type="hidden" name="action" value="' . $action . '">';
+        }
+        print '<input type="hidden" name="search_showbirthday" value="' . ((int) $showbirthday) . '">';
+
+        if ($canedit) {
+            // Assigned to user
+            print '<div class="divsearchfield">';
+            print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="pictofixedwidth inline-block"');
+            print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth150 maxwidth500 widthcentpercentminusxx');
+            print '</div>';
+        }
+
+        if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) {
+            // Status
+            print '<div class="divsearchfield">';
+            print img_picto($langs->trans("Status"), 'setup', 'class="pictofixedwidth inline-block"');
+            $formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100');
+            print '</div>';
+        }
+
+        //print $form->select_dolusers($eventdetails, 'search_eventdetails', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth150 maxwidth500 widthcentpercentminusxx');
+        // new filters (event_details, event products, event location from)
+        print '<div class="divsearchfield">';
+        print img_picto($langs->trans("ActionsToDoBy"), 'fa-cogs', 'class="pictofixedwidth inline-block"');
+        print $this->eventselector($eventdetails, 'eventdetails', 1);
+        print '</div>';
+        print '<div class="divsearchfield">';
+        print img_picto($langs->trans("ActionsToDoBy"), 'fa-product-hunt', 'class="pictofixedwidth inline-block"');
+        print $this->eventselector($eventproduct, 'eventproduct', 1);
+        print '</div>';
+        print '<div class="divsearchfield">';
+        print img_picto($langs->trans("ActionsToDoBy"), 'fa-location-arrow', 'class="pictofixedwidth inline-block"');
+        print $this->eventselector($eventlocation, 'eventlocation', 1);
+        print '</div>';
+        // Hooks
+        $parameters = array('canedit' => $canedit, 'pid' => $pid, 'socid' => $socid);
+        $object = null;
+        $reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been
+
+        print '<div style="clear:both"></div>';
+    }
+
+    private function eventselector($selected, $htmlname, $show_empty = 0,  $multiple = false, $disabled = 0)
+    {
+        global $db, $langs;
+        $i = 0;
+        $out = '';
+        $morecss = '';
+        $textforempty = '&nbsp;';
+        $sql = "SELECT rowid, label FROM llx_eventwizard_{$htmlname} ORDER BY label ASC";
+        $result = $this->db->query($sql);
+        $num = $this->db->num_rows($result);
+
+        if ($selected === '') {
+            $selected = array();
+        } elseif (!is_array($selected)) {
+            $selected = array($selected);
+        }
+        if ($num) {
+            $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : ' minwidth200') . '" id="search_' . $htmlname . '" name="search_' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>';
+            $out .= '<option class="optiongrey" value="' . ($show_empty < 0 ? $show_empty : -1) . '"' . ((empty($selected) || in_array(-1, $selected)) ? ' selected' : '') . '>' . $textforempty . '</option>' . "\n";
+            while ($i < $num) {
+                while ($obj = $this->db->fetch_object($result)) {
+                    $out .= '<option value="' . $obj->rowid . '"';
+                    if (in_array($obj->rowid, $selected)) {
+                        $out .= ' selected';
+                    }
+                    $out .= '>';
+                    $out .= $obj->label;
+                    $out .= '</option>';
+                    $i++;
+                }
+            }
+        } else {
+            $out .= '<select class="flat" id="search_' . $htmlname . '" name="search_' . $htmlname . '" disabled>';
+            $out .= '<option value="">' . $langs->trans("None") . '</option>';
+        }
+        $out .= '</select>';
+        return $out;
+    }
+
+    function getSearchedElement($element)
+    {
+        return GETPOST("search_" . $element, "int", 3) ? GETPOST("search_" . $element, "int", 3) : GETPOST($element, "int", 3);
+    }
+
+    function completeParametersArray($parameters, $eventdetails, $eventproduct, $eventlocation)
+    {
+        foreach ($this->addedFilters as $filter) {
+            $parameters[$filter] = $$filter;
+        }
+        return $parameters;
+    }
+
+    function completeParamString($eventdetails, $eventproduct, $eventlocation)
+    {
+        $param = '';
+        if ($eventdetails) {
+            $param .= "&search_eventdetails=" . urlencode($eventdetails);
+        }
+        if ($eventproduct) {
+            $param .= "&search_eventproduct=" . urlencode($eventproduct);
+        }
+        if ($eventlocation) {
+            $param .= "&search_eventlocation=" . urlencode($eventlocation);
+        }
+        return $param;
+    }
+
+    function completeSqlSelectString($eventdetails, $eventproduct, $eventlocation)
+    {
+        $sql = '';
+        if ($eventdetails != '' && $eventdetails != -1)
+            $sql .= ' edt.rowid as ed_rowid,';
+        if ($eventproduct != '' && $eventproduct != -1)
+            $sql .= ' epr.rowid as epr_rowid,';
+        if ($eventlocation != '' && $eventlocation != -1)
+            $sql .= ' eln.rowid as loc_rowid,';
+
+        return $sql;
+    }
+
+    function completeSqlFromString($eventlocation)
+    {
+        $sql = "";
+        //if($eventdetails != '' && $eventdetails != -1)
+        $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "eventwizard_eventdetails as edt ON edt.rowid = a.fk_element";
+        //if($eventproduct != '' && $eventproduct != -1)
+        $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "eventwizard_eventproduct as epr ON epr.fk_eventdetails = edt.rowid";
+        if ($eventlocation != '' && $eventlocation != -1)
+            $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "eventwizard_eventlocation as eln ON eln.rowid = edt.fk_elventlocation_departure";
+
+        return $sql;
+    }
+
+    function completeSqlWhereString($eventdetails, $eventproduct, $eventlocation)
+    {
+        $sql = "";
+        if ($eventdetails != '' && $eventdetails != -1)
+            $sql .= " AND edt.rowid = {$eventdetails}";
+        if ($eventproduct != '' && $eventproduct != -1)
+            $sql .= " AND epr.rowid = {$eventproduct}";
+        if ($eventlocation != '' && $eventlocation != -1)
+            $sql .= " AND eln.rowid = {$eventlocation}";
+        
+        return $sql;
+    }
+}

+ 19 - 235
comm/action/index.php

@@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
 require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php';
+require_once DOL_DOCUMENT_ROOT . '/comm/action/class/agendaplus.class.php';
 if (isModEnabled('project')) {
 	require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
 }
@@ -60,10 +61,12 @@ $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int"
 $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
 $showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1;
 
+$agendaplus = new AgendaPlus();
+
 // new filters (event_details, event products, event location from)
-$eventdetails = GETPOST("search_eventdetails", "int", 3) ? GETPOST("search_eventdetails", "int", 3) : GETPOST("eventdetails", "int", 3);
-$eventproduct = GETPOST("search_eventproduct", "int", 3) ? GETPOST("search_eventproduct", "int", 3) : GETPOST("eventproduct", "int", 3);
-$eventlocation = GETPOST("search_eventlocation", "int", 3) ? GETPOST("search_eventlocation", "int", 3) : GETPOST("eventlocation", "int", 3);
+$eventdetails = $agendaplus->getSearchedElement('eventdetails');
+$eventproduct = $agendaplus->getSearchedElement('eventproduct');
+$eventlocation = $agendaplus->getSearchedElement('eventlocation');
 
 // If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user.
 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
@@ -252,10 +255,10 @@ $parameters = array(
 	'pid' => $pid,
 	'resourceid' => $resourceid,
 	'usergroup' => $usergroup,
-	'eventdetails' => $eventdetails,
-	'eventproduct' => $eventproduct,
-	'eventlocation' => $eventlocation,
 );
+
+$parameters = $agendaplus->completeParametersArray($parameters, $eventdetails, $eventproduct, $eventlocation);
+
 $reshook = $hookmanager->executeHooks('beforeAgenda', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) {
 	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -437,15 +440,7 @@ if ($type) {
 }
 
 // new filters (event_details, event products, event location from)
-if ($eventdetails) {
-	$param .= "&search_eventdetails=" . urlencode($eventdetails);
-}
-if ($eventproduct) {
-	$param .= "&search_eventproduct=" . urlencode($eventproduct);
-}
-if ($eventlocation) {
-	$param .= "&search_eventlocation=" . urlencode($eventlocation);
-}
+$param .= $agendaplus->completeParamString($eventdetails, $eventproduct, $eventlocation);
 
 $param .= "&maxprint=" . urlencode($maxprint);
 if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') {
@@ -685,12 +680,8 @@ $sql = 'SELECT ';
 if ($usergroup > 0) {
 	$sql .= " DISTINCT";
 }
-if ($eventdetails != '' && $eventdetails != -1)
-	$sql .= ' edt.rowid as ed_rowid,';
-if ($eventproduct != '' && $eventproduct != -1)
-	$sql .= ' epr.rowid as epr_rowid,';
-if ($eventlocation != '' && $eventlocation != -1)
-	$sql .= ' eln.rowid as loc_rowid,';
+$sql .= $agendaplus->completeSqlSelectString($eventdetails, $eventproduct, $eventlocation);
+
 $sql .= ' a.id, a.label,';
 $sql .= ' a.datep,';
 $sql .= ' a.datep2,';
@@ -701,12 +692,9 @@ $sql .= ' a.fk_soc, a.fk_contact, a.fk_project,';
 $sql .= ' a.fk_element, a.elementtype,';
 $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto';
 $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_actioncomm as ca, ' . MAIN_DB_PREFIX . "actioncomm as a";
-//if($eventdetails != '' && $eventdetails != -1)
-$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "eventwizard_eventdetails as edt ON edt.rowid = a.fk_element";
-//if($eventproduct != '' && $eventproduct != -1)
-$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "eventwizard_eventproduct as epr ON epr.fk_eventdetails = edt.rowid";
-if ($eventlocation != '' && $eventlocation != -1)
-	$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "eventwizard_eventlocation as eln ON eln.rowid = edt.fk_elventlocation_departure";
+
+$sql .= $agendaplus->completeSqlFromString($eventlocation);
+
 if (empty($user->rights->societe->client->voir) && !$socid) {
 	$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
 }
@@ -827,12 +815,7 @@ if ($filtert > 0 || $usergroup > 0) {
 }
 // Sort on date
 $sql .= " AND ca.code = 'AC_EVENT'";
-if ($eventdetails != '' && $eventdetails != -1)
-	$sql .= " AND edt.rowid = {$eventdetails}";
-if ($eventproduct != '' && $eventproduct != -1)
-	$sql .= " AND epr.rowid = {$eventproduct}";
-if ($eventlocation != '' && $eventlocation != -1)
-	$sql .= " AND eln.rowid = {$eventlocation}";
+$sql .= $agendaplus->completeSqlWhereString($eventdetails, $eventproduct, $eventlocation);
 $sql .= ' ORDER BY datep';
 //print $sql;
 //print_r($_REQUEST);
@@ -974,79 +957,6 @@ if ($resql) {
 }
 //var_dump($eventarray);
 
-// BIRTHDATES CALENDAR
-// Complete $eventarray with birthdates
-if ($showbirthday) {
-	// Add events in array
-	$sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
-	$sql .= ' FROM ' . MAIN_DB_PREFIX . 'socpeople as sp';
-	$sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat=' . ((int) $user->id) . '))';
-	$sql .= " AND sp.entity IN (" . getEntity('contact') . ")";
-	if ($mode == 'show_day') {
-		$sql .= ' AND MONTH(birthday) = ' . ((int) $month);
-		$sql .= ' AND DAY(birthday) = ' . ((int) $day);
-	} else {
-		$sql .= ' AND MONTH(birthday) = ' . ((int) $month);
-	}
-	$sql .= ' ORDER BY birthday';
-
-	dol_syslog("comm/action/index.php", LOG_DEBUG);
-	$resql = $db->query($sql);
-	if ($resql) {
-		$num = $db->num_rows($resql);
-		$i = 0;
-		while ($i < $num) {
-			$obj = $db->fetch_object($resql);
-
-			$event = new ActionComm($db);
-
-			$event->id = $obj->rowid; // We put contact id in action id for birthdays events
-			$event->ref = $event->id;
-
-			$datebirth = dol_stringtotime($obj->birthday, 1);
-			//print 'ee'.$obj->birthday.'-'.$datebirth;
-			$datearray = dol_getdate($datebirth, true);
-			$event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output
-			$event->datef = $event->datep;
-
-			$event->type_code = 'BIRTHDAY';
-			$event->type_label = '';
-			$event->type_color = '';
-			$event->type = 'birthdate';
-			$event->type_picto = 'birthdate';
-
-			$event->label = $langs->trans("Birthday") . ' ' . dolGetFirstLastname($obj->firstname, $obj->lastname);
-			$event->percentage = 100;
-			$event->fulldayevent = 1;
-
-			$event->date_start_in_calendar = $db->jdate($event->datep);
-			$event->date_end_in_calendar = $db->jdate($event->datef);
-
-			// Add an entry in eventarray for each day
-			$daycursor = $event->datep;
-			$annee = dol_print_date($daycursor, '%Y', 'tzuserrel');
-			$mois = dol_print_date($daycursor, '%m', 'tzuserrel');
-			$jour = dol_print_date($daycursor, '%d', 'tzuserrel');
-
-			$daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt');
-
-			$eventarray[$daykey][] = $event;
-
-			/*$loop = true;
-			 $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee);
-			 do {
-			 $eventarray[$daykey][] = $event;
-			 $daykey += 60 * 60 * 24;
-			 if ($daykey > $event->date_end_in_calendar) $loop = false;
-			 } while ($loop);
-			 */
-			$i++;
-		}
-	} else {
-		dol_print_error($db);
-	}
-}
-
 // LEAVE CALENDAR
 $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.statut, x.rowid, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.statut as status";
 $sql .= " FROM " . MAIN_DB_PREFIX . "holiday as x, " . MAIN_DB_PREFIX . "user as u";
@@ -1463,7 +1373,7 @@ if (empty($mode) || $mode == 'show_month') {      // View by month
 
 	print '<div class="liste_titre liste_titre_bydiv centpercent">';
 	//print_r($_REQUEST);
-	new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, $eventdetails, $eventproduct, $eventlocation, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+	$agendaplus->new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, $eventdetails, $eventproduct, $eventlocation, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
 	print '</div>';
 
 	print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">';
@@ -1572,7 +1482,7 @@ if (empty($mode) || $mode == 'show_month') {      // View by month
 	$newparam .= '&viewweek=1';
 
 	print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
-	print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+	$agendaplus->new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, $eventdetails, $eventproduct, $eventlocation, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
 	print '</div></div>';
 
 	print '<div class="div-table-responsive-no-min sectioncalendarbyweek maxscreenheightless300">';
@@ -1639,7 +1549,7 @@ if (empty($mode) || $mode == 'show_month') {      // View by month
 	$arraytimestamp = dol_getdate($timestamp);
 
 	print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
-	print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+	$agendaplus->new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, $eventdetails, $eventproduct, $eventlocation, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
 	print '</div></div>';
 
 	print '<div class="div-table-responsive-no-min sectioncalendarbyday maxscreenheightless300">';
@@ -1717,132 +1627,6 @@ print "\n" . '</form>';
 llxFooter();
 $db->close();
 
-
-/**
- * Show filter form in agenda view
- *
- * @param	Form	$form			Form object
- * @param	int		$canedit		Can edit filter fields
- * @param	int		$status			Status
- * @param 	int		$year			Year
- * @param 	int		$month			Month
- * @param 	int		$day			Day
- * @param 	int		$showbirthday	Show birthday
- * @param 	string	$filtera		Filter on create by user
- * @param 	string	$filtert		Filter on assigned to user
- * @param 	string	$eventdetails	Filter on eventdetails
- * @param 	string	$eventproduct	Filter on eventproduct
- * @param 	string	$eventlocation	Filter on eventlocation
- * @param 	string	$filterd		Filter of done by user
- * @param 	int		$pid			Product id
- * @param 	int		$socid			Third party id
- * @param	string	$action			Action string
- * @param	array	$showextcals	Array with list of external calendars (used to show links to select calendar), or -1 to show no legend
- * @param	string|array	$actioncode		Preselected value(s) of actioncode for filter on event type
- * @param	int		$usergroupid	Id of group to filter on users
- * @param	string	$excludetype	A type to exclude ('systemauto', 'system', '')
- * @param	int   	$resourceid	    Preselected value of resource for filter on resource
- * @return	void
- */
-function new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $eventdetails, $eventproduct, $eventlocation, $filterd, $pid, $socid, $action, $showextcals = array(), $actioncode = '', $usergroupid = '', $excludetype = '', $resourceid = 0)
-{
-	global $conf, $user, $langs, $db, $hookmanager;
-	global $begin_h, $end_h, $begin_d, $end_d;
-	global $massaction;
-
-	$langs->load("companies");
-
-	include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
-	$formactions = new FormActions($db);
-
-	// Filters
-	//print '<form name="listactionsfilter" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '" method="get">';
-	print '<input type="hidden" name="token" value="' . newToken() . '">';
-	print '<input type="hidden" name="year" value="' . ((int) $year) . '">';
-	print '<input type="hidden" name="month" value="' . ((int) $month) . '">';
-	print '<input type="hidden" name="day" value="' . ((int) $day) . '">';
-	if ($massaction != 'predelete' && $massaction != 'preaffecttag') {		// When $massaction == 'predelete', action may be already output to 'delete' by the mass action system.
-		print '<input type="hidden" name="action" value="' . $action . '">';
-	}
-	print '<input type="hidden" name="search_showbirthday" value="' . ((int) $showbirthday) . '">';
-
-	if ($canedit) {
-		// Assigned to user
-		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="pictofixedwidth inline-block"');
-		print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth150 maxwidth500 widthcentpercentminusxx');
-		print '</div>';
-	}
-
-	if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) {
-		// Status
-		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("Status"), 'setup', 'class="pictofixedwidth inline-block"');
-		$formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100');
-		print '</div>';
-	}
-
-	//print $form->select_dolusers($eventdetails, 'search_eventdetails', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth150 maxwidth500 widthcentpercentminusxx');
-	// new filters (event_details, event products, event location from)
-	print '<div class="divsearchfield">';
-	print img_picto($langs->trans("ActionsToDoBy"), 'fa-cogs', 'class="pictofixedwidth inline-block"');
-	print eventselector($eventdetails, 'eventdetails', 1);
-	print '</div>';
-	print '<div class="divsearchfield">';
-	print img_picto($langs->trans("ActionsToDoBy"), 'fa-product-hunt', 'class="pictofixedwidth inline-block"');
-	print eventselector($eventproduct, 'eventproduct', 1);
-	print '</div>';
-	print '<div class="divsearchfield">';
-	print img_picto($langs->trans("ActionsToDoBy"), 'fa-location-arrow', 'class="pictofixedwidth inline-block"');
-	print eventselector($eventlocation, 'eventlocation', 1);
-	print '</div>';
-	// Hooks
-	$parameters = array('canedit' => $canedit, 'pid' => $pid, 'socid' => $socid);
-	$object = null;
-	$reshook = $hookmanager->executeHooks('searchAgendaFrom', $parameters, $object, $action); // Note that $action and $object may have been
-
-	print '<div style="clear:both"></div>';
-}
-
-function eventselector($selected, $htmlname, $show_empty = 0,  $multiple = false, $disabled = 0)
-{
-	global $db, $langs;
-	$i = 0;
-	$out = '';
-	$morecss = '';
-	$textforempty = '&nbsp;';
-	$sql = "SELECT rowid, label FROM llx_eventwizard_{$htmlname} ORDER BY label ASC";
-	$result = $db->query($sql);
-	$num = $db->num_rows($result);
-
-	if ($selected === '') {
-		$selected = array();
-	} elseif (!is_array($selected)) {
-		$selected = array($selected);
-	}
-	if ($num) {
-		$out .= '<select class="flat' . ($morecss ? ' ' . $morecss : ' minwidth200') . '" id="search_' . $htmlname . '" name="search_' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>';
-		$out .= '<option class="optiongrey" value="' . ($show_empty < 0 ? $show_empty : -1) . '"' . ((empty($selected) || in_array(-1, $selected)) ? ' selected' : '') . '>' . $textforempty . '</option>' . "\n";
-		while ($i < $num) {
-			while ($obj = $db->fetch_object($result)) {
-				$out .= '<option value="' . $obj->rowid . '"';
-				if (in_array($obj->rowid, $selected)) {
-					$out .= ' selected';
-				}
-				$out .= '>';
-				$out .= $obj->label;
-				$out .= '</option>';
-				$i++;
-			}
-		}
-	} else {
-		$out .= '<select class="flat" id="search_' . $htmlname . '" name="search_' . $htmlname . '" disabled>';
-		$out .= '<option value="">' . $langs->trans("None") . '</option>';
-	}
-	$out .= '</select>';
-	return $out;
-}
-
 /**
  * Show event of a particular day
  *

+ 21 - 2
comm/action/list.php

@@ -35,6 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+require_once DOL_DOCUMENT_ROOT . '/comm/action/class/agendaplus.class.php';
 
 // Load translation files required by the page
 $langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", "orders", "bills"));
@@ -91,6 +92,12 @@ $filtert = GETPOST("search_filtert", "int", 3) ?GETPOST("search_filtert", "int",
 $usergroup = GETPOST("search_usergroup", "int", 3) ?GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3);
 $showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ?GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1;
 
+$agendaplus = new AgendaPlus();
+
+// new filters (event_details, event products, event location from)
+$eventdetails = $agendaplus->getSearchedElement('eventdetails');
+$eventproduct = $agendaplus->getSearchedElement('eventproduct');
+$eventlocation = $agendaplus->getSearchedElement('eventlocation');
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
 $object = new ActionComm($db);
 $hookmanager->initHooks(array('agendalist'));
@@ -103,7 +110,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
 // If not choice done on calendar owner, we filter on user.
 if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) {
-	$filtert = $user->id;
+	//$filtert = $user->id;
 }
 
 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
@@ -381,6 +388,9 @@ if (GETPOST('dateendyear_dtend', 'int')) {
 if ($optioncss != '') {
 	$param .= '&optioncss='.urlencode($optioncss);
 }
+
+$param .= $agendaplus->completeParamString($eventdetails, $eventproduct, $eventlocation);
+
 // Add $param from extra fields
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
 
@@ -407,6 +417,8 @@ $sql = "SELECT";
 if ($usergroup > 0) {
 	$sql .= " DISTINCT";
 }
+$sql .= $agendaplus->completeSqlSelectString($eventdetails, $eventproduct, $eventlocation);
+
 $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
 $sql .= " a.id, a.code, a.label, a.note, a.datep as dp, a.datep2 as dp2, a.fulldayevent, a.location,";
 $sql .= " a.fk_user_author, a.fk_user_action,";
@@ -436,6 +448,8 @@ if (empty($user->rights->societe->client->voir) && !$socid) {
 }
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
+$sql .= $agendaplus->completeSqlFromString($eventlocation);
+
 $sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
 // We must filter on resource table
 if ($resourceid > 0) {
@@ -582,6 +596,8 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 	}
 	$db->free($resql);
 }
+$sql .= " AND a.code = 'AC_EVENT'";
+$sql .= $agendaplus->completeSqlWhereString($eventdetails, $eventproduct, $eventlocation);
 
 // Complete request and execute it with limit
 $sql .= $db->order($sortfield, $sortorder);
@@ -589,6 +605,8 @@ if ($limit) {
 	$sql .= $db->plimit($limit + 1, $offset);
 }
 
+//print $sql;
+
 $resql = $db->query($sql);
 if (!$resql) {
 	dol_print_error($db);
@@ -721,7 +739,8 @@ if ($massactionbutton) {
 $i = 0;
 
 print '<div class="liste_titre liste_titre_bydiv centpercent">';
-print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+//print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+$agendaplus->new_print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, $eventdetails, $eventproduct, $eventlocation, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
 print '</div>';
 
 print '<div class="div-table-responsive">';

+ 20 - 20
custom/eventwizard/class/eventdetails.class.php

@@ -114,26 +114,26 @@ class EventDetails extends CommonObject
 	/**
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
 	 */
-	public $fields = array(
-		'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"),
-		'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 0, 'default' => '1', 'index' => 1,),
-		'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => '1', 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'validate' => '1', 'comment' => "Reference of object"),
-		'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => '1', 'position' => 30, 'notnull' => 0, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'help' => "Help text", 'showoncombobox' => '2', 'validate' => '1',),
-		'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label' => 'ThirdParty', 'enabled' => '1', 'position' => 50, 'notnull' => -1, 'visible' => 0, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'help' => "OrganizationEventLinkToThirdParty", 'validate' => '1',),
-		'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => '1', 'position' => 60, 'notnull' => 0, 'visible' => 3, 'validate' => '1',),
-		'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => '1', 'position' => 61, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => '1',),
-		'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => '1', 'position' => 62, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => '1',),
-		'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => '1', 'position' => 500, 'notnull' => 1, 'visible' => -2,),
-		'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 501, 'notnull' => 0, 'visible' => -2,),
-		'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => '1', 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',),
-		'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => '1', 'position' => 511, 'notnull' => -1, 'visible' => -2,),
-		'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => '1', 'position' => 600, 'notnull' => 0, 'visible' => 0,),
-		'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
-		'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => '1', 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
-		'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => '1', 'position' => 2000, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Piszkozat', '1' => 'Hiteles&iacute;tve', '9' => 'Cancelled'), 'validate' => '1',),
-		'type' => array('type' => 'integer:BasicServices:custom/bbus/class/basicservices.class.php', 'label' => 'Type', 'enabled' => '1', 'position' => 50, 'notnull' => 0, 'visible' => -1,),
-		'fk_elventlocation_departure' => array('type' => 'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label' => 'DeparturePoint', 'enabled' => '1', 'position' => 51, 'notnull' => 0, 'visible' => -1, 'default' => 'null',),
-		'fk_elventlocation_arrival' => array('type' => 'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label' => 'ArrivalPoint', 'enabled' => '1', 'position' => 52, 'notnull' => 0, 'visible' => -1, 'default' => 'null',),
+	public $fields=array(
+		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
+		'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'default'=>'1', 'index'=>1,),
+		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"),
+		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',),
+		'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>0, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"OrganizationEventLinkToThirdParty", 'validate'=>'1',),
+		'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
+		'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
+		'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
+		'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
+		'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
+		'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
+		'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
+		'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
+		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
+		'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
+		'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft / Piszkozat', '1'=>'Verified / Hitelesítve', '9'=>'Cancelled / Törölve'), 'validate'=>'1',),
+		'type' => array('type'=>'integer:BasicServices:custom/bbus/class/basicservices.class.php', 'label'=>'Type', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,),
+		'fk_elventlocation_departure' => array('type'=>'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label'=>'DeparturePoint', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>-1, 'default'=>'null',),
+		'fk_elventlocation_arrival' => array('type'=>'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label'=>'ArrivalPoint', 'enabled'=>'1', 'position'=>52, 'notnull'=>0, 'visible'=>-1, 'default'=>'null',),
 	);
 	public $rowid;
 	public $entity;

+ 119 - 105
custom/eventwizard/class/eventdetails.class.php.back

@@ -24,7 +24,8 @@
 
 // Put here all includes required by your class file
 use Luracast\Restler\RestException;
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+
+require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 
@@ -113,26 +114,26 @@ class EventDetails extends CommonObject
 	/**
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
 	 */
-	public $fields=array(
-		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
-		'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0, 'default'=>'1', 'index'=>1,),
-		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>4, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"),
-		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',),
-		'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>0, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"OrganizationEventLinkToThirdParty", 'validate'=>'1',),
-		'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',),
-		'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
-		'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',),
-		'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
-		'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
-		'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
-		'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
-		'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
-		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
-		'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
-		'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Piszkozat', '1'=>'Hiteles&iacute;tve', '9'=>'Cancelled'), 'validate'=>'1',),
-		'type' => array('type'=>'integer:BasicServices:custom/bbus/class/basicservices.class.php', 'label'=>'Type', 'enabled'=>'1', 'position'=>50, 'notnull'=>0, 'visible'=>-1,),
-		'fk_elventlocation_departure' => array('type'=>'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label'=>'Departure point', 'enabled'=>'1', 'position'=>51, 'notnull'=>0, 'visible'=>-1, 'default'=>'null',),
-		'fk_elventlocation_arrival' => array('type'=>'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label'=>'Arrival point', 'enabled'=>'1', 'position'=>52, 'notnull'=>0, 'visible'=>-1, 'default'=>'null',),
+	public $fields = array(
+		'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => '1', 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => '1', 'index' => 1, 'css' => 'left', 'comment' => "Id"),
+		'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => '1', 'position' => 10, 'notnull' => 1, 'visible' => 0, 'default' => '1', 'index' => 1,),
+		'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => '1', 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'validate' => '1', 'comment' => "Reference of object"),
+		'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => '1', 'position' => 30, 'notnull' => 0, 'visible' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'help' => "Help text", 'showoncombobox' => '2', 'validate' => '1',),
+		'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label' => 'ThirdParty', 'enabled' => '1', 'position' => 50, 'notnull' => -1, 'visible' => 0, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'help' => "OrganizationEventLinkToThirdParty", 'validate' => '1',),
+		'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => '1', 'position' => 60, 'notnull' => 0, 'visible' => 3, 'validate' => '1',),
+		'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => '1', 'position' => 61, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => '1',),
+		'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => '1', 'position' => 62, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => '1',),
+		'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => '1', 'position' => 500, 'notnull' => 1, 'visible' => -2,),
+		'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => '1', 'position' => 501, 'notnull' => 0, 'visible' => -2,),
+		'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => '1', 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid',),
+		'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => '1', 'position' => 511, 'notnull' => -1, 'visible' => -2,),
+		'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => '1', 'position' => 600, 'notnull' => 0, 'visible' => 0,),
+		'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => '1', 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
+		'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => '1', 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
+		'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => '1', 'position' => 2000, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array('0' => 'Piszkozat', '1' => 'Hiteles&iacute;tve', '9' => 'Cancelled'), 'validate' => '1',),
+		'type' => array('type' => 'integer:BasicServices:custom/bbus/class/basicservices.class.php', 'label' => 'Type', 'enabled' => '1', 'position' => 50, 'notnull' => 0, 'visible' => -1,),
+		'fk_elventlocation_departure' => array('type' => 'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label' => 'DeparturePoint', 'enabled' => '1', 'position' => 51, 'notnull' => 0, 'visible' => -1, 'default' => 'null',),
+		'fk_elventlocation_arrival' => array('type' => 'integer:EventLocation:custom/eventwizard/class/eventlocation.class.php:1:(t.status:=:1) AND (t.entity:in:__SHARED_ENTITIES__)', 'label' => 'ArrivalPoint', 'enabled' => '1', 'position' => 52, 'notnull' => 0, 'visible' => -1, 'default' => 'null',),
 	);
 	public $rowid;
 	public $entity;
@@ -272,15 +273,15 @@ class EventDetails extends CommonObject
 		// Load source object
 		$result = $object->fetchCommon($fromid);
 		if ($result > 0 && !empty($object->table_element_line)) {
-			require_once DOL_DOCUMENT_ROOT.'/custom/eventwizard/class/eventdetailsline.class.php';
-			require_once DOL_DOCUMENT_ROOT.'/custom/eventwizard/class/eventproduct.class.php';
-			require_once DOL_DOCUMENT_ROOT.'/custom/eventwizard/class/eventoption.class.php';
+			require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventdetailsline.class.php';
+			require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventproduct.class.php';
+			require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventoption.class.php';
 			require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 			$object->fetchLines();
 		}
 
 		// get lines so they will be clone
-		foreach($this->lines as $line)
+		foreach ($this->lines as $line)
 			$line->fetch_optionals();
 
 		// Reset some properties
@@ -290,10 +291,10 @@ class EventDetails extends CommonObject
 
 		// Clear fields
 		if (property_exists($object, 'ref')) {
-			$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
+			$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_" . $object->ref : $this->fields['ref']['default'];
 		}
 		if (property_exists($object, 'label')) {
-			$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
+			$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf") . " " . $object->label : $this->fields['label']['default'];
 		}
 		if (property_exists($object, 'status')) {
 			$object->status = self::STATUS_DRAFT;
@@ -366,9 +367,9 @@ class EventDetails extends CommonObject
 	{
 		$result = $this->fetchCommon($id, $ref);
 		if ($result > 0 && !empty($this->table_element_line)) {
-			require_once DOL_DOCUMENT_ROOT.'/custom/eventwizard/class/eventdetailsline.class.php';
-			require_once DOL_DOCUMENT_ROOT.'/custom/eventwizard/class/eventproduct.class.php';
-			require_once DOL_DOCUMENT_ROOT.'/custom/eventwizard/class/eventoption.class.php';
+			require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventdetailsline.class.php';
+			require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventproduct.class.php';
+			require_once DOL_DOCUMENT_ROOT . '/custom/eventwizard/class/eventoption.class.php';
 			require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 			$this->fetchLines();
 		}
@@ -388,7 +389,7 @@ class EventDetails extends CommonObject
 		return $result;
 	}
 
-	
+
 	/**
 	 * Load list of objects in memory from the database.
 	 *
@@ -410,9 +411,9 @@ class EventDetails extends CommonObject
 
 		$sql = "SELECT ";
 		$sql .= $this->getFieldList('t');
-		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
+		$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element . " as t";
 		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
-			$sql .= " WHERE t.entity IN (".getEntity($this->element).")";
+			$sql .= " WHERE t.entity IN (" . getEntity($this->element) . ")";
 		} else {
 			$sql .= " WHERE 1 = 1";
 		}
@@ -421,20 +422,20 @@ class EventDetails extends CommonObject
 		if (count($filter) > 0) {
 			foreach ($filter as $key => $value) {
 				if ($key == 't.rowid') {
-					$sqlwhere[] = $key." = ".((int) $value);
+					$sqlwhere[] = $key . " = " . ((int) $value);
 				} elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
-					$sqlwhere[] = $key." = '".$this->db->idate($value)."'";
+					$sqlwhere[] = $key . " = '" . $this->db->idate($value) . "'";
 				} elseif ($key == 'customsql') {
 					$sqlwhere[] = $value;
 				} elseif (strpos($value, '%') === false) {
-					$sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
+					$sqlwhere[] = $key . " IN (" . $this->db->sanitize($this->db->escape($value)) . ")";
 				} else {
-					$sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
+					$sqlwhere[] = $key . " LIKE '%" . $this->db->escape($value) . "%'";
 				}
 			}
 		}
 		if (count($sqlwhere) > 0) {
-			$sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
+			$sql .= " AND (" . implode(" " . $filtermode . " ", $sqlwhere) . ")";
 		}
 
 		if (!empty($sortfield)) {
@@ -462,8 +463,8 @@ class EventDetails extends CommonObject
 
 			return $records;
 		} else {
-			$this->errors[] = 'Error '.$this->db->lasterror();
-			dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
+			$this->errors[] = 'Error ' . $this->db->lasterror();
+			dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
 
 			return -1;
 		}
@@ -524,13 +525,13 @@ class EventDetails extends CommonObject
 	{
 		global $conf, $langs;
 
-		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+		require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
 
 		$error = 0;
 
 		// Protection
 		if ($this->status == self::STATUS_VALIDATED) {
-			dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
+			dol_syslog(get_class($this) . "::validate action abandonned: already validated", LOG_WARNING);
 			return 0;
 		}
 
@@ -556,18 +557,18 @@ class EventDetails extends CommonObject
 
 		if (!empty($num)) {
 			// Validate
-			$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
-			$sql .= " SET ref = '".$this->db->escape($num)."',";
-			$sql .= " status = ".self::STATUS_VALIDATED;
+			$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element;
+			$sql .= " SET ref = '" . $this->db->escape($num) . "',";
+			$sql .= " status = " . self::STATUS_VALIDATED;
 			if (!empty($this->fields['date_validation'])) {
-				$sql .= ", date_validation = '".$this->db->idate($now)."'";
+				$sql .= ", date_validation = '" . $this->db->idate($now) . "'";
 			}
 			if (!empty($this->fields['fk_user_valid'])) {
-				$sql .= ", fk_user_valid = ".((int) $user->id);
+				$sql .= ", fk_user_valid = " . ((int) $user->id);
 			}
-			$sql .= " WHERE rowid = ".((int) $this->id);
+			$sql .= " WHERE rowid = " . ((int) $this->id);
 
-			dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
+			dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
 			$resql = $this->db->query($sql);
 			if (!$resql) {
 				dol_print_error($this->db);
@@ -591,30 +592,31 @@ class EventDetails extends CommonObject
 			// Rename directory if dir was a temporary ref
 			if (preg_match('/^[\(]?PROV/i', $this->ref)) {
 				// Now we rename also files into index
-				$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'eventdetails/".$this->db->escape($this->newref)."'";
-				$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'eventdetails/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+				$sql = 'UPDATE ' . MAIN_DB_PREFIX . "ecm_files set filename = CONCAT('" . $this->db->escape($this->newref) . "', SUBSTR(filename, " . (strlen($this->ref) + 1) . ")), filepath = 'eventdetails/" . $this->db->escape($this->newref) . "'";
+				$sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'eventdetails/" . $this->db->escape($this->ref) . "' and entity = " . $conf->entity;
 				$resql = $this->db->query($sql);
 				if (!$resql) {
-					$error++; $this->error = $this->db->lasterror();
+					$error++;
+					$this->error = $this->db->lasterror();
 				}
 
 				// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
 				$oldref = dol_sanitizeFileName($this->ref);
 				$newref = dol_sanitizeFileName($num);
-				$dirsource = $conf->eventwizard->dir_output.'/eventdetails/'.$oldref;
-				$dirdest = $conf->eventwizard->dir_output.'/eventdetails/'.$newref;
+				$dirsource = $conf->eventwizard->dir_output . '/eventdetails/' . $oldref;
+				$dirdest = $conf->eventwizard->dir_output . '/eventdetails/' . $newref;
 				if (!$error && file_exists($dirsource)) {
-					dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
+					dol_syslog(get_class($this) . "::validate() rename dir " . $dirsource . " into " . $dirdest);
 
 					if (@rename($dirsource, $dirdest)) {
 						dol_syslog("Rename ok");
 						// Rename docs starting with $oldref with $newref
-						$listoffiles = dol_dir_list($conf->eventwizard->dir_output.'/eventdetails/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
+						$listoffiles = dol_dir_list($conf->eventwizard->dir_output . '/eventdetails/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/'));
 						foreach ($listoffiles as $fileentry) {
 							$dirsource = $fileentry['name'];
-							$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
-							$dirsource = $fileentry['path'].'/'.$dirsource;
-							$dirdest = $fileentry['path'].'/'.$dirdest;
+							$dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource);
+							$dirsource = $fileentry['path'] . '/' . $dirsource;
+							$dirdest = $fileentry['path'] . '/' . $dirdest;
 							@rename($dirsource, $dirdest);
 						}
 					}
@@ -730,14 +732,14 @@ class EventDetails extends CommonObject
 
 		$result = '';
 
-		$label = img_picto('', $this->picto).' <u>'.$langs->trans("EventDetails").'</u>';
+		$label = img_picto('', $this->picto) . ' <u>' . $langs->trans("EventDetails") . '</u>';
 		if (isset($this->status)) {
-			$label .= ' '.$this->getLibStatut(5);
+			$label .= ' ' . $this->getLibStatut(5);
 		}
 		$label .= '<br>';
-		$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
+		$label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
 
-		$url = dol_buildpath('/eventwizard/eventdetails_card.php', 1).'?id='.$this->id;
+		$url = dol_buildpath('/eventwizard/eventdetails_card.php', 1) . '?id=' . $this->id;
 
 		if ($option != 'nolink') {
 			// Add param to save lastsearch_values or not
@@ -754,20 +756,20 @@ class EventDetails extends CommonObject
 		if (empty($notooltip)) {
 			if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
 				$label = $langs->trans("ShowEventDetails");
-				$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+				$linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';
 			}
-			$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
-			$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+			$linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"';
+			$linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"';
 		} else {
-			$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+			$linkclose = ($morecss ? ' class="' . $morecss . '"' : '');
 		}
 
 		if ($option == 'nolink' || empty($url)) {
 			$linkstart = '<span';
 		} else {
-			$linkstart = '<a href="'.$url.'"';
+			$linkstart = '<a href="' . $url . '"';
 		}
-		$linkstart .= $linkclose.'>';
+		$linkstart .= $linkclose . '>';
 		if ($option == 'nolink' || empty($url)) {
 			$linkend = '</span>';
 		} else {
@@ -778,29 +780,29 @@ class EventDetails extends CommonObject
 
 		if (empty($this->showphoto_on_popup)) {
 			if ($withpicto) {
-				$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+				$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
 			}
 		} else {
 			if ($withpicto) {
-				require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+				require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
 
 				list($class, $module) = explode('@', $this->picto);
-				$upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
+				$upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref);
 				$filearray = dol_dir_list($upload_dir, "files");
 				$filename = $filearray[0]['name'];
 				if (!empty($filename)) {
 					$pospoint = strpos($filearray[0]['name'], '.');
 
-					$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
-					if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
-						$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
+					$pathtophoto = $class . '/' . $this->ref . '/thumbs/' . substr($filename, 0, $pospoint) . '_mini' . substr($filename, $pospoint);
+					if (empty($conf->global->{strtoupper($module . '_' . $class) . '_FORMATLISTPHOTOSASUSERS'})) {
+						$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo' . $module . '" alt="No photo" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $module . '&entity=' . $conf->entity . '&file=' . urlencode($pathtophoto) . '"></div></div>';
 					} else {
-						$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
+						$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $module . '&entity=' . $conf->entity . '&file=' . urlencode($pathtophoto) . '"></div>';
 					}
 
 					$result .= '</div>';
 				} else {
-					$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+					$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="' . (($withpicto != 2) ? 'paddingright ' : '') . 'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
 				}
 			}
 		}
@@ -814,7 +816,7 @@ class EventDetails extends CommonObject
 
 		global $action, $hookmanager;
 		$hookmanager->initHooks(array('eventdetailsdao'));
-		$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
+		$parameters = array('id' => $this->id, 'getnomurl' => &$result);
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 		if ($reshook > 0) {
 			$result = $hookmanager->resPrint;
@@ -869,7 +871,7 @@ class EventDetails extends CommonObject
 			$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
 		}
 
-		$statusType = 'status'.$status;
+		$statusType = 'status' . $status;
 		//if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
 		if ($status == self::STATUS_CANCELED) {
 			$statusType = 'status6';
@@ -889,8 +891,8 @@ class EventDetails extends CommonObject
 		$sql = "SELECT rowid,";
 		$sql .= " date_creation as datec, tms as datem,";
 		$sql .= " fk_user_creat, fk_user_modif";
-		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
-		$sql .= " WHERE t.rowid = ".((int) $id);
+		$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element . " as t";
+		$sql .= " WHERE t.rowid = " . ((int) $id);
 
 		$result = $this->db->query($sql);
 		if ($result) {
@@ -942,7 +944,7 @@ class EventDetails extends CommonObject
 		$this->lines = array();
 
 		$objectline = new EventDetailsLine($this->db);
-		$result = $objectline->fetchAll('ASC', 'rowid', 0, 0, array('customsql'=>'fk_eventdetails = '.((int) $this->id)));
+		$result = $objectline->fetchAll('ASC', 'rowid', 0, 0, array('customsql' => 'fk_eventdetails = ' . ((int) $this->id)));
 
 		if (is_numeric($result)) {
 			$this->error = $objectline->error;
@@ -971,20 +973,20 @@ class EventDetails extends CommonObject
 		if (!empty($conf->global->EVENTWIZARD_EVENTDETAILS_ADDON)) {
 			$mybool = false;
 
-			$file = $conf->global->EVENTWIZARD_EVENTDETAILS_ADDON.".php";
+			$file = $conf->global->EVENTWIZARD_EVENTDETAILS_ADDON . ".php";
 			$classname = $conf->global->EVENTWIZARD_EVENTDETAILS_ADDON;
 
 			// Include file with class
 			$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 			foreach ($dirmodels as $reldir) {
-				$dir = dol_buildpath($reldir."core/modules/eventwizard/");
+				$dir = dol_buildpath($reldir . "core/modules/eventwizard/");
 
 				// Load file with numbering class (if found)
-				$mybool |= @include_once $dir.$file;
+				$mybool |= @include_once $dir . $file;
 			}
 
 			if ($mybool === false) {
-				dol_print_error('', "Failed to include file ".$file);
+				dol_print_error('', "Failed to include file " . $file);
 				return '';
 			}
 
@@ -1000,7 +1002,7 @@ class EventDetails extends CommonObject
 					return "";
 				}
 			} else {
-				print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
+				print $langs->trans("Error") . " " . $langs->trans("ClassNotFound") . ' ' . $classname;
 				return "";
 			}
 		} else {
@@ -1079,15 +1081,15 @@ class EventDetails extends CommonObject
 	}
 
 
-	public function genEvents($data){
+	public function genEvents($data)
+	{
 
 		global $conf, $langs, $user;
 		//event
-		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+		require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
 		if (!$user->rights->agenda->myactions->create) {
 			// throw new RestException(401, "Insufficient rights to create your Agenda Event");
 			throw new RestException(401, "user->rights->agenda->myactions->create DENIED");
-
 		}
 		if (!$user->rights->agenda->allactions->create && $user->id != $request_data['userownerid']) {
 			// throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.$user->id);
@@ -1098,31 +1100,33 @@ class EventDetails extends CommonObject
 		// $result = $this->_validate($request_data);
 
 		// foreach ($request_data as $field => $value) {
-			// $this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm);
+		// $this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm);
 		// }
 		$now = dol_now();
-		
+
 		//... !!! $this->db->begin();
-		$AC_EVENT_ID = getDictionaryValue('c_actioncomm','id','AC_EVENT',false,'code');
-		if(!$AC_EVENT_ID){
+		$AC_EVENT_ID = getDictionaryValue('c_actioncomm', 'id', 'AC_EVENT', false, 'code');
+		if (!$AC_EVENT_ID) {
 			throw new RestException(401, "AC_EVENT_ID missing!");
 		}
-		foreach($data['dates'] as $k=>$v){
-			foreach($v as $k2=>$v2){
+		foreach ($data['dates'] as $k => $v) {
+			foreach ($v as $k2 => $v2) {
 				$this->actioncomm = new ActionComm($this->db);
-				
+
 				$this->actioncomm->entity = 1;
 				$this->actioncomm->fk_parent = 0;
 				$this->actioncomm->ref = '(PROV)';
+				$this->actioncomm->ref = 'Label';
+				$this->actioncomm->label = $this->getEventDetailsLabel((int)$data['id_eventdetails']);
 				$this->actioncomm->datec = $this->db->idate($now);
-				$this->actioncomm->datep = $k.' '.$v2['start'];
+				$this->actioncomm->datep = strtotime($k . ' ' . $v2['start']);
 				// $this->actioncomm->datef = $k.' '.$v2['end'];
-				$timeExpl = explode(":",$v2['duration']);
-				$time = new DateTime($this->actioncomm->datep);
-				$time->add(new DateInterval('PT' . $timeExpl[0] . 'H'. $timeExpl[1] . 'M'));
-				$this->actioncomm->datef = $time->format('Y-m-d H:i');
+				$timeExpl = explode(":", $v2['duration']);
+				$time = new DateTime($k . ' ' . $v2['start']);
+				$time->add(new DateInterval('PT' . $timeExpl[0] . 'H' . $timeExpl[1] . 'M'));
+				$this->actioncomm->datef = strtotime($time->format('Y-m-d H:i:s'));
 				// $this->actioncomm->datep2 = $k.' '.$v2['end'];
-				
+
 				$this->actioncomm->type_id = $AC_EVENT_ID;
 				$this->actioncomm->code = 'AC_EVENT';
 				$this->actioncomm->elementtype = 'eventdetails@eventwizard';
@@ -1141,7 +1145,7 @@ class EventDetails extends CommonObject
 					"buffer" => (int)$data['buffer'],
 					"participants" => (int)$data['participants']
 				];
-				
+
 				// 	transparency	priority	visibility	fulldayevent	percent	location	durationp	label	note	calling_duration	email_subject	email_msgid	email_from	email_sender	email_to	email_tocc	email_tobcc	errors_to	reply_to	recurid	recurrule	recurdateend	num_vote	event_paid	status	fk_element	elementtype	import_key	extraparams
 				// $this->actioncomm->
 				// $info = [];
@@ -1160,5 +1164,15 @@ class EventDetails extends CommonObject
 		}
 		return true;
 	}
-}
 
+	private function getEventDetailsLabel($eventdetails_id) {
+		$sql = "SELECT label FROM llx_eventwizard_eventdetails WHERE rowid = {$eventdetails_id}";
+		$result = $this->db->query($sql);
+		if($this->db->num_rows($result) > 0){
+			while($row = $this->db->fetch_object($result)){
+				return $row->label;
+			}
+		}
+		return '';
+	}
+}

+ 2 - 2
custom/eventwizard/eventdetails_card.php

@@ -781,8 +781,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 						//autoUpdateInput: false,
 						locale: {
 							"format": "'.$langs->trans('DateFormatYYYYMMDD').'",
-							cancelLabel: "'.$langs->trans('Mégse').'",
-							applyLabel: "'.$langs->trans('Rendben').'",
+							cancelLabel: "'.$langs->trans('Cancel').'",
+							applyLabel: "'.$langs->trans('Ok').'",
 							"monthNames": [
 								"'.$langs->trans('Month01').'",
 								"'.$langs->trans('Month02').'",