Post by mash0028 » Sat Nov 14, 2015 3:37 pm

Hello,
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; ?>
Last edited by mash0028 on Sat Nov 14, 2015 3:43 pm, edited 2 times in total.

New member

Posts

Joined
Fri Jul 24, 2015 3:36 pm

Post by mash0028 » Sat Nov 14, 2015 3:39 pm

It also comes with VQMOD FILE.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <name>upload_image_in_Account</name>
    <code>UPIMGA0100</code>
    <version>1.0.0</version>
    <author>mash0028</author>
    <vqmver><![CDATA[2.5.1]]></vqmver>

<file path="admin/controller/sale/customer.php">
        <operation>
<search><![CDATA[
$data['tab_ip'] = $this->language->get('tab_ip');
        ]]></search>
        <add position="after"><![CDATA[
$data['tab_image'] = $this->language->get('tab_image');
            ]]></add>
        </operation>

        <operation>
<search><![CDATA[$data['column_total'] = $this->language->get('column_total');]]></search>
            <add position="after"><![CDATA[
$data['column_image'] = $this->language->get('column_image');
            ]]></add>
        </operation>

        <operation>
      <search><![CDATA[// Custom Fields]]></search>
            <add position="before"><![CDATA[
$data['images'] = array();

if (!empty($customer_info)) {
  $results = $this->model_sale_customer->getImagesByCustomerId($this->request->get['customer_id']);

  $total_images = $this->model_sale_customer->getTotalImagesById($this->request->get['customer_id']);

  $this->load->model('tool/image');

  foreach ($results as $result) {
    $this->data['images'][] = array(
      'customer_image' => $this->model_tool_image->resize($result['customer_image'], '100', '100'),
      'total'      => $total_images,
      'date_added' => date('d/m/y', strtotime($result['date_added']))
    );
  }
}

            ]]></add>
        </operation>
</file>


<file path="admin/language/english/sale/customer.php">
        <operation>
<search><![CDATA[
$_['column_action']         = 'Action';
]]></search>
        <add position="after"><![CDATA[
$_['column_image']          = 'Customer Image';
            ]]></add>
        </operation>
</file>

<file path="admin/model/sale/customer.php">
		<operation info="Add Text">
		<search position="bottom"></search>
			<add><![CDATA[
public function getImagesByCustomerId($customer_id) {
  $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_image WHERE customer_id = '" . (int)$customer_id . "'");

  return $query->rows;
}

public function getTotalImagesById($customer_id) {
  $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_image WHERE customer_id = '" . (int)$customer_id . "'");

  return $query->row['total'];
}

public function getTotalImages($customer_id) {
  $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_image WHERE customer_id = '" . (int)$customer_id . "'");

  return $query->row['total'];
}

	]]></add>
	</operation>
</file>

<file path="admin/view/template/sale/customer_form.tpl">
        <operation>
<search><![CDATA[<li><a href="#tab-ip" data-toggle="tab"><?php echo $tab_ip; ?></a></li>
]]></search>
            <add position="after"><![CDATA[
<li><a href="#tab-image" data-toggle="tab"><?php echo $tab_image; ?></a></li>
            ]]></add>
        </operation>
        <operation>
<search position="after" offset="2"><![CDATA[
 <div class="tab-pane" id="tab-ip">
]]></search>
            <add><![CDATA[
<div class="tab-pane" id="tab-image">
  <div id="image"></div>
</div>
            ]]></add>
        </operation>

        <operation>
<search position="before"><![CDATA[$('#content').delegate]]></search>
            <add><![CDATA[
$('#image').load('index.php?route=sale/customer/image&token=<?php echo $token; ?>&customer_id=<?php echo $customer_id; ?>');


            ]]></add>
        </operation>
</file>

#########################SETTING FILES##########################

<file path="admin\view\template\setting\setting.tpl">
        <operation>
<search position="after" offset="2"><![CDATA[<?php echo $config_file_ext_allowed; ?></textarea>]]></search>
            <add><![CDATA[
<div class="form-group">
  <label class="col-sm-2 control-label" for="input-image-ext-allowed"><span data-toggle="tooltip" title="<?php echo $help_fimage_ext_allowed; ?>"><?php echo $entry_image_ext_allowed; ?></span></label>
  <div class="col-sm-10">
    <textarea name="config_image_ext_allowed" rows="5" placeholder="<?php echo $entry_image_ext_allowed; ?>" id="input-image-ext-allowed" class="form-control"><?php echo $config_image_ext_allowed; ?></textarea>
  </div>
</div>
 ]]></add>
        </operation>
</file>

<file path="admin\language\english\setting\setting.php">
	<operation>
		<search position=“after”><![CDATA[
$_['entry_file_ext_allowed']           = 'Allowed File Extensions';]]></search>
		<add><![CDATA[
$_['entry_image_ext_allowed']          = 'Allowed Image Extensions';
]]></add>
	</operation>

	<operation>
		<search position="after"><![CDATA[
$_['help_file_ext_allowed']            = 'Add which file extensions are allowed to be uploaded. Use a new line for each value.';]]></search>
		<add><![CDATA[
$_['help_image_ext_allowed']           = 'Add which image extensions are allowed to be uploaded. Use a new line for each value.';]]></add>
	</operation>
</file>

<file path="admin\controller\setting\setting.php">
	<operation>
		<search position="after"><![CDATA[
$data['entry_file_ext_allowed'] = $this->language->get('entry_file_ext_allowed');
]]></search>
		<add><![CDATA[
$data['entry_image_ext_allowed'] = $this->language->get('entry_image_ext_allowed');

	]]></add>
	</operation>
	<operation>
		<search position="after"><![CDATA[
$data['help_image_ext_allowed'] = $this->language->get('help_image_ext_allowed');
]]></search>
		<add><![CDATA[
$data['help_image_ext_allowed'] = $this->language->get('help_image_ext_allowed');
]]></add>
	</operation>

	<operation>
		<search position="after"><![CDATA[
if (isset($this->request->post['config_file_ext_allowed'])) {
  $data['config_file_ext_allowed'] = $this->request->post['config_file_ext_allowed'];
} else {
  $data['config_file_ext_allowed'] = $this->config->get('config_file_ext_allowed');
}
]]></search>
		<add><![CDATA[
if (isset($this->request->post['config_image_ext_allowed'])) {
  $data['config_image_ext_allowed'] = $this->request->post['config_image_ext_allowed'];
} else {
  $data['config_image_ext_allowed'] = $this->config->get('config_image_ext_allowed');
}]]></add>
	</operation>
</file>

==================================================================================

<file path="catalog/controller/account/account.php">
	<operation>
		<search position="after"><![CDATA[
$data['text_newsletter'] = $this->language->get('text_newsletter');
]]></search>
		<add><![CDATA[
$data['text_view_images'] = $this->language->get('text_view_images');
]]></add>
	</operation>

	<operation>
		<search position="after"><![CDATA[
$data['newsletter'] = $this->url->link('account/newsletter', '', 'SSL');
]]></search>
		<add><![CDATA[
$data['view_images'] = $this->url->link('account/image', '', 'SSL');
]]></add>
	</operation>
</file>

<file path="catalog/language/english/account/account.php">
		<operation info="Add Text”>
			<search position="bottom"></search>
			<add><![CDATA[
			$_['text_view_images']   = 'View Image Account';
			]]></add>
		</operation>
</file>

============================Add Customer Image========================================================

<file path="catalog/model/account/customer.php">
	<operation>
	<search position="before"><![CDATA[public function editPassword($email, $password) { ]]></search>
		<add><![CDATA[
			if($data['customer_image']){
  $this->db->query("INSERT INTO " . DB_PREFIX . "customer_image SET customer_id = '" . (int)$this->customer->getId() . "', customer_image = '" . $this->db->escape($data['customer_image']) . "', date_added = NOW()");
}

			]]></add>
	</operation>

	<operation info="last Script">
			<search position="bottom"></search>
			<add><![CDATA[
public function getImagesByCustomerId($customer_id) {
  $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_image WHERE customer_id = '" . (int)$customer_id . "'");

  return $query->rows;
}

public function getTotalImagesById($customer_id) {
  $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_image WHERE customer_id = '" . (int)$customer_id . "'");

  return $query->row['total'];
}

public function addCustomerImage($data){
  $this->db->query("INSERT INTO " . DB_PREFIX . "customer_image SET customer_id = '" . (int)$this->customer->getId() . "', customer_image = '" . $this->db->escape($data['customer_image']) . "', date_added = NOW()");
}

			]]></add>
	</operation>
</file>

<file path="catalog/view/theme/*/template/account/account.tpl">
	<operation>
		<search><![CDATA[
<li><a href="<?php echo $edit; ?>"><?php echo $text_edit; ?></a></li>
]]></search>
		<add position="after"><![CDATA[
<li><a href="<?php echo $view_images; ?>"><?php echo $text_view_images; ?></a></li>
]]></add>
	</operation>
</file>

<file path="catalog/view/theme/*/template/module/account.tpl">
	<operation>
		<search><![CDATA[
<li class="box-account__item"><a href="<?php echo $edit; ?>"><?php echo $text_edit; ?></a></li>
]]></search>
		<add position="after"><![CDATA[
<li class="box-account__item"><a href="<?php echo $view_images; ?>"><?php echo $text_view_images; ?></a></li>
]]></add>
	</operation>
</file>

</modification>

New member

Posts

Joined
Fri Jul 24, 2015 3:36 pm

Post by mash0028 » Sat Nov 14, 2015 3:58 pm

561e2563084e0-resize-500x500.jpg

it should - 561e2563084e0-resize-500x500.jpg (27.32 KiB) Viewed 2677 times

Its should be like that

V2.0.2.0

Is my opencart account

New member

Posts

Joined
Fri Jul 24, 2015 3:36 pm
Who is online

Users browsing this forum: No registered users and 15 guests