get($_SESSION['id']); // Header data for future set default where empty (default img / text / etc.) $header = [ 'left-img' => '', 'left-title' => '', 'left-phone' => '', 'manager-name' => '', 'manager-is' => false, 'manager-img' => '', 'email' => '', 'sitename' => '', 'site' => '', 'address' => '', 'phone' => '', 'close' => $closeHeader, ]; if($user->photo) $header['left-img'] = $_SERVER['DOCUMENT_ROOT']."/photos/agency/".$_SESSION['photo']; else $header['left-img'] = ''; if ($user->agency) { $header['left-title'] = htmlspecialchars_decode($user->agency_name); } else if ($_SESSION['agency'] && $_SESSION['agency_name']) { $header['left-title'] = htmlspecialchars_decode($_SESSION['agency_name']); } else if (isset($user->agencyName)) { $header['left-title'] = htmlspecialchars_decode($user->agencyName); } if($user->phoneAgency){ $header['left-phone'] = $user->phoneAgency; }else{ $header['left-phone'] = $user->phone; } /*if(!$_SESSION['agency']) $header['manager-name'] = htmlspecialchars_decode($user->fio); else $header['manager-name'] = $user->director; */ $header['manager-name'] = htmlspecialchars_decode(trim($user->last_name . ' ' . $user->first_name . ' ' . $user->middle_name)); if ($_SESSION['individual'] == 1) { $header['email'] = $_SESSION['email']; if($user->sitename) { $header['sitename'] = $user->sitename; $header['site'] = $user->site; } $header['address'] = $user->adres; }elseif ($_SESSION['individual'] == 0) { $header['manager-is'] = true; $header['email']= $_SESSION['email']; $header['phone'] = $_SESSION['phone']; if ($user->user_logo) { $header['manager-img'] = $_SERVER['DOCUMENT_ROOT'] . "/photos/agency/" . $user->user_logo; } } return $header; } /* Формирование шаблона шапки PDF */ function pdf_header($header){ if($header['close'] == 1){ $html = ''; } else { $html = ''; }else{ $html .= ''; } if($header['manager-is']) $html .= ''; $html .= '
'; if($header['left-img'] != '') $html.= ''; $html .= '
'.$header['left-title'].'
'.$header['left-phone'].'
'.$header['email'].'
'.$header['sitename'].''; if($header['address'] != ''){ $html .= '
'.$header['address'].''; $html .= '
'; if($header['manager-img']!='') $html .= ''; if(!empty($header['manager-name'])) $html .= '
Ваш менеджер '.$header['manager-name'].'
'; } return $html; } /* Формирование первой страницы */ function pdf_body_first($arrTop, $arrProps, $type = null, $typeCategory = null){ $data = [ 'type' => $arrTop['type'], 'commerce_type' => $arrTop['commerce_type'], 'operation_type' => $arrTop['operation_type'], 'sdelka' => $arrTop['sdelka'], 'nazv' => $arrTop['nazv'], 'etazh' => $arrTop['etazh'], 'etazh_iz' => $arrTop['etazh_iz'], 'stoim' => $arrTop['stoim'], 'currency' => get_currency_sign($arrTop['currency']), 'replace_plan' => $arrTop['replace_plan'], 'planirovka' => $arrTop['plan'], 'metro' => [ 'name'=> $arrTop['metrostr'], 'way'=>$arrTop['way'] ], 'address' => $arrTop['address'], 'rayon' => $arrTop['rayon'], 'square' => [ 'all' => $arrTop['ploshad'], 'live' => $arrTop['ploshad_komn'], 'kitchen' => $arrTop['ploshad_k'], ], 'squareLand' => $arrTop['commerc_site'], 'landArea' => $arrTop['land_area'] ]; $countProps = count($arrProps); if($countProps > 30){ $props = array_slice($arrProps,0,30); }else{ $props = $arrProps; } $etazhnost = empty($data['etazh_iz']) ? $data['etazh'] : $data['etazh'].' из '.$data['etazh_iz']; if(empty($etazhnost)) $etazhnost = '-'; $arrType = ['-', 'Квартира','Комната','Дом','Коммерческая недвижимость','Часть дома','Комплекс','Участок']; $subtitle = $arrType[$data['type']]; if(!empty($data['commerce_type'])){ $subtitle .= ' - '.$data['commerce_type']; } $propsHTML = ''; $html = '

