PageRenderTime 39ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/agent/openhouse/listing-info.php

https://bitbucket.org/OverSite/capstone-demo
PHP | 216 lines | 166 code | 41 blank | 9 comment | 14 complexity | 2a4610e071b16a62fe422a710ccc26c2 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, MIT, LGPL-2.1, Apache-2.0
  1. <?php
  2. session_start();
  3. if (!isset($_SESSION['userId'])) {
  4. header("Location: http://jjp2017.org/login.php");
  5. }
  6. require '../../databaseConnection.php';
  7. $dbConn = getConnection();
  8. $sql = "SELECT * FROM HouseInfo WHERE listingId = :listingId";
  9. $namedParameters = array();
  10. $namedParameters[':listingId'] = $_GET['id'];
  11. $stmt = $dbConn->prepare($sql);
  12. $stmt->execute($namedParameters);
  13. $result = $stmt->fetch();
  14. $url = 'https://api.idxbroker.com/clients/featured';
  15. $method = 'GET';
  16. // headers (required and optional)
  17. $headers = array(
  18. 'Content-Type: application/x-www-form-urlencoded', // required
  19. 'accesskey: e1Br0B5DcgaZ3@JXI9qib5', // required - replace with your own
  20. 'outputtype: json' // optional - overrides the preferences in our API control page
  21. );
  22. // set up cURL
  23. $handle = curl_init();
  24. curl_setopt($handle, CURLOPT_URL, $url);
  25. curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
  26. curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  27. curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
  28. curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
  29. // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
  30. $response = curl_exec($handle);
  31. $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
  32. if ($code >= 200 || $code < 300) {
  33. $response = json_decode($response, true);
  34. } else {
  35. $error = $code;
  36. }
  37. // print_r($response);
  38. $keys = array_keys($response);
  39. $listingId = $_GET['id'];
  40. ?>
  41. <!DOCTYPE html>
  42. <html>
  43. <head>
  44. <meta charset="utf-8">
  45. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  46. <title>RE/MAX Salinas | Listing Information</title>
  47. <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  48. <!-- BEGIN TEMPLATE default-css.php INCLUDE -->
  49. <?php include "./templates-oh/default-css.php" ?>
  50. <!-- END TEMPLATE default-css.php INCLUDE -->
  51. </head>
  52. <body class="hold-transition skin-black sidebar-mini">
  53. <!-- Site Wrapper -->
  54. <div class="wrapper">
  55. <!-- BEGIN TEMPLATE header.php INCLUDE -->
  56. <?php include "./templates-oh/header.php" ?>
  57. <!-- END TEMPLATE header.php INCLUDE -->
  58. <!-- BEGIN TEMPLATE nav.php INCLUDE -->
  59. <?php include "./templates-oh/nav.php" ?>
  60. <!-- END TEMPLATE nav.php INCLUDE -->
  61. <!-- Content Wrapper. Contains page content -->
  62. <div class="content-wrapper">
  63. <!-- Content Header (Page header) -->
  64. <section>
  65. <section class="content-header">
  66. <h1 class="col-md-6 col-sm-6 col-xs-12">
  67. <!-- 321 Tynan WAY Salinas California, 93906 -->
  68. <?php echo $result['address'] . " " . $result['city'] . " " . $result['state'] . ", " . $result['zip']; ?>
  69. </h1>
  70. <h1 class="col-md-3 col-sm-3 col-xs-6">
  71. Current Flyer
  72. </h1>
  73. <h1 class="col-md-3 col-sm-3 col-xs-6">
  74. <?php
  75. echo "<a href='create-flyer.php?id=" . $listingId . "'><button type=\"button\" class=\"btn btn-danger\">Create New Flyer</button></a>";
  76. ?>
  77. </h1>
  78. </section>
  79. <section class="content">
  80. <div class="container col-md-6 col-sm-6 col-xs-12">
  81. <div id="myCarousel" class="carousel slide" data-ride="carousel">
  82. <?php
  83. for ($i = 0; $i < sizeof($keys); $i++) {
  84. if ($response[$keys[$i]]['listingID'] == $listingId) {
  85. echo '<div class="carousel-inner">
  86. <div class="item active">
  87. <img src="' . $response[$keys[$i]]['image'][0]['url'] . '" alt="img" style="width:100%;">
  88. </div>';
  89. for ($j = 1; $j < (int)$response[$keys[$i]]['image']['totalCount']; $j++) {
  90. echo '<div class="item">
  91. <img src="' . $response[$keys[$i]]['image'][$j]['url'] . '" alt="img" style="width:100%;">
  92. </div>';
  93. }
  94. echo '</div>';
  95. $message = $response[$keys[$i]]['remarksConcat'];
  96. $picAmount = (int)$response[$keys[$i]]['image']['totalCount'];
  97. break;
  98. }
  99. }
  100. ?>
  101. <!-- Indicators -->
  102. <ol class="carousel-indicators">
  103. <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
  104. <?php
  105. if ((int)$response[$keys[$i]]['image']['totalCount'] > 0) {
  106. for ($j = 1; $j < $picAmount; $j++) {
  107. echo '<li data-target="#myCarousel" data-slide-to="' . $j . '">';
  108. }
  109. }
  110. ?>
  111. <!-- <li data-target="#myCarousel" data-slide-to="1"></li>
  112. <li data-target="#myCarousel" data-slide-to="2"></li> -->
  113. </ol>
  114. <!-- Wrapper for slides -->
  115. <!-- <div class="carousel-inner">
  116. <div class="item active">
  117. <img src="listingImg/exim1.png" alt="img" style="width:100%;">
  118. </div>
  119. <div class="item">
  120. <img src="listingImg/exim2.png" alt="img" style="width:100%;">
  121. </div>
  122. <div class="item">
  123. <img src="listingImg/exim3.png" alt="img" style="width:100%;">
  124. </div>
  125. </div> -->
  126. <!-- Left and right controls -->
  127. <a class="left carousel-control" href="#myCarousel" data-slide="prev">
  128. <span class="fa fa-angle-left"></span>
  129. <span class="sr-only">Previous</span>
  130. </a>
  131. <a class="right carousel-control" href="#myCarousel" data-slide="next">
  132. <span class="fa fa-angle-right"></span>
  133. <span class="sr-only">Next</span>
  134. </a>
  135. <div class="row">
  136. <div class="col-md-3 col-sm-3 col-xs-3">
  137. $ <?php echo number_format($result['price'], 2); ?></div>
  138. <div class="col-md-3 col-sm-3 col-xs-3"><?php echo $result['bedrooms']; ?> Bed</div>
  139. <div class="col-md-3 col-sm-3 col-xs-3"><?php echo $result['bathrooms']; ?> Bath</div>
  140. <div class="col-md-3 col-sm-3 col-xs-3">MLS# <?php echo $result['listingId']; ?></div>
  141. </div>
  142. </div>
  143. <div class="row" style="margin-top:20px;">
  144. <p><?php echo $message; ?></p>
  145. </div>
  146. </div>
  147. <div class="col-md-6 col-sm-6 col-xs-12">
  148. <div>
  149. <?php
  150. // if(isset($result['flyer']))
  151. // echo '<img src="../../uploadFlyers/' . $result['flyer'] . '" alt="pdf" style="width:80%; margin-top:10px;">';
  152. // else{
  153. // echo '<img src="listingImg/flyerPlaceHolder.png" alt="pdf" style="width:80%; margin-top:10px;">';
  154. // }
  155. if ($result['flyer'] == NULL) {
  156. echo '<img src="listingImg/flyerPlaceHolder.png" alt="pdf" style="width:80%; margin-top:10px;">';
  157. } else {
  158. echo '<iframe id="pdf" src="../../uploadFlyers/' . $result['flyer'] . '"
  159. style="width:600px; height:500px;" frameborder="0"></iframe>';
  160. }
  161. ?>
  162. </div>
  163. </div>
  164. </section>
  165. </section>
  166. </div>
  167. </div>
  168. <!-- BEGIN TEMPLATE default-footer.php INCLUDE -->
  169. <?php include "./templates-oh/default-footer.php" ?>
  170. <!-- END TEMPLATE default-footer.php INCLUDE -->
  171. <!-- BEGIN TEMPLATE default-js.php INCLUDE -->
  172. <?php include "./templates-oh/default-js.php" ?>
  173. <!-- END TEMPLATE default-js.php INCLUDE -->
  174. </body>
  175. </html>