Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions admin/currency/currency.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
$conn=mysqli_connect("localhost", "kasw_admin_opencart", "admin@123", "kasw_opencart", 3306);
if(isset($_POST['currency-status'])!='' )
{

$date = date('Y/m/d H:i:s');

$cur_status=$_POST['currency-status'];
if($cur_status==1)
{
$select = "SELECT * FROM oc_currency WHERE `code`='SEK'";
$check_data=mysqli_query($conn,$select);
$rowcount=mysqli_num_rows($check_data);
if($rowcount==1)
{
$update = "UPDATE `oc_currency` SET `status` = '1' WHERE `code`='SEK'";
$update_currency=mysqli_query($conn,$update);

if($update_currency)
{
echo 'sucessfully updated the setting';
}else{
echo 'error';
}
}elseif($rowcount==0){
$sql = "INSERT INTO `oc_currency` (`title`, `code`, `symbol_left`, `symbol_right`, `decimal_place`, `value`, `status`, `date_modified`) VALUES ('Swedish krona', 'SEK', 'kr', '', '1', '1', '1', '$date')";
$insert=mysqli_query($conn,$sql);

if($insert)
{
echo 'sucessfully Added the setting';
}else{
echo 'error';
}
}

}
if($cur_status==0)
{
$update = "UPDATE `oc_currency` SET `status` = '0' WHERE `code`='SEK'";
$update_currency=mysqli_query($conn,$update);

if($update_currency)
{
echo 'sucessfully updated the setting';
}else{
echo 'error';
}
}
}

?>
52 changes: 51 additions & 1 deletion admin/view/template/extension/module/bmcheckout/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
class="form-control" />
</div>
</div>

<div class="form-group">
<label class="col-sm-2 control-label" for="input-status">{{ entry_enable_logging_bm_requests }}</label>
<div class="col-sm-10">
Expand All @@ -258,14 +259,63 @@
</div>
</div>
</form>



</div>
</div>


<form id="custom-module-setting" method="POST">




<div class="form-group">
<label class="col-sm-2 control-label" for="currency-status">Currency setting</label>
<div class="col-sm-10">
<select name="currency-status" id="currency-status" class="form-control">

<option value="1" selected="selected">{{ text_enabled }}</option>
<option value="0">{{ text_disabled }}</option>

</select>
</div>
</div>

</form>
<button name="add_currency" value="add_currency">save</button>
{{ info_block }}
</div>
</div>
{{ footer }}
<script type="text/javascript">
$(document).ready(function() {
$.fn.pushEventsSwitcher.init();


});
</script>
</script>
<script>
$(document).ready(function() {
$('button[name="add_currency"]').click(function(){

var form= $("#custom-module-setting");
var name=$('#input-title').val();
$.ajax({
type:"POST",
url: "/admin/currency/currency.php",
data:form.serialize(),
success: function(response){
alert(response);
}
});

});
});
</script>
<style>
button[name="add_currency"] {
margin: 10px;
}
</style>
8 changes: 4 additions & 4 deletions system/library/encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ public static function toUTF8($text)
$max = strlen($text);
$buf = "";
for($i = 0; $i < $max; $i++){
$c1 = $text{$i};
$c1 = substr($text, $i, 1);
if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already
$c2 = $i+1 >= $max? "\x00" : $text{$i+1};
$c3 = $i+2 >= $max? "\x00" : $text{$i+2};
$c4 = $i+3 >= $max? "\x00" : $text{$i+3};
$c2 = $i+1 >= $max? "\x00" : substr($text, $i+1, 1);
$c3 = $i+2 >= $max? "\x00" : substr($text, $i+2, 1);
$c4 = $i+3 >= $max? "\x00" : substr($text, $i+3, 1);
if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8
if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already
$buf .= $c1 . $c2;
Expand Down