-
Notifications
You must be signed in to change notification settings - Fork 130
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
Showing
19 changed files
with
1,068 additions
and
6 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
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
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
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
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
206 changes: 206 additions & 0 deletions
206
application/plugins/sms_credit/controllers/sms_credit.php
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,206 @@ | ||
<?php | ||
/** | ||
* Kalkun | ||
* An open source web based SMS Management | ||
* | ||
* @package Kalkun | ||
* @author Kalkun Dev Team | ||
* @license http://kalkun.sourceforge.net/license.php | ||
* @link http://kalkun.sourceforge.net | ||
*/ | ||
|
||
// ------------------------------------------------------------------------ | ||
|
||
/** | ||
* SMS_credit Class | ||
* | ||
* @package Kalkun | ||
* @subpackage Plugin | ||
* @category Controllers | ||
*/ | ||
include_once(APPPATH.'plugins/Plugin_Controller.php'); | ||
|
||
class SMS_credit extends Plugin_Controller { | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @access public | ||
*/ | ||
function __construct() | ||
{ | ||
parent::Plugin_Controller(); | ||
$this->load->model('sms_credit_model', 'plugin_model'); | ||
} | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* Index | ||
* | ||
* Display list of all users | ||
* | ||
* @access public | ||
*/ | ||
function index() | ||
{ | ||
$param = array(); | ||
if($_POST) | ||
{ | ||
$param['q'] = $this->input->post('search_name'); | ||
$data['query'] = $param['q']; | ||
} | ||
|
||
$this->load->library('pagination'); | ||
$config['base_url'] = site_url('plugin/sms_credit/index'); | ||
$config['total_rows'] = $this->plugin_model->get_users()->num_rows(); | ||
$config['per_page'] = $this->Kalkun_model->get_setting()->row('paging'); | ||
$config['cur_tag_open'] = '<span id="current">'; | ||
$config['cur_tag_close'] = '</span>'; | ||
$config['uri_segment'] = 4; | ||
$this->pagination->initialize($config); | ||
$param['limit'] = $config['per_page']; | ||
$param['offset'] = $this->uri->segment(4,0); | ||
|
||
$data['main'] = 'index'; | ||
$data['title'] = 'Users Credit'; | ||
$data['users'] = $this->plugin_model->get_users($param); | ||
$data['packages'] = $this->plugin_model->get_packages(); | ||
|
||
$this->load->view('main/layout', $data); | ||
} | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* Add Users | ||
* | ||
* Add an User with packages | ||
* | ||
* @access public | ||
*/ | ||
function add_users() | ||
{ | ||
if($_POST) | ||
{ | ||
$param['id_user'] = $this->input->post('id_user'); | ||
$param['id_template_credit'] = $this->input->post('package'); | ||
$param['valid_start'] = $this->input->post('package_start'); | ||
$param['valid_end'] = $this->input->post('package_end'); | ||
|
||
if(empty($param['id_user'])) | ||
{ | ||
unset($param['id_user']); | ||
$param['realname'] = trim($this->input->post('realname')); | ||
$param['username'] = trim($this->input->post('username')); | ||
$param['phone_number'] = $this->input->post('phone_number'); | ||
$param['level'] = $this->input->post('level'); | ||
$param['password'] = sha1($this->input->post('password')); | ||
$this->plugin_model->add_users($param); | ||
} | ||
else | ||
{ | ||
$this->plugin_model->change_users_package($param); | ||
} | ||
|
||
redirect('plugin/sms_credit'); | ||
} | ||
} | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* Delete Users | ||
* | ||
* Delete an User | ||
* | ||
* @access public | ||
*/ | ||
function delete_users($id = NULL) | ||
{ | ||
$this->plugin_model->delete_users($id); | ||
redirect('plugin/sms_credit'); | ||
} | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* Packages | ||
* | ||
* Display list of all packages | ||
* | ||
* @access public | ||
*/ | ||
function packages() | ||
{ | ||
$this->load->library('pagination'); | ||
$config['base_url'] = site_url('plugin/sms_credit/packages'); | ||
$config['total_rows'] = $this->plugin_model->get_packages()->num_rows(); | ||
$config['per_page'] = $this->Kalkun_model->get_setting()->row('paging'); | ||
$config['cur_tag_open'] = '<span id="current">'; | ||
$config['cur_tag_close'] = '</span>'; | ||
$config['uri_segment'] = 4; | ||
$this->pagination->initialize($config); | ||
$param['limit'] = $config['per_page']; | ||
$param['offset'] = $this->uri->segment(4,0); | ||
|
||
if($_POST) | ||
{ | ||
$data['query'] = $this->input->post('query'); | ||
$data['packages'] = $this->plugin_model->search_packages($data['query']); | ||
} | ||
else | ||
{ | ||
$data['packages'] = $this->plugin_model->get_packages($param); | ||
} | ||
|
||
$data['main'] = 'packages'; | ||
$data['title'] = 'Credit Package'; | ||
$this->load->view('main/layout', $data); | ||
} | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* Add Packages | ||
* | ||
* Add Packages | ||
* | ||
* @access public | ||
*/ | ||
function add_packages() | ||
{ | ||
if($_POST) | ||
{ | ||
$param['id_credit_template'] = $this->input->post('id_package'); | ||
|
||
if(empty($param['id_credit_template'])) { | ||
unset($param['id_credit_template']); | ||
} | ||
|
||
$param['template_name'] = trim($this->input->post('package_name')); | ||
$param['sms_numbers'] = trim($this->input->post('sms_amount')); | ||
$this->plugin_model->add_packages($param); | ||
redirect('plugin/sms_credit/packages'); | ||
} | ||
} | ||
|
||
// -------------------------------------------------------------------- | ||
|
||
/** | ||
* Delete Packages | ||
* | ||
* Delete Packages | ||
* | ||
* @access public | ||
*/ | ||
function delete_packages($id = NULL) | ||
{ | ||
$this->plugin_model->delete_packages($id); | ||
redirect('plugin/sms_credit/packages'); | ||
} | ||
|
||
} | ||
|
||
/* End of file sms_credit.php */ | ||
/* Location: ./application/plugins/sms_credit/controllers/sms_credit.php */ |
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,13 @@ | ||
CREATE TABLE IF NOT EXISTS `plugin_sms_credit` ( | ||
`id_user_credit` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , | ||
`id_user` INT( 11 ) NOT NULL , | ||
`id_template_credit` INT( 11 ) NOT NULL , | ||
`valid_start` DATETIME NOT NULL , | ||
`valid_end` DATETIME NOT NULL | ||
) ENGINE = MYISAM ; | ||
|
||
CREATE TABLE IF NOT EXISTS `plugin_sms_credit_template` ( | ||
`id_credit_template` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , | ||
`template_name` VARCHAR( 50 ) NOT NULL , | ||
`sms_numbers` INT( 11 ) NOT NULL | ||
) ENGINE = MYISAM ; |
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,13 @@ | ||
CREATE TABLE "plugin_sms_credit" ( | ||
"id_user_credit" serial PRIMARY KEY, | ||
"id_user" integer NOT NULL, | ||
"id_template_credit" integer NOT NULL, | ||
"valid_start" timestamp(0) WITHOUT time zone NOT NULL, | ||
"valid_end" timestamp(0) WITHOUT time zone NOT NULL | ||
); | ||
|
||
CREATE TABLE "plugin_sms_credit_template" ( | ||
"id_credit_template" serial PRIMARY KEY, | ||
"template_name" varchar(50) NOT NULL, | ||
"sms_numbers" integer NOT NULL | ||
); |
13 changes: 13 additions & 0 deletions
13
application/plugins/sms_credit/media/sqlite_sms_credit.sql
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,13 @@ | ||
CREATE TABLE "plugin_sms_credit" ( | ||
"id_user_credit" INTEGER PRIMARY KEY AUTOINCREMENT, | ||
"id_user" INTEGER NOT NULL, | ||
"id_template_credit" INTEGER NOT NULL, | ||
"valid_start" DATETIME NOT NULL, | ||
"valid_end" DATETIME NOT NULL | ||
); | ||
|
||
CREATE TABLE "plugin_sms_credit_template" ( | ||
"id_credit_template" INTEGER PRIMARY KEY AUTOINCREMENT, | ||
"template_name" VARCHAR(50) NOT NULL, | ||
"sms_numbers" INTEGER NOT NULL | ||
); |
Oops, something went wrong.