Bez popisu

funciones.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
  3. $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  4. switch ($theType) {
  5. case "text":
  6. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  7. break;
  8. case "long":
  9. case "int":
  10. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  11. break;
  12. case "double":
  13. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  14. break;
  15. case "date":
  16. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  17. break;
  18. case "defined":
  19. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  20. break;
  21. }
  22. return $theValue;
  23. }
  24. function presentaPregsRangoSelect($min_val,$min_text,$max_val,$max_text,$id_q)
  25. {
  26. //print $id_q;
  27. print('<select class="form-control" name="question'.$id_q.'" required>');
  28. print('<option></option>');
  29. print('<option value="'.$min_val.'">'.$min_val." - ".$min_text.'</option>');
  30. print("\n");
  31. for($i=$min_val+1;$i<($max_val);$i++)
  32. {
  33. print('<option value="'.$i.'">'.$i.'</option>');
  34. print($i);
  35. print("\n");
  36. }
  37. print('<option value="'.$max_val.'">'.$max_val." - ".$max_text.'</option>');
  38. print("\n");
  39. print("</select>");
  40. print("\n");
  41. }
  42. function presentaPregsRangoSlider($min_val,$min_text,$max_val,$max_text,$id_q)
  43. {
  44. //print('<div class="slidecontainer">');
  45. print('<input type="range" class="form-control-range slider" value="0" min="'.$min_val.'" max="'.$max_val.'" name="question'.$id_q.'" id="question'.$id_q.'" required>');
  46. print('<div class="row">');
  47. print('<div class="col-4">');
  48. print("<small>$min_text</small>");
  49. print('</div>');
  50. print('<div class="col-4 text-center">');
  51. print('<span id="val'.$id_q.'"></span>');
  52. print('</div>');
  53. print('<div class="col-4 text-right">');
  54. print("<small>$max_text</small>");
  55. print('</div>');
  56. print('</div>');
  57. print('
  58. <script>
  59. var slider'.$id_q.' = document.getElementById("question'.$id_q.'");
  60. var output'.$id_q.' = document.getElementById("val'.$id_q.'");
  61. output'.$id_q.'.innerHTML = slider'.$id_q.'.value;
  62. slider'.$id_q.'.onclick = function() {
  63. output'.$id_q.'.innerHTML = this.value;
  64. }
  65. </script>
  66. ');
  67. //print('</div>');
  68. }
  69. function presentaPregsRangoRadio($min_val,$min_text,$max_val,$max_text,$id_q)
  70. {
  71. print('<div class="row-sm">');
  72. print('<div class="form-check">');
  73. print('<input class="form-check-input" type="radio" name="question'.$id_q.'" id="radio'.$min_val.'" value="'.$min_val.'" required>');
  74. print('<label class="form-check-label" for="radio'.$min_val.'">'.$min_val.' - '.$min_text.'</label>');
  75. print('</div>');
  76. for($i=$min_val+1;$i<($max_val);$i++)
  77. {
  78. print('<div class="form-check">');
  79. print('<input class="form-check-input" type="radio" name="question'.$id_q.'" id="radio'.$i.'" value="'.$i.'">');
  80. print('<label class="form-check-label" for="radio'.$i.'">'.$i.'</label>');
  81. print('</div>');
  82. }
  83. print('<div class="form-check">');
  84. print('<input class="form-check-input" type="radio" name="question'.$id_q.'" id="radio'.$max_val.'" value="'.$max_val.'">');
  85. print('<label class="form-check-label" for="radio'.$max_val.'">'.$max_val.' - '.$max_text.'</label>');
  86. print('</div>');
  87. print('</div>');
  88. }
  89. function presentaPregsRangoRadio2($min_val,$min_text,$max_val,$max_text,$id_q)
  90. {
  91. print('<div class="row-sm">');
  92. print('<div class="col">');
  93. print('<div class="form-check form-check-inline">');
  94. print('<input class="form-check-input" type="radio" name="question'.$id_q.'" id="radio'.$min_val.'" value="'.$min_val.'">');
  95. print('</div>');
  96. print('</div>');
  97. for($i=$min_val+1;$i<($max_val);$i++)
  98. {
  99. print('<div class="col">');
  100. print('<div class="form-check form-check-inline">');
  101. print('<input class="form-check-input" type="radio" name="question'.$id_q.'" id="radio'.$i.'" value="'.$i.'">');
  102. print('</div>');
  103. print('</div>');
  104. }
  105. print('<div class="col">');
  106. print('<div class="form-check form-check-inline">');
  107. print('<input class="form-check-input" type="radio" name="question'.$id_q.'" id="radio'.$max_val.'" value="'.$max_val.'">');
  108. print('</div>');
  109. print('</div>');
  110. print('</div>');
  111. print('<div class="row-sm">');
  112. print('<div class="col">');
  113. print('<label class="form-check-label" for="radio'.$min_val.'">'.$min_val.' - '.$min_text.'</label>');
  114. print('</div>');
  115. for($i=$min_val+1;$i<($max_val);$i++)
  116. {
  117. print('<div class="col">');
  118. print('<label class="form-check-label" for="radio'.$i.'">'.$i.'</label>');
  119. print('</div>');
  120. }
  121. print('<div class="col">');
  122. print('<label class="form-check-label" for="radio'.$max_val.'">'.$max_val.' - '.$max_text.'</label>');
  123. print('</div>');
  124. print('</div>');
  125. }
  126. ?>