Joywork/war-object-report.php
2026-05-22 21:21:54 +03:00

468 lines
25 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Просмотр статуса заказа на оценку
* загрузка документов
* обмен сообщениями
* Выполнение запроса по API на добавление объкета в очередь на оценку в WebAppRaiser
*/
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
if(!$_SESSION['id']) {
header("location:index.php");
die("Доступ запрещён!");
}
$user = new User($_SESSION["id"]);
require_once($_SERVER["DOCUMENT_ROOT"]."/engine/classes/WebAppRaiser/autoload.php");
$WebAppRaiserAPI = new WebAppRaiserAPI($user);
//msg('USER', $user);
//msg('WebAppRaiserAPI', $WebAppRaiserAPI);
//ini_set('display_errors', 1);
//error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
$page = array(
'title'=> 'ВебОценщик',
'subtitle'=> '',
'status'=> 'success',
'msg'=> [],
'tabs'=> '',
'content'=> '',
'destination' => '',
);
function dpm($data) {
return '<pre style="width:1080px;margin:0 auto;">'.print_r($data, true).'</pre>';
}
function msg($op, $msg_text = '') {
static $msg = array();
if($op == 'get') {
return $msg;
}
else {
if(is_array($msg_text)) {
$msg[] = dpm([$op => $msg_text]);
}
else {
$msg[] = dpm([$op => $msg_text]);
}
}
}
$breadcrumb_array_svg = '&nbsp;<svg xmlns="http://www.w3.org/2000/svg" width="20" height="18" viewBox="0 0 16 10" fill="none"><path d="M15.2069 4.864L10.6149 9.456L10.0789 8.896C9.96688 8.77867 9.92154 8.664 9.94288 8.552C9.96421 8.43467 10.0282 8.32267 10.1349 8.216L12.2629 6.096C12.5242 5.83467 12.7642 5.61867 12.9829 5.448C12.6949 5.48533 12.3935 5.51467 12.0789 5.536C11.7642 5.55733 11.4389 5.568 11.1029 5.568H0.974875V4.144H11.1029C11.4389 4.144 11.7642 4.15467 12.0789 4.176C12.3989 4.19733 12.7029 4.22933 12.9909 4.272C12.7722 4.096 12.5295 3.87733 12.2629 3.616L10.1189 1.48C10.0122 1.37333 9.94821 1.264 9.92688 1.152C9.90554 1.03467 9.95088 0.917333 10.0629 0.799999L10.5989 0.24L15.2069 4.864Z" fill="#7D7D7D"></path></svg>'.PHP_EOL;
if(isset($_POST)) {
//TODO выполняем запрос по API на добавления заказа на отчет об оценке.
//$comment = mysql_real_escape_string($_POST['comment']);
//$cabinetId = mysql_real_escape_string($_POST['cabinet_id']);
//$showSame = mysql_real_escape_string($_POST['showSame']);
//$showSame = mysql_real_escape_string($_POST['showSame']);
//$showEmptyLinks = mysql_real_escape_string($_POST['showEmptyLinks']);
//msg('POST', $_POST);
$post = clearInputData($_POST);
// Выполнение метода в зависимости от нажатой кнопки. добавление объекта, закрузка документов и пр.
if(!empty($post['form_id'])){
$form = WebAppRaiserForm::getForm($post['form_id']);
$status = $form->validate();
$form->submit($status, $page, $WebAppRaiserAPI);
//msg('STATUS', $status);
}
}
// Отображаем шапку страницы
require($_SERVER['DOCUMENT_ROOT']."/templates/new-header.php");
// Список валидных кодов операций
$valid_ops = array(
'index' => 'Отчет об оценке',
'msg_list' => 'Список сообщений',
'msg_get' => 'Прочитать сообщение',
//'order_list' => 'Список заказов',
'order_post' => 'Отправкв заказа',
'order_info' => 'Получение информации о заказе',
'order_docs' => 'Дополнительные документы к заказу',
'order_report' => 'Получение отчета об оценке',
'order_txt' => 'Отправка текстового сообщения к заказу',
'order_del' => 'Удалить заказ',
'banks'=> 'Список банков',
'obj_checkinfo'=> 'Проверка наличия информации для проведения расчета стоимости',
'obj_calculate'=> 'Расчет стоимости объекта',
'person_checkinfo'=> 'Получение списка проверок физического лица',
'person_verify' => 'Запрос проверки физического лица',
'person_getverif' => 'Получение информации о проверке физ лица',
'person_report' => 'Получение отчета о проверке физ лица'
);
// Список табов страницы
$valid_tabs = array(
'index'=> array(
'title'=> 'Заказ на оценку',
'active'=> ['index', 'order_list', 'order_post', 'order_info', 'order_docs', 'order_report', 'order_txt'],
),
/*'msg_list'=> array(
'title'=> 'История',
'active'=> ['msg_list', 'msg_get'],
), // */
/*'banks'=> array(
'title'=> 'Банки',
'active'=> ['banks'],
), // */
/*'obj_checkinfo'=> array(
'title'=> 'Расчет стоимости',
'active'=> ['obj_checkinfo', 'obj_calculate'],
), // */
);
$get=clearInputData($_GET);
if(empty($get['op']))
$get['op'] = 'index';
if(isset($get['status']))
$page['status'] = $get['status'];
if(isset($get['msg']))
$page['msg'][] = strip_tags($get['msg']);
// Рендеринг табов
foreach($valid_tabs as $tab_key => $tab_item){
$active_class = '';
if(in_array($get['op'], $tab_item['active']))
$active_class = ' active';
$page['tabs'] .= sprintf('<a href="/war-object-report.php?id=%s&op=%s" class="tab%s"><span>%s</span></a>'.PHP_EOL,
$get['id'], $tab_key, $active_class, $tab_item['title']);
}
if(isset($get) && isset($get['id']) && $get['id'] != 0) {
// Выборка сведений об объекте.
// отображать разную информацию в завсимости от параметра $_GET['op']
$obj = WebAppRaiserObject::getObject($get['id']);
$object = $obj->get('object');
$warObjectData = WebAppRaiserOrder::load($get['id'], $WebAppRaiserAPI);
//msg('ObjectData', [$obj, $warObjectData]);
$page['breadcrumbs']['/my-objects.php'] = 'Объекты';
//$page['breadcrumbs']['/object.php?id='.$get['id']] = 'Объект '.$get['id'];
$page['breadcrumbs']['/war-object-report.php?op=index&id='.$get['id']] = 'Заказы ВебОценщик по объекту '.$get['id'];
if($WebAppRaiserAPI->war_expired){
$page['status'] = 'error';
$page['msg'][] = 'Ваш токен для доступа к API просрочен.';
$page['content'] .= '<p style="margin-bottom: 1em;">Ваш токен просрочен. Обновите его в настройках: </p>';
$page['content'] .= '<p><a class="fr-btn edit-btn steel i-btn very-small" style="-webkit-box-sizing:initial;" href="/settings.php#war_api">Обновить настройки</a></p>';
}
elseif(empty($WebAppRaiserAPI->get('war_id'))){
$page['status'] = 'error';
$page['msg'][] = 'Вы не подключены к API.';
$page['content'] .= '<div style="display:flex;justify-content: space-between;"><div style="width:50%;padding-right: 24px;">';
$page['content'] .= '<h2>Вход по секретному ключу</h2>';
$page['content'] .= '<p style="margin-bottom: 3em;">Вы не можете работать с API ВебОценщик. Если Вам известен логин и секретный ключ для подключения к API, то введите эти данные в настройках: </p>';
$page['content'] .= '<p><a class="fr-btn edit-btn steel i-btn very-small" style="-webkit-box-sizing:initial;" href="/settings.php#war_api">Обновить настройки</a></p>';
$page['content'] .= '</div><div style="width: 50%;border-left: 2px solid rgb(67, 160, 71);padding-left: 24px;">';
$page['content'] .= '<h2>Вход по пинкоду</h2>';
$page['content'] .= '<p style="margin-bottom: 1em;">Если Вам известен логин и пинкод для подключения общего доступа к API, то введите эти данные в этой форме: </p>';
$pincode_form = WebAppRaiserForm::getForm('api_pincode_form');
$page['content'] .= $pincode_form->render(['uid'=>$user->id, 'destination' => 'war-object-report.php?op=index&id='.$get['id']]);
$page['content'] .= '</div></div>';
}
else {
// выполняем операции только если задан правильно код операции
if(isset($get['op']) && isset($valid_ops[$get['op']])) {
//TODO переключаемся по кодам операций
switch($get['op']){
case 'index':
$page['subtitle'] = 'Отчет об оценке';
if(empty($warObjectData)){
// Если нет заказа, то создаем и показываем форму подачи заказа
$fields = array(
'woid' => 0,
'object_id'=> $get['id'],
'address'=> $object['adres'],
'contractCost' => $object['stoim'],
//'customerName' => $object['sobstv'],
//'customerPhone'=> $object['phone'],
'managerEmail'=> $WebAppRaiserAPI->get('war_username'),
'cadNum' => $object['cadastral_number'], //Кадастровый номер объекта
'objectType' => WebAppRaiserObject::getAPIType($object['type']),
'buildingStage' => 'BUILT',
'floor'=> $object['etazh'], //Этаж расположения объекта
'totalFloors' => $object['etazh_iz'], //Количество этажей в доме
'square' => $object['ploshad'], //Площадь объекта
'decorationType' => 'GOOD',
'buildYear' => $object['build_year'], //Год постройки дома
'wallMaterial' => WebAppRaiserObject::getAPIMaterial($object['house_material']),
'latitude' => $object['latitude'],
'longitude' => $object['longitude'],
'estimateValue' => $object['stoim'],
'сontactName' => trim($user->first_name.' '.$user->last_name),
'сontactPhone' => $user->phone,
'сontactEmail' => $user->email,
'images' => $obj->getFotos('create_order_form'),
'destination' => 'war-object-report.php?op=index&id='.$get['id'],
//'appraisalCompanyId' => $WebAppRaiser->get('appraisalCompanyId'),
);
$form = WebAppRaiserForm::getForm('order_create_form');
$page['content'] .= $form->render($fields);
$page['content'] .= WebAppRaiserForm::getForm('cost_analice_form')->render($fields, true);
}
else {
// Если есть заказ на оценку, то показываем информацию о заказе
$page['content'] .= '<p style="margin: 0 0 12px 0;"><a class="fr-btn edit-btn steel i-btn very-small" style="-webkit-box-sizing:initial;" href="/war-object-report.php?id='.$get['id'].'&op=order_post">Новый заказ</a></p>';
foreach($warObjectData as $obj){
$page['content'] .= $obj->render();
}
}
break;
case 'msg_list':
$page['subtitle'] = 'Список сообщений';
$page['breadcrumbs']['/war-object-report.php?op=msg_list&id='.$get['id'].'&order_id='.$get['order_id']] = 'Сообщения по заказу '.$get['order_id'];
$WebAppRaiserAPI->сhatMessages($get['order_id']);
WebAppRaiserOrder::updateMessages($WebAppRaiserAPI);
$page['content'] .= '<div class="row"><div class="col col-12 col-md-8" style="border-right:1px solid rgb(67, 160, 71);">';
$page['content'] .= '<h2>Сообщения в чате</h2>';
$page['content'] .= WebAppRaiserOrder::msgTable($get['id'], $get['order_id'], true);
$page['content'] .= '<p style="margin-bottom:2em;"><a class="fr-btn edit-btn steel i-btn very-small message_chat_form_modal_open" style="-webkit-box-sizing:initial;" href="#">Написать в чат</a></p>';
$page['content'] .= '</div><div class="col col-12 col-md-4">';
$page['content'] .= '<h2>История изменений</h2>';
$page['content'] .= WebAppRaiserOrder::msgTable($get['id'], $get['order_id'], false);
$page['content'] .= '</div></div>';
$fields = array(
'object_id'=> $get['id'],
'order_id'=> $get['order_id'],
'destination' => 'war-object-report.php?op=msg_list&id='.$get['id'].'&order_id='.$get['order_id'],
);
$page['content'] .= WebAppRaiserForm::getForm('message_chat_form')->render($fields, true);
//msg('ObjectData', $warObjectData);
//msg('USER', $user);
break;
case 'msg_get':
$page['subtitle'] = 'Прочитать сообщение';
break;
case 'order_post':
$page['subtitle'] = 'Отправка заказа';
$page['breadcrumbs']['/war-object-report.php?op=order_post&id='.$get['id']] = 'Создать заказ';
$fields = array(
'woid' => 0,
'object_id'=> $get['id'],
'address'=> $object['adres'],
'contractCost' => $object['stoim'],
//'customerName' => $object['sobstv'],
//'customerPhone'=> $object['phone'],
'managerEmail'=> $WebAppRaiserAPI->get('war_username'),
'cadNum' => $object['cadastral_number'], //Кадастровый номер объекта
'objectType' => WebAppRaiserObject::getAPIType($object['type']),
'buildingStage' => 'BUILT',
'floor'=> $object['etazh'], //Этаж расположения объекта
'totalFloors' => $object['etazh_iz'], //Количество этажей в доме
'square' => $object['ploshad'], //Площадь объекта
'decorationType' => 'GOOD',
'buildYear' => $object['build_year'], //Год постройки дома
'wallMaterial' => WebAppRaiserObject::getAPIMaterial($object['house_material']),
'latitude' => $object['latitude'],
'longitude' => $object['longitude'],
'estimateValue' => $object['stoim'],
'сontactName' => trim($user->first_name.' '.$user->last_name),
'сontactPhone' => $user->phone,
'сontactEmail' => $user->email,
'images' => $obj->getFotos('create_order_form'),
'destination' => 'war-object-report.php?op=index&id='.$get['id'],
//'appraisalCompanyId' => $WebAppRaiser->get('appraisalCompanyId'),
);
$form = WebAppRaiserForm::getForm('order_create_form');
$page['content'] .= $form->render($fields);
$page['content'] .= WebAppRaiserForm::getForm('cost_analice_form')->render($fields, true);
break;
case 'order_info':
$page['subtitle'] = 'Получение информации о заказе';
break;
case 'order_docs':
$page['subtitle'] = 'Дополнительные документы к заказу';
$page['breadcrumbs']['/war-object-report.php?op=order_docs&id='.$get['id'].'&order_id='.$get['order_id']] = 'Документы к заказу '.$get['order_id'];
$page['content'] .= '<p style="margin-bottom:2em;"><a class="fr-btn edit-btn steel i-btn very-small order_docs_form_modal_open" style="-webkit-box-sizing:initial;" href="#">Добавить документы</a></p>';
$page['content'] .= WebAppRaiserDocs::renderDocsTable(WebAppRaiserDocs::getDocs($get['order_id']));
$fields = array(
'object_id'=> $get['id'],
'order_id'=> $get['order_id'],
'destination' => 'war-object-report.php?op=order_docs&id='.$get['id'].'&order_id='.$get['order_id'],
);
$page['content'] .= WebAppRaiserForm::getForm('order_docs_form')->render($fields, true);
break;
case 'order_report':
$page['subtitle'] = 'Получение отчета об оценке';
$page['breadcrumbs']['/war-object-report.php?op=order_report&id='.$get['id'].'&order_id='.$get['order_id']] = 'Скачать отчет к заказу '.$get['order_id'];
$page['content'] .= '<h2>Скачать отчет об оценке</h2>';
$page['content'] .= '<p style="margin-bottom:2em;">Скачать набор документов в формате ZIP.</p>';
$fields = array(
'object_id'=> $get['id'],
'order_id'=> $get['order_id'],
'destination' => 'war-object-report.php?op=order_report&id='.$get['id'].'&order_id='.$get['order_id'],
);
$page['content'] .= WebAppRaiserForm::getForm('order_getreport_form')->render($fields);
break;
case 'order_txt':
$page['subtitle'] = 'Отправка текстового сообщения к заказу';
$page['content'] .= '<p>В процессе разработки.</p>';
$page['content'] .= '<p>Это форма для отправки текстового сообщения. Данная опция является излишней, так как форма сообщения будет открываться в модальном виде.</p>';
break;
case 'order_del':
$page['subtitle'] = 'Удаление заказа';
$page['breadcrumbs']['/war-object-report.php?op=order_del&id='.$get['id'].'&order_id='.$get['order_id']] = 'Удалить заказ '.$get['order_id'];
$fields = array(
'object_id'=> $get['id'],
'order_id'=> $get['order_id'],
);
$page['content'] .= '<h2>Внимание!!!</h2>';
$page['content'] .= '<p style="margin-bottom:2em;">Заказ на оценку будет удален в системе ВебОценщик.</p>';
$page['content'] .= WebAppRaiserForm::getForm('order_delete_form')->render($fields);
break;
/*case 'banks':
$page['subtitle'] = 'Список банков';
$banks = $WebAppRaiserAPI->loadBanks();
$page['msg'][] = $dpm($banks);
break; // */
case 'obj_checkinfo':
$page['subtitle'] = 'Проверка наличия информации для проведения расчета стоимости';
break;
case 'obj_calculate':
$page['subtitle'] = 'Расчет стоимости объекта';
break;
case 'person_checkinfo':
$page['subtitle'] = 'Получение списка проверок физического лица';
break;
case 'person_verify':
$page['subtitle'] = 'Запрос проверки физического лица';
break;
case 'person_getverif':
$page['subtitle'] = 'Получение информации о проверке физ лица';
break;
case 'person_report':
$page['subtitle'] = 'Получение отчета о проверке физ лица';
break;
}
}
else {
$page['status'] = 'error';
$page['msg'][] = 'Не найден код операции';
$page['subtitile'] = 'Операция не найдена';
}
}
} else {
$page['status'] = 'error';
$page['message'] = 'Не найден ИД объкта!';
}
$breadcrumbs = '';
if(!empty($page['breadcrumbs']) && is_array($page['breadcrumbs'])){
//$bread_keys = array_keys($page['breadcrumbs']);
$count_keys = count($page['breadcrumbs']);
foreach($page['breadcrumbs'] as $key => $bc){
$count_keys = $count_keys - 1;
$x = explode('|', $bc);
$breadcrumbs .= '<a href="'.$key.'" class="router-link-active';
if(isset($x[1]) && $x[1] == 1){
$breadcrumbs .= ' router-link-exact-active active-step';
}
elseif($count_keys == 0){
$breadcrumbs .= ' router-link-exact-active active-step';
}
$breadcrumbs .= '">'.$x[0];
if($count_keys > 0){
$breadcrumbs .= $breadcrumb_array_svg;
}
$breadcrumbs .= PHP_EOL.'</a>'.PHP_EOL;
}
}
?>
<link rel="stylesheet" href="/engine/classes/WebAppRaiser/bootstrap-grid.css" type="text/css" />
<script type="text/javascript">
setTimeout(function(){
var elem = document.createElement('script');
elem.type = 'text/javascript';
elem.src = 'https://api-maps.yandex.ru/2.1/?load=package.standard&apikey=692f0a05-cb88-4158-88b9-06bc0dc93004&lang=ru_RU';
document.getElementsByTagName('body')[0].appendChild(elem);
}, 1000);
</script>
<div class="content-right">
<div class="inner">
<div class="main-title">
<h1>
<?php print $page['title']; ?>
</h1>
</div>
<!--<div class="new">
<div class="jw__page__tabs type__tabs">
<?php print $page['tabs']; ?>
</div>
</div> -->
<?php if(!empty($breadcrumbs)): ?>
<div class="navigation-container">
<div class="breadcrumbs">
<?php print $breadcrumbs; ?>
<!--<a href="#/my-objects" class="router-link-active">Жилые комплексы
<?php print $breadcrumb_array_svg; ?>
</a>
<a href="#/my-objects/377" class="router-link-active router-link-exact-active active-step">Новый Оккервиль</a> -->
</div>
</div>
<?php endif; ?>
<?php
$messages = msg('get');
if(!empty($messages)) {
foreach($messages as $msg_item) {
$page['msg'][] = $msg_item;
}
}
if(!empty($page['msg'])){
print '<div class="new-object" style="border:none;">';
if($page['status'] == 'error')
echo '<div class="error_msg" style="margin-bottom: 0;">'.implode('<br/>', $page['msg']).'</div>';
else
echo '<div class="success_msg" style="margin-bottom: 0;">'.implode('<br/>', $page['msg']).'</div>';
print '</div>';
}
?>
<div class="new-object">
<div class="new-object__form">
<div class="block">
<h2><?php print $page['subtitle'] ?></h2>
<p>Объект: <a target="_blank" href="/object.php?id=<?php echo $object['id']; ?>"><?php echo $object['id']; ?></a> (<?php echo $object['nazv']; ?>)</p>
</div>
<div class="block">
<?php
print $page['content'];
?>
</div>
</div>
</div>
</div>
</div>
<?php require($_SERVER['DOCUMENT_ROOT']."/templates/footer.php"); ?>