File: /var/www/biblioteka/wp-content/plugins/bibliotekos-zemelapis/nauja.php
<?php
function gauti_sifrus($lent)
{
global $wpdb;
$table_name2 = $wpdb->prefix . 'sifrai';
$lentynos = $wpdb->get_results("SELECT * FROM $table_name2 WHERE lent = '$lent'");
foreach ($lentynos as $key => $value) {
echo '<td><input type="checkbox" name="trinti_s[]" id="trinti_s" value="'.$value->id.'">'.$value->sifras.'</td>';
}
}
function gauti_temas($lent)
{
global $wpdb;
$table_name = $wpdb->prefix . 'temos';
$lentynos = $wpdb->get_results("SELECT * FROM $table_name WHERE lent = '$lent'");
foreach ($lentynos as $key => $value) {
echo '<td><input type="checkbox" name="trinti[]" id="trinti" value="'.$value->id_t.'">'.$value->tema.'</td>';
}
}
?>
<form class="forma" method="POST">
<div class="form-title"><h2>Pridėti</h2></div>
<label for="lent">Lentyna</label>
<select name="lent" id="lent" class="form-field">
<option value="lent1">Lentyna 1</option>
<option value="lent2">Lentyna 2</option>
<option value="lent3">Lentyna 3</option>
<option value="lent4">Lentyna 4</option>
<option value="lent5">Lentyna 5</option>
<option value="lent6">Lentyna 6</option>
<option value="lent7">Lentyna 7</option>
<option value="lent8">Lentyna 8</option>
<option value="lent9">Lentyna 9</option>
<option value="lent10">Lentyna 10</option>
<option value="lent11">Lentyna 11</option>
<option value="lent12">Lentyna 12</option>
<option value="lent13">Lentyna 13</option>
<option value="lent14">Lentyna 14</option>
<option value="lent15">Lentyna 15</option>
<option value="lent16">Lentyna 16</option>
<option value="lent17">Lentyna 17</option>
<option value="lent18">Lentyna 18</option>
<option value="lent19">Lentyna 19</option>
<option value="lent20">Lentyna 20</option>
<option value="lent21">Lentyna 21</option>
<option value="lent1apv">Lentyna 1 apvali</option>
<option value="lent2apv">Lentyna 2 apvali</option>
<option value="lent3apv">Lentyna 3 apvali</option>
</select></br>
<label for="sifras">šifras</label>
<input type="text" id="sifras" name="sifras" value="" class="form-field"></br>
<label for="rodyti">Pridėti ir temą, kuri bus rodoma lentynoje:</label>
<input type="checkbox" name="rodyti" id="rodyti" value="taip"></br></br>
<div class="temaD">
<label for="sifrasLentyna">Ši tema yra pagrindinė ir jos šifras bus rodomas ant lentynos:</label>
<input type="checkbox" name="sifrasLentyna" id="sifrasLentyna" value="1"></br></br>
<label for="tema"><b>Tema:</b> (<i>Nepamirškite nurodyti pagrindinio šifro, laukelyje <b>šifras</b>, kuris bus pridėtas prie temos</i>)</label>
<input type="text" name="tema" id="tema" value="" class="form-field"></br>
</div>
<script type="text/javascript">
jQuery('.temaD').hide();
jQuery('#rodyti').click(function() {
jQuery('.temaD')[this.checked ? "show" : "hide"]();
});
</script>
<input type="submit" name="save" value="Pridėti" class="submit-button"></br>
</form>
<?php
if ( isset($_POST['save']) ) {
if (trim($_POST['sifras']) != '') {
global $wpdb;
$table_name = $wpdb->prefix . 'temos';
$table_name2 = $wpdb->prefix . 'sifrai';
if (isset($_POST['rodyti'])) {
$rodoma_tema = $_POST['sifras'].' '.$_POST['tema'];
if (isset($_POST['sifrasLentyna'])) {
$wpdb->insert($table_name2, array('id'=>'','lent' => $_POST['lent'], 'sifras'=>$_POST['sifras']));
$wpdb->insert($table_name, array('id_t'=>'','lent' => $_POST['lent'], 'pgr_srift'=>$_POST['sifras'], 'tema'=>$rodoma_tema, 'sifrasLentyna'=>'1'));
}else{
$wpdb->insert($table_name2, array('id'=>'','lent' => $_POST['lent'], 'sifras'=>$_POST['sifras']));
$wpdb->insert($table_name, array('id_t'=>'','lent' => $_POST['lent'], 'pgr_srift'=>$_POST['sifras'], 'tema'=>$rodoma_tema, 'sifrasLentyna'=> '0'));
}
}else{
$wpdb->insert($table_name2, array('id'=>'','lent' => $_POST['lent'], 'sifras'=>$_POST['sifras']));
}
}else{
echo '<h1 id="err">Prašome užpildyti atitinkamus laukelius</h1>';
}
}
if (isset($_POST['trinti'])) {
global $wpdb;
$table_name = $wpdb->prefix . 'temos';
foreach ($_POST['trinti'] as $key => $id) {
$wpdb->delete($table_name, array('id_t'=>$id));
}
}
if (isset($_POST['trinti_s'])) {
global $wpdb;
$table_name2 = $wpdb->prefix . 'sifrai';
foreach ($_POST['trinti_s'] as $key => $id) {
$wpdb->delete($table_name2, array('id'=>$id));
}
}
?>
<form method="POST">
<input type="submit" name="trinimas" value="Ištrinti pažymėtus" class="submit-button"></br>
<table class="lentele">
<thead>
<tr>
<th>Temos</th>
</tr>
</thead>
<tbody>
<tr>
<th>Lentyna 1</th>
</tr>
<tr><?php gauti_temas('lent1'); ?></tr>
<tr>
<th>Lentyna 2</th>
</tr>
<tr><?php gauti_temas('lent2'); ?></tr>
<tr>
<th>Lentyna 3</th>
</tr>
<tr><?php gauti_temas('lent3'); ?></tr>
<tr>
<th>Lentyna 4</th>
</tr>
<tr><?php gauti_temas('lent4'); ?></tr>
<tr>
<th>Lentyna 5</th>
</tr>
<tr><?php gauti_temas('lent5'); ?></tr>
<tr>
<th>Lentyna 6</th>
</tr>
<tr><?php gauti_temas('lent6'); ?></tr>
<tr>
<th>Lentyna 7</th>
</tr>
<tr><?php gauti_temas('lent7'); ?></tr>
<tr>
<th>Lentyna 8</th>
</tr>
<tr><?php gauti_temas('lent8'); ?></tr>
<tr>
<th>Lentyna 9</th>
</tr>
<tr><?php gauti_temas('lent9'); ?></tr>
<tr>
<th>Lentyna 10</th>
</tr>
<tr><?php gauti_temas('lent10'); ?></tr>
<tr>
<th>Lentyna 11</th>
</tr>
<tr><?php gauti_temas('lent11'); ?></tr>
<tr>
<th>Lentyna 12</th>
</tr>
<tr><?php gauti_temas('lent12'); ?></tr>
<tr>
<th>Lentyna 13</th>
</tr>
<tr><?php gauti_temas('lent13'); ?></tr>
<tr>
<th>Lentyna 14</th>
</tr>
<tr><?php gauti_temas('lent14'); ?></tr>
<tr>
<th>Lentyna 15</th>
</tr>
<tr><?php gauti_temas('lent15'); ?></tr>
<tr>
<th>Lentyna 16</th>
</tr>
<tr><?php gauti_temas('lent16'); ?></tr>
<tr>
<th>Lentyna 17</th>
</tr>
<tr><?php gauti_temas('lent17'); ?></tr>
<tr>
<th>Lentyna 18</th>
</tr>
<tr><?php gauti_temas('lent18'); ?></tr>
<tr>
<th>Lentyna 19</th>
</tr>
<tr><?php gauti_temas('lent19'); ?></tr>
<tr>
<th>Lentyna 20</th>
</tr>
<tr><?php gauti_temas('lent20'); ?></tr>
<tr>
<th>Lentyna 21</th>
</tr>
<tr><?php gauti_temas('lent21'); ?></tr>
<tr>
<th>Lentyna 1 apvali</th>
</tr>
<tr><?php gauti_temas('lent1apv'); ?></tr>
<tr>
<th>Lentyna 2 apvali</th>
</tr>
<tr><?php gauti_temas('lent2apv'); ?></tr>
<tr>
<th>Lentyna 3 apvali</th>
</tr>
<tr><?php gauti_temas('lent3apv'); ?></tr>
</tbody>
</table>
<table class="lentele">
<thead>
<tr>
<th>Šifrai</th>
</tr>
</thead>
<tr>
<th>Lentyna 1</th>
</tr>
<tr><?php gauti_sifrus('lent1'); ?></tr>
<tr>
<th>Lentyna 2</th>
</tr>
<tr><?php gauti_sifrus('lent2'); ?></tr>
<tr>
<th>Lentyna 3</th>
</tr>
<tr><?php gauti_sifrus('lent3'); ?></tr>
<tr>
<th>Lentyna 4</th>
</tr>
<tr><?php gauti_sifrus('lent4'); ?></tr>
<tr>
<th>Lentyna 5</th>
</tr>
<tr><?php gauti_sifrus('lent5'); ?></tr>
<tr>
<th>Lentyna 6</th>
</tr>
<tr><?php gauti_sifrus('lent6'); ?></tr>
<tr>
<th>Lentyna 7</th>
</tr>
<tr><?php gauti_sifrus('lent7'); ?></tr>
<tr>
<th>Lentyna 8</th>
</tr>
<tr><?php gauti_sifrus('lent8'); ?></tr>
<tr>
<th>Lentyna 9</th>
</tr>
<tr><?php gauti_sifrus('lent9'); ?></tr>
<tr>
<th>Lentyna 10</th>
</tr>
<tr><?php gauti_sifrus('lent10'); ?></tr>
<tr>
<th>Lentyna 11</th>
</tr>
<tr><?php gauti_sifrus('lent11'); ?></tr>
<tr>
<th>Lentyna 12</th>
</tr>
<tr><?php gauti_sifrus('lent12'); ?></tr>
<tr>
<th>Lentyna 13</th>
</tr>
<tr><?php gauti_sifrus('lent13'); ?></tr>
<tr>
<th>Lentyna 14</th>
</tr>
<tr><?php gauti_sifrus('lent14'); ?></tr>
<tr>
<th>Lentyna 15</th>
</tr>
<tr><?php gauti_sifrus('lent15'); ?></tr>
<tr>
<th>Lentyna 16</th>
</tr>
<tr><?php gauti_sifrus('lent16'); ?></tr>
<tr>
<th>Lentyna 17</th>
</tr>
<tr><?php gauti_sifrus('lent17'); ?></tr>
<tr>
<th>Lentyna 18</th>
</tr>
<tr><?php gauti_sifrus('lent18'); ?></tr>
<tr>
<th>Lentyna 19</th>
</tr>
<tr><?php gauti_sifrus('lent19'); ?></tr>
<tr>
<th>Lentyna 20</th>
</tr>
<tr><?php gauti_sifrus('lent20'); ?></tr>
<tr>
<th>Lentyna 21</th>
</tr>
<tr><?php gauti_sifrus('lent21'); ?></tr>
<tr>
<th>Lentyna 1 apvali</th>
</tr>
<tr><?php gauti_sifrus('lent1apv'); ?></tr>
<tr>
<th>Lentyna 2 apvali</th>
</tr>
<tr><?php gauti_sifrus('lent2apv'); ?></tr>
<tr>
<th>Lentyna 3 apvali</th>
</tr>
<tr><?php gauti_sifrus('lent3apv'); ?></tr>
</table>
</form>
<div class="map">
<div class="aukstai">
<button class="a2 btn">II aukštas</button>
<button class="a3 btn">III aukštas</button>
</div>
<!--3 aukstas -->
<svg version="1.1" class="aukstas3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="800px" height="800px" viewBox="100 0 500 500" style="enable-background:new 0 0 512 1027; display:none" xml:space="preserve">
<g id="lent9">
<rect id="l8" x="142.7" y="303.2" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 314)" style="fill:#FFFFFF; font-family:'Arial'; font-size:9px;">Lentyna 9</text>
</g>
<g id="lent10">
<rect id="l9" x="142.7" y="271.2" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 281.4731)" style="fill:#FFFFFF; font-family:'Arial'; font-size:7px;">Lentyna 10</text>
</g>
<g id="lent11">
<rect id="l10" x="142.7" y="245" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 255)" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 11</text>
</g>
<g id="lent12">
<rect id="_x32_1" x="142.7" y="220" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 230)" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 12</text>
</g>
<g id="lent13">
<rect id="l11" x="142.7" y="195" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 205)" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 13</text>
</g>
<g id="lent14">
<rect id="l12" x="142.7" y="168.2" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 179)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 14</tspan>
</text>
</g>
<g id="lent15">
<rect id="l13" x="142.7" y="137.2" style="fill:#F16522;" width="111" height="15.5"/>
<text transform="matrix(1 0 0 1 145 148)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 15</tspan>
</text>
</g>
<g id="lent16">
<rect id="l14" x="277.2" y="137.2" style="fill:#F16522;" width="96.5" height="15.5"/>
<text transform="matrix(1 0 0 1 280 148)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 16</tspan>
</text>
</g>
<g id="lent17">
<rect id="l15" x="277.2" y="168.2" style="fill:#F16522;" width="96.5" height="15.5"/>
<text transform="matrix(1 0 0 1 280 179)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 17</tspan>
</text>
</g>
<g id="lent18">
<rect id="l16" x="277.2" y="205.2" style="fill:#F16522;" width="96.5" height="15.5"/>
<text transform="matrix(1 0 0 1 280 215)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 18</tspan>
</text>
</g>
<g id="lent19">
<rect id="l17" x="277.2" y="238.2" style="fill:#F16522;" width="96.5" height="15.5"/>
<text transform="matrix(1 0 0 1 280 248)" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 19</text>
</g>
<g id="lent20">
<rect id="l18" x="102.7" y="103.7" style="fill:#F16522;" width="113.8" height="7.5"/>
<text transform="matrix(1 0 0 1 110 110)" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 20</text>
</g>
<g id="lent21">
<rect id="l19" x="303.2" y="103.7" style="fill:#F16522;" width="51.3" height="7.5"/>
<text transform="matrix(1 0 0 1 305 110)" style="fill:#FFFFFF; font-family:'Arial'; font-size:8px;">Lentyna 21</text>
</g>
<text id="a3click" transform="matrix(1 0 0 1 120 70)" style="fill:#c2c2c2; font-family:'Arial'; font-size:60px;">III AUKŠTAS</text>
</svg>
<!--2 aukstas -->
<svg version="1.1" class="aukstas2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="800px" height="800px" viewBox="100 0 500 500" xml:space="preserve">
<g id="lent3apv">
<path id="lentyna3" style="fill:#F16522;" d="M340.7,215c18.2,0,33,14.8,33,33s-14.8,33-33,33s-33-14.8-33-33h9.3
c0,13.1,10.6,23.7,23.7,23.7s23.7-10.6,23.7-23.7s-10.6-23.7-23.7-23.7V215z"/>
<text transform="matrix(1 0 0 1 328.875 239.5)">
<tspan x="0" y="0" style="fill:#231F20; font-family:'Arial'; font-size:9px;">Lentyna 3</tspan>
<tspan x="0" y="9" style="fill:#231F20; font-family:'Arial'; font-size:9px;">apvali</tspan>
</text>
</g>
<g id="lent2apv">
<path id="lentyna2" style="fill:#F16522;" d="M340.7,193.2c16.2,0,29.3-13.1,29.3-29.3s-13.1-29.3-29.3-29.3s-29.3,13.1-29.3,29.3
h9.2c0-11.1,9-20.2,20.2-20.2s20.2,9,20.2,20.2s-9,20.2-20.2,20.2V193.2z"/>
<text transform="matrix(1 0 0 1 328.875 153.375)">
<tspan x="0" y="0" style="fill:#231F20; font-family:'Arial'; font-size:8px;">Lentyna 2</tspan>
<tspan x="0" y="7" style="fill:#231F20; font-family:'Arial'; font-size:8px;">apvali</tspan>
<tspan x="0" y="14" style="fill:#231F20; font-family:'Arial'; font-size:8px;"></tspan>
<tspan x="0" y="21" style="fill:#231F20; font-family:'Arial'; font-size:8px;"></tspan>
</text>
</g>
<g id="lent1apv">
<path id="lentyna1" style="fill:#F16522;" d="M262.7,206.3v-9c-8.7,0-15.7-7-15.7-15.7s7-15.7,15.7-15.7c8.7,0,15.7,7,15.7,15.7h9
c0-13.6-11-24.7-24.7-24.7c-13.6,0-24.7,11-24.7,24.7S249,206.3,262.7,206.3z"/>
<text transform="matrix(1 0 0 1 255.75 176.875)">
<tspan x="0" y="0" style="fill:#231F20; font-family:'Arial'; font-size:8px;">Lentyna 1</tspan>
<tspan x="0" y="7" style="fill:#231F20; font-family:'Arial'; font-size:8px;">apvali</tspan>
<tspan x="0" y="14" style="fill:#231F20; font-family:'Arial'; font-size:8px;"></tspan>
</text>
</g>
<g id="lent8">
<rect id="l7" x="304.5" y="109" style="fill:#F16522;" width="82" height="15"/>
<text transform="matrix(1 0 0 1 310 120)" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 8</text>
</g>
<g id="lent7">
<rect id="l6" x="217.3" y="109" style="fill:#F16522;" width="82.4" height="15.4"/>
<text transform="matrix(1 0 0 1 220 120)" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 7</text>
</g>
<g id="lent6">
<rect id="l6_1_" x="217.3" y="134" style="fill:#F16522;" width="82.4" height="15.4"/>
<text transform="matrix(1 0 0 1 220 145)" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 6</text>
</g>
<g id="lent5">
<rect id="l5" x="137.5" y="215.2" style="fill:#F16522;" width="79.8" height="15"/>
<text transform="matrix(1 0 0 1 150 226)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 5</tspan>
</text>
</g>
<g id="lent4">
<rect id="l4" x="137.5" y="249" style="fill:#F16522;" width="79.8" height="15"/>
<text transform="matrix(1 0 0 1 150 259)">
<tspan x="0" y="0" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 4</tspan>
</text>
</g>
<g id="lent3">
<rect id="l3" x="137.5" y="288.8" style="fill:#F16522;" width="79.8" height="15"/>
<text transform="matrix(1 0 0 1 150 299)" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 3</text>
</g>
<g id="lent2">
<rect id="l2" x="137.5" y="327.5" style="fill:#F16522;" width="79.8" height="15"/>
<text transform="matrix(1 0 0 1 150 339.25)" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 2</text>
</g>
<g id="lent1">
<rect id="l1" x="137.5" y="367.7" style="fill:#F16522;" width="79.8" height="15"/>
<text transform="matrix(1 0 0 1 150 379.1665)" style="fill:#FFFFFF; font-family:'Arial'; font-size:12px;">Lentyna 1</text>
</g>
<g id="textai">
<text id="a2click" transform="matrix(1 0 0 1 120 70)" style="fill:#c2c2c2; font-family:'Arial'; font-size:60px;">II AUKŠTAS</text>
</g>
</svg>
</div>