Guest User

Untitled

a guest
Sep 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.17 KB | None | 0 0
  1. <?php
  2. //including the database connection file
  3. include_once("../config/config.php");
  4.  
  5. if(isset($_POST['Submit'])) {
  6. $fileid2 = $_POST['fileid2'];
  7. $roomid = $_POST['roomid'];
  8. $prefixpri = $_POST['prefixpri'];
  9. $fnamepri = $_POST['fnamepri'];
  10. $lnamepri = $_POST['lnamepri'];
  11. $nationalitypri = $_POST['nationalitypri'];
  12. $extrabed = $_POST['extrabed'];
  13. $roomtype = $_POST['roomtype'];
  14.  
  15.  
  16. // checking empty fields
  17. if(empty($fileid2)) {
  18. if(empty($fileid2)) {
  19. echo "<font color='red'>Category field is empty.</font><br/>";
  20. }
  21. //link to the previous page
  22. echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
  23. } else {
  24. // if all the fields are filled (not empty)
  25. //insert data to database
  26.  
  27. for ($i = 0; $i < count($_POST['fileid2']); $i++) {
  28. $fileid2 = $_POST['fileid2'][$i];
  29. $roomid = $_POST['roomid'][$i];
  30. $prefixpri = $_POST['prefixpri'][$i];
  31. $fnamepri = $_POST['fnamepri'][$i];
  32. $lnamepri = $_POST['lnamepri'][$i];
  33. $nationalitypri = $_POST['nationalitypri'][$i];
  34. $extrabed = $_POST['extrabed'][$i];
  35. //$roomtype = $_POST['roomtype'][$i];
  36.  
  37. //insert info of pri guest to rez_client table
  38. $result = mysqli_query($mysqli, "INSERT INTO
  39. test (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`, `value7`)
  40. VALUES('$fileid2','$roomid','$prefixpri','$fnamepri','$lnamepri','$nationalitypri','$extrabed')");
  41.  
  42. //insert info of pri guest to guestdetails table
  43. $result1 = mysqli_query($mysqli, "INSERT INTO
  44. testt (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`)
  45. VALUES('$fileid2','$roomid','$prefixpri','$fnamepri','$lnamepri','$nationalitypri')");
  46.  
  47. //check if extrabed drop dwon is yes or no
  48. if($extrabed == 'Yes'){
  49. $fileid2ext = $_POST['fileid2'][$i];
  50. $roomidext = $_POST['roomid'][$i];
  51. $prefixext = $_POST['prefixext'][$i];
  52. $fnameext = $_POST['fnameext'][$i];
  53. $lnameext = $_POST['lnameext'][$i];
  54. $nationalityext = $_POST['nationalityext'][$i];
  55. $extrabed = $_POST['extrabed'][$i];
  56.  
  57. //insert info of extrabed guest to guestdetails table (if extrabed is yes)
  58. $resultt = mysqli_query($mysqli, "INSERT INTO
  59. testt (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`)
  60. VALUES('$fileid2ext','$roomidext','$prefixext','$fnameext','$lnameext','$nationalityext')");
  61. }//close if
  62. else {
  63. //donothing;
  64. }
  65.  
  66.  
  67.  
  68. }//close for
  69.  
  70. ///////////////////////////////////////////////////
  71. if($roomtype == 'None'){
  72. //donothing;
  73. }
  74. elseif($roomtype == 'Single'){
  75. //donothing;
  76. }
  77. else{
  78. for ($x = 0; $x < count($_POST['roomid']); $x++) {
  79.  
  80. $fileid2x = $_POST['fileid2'][$x];
  81. $roomidx = $_POST['roomid'][$x];
  82.  
  83. $prefixx = $_POST['prefix'][$x];
  84. $fnamex = $_POST['fname'][$x];
  85. $lnamex = $_POST['lname'][$x];
  86. $nationalityx = $_POST['nationality'][$x];
  87.  
  88. $resultt = mysqli_query($mysqli, "INSERT INTO
  89. testt (`value1`, `value2`, `value3`, `value4`, `value5`, `value6`)
  90. VALUES('$fileid2x','$roomidx','$prefixx','$fnamex','$lnamex','$nationalityx')");
  91. }// close for
  92. }// close else
  93.  
  94.  
  95. //display success message
  96. echo "<font color='green'>Data added successfully.";
  97. echo "<br/><a href='2loopindex.php'>View Result</a>";
  98.  
  99.  
  100. }// close else
  101. }// close if isset
  102. ?>
  103.  
  104. <?php
  105. //including the database connection file
  106. include_once("../config/config.php");
  107.  
  108.  
  109. //fetching data in descending order (lastest entry first)
  110. //$result = mysql_query("SELECT * FROM users ORDER BY id DESC"); // mysql_query is deprecated
  111. $resultagency = mysqli_query($mysqli, "SELECT * FROM agency ORDER BY id DESC"); // using mysqli_query instead
  112. $reshotlnam = mysqli_query($mysqli, "SELECT * FROM hotels ORDER BY id DESC"); // using mysqli_query instead
  113. $resromtyp = mysqli_query($mysqli, "SELECT * FROM roomtype ORDER BY id"); // using mysqli_query instead
  114. $resroomcat = mysqli_query($mysqli, "SELECT * FROM roomcat ORDER BY id DESC"); // using mysqli_query instead
  115. $resboard = mysqli_query($mysqli, "SELECT * FROM board ORDER BY id DESC"); // using mysqli_query instead
  116. $resulttours = mysqli_query($mysqli, "SELECT * FROM tours ORDER BY id DESC"); // using mysqli_query instead
  117. $resulttransfers = mysqli_query($mysqli, "SELECT * FROM transfers ORDER BY id DESC"); // using mysqli_query instead
  118.  
  119. // code to generate File ID
  120.  
  121. $gen_fileid = mysqli_query($mysqli, "SELECT max(fileid) FROM rez_file_info ORDER BY fileid DESC LIMIT 1;");
  122. if (mysqli_num_rows($gen_fileid) > 0) {
  123. $max_fileid = mysqli_fetch_row($gen_fileid);
  124. //echo $max_fileid[0]; //Here it is
  125. $generated_fileid =$max_fileid[0] +1;
  126. }
  127.  
  128. ?>
  129. <script src="../scripts/teknocave-js.js" type="text/javascript"></script>
  130. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  131.  
  132.  
  133. <script type="text/javascript">
  134. function GetDays(target){
  135. var dropdt = new Date($(target).find(".drop_date").val());
  136. var pickdt = new Date($(target).find(".pick_date").val());
  137. return parseInt((dropdt - pickdt) / (24 * 3600 * 1000));
  138. }
  139. function cal(target){
  140. console.log($(target).parent(), $(target).parent().find('numdays2'));
  141. $(target).parent().find('.numdays2').val(GetDays($(target).parent()));
  142. }
  143. </script>
  144.  
  145.  
  146. <script type="text/javascript">
  147. $(document).ready(function() {
  148. var genroomid = 2; // change 0 to the number you want to start with
  149. $(".add-row").click(function() {
  150. var $clone = $("ul.personal-details").first().clone();
  151. var $input = $clone.find('#roomid');
  152. $input.val(genroomid).attr('genroomid', +genroomid) // change fileid with any string you want
  153. $clone.append("<button type='button' class='remove-row'>-</button>");
  154. $clone.insertBefore(".add-row");
  155. genroomid++; // increase id by 1
  156. });
  157.  
  158. $(".cloned-removed-div").on("click", ".remove-row", function() {
  159. $(this).parent().remove();
  160. genroomid--;
  161. });
  162. //code of display guest info
  163. // var codes of Primary Guest info
  164. var blkofcod1pri = "<select class='stretch' name='prefixpri[]'><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Child'>Child</option><option value='Infant'>Infant</option></select>";
  165. var blkofcod2pri = "<input name='fnamepri[]' type='text' class='stretch' placeholder='First Name' size='15' maxlength='30' required >&nbsp;<input name='lnamepri[]' type='text' class='stretch' placeholder='Last Name' size='15' maxlength='30' required >";
  166. var blkofcod3pri = "<input name='nationalitypri[]' type='text' placeholder='Nationality' class='stretch' size='15' maxlength='30' required >";
  167.  
  168. // var codes of other Guest info in same room
  169. var blkofcod1 = "<select class='stretch' name='prefix[]'><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Child'>Child</option><option value='Infant'>Infant</option></select>";
  170. var blkofcod2 = "<input name='fname[]' type='text' class='stretch' placeholder='First Name' size='15' maxlength='30' required >&nbsp;<input name='lname[]' type='text' class='stretch' placeholder='Last Name' size='15' maxlength='30' required >";
  171. var blkofcod3 = "<input name='nationality[]' type='text' placeholder='Nationality' class='stretch' size='15' maxlength='30' required >";
  172.  
  173. // var codes of other Guest info of extra bed
  174. var blkofcod1ext = "<select class='stretch' name='prefixext[]'><option value='Mr'>Mr</option><option value='Ms'>Ms</option><option value='Child'>Child</option><option value='Infant'>Infant</option></select>";
  175. var blkofcod2ext = "<input name='fnameext[]' type='text' class='stretch' placeholder='First Name' size='15' maxlength='30' required >&nbsp;<input name='lnameext[]' type='text' class='stretch' placeholder='Last Name' size='15' maxlength='30' required >";
  176. var blkofcod3ext = "<input name='nationalityext[]' type='text' placeholder='Nationality' class='stretch' size='15' maxlength='30' required >";
  177.  
  178. $(document).on('change', '#roomtype', function() {
  179. var value = $(this).val();
  180. var toAppend = '';
  181. var $container = $(this).siblings('#container')
  182.  
  183. switch (value) {
  184. case 'None':
  185. toAppend = $container.html(toAppend);
  186. return;
  187. break;
  188.  
  189. case 'Single':
  190. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri;
  191. $container.html(toAppend);
  192. return;
  193. break;
  194.  
  195. case 'Double':
  196. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  197. $container.html(toAppend);
  198. return;
  199. break;
  200.  
  201. case 'Triple':
  202. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  203. $container.html(toAppend);
  204. return;
  205. break;
  206.  
  207. case 'Quadruple':
  208. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  209. $container.html(toAppend);
  210. return;
  211. break;
  212.  
  213. case 'Quintuple(5)':
  214. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  215. $container.html(toAppend);
  216. return;
  217. break;
  218.  
  219. case 'Sextuple(6)':
  220. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  221. $container.html(toAppend);
  222. return;
  223. break;
  224.  
  225. case 'Septuple(7)':
  226. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  227. $container.html(toAppend);
  228. return;
  229. break;
  230.  
  231. case 'Octuple(8)':
  232. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  233. $container.html(toAppend);
  234. return;
  235. break;
  236.  
  237. case 'Nonuple(9)':
  238. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  239. $container.html(toAppend);
  240. return;
  241. break;
  242.  
  243. case 'Decuple(10)':
  244. toAppend = blkofcod1pri + blkofcod2pri + blkofcod3pri + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3 + "<br>" + blkofcod1 + blkofcod2 + blkofcod3;
  245. $container.html(toAppend);
  246. return;
  247. break;
  248.  
  249. default:
  250. toAppend = $container.html(toAppend);
  251. return;
  252. }
  253. });
  254.  
  255. // code of display guest info of extra bed
  256. $(document).on('change', '#extrabed', function() {
  257. var value2 = $(this).val();
  258. var toAppend2 = '';
  259. var $container2 = $(this).siblings('#container2')
  260.  
  261. switch (value2) {
  262. case 'No':
  263. toAppend2 = $container2.html(toAppend2);
  264. return;
  265. break;
  266.  
  267. case 'Yes':
  268. toAppend2 = blkofcod1ext + blkofcod2ext + blkofcod3ext;
  269. $container2.html(toAppend2);
  270. return;
  271. break;
  272.  
  273. default:
  274. toAppend2 = $container2.html(toAppend2);
  275. return;
  276. }
  277. });
  278.  
  279. });
  280.  
  281.  
  282.  
  283. </script>
  284. <!--<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
  285. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  286. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  287. <script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script>
  288. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
  289. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>-->
  290.  
  291. <!DOCTYPE html><html lang="en">
  292. <head>
  293. <body>
  294. <form name="form_reservations" method="post" action="2loopadd.php">
  295. <div class="cloned-removed-div">
  296. <ul class="personal-details">
  297. <table class="stretch" border="1">
  298. <tr>
  299. <!--<td>File ID</td>-->
  300. <td>TEST</td>
  301. <td>TEST</td>
  302. </tr>
  303. <tr>
  304. <td>
  305. <label for="fileid2">FileID</label>
  306. <input name="fileid2[]" type="text" class="stretchnights" id="fileid2" >
  307.  
  308. <label for="roomid">RoomID</label>
  309. <input name="roomid[]" type="text" class="stretchnights" id="roomid" readonly="readonly" value="1">
  310. </td>
  311.  
  312. <td>
  313. <div>
  314. <select class="stretch" id="roomtype" name="roomtype[]" required="required">
  315. <option value="">Room Type</option>
  316. <option value="None">None </option>
  317. <?php
  318. foreach ($resromtyp as $row3) {
  319. echo '<option value="' . $row3['name'] . '">' . $row3['name'] . '</option>';
  320. }
  321. ?>
  322. </select>
  323. <div id="container"></div>
  324. <label for="extrabed">Extra Bed
  325. <select class="stretch" name="extrabed[]" id="extrabed" required="required">
  326. <option value=""> </option>
  327. <option value="No">No</option>
  328. <option value="Yes">Yes</option>
  329. </select>
  330. <div id="container2"></div></label>
  331.  
  332.  
  333. </div>
  334. </td>
  335.  
  336.  
  337. </tr>
  338. <tr><td colspan="6">
  339. <label for="note2">Note:
  340. <textarea name="note2[]" style="width:100%;" ></textarea></label>
  341. </td></tr>
  342. </table>
  343.  
  344.  
  345. </ul>
  346. <button type="button" class="add-row" >+ New Client</button>
  347. <table width="25%" border="0"> <tr> <input type="submit" name="Submit" value="Insert"></tr></table>
  348. </div>
  349. </form>
  350.  
  351. </body>
  352. </head>
Add Comment
Please, Sign In to add comment