Example #1
0
 /**
  * Print the user preference form
  *
  * @param $target          form target
  * @param $ID     integer  Id of the user
  *
  * @return boolean : user found
  **/
 function showMyForm($target, $ID)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) {
         return false;
     }
     if ($this->getFromDB($ID)) {
         $rand = mt_rand();
         $authtype = $this->getAuthMethodsByID();
         $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
         // No autocopletion :
         $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"];
         $CFG_GLPI["use_ajax_autocompletion"] = false;
         echo "<div class='center'>";
         echo "<form method='post' name='user_manager' enctype='multipart/form-data' action='" . $target . "' autocomplete='off'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Login'), $this->fields["name"]);
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
         if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) {
             echo $this->fields["realname"];
         } else {
             Html::autocompletionTextField($this, "realname");
         }
         echo "</td>";
         if (!empty($this->fields["name"])) {
             echo "<td rowspan='3'>" . __('Picture') . "</td>";
             echo "<td rowspan='3'>";
             echo "<div class='user_picture_border_small' id='picture{$rand}'>";
             echo "<img class='user_picture_small' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($this->fields['picture']) . "'>";
             echo "</div>";
             $full_picture = "<div class='user_picture_border'>";
             $full_picture .= "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getURLForPicture($this->fields['picture']) . "'>";
             $full_picture .= "</div>";
             Html::showTooltip($full_picture, array('applyto' => "picture{$rand}"));
             echo "<input type='file' name='picture' accept='image/*'>";
             echo "&nbsp;";
             Html::showCheckbox(array('name' => '_blank_picture', 'title' => __('Clear')));
             echo "&nbsp;" . __('Clear');
             echo "</td>";
             echo "</tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
         if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
             echo $this->fields["firstname"];
         } else {
             Html::autocompletionTextField($this, "firstname");
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         if (!GLPI_DEMO_MODE) {
             echo "<td>" . __('Language') . "</td><td>";
             // Use session variable because field in table may be null if same of the global config
             Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
         //do some rights verification
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Password') . "</td>";
             echo "<td><input id='password' type='password' name='password' value='' size='30' autocomplete='off' onkeyup=\"return passwordCheck();\">";
             echo "</td>";
             echo "<td rowspan='2'>" . __('Password security policy') . "</td>";
             echo "<td rowspan='2'>";
             Config::displayPasswordSecurityChecks();
             echo "</td>";
             echo "</tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Password confirmation') . "</td>";
             echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>";
         if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
             echo $this->fields["phone"];
         } else {
             Html::autocompletionTextField($this, "phone");
         }
         echo "</td>";
         echo "<td class='top'>" . _n('Email', 'Emails', Session::getPluralNumber());
         UserEmail::showAddEmailButton($this);
         echo "</td><td>";
         UserEmail::showForUser($this);
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . "&nbsp;</td><td>";
         if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
             echo $this->fields["mobile"];
         } else {
             Html::autocompletionTextField($this, "mobile");
         }
         echo "</td>";
         if (count($_SESSION['glpiprofiles']) > 1) {
             echo "<td>" . __('Default profile') . "</td><td>";
             $options = Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"], 'display_emptychoice' => true));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>";
         if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
             echo $this->fields["phone2"];
         } else {
             Html::autocompletionTextField($this, "phone2");
         }
         echo "</td>";
         $entities = Profile_User::getUserEntities($this->fields['id'], 1);
         if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
             echo "<td>" . __('Default entity') . "</td><td>";
             Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Administrative number') . "</td><td>";
         if ($extauth && isset($authtype['registration_number_field']) && !empty($authtype['registration_number_field'])) {
             echo $this->fields["registration_number"];
         } else {
             Html::autocompletionTextField($this, "registration_number");
         }
         echo "</td><td colspan='2'></td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
         $entities = Profile_User::getUserEntities($ID, true);
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities));
         if (Config::canUpdate()) {
             echo "<td>" . __('Use GLPI in mode') . "</td><td>";
             $modes[Session::NORMAL_MODE] = __('Normal');
             //$modes[Session::TRANSLATION_MODE] = __('Translation');
             $modes[Session::DEBUG_MODE] = __('Debug');
             Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
         return true;
     }
     return false;
 }
