123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- if (!$logged_me_in_successfully234)
- return;
- include "auth.php";
- ?>
- <script src="typeobjectdesc.js" type="text/javascript"></script>
- <script src="typeobjectadd.js" type="text/javascript"></script>
- <script src="typeobjectfield.js" type="text/javascript"></script>
- <?php
- if(isset($_POST['machinebut']))
- {
- $idmachine = $_POST['hiddenid'];
- $namelink = $_POST['namelink'];
- $textlink = $_POST['textlink'];
- $typelink = $_POST['machinetypelink'];
- switch ($typelink)
- {
- case 'typetext' :
- $query = "INSERT INTO type_detals VALUES
- (NULL,'$namelink','$idmachine',null,'$typelink','$textlink',null,null,'')";
- break;
- case 'typeint' :
- $query = "INSERT INTO type_detals VALUES
- (NULL,'$namelink','$idmachine',null,'$typelink',null,".$textlink.",null,'')";
- break;
- case 'typefloat' :
- $query = "INSERT INTO type_detals VALUES
- (NULL,'$namelink','$idmachine',null,'$typelink',null,null,".$textlink.",'')";
- break;
- case 'typebinary' :
- $query = "INSERT INTO type_detals VALUES
- (NULL,'$namelink','$idmachine',null,'$typelink',null,null,null,".$textlink.")";
- break;
- }
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- }
- if(isset($_GET["delete"])){
- $deleteid=($_GET["delete"]);
- $query = "DELETE FROM type_detals WHERE id=$deleteid";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- }
- if (isset($_POST['save'])) {
- $idmachine = ($_POST['hiddenid']);
- $query = mysqli_query($link, "select * from type_detals where id_type='$idmachine'");
- while ($res = mysqli_fetch_array($query)) {
- $id = $res['id'];
- {
- $name_detals = "detals" . $id;
- $count = "count" . $id;
- $type = "type" . $id;
- $name_detals = ($_POST[$name_detals]);
- $count = ($_POST[$count]);
- $type = ($_POST[$type]);
- if ($type!='typetext')
- $query2 = "UPDATE type_detals SET name_detals='$name_detals', type='$type', $type=".$count." WHERE id='$id'";
- else
- $query2 = "UPDATE type_detals SET name_detals='$name_detals', type='$type', $type='$count' WHERE id='$id'";
- $result = mysqli_query($link, $query2) or die("Ошибка " . mysqli_error($link));
- }
- }
- }
- if (isset($_POST['removed']))
- {
- $id1 = $_POST['machine'];
- $query = "DELETE FROM type_object WHERE id=$id1";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- echo "тип $id1 удален";
- }
- echo "
- <div name='type' style='float:left'>
- <form id='form1' action='?act=typeobject' method='POST' enctype='multipart/form-data'>
- <input type='submit' name='added' value='Добавить тип'>
- <input type='hidden' name='new' value='1'>
- <input type='submit' name='removed' value='Удалить тип'>
- <br>
- <select id='machine' name='machine' size='5'>";
- $query = mysqli_query($link,"select * from type_object where company='$companyID'");
- while ($res = mysqli_fetch_array($query)) {
- echo "<option value='".$res['id']."'>".$res['name']."</option>";
- }
- echo "</select>";
- echo"
- </div>
- <div style='float:left' >
- <div id='message' name='message'></div>
- <div id='messagechild' name='messagechild'></div>
- </div>
- </form>";
- if (isset($_POST['added']) && $_POST['new']==1 )
- {
- echo "
- <form id='form2' name='form2' method='POST'>
- <p>Название:<br>
- <input type='text' name='namemachine' id='namemachine'></p>
- <p>Описание: <br>
- <textarea rows='10' cols='45' name='specification' id='specification'></textarea></p>
- <input type='hidden' id='company' name='company' value='".$companyID."'>
- <input id='submit' type='button' value='Добавить'>";
- echo "</form>";
- }
- ?>
|