| 1 |
<?php |
<?php |
| 2 |
// $Id: uc_turkish_banks.module,v 1.3 2008/06/22 18:46:51 bakyildiz Exp $ |
// $Id: uc_turkish_banks.module,v 1.6 2008/06/22 20:39:58 bakyildiz Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 116 |
return $items; |
return $items; |
| 117 |
} |
} |
| 118 |
|
|
| 119 |
|
/** |
| 120 |
|
* Implementation of hook_perm(). |
| 121 |
|
*/ |
| 122 |
function uc_turkish_banks_perm() { |
function uc_turkish_banks_perm() { |
| 123 |
return array('1' => 'view banks', '1' => 'manage banks'); |
return array('view banks', 'manage banks'); |
| 124 |
} |
} |
| 125 |
|
|
| 126 |
function uc_turkish_banks_instalments_display() { |
function uc_turkish_banks_instalments_display() { |
| 127 |
$cid=arg(5); |
$cid = arg(5); |
| 128 |
$result = db_query("SELECT cid, instalment, instalment_ratio, valid_until FROM {uc_turkish_banks_instalments} where cid = %d ORDER BY instalment", $cid); |
$result = db_query("SELECT cid, instalment, instalment_ratio, valid_until FROM {uc_turkish_banks_instalments} where cid = %d ORDER BY instalment", $cid); |
| 129 |
$rows = array(); |
$rows = array(); |
| 130 |
while ($row = db_fetch_object($result)) { |
while ($row = db_fetch_object($result)) { |
| 135 |
$value = '$'. $row->value; |
$value = '$'. $row->value; |
| 136 |
} |
} |
| 137 |
$rows[] = array( |
$rows[] = array( |
| 138 |
$row->cid, |
$row->cid, |
| 139 |
$row->instalment, |
$row->instalment, |
| 140 |
$row->instalment_ratio, |
$row->instalment_ratio, |
| 141 |
format_date($row->valid_until, 'custom', 'd/m/Y'), |
format_date($row->valid_until, 'custom', 'd/m/Y'), |
| 142 |
l(t('delete'), "admin/store/settings/banks/instalments/$row->cid/$row->instalment/delete")); |
l(t('delete'), "admin/store/settings/banks/instalments/$row->cid/$row->instalment/delete") |
| 143 |
|
); |
| 144 |
} |
} |
| 145 |
|
|
| 146 |
$header = array(array('data' => 'Instalment', 'width' => '10'), 'Ratio', 'Valid Until', 'Ops'); |
$header = array(array('data' => 'Instalment', 'width' => '10'), 'Ratio', 'Valid Until', 'Ops'); |
| 147 |
$output .= theme('table', $header, $rows, array('width' => '100%')); |
$output .= theme('table', $header, $rows, array('width' => '100%')); |
| 148 |
if ($output == null) { |
if ($output == NULL) { |
| 149 |
$output = "<p>There are currently no instalments in the system.</p>"; |
$output = "<p>There are currently no instalments in the system.</p>"; |
| 150 |
} |
} |
| 151 |
$output .= l(t('Add a new instalment'), "admin/store/settings/banks/instalments/add/$cid"); |
$output .= l(t('Add a new instalment'), "admin/store/settings/banks/instalments/add/$cid"); |
| 219 |
*/ |
*/ |
| 220 |
function uc_turkish_banks_instalments_add_form_submit($form_id, $form) { |
function uc_turkish_banks_instalments_add_form_submit($form_id, $form) { |
| 221 |
$valid_until = mktime(23, 59, 59, |
$valid_until = mktime(23, 59, 59, |
| 222 |
$form['valid_until']['month'], |
$form['valid_until']['month'], |
| 223 |
$form['valid_until']['day'], |
$form['valid_until']['day'], |
| 224 |
$form['valid_until']['year'] |
$form['valid_until']['year'] |
| 225 |
); |
); |
| 226 |
$result = db_query("INSERT INTO {uc_turkish_banks_instalments} (cid, instalment, instalment_ratio, valid_until) |
$result = db_query("INSERT INTO {uc_turkish_banks_instalments} (cid, instalment, instalment_ratio, valid_until) |
| 227 |
VALUES (%d, %d, %f, %d)", $form['cid'], $form['instalment'], $form['instalment_ratio'], $valid_until); |
VALUES (%d, %d, %f, %d)", $form['cid'], $form['instalment'], $form['instalment_ratio'], $valid_until); |
| 242 |
$form['cid'] = array('#type' => 'value', '#value' => $cid); |
$form['cid'] = array('#type' => 'value', '#value' => $cid); |
| 243 |
$form['instalment'] = array('#type' => 'value', '#value' => $instalment); |
$form['instalment'] = array('#type' => 'value', '#value' => $instalment); |
| 244 |
return confirm_form($form, |
return confirm_form($form, |
| 245 |
t('Confirm Deletion of instalment %instalment', array('%instalment' => $instalment)), |
t('Confirm Deletion of instalment %instalment', array('%instalment' => $instalment)), |
| 246 |
'admin/store/settings/banks/instalments/'. $cid, |
'admin/store/settings/banks/instalments/'. $cid, |
| 247 |
t('Are you sure?'), |
t('Are you sure?'), |
| 248 |
t('Delete'), |
t('Delete'), |
| 249 |
t('Cancel') |
t('Cancel') |
| 250 |
); |
); |
| 251 |
} |
} |
| 252 |
|
|
| 368 |
'#options' => array( |
'#options' => array( |
| 369 |
'Auth' => t('Auth'), |
'Auth' => t('Auth'), |
| 370 |
'PreAuth' => t('PreAuth'), |
'PreAuth' => t('PreAuth'), |
| 371 |
), |
), |
| 372 |
'#weight' => 1, |
'#weight' => 1, |
| 373 |
'#required' => true, |
'#required' => true, |
| 374 |
); |
); |
| 416 |
*/ |
*/ |
| 417 |
function uc_turkish_banks_add_form_submit($form_id, $form) { |
function uc_turkish_banks_add_form_submit($form_id, $form) { |
| 418 |
$valid_until = mktime(23, 59, 59, |
$valid_until = mktime(23, 59, 59, |
| 419 |
$form['valid_until']['month'], |
$form['valid_until']['month'], |
| 420 |
$form['valid_until']['day'], |
$form['valid_until']['day'], |
| 421 |
$form['valid_until']['year'] |
$form['valid_until']['year'] |
| 422 |
); |
); |
| 423 |
|
|
| 424 |
if (!isset($form['cid'])) { |
if (!isset($form['cid'])) { |
| 425 |
|
if (db_query("INSERT INTO {uc_turkish_banks} (bankname, clientid, username, password, bankurl, storekey, processtype, cardname, valid_until) |
| 426 |
if (db_query("INSERT INTO {uc_turkish_banks} (bankname,clientid,username,password,bankurl,storekey,processtype,cardname,valid_until) |
VALUES ('%s','%s','%s','%s','%s','%s','%s','%s', '%d')", |
| 427 |
VALUES ('%s','%s','%s','%s','%s','%s','%s','%s', '%d')", |
$form['bankname'], $form['clientid'], $form['username'], $form['password'], $form['bankurl'], $form['storekey'], $form['processtype'], $form['cardname'], $valid_until)) |
| 428 |
$form['bankname'], $form['clientid'], $form['username'], $form['password'], $form['bankurl'], $form['storekey'], $form['processtype'], $form['cardname'], $valid_until |
{ |
|
)) { |
|
| 429 |
$message = "New bank {$form['name']} added succesfully"; |
$message = "New bank {$form['name']} added succesfully"; |
| 430 |
} |
} |
| 431 |
else { |
else { |
| 434 |
} |
} |
| 435 |
else { |
else { |
| 436 |
// Otherwise we try to update the coupon with matching coupon id |
// Otherwise we try to update the coupon with matching coupon id |
| 437 |
if (db_query("UPDATE {uc_turkish_banks} SET bankname = '%s', clientid = '%s',username = '%s',password = '%s',bankurl = '%s',storekey = '%s',processtype = '%s',cardname = '%s',valid_until = %d WHERE cid = %d", |
if (db_query("UPDATE {uc_turkish_banks} SET bankname = '%s', clientid = '%s', username = '%s', password = '%s', bankurl = '%s', storekey = '%s', processtype = '%s', cardname = '%s', valid_until = %d WHERE cid = %d", |
| 438 |
$form['bankname'], $form['clientid'], $form['username'], $form['password'], $form['bankurl'], $form['storekey'], $form['processtype'], $form['cardname'], $valid_until, $form['cid'])) { |
$form['bankname'], $form['clientid'], $form['username'], $form['password'], $form['bankurl'], $form['storekey'], $form['processtype'], $form['cardname'], $valid_until, $form['cid'])) |
| 439 |
|
{ |
| 440 |
$message = "Bank updated succssfully"; |
$message = "Bank updated succssfully"; |
| 441 |
} |
} |
| 442 |
else { |
else { |
| 465 |
function uc_turkish_banks_delete_confirm($cid) { |
function uc_turkish_banks_delete_confirm($cid) { |
| 466 |
$form['cid'] = array('#type' => 'value', '#value' => $cid); |
$form['cid'] = array('#type' => 'value', '#value' => $cid); |
| 467 |
return confirm_form($form, |
return confirm_form($form, |
| 468 |
t('Confirm Deletion of Bank %cid', array('%cid' => $cid)), |
t('Confirm Deletion of Bank %cid', array('%cid' => $cid)), |
| 469 |
'admin/store/settings/banks', |
'admin/store/settings/banks', |
| 470 |
t('Are you sure ?'), |
t('Are you sure ?'), |
| 471 |
t('Delete'), |
t('Delete'), |
| 472 |
t('Cancel') |
t('Cancel') |
| 473 |
); |
); |
| 474 |
} |
} |
| 475 |
|
|
| 493 |
case 'save': |
case 'save': |
| 494 |
list($bank_temp, $amount_temp, $bank_cid, $taksit)=explode('|', $_SESSION['taksit']); |
list($bank_temp, $amount_temp, $bank_cid, $taksit)=explode('|', $_SESSION['taksit']); |
| 495 |
//print "TEST:".$_SESSION['bank_cid'].' '. $bank.' '.$amount ; |
//print "TEST:".$_SESSION['bank_cid'].' '. $bank.' '.$amount ; |
| 496 |
db_query("UPDATE {uc_order_line_items} SET title = '%s', amount = %f, weight = 0 WHERE order_id = %d AND type ='instalment'", $bank_temp, $amount_temp, $arg1->order_id); |
db_query("UPDATE {uc_order_line_items} SET title = '%s', amount = %f, weight = 0 WHERE order_id = %d AND type = 'instalment'", $bank_temp, $amount_temp, $arg1->order_id); |
| 497 |
if (db_affected_rows() == 0) { |
if (db_affected_rows() == 0) { |
| 498 |
db_query("INSERT INTO {uc_order_line_items} (order_id, type, title, amount, weight) VALUES (%d, 'instalment', '%s', %f, 0)", $arg1->order_id, $bank_temp, $amount_temp); |
db_query("INSERT INTO {uc_order_line_items} (order_id, type, title, amount, weight) VALUES (%d, 'instalment', '%s', %f, 0)", $arg1->order_id, $bank_temp, $amount_temp); |
| 499 |
} |
} |
| 613 |
$result = db_query("SELECT * FROM {uc_turkish_banks} where valid_until > CURDATE() ORDER BY bankname"); |
$result = db_query("SELECT * FROM {uc_turkish_banks} where valid_until > CURDATE() ORDER BY bankname"); |
| 614 |
if (db_affected_rows() > 0) { |
if (db_affected_rows() > 0) { |
| 615 |
$options = array(); |
$options = array(); |
| 616 |
$select2='<select NAME="taksit" ID="taksit" class="combobox" onChange="instalment(this)">' |
$select2 = '<select NAME="taksit" ID="taksit" class="combobox" onChange="instalment(this)">' |
| 617 |
.'<option selected>Taksitler...</option>' |
.'<option selected>Taksitler...</option>' |
| 618 |
.'</select>'; |
.'</select>'; |
| 619 |
$select1='<select NAME="banka" ID="banka" onChange="subselect(this.options.selectedIndex)" ="combobox">'; |
$select1 = '<select NAME="banka" ID="banka" onChange="subselect(this.options.selectedIndex)" ="combobox">'; |
| 620 |
$select1.='<option selected>Bankalar...</option>'; |
$select1 .= '<option selected>Bankalar...</option>'; |
| 621 |
$outer=1; |
$outer = 1; |
| 622 |
while ($row = db_fetch_array($result)) { |
while ($row = db_fetch_array($result)) { |
| 623 |
$select1 .= '<option value="'. $outer .'">'. $row['bankname'] .'</option>'; |
$select1 .= '<option value="'. $outer .'">'. $row['bankname'] .'</option>'; |
| 624 |
$select2Opt .= 'group[0]['. $outer .']=new Option("option'. $outer .'");'; |
$select2Opt .= 'group[0]['. $outer .']=new Option("option'. $outer .'");'; |
| 625 |
$inner=0; |
$inner = 0; |
| 626 |
$select3OptLst .= 'group['. $outer .']['. $inner++ .']=new Option("Taksitler");'; |
$select3OptLst .= 'group['. $outer .']['. $inner++ .']=new Option("Taksitler");'; |
| 627 |
|
|
| 628 |
$cid_ins = $row['cid']; |
$cid_ins = $row['cid']; |
| 629 |
$result_ins = db_query("SELECT * FROM {uc_turkish_banks_instalments} where cid = %d and valid_until > CURDATE() ORDER BY instalment", $cid_ins); |
$result_ins = db_query("SELECT * FROM {uc_turkish_banks_instalments} where cid = %d and valid_until > CURDATE() ORDER BY instalment", $cid_ins); |
| 630 |
while ($row_ins = db_fetch_array($result_ins)) { |
while ($row_ins = db_fetch_array($result_ins)) { |
| 631 |
$new= $row_ins['instalment_ratio'] * $subtotal; |
$new = $row_ins['instalment_ratio'] * $subtotal; |
| 632 |
$select_text = $row_ins['instalment'] ." taksit +". uc_currency_format($new); |
$select_text = $row_ins['instalment'] ." taksit +". uc_currency_format($new); |
| 633 |
$select_value= $row['cardname'] .' ile '. $row_ins['instalment'] .' taksit'.'|'. $new .'|'. $row['cid'] .'|'. $i; |
$select_value = $row['cardname'] .' ile '. $row_ins['instalment'] .' taksit'.'|'. $new .'|'. $row['cid'] .'|'. $i; |
| 634 |
$select3OptLst .= 'group['. $outer. ']['. $inner++ .']=new Option("'. $select_text .'","'. $select_value .'");'; |
$select3OptLst .= 'group['. $outer .']['. $inner++ .']=new Option("'. $select_text .'","'. $select_value .'");'; |
| 635 |
} |
} |
| 636 |
/* |
/* |
| 637 |
for ($i=2;$i<=18;$i++) |
for ($i=2;$i<=18;$i++) |
| 647 |
*/ |
*/ |
| 648 |
$outer++; |
$outer++; |
| 649 |
} |
} |
| 650 |
$select1.='</select>'; |
$select1 .= '</select>'; |
| 651 |
|
|
| 652 |
$details = '<div class="form-item"><b>'. t('Select instalment:') .'</b>' |
$details = '<div class="form-item"><b>'. t('Select instalment:') .'</b>' |
| 653 |
. $select1 |
. $select1 |
| 888 |
'#options' => array( |
'#options' => array( |
| 889 |
'Auth' => t('Satis'), |
'Auth' => t('Satis'), |
| 890 |
'PreAuth' => t('On Otorizasyon'), |
'PreAuth' => t('On Otorizasyon'), |
| 891 |
), |
), |
| 892 |
'#default_value' => variable_get('banks_transaction_mode', 'Auth'), |
'#default_value' => variable_get('banks_transaction_mode', 'Auth'), |
| 893 |
); |
); |
| 894 |
$form['banks_settings']['banks_transaction_mode'] = array( |
$form['banks_settings']['banks_transaction_mode'] = array( |
| 898 |
'#options' => array( |
'#options' => array( |
| 899 |
'uretim' => t('Uretim'), |
'uretim' => t('Uretim'), |
| 900 |
'test' => t('Test'), |
'test' => t('Test'), |
| 901 |
), |
), |
| 902 |
'#default_value' => variable_get('banks_transaction_mode', 'test'), |
'#default_value' => variable_get('banks_transaction_mode', 'test'), |
| 903 |
); |
); |
| 904 |
return $form; |
return $form; |
| 911 |
} |
} |
| 912 |
|
|
| 913 |
// XML request sablonu |
// XML request sablonu |
| 914 |
$request= "DATA=<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>". |
$request = "DATA=<?xml version=\"1.0\" encoding=\"ISO-8859-9\"?>". |
| 915 |
"<CC5Request>". |
"<CC5Request>". |
| 916 |
"<Name>{NAME}</Name>". |
"<Name>{NAME}</Name>". |
| 917 |
"<Password>{PASSWORD}</Password>". |
"<Password>{PASSWORD}</Password>". |
| 959 |
"<Extra></Extra>". |
"<Extra></Extra>". |
| 960 |
"</CC5Request>"; |
"</CC5Request>"; |
| 961 |
|
|
| 962 |
$taksit=0; |
$taksit = 0; |
| 963 |
|
|
| 964 |
$request = str_replace("{NAME}", variable_get('banks_settings_name', ''), $request); |
$request = str_replace("{NAME}", variable_get('banks_settings_name', ''), $request); |
| 965 |
$request = str_replace("{PASSWORD}", variable_get('banks_settings_password', ''), $request); |
$request = str_replace("{PASSWORD}", variable_get('banks_settings_password', ''), $request); |
| 1009 |
$err_msg = ""; |
$err_msg = ""; |
| 1010 |
$host_msg = ""; |
$host_msg = ""; |
| 1011 |
|
|
| 1012 |
$response_tag="Response"; |
$response_tag = "Response"; |
| 1013 |
$posf = strpos($result, "<". $response_tag .">"); |
$posf = strpos($result, "<". $response_tag .">"); |
| 1014 |
$posl = strpos($result, "</". $response_tag .">"); |
$posl = strpos($result, "</". $response_tag .">"); |
| 1015 |
$posf = $posf+ strlen($response_tag) +2 ; |
$posf = $posf+ strlen($response_tag) +2 ; |
| 1016 |
$response = substr($result, $posf, $posl - $posf); |
$response = substr($result, $posf, $posl - $posf); |
| 1017 |
|
|
| 1018 |
$response_tag="OrderId"; |
$response_tag = "OrderId"; |
| 1019 |
$posf = strpos($result, "<". $response_tag .">"); |
$posf = strpos($result, "<". $response_tag .">"); |
| 1020 |
$posl = strpos($result, "</". $response_tag .">"); |
$posl = strpos($result, "</". $response_tag .">"); |
| 1021 |
$posf = $posf+ strlen($response_tag) +2; |
$posf = $posf+ strlen($response_tag) +2; |
| 1022 |
$order_id = substr($result, $posf, $posl - $posf); |
$order_id = substr($result, $posf, $posl - $posf); |
| 1023 |
|
|
| 1024 |
$response_tag="AuthCode"; |
$response_tag = "AuthCode"; |
| 1025 |
$posf = strpos($result, "<". $response_tag .">"); |
$posf = strpos($result, "<". $response_tag .">"); |
| 1026 |
$posl = strpos($result, "</". $response_tag .">"); |
$posl = strpos($result, "</". $response_tag .">"); |
| 1027 |
$posf = $posf+ strlen($response_tag) +2; |
$posf = $posf+ strlen($response_tag) +2; |
| 1028 |
$auth_code = substr($result, $posf, $posl - $posf); |
$auth_code = substr($result, $posf, $posl - $posf); |
| 1029 |
|
|
| 1030 |
$response_tag="ProcReturnCode"; |
$response_tag = "ProcReturnCode"; |
| 1031 |
$posf = strpos($result, "<". $response_tag .">"); |
$posf = strpos($result, "<". $response_tag .">"); |
| 1032 |
$posl = strpos($result, "</". $response_tag .">"); |
$posl = strpos($result, "</". $response_tag .">"); |
| 1033 |
$posf = $posf+ strlen($response_tag) +2; |
$posf = $posf+ strlen($response_tag) +2; |
| 1034 |
$proc_return_code = substr($result, $posf, $posl - $posf); |
$proc_return_code = substr($result, $posf, $posl - $posf); |
| 1035 |
|
|
| 1036 |
$response_tag="ErrMsg"; |
$response_tag = "ErrMsg"; |
| 1037 |
$posf = strpos($result, "<". $response_tag .">"); |
$posf = strpos($result, "<". $response_tag .">"); |
| 1038 |
$posl = strpos($result, "</". $response_tag .">"); |
$posl = strpos($result, "</". $response_tag .">"); |
| 1039 |
$posf = $posf+ strlen($response_tag) +2; |
$posf = $posf+ strlen($response_tag) +2; |