Upload Logo For PDF Reports
This commit is contained in:
parent
51416626fb
commit
1b15da5c04
@ -33,6 +33,63 @@ class File
|
||||
rmdir($path);
|
||||
}
|
||||
|
||||
public static function resizeCropImage($source_file, $dst_dir, $max_width, $max_height, $quality = 80)
|
||||
{
|
||||
$imgsize = getimagesize($source_file);
|
||||
$width = $imgsize[0];
|
||||
$height = $imgsize[1];
|
||||
$mime = $imgsize['mime'];
|
||||
|
||||
switch ($mime) {
|
||||
case 'image/gif':
|
||||
$image_create = "imagecreatefromgif";
|
||||
$image = "imagegif";
|
||||
break;
|
||||
|
||||
case 'image/png':
|
||||
$image_create = "imagecreatefrompng";
|
||||
$image = "imagepng";
|
||||
$quality = 7;
|
||||
break;
|
||||
|
||||
case 'image/jpeg':
|
||||
$image_create = "imagecreatefromjpeg";
|
||||
$image = "imagejpeg";
|
||||
$quality = 80;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($max_width == 0) {
|
||||
$max_width = $width;
|
||||
}
|
||||
|
||||
if ($max_height == 0) {
|
||||
$max_height = $height;
|
||||
}
|
||||
|
||||
$widthRatio = $max_width / $width;
|
||||
$heightRatio = $max_height / $height;
|
||||
$ratio = min($widthRatio, $heightRatio);
|
||||
$nwidth = (int)$width * $ratio;
|
||||
$nheight = (int)$height * $ratio;
|
||||
|
||||
$dst_img = imagecreatetruecolor($nwidth, $nheight);
|
||||
$white = imagecolorallocate($dst_img, 255, 255, 255);
|
||||
imagefill($dst_img, 0, 0, $white);
|
||||
$src_img = $image_create($source_file);
|
||||
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
|
||||
|
||||
$image($dst_img, $dst_dir, $quality);
|
||||
|
||||
if ($dst_img) imagedestroy($dst_img);
|
||||
if ($src_img) imagedestroy($src_img);
|
||||
return file_exists($dst_dir);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* file path fixer
|
||||
|
@ -17,6 +17,12 @@ switch ($action) {
|
||||
if ($admin['user_type'] != 'Admin') {
|
||||
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
|
||||
}
|
||||
if (file_exists('system/uploads/logo.png')) {
|
||||
$logo = 'system/uploads/logo.png?' . time();
|
||||
} else {
|
||||
$logo = 'system/uploads/logo.default.png';
|
||||
}
|
||||
$ui->assign('logo', $logo);
|
||||
run_hook('view_app_settings'); #HOOK
|
||||
$ui->display('app-settings.tpl');
|
||||
break;
|
||||
@ -219,8 +225,17 @@ switch ($action) {
|
||||
$user_notification_payment = _post('user_notification_payment');
|
||||
$address = _post('address');
|
||||
$tawkto = _post('tawkto');
|
||||
$radius_mode = _post('radius_mode')*1;
|
||||
$radius_mode = _post('radius_mode') * 1;
|
||||
run_hook('save_settings'); #HOOK
|
||||
|
||||
|
||||
if ($_FILES['logo']['error'] > 0) {
|
||||
r2(U . 'settings/app', 'e', 'Failed to process logo');
|
||||
}
|
||||
if (!empty($_FILES['logo']['name'])) {
|
||||
if (file_exists('system/uploads/logo.png')) unlink('system/uploads/logo.png');
|
||||
File::resizeCropImage($_FILES['logo']['tmp_name'], 'system/uploads/logo.png', 1078, 200, 100);
|
||||
}
|
||||
if ($company == '') {
|
||||
r2(U . 'settings/app', 'e', $_L['All_field_is_required']);
|
||||
} else {
|
||||
@ -239,10 +254,10 @@ switch ($action) {
|
||||
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'CompanyFooter')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $footer;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'CompanyFooter';
|
||||
$d->value = $footer;
|
||||
@ -250,10 +265,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'disable_voucher')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $disable_voucher;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'disable_voucher';
|
||||
$d->value = $disable_voucher;
|
||||
@ -261,10 +276,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'enable_balance')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $enable_balance;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'enable_balance';
|
||||
$d->value = $enable_balance;
|
||||
@ -272,10 +287,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'allow_balance_transfer')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $allow_balance_transfer;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'allow_balance_transfer';
|
||||
$d->value = $allow_balance_transfer;
|
||||
@ -283,10 +298,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'minimum_transfer')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $minimum_transfer;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'minimum_transfer';
|
||||
$d->value = $minimum_transfer;
|
||||
@ -294,10 +309,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'telegram_bot')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $telegram_bot;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'telegram_bot';
|
||||
$d->value = $telegram_bot;
|
||||
@ -305,10 +320,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'telegram_target_id')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $telegram_target_id;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'telegram_target_id';
|
||||
$d->value = $telegram_target_id;
|
||||
@ -316,10 +331,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'sms_url')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $sms_url;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'sms_url';
|
||||
$d->value = $sms_url;
|
||||
@ -327,10 +342,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'wa_url')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $wa_url;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'wa_url';
|
||||
$d->value = $wa_url;
|
||||
@ -338,10 +353,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_expired')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $user_notification_expired;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'user_notification_expired';
|
||||
$d->value = $user_notification_expired;
|
||||
@ -349,10 +364,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_reminder')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $user_notification_reminder;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'user_notification_reminder';
|
||||
$d->value = $user_notification_reminder;
|
||||
@ -360,10 +375,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'user_notification_payment')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $user_notification_payment;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'user_notification_payment';
|
||||
$d->value = $user_notification_payment;
|
||||
@ -371,10 +386,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'tawkto')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $tawkto;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'tawkto';
|
||||
$d->value = $tawkto;
|
||||
@ -382,10 +397,10 @@ switch ($action) {
|
||||
}
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'radius_mode')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $radius_mode;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'radius_mode';
|
||||
$d->value = $radius_mode;
|
||||
@ -436,10 +451,10 @@ switch ($action) {
|
||||
|
||||
|
||||
$d = ORM::for_table('tbl_appconfig')->where('setting', 'country_code_phone')->find_one();
|
||||
if($d){
|
||||
if ($d) {
|
||||
$d->value = $country_code_phone;
|
||||
$d->save();
|
||||
}else{
|
||||
} else {
|
||||
$d = ORM::for_table('tbl_appconfig')->create();
|
||||
$d->setting = 'country_code_phone';
|
||||
$d->value = $country_code_phone;
|
||||
@ -509,9 +524,9 @@ switch ($action) {
|
||||
r2(U . "dashboard", 'e', $_L['Do_Not_Access']);
|
||||
}
|
||||
run_hook('view_notifications'); #HOOK
|
||||
if(file_exists("system/uploads/notifications.json")){
|
||||
if (file_exists("system/uploads/notifications.json")) {
|
||||
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.json'), true));
|
||||
}else{
|
||||
} else {
|
||||
$ui->assign('_json', json_decode(file_get_contents('system/uploads/notifications.default.json'), true));
|
||||
}
|
||||
$ui->assign('_default', json_decode(file_get_contents('system/uploads/notifications.default.json'), true));
|
||||
|
@ -384,3 +384,4 @@ $_L['Send_Balance'] = 'Send Balance';
|
||||
$_L['Received_Balance'] = 'Received Balance';
|
||||
$_L['Minimum_Balance_Transfer'] = 'Minimum Balance Transfer';
|
||||
$_L['Minimum_Transfer'] = 'Minimum Transfer';
|
||||
$_L['Company_Logo'] = 'Company Logo';
|
||||
|
@ -1,6 +1,6 @@
|
||||
{include file="sections/header.tpl"}
|
||||
|
||||
<form class="form-horizontal" method="post" role="form" action="{$_url}settings/app-post">
|
||||
<form class="form-horizontal" method="post" role="form" action="{$_url}settings/app-post" enctype="multipart/form-data">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="panel panel-primary panel-hovered panel-stacked mb30">
|
||||
@ -17,10 +17,19 @@
|
||||
<div class="col-md-6">
|
||||
<input type="text" required class="form-control" id="company" name="company"
|
||||
value="{$_c['CompanyName']}">
|
||||
|
||||
</div>
|
||||
<span class="help-block col-md-4">{$_L['App_Name_Help_Text']}</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Company Logo')}</label>
|
||||
<div class="col-md-6">
|
||||
<input type="file" class="form-control" id="logo" name="logo" accept="image/*">
|
||||
<span class="help-block">For PDF Reports | Beset size 1078 x 200 | uploaded image will be autosize</span>
|
||||
</div>
|
||||
<span class="help-block col-md-4">
|
||||
<a href="./{$logo}" target="_blank"><img src="./{$logo}" height="48" alt="logo for PDF"></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{Lang::T('Company Footer')}</label>
|
||||
<div class="col-md-6">
|
||||
|
Loading…
x
Reference in New Issue
Block a user