Ignore:
Timestamp:
Apr 23, 2015 12:00:06 PM (10 years ago)
Author:
namnd
Message:
 
Location:
pro-violet-viettel/sourcecode/application/modules
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php

    r838 r906  
    1717        $admin_info = $this->session->userdata('adminInfo');
    1818        if ($admin_info) {
    19             $data['content'] = $this->getCollaborators();
     19                        $roles=array();
     20            foreach ($admin_info['roles'] as $role)
     21            {
     22                $roles[]=$role['role_name'];
     23            }
     24            //$data['roles']=$roles;
     25            $data['content'] = $this->getCollaborators(array(), $roles);
    2026            $this->load->view('collaborator/index', $data);
    2127        } else {
     
    2430    }
    2531
    26     public function getCollaborators($filters = array()) {
     32    public function getCollaborators($filters = array(), $roles) {
    2733        $this->load->helper('pagging');
    2834        $this->load->model('collabolator_model');
     
    7682        $data['num_links'] = 2;
    7783        $data['paging'] = pagging($data);
    78 
     84                $data['roles'] = $roles;
     85               
    7986        if ($this->input->is_ajax_request()) {
    8087            return $this->load->view('collaborator/listview', $data);
     
    8895        $input = $this->input->post();
    8996        $this->load->model('collabolator_model');
    90         if (strlen($input['full_name'])==0)
    91         {
    92             $result['errors'][]=array("content"=>"Tên cộng tác viên khÃŽng được để trống","field"=>"full_name");
    93         }
    94         if (strlen($input['login_name'])==0)
    95         {
    96             $result['errors'][]=array("content"=>"Tên đăng nhập khÃŽng được để trống","field"=>"login_name");
     97               
     98        if (strlen($input['cellphone'])==0)
     99        {
     100            $result['errors'][] = array("content"=>lang('_SBG_PHONE_REQUIRED_MSG'),"field"=>"cellphone");
    97101        }
    98102        else
    99103        {
    100             if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name'])))
    101             {
    102                 $result['errors'][]=array("content"=>"Tên đăng nhập đã được sá»­ dụng","field"=>"login_name");
    103             }
    104         }
    105         if (strlen($input['cellphone'])==0)
    106         {
    107             $result['errors'][]=array("content"=>"Số điện thoại khÃŽng được để trống","field"=>"cellphone");
    108         }
    109         else
    110         {
     104                        if (!preg_match('/^([0-9]{10,11}$)$/', $input['cellphone'])) {
     105                                $result['errors'][] = array("content"=>lang('_SBG_PHONE_FORMAT_ERROR_MSG'), "field"=>"cellphone");
     106                        }
     107                       
    111108            if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'])))
    112109            {
    113                 $result['errors'][]=array("content"=>"Số điện thoại đã được sá»­ dụng","field"=>"cellphone");
    114             }
    115         }
    116         if (strlen($input['passwd'])==0)
    117         {
    118             $result['errors'][]=array("content"=>"Mật khẩu khÃŽng được để trống","field"=>"passwd");
    119         }
    120         else
    121         {
    122             if ($input['passwd'] != $input['passwd2'])
    123             {
    124                 $result['errors'][]=array("content"=>"Mật khẩu phải trùng nhau","field"=>"passwd");
    125             }
    126         }
     110                $result['errors'][] = array("content"=>lang("_SBG_PHONE_DUPLICATE_MSG"),"field"=>"cellphone");
     111            }
     112        }
     113       
    127114        if (!isset($result['errors']))
    128115        {
    129             unset($input['passwd2']);
    130             $input['passwd']=md5($input['activated']);
    131             $input['activated']=1;
    132             $input['created_time']=date("Y-m-d H:i:s");
    133             $input['updated_time']=date("Y-m-d H:i:s");
     116   
     117                        $passwd = $this->collabolator_model->createRandomPassword();
     118            $input['passwd'] = md5($input['activated']);
     119                        $input['login_name'] = $input['cellphone'];
     120                        $input['author'] = 1;
     121            $input['activated'] = 1;
     122            $input['created_time'] = date("Y-m-d H:i:s");
     123            $input['updated_time'] = date("Y-m-d H:i:s");
    134124            $this->load->model('collabolator_model');
     125                       
    135126            $this->collabolator_model->insert($input);
    136127            $result['success'] = 1;
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportAsistant.php

    r838 r906  
    2424        }
    2525    }
    26 
     26       
    2727    public function viewAsistant() {
    2828        $data = array();
     
    159159        $data['keyword'] = "";
    160160        $data['sorting_order'] = "sorting_desc";
    161         $data['sorting_field'] = "id";
     161        $data['sorting_field'] = "user_created_time";
    162162
    163163        if ($this->input->post('sorting_order')) {
     
    181181                $data['daterange_start'] = "";
    182182                $data['daterange_end'] = "";
     183               
    183184                if ($this->input->post('daterange')){
    184185                        $daterange = explode(" - ", $this->input->post('daterange'));
     
    190191               
    191192        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
     193                //write_file('./log/sql.log', date('d-m-Y H:i:s').": Start query \n", FOPEN_WRITE_CREATE);
    192194        $data['total'] = $this->collabolator_model->countCountCollaboratorUsers($data);
     195                write_file('./log/sql.log', date('d-m-Y H:i:s').": Start query \n", FOPEN_WRITE_CREATE);
    193196        $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
     197               
    194198        foreach ($data['paidlogs'] as $index=>$paidlog)
    195199        {
    196200            $data['paidlogs'][$index]['username']=$this->get_fullname($paidlog['us_id']);
    197201        }
     202                write_file('./log/sql.log', date('d-m-Y H:i:s').": Finished query \n", FOPEN_WRITE_CREATE);
    198203        $data['paging_url'] = base_url() . "/admin/thong_ke_cong_tac_vien/trang_ctv/" . $data['id'];
    199204        $data['num_links'] = 2;
     
    203208            return $this->load->view('reportAsistant/listview_user', $data);
    204209        }
     210               
    205211        return $this->load->view('reportAsistant/listview_user', $data, true);
    206212    }
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php

    r883 r906  
    132132                $this->load->model('reportmodel');
    133133                $data['date'] = 1;
    134         $data['month'] = $this->uri->segment(4);
    135         $data['year'] = $this->uri->segment(5);
    136         $data['to_date'] = date("d");
     134        $data['month'] = $this->uri->segment(5);
     135        $data['year'] = $this->uri->segment(6);
     136        $data['to_date'] = $this->uri->segment(4);
    137137        $data['to_month'] = date("m");
    138138        $data['to_year'] = date("Y");
     139                /*
    139140        if ($this->input->post()) {
    140141                        //$data['date'] = $this->input->post('date');
     
    144145            $data['to_month'] = $this->input->post('to_month');
    145146            $data['to_year'] = $this->input->post('to_year');
    146         }
     147        }*/
    147148               
    148149        $result = $this->reportmodel->getProvinces($data);
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php

    r883 r906  
    8181                        $daterange [0] = str_replace ( '/', '-', $daterange [0] );
    8282                        $daterange [1] = str_replace ( '/', '-', $daterange [1] );
     83                        $data['date_start'] = $daterange [0];
     84                        $data['date_end'] = $daterange [1];
    8385                        $data ['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $daterange [0] ) );
    8486                        $data ['daterange_end'] = date ( 'Y-m-d H:is:s', strtotime ( $daterange [1] . ' + 1 day' ) );
     
    208210                );
    209211                $data ['status'] = $this->uri->segment (7, 0);
    210                 /*
    211                 if ($this->input->post ( 'status' )) {
    212                         $data ['status'] = ( int ) $this->input->post ( 'status' );
    213                 }
    214                 */
     212               
    215213                $data['provinces'] = $provinces;
    216214                $data['province'] = $this->uri->segment (8);
     215               
    217216                if ($data['province'] == 'default') $data['province'] = null;
    218                 if ($this->input->post ( 'province' )) {
    219                         $data ['province'] = $this->input->post ( 'province' );
    220                 }
    221217                if ($data['province'])
    222218                        $data['districts'] = $this->user_model->getDistrictByProvince($data ['province']);
    223                 if ($this->input->post ( 'district' )) {
    224                         $data['district'] = $this->input->post ( 'district' );
    225                 }
    226                
     219
    227220                $data['district'] = $this->uri->segment (9);
    228221                if ($data['district'] == 'default') $data['district'] = null;
    229222                $data ['keyword'] = $this->uri->segment (6);
    230223                if ($data['keyword'] == 'default') $data['keyword'] = null;
     224               
    231225                $data ['sorting_order'] = "sorting_desc";
    232226                $data ['sorting_field'] = "created_time";
    233                 $data ['sorting_order'] = $this->uri->segment (11);
    234                 $data ['sorting_field'] = $this->uri->segment (12);
    235                
    236                 if ($this->input->post ( 'sorting_order' )) {
    237                         if ($this->input->post ( 'sorting_order' ) != "sorting") {
    238                                 $data ['sorting_order'] = $this->input->post ( 'sorting_order' );
    239                                 $data ['sorting_field'] = $this->input->post ( 'sorting_field' );
    240                         }
    241                 }
    242                
    243                 if ($this->input->post ( 'items' )) {
    244                         $data ['perpage'] = $this->input->post ( 'items' );
    245                 }
    246                
    247                 if ($this->input->post ( 'keyword' )) {
    248                         $data ['keyword'] = $this->input->post ( 'keyword' );
    249                 }
    250                
    251                 $data ['daterange_start'] = "";
    252                 $data ['daterange_end'] = "";
    253                 $daterange = $this->uri->segment (10);
    254                 if ($daterange == 'default') $daterange = null;
    255                 if($daterange){
    256                         $daterange = explode ( " - ", $daterange );
    257                         $daterange [0] = str_replace ( '/', '-', $daterange [0] );
    258                         $daterange [1] = str_replace ( '/', '-', $daterange [1] );
    259                         $data ['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $daterange [0] ) );
    260                         $data ['daterange_end'] = date ( 'Y-m-d H:is:s', strtotime ( $daterange [1] . ' + 1 day' ) );
    261                 }
    262                 if ($this->input->post ( 'daterange' )) {
    263                         $daterange = explode ( " - ", $this->input->post ( 'daterange' ) );
    264                         $daterange [0] = str_replace ( '/', '-', $daterange [0] );
    265                         $daterange [1] = str_replace ( '/', '-', $daterange [1] );
    266                         $data ['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $daterange [0] ) );
    267                         $data ['daterange_end'] = date ( 'Y-m-d H:is:s', strtotime ( $daterange [1] . ' + 1 day' ) );
    268                 }
     227                $data ['sorting_order'] = $this->uri->segment (12);
     228                $data ['sorting_field'] = $this->uri->segment (13);
     229
     230                $data ['daterange_start'] = $this->uri->segment (10);
     231                $data ['daterange_end'] = $this->uri->segment (11);
     232                if ($data['daterange_start'] == 'default') $data['daterange_start'] = null;
     233                if ($data['daterange_end'] == 'default') $data['daterange_end'] = null;
     234                if ($data['daterange_start'])
     235                        $data['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $data ['daterange_start'] ) );
     236                if ($data['daterange_end'])
     237                        $data['daterange_end'] = date ( 'Y-m-d H:i:s', strtotime ( $data['daterange_end'] . ' + 1 day' ) );
     238
    269239                $data ['start'] = ($data ['current_page'] - 1) * $data ['perpage'];
     240                //echo json_encode($data);
    270241                $data ['total'] = $this->user_model->get_total_users ( $data );
    271242                $us = $this->user_model->get_list_users ( $data );
    272243                $users = array ();
     244               
    273245               
    274246                foreach ( $us as $u ) {
     
    295267                        array_push ( $users, $u );
    296268                }
    297        
     269               
    298270                $data ['users'] = $users;
    299271                $data ['paging_url'] = base_url () . "admin/nguoi_dung/trang/";
  • pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php

    r838 r906  
    4949    function getAllCollaboratorUser($from,$id=false)
    5050    {
    51         $from = date("Y-m-d 00:00:00",$from);
     51        $from = date("Y-m-d 00:00:00",$from);
     52                $order = "";
     53        if ($data['sorting_order'] != "sorting") {
     54           
     55                $sort = "DESC";
     56                if ($data['sorting_order'] == "sorting_asc")
     57                    $sort = "ASC";
     58                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
     59           
     60        }
    5261        $where="";
    5362        if ($id)
    5463        {
    55             $where = " AND tbluser.collaborator = $id ";
     64            //$where = " AND tbluser.collaborator = $id ";
     65                        $where = " AND tblcollaborator.id = $id ";
    5666        }
    5767        //$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.id WHERE tbluser.created_time > '".$from."'".$where."";
    5868                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone WHERE tbluser.created_time > '".$from."'".$where."";
    59 
     69               
    6070        $result = $this->db->query($sql)->result_array();
    6171        foreach ($result as $index=>$paidlog)
     
    120130       
    121131                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time, COUNT(tbluser.collaborator) as total_user  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." GROUP BY tblcollaborator.id ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
    122 
     132               
    123133        $result = $this->db->query($sql)->result_array();
    124134        foreach ($result as $index=>$paidlog)
     
    153163                }else{
    154164                        $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order."";
    155                 }       
     165                }
     166                //write_file('./log/sql.log', date('d-m-Y H:i:s').": ".$sql."\n", FOPEN_WRITE_CREATE);         
    156167                $result = $this->db->query($sql)->result_array();
     168               
    157169        foreach ($result as $index=>$paidlog)
    158170        {
    159171            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
    160172        }
    161 
     173               
    162174        return count($result);
    163175    }
    164         function getCountCollaboratorUsers($data)
     176       
     177        function getCountCollaboratorUsers($data)
    165178    {
    166179        $order = "";
    167         if ($data['sorting_order'] != "sorting") {
    168            
     180        if ($data['sorting_order'] != "sorting") {       
    169181                $sort = "DESC";
    170182                if ($data['sorting_order'] == "sorting_asc")
     
    174186        }
    175187        $where="";
     188               
    176189        if ($data['keyword']) {
    177190            if ($data['search_field'] == "cellphone") {
     
    179192            }
    180193        }
     194               
    181195       // $from = date("Y-m-d 00:00:00",$from);
    182196       // $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.id ".$where." AND tbluser.collaborator = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
    183                 if(strlen($data['daterange_start'])>0){
    184                         $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND (tbluser.created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."') AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
     197           
     198                if($data['daterange_start']){
     199                       
     200                        if ($data['perpage']){
     201                                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND (tbluser.created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."') AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
     202                        }else{
     203                                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND (tbluser.created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."') AND tblcollaborator.id = ".$data['id']." ".$order;
     204                        }
    185205                }else{
    186                         $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
     206                        if ($data['perpage']){
     207                                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
     208                        }else{
     209                                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order;
     210                        }
    187211                }
    188212                $result = $this->db->query($sql)->result_array();
     
    454478        }
    455479       
     480        public function createRandomPassword()
     481        {
     482                $alphabet = "0123456789";
     483                $pass = array ();
     484                $alphaLength = strlen ( $alphabet ) - 1;
     485                for($i = 0; $i < 6; $i ++) {
     486                        $n = rand ( 0, $alphaLength );
     487                        $pass [] = $alphabet [$n];
     488                }
     489                return implode ( $pass );
     490        }
    456491}
  • pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php

    r883 r906  
    2323        function get_list_users($data)
    2424        {
     25               
    2526                $sql="SELECT * FROM ".$this->table_name;
    2627                if ($data['status'] == 1){
     
    3637                        $sql.=" WHERE expire_date < NOW() AND p_id <> 5";
    3738                }
    38                 if (isset($data['keyword']))
    39                 {
     39                //if (isset($data['keyword']))
     40                //{
    4041                        if (strlen($data['keyword'])>0){
    4142                                if ($data['status']==0){
     
    4344                                                if (strlen($data['district'])>0){
    4445                                                        if(strlen($data['daterange_start'])>0){
    45                                                                 $sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    46                                                         }
    47                                                 }else{
    48                                                         if(strlen($data['daterange_start'])>0){
    49                                                                 $sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     46                                                                $sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     47                                                        }else{
     48                                                                $sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     49                                                        }
     50                                                }else{
     51                                                        if(strlen($data['daterange_start'])>0){
     52                                                                $sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     53                                                        }else{
     54                                                                $sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
    5055                                                        }
    5156                                                }
    5257                                        }else{
    5358                                                if(strlen($data['daterange_start'])>0){
    54                                                         $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     59                                                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    5560                                                }else
    5661                                                {
    57                                                         $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     62                                                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
    5863                                                }
    5964                                        }
     
    6368                                                if (strlen($data['district'])>0){
    6469                                                        if(strlen($data['daterange_start'])>0){
    65                                                                 $sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    66                                                         }else{
    67                                                                 $sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
    68                                                         }
    69                                                 }else{
    70                                                         if(strlen($data['daterange_start'])>0){
    71                                                                 $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    72                                                         }else{
    73                                                                 $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
     70                                                                $sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     71                                                        }else{
     72                                                                $sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
     73                                                        }
     74                                                }else{
     75                                                        if(strlen($data['daterange_start'])>0){
     76                                                                $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     77                                                        }else{
     78                                                                $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
    7479                                                        }
    7580                                                }
     
    8085                        {
    8186                                if(strlen($data['daterange_start'])>0){
     87                                       
    8288                                        if ($data['status']==0){
    8389                                                if (strlen($data['province'])>0){
     
    105111                                else{
    106112                                        if ($data['status']==0){
     113                                       
    107114                                                if (strlen($data['province'])>0){
    108115                                                        if (strlen($data['district'])>0){
     
    111118                                                                $sql.=" WHERE province = '".$data['province']."'";
    112119                                                        }
    113                                                 }
    114                                         }else{
     120                                                       
     121                                                }
     122                                        }else{
     123                                                write_file('./log/test.log', date("d-m-Y: H:i:s"). ": ".$sql."\n" , FOPEN_WRITE_CREATE);
    115124                                                if (strlen($data['province'])>0){
    116125                                                        if (strlen($data['district'])>0){
     
    125134                                }
    126135                        }
    127                 }
     136                //}
    128137       
    129138                $order = "";
     
    158167                }
    159168               
    160                 if (isset($data['keyword']))
    161                 {
     169                //if (isset($data['keyword']))
     170                //{
    162171                        if (strlen($data['keyword'])>0){
    163172                                if ($data['status']==0){
     
    165174                                                if (strlen($data['district'])>0){
    166175                                                        if(strlen($data['daterange_start'])>0){
    167                                                         $sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    168                                                 }
    169                                                 }else{
    170                                                         if(strlen($data['daterange_start'])>0){
    171                                                         $sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    172                                                 }
     176                                                                $sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     177                                                        }else{
     178                                                                $sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     179                                                        }
     180                                               
     181                                                }else{
     182                                                        if(strlen($data['daterange_start'])>0){
     183                                                                $sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     184                                                        }else{
     185                                                                $sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     186                                                        }
     187                                               
    173188                                                }
    174189                                               
    175190                                        }else{
    176191                                                if(strlen($data['daterange_start'])>0){
    177                                                         $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     192                                                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    178193                                                }else
    179194                                                {
    180                                                         $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
     195                                                        $sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
    181196                                                }
    182197                                        }
     
    192207                                                }else{
    193208                                                        if(strlen($data['daterange_start'])>0){
    194                                                                 $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
    195                                                         }else{
    196                                                                 $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
     209                                                                $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
     210                                                        }else{
     211                                                                $sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
    197212                                                        }
    198213                                                }
     
    244259                                }
    245260                        }
    246                 }
    247                
     261                //}
     262                //write_file('./log/sql.log', date("d-m-Y: H:i:s"). ": ".$sql."\n" , FOPEN_WRITE_CREATE);
    248263                $query = $this->db->query($sql);
    249264                $row = $query->row_array();
  • pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php

    r690 r906  
    134134            <div class="modal-body">
    135135                <form id="add_user" onsubmit="return false;" class="form-horizontal" role="form">
    136                     <div class="form-group">
    137                         <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Tên đầy đủ </label>
    138 
    139                         <div class="col-sm-9">
    140                             <label class="block clearfix has-error">
    141                             <span class="input-icon">
    142                                 <input name="full_name" type="text" id="form-field-1" placeholder="Tên cộng tác viên">
    143                                 <i class="icon-user blue"></i>
    144                             </span>
    145                             <div id="full_name" class="help-block error"></div>
    146                             </label>
    147                         </div>
    148                         <div class="help-block"> </div>
     136                                         <div class="row">
     137                                                <div class="col-sm-9">
     138                                                        <div class="form-group">
     139                                                                <label for="cellphone" class="col-sm-4 control-label no-padding-right">Số điện thoại</label>
     140                                                                                                                                       
     141                                                                        <div class="col-sm-8">
     142                                                                                <input type="text" name="cellphone" placeholder="Số điện thoại" id="cellphone" class="col-xs-12 col-sm-10">
     143                                                                        </div>
     144                                                                        <label class="block clearfix has-error">       
     145                                                                                <small><div class="col-sm-8 help-block error" id="cellphone"> </div></small>
     146                                                                        </label>
     147                                                        </div>
     148                                                </div>
    149149                    </div>
    150                     <div class="form-group">
    151                         <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Tên đăng nhập </label>
    152 
    153                         <div class="col-sm-9">
    154                             <label class="block clearfix has-error">
    155                             <span class="input-icon">
    156                                 <input name="login_name" type="text" id="form-field-1" placeholder="Tài khoản">
    157                                 <i class="icon-user blue"></i>
    158                             </span>
    159                             <div id="login_name" class="help-block error"></div>
    160                             </label>
    161                         </div>
    162                         <div class="help-block"> </div>
    163                     </div>
    164                     <div class="form-group">
    165                         <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Số điện thoại</label>
    166 
    167                         <div class="col-sm-9">
    168                             <label class="block clearfix has-error">
    169                             <span class="input-icon">
    170                                 <input name="cellphone" type="text" id="form-field-1" placeholder="Số điện thoại">
    171                                 <i class="icon-user blue"></i>
    172                             </span>
    173                             <div id="cellphone" class="help-block error"></div>
    174                             </label>
    175                         </div>
    176                         <div class="help-block"> </div>
    177                     </div>
    178                     <div class="space-4"></div>
    179 
    180                     <div class="form-group">
    181                         <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> Mật khẩu </label>
    182 
    183                         <div class="col-sm-9">
    184                             <label class="block clearfix has-error">
    185                             <span class="input-icon">
    186                                 <input type="password" name="passwd" id="form-field-2" placeholder="Mật khẩu">
    187                                 <i class="icon-lock blue"></i>
    188                             </span>
    189                             <div id="passwd" class="help-block error"></div>
    190                             </label>
    191                         </div>
    192                         <div class="help-block"> </div>
    193                     </div>
    194                     <div class="form-group">
    195                         <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> Mật khẩu </label>
    196 
    197                         <div class="col-sm-9">
    198                             <span class="input-icon">
    199                                 <input type="password" name="passwd2" id="form-field-2" placeholder="Nhập lại mật khẩu">
    200                                 <i class="icon-lock blue"></i>
    201                             </span>
    202                         </div>
    203                         <div class="help-block"> </div>
    204                     </div>
    205                     <div class="form-group">
    206                         <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Kích hoạt</label>
    207 
    208                         <div class="col-sm-9">
    209                             <span class="input-icon">
    210                                 <input type='checkbox' name="activated" checked="checked" value="1"  />
    211                             </span>
    212                         </div>
    213                         <div class="help-block"> </div>
    214                     </div>
    215 
    216                     <div class="space-4"></div>
    217                     <div class="form-group errors" id="add_user"></div>
    218                        
    219                     </div>
     150                                       
    220151                    <div class="clearfix form-actions">
    221152                        <div class="col-md-offset-3 col-md-9">
  • pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/listview.php

    r838 r906  
    11<?php
    2 $admin_info = $this->session->userdata('adminInfo');
    3 $role_id = $admin_info['role_id'];
     2//$admin_info = $this->session->userdata('adminInfo');
     3//$role_id = $admin_info['role_id'];
    44?>
    55<div id="breadcrumbs" class="breadcrumbs">
     
    4545            <div style="padding-bottom:4px" class="table-header">
    4646                Thống kê tài khoản
    47                 <?php if ($role_id == 1): ?>
    48                     <button href="#addUser" data-toggle="modal" class="btn btn-success pull-right">
    49                         <i class="icon-plus"></i>
    50                         Thêm cộng tác viên
    51                     </button>
    52                 <?php endif; ?>
    53 
     47                                <?php if (in_array("editUserInfo", $roles)) { ?>
     48                                        <div class="col-xs-12 pull-right" style="margin:5px;">
     49                                                <div class="form-group">
     50                                                        <!--<input  class="btn btn-primary pull-right " type="button" value="Thêm cộng tác viên" onclick="admin_update_user();"/>-->
     51                                                        <button href="#addUser" data-toggle="modal" class="btn btn-success pull-right">
     52                                                        <i class="icon-plus"></i>
     53                                                                Thêm cộng tác viên
     54                                                        </button>
     55                                                </div>
     56                                        </div>
     57                                <?php } ?>
    5458            </div>
    5559
  • pro-violet-viettel/sourcecode/application/modules/admin/views/reportAsistant/listview_user.php

    r743 r906  
    4444                                <th class="<?php if ($sorting_field == 'full_name') {echo $sorting_order;} else {echo "";}?>" id="full_name" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Số điện thoại: activate to sort column ascending">Tên người dùng</th>
    4545                                <th class="<?php if ($sorting_field == 'collaborator_cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 283px;" aria-label="Họ tên: activate to sort column ascending">Số thuê bao</th>
    46                                 <th class="<?php if ($sorting_field == 'total_user') {echo $sorting_order;} else {echo "sorting";}?>" id="total_user" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Số điện thoại: activate to sort column ascending">Ngày giới thiệu</th> 
     46                                <th class="<?php if ($sorting_field == 'user_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="user_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Ngày giới thiệu: activate to sort column ascending">Ngày giới thiệu</th> 
    4747                                <!--<th class="<?php if ($sorting_field == 'collaborator_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="Ngày đăng kÜ: activate to sort column ascending">Ngày đăng kÜ</th>-->
    4848                                 
  • pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php

    r883 r906  
    1010                <div class="pull-right" style="margin:5px;">
    1111                    <!--<a style="color:#fff" href="<?php echo base_url();?>admin/reportprovince/export/<?php echo $month;?>/<?php echo $year;?>">Xuất ra Excel</a>-->
    12                                         <a style="color:#fff" href="<?php echo base_url();?>admin/reportprovince/exportProvince/<?php echo $month;?>/<?php echo $year;?>">Xuất ra Excel</a>
     12                                        <a style="color:#fff" href="<?php echo base_url();?>admin/reportprovince/exportProvince/<?php echo $to_date; ?>/<?php echo $month;?>/<?php echo $year;?>">Xuất ra Excel</a>
    1313                </div>
    1414            </div>
  • pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php

    r883 r906  
    4747                                <div class="pull-right" style="margin:5px;">
    4848                   
    49                                         <a style="color:#fff" href="<?php echo base_url();?>admin/user/export/<?php echo $current_page; ?>/<?php echo $perpage; ?>/<?php echo ($keyword)?$keyword:'default'; ?>/<?php echo $status; ?>/<?php echo ($province)?$povince:'default'; ?>/<?php echo ($district)?$district:'default';?>/<?php echo ($daterange)?$daterange:'default'; ?>/<?php echo $sorting_order; ?>/<?php echo $sorting_field;?>">Xuất ra Excel</a>
     49                                        <a style="color:#fff" href="<?php echo base_url();?>admin/user/export/<?php echo $current_page; ?>/<?php echo $perpage; ?>/<?php echo ($keyword)?$keyword:'default'; ?>/<?php echo $status; ?>/<?php echo ($province)?$province:'default'; ?>/<?php echo ($district)?$district:'default';?>/<?php echo ($date_start)?$date_start:'default'; ?>/<?php echo ($date_end)?$date_end:'default'; ?>/<?php echo $sorting_order; ?>/<?php echo $sorting_field;?>">Xuất ra Excel</a>
    5050                                       
    5151                </div>
     
    8383                                                                <div class="dataTables_province" style="float: right;" id="sample-table-2_status"><label>Lọc theo Tỉnh/TP:
    8484                                                                        <select onchange="filter();" name="province" class="form-field-province" size="1" style="width: 176px; height: 28px;">
    85                                                                                 <option value=''></option>
     85                                                                                <option value=''>Tất cả</option>
    8686                                               
    8787                                                                                <?php foreach ($provinces as $key => $pro): ?>
     
    9494                                                                        <select onchange="filter();" name="district" id="form-field-district" class="form-field-district" size="1" style="width: 176px; height: 28px;">
    9595                                                                                <?php if ($districts):?>
    96                                                                                         <option value=''></option>
     96                                                                                        <option value=''>Tất cả</option>
    9797                                                                                        <?php foreach ($districts as $key => $dist): ?>
    9898                                                                                                <option <?php if ($dist['district_id'] == $district) echo "selected"; ?> value="<?php echo $dist['district_id']; ?>"><?php echo $dist['district_name']; ?></option>
  • pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/collaborator.php

    r883 r906  
    1414                $this->lang->load('messages', 'message');
    1515    }
    16 
    17     public function index() {
    18         $data = array();
    19         $collaborator_info = $this->session->userdata('collaboratorInfo');
    20         if ($collaborator_info) {
    21             $data['statistics'] = $this->getStatistics();
    22             $data['content'] = $this->getCollaborators();
    23             $this->load->view('collaborator/reportAsistant/index', $data);
    24         } else {
    25             $this->load->view('login');
    26         }
    27     }
    28 
    29     public function viewAsistant() {
    30         $data = array();
    31 
    32         $collaborator_info = $this->session->userdata('collaboratorInfo');
    33         if ($collaborator_info) {
    34             $id = $this->uri->segment(2);
    35             $data['id'] = $id;
    36             $data['statistics'] = $this->getStatistics($id);
    37             $data['content'] = $this->getCollaboratorsUsers(array(), $id);
    38             $this->load->view('collaborator/reportAsistant/indexCollaborator', $data);
    39         } else {
    40             $this->load->view('login');
    41         }
    42     }
    43 
    44     public function getStatistics($id = false) {
    45         $data = array();
    46 
    47         $this_year['start'] = strtotime(date("Y") . "-01-01 00:00:00");
    48 
    49         $this->load->model('admin/collabolator_model');
    50         $collaborators = $this->collabolator_model->getAllCollaboratorUser($this_year['start'], $id);
    51         for ($i = 1; $i <= 12; $i++) {
    52             $statistics[$i] = 0;
    53         }
    54         $y = date("Y");
    55         foreach ($collaborators as $collaborator) {
    56             for ($i = 1; $i <= 12; $i++) {
    57                 if ($i < 12) {
    58                     if (($collaborator['time'] > strtotime($y . "-" . $i . "-1 00:00:00")) && (($collaborator['time'] < strtotime($y . "-" . ($i + 1) . "-1 00:00:00")))) {
    59                         $statistics[$i] ++;
    60                     }
    61                 } else {
    62                     if (($collaborator['time'] > strtotime($y . "-" . $i . "-1 00:00:00")) && (($collaborator['time'] < strtotime(($y + 1) . "-1-1 00:00:00")))) {
    63                         $statistics[$i] ++;
    64                     }
    65                 }
    66             }
    67         }
    68 
    69         $max = 0;
    70         foreach ($statistics as $index => $total) {
    71             if ($total > $max) {
    72                 $max = $total;
    73             }
    74             $chart[] = array($index, $total);
    75         }
    76 
    77         $data['max'] = $max;
    78         $chard[] = array("color" => "#e67e22", "label" => "Lượng người dùng giới thiệu bởi cộng tác viên theo từng tháng", "data" => $chart);
    79         $data['chard'] = $chard;
    80          
    81         return $this->load->view('collaborator/reportAsistant/statistics', $data, true);
    82     }
    83 
    84     public function getLastquarter() {
    85         $current_month = date('m');
    86         $current_year = date('Y');
    87 
    88         if ($current_month >= 1 && $current_month <= 3) {
    89             $start_date = strtotime('1-October-' . ($current_year - 1));  // timestamp or 1-October Last Year 12:00:00 AM
    90             $end_date = strtotime('1-Janauary-' . $current_year);  // // timestamp or 1-January  12:00:00 AM means end of 31 December Last year
    91         } else if ($current_month >= 4 && $current_month <= 6) {
    92             $start_date = strtotime('1-January-' . $current_year);  // timestamp or 1-Janauray 12:00:00 AM
    93             $end_date = strtotime('1-April-' . $current_year);  // timestamp or 1-April 12:00:00 AM means end of 31 March
    94         } else if ($current_month >= 7 && $current_month <= 9) {
    95             $start_date = strtotime('1-April-' . $current_year);  // timestamp or 1-April 12:00:00 AM
    96             $end_date = strtotime('1-July-' . $current_year);  // timestamp or 1-July 12:00:00 AM means end of 30 June
    97         } else if ($current_month >= 10 && $current_month <= 12) {
    98             $start_date = strtotime('1-July-' . $current_year);  // timestamp or 1-July 12:00:00 AM
    99             $end_date = strtotime('1-October-' . $current_year);  // timestamp or 1-October 12:00:00 AM means end of 30 September
    100         }
    101         return array("start" => $start_date, "end" => $end_date);
    102     }
    103 
    104 
    105     public function getCollaboratorsUsers($filters = array(), $id = false) {
    106 
    107         $this->load->helper('pagging');
    108         $this->load->model('admin/collabolator_model');
    109         $data['current_page'] = $this->uri->segment(5, 1);
    110 
    111         $data['itemsoptions'] = array(10, 25, 50, 100);
    112         $data['perpage'] = 10;
    113         if (!$id) {
    114             $data['id'] = $this->uri->segment(4, 1);
    115         } else {
    116             $data['id'] = $id;
    117         }
    118 
    119         $data['keyword'] = "";
    120         $data['sorting_order'] = "sorting_desc";
    121         $data['sorting_field'] = "id";
    122 
    123         if ($this->input->post('sorting_order')) {
    124             if ($this->input->post('sorting_order') != "sorting") {
    125                 $data['sorting_order'] = $this->input->post('sorting_order');
    126                 $data['sorting_field'] = $this->input->post('sorting_field');
    127             }
    128         }
    129         if ($this->input->post('items')) {
    130             $data['perpage'] = $this->input->post('items');
    131         }
    132         if ($this->input->post('keyword')) {
    133             $data['search_field'] = "";
    134             $data['keyword'] = $this->input->post('keyword');
    135 
    136             if (preg_match("/[0-9]/", $data['keyword'])) {
    137                 $data['search_field'] = "cellphone";
    138             }
    139         }
    140 
    141                 $data['daterange_start'] = "";
    142                 $data['daterange_end'] = "";
    143                 if ($this->input->post('daterange')){
    144                         $daterange = explode(" - ", $this->input->post('daterange'));
    145                         $daterange[0] = str_replace('/', '-', $daterange[0]);
    146                         $daterange[1] = str_replace('/', '-', $daterange[1]);
    147                         $data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
    148                         $data['daterange_end'] = date('Y-m-d H:is:s', strtotime($daterange[1].' + 1 day'));
    149                 }
    150                
    151         $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
    152         $data['total'] = $this->collabolator_model->countCountCollaboratorUsers($data);
    153         $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
    154         foreach ($data['paidlogs'] as $index=>$paidlog)
    155         {
    156             $data['paidlogs'][$index]['username']=$this->get_fullname($paidlog['us_id']);
    157         }
    158         $data['paging_url'] = base_url() . "/cong_tac_vien/thong_ke_cong_tac_vien/trang_ctv/" . $data['id'];
    159         $data['num_links'] = 2;
    160         $data['paging'] = pagging($data);
    161 
    162         if ($this->input->is_ajax_request()) {
    163             return $this->load->view('collaborator/reportAsistant/listview_user', $data);
    164         }
    165         return $this->load->view('collaborator/reportAsistant/listview_user', $data, true);
    166     }
    167 
    168     private function get_fullname($us_id) {
    169         $fullname="";
    170         $src = 'violet';
    171         $token = md5($us_id . self::TOKENPW);
    172         $this->load->model('admin/user_model');
    173         $data = $this->user_model->get_user_info($src, $us_id, $token);
    174         parse_str($data,$data);
    175         if (isset($data['fullname']))
    176         {
    177             $fullname=$data['fullname'];
    178         }
    179         return $fullname;
    180     }
    181 
     16       
    18217        public function profile(){
    18318                $collaborator_info = $this->session->userdata('collaboratorInfo');
    18419        if ($collaborator_info) {
    18520                        $data['collaborator_id'] = $collaborator_info['id'];
     21                        $data['username'] = $collaborator_info['login_name'];
     22                        $data['fullname'] = $collaborator_info['fullname'];
    18623                        $this->load->view('collaborator/collaborator_profile', $data);
     24                }else{
     25                        $this->load->view('login');
     26                }
     27        }
     28       
     29        public function updateCollaborator(){
     30                $this->load->model('collaborator_model');
     31                $collaborator_info = $this->session->userdata('collaboratorInfo');
     32                $result['success'] = 0;
     33        if ($collaborator_info) {
     34                       
     35                        $collaborator_id = $collaborator_info['id'];
     36                        $login_name = $collaborator_info['login_name'];
     37                        $input = $this->input->post();
     38                        if (strlen($input['fullname']) == 0) {
     39                                $result['errors'][] = array("content"=>lang('_SBG_FULLNAME_REQUIRED_MSG'),"field"=>"fullname_err");
     40                        }
     41                        if (!isset($result['errors'])) {
     42                                $collaborator = array('full_name' => $input['fullname']);
     43                                $result['success'] = 1;
     44                                $result['data'] = $this->collaborator_model->updateCollaborator($collaborator_id, $collaborator);
     45                $collaboratorData = array('login_name' => $login_name, 'id' => $collaborator_id, 'fullname' => $input['fullname'], 'logined_in' => TRUE);
     46                $this->session->set_userdata('collaboratorInfo', $collaboratorData);
     47                        }
     48                        echo json_encode($result);
    18749                }else{
    18850                        $this->load->view('login');
     
    19254        public function change_password(){
    19355                $this->load->model('collaborator_model');
    194                 //$collaborator_id = $this->uri->segment(4, 1);
    19556                $collaborator_info = $this->session->userdata('collaboratorInfo');
    19657        if ($collaborator_info) {
  • pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/home.php

    r883 r906  
    2020        if ($collaborator_info) {
    2121                        $id = $collaborator_info['id'];
    22             $data['id'] = $id;
    2322            $data['statistics'] = $this->getStatistics($id);
    24             $data['content'] = $this->getCollaboratorsUsers(array(), $id);
     23                        $data['content'] = $this->getCollaboratorsUsers();
    2524            $this->load->view('collaborator/reportAsistant/indexCollaborator', $data);
    2625        } else {
     
    122121
    123122
    124     public function getCollaboratorsUsers($filters = array(), $id = false) {
    125 
    126         $this->load->helper('pagging');
    127         $this->load->model('admin/collabolator_model');
    128         $data['current_page'] = $this->uri->segment(5, 1);
    129 
    130         $data['itemsoptions'] = array(10, 25, 50, 100);
    131         $data['perpage'] = 10;
    132         if (!$id) {
    133             $data['id'] = $this->uri->segment(4, 1);
    134         } else {
     123    public function getCollaboratorsUsers() {
     124                $collaborator_info = $this->session->userdata('collaboratorInfo');
     125        if ($collaborator_info) {
     126                        $this->load->helper('pagging');
     127                        $this->load->model('admin/collabolator_model');
     128                        $data['current_page'] = $this->uri->segment(5, 1);
     129                       
     130                        $data['itemsoptions'] = array(10, 25, 50, 100);
     131                        $data['perpage'] = 10;
     132                        $id = $collaborator_info['id'];
    135133            $data['id'] = $id;
    136         }
    137        
    138         $data['keyword'] = "";
    139         $data['sorting_order'] = "sorting_desc";
    140         $data['sorting_field'] = "id";
    141 
    142         if ($this->input->post('sorting_order')) {
    143             if ($this->input->post('sorting_order') != "sorting") {
    144                 $data['sorting_order'] = $this->input->post('sorting_order');
    145                 $data['sorting_field'] = $this->input->post('sorting_field');
    146             }
    147         }
    148         if ($this->input->post('items')) {
    149             $data['perpage'] = $this->input->post('items');
    150         }
    151         if ($this->input->post('keyword')) {
    152             $data['search_field'] = "";
    153             $data['keyword'] = $this->input->post('keyword');
    154 
    155             if (preg_match("/[0-9]/", $data['keyword'])) {
    156                 $data['search_field'] = "cellphone";
    157             }
    158         }
    159 
    160                 $data['daterange_start'] = "";
    161                 $data['daterange_end'] = "";
    162                 if ($this->input->post('daterange')){
    163                         $daterange = explode(" - ", $this->input->post('daterange'));
    164                         $daterange[0] = str_replace('/', '-', $daterange[0]);
    165                         $daterange[1] = str_replace('/', '-', $daterange[1]);
    166                         $data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
    167                         $data['daterange_end'] = date('Y-m-d H:is:s', strtotime($daterange[1].' + 1 day'));
     134                       
     135                        $data['keyword'] = "";
     136                        $data['sorting_order'] = "sorting_desc";
     137                        $data['sorting_field'] = "user_created_time";
     138
     139                        if ($this->input->post('sorting_order')) {
     140                                if ($this->input->post('sorting_order') != "sorting") {
     141                                        $data['sorting_order'] = $this->input->post('sorting_order');
     142                                        $data['sorting_field'] = $this->input->post('sorting_field');
     143                                }
     144                        }
     145                        if ($this->input->post('items')) {
     146                                $data['perpage'] = $this->input->post('items');
     147                        }
     148                        if ($this->input->post('keyword')) {
     149                                $data['search_field'] = "";
     150                                $data['keyword'] = $this->input->post('keyword');
     151
     152                                if (preg_match("/[0-9]/", $data['keyword'])) {
     153                                        $data['search_field'] = "cellphone";
     154                                }
     155                        }
     156
     157                        $data['daterange_start'] = "";
     158                        $data['daterange_end'] = "";
     159                        if ($this->input->post('daterange')){
     160                                $daterange = explode(" - ", $this->input->post('daterange'));
     161                                $daterange[0] = str_replace('/', '-', $daterange[0]);
     162                                $daterange[1] = str_replace('/', '-', $daterange[1]);
     163                                $data['date_start'] = $daterange[0];
     164                                $data['date_end'] = $daterange[1];
     165                                $data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
     166                                $data['daterange_end'] = date('Y-m-d H:is:s', strtotime($daterange[1].' + 1 day'));
     167                        }
     168                       
     169                        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
     170                        $data['total'] = $this->collabolator_model->countCountCollaboratorUsers($data);
     171                        $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
     172                        foreach ($data['paidlogs'] as $index => $paidlog)
     173                        {
     174                                $data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']);
     175                        }
     176                        $data['paging_url'] = base_url() . "collaborator/home/getCollaboratorsUsers/".$data['id'];
     177                        $data['num_links'] = 2;
     178                        $data['paging'] = pagging($data);
     179               
     180                        if ($this->input->is_ajax_request()) {
     181                                return $this->load->view('collaborator/reportAsistant/listview_user', $data);
     182                        }
     183                        return $this->load->view('collaborator/reportAsistant/listview_user', $data, true);
     184                }else{
     185                        $this->load->view('login');
    168186                }
    169                
    170         $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
    171         $data['total'] = $this->collabolator_model->countCountCollaboratorUsers($data);
    172         $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
    173 
    174         foreach ($data['paidlogs'] as $index => $paidlog)
    175         {
    176 
    177             $data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']);
    178         }
    179                
    180         $data['paging_url'] = base_url() . "cong_tac_vien/thong_ke_nguoi_dung/trang/" ;
    181         $data['num_links'] = 2;
    182         $data['paging'] = pagging($data);
    183                
    184         if ($this->input->is_ajax_request()) {
    185             return $this->load->view('collaborator/reportAsistant/listview_user', $data);
    186         }
    187         return $this->load->view('collaborator/reportAsistant/listview_user', $data, true);
    188187    }
    189188
     
    202201    }
    203202       
     203       
     204        public function export(){
     205               
     206                $collaborator_info = $this->session->userdata('collaboratorInfo');
     207        if ($collaborator_info) {
     208                        $id = $collaborator_info['id'];
     209            $data['id'] = $id;
     210                        $data['fullname'] = $collaborator_info['fullname'];
     211                        $this->load->model('admin/collabolator_model');
     212                        //$data['perpage'] = $this->uri->segment(4, 10);
     213                        $data['keyword'] = $this->uri->segment(5);
     214                        if ($data['keyword'] == 'default') $data['keyword'] = null;
     215                        if (preg_match("/[0-9]/", $data['keyword'])) {
     216                                        $data['search_field'] = "cellphone";
     217                        }
     218                        $data['daterange_start'] = $this->uri->segment(6);
     219                        $data['daterange_end'] = $this->uri->segment(7);
     220                        if ($data['daterange_start'] == 'default') $data['daterange_start'] = null;
     221                        if ($data['daterange_end'] == 'default') $data['daterange_end'] = null;
     222                        if ($data['daterange_start'])
     223                                $data['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $data ['daterange_start'] ) );
     224                        if ($data['daterange_end'])
     225                                $data['daterange_end'] = date ( 'Y-m-d H:i:s', strtotime ( $data['daterange_end'] . ' + 1 day' ) );
     226                       
     227                        $data['sorting_field'] = "user_created_time";
     228                        $data['sorting_order'] = $this->uri->segment(8);
     229                       
     230                        $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
     231                       
     232                        foreach ($data['paidlogs'] as $index => $paidlog)
     233                        {
     234                                $data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']);
     235                        }
     236                        $users = $data['paidlogs'];
     237                       
     238                        ob_end_clean();
     239                        $this->load->library("PHPExcel");
     240                        $sheet = $this->phpexcel->getActiveSheet();
     241                       
     242                        $sheet->setTitle("bao cao cua CTV " . date('m') . " - " . date('Y'));
     243                        $sheet->getColumnDimension('A')->setWidth(10);
     244                        $sheet->getColumnDimension('B')->setWidth(25);
     245                        $sheet->getColumnDimension('C')->setWidth(25);
     246                        $sheet->getColumnDimension('D')->setWidth(25);
     247                        $sheet->getColumnDimension('E')->setWidth(15);
     248                        $sheet->getColumnDimension('F')->setWidth(15);
     249                        $sheet->getColumnDimension('G')->setWidth(15);
     250                        $sheet->getColumnDimension('H')->setWidth(25);
     251                        $sheet->getColumnDimension('I')->setWidth(25);
     252                       
     253                       
     254                        $sheet->setCellValue('B1', "TẬP ĐOÀN VIỄN THÔNG QUÂN ĐỘI");
     255                        $style = array(
     256                                'font' => array('bold' => true, 'size' => 12, 'name' =>'Cambria', 'color' => array('rgb' => '0070bf')),
     257                                'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
     258                                                                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
     259                                                                        'wrap' => true )
     260                        );
     261                        $sheet->mergeCells('B1:E1');
     262                        $sheet->getStyle('B1')->applyFromArray($style);
     263                       
     264                        $sheet->setCellValue('B2', "TỔNG CÔNG TY VIỄN THÔNG VIETTEL");
     265                        $style = array(
     266                                'font' => array('size' => 12, 'name' =>'Cambria', 'color' => array('rgb' => '0070bf')),
     267                                'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
     268                                                                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
     269                                                                        'wrap' => true )
     270                        );
     271                        $sheet->mergeCells('B2:E2');
     272                        $sheet->getStyle('B2')->applyFromArray($style);
     273                       
     274                       
     275                        $sheet->setCellValue('A4', "DANH SÁCH NGƯỜI DÙNG DO CỘNG TÁC VIÊN GIỚI THIỆU");
     276                        $style = array(
     277                                'font' => array('bold' => true, 'size' => 14, 'name' =>'Cambria'),
     278                                'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
     279                                                                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
     280                                                                        'wrap' => true )
     281                        );
     282                        $sheet->mergeCells('A4:E4');
     283                        $sheet->getStyle('A4')->applyFromArray($style);
     284                       
     285                       
     286                       
     287                        $style = array(
     288                                'font' => array('size' => 11, 'name' =>'Cambria'),
     289                                'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
     290                                                                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
     291                                                                        'wrap' => true),
     292                                'borders' =>    array(
     293                                        'allborders' => array(
     294                                                'style' => \PHPExcel_Style_Border::BORDER_THIN
     295                                                )
     296                                )
     297                        );
     298                       
     299                        $sheet->setCellValue('B6', "Từ ngày: ".$data['daterange_start']);
     300                        $sheet->setCellValue('C6', "Đến ngày: ".$data['daterange_end']);
     301                        $sheet->setCellValue('B7', "Ngày kết xuất: ".date("d")."/".date("m")."/".date("Y"));
     302                        $sheet->setCellValue('C7', "CTV: ".$data['fullname']);
     303                       
     304                        $sheet->getStyle('B6')->applyFromArray($style);
     305                        $sheet->getStyle('C6')->applyFromArray($style);
     306                        $sheet->getStyle('B7')->applyFromArray($style);
     307                        $sheet->getStyle('C7')->applyFromArray($style);
     308                       
     309                        $sheet->setCellValue('A9', 'STT');
     310                        $sheet->setCellValue('B9', 'Tên người dùng');
     311                        $sheet->setCellValue('C9', 'Số thuê bao');
     312                        $sheet->setCellValue('D9', 'Ngày giờ giới thiệu');
     313                        $style = array(
     314                                'font' => array('bold' => true, 'size' => 11, 'name' =>'Cambria'),
     315                                'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
     316                                                                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
     317                                                                        'wrap' => true),
     318                                'borders' =>    array(
     319                                        'allborders' => array(
     320                                                'style' => \PHPExcel_Style_Border::BORDER_THIN
     321                                                )
     322                                )
     323                        );
     324                        $sheet->getStyle('A9:D9')->applyFromArray($style);
     325                       
     326                        $style = array(
     327                                'font' => array('size' => 11, 'name' =>'Cambria'),
     328                                'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
     329                                                                        'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
     330                                                                        'wrap' => true),
     331                                'borders' =>    array(
     332                                        'allborders' => array(
     333                                                'style' => \PHPExcel_Style_Border::BORDER_THIN
     334                                                )
     335                                )
     336                        );
     337                       
     338                        $dem = 0;
     339                        foreach ($users as $index => $user):
     340                                $sheet->setCellValue('A' . ($dem + 10), $index + 1);
     341                                $sheet->setCellValue('B' . ($dem + 10), $user['username']);
     342                                $sheet->setCellValueExplicit('C' . ($dem + 10), $user['user_cellphone'], PHPExcel_Cell_DataType::TYPE_STRING);
     343                                $sheet->setCellValue('D' . ($dem + 10), $user['user_created_time']);
     344                                $sheet->getStyle('A' . ($dem + 10).':D'.($dem + 10))->applyFromArray($style);
     345                                $dem++;
     346                        endforeach;
     347                       
     348                        $writer = new PHPExcel_Writer_Excel5($this->phpexcel);
     349                        header('Content-Type: application/vnd.ms-excel');
     350                        header('Content-Disposition: attachment; filename="danhsachnguoidung_ctv_'.date('d/m/Y').'.xls"');
     351                        $writer->save('php://output');
     352                }else{
     353                        $this->load->view('login');
     354                }
     355        }
     356       
    204357}
  • pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/user.php

    r883 r906  
    2222                        $this->load->view('collaborator/user/index', $data);
    2323                }else{
    24                         show_404();
     24                        $this->load->view(login);
    2525                }
    2626        }
     
    3232                        $collaborator = $collaborator_info['login_name'];
    3333                        $config['upload_path'] = './upload/uploads/';
    34                         $config['allowed_types'] = 'xls|xlsx';
    35                         /*$config['max_size']   = '100';
    36                         $config['max_width']  = '1024';
    37                         $config['max_height']  = '768';*/
    38                        
     34                        $config['allowed_types'] = '*';
    3935                        $this->load->library('upload', $config);
    4036                       
     
    4339                                $error = array('error' => $this->upload->display_errors('', ''));
    4440                                $data['success'] = 0;
    45                                 $data['process'] = $error;
     41                                $data['upload_error'] = $error;
    4642                        }
    4743                        else
     
    4945                                $data = array('upload_data' => $this->upload->data());
    5046                                $file = $data['upload_data']['full_path'];
    51                                 //$result = $this->processData($file);
    5247                                $process = $this->processData($file, $collaborator);
    5348                                if ($process){
    5449                                        $data['process'] = $process;
    55                                        
    5650                                }else{
    57                                         $data['process'] = null;
     51                                        $data['process'] = null;                               
    5852                                }
    5953                                $data['success'] = 1;
     
    6155                        $result = $this->load->view('collaborator/user/result', $data, true);
    6256                        echo json_encode($result);
     57
    6358                }else{
    64                         show_404();
     59                        $this->load->view('login');
    6560                }
    6661        }
     
    9388                $this->load->model('collaborator_model');
    9489                $data = $this->readExcelFile($file);
     90
    9591                $result = array();
    9692                $user = array();
     
    104100                                $user['district'] = $arrPD['district'];
    105101                                $user['school'] = $value['E'];
    106                                 $user['username'] = $this->services_model->formatPhoneNumber($value['F'], 2);
     102                                $user['username'] = $this->services_model->formatPhoneNumber((string)$value['F'], 2);
    107103                                $user['service'] = $value['G'];
    108104                                $user['amount'] = $value['H'];
    109105                                $user['collboratorId'] = $value['I'];
    110106                               
     107                               
    111108                                if ($user['username']){
    112109       
    113110                                        if (!preg_match('/^([0-9]{10,11}$)$/', $user['username'])) {
    114                                                 $result[$index]['success'] = 0;
    115                                                 $result[$index]['error'] = lang('_SBG_MO_PHONENUM_WRONG_FORMAT_MSG');
    116                                                 $result[$index]['user'] = $user;
     111                                                $result[$index-1]['success'] = 0;
     112                                                $result[$index-1]['error'] = lang('_SBG_MO_PHONENUM_WRONG_FORMAT_MSG');
     113                                                $result[$index-1]['user'] = $user;
    117114                                        }else{
    118                                                 $result[$index] = $this->collaborator_model->processUser($user, $sentNumber);
    119                                                
    120                                                
     115                                                $result[$index-1] = $this->collaborator_model->processUser($user, $sentNumber);
    121116                                        }
    122                                         $result[$index]['date'] = date('d-m-Y H:i:s');
    123117                                }
    124118                               
    125119                        endforeach;
    126120                }
    127                
    128121                return $result;
    129122        }
  • pro-violet-viettel/sourcecode/application/modules/collaborator/models/collaborator_model.php

    r883 r906  
    77if ( ! defined('_SBG_REGISTER_VIP_FOR'))                                define('_SBG_REGISTER_VIP_FOR',                                 'VIP');
    88if ( ! defined('_SBG_CHARGING_FOR'))                                    define('_SBG_CHARGING_FOR',                             'NAP');
    9 if ( ! defined('_SBG_SYNTAX_ERR'))                                      define('_SBG_SYNTAX_ERR',                       'SYNTAX_ERR');
     9if ( ! defined('_SBG_SYNTAX_ERR'))                                              define('_SBG_SYNTAX_ERR',                       'SYNTAX_ERR');
    1010
    1111if ( ! defined('_SBG_CHARGING_SUCCESS'))                                define('_SBG_CHARGING_SUCCESS', 1);
     
    2424if ( ! defined('_SBG_PAIDTYPE_CARD')) define('_SBG_PAIDTYPE_CARD', 2);
    2525
     26if ( ! defined('_SBG_MO_PROCCESS_ERR'))                                 define('_SBG_MO_PROCCESS_ERR', 0);
     27
    2628class Collaborator_model extends CI_Model {
    2729       
     
    4042                $this->load->helper('language');
    4143                $this->lang->load('messages', 'message');
    42         }
    43        
    44         public function isExistUser($username){
    45                 return false;
    4644        }
    4745       
     
    6664                }
    6765               
     66               
    6867                return array('case' => $case, 'content' => $aryContent);
    6968        }
    7069       
    71         public function processUser($user, $sentNumber){
     70        public function isExistUser($cellphone)
     71        {
     72                $sql = "SELECT * FROM tbluser WHERE cellphone = ?";
     73                $this->db->query($sql, array('cellphone'=>$cellphone));
     74                if ($this->db->affected_rows() >0){
     75                        return true;
     76                }else{
     77                        return false;
     78                }
     79        }
     80       
     81        public function processUser($user, $sentNumber)
     82        {
     83                $this->load->model('frontend/user_model');
     84                $data = array();
     85                $data['charging'] = array();
     86                $data['register-vip'] = array();
     87                $data['register'] = array();
     88                $username = $user['username'];
     89                $service = $user['service'];
     90                $amount = $user['amount'];
     91                $isExist = $this->isExistUser($username);
     92                //$isExist = false;
     93                if (!$isExist){
     94                        $data['register']['data'] = $this->registerUser($user, $sentNumber);
     95                        $user['service'] = "Đăng kÜ";
     96                        $user['amount'] = null;
     97                        $data['register']['user'] = $user;
     98                        $data['register']['date'] = date('d-m-Y H:i:s');
     99                }else{
     100                        $data['register']['data']['success'] = 0;
     101                        $data['register']['data']['error'] = "Người dùng đã tồn tại";
     102                        $user['service'] = "Đăng kÜ";
     103                        $user['amount'] = null;
     104                        $data['register']['user'] = $user;
     105                        $data['register']['date'] = date('d-m-Y H:i:s');
     106                }
     107               
     108                // NAP
     109                if ($amount){
     110                        $user['amount'] = $amount;
     111                        $data['charging']['data'] = $this->chargingForUser($user, $sentNumber);
     112                        $user['service'] = "Nạp tiền";
     113                        $data['charging']['user'] = $user;
     114                        $data['charging']['date'] = date('d-m-Y H:i:s');
     115                }
     116                if ($service){
     117                        // ĐK VIP
     118                       
     119                        $aryMatched = explode(' ', trim($service));
     120                        $p_code = $aryMatched[1];
     121                        $package = $package = $this->user_model->get_package ( $p_code );
     122                        $amount = $package['p_price'];
     123                        $user['amount'] = $amount;
     124                        $data['chargingvip']['data'] = $this->chargingForUser($user, $sentNumber);
     125                        $user['service'] = "Nạp tiền";
     126                        $data['chargingvip']['user'] = $user;
     127                        $data['chargingvip']['date'] = date('d-m-Y H:i:s');
     128                       
     129                        if ($data['chargingvip']['data']['success'] == 1){
     130                       
     131                                $data['register-vip']['data'] = $this->registerVipUser($user, $p_code);
     132                                $user['service'] = "Đăng kÜ ".trim($service);
     133                                $user['amount'] = -$amount;
     134                                $data['register-vip']['user'] = $user;
     135                                $data['register-vip']['date'] = date('d-m-Y H:i:s');
     136                        }else{
     137                                $data['register-vip']['data']['success'] = 0;
     138                                $data['register-vip']['data']['error'] = "Tài khoản chính cá»§a thuê bao ".$sentNumber. " khÃŽng đủ để thá»±c hiện giao dịch này";
     139                                $user['service'] = "Đăng kÜ ".trim($service);
     140                                $user['amount'] = -$amount;
     141                                $data['register-vip']['user'] = $user;
     142                                $data['register-vip']['date'] = date('d-m-Y H:i:s');
     143                        }
     144                       
     145                }
     146                /*     
     147                }elseif ($service){
     148                        // ĐK VIP
     149                        $aryMatched = explode(' ', trim($service));
     150                        $p_code = $aryMatched[1];
     151                        $data['register-vip']['data'] = $this->registerVipUser($user, $p_code);
     152                        $user['service'] = "Đăng kÜ ".trim($service);
     153                        $data['register-vip']['user'] = $user;
     154                        $data['register-vip']['date'] = date('d-m-Y H:i:s');
     155                }else{
     156                        // DK
     157                        $data['register']['data'] = $this->registerUser($user, $sentNumber);
     158                        $user['service'] = "Đăng kÜ";
     159                        $data['register']['user'] = $user;
     160                        $data['register']['date'] = date('d-m-Y H:i:s');
     161                }*/
     162                return $data;
     163        }
     164        /*
     165        public function processUser($user, $sentNumber)
     166        {
    72167                $data = array();       
    73168                $serviceAnalys = $this->serviceAnalys($user['service']);
    74169               
    75170                $case = $serviceAnalys['case'];
    76                 $aryContents = isset($serviceAnalys['content']) ? $serviceAnalys['content']: null;
     171                $aryContents = isset($serviceAn
     172                alys['content']) ? $serviceAnalys['content']: null;
    77173               
    78174                switch($case){
    79175                        case _SBG_REGISTER_FOR:
    80                                 $data = $this->registerUser($user);
     176                                $data = $this->registerUser($user, $sentNumber);
    81177                                break;
    82178                        case _SBG_REGISTER_VIP_FOR:
     
    98194               
    99195        }
    100 
    101         public function registerUser($user){
     196*/
     197        public function registerUser($user, $sentNumber)
     198        {
    102199
    103200                $data = array();
    104                 $data['user'] = $user;
     201                //$data['user'] = $user;
    105202                $this->load->model('frontend/user_model');
    106203                $this->load->model('services/services_model');
     
    108205                $token = md5($user['username'] . self::TOKENPW);
    109206                $sms = '';
    110                 $collborator = $user['collboratorId'];
     207                $collboratorId = $user['collboratorId'];
    111208                $username = $user['username'];
    112209                $password = $this->createRandomPassword();
     
    139236                                $arrUser['us_id'] = $us_id;
    140237                                $arrUser['cellphone'] = $username;
    141                                 $arrUser['collborator'] = $collborator;
     238                                $arrUser['collaborator'] = $sentNumber;
    142239                                $arrUser['acc_balanced'] = 0;
    143240                                $arrUser['p_id'] = $trialpackage['p_id'];
     
    178275        }
    179276       
    180         public function registerVipUser($arrUser, $p_code){
     277        public function registerVipUser($arrUser, $p_code)
     278        {
    181279                $data = array();
    182                 $data['user'] = $arrUser;
     280                //$data['user'] = $arrUser;
    183281                $this->load->model('frontend/user_model');
    184282                $username = $arrUser['username'];
     
    232330        }
    233331       
    234         public function chargingForUser($user, $sentNumber){
     332        public function chargingForUser($user, $sentNumber)
     333        {
    235334
    236335                $this->load->model('services/services_model');
    237336                $this->load->model('frontend/user_model');
    238337                $data = array();
    239                 $data['user'] = $user;
     338                //$data['user'] = $user;
    240339                $username = $user['username'];
    241340                $amount = $user['amount'];
     341               
     342                if (!preg_match('/^[0-9]{3,}$/', $amount)) {
     343                        $smsReturn = lang('_SBG_MO_AMOUNT_WRONG_FORMAT_MSG');
     344                        $data['success'] = 0;
     345                        $data['error'] = $smsReturn;
     346                }
    242347       
    243348                $result =$this->services_model->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG');
     
    284389        }
    285390       
    286        
    287         public function createRandomPassword(){
     391        public function getCollaboratorByPhone($sentNumber){
     392                $sql = "SELECT * from tblcollaborator where login_name = ? LIMIT 0,1";
     393                $query = $this->db->query ( $sql, array ( $sentNumber  ) );
     394                $row = $query->row_array ();
     395                return $row;
     396        }
     397       
     398        public function getPassword($sentNumber){
     399                $collaborator = array();
     400                $collaborator = $this->getCollaboratorByPhone($sentNumber);
     401                if ($collaborator){
     402                        $passwd = $this->createRandomPassword();
     403                        $collaborator['passwd'] = md5($passwd);
     404                        $this->updateCollaborator($collaborator['id'], $collaborator);
     405                        $aryPatterns = array('/:password:/');
     406                        $sms = preg_replace($aryPatterns, array($passwd), lang('_SBG_COLLABORATOR_PASSWORD_MSG'));
     407                        $status = 1;
     408                       
     409                }else{
     410                        $aryPatterns = array('/:collaborator:/');
     411                        $sms = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_COLLABORATOR_NOT_FOUND_MSG'));
     412                        $status = 0;
     413                }
     414                return $status . '|' . $sms;
     415        }
     416       
     417        public function createRandomPassword()
     418        {
    288419                $alphabet = "0123456789";
    289420                $pass = array ();
     
    296427        }
    297428       
    298         public function getProvinceAndDistict($province, $district){
    299                 $result['province'] = $province;
    300                 $result['district'] = $district;
     429        public function getProvinceAndDistict($province, $district)
     430        {
     431                $result['province'] = '';
     432                $p = trim(ucwords($province));
     433                $result['district'] = '';
     434                $d = trim(ucwords($district));
    301435                $provinces = lang('_PROVINCES_');
    302436
    303437                foreach ($provinces as $key => $pro):
    304                         if($province == $pro){
     438                        if($p == $pro){
    305439                                $result['province'] = $key;
    306440                                break;
    307441                        }
    308442                endforeach;
    309                 $sql = "SELECT * FROM tbldistrict where province_id = ? AND district_name = ?";
    310                
    311                 $query = $this->db->query ( $sql, array ($result['province'], $result['district']) );
     443                //$sql = "SELECT * FROM tbldistrict where province_id = ? AND district_name LIKE '%".$d."%'";
     444                $sql = "SELECT * FROM tbldistrict where province_id = ? AND INSTR(?, district_name)>0";
     445                //write_file('./log/sql.log', date('d-m-Y H:i:s') . ": " . $sql . "\n", FOPEN_WRITE_CREATE);
     446                $query = $this->db->query ( $sql, array ($result['province'], $d) );
    312447                if ($query->num_rows () > 0) {
    313448                        $row = $query->row_array ();
     
    317452        }
    318453       
    319         public function updateCollaborator($id, $collaborator){
     454        public function updateCollaborator($id, $collaborator)
     455        {
    320456                $this->db->where ( 'id', $id );
    321457                return $this->db->update ( 'tblcollaborator', $collaborator );
    322458        }
    323459       
    324         public function checkPassCollaborator($id, $passwd){
     460        public function checkPassCollaborator($id, $passwd)
     461        {
    325462                $passwd = md5($passwd);;
    326463                $sql = "SELECT * FROM tblcollaborator WHERE id = ? AND passwd = ?";
     
    332469                }
    333470        }
     471       
     472        public function insertUser($user)
     473        {
     474                $this->db->insert ( 'tbluser', $user );
     475                //var_dump($user);
     476                if ($this->db->affected_rows()>0){
     477                        return true;
     478                }else{
     479                        return false;
     480                }
     481        }
    334482}
  • pro-violet-viettel/sourcecode/application/modules/collaborator/views/collaborator_profile.php

    r883 r906  
    1818                <div class="collaborator-profile row" id="collaborator-profile-3">
    1919                    <div class="col-sm-offset-1 col-sm-10">
    20 
    2120                        <div class="tabbable">
    2221                            <ul class="nav nav-tabs padding-16">
    23 
    24                                 <li class="active">
    25                                     <a id="edit-password-tab" href="" data-toggle="tab">
     22                                                                <li class="active">
     23                                    <a id="edit-basic-tab" href="#edit-basic" data-toggle="tab">
     24                                        <i class="blue icon-key bigger-125"></i>
     25                                       ThÃŽng tin cá nhân
     26                                    </a>
     27                                </li>
     28                                <li>
     29                                    <a id="edit-password-tab" href="#edit-password" data-toggle="tab">
    2630                                        <i class="blue icon-key bigger-125"></i>
    2731                                       Thay đổi mật khẩu
    2832                                    </a>
    2933                                </li>
    30 
    3134                            </ul>
    32 
     35                                                       
    3336                            <div class="tab-content profile-edit-tab-content">
    34                                 <div class="tab-pane active" id="edit-password">
    35                                                                         <!--<form id="frm-change-password" class="form-horizontal" role="form" action="<?php echo $base_url; ?>collaborator/collaborator/change_password" method="POST">-->
     37                                                                <div class="tab-pane active" id="edit-basic">           
     38                                                                        <form id="frm-update-info" class="form-horizontal" role="form">
     39                                                                                <h4 class="header blue bolder smaller">ThÃŽng tin cá nhân</h4>
     40                                                                                <div class="row">
     41                                            <div class="col-sm-9">
     42                                                                                                <div class="form-group">
     43                                                                                                        <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Số điện thoại</label>
     44                                                                                                        <div class="col-sm-8">
     45                                                                                                                <input type="text" name="username" value="<?php echo $username; ?>" placeholder="Số điện thoại" id="form-field-username" class="col-xs-12 col-sm-10" disabled>
     46                                                                                                        </div>
     47                                                                                                </div>
     48                                                                                                <div class="form-group">
     49                                                                                                        <label for="form-field-first" class="col-sm-4 control-label no-padding-right">Họ và tên</label>
     50                                                                                                        <label class="block clearfix has-error">                                                                               
     51                                                                                                                <div class="col-sm-8">
     52                                                                                                                        <input type="text" name="fullname" value="<?php echo $fullname; ?>" placeholder="Họ và tên" id="form-field-first" class="col-xs-12 col-sm-10">
     53                                                                                                                </div>
     54                                                                                                                <small><div class="col-sm-8 help-block" id="fullname_err"> </div></small>
     55                                                                                                        </label>
     56                                                                                                </div>
     57                                                                                        </div>
     58                                        </div>
     59                                        <div class="clearfix form-actions">
     60                                            <div class="col-md-offset-3 col-md-9">
     61                                                <button type="button" onclick="return updateInfo();" class="btn btn-info">
     62                                                    <i class="icon-ok bigger-110"></i>
     63                                                    Cập nhật
     64                                                </button>       
     65                                            </div>
     66                                        </div>
     67                                                                        </form>
     68                                                                </div>
     69                                                               
     70                                <div class="tab-pane" id="edit-password">
     71                                                                       
    3672                                                                        <form id="frm-change-password" class="form-horizontal" role="form">
    3773                                                                                <h4 class="header blue bolder smaller">Thay đổi mật khẩu</h4>
     
    81117                                                                                        <div class="col-md-offset-3 col-md-9">
    82118                                                                                                <button type="button" onclick="return changePassword(<?php echo $collaborator_id; ?>);"  class="btn btn-info">
    83                                                                                                 <!--<button type="submit"  class="btn btn-info">-->
    84119                                                                                                        <i class="icon-ok bigger-110"></i>
    85120                                                                                                        Thay đổi
     
    90125                                                                                </form>
    91126                                </div>
     127                                                               
    92128
    93129                            </div>
     
    103139</div><!-- /.main-container-inner -->
    104140</div><!-- /.main-container -->
     141
     142<div class="modal fade" id="updateInfoSuccess" tabindex="-1" role="dialog"aria-hidden="true">
     143        <div class="modal-dialog">
     144                <div class="modal-content">
     145                        <div class="modal-header">
     146                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
     147                                <h4 class="modal-title">Cập nhật thÃŽng tin</h4>
     148                        </div>
     149                        <div class="modal-body">
     150                                <div class="alert alert-block alert-success"><center><?php echo lang('_SBG_USER_UPDATE_INFO_SUCCESS_MSG'); ?><center></div>
     151                                <center><button id="close" class="btn btn-primary" data-dismiss="modal">Đóng</button></center>
     152                        </div>
     153               
     154                </div>
     155        </div>
     156</div>
    105157
    106158<div class="modal fade" id="changePassSuccess" tabindex="-1" role="dialog"aria-hidden="true">
  • pro-violet-viettel/sourcecode/application/modules/collaborator/views/login.php

    r883 r906  
    8080                                                                                                                <div class="help-block"> </div>
    8181                                                                                                        </label>
     82                                                                                                       
     83                                                                                                        <label class="block clearfix alert-success">
     84                                                                                                                        Nếu chưa có hoặc quên mật khẩu, soạn tin nhắn theo cú pháp: <strong>SBG CTV</strong> gá»­i <strong>8062</strong>
     85                                                                                                        </label>
     86                                                                                                       
     87                                                                                               
    8288
    8389                                                                                                        <div class="space"></div>
  • pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/indexCollaborator.php

    r883 r906  
    1616                {
    1717                    // $result = jQuery.parseJSON(data);
     18                                        console.log(data);
    1819                    $("#content").html(data);
    1920                    init_page();
     
    122123                daterange = $('input[name="daterange"]').val();
    123124        $.ajax({
    124             url: '<?php echo base_url();?>cong_tac_vien/thong_ke_cong_tac_vien/trang_ctv/<?php echo $id;?>/1',
     125            url: '<?php echo base_url();?>collaborator/home/getCollaboratorsUsers/<?php echo $id;?>/1',
    125126            type: "POST",
    126127            data: $("#collaborator").serialize(),
     
    219220</div><!-- /.modal-dialog -->
    220221<?php
    221 $this->load->view('layout/admin/footer', array('base_url' => $base_url,'adminjs' => array('assets/js/admin/collaborator.js')));
     222$this->load->view('layout/collaborator/footer', array('base_url' => $base_url,'collaboratorjs' => array('assets/js/collaborator/collaborator.js')));
    222223?>
  • pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/listview_user.php

    r883 r906  
    33            <!-- PAGE CONTENT BEGINS -->
    44            <div style="padding-bottom:4px" class="table-header">
     5                       
    56                Đã giới thiệu
     7                                <div class="pull-right" style="margin:5px;">
     8                                        <a style="color:#fff" href="<?php echo base_url();?>collaborator/home/export/<?php echo $perpage?>/<?php echo ($keyword)?$keyword:'default'; ?>/<?php echo ($date_start)?$date_start:'default'; ?>/<?php echo ($date_end)?$date_end:'default'; ?>/<?php echo $sorting_order; ?>">Xuất ra Excel</a>
     9                                </div>
    610            </div>
    711
     
    4347                                <th class="<?php if ($sorting_field == 'full_name') {echo $sorting_order;} else {echo "";}?>" id="full_name" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Số điện thoại: activate to sort column ascending">Tên người dùng</th>
    4448                                <th class="<?php if ($sorting_field == 'collaborator_cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 283px;" aria-label="Họ tên: activate to sort column ascending">Số thuê bao</th>
    45                                 <th class="<?php if ($sorting_field == 'total_user') {echo $sorting_order;} else {echo "sorting";}?>" id="total_user" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Số điện thoại: activate to sort column ascending">Ngày giới thiệu</th> 
     49                                <th class="<?php if ($sorting_field == 'user_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="user_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Ngày giới thiệu: activate to sort column ascending">Ngày giới thiệu</th> 
    4650                                <!--<th class="<?php if ($sorting_field == 'collaborator_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="Ngày đăng kÜ: activate to sort column ascending">Ngày đăng kÜ</th>-->
    4751                                 
     
    5256                           
    5357                            <?php
     58                                                        //var_dump($paidlogs);
    5459                            foreach ($paidlogs as $paidlog) {
    5560                                ?>
  • pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/index.php

    r883 r906  
    2929     <div class="row" id="content">
    3030                <div class="col-xs-12">
    31                         <div class="row">
    32                                 <div class="col-sm-offset-1 col-sm-10">
    33                                         <form method="POST" id="frm-upload" action="" enctype="multipart/form-data" class="form-horizontal">
    34                                                 <h4 class="header blue bolder smaller">Chọn và tải file từ máy tính</h4>
    35                                                 <div class="row">
    36                                                         <div class="col-sm-9">
    37                                                                 <div class="form-group">
    38                                                                         <div class="col-sm-8" >
     31                        <div class="col-sm-offset-0 col-sm-12">
     32                                <div class="row">
     33                                <h4 class="header blue bolder smaller"> Bước 1: Tải file Đăng kÜ <a href="<?php echo $base_url ?>assets/Mau dang ky cua CTV.xls"><span style="color: red;">Tại đây</span></a></h4>
     34                                </div>
     35                                <div class="row">
     36                                        <h4 class="header blue bolder smaller">Bước 2: Điền thÃŽng tin vào file Đăng kÜ</h4>
     37                                        <h5>
     38                                        <ul class="nav">
     39                                                <li>    <b>Tên khách hàng</b>: KhÃŽng bắt buộc</li>
     40                                                <li>    <b>Tỉnh</b>: KhÃŽng bắt buộc</li>
     41                                                <li>    <b>Quận/Huyện</b>: KhÃŽng bắt buộc</li>
     42                                                <li>    <b>Đơn vị</b>: KhÃŽng bắt buộc</li>
     43                                                <li>    <b>Số điện thoại khách hàng</b>: Bắt buộc (có thể có số 0 đứng đầu hoặc khÃŽng có; phải là số điện thoại đi động, chỉ hỗ trợ Viettel, Vinaphone và Mobifone)</li>
     44                                                <li>    <b>Đăng kÜ gói dịch vụ</b>: KhÃŽng bắt buộc (Chọn VIP 1 hoặc VIP 3 hoặc để trống)</li>
     45                                                <li>    <b>Số tiền nạp vào TK SBG cá»§a khách hàng</b>: KhÃŽng bắt buộc (Nếu chọn thì chọn các giá trị có sẵn hoặc để trống)</li>
     46                                                <li>    <b>Mã CTV</b>: KhÃŽng bắt buộc</li>
     47                                        </ul>
     48                                        </h5>
     49                                </div>
     50                                <div class="row">
     51                                        <h4 class="header blue bolder smaller">Lưu Ü:</h4>
     52                                        <h5><ul>
     53                                                <li>    File đăng kÜ mẫu phải giữ nguyên định dạng XLS. KhÃŽng sá»­a định dạng cá»§a file mẫu, mọi sá»± thay đổi khÃŽng đúng sẜ có thể dẫn đến việc trừ tiền từ tài khoản cá»§a CTV khÃŽng đúng.</li>
     54                                                <li>    Các giao dịch trên file, nếu có tính phí thì phí sẜ được trừ trá»±c tiếp từ tài khoản chính cá»§a số điện thoại CTV (chính là số ĐT dùng để đăng nhập).</li>
     55                                        </ul></h5>
     56                                </div>
     57                               
     58                                <div class="row">
     59                                        <h4 class="header blue bolder smaller">Buớc 3: Upload file Đăng kÜ</h4>
     60                                        <div class="col-sm-offset-1 col-sm-10">
     61                                                <!--<h4 class="header blue bolder smaller">Chọn và tải file từ máy tính</h4>-->
     62                                                <form method="POST" id="frm-upload" action="" enctype="multipart/form-data" class="form-horizontal">
     63                                                       
     64                                                        <div class="row">
     65                                                                <div class="col-sm-9">
     66                                                                        <div class="form-group">
     67                                                                                <div class="col-sm-8" >
     68                                                                                       
     69                                                                                        <input type="text" id="input-upload" class="form-control"/>
     70                                                                                        <div class="file-upload btn btn-success">
     71                                                                                                <span>Chọn file ...</span>
     72                                                                                       
     73                                                                                                <input id="userfile" type="file" class="upload" name="userfile" />
     74                                                                                        </div>
     75                                                                                        <input type="submit" id="btn-submit" class="btn btn-primary" value="Tải lên" />
     76                                                                                </div>
    3977                                                                               
    40                                                                                 <input type="text" id="input-upload" class="form-control"/>
    41                                                                                 <div class="file-upload btn btn-success">
    42                                                                                         <span>Chọn file ...</span>
    43                                                                                
    44                                                                                         <input id="userfile" type="file" class="upload" name="userfile" />
    45                                                                                 </div>
    46                                                                                 <input type="submit" id="btn-submit" class="btn btn-primary" value="Tải lên" />
    4778                                                                        </div>
    48                                                                        
    4979                                                                </div>
    5080                                                        </div>
    51                                                 </div>
    52                                                 <h4 class="header blue bolder smaller"></h4>
    53                                                
     81                                                        <h4 class="header blue bolder smaller"></h4>
     82                                                       
    5483
    55                                         </form>
     84                                                </form>
     85                                        </div>
    5686                                </div>
    5787                        </div>
     
    6191        <center><label id="charging" style="display: none;"><h4><span class="icon-refresh icon-refresh-animate"></span> Đang xá»­ lÜ. Xin vui lòng chờ...</h4></label></center>
    6292        <div id="result">
    63         </div> 
     93        </div>
     94       
     95       
    6496</div><!-- /.main-content -->
    6597</div><!-- /.main-container-inner -->
  • pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/result.php

    r883 r906  
    1 <?php if($success==0){ ?>
     1<?php if ($success == 0){ ?>
    22        <div id="error-upload" class="alert alert-danger" role="alert">
    33                <span class="icon-exclamation-sign" aria-hidden="true"></span>
    4                 <span class="sr-only">Error:</span> <?php echo " ".$process['error']; ?>
     4                <span class="sr-only">Error:</span> <?php echo " ".$upload_error['error']; ?>
    55        </div>
    6 <?php }elseif($success == 1){ ?>
    7         <?php if ($process){?>
     6<?php }else { ?>
     7        <?php if($process){ ?>
    88                <div class="row">
    99                        <div class="col-xs-12">
    10                                 <!-- PAGE CONTENT BEGINS -->
    1110                                <div style="padding-bottom:4px" class="table-header">
    1211                                Kết quả
    1312                                </div>
    14                         <?php //if ($success == 0){ ?>
    15                                
    16                         <?php //}elseif($success == 1){ ?>
    1713                                <div class="table-responsive">
    1814                                        <div role="grid" class="dataTables_wrapper" id="sample-table-2_wrapper">
     
    2117                                                                <thead>
    2218                                                                        <tr role="row">
    23                                                                                 <th class="center sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 44px;" aria-label="">
    24                                                                                         <label>
    25                                                                                                 <input type="checkbox" class="ace">
    26                                                                                                 <span class="lbl"></span>
    27                                                                                         </label>
    2819                                                                                </th>
    2920                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Số điện thoại</th>
    3021                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Họ và tên</th>
    31                                                                                 <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Gói dịch vụ</th>
    32                                                                                 <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Số tiền nạp vào</th>
     22                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Tên dịch vụ</th>
     23                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Số tiền</th>
    3324                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Ngày giờ thá»±c hiện</th>
    3425                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Kết quả</th>
    3526                                                                                <th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">LÜ do</th>
    3627                                                                        </tr>
    37                                                                          <tbody role="alert" aria-live="polite" aria-relevant="all">
    38 
    39                                                                                 <?php
    40                                                                                 foreach ($process as $user): ?>
    41                                                                                 <tr class="odd">
    42                                                                                         <td class="center  sorting_1">
    43                                                                                                 <label>
    44                                                                                                         <input type="checkbox" class="ace">
    45                                                                                                         <span class="lbl"></span>
    46                                                                                                 </label>
    47                                                                                         </td>
    48                                                                                         <td class=" "><?php echo $user['user']['username']; ?></td>
    49                                                                                         <td class=" "><?php echo $user['user']['fullname']; ?></td>
    50                                                                                         <td class=" "><?php echo $user['user']['service']; ?></td>
    51                                                                                         <td class=" "><?php echo $user['user']['amount']; ?></td>
    52                                                                                         <td class=" "><?php echo $user['date']; ?></td>
    53                                                                                         <td class=" "><?php echo ($user['success'] == 1? "Thành cÃŽng": "KhÃŽng thành cÃŽng"); ?></td>
    54                                                                                         <td class=" "><?php  echo $user['error']; ?></td>
    55                                                                                 </tr>
    56                                                                                 <?php endforeach; ?>
     28                                                                        <tbody role="alert" aria-live="polite" aria-relevant="all">
     29                                                                        <?php foreach ($process as $result ){ ?>
     30                                                                       
     31                                                                                <?php if ($result['register']){ ?>
     32                                                                                        <tr>
     33                                                                                                <td class=" "><?php echo $result['register']['user']['username']; ?></td>
     34                                                                                                <td class=" "><?php echo $result['register']['user']['fullname']; ?></td>
     35                                                                                                <td class=" "><?php echo $result['register']['user']['service']; ?></td>
     36                                                                                                <td class=" "><?php echo $result['register']['user']['amount']; ?></td>
     37                                                                                                <td class=" "><?php echo $result['register']['date']; ?></td>
     38                                                                                                <td class=" "><?php echo ($result['register']['data']['success'] == 1? "Thành cÃŽng": "KhÃŽng thành cÃŽng"); ?></td>
     39                                                                                                <td class=" "><?php echo $result['register']['data']['error']; ?></td>
     40                                                                                        </tr>                                                                   
     41                                                                                <?php } ?>
     42                                                                               
     43                                                                                <?php if ($result['charging']){ ?>
     44                                                                                        <tr>
     45                                                                                                <td class=" "><?php echo $result['charging']['user']['username']; ?></td>
     46                                                                                                <td class=" "><?php echo $result['charging']['user']['fullname']; ?></td>
     47                                                                                                <td class=" "><?php echo $result['charging']['user']['service']; ?></td>
     48                                                                                                <td class=" "><?php echo number_format($result['charging']['user']['amount'], 0); ?></td>
     49                                                                                                <td class=" "><?php echo $result['charging']['date']; ?></td>
     50                                                                                                <td class=" "><?php echo ($result['charging']['data']['success'] == 1? "Thành cÃŽng": "KhÃŽng thành cÃŽng"); ?></td>
     51                                                                                                <td class=" "><?php echo $result['charging']['data']['error']; ?></td>
     52                                                                                        </tr>                                                                   
     53                                                                                <?php } ?>
     54                                                                               
     55                                                                                <?php if ($result['chargingvip']){ ?>
     56                                                                                        <tr>
     57                                                                                                <td class=" "><?php echo $result['chargingvip']['user']['username']; ?></td>
     58                                                                                                <td class=" "><?php echo $result['chargingvip']['user']['fullname']; ?></td>
     59                                                                                                <td class=" "><?php echo $result['chargingvip']['user']['service']; ?></td>
     60                                                                                                <td class=" "><?php echo number_format($result['chargingvip']['user']['amount'], 0); ?></td>
     61                                                                                                <td class=" "><?php echo $result['chargingvip']['date']; ?></td>
     62                                                                                                <td class=" "><?php echo ($result['chargingvip']['data']['success'] == 1? "Thành cÃŽng": "KhÃŽng thành cÃŽng"); ?></td>
     63                                                                                                <td class=" "><?php echo $result['chargingvip']['data']['error']; ?></td>
     64                                                                                        </tr>                                                                   
     65                                                                                <?php } ?>
     66                                                                               
     67                                                                                <?php if ($result['register-vip']){ ?>
     68                                                                                        <tr>
     69                                                                                                <td class=" "><?php echo $result['register-vip']['user']['username']; ?></td>
     70                                                                                                <td class=" "><?php echo $result['register-vip']['user']['fullname']; ?></td>
     71                                                                                                <td class=" "><?php echo $result['register-vip']['user']['service']; ?></td>
     72                                                                                                <td class=" "><?php echo number_format($result['register-vip']['user']['amount'], 0); ?></td>
     73                                                                                                <td class=" "><?php echo $result['register-vip']['date']; ?></td>
     74                                                                                                <td class=" "><?php echo ($result['register-vip']['data']['success'] == 1? "Thành cÃŽng": "KhÃŽng thành cÃŽng"); ?></td>
     75                                                                                                <td class=" "><?php echo $result['register-vip']['data']['error']; ?></td>
     76                                                                                        </tr>                                                                   
     77                                                                                <?php } ?>
     78                                                                               
     79                                                                               
     80                                                                        <?php } ?>
     81                                                                       
    5782                                                                        </tbody>
    5883                                                                </thead>
    59                                                                 </table>
     84                                                        </table>
    6085                                                </div>
    6186                                        </div>
    6287                                </div>
    6388                        </div>
    64                         </div>
    65         <?php }else{ ?>
    66                 <div id="error-upload" class="alert alert-danger" role="alert">
    67                         <span class="icon-exclamation-sign" aria-hidden="true"></span>
    68                         <span class="sr-only">Error:</span> KhÃŽng đọc được file</div>
     89                </div>                                                 
    6990        <?php } ?>
    7091<?php } ?>
  • pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php

    r884 r906  
    136136       
    137137        public function test(){
    138                 $aryMatch = array();
    139                 $phoneNumber = '987133325';
    140                 $regex = '/^[1,9][0-9]{8,9}$/';
    141                 if (preg_match('/^[1,9]([0-9]{8,9})$/', $phoneNumber, $aryMatch)){
    142                         $phoneNumber = "0".$phoneNumber;
    143                         echo $phoneNumber;
    144                 }else{
    145                         echo "Not match";
    146                 }
     138                $this->load->model('collaborator/collaborator_model');
     139                $province = ' Hà nội';
     140                //$str = trim(ucwords($str));
     141                $district = 'Quận Hai bà trưng';
     142                $str = $this->collaborator_model->getProvinceAndDistict($province, $district);
     143                var_dump($str);
     144                //echo "Result: ".$str;
    147145        }
    148146}
  • pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php

    r884 r906  
    5353            }
    5454                       
    55                         if ($u['province'] == '' && $u['p_id'] != ''){
     55                        if ((!$u['province'] || !$u['district']) && $u['p_id'] != ''){
    5656                                $update_user_info=1;
    5757                        }
  • pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php

    r884 r906  
    286286                                if (strlen($input['province']) == 0) {
    287287                    $result['errors'][] = array("content"=>lang('_SBG_PROVINCE_REQUIRED_MSG'),"field"=>"province");
     288                }
     289                                if (strlen($input['district']) == 0) {
     290                    $result['errors'][] = array("content"=>lang('_SBG_DISTRICT_REQUIRED_MSG'),"field"=>"district");
    288291                }
    289292                $input['password'] = '';
  • pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php

    r883 r906  
    100100                                $this->db->insert ( 'tbluser', $user );
    101101                                //write_file('./log/test.log', date("H:i:s m-d-Y").": ". var_export($user, TRUE)."\n" , FOPEN_WRITE_CREATE);
    102                                 $aryPatterns = array ('/:trialdays:/', '/:username:/', '/:password:/');
     102                                //$aryPatterns = array ('/:trialdays:/', '/:username:/', '/:password:/');
     103                                $aryPatterns = array ('/:username:/', '/:password:/');
    103104                                $trialdays = $this->config->item('trial_period');
    104105                                $trialdays = strlen($trialdays) < 2 ? '0'. $trialdays : $trialdays;
    105106                                if ($this->isViettel($username)){
    106                                         $sms = preg_replace($aryPatterns, array($trialdays. ' ngay', $username, $password), lang('_SBG_MO_USER_VIETTEL_REGISTER_SUCCESS_MSG'));
     107                                        $sms = preg_replace($aryPatterns, array($username, $password), lang('_SBG_MO_USER_VIETTEL_REGISTER_SUCCESS_MSG'));
    107108                                }else{
    108                                         $aryPatterns = array ('/:username:/', '/:password:/');
     109                                        //$aryPatterns = array ('/:username:/', '/:password:/');
    109110                                        $sms = preg_replace($aryPatterns, array($username, $password), lang('_SBG_MO_USER_NOT_VIETTEL_REGISTER_SUCCESS_MSG'));
    110111                                }
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php

    r838 r906  
    9393                                                </div>
    9494                                                <div class="form-group">
    95                                                         <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
     95                                                        <label for="form-field-district" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
    9696                                                        <div class="col-sm-8">
    9797                                                                <select name="district" id="form-field-district" class="input-large"></select>
     98                                                                <label class="block clearfix has-error">
     99                                                                        <div id="district" class="help-block error"></div>
     100                                </label>
    98101                                                        </div>
     102                                                       
    99103                                                </div>
    100104
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/user_infor.php

    r883 r906  
    2626            <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Tỉnh / Thành phố</label>
    2727            <div class="col-sm-8">
    28                 <select name="province" id="form-field-province" class="form-field-province col-xs-12 col-sm-10">
     28                <select name="province" id="form-field-province" class="form-field-province-user col-xs-12 col-sm-10">
     29                                        <option></option>
    2930                    <?php foreach ($provinces as $key => $pro): ?>
    3031                        <option value="<?php echo $key; ?>" <?php if ($user['province'] == $key) echo "selected"; ?>><?php echo $pro; ?></option>
     
    3839                        <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quận / Huyện</label>
    3940                        <div class="col-sm-8">
    40                                 <select name="district" id="form-field-district" class="form-field-district col-xs-12 col-sm-10">
     41                                <select name="district" id="form-field-district" class="form-field-district-user col-xs-12 col-sm-10">
    4142
    4243                                </select>
     
    6061var district_id = "<?php echo $user['district']; ?>";
    6162var province_id = "<?php echo $user['province']; ?>";
     63
    6264$(document).ready(function(){
    63         $(".form-field-province").change(function(){
     65        $(".form-field-province-user").change(function(){
    6466                changeEventProvince(province_id);
    6567        });
    66         if ($(".form-field-province").val() !== 'undefined'){
     68        if ($(".form-field-province-user").val() !== 'undefined'){
    6769                checkSelectedDistrict(province_id);
    6870        }
    6971});
     72
     73function changeEventProvince(provinceId){
     74        $(".form-field-district-user").html("");
     75        $.ajax({
     76        url: '/frontend/user/getDistrict/' + provinceId,
     77        type: 'POST',
     78        success: function (data, textStatus, jqXHR)
     79        {
     80            result = jQuery.parseJSON(data);
     81                        content = "<option></option>";
     82                        if (result != null){
     83                                for (var i in result){                 
     84                                        content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " "  + result[i].district_name + '</option>'
     85                                }
     86                        }
     87                        $(".form-field-district-user").html(content);
     88        }
     89    });
     90}
     91
     92function checkSelectedDistrict(provinceId){
     93        $.ajax({
     94        url: '/frontend/user/getDistrict/' + provinceId,
     95        type: 'POST',
     96        success: function (data, textStatus, jqXHR)
     97        {
     98            result = jQuery.parseJSON(data);   
     99                        content = "<option></option>";
     100                        if (result != null){
     101                                for (var i in result){
     102                                        if (result[i].district_id === district_id){
     103                                                content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
     104                                        }else{
     105                                                content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " "  + result[i].district_name + '</option>';
     106                                        }
     107                                }
     108                               
     109                        }
     110                        $(".form-field-district-user").html(content);
     111        }
     112    });
     113}
    70114</script>
  • pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php

    r838 r906  
    302302                                        <div class="alert alert-block alert-success">                                           
    303303                                            <p>
    304                                                 QuÜ vị cÅ©ng có thể sá»­ dụng số điện thoại&nbsp;<strong><?php echo $username;?></strong> và soạn tin theo cú pháp: <strong>SBG VIP 1</strong> (hay VIP 3, VIP 6, VIP 12) <strong>gá»­i tới 8062</strong> (Hệ thống sẜ trừ tiền trên tài khoản chính cá»§a số điện thoại&nbsp;<strong><?php echo $username;?></strong>)
     304                                                QuÜ vị cÅ©ng có thể sá»­ dụng số điện thoại&nbsp;<strong><?php echo $username;?></strong> và soạn tin theo cú pháp: <strong>SBG VIP 1</strong> (hay VIP 3) <strong>gá»­i tới 8062</strong> (Hệ thống sẜ trừ tiền trên tài khoản chính cá»§a số điện thoại&nbsp;<strong><?php echo $username;?></strong>)
    305305                                        </p>
    306306                                        </div>
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php

    r838 r906  
    4747                                                                'id'=>(int)$item['id'],
    4848                                                                'full_name'=>(string)$item['name'],
    49                                                                 'passwd' => md5($phoneNumber),
     49                                                                'passwd'=>md5($phoneNumber),
     50                                                                'login_name'=>$phoneNumber,
    5051                                                                'cellphone'=>$phoneNumber,
    5152                                                                'precinct'=>(string)$item['precinct'],
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r884 r906  
    11<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    22
    3 if ( ! defined('_SBG_MO_REGISTER'))                                     define('_SBG_MO_REGISTER',                              'SUBSCR');
    4 if ( ! defined('_SBG_MO_REGISTER_FOR'))                                 define('_SBG_MO_REGISTER_FOR',                  'SUBSCR_FOR');
    5 if ( ! defined('_SBG_MO_PHONENUM_CHANGE'))                              define('_SBG_MO_PHONENUM_CHANGE',               'PHONE_CHANGE');
    6 if ( ! defined('_SBG_MO_PASSWORD_RECOVERY'))                    define('_SBG_MO_PASSWORD_RECOVERY',     'PWD_RECOVER');
    7 if ( ! defined('_SBG_MO_VIP_REGISTER'))                                 define('_SBG_MO_VIP_REGISTER',                  'REG_VIP');
    8 if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT'))                               define('_SBG_MO_PAY_TO_ACCOUNT',                'PAY');
    9 if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT_FOR'))                   define('_SBG_MO_PAY_TO_ACCOUNT_FOR',    'PAY_FOR');
    10 if ( ! defined('_SBG_MO_UNSUBSCRIBE_SERVICE'))                  define('_SBG_MO_UNSUBSCRIBE_SERVICE',   'UNSUBSCR');
    11 if ( ! defined('_SBG_MO_SUPPOR_SERVICE'))                               define('_SBG_MO_SUPPOR_SERVICE',                'SUPPORT');
    12 if ( ! defined('_SBG_MO_SYNTAX_ERR'))                                   define('_SBG_MO_SYNTAX_ERR',                    'SYNTAX_ERR');
    13 
    14 if ( ! defined('_SBG_CARD_PAY_FAIL'))                                   define('_SBG_CARD_PAY_FAIL',                    -1);
    15 if ( ! defined('_SBG_CARD_PAY_SUCCESS'))                                define('_SBG_CARD_PAY_SUCCESS',                 1);
    16 
    17 if ( ! defined('_SBG_CHARGING_FAIL'))                                   define('_SBG_CHARGING_FAIL', -1);
    18 if ( ! defined('_SBG_CHARGING_SUCCESS'))                                define('_SBG_CHARGING_SUCCESS', 1);
    19 if ( ! defined('_SBG_CHARGING_FAIL_NOT_ENOUGH'))                define('_SBG_CHARGING_FAIL_NOT_ENOUGH', 401);
    20 if ( ! defined('_SBG_CHARGING_FAIL_NOT_VIETTEL'))               define('_SBG_CHARGING_FAIL_NOT_VIETTEL', 402);
    21 if ( ! defined('_SBG_CHARGING_NUMBER_NOT_EXISTED'))     define('_SBG_CHARGING_NUMBER_NOT_EXISTED', 403);
    22 if ( ! defined('_SBG_CHARGING_NUMBER_NOT_AVAILABLE'))   define('_SBG_CHARGING_NUMBER_NOT_AVAILABLE', 404);
    23 if ( ! defined('_SBG_CHARGING_NUMBER_CHANGED_OWNER'))   define('_SBG_CHARGING_NUMBER_CHANGED_OWNER', 405);
    24 if ( ! defined('_SBG_CHARGING_FAIL_MORETHAN_LIMIT'))    define('_SBG_CHARGING_FAIL_MORETHAN_LIMIT', 406);
    25 if ( ! defined('_SBG_CHARGING_GENERAL_ERROR'))                  define('_SBG_CHARGING_GENERAL_ERROR', 440);
    26 if ( ! defined('_SBG_CHARGING_NUMBER_NOT_REGISTED'))    define('_SBG_CHARGING_NUMBER_NOT_REGISTED', 501);
    27 if ( ! defined('_SBG_CHARGING_MAX_VALUE'))                              define('_SBG_CHARGING_MAX_VALUE', 50000);
    28 if ( ! defined('_SBG_CHARGING_MIN_VALUE'))                              define('_SBG_CHARGING_MIN_VALUE', 5000);
    29 
    30 
    31 if ( ! defined('_SBG_SEND_MT_FAIL'))                                    define('_SBG_SEND_MT_FAIL', -1);
    32 if ( ! defined('_SBG_SEND_MT_SUCCESS'))                                 define('_SBG_SEND_MT_SUCCESS', 1);
    33 if ( ! defined('_SBG_MT_SEND_NUMBER'))                                  define('_SBG_MT_SEND_NUMBER', '841662860000');
    34 if ( ! defined('_SBG_MT_CP_CODE'))                                              define('_SBG_MT_CP_CODE', '601');
    35 
    36 if ( ! defined('_SBG_SERVICE_COMMAND_CODE'))                    define('_SBG_SERVICE_COMMAND_CODE', 'SBG');
    37 if ( ! defined('_SBG_SERVICE_SERVICEID'))                               define('_SBG_SERVICE_SERVICEID', '8062');
    38 
    39 if ( ! defined('_SBG_MO_PROCCESS_ERR'))                                 define('_SBG_MO_PROCCESS_ERR', 0);
    40 
    41 if ( ! defined('_SBG_GET_COLLABORATOR_FAIL'))                   define('_SBG_GET_COLLABORATOR_FAIL', -1);
     3if ( ! defined('_SBG_MO_REGISTER'))                                             define('_SBG_MO_REGISTER',                                              'SUBSCR');
     4if ( ! defined('_SBG_MO_REGISTER_FOR'))                                         define('_SBG_MO_REGISTER_FOR',                                  'SUBSCR_FOR');
     5if ( ! defined('_SBG_MO_PHONENUM_CHANGE'))                                      define('_SBG_MO_PHONENUM_CHANGE',                               'PHONE_CHANGE');
     6if ( ! defined('_SBG_MO_PASSWORD_RECOVERY'))                            define('_SBG_MO_PASSWORD_RECOVERY',                     'PWD_RECOVER');
     7if ( ! defined('_SBG_MO_VIP_REGISTER'))                                         define('_SBG_MO_VIP_REGISTER',                                  'REG_VIP');
     8if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT'))                                       define('_SBG_MO_PAY_TO_ACCOUNT',                                'PAY');
     9if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT_FOR'))                           define('_SBG_MO_PAY_TO_ACCOUNT_FOR',                    'PAY_FOR');
     10if ( ! defined('_SBG_MO_UNSUBSCRIBE_SERVICE'))                          define('_SBG_MO_UNSUBSCRIBE_SERVICE',                   'UNSUBSCR');
     11if ( ! defined('_SBG_MO_SUPPOR_SERVICE'))                                       define('_SBG_MO_SUPPOR_SERVICE',                                'SUPPORT');
     12if ( ! defined('_SBG_MO_SYNTAX_ERR'))                                           define('_SBG_MO_SYNTAX_ERR',                                    'SYNTAX_ERR');
     13if ( ! defined('_SBG_MO_PASSWORD_COLLABORATOR_SERVICE'))        define('_SBG_MO_PASSWORD_COLLABORATOR_SERVICE', 'PWD_COLLABORATOR');
     14
     15if ( ! defined('_SBG_CARD_PAY_FAIL'))                                           define('_SBG_CARD_PAY_FAIL',                    -1);
     16if ( ! defined('_SBG_CARD_PAY_SUCCESS'))                                        define('_SBG_CARD_PAY_SUCCESS',                 1);
     17
     18if ( ! defined('_SBG_CHARGING_FAIL'))                                           define('_SBG_CHARGING_FAIL', -1);
     19if ( ! defined('_SBG_CHARGING_SUCCESS'))                                        define('_SBG_CHARGING_SUCCESS', 1);
     20if ( ! defined('_SBG_CHARGING_FAIL_NOT_ENOUGH'))                        define('_SBG_CHARGING_FAIL_NOT_ENOUGH', 401);
     21if ( ! defined('_SBG_CHARGING_FAIL_NOT_VIETTEL'))                       define('_SBG_CHARGING_FAIL_NOT_VIETTEL', 402);
     22if ( ! defined('_SBG_CHARGING_NUMBER_NOT_EXISTED'))             define('_SBG_CHARGING_NUMBER_NOT_EXISTED', 403);
     23if ( ! defined('_SBG_CHARGING_NUMBER_NOT_AVAILABLE'))           define('_SBG_CHARGING_NUMBER_NOT_AVAILABLE', 404);
     24if ( ! defined('_SBG_CHARGING_NUMBER_CHANGED_OWNER'))           define('_SBG_CHARGING_NUMBER_CHANGED_OWNER', 405);
     25if ( ! defined('_SBG_CHARGING_FAIL_MORETHAN_LIMIT'))            define('_SBG_CHARGING_FAIL_MORETHAN_LIMIT', 406);
     26if ( ! defined('_SBG_CHARGING_GENERAL_ERROR'))                          define('_SBG_CHARGING_GENERAL_ERROR', 440);
     27if ( ! defined('_SBG_CHARGING_NUMBER_NOT_REGISTED'))            define('_SBG_CHARGING_NUMBER_NOT_REGISTED', 501);
     28if ( ! defined('_SBG_CHARGING_MAX_VALUE'))                                      define('_SBG_CHARGING_MAX_VALUE', 50000);
     29if ( ! defined('_SBG_CHARGING_MIN_VALUE'))                                      define('_SBG_CHARGING_MIN_VALUE', 5000);
     30
     31
     32if ( ! defined('_SBG_SEND_MT_FAIL'))                                            define('_SBG_SEND_MT_FAIL', -1);
     33if ( ! defined('_SBG_SEND_MT_SUCCESS'))                                         define('_SBG_SEND_MT_SUCCESS', 1);
     34if ( ! defined('_SBG_MT_SEND_NUMBER'))                                          define('_SBG_MT_SEND_NUMBER', '841662860000');
     35if ( ! defined('_SBG_MT_CP_CODE'))                                                      define('_SBG_MT_CP_CODE', '601');
     36
     37if ( ! defined('_SBG_SERVICE_COMMAND_CODE'))                            define('_SBG_SERVICE_COMMAND_CODE', 'SBG');
     38if ( ! defined('_SBG_SERVICE_SERVICEID'))                                       define('_SBG_SERVICE_SERVICEID', '8062');
     39
     40if ( ! defined('_SBG_MO_PROCCESS_ERR'))                                         define('_SBG_MO_PROCCESS_ERR', 0);
     41
     42if ( ! defined('_SBG_GET_COLLABORATOR_FAIL'))                           define('_SBG_GET_COLLABORATOR_FAIL', -1);
    4243
    4344Class Services_model extends CI_Model
    4445{
    4546        private $_arySmsMO = array(
    46                 _SBG_MO_REGISTER                        => array('pattern' => '/^(SBG)([[:blank:]])(DK)$/'),
    47                 _SBG_MO_REGISTER_FOR            => array('pattern' => '/^(SBG)([[:blank:]])(DK)([[:blank:]])([0-9]{10,11})$/'),
    48                 //_SBG_MO_PHONENUM_CHANGE       => array('pattern' => '/^(SBG)([[:blank:]])(DDT)([[:blank:]])([0-9]{10,11})([[:blank:]])([a-zA-Z0-9]{1,})$/'),
    49                 _SBG_MO_PASSWORD_RECOVERY       => array('pattern' => '/^(SBG)([[:blank:]])(MK)$/'),
    50                 _SBG_MO_VIP_REGISTER            => array('pattern' => '/^(SBG)([[:blank:]])(VIP)([[:blank:]])([a-zA-Z0-9]{1,})$/'),
    51                 _SBG_MO_PAY_TO_ACCOUNT          => array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})$/'),
    52                 _SBG_MO_PAY_TO_ACCOUNT_FOR      => array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})([[:blank:]])([0-9]{10,11})$/'),
    53                 _SBG_MO_SUPPOR_SERVICE          => array('pattern' => '/^(SBG)([[:blank:]])(HD)$/'),
    54                 _SBG_MO_UNSUBSCRIBE_SERVICE => array('pattern' => '/^(SBG)([[:blank:]])(HUY)$/')
     47                _SBG_MO_REGISTER                                                => array('pattern' => '/^(SBG)([[:blank:]])(DK)$/'),
     48                _SBG_MO_REGISTER_FOR                                    => array('pattern' => '/^(SBG)([[:blank:]])(DK)([[:blank:]])([0-9]{10,11})$/'),
     49                //_SBG_MO_PHONENUM_CHANGE                               => array('pattern' => '/^(SBG)([[:blank:]])(DDT)([[:blank:]])([0-9]{10,11})([[:blank:]])([a-zA-Z0-9]{1,})$/'),
     50                _SBG_MO_PASSWORD_RECOVERY                               => array('pattern' => '/^(SBG)([[:blank:]])(MK)$/'),
     51                _SBG_MO_VIP_REGISTER                                    => array('pattern' => '/^(SBG)([[:blank:]])(VIP)([[:blank:]])([a-zA-Z0-9]{1,})$/'),
     52                _SBG_MO_PAY_TO_ACCOUNT                                  => array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})$/'),
     53                _SBG_MO_PAY_TO_ACCOUNT_FOR                              => array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})([[:blank:]])([0-9]{10,11})$/'),
     54                _SBG_MO_SUPPOR_SERVICE                                  => array('pattern' => '/^(SBG)([[:blank:]])(HD)$/'),
     55                _SBG_MO_UNSUBSCRIBE_SERVICE                     => array('pattern' => '/^(SBG)([[:blank:]])(HUY)$/'),
     56                _SBG_MO_PASSWORD_COLLABORATOR_SERVICE   => array('pattern' => '/^(SBG)([[:blank:]])(CTV)$/')
    5557        );
    5658
     
    113115                $aryContents = isset($aryMOAnalys['content']) ? $aryMOAnalys['content']: null;
    114116                $this->load->model('frontend/user_model', 'objUserModel');
     117                $this->load->model('collaborator/collaborator_model', 'objCollaboratorModel');
    115118                $debugMsg .= $case;
    116119
     
    262265                                }
    263266                                break;
    264 
     267                               
     268                        case _SBG_MO_PASSWORD_COLLABORATOR_SERVICE:
     269                                $smsReturn = $this->objCollaboratorModel->getPassword($sentNumber);
     270                                break;
     271                       
    265272                        case _SBG_MO_UNSUBSCRIBE_SERVICE:
    266273                        case _SBG_MO_SYNTAX_ERR:
     
    508515
    509516        public function deleteCollaborator($id){
    510                 $sql = "DELETE FROM tblcollaborator WHERE id = ". $id;
     517                $sql = "DELETE FROM tblcollaborator WHERE id = ". $id. " AND author is null";
    511518                $this->db->query($sql);
    512519                if ($this->db->affected_rows()){
Note: See TracChangeset for help on using the changeset viewer.