blob: 787f665377363e9d84241721d61cae0782d31a78 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::ADMIN);
4
5$mdHeaderRowBefore = visual::backBtn("settings.php");
6?>
7<!DOCTYPE html>
8<html>
9<head>
10 <title><?php echo $conf["appName"]; ?></title>
11 <?php visual::includeHead(); ?>
12 <link rel="stylesheet" href="css/dashboard.css">
13
14 <style>
15 .addcompany {
16 position: fixed;
17 bottom: 16px;
18 right: 16px;
19 z-index: 1000;
20 }
21
22 @media (max-width: 655px) {
23 .extra {
24 display: none;
25 }
26 }
27 </style>
28</head>
29<?php visual::printBodyTag(); ?>
30 <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header mdl-layout--fixed-drawer">
31 <?php visual::includeNav(); ?>
32 <button class="addcompany mdl-button md-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--accent"><i class="material-icons">add</i><span class="mdl-ripple"></span></button>
33 <main class="mdl-layout__content">
34 <div class="page-content">
35 <div class="main mdl-shadow--4dp">
36 <h2>Empresas</h2>
37 <?php
38 $companies = companies::getAll(false);
39 if (count($companies)) {
40 ?>
41 <div class="overflow-wrapper overflow-wrapper--for-table">
42 <table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
43 <thead>
44 <tr>
45 <th class="extra">ID</th>
46 <th class="mdl-data-table__cell--non-numeric">Empresa</th>
47 <th class="mdl-data-table__cell--non-numeric">CIF</th>
48 <th class="mdl-data-table__cell--non-numeric"></th>
49 </tr>
50 </thead>
51 <tbody>
52 <?php
53 foreach ($companies as $c) {
54 ?>
55 <tr>
56 <td class="extra"><?=(int)$c["id"]?></td>
57 <td class="mdl-data-table__cell--non-numeric"><?=security::htmlsafe($c["name"])?></td>
58 <td class="mdl-data-table__cell--non-numeric"><?=(empty($c["cif"]) ? "-" : security::htmlsafe($c["cif"]))?></td>
59 <td class='mdl-data-table__cell--non-numeric'><a href='dynamic/editcompany.php?id=<?=(int)$c["id"]?>' data-dyndialog-href='dynamic/editcompany.php?id=<?=(int)$c["id"]?>' title='Editar empresa'><i class='material-icons icon'>edit</i></a></td>
60 </tr>
61 <?php
62 }
63 ?>
64 </tbody>
65 </table>
66 </div>
67 <?php
68 } else {
69 ?>
70 <p>Todavía no hay definida ninguna empresa.</p>
71 <p>Puedes añadir una haciendo clic en el botón de la esquina inferior derecha de la página.</p>
72 <?php
73 }
74 ?>
75
76 <?php visual::printDebug("companies::getAll()", $companies); ?>
77 </div>
78 </div>
79 </main>
80 </div>
81
82 <dialog class="mdl-dialog" id="addcompany">
83 <form action="doaddcompany.php" method="POST" autocomplete="off">
84 <h4 class="mdl-dialog__title">Añade una empresa</h4>
85 <div class="mdl-dialog__content">
86 <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
87 <input class="mdl-textfield__input" type="text" name="name" id="name" autocomplete="off" data-required>
88 <label class="mdl-textfield__label" for="name">Nombre de la empresa</label>
89 </div>
90 <br>
91 <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
92 <input class="mdl-textfield__input" type="text" name="cif" id="cif" autocomplete="off">
93 <label class="mdl-textfield__label" for="cif">CIF (opcional)</label>
94 </div>
95 </div>
96 <div class="mdl-dialog__actions">
97 <button type="submit" class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent">Añadir</button>
98 <button onclick="event.preventDefault(); document.querySelector('#addcompany').close();" class="mdl-button mdl-js-button mdl-js-ripple-effect cancel">Cancelar</button>
99 </div>
100 </form>
101 </dialog>
102
103 <?php
104 visual::smartSnackbar([
105 ["added", "Se ha añadido la empresa correctamente."],
106 ["modified", "Se ha modificado la empresa correctamente."],
107 ["empty", "Faltan datos por introducir en el formulario."],
108 ["unexpected", "Ha ocurrido un error inesperado. Inténtelo de nuevo en unos segundos."]
109 ]);
110 ?>
111
112 <script src="js/companies.js"></script>
113</body>
114</html>