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

Thong ke cong tac vien

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php

    r461 r464  
    3434        return $this->db->query($sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " ")->result_array();
    3535    }
    36     function getAllCollaboratorUser($from)
     36    function getAllCollaboratorUser($from,$id=false)
    3737    {
    3838        $from = date("Y-m-d 00:00:00",$from);
    39         $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."'";
    40 
    41         $result = $this->db->query($sql)->result_array();
    42         foreach ($result as $index=>$paidlog)
    43         {
    44             $result[$index]['time']=  strtotime($paidlog['user_created_time']);
    45         }
    46         return $result;
     39        $where="";
     40        if ($id)
     41        {
     42            $where = " AND tbluser.collaborator = $id ";
     43        }
     44        $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."";
     45
     46        $result = $this->db->query($sql)->result_array();
     47        foreach ($result as $index=>$paidlog)
     48        {
     49            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
     50        }
     51        return $result;
     52    }
     53    function countCountCollaboratorUser($data)
     54    {
     55        $order = "";
     56        if ($data['sorting_order'] != "sorting") {
     57           
     58                $sort = "DESC";
     59                if ($data['sorting_order'] == "sorting_asc")
     60                    $sort = "ASC";
     61                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
     62           
     63        }
     64        $where="";
     65        if ($data['keyword']) {
     66            if ($data['search_field'] == "cellphone") {
     67                $where.=" WHERE (tblcollaborator.cellphone LIKE '%" . $data['keyword'] . "%')";
     68            } else {
     69                $where.=" WHERE (full_name LIKE '%" . $data['keyword'] . "%' OR login_name LIKE '%" . $data['keyword'] . "%') ";
     70            }
     71        }
     72       // $from = date("Y-m-d 00:00:00",$from);
     73        $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." ";
     74       
     75        $result = $this->db->query($sql)->result_array();
     76       
     77
     78        return count($result);
    4779    }
    4880    function getCountCollaboratorUser($data)
     
    6799       // $from = date("Y-m-d 00:00:00",$from);
    68100        $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'] . " ";
    69         echo $sql;
    70         $result = $this->db->query($sql)->result_array();
    71         foreach ($result as $index=>$paidlog)
    72         {
    73             $result[$index]['time']=  strtotime($paidlog['user_created_time']);
    74         }
    75 
    76         return $result;
    77     }
     101       
     102        $result = $this->db->query($sql)->result_array();
     103        foreach ($result as $index=>$paidlog)
     104        {
     105            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
     106        }
     107
     108        return $result;
     109    }
     110   
     111        function countCountCollaboratorUsers($data)
     112    {
     113        $order = "";
     114        if ($data['sorting_order'] != "sorting") {
     115           
     116                $sort = "DESC";
     117                if ($data['sorting_order'] == "sorting_asc")
     118                    $sort = "ASC";
     119                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
     120           
     121        }
     122        $where="";
     123        if ($data['keyword']) {
     124            if ($data['search_field'] == "cellphone") {
     125                $where.=" WHERE (tblcollaborator.cellphone LIKE '%" . $data['keyword'] . "%')";
     126            } else {
     127                $where.=" WHERE (full_name LIKE '%" . $data['keyword'] . "%' OR login_name LIKE '%" . $data['keyword'] . "%') ";
     128            }
     129        }
     130       // $from = date("Y-m-d 00:00:00",$from);
     131        $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."";
     132   
     133        $result = $this->db->query($sql)->result_array();
     134        foreach ($result as $index=>$paidlog)
     135        {
     136            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
     137        }
     138
     139        return count($result);
     140    }
     141        function getCountCollaboratorUsers($data)
     142    {
     143        $order = "";
     144        if ($data['sorting_order'] != "sorting") {
     145           
     146                $sort = "DESC";
     147                if ($data['sorting_order'] == "sorting_asc")
     148                    $sort = "ASC";
     149                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
     150           
     151        }
     152        $where="";
     153        if ($data['keyword']) {
     154            if ($data['search_field'] == "cellphone") {
     155                $where.=" WHERE (tblcollaborator.cellphone LIKE '%" . $data['keyword'] . "%')";
     156            } else {
     157                $where.=" WHERE (full_name LIKE '%" . $data['keyword'] . "%' OR login_name LIKE '%" . $data['keyword'] . "%') ";
     158            }
     159        }
     160       // $from = date("Y-m-d 00:00:00",$from);
     161        $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'] . " ";
     162   
     163        $result = $this->db->query($sql)->result_array();
     164        foreach ($result as $index=>$paidlog)
     165        {
     166            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
     167        }
     168
     169        return $result;
     170    }
     171   
    78172    function isExist($data) {
    79173        $sql = "SELECT COUNT(id) as total FROM " . $this->table_name . " WHERE " . $data['field'] . " = '" . $data['value'] . "'";
Note: See TracChangeset for help on using the changeset viewer.