diff --git a/HTTPServices/apache2.conf b/HTTPServices/apache2.conf new file mode 100644 index 0000000..12038f5 --- /dev/null +++ b/HTTPServices/apache2.conf @@ -0,0 +1,23 @@ +## Apache 1. + +# StatusForm publication +#Alias "/statusform" "/var/www/statusform/" + + AllowOverride AuthConfig FileInfo Limit + + +# 1c publication +Alias "/emp" "/var/www/emp/" + + AllowOverride All + Options None + Require all granted + SetHandler 1c-application + ManagedApplicationDescriptor "/var/www/emp/default.vrd" + +# + + +# !! 1 +# 1 Apache 1 +LoadModule _1cws_module "/opt/1cv8/x86_64/8.3.20.1996/wsap24.so" \ No newline at end of file diff --git a/HTTPServices/emp/default.vrd b/HTTPServices/emp/default.vrd new file mode 100644 index 0000000..06f3add --- /dev/null +++ b/HTTPServices/emp/default.vrd @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/HTTPServices/statusform/action.php b/HTTPServices/statusform/action.php new file mode 100644 index 0000000..7335d0d --- /dev/null +++ b/HTTPServices/statusform/action.php @@ -0,0 +1,31 @@ + array( + 'method' => 'POST', + 'header' => 'Content-type: application/json', //'Content-type: application/x-www-form-urlencoded', + 'content' => $post//json_encode($post) //http_build_query($params) +) +))); + +// $arr = json_decode($result); + + +// тестовый ответ +//sleep(5); // имитация ожидания ответа от сервака 5 sec +//$str='[{"Контрагент":"Общество с ограниченной ответственностью \"Фотон сервис\"","Заявка":"Заказ 00НОЕМ-000035 от 10.02.2021 16:24:35","СтатусЗаявки":"Зарегистрировано","Счет":"Счет покупателю 00000000711 от 10.02.2021 16:31:20","НаличиеОплаты":"Оплаты нет","СуммаОплаты":0}, {"Контрагент":"Общество с ограниченной ответственностью \"Фотон сервис\"","Заявка":"Заказ 00НОЕМ-000043 от 12.02.2021 11:32:58","СтатусЗаявки":"Зарегистрировано","Счет":"Счет покупателю 00000000793 от 12.02.2021 11:33:21","НаличиеОплаты":"Оплаты нет","СуммаОплаты":0}, {"Контрагент":"Общество с ограниченной ответственностью \"Фотон сервис\"","Заявка":"Заказ НРО-ЗАК-00072 от 24.03.2021 15:09:49","СтатусЗаявки":"Выполняется","Счет":"Счет покупателю НРО-СЧ-0065 от 24.03.2021 15:10:18","НаличиеОплаты":"Оплата есть","СуммаОплаты":12166.2}, {"Контрагент":"Общество с ограниченной ответственностью \"Фотон сервис\"","Заявка":"Заказ НРО-ЗАК-00276 от 23.06.2021 11:19:58","СтатусЗаявки":"Выполняется","Счет":"Счет покупателю НРО-СЧ-0312 от 07.07.2021 14:17:04","НаличиеОплаты":"Оплата есть","СуммаОплаты":89602.2}]'; +//echo $str; + +echo $result; +?> \ No newline at end of file diff --git a/HTTPServices/statusform/index.php b/HTTPServices/statusform/index.php new file mode 100644 index 0000000..fc43a2d --- /dev/null +++ b/HTTPServices/statusform/index.php @@ -0,0 +1,164 @@ + + + + + + + ФБУ "Якутский ЦСМ"| Проверка статуса Заявки клиента + + + + + + + + +

Проверка статуса готовности
по номеру Заявки / Счета

+
+ +
+
+ + + + +
+ + + + + +
+

+ Порядок действий:
+ 1. Выбрать представление Контрагента - Юр.лицо / Физ.лицо
+ 2. (Опционально) Для Юр.лица указать ИНН
+ 3. Внести список номеров документов, разделенных запятой
+ ... Пример: ТТ-ЗАК-00123,ЭЛР-СЧ-01234 и т.д. Желательно, не более 5 номеров
+ 4. Нажать кнопку "Получить данные"

