I download this Extensions - Customer Image Management
I am really looking forward to this extension, because I need customers photo, ID photo, Store Picture or Online Shop Screen shot to verify their membership as a Dealer.
I actually look for same extension, I am willing to pay but extensions available is so complicated.
This file contain
controller file
language file
View file
and
VQMOD file
This is FREE MODULES from EXTENSION PAGE of Opencart.com
I install this but I got ERROR 500. which has an error with the codes, hoping someone can help me whats wrong to the codes.
Thank you so much
heres the code in catalog/controller/account/image.php
Code: Select all
<?php
class ControllerAccountImage extends Controller {
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/account', '', 'SSL');
$this->response->redirect($this->url->link('account/login', '', 'SSL'));
}
$this->language->load('account/image');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home'),
'separator' => false
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_account'),
'href' => $this->url->link('account/account', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_image'),
'href' => $this->url->link('account/image', '', 'SSL'),
'separator' => $this->language->get('text_separator')
);
$this->load->model('account/customer');
$data['heading_title'] = $this->language->get('heading_title');
$data['text_image'] = $this->language->get('text_image');
$data['text_customer_image'] = $this->language->get('text_customer_image');
$data['text_date_added'] = $this->language->get('text_date_added');
$data['text_no_image'] = $this->language->get('text_no_image');
$data['column_image'] = $this->language->get('column_image');
$data['column_date_added'] = $this->language->get('column_date_added');
$data['entry_upload'] = $this->language->get('entry_upload');
$data['button_upload'] = $this->language->get('button_upload');
$data['button_back'] = $this->language->get('button_back');
$data['button_continue'] = $this->language->get('button_continue');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
//Added By Tirthra
$data['images'] = array();
$image_total = $this->model_account_customer->getTotalImages($this->customer->getId());
$customer_images = $this->model_account_customer->getImagesByCustomerId($this->customer->getId());
$this->load->model('tool/image');
foreach($customer_images as $customer_image){
$data['images'][] = array(
'image' => $this->model_tool_image->resize($customer_image['customer_image'], 100,100),
'date_added' => date('d/m/y', strtotime($customer_image['date_added']))
);
}
//End Here.
$pagination = new Pagination();
$pagination->total = $image_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->url = $this->url->link('account/image', 'page={page}', 'SSL');
$data['pagination'] = $pagination->render();
$data['results'] = sprintf($this->language->get('text_pagination'), ($image_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($image_total - 10)) ? $image_total : ((($page - 1) * 10) + 10), $image_total, ceil($image_total / 10));
$data['continue'] = $this->url->link('account/account', '', 'SSL');
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/image.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/account/image.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/account/image.tpl', $data));
}
}
}
public function upload() {
$this->language->load('account/image');
$json = array();
if (!empty($this->request->files['file']['name'])) {
$filename = basename(preg_replace('/[^a-zA-Z0-9\.\-\s+]/', '', html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8')));
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
$json['error'] = $this->language->get('error_filename');
}
$allowed = array();
$filetypes = explode("\n", $this->config->get('config_image_ext_allowed'));
foreach ($filetypes as $filetype) {
$allowed[] = trim($filetype);
}
if (!in_array(substr(strrchr($filename, '.'), 1), $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}
$allowed = array(
'.jpg',
'.jpeg',
'.gif',
'.png',
'.flv'
);
if (!in_array(strtolower(strrchr($filename, '.')), $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}
if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
$json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']);
}
} else {
$json['error'] = $this->language->get('error_upload');
}
if (!$json) {
if (is_uploaded_file($this->request->files['file']['tmp_name']) && file_exists($this->request->files['file']['tmp_name'])) {
$file = md5(mt_rand()). "." . basename($filename);
// Hide the uploaded file name so people can not link to it directly.
$json['file'] = 'data/customerimages/'. $file;
$data = array();
$data['customer_image'] = 'data/customerimages/'. $file;
$this->load->model('account/customer');
move_uploaded_file($this->request->files['file']['tmp_name'], DIR_IMAGE . '/data/customerimages/'. $file);
$this->model_account_customer->addCustomerImage($data);
}
$json['success'] = $this->language->get('text_upload');
}
$this->response->setOutput(json_encode($json));
}
?>
In language file catalog/language/english/account/image.php
Code: Select all
<?php
// Heading
$_['heading_title'] = 'View Images';
// Column
$_['column_date_added'] = 'Date Added';
$_['column_image'] = 'Image Account';
// Text
$_['text_image'] = 'Image Account';
$_['text_account'] = 'Account';
$_['text_customer_image'] = 'Customer Image';
$_['text_date_added'] = 'Date Added';
$_['text_no_image'] = 'There are no images in your account';
$_['text_upload'] = 'Your file was successfully uploaded!';
$_['entry_upload'] = 'Upload Image:';
// Error
$_['error_upload'] = 'Upload required!';
$_['error_filename'] = 'Filename must be between 3 and 64 characters!';
$_['error_filetype'] = 'Invalid file type!';
$_['button_upload'] = 'Upload';
$_['text_upload'] = 'Your file was successfully uploaded!';
$_['entry_upload'] = 'Upload Image:';
$_['error_upload'] = 'Upload required!';
$_['error_filename'] = 'Filename must be between 3 and 64 characters!';
$_['error_filetype'] = 'Invalid file type!';
?>
In tpl file catalog/view/theme/default/template/account/image.tpl
Code: Select all
<?php echo $header; ?>
<div class="container">
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
<?php } ?>
</ul>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-lg-6 col-md-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-lg-9 col-md-9'; ?>
<?php } else { ?>
<?php $class = 'col-lg-12 col-md-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
<h2 class="page-heading"><?php echo $heading_title; ?></h2>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left"><?php echo $entry_upload; ?>
<input type="button" value="<?php echo $button_upload; ?>" id="button-upload" class="button">
<input type="hidden" name="customer_image" value="" />
</td>
</tr>
</thead>
</table>
<table class="table table-bordered table-hover">
<thead>
<tr>
<td class="text-left"><?php echo $column_image; ?></td>
<td class="text-left"><?php echo $column_date_added; ?></td>
</tr>
</thead>
<tbody>
<?php if($images) { ?>
<tr>
<th width="50%"><?php echo $text_customer_image; ?></th>
<th><?php echo $text_date_added; ?></th>
</tr>
<?php foreach($images as $image) { ?>
<tr>
<td><img src="<?php echo $image['image']; ?>" /></td>
<td><?php echo $image['date_added']; ?></td>
</tr>
<?php } ?>
<?php }else { ?>
<tr>
<td class="text-center" colspan="3">
<?php echo $text_no_image; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="row">
<div class="col-sm-6 text-left"><?php echo $pagination; ?></div>
<div class="col-sm-6 text-right"><?php echo $results; ?></div>
</div>
<div class="buttons clearfix">
<div class="pull-left"><a href="<?php echo $back; ?>" class="btn"><span><?php echo $button_back; ?></span></a></div>
<div class="pull-right"><button type="submit" class="btn"><span><?php echo $button_save; ?></span></button>
</div>
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<script type="text/javascript" src="catalog/view/javascript/jquery/ajaxupload.js"></script>
<script type="text/javascript"><!--
new AjaxUpload('#button-upload', {
action: 'index.php?route=account/image/upload',
name: 'file',
autoSubmit: true,
responseType: 'json',
onSubmit: function(file, extension) {
$('#button-upload').after('<img src="catalog/view/theme/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
$('#button-upload').attr('disabled', true);
},
onComplete: function(file, json) {
$('#button-upload').attr('disabled', false);
$('.error').remove();
if (json['success']) {
alert(json['success']);
$('input[name=\'customer_image\']').attr('value', json['file']);
location.reload();
}
if (json['error']) {
alert(json['error']);
}
$('.loading').remove();
}
});
//--></script>
<script type="text/javascript" src="catalog/view/javascript/jquery/ajaxupload.js"></script>
<script type="text/javascript"><!--
new AjaxUpload('#button-upload', {
action: 'index.php?route=account/edit/upload',
name: 'file',
autoSubmit: true,
responseType: 'json',
onSubmit: function(file, extension) {
$('#button-upload').after('<img src="catalog/view/theme/default/image/loading.gif" class="loading" style="padding-left: 5px;" />');
$('#button-upload').attr('disabled', true);
},
onComplete: function(file, json) {
$('#button-upload').attr('disabled', false);
$('.error').remove();
if (json['success']) {
alert(json['success']);
$('input[name=\'customer_image\']').attr('value', json['file']);
}
if (json['error']) {
alert(json['error']);
}
$('.loading').remove();
}
});
//--></script>
<?php echo $footer; ?>