Example #2
0
    /**
     * Print a nice HTML head for help page
     *
     * @param $title  title of the page
     * @param $url    not used anymore (default '')
     **/
    static function helpHeader($title, $url = '')
    {
        global $CFG_GLPI, $HEADER_LOADED, $PLUGIN_HOOKS, $DB;
        // Print a nice HTML-head for help page
        if ($HEADER_LOADED) {
            return;
        }
        $HEADER_LOADED = true;
        self::includeHeader($title);
        // Body
        echo "<body>";
        echo '
<nav class="navbar navbar-default" id="menuHeader">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="' . $CFG_GLPI["root_doc"] . '/front/central.php">
      	<img src="' . $CFG_GLPI["root_doc"] . '/pics/fd_logo1.png" style="margin-top:-4px;" />
      	<span class=\'invisible\'>Logo</span>
      </a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">';
        echo "<li id='menu1'>";
        echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\" class='itemP'>" . __('Home') . "</a>";
        echo "</li>";
        //  Create ticket
        if (Session::haveRight("ticket", CREATE)) {
            echo "<li id='menu2'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1' " . "title=\"" . __s('Create a ticket') . "\" class='itemP'>" . __('Create a ticket') . "</a>";
            echo "</li>";
        }
        //  Suivi ticket
        if (Session::haveRight("ticket", Ticket::READMY) || Session::haveRight("followup", TicketFollowup::SEEPUBLIC)) {
            echo "<li id='menu3'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php' title=\"" . __s('Ticket followup') . "\" class='itemP'>" . _n('Ticket', 'Tickets', Session::getPluralNumber()) . "</a>";
            echo "</li>";
        }
        // Reservation
        if (Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
            echo "<li id='menu4'>";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.php' title=\"" . _sn('Reservation', 'Reservations', Session::getPluralNumber()) . "\" class='itemP'>" . _n('Reservation', 'Reservations', Session::getPluralNumber()) . "</a>";
            echo "</li>";
        }
        // FAQ
        if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
            echo "<li id='menu5' >";
            echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.faq.php' title=\"" . __s('FAQ') . "\" class='itemP'>" . __('FAQ') . "</a>";
            echo "</li>";
        }
        // PLUGINS
        $plugins = array();
        if (isset($PLUGIN_HOOKS["helpdesk_menu_entry"]) && count($PLUGIN_HOOKS["helpdesk_menu_entry"])) {
            foreach ($PLUGIN_HOOKS["helpdesk_menu_entry"] as $plugin => $active) {
                if ($active) {
                    $plugins[$plugin] = Plugin::getInfo($plugin);
                }
            }
        }
        if (isset($plugins) && count($plugins) > 0) {
            $list = array();
            foreach ($plugins as $key => $val) {
                $list[$key] = $val["name"];
            }
            asort($list);
            //echo "<li id='menu5' onmouseover=\"javascript:menuAff('menu5','menu');\">";
            echo "<li id='menu5'>";
            echo "<a href='#' title=\"" . _sn('Plugin', 'Plugins', Session::getPluralNumber()) . "\" class='itemP'>" . __('Plugins') . "</a>";
            // default none
            echo "<ul class='ssmenu'>";
            // list menu item
            foreach ($list as $key => $val) {
                $link = "";
                if (is_string($PLUGIN_HOOKS["helpdesk_menu_entry"][$key])) {
                    $link = $PLUGIN_HOOKS["helpdesk_menu_entry"][$key];
                }
                echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/plugins/" . $key . $link . "'>" . $plugins[$key]["name"] . "</a></li>\n";
            }
            echo "</ul></li>";
        }
        echo "<div class='sep'></div>";
        echo '</ul>';
        echo '<ul class="nav navbar-nav navbar-right">';
        $sql_photo2 = "SELECT picture\n\t\t\t\t\t\t\t\tFROM glpi_users\n\t\t\t\t\t\t\t\tWHERE id = " . $_SESSION["glpiID"] . " ";
        $res_photo2 = $DB->query($sql_photo2);
        $pic2 = $DB->result($res_photo2, 0, 'picture');
        $photo_url2 = User::getURLForPicture($pic2);
        echo '<li class="dropdown">';
        echo '<a href="#" style="padding:0px; margin:0px;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><img src="' . $photo_url2 . '" class="avatar" alt="" title="' . formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20) . '" /></a>';
        echo "<ul class=\"dropdown-menu\" role=\"menu\">";
        echo "<li><a href='" . (empty($CFG_GLPI["central_doc_url"]) ? "http://glpi-project.org/help-central" : $CFG_GLPI["central_doc_url"]) . "' target='_blank' title=\"" . __s('Help') . "\"><i class='fa fa-question-circle'></i> " . __('Help') . "</a></li>";
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . __s('My settings') . "\"><i class='fa fa-cog'></i> " . __('My settings') . "</a></li>";
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . addslashes(Dropdown::getLanguageName($_SESSION['glpilanguage'])) . "\"><i class='fa fa-flag'></i> " . Dropdown::getLanguageName($_SESSION['glpilanguage']) . "</a></li>";
        echo "<li id='deconnexion'><a href='" . $CFG_GLPI["root_doc"] . "/front/logout.php";
        // logout witout noAuto login for extauth
        if (isset($_SESSION['glpiextauth']) && $_SESSION['glpiextauth']) {
            echo "?noAUTO=1";
        }
        echo "' title=\"" . __s('Logout') . "\"><i class='fa fa-lock'></i> " . __('Logout') . "</a>";
        // check user id : header used for display messages when session logout
        if (Session::getLoginUserID()) {
            //echo " (";
            // echo formatUserName (0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20);
            // echo ")";
        }
        echo "</li>\n";
        echo "</ul>";
        echo '  </li>';
        echo '
			      </ul>
			    </div><!-- /.navbar-collapse -->
			  </div><!-- /.container-fluid -->
			</nav> ';
        echo '<nav class="navbar navbar-default nav2" style="margin-top: -20px;">';
        // Display item
        echo "<div id='c_ssmenu2'>";
        echo "<ul>";
        echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\">" . __('Home') . "></a></li>";
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        if (Session::haveRightsOr('ticketvalidation', array(TicketValidation::VALIDATEREQUEST, TicketValidation::VALIDATEINCIDENT))) {
            $opt = array();
            $opt['reset'] = 'reset';
            $opt['criteria'][0]['field'] = 55;
            // validation status
            $opt['criteria'][0]['searchtype'] = 'equals';
            $opt['criteria'][0]['value'] = TicketValidation::WAITING;
            $opt['criteria'][0]['link'] = 'AND';
            $opt['criteria'][1]['field'] = 59;
            // validation aprobator
            $opt['criteria'][1]['searchtype'] = 'equals';
            $opt['criteria'][1]['value'] = Session::getLoginUserID();
            $opt['criteria'][1]['link'] = 'AND';
            $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&amp;');
            $pic_validate = "<a href='{$url_validate}'>" . "<img title=\"" . __s('Ticket waiting for your approval') . "\" alt=\"" . __s('Ticket waiting for your approval') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png'></a>";
            echo "<li>{$pic_validate}</li>\n";
        }
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        if (Session::haveRight('ticket', CREATE) && strpos($_SERVER['PHP_SELF'], "ticket")) {
            echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1'>";
            echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"></a></li>";
        }
        echo "<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>";
        /// Bookmark load
        echo "<li>";
        Ajax::createIframeModalWindow('loadbookmark', $CFG_GLPI["root_doc"] . "/front/bookmark.php?action=load", array('title' => __('Load a bookmark'), 'reloadonclose' => true));
        echo "<a href='#' onClick=\"" . Html::jsGetElementbyID('loadbookmark') . ".dialog('open');\"\">";
        echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png' title=\"" . __s('Load a bookmark') . "\" alt=\"" . __s('Load a bookmark') . "\">";
        echo "</a></li>";
        // check user id : header used for display messages when session logout
        if (Session::getLoginUserID()) {
            self::showProfileSelecter($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
        }
        echo "</ul></div>";
        //end c_ssmenu2
        Html::scriptStart();
        echo self::jsGetElementbyID('show_all_menu') . ".dialog({\n         height: 'auto',\n         width: 'auto',\n         modal: true,\n         autoOpen: false\n         });";
        echo Html::scriptEnd();
        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        // echo "</li>";
        echo '</nav>';
    }
                    }
                    if ($barra > 51 and $barra < 80) {
                        $cor = "progress-bar-warning";
                    }
                    if ($barra > 0 and $barra <= 50) {
                        $cor = "progress-bar-danger";
                    }
                    if ($barra < 0) {
                        $cor = "progress-bar-danger";
                        $barra = 0;
                    }
                }
            } else {
                $barra = 0;
            }
            echo "\n\t\t<tr>\n\t\t\t<td style='vertical-align:middle; text-align:left;'><i class='del fa fa-times' style='cursor:pointer;' title='" . __('Hide') . "'>&nbsp;&nbsp;&nbsp; </i>\n\t\t\t<img class='avatar2' width='40px' height='43px' src='" . User::getURLForPicture($id_tec['picture']) . "'></img>&nbsp;&nbsp;\t\n\t\t\t<a href='rel_tecnico.php?con=1&tec=" . $id_tec['id'] . "&date1=" . $data_ini . "&date2=" . $data_fin . "' target='_blank' >" . $id_tec['fname'] . ' ' . $id_tec['rname'] . ' (' . $id_tec['id'] . ")</a>\n\t\t\t</td>\n\t\t\t<td style='vertical-align:middle; text-align:center;'> " . $id_tec['chamados'] . " </td>\n\t\t\t<td style='vertical-align:middle; text-align:center;'> " . $abertos . " </td>\n\t\t\t<td style='vertical-align:middle; text-align:center;'> " . $solucionados . " </td>\n\t\t\t<td style='vertical-align:middle; text-align:center;'> " . $fechados . " </td>\t\t\t\n\t\t\t<td style='vertical-align:middle; text-align:center;'> \n\t\t\t\t<div class='progress' style='margin-top: 5px; margin-bottom: 5px;'>\n\t\t\t\t\t<div class='progress-bar " . $cor . " progress-bar-striped active' role='progressbar' aria-valuenow='" . $barra . "' aria-valuemin='0' aria-valuemax='100' style='width: " . $barra . "%;'>\n\t\t\t \t\t\t" . $barra . " % \t\n\t\t\t \t\t</div>\t\t\n\t\t\t\t</div>\t\t\t\n\t\t   </td>";
            if ($sats != '') {
                echo "<td style='vertical-align:middle; text-align:center;'> \t\n\t\t\t\t\t<img src='../img/s" . $nota . ".png' alt='" . $satisfacao . " %' title='" . $satisfacao . " %'>\n\t\t\t\t</td>";
            }
            echo "</tr>";
            //fim while1
        }
        echo "</tbody>\n\t\t</table>\n\t\t</div>";
        //fim $con
    }
}
?>

