Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/smstemplate.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/smstemplate.php	(revision 405)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/smstemplate.php	(revision 405)
@@ -0,0 +1,217 @@
+<?php
+
+if (!defined('BASEPATH'))
+    exit('No direct script access allowed');
+
+class Smstemplate extends MX_Controller {
+
+    public function __construct() {
+        parent::__construct();
+        $this->load->helper('cookie');
+    }
+
+    public function index() {
+        $data = array();
+        $admin_info = $this->session->userdata('adminInfo');
+        if ($admin_info) {
+            $data['content'] = $this->getSmstemplates();
+            $this->load->view('smstemplate/index', $data);
+        } else {
+            $this->load->view('login');
+        }
+    }
+
+    public function getSmstemplates($filters = array()) {
+        $this->load->helper('pagging');
+        $this->load->model('Smstemplate_model');
+        $data['current_page'] = $this->uri->segment(4, 1);
+        $data['itemsoptions'] = array(10, 25, 50, 100);
+        $data['perpage'] = 10;
+        $data['keyword'] = "";
+        $data['sorting_order']="sorting_desc";
+        $data['sorting_field']="sms_id";
+        
+        if ($this->input->post('sorting_order')) {
+            if ($this->input->post('sorting_order') != "sorting")
+            {
+               $data['sorting_order']=$this->input->post('sorting_order');
+               $data['sorting_field']=$this->input->post('sorting_field'); 
+            }
+        }
+        if ($this->input->post('items')) {
+            $data['perpage'] = $this->input->post('items');
+        }
+        if ($this->input->post('keyword')) {
+            $data['search_field']="";
+            $data['keyword'] = $this->input->post('keyword');
+            
+            if (preg_match("/[0-9]/", $data['keyword']))
+            {
+               $data['search_field']="cellphone"; 
+            }
+            
+        }
+        
+        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
+        $data['total'] = $this->Smstemplate_model->countSmstemplate($data);  
+       
+        $data['smstemplates'] = $this->Smstemplate_model->getSmstemplates($data);
+        
+        $data['paging_url'] = base_url() . "/admin/mau_tin_nhan/trang/";
+        $data['num_links'] = 2;
+        $data['paging'] = pagging($data);
+
+        if ($this->input->is_ajax_request()) {
+            return $this->load->view('smstemplate/listview', $data);
+        }
+        return $this->load->view('smstemplate/listview', $data, true);
+    }
+
+    public function addSmstemplate() {
+        $result['success'] = 0;
+        $result = array();
+        $input = $this->input->post();
+        $this->load->model('Smstemplate_model');
+        if (strlen($input['full_name'])==0)
+        {
+            $result['errors'][]="TÃªn cá»ng tÃ¡c viÃªn khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        if (strlen($input['login_name'])==0)
+        {
+            $result['errors'][]="TÃªn ÄÄng nháº­p khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        else
+        {
+            if ($this->Smstemplate_model->isExist(array('field'=>'login_name','value'=>$input['login_name'])))
+            {
+                $result['errors'][]="TÃªn ÄÄng nháº­p ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng";
+            }
+        }
+        if (strlen($input['cellphone'])==0)
+        {
+            $result['errors'][]="Sá» Äiá»n thoáº¡i khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        else
+        {
+            if ($this->Smstemplate_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'])))
+            {
+                $result['errors'][]="Sá» Äiá»n thoáº¡i ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng";
+            }
+        }
+        if (strlen($input['passwd'])==0)
+        {
+            $result['errors'][]="Máº­t kháº©u khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        if ($input['passwd'] != $input['passwd2'])
+        {
+            $result['errors'][]="Máº­t kháº©u khÃŽng trÃ¹ng nhau";
+        }
+        if (!isset($result['errors']))
+        {
+            unset($input['passwd2']);
+            $input['passwd']=md5($input['activated']);
+            $input['activated']=1;
+            $input['created_time']=date("Y-m-d H:i:s");
+            $input['updated_time']=date("Y-m-d H:i:s");
+            $this->load->model('Smstemplate_model');
+            $this->Smstemplate_model->insert($input);
+            $result['success'] = 1;
+        }
+
+        
+        echo json_encode($result);
+    }
+    public function viewUser()
+    {
+        $id=$this->uri->segment(4);
+        $this->load->model('Smstemplate_model');
+        $data=$this->Smstemplate_model->getSmstemplate($id);
+        $this->load->view('smstemplate/viewUser',$data);
+    }
+    public function editUser()
+    {
+        $id=$this->uri->segment(4);
+        $this->load->model('Smstemplate_model');
+        $data=$this->Smstemplate_model->getSmstemplate($id);
+        $this->load->view('smstemplate/editUser',$data);
+    }
+    public function dodeleteUser()
+    {
+        $input=$this->input->post();
+        $id=$input['id'];
+        $this->load->model('Smstemplate_model');
+        $data=$this->Smstemplate_model->delete($id);
+        $result['success']=1;
+        echo json_encode($result);
+    }
+    public function deleteUser()
+    {
+        $id=$this->uri->segment(4);
+        $this->load->model('Smstemplate_model');
+        $data=$this->Smstemplate_model->getSmstemplate($id);
+        $this->load->view('smstemplate/deleteUser',$data);
+    }
+    public function updateUser()
+    {
+        $input['activated']=0;
+        $input=  array_merge($input,$this->input->post());
+        $this->load->model('Smstemplate_model');
+        if (strlen($input['full_name'])==0)
+        {
+            $result['errors'][]="TÃªn cá»ng tÃ¡c viÃªn khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        if (strlen($input['login_name'])==0)
+        {
+            $result['errors'][]="TÃªn ÄÄng nháº­p khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        else
+        {
+            if ($this->Smstemplate_model->isExist(array('field'=>'login_name','value'=>$input['login_name'],'id'=>$input['id'])))
+            {
+                $result['errors'][]="TÃªn ÄÄng nháº­p ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng";
+            }
+        }
+        if (strlen($input['cellphone'])==0)
+        {
+            $result['errors'][]="Sá» Äiá»n thoáº¡i khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        else
+        {
+            if ($this->Smstemplate_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'],'id'=>$input['id'])))
+            {
+                $result['errors'][]="Sá» Äiá»n thoáº¡i ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng";
+            }
+        }
+        if (strlen($input['passwd'])==0)
+        {
+            //$result['errors'][]="Máº­t kháº©u khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        if ($input['passwd'] != $input['passwd2'])
+        {
+            $result['errors'][]="Máº­t kháº©u khÃŽng trÃ¹ng nhau";
+        }
+        if (!isset($result['errors']))
+        {
+            unset($input['passwd2']);
+            $input['passwd']=md5($input['activated']);
+            $input['updated_time']=date("Y-m-d H:i:s");
+            $this->load->model('Smstemplate_model');
+            $this->Smstemplate_model->update($input['id'],$input);
+            $result['success'] = 1;
+        }
+        echo json_encode($result);
+    }
+    public function test() {
+        
+       
+        for ($i = 1; $i <= 50; $i++) {
+            $input['sms_content']="Chuc mung {full_name} da dang ky thanh cong".$i;
+            $input['sms_reply']="sms reply".$i;
+            $input['service_id']=$i;
+            $input['commandcode']="commandcode".$i;
+            $this->load->model('Smstemplate_model');
+            $this->Smstemplate_model->insert($input);
+        }
+    }
+
+}
