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 | $companies = companies::getAll(); |
| 6 | |
| 7 | $date = new DateTime(); |
| 8 | $interval = new DateInterval("P1D"); |
| 9 | $date->sub($interval); |
| 10 | $yesterday = date("Y-m-d", $date->getTimestamp()); |
| 11 | ?> |
| 12 | <!DOCTYPE html> |
| 13 | <html> |
| 14 | <head> |
| 15 | <title><?php echo $conf["appName"]; ?></title> |
| 16 | <?php visual::includeHead(); ?> |
| 17 | <link rel="stylesheet" href="css/dashboard.css"> |
| 18 | |
| 19 | <style> |
| 20 | .categories-select { |
| 21 | float: right; |
| 22 | border-left: 1px solid #ccc; |
| 23 | padding: 0 32px 16px 16px; |
| 24 | user-select: none; |
| 25 | } |
| 26 | |
| 27 | .categories-select .select-all { |
| 28 | color: blue; |
| 29 | text-decoration: underline; |
| 30 | cursor: pointer; |
| 31 | } |
| 32 | |
| 33 | @media (max-width: 500px) { |
| 34 | .categories-select { |
| 35 | float: none; |
| 36 | border-left: none; |
| 37 | border-top: 1px solid #ddd; |
| 38 | border-bottom: 1px solid #ddd; |
| 39 | padding: 0 0 16px 0; |
| 40 | margin-bottom: 16px; |
| 41 | } |
| 42 | } |
| 43 | </style> |
| 44 | </head> |
| 45 | <?php visual::printBodyTag(); ?> |
| 46 | <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer"> |
| 47 | <?php visual::includeNav(); ?> |
| 48 | <main class="mdl-layout__content"> |
| 49 | <div class="page-content"> |
| 50 | <div class="main mdl-shadow--4dp"> |
| 51 | <h2>Exportar registro</h2> |
| 52 | <p>Aquí puedes configurar cómo quieres exportar los datos del registro:</p> |
| 53 | <form action="doexport.php" method="GET"> |
| 54 | <h5>Periodo</h5> |
| 55 | <p>Del <input type="date" name="begins" max="<?=security::htmlsafe($yesterday)?>" required> al <input type="date" name="ends" max="<?=security::htmlsafe($yesterday)?>" required></p> |
| 56 | |
| 57 | <h5>Empresas</h5> |
| 58 | <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label"> |
| 59 | <div id="companies" class="mdlext-selectfield__select mdl-custom-selectfield__select" tabindex="0">-</div> |
| 60 | <ul class="mdl-menu mdl-menu--bottom mdl-js-menu mdl-custom-multiselect mdl-custom-multiselect-js" for="companies"> |
| 61 | <?php |
| 62 | foreach (companies::getAll() as $id => $company) { |
| 63 | if ($id == calendars::TYPE_FESTIU) continue; |
| 64 | ?> |
| 65 | <li class="mdl-menu__item mdl-custom-multiselect__item"> |
| 66 | <label class="mdl-checkbox mdl-js-checkbox" for="company-<?=(int)$id?>"> |
| 67 | <input type="checkbox" id="company-<?=(int)$id?>" name="companies[]" value="<?=(int)$id?>" data-value="<?=(int)$id?>" class="mdl-checkbox__input"> |
| 68 | <span class="mdl-checkbox__label"><?=security::htmlsafe($company)?></span> |
| 69 | </label> |
| 70 | </li> |
| 71 | <?php |
| 72 | } |
| 73 | ?> |
| 74 | </ul> |
| 75 | <label for="companies" class="mdlext-selectfield__label always-focused mdl-color-text--primary">Empresas</label> |
| 76 | </div> |
| 77 | |
| 78 | <h5>Trabajadores</h5> |
| 79 | <div class="categories-select"> |
| 80 | <h6>Seleccionar:</h6> |
| 81 | <?php |
| 82 | $categories = categories::getAllWithWorkers(); |
| 83 | foreach ($categories as $c) { |
| 84 | if (!count($c["workers"])) continue; |
| 85 | echo "<span class=\"select-all\" data-workers=\"".security::htmlsafe(implode(",", $c["workers"]))."\">".security::htmlsafe($c["name"])."</span><br>"; |
| 86 | } |
| 87 | ?> |
| 88 | </div> |
| 89 | <div class="overflow-wrapper overflow-wrapper--for-table"> |
| 90 | <table class="mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp"> |
| 91 | <thead> |
| 92 | <tr> |
| 93 | <?php |
| 94 | if ($conf["debug"]) { |
| 95 | ?> |
| 96 | <th class="extra">ID</th> |
| 97 | <?php |
| 98 | } |
| 99 | ?> |
| 100 | <th class="mdl-data-table__cell--non-numeric">Nombre</th> |
| 101 | <th class="mdl-data-table__cell--non-numeric">Empresa</th> |
| 102 | <th class="mdl-data-table__cell--non-numeric extra">Categoría</th> |
| 103 | </tr> |
| 104 | </thead> |
| 105 | <tbody> |
| 106 | <?php |
| 107 | $workers = people::getAll(false, true); |
| 108 | foreach ($workers as $w) { |
| 109 | ?> |
| 110 | <tr data-worker-id="<?=(int)$w["workerid"]?>" data-company-id="<?=(int)$w["companyid"]?>"> |
| 111 | <?php |
| 112 | if ($conf["debug"]) { |
| 113 | ?> |
| 114 | <td class="extra"><?=(int)$w["workerid"]?></td> |
| 115 | <?php |
| 116 | } |
| 117 | ?> |
| 118 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($w["name"])?></td> |
| 119 | <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($companies[$w["companyid"]])?></td> |
| 120 | <td class="mdl-data-table__cell--non-numeric extra"><?=security::htmlsafe($w["category"])?></td> |
| 121 | </tr> |
| 122 | <?php |
| 123 | } |
| 124 | ?> |
| 125 | </tbody> |
| 126 | </table> |
| 127 | </div> |
| 128 | |
| 129 | <div style="clear: both;"></div> |
| 130 | |
| 131 | <h5>Formato</h5> |
| 132 | <div class="mdlext-selectfield mdlext-js-selectfield mdlext-selectfield--floating-label"> |
| 133 | <select name="format" id="format" class="mdlext-selectfield__select"> |
| 134 | <?php |
| 135 | foreach (export::$formats as $i => $format) { |
| 136 | echo '<option value="'.(int)$i.'">'.security::htmlsafe($format).'</option>'; |
| 137 | } |
| 138 | ?> |
| 139 | </select> |
| 140 | <label for="format" class="mdlext-selectfield__label">Formato</label> |
| 141 | </div> |
| 142 | |
| 143 | <div id="pdf"> |
| 144 | <h5>Opciones para PDF</h5> |
| 145 | <p> |
| 146 | <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="ignoreempty"> |
| 147 | <input type="checkbox" id="ignoreempty" name="ignoreempty" value="1" class="mdl-switch__input" checked> |
| 148 | <span class="mdl-switch__label">No incluir trabajadores que no tengan ningún registro ni incidencia</span> |
| 149 | </label> |
| 150 | </p> |
| 151 | <p> |
| 152 | <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="labelinvalid"> |
| 153 | <input type="checkbox" id="labelinvalid" name="labelinvalid" value="1" class="mdl-switch__input" checked> |
| 154 | <span class="mdl-switch__label">Marcar en rojo incidencias/registros no validados</span> |
| 155 | </label> |
| 156 | </p> |
| 157 | <p style="font-weight: bold;"> |
| 158 | Mostrar registros/incidencias que estén: |
| 159 | </p> |
| 160 | <p> |
| 161 | <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="showvalidated"> |
| 162 | <input type="checkbox" id="showvalidated" name="showvalidated" value="1" class="mdl-checkbox__input" checked> |
| 163 | <span class="mdl-checkbox__label">Validados</span> |
| 164 | </label> |
| 165 | <br> |
| 166 | <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="shownotvalidated"> |
| 167 | <input type="checkbox" id="shownotvalidated" name="shownotvalidated" value="1" class="mdl-checkbox__input" checked> |
| 168 | <span class="mdl-checkbox__label">No validados</span> |
| 169 | </label> |
| 170 | </p> |
| 171 | </div> |
| 172 | <br> |
| 173 | <button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect">Exportar</button> |
| 174 | </form> |
| 175 | |
| 176 | <?php visual::printDebug("categories::getAllWithWorkers()", $categories); ?> |
| 177 | </div> |
| 178 | </div> |
| 179 | </main> |
| 180 | </div> |
| 181 | |
| 182 | <?php |
| 183 | visual::smartSnackbar([ |
| 184 | ["empty", "Faltan datos por introducir en el formulario."], |
| 185 | ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."], |
| 186 | ["inverted", "La fecha de inicio debe ser anterior a la de fin."], |
| 187 | ["forecastingthefutureisimpossible", "La fecha de fin debe ser anterior al día de hoy."] |
| 188 | ]); |
| 189 | ?> |
| 190 | |
| 191 | <script src="js/export.js"></script> |
| 192 | </body> |
| 193 | </html> |