Ignore:
Timestamp:
Nov 4, 2014 4:14:22 PM (11 years ago)
Author:
quyenla
Message:

collaborator

Location:
pro-violet-viettel/sourcecode/application/modules/admin
Files:
4 edited

Legend:

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

    r373 r401  
    5656        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
    5757        $data['total'] = $this->collabolator_model->countCollaborator($data); 
    58         $data['collaborators'] = $this->collabolator_model->getCollaborator($data);
     58        $data['collaborators'] = $this->collabolator_model->getCollaborators($data);
    5959
    6060        $data['paging_url'] = base_url() . "/admin/cong_tac_vien/trang/";
     
    121121        echo json_encode($result);
    122122    }
    123 
     123    public function viewUser()
     124    {
     125        $id=$this->uri->segment(4);
     126        $this->load->model('collabolator_model');
     127        $data=$this->collabolator_model->getCollaborator($id);
     128        $this->load->view('collaborator/viewUser',$data);
     129    }
     130    public function editUser()
     131    {
     132        $id=$this->uri->segment(4);
     133        $this->load->model('collabolator_model');
     134        $data=$this->collabolator_model->getCollaborator($id);
     135        $this->load->view('collaborator/editUser',$data);
     136    }
     137    public function updateUser()
     138    {
     139        $input['activated']=0;
     140        $input=  array_merge($input,$this->input->post());
     141        $this->load->model('collabolator_model');
     142        if (strlen($input['full_name'])==0)
     143        {
     144            $result['errors'][]="Tên cộng tác viên khÃŽng được để trống";
     145        }
     146        if (strlen($input['login_name'])==0)
     147        {
     148            $result['errors'][]="Tên đăng nhập khÃŽng được để trống";
     149        }
     150        else
     151        {
     152            if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name'],'id'=>$input['id'])))
     153            {
     154                $result['errors'][]="Tên đăng nhập đã được sá»­ dụng";
     155            }
     156        }
     157        if (strlen($input['cellphone'])==0)
     158        {
     159            $result['errors'][]="Số điện thoại khÃŽng được để trống";
     160        }
     161        else
     162        {
     163            if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'],'id'=>$input['id'])))
     164            {
     165                $result['errors'][]="Số điện thoại đã được sá»­ dụng";
     166            }
     167        }
     168        if (strlen($input['passwd'])==0)
     169        {
     170            //$result['errors'][]="Mật khẩu khÃŽng được để trống";
     171        }
     172        if ($input['passwd'] != $input['passwd2'])
     173        {
     174            $result['errors'][]="Mật khẩu khÃŽng trùng nhau";
     175        }
     176        if (!isset($result['errors']))
     177        {
     178            unset($input['passwd2']);
     179            $input['activated']=1;
     180            $input['updated_time']=date("Y-m-d H:i:s");
     181            $this->load->model('collabolator_model');
     182            $this->collabolator_model->update($input['id'],$input);
     183            $result['success'] = 1;
     184        }
     185        echo json_encode($result);
     186    }
    124187    public function test() {
    125188       
    126         $this->load->library('doctrine');
     189       
    127190        for ($i = 1; $i <= 500; $i++) {
    128             $collaborator = new Entities\Tblcollaborator();
    129             $collaborator->setActivated(rand(0, 1));
    130             $collaborator->setAuthor(1);
    131             $collaborator->setCellphone('0' . (1695061706 + $i));
    132             $collaborator->setCreatedTime(date("Y-m-d H:i:s"));
    133             $collaborator->setFullName("Full Name " . $i);
    134             $collaborator->setLoginName("loginname" . $i);
    135             $collaborator->setPasswd(md5("12345678"));
    136             $collaborator->setUpdatedTime(date("Y-m-d H:i:s"));
    137             try {
    138                 $this->doctrine->em->persist($collaborator);
    139                 $this->doctrine->em->flush();
    140                 $result['success'] = 1;
    141             } catch (Exception $e) {
    142 
    143                 echo $e;
    144             }
     191            $input['full_name']="Full Name ".$i;
     192            $input['login_name']="loginname".$i;
     193            $input['passwd']=md5("12345678");
     194            $input['cellphone']="01234567".(100+$i);
     195            $input['activated']=rand(0,1);
     196            $input['created_time']=date("Y-m-d H:i:s");
     197            $input['updated_time']=date("Y-m-d H:i:s");
     198            $this->load->model('collabolator_model');
     199            $this->collabolator_model->insert($input);
    145200        }
    146201    }
  • pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php

    r374 r401  
    1212    }
    1313
    14     function getCollaborator($data) {
     14    function getCollaborators($data) {
    1515        $sql = "SELECT * FROM " . $this->table_name;
    1616        if ($data['keyword']) {
     
    3636
    3737    function isExist($data) {
    38         $sql = "SELECT COUNT(id) as total FROM " . $this->table_name . " WHERE " . $data['field'] . " = '" . $data['value'] . "' LIMIT 1";
    39         if ($this->db->query($sql)->row_array()['total'] == 1) {
     38        $sql = "SELECT COUNT(id) as total FROM " . $this->table_name . " WHERE " . $data['field'] . " = '" . $data['value'] . "'";
     39        if (isset($data['id']))
     40        {
     41            $id=$data['id'];
     42            $sql.=" AND id <> ".$id." LIMIT 1";
     43        }
     44        $result = $this->db->query($sql)->row_array();
     45        if ($result['total'] == 1) {
    4046            return true;
    4147        } else {
     
    5359            }
    5460        }
    55         if (isset($this->db->query($sql)->row_array()['total']))
    56         {
    57         return $this->db->query($sql)->row_array()['total'];
    58         }
    59         else
    60         {
    61             return 0;
    62         }
     61        $result = $this->db->query($sql)->row_array();
     62        return $result['total'];
     63    }
     64    function getCollaborator($id)
     65    {
     66        $sql="SELECT * FROM ".$this->table_name." WHERE id=".$id." LIMIT 1";
     67        $result = $this->db->query($sql)->row_array();
     68        return $result;
    6369    }
    6470
  • pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php

    r375 r401  
    22$base_url = base_url();
    33$this->load->view('layout/admin/header', array('base_url' => $base_url));
    4 $this->load->view('layout/admin/sidebar', array('base_url' => $base_url));
     4$this->load->view('layout/admin/sidebar', array('base_url' => $base_url, 'method'=>$this->router->method, 'class'=>$this->router->class  ));
    55?>
    66<script type="text/javascript">
     
    3535       
    3636       
    37 $( '.sorting, .sorting_desc, .sorting_asc' ).click(function( index ) {
     37        $( '.sorting, .sorting_desc, .sorting_asc' ).click(function( index ) {
    3838            var current_class=$( this ).attr('class');
    3939            $(".sorting_desc").attr("class","sorting");
     
    6262            filter();
    6363        });
     64        $('[data-toggle="ajaxModal"]').on('click',
     65              function(e) {
     66                $('#ajaxModal').remove();
     67                e.preventDefault();
     68                var $this = $(this)
     69                  , $remote = $this.data('remote') || $this.attr('href')
     70                  , $modal = $('<div class="modal" id="ajaxModal"><div class="modal-body"></div></div>');
     71                $('body').append($modal);
     72                $modal.modal({backdrop: 'static', keyboard: false});
     73                $modal.load($remote);
     74              }
     75            );
    6476
    6577
  • pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/listview.php

    r373 r401  
    8383                                    </label>
    8484                                </th>
     85                             
     86                                <th class="<?php if ($sorting_field == 'full_name') {echo $sorting_order;} else {echo "sorting";}?>" id="full_name" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 183px;" aria-label="Họ tên: activate to sort column ascending">Họ tên</th>
    8587                                <th class="<?php if ($sorting_field == 'cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="cellphone" 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">Số điện thoại</th>
    86                                 <th class="<?php if ($sorting_field == 'full_name') {echo $sorting_order;} else {echo "sorting";}?>" id="full_name" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 183px;" aria-label="Họ tên: activate to sort column ascending">Họ tên</th>
    8788                                <th class="sorting" id="money" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 122px;" aria-label="Tiền: activate to sort column ascending">Tiền</th>
    8889                                <th class="<?php if ($sorting_field == 'created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="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">
     
    107108                                </td>
    108109
     110                               
     111                                <td class=" "><?php echo $collaborator['full_name']?></td>
    109112                                <td class=" ">
    110113                                    <a href="#"><?php echo $collaborator['cellphone']?></a>
    111114                                </td>
    112                                 <td class=" "><?php echo $collaborator['full_name']?></td>
    113115                                <td class="hidden-480 ">3,330 VND</td>
    114116                                <td class=" "><?php echo $collaborator['created_time']?></td>
     
    131133                                    <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
    132134                                        <a href="#" class="blue">
    133                                             <i class="icon-zoom-in bigger-130"></i>
     135                                            <i data-toggle="ajaxModal" href='http://viettel.violet.vn/admin/cong_tac_vien/xem/<?php echo $collaborator['id'];?>'  class="icon-zoom-in bigger-130"></i>
    134136                                        </a>
    135137
    136138                                        <a href="#" class="green">
    137                                             <i class="icon-pencil bigger-130"></i>
     139                                            <i data-toggle="ajaxModal" href='http://viettel.violet.vn/admin/cong_tac_vien/sua/<?php echo $collaborator['id'];?>' data-toggle="modal" href='#editUser' class="icon-pencil bigger-130"></i>
    138140                                        </a>
    139141
    140142                                        <a href="#" class="red">
    141                                             <i class="icon-trash bigger-130"></i>
     143                                            <i data-toggle="ajaxModal" href='http://viettel.violet.vn/admin/cong_tac_vien/xoa/<?php echo $collaborator['id'];?>' data-toggle="modal" href='#deleteUser' class="icon-trash bigger-130"></i>
    142144                                        </a>
    143145                                    </div>
Note: See TracChangeset for help on using the changeset viewer.