+
+
+
+
+ + \ No newline at end of file diff --git a/HTTPServices/statusform/script.js b/HTTPServices/statusform/script.js new file mode 100644 index 0000000..e84cbfb --- /dev/null +++ b/HTTPServices/statusform/script.js @@ -0,0 +1,181 @@ +function btnClick() +{ + var errorText = ""; + var INNVal = ""; + var urfiz = ""; + + //urfiz = GetValChackedRadioButton('urfiz'); + urfiz = document.querySelector('input[name="urfiz"]:checked').value; + INNVal = document.getElementById('INN').value; + errorText = ''; + + if (urfiz == "fiz" & INNVal.length != 0){ + errorText = 'Для физ.лиц задавать ИНН не нужно.'; + document.getElementById('INN').value = ""; + INNVal = document.getElementById('INN').value; + } + + if (urfiz == "fiz" & INNVal.length == 0){ + document.getElementById('INN').hidden = true; + } + + if (urfiz == "ur" & INNVal.length == 0){ + document.getElementById('INN').hidden = false; + } + + if (errorText != ""){ + document.getElementById('ErrorMessage').hidden = false; + document.getElementById('ErrorMessage').innerHTML="
"+ + "ВНИМАНИЕ: " + errorText.bold() + "
"; + }else{ + document.getElementById('ErrorMessage').hidden = true; + } + //alert(document.querySelector("#INN").value); +} + +function checkRegExpValNumber(){ + //тут проверяем, а не входит ли случайно введеный символ в инн, + // в список НЕ цифр. Если символ не цифра, то ругаемся и удаляем символ. + const inn = document.querySelector('input[name="INN"]'); + inn.addEventListener('input', updateValueInn); +} + +function updateValueInn(letter){ + var reg = /^\d{10}$/; + var bukva = letter.target.value; //получаем измененную строку + var validNum = reg.test(bukva); + + if (!validNum) { + var errorText = "ИНН должен состоять ТОЛЬКО из цифр и составлять 10 знаков"; + document.getElementById('ErrorMessage').hidden = false; + document.getElementById('ErrorMessage').innerHTML="
"+ + "ВНИМАНИЕ: " + errorText.bold() + "
"; + }else{ + var errorText = ""; + document.getElementById('ErrorMessage').hidden = true; + document.getElementById('ErrorMessage').innerHTML=""; + } +} + +function checkRegExpValRusNum(){ + const strNumDoc = document.querySelector('input[name="strNumDoc"]'); + strNumDoc.addEventListener('input', updateValueStrNumDoc); +} + +function updateValueStrNumDoc(letter){ + var reg = /^[-\s,а-яА-ЯёЁ0-9]+$/; + var bukva = letter.target.value; //получаем измененную строку + var validNum = reg.test(bukva); + + if (!validNum) { + var errorText = "Строка с номерами может содержать только кирилицу, тире, числа и запятые \n Пример: ТТ-ЗАК-01234, ЭЛР-СЧ-12345"; + document.getElementById('ErrorMessage').hidden = false; + document.getElementById('ErrorMessage').innerHTML="
"+ + "ВНИМАНИЕ: " + errorText.bold() + "
"; + }else{ + var errorText = ""; + document.getElementById('ErrorMessage').hidden = true; + document.getElementById('ErrorMessage').innerHTML=""; + } +} + +//***************** K0t0vICH ***************/ +function send_data(){ + // блочим кнопку отправки запроса + //startCheck("submit_btn"); + toggleButton("submit_btn"); + + // удаляем предыдущую таблицу + if (document.querySelector('#result_table').childNodes.length>0) { + document.querySelector('#result_table').removeChild(document.querySelector('#result_table').childNodes[0]); + } + + // Данные формы + const params = { + urfiz: document.querySelector('input[name="urfiz"]:checked').value, + INN: document.querySelector('#INN').value, + strNumDoc: document.querySelector('#strNumDoc').value + } + + var http = new XMLHttpRequest(); + http.open('POST', 'action.php', true); + http.setRequestHeader('Content-type', 'application/json'); + http.onreadystatechange = function() { // Ожидание ответа + if(http.readyState == 4 && http.status == 200) { + console.log(http.responseText); // проверка приходящих параметров + // разблокируем кнопку отправки запроса + toggleButton("submit_btn"); + + var result_table = JSON.parse(http.responseText); + + // Заголовки таблицы + var col = []; + for (var i = 0; i < result_table.length; i++) { + for (var key in result_table[i]) { + if (col.indexOf(key) === -1) { + col.push(key); + } + } + } + + // Создаем таблицу + var table = document.createElement("table"); + var tr = table.insertRow(-1); // TABLE ROW. + for (var i = 0; i < col.length; i++) { + var th = document.createElement("th"); // TABLE HEADER. + th.innerHTML = col[i]; + tr.appendChild(th); + } + + // JSON DATA -> ROWS. + for (var i = 0; i < result_table.length; i++) { + + tr = table.insertRow(-1); + + for (var j = 0; j < col.length; j++) { + var tabCell = tr.insertCell(-1); + tabCell.innerHTML = result_table[i][col[j]]; + } + } + + // Создаем таблицу в контейнере + var divContainer = document.getElementById("result_table"); + divContainer.innerHTML = ""; + divContainer.appendChild(table); + + // скролим строницу на таблицу результатов + document.getElementById("result_table").scrollIntoView(); + + } + } + http.send(JSON.stringify(params)); // упаковываем! +}; + +function startCheck(button_id){ + var el = document.getElementById(button_id); + var urfiz = document.getElementsByName("urfiz"); + if (!urfiz["ur"].checked && !urfiz["ur"].checked){ + el.value = "Не выбрано Юр./Физ.лицо" + el.disabled = true$ + } + else + { + el.value = "Получить данные"; + el.disabled = false; + } +} + +function toggleButton(button_id) +{ + var el = document.getElementById(button_id); + if (el.value == "Запрос обрабатывается...") + { + el.value = "Получить данные"; + el.disabled = false; + } + else + { + el.value = "Запрос обрабатывается..."; + el.disabled = true; + } +} \ No newline at end of file diff --git a/HTTPServices/statusform/style.css b/HTTPServices/statusform/style.css new file mode 100644 index 0000000..90825f7 --- /dev/null +++ b/HTTPServices/statusform/style.css @@ -0,0 +1,175 @@ +red{ + color: red; +} + +divcenter { + width: 760px; + display: block; + top: 5%; + left: 25%; + position: absolute; + } + +ErrorMessage{ + color: red; + } + +/* +div.new_form { + width: 680px; + border: 1px solid red; + display: block; + }*/ + + div.new_form { + width: 680px; + border: 1px solid #cecece; + display: block; + height: 320px; + padding: 40px; + box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 3px 6px rgba(0,0,0,0.22); + margin: auto; + } + +div.new_form input[type="text"] { + width: 100%; + margin-top: 10px; + padding: 10px 0; + text-indent: 15px; + } + + div.new_form input[type="number"] { + width: 100%; + margin-top: 10px; + padding: 10px 0; + text-indent: 15px; + } + + div.new_form input[type="radio"] { + width: 15px; + padding: 10px 0; + text-indent: 1px; + } + + div.new_form input[type="submit"] { + float: right; + } + + div.new_form input { + width: 49%; + margin-top: 10px; + padding: 10px 0; + text-indent: 15px; + } + + h2.forms { + text-align: center; + font-family: sans-serif; + font-weight: 100; + color: #4d5d53; + text-transform: uppercase; + } + + /* начало раскраски кнопок RADIO */ + + .form_radio_btn { + display: inline-block; + /* margin-right: 10px; */ + } + + .form_radio_btn input[type=radio] { + display: none; + } + + .form_radio_btn label { + width: 306px; + display: inline-block; + cursor: pointer; + padding: 0px 15px; + line-height: 35px; + border: 1px solid #999; + border-radius: 6px; + user-select: none; + } + + /* Checked */ + .form_radio_btn input[type=radio]:checked + label { + background: #ffe0a6; + } + + /* Hover */ + .form_radio_btn label:hover { + color: #666; + } + + /* Disabled */ + .form_radio_btn input[type=radio]:disabled + label { + background: #efefef; + color: #666; + } + + /* конец раскраски кнопок RADIO */ + + rezult { + display: block; + margin: 14px; + } + + /* + #result_table { + position:relative; + margin-top:70px; + top:0; + width: 100%; + display: block; + border: 1px solid #cecece; + box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 3px 6px rgba(0,0,0,0.22); + margin: auto; + } + */ + + /* раскраска таблицы */ + #result_table table { + font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; + border-collapse: collapse; + /*width: 600px;*/ + /*height: 210px;*/ + padding: 10px; + position:relative; + margin-top:15px; + top:15px; + width: 100%; + display: block; + border: 1px solid #cecece; + box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 3px 6px rgba(0,0,0,0.22); +} + +#result_table table td, table th { + border: 1px solid #ddd; + padding: 4px; +} +#result_table table tr:nth-child(even){ + background-color: #f2f2f2; +} +#result_table table tr:hover { + background-color: #ddd; +} +#result_table table th { + padding-top: 8px; + padding-bottom: 8px; + text-align: left; + background-color: #808583; + color: white; +} + +#bottom_text p { + display: inline-block; + position:relative; + margin-top: 10px; + border: 1px solid rgb(219, 11, 11); + border-radius: 6px; + padding: 10px; + top:5px; + width: 97%; + +} \ No newline at end of file diff --git a/README.md b/README.md index e1a9f12..fce3014 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ - **README.MD** - Непосредственно этот файл, который является инструкцией и описанием всего проекта и расширения. - **HTTPServices.cfe** - файл расширения, который нужно добавить в рабочую базу 1С ЕМП. -- **HTTPServices\default.vrd** - файл настроек публикации и подключения HTTP сервиса на стороне веб сервера Apache. +- **HTTPServices\emp\default.vrd** - файл настроек публикации и подключения HTTP сервиса на стороне веб сервера Apache. +- **HTTPServices\statusform** - папка с файлами виджета, которую нужно настроить и перенести на сторону каталога сайта. +- **HTTPServices\statusform\action.php** - файл обработка, производит непосредственный запрос на сторону нашего веб сервера, для связи с HTTP сервисом. В этом файле нужно указать внешний путь к опубликованному сервису. - **HTTPServises\apache.conf** - файл с блоком настроек на стороне веб сервера Apache, для реализации публикации HTTP сервиса во вне. ## Источники вдохновения, основа кода расширения, и чтиво для понимания. (ссылки)