$sql = "SELECT userid AS uid, users.email AS email FROM places_users\n INNER JOIN users ON users.id = places_users.userid WHERE places_users.placesid ={$plid} AND users.email <> ''"; $result = $sqlcn->ExecuteSQL($sql); while ($row = mysqli_fetch_array($result)) { smtpmail($row['email'], $title, $txt); } } if (isset($_GET["step"])) { $step = $_GET["step"]; } else { $step = ""; } // Выполняем токма если юзер зашел! if ($user->TestRoles("1,4,5,6") == true and $step != '') { if ($step != 'move') { $dtpost = DateToMySQLDateTime2($_POST["dtpost"] . " 00:00:00"); $dtendgar = DateToMySQLDateTime2($_POST["dtendgar"] . " 00:00:00"); if ($dtpost == "") { $err[] = "Не выбрана дата!"; } if (isset($_POST["sorgid"])) { $sorgid = $_POST["sorgid"]; } else { if ($sorgid == "") { $err[] = "Не выбрана организация!"; } } if (isset($_POST["splaces"])) { $splaces = $_POST["splaces"]; } else { if ($splaces == "") { $err[] = "Не выбрано помещение!";
TXT; $result = $sqlcn->ExecuteSQL($sql); while ($row = mysqli_fetch_array($result)) { smtpmail($row['email'], $title, $txt); } } $step = GetDef('step'); $sorgid = PostDef('sorgid'); $splaces = PostDef('splaces'); $suserid = PostDef('suserid'); // Выполняем только при наличии у пользователя соответствующей роли // http://грибовы.рф/wiki/doku.php/основы:доступ:роли if ($user->TestRoles('1,4,5,6') && $step != '') { if ($step != 'move') { $dtpost = DateToMySQLDateTime2(PostDef('dtpost') . ' 00:00:00'); $dtendgar = DateToMySQLDateTime2(PostDef('dtendgar') . ' 00:00:00'); if ($dtpost == '') { $err[] = 'Не выбрана дата!'; } if ($sorgid == '') { $err[] = 'Не выбрана организация!'; } if ($splaces == '') { $err[] = 'Не выбрано помещение!'; } if ($suserid == '') { $err[] = 'Не выбран пользователь!'; } $sgroupname = PostDef('sgroupname'); if ($sgroupname == '') { $err[] = 'Не выбрана группа номенклатуры!';
<?php // Данный код создан и распространяется по лицензии GPL v3 // Изначальный автор данного кода - Грибов Павел // http://грибовы.рф if (isset($_GET["step"])) { $step = $_GET["step"]; } else { $step = ""; } if ($user->mode == 1 and $step != '') { $dtpost = DateToMySQLDateTime2($_POST["dtpost"]); if ($dtpost == "") { $err[] = "Не введена дата!"; } $title = $_POST["title"]; if ($title == "") { $title = "Не задан заголовок!"; } $txt = ClearMySqlString($sqlcn->idsqlconnection, $_POST["txt"]); if ($txt == "") { $txt = "Нету тела новости!"; } $newsid = $_GET["newsid"]; if ($step == "add") { if (count($err) == 0) { $sql = "INSERT INTO news (id,dt,title,body) VALUES (NULL,'{$dtpost}','{$title}','{$txt}')"; $result = $sqlcn->ExecuteSQL($sql); //echo "$sql"; if ($result == '') { die('Не смог добавить новость!: ' . mysqli_error($sqlcn->idsqlconnection));
$sql = <<<TXT INSERT INTO repair (id,dt,kntid,eqid,cost,comment,dtend,status,userfrom,userto,doc) VALUES (NULL,'{$dtpost}','{$kntid}','{$eqid}','{$cst}','{$comment}','{$dt}','1','{$suserid1}','{$suserid2}','{$doc}') TXT; $result = $sqlcn->ExecuteSQL($sql) or die('Не смог добавить ремонт!: ' . mysqli_error($sqlcn->idsqlconnection)); // ставим статус "ремонт", только если нужен сервис в общем списке ТМЦ if ($status != 0) { $sql = "UPDATE equipment SET repair = '{$status}' WHERE id = '{$eqid}'"; $sqlcn->ExecuteSQL($sql) or die('Не смог обновить запись о ремонте!: ' . mysqli_error($sqlcn->idsqlconnection)); } } } if ($step == 'edit') { $dt = DateToMySQLDateTime2(PostDef('dtpost') . ' 00:00:00'); $dtend = DateToMySQLDateTime2(PostDef('dt') . ' 00:00:00'); $cost = PostDef('cst'); $comment = PostDef('comment'); $rstatus = PostDef('status'); $doc = PostDef('doc'); $suserid1 = PostDef('suserid1'); $suserid2 = PostDef('suserid2'); $kntid = PostDef('kntid'); $sql = <<<TXT UPDATE repair SET dt = '{$dt}',dtend = '{$dtend}',cost = '{$cost}',comment = '{$comment}',status = '{$rstatus}',doc = '{$doc}', userfrom = '{$suserid1}', userto = '{$suserid2}',kntid = '{$kntid}' WHERE id = '{$eqid}' TXT; $sqlcn->ExecuteSQL($sql) or die('Не смог обновить статус ремонта! ' . mysqli_error($sqlcn->idsqlconnection));
$responce->rows[$i]['id'] = $row['rpid']; if ($row['rstatus'] == '1') { $row['rstatus'] = "Ремонт"; } else { $row['rstatus'] = "Сделано"; } $responce->rows[$i]['cell'] = array($row['rpid'], $row['namekont'], $row['namenome'], MySQLDateToDate($row['dt']), MySQLDateToDate($row['dtend']), $row['cost'], $row['comment'], $row['rstatus']); $i++; } echo json_encode($responce); } if ($step == 'edit') { //echo "!$oper!!"; if ($oper == 'edit') { $dt = DateToMySQLDateTime2($_POST["dt"] . " 00:00:00"); $dtend = DateToMySQLDateTime2($_POST["dtend"] . " 00:00:00"); $cost = $_POST['cost']; $comment = $_POST['comment']; $rstatus = $_POST['rstatus']; $SQL = "UPDATE repair SET dt='{$dt}',dtend='{$dtend}',cost='{$cost}',comment='{$comment}',status='{$rstatus}' WHERE id='{$eqid}'"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не смог обновить статус ремонта!" . mysqli_error($sqlcn->idsqlconnection)); ReUpdateRepairEq(); } if ($oper == 'del') { //echo "!$oper!$eqid!"; $SQL = "SELECT * FROM repair WHERE id='{$eqid}'"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не получилось выбрать список ремонтов!" . mysqli_error($sqlcn->idsqlconnection)); while ($row = mysqli_fetch_array($result)) { $status = $row['status']; } //echo "!$oper!$eqid!$status!";
} echo json_encode($responce); } if ($oper == 'edit') { if ($work == 'Yes') { $work = '1'; } else { $work = '0'; } $datestart = DateToMySQLDateTime2($datestart); $dateend = DateToMySQLDateTime2($dateend); $SQL = "UPDATE contract SET num='{$num}',name='{$name}',comment='{$comment}',datestart='{$datestart}',dateend='{$dateend}',work='{$work}' WHERE id='{$id}'"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не могу обновить данные по договору!" . mysqli_error($sqlcn->idsqlconnection)); echo "!{$SQL}!"; } if ($oper == 'add') { if ($work == 'Yes') { $work = '1'; } else { $work = '0'; } $datestart = DateToMySQLDateTime2($datestart); $dateend = DateToMySQLDateTime2($dateend); $SQL = "INSERT INTO contract (id,kntid,num,name,comment,datestart,dateend,work,active) VALUES (null,'{$idknt}','{$num}','{$name}','{$comment}','{$datestart}','{$dateend}','{$work}',1)"; //echo "!$SQL!"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не могу добавить данные по договору!" . mysqli_error($sqlcn->idsqlconnection)); } if ($oper == 'del') { $SQL = "UPDATE contract SET active=not active WHERE id='{$id}'"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не смог пометить на удаление договор!" . mysqli_error($sqlcn->idsqlconnection)); }
$row['userto'] = 'не задано'; } if ($row['userfrom'] != '-1') { $zz->GetById($row['userfrom']); $row['userfrom'] = $zz->fio; } else { $row['userfrom'] = 'не задано'; } $responce->rows[$i]['cell'] = array($row['id'], $dt, $dtend, $row['name'], $row['cost'], $row['comment'], $st, $row['userfrom'], $row['userto'], $row['doc']); $i++; } jsonExit($responce); } if ($oper == 'edit') { $dt = DateToMySQLDateTime2($dt . ' 00:00:00'); $dtend = DateToMySQLDateTime2($dtend . ' 00:00:00'); $sql = <<<TXT UPDATE repair SET comment = '{$comment}',dt = '{$dt}',dtend = '{$dtend}',status = '{$status}',doc = '{$doc}' WHERE id = '{$id}' TXT; $result = $sqlcn->ExecuteSQL($sql) or die('Не могу обновить статус ремонта ТМЦ! ' . mysqli_error($sqlcn->idsqlconnection)); ReUpdateRepairEq(); exit; } if ($oper == 'del') { $SQL = "DELETE FROM repair WHERE id = '{$id}'"; $result = $sqlcn->ExecuteSQL($SQL) or die('Не могу удалить запись о ремонте! ' . mysqli_error($sqlcn->idsqlconnection)); ReUpdateRepairEq(); exit; }
} $zz = new Tusers(); if ($row['userto'] != "-1") { $zz->GetById($row['userto']); $row['userto'] = $zz->fio; } else { $row['userto'] = 'не задано'; } if ($row['userfrom'] != "-1") { $zz->GetById($row['userfrom']); $row['userfrom'] = $zz->fio; } else { $row['userfrom'] = 'не задано'; } $responce->rows[$i]['cell'] = array($row["id"], $dt, $dtend, $row["name"], $row["cost"], $row["comment"], $st, $row['userfrom'], $row['userto'], $row['doc']); $i++; } echo json_encode($responce); } if ($oper == 'edit') { $dt = DateToMySQLDateTime2($dt . " 00:00:00"); $dtend = DateToMySQLDateTime2($dtend . " 00:00:00"); $SQL = "UPDATE repair SET comment='{$comment}',dt='{$dt}',dtend='{$dtend}',status='{$status}',doc='{$doc}' WHERE id='{$id}'"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не могу обновить статус ремонта ТМЦ!" . mysqli_error($sqlcn->idsqlconnection)); ReUpdateRepairEq(); } if ($oper == 'del') { $SQL = "DELETE FROM repair WHERE id='{$id}'"; $result = $sqlcn->ExecuteSQL($SQL) or die("Не могу удалить запись о ремонте!" . mysqli_error($sqlcn->idsqlconnection)); ReUpdateRepairEq(); }