ACC SHELL
<?php // -*- mode: php; indent-tabs-mode: t -*-
/* $Id$ */
class PagesController extends AppController
{
var $uses = array('Article');
var $name = 'Pages';
var $title = array('TSI System');
var $helpers = array('Cache', 'Html', 'Javascript');
var $components = array('Session');
var $cacheAction = array(
'publikace-' => 0,
'login' => 0,
'registrace' => 0,
'poptavka' => 0,
'dotazy' => 0,
'kontakty' => 0, // because cakephp bug in cake:nocache handlig
'' => WEEK
);
/**
*
*/
function beforeRender()
{
$this->pageTitle = join(' » ', $this->title);
}
/**
*
*/
function beforeFilter()
{
}
/**
*
*/
function news()
{
@$this->t = (int) $this->params['type'];
$this->title[] = $this->t ? 'Výstavy, konference, semináře' : 'Novinky';
$this->set('where', $this->t ? 'Výstavy, konference, semináře' : 'Novinky');
if (! empty($this->params['date']) && ! empty($this->params['name'])) {
$data = $this->Article->findByTitle_idx(
$this->params['date'] . '-' . $this->params['name']
);
if (! $data) {
$this->redirect($this->t ? '/vystavy-konference-seminare' : '/novinky');
exit();
}
if (! $data['Article']['published']
|| ($data['Article']['publish_from']
&& strtotime($data['Article']['publish_from']) > time())
|| ($data['Article']['publish_to']
&& strtotime($data['Article']['publish_to']) < time())) {
$this->redirect($this->t ? '/vystavy-konference-seminare' : '/novinky');
exit();
}
$this->set('single', 1);
$this->set('news', $data);
$this->set('files', @unserialize($data['Article']['files']));
return;
}
$data = $this->Article->findAll(
'article_type = ' . $this->t
. ' AND published = 1 AND (publish_from IS NULL OR publish_from <= NOW())
AND (publish_to IS NULL OR publish_to > NOW())', NULL, 'created_d DESC'
);
$this->set('news', $data);
}
function company() { $this->title[] = 'Společnost'; }
function contacts() { $this->title[] = 'Kontakty'; }
function career() { $this->title[] = 'Kariéra'; }
function prezentace() { $this->title[] = 'Prezentace'; }
function calibration() { $this->title[] = 'Kalibrace'; }
function repairs() { $this->title[] = 'Opravy'; }
function measuration() { $this->title[] = 'Měření a zkoušení'; }
function providers()
{
$providers = array(
'nedestruktivni-zkouseni' => array(
'name' => 'Nedestruktivní zkoušení',
'child' => array(
'defelsko-corp' => 'DeFelsko Corp.',
'amsterdam-technology-bv' => 'Amsterdam Technology bv',
'pcwi' => 'PCWI',
'UE Systems' => 'UE Systems',
),
),
'bezkontaktni-mereni' => array(
'name' => 'Bezkontaktní měření',
'child' => array(
'fluke-europe-bv' => 'Fluke Europe B.V.',
'raytek-gmbh' => 'Raytek GmbH',
'ircon' => 'Ircon',
),
),
'zkousky-materialu' => array(
'name' => 'Zkoušky materiálů',
'child' => array(
'atm-gmbh' => 'ATM GmbH',
'tecmet-2000-srl' => 'TECMET 2000 Srl',
'lam-plan-sa' => 'LAM PLAN S.A.',
'heraeus-kulzer-gmbh' => 'Heraeus Kulzer GmbH',
'ernst-harteprufer-sa' => 'Ernst Härteprüfer SA',
'future-tech-corp' => 'FUTURE-TECH CORP.',
),
),
);
$menu = '';
$selected = empty($this->params['selected']) ? '' : $this->params['selected'];
foreach ($providers as $top_id => $ary) {
$current = 0;
$tmp = '';
foreach ($ary['child'] as $id => $name) {
$tmp .= sprintf('<li class="menu-3"><a href="%sdodavatele/%s"%s>%s</a></li>',
$this->webroot, $id,
$selected == $id ? ' class="current"' : '',
$name);
if ($selected == $id) {
$current = 1;
}
}
if ($top_id == $selected) {
$menu .= sprintf('<li class="menu-1"><a href="%sdodavatele/%s" class="current">%s</a>',
$this->webroot, $top_id,
$ary['name']);
}
else {
$menu .= sprintf('<li><a href="%sdodavatele/%s">%s</a>',
$this->webroot, $top_id,
$ary['name']);
}
if ($current || $top_id == $selected) {
$menu .= '<ul class="right-menu right-menu-3">' . $tmp . '</ul>';
}
$menu .= '</li>';
}
$this->set('menu', $menu);
$this->title[] = 'Dodavatelé';
if (! empty($this->params['selected'])) {
if (in_array($this->params['selected'], array(
'olympus-ndt-inc', 'defelsko-corp',
'raytek-gmbh', 'fluke-europe-bv', 'cognex-corp',
'atm-gmbh', 'lam-plan-sa', 'heraeus-kulzer-gmbh',
'affri-di-affri-roberto', 'pcwi', 'buchner-lichtsysteme-gmbh',
'nedestruktivni-zkouseni', 'bezkontaktni-mereni', 'zkousky-materialu',
'amsterdam-technology-bv', 'ernst-harteprufer-sa', 'future-tech-corp', 'tecmet-2000-srl',
'ircon','UE Systems'
))) {
$this->set('part', $this->params['selected']);
return;
}
$this->redirect('/dodavatele');
}
$this->set('part', 'providers');
}
/**
*
*/
function publications()
{
if (empty($_REQUEST['y'])) {
$year = date('Y');
}
else {
$year = (int) $_REQUEST['y'];
}
$this->set('y', $year);
if (! empty($this->params['date']) && ! empty($this->params['name'])) {
$data = $this->Article->findByTitle_idx(
$this->params['date'] . '-' . $this->params['name']
);
if (! $data) {
$this->redirect('/publikace-inzerce');
exit();
}
if (! $data['Article']['published']
|| ($data['Article']['publish_from']
&& strtotime($data['Article']['publish_from']) > time())
|| ($data['Article']['publish_to']
&& strtotime($data['Article']['publish_to']) < time())) {
$this->redirect('/publikace-inzerce');
exit();
}
$this->set('single', 1);
$this->set('news', $data);
$this->set('files', @unserialize($data['Article']['files']));
$this->set('y', '20' . substr($this->params['date'], 0, 2));
return;
}
if ($year == 2002) {
$where = 'YEAR(created_d) < 2003';
}
else {
$where = 'YEAR(created_d) = ' . $year;
}
$data = $this->Article->findAll(
$where . ' AND article_type = 2 AND published = 1 AND ' .
'(publish_from IS NULL OR publish_from <= NOW())
AND (publish_to IS NULL OR publish_to > NOW())', NULL, 'created_d DESC'
);
$this->set('news', $data);
}
/**
*
*/
function questions()
{
$this->title[] = 'Dotazy';
global $DOMAINS;
$domains = $DOMAINS;
$emails = array_values($domains);
$this->set('domains', array_keys($domains));
if (! empty($this->params['form'])) {
$customer = $this->params['form'];
}
else {
$customer = $this->Session->read('logged_customer');
if (! $customer) {
$customer = array(
'firm' => '',
'email' => '',
'address' => '',
'real_name' => '',
'role' => '',
'phone' => '',
'fax' => '',
);
}
// $customer['address'] = str_replace(', ', "\r\n", $customer['address']);
}
$customer['address'] = text_address($customer['address']);
$this->set('customer', array_map('htmlspecialchars', $customer));
if (empty($_REQUEST['real_name']) || empty($_REQUEST['email'])
|| empty($_REQUEST['phone']) || empty($_REQUEST['question'])
|| empty($_REQUEST['domain']) || empty($_REQUEST['address'])) {
return;
}
setDefault($_REQUEST['fax'], '-', 0);
setDefault($_REQUEST['firm'], '-', 0);
setDefault($_REQUEST['role'], '-', 0);
$mail_to = $_REQUEST['domain'] < 10 ? 'obchod@tsisystem.cz' : 'servis@tsisystem.cz';
$mail_to .= ', ' . $emails[$_REQUEST['domain']];
$domains = array_keys($domains);
$domain = $domains[$_REQUEST['domain']];
$_REQUEST['address'] = preg_replace('/\\r?\\n/', ', ', $_REQUEST['address']);
$text = <<<EOT
Název firmy: {$_REQUEST['firm']}
Jméno a přijmení: {$_REQUEST['real_name']}
Funkce ve firmě: {$_REQUEST['role']}
Adresa: {$_REQUEST['address']}
Telefon: {$_REQUEST['phone']}
Fax: {$_REQUEST['fax']}
E-mail: {$_REQUEST['email']}
Obor dotazu: $domain
Dotaz:
{$_REQUEST['question']}
EOT;
mail(
$mail_to,
'WWW TSI System: dotaz od ' . $_REQUEST['real_name'],
$text,
"From: noreply@tsisystem.cz\n" .
"Reply-To: info@tsisystem.cz\n" .
"MIME-Version: 1.0\n" .
"Content-Type: text/plain; charset=ISO-8859-2\n"// .
// "From: \"Dotaz z WWW stranek TSI System\" <noreply@tsisystem.cz>\r\n"
);
$this->set('send', 1);
}
/**
*
*/
function ref()
{
}
}
?>
ACC SHELL 2018