Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::ADMIN); |
| 4 | |
| 5 | $mdHeaderRowMore = '<div class="mdl-layout-spacer"></div> |
| 6 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable |
| 7 | mdl-textfield--floating-label mdl-textfield--align-right"> |
| 8 | <label class="mdl-button mdl-js-button mdl-button--icon" |
| 9 | for="usuario"> |
| 10 | <i class="material-icons">search</i> |
| 11 | </label> |
| 12 | <div class="mdl-textfield__expandable-holder"> |
| 13 | <input class="mdl-textfield__input" type="text" name="usuario" |
| 14 | id="usuario"> |
| 15 | </div> |
| 16 | </div>'; |
| 17 | |
| 18 | listings::buildSelect("users.php"); |
| 19 | |
| 20 | $categories = categories::getAll(); |
| 21 | $companies = companies::getAll(); |
| 22 | ?> |
| 23 | <!DOCTYPE html> |
| 24 | <html> |
| 25 | <head> |
| 26 | <title><?php echo $conf["appName"]; ?></title> |
| 27 | <?php visual::includeHead(); ?> |
| 28 | <link rel="stylesheet" href="css/dashboard.css"> |
| 29 | |
| 30 | <style> |
| 31 | .adduser { |
| 32 | position: fixed; |
| 33 | bottom: 16px; |
| 34 | right: 16px; |
| 35 | } |
| 36 | .importcsv { |
| 37 | position:fixed; |
| 38 | bottom: 80px; |
| 39 | right: 25px; |
| 40 | } |
| 41 | .filter { |
| 42 | position:fixed; |
| 43 | bottom: 126px; |
| 44 | right: 25px; |
| 45 | } |
| 46 | .adduser, .importcsv, .filter { |
| 47 | z-index: 1000; |
| 48 | } |
| 49 | |
| 50 | @media (max-width: 655px) { |
| 51 | .extra { |
| 52 | display: none; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /* Hide datable's search box */ |
| 57 | .dataTables_wrapper .mdl-grid:first-child { |
| 58 | display: none; |
| 59 | } |
| 60 | .dt-table { |
| 61 | padding: 0!important; |
| 62 | } |
| 63 | .dt-table .mdl-cell { |
| 64 | margin: 0!important; |
| 65 | } |
| 66 | #usuario { |
| 67 | position: relative; |
| 68 | } |
| 69 | </style> |
| 70 | </head> |
| 71 | <?php visual::printBodyTag(); ?> |
| 72 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 73 | <?php visual::includeNav(); ?> |
| 74 | <button class="adduser mdl-button md-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--accent"><i class="material-icons">person_add</i><span class="mdl-ripple"></span></button> |
| 75 | <button class="importcsv mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-color--grey-200"><i class="material-icons">file_upload</i></button> |
| 76 | <button class="filter mdl-button mdl-js-button mdl-button--fab mdl-button--mini-fab mdl-color--grey-200"><i class="material-icons">filter_list</i></button> |
| 77 | <main class="mdl-layout__content"> |
| 78 | <div class="page-content"> |
| 79 | <div class="main mdl-shadow--4dp"> |
| 80 | <h2>Personas</h2> |
| 81 | <div class="overflow-wrapper overflow-wrapper--for-table"> |
| 82 | <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp datatable"> |
| 83 | <thead> |
| 84 | <tr> |
| 85 | <?php |
| 86 | if ($conf["debug"]) { |
| 87 | ?> |
| 88 | <th class="extra">ID</th> |
| 89 | <?php |
| 90 | } |
| 91 | ?> |
| 92 | <th class="mdl-data-table__cell--non-numeric">Nombre</th> |
| 93 | <th class="mdl-data-table__cell--non-numeric">Categoría</th> |
| 94 | <th class="mdl-data-table__cell--non-numeric extra">Tipo</th> |
| 95 | <th class="mdl-data-table__cell--centered">Baja</th> |
| 96 | <th class="mdl-data-table__cell--non-numeric"></th> |
| 97 | </tr> |
| 98 | </thead> |
| 99 | <tbody> |
| 100 | <?php |
| 101 | $people = people::getAll($select); |
| 102 | foreach ($people as $p) { |
| 103 | ?> |
| 104 | <tr> |
| 105 | <?php |
| 106 | if ($conf["debug"]) { |
| 107 | ?> |
| 108 | <td class="extra"><?=(int)$p["id"]?></td> |
| 109 | <?php |
| 110 | } |
| 111 | ?> |
| 112 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($p["name"])?></td> |
| 113 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe(($p["categoryid"] == -1 ? "-" : $p["category"]))?></td> |
| 114 | <td class="mdl-data-table__cell--non-numeric extra"><?=security::htmlsafe(security::$types[$p["type"]])?></td> |
| 115 | <td class="mdl-data-table__cell--centered"><?=($p["baixa"] == 1 ? visual::YES : "")?></td> |
| 116 | <td class='mdl-data-table__cell--non-numeric'> |
| 117 | <a href='dynamic/user.php?id=<?=(int)$p['id']?>' data-dyndialog-href='dynamic/user.php?id=<?=(int)$p['id']?>' title='Ver información completa'><i class='material-icons icon'>open_in_new</i></a> |
| 118 | <?php if (security::isAllowed($p['type'])) { ?> |
| 119 | <a href='dynamic/edituser.php?id=<?=(int)$p['id']?>' data-dyndialog-href='dynamic/edituser.php?id=<?=(int)$p['id']?>' title='Editar persona'><i class='material-icons icon'>edit</i></a> |
| 120 | <?php } ?> |
| 121 | <a href='dynamic/companyuser.php?id=<?=(int)$p['id']?>' data-dyndialog-href='dynamic/companyuser.php?id=<?=(int)$p['id']?>' title='Ver y añadir empresas a la persona'><i class='material-icons icon'>work</i></a> |
| 122 | <?php if (count($p['companies'])) { ?> |
| 123 | <a href='workerschedule.php?id=<?=(int)$p['id']?>' title='Ver y gestionar los horarios de la persona'><i class='material-icons icon'>timelapse</i></a> |
| 124 | <a href='userincidents.php?id=<?=(int)$p['id']?>' title='Ver y gestionar las incidencias del trabajador'><i class='material-icons icon'>assignment_late</i></a> |
| 125 | <a href='userregistry.php?id=<?=(int)$p['id']?>' title='Ver y gestionar los registros del trabajador'><i class='material-icons icon'>list</i></a> |
| 126 | <?php } ?> |
| 127 | </td> |
| 128 | </tr> |
| 129 | <?php |
| 130 | } |
| 131 | ?> |
| 132 | </tbody> |
| 133 | </table> |
| 134 | </div> |
| 135 | |
| 136 | <?php visual::printDebug("people::getAll(\$select)", $people); ?> |
| 137 | <?php visual::printDebug("\$select", $select); ?> |
| 138 | </div> |
| 139 | </div> |
| 140 | </main> |
| 141 | </div> |
| 142 | |
| 143 | <dialog class="mdl-dialog" id="adduser"> |
| 144 | <form action="doadduser.php" method="POST" autocomplete="off"> |
| 145 | <h4 class="mdl-dialog__title">Añade un trabajador</h4> |
| 146 | <div class="mdl-dialog__content"> |
| 147 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 148 | <input class="mdl-textfield__input" type="text" name="username" id="username" autocomplete="off" data-required> |
| 149 | <label class="mdl-textfield__label" for="username">Nombre de usuario</label> |
| 150 | </div> |
| 151 | <br> |
| 152 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 153 | <input class="mdl-textfield__input" type="text" name="name" id="name" autocomplete="off" data-required> |
| 154 | <label class="mdl-textfield__label" for="name">Nombre</label> |
| 155 | </div> |
| 156 | <br> |
| 157 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 158 | <input class="mdl-textfield__input" type="text" name="dni" id="dni" autocomplete="off"> |
| 159 | <label class="mdl-textfield__label" for="dni">DNI (opcional)</label> |
| 160 | </div> |
| 161 | <br> |
| 162 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 163 | <input class="mdl-textfield__input" type="email" name="email" id="email" autocomplete="off"> |
| 164 | <label class="mdl-textfield__label" for="email">Correo electrónico (opcional)</label> |
| 165 | </div> |
| 166 | <br> |
| 167 | <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label"> |
| 168 | <select name="category" id="category" class="mdlext-selectfield__select"> |
| 169 | <option value="-1"></option> |
| 170 | <?php |
| 171 | foreach ($categories as $id => $category) { |
| 172 | echo '<option value="'.(int)$id.'">'.security::htmlsafe($category).'</option>'; |
| 173 | } |
| 174 | ?> |
| 175 | </select> |
| 176 | <label for="category" class="mdlext-selectfield__label">Categoría (opcional)</label> |
| 177 | </div> |
| 178 | <br> |
| 179 | <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> |
| 180 | <input class="mdl-textfield__input" type="password" name="password" id="password" autocomplete="off" data-required> |
| 181 | <label class="mdl-textfield__label" for="password">Contraseña</label> |
| 182 | </div> |
| 183 | <p><?=security::htmlsafe(security::$passwordHelperText)?></p> |
| 184 | <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label" data-required> |
| 185 | <select name="type" id="type" class="mdlext-selectfield__select"> |
| 186 | <?php |
| 187 | foreach (security::$types as $i => $type) { |
| 188 | echo '<option value="'.(int)$i.'"'.(security::isAllowed($i) ? "" : " disabled").'>'.security::htmlsafe($type).'</option>'; |
| 189 | } |
| 190 | ?> |
| 191 | </select> |
| 192 | <label for="type" class="mdlext-selectfield__label">Tipo</label> |
| 193 | </div> |
| 194 | </div> |
| 195 | <div class="mdl-dialog__actions"> |
| 196 | <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Añadir</button> |
| 197 | <button onclick="event.preventDefault(); document.querySelector('#adduser').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button> |
| 198 | </div> |
| 199 | </form> |
| 200 | </dialog> |
| 201 | |
| 202 | <dialog class="mdl-dialog" id="importcsv"> |
| 203 | <form action="csvimport.php" method="POST" enctype="multipart/form-data"> |
| 204 | <h4 class="mdl-dialog__title">Importar CSV</h4> |
| 205 | <div class="mdl-dialog__content"> |
| 206 | <p>Selecciona debajo el archivo CSV:</p> |
| 207 | <p><input type="file" name="file" accept=".csv" required></p> |
| 208 | <p>El formato de la cabecera debe ser: <code><?=security::htmlsafe(implode(";", csv::$fields))?></code></p> |
| 209 | <p>En la columna <code>category</code>, introduce el ID de la categoría ya creada en el sistema (o <code>-1</code> si no quieres definir una categoría para esa persona), y en la columna <code>companies</code> introduce una lista separada por comas de los IDs de las empresas que quieres añadir a esa persona.</p> |
| 210 | </div> |
| 211 | <div class="mdl-dialog__actions"> |
| 212 | <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Importar</button> |
| 213 | <button onclick="event.preventDefault(); document.querySelector('#importcsv').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button> |
| 214 | </div> |
| 215 | </form> |
| 216 | </dialog> |
| 217 | |
| 218 | <?php listings::renderFilterDialog("users.php", $select); ?> |
| 219 | |
| 220 | <?php |
| 221 | visual::smartSnackbar([ |
| 222 | ["added", "Se ha añadido la persona correctamente."], |
| 223 | ["modified", "Se ha modificado la persona correctamente."], |
| 224 | ["empty", "Faltan datos por introducir en el formulario o el correo electrónico es incorrecto."], |
| 225 | ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."], |
| 226 | ["couldntupdatepassword", "Se ha actualizado la información pero no se ha podido actualizar la contraseña. Inténtelo de nuevo en unos segundos."], |
| 227 | ["weakpassword", security::$passwordHelperText], |
| 228 | ["disabledsecondfactor", "Se ha desactivado la verificación en dos pasos correctamente."] |
| 229 | ]); |
| 230 | ?> |
| 231 | |
| 232 | <script src="js/users.js"></script> |
| 233 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
| 234 | <script src="node_modules/datatables/media/js/jquery.dataTables.min.js"></script> |
| 235 | <script src="lib/datatables/dataTables.material.min.js"></script> |
| 236 | </body> |
| 237 | </html> |