<?php
/**
Template Name: Cooperation
* Post Template
*
* This template is loaded when browsing a Feature Custom Post Type.
*
* @package Invent
* @subpackage Template
*/
$image_size = 'large';
get_header();
?>
<?php mo_exec_action('before_content'); ?>
<div id="content" class="<?php echo mo_get_content_class(); ?>">
<?php mo_exec_action('start_content'); ?>
<?php the_content(); ?>
<?
error_reporting(0);
function show_form()
{
?>
<div id="registr_form" class="registration registr-page">
<div id="form-area">
<div class="form">
<form action="" method=post>
<input type="hidden" name="user_id" value="" />
<div id="reg-form-step1">
<div class="row">
<label><?php echo __('imja','cooperation');?>:*</label>
<input type="text" name="input_name[0]" value="<?=substr(htmlspecialchars(trim($_POST['input_name'][0])), 0, 500);?>" />
<input type="hidden" name="check[]" value="1"></b>
<span id="result_mail" style="display:none;"></span>
</div>
<div class="row">
<label><?php echo __('familija','cooperation');?>:*</label>
<input type="text" name="input_name[1]" value="<?=substr(htmlspecialchars(trim($_POST['input_name'][1])), 0, 500);?>" />
<input type="hidden" name="check[]" value="1"></b>
<span id="result_mail" style="display:none;"></span>
</div>
<div class="row">
<label><?php echo __('mesto-raboti','cooperation');?>:*</label>
<input type="text" name="input_name[2]" value="<?=substr(htmlspecialchars(trim($_POST['input_name'][2])), 0, 500);?>" />
<input type="hidden" name="check[]" value="1"></b>
<span id="result_mail" style="display:none;"></span>
</div>
<div class="row">
<label><?php echo __('dolzhnostj','cooperation');?>:*</label>
<input type="text" name="input_name[3]" value="<?=substr(htmlspecialchars(trim($_POST['input_name'][3])), 0, 500);?>" />
<input type="hidden" name="check[]" value="1"></b>
<span id="result_mail" style="display:none;"></span>
</div>
<div class="row">
<label><?php echo __('telefon','cooperation');?>:*</label>
<input type="text" name="input_name[4]" value="<?=substr(htmlspecialchars(trim($_POST['input_name'][4])), 0, 500);?>" />
<input type="hidden" name="check[]" value="1"></b>
<span id="result_mail" style="display:none;"></span>
</div>
<div class="row">
<label><?php echo __('mail','cooperation');?>:*</label>
<input type="text" name="input_name[5]" value="<?=substr(htmlspecialchars(trim($_POST['input_name'][5])), 0, 500);?>" />
<input type="hidden" name="check[]" value="1"></b>
<span id="result_mail" style="display:none;"></span>
</div>
<td bgcolor="#1F2760">
<td align="left">
</td><td align="right"><input type="submit" value="<?php echo __('otpravitj','cooperation');?>" style="background-color:#B0ADC3;border: #000 1px solid;" name="submit">
</td>
</td>
</tr>
</table>
</div>
<br />
</form><div align="center">* <?php echo __('pomechenie-polja-neobxodimo-zapolnitj','cooperation');?></div>
<?
}
function complete_mail() {
$empty_input[] = __('imja','cooperation');
$empty_input[] = __('familija','cooperation');
$empty_input[] = __('mesto-raboti','cooperation');
$empty_input[] = __('dolzhnostj','cooperation');
$empty_input[] = __('telefon','cooperation');
$empty_input[] = __('mail','cooperation');
for ($i=0; $i<count($_POST['input_name']); $i++) {
$_POST['input_name'][$i] = substr(htmlspecialchars(trim($_POST['input_name'][$i])), 0, 100000);
if(substr(htmlspecialchars(trim($_POST['check'][$i])), 0, 1) == 1) {
if(empty($_POST['input_name'][$i])) {
$sendemail = 'No';
echo '<br /><b>';
echo __('neobxodimo-zapolnitj-pole','cooperation');
echo ' ';
echo $empty_input[$i];
echo '!</b>';
}
}
}
if($sendemail == 'No') show_form();
$mess = '';
$mess .= '<b>Имя: </b>'.$_POST['input_name'][0].'<br />';
$mess .= '<b>Фамилия: </b>'.$_POST['input_name'][1].'<br />';
$mess .= '<b>Место работы: </b>'.$_POST['input_name'][2].'<br />';
$mess .= '<b>Должность: </b>'.$_POST['input_name'][3].'<br />';
$mess .= '<b>Телефон: </b>'.$_POST['input_name'][4].'<br />';
$mess .= '<b>Майл: </b>'.$_POST['input_name'][5].'<br />';
require 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->From = 'work@mail.ru'; // от кого email
$mail->FromName = 'Сотрудничество'; // от кого имя
$mail->CharSet = "utf-8";
$mail->AddAddress('denis@mail.ru', 'denis@mail.ru'); // кому - адрес, Имя
$mail->IsHTML(true); // выставляем формат письма HTML
$mail->Subject = 'Сотрудничество'; // тема письма
$mail->Body = $mess;
if($sendemail != 'No'){
// отправляем письмо
if (!$mail->Send()) die ('Mailer Error: '.$mail->ErrorInfo);
echo __('spasibo-vashe-pisjmo-otpravleno','ask-work');
}
}
if (!empty($_POST['submit'])) complete_mail();
else show_form();
?>
<?php mo_exec_action('end_content'); ?>
<?php get_template_part('loop-nav'); // Loads the loop-nav.php template. ?>
</div><!-- #content -->
</div>
</div>
</div>
</div>
</div>
<?php mo_exec_action('after_content'); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>