| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?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 = ' ';
- $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;
- }
- }
|