📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv11.demodesign.com.tr
/
propanel
/
controller
/
eticdokargo
📝
eticdokargo.php
← Geri Dön
<?php class ControllerEticdokargoEticdokargo extends Controller { private $error = array(); public function index() { $this->load->model( 'eticdokargo/eticdokargo' ); $this->load->language( 'eticdokargo/eticdokargo' ); $this->model_eticdokargo_eticdokargo->fix_table(); $this->load->model( 'setting/setting' ); if ( ( $this->request->server[ 'REQUEST_METHOD' ] == 'POST' ) && $this->validate() ) { $this->model_setting_setting->editSetting( 'eticdokargo', array( 'eticdokargo' => $this->request->post[ 'eticdokargo' ] ) ); $this->session->data[ 'success' ] = $this->language->get( 'Ayarlar kaydedildi...' ); $this->response->redirect( $this->url->link( 'eticdokargo/eticdokargo', user_token_key. '=' . $this->session->data[ 'user_token' ] . '&type=module', true ) ); } $data = $this->model_setting_setting->getSetting( 'eticdokargo' ); if(isset($data['eticdokargo']) && empty($data['eticdokargo']['email'])){ $data['eticdokargo']['email'] = 'Sayın {firstname} {lastname} #{order_id} Numaralı siparişiniz kargoya teslim edilmiştir. Kargonuzu profiliniz altındaki "Siparişlerişlerim" sekmesinden de kontrol edebilirsiniz. . Kargonuz {kargo_firma} kargo ile tarafınıza ulaştırılacaktır. Kargonuzun şuanki durumu: {kargo_sonuc} Takip için: {kargo_url} Ürününüzü güzel günlerde kullanmanızı dileriz. Keyifli alışverişler, sağlıklı günler...'; } if ( isset( $this->error[ 'warning' ] ) ) { $data[ 'error_warning' ] = $this->error[ 'warning' ]; } else { $data[ 'error_warning' ] = ''; } if (isset($this->session->data['success'])) { $data['success'] = $this->session->data['success']; unset($this->session->data['success']); } else { $data['success'] = ''; } $data[ 'breadcrumbs' ] = array(); $data[ 'breadcrumbs' ][] = array( 'text' => $this->language->get( 'text_home' ), 'href' => $this->url->link( 'common/dashboard', user_token_key. '=' . $this->session->data[ 'user_token' ], true ) ); $data[ 'breadcrumbs' ][] = array( 'text' => $this->language->get( 'text_extension' ), 'href' => $this->url->link( 'marketplace/extension', user_token_key. '=' . $this->session->data[ 'user_token' ] . '&type=module', true ) ); $data[ 'breadcrumbs' ][] = array( 'text' => $this->language->get( 'heading_title' ), 'href' => $this->url->link( 'eticdokargo/eticdokargo', user_token_key. '=' . $this->session->data[ 'user_token' ], true ) ); $data[ 'action' ] = $this->url->link( 'eticdokargo/eticdokargo', user_token_key. '=' . $this->session->data[ 'user_token' ], true ); $data[ 'cancel' ] = $this->url->link( 'marketplace/extension', user_token_key. '=' . $this->session->data[ 'user_token' ] . '&type=module', true ); $data[ 'firma_isimleri' ] = $this->eticdokargo->get_firmalar(); $data[ 'css' ] = $this->eticdokargo->css; $data[ 'status' ] = $this->eticdokargo->get_status(); $data[ 'otomatik_tamamlandi' ] = $this->eticdokargo->otomatik_tamamlandi; $data[ 'sorulacaklar' ] = $this->eticdokargo->sorulacaklar; $data[ 'aktif_metodlar' ] = $this->eticdokargo->aktif_metodlar; $data[ 'metodlar' ] = $this->eticdokargo->metodlar; $data[ 'irsaliye_template' ] = '';//file_get_contents(DIR_APPLICATION.'view3/template/eticdokargo/irsaliye.twig'); $data[ 'firmalar' ] = array(); foreach ( $data[ 'firma_isimleri' ] as $firma => $firma_name ) { $data[ 'firmalar' ][ $firma ] = $this->eticdokargo->$firma; } if ( isset( $this->request->post[ 'module_eticdokargo_status' ] ) ) { $data[ 'module_eticdokargo_status' ] = $this->request->post[ 'module_eticdokargo_status' ]; } else { $data[ 'module_eticdokargo_status' ] = $this->config->get( 'module_eticdokargo_status' ); } $this->load->model( 'localisation/order_status' ); $data[ 'order_statuses' ] = $this->model_localisation_order_status->getOrderStatuses(); $data[ 'payment_methods' ] = array(); $query = $this->db->query( "SELECT `code` FROM `" . DB_PREFIX . "setting` WHERE `code` LIKE 'payment%' AND `key` LIKE '%status'" ); if ( $query->num_rows ) { foreach ( $query->rows as $row ) { $payment_method = ltrim( $row[ 'code' ], 'payment_' ); $this->load->language( 'extension/payment/' . $payment_method ); $data[ 'payment_methods' ][ $payment_method ] = array( 'code' => $payment_method, 'name' => $this->language->get( 'heading_title' )."($payment_method)" ); } } $this->load->language( 'eticdokargo/eticdokargo' ); $this->document->setTitle( 'Kargo Ayarları' ); $data[ 'SERVER_NAME' ] = $this->request->server[ 'SERVER_NAME' ]; $data[ 'cron_page_href' ] = HTTPS_CATALOG . 'index.php?route=eticdokargo/cron_job'; $data[ 'test_data_url' ] = htmlspecialchars_decode( $this->url->link( 'eticdokargo/eticdokargo/test_data', user_token_key. '=' . $this->session->data[ 'user_token' ].'&debug=1&test=1', true ) ); $data[ 'fix_database_url' ] = htmlspecialchars_decode( $this->url->link( 'eticdokargo/eticdokargo/fix_database', user_token_key. '=' . $this->session->data[ 'user_token' ], true ) ); $data[ 'activation_url' ] = htmlspecialchars_decode( $this->url->link( 'eticdokargo/eticdokargo/get_activation', user_token_key. '=' . $this->session->data[ 'user_token' ], true ) ); $data[ 'logo_url' ] = HTTPS_CATALOG . 'image/catalog/kargo_firma/'; $data[ 'header' ] = $this->load->controller( 'common/header' ); $data[ 'header' ] = $this->load->controller( 'common/header' ); $data[ 'column_left' ] = $this->load->controller( 'common/column_left' ); $data[ 'footer' ] = $this->load->controller( 'common/footer' ); $data[ 'HTTP_CATALOG' ] = HTTP_CATALOG; $data[ 'HTTPS_CATALOG' ] = HTTPS_CATALOG; $data[ 'user_token' ] = $this->session->data[ 'user_token' ]; $this->response->setOutput( $this->load->view( 'eticdokargo/eticdokargo', $data ) ); } public function fix_database(){ if($this->eticdokargo->fix_table()){ $this->session->data['success'] = "Veritabanı gözden geçirildi"; $this->response->redirect( $this->url->link( 'eticdokargo/eticdokargo', user_token_key. '=' . $this->session->data[ 'user_token' ] . '&type=module', true ) ); } else{ $this->error[ 'warning' ] = 'Veritabanı incelenemedi'; $this->index(); } } public function toplu_sevk_yazdir() { $result[ 'status' ] = '1'; $result[ 'action' ] = 'toplu_kayit_ac_result'; $result[ 'message' ] = 'Toplu İşlem Sona Erdi'; $result[ 'html' ] = ''; $order_ids = isset( $_GET[ 'order_ids' ] ) ? $_GET[ 'order_ids' ] : ''; $this->irsaliye( $order_ids, true ); } public function irsaliye( $ids = '' ) { $order_ids = array(); $order_id = isset( $_GET[ 'order_id' ] ) ? $_GET[ 'order_id' ] : ''; $ids .= ',' . $order_id; foreach ( explode( ',', $ids ) as $order_id ) { if ( ( int )$order_id ) { $order_ids[ $order_id ] = $order_id; } } if ( $order_ids ) { $this->request->post[ 'selected' ] = $order_ids; $this->invoice(); } else { die( 'Sipariş Hatası' ); } } public function hesap_test() { $kargo_firma = isset( $_GET[ 'firma' ] ) ? $_GET[ 'firma' ] : ''; $data[ 'method' ] = isset( $_GET[ 'method' ] ) ? $_GET[ 'method' ] : ''; if ( $kargo_firma ) { $result = $this->eticdokargo->hesap_test( $kargo_firma, $data ); die( 'Sonuc<br>' . $result[ 'html' ] . '<br>' ); } else { die( $result[ 'Hatalı Kargo Firması' ] ); } } public function test_data() { $this->request->post[ 'firma' ] = isset( $_GET[ 'firma' ] ) ? $_GET[ 'firma' ] : ''; $data[ 'method' ] = isset( $_GET[ 'method' ] ) ? $_GET[ 'method' ] : ''; $order_id = isset( $_GET[ 'order_id' ] ) ? $_GET[ 'order_id' ] : ''; if ( $this->request->post[ 'firma' ] ) { if(isset($_GET['test'])) define( 'ETİCDOKARGO_TEST', 1 ); if(isset($_GET['debug'])) define( 'ETİCDOKARGO_DEBUG', 1 ); $result = $this->kayit_ac( $order_id ); die( 'Sonuc<br>' . $result[ 'html' ] . '<br>' ); } else { die( $result[ 'Hatalı Kargo Firması' ] ); } } public function kayit_ac( $order_id = false, $toplu = false ) { $result[ 'status' ] = '0'; $result[ 'message' ] = ''; $result[ 'html' ] = ''; $html = 'İşlem Başladı'; $kargo_firma = isset( $this->request->post[ 'firma' ] ) ? $this->request->post[ 'firma' ] : ''; if ( $order_id ) { $data[ 'order_id' ] = $order_id; } else { $data[ 'order_id' ] = isset( $_POST[ 'order_id' ] ) ? $_POST[ 'order_id' ] : ''; } $this->load->model( 'eticdokargo/eticdokargo' ); $this->load->model( 'sale/order' ); $order = $this->model_sale_order->getOrder( $data[ 'order_id' ] ); if ( $order ) { if ( !$kargo_firma ) { $kargo_firma = $this->model_eticdokargo_eticdokargo->get_shipping_name( $order ); } $order_pazaryeri = $this->model_eticdokargo_eticdokargo->get_order_pazaryeri($data[ 'order_id' ]); if($order_pazaryeri){ $html = 'Pazaryeri Siparişine Kargo Kaydı Açılamaz ...'; } else { $html = '<img src="' . HTTPS_CATALOG . 'image/catalog/kargo_firma/' . $kargo_firma . '_32.png" alt="' . $kargo_firma . '" title="' . $kargo_firma . '"> <strong>#' . $order[ 'order_id' ] . ' ' . $order[ 'customer' ] . '</strong>: '; if ( $kargo_firma ) { $order[ 'paket' ] = isset( $_POST[ 'paket' ] ) ? $_POST[ 'paket' ] : '1'; if ( isset( $_GET[ 'iptal' ] ) ) { $result = $this->eticdokargo->kayit_iptal( $kargo_firma, $order ); $result[ 'status' ] = 0; //mesaj gitmemesi için } else { $result = $this->eticdokargo->kayit_ac( $kargo_firma, $order ); } if ( $result[ 'status' ] ) { $this->model_eticdokargo_eticdokargo->kargo_sonuc_uygula( $result[ 'data' ], false, $result[ 'message' ] ); } } else { $result[ 'message' ] = 'Hatalı Kargo Firması: ' . $kargo_firma; $result[ 'html' ] = 'Hatalı Kargo Firması: ' . $kargo_firma; } if ( isset( $this->session->data[ 'error_add_history' ] ) ) { $this->db->query( "INSERT INTO `" . DB_PREFIX . "order_history` SET `order_id` = '" . ( int )$order[ 'order_id' ] . "', `order_status_id` = '" . ( int )$result[ 'data' ][ 'order_status_id' ] . "', `notify` = '0', `comment` = '" . $this->db->escape( $result[ 'message' ] ) . "', `date_added` = NOW()" ); $result[ 'message' ] .= '<br>' . implode( '<br>', $this->session->data[ 'error_add_history' ] ); unset( $this->session->data[ 'error_add_history' ] ); } } $html .= $result[ 'message' ] . '<hr>'; } else { $result[ 'message' ] = 'Sipariş Bilgisi Alınamadı'; $html .= 'Sipariş Bilgisi Alınamadı<br>'; } if ( $toplu ) return $html; die( json_encode( $result ) ); } public function toplu_kayit_ac() { $result[ 'status' ] = '1'; $result[ 'action' ] = 'toplu_kayit_ac_result'; $result[ 'message' ] = 'Toplu İşlem Sona Erdi'; $result[ 'html' ] = ''; $order_ids = isset( $_GET[ 'order_ids' ] ) ? explode( ',', $_GET[ 'order_ids' ] ) : array(); foreach ( $order_ids as $order_id ) { if((int)$order_id>0 ) $result[ 'html' ] .= $this->kayit_ac( ( int )$order_id, true ); } die( $result[ 'html' ] ); } public function get_activation() { $firma_isimleri = $this->eticdokargo->installed_firmalar( false ); $html = ''; $module = 'eticdokargo'; foreach ( $firma_isimleri as $key => $firma_isim ) { $site = $this->request->server[ 'SERVER_NAME' ]; $url = "http://www.teknovip.net/licancess/check/?module=" . base64_encode( $module ) . "&site=" . base64_encode( $site ) . "&key=" . base64_encode( $key ); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $result = curl_exec( $ch ); if ( strlen( $result ) == '32' ) { $licance_file = fopen( $this->eticdokargo->get_folder() . $result, "w" )or die( "Unable to open file!" ); $txt = "Tulpar Studyo"; fwrite( $licance_file, $txt ); fclose( $licance_file ); $html .= "<strong>Kargo $firma_isim Modülü</strong> $site sitesi için lisanslandı.<br>"; } curl_close( $ch ); } die( ' <i class="fa fa-check text-success"></i>Aktivasyon İşlemi Tamamlandı.<br>' . $html . 'Lütfen bir kaç saniye bekleyiniz...<script>window.setInterval(function(){location.reload(true);}, 3000);</script>' ); } protected function validate() { if ( !$this->user->hasPermission( 'modify', 'eticdokargo/eticdokargo' ) ) { $this->error[ 'warning' ] = $this->language->get( 'error_permission' ); } return !$this->error; } private function invoice() { $this->load->language('sale/order'); $data['title'] = $this->language->get('text_invoice'); if ($this->request->server['HTTPS']) { $data['base'] = HTTPS_SERVER; } else { $data['base'] = HTTP_SERVER; } $data['direction'] = $this->language->get('direction'); $data['lang'] = $this->language->get('code'); $this->load->model('sale/order'); $this->load->model('setting/setting'); $data['orders'] = array(); $orders = array(); if (isset($this->request->post['selected'])) { $orders = $this->request->post['selected']; } elseif (isset($this->request->get['order_id'])) { $orders[] = $this->request->get['order_id']; } foreach ($orders as $order_id) { $order_info = $this->model_sale_order->getOrder($order_id); if ($order_info) { $store_info = $this->model_setting_setting->getSetting('config', $order_info['store_id']); if ($store_info) { $store_address = $store_info['config_address']; $store_email = $store_info['config_email']; $store_telephone = $store_info['config_telephone']; $store_fax = $store_info['config_fax']; } else { $store_address = $this->config->get('config_address'); $store_email = $this->config->get('config_email'); $store_telephone = $this->config->get('config_telephone'); $store_fax = $this->config->get('config_fax'); } if ($order_info['invoice_no']) { $invoice_no = $order_info['invoice_prefix'] . $order_info['invoice_no']; } else { $invoice_no = ''; } if ($order_info['payment_address_format']) { $format = $order_info['payment_address_format']; } else { $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; } $find = array( '{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}' ); $replace = array( 'firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country'] ); $payment_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); if ($order_info['shipping_address_format']) { $format = $order_info['shipping_address_format']; } else { $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; } $find = array( '{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}' ); $replace = array( 'firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country'] ); $shipping_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); $this->load->model('tool/upload'); $this->load->model('tool/image'); $product_data = array(); $products = $this->model_sale_order->getOrderProducts($order_id); foreach ($products as $product) { $option_data = array(); $options = $this->model_sale_order->getOrderOptions($order_id, $product['order_product_id']); foreach ($options as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); if ($upload_info) { $value = $upload_info['name']; } else { $value = ''; } } $option_data[] = array( 'name' => $option['name'], 'value' => $value ); } $query = $this->db->query("SELECT `image` FROM `".DB_PREFIX."product` WHERE `model`='".$product['model']."' LIMIT 1"); if ( $query->num_rows && is_file(DIR_IMAGE . $query->row['image'])) { $thumb = $this->model_tool_image->resize($query->row['image'], 100, 100); } else { $thumb = $this->model_tool_image->resize('no_image.png', 100, 100); } $product_data[] = array( 'name' => $product['name'], 'thumb' => $thumb, 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']) ); } $voucher_data = array(); $vouchers = $this->model_sale_order->getOrderVouchers($order_id); foreach ($vouchers as $voucher) { $voucher_data[] = array( 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']) ); } $total_data = array(); $totals = $this->model_sale_order->getOrderTotals($order_id); foreach ($totals as $total) { $total_data[] = array( 'title' => $total['title'], 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']) ); } $data['orders'][] = array( 'order_id' => $order_id, 'invoice_no' => $invoice_no, 'date_added' => date($this->language->get('date_format_short'), strtotime($order_info['date_added'])), 'store_name' => $order_info['store_name'], 'store_url' => rtrim($order_info['store_url'], '/'), 'store_address' => nl2br($store_address), 'store_email' => $store_email, 'store_telephone' => $store_telephone, 'store_fax' => $store_fax, 'email' => $order_info['email'], 'telephone' => $order_info['telephone'], 'shipping_address' => $shipping_address, 'shipping_method' => $order_info['shipping_method'], 'payment_address' => $payment_address, 'payment_method' => $order_info['payment_method'], 'product' => $product_data, 'voucher' => $voucher_data, 'total' => $total_data, 'comment' => nl2br($order_info['comment']), 'thumb' => $thumb ); } } foreach($data['orders'] as $order_key=>$order){ $query = $this->db->query( "SELECT * FROM `" . DB_PREFIX . "order` WHERE `order_id`=".$order['order_id'] ); if($query->num_rows){ $data['orders'][$order_key]['kargo'] = $query->row; } else { $data['orders'][$order_key]['kargo'] = []; } } $file_extension = ''; if ( VERSION == '2.1.0.1' ) { $file_extension = '.tpl'; } $this->response->setOutput($this->load->view('eticdokargo/irsaliye'.$file_extension, $data)); } }
💾 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