<script type="text/javascript" charset="utf-8">

$('#tec')
            </div>
            <!-- /widget-header -->
            
				<?php 
if ($num_users <= 10) {
    echo '<div class="widget-content striped" style="min-height:318px;">';
} else {
    echo '<div class="widget-content striped" style="min-height:318px;">';
}
//echo '   <div class="widget-content striped ">'; }
?>
        
              <table id="logged_users" class="table table-hover table-bordered table-condensed" >                         
				<?php 
while ($row_name = $DB->fetch_assoc($result_name)) {
    echo "<tr>\n\t\t\t\t\t\t\t\t\t<td style='text-align: left;'><img src=" . User::getURLForPicture($row_name['picture']) . " alt='user' width='30px' height='35px' />&nbsp; &nbsp;<a href=../../../front/user.form.php?id=" . $row_name['uid'] . " target=_blank style='color: #526273;'>\n\t\t\t\t\t\t\t\t\t\t" . $row_name['name'] . " " . $row_name['sname'] . " (" . $row_name['uid'] . ")</a>\t\n\t\t\t\t\t\t\t\t\t</td>\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</tr>";
}
?>
                                       
              </table>
              
            </div>
            <!-- /widget-content --> 
          </div>
	</div>                    		
          <!-- content row 2 --> 
	<!-- </div> -->                    
   </div>       
	</div> 
 
<script>
        break;
    case "4":
        $dia = __('Thursday', 'dashboard');
        break;
    case "5":
        $dia = __('Friday', 'dashboard');
        break;
    case "6":
        $dia = __('Saturday', 'dashboard');
        break;
}
//user image and name
$sql_photo = "SELECT picture \n\t\t\t\tFROM glpi_users\n\t\t\t\tWHERE id = " . $_SESSION["glpiID"] . " ";
$res_photo = $DB->query($sql_photo);
$pic = $DB->result($res_photo, 0, 'picture');
$photo_url = User::getURLForPicture($pic);
//redirect tech profile
if (Session::haveRight("profile", READ)) {
    $redir = '<meta http-equiv="refresh" content= "120"/>';
} else {
    $redir = '<meta http-equiv="refresh" content="0; url=graficos/graf_tech.php?con=1" />';
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>GLPI - Dashboard - Home</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php