public function view_order() { $name = 'name_' . lang_prefix(); $id = $this->params->id; if (!is_numeric($id)) { $this->redirect(array('controller' => 'showerror', 'action' => '/')); exit; } $this->title_name = "Заявка"; $this->set('title', Configure::read('SITENAME') . " - " . Configure::read('ADMIN_PANEL') . " - " . $this->title_name); //данные заявки $order_data = $this->Order->find('first', array('conditions' => array('id' => $id))); // если материал не существует if (count($order_data) > 0) { foreach ($order_data as &$order) { //pr($order); if ($order['category_id'] != 0) { $category = $this->Categories->find('first', array('conditions' => array('id' => $order['category_id']))); $order['category_name'] = $category['Categories'][$name]; } else { $order['category_name'] = L("NOT_DEFINED"); } if ($order['service_id'] != 0) { $service = $this->Service->find('first', array('conditions' => array('id' => $order['service_id']))); $order['service_name'] = $service['Service'][$name]; } else { $order['service_name'] = L("NOT_DEFINED"); } } $order_name = L('ORDER') . " №" . $order_data['Order']['id'] . " " . L('FROM') . " " . lang_calendar($order_data['Order']['created']); $this->Breadcrumbs->add($order_name, ''); //комментарии от мастеров $order_master_actions = $this->Masterorder->find('all', array('conditions' => array('order_id' => $order_data['Order']['id'], 'user_id' => $this->user_data["User"]["id"]), 'joins' => array(array('table' => 'users', 'alias' => 'User', 'type' => 'INNER', 'conditions' => array('User.id = Masterorder.user_id'))), 'fields' => array('Masterorder.*', 'User.*'), 'order' => 'Masterorder.created DESC')); $this->set('order_master_actions', $order_master_actions); $this->set('order_data', $order_data); } else { $this->redirect(array('controller' => 'showerror', 'action' => '/')); } }
public function view_order() { $id = $this->params->id; if (!is_numeric($id)) { $this->redirect(array('controller' => 'showerror', 'action' => '/')); exit; } $this->admin_path_title_name = "Управление заявками"; $this->set('title', Configure::read('SITENAME') . " - " . Configure::read('ADMIN_PANEL') . " - " . $this->admin_path_title_name); //материал $order_data = $this->Order->find('first', array('conditions' => array('id' => $id))); // если материал не существует if (count($order_data) > 0) { foreach ($order_data as &$order) { //pr($order); if ($order['category_id'] != 0) { $category = $this->Categories->find('first', array('conditions' => array('id' => $order['category_id']))); $order['category_name'] = $category['Categories']['name_ru']; } else { $order['category_name'] = L("NOT_DEFINED"); } if ($order['service_id'] != 0) { $service = $this->Service->find('first', array('conditions' => array('id' => $order['service_id']))); $order['service_name'] = $service['Service']['name_ru']; } else { $order['service_name'] = L("NOT_DEFINED"); } if ($order['payment_type_id'] != 0) { $payment_type = $this->ServicePayType->find('first', array('conditions' => array('id' => $order['payment_type_id']))); //pr($this->ServicePayType); $order['payment_type_name'] = $payment_type['ServicePayType']['name_ru']; } else { $order['payment_type_name'] = L("NOT_DEFINED"); } $order_tender = $this->Tender->find('first', array('conditions' => array('order_id' => $order['id']), 'fields' => array('Tender.*', 'UNIX_TIMESTAMP(stop_time) - UNIX_TIMESTAMP(NOW()) AS left_time', 'UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(created) AS elapsed_time'))); if (count($order_tender) > 0) { $order['order_tender'] = $order_tender['Tender']; $order['elapsed_tender'] = $order_tender[0]['elapsed_time']; $order['left_tender'] = $order_tender[0]['left_time']; } $user_country_id = $order['country_id']; $country = $this->Countries->find('first', array('conditions' => array('id' => $user_country_id))); $order['country_name'] = $country['Countries']['name_ru']; $city = $this->Cities->find('first', array('conditions' => array('id' => $order['city_id']))); $order['city_name'] = $city['Cities']['name_ru']; } $order_name = "Заявка №" . $order_data['Order']['id'] . " " . L('FROM') . " " . lang_calendar($order_data['Order']['created']); $this->Breadcrumbs->add($order_name, ''); //лог действий администратора над заявкой $this->loadModel('Adminactionlog'); $this->Adminactionlog->useTable = "admin_actions_logs"; $this->loadModel('Adminactiontype'); $this->Adminactiontype->useTable = "admin_action_types"; $order_actions = $this->Adminactiontype->find('all', array('conditions' => array('group_id' => 2))); $ids = array(); foreach ($order_actions as $action) { //pr($action['Adminactiontype']['id']); $ids[] = $action['Adminactiontype']['id']; } //pr($ids); $order_admin_actions = $this->Adminactionlog->find('all', array('conditions' => array('Adminactionlog.data_1' => $order_data['Order']['id'], 'Adminactionlog.action_type_id IN' => $ids), 'joins' => array(array('table' => 'admins', 'alias' => 'Admin', 'type' => 'INNER', 'conditions' => array('Admin.id = Adminactionlog.admin_id')), array('table' => 'admin_action_types', 'alias' => 'Adminactiontype', 'type' => 'INNER', 'conditions' => array('Adminactiontype.id = Adminactionlog.action_type_id'))), 'fields' => array('Adminactionlog.*', 'Admin.*', 'Adminactiontype.*'), 'order' => 'Adminactionlog.created DESC')); $this->set('order_admin_actions', $order_admin_actions); //действия от мастеров $order_master_actions = $this->Masterorderaction->find('all', array('conditions' => array('order_id' => $order_data['Order']['id']), 'joins' => array(array('table' => 'users', 'alias' => 'User', 'type' => 'INNER', 'conditions' => array('User.id = Masterorderaction.user_id'))), 'fields' => array('Masterorderaction.*', 'User.*'), 'order' => 'Masterorderaction.created DESC')); $this->set('order_master_actions', $order_master_actions); //комментарии от мастеров $order_admin_comments = $this->Adminordercomment->find('all', array('conditions' => array('order_id' => $order_data['Order']['id']), 'joins' => array(array('table' => 'admins', 'alias' => 'Admin', 'type' => 'INNER', 'conditions' => array('Admin.id = Adminordercomment.admin_id'))), 'fields' => array('Adminordercomment.*', 'Admin.*'), 'order' => 'Adminordercomment.created DESC')); $this->set('order_admin_comments', $order_admin_comments); //вывод типов оплаты для управления стоимостью заявки $this->loadModel('ServicePayTypes'); $this->ServicePayTypes->useTable = 'service_pay_types'; $paytype = $this->ServicePayTypes->find('first', array('conditions' => array('id' => $order_data['Order']['payment_type_id']))); $this->set('paytype', $paytype); $this->set('order_data', $order_data); $this->set('order_name', $order_name); } else { $this->redirect(array('controller' => 'showerror', 'action' => '/')); } }