Changeset 366 for pro-violet-viettel/sourcecode
- Timestamp:
- Oct 31, 2014 2:55:30 PM (11 years ago)
- Location:
- pro-violet-viettel/sourcecode
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php
r363 r366 52 52 53 53 public function addCollaborator() { 54 54 $result['success'] = 0; 55 55 $result = array(); 56 56 $input = $this->input->post(); 57 57 $this->load->model('collabolator_model'); 58 $this->collabolator_model->insert($input); 59 $result['success'] = 1; 58 if (strlen($input['full_name'])==0) 59 { 60 $result['errors'][]="Tên cá»ng tác viên khÃŽng ÄÆ°á»£c Äá» trá»ng"; 61 } 62 if (strlen($input['login_name'])==0) 63 { 64 $result['errors'][]="Tên ÄÄng nháºp khÃŽng ÄÆ°á»£c Äá» trá»ng"; 65 } 66 else 67 { 68 if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name']))) 69 { 70 $result['errors'][]="Tên ÄÄng nháºp Äã ÄÆ°á»£c sá» dụng"; 71 } 72 } 73 if (strlen($input['cellphone'])==0) 74 { 75 $result['errors'][]="Sá» Äiá»n thoại khÃŽng ÄÆ°á»£c Äá» trá»ng"; 76 } 77 else 78 { 79 if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone']))) 80 { 81 $result['errors'][]="Sá» Äiá»n thoại Äã ÄÆ°á»£c sá» dụng"; 82 } 83 } 84 if (strlen($input['passwd'])==0) 85 { 86 $result['errors'][]="Máºt khẩu khÃŽng ÄÆ°á»£c Äá» trá»ng"; 87 } 88 if ($input['passwd'] != $input['passwd2']) 89 { 90 $result['errors'][]="Máºt khẩu khÃŽng trùng nhau"; 91 } 92 if (!isset($result['errors'])) 93 { 94 unset($input['passwd2']); 95 $input['activated']=1; 96 $input['created_time']=date("Y-m-d H:i:s"); 97 $input['updated_time']=date("Y-m-d H:i:s"); 98 $this->load->model('collabolator_model'); 99 $this->collabolator_model->insert($input); 100 $result['success'] = 1; 101 } 102 103 60 104 echo json_encode($result); 61 105 } -
pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php
r360 r366 4 4 { 5 5 6 protected $table_name = 'tblcollabo lator';6 protected $table_name = 'tblcollaborator'; 7 7 protected $id_name = 'id'; 8 8 … … 13 13 function getCollaborator($data) 14 14 { 15 $sql="SELECT * FROM tblcollaborator";15 $sql="SELECT * FROM ".$this->table_name; 16 16 $data['keyword']=''; 17 17 18 18 if ($data['keyword']) 19 19 { 20 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";20 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') "; 21 21 } 22 return $this->db->query($sql." LIMIT ".$data['start'].", ".$data['perpage']."")->result_array();22 return $this->db->query($sql." ORDER BY id DESC LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array(); 23 23 24 } 25 function isExist($data) 26 { 27 $sql="SELECT COUNT(id) as total FROM ".$this->table_name." WHERE ".$data['field']." = '".$data['value']."' LIMIT 1"; 28 if ($this->db->query($sql)->row_array()['total']==1) 29 { 30 return true; 31 } 32 else 33 { 34 return false; 35 } 36 24 37 } 25 38 function countCollaborator($data) 26 39 { 27 $sql="SELECT COUNT(id) as total FROM tblcollaborator";40 $sql="SELECT COUNT(id) as total FROM ".$this->table_name; 28 41 if (isset($data['keyword'])) 29 42 { 30 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";43 $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') "; 31 44 } 32 45 -
pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php
r359 r366 131 131 <div class="help-block"> </div> 132 132 </div> 133 <div class="form-group"> 134 <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> Máºt khẩu </label> 135 136 <div class="col-sm-9"> 137 <span class="input-icon"> 138 <input type="password" name="passwd2" id="form-field-2" placeholder="Nháºp lại máºt khẩu"> 139 <i class="icon-lock blue"></i> 140 </span> 141 </div> 142 <div class="help-block"> </div> 143 </div> 133 144 134 145 <div class="space-4"></div> 135 146 <div class="form-group errors" id="add_user"> 147 148 </div> 136 149 <div class="clearfix form-actions"> 137 150 <div class="col-md-offset-3 col-md-9"> -
pro-violet-viettel/sourcecode/assets/js/admin/collaborator.js
r360 r366 7 7 })(jQuery); 8 8 $(".btn#add_user").click(function () 9 { 9 {$(".errors#add_user").html(""); 10 10 $.ajax({ 11 11 url: "cong_tac_vien/them", … … 14 14 success: function (data, textStatus, jqXHR) 15 15 { 16 // $result = jQuery.parseJSON(data); 17 $("#content").html(data); 18 init_page(); 19 16 $result = jQuery.parseJSON(data); 17 if ($result.success == "1") 18 { 19 filter(); 20 $('#addUser').modal('hide'); 21 } 22 else 23 { 24 25 for(var i =0;i < $result.errors.length;i++) 26 { 27 var er= $result.errors[i]; 28 $(".errors#add_user").append("<div class='error'>"+er+"</div>"); 29 } 30 } 31 20 32 }, 21 error: function (jqXHR, textStatus, errorThrown) 22 { 23 $(".ajaxloading").hide(); 24 } 33 25 34 }); 26 35
Note: See TracChangeset
for help on using the changeset viewer.