function ajax_json_get_items_for_order_id() { global $cms_db_tables; $table = $cms_db_tables['table_cart']; $page = $_REQUEST['page']; // get the requested page $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction if (!$sidx) { $sidx = 1; } $wh = ""; $searchOn = Strip($_REQUEST['_search']); $the_item_ids_from_search_array = array(); if ($searchOn == 'true') { $searchstr = Strip($_REQUEST['filters']); $wh = constructWhere($searchstr); if (strval($wh) != '') { $q = " select id from {$table} where id is not null {$wh}"; //var_Dump($q); $q = CI::model('core')->dbQuery($q); if (!empty($q)) { foreach ($q as $sresult) { $some_id = $sresult['id']; $the_item_ids_from_search_array[] = $some_id; } } } //var_dump($the_item_ids_from_search_array); } //ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit; $this->template['functionName'] = strtolower(__FUNCTION__); $id = CI::model('core')->getParamFromURL('id'); $items_conf = array(); $items_conf['id'] = intval($id); //$items_conf ['order_completed'] = 'y'; $order = $this->cart_model->itemsOrders($items_conf); $order = $order[0]; $order_currency_code = $order['currency_code']; $order_promo_code = $order['promo_code']; $order_id = $order['order_id']; $items_conf = array(); $items_conf['order_completed'] = 'y'; $items_conf['order_id'] = $order_id; //$limit = false, $offset = false, $orderby = false, $cache_group = false, $debug = false, $ids = false, $count_only = false, $only_those_fields = false, $exclude_ids = false, $force_cache_id = false, $get_only_whats_requested_without_additional_stuff = false if ($start != false and $limit != false) { $limits_array = array(); $limits_array[0] = $start; $limits_array[1] = $limit; } else { $limits_array = false; } if ($sidx != false and $sord != false) { $order_by_array = array(); $order_by_array[0] = $sidx; $order_by_array[1] = $sord; } else { $order_by_array = false; } //$start." , ".$limit $items = $this->cart_model->itemsGet($items_conf, $limits_array, false, $order_by_array, false, false, $ids = $the_item_ids_from_search_array); header("Content-type: text/xml;charset=utf-8"); $s = "<?xml version='1.0' encoding='utf-8'?>"; $s .= "<rows>"; $s .= "<page>" . $page . "</page>"; $s .= "<total>" . count($items) . "</total>"; $s .= "<records>" . count($items) . "</records>"; $i = 0; foreach ($items as $item) { $item['id'] = $item['id']; $price_in_curency = $this->cart_model->currencyConvertPrice($item['price'], $order_currency_code); $s .= "<row id='" . $item['id'] . "'>"; $s .= "<cell>" . $item['sku'] . "</cell>"; $s .= "<cell>" . $item['created_on'] . "</cell>"; $s .= "<cell>" . $item['item_name'] . "</cell>"; $s .= "<cell>" . $item['qty'] . "</cell>"; $s .= "<cell>" . $this->cart_model->currencyConvertPrice($item['price'], $order_currency_code) . "</cell>"; $s .= "<cell>" . $this->cart_model->currencyConvertPrice($item['qty'] * $item['price'], $order_currency_code) . "</cell>"; if (trim($item['skip_promo_code']) != 'y') { $s .= "<cell>" . $this->cart_model->promoCodeApplyToAmount($price_in_curency, $order_promo_code) . "</cell>"; } else { $s .= "<cell>" . $price_in_curency . "</cell>"; } // $s .= "<cell>" . floatval($item['weight']) . "</cell>"; $s .= "<cell>" . floatval($item['qty'] * $item['weight']) . "</cell>"; $s .= "<cell>" . $item['size'] . "</cell>"; $s .= "<cell>" . trim($item['colors']) . "</cell>"; $s .= "<cell>" . $item['sid'] . "</cell>"; $s .= "<cell>" . $item['id'] . "</cell>"; $s .= "</row>"; $i++; } $s .= "</rows>"; echo $s; exit; }
// get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction if (!$sidx) { $sidx = 1; } // search options // IMPORTANT NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!! // this type of constructing is not recommendet // it is only for demonstration //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $wh = " "; $searchOn = Strip($_REQUEST['_search']); if ($searchOn == 'true') { $searchstr = Strip($_REQUEST['filters']); $wh = constructWhere($searchstr); //echo $wh; } function constructWhere($s) { $qwery = ""; //['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc'] $qopers = array('eq' => " = ", 'ne' => " <> ", 'lt' => " < ", 'le' => " <= ", 'gt' => " > ", 'ge' => " >= ", 'bw' => " LIKE ", 'bn' => " NOT LIKE ", 'in' => " IN ", 'ni' => " NOT IN ", 'ew' => " LIKE ", 'en' => " NOT LIKE ", 'cn' => " LIKE ", 'nc' => " NOT LIKE "); if ($s) { include_once "../includes/obj2array.php"; $jsona = json_decode($s, true); if (is_array($jsona)) { $gopr = $jsona['groupOp']; $rules = $jsona['rules']; $i = 0; foreach ($rules as $key => $val) {
function ajax_json_get_items_for_order_id() { global $cms_db_tables; $table = $cms_db_tables['table_cart']; $page = $_REQUEST['page']; // get the requested page $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction if (!$sidx) { $sidx = 1; } $wh = ""; $searchOn = Strip($_REQUEST['_search']); $the_item_ids_from_search_array = array(); if ($searchOn == 'true') { $searchstr = Strip($_REQUEST['filters']); $wh = constructWhere($searchstr); if (strval($wh) != '') { $q = " select id from {$table} where id is not null {$wh}"; //var_Dump($q); $q = CI::model('core')->dbQuery($q); if (!empty($q)) { foreach ($q as $sresult) { $some_id = $sresult['id']; $the_item_ids_from_search_array[] = $some_id; } } } //var_dump($the_item_ids_from_search_array); } //ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit; $this->template['functionName'] = strtolower(__FUNCTION__); $id = CI::model('core')->getParamFromURL('id'); $items_conf = array(); $items_conf['id'] = intval($id); //$items_conf ['order_completed'] = 'y'; //$order = $this->cart_model->itemsOrders ( $items_conf ); //$order = CI::model('core')->dbQuery("SELECT * from firecms_cart_orders where sid='a7a82e994be6eb4e198355111f37ed3f'"); //$order = $order [0]; //$order_id = $order ['sid']; $items_conf = array(); $items_conf['order_completed'] = 'y'; $items_conf['sid'] = $order_id; $query = <<<STR \t\tSELECT fc.*,fo.order_id as order_id,fo.id orderid from {$cms_db_tables['table_cart']} fc \t\tinner join {$cms_db_tables['table_cart_orders']} fo on (fc.sid=fo.sid) \t\twhere fo.id='{$id}' AND fc.order_completed='y' and fo.transactionid is not null \t\t AND fo.order_id=fc.order_id; \t STR; $items = CI::model('core')->dbQuery($query); header("Content-type: text/xml;charset=utf-8"); $s = "<?xml version='1.0' encoding='utf-8'?>"; $s .= "<rows>"; $s .= "<page>" . $page . "</page>"; $s .= "<total>" . count($items) . "</total>"; $s .= "<records>" . count($items) . "</records>"; $i = 0; foreach ($items as $item) { //$item ['id'] = $item ['sid']; $s .= "<row id='" . $item['orderid'] . ':' . $item['id'] . "'>"; //$s .= "<cell>" . $item ['sku'] . "</cell>"; $s .= "<cell>" . $item['created_on'] . "</cell>"; $s .= "<cell>" . $item['item_name'] . "</cell>"; $s .= "<cell>" . $item['qty'] . "</cell>"; $s .= "<cell>" . $item['price'] . "</cell>"; $s .= "<cell>" . floatval($item['qty'] * $item['price']) . "</cell>"; $s .= "<cell>" . floatval($item['weight']) . "</cell>"; $s .= "<cell>" . floatval($item['qty'] * $item['weight']) . "</cell>"; //$s .= "<cell>" . $item ['size'] . "</cell>"; //$s .= "<cell>" . trim ( $item ['colors'] ) . "</cell>"; //$s .= "<cell>" . $item ['sid'] . "</cell>"; $s .= "<cell>" . $item['id'] . "</cell>"; $s .= "</row>"; $i++; } $s .= "</rows>"; echo $s; exit; }