index.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. $http_host = $_SERVER['HTTP_HOST'];
  3. $default_host = substr($http_host, 0, strpos($http_host, ':'));
  4. include("../functions.php");
  5. $con = startdb();
  6. if (!checkSession($con)){
  7. header("Location: /index.php");
  8. exit (-1);
  9. }
  10. else{
  11. //Get year
  12. $year = date("Y");
  13. ?>
  14. <html>
  15. <head>
  16. <meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
  17. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
  18. <title>Preparar las fiestas de <?php echo $year; ?> - Administracion</title>
  19. <!-- CSS files -->
  20. <link rel="stylesheet" type="text/css" href="/css/ui.css"/>
  21. <link rel="stylesheet" type="text/css" href="/css/lablanca.css"/>
  22. <!-- CSS for mobile version -->
  23. <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
  24. <link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/lablanca.css"/>
  25. <!-- Script files -->
  26. <script type="text/javascript" src="script.js"></script>
  27. </head>
  28. <body onLoad='calculate("all");'>
  29. <div id='content'>
  30. <div class='section' id='section_header'>
  31. <h4>Paso 1: Cabecera de la p&aacute;gina de fiestas</h4>
  32. <div class='entry status' id='status_header'>
  33. ...calculando...
  34. </div>
  35. <div class='entry' id='entry_header'>
  36. <div class='header_text'>
  37. Texto castellano:
  38. <?php
  39. $q = mysqli_query($con, "SELECT * FROM festival WHERE year = $year;");
  40. $r = mysqli_fetch_array($q);
  41. echo "<textarea onChange='updateField(\"festival\", \"text_es\", this.value, $r[id], \"text\", false);calculate(\"header\");'>$r[text_es]</textarea>\n";
  42. ?>
  43. </div>
  44. <div class='header_text'>
  45. Texto ingl&eacute;s:
  46. <?php
  47. echo "<textarea onChange='updateField(\"festival\", \"text_en\", this.value, $r[id]);calculate(\"header\");'>$r[text_en]</textarea>\n";
  48. ?>
  49. </div>
  50. <div class='header_text'>
  51. Texto euskera:
  52. <?php
  53. echo "<textarea onChange='updateField(\"festival\", \"text_eu\", this.value, $r[id]);calculate(\"header\");'>$r[text_eu]</textarea>\n";
  54. ?>
  55. </div>
  56. <div id='header_image'>
  57. Cartel:<br/>
  58. <?php
  59. if (mysqli_num_rows($q) > 0){
  60. if (strlen($r['img']) == 0){
  61. echo "<img id='header_img' src='/img/lablanca/header-null.png'/><br/>\n";
  62. }
  63. else{
  64. echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
  65. }
  66. }
  67. else{
  68. echo "<img id='header_img' src='http://$default_host/img/fiestas/miniature/$r[img]'/><br/>\n";
  69. }
  70. echo "<input type='file' id='header_img_selector' onChange='uploadHeaderImage(event, $r[id]);calculate(\"header\");'/>\n";
  71. ?>
  72. </div>
  73. </div>
  74. </div>
  75. <div class='section' id='section_prices'>
  76. <h4>Paso 2: Seleccionar precios:</h4>
  77. <div class='entry status' id='status_prices'>
  78. ...calculando...
  79. </div>
  80. <div class='entry' id='entry_prices'>
  81. <?php
  82. $q = mysqli_query($con, "SELECT * FROM festival_day WHERE year(date) = '$year' AND price > 0;");
  83. if (mysqli_num_rows($q) != 6){
  84. echo "<input type='button' value='A&ntilde;adir precios'/>\n"; //TODO onclick
  85. echo "<input type='button' value='Utilzar precios del a&ntilde;o pasado'/>\n"; //TODO onclick
  86. }
  87. else{
  88. echo "<h4>D&iacute;as sueltos:</h4>";
  89. echo "<table id='prices'><tr><th>Fecha</th>";
  90. echo "<th>Nombre<br/>castellano</th><th>Nombre<br/>ingl&eacute;s</th><th>Nombre<br/>euskera</th>";
  91. echo "<th>Precio</th></tr>\n";
  92. $dates = ["25 Jul", "5 Ago", "6 Ago", "7 Ago", "8 Ago", "9 Ago"];
  93. $i = 0;
  94. while ($r = mysqli_fetch_array($q)){
  95. echo "<tr><td>" . $dates[$i];
  96. if ($r['name_en'] == $r['name_es']){
  97. $en = '';
  98. }
  99. else{
  100. $en = $r['name_en'];
  101. }
  102. if ($r['name_eu'] == $r['name_es']){
  103. $eu = '';
  104. }
  105. else{
  106. $eu = $r['name_eu'];
  107. }
  108. echo "</td>\n";
  109. echo "<td><input type='text' value='$r[name_es]' onchange='updateField(\"festival_day\", \"name_es\", this.value, $r[id]);'/></td>\n";
  110. echo "<td><input type='text' value='$en' onchange='updateField(\"festival_day\", \"name_en\", this.value, $r[id]);'/></td>\n";
  111. echo "<td><input type='text' value='$eu' onchange='updateField(\"festival_day\", \"name_eu\", this.value, $r[id]);'/></td>\n";
  112. echo "<td><input type='number' value='$r[price]' onchange='updateField(\"festival_day\", \"price\", this.value, $r[id], \"number\", false);'/>&euro;</td></tr>";
  113. $i = $i + 1;
  114. }
  115. echo "</table>\n";
  116. echo "<div id='prices_offers'>\n";
  117. echo "...calculando...\n";
  118. echo "</div>\n";
  119. }
  120. ?>
  121. </div>
  122. </div>
  123. <div class='section' id='section_schedule'>
  124. <h4>Paso 3: Establecer programa:</h4>
  125. <div class='entry status' id='status_schedule'>
  126. ...calculando...
  127. </div>
  128. <div class='entry entry_schedule' id='entry_schedule_25'>
  129. <h4><img src='/img/misc/slid-right.png' onClick='expandSchedule(25);'/>25 de julio</h4>
  130. <div id='list_schedule_25' class='list_schedule'>
  131. </div>
  132. Nuevo:
  133. <table class='new_event'>
  134. <tr class='title'>
  135. <th>Castellano</th>
  136. <th>Euskera</th>
  137. <th>Ingl&eacute;s</th>
  138. </tr>
  139. <tr>
  140. <td>
  141. <input type='text' id='new_event_25_name_es' placeholder='Nombre'/><br/>
  142. <textarea id='new_event_25_description_es' placeholder='Descripcion'></textarea>
  143. </td>
  144. <td>
  145. <input type='text' id='new_event_25_name_en' placeholder='Nombre'/><br/>
  146. <textarea id='new_event_25_description_en' placeholder='Descripcion'></textarea>
  147. </td>
  148. <td>
  149. <input type='text' id='new_event_25_name_eu' placeholder='Nombre'/><br/>
  150. <textarea id='new_event_25_description_eu' placeholder='Descripcion'></textarea>
  151. </td>
  152. </tr>
  153. <tr class='title'>
  154. <th>Inicio - Fin</th>
  155. <th>Organiza</th>
  156. <th>Lugar</th>
  157. </tr>
  158. <tr>
  159. <td>
  160. <input type='number' value='00' id='new_event_25_start_h'/>:
  161. <input type='number' value='00' id='new_event_25_start_m'/> --
  162. <input type='number' id='new_event_25_end_h'/>:
  163. <input type='number' id='new_event_25_end_m'/>
  164. </td>
  165. <td>
  166. <select id='new_event_25_host' class='new_event_host'>
  167. <option value='-2' selected='selected'>SELECCIONA...</option>
  168. <option value='-1' selected='selected'>A&Ntilde;ADIR NUEVO...</option>
  169. <?php
  170. $q = mysqli_query($con, "SELECT * FROM people;");
  171. while ($r = mysqli_fetch_array($q)){
  172. echo "<option value='$r[id]'>$r[name_es]</option>\n";
  173. }
  174. ?>
  175. </select>
  176. </td>
  177. <td>
  178. <select id='new_event_25_host' class='new_event_host'>
  179. <option value='-2' selected='selected'>SELECCIONA...</option>
  180. <option value='-1' selected='selected'>A&Ntilde;ADIR NUEVO...</option>
  181. <?php
  182. $q = mysqli_query($con, "SELECT * FROM place;");
  183. while ($r = mysqli_fetch_array($q)){
  184. echo "<option value='$r[id]'>$r[name_es] ($r[address_es])</option>\n";
  185. }
  186. ?>
  187. </select>
  188. </td>
  189. </tr>
  190. </table>
  191. </div>
  192. </div>
  193. </div>
  194. <div id='screen_cover'></div>
  195. <div id='form_new_offer' class='section'>
  196. <h3>A&ntilde;adir oferta</h3>
  197. <div class='entry'>
  198. <table>
  199. <tr>
  200. <th>Castellano</th><th>Ingl&eacute;s</th><th>Euskera</th><th>D&iacute;as</th><th>Precio</th>
  201. </tr>
  202. <tr>
  203. <td>
  204. <input type='text' id='new_offer_title_es'/><br/>
  205. <textarea id='new_offer_text_es'></textarea>
  206. </td>
  207. <td class='large'>
  208. <input type='text' id='new_offer_title_en'/><br/>
  209. <textarea id='new_offer_text_en'></textarea>
  210. </td>
  211. <td/>
  212. <input type='text' id='new_offer_title_eu'/><br/>
  213. <textarea id='new_offer_text_eu'></textarea>
  214. </td>
  215. <td class='small'>
  216. <input type='number' value='1' id='new_offer_days'/>
  217. </td>
  218. <td class='small'>
  219. <input type='number' value='0' id='new_offer_price'/>&euro;
  220. </td>
  221. </tr>
  222. </table>
  223. <div id='controls'>
  224. <input type='button' value='Guardar' onClick='saveNewOffer(<?php echo $year;?>);'/>
  225. <input type='button' value='Cancelar' onClick='cancelNewOffer();'/>
  226. </div>
  227. </div>
  228. </div>
  229. </body>
  230. </html>
  231. <?php } ?>