📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv11.demodesign.com.tr
/
catalog
/
model
/
emticket
📝
emticket.php
← Geri Dön
<?php class ModelEmticketEmticket extends Model { public function addTicket($status,$data) { $ticket_setting = $this->config->get('emticketsetting_status'); if($this->customer->isLogged()){ $data['customer_id'] = $this->customer->getId(); $data['firstname'] = $this->customer->getFirstName(); $data['lastname'] = $this->customer->getLastName(); $data['email'] = $this->customer->getEmail(); $data['telephone'] = $this->customer->getTelephone(); } $this->db->query("INSERT INTO " . DB_PREFIX . "emtickets SET customer_id = '" . (int)$data['customer_id'] . "', department = '" . (int)$data['department'] . "', priority = '" . (int)$data['priority'] . "', ticket_status = '" . (int)$status . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', subject = '" . $this->db->escape($data['subject']) . "', message = '" . $this->db->escape($data['message']) . "', date_added = NOW(), date_modified = NOW()"); $ticket_id = $this->db->getLastId(); if(isset($data['attachments'])){ foreach($data['attachments'] as $attach){ $this->db->query("INSERT INTO " . DB_PREFIX . "emticket_attach SET ticket_id = '" . (int)$ticket_id . "', code = '" . $this->db->escape($attach) . "'"); } } // New Ticket email to Client/Customer if(isset($ticket_setting['user_newticket_alert'])){ $this->load->language('emticket/mail'); $message = sprintf($this->language->get('text_ticket_request'),$ticket_id) . "\n\n"; $message .= $this->language->get('text_staff_review') . "\n\n\n"; $message .= $this->language->get('text_review_link') . "\n"; $message .= $this->url->link('emticket/ticketview' . '&ticket_id=' .$ticket_id) . "\n\n\n"; $message .= $this->language->get('text_ticket_id') . ' ' . $ticket_id . "\n"; $message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n\n"; $message .= $data['message'] . "\n\n"; // Email Template Customer Setting Start 30-1-19 if($ticket_setting['emailtemp_description'][$this->config->get('config_language_id')]['user_newticket']){ $format = html_entity_decode($ticket_setting['emailtemp_description'][$this->config->get('config_language_id')]['user_newticket']); $find = array( '{firstname}', '{lastname}', '{email}', '{telephone}', '{priority}', '{department}', '{ticketstatus}', '{subject}', '{customermessage}', '{ticketid}', '{link}' ); $replace = array( 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'email' => $data['email'], 'telephone' => $data['telephone'], 'priority' => $this->getPriorityNameById($data['priority']), 'department' => $this->getDepartmentNameById($data['department']), 'ticketstatus' => $this->getTicketstatusNameById($status), 'subject' => $data['subject'], 'customermessage' => $data['message'], 'ticketid' => $ticket_id, 'link' => $this->url->link('emticket/ticketview' . '&ticket_id=' .$ticket_id) ); $message = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); } // Email Template Customer Setting End $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($data['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); $mail->setSubject(html_entity_decode($this->language->get('text_ticket_requested'), ENT_QUOTES, 'UTF-8')); $mail->setHtml(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } // New Ticket email to Client/Customer // New Ticket email to admin if(isset($ticket_setting['admin_newticket_alert'])){ $message = sprintf($this->language->get('text_ticket_submission'),$this->config->get('config_name')) . "\n\n"; $message .= $this->language->get('text_ticket_info') . "\n"; $message .= $this->language->get('text_ticket_id') . ' ' . $ticket_id . "\n"; $message .= $this->language->get('text_firstname') . ' ' . $data['firstname'] . "\n\n"; $message .= $this->language->get('text_lastname') . ' ' . $data['lastname'] . "\n\n"; $message .= $this->language->get('text_email') . ' ' . $data['email'] . "\n\n"; $message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n\n\n"; $message .= $data['message'] . "\n\n"; // Email Template Admin Setting Start 30-1-19 if($ticket_setting['emailtemp_description'][$this->config->get('config_language_id')]['admin_newticket']){ $format = html_entity_decode($ticket_setting['emailtemp_description'][$this->config->get('config_language_id')]['admin_newticket']); $find = array( '{firstname}', '{lastname}', '{email}', '{telephone}', '{priority}', '{department}', '{ticketstatus}', '{subject}', '{customermessage}', '{ticketid}', '{link}' ); $replace = array( 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'email' => $data['email'], 'telephone' => $data['telephone'], 'priority' => $this->getPriorityNameById($data['priority']), 'department' => $this->getDepartmentNameById($data['department']), 'ticketstatus' => $this->getTicketstatusNameById($status), 'subject' => $data['subject'], 'customermessage' => $data['message'], 'ticketid' => $ticket_id, 'link' => $this->url->link('emticket/ticketview' . '&ticket_id=' .$ticket_id) ); $message = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); } // Email Template Admin Setting End $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); $mail->setSubject(html_entity_decode($this->language->get('text_new_ticket_submit'), ENT_QUOTES, 'UTF-8')); $mail->setHtml(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } // New Ticket email to admin } public function getTicket($ticket_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "emtickets WHERE ticket_id = '" . (int)$ticket_id . "' and (customer_id = '" . (int)$this->customer->getId() . "' or email = '".$this->customer->getEmail()."')"); return $query->row; } public function verifyTicket($ticket_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "emtickets WHERE ticket_id = '" . (int)$ticket_id . "' and email = '".$this->customer->getEmail()."'"); $query->row; if($query->row){ $this->db->query("Update " . DB_PREFIX . "emtickets SET customer_id = '". (int)$this->customer->getId() ."' where ticket_id='".$ticket_id."'"); } else{ return 'error'; } } public function getTickets($data = array()) { $sql = "SELECT * FROM " . DB_PREFIX . "emtickets where (customer_id = '" . (int)$this->customer->getId() . "' OR email = '" .$this->customer->getEmail(). "')"; if ($data['filter_status']!="") { $sql .= " AND ticket_status = '" . (int)$data['filter_status'] . "'"; } if ($data['filter_department']!="") { $sql .= " AND department = '" . (int)$data['filter_department'] . "'"; } if ($data['filter_priority']!="") { $sql .= " AND priority = '" . (int)$data['filter_priority'] . "'"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; } $query = $this->db->query($sql); return $query->rows; } public function getTotalTickets($data = array()) { $sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "emtickets where (customer_id = '" . (int)$this->customer->getId() . "' OR email = '". $this->customer->getEmail() ."')"; if ($data['filter_status']!="") { $sql .= " AND ticket_status = '" . (int)$data['filter_status'] . "'"; } if ($data['filter_department']!="") { $sql .= " AND department = '" . (int)$data['filter_department'] . "'"; } if ($data['filter_priority']!="") { $sql .= " AND priority = '" . (int)$data['filter_priority'] . "'"; } $query = $this->db->query($sql); return $query->row['total']; } public function getTicketAttachments($ticket_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "emticket_attach WHERE ticket_id = '" . (int)$ticket_id . "' and reply_id = 0"); return $query->rows; } public function getPriorityNameById($priority_id) { $query = $this->db->query("SELECT info FROM " . DB_PREFIX . "emticket_priority where priority_id='" .(int)$priority_id . "'"); if($query->row['info']){ $info = json_decode($query->row['info'], true); return '<span class="label label-default" style="background:'.$info['label_bg'].' ;color:'.$info['label_clr'].' ;">'.$info[(int)$this->config->get('config_language_id')]['name'].'</span>'; } else { return 0; } } public function getTicketstatusNameById($id) { $query = $this->db->query("SELECT info FROM " . DB_PREFIX . "emticket_status where id='" .(int)$id . "'"); if($query->row['info']){ $info = json_decode($query->row['info'], true); return '<span class="label label-default" style="background:'.$info['label_bg'].' ;color:'.$info['label_clr'].' ;">'.$info[(int)$this->config->get('config_language_id')]['name'].'</span>'; } else { return 0; } } public function getDepartmentNameById($department_id) { $query = $this->db->query("SELECT name FROM " . DB_PREFIX . "emticket_department_description where department_id='" .(int)$department_id . "' and language_id='".(int)$this->config->get('config_language_id')."'"); return $query->row['name']; } public function getDepartments($data = array()) { $sql = "SELECT * FROM " . DB_PREFIX . "emticket_department where status = 1 ORDER BY sort_order ASC"; $query = $this->db->query($sql); return $query->rows; } public function getDepartmentDescriptions($department_id) { $department_description_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "emticket_department_description WHERE department_id = '" . (int)$department_id . "'"); foreach ($query->rows as $result) { $department_description_data[$result['language_id']] = array( 'name' => $result['name'], 'small_desc' => $result['small_desc'], ); } return $department_description_data; } public function getPrioritys($data = array()) { $sql = "SELECT * FROM " . DB_PREFIX . "emticket_priority where status = 1 ORDER BY sort_order ASC"; $query = $this->db->query($sql); return $query->rows; } public function addReply($ticket_id,$data,$wait_status_id) { //print_r($data);die(); $this->db->query("Update " . DB_PREFIX . "emtickets SET ticket_status = '" . (int)$wait_status_id . "', date_modified = NOW() where ticket_id='".$ticket_id."'"); $this->db->query("INSERT INTO " . DB_PREFIX . "emtickets_reply SET ticket_id = '" . (int)$ticket_id . "', user_identity = 1, client_id = 1, message = '" . $this->db->escape($data['message']) . "', date_added = NOW()"); $reply_id = $this->db->getLastId(); if(isset($data['attachments'])){ foreach($data['attachments'] as $attach){ $this->db->query("INSERT INTO " . DB_PREFIX . "emticket_attach SET reply_id = '" . (int)$reply_id . "', ticket_id = '" . (int)$ticket_id . "', code = '" . $this->db->escape($attach) . "'"); } } // Reply email to admin $ticket_setting = $this->config->get('emticketsetting_status'); if(isset($ticket_setting['customer_reply_alert_admin'])){ $this->load->language('emticket/mail'); $name = $this->customer->getFirstName(). "" . $this->customer->getLastName(); $message = sprintf($this->language->get('text_reply_submitted'),$name) . "\n\n"; $message .= $this->language->get('text_ticket_info') . "\n"; $message .= $this->language->get('text_ticket_id') . ' ' . $ticket_id . "\n"; $message .= $this->language->get('text_firstname') . ' ' . $data['firstname'] . "\n\n"; $message .= $this->language->get('text_lastname') . ' ' . $data['lastname'] . "\n\n"; $message .= $this->language->get('text_email') . ' ' . $data['email'] . "\n\n"; $message .= $this->language->get('text_telephone') . ' ' . $data['telephone'] . "\n\n\n"; $message .= $data['message'] . "\n\n\n"; $message .= $this->language->get('text_reply_link'). "\n\n"; $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8')); $mail->setSubject($this->language->get('text_new_ticket_submit'), ENT_QUOTES, 'UTF-8'); $mail->setText($message); $mail->send(); } // Reply email to admin } public function getTicketReply($ticket_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "emtickets_reply WHERE ticket_id = '" . (int)$ticket_id . "' ORDER BY date_added DESC"); return $query->rows; } public function getReplyAttachments($reply_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "emticket_attach WHERE reply_id = '" . (int)$reply_id . "'"); return $query->rows; } // ticket status public function getStatuss() { $sql = "SELECT * FROM " . DB_PREFIX . "emticket_status"; $query = $this->db->query($sql); return $query->rows; } public function getTotalTicketsByStatusId($id) { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "emtickets where ticket_status ='". $id ."' AND (customer_id = '" . (int)$this->customer->getId() . "' OR email = '". $this->customer->getEmail() ."')"); return $query->row['total']; } // ticket Priority /* public function getPrioritys() { $sql = "SELECT * FROM " . DB_PREFIX . "emticket_priority"; $query = $this->db->query($sql); return $query->rows; } */ public function getTotalTicketsByPriorityId($id) { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "emtickets where priority ='". $id ."' AND (customer_id = '" . (int)$this->customer->getId() . "' OR email = '". $this->customer->getEmail() ."')"); return $query->row['total']; } public function getTotalTicketsByDepartmentId($id) { $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "emtickets where department ='". $id ."' AND (customer_id = '" . (int)$this->customer->getId() . "' OR email = '". $this->customer->getEmail() ."')"); return $query->row['total']; } }
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula