Esempio n. 1
0
/**
 * Gets orders on a page
 *
 * @param int $page - number of the page
 * @param str $status_id - status of the orders
 * @param str $type      - type of the orders
 * @param str $search    - a search keyphrase
 * @param date $from_date - starting date of the orders
 * @param date $to_date   - ending date of the orders
 * @param bool $delivery_date - whether a delivery date(true) or order date (fasle)
 * @return arr - list with orders
 */
function orders_get($page, $status_id, $type, $search, $from_date, $to_date, $delivery_date)
{
    $where = order_search_build_where_clause($search, $from_date, $to_date, $delivery_date);
    if (is_array($status_id)) {
        $status_check = "AND oh.STATUS_ID IN ('" . implode("','", $status_id) . "')";
    } else {
        $status_check = "AND oh.STATUS_ID = '" . esc($status_id) . "'";
    }
    $query = "SELECT oh.ORDER_ID, oh.COMPANY, oh.CREATED_BY, oh.LOCATION, oh.EXTERNAL_ID, oh.ORDER_DATE, oh.DELIVERY_DATE, oh.STATUS_ID, oro.PARTY_ID, oh.GRAND_TOTAL, oh.DPD_TEXT,\n\t\t\t\t\t oh.GRAND_TOTAL_NO_TAX, oh.CURRENCY_UOM, oh.SYNC_STATUS_ID, oh.COMMENTS, oh.SESSION_SERILIALIZE\n\t\t\t  FROM order_header oh JOIN order_role oro\n\t\t\t  ON oh.ORDER_ID = oro.ORDER_ID\n\t\t\t  WHERE oh.ORDER_TYPE_ID='" . esc($type) . "' {$status_check} AND oro.ROLE_TYPE_ID = '" . ORDER_CUSTOMER . "' {$where}\n\t\t\t  ORDER BY oh.ORDER_DATE DESC ";
    if ($page !== false) {
        $query .= db_get_limit($page);
    }
    return db_query_to_array($query);
}
Esempio n. 2
0
/**
 *
 * Gets a list of customers
 * @param int $page     - number of page
 * @param str $order_by - the column to be ordered by
 * @param str $asc      - the orientation of the sorting
 * @return arr - list wiht clients
 */
function users_get_clients($page, $order_by, $asc)
{
    if ($order_by == '') {
        $order_by = 'pe.FIRST_NAME';
    }
    if ($order_by == 'pe.PARTY_ID') {
        $order_by = 'CAST( SUBSTR(pe.PARTY_ID FROM 3) as SIGNED INTEGER)';
    }
    if ($asc == '') {
        $asc = 'ASC';
    }
    $query = "SELECT p.DATA_SOURCE_ID,\n\t\t\t\t\t pe.PARTY_ID, pe.COMPANY, pe.FIRST_NAME, pe.LAST_NAME, pe.STATUS_ID,\n\t\t\t\t\t ul.ENABLED\n\t\t\t  FROM party p JOIN person pe JOIN user_login ul JOIN party_role pr\n\t\t\t  ON p.PARTY_ID = pe.PARTY_ID AND pe.PARTY_ID = ul.PARTY_ID AND pr.PARTY_ID = p.PARTY_ID\n\t\t\t  WHERE pr.ROLE_TYPE_ID = '" . ROLE_CLIENT . "' AND pe.STATUS_ID != '" . DELETED . "'\n\t\t\t  ORDER BY {$order_by} {$asc}";
    if ($page) {
        $query .= db_get_limit($page);
    }
    return db_query_to_array($query);
}