Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php	(revision 365)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php	(revision 366)
@@ -52,10 +52,54 @@
 
     public function addCollaborator() {
-        
+        $result['success'] = 0;
         $result = array();
         $input = $this->input->post();
         $this->load->model('collabolator_model');
-        $this->collabolator_model->insert($input);
-        $result['success'] = 1;
+        if (strlen($input['full_name'])==0)
+        {
+            $result['errors'][]="TÃªn cá»ng tÃ¡c viÃªn khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        if (strlen($input['login_name'])==0)
+        {
+            $result['errors'][]="TÃªn ÄÄng nháº­p khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        else
+        {
+            if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name'])))
+            {
+                $result['errors'][]="TÃªn ÄÄng nháº­p ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng";
+            }
+        }
+        if (strlen($input['cellphone'])==0)
+        {
+            $result['errors'][]="Sá» Äiá»n thoáº¡i khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        else
+        {
+            if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'])))
+            {
+                $result['errors'][]="Sá» Äiá»n thoáº¡i ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng";
+            }
+        }
+        if (strlen($input['passwd'])==0)
+        {
+            $result['errors'][]="Máº­t kháº©u khÃŽng ÄÆ°á»£c Äá» trá»ng";
+        }
+        if ($input['passwd'] != $input['passwd2'])
+        {
+            $result['errors'][]="Máº­t kháº©u khÃŽng trÃ¹ng nhau";
+        }
+        if (!isset($result['errors']))
+        {
+            unset($input['passwd2']);
+            $input['activated']=1;
+            $input['created_time']=date("Y-m-d H:i:s");
+            $input['updated_time']=date("Y-m-d H:i:s");
+            $this->load->model('collabolator_model');
+            $this->collabolator_model->insert($input);
+            $result['success'] = 1;
+        }
+
+        
         echo json_encode($result);
     }
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php	(revision 365)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php	(revision 366)
@@ -4,5 +4,5 @@
 {
 	
-	protected $table_name = 'tblcollabolator';
+	protected $table_name = 'tblcollaborator';
 	protected $id_name = 'id';
 
@@ -13,20 +13,33 @@
 	function getCollaborator($data)
         {
-            $sql="SELECT * FROM tblcollaborator";
+            $sql="SELECT * FROM ".$this->table_name;
             $data['keyword']='';
 
             if ($data['keyword'])
             {
-            $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%')";
+            $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";
             }
-            return $this->db->query($sql." LIMIT ".$data['start'].", ".$data['perpage']."")->result_array();
+            return $this->db->query($sql." ORDER BY id DESC LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
 
+        }
+        function isExist($data)
+        {
+            $sql="SELECT COUNT(id) as total FROM ".$this->table_name." WHERE ".$data['field']." = '".$data['value']."' LIMIT 1";
+            if ($this->db->query($sql)->row_array()['total']==1)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+            
         }
         function countCollaborator($data)
         {
-            $sql="SELECT COUNT(id) as total FROM tblcollaborator";
+            $sql="SELECT COUNT(id) as total FROM ".$this->table_name;
             if (isset($data['keyword']))
             {
-            $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%')";
+            $sql.=" WHERE (full_name LIKE '%".$data['keyword']."%' OR login_name LIKE '%".$data['keyword']."%') ";
             }
 
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php	(revision 365)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php	(revision 366)
@@ -131,7 +131,20 @@
                         <div class="help-block"> </div>
                     </div>
+                    <div class="form-group">
+                        <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> Máº­t kháº©u </label>
+
+                        <div class="col-sm-9">
+                            <span class="input-icon">
+                                <input type="password" name="passwd2" id="form-field-2" placeholder="Nháº­p láº¡i máº­t kháº©u">
+                                <i class="icon-lock blue"></i>
+                            </span>
+                        </div>
+                        <div class="help-block"> </div>
+                    </div>
 
                     <div class="space-4"></div>
-
+                    <div class="form-group errors" id="add_user">
+                        
+                    </div>
                     <div class="clearfix form-actions">
                         <div class="col-md-offset-3 col-md-9">
Index: pro-violet-viettel/sourcecode/assets/js/admin/collaborator.js
===================================================================
--- pro-violet-viettel/sourcecode/assets/js/admin/collaborator.js	(revision 365)
+++ pro-violet-viettel/sourcecode/assets/js/admin/collaborator.js	(revision 366)
@@ -7,5 +7,5 @@
 })(jQuery);
 $(".btn#add_user").click(function () 
-{
+{$(".errors#add_user").html("");
     $.ajax({
                 url: "cong_tac_vien/them",
@@ -14,13 +14,22 @@
                 success: function (data, textStatus, jqXHR)
                 {
-                    // $result = jQuery.parseJSON(data);
-                    $("#content").html(data);
-                    init_page();
-
+                    $result = jQuery.parseJSON(data);
+                    if ($result.success == "1")
+                    {   
+                    filter();
+                    $('#addUser').modal('hide');
+                    }
+                    else
+                    {
+                        
+                        for(var i =0;i < $result.errors.length;i++)
+                        {
+                          var er= $result.errors[i];
+                          $(".errors#add_user").append("<div class='error'>"+er+"</div>");
+                        }
+                    }
+                    
                 },
-                error: function (jqXHR, textStatus, errorThrown)
-                {
-                    $(".ajaxloading").hide();
-                }
+               
             });
         
