📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv11.demodesign.com.tr
/
propanel
/
model
/
eticdokargo
📝
eticdokargo.php
← Geri Dön
<?php class ModelEticdokargoEticdokargo extends Model { function getKargolaButonlari( $order ) { $html = ''; if ( !$this->eticdokargo->get_status() ) { return $html; } $default = '<a href="javascript:void()" data-toggle="tooltip" title="" class="btn btn-primary" title="Kargola"><i class="fa fa-truck"></i></a>'; $shipping_method = $this->get_shipping_name( $order ); foreach ( $this->eticdokargo->get_firmalar() as $firmakey => $firma_name ) { if ( $this->eticdokargo->$firmakey->status ) { $src = HTTPS_CATALOG . 'image/catalog/kargo_firma/' . $firmakey . '_32.png'; $href = $this->url->link( 'eticdokargo/eticdokargo/kayit_ac', user_token_key.'=' . $this->session->data[ 'user_token' ] . '&order_id=' . $order[ 'order_id' ], true ); if ( strpos( $shipping_method, $firmakey ) !== false ) { $default = '<a class="btn kargola" title="' . $firma_name . ' ile Kargola" data-href="' . $href . '" data-toggle="tooltip" data-customer="' . $order[ 'customer' ] . '" data-order_id="' . $order[ 'order_id' ] . '" data-firma="' . $firmakey . '" style="padding: 0px 3px;"><img src="' . $src . '" class="pull-left"></a>'; } $buttons[] = '<li><a class="text-warning kargola" data-href="' . $href . '" data-toggle="tooltip" data-customer="' . $order[ 'customer' ] . '" data-order_id="' . $order[ 'order_id' ] . '" data-firma="' . $firmakey . '"><img src="' . $src . '"> ' . $firma_name . '</a></li>'; } } if ( isset( $buttons ) ) { $src = HTTPS_CATALOG . 'image/catalog/kargo_firma/irsaliye_32.png'; $href = $this->url->link( 'eticdokargo/eticdokargo/irsaliye', user_token_key.'=' . $this->session->data[ 'user_token' ] . '&order_id=' . $order[ 'order_id' ], true ); $buttons[] = '<li><a class="text-warning sevk-yazdir" target="_blank" data-href="' . $href . '" data-toggle="tooltip" data-customer="' . $order[ 'customer' ] . '" data-order_id="' . $order[ 'order_id' ] . '" ><img src="' . $src . '"> Barkod Çıktısı</a></li>'; $html = '<div class="btn-group"> ' . $default . '<button type="button" data-toggle="dropdown" class="btn btn-primary dropdown-toggle"><span class="caret"></span></button><ul class="dropdown-menu dropdown-menu-right">' . implode( '', $buttons ) . '<a></a></ul></div>'; } return $html; } function getKargoSonuc( $order ) { $html = ''; $sql = "SELECT `kargo_sonuc`, `kargo_barcode`, `kargo_firma`, `kargo_tarih`, `kargo_talepno`, `kargo_takipno`, `kargo_url`, `kargo_paketadet` FROM `" . DB_PREFIX . "order` WHERE `order_id`=" . ( int )$order[ 'order_id' ]; $query = $this->db->query( $sql ); if ( $query->num_rows ) { $text = $query->row[ 'kargo_sonuc' ]; if ( mb_strlen( $query->row[ 'kargo_sonuc' ] ) > 24 )$text = mb_substr( $query->row[ 'kargo_sonuc' ], 0, 24 ); if ( $query->row[ 'kargo_url' ] ) { $html = '<a href="' . $query->row[ 'kargo_url' ] . '" traget="_blank" title="' . $query->row[ 'kargo_sonuc' ] . '" data-toggle="tooltip" target="_blank">' . $text . '</a>'; } else { $html = '<span title="' . $query->row[ 'kargo_sonuc' ] . '" data-toggle="tooltip">' . $text . '</span>'; } } return $html; } function get_shipping_name( $order ) { if ( defined( 'KARGO_DAGITICI' ) ) return KARGO_DAGITICI; $firma_key = ''; if(!isset( $order[ 'shipping_method' ] )){ $query = $this->db->query("SELECT shipping_method FROM `" . DB_PREFIX . "order` WHERE `order_id`=".(int)$order['order_id']); if($query->num_rows){ $order[ 'shipping_method' ] = $query->row[ 'shipping_method' ]; } } $shipping_code = strtolower( $order[ 'shipping_method' ] ); $shipping_code = str_replace(array('Ç','ç'), 'c', $shipping_code); $shipping_code = str_replace(array('U','u'), 'u', $shipping_code); $firmalar = $this->eticdokargo->get_firmalar(); foreach ( $firmalar as $firmakey => $firma_name ) { if ( strpos( $shipping_code, $firmakey ) !== false )$firma_key = $firmakey; } if ( empty( $firma_key ) )$firma_key = current( array_keys( $firmalar ) ); if ( empty( $firma_key ) ) $firma_key = 'yurtici'; return $firma_key; } function get_order_pazaryeri( $order_id ) { $query = $this->db->query("SELECT `pazaryeri` FROM " . DB_PREFIX . "order WHERE `order_id`=" . ( int )$order_id); if($query->num_rows){ return $query->row['pazaryeri']; } return ''; } function kargo_sonuc_uygula( $result, $notify = false, $message = '' ) { $order_status_id = "`order_status_id`='" . $this->db->escape( $result[ 'order_status_id' ] ) . "'"; $kargo_sonuc = "`kargo_sonuc`='" . $this->db->escape( $result[ 'kargo_sonuc' ] ) . "'"; $kargo_barcode = "`kargo_barcode`='" . $this->db->escape( $result[ 'kargo_barcode' ] ) . "'"; $kargo_firma = "`kargo_firma`='" . $this->db->escape( $result[ 'kargo_firma' ] ) . "'"; $kargo_tarih = "`kargo_tarih`='" . $this->db->escape( $result[ 'kargo_tarih' ] ) . "'"; $kargo_talepno = "`kargo_talepno`='" . $this->db->escape( $result[ 'kargo_talepno' ] ) . "'"; $kargo_takipno = "`kargo_takipno`='" . $this->db->escape( $result[ 'kargo_takipno' ] ) . "'"; $kargo_url = "`kargo_url`='" . $this->db->escape( $result[ 'kargo_url' ] ) . "'"; $sql = "UPDATE " . DB_PREFIX . "order SET $kargo_sonuc, $kargo_barcode, $kargo_firma, $kargo_tarih, $kargo_talepno, $kargo_url, $order_status_id WHERE `order_id`=" . ( int )$result[ 'order_id' ]; $this->db->query( $sql ); $this->addHistory( $result, $notify, $message ); } function fix_table() { // sytem klasöründe } function addHistory( $data, $notify = 0, $message = '' ) { // API login $catalog = $this->request->server[ 'HTTPS' ] ? HTTPS_CATALOG : HTTP_CATALOG; // API login $query = $this->db->query("SELECT `key` FROM `" . DB_PREFIX . "api` WHERE `username`='default' || `username`='Varsayılan' ORDER BY `api_id` LIMIT 1"); if($query->num_rows){ $api_token = md5($query->row['key']); } else{ $api_token = false; } $message = $message == 'Kargo Ayarları' ? '' : $message; $data = array( 'order_id' => $data[ 'order_id' ], 'notify' => $notify, 'order_status_id' => $data[ 'order_status_id' ], 'comment' => $message, 'override' => 1, 'api_token' => $api_token, ); $curl = curl_init(); // Set SSL if required if ( substr( $url, 0, 5 ) == 'https' ) { curl_setopt( $curl, CURLOPT_PORT, 443 ); } curl_setopt( $curl, CURLOPT_HEADER, false ); curl_setopt( $curl, CURLINFO_HEADER_OUT, true ); curl_setopt( $curl, CURLOPT_USERAGENT, $this->request->server[ 'HTTP_USER_AGENT' ] ); curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false ); curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $curl, CURLOPT_FORBID_REUSE, false ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $curl, CURLOPT_URL, $catalog . 'index.php?route=eticdokargo/eticdokargo/history&api_token=' . $api_token . '&order_id=' . $data[ 'order_id' ] ); curl_setopt( $curl, CURLOPT_POST, true ); curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $data ) ); $result = curl_exec( $curl ); curl_close( $curl ); $add_history = json_decode( $result, 1 ); if ( $add_history ) { if ( isset( $add_history[ 'error' ] ) ) { $this->session->data[ 'error_add_history' ][] = $add_history[ 'error' ]; } if ( isset( $add_history[ 'success' ] ) ) { $this->session->data[ 'success_add_history' ][] = $add_history[ 'success' ]; return true; } } else { $this->session->data[ 'error_add_history' ][] = 'Opencart Curl Hatası'; } return false; } } ?>
💾 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