11-23-2017, 01:37 AM
Ребят пилю потихоньку веб аукцион так вот возникла такая ситуация
сейчас реализована такая система:
продавец выставляет продукт-> продукт находит покупатель-> покупатель делает ставку> продаван подтверждает ставку> а далее костыль получается((( по старому движку продавец должен внести деньги которые поставил покупатель и после окончания сделки (там несколько этапов) деньги должны поступить покупателю.
А мне нужно: продавец выставляет продукт-> продукт находит покупатель-> покупатель делает ставку> продаван подтверждает ставку>покупатель вносит деньги
помогите исправить вот :
(в нынешней версии кода продавец это user покупатель author)
переписываю движок с codeigniter
сейчас реализована такая система:
продавец выставляет продукт-> продукт находит покупатель-> покупатель делает ставку> продаван подтверждает ставку> а далее костыль получается((( по старому движку продавец должен внести деньги которые поставил покупатель и после окончания сделки (там несколько этапов) деньги должны поступить покупателю.
А мне нужно: продавец выставляет продукт-> продукт находит покупатель-> покупатель делает ставку> продаван подтверждает ставку>покупатель вносит деньги
помогите исправить вот :
(в нынешней версии кода продавец это user покупатель author)
код
[SRC="php"]<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Orders extends CI_Controller
{
private $_files;
private $_error;
public function __construct()
{
parent::__construct();
$this->load->model('Order', 'order');
$this->load->model('common', 'common');
$this->layout->setLayout('2_columns');
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
$this->_files = array(
'file1' => '',
'file2' => '',
'file3' => ''
);
$this->load->helper('seo');
}
public function index()
{
$data['result'] = array();
$data['q'] = '';
$data['order'] = 'date';
$data['work_types'] = $this->common->get_asc('work_types');
$data['work_themes'] = $this->common->get_asc('work_themes');
$data['work_languages'] = $this->common->get_asc('work_languages');
$data['type_values'] = array();
$data['theme_values'] = array();
$data['language_values'] = array();
foreach ($data['work_types'] as $worktype)
{
$data['type_values'][$worktype->id] = 0;
}
foreach ($data['work_themes'] as $worktheme)
{
$data['theme_values'][$worktheme->id] = 0;
}
foreach ($data['work_languages'] as $worklanguage)
{
$data['language_values'][$worklanguage->id] = 0;
}
$this->form_validation->set_rules('q', 'Поисковый запрос', 'xss_clean');
if ($this->form_validation->run() == true)
{
$q = (string) $this->input->post('q');
$insertdata = array('query' => $q);
$query_id = $this->common->insert('search_queries', $insertdata);
$data['query_id'] = $query_id;
$data['q'] = $q;
$types = (array) $this->input->post('types');
$themes = (array) $this->input->post('themes');
$languages = (array) $this->input->post('languages');
$types_array = array();
$themes_array = array();
$languages_array = array();
if (isset($types[0]))
{
$data['types_all'] = ($types[0] == 1) ? 1 : 0;
}
else
{
$data['types_all'] = 0;
}
if (isset($themes[0]))
{
$data['themes_all'] = ($themes[0] == 1) ? 1 : 0;
}
else
{
$data['themes_all'] = 0;
}
if (isset($languages[0]))
{
$data['languages_all'] = ($languages[0] == 1) ? 1 : 0;
}
else
{
$data['languages_all'] = 0;
}
$data['types_some'] = 0;
$data['themes_some'] = 0;
$data['languages_some'] = 0;
foreach ($types as $type => $value)
{
if ($value == 1)
{
$types_array[] = $type;
$data['type_values'][$type] = 1;
$data['types_some'] = 1;
}
}
foreach ($themes as $theme => $value)
{
if ($value == 1)
{
$themes_array[] = $theme;
$data['theme_values'][$theme] = 1;
$data['themes_some'] = 1;
}
}
foreach ($languages as $language => $value)
{
if ($value == 1)
{
$languages_array[] = $language;
$data['language_values'][$language] = 1;
$data['languages_some'] = 1;
}
}
$page = (int) $this->uri->segment(2);
$order = (string) $this->input->post('order');
$data['order'] = $order;
$data['founded'] = $this->order->count_all_search($q, $types_array, $themes_array, $languages_array);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/index/';
$config['total_rows'] = $data['founded'];
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['result'] = $this->order->search($q, $types_array, $themes_array, $languages_array, $order, $page);
}
else
{
$page = (int) $this->uri->segment(3);
$query_id = (int) $this->uri->segment(4);
$data['types_all'] = 0;
$data['themes_all'] = 0;
$data['languages_all'] = 0;
$data['types_some'] = 0;
$data['themes_some'] = 0;
$data['languages_some'] = 0;
if ($query_id != 0)
{
$query = $this->common->get_item_by_params('search_queries', array('query' => $q));
$data['founded'] = $this->order->count_all_search($query->query, $types_array, $themes_array, $languages_array);
}
else
{
$data['founded'] = $this->order->count_all_search(false, array(), array(), array());
}
$this->load->library('pagination');
$config['base_url'] = '/zakaz/index/';
$config['total_rows'] = $data['founded'];
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['result'] = $this->order->search(false, array(), array(), array(), 'id', $page);
}
$page = $this->common->get_item_by_params('pages', array('alias' => 'orders'));
$data['text'] = $page->text;
$this->layout->title = $page->title;
$this->layout->keywords = $page->keywords;
$this->layout->description = $page->description;
$this->layout->view('orders/index', $data);
}
public function add()
{
$next_id = $this->common->getNext('orders');
if ($_POST)
{
if ($this->input->post('next_id') < $next_id)
{
$page = $this->common->getSeo('orders', $this->input->post('next_id'));
redirect('/zakaz/tema/' . $page);
}
}
//echo date('d-y-m', )
$data['title'] = 'Новый заказ';
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
$this->form_validation->set_rules('name', 'Название', 'required|xss_clean');
$this->form_validation->set_rules('type', 'Тип работы', 'required|integer');
$this->form_validation->set_rules('theme', 'Предмет', 'required|integer');
$this->form_validation->set_rules('language', 'Язык', 'required|integer');
$this->form_validation->set_rules('minpages', 'Минимальный объем', 'required|integer|greater_than[0]');
$this->form_validation->set_rules('maxpages', 'Максимальный объем', 'required|integer');
$this->form_validation->set_rules('description', 'Задание', 'xss_clean');
$this->form_validation->set_rules('date', 'Сроки', 'xss_clean|callback_check_date');
$this->form_validation->set_rules('budget', 'Бюджет', 'required|greater_than[0]');
$config['upload_path'] = './uploads/files/';
$config['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf|tif';
$config['max_size'] = '15360';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
$this->upload->display_errors('<p class="error">', '</p>');
for ($i = 1; $i < 4; $i++)
{
$field = 'file' . $i;
if (isset($_FILES[$field]['name']))
{
if ($_FILES[$field]['name'] != '')
{
if ($this->upload->do_upload($field))
{
$data = $this->upload->data();
$this->_files[$field] = $data['file_name'];
$this->common->insert('filenames', array('hashname' => $data['file_name'], 'realname' => $_FILES[$field]['name']));
}
else
{
$filename = $_FILES[$field]['name'];
$this->_error = $this->upload->display_errors();
$this->form_validation->set_rules($field, 'Файл ' . $i, 'callback_upload_file');
}
}
}
}
if ($this->form_validation->run() == true)
{
$user = $this->ion_auth->profile();
$is_auth = $this->ion_auth->logged_in() ? 1 : 0;
$date = (string) $this->input->post('date');
$date = strtotime($date) + 86340;
$this->load->helper('text');
$description = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$description = word_censor($description, $disallowed, '[ ***** ]');
$this->load->helper('seo');
$seo_url = (string) convertSeo($this->input->post('name'));
$insertdata = array(
'name' => (string) $this->input->post('name'),
'seo' => '',
'type' => (int) $this->input->post('type'),
'theme' => (int) $this->input->post('theme'),
'subject' => (int) $this->input->post('subject'),
'language' => (int) $this->input->post('language'),
'minpages' => (int) $this->input->post('minpages'),
'maxpages' => (int) $this->input->post('maxpages'),
'description' => $description,
'file1' => $this->_files['file1'],
'file2' => $this->_files['file2'],
'file3' => $this->_files['file3'],
'date' => $date,
'budget' => (int) $this->input->post('budget'),
'user' => $is_auth ? $user['id'] : 0,
'created' => time(),
'status' => 1
);
if (!$is_auth)
{
$hash = md5(rand() % 100000);
$insertdata['status'] = 0;
$insertdata['temp_hash'] = $hash;
setcookie('order_hash', $hash, time() + 3600, '/');
}
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$insertdata['description'] = word_censor($insertdata['description'], $disallowed, '[ ***** ]');
if ($this->input->post('urgent') == 'yes')
{
$insertdata['urgent'] = 1;
$budget = (int) $this->input->post('budget');
$comission = (int) $this->config->item('urgent_comission');
$adminmoney = round($budget * ($comission / 100));
}
$id = $this->common->insert('orders', $insertdata);
$this->common->update('orders', $id, array('seo' => $seo_url . "-" . $id));
if ($insertdata['status'] == 1)
$this->order->after_create($id);
if ($this->input->post('urgent') == 'yes')
{
$money = $user['money'] - $adminmoney;
$this->common->update('users', $user['id'], array('money' => $money));
$this->common->insert('payments', array('user' => $user['id'], 'amount' => '-' . $adminmoney, 'description' => 'Комиссия за срочный заказ <a href="zakaz/tema/' . $id . '">' . $insertdata['name'] . '</a>', 'date' => time()));
$admin = $this->common->get_item_by_id('users', 1);
$this->common->update('users', 1, array('money' => ($admin->money + $adminmoney)));
$this->common->insert('payments', array('user' => 1, 'amount' => $adminmoney, 'description' => 'Комиссия за срочный заказ <a href="zakaz/tema/' . $id . '">' . $insertdata['name'] . '</a>', 'date' => time()));
}
$neworder = $this->order->get($id);
if ($user)
{
$this->notification->send($user['email'], $this->config->item('neworder'), 'orders/mail/neworder', array(
'order' => $neworder,
'user' => $user
));
}
else
{
redirect('kluent/reguctracua');
}
// $newdata = array('just_sended' => false);
$this->session->set_userdata($newdata);
redirect('zakaz/tema/' . $seo_url . "-" . $id . '/');
}
else
{
$data['work_types'] = $this->common->get_asc('work_types');
$data['work_themes'] = $this->common->get_asc('work_themes');
$data['work_subjects'] = $this->common->get_asc('work_subjects');
$data['work_languages'] = $this->common->get_asc('work_languages');
$data['user'] = $this->ion_auth->profile();
$data['comission'] = (int) $this->config->item('urgent_comission');
$data['is_auth'] = $this->ion_auth->logged_in() ? 1 : 0;
$data['next_id'] = $this->common->getNext('orders');
}
$this->layout->view('orders/add', $data);
}
else
{
$this->session->set_flashdata('return', 'zakaz/dobavut');
$this->layout->view('noaccess', $data);
}
}
public function edit()
{
$data['title'] = 'Редактирование заказа';
$id = $this->uri->segment(3);
$order = $this->order->get($id);
$user = $this->ion_auth->profile();
if ($this->ion_auth->logged_in() && ($user['id'] == $order->user))
{
$this->form_validation->set_rules('name', 'Название', 'required|xss_clean');
$this->form_validation->set_rules('type', 'Тип работы', 'required|integer');
$this->form_validation->set_rules('theme', 'Предмет', 'required|integer');
$this->form_validation->set_rules('language', 'Язык', 'required|integer');
$this->form_validation->set_rules('minpages', 'Минимальный объем', 'required|integer');
$this->form_validation->set_rules('maxpages', 'Максимальный объем', 'required|integer');
$this->form_validation->set_rules('description', 'Задание', 'xss_clean');
$this->form_validation->set_rules('date', 'Сроки', 'xss_clean|callback_check_date');
if (isset($_POST['budget']))
$this->form_validation->set_rules('budget', 'Бюджет', 'required|greater_than[0]');
$config['upload_path'] = './uploads/files/';
$config['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf';
$config['max_size'] = '10240';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
for ($i = 1; $i < 4; $i++)
{
$field = 'file' . $i;
if ($this->upload->do_upload($field))
{
$data = $this->upload->data();
$this->_files[$field] = $data['file_name'];
$this->common->insert('filenames', array('hashname' => $data['file_name'], 'realname' => $_FILES[$field]['name']));
}
else
{
$filename = $this->input->post($field);
if ($filename != '')
{
$this->_errors[$filename] = $this->upload->display_errors();
$this->form_validation->set_rules($field, 'Файл ' . $i, 'callback_upload_file|required');
}
}
}
if ($this->form_validation->run() == true)
{
$date = (string) $this->input->post('date');
$date = strtotime($date) + 86340;
$description = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$description = word_censor($description, $disallowed, '[ ***** ]');
$seo_url = (string) convertSeo($this->input->post('name'));
$insertdata = array(
'name' => (string) $this->input->post('name'),
'seo' => $seo_url . "-" . $id,
'type' => (int) $this->input->post('type'),
'theme' => (int) $this->input->post('theme'),
'subject' => (int) $this->input->post('subject'),
'language' => (int) $this->input->post('language'),
'minpages' => (int) $this->input->post('minpages'),
'maxpages' => (int) $this->input->post('maxpages'),
'description' => $description,
'date' => $date,
'created' => time(),
);
if (isset($_POST['budget']))
$insertdata['budget'] = (int) $this->input->post('budget');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$insertdata['description'] = word_censor($insertdata['description'], $disallowed, '[ ***** ]');
foreach ($this->_files as $filename => $filevalue)
{
if ($filevalue != '')
{
$insertdata[$filename] = $filevalue;
}
}
if ($order->status == 10)
{
$date = (string) $this->input->post('date');
$date = strtotime($date) + 86340;
$insertdata['date'] = $date;
$insertdata['status'] = 1;
$insertdata['created'] = time();
$this->order->after_create($id);
$this->db->query('UPDATE `orders_rates` SET `visible` = 1 WHERE `order` = ' . $order->id);
$this->notification->send($user['email'], $this->config->item('neworder'), 'orders/mail/neworder', array(
'order' => $order,
'user' => $user
));
}
$id = $this->common->update('orders', $id, $insertdata);
redirect('zakaz/tema/' . $order->seo . '/');
}
else
{
$data['work_types'] = $this->common->get_asc('work_types');
$data['work_themes'] = $this->common->get_asc('work_themes');
$data['work_subjects'] = $this->common->get_asc('work_subjects');
$data['work_languages'] = $this->common->get_asc('work_languages');
}
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
$data['order'] = $order;
$this->layout->view('orders/edit', $data);
}
else
{
$this->layout->view('denied');
}
}
public function view($id = '')
{
$id = $id ? $id : $this->uri->segment(3);
$digit = true;
for ($i = 0; $i < strlen($id); $i++)
if ($id[$i] < '0' || $id[$i] > '9')
$digit = false;
$order = $digit ? $this->common->get_item_by_params('orders', array('id' => $id)) : $this->common->get_item_by_params('orders', array('seo' => $id));
if (!$order)
show_404();
$id = $order->id;
$order = $this->order->get($id);
if (!$order)
show_404('zakaz/tema/' . $id);
if ($this->ion_auth->logged_in())
$user = $this->ion_auth->profile();
else
$user = -1;
if ($user == -1 && $order->status != 1)
redirect('kluent/reguctracua/');
if ($order->status > 1 && $order->status < 10 && $user['id'] != $order->user && $user['id'] != 1 && $user['id'] != $order->author)
{
redirect('/');
}
if ($order->status == 10)
{
$rates = $this->order->rates($order->id);
$users_access = array($order->user, $order->author, 1);
foreach ($rates as $rate)
$users_access[] = $rate['userid'];
if (!in_array($user['id'], $users_access) && $user['id'] != 1)
redirect('/');
}
$data['user'] = $user;
$data['allowchat'] = true;
$data['title'] = 'Просмотр заказа «' . $order->name . '»';
if (!$order)
{
$data['error'] = true;
$this->layout->view('orders/error', $data);
}
else
{
$data['order'] = $order;
switch ($order->status)
{
case 0:
$data['status'] = 'Ожидает одобрения администратором';
break;
case 1:
$data['status'] = 'Выбор автора';
break;
case 2:
$data['status'] = 'Ожидает подтверждения автором';
break;
case 3:
$data['status'] = 'Ожидает оплаты';
break;
case 4:
$data['status'] = 'В работе';
break;
case 5:
$data['status'] = 'Согласование';
break;
case 6:
$data['status'] = 'Завершён';
break;
case 7:
$data['status'] = 'Гарантийная поддержка';
break;
case 8:
$data['status'] = 'Невыполнен';
break;
case 9:
$data['status'] = 'Завершен арбитражем';
break;
case 10:
$data['status'] = 'Истек срок';
break;
}
if ($order->status == 7 && !$order->author)
$data['status'] = 'Автор не найден';
// echo " <pre> order = ", print_r ($order,true); echo "</pre>", PHP_EOL;
// echo " <pre> user['id'] = ", print_r ($user,true); echo "</pre>", PHP_EOL;
if ($order->user == $user['id'])
{
$config['upload_path'] = 'uploads/files/';
$config['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf';
$config['max_size'] = 8190;
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
$upl = $this->upload->do_upload('file');
echo " <pre> загрузка файла ", print_r ($upl,true); echo "</pre>", PHP_EOL;
if ($upl)
{
$upload_data = $this->upload->data();
$this->common->insert('filenames', array('hashname' => $upload_data['file_name'], 'realname' => $_FILES['file']['name']));
$insert_data = array(
'order' => $id,
'from' => $order->user,
'to' => $order->author,
'message' => 'Я отправил новый файл: <a href="/upload/files/' . $upload_data['file_name'] . '">' . $_FILES['file']['name'] . '</a>',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $insert_data);
$customer = $this->common->get_item_by_id('users', $order->user);
$author = $this->common->get_item_by_id('users', $order->author);
$notice = array(
'order' => $order,
'file' => site_url('/upload/files/' . $upload_data['file_name']),
'user' => $author
);
$this->notification->send($author->email, $this->config->item('newfile'), 'orders/mail/newfile', $notice);
$this->notification->send('diplomspb.mail@gmail.com', $this->config->item('newfile'), 'orders/mail/newfile', $notice);
}
else
{
$filename = $this->input->post('file');
if ($filename != '')
{
$this->_errors[$filename] = $this->upload->display_errors();
$this->form_validation->set_rules('file', 'Файл', 'required|callback_upload_file');
}
}
$data['rates'] = $this->order->rates($order->id);
if (!$data['rates'])
{
$data['rates'] = array();
}
$data['files'] = $this->common->get_items_by_params('orders_files', array('order' => $order->id, 'user' => $order->author));
$this->layout->view('orders/view_customer', $data);
}
else
{
$data['rates'] = $this->common->count_by_params('orders_rates', array('order' => $order->id));
$data['rate'] = $this->common->count_by_params('orders_rates', array('order' => $order->id, 'user' => $user['id']));
$data['maxrate'] = $this->order->maxrate($order->id);
$data['minrate'] = $this->order->minrate($order->id);
$data['files'] = $this->common->get_items_by_params('orders_files', array('order' => $order->id, 'user' => $order->author));
if ($data['rate'] > 0)
{
$rate = $this->common->get_items_by_params('orders_rates', array('order' => $id, 'user' => $user['id']));
$data['rate_id'] = $rate[0]['id'];
}
$this->layout->view('orders/view_author', $data);
}
}
}
public function back()
{
$id = (int) $this->uri->segment(3);
$order = $this->order->get($id);
$user = $this->ion_auth->profile();
if ($order->user == $user['id'])
{
$insert_data = array(
'order' => $id,
'from' => $user['id'],
'to' => $order->author,
'message' => 'Заказ отправлен на доработку',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $insert_data);
$update_data = array(
'agreement_date' => 0,
'completed_date' => 0,
'date' => $order->date + 259200,
'status' => 4
);
$this->common->update('orders', $id, $update_data);
$customer = $this->common->get_item_by_id('users', $order->user);
$author = $this->common->get_item_by_id('users', $order->author);
$notice = array(
'order' => $order,
'customer' => $customer,
'author' => $author
);
$this->notification->send($author->email, $this->config->item('back'), 'orders/mail/back', $notice);
redirect('zakaz/tema/' . $order->seo . '/');
}
else
{
redirect('/');
}
}
public function rate()
{
$data['title'] = 'Сделать ставку';
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_rules('order', 'Заказ', 'required|integer');
$this->form_validation->set_rules('rate', 'Ставка', 'required|integer|is_natural_no_zero');
$this->form_validation->set_rules('description', 'Комментарий к ставке', 'xss_clean');
if ($this->form_validation->run() == true)
{
$user = $this->ion_auth->profile();
$order = (int) $this->input->post('order');
$_rates = $this->common->get_item_by_params('orders_rates', array('order' => $order, 'user' => $user['id']));
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
if (count($_rates) == 0)
{
$text = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$censored_text = word_censor($text, $disallowed, '[ ***** ]');
$censored_count = substr_count($censored_text, '[ ***** ]');
$verified = 1;
if ($censored_count > 0)
{
$description = 'Обмен контактными данными запрещен. Сообщение появится после проверки администратором';
$original = $text;
$verified = 0;
}
else
{
$description = $text;
$original = '';
}
$insertdata = array(
'order' => $order,
'user' => $user['id'],
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'real_rate' => (float) $this->input->post('rate'),
'description' => $description,
'description_original' => $original,
'date' => time(),
'verified' => $verified
);
$rate_id = $this->common->insert('orders_rates', $insertdata);
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $_order->user,
'message' => 'Я сделал ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $description,
'original' => $censored_count ? 'Я сделал ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $text : '',
'verified' => 1,
'time' => time(),
'rate_id' => $rate_id
);
$this->common->insert('chat', $data);
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'id' => $order,
'order' => $_order->name,
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'user' => $customer
);
$this->notification->send($customer->email, $this->config->item('rate'), 'orders/mail/rate', $notice);
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
else
{
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
}
else
{
if ((int) $this->input->post('order') > 0)
{
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
else
{
redirect(site_url());
}
}
}
else
{
$this->session->set_flashdata('return', 'orders');
$this->layout->view('noaccess', $data);
}
}
public function change_rate()
{
$data['title'] = 'Изменить ставку';
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_rules('rate_id', 'ID ставки', 'required|integer');
$this->form_validation->set_rules('rate', 'Ставка', 'required|integer|is_natural_no_zero');
$this->form_validation->set_rules('description', 'Комментарий к ставке', 'xss_clean');
if ($this->form_validation->run() == true)
{
$user = $this->ion_auth->profile();
$rate = $this->common->get_item_by_id('orders_rates', $this->input->post('rate_id'));
$_order = $this->common->get_item_by_params('orders', array('id' => $rate->order));
if (count($rate) > 0 && $rate->user == $user['id'])
{
$text = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$censored_text = word_censor($text, $disallowed, '[ ***** ]');
$censored_count = substr_count($censored_text, '[ ***** ]');
$verified = 1;
if ($censored_count > 0)
{
$description = 'Обмен контактными данными запрещен. Сообщение появится после проверки администратором';
$original = $text;
$verified = 0;
}
else
{
$description = $text;
$original = '';
}
$updatedata = array(
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'real_rate' => (float) $this->input->post('rate'),
'description' => $description,
'description_original' => $original,
'date' => time(),
'verified' => $verified
);
$this->common->update('orders_rates', $rate->id, $updatedata);
$data = array(
'order' => $rate->order,
'from' => $user['id'],
'to' => $_order->user,
'message' => 'Я изменил ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $description,
'original' => $censored_count ? 'Я сделал ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $text : '',
'verified' => 1,
'time' => time(),
'rate_id' => $rate->id
);
$this->common->insert('chat', $data);
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'id' => $rate->order,
'order' => $_order->name,
'author' => $user['username'],
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'user' => $customer
);
$this->notification->send($customer->email, $this->config->item('changerate'), 'orders/mail/changerate', $notice);
redirect('zakaz/tema/' . $_order->seo . '/');
}
else
{
redirect('zakaz/tema/' . $_order->seo . '/');
}
}
else
{
redirect(site_url());
}
}
else
{
$this->session->set_flashdata('return', 'orders');
$this->layout->view('noaccess', $data);
}
}
public function choseauthor()
{
if ($this->ion_auth->logged_in())
{
$order = (int) $this->uri->segment(3);
$rate = (int) $this->uri->segment(4);
$rate = $this->common->get_item_by_params('orders_rates', array('id' => $rate, 'order' => $order));
if (!is_array($rate))
{
$this->common->update('orders_rates', $rate->id, array('accepted' => 1));
$this->common->update('orders', $order, array('author' => $rate->user, 'author_deadline' => (time() + 86400), 'status' => 2));
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $rate->user,
'message' => 'Статус заказа: Ожидает подтверждения автором',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$_order = $this->common->get_item_by_id('orders', $order);
$author = $this->common->get_item_by_id('users', $_order->author);
$notice = array(
'order' => $_order,
'user' => $author
);
$this->notification->send($author->email, $this->config->item('choseauthor'), 'orders/mail/choseauthor', $notice);
redirect('zakaz/tema/' . $_order->seo . '/');
}
else
{
$_order = $this->common->get_item_by_id('orders', $order);
redirect('zakaz/tema/' . $_order->seo . '/');
}
}
else
{
$this->session->set_flashdata('return', 'orders/choseauthor/' . (int) $this->uri->segment(3) . '/' . (string) $this->uri->segment(4));
$this->layout->view('noaccess', $data);
}
}
public function will()
{
if ($this->ion_auth->logged_in())
{
$will = (string) $this->uri->segment(3);
$order = (int) $this->uri->segment(4);
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array('order' => $_order, 'author' => $user, 'user' => $customer);
if ($_order->status > 3 && $_order->author != $user['id'])
redirect('/');
if ($_order->author == $user['id'])
{
if ($will == 'yes')
{
$payment_deadline = time() + 604800;
$rate = $this->common->get_item_by_params('orders_rates', array('user' => $user['id'], 'order' => $order));
$this->common->update('orders', $order, array('status' => 3, 'payment_deadline' => $payment_deadline, 'budget' => $rate->rate));
$this->notification->send($customer->email, $this->config->item('will-yes'), 'orders/mail/will-yes', $notice);
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $customer->id,
'message' => 'Статус заказа: Ожидает оплаты',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
redirect('zakaz/tema/' . $order . '/');
}
else
{
$this->common->update('orders', $order, array('author' => 0, 'status' => 1));
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $customer->id,
'message' => 'Я отклонил Ваше предложение выполнить заказ',
'original' => '',
'verified' => 1,
'time' => time()
);
$id = $this->common->insert('chat', $data);
$this->notification->send($customer->email, $this->config->item('will-no'), 'orders/mail/will-no', $notice);
redirect('zakaz/tema/' . $order . '/');
}
}
else
{
redirect('/');
}
}
else
{
$this->session->set_flashdata('return', 'orders/will/' . (string) $this->uri->segment(3) . '/' . (int) $this->uri->segment(4));
$this->layout->view('noaccess');
}
}
public function pay()
{
if ($this->ion_auth->logged_in())
{
$order = (int) $this->uri->segment(3);
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
$rate = $this->common->get_item_by_params('orders_rates', array('order' => $order, 'user' => $_order->author));
if ($_order->user == $user['id'])
{
if ($user['money'] > $rate->rate || $user['money'] == $rate->rate)
{
$blocked = $user['money_blocked'] + $rate->rate;
$money = $user['money'] - $rate->rate;
$this->common->update('users', $_order->user, array('money' => $money, 'money_blocked' => $blocked));
$this->common->update('orders', $order, array('status' => 4, 'payment_deadline' => 0));
$insertdata = array(
'user' => $user['id'],
'amount' => (float) $rate->rate,
'description' => $rate->rate . ' заблокировано для оплаты <a href="/zakaz/tema/' . $_order->id . '">' . $_order->name . '</a>',
'date' => time()
);
$this->common->insert('payments', $insertdata);
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $rate->user,
'message' => 'Заказ оплачен. Статус заказа: В работе',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$author = $this->common->get_item_by_id('users', $_order->author);
$notice = array(
'order' => $_order,
'user' => $author
);
$this->notification->send($author->email, $this->config->item('pay'), 'orders/mail/pay', $notice);
redirect('zakaz/tema/' . $order . '/');
}
else
{
$data['title'] = 'Оплата заказа';
$this->layout->view('orders/getmoney');
}
}
else
{
redirect('/');
}
}
else
{
$this->session->set_flashdata('return', 'orders/will/' . (string) $this->uri->segment(3) . '/' . (int) $this->uri->segment(4));
$this->layout->view('noaccess');
}
}
public function end()
{
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_rules('order', 'Номер заказа', 'required|integer');
$ended = (bool) $this->input->post('ended');
$uploadconfig['upload_path'] = './uploads/orders_files/';
$uploadconfig['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf';
$uploadconfig['max_size'] = '10240';
$uploadconfig['encrypt_name'] = true;
$this->load->library('upload', $uploadconfig);
if ($this->upload->do_upload('workfile'))
{
$data = $this->upload->data();
$workfile = $data['file_name'];
$this->common->insert('filenames', array('hashname' => $data['file_name'], 'realname' => $_FILES['workfile']['name']));
}
else
{
$filename = $this->input->post('workfile');
$this->_errors[$filename] = $this->upload->display_errors();
$this->form_validation->set_rules('workfile', 'Файл', 'required|callback_upload_file');
$workfile = false;
}
$order = (bool) $this->input->post('order');
if ($order && $workfile != false)
{
$order = (int) $this->input->post('order');
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
if ($ended)
{
$insertdata = array(
'workfile' => $workfile,
'agreement_date' => time(),
'status' => 5,
'agreement_deadline' => time() + 86400
);
$this->common->update('orders', $order, $insertdata);
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $_order->user,
'message' => 'Считаю заказ завершенным. Статус заказа: Согласование. <a href="/upload/orders_files/' . $workfile . '">Файл с работой</a>',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'order' => $_order,
'user' => $customer
);
$this->notification->send($customer->email, $this->config->item('end'), 'orders/mail/end', $notice);
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
else
{
$insertdata = array(
'order' => $order,
'user' => $user['id'],
'file' => $workfile,
'date' => time()
);
$this->common->insert('orders_files', $insertdata);
$data = array(
'order' => $order,
'from' => $_order->user,
'to' => $_order->author,
'message' => 'Я отправил вам рабочий <a href="/upload/orders_files/' . $workfile . '">файл</a>',
'original' => '',
'verified' => 1,
'time' => time(),
'status' => 0
);
$id = $this->common->insert('chat', $data);
$user = $this->common->get_item_by_id('users', $_order->author);
$active_deadline = $user->last_active + 600;
if ($active_deadline < time())
{
$from = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'order' => $_order,
'from' => $from,
'user' => $user
);
$this->notification->send($user->email, $this->config->item('chat'), 'orders/mail/chat', $notice);
}
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
}
else
{
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
}
else
{
$this->session->set_flashdata('return', 'zakaz/tema/' . (int) $this->input->post('order'));
$this->layout->view('noaccess');
}
}
public function complete()
{
if ($this->ion_auth->logged_in())
{
$complete = (string) $this->uri->segment(3);
$order = (int) $this->uri->segment(4);
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
$this->form_validation->set_rules('comment', 'Отзыв', 'required');
if (isset($_POST['review_page']))
{
if ($this->form_validation->run() == true)
{
$insertdata = array(
'user' => (int) $this->input->post('to'),
'author' => (int) $this->input->post('from'),
'comment' => (string) $this->input->post('comment'),
'date' => time()
);
$this->common->insert('users_comments', $insertdata);
$to = $this->common->get_item_by_id('users', (int) $this->input->post('to'));
$this->common->update('users', (int) $this->input->post('to'), array('comments' => ($to->comments + 1)));
$review = (string) $this->input->post('review');
if ($review != '')
$this->common->insert('reviews', array(
'user' => (int) $this->input->post('from'),
'review' => $review,
'date' => time(),
'status' => 0
));
$this->common->update('orders', $order, array('comment' => 1));
redirect('zakaz/tema/' . $order . '/');
}
} else
{
// die('here');
if ($_order->user == $user['id'])
{
if ($complete == 'yes')
{
$this->common->update('orders', $order, array(
'status' => 7,
'completed_date' => time(),
'ready_deadline_status' => $this->input->post('status')
));
// $t = time();
// echo $t;
// die($t);
//
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $_order->user,
'to' => $_order->author,
'message' => 'Статус заказа: Гарантийная поддержка',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$author = $this->common->get_item_by_id('users', $_order->author);
$notice = array(
'order' => $_order,
'user' => $author
);
$this->notification->send($author->email, $this->config->item('complete'), 'orders/mail/complete', $notice);
$data['title'] = 'Отзыв об авторе';
$data['from'] = $_order->user;
$data['to'] = $_order->author;
$data['order'] = $order;
$current_date = date('d.m.Y');
$end_date = date('d.m.Y', $_order->date);
if ($current_date == $end_date)
{
$this->common->update('orders', $order, array(
'date' => $_order->date + 86400,
));
}
if ($_order->comment == 1)
{
// redirect('zakaz/tema/' . $order . '/');
}
$this->layout->view('orders/comment', $data);
}
else
{
$this->common->update('orders', $order, array('status' => 4, 'agreement_date' => 0));
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $_order->user,
'to' => $_order->author,
'message' => 'Считаю заказ незавершенным. Статус заказа: В работе',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
redirect('zakaz/tema/' . $order . '/');
}
}
}
}
else
{
$this->session->set_flashdata('return', 'orders/complete/' . (string) $this->uri->segment(3) . '/' . (int) $this->uri->segment(4));
$this->layout->view('noaccess');
}
}
public function noauthor()
{
$data['title'] = 'Утверждение автора';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_choose_author_4_customer($user['id'], $page, 10);
foreach ($data['orders'] as $order)
{
$data['rates_num'][$order->id] = $this->order->get_rates_num($order->id);
}
$this->load->library('pagination');
$config['base_url'] = '/zakaz/noauthor/';
$config['total_rows'] = $this->order->count_choose_author_4_customer($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables_2', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/noauthor');
$this->layout->view('noaccess');
}
}
public function inwork()
{
$data['title'] = 'В работе';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_in_work_4_customer($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/inwork/';
$config['total_rows'] = $this->order->count_in_work_4_customer($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/inwork');
$this->layout->view('noaccess');
}
}
public function completed()
{
$data['title'] = 'Завершенные';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_completed_4_customer($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/completed/';
$config['total_rows'] = $this->order->count_completed_4_customer($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/completed');
$this->layout->view('noaccess');
}
}
public function rates()
{
$data['title'] = 'Ставки';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$this->form_validation->set_rules('q', 'Поисковый запрос', 'xss_clean');
$this->load->library('pagination');
$config['base_url'] = '/zakaz/rates/';
$config['total_rows'] = $this->order->count_rates_4_author($user['id'], 1);
$config['per_page'] = 10;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['uri_segment'] = 3;
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['ratespage'] = true;
$data['user'] = $user;
if ($this->form_validation->run() == true)
{
$q = (string) $this->input->post('q');
$data['orders'] = $this->order->search_rates_4_author($q, $user['id'], $page, 10);
$config['total_rows'] = $$this->order->count_search_rates_4_author($q, $user['id'], $page, 10);
}
else
{
$data['orders'] = $this->order->get_rates_4_author($user['id'], $page, 10);
}
$this->layout->view('orders/tables_search', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/rates');
$this->layout->view('noaccess');
}
}
public function iamauthor()
{
$data['title'] = 'Выбор автора';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_choose_author_4_author($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/rates/';
$config['total_rows'] = $this->order->count_choose_author_4_author($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/rates');
$this->layout->view('noaccess');
}
}
public function inprogress()
{
$data['title'] = 'В работе';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_inprogress_4_author($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/completed/';
$config['total_rows'] = $this->order->count_inprogress_4_author($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/completed');
$this->layout->view('noaccess');
}
}
public function done()
{
$data['title'] = 'Завершенные';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_done_4_author($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/orders/completed/';
$config['total_rows'] = $this->order->count_done_4_author($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/completed');
$this->layout->view('noaccess');
}
}
public function deleterates()
{
if ($this->ion_auth->logged_in())
{
$deleteall = (bool) $this->input->post('deleteall');
$deleterates = $this->input->post('deleterate');
$user = $this->ion_auth->profile();
if ($deleteall == true)
{
$rates = $this->order->get_rates_4_author($user['id'], 0, 10000);
foreach ($rates as $rate)
{
if ($rate->author != $user['id'])
{
$this->common->delete('orders_rates', $rate->id);
}
}
}
if ($deleterates != false && $deleteall == false && is_array($deleterates))
{
foreach ($deleterates as $rate)
{
$_rate = $this->common->get_item_by_id('orders_rates', $rate);
$_order = $this->common->get_item_by_id('orders', $_rate->order);
if ($_rate->user == $user['id'] && $_order->author != $user['id'])
{
$this->common->delete('orders_rates', $rate);
}
}
}
}
redirect('zakaz/rates/');
}
public function no_file()
{
$this->form_validation->set_message('no_file', 'Вы не выбрали ни одного файла');
return false;
}
public function upload_file()
{
$this->form_validation->set_message('upload_file', $this->_error);
return false;
}
public function check_date($date)
{
$time = strtotime($date) + 86340;
$today = strtotime(date('d.m.Y')) - 1;
if ($time > $today)
{
return true;
}
else
{
$this->form_validation->set_message('check_date', 'Необходимо указать более позднюю дату');
return false;
}
}
public function cron()
{
$orders = $this->common->get_items_by_params('orders', array('status' => 4, 'deadline_notif_sent' => 0));
foreach ($orders as $order)
{
if (time() + 43200 >= $order['date'] && !$order['deadline_notif_sent'])
{
$author = $this->common->get_item_by_params('users', array('id' => $order['author']));
$this->common->update('orders', $order['id'], array('deadline_notif_sent' => '1'));
// $this->notification->send($author->email, $this->config->item('deadline_notification'), 'orders/mail/deadline_notification', array(
// 'user' => $author,
// 'order' => $order,
// ));
}
}
$orders = $this->common->get_items_by_params('orders', array('status' => 5));
foreach ($orders as $order)
{
if (time() >= $order['agreement_deadline'])
{
$this->common->update('orders', $order['id'], array('status' => 7, 'agreement_date' => 0));
$author = $this->common->get_item_by_params('users', array('id' => $order['author']));
}
}
$orders = $this->common->get_items_by_params('orders', array('status' => 2));
echo "orders array ", print_r($orders, true);
echo PHP_EOL; // запись в cron.txt перед нотификацией
foreach ($orders as $order)
{
if (time() >= $order['author_deadline'])
{
$this->common->update('orders', $order['id'], array('status' => 1, 'author_deadline' => 0, 'author' => 0));
$this->notification->send($author->email, $this->config->item('deadline_notification'), 'orders/mail/author_fail', array(
'user' => $author,
'order' => $order,
));
}
}
/*
if (time() + 43200 >= $order['date'] && !$order['deadline_notif_sent']) {
$author = $this->common->get_item_by_params('users', array('id' => $order['author']));
$this->common->update('orders', $order['id'], array('deadline_notif_sent' => '1', 'author' => 0, 'author_deadline' => 0, 'status' => 1));
$this->notification->send($author->email, $this->config->item('deadline_notification'), 'orders/mail/deadline_notification', array(
'user' => $author,
'order' => $order,
));
}
*/
//$this->db->query("INSERT INTO emails(`to`, `subject`, `message`) VALUES('test', 'test', 'test')");
}
public function delete($id = 0)
{
if ($this->ion_auth->logged_in())
{
$order = $this->order->get($id);
$user = $this->ion_auth->profile();
if ($order->status != 10)
show_404();
if ($order->user == $user['id'])
$this->order->delete($id);
else
{
$rate = $this->common->get_item_by_params('orders_rates', array('order' => $order->id, 'user' => $user['id']));
$this->common->update('orders_rates', $rate->id, array('visible' => 0));
redirect('/zakaz/rates');
}
redirect('/zakaz/noauthor');
} else
show_404();
}
}
/* End of file orders.php */
/* Location: ./application/controllers/orders.php */
[/SRC]
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Orders extends CI_Controller
{
private $_files;
private $_error;
public function __construct()
{
parent::__construct();
$this->load->model('Order', 'order');
$this->load->model('common', 'common');
$this->layout->setLayout('2_columns');
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
$this->_files = array(
'file1' => '',
'file2' => '',
'file3' => ''
);
$this->load->helper('seo');
}
public function index()
{
$data['result'] = array();
$data['q'] = '';
$data['order'] = 'date';
$data['work_types'] = $this->common->get_asc('work_types');
$data['work_themes'] = $this->common->get_asc('work_themes');
$data['work_languages'] = $this->common->get_asc('work_languages');
$data['type_values'] = array();
$data['theme_values'] = array();
$data['language_values'] = array();
foreach ($data['work_types'] as $worktype)
{
$data['type_values'][$worktype->id] = 0;
}
foreach ($data['work_themes'] as $worktheme)
{
$data['theme_values'][$worktheme->id] = 0;
}
foreach ($data['work_languages'] as $worklanguage)
{
$data['language_values'][$worklanguage->id] = 0;
}
$this->form_validation->set_rules('q', 'Поисковый запрос', 'xss_clean');
if ($this->form_validation->run() == true)
{
$q = (string) $this->input->post('q');
$insertdata = array('query' => $q);
$query_id = $this->common->insert('search_queries', $insertdata);
$data['query_id'] = $query_id;
$data['q'] = $q;
$types = (array) $this->input->post('types');
$themes = (array) $this->input->post('themes');
$languages = (array) $this->input->post('languages');
$types_array = array();
$themes_array = array();
$languages_array = array();
if (isset($types[0]))
{
$data['types_all'] = ($types[0] == 1) ? 1 : 0;
}
else
{
$data['types_all'] = 0;
}
if (isset($themes[0]))
{
$data['themes_all'] = ($themes[0] == 1) ? 1 : 0;
}
else
{
$data['themes_all'] = 0;
}
if (isset($languages[0]))
{
$data['languages_all'] = ($languages[0] == 1) ? 1 : 0;
}
else
{
$data['languages_all'] = 0;
}
$data['types_some'] = 0;
$data['themes_some'] = 0;
$data['languages_some'] = 0;
foreach ($types as $type => $value)
{
if ($value == 1)
{
$types_array[] = $type;
$data['type_values'][$type] = 1;
$data['types_some'] = 1;
}
}
foreach ($themes as $theme => $value)
{
if ($value == 1)
{
$themes_array[] = $theme;
$data['theme_values'][$theme] = 1;
$data['themes_some'] = 1;
}
}
foreach ($languages as $language => $value)
{
if ($value == 1)
{
$languages_array[] = $language;
$data['language_values'][$language] = 1;
$data['languages_some'] = 1;
}
}
$page = (int) $this->uri->segment(2);
$order = (string) $this->input->post('order');
$data['order'] = $order;
$data['founded'] = $this->order->count_all_search($q, $types_array, $themes_array, $languages_array);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/index/';
$config['total_rows'] = $data['founded'];
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['result'] = $this->order->search($q, $types_array, $themes_array, $languages_array, $order, $page);
}
else
{
$page = (int) $this->uri->segment(3);
$query_id = (int) $this->uri->segment(4);
$data['types_all'] = 0;
$data['themes_all'] = 0;
$data['languages_all'] = 0;
$data['types_some'] = 0;
$data['themes_some'] = 0;
$data['languages_some'] = 0;
if ($query_id != 0)
{
$query = $this->common->get_item_by_params('search_queries', array('query' => $q));
$data['founded'] = $this->order->count_all_search($query->query, $types_array, $themes_array, $languages_array);
}
else
{
$data['founded'] = $this->order->count_all_search(false, array(), array(), array());
}
$this->load->library('pagination');
$config['base_url'] = '/zakaz/index/';
$config['total_rows'] = $data['founded'];
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['result'] = $this->order->search(false, array(), array(), array(), 'id', $page);
}
$page = $this->common->get_item_by_params('pages', array('alias' => 'orders'));
$data['text'] = $page->text;
$this->layout->title = $page->title;
$this->layout->keywords = $page->keywords;
$this->layout->description = $page->description;
$this->layout->view('orders/index', $data);
}
public function add()
{
$next_id = $this->common->getNext('orders');
if ($_POST)
{
if ($this->input->post('next_id') < $next_id)
{
$page = $this->common->getSeo('orders', $this->input->post('next_id'));
redirect('/zakaz/tema/' . $page);
}
}
//echo date('d-y-m', )
$data['title'] = 'Новый заказ';
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
$this->form_validation->set_rules('name', 'Название', 'required|xss_clean');
$this->form_validation->set_rules('type', 'Тип работы', 'required|integer');
$this->form_validation->set_rules('theme', 'Предмет', 'required|integer');
$this->form_validation->set_rules('language', 'Язык', 'required|integer');
$this->form_validation->set_rules('minpages', 'Минимальный объем', 'required|integer|greater_than[0]');
$this->form_validation->set_rules('maxpages', 'Максимальный объем', 'required|integer');
$this->form_validation->set_rules('description', 'Задание', 'xss_clean');
$this->form_validation->set_rules('date', 'Сроки', 'xss_clean|callback_check_date');
$this->form_validation->set_rules('budget', 'Бюджет', 'required|greater_than[0]');
$config['upload_path'] = './uploads/files/';
$config['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf|tif';
$config['max_size'] = '15360';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
$this->upload->display_errors('<p class="error">', '</p>');
for ($i = 1; $i < 4; $i++)
{
$field = 'file' . $i;
if (isset($_FILES[$field]['name']))
{
if ($_FILES[$field]['name'] != '')
{
if ($this->upload->do_upload($field))
{
$data = $this->upload->data();
$this->_files[$field] = $data['file_name'];
$this->common->insert('filenames', array('hashname' => $data['file_name'], 'realname' => $_FILES[$field]['name']));
}
else
{
$filename = $_FILES[$field]['name'];
$this->_error = $this->upload->display_errors();
$this->form_validation->set_rules($field, 'Файл ' . $i, 'callback_upload_file');
}
}
}
}
if ($this->form_validation->run() == true)
{
$user = $this->ion_auth->profile();
$is_auth = $this->ion_auth->logged_in() ? 1 : 0;
$date = (string) $this->input->post('date');
$date = strtotime($date) + 86340;
$this->load->helper('text');
$description = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$description = word_censor($description, $disallowed, '[ ***** ]');
$this->load->helper('seo');
$seo_url = (string) convertSeo($this->input->post('name'));
$insertdata = array(
'name' => (string) $this->input->post('name'),
'seo' => '',
'type' => (int) $this->input->post('type'),
'theme' => (int) $this->input->post('theme'),
'subject' => (int) $this->input->post('subject'),
'language' => (int) $this->input->post('language'),
'minpages' => (int) $this->input->post('minpages'),
'maxpages' => (int) $this->input->post('maxpages'),
'description' => $description,
'file1' => $this->_files['file1'],
'file2' => $this->_files['file2'],
'file3' => $this->_files['file3'],
'date' => $date,
'budget' => (int) $this->input->post('budget'),
'user' => $is_auth ? $user['id'] : 0,
'created' => time(),
'status' => 1
);
if (!$is_auth)
{
$hash = md5(rand() % 100000);
$insertdata['status'] = 0;
$insertdata['temp_hash'] = $hash;
setcookie('order_hash', $hash, time() + 3600, '/');
}
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$insertdata['description'] = word_censor($insertdata['description'], $disallowed, '[ ***** ]');
if ($this->input->post('urgent') == 'yes')
{
$insertdata['urgent'] = 1;
$budget = (int) $this->input->post('budget');
$comission = (int) $this->config->item('urgent_comission');
$adminmoney = round($budget * ($comission / 100));
}
$id = $this->common->insert('orders', $insertdata);
$this->common->update('orders', $id, array('seo' => $seo_url . "-" . $id));
if ($insertdata['status'] == 1)
$this->order->after_create($id);
if ($this->input->post('urgent') == 'yes')
{
$money = $user['money'] - $adminmoney;
$this->common->update('users', $user['id'], array('money' => $money));
$this->common->insert('payments', array('user' => $user['id'], 'amount' => '-' . $adminmoney, 'description' => 'Комиссия за срочный заказ <a href="zakaz/tema/' . $id . '">' . $insertdata['name'] . '</a>', 'date' => time()));
$admin = $this->common->get_item_by_id('users', 1);
$this->common->update('users', 1, array('money' => ($admin->money + $adminmoney)));
$this->common->insert('payments', array('user' => 1, 'amount' => $adminmoney, 'description' => 'Комиссия за срочный заказ <a href="zakaz/tema/' . $id . '">' . $insertdata['name'] . '</a>', 'date' => time()));
}
$neworder = $this->order->get($id);
if ($user)
{
$this->notification->send($user['email'], $this->config->item('neworder'), 'orders/mail/neworder', array(
'order' => $neworder,
'user' => $user
));
}
else
{
redirect('kluent/reguctracua');
}
// $newdata = array('just_sended' => false);
$this->session->set_userdata($newdata);
redirect('zakaz/tema/' . $seo_url . "-" . $id . '/');
}
else
{
$data['work_types'] = $this->common->get_asc('work_types');
$data['work_themes'] = $this->common->get_asc('work_themes');
$data['work_subjects'] = $this->common->get_asc('work_subjects');
$data['work_languages'] = $this->common->get_asc('work_languages');
$data['user'] = $this->ion_auth->profile();
$data['comission'] = (int) $this->config->item('urgent_comission');
$data['is_auth'] = $this->ion_auth->logged_in() ? 1 : 0;
$data['next_id'] = $this->common->getNext('orders');
}
$this->layout->view('orders/add', $data);
}
else
{
$this->session->set_flashdata('return', 'zakaz/dobavut');
$this->layout->view('noaccess', $data);
}
}
public function edit()
{
$data['title'] = 'Редактирование заказа';
$id = $this->uri->segment(3);
$order = $this->order->get($id);
$user = $this->ion_auth->profile();
if ($this->ion_auth->logged_in() && ($user['id'] == $order->user))
{
$this->form_validation->set_rules('name', 'Название', 'required|xss_clean');
$this->form_validation->set_rules('type', 'Тип работы', 'required|integer');
$this->form_validation->set_rules('theme', 'Предмет', 'required|integer');
$this->form_validation->set_rules('language', 'Язык', 'required|integer');
$this->form_validation->set_rules('minpages', 'Минимальный объем', 'required|integer');
$this->form_validation->set_rules('maxpages', 'Максимальный объем', 'required|integer');
$this->form_validation->set_rules('description', 'Задание', 'xss_clean');
$this->form_validation->set_rules('date', 'Сроки', 'xss_clean|callback_check_date');
if (isset($_POST['budget']))
$this->form_validation->set_rules('budget', 'Бюджет', 'required|greater_than[0]');
$config['upload_path'] = './uploads/files/';
$config['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf';
$config['max_size'] = '10240';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
for ($i = 1; $i < 4; $i++)
{
$field = 'file' . $i;
if ($this->upload->do_upload($field))
{
$data = $this->upload->data();
$this->_files[$field] = $data['file_name'];
$this->common->insert('filenames', array('hashname' => $data['file_name'], 'realname' => $_FILES[$field]['name']));
}
else
{
$filename = $this->input->post($field);
if ($filename != '')
{
$this->_errors[$filename] = $this->upload->display_errors();
$this->form_validation->set_rules($field, 'Файл ' . $i, 'callback_upload_file|required');
}
}
}
if ($this->form_validation->run() == true)
{
$date = (string) $this->input->post('date');
$date = strtotime($date) + 86340;
$description = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$description = word_censor($description, $disallowed, '[ ***** ]');
$seo_url = (string) convertSeo($this->input->post('name'));
$insertdata = array(
'name' => (string) $this->input->post('name'),
'seo' => $seo_url . "-" . $id,
'type' => (int) $this->input->post('type'),
'theme' => (int) $this->input->post('theme'),
'subject' => (int) $this->input->post('subject'),
'language' => (int) $this->input->post('language'),
'minpages' => (int) $this->input->post('minpages'),
'maxpages' => (int) $this->input->post('maxpages'),
'description' => $description,
'date' => $date,
'created' => time(),
);
if (isset($_POST['budget']))
$insertdata['budget'] = (int) $this->input->post('budget');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$insertdata['description'] = word_censor($insertdata['description'], $disallowed, '[ ***** ]');
foreach ($this->_files as $filename => $filevalue)
{
if ($filevalue != '')
{
$insertdata[$filename] = $filevalue;
}
}
if ($order->status == 10)
{
$date = (string) $this->input->post('date');
$date = strtotime($date) + 86340;
$insertdata['date'] = $date;
$insertdata['status'] = 1;
$insertdata['created'] = time();
$this->order->after_create($id);
$this->db->query('UPDATE `orders_rates` SET `visible` = 1 WHERE `order` = ' . $order->id);
$this->notification->send($user['email'], $this->config->item('neworder'), 'orders/mail/neworder', array(
'order' => $order,
'user' => $user
));
}
$id = $this->common->update('orders', $id, $insertdata);
redirect('zakaz/tema/' . $order->seo . '/');
}
else
{
$data['work_types'] = $this->common->get_asc('work_types');
$data['work_themes'] = $this->common->get_asc('work_themes');
$data['work_subjects'] = $this->common->get_asc('work_subjects');
$data['work_languages'] = $this->common->get_asc('work_languages');
}
$this->form_validation->set_error_delimiters('<p class="error">', '</p>');
$data['order'] = $order;
$this->layout->view('orders/edit', $data);
}
else
{
$this->layout->view('denied');
}
}
public function view($id = '')
{
$id = $id ? $id : $this->uri->segment(3);
$digit = true;
for ($i = 0; $i < strlen($id); $i++)
if ($id[$i] < '0' || $id[$i] > '9')
$digit = false;
$order = $digit ? $this->common->get_item_by_params('orders', array('id' => $id)) : $this->common->get_item_by_params('orders', array('seo' => $id));
if (!$order)
show_404();
$id = $order->id;
$order = $this->order->get($id);
if (!$order)
show_404('zakaz/tema/' . $id);
if ($this->ion_auth->logged_in())
$user = $this->ion_auth->profile();
else
$user = -1;
if ($user == -1 && $order->status != 1)
redirect('kluent/reguctracua/');
if ($order->status > 1 && $order->status < 10 && $user['id'] != $order->user && $user['id'] != 1 && $user['id'] != $order->author)
{
redirect('/');
}
if ($order->status == 10)
{
$rates = $this->order->rates($order->id);
$users_access = array($order->user, $order->author, 1);
foreach ($rates as $rate)
$users_access[] = $rate['userid'];
if (!in_array($user['id'], $users_access) && $user['id'] != 1)
redirect('/');
}
$data['user'] = $user;
$data['allowchat'] = true;
$data['title'] = 'Просмотр заказа «' . $order->name . '»';
if (!$order)
{
$data['error'] = true;
$this->layout->view('orders/error', $data);
}
else
{
$data['order'] = $order;
switch ($order->status)
{
case 0:
$data['status'] = 'Ожидает одобрения администратором';
break;
case 1:
$data['status'] = 'Выбор автора';
break;
case 2:
$data['status'] = 'Ожидает подтверждения автором';
break;
case 3:
$data['status'] = 'Ожидает оплаты';
break;
case 4:
$data['status'] = 'В работе';
break;
case 5:
$data['status'] = 'Согласование';
break;
case 6:
$data['status'] = 'Завершён';
break;
case 7:
$data['status'] = 'Гарантийная поддержка';
break;
case 8:
$data['status'] = 'Невыполнен';
break;
case 9:
$data['status'] = 'Завершен арбитражем';
break;
case 10:
$data['status'] = 'Истек срок';
break;
}
if ($order->status == 7 && !$order->author)
$data['status'] = 'Автор не найден';
// echo " <pre> order = ", print_r ($order,true); echo "</pre>", PHP_EOL;
// echo " <pre> user['id'] = ", print_r ($user,true); echo "</pre>", PHP_EOL;
if ($order->user == $user['id'])
{
$config['upload_path'] = 'uploads/files/';
$config['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf';
$config['max_size'] = 8190;
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
$upl = $this->upload->do_upload('file');
echo " <pre> загрузка файла ", print_r ($upl,true); echo "</pre>", PHP_EOL;
if ($upl)
{
$upload_data = $this->upload->data();
$this->common->insert('filenames', array('hashname' => $upload_data['file_name'], 'realname' => $_FILES['file']['name']));
$insert_data = array(
'order' => $id,
'from' => $order->user,
'to' => $order->author,
'message' => 'Я отправил новый файл: <a href="/upload/files/' . $upload_data['file_name'] . '">' . $_FILES['file']['name'] . '</a>',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $insert_data);
$customer = $this->common->get_item_by_id('users', $order->user);
$author = $this->common->get_item_by_id('users', $order->author);
$notice = array(
'order' => $order,
'file' => site_url('/upload/files/' . $upload_data['file_name']),
'user' => $author
);
$this->notification->send($author->email, $this->config->item('newfile'), 'orders/mail/newfile', $notice);
$this->notification->send('diplomspb.mail@gmail.com', $this->config->item('newfile'), 'orders/mail/newfile', $notice);
}
else
{
$filename = $this->input->post('file');
if ($filename != '')
{
$this->_errors[$filename] = $this->upload->display_errors();
$this->form_validation->set_rules('file', 'Файл', 'required|callback_upload_file');
}
}
$data['rates'] = $this->order->rates($order->id);
if (!$data['rates'])
{
$data['rates'] = array();
}
$data['files'] = $this->common->get_items_by_params('orders_files', array('order' => $order->id, 'user' => $order->author));
$this->layout->view('orders/view_customer', $data);
}
else
{
$data['rates'] = $this->common->count_by_params('orders_rates', array('order' => $order->id));
$data['rate'] = $this->common->count_by_params('orders_rates', array('order' => $order->id, 'user' => $user['id']));
$data['maxrate'] = $this->order->maxrate($order->id);
$data['minrate'] = $this->order->minrate($order->id);
$data['files'] = $this->common->get_items_by_params('orders_files', array('order' => $order->id, 'user' => $order->author));
if ($data['rate'] > 0)
{
$rate = $this->common->get_items_by_params('orders_rates', array('order' => $id, 'user' => $user['id']));
$data['rate_id'] = $rate[0]['id'];
}
$this->layout->view('orders/view_author', $data);
}
}
}
public function back()
{
$id = (int) $this->uri->segment(3);
$order = $this->order->get($id);
$user = $this->ion_auth->profile();
if ($order->user == $user['id'])
{
$insert_data = array(
'order' => $id,
'from' => $user['id'],
'to' => $order->author,
'message' => 'Заказ отправлен на доработку',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $insert_data);
$update_data = array(
'agreement_date' => 0,
'completed_date' => 0,
'date' => $order->date + 259200,
'status' => 4
);
$this->common->update('orders', $id, $update_data);
$customer = $this->common->get_item_by_id('users', $order->user);
$author = $this->common->get_item_by_id('users', $order->author);
$notice = array(
'order' => $order,
'customer' => $customer,
'author' => $author
);
$this->notification->send($author->email, $this->config->item('back'), 'orders/mail/back', $notice);
redirect('zakaz/tema/' . $order->seo . '/');
}
else
{
redirect('/');
}
}
public function rate()
{
$data['title'] = 'Сделать ставку';
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_rules('order', 'Заказ', 'required|integer');
$this->form_validation->set_rules('rate', 'Ставка', 'required|integer|is_natural_no_zero');
$this->form_validation->set_rules('description', 'Комментарий к ставке', 'xss_clean');
if ($this->form_validation->run() == true)
{
$user = $this->ion_auth->profile();
$order = (int) $this->input->post('order');
$_rates = $this->common->get_item_by_params('orders_rates', array('order' => $order, 'user' => $user['id']));
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
if (count($_rates) == 0)
{
$text = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$censored_text = word_censor($text, $disallowed, '[ ***** ]');
$censored_count = substr_count($censored_text, '[ ***** ]');
$verified = 1;
if ($censored_count > 0)
{
$description = 'Обмен контактными данными запрещен. Сообщение появится после проверки администратором';
$original = $text;
$verified = 0;
}
else
{
$description = $text;
$original = '';
}
$insertdata = array(
'order' => $order,
'user' => $user['id'],
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'real_rate' => (float) $this->input->post('rate'),
'description' => $description,
'description_original' => $original,
'date' => time(),
'verified' => $verified
);
$rate_id = $this->common->insert('orders_rates', $insertdata);
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $_order->user,
'message' => 'Я сделал ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $description,
'original' => $censored_count ? 'Я сделал ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $text : '',
'verified' => 1,
'time' => time(),
'rate_id' => $rate_id
);
$this->common->insert('chat', $data);
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'id' => $order,
'order' => $_order->name,
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'user' => $customer
);
$this->notification->send($customer->email, $this->config->item('rate'), 'orders/mail/rate', $notice);
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
else
{
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
}
else
{
if ((int) $this->input->post('order') > 0)
{
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
else
{
redirect(site_url());
}
}
}
else
{
$this->session->set_flashdata('return', 'orders');
$this->layout->view('noaccess', $data);
}
}
public function change_rate()
{
$data['title'] = 'Изменить ставку';
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_rules('rate_id', 'ID ставки', 'required|integer');
$this->form_validation->set_rules('rate', 'Ставка', 'required|integer|is_natural_no_zero');
$this->form_validation->set_rules('description', 'Комментарий к ставке', 'xss_clean');
if ($this->form_validation->run() == true)
{
$user = $this->ion_auth->profile();
$rate = $this->common->get_item_by_id('orders_rates', $this->input->post('rate_id'));
$_order = $this->common->get_item_by_params('orders', array('id' => $rate->order));
if (count($rate) > 0 && $rate->user == $user['id'])
{
$text = (string) $this->input->post('description');
$disallowed = array();
$disallowed_result = $this->common->get('chat_disallowed');
foreach ($disallowed_result as $disallowed_row)
{
$disallowed[] = $disallowed_row->word;
}
$censored_text = word_censor($text, $disallowed, '[ ***** ]');
$censored_count = substr_count($censored_text, '[ ***** ]');
$verified = 1;
if ($censored_count > 0)
{
$description = 'Обмен контактными данными запрещен. Сообщение появится после проверки администратором';
$original = $text;
$verified = 0;
}
else
{
$description = $text;
$original = '';
}
$updatedata = array(
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'real_rate' => (float) $this->input->post('rate'),
'description' => $description,
'description_original' => $original,
'date' => time(),
'verified' => $verified
);
$this->common->update('orders_rates', $rate->id, $updatedata);
$data = array(
'order' => $rate->order,
'from' => $user['id'],
'to' => $_order->user,
'message' => 'Я изменил ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $description,
'original' => $censored_count ? 'Я сделал ставку: ' . $this->input->post('rate') . ' руб. Комментарий: ' . $text : '',
'verified' => 1,
'time' => time(),
'rate_id' => $rate->id
);
$this->common->insert('chat', $data);
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'id' => $rate->order,
'order' => $_order->name,
'author' => $user['username'],
'rate' => (float) $this->input->post('rate') * (1 + ($this->config->item('order_comission') / 100)),
'user' => $customer
);
$this->notification->send($customer->email, $this->config->item('changerate'), 'orders/mail/changerate', $notice);
redirect('zakaz/tema/' . $_order->seo . '/');
}
else
{
redirect('zakaz/tema/' . $_order->seo . '/');
}
}
else
{
redirect(site_url());
}
}
else
{
$this->session->set_flashdata('return', 'orders');
$this->layout->view('noaccess', $data);
}
}
public function choseauthor()
{
if ($this->ion_auth->logged_in())
{
$order = (int) $this->uri->segment(3);
$rate = (int) $this->uri->segment(4);
$rate = $this->common->get_item_by_params('orders_rates', array('id' => $rate, 'order' => $order));
if (!is_array($rate))
{
$this->common->update('orders_rates', $rate->id, array('accepted' => 1));
$this->common->update('orders', $order, array('author' => $rate->user, 'author_deadline' => (time() + 86400), 'status' => 2));
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $rate->user,
'message' => 'Статус заказа: Ожидает подтверждения автором',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$_order = $this->common->get_item_by_id('orders', $order);
$author = $this->common->get_item_by_id('users', $_order->author);
$notice = array(
'order' => $_order,
'user' => $author
);
$this->notification->send($author->email, $this->config->item('choseauthor'), 'orders/mail/choseauthor', $notice);
redirect('zakaz/tema/' . $_order->seo . '/');
}
else
{
$_order = $this->common->get_item_by_id('orders', $order);
redirect('zakaz/tema/' . $_order->seo . '/');
}
}
else
{
$this->session->set_flashdata('return', 'orders/choseauthor/' . (int) $this->uri->segment(3) . '/' . (string) $this->uri->segment(4));
$this->layout->view('noaccess', $data);
}
}
public function will()
{
if ($this->ion_auth->logged_in())
{
$will = (string) $this->uri->segment(3);
$order = (int) $this->uri->segment(4);
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array('order' => $_order, 'author' => $user, 'user' => $customer);
if ($_order->status > 3 && $_order->author != $user['id'])
redirect('/');
if ($_order->author == $user['id'])
{
if ($will == 'yes')
{
$payment_deadline = time() + 604800;
$rate = $this->common->get_item_by_params('orders_rates', array('user' => $user['id'], 'order' => $order));
$this->common->update('orders', $order, array('status' => 3, 'payment_deadline' => $payment_deadline, 'budget' => $rate->rate));
$this->notification->send($customer->email, $this->config->item('will-yes'), 'orders/mail/will-yes', $notice);
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $customer->id,
'message' => 'Статус заказа: Ожидает оплаты',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
redirect('zakaz/tema/' . $order . '/');
}
else
{
$this->common->update('orders', $order, array('author' => 0, 'status' => 1));
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $customer->id,
'message' => 'Я отклонил Ваше предложение выполнить заказ',
'original' => '',
'verified' => 1,
'time' => time()
);
$id = $this->common->insert('chat', $data);
$this->notification->send($customer->email, $this->config->item('will-no'), 'orders/mail/will-no', $notice);
redirect('zakaz/tema/' . $order . '/');
}
}
else
{
redirect('/');
}
}
else
{
$this->session->set_flashdata('return', 'orders/will/' . (string) $this->uri->segment(3) . '/' . (int) $this->uri->segment(4));
$this->layout->view('noaccess');
}
}
public function pay()
{
if ($this->ion_auth->logged_in())
{
$order = (int) $this->uri->segment(3);
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
$rate = $this->common->get_item_by_params('orders_rates', array('order' => $order, 'user' => $_order->author));
if ($_order->user == $user['id'])
{
if ($user['money'] > $rate->rate || $user['money'] == $rate->rate)
{
$blocked = $user['money_blocked'] + $rate->rate;
$money = $user['money'] - $rate->rate;
$this->common->update('users', $_order->user, array('money' => $money, 'money_blocked' => $blocked));
$this->common->update('orders', $order, array('status' => 4, 'payment_deadline' => 0));
$insertdata = array(
'user' => $user['id'],
'amount' => (float) $rate->rate,
'description' => $rate->rate . ' заблокировано для оплаты <a href="/zakaz/tema/' . $_order->id . '">' . $_order->name . '</a>',
'date' => time()
);
$this->common->insert('payments', $insertdata);
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $rate->user,
'message' => 'Заказ оплачен. Статус заказа: В работе',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$author = $this->common->get_item_by_id('users', $_order->author);
$notice = array(
'order' => $_order,
'user' => $author
);
$this->notification->send($author->email, $this->config->item('pay'), 'orders/mail/pay', $notice);
redirect('zakaz/tema/' . $order . '/');
}
else
{
$data['title'] = 'Оплата заказа';
$this->layout->view('orders/getmoney');
}
}
else
{
redirect('/');
}
}
else
{
$this->session->set_flashdata('return', 'orders/will/' . (string) $this->uri->segment(3) . '/' . (int) $this->uri->segment(4));
$this->layout->view('noaccess');
}
}
public function end()
{
if ($this->ion_auth->logged_in())
{
$this->form_validation->set_rules('order', 'Номер заказа', 'required|integer');
$ended = (bool) $this->input->post('ended');
$uploadconfig['upload_path'] = './uploads/orders_files/';
$uploadconfig['allowed_types'] = 'doc|docx|xls|xlsx|txt|jpg|png|pdf|rar|zip|ppt|pptx|rtf';
$uploadconfig['max_size'] = '10240';
$uploadconfig['encrypt_name'] = true;
$this->load->library('upload', $uploadconfig);
if ($this->upload->do_upload('workfile'))
{
$data = $this->upload->data();
$workfile = $data['file_name'];
$this->common->insert('filenames', array('hashname' => $data['file_name'], 'realname' => $_FILES['workfile']['name']));
}
else
{
$filename = $this->input->post('workfile');
$this->_errors[$filename] = $this->upload->display_errors();
$this->form_validation->set_rules('workfile', 'Файл', 'required|callback_upload_file');
$workfile = false;
}
$order = (bool) $this->input->post('order');
if ($order && $workfile != false)
{
$order = (int) $this->input->post('order');
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
if ($ended)
{
$insertdata = array(
'workfile' => $workfile,
'agreement_date' => time(),
'status' => 5,
'agreement_deadline' => time() + 86400
);
$this->common->update('orders', $order, $insertdata);
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $user['id'],
'to' => $_order->user,
'message' => 'Считаю заказ завершенным. Статус заказа: Согласование. <a href="/upload/orders_files/' . $workfile . '">Файл с работой</a>',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$customer = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'order' => $_order,
'user' => $customer
);
$this->notification->send($customer->email, $this->config->item('end'), 'orders/mail/end', $notice);
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
else
{
$insertdata = array(
'order' => $order,
'user' => $user['id'],
'file' => $workfile,
'date' => time()
);
$this->common->insert('orders_files', $insertdata);
$data = array(
'order' => $order,
'from' => $_order->user,
'to' => $_order->author,
'message' => 'Я отправил вам рабочий <a href="/upload/orders_files/' . $workfile . '">файл</a>',
'original' => '',
'verified' => 1,
'time' => time(),
'status' => 0
);
$id = $this->common->insert('chat', $data);
$user = $this->common->get_item_by_id('users', $_order->author);
$active_deadline = $user->last_active + 600;
if ($active_deadline < time())
{
$from = $this->common->get_item_by_id('users', $_order->user);
$notice = array(
'order' => $_order,
'from' => $from,
'user' => $user
);
$this->notification->send($user->email, $this->config->item('chat'), 'orders/mail/chat', $notice);
}
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
}
else
{
redirect('zakaz/tema/' . (int) $this->input->post('order') . '/');
}
}
else
{
$this->session->set_flashdata('return', 'zakaz/tema/' . (int) $this->input->post('order'));
$this->layout->view('noaccess');
}
}
public function complete()
{
if ($this->ion_auth->logged_in())
{
$complete = (string) $this->uri->segment(3);
$order = (int) $this->uri->segment(4);
$user = $this->ion_auth->profile();
$_order = $this->common->get_item_by_params('orders', array('id' => $order));
$this->form_validation->set_rules('comment', 'Отзыв', 'required');
if (isset($_POST['review_page']))
{
if ($this->form_validation->run() == true)
{
$insertdata = array(
'user' => (int) $this->input->post('to'),
'author' => (int) $this->input->post('from'),
'comment' => (string) $this->input->post('comment'),
'date' => time()
);
$this->common->insert('users_comments', $insertdata);
$to = $this->common->get_item_by_id('users', (int) $this->input->post('to'));
$this->common->update('users', (int) $this->input->post('to'), array('comments' => ($to->comments + 1)));
$review = (string) $this->input->post('review');
if ($review != '')
$this->common->insert('reviews', array(
'user' => (int) $this->input->post('from'),
'review' => $review,
'date' => time(),
'status' => 0
));
$this->common->update('orders', $order, array('comment' => 1));
redirect('zakaz/tema/' . $order . '/');
}
} else
{
// die('here');
if ($_order->user == $user['id'])
{
if ($complete == 'yes')
{
$this->common->update('orders', $order, array(
'status' => 7,
'completed_date' => time(),
'ready_deadline_status' => $this->input->post('status')
));
// $t = time();
// echo $t;
// die($t);
//
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $_order->user,
'to' => $_order->author,
'message' => 'Статус заказа: Гарантийная поддержка',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
$author = $this->common->get_item_by_id('users', $_order->author);
$notice = array(
'order' => $_order,
'user' => $author
);
$this->notification->send($author->email, $this->config->item('complete'), 'orders/mail/complete', $notice);
$data['title'] = 'Отзыв об авторе';
$data['from'] = $_order->user;
$data['to'] = $_order->author;
$data['order'] = $order;
$current_date = date('d.m.Y');
$end_date = date('d.m.Y', $_order->date);
if ($current_date == $end_date)
{
$this->common->update('orders', $order, array(
'date' => $_order->date + 86400,
));
}
if ($_order->comment == 1)
{
// redirect('zakaz/tema/' . $order . '/');
}
$this->layout->view('orders/comment', $data);
}
else
{
$this->common->update('orders', $order, array('status' => 4, 'agreement_date' => 0));
$user = $this->ion_auth->profile();
$data = array(
'order' => $order,
'from' => $_order->user,
'to' => $_order->author,
'message' => 'Считаю заказ незавершенным. Статус заказа: В работе',
'original' => '',
'verified' => 1,
'time' => time()
);
$this->common->insert('chat', $data);
redirect('zakaz/tema/' . $order . '/');
}
}
}
}
else
{
$this->session->set_flashdata('return', 'orders/complete/' . (string) $this->uri->segment(3) . '/' . (int) $this->uri->segment(4));
$this->layout->view('noaccess');
}
}
public function noauthor()
{
$data['title'] = 'Утверждение автора';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_choose_author_4_customer($user['id'], $page, 10);
foreach ($data['orders'] as $order)
{
$data['rates_num'][$order->id] = $this->order->get_rates_num($order->id);
}
$this->load->library('pagination');
$config['base_url'] = '/zakaz/noauthor/';
$config['total_rows'] = $this->order->count_choose_author_4_customer($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables_2', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/noauthor');
$this->layout->view('noaccess');
}
}
public function inwork()
{
$data['title'] = 'В работе';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_in_work_4_customer($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/inwork/';
$config['total_rows'] = $this->order->count_in_work_4_customer($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/inwork');
$this->layout->view('noaccess');
}
}
public function completed()
{
$data['title'] = 'Завершенные';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_completed_4_customer($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/completed/';
$config['total_rows'] = $this->order->count_completed_4_customer($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/completed');
$this->layout->view('noaccess');
}
}
public function rates()
{
$data['title'] = 'Ставки';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$this->form_validation->set_rules('q', 'Поисковый запрос', 'xss_clean');
$this->load->library('pagination');
$config['base_url'] = '/zakaz/rates/';
$config['total_rows'] = $this->order->count_rates_4_author($user['id'], 1);
$config['per_page'] = 10;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['uri_segment'] = 3;
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['ratespage'] = true;
$data['user'] = $user;
if ($this->form_validation->run() == true)
{
$q = (string) $this->input->post('q');
$data['orders'] = $this->order->search_rates_4_author($q, $user['id'], $page, 10);
$config['total_rows'] = $$this->order->count_search_rates_4_author($q, $user['id'], $page, 10);
}
else
{
$data['orders'] = $this->order->get_rates_4_author($user['id'], $page, 10);
}
$this->layout->view('orders/tables_search', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/rates');
$this->layout->view('noaccess');
}
}
public function iamauthor()
{
$data['title'] = 'Выбор автора';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_choose_author_4_author($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/rates/';
$config['total_rows'] = $this->order->count_choose_author_4_author($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/rates');
$this->layout->view('noaccess');
}
}
public function inprogress()
{
$data['title'] = 'В работе';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_inprogress_4_author($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/zakaz/completed/';
$config['total_rows'] = $this->order->count_inprogress_4_author($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/completed');
$this->layout->view('noaccess');
}
}
public function done()
{
$data['title'] = 'Завершенные';
if ($this->ion_auth->logged_in())
{
$user = $this->ion_auth->profile();
$page = (int) $this->uri->segment(3);
$data['orders'] = $this->order->get_done_4_author($user['id'], $page, 10);
$this->load->library('pagination');
$config['base_url'] = '/orders/completed/';
$config['total_rows'] = $this->order->count_done_4_author($user['id']);
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['first_link'] = 'Первая';
$config['last_link'] = 'Последняя';
$config['suffix'] = '/';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->layout->view('orders/tables', $data);
}
else
{
$this->session->set_flashdata('return', 'orders/completed');
$this->layout->view('noaccess');
}
}
public function deleterates()
{
if ($this->ion_auth->logged_in())
{
$deleteall = (bool) $this->input->post('deleteall');
$deleterates = $this->input->post('deleterate');
$user = $this->ion_auth->profile();
if ($deleteall == true)
{
$rates = $this->order->get_rates_4_author($user['id'], 0, 10000);
foreach ($rates as $rate)
{
if ($rate->author != $user['id'])
{
$this->common->delete('orders_rates', $rate->id);
}
}
}
if ($deleterates != false && $deleteall == false && is_array($deleterates))
{
foreach ($deleterates as $rate)
{
$_rate = $this->common->get_item_by_id('orders_rates', $rate);
$_order = $this->common->get_item_by_id('orders', $_rate->order);
if ($_rate->user == $user['id'] && $_order->author != $user['id'])
{
$this->common->delete('orders_rates', $rate);
}
}
}
}
redirect('zakaz/rates/');
}
public function no_file()
{
$this->form_validation->set_message('no_file', 'Вы не выбрали ни одного файла');
return false;
}
public function upload_file()
{
$this->form_validation->set_message('upload_file', $this->_error);
return false;
}
public function check_date($date)
{
$time = strtotime($date) + 86340;
$today = strtotime(date('d.m.Y')) - 1;
if ($time > $today)
{
return true;
}
else
{
$this->form_validation->set_message('check_date', 'Необходимо указать более позднюю дату');
return false;
}
}
public function cron()
{
$orders = $this->common->get_items_by_params('orders', array('status' => 4, 'deadline_notif_sent' => 0));
foreach ($orders as $order)
{
if (time() + 43200 >= $order['date'] && !$order['deadline_notif_sent'])
{
$author = $this->common->get_item_by_params('users', array('id' => $order['author']));
$this->common->update('orders', $order['id'], array('deadline_notif_sent' => '1'));
// $this->notification->send($author->email, $this->config->item('deadline_notification'), 'orders/mail/deadline_notification', array(
// 'user' => $author,
// 'order' => $order,
// ));
}
}
$orders = $this->common->get_items_by_params('orders', array('status' => 5));
foreach ($orders as $order)
{
if (time() >= $order['agreement_deadline'])
{
$this->common->update('orders', $order['id'], array('status' => 7, 'agreement_date' => 0));
$author = $this->common->get_item_by_params('users', array('id' => $order['author']));
}
}
$orders = $this->common->get_items_by_params('orders', array('status' => 2));
echo "orders array ", print_r($orders, true);
echo PHP_EOL; // запись в cron.txt перед нотификацией
foreach ($orders as $order)
{
if (time() >= $order['author_deadline'])
{
$this->common->update('orders', $order['id'], array('status' => 1, 'author_deadline' => 0, 'author' => 0));
$this->notification->send($author->email, $this->config->item('deadline_notification'), 'orders/mail/author_fail', array(
'user' => $author,
'order' => $order,
));
}
}
/*
if (time() + 43200 >= $order['date'] && !$order['deadline_notif_sent']) {
$author = $this->common->get_item_by_params('users', array('id' => $order['author']));
$this->common->update('orders', $order['id'], array('deadline_notif_sent' => '1', 'author' => 0, 'author_deadline' => 0, 'status' => 1));
$this->notification->send($author->email, $this->config->item('deadline_notification'), 'orders/mail/deadline_notification', array(
'user' => $author,
'order' => $order,
));
}
*/
//$this->db->query("INSERT INTO emails(`to`, `subject`, `message`) VALUES('test', 'test', 'test')");
}
public function delete($id = 0)
{
if ($this->ion_auth->logged_in())
{
$order = $this->order->get($id);
$user = $this->ion_auth->profile();
if ($order->status != 10)
show_404();
if ($order->user == $user['id'])
$this->order->delete($id);
else
{
$rate = $this->common->get_item_by_params('orders_rates', array('order' => $order->id, 'user' => $user['id']));
$this->common->update('orders_rates', $rate->id, array('visible' => 0));
redirect('/zakaz/rates');
}
redirect('/zakaz/noauthor');
} else
show_404();
}
}
/* End of file orders.php */
/* Location: ./application/controllers/orders.php */
[/SRC]
переписываю движок с codeigniter