typeobject.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. include "auth.php";
  5. ?>
  6. <script src="typeobjectdesc.js" type="text/javascript"></script>
  7. <script src="typeobjectadd.js" type="text/javascript"></script>
  8. <script src="typeobjectfield.js" type="text/javascript"></script>
  9. <?php
  10. if(isset($_POST['machinebut']))
  11. {
  12. $idmachine = $_POST['hiddenid'];
  13. $namelink = $_POST['namelink'];
  14. $textlink = $_POST['textlink'];
  15. $typelink = $_POST['machinetypelink'];
  16. switch ($typelink)
  17. {
  18. case 'typetext' :
  19. $query = "INSERT INTO type_detals VALUES
  20. (NULL,'$namelink','$idmachine',null,'$typelink','$textlink',null,null,'')";
  21. break;
  22. case 'typeint' :
  23. $query = "INSERT INTO type_detals VALUES
  24. (NULL,'$namelink','$idmachine',null,'$typelink',null,".$textlink.",null,'')";
  25. break;
  26. case 'typefloat' :
  27. $query = "INSERT INTO type_detals VALUES
  28. (NULL,'$namelink','$idmachine',null,'$typelink',null,null,".$textlink.",'')";
  29. break;
  30. case 'typebinary' :
  31. $query = "INSERT INTO type_detals VALUES
  32. (NULL,'$namelink','$idmachine',null,'$typelink',null,null,null,".$textlink.")";
  33. break;
  34. }
  35. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  36. }
  37. if(isset($_GET["delete"])){
  38. $deleteid=($_GET["delete"]);
  39. $query = "DELETE FROM type_detals WHERE id=$deleteid";
  40. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  41. }
  42. if (isset($_POST['save'])) {
  43. $idmachine = ($_POST['hiddenid']);
  44. $query = mysqli_query($link, "select * from type_detals where id_type='$idmachine'");
  45. while ($res = mysqli_fetch_array($query)) {
  46. $id = $res['id'];
  47. {
  48. $name_detals = "detals" . $id;
  49. $count = "count" . $id;
  50. $type = "type" . $id;
  51. $name_detals = ($_POST[$name_detals]);
  52. $count = ($_POST[$count]);
  53. $type = ($_POST[$type]);
  54. if ($type!='typetext')
  55. $query2 = "UPDATE type_detals SET name_detals='$name_detals', type='$type', $type=".$count." WHERE id='$id'";
  56. else
  57. $query2 = "UPDATE type_detals SET name_detals='$name_detals', type='$type', $type='$count' WHERE id='$id'";
  58. $result = mysqli_query($link, $query2) or die("Ошибка " . mysqli_error($link));
  59. }
  60. }
  61. }
  62. if (isset($_POST['removed']))
  63. {
  64. $id1 = $_POST['machine'];
  65. $query = "DELETE FROM type_object WHERE id=$id1";
  66. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  67. echo "тип $id1 удален";
  68. }
  69. echo "
  70. <div name='type' style='float:left'>
  71. <form id='form1' action='?act=typeobject' method='POST' enctype='multipart/form-data'>
  72. <input type='submit' name='added' value='Добавить тип'>
  73. <input type='hidden' name='new' value='1'>
  74. <input type='submit' name='removed' value='Удалить тип'>
  75. <br>
  76. <select id='machine' name='machine' size='5'>";
  77. $query = mysqli_query($link,"select * from type_object where company='$companyID'");
  78. while ($res = mysqli_fetch_array($query)) {
  79. echo "<option value='".$res['id']."'>".$res['name']."</option>";
  80. }
  81. echo "</select>";
  82. echo"
  83. </div>
  84. <div style='float:left' >
  85. <div id='message' name='message'></div>
  86. <div id='messagechild' name='messagechild'></div>
  87. </div>
  88. </form>";
  89. if (isset($_POST['added']) && $_POST['new']==1 )
  90. {
  91. echo "
  92. <form id='form2' name='form2' method='POST'>
  93. <p>Название:<br>
  94. <input type='text' name='namemachine' id='namemachine'></p>
  95. <p>Описание: <br>
  96. <textarea rows='10' cols='45' name='specification' id='specification'></textarea></p>
  97. <input type='hidden' id='company' name='company' value='".$companyID."'>
  98. <input id='submit' type='button' value='Добавить'>";
  99. echo "</form>";
  100. }
  101. ?>