Index: pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php	(revision 461)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php	(revision 464)
@@ -34,15 +34,47 @@
         return $this->db->query($sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " ")->result_array();
     }
-    function getAllCollaboratorUser($from)
+    function getAllCollaboratorUser($from,$id=false)
     {
         $from = date("Y-m-d 00:00:00",$from); 
-        $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."'";
-
-        $result = $this->db->query($sql)->result_array();
-        foreach ($result as $index=>$paidlog)
-        {
-            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
-        }
-        return $result;
+        $where="";
+        if ($id)
+        {
+            $where = " AND tbluser.collaborator = $id ";
+        }
+        $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."";
+
+        $result = $this->db->query($sql)->result_array();
+        foreach ($result as $index=>$paidlog)
+        {
+            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
+        }
+        return $result;
+    }
+    function countCountCollaboratorUser($data)
+    {
+        $order = "";
+        if ($data['sorting_order'] != "sorting") {
+            
+                $sort = "DESC";
+                if ($data['sorting_order'] == "sorting_asc")
+                    $sort = "ASC";
+                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
+            
+        }
+        $where="";
+        if ($data['keyword']) {
+            if ($data['search_field'] == "cellphone") {
+                $where.=" WHERE (tblcollaborator.cellphone LIKE '%" . $data['keyword'] . "%')";
+            } else {
+                $where.=" WHERE (full_name LIKE '%" . $data['keyword'] . "%' OR login_name LIKE '%" . $data['keyword'] . "%') ";
+            }
+        }
+       // $from = date("Y-m-d 00:00:00",$from); 
+        $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.id ".$where." GROUP BY tblcollaborator.id ".$order." ";
+        
+        $result = $this->db->query($sql)->result_array();
+        
+
+        return count($result);
     }
     function getCountCollaboratorUser($data)
@@ -67,13 +99,75 @@
        // $from = date("Y-m-d 00:00:00",$from); 
         $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.id ".$where." GROUP BY tblcollaborator.id ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
-        echo $sql;
-        $result = $this->db->query($sql)->result_array();
-        foreach ($result as $index=>$paidlog)
-        {
-            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
-        }
-
-        return $result;
-    }
+        
+        $result = $this->db->query($sql)->result_array();
+        foreach ($result as $index=>$paidlog)
+        {
+            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
+        }
+
+        return $result;
+    }
+    
+        function countCountCollaboratorUsers($data)
+    {
+        $order = "";
+        if ($data['sorting_order'] != "sorting") {
+            
+                $sort = "DESC";
+                if ($data['sorting_order'] == "sorting_asc")
+                    $sort = "ASC";
+                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
+            
+        }
+        $where="";
+        if ($data['keyword']) {
+            if ($data['search_field'] == "cellphone") {
+                $where.=" WHERE (tblcollaborator.cellphone LIKE '%" . $data['keyword'] . "%')";
+            } else {
+                $where.=" WHERE (full_name LIKE '%" . $data['keyword'] . "%' OR login_name LIKE '%" . $data['keyword'] . "%') ";
+            }
+        }
+       // $from = date("Y-m-d 00:00:00",$from); 
+        $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."";
+   
+        $result = $this->db->query($sql)->result_array();
+        foreach ($result as $index=>$paidlog)
+        {
+            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
+        }
+
+        return count($result);
+    }
+        function getCountCollaboratorUsers($data)
+    {
+        $order = "";
+        if ($data['sorting_order'] != "sorting") {
+            
+                $sort = "DESC";
+                if ($data['sorting_order'] == "sorting_asc")
+                    $sort = "ASC";
+                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
+            
+        }
+        $where="";
+        if ($data['keyword']) {
+            if ($data['search_field'] == "cellphone") {
+                $where.=" WHERE (tblcollaborator.cellphone LIKE '%" . $data['keyword'] . "%')";
+            } else {
+                $where.=" WHERE (full_name LIKE '%" . $data['keyword'] . "%' OR login_name LIKE '%" . $data['keyword'] . "%') ";
+            }
+        }
+       // $from = date("Y-m-d 00:00:00",$from); 
+        $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'] . " ";
+   
+        $result = $this->db->query($sql)->result_array();
+        foreach ($result as $index=>$paidlog)
+        {
+            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
+        }
+
+        return $result;
+    }
+    
     function isExist($data) {
         $sql = "SELECT COUNT(id) as total FROM " . $this->table_name . " WHERE " . $data['field'] . " = '" . $data['value'] . "'";
