Plugin Directory

Changeset 1335255


Ignore:
Timestamp:
01/25/2016 04:43:32 AM (10 years ago)
Author:
kodeplusdev
Message:

Fix pagination for rates, agent, assignment list

Location:
kandy
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • kandy/tags/2.3.0/admin/AgentRatesList.php

    r1265749 r1335255  
    6666    function prepare_items()
    6767    {
    68         $data = $this->get_data();
    6968        $columns = $this->get_columns();
    7069        $hidden = array();
     
    7372
    7473        //pagination
    75         $per_page = 5;
     74        $per_page = 10;
    7675        $current_page = $this->get_pagenum();
    77         $total_items = count($data);
     76        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     77        $total_items = KandyApi::totalAgentRates($_GET['id']);
    7878
    79         //search
    80         $searchItem = array_slice(
    81             $data,
    82             (($current_page - 1) * $per_page),
    83             $per_page
    84         );
    85         //sorting
    86         usort($searchItem, array(&$this, 'usort_reorder'));
    8779        $this->set_pagination_args(
    8880            array(
     
    9385            )
    9486        );
    95         $this->items = $searchItem;
     87        $this->items = $data;
    9688    }
    9789
  • kandy/tags/2.3.0/admin/AgentsTableList.php

    r1265749 r1335255  
    6565    function prepare_items()
    6666    {
    67         $data = $this->get_data();
    6867        $columns = $this->get_columns();
    6968        $hidden = array();
     
    7271
    7372        //pagination
    74         $per_page = 5;
     73        $per_page = 10;
    7574        $current_page = $this->get_pagenum();
    76         $total_items = count($data);
     75        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     76        $total_items = KandyApi::totalListAgents();
    7777
    78         //search
    79         $searchItem = array_slice(
    80             $data,
    81             (($current_page - 1) * $per_page),
    82             $per_page
    83         );
    84         //sorting
    85         usort($searchItem, array(&$this, 'usort_reorder'));
    8678        $this->set_pagination_args(
    8779            array(
     
    9284            )
    9385        );
    94         $this->items = $searchItem;
     86        $this->items = $data;
    9587    }
    9688
  • kandy/tags/2.3.0/admin/AssignmentTableList.php

    r1265749 r1335255  
    6464    function prepare_items()
    6565    {
    66         $data = $this->get_data();
     66        $countUsers = count_users();
    6767        $columns = $this->get_columns();
    6868        $hidden = array();
     
    7171
    7272        //pagination
    73         $per_page = 5;
     73        $per_page = 10;
    7474        $current_page = $this->get_pagenum();
    75         $total_items = count($data);
     75        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     76        $total_items = $countUsers['total_users'];
    7677
    77         //search
    78         $searchItem = array_slice(
    79             $data,
    80             (($current_page - 1) * $per_page),
    81             $per_page
    82         );
    8378        //sorting
    84         usort($searchItem, array(&$this, 'usort_reorder'));
    8579        $this->set_pagination_args(
    8680            array(
     
    9185            )
    9286        );
    93         $this->items = $searchItem;
     87        $this->items = $data;
    9488    }
    9589
  • kandy/tags/2.3.0/api/kandy-api-class.php

    r1212258 r1335255  
    2020
    2121        // Change the number of rows with the limit() call.
    22         $result = get_users(array("number" => $limit, "offset" => $offset));
     22        $result = get_users(array("number" => $limit, "offset" => $offset, 'orderby' => 'id'));
    2323
    2424        $rows = array();
     
    611611    }
    612612
    613 
     613    /**
     614     * @return int
     615     */
     616    public static function totalListAgents() {
     617        global $wpdb;
     618        $kandyUserTable = $wpdb->prefix . 'kandy_users';
     619        $mainUserTable = $wpdb->prefix . 'users';
     620        $agentType = KANDY_USER_TYPE_AGENT;
     621        $rateTable = $wpdb->prefix . 'kandy_live_chat_rate';
     622        $sql = "SELECT count($kandyUserTable.id)
     623                FROM $mainUserTable
     624                INNER JOIN $kandyUserTable ON $mainUserTable.ID = $kandyUserTable.main_user_id
     625                LEFT JOIN $rateTable ON $mainUserTable.id = $rateTable.main_user_id
     626                WHERE $kandyUserTable.type = $agentType";
     627        ;
     628        $result = $wpdb->get_var($sql);
     629        return (int) $result;
     630    }
     631
     632    /**
     633     * @param $limit
     634     * @param $offset
     635     *
     636     * @return mixed
     637     */
    614638    public static function getListAgents($limit, $offset) {
    615639        global $wpdb;
     
    663687        return $users;
    664688
     689    }
     690
     691    /**
     692     * @param $agentId
     693     *
     694     * @return int
     695     */
     696    public static function totalAgentRates($agentId) {
     697        global $wpdb;
     698        $tableRate = $wpdb->prefix . 'kandy_live_chat_rate';
     699        $agentId = intval($agentId);
     700        $sql = "SELECT * FROM $tableRate WHERE main_user_id = $agentId ORDER BY rated_time DESC";
     701        $result = $wpdb->get_var($sql);
     702        return (int) $result;
    665703    }
    666704
  • kandy/tags/2.4.2/admin/AgentRatesList.php

    r1325542 r1335255  
    6666    function prepare_items()
    6767    {
    68         $data = $this->get_data();
    6968        $columns = $this->get_columns();
    7069        $hidden = array();
     
    7372
    7473        //pagination
    75         $per_page = 5;
     74        $per_page = 10;
    7675        $current_page = $this->get_pagenum();
    77         $total_items = count($data);
     76        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     77        $total_items = KandyApi::totalAgentRates($_GET['id']);
    7878
    79         //search
    80         $searchItem = array_slice(
    81             $data,
    82             (($current_page - 1) * $per_page),
    83             $per_page
    84         );
    85         //sorting
    86         usort($searchItem, array(&$this, 'usort_reorder'));
    8779        $this->set_pagination_args(
    8880            array(
     
    9385            )
    9486        );
    95         $this->items = $searchItem;
     87        $this->items = $data;
    9688    }
    9789
  • kandy/tags/2.4.2/admin/AgentsTableList.php

    r1325542 r1335255  
    6565    function prepare_items()
    6666    {
    67         $data = $this->get_data();
    6867        $columns = $this->get_columns();
    6968        $hidden = array();
     
    7271
    7372        //pagination
    74         $per_page = 5;
     73        $per_page = 10;
    7574        $current_page = $this->get_pagenum();
    76         $total_items = count($data);
     75        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     76        $total_items = KandyApi::totalListAgents();
    7777
    78         //search
    79         $searchItem = array_slice(
    80             $data,
    81             (($current_page - 1) * $per_page),
    82             $per_page
    83         );
    84         //sorting
    85         usort($searchItem, array(&$this, 'usort_reorder'));
    8678        $this->set_pagination_args(
    8779            array(
     
    9284            )
    9385        );
    94         $this->items = $searchItem;
     86        $this->items = $data;
    9587    }
    9688
  • kandy/tags/2.4.2/admin/AssignmentTableList.php

    r1325542 r1335255  
    6464    function prepare_items()
    6565    {
    66         $data = $this->get_data();
     66        $countUsers = count_users();
    6767        $columns = $this->get_columns();
    6868        $hidden = array();
     
    7171
    7272        //pagination
    73         $per_page = 5;
     73        $per_page = 10;
    7474        $current_page = $this->get_pagenum();
    75         $total_items = count($data);
     75        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     76        $total_items = $countUsers['total_users'];
    7677
    77         //search
    78         $searchItem = array_slice(
    79             $data,
    80             (($current_page - 1) * $per_page),
    81             $per_page
    82         );
    8378        //sorting
    84         usort($searchItem, array(&$this, 'usort_reorder'));
    8579        $this->set_pagination_args(
    8680            array(
     
    9185            )
    9286        );
    93         $this->items = $searchItem;
     87        $this->items = $data;
    9488    }
    9589
  • kandy/tags/2.4.2/api/kandy-api-class.php

    r1325542 r1335255  
    2020
    2121        // Change the number of rows with the limit() call.
    22         $result = get_users(array("number" => $limit, "offset" => $offset));
     22        $result = get_users(array("number" => $limit, "offset" => $offset, 'orderby' => 'id'));
    2323
    2424        $rows = array();
     
    611611    }
    612612
     613    /**
     614     * @return int
     615     */
     616    public static function totalListAgents() {
     617        global $wpdb;
     618        $kandyUserTable = $wpdb->prefix . 'kandy_users';
     619        $mainUserTable = $wpdb->prefix . 'users';
     620        $agentType = KANDY_USER_TYPE_AGENT;
     621        $rateTable = $wpdb->prefix . 'kandy_live_chat_rate';
     622        $sql = "SELECT count($kandyUserTable.id)
     623                FROM $mainUserTable
     624                INNER JOIN $kandyUserTable ON $mainUserTable.ID = $kandyUserTable.main_user_id
     625                LEFT JOIN $rateTable ON $mainUserTable.id = $rateTable.main_user_id
     626                WHERE $kandyUserTable.type = $agentType";
     627        ;
     628        $result = $wpdb->get_var($sql);
     629        return (int) $result;
     630    }
    613631
    614632    public static function getListAgents($limit, $offset) {
     
    663681        return $users;
    664682
     683    }
     684
     685    /**
     686     * @param $agentId
     687     *
     688     * @return int
     689     */
     690    public static function totalAgentRates($agentId) {
     691        global $wpdb;
     692        $tableRate = $wpdb->prefix . 'kandy_live_chat_rate';
     693        $agentId = intval($agentId);
     694        $sql = "SELECT count(*) FROM $tableRate WHERE main_user_id = $agentId ORDER BY rated_time DESC";
     695        $result = $wpdb->get_var($sql);
     696        return (int) $result;
    665697    }
    666698
  • kandy/trunk/admin/AgentRatesList.php

    r1265746 r1335255  
    6666    function prepare_items()
    6767    {
    68         $data = $this->get_data();
    6968        $columns = $this->get_columns();
    7069        $hidden = array();
     
    7372
    7473        //pagination
    75         $per_page = 5;
     74        $per_page = 10;
    7675        $current_page = $this->get_pagenum();
    77         $total_items = count($data);
     76        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     77        $total_items = KandyApi::totalAgentRates($_GET['id']);
    7878
    79         //search
    80         $searchItem = array_slice(
    81             $data,
    82             (($current_page - 1) * $per_page),
    83             $per_page
    84         );
    85         //sorting
    86         usort($searchItem, array(&$this, 'usort_reorder'));
    8779        $this->set_pagination_args(
    8880            array(
     
    9385            )
    9486        );
    95         $this->items = $searchItem;
     87        $this->items = $data;
    9688    }
    9789
  • kandy/trunk/admin/AgentsTableList.php

    r1265746 r1335255  
    6565    function prepare_items()
    6666    {
    67         $data = $this->get_data();
    6867        $columns = $this->get_columns();
    6968        $hidden = array();
     
    7271
    7372        //pagination
    74         $per_page = 5;
     73        $per_page = 10;
    7574        $current_page = $this->get_pagenum();
    76         $total_items = count($data);
     75        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     76        $total_items = KandyApi::totalListAgents();
    7777
    78         //search
    79         $searchItem = array_slice(
    80             $data,
    81             (($current_page - 1) * $per_page),
    82             $per_page
    83         );
    84         //sorting
    85         usort($searchItem, array(&$this, 'usort_reorder'));
    8678        $this->set_pagination_args(
    8779            array(
     
    9284            )
    9385        );
    94         $this->items = $searchItem;
     86        $this->items = $data;
    9587    }
    9688
  • kandy/trunk/admin/AssignmentTableList.php

    r1265746 r1335255  
    6464    function prepare_items()
    6565    {
    66         $data = $this->get_data();
     66        $countUsers = count_users();
    6767        $columns = $this->get_columns();
    6868        $hidden = array();
     
    7171
    7272        //pagination
    73         $per_page = 5;
     73        $per_page = 10;
    7474        $current_page = $this->get_pagenum();
    75         $total_items = count($data);
     75        $data = $this->get_data($per_page, ($current_page-1)*$per_page);
     76        $total_items = $countUsers['total_users'];
    7677
    77         //search
    78         $searchItem = array_slice(
    79             $data,
    80             (($current_page - 1) * $per_page),
    81             $per_page
    82         );
    8378        //sorting
    84         usort($searchItem, array(&$this, 'usort_reorder'));
    8579        $this->set_pagination_args(
    8680            array(
     
    9185            )
    9286        );
    93         $this->items = $searchItem;
     87        $this->items = $data;
    9488    }
    9589
  • kandy/trunk/api/kandy-api-class.php

    r1325532 r1335255  
    2020
    2121        // Change the number of rows with the limit() call.
    22         $result = get_users(array("number" => $limit, "offset" => $offset));
     22        $result = get_users(array("number" => $limit, "offset" => $offset, 'orderby' => 'id'));
    2323
    2424        $rows = array();
     
    611611    }
    612612
     613    /**
     614     * @return int
     615     */
     616    public static function totalListAgents() {
     617        global $wpdb;
     618        $kandyUserTable = $wpdb->prefix . 'kandy_users';
     619        $mainUserTable = $wpdb->prefix . 'users';
     620        $agentType = KANDY_USER_TYPE_AGENT;
     621        $rateTable = $wpdb->prefix . 'kandy_live_chat_rate';
     622        $sql = "SELECT count($kandyUserTable.id)
     623                FROM $mainUserTable
     624                INNER JOIN $kandyUserTable ON $mainUserTable.ID = $kandyUserTable.main_user_id
     625                LEFT JOIN $rateTable ON $mainUserTable.id = $rateTable.main_user_id
     626                WHERE $kandyUserTable.type = $agentType";
     627        ;
     628        $result = $wpdb->get_var($sql);
     629        return (int) $result;
     630    }
    613631
    614632    public static function getListAgents($limit, $offset) {
     
    663681        return $users;
    664682
     683    }
     684
     685    /**
     686     * @param $agentId
     687     *
     688     * @return int
     689     */
     690    public static function totalAgentRates($agentId) {
     691        global $wpdb;
     692        $tableRate = $wpdb->prefix . 'kandy_live_chat_rate';
     693        $agentId = intval($agentId);
     694        $sql = "SELECT count(*) FROM $tableRate WHERE main_user_id = $agentId ORDER BY rated_time DESC";
     695        $result = $wpdb->get_var($sql);
     696        return (int) $result;
    665697    }
    666698
Note: See TracChangeset for help on using the changeset viewer.