'.$data['nazv'].'

'.$subtitle.'

Тип сделки: '.$data['sdelka'].'

'; if ($data['metro'] && $data['metro']['name']) { $html .= ''; } $html .= '
'.$data['metro']['name'].' '.$data['metro']['way'].''.$data['address'].' '.$data['rayon'].'
'; if ($type && ($type == 7 || ($type == 4 && $typeCategory == 9))) { $html .= '

Цена:   ' . $data['stoim'] . ' ' . $data['currency'] . '

'; } else { $html .= '

Этажность: ' . $etazhnost . '

Цена:   ' . $data['stoim'] . ' ' . $data['currency'] . '

'; } if($countProps > 15){ $layout = 1; $propsHTML .= ''; for($i=0; $i < 15; $i++){ $propsHTML .= ''; } $propsHTML .= '
'.$props[$i]['desc'].''.$props[$i]['val'].'
'; for($i=15; $i < $countProps; $i++){ $propsHTML .= ''; } $propsHTML .= '
'.$props[$i]['desc'].''.$props[$i]['val'].'
'; }elseif($countProps <= 15 && $countProps > 0){ $layout = 2; foreach($props as $val){ $propsHTML .= ''.$val['desc'].''.$val['val'].''; } }else{ $layout = 3; } $html .= ''; if ($type && $type == 4 && $typeCategory && $typeCategory == 9) { $squareHTML = '

Площадь:

'; $squareHTML .= '
Общая: '.$data['squareLand'].' ГА
'; } else { if ($type && $type == 7) { $squareHTML = '

Площадь:

'; $squareHTML .= '
Общая: '.$data['landArea'].' соток
'; } else { $squareHTML = '

Площадь:

'; if (!empty($data['square']['live'])) $squareHTML .= ''; if (!empty($data['square']['kitchen'])) $squareHTML .= ''; $squareHTML .= '
Общая: ' . $data['square']['all'] . ' м2Жилая: ' . $data['square']['live'] . ' м2Кухня: ' . $data['square']['kitchen'] . ' м2
'; } } $planTitle = $data['replace_plan'] ? ' ' : 'Планировка:'; switch ($layout) { case 1: // все свойства и картинка справа $html .= ''; $html .= $squareHTML; $html .= '

Характеристики:

'; $html .= ''.$propsHTML.'
'; $html .= ''; if(!empty($data['planirovka'])) $html .= '

'.$planTitle.'

'; break; case 2: // половина свойств и картинка справа $html .= ''; $html .= $squareHTML; $html .= '

Характеристики:

'; $html .= ''.$propsHTML.'
'; $html .= ''; if(!empty($data['planirovka'])) $html .= '

'.$planTitle.'

'; break; case 3: // нет свойств и картинка снизу $html .= ''; $html .= $squareHTML; if(!empty($data['planirovka'])) $html .= '

'.$planTitle.'

'; $html .= ''; break; } $html .= ''; return $html; } /* Формирование второй страницы с описанием */ function pdf_body_second($opis, $img, $common) { $html = '

Описание

'; /* Формирование доп. инфо */ if (count($common) > 0) { $propsHTML = ''; foreach($common as $key => $value) { $propsHTML .= ''; } $opis .= '

'; $opis .= '

Дополнительная информация:

'; $opis .= '
'.$key.':'.$value.'
'.$propsHTML.'
'; } if ($img == '') { $html .= ''.$opis.''; } else { $html .= ''.$opis.''; $html .= ''; } $html .= ''; return $html; } /* Формирование третьей страницы с фотографиями */ function pdf_body_third($photos){ $html = '

Фотографии

'; foreach($photos as $photo){ $html .= ''; } $html .= '
'; return $html; } function get_currency_sign($currencyNumber) { switch ($currencyNumber) { case 0: return 'р.'; case 1: return '$'; case 2: return '€'; } } ?>