Last active
May 10, 2022 12:51
-
-
Save yasinkuyu/68dbf934b9bf54349914026c69de95a0 to your computer and use it in GitHub Desktop.
Opencart Yurtiçi (ocmod) 2.0.x & 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<modification> | |
<name>insya_yurtici</name> | |
<code>insya_yurtici</code> | |
<version>1.0</version> | |
<author>Yasin Kuyu | [email protected]</author> | |
<link>http://insya.com</link> | |
<file path="admin/controller/setting/setting.php"> | |
<operation> | |
<search position="before"><![CDATA[ | |
if (isset($this->request->post['config_order_status_id'])) | |
]]></search> | |
<add><![CDATA[ | |
if (isset($this->request->post['config_yurtici_user'])) { | |
$data['config_yurtici_user'] = $this->request->post['config_yurtici_user']; | |
} else { | |
$data['config_yurtici_user'] = $this->config->get('config_yurtici_user'); | |
} | |
if (isset($this->request->post['config_yurtici_pass'])) { | |
$data['config_yurtici_pass'] = $this->request->post['config_yurtici_pass']; | |
} else { | |
$data['config_yurtici_pass'] = $this->config->get('config_yurtici_pass'); | |
} | |
if (isset($this->request->post['config_yurtici_ekucret'])) { | |
$data['config_yurtici_ekucret'] = $this->request->post['config_yurtici_ekucret']; | |
} else { | |
$data['config_yurtici_ekucret'] = $this->config->get('config_yurtici_ekucret'); | |
} | |
if (isset($this->request->post['config_yurtici_pays'])) { | |
$data['config_yurtici_pays'] = $this->request->post['config_yurtici_pays']; | |
} else { | |
$data['config_yurtici_pays'] = $this->config->get('config_yurtici_pays'); | |
} | |
if(!is_array($data['config_yurtici_pays'])) $data['config_yurtici_pays'] = array(); | |
$this->load->model('extension/extension'); | |
$installedpayments = $this->model_extension_extension->getInstalled('payment'); | |
$data['payments'] = array(); | |
foreach($installedpayments as $installedpayment) | |
{ | |
$this->load->language('payment/' . $installedpayment); | |
$data['payments'][$installedpayment]['code'] = $installedpayment; | |
$data['payments'][$installedpayment]['name'] = $this->language->get('heading_title')." ($installedpayment)"; | |
} | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/view/template/setting/setting.tpl"> | |
<operation> | |
<search position="after"><![CDATA[ | |
<li><a href="#tab-mail" data-toggle="tab"><?php echo $tab_mail; ?></a></li> | |
]]></search> | |
<add><![CDATA[ | |
<li><a href="#tab-yurtici" data-toggle="tab">Yurtiçi Kargo</a></li> | |
]]></add> | |
</operation> | |
<operation> | |
<search position="before"><![CDATA[ | |
<div class="tab-pane" id="tab-mail"> | |
]]></search> | |
<add><![CDATA[ | |
<div class="tab-pane" id="tab-yurtici"> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Kullanım Durumu">Durumu</span></label> | |
<div class="col-sm-10"> | |
<label class="radio-inline"> | |
<input type="radio" name="config_kargofirma" value="YURTICI" id="config_kargofirma" <?php if($config_kargofirma=='YURTICI') echo 'checked="checked"';?>>Aktif Kargo Firması | |
</label> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Gönderilen kargo için durum kodu">Kullanıcı Adı</span></label> | |
<div class="col-sm-10"> | |
<input type="text" name="config_yurtici_user" value="<?=$config_yurtici_user?>" placeholder="Yurtiçi Kargo Api adı" id="input-admin-limit" class="form-control"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Yurtiçi Kargo Api Şifresi">Kullanıcı Şifresi</span></label> | |
<div class="col-sm-10"> | |
<input type="text" name="config_yurtici_pass" value="<?=$config_yurtici_pass?>" placeholder="Yurtiçi Kargo Api Şifresi" id="config_yurtici_pass" class="form-control"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Kargo ile tahsilat durumunda alınacak ek ücret">Ek kargo ücreti</span></label> | |
<div class="col-sm-10"> | |
<input type="text" name="config_yurtici_ekucret" value="<?=$config_yurtici_ekucret?>" placeholder="Ek kargo ücreti" id="config_yurtici_ekucret" class="form-control"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Kapıda Tahsilat durumunda sipariş bedeli kargo kaydına aktarılır">Tahsilatlı kargo durumları</span></label> | |
<div class="col-sm-10"> | |
<div class="well well-sm" style="height: 150px; overflow: auto;"> | |
<?php foreach ($payments as $payment) { ?> | |
<div class="checkbox"> | |
<label> | |
<?php if (in_array($payment['code'], $config_yurtici_pays)) { ?> | |
<input type="checkbox" name="config_yurtici_pays[]" value="<?php echo $payment['code']; ?>" checked="checked" /> | |
<?php echo $payment['name']; ?> | |
<?php } else { ?> | |
<input type="checkbox" name="config_yurtici_pays[]" value="<?php echo $payment['code']; ?>" /> | |
<?php echo $payment['name']; ?> | |
<?php } ?> | |
</label> | |
</div> | |
<?php } ?> | |
</div> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Yardım uyarıları">Yardım</span></label> | |
<div class="col-sm-10"> | |
<div class="alert alert-warning"> | |
<ul> | |
<li>Seçenekler tabından kargo işlemi sipariş durum kodunu ayarlamayı unutmayınız. O kod tüm kargo entegrasyonlarımız için ortaktır </li> | |
<li>Yuriçi Kargo sisteminin kullanılması için sunucunuzda 8080 portunun açık olmas gerekmektedir</li> | |
<li>Destek <a href="http://insya.com">[email protected] (c) Insya Bilisim</a></li> | |
</ul> </div> | |
</div> | |
</div> | |
</div> | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/controller/sale/order.php"> | |
<operation> | |
<search position="before"><![CDATA[ | |
public function index() | |
]]></search> | |
<add><![CDATA[ | |
function YURTICI($order_info) | |
{ | |
$pays = $this->config->get('config_yurtici_pays'); | |
$ekucret = $this->config->get('config_yurtici_ekucret'); | |
$wsUserName = $this->config->get('config_yurtici_user'); | |
$wsPassword = $this->config->get('config_yurtici_pass'); | |
$userLanguage = 'TR'; | |
$cargoid= 1000000000000+$order_info['order_id']; | |
$order = array( | |
'cargoKey' => $cargoid, | |
'invoiceKey' => substr(md5($cargoid),9,10), | |
'receiverCustName' => $order_info['shipping_firstname'].' '.$order_info['shipping_lastname'], | |
'receiverAddress' => $order_info['shipping_address_1'].' '.$order_info['shipping_address_2'], | |
'cityName' => $order_info['shipping_zone'], | |
'townName' => $order_info['shipping_city'], | |
'receiverPhone1' => $order_info['telephone'], | |
'receiverPhone2' => $order_info['fax'], | |
'receiverPhone3' => "", | |
'emailAddress' => $order_info['email'], | |
'taxOfficeId' =>'', | |
'taxNumber' =>"", | |
'taxOfficeName' =>"", | |
'desi' =>"", | |
'kg' =>"", | |
'cargoCount' =>"", | |
'waybillNo' =>$cargoid, //Sevk İrsaliye No (Ticari gönderilerde zorunludur) | |
'specialField1' =>"", | |
'specialField2' =>"", | |
'specialField3' =>"", | |
'ttInvoiceAmount' =>"10", | |
'ttDocumentId' =>$cargoid, | |
'ttCollectionType' =>"0", | |
'ttDocumentSaveType'=>"0", | |
'dcSelectedCredit' =>"", | |
'dcCreditRule' =>'', | |
'description' =>"", | |
'orgGeoCode' =>"", | |
'privilegeOrder' =>"", | |
'custProdId' =>"", | |
'orgReceiverCustId' =>"", | |
); | |
// http://selfservis.yurticikargo.com/reports/SSWDocumentDetail.aspx?DocId=102163652617 | |
// Gönderici Ödemeli, Alıcı Ödemeli, Gönderici Ödemeli Tahsilatlı Teslimat, Alıcı Ödemeli Tahsilatlı Teslimat | |
if(in_array($order_info['payment_code'], $pays)) | |
{ | |
//echo '<br>Tahsilatlı Kargo<br>'; | |
//$order['ttCollectionType'] = '1'; | |
//$order['ttInvoiceAmount'] = $order_info['total']+(float)$ekucret; | |
} | |
try { | |
//$serviceurl = 'http://testwebservices.yurticikargo.com:9090'; | |
$serviceurl = 'http://webservices.yurticikargo.com:8080'; | |
$serviceurl = $serviceurl . '/KOPSWebServices/ShippingOrderDispatcherServices?wsdl'; | |
$client = new SoapClient($serviceurl, ['trace' => true, 'cache_wsdl' => WSDL_CACHE_MEMORY]); | |
$send = array('wsUserName'=>$wsUserName, 'wsPassword'=>$wsPassword, 'userLanguage'=>$userLanguage, 'ShippingOrderVO'=>array($order)); | |
$response = $client->createShipment( $send ); | |
//$response = $client->queryShipment( $send ); | |
//$response = $client->cancelShipment( $send ); | |
//print_r($response); die(); | |
if( property_exists($response,'ShippingOrderResultVO') && $response->ShippingOrderResultVO->errCode == 0 ) { | |
// print_r($response); | |
return 1; | |
} else { | |
return $response->ShippingOrderResultVO->shippingOrderDetailVO->errMessage; | |
} | |
} | |
catch(Exception $e) { | |
echo 'Error: ' .$e->getMessage(); | |
} | |
} | |
]]></add> | |
</operation> | |
</file> | |
</modification> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<modification> | |
<name>insya_yurtyici</name> | |
<code>insya_yurtyici</code> | |
<version>1.0</version> | |
<author>[email protected]</author> | |
<link>http://insya.com</link> | |
<file path="admin/controller/setting/setting.php"> | |
<operation> | |
<search position="before"><![CDATA[ | |
if (isset($this->request->post['config_order_status_id'])) | |
]]></search> | |
<add><![CDATA[ | |
if (isset($this->request->post['config_kargo_status_id'])) { | |
$data['config_kargo_status_id'] = $this->request->post['config_kargo_status_id']; | |
} else { | |
$data['config_kargo_status_id'] = $this->config->get('config_kargo_status_id'); | |
} | |
if (isset($this->request->post['config_kargofirma'])) { | |
$data['config_kargofirma'] = $this->request->post['config_kargofirma']; | |
} else { | |
$data['config_kargofirma'] = $this->config->get('config_kargofirma'); | |
} | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/view/template/setting/setting.twig"> | |
<operation> | |
<search><![CDATA[ | |
<legend>{{ text_review }}</legend> | |
]]></search> | |
<add position="after" offset="-2"><![CDATA[ | |
<fieldset> | |
<legend>Kargo</legend> | |
<div class="form-group"> | |
<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="" data-original-title="Gönderilen kargo için sipariş durum kodu">Kargolandı Durum Kodu</span></label> | |
<div class="col-sm-10"> | |
<select name="config_kargo_status_id" id="input-kargo-status" class="form-control"> | |
{% for order_status in order_statuses %} | |
{% if order_status.order_status_id == config_kargo_status_id %} | |
<option value="{{ order_status.order_status_id }}" selected="selected">{{ order_status.name }}</option> | |
{% else %} | |
<option value="{{ order_status.order_status_id }}">{{ order_status.name }}</option> | |
{% endif %} | |
{% endfor %} | |
</select> | |
</div> | |
</div> | |
</fieldset> | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/view/template/sale/order_list.twig"> | |
<operation> | |
<search position="after"><![CDATA[ | |
<button type="submit" id="button-invoice" form="form-order" formaction="{{ invoice }}" formtarget="_blank" data-toggle="tooltip" title="{{ button_invoice_print }}" class="btn btn-info"><i class="fa fa-print"></i></button> | |
]]></search> | |
<add><![CDATA[ | |
<button data-toggle="tooltip" id="button-cargo" title="" class="btn btn-success kargola" data-original-title="Kargola" ><i class="fa fa-truck"></i></button> | |
]]></add> | |
</operation> | |
<operation> | |
<search position="before"><![CDATA[ | |
{{ footer }} | |
]]></search> | |
<add><![CDATA[ | |
<script> | |
$('#button-cargo').prop('disabled', true); | |
$('input[name^=\'selected\']').on('change', function() { | |
$('#button-cargo').prop('disabled', true); | |
var selected = $('input[name^=\'selected\']:checked'); | |
if (selected.length) { | |
$('#button-cargo').prop('disabled', false); | |
} | |
}); | |
$('#button-cargo').click(function(e){ | |
e.preventDefault(); | |
var ids = []; | |
var selected = $('input[name^=\'selected\']:checked'); | |
$('body').find('#modal-report').html(' '); | |
$('body').find('#modal-body').html(' '); | |
for (i = 0; i < selected.length; i++) { | |
ids.push($(selected[i]).val()); | |
} | |
makePopup('Seçilen Siparişleri Yurtiçi Kargoya Gönder', ids.join(", ") + ' <strong>numaralı sipariş(ler) kargolanacak. Emin misiniz?</strong> <br><br><hr>', 'Test' , 'warning', '---', 'kargo-ac', 'order_id="'+ ids.join(", ") +'"'); | |
return false; | |
}); | |
$('body').on('click', '.btn.kargo-ac', function(e){ | |
e.preventDefault(); | |
$('body').find('#modal-report').html(' '); | |
$('body').find('#modal-body').html(' '); | |
$('body').find('#modal-body').html('<br> Yükleniyor...<br><br>'); | |
var selected = $('input[name^=\'selected\']:checked'); | |
for (i = 0; i < selected.length; i++) { | |
var order_id = $(selected[i]).val(); | |
var href = 'index.php?route=sale/order/kargola&order_id='+ order_id +'&token={{ user_token }}'; | |
$.get( href, function(data, status){ | |
$('body').find('#modal-body').append('<br> <strong>' + order_id + ' işlem sonucu:</strong> '+ data +'<br><hr>'); | |
//console.log("Data: " + data + "\nStatus: " + status +"<br><hr>"); | |
}).fail(function(data, status) { | |
$('body').find('#modal-report').html('İletişim Hatası! Lütfentekrar deneyiniz.'); | |
}); | |
} | |
}); | |
function makePopup(title='!', content='...', lnk='', css='warning', style='', btnstatus='', attrib='') | |
{ | |
if(style=='large') style='width: 95%;max-width: 1000px;'; | |
$('body').find('#modal-box').remove(); | |
var html = '<div id="modal-box" class="modal fade" tabindex="-1" role="dialog">'; | |
html += ' <div class="modal-dialog" style="'+style+'">'; | |
html += ' <div class="modal-content">'; | |
html += ' <div class="modal-header">'; | |
html += ' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'; | |
html += ' <h4 id="modal-title" class="modal-title">' + title + '</h4>'; | |
html += ' </div>'; | |
html += ' <div id="modal-body" style="" class="modal-body">'+content+'</div>'; | |
html += ' <div class="modal-footer">'; | |
if(lnk!='')html += ' <a id="btn-accept" '+btnstatus+' href="'+lnk+'" '+attrib+' class="btn btn-primary '+ btnstatus +'"><i class="fa fa-send"></i> Yurtiçi Kargoya Gönder</a>'; | |
html += ' <button class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i> Vazgeç</button>'; | |
html += ' <div id="modal-report"></div></div>'; | |
html += ' </div'; | |
html += ' </div>'; | |
html += '</div>'; | |
$('body').append(html); | |
$('#modal-box').modal({ | |
backdrop: 'static', | |
keyboard: false | |
}); | |
$('#modal-box').on('shown.bs.modal', function (e) { | |
var inputs = $('body').find('input.barcode'); | |
if(inputs.get(0) != undefined) | |
{ | |
inputs.get(0).focus(); | |
} | |
}) | |
$('body').find('#modal-report').html(''); | |
} | |
</script> | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/controller/sale/order.php"> | |
<operation> | |
<search><![CDATA[ | |
public function index() | |
]]></search> | |
<add position="before"><![CDATA[ | |
function kargola() | |
{ | |
// require_once(modification(DIR_SYSTEM . 'library/barcodegenerator.php')); | |
require_once(DIR_SYSTEM . 'library/barcodegenerator.php'); | |
$barcodegenerator = new BarcodeGenerator(); | |
if($this->request->get['order_id']) | |
{ | |
$order_id = $this->request->get['order_id']; | |
} else { | |
$order_id = false; | |
} | |
if ($order_id) | |
{ | |
$this->load->model('sale/order'); | |
$order_info = $this->model_sale_order->getOrder($order_id); | |
} else { | |
die('Sipariş no alınamadı.'); | |
} | |
if($order_info) | |
{ | |
$kargo_status_id = $this->config->get('config_kargo_status_id'); | |
$firma = $this->config->get('config_kargo_firma'); | |
if(!$firma){ | |
$firma='YURTICI'; | |
} | |
$result = $this->$firma($order_info); | |
$cargoid = 1000000000000+$order_id; | |
if($result==1) | |
{ | |
$this->db->query("UPDATE " . DB_PREFIX . "order SET `order_status_id`='$kargo_status_id' WHERE `order_id`='$order_id'"); | |
$barcode = $barcodegenerator->getBarcode($cargoid, $barcodegenerator::TYPE_CODE_128); | |
die($firma . ' Kargo kaydı açıldı. <br> Barkod: '. $barcode); | |
} else { | |
die("Hata: ". $result); | |
} | |
} else { | |
die('Sipariş bilgisi alınamadı.'); | |
} | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search position="before"><![CDATA[ | |
$vouchers = $this->model_sale_order->getOrderVouchers($order_id) | |
]]></search> | |
<add><![CDATA[ | |
$cargoid= 1000000000000+$order_id; | |
$barcode = $barcodegenerator->getBarcode($cargoid, $barcodegenerator::TYPE_CODE_128); | |
]]></add> | |
</operation> | |
<operation> | |
<search position="after"><![CDATA[ $total_data, ]]></search> | |
<add><![CDATA[ 'barcode' => $barcode,]]></add> | |
</operation> | |
<operation> | |
<search position="after"><![CDATA[ | |
public function invoice() | |
]]></search> | |
<add><![CDATA[ | |
require_once(modification(DIR_SYSTEM . 'library/barcodegenerator.php')); | |
$barcodegenerator = new BarcodeGenerator(); | |
]]></add> | |
</operation> | |
</file> | |
</modification> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment