57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
|
|
<?php
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
|
|||
|
|
if ($_SESSION['id'] && $_GET['view'] == "option") {
|
|||
|
|
|
|||
|
|
$output = [];
|
|||
|
|
$get = clearInputData($_GET);
|
|||
|
|
$client_id = 0;
|
|||
|
|
$req_id = 0;
|
|||
|
|
|
|||
|
|
$required = null;
|
|||
|
|
if (isset($get['required']))
|
|||
|
|
$required = $get['required'];
|
|||
|
|
if(isset($get['client_id']))
|
|||
|
|
$client_id = (int)$get['client_id'];
|
|||
|
|
if(isset($get['req_id']))
|
|||
|
|
$req_id = (int)$get['rq_id'];
|
|||
|
|
|
|||
|
|
//Поиск клиента по id заявки
|
|||
|
|
if($req_id > 0){
|
|||
|
|
$sql = "SELECT client_id FROM requisitions WHERE id = {$req_id}";
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
if($r = mysql_fetch_assoc($q)){
|
|||
|
|
$client_id = (int)$r['client_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($options = Docs::getSourcesList($get['agency_id'], $get['section'], $required)) {
|
|||
|
|
foreach ($options as $option) {
|
|||
|
|
$name = $option['name'];
|
|||
|
|
$selected = '';
|
|||
|
|
if ($get['section'] == "clients") {
|
|||
|
|
$contacts = [];
|
|||
|
|
if($option['id'] == $client_id)
|
|||
|
|
$selected = 'selected';
|
|||
|
|
|
|||
|
|
if (!empty($option['email']))
|
|||
|
|
$contacts[] = $option['email'];
|
|||
|
|
|
|||
|
|
if (!empty($option['phone']))
|
|||
|
|
$contacts[] = $option['phone'];
|
|||
|
|
|
|||
|
|
if (!empty($contacts))
|
|||
|
|
$name .= ' (' . implode(', ', $contacts) . ')';
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
if (!empty($option['address']))
|
|||
|
|
$name .= ' (' . $option['address'] . ')';
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$output[] = '<option '.$selected.' value="' . $option['id'] . '">' . $name . '</option>';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo implode("\r\n", $output);
|
|||
|
|
}
|