-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2d4853
commit aa7ae6a
Showing
10 changed files
with
423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 邀请好友注册奖励模块 | ||
|
||
 | ||
 | ||
|
||
## 安装方法 | ||
|
||
将文件夹上传至项目根目录,module->install,完成安装 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
class ControllerModuleInvitation extends Controller { | ||
private $error = array(); | ||
|
||
public function index() { | ||
$this->load->language('module/invitation'); | ||
|
||
$this->document->setTitle($this->language->get('heading_title')); | ||
|
||
$this->load->model('module/invitation'); | ||
|
||
$data['heading_title'] = $this->language->get('heading_title'); | ||
|
||
$data['text_list'] = $this->language->get('text_list'); | ||
$data['text_no_results'] = $this->language->get('text_no_results'); | ||
$data['column_inviter'] = $this->language->get('column_inviter'); | ||
$data['column_invitee'] = $this->language->get('column_invitee'); | ||
$data['column_time'] = $this->language->get('column_time'); | ||
|
||
if (isset($this->error['warning'])) { | ||
$data['error_warning'] = $this->error['warning']; | ||
} else { | ||
$data['error_warning'] = ''; | ||
} | ||
|
||
if (isset($this->session->data['success'])) { | ||
$data['success'] = $this->session->data['success']; | ||
|
||
unset($this->session->data['success']); | ||
} else { | ||
$data['success'] = ''; | ||
} | ||
|
||
if (isset($this->error['warning'])) { | ||
$data['error_warning'] = $this->error['warning']; | ||
} else { | ||
$data['error_warning'] = ''; | ||
} | ||
|
||
$data['breadcrumbs'] = array(); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_home'), | ||
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL') | ||
); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_module'), | ||
'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL') | ||
); | ||
|
||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('heading_title'), | ||
'href' => $this->url->link('module/invitation', 'token=' . $this->session->data['token'], 'SSL') | ||
); | ||
|
||
$page = isset($this->request->get['page'])?$this->request->get['page']:1; | ||
|
||
$data['invitations'] = $this->model_module_invitation->getinvitation($page); | ||
$total = $this->model_module_invitation->getTotalinvitation(); | ||
$pagination = new Pagination(); | ||
$pagination->total = $total; | ||
$pagination->page = $page; | ||
$page_count = 20; | ||
$pagination->limit = $page_count; | ||
$pagination->url = $this->url->link('module/invitation', 'token=' . $this->session->data['token'] . '&page={page}', 'SSL'); | ||
|
||
$data['pagination'] = $pagination->render(); | ||
|
||
$data['results'] = sprintf($this->language->get('text_pagination'), ($total) ? (($page - 1) * $page_count) + 1 : 0, ((($page - 1) * $page_count) > ($total - $page_count)) ? $total : ((($page - 1) * $page_count) + $page_count), $total, ceil($total / $page_count)); | ||
|
||
$data['header'] = $this->load->controller('common/header'); | ||
$data['column_left'] = $this->load->controller('common/column_left'); | ||
$data['footer'] = $this->load->controller('common/footer'); | ||
$this->response->setOutput($this->load->view('module/invitation.tpl', $data)); | ||
} | ||
|
||
public function install() { | ||
$this->db->query("CREATE TABLE ". DB_PREFIX . "invitation (id int primary key auto_increment,uid int,ivid int,add_time int)"); | ||
} | ||
|
||
public function uninstall() { | ||
$this->db->query("DROP TABLE ". DB_PREFIX . "invitation"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
// Heading | ||
$_['heading_title'] = 'Invitation'; | ||
|
||
// Text | ||
$_['text_module'] = 'Modules'; | ||
$_['text_success'] = 'Success: You have modified Invitation module!'; | ||
$_['text_edit'] = 'Edit Invitation Module'; | ||
|
||
// Entry | ||
$_['text_list'] = 'Invitation List'; | ||
$_['entry_status'] = 'Status'; | ||
$_['text_no_results'] = 'No Invitation!'; | ||
$_['text_confirm'] = 'Are you sure?'; | ||
$_['column_inviter'] = 'inviter'; | ||
$_['column_invitee'] = 'invitee'; | ||
$_['column_time'] = 'Invite Time'; | ||
$_['button_save'] = 'Save info'; | ||
$_['button_cancel'] = 'cancel'; | ||
$_['text_success'] = 'Save Success'; | ||
|
||
// Error | ||
$_['error_permission'] = 'Warning: You do not have permission to modify store module!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
class ModelModuleInvitation extends Model { | ||
public function getinvitation($page) | ||
{ | ||
$limit = ($page-1)*20; | ||
$query = $this->db->query("SELECT oc1.firstname as inviter,oc2.firstname as invitee,oi.add_time FROM " . DB_PREFIX . "invitation oi left join " . DB_PREFIX . "customer oc1 on oi.uid=oc1.customer_id left join " . DB_PREFIX . "customer oc2 on oi.ivid=oc2.customer_id order by oi.add_time desc limit $limit,20"); | ||
|
||
$invitation_data = $query->rows; | ||
|
||
return $invitation_data; | ||
} | ||
|
||
|
||
public function getTotalinvitation() { | ||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "invitation"); | ||
|
||
return $query->row['total']; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php echo $header; ?><?php echo $column_left; ?> | ||
<div id="content"> | ||
<div class="page-header"> | ||
<div class="container-fluid"> | ||
<h1><?php echo $heading_title; ?></h1> | ||
<ul class="breadcrumb"> | ||
<?php foreach ($breadcrumbs as $breadcrumb) { ?> | ||
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li> | ||
<?php } ?> | ||
</ul> | ||
</div> | ||
</div> | ||
<div class="container-fluid"> | ||
<?php if ($error_warning) { ?> | ||
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?> | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
</div> | ||
<?php } ?> | ||
<?php if ($success) { ?> | ||
<div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?> | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
</div> | ||
<?php } ?> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title"><i class="fa fa-list"></i> <?php echo $text_list; ?></h3> | ||
</div> | ||
<div class="panel-body"> | ||
<form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form-invitation"> | ||
<div class="table-responsive"> | ||
<table class="table table-bordered table-hover"> | ||
<thead> | ||
<tr> | ||
<td class="text-left"><?php echo $column_inviter; ?></td> | ||
<td class="text-left"><?php echo $column_invitee; ?></td> | ||
<td class="text-right"><?php echo $column_time; ?></td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php if ($invitations) { ?> | ||
<?php foreach ($invitations as $invitation) { ?> | ||
<tr> | ||
<td class="text-left"><?php echo $invitation['inviter']; ?></td> | ||
<td class="text-left"><?php echo $invitation['invitee']; ?></td> | ||
<td class="text-right"><?php echo date('Y-m-d H:i:s',$invitation['add_time']); ?></td> | ||
</tr> | ||
<?php } ?> | ||
<?php } else { ?> | ||
<tr> | ||
<td class="text-center" colspan="4"><?php echo $text_no_results; ?></td> | ||
</tr> | ||
<?php } ?> | ||
</tbody> | ||
</table> | ||
<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> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<?php echo $footer; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
class Controllermoduleinvitation extends Controller { | ||
public function index() { | ||
|
||
if (!$this->customer->isLogged()) { | ||
$this->session->data['redirect'] = $this->url->link('module/invitation', '', 'SSL'); | ||
|
||
$this->response->redirect($this->url->link('account/login', '', 'SSL')); | ||
} | ||
|
||
$this->load->language('module/invitation'); | ||
$data['heading_title'] = $this->language->get('heading_title'); | ||
$data['text_empty'] = $this->language->get('text_empty'); | ||
|
||
$data['breadcrumbs'] = array(); | ||
$data['breadcrumbs'][] = array( | ||
'text' => $this->language->get('text_home'), | ||
'href' => $this->url->link('common/home') | ||
); | ||
$data['breadcrumbs'][] = array( | ||
'text' => 'invitation', | ||
'href' => $this->url->link('module/invitation') | ||
); | ||
|
||
$this->load->model('module/invitation'); | ||
$page = isset($this->request->get['page'])?$this->request->get['page']:1; | ||
|
||
$data['invitations'] = $this->model_module_invitation->getinvitation($page); | ||
$total = $this->model_module_invitation->getTotalinvitation(); | ||
$pagination = new Pagination(); | ||
$pagination->total = $total; | ||
$pagination->page = $page; | ||
$page_count = 20; | ||
$pagination->limit = $page_count; | ||
$pagination->url = $this->url->link('module/invitation', 'token=' . $this->session->data['token'] . '&page={page}', 'SSL'); | ||
|
||
$data['pagination'] = $pagination->render(); | ||
|
||
$data['results'] = sprintf($this->language->get('text_pagination'), ($total) ? (($page - 1) * $page_count) + 1 : 0, ((($page - 1) * $page_count) > ($total - $page_count)) ? $total : ((($page - 1) * $page_count) + $page_count), $total, ceil($total / $page_count)); | ||
$data['column_inviter'] = $this->language->get('column_inviter'); | ||
$data['column_invitee'] = $this->language->get('column_invitee'); | ||
$data['column_time'] = $this->language->get('column_time'); | ||
$data['invitation_link'] = $this->url->link('/','','SSL').'?invite='.$this->customer->getid(); | ||
$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/module/invitation.tpl')) { | ||
return $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/module/invitation.tpl', $data)); | ||
} else { | ||
return $this->response->setOutput($this->load->view('default/template/module/invitation.tpl', $data)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
// Heading | ||
$_['heading_title'] = 'My Invitation'; | ||
|
||
$_['column_inviter'] = 'inviter'; | ||
$_['column_invitee'] = 'invitee'; | ||
$_['column_time'] = 'Invite Time'; | ||
$_['text_empty'] = 'No Invite!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
class ModelModuleInvitation extends Model { | ||
public function getinvitation($page) | ||
{ | ||
$limit = ($page-1)*20; | ||
$query = $this->db->query("SELECT oc2.firstname as invitee,oi.add_time FROM " . DB_PREFIX . "invitation oi left join " . DB_PREFIX . "customer oc2 on oi.ivid=oc2.customer_id where oi.uid = '".$this->customer->getid()."' order by oi.add_time desc limit $limit,20"); | ||
|
||
$invitation_data = $query->rows; | ||
|
||
return $invitation_data; | ||
} | ||
|
||
|
||
public function getTotalinvitation() { | ||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "invitation where uid = '".$this->customer->getid()."'"); | ||
|
||
return $query->row['total']; | ||
} | ||
|
||
|
||
public function addInvitation($data) | ||
{ | ||
$this->db->query("insert into " . DB_PREFIX . "invitation set uid = '".$data['uid']."',ivid = '".$data['ivid']."',add_time = '".time()."'"); | ||
|
||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward set customer_id = '".$data['uid']."',order_id = '0',date_added = '".date('Y-m-d H:i:s',time())."',points = 50,description = 'Invite user(id:".$data['ivid'].")'"); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
Invitations/catalog/view/theme/default/template/module/invitation.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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 $class = 'col-sm-12'; ?> | ||
<div id="content" class="<?php echo $class; ?>"> | ||
<h1><?php echo $heading_title; ?></h1> | ||
<div class="container"> | ||
<h2>REFERRAL LINK</h2> | ||
<p>Copy + paste your personal link into your blog, email or IM.</p> | ||
<p><input type="text" value="<?php echo $invitation_link;?>" style="width: 80%;height: 20px;line-height: 20px;padding: 0; text-align: left;color: #000;"></p> | ||
<p><!-- Go to www.addthis.com/dashboard to customize your tools --> <div class="addthis_inline_share_toolbox"></div><!-- Go to www.addthis.com/dashboard to customize your tools --> | ||
<script type="text/javascript">var addthis_share = { | ||
description: "", | ||
title: "", | ||
url: '<?php echo $invitation_link;?>' | ||
}</script> | ||
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-59c8bb1540db10a2"></script> </p> | ||
</div> | ||
<br><br> | ||
<h2>My invitation list</h2> | ||
<div class="table-responsive"> | ||
<table class="table table-bordered table-hover"> | ||
<thead> | ||
<tr> | ||
<td class="text-left"><?php echo $column_invitee; ?></td> | ||
<td class="text-right"><?php echo $column_time; ?></td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php if ($invitations) { ?> | ||
<?php foreach ($invitations as $invitation) { ?> | ||
<tr> | ||
<td class="text-left"><?php echo $invitation['invitee']; ?></td> | ||
<td class="text-right"><?php echo date('Y-m-d H:i:s',$invitation['add_time']); ?></td> | ||
</tr> | ||
<?php } ?> | ||
<?php } else { ?> | ||
<tr> | ||
<td class="text-center" colspan="3"><?php echo $text_empty; ?></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></div> | ||
</div> | ||
<?php echo $footer; ?> |
Oops, something went wrong.