PageRenderTime 137ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/public_html/adm/preturi_teztour/spo.php

https://bitbucket.org/ocaziituristice/ocaziituristice.ro
PHP | 218 lines | 209 code | 7 blank | 2 comment | 9 complexity | f16d217d157e603254eeebaf6a733fe8 MD5 | raw file
  1. <h1>Oferte TezTour cu plecare din Romania</h1>
  2. <?php $dbhost_tz = 'ocaziituristice.ro';
  3. $dbuser_tz = 'ocazii_rusia';
  4. $dbpass_tz = 'teztourrus';
  5. $conn_tz = mysql_connect($dbhost_tz, $dbuser_tz, $dbpass_tz) or die ('Error connecting to mysql');
  6. $dbname_tz = 'ocazii_teztour';
  7. mysql_select_db($dbname_tz, $conn_tz); ?>
  8. <div class="filtrare">
  9. <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  10. <tr>
  11. <td align="left" valign="middle">
  12. <form name="filtru_sejur" method="get" enctype="multipart/form-data" action="preturi_teztour.php">
  13. <?php $selPle="select localitati.nume, localitati.id_localitate from spo inner join localitati on spo.id_oras = localitati.id_localitate inner join tari on localitati.id_tara = tari.id_tara where tari.nume = 'Romania' Group by localitati.id_localitate Order by localitati.nume ";
  14. $quePle=mysql_query($selPle, $conn_tz) or die(mysql_error()); ?>
  15. Localitate Plecare:
  16. <select name="plecare" class="select">
  17. <option value="0">Selectaza</option>
  18. <?php while($rowPle=mysql_fetch_array($quePle)) { ?>
  19. <option value="<?php echo $rowPle['id_localitate']; ?>" <?php if($_GET['plecare']==$rowPle['id_localitate']) { ?> selected="selected" <?php } ?>><?php echo $rowPle['nume']; ?></option>
  20. <?php } @mysql_free_result($quePle); ?>
  21. </select>
  22. &nbsp;&nbsp;&nbsp;&nbsp;
  23. <?php $selPle="select tari.nume, tari.id_tara from spo inner join tari on spo.id_tara = tari.id_tara inner join localitati on spo.id_oras = localitati.id_localitate inner join tari as tari_plec on localitati.id_tara = tari_plec.id_tara where tari_plec.nume = 'Romania' Group by tari.id_tara Order by tari.nume ";
  24. $quePle=mysql_query($selPle, $conn_tz) or die(mysql_error()); ?>
  25. Tari sosire:
  26. <select name="tara" class="tara">
  27. <option value="0">Selectaza</option>
  28. <?php while($rowPle=mysql_fetch_array($quePle)) { ?>
  29. <option value="<?php echo $rowPle['id_tara']; ?>" <?php if($_GET['tara']==$rowPle['id_tara']) { ?> selected="selected" <?php } ?>><?php echo $rowPle['nume']; ?></option>
  30. <?php } @mysql_free_result($quePle); ?>
  31. </select>
  32. &nbsp;&nbsp;&nbsp;
  33. <button type="submit">Go</button>
  34. </form>
  35. <form name="filtru_sejur" method="get" enctype="multipart/form-data" action="preturi_teztour.php">
  36. <button type="submit">Reset</button>
  37. </form>
  38. </td>
  39. </tr>
  40. </table>
  41. </div>
  42. <?php
  43. if($_GET['scoate']) {
  44. $insEx="INSERT INTO exceptii_lista_spo (spo) VALUES ('".$_GET['scoate']."') ";
  45. $queEx=mysql_query($insEx, $connect->link) or die(mysql_error());
  46. @mysql_free_result($queEx);
  47. echo "<script> alert('Oferta a fost scoasa din lista!'); document.location.href='/adm/preturi_teztour.php?plecare=".$_GET['plecare']."&tara=".$_GET['tara']."&nr_pagina=".$_GET['nr_pagina']."'; </script>";
  48. }
  49. $selEX="SELECT spo FROM exceptii_lista_spo GROUP BY spo ";
  50. $queEX=mysql_query($selEX, $connect->link) or die(mysql_error());
  51. while($rowEX=mysql_fetch_array($queEX)) {
  52. $exeptii=$exeptii."'".$rowEX['spo']."',";
  53. }
  54. $exeptii=substr($exeptii,0,-1);
  55. $query="select tari.nume as denumire_tara, localitati.nume as localitate_plecare, spo.id, spo.descriere, spo.nume, spo.update_time, spo.data_creat, spo.data_start, spo.data_end, spo.nr_oferte_speciale, spo.pret_minim_dbl, spo_zona.zona1, spo_zona.zona2, spo_zona.zona3 from spo inner join tari on spo.id_tara = tari.id_tara inner join localitati on spo.id_oras = localitati.id_localitate inner join tari as tara_plecare on localitati.id_tara = tara_plecare.id_tara left join spo_zona on spo.spo_region_set = spo_zona.id where tara_plecare.nume = 'Romania' and spo.data_end >= now() and spo.preturi = 'da' "; if($_GET['plecare']) $query=$query." and localitati.id_localitate = '".$_GET['plecare']."' "; if($_GET['tara']) $query=$query." and spo.id_tara = '".$_GET['tara']."' "; if($exeptii) $query=$query." and spo.id NOT IN (".$exeptii.") "; $query=$query." Group by spo.id Order by localitati.nume, spo.nume ";
  56. //paginatia
  57. if(strlen($_GET['nr_pagina'])>0)
  58. $nr_pagina=$_GET['nr_pagina'];
  59. else
  60. $nr_pagina=1;
  61. //echo $nr_pagina;
  62. $limit=20;
  63. $start=$limit*($nr_pagina-1);
  64. $adresa_curenta="";
  65. $arrayu=explode("?", $_SERVER['REQUEST_URI']);
  66. $arrayu2=explode("&", $arrayu[1]);
  67. $i=0;
  68. while($arrayu2[$i])
  69. {
  70. $array3=explode("=", $arrayu2[$i]);
  71. if($array3[0]!="nr_pagina")
  72. {
  73. $new=$new.$array3[0]."=".$array3[1]."&";
  74. }
  75. $i++;
  76. }
  77. $link_prez="";
  78. $link_prez=$_SERVER['REQUEST_URI'];
  79. if(eregi("\([^>]*\"?[^)]*\)", $link_prez)) {
  80. $adresa_curenta=$link_prez."&".$new; } else {
  81. $adresa_curenta="preturi_teztour.php?".$new; }
  82. $rez=mysql_query($query);
  83. $numar_total=mysql_num_rows($rez);
  84. $lquery = "LIMIT ".$start.",".$limit." ";
  85. $rez_limit = mysql_query($query.$lquery, $conn_tz)or die(mysql_error());
  86. if($numar_total>$limit){
  87. $nr_pagini=floor($numar_total/$limit);
  88. if(fmod($numar_total,$limit)!=0)
  89. {
  90. $nr_pagini=$nr_pagini+1;
  91. }
  92. $pagini="";
  93. if(($start*$limit)>$numar_total)
  94. {
  95. $produse_afisate=($start+1)."-".($start+1)*$limit;
  96. }else{
  97. $produse_afisate=($start+1)."-".$nr_total;
  98. }
  99. $begin_ct=1;
  100. $end_ct=$nr_pagini;
  101. if($nr_pagina>10){
  102. $begin_ct = $nr_pagina-10;
  103. }
  104. if($nr_pagina>1)
  105. $pagini.="<a href=\"".$adresa_curenta."nr_pagina=1\">Start</a>&nbsp" ;
  106. else $pagini.="<span class=\"selNav\">Start</span>&nbsp;";
  107. $afis=$nr_pagina-1;
  108. if($nr_pagina>1)
  109. $pagini.="<a href=\"".$adresa_curenta."nr_pagina=".$afis."\">Prev</a>&nbsp;" ;
  110. else $pagini.="<span class=\"selNav\">Prev</span>&nbsp;";
  111. if($nr_pagini>20){
  112. $end_ct=$nr_pagina+10;
  113. if($end_ct>$nr_pagini)
  114. $end_ct=$nr_pagini;
  115. }
  116. //echo $begin_ct.">".$end_ct;
  117. for($i=$begin_ct;$i<=$end_ct;$i++) {
  118. if($i==$nr_pagina) {
  119. $pagini.="<span class=\"sel\">".$i."</span>&nbsp";
  120. } else {
  121. $pagini.="<a href=\"".$adresa_curenta."nr_pagina=".$i."\">".$i."</a>&nbsp;";
  122. }
  123. }
  124. $afis=$nr_pagina+1;
  125. if($nr_pagina<$nr_pagini)
  126. $pagini.="<a href=\"".$adresa_curenta."nr_pagina=".$afis."\">Next</a>&nbsp;" ;
  127. else $pagini.="<span class=\"selNav\">Next</span>&nbsp;";
  128. if($nr_pagina<$nr_pagini)
  129. $pagini.="<a href=\"".$adresa_curenta."nr_pagina=".$nr_pagini."\">End</a>" ;
  130. else $pagini.="<span class=\"selNav\">End</span>&nbsp;";
  131. }
  132. ?>
  133. <div class="paginatie">
  134. <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  135. <tr>
  136. <td width="170" align="left" valign="middle">Afisare <?php $st=$limit*($nr_pagina-1)+1; echo $st; $sf=$limit*$nr_pagina; echo "-".$sf; ?> din <?php echo $numar_total; ?></td>
  137. <td align="center" valign="middle"><? echo $pagini?></td>
  138. <td width="160" align="right" valign="middle">Pagina <?php echo $nr_pagina; ?> din <?php echo $nr_pagini; ?></td>
  139. </tr>
  140. </table>
  141. </div>
  142. <table cellpadding="2" cellspacing="2" border="1" width="100%" align="center" class="tabel">
  143. <tr>
  144. <th width="20" align="center" valign="top">#</th>
  145. <th align="center" valign="top">Denumire</th>
  146. <th align="center" valign="top">Oras plecare</th>
  147. <th align="center" valign="top">Oferte</th>
  148. <th align="center" valign="top">Durata valabilitatii</th>
  149. <th align="center" valign="top">Locatie</th>
  150. <th align="center" valign="top">Pret minim DBL</th>
  151. <th align="center" valign="top">Ultimu update</th>
  152. </tr>
  153. <?php $alternate = false; $i=$st-1;
  154. while($row=mysql_fetch_array($rez_limit, MYSQL_ASSOC))
  155. {
  156. $i++; ?>
  157. <tr class="normal" onmouseout="this.className='normal'; if(document.getElementById('tools<?php echo $row['id']; ?>').style.visibility == 'visible'){ document.getElementById('tools<?php echo $row['id']; ?>').style.visibility = 'hidden'; }" onmouseover="this.className='hover'; if(document.getElementById('tools<?php echo $row['id']; ?>').style.visibility == 'hidden'){ document.getElementById('tools<?php echo $row['id']; ?>').style.visibility = 'visible'; }else{ document.getElementById('tools<?php echo $row['id']; ?>').style.display = 'hidden'; }">
  158. <td align="right" valign="top"><?php echo $i; ?></td>
  159. <td align="left" valign="top">
  160. <a href="preturi_teztour.php?pas=2&spo=<?php echo $row['id']; ?>" class="titluArticol"><?php echo 'SPO '.$row['nr_oferte_speciale']; ?></a>
  161. <div style="visibility:hidden;" id="tools<?php echo $row['id']; ?>" class="tools">
  162. <a href="preturi_teztour.php?pas=2&spo=<?php echo $row['id']; ?>">Adauga</a> | <a href="javascript: if(confirm('Sunteti siguri ca doriti sa scoateti aceasta oferta din lista?')) document.location.href='/adm/preturi_teztour.php?plecare=<?php echo $_GET['plecare']; ?>&tara=<?php echo $_GET['tara']; ?>&nr_pagina=<?php echo $_GET['nr_pagina']; ?>&scoate=<?php echo $row['id']; ?>'; ">Scoateti din lista</a>
  163. </div>
  164. </td>
  165. <td align="center" valign="top"><?php echo $row['localitate_plecare']; ?></td>
  166. <td align="center" valign="top"><?php echo $row['nr_oferte_speciale']; ?></td>
  167. <td align="center" valign="top"><?php echo $row['data_start']." - ".$row['data_end']; ?></td>
  168. <td align="center" valign="top">Tara: <?php echo $row['denumire_tara']; ?> <?php for($j=1;$j<=3;$j++) { if($row['zona'.$j]) { echo "<br/>Zona".$j.": "; $selZo="select zone.nume from zone where id_zona = '".$row['zona'.$j]."' "; $queZo=mysql_query($selZo, $conn_tz) or die(mysql_error()); $rowZo=mysql_fetch_array($queZo); @mysql_free_result($queZo); echo $rowZo['nume']; } } ?> </td>
  169. <td align="center" valign="top"><?php echo $row['pret_minim_dbl']; ?></td>
  170. <td align="center" valign="top"><?php $up="select spo_import.data_update from spo_import where id_spo = '".$row['id']."' "; $qu=mysql_query($up, $connect->link) or die(mysql_error()); $ro=mysql_fetch_array($qu); @mysql_free_result($qu); if($ro['data_update']) echo $ro['data_update']; else echo "Niciodata"; ?></td>
  171. </tr>
  172. <?php } ?>
  173. </table>
  174. <div class="paginatie">
  175. <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  176. <tr>
  177. <td width="170" align="left" valign="middle">Afisare <?php $st=$limit*($nr_pagina-1)+1; echo $st; $sf=$limit*$nr_pagina; echo "-".$sf; ?> din <?php echo $numar_total; ?></td>
  178. <td align="center" valign="middle"><? echo $pagini?></td>
  179. <td width="160" align="right" valign="middle">Pagina <?php echo $nr_pagina; ?> din <?php echo $nr_pagini; ?></td>
  180. </tr>
  181. </table>
  182. </div>
  183. <? @mysql_free_result($rez_limit); ?>