function getBannersClicked($banid, $userid = null) { $rarray = array(); $update_qry = "UPDATE banners set number_of_click = number_of_click+1 where id={$banid}"; if (updateByQuery($update_qry)) { if (!empty($userid)) { $add_details = findByIdArray($banid, 'banners'); $already_exists_query = "SELECT * from point_details where type='B' and parent_id=" . $add_details['id'] . " and user_id=" . $userid; $if_exist = findByQuery($already_exists_query); echo '<pre>'; //var_dump($add_details); var_dump($if_exist); //var_dump($add_details); if (!empty($add_details) && $add_details['target_click'] >= $add_details['number_of_click'] && empty($if_exist)) { $given_point_details = findByConditionArray(array('id' => $add_details['mpoint_name']), 'point_master'); $given_point_exipre_date = $given_point_details[0]['expire_date']; $temp = array(); $temp['user_id'] = $userid; $temp['points'] = $add_details['mpoint_get_per_click']; $temp['point_id'] = $add_details['mpoint_name']; $temp['merchant_id'] = $add_details['merchant_id']; $temp['source'] = "earn from banner click"; $temp['type'] = 'B'; $temp['parent_id'] = $add_details['id']; $temp['date'] = $add_details['start_date']; $temp['expire_date'] = $given_point_exipre_date; $temp['redeemed_points'] = 0; $temp['redeemed_points'] = 0; $temp['remaining_points'] = $add_details['mpoint_get_per_click']; $t = add(json_encode(array('save_data' => $temp)), 'points'); $temp = array(); $temp['user_id'] = $userid; $temp['points'] = $add_details['mpoint_get_per_click']; $temp['point_id'] = $add_details['mpoint_name']; $temp['merchant_id'] = $add_details['merchant_id']; $temp['source'] = "earn from banner click"; $temp['type'] = 'B'; $temp['parent_id'] = $add_details['id']; $temp['date'] = $add_details['start_date']; $temp['expire_date'] = $given_point_exipre_date; $temp['redeemed_points'] = 0; $temp['remaining_points'] = $add_details['mpoint_get_per_click']; $temp['transaction_type'] = 0; $t = add(json_encode(array('save_data' => $temp)), 'point_details'); $rarray = array('type' => 'success', 'message' => 'Congratulation. You have got ' . $add_details['mpoint_get_per_click'] . ' m-points.'); } else { //echo 'helllo'; //$rarray = array('type' => 'error', 'message' => 'Banners not found.'); } } else { $rarray = array('type' => 'success', 'message' => 'Banners clicked successfully.'); } } else { $rarray = array('type' => 'error', 'message' => 'Internal error. Please try again later.'); } echo json_encode($rarray); }
function getBankDetailsByUser($user_id) { $rarray = array(); $query = "select * from bank_details where user_id={$user_id}"; $details = findByQuery($query, 'one'); if (!empty($details)) { $rarray = array("type" => "success", "details" => $details); } else { $rarray = array("type" => "error", "message" => "Bank details not found."); } echo json_encode($rarray); exit; }
function getSpecialMerchantNews($res_id) { $rarray = array('type' => 'error', 'message' => 'No news found.'); $news_restaurants = findByConditionArray(array('restaurant_id' => $res_id), 'news_restaurant_map'); $restaurants = array_column($news_restaurants, 'news_id'); $news_query = "SELECT * FROM news WHERE id in(" . implode(',', $restaurants) . ") and special_event=1"; $news = findByQuery($news_query); if (!empty($news)) { $news = array_map(function ($t) { $t['image_url'] = SITEURL . 'news_images/' . $t['image']; return $t; }, $news); $rarray = array('type' => 'success', 'data' => $news); } echo json_encode($rarray); }
function getHotAds() { $rarray = array(); $query = "select * from advertisements where DATE(start_date)<=CURDATE() and DATE(end_date)>=CURDATE() and is_active=1 order by advertisements.number_of_click DESC"; $result = findByQuery($query); if (!empty($result)) { $result = array_map(function ($t) { if (!empty($t['image'])) { $t['image_url'] = SITEURL . "advertisement_images/" . $t['image']; } $t['expire_date'] = date('d M,Y H:i:s', strtotime($t['end_date'])); return $t; }, $result); $rarray = array('type' => 'success', 'ads' => $result); } else { $rarray = array('type' => 'error', 'message' => 'No ads found.'); } echo json_encode($rarray); }
function cornForCartValidity() { $cur_time = time(); //echo $cur_time; $cartsql = "select * from cart where validity <= '" . $cur_time . "'"; $cartres = findByQuery($cartsql); if (!empty($cartres)) { foreach ($cartres as $cartres_key => $cartres_val) { $offer_id = $cartres_val['offer_id']; $offer_qty = $cartres_val['quantity']; $cart_id = $cartres_val['id']; //$offer_details = findByConditionArray(array('id' => $offer_id),'offers'); //print_r $up_query = "UPDATE offers SET buy_count=buy_count -" . $offer_qty . " where id=" . $offer_id; updateByQuery($up_query); delete('cart', $cart_id); } } }
function getMerchantRestaurantDetails($res_id) { $rarray = array(); $details = findByIdArray($res_id, 'merchantrestaurants'); if (!empty($details)) { $details['logo_url'] = SITEURL . 'merchantrestaurant_images/' . $details['logo']; $outlet_query = "SELECT * FROM merchantoutlets WHERE restaurant_id={$res_id} and is_active=1"; $outlets = findByQuery($outlet_query); $outlets = array_map(function ($t) { $t['image_url'] = SITEURL . 'merchantoutlet_images/' . $t['image']; $s['iconurl'] = ""; if (!empty($t['icon'])) { $t['iconurl'] = SITEURL . 'merchantrestaurant_icon/' . $t['icon']; } return $t; }, $outlets); $details['outlets'] = $outlets; $rarray = array('type' => 'success', 'data' => $details); } else { $rarray = array('type' => 'error', 'message' => 'Restaurant not found.'); } echo json_encode($rarray); }
function activeProfile($unique_id) { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); //print_r($body);exit; //$email = $body->email; //$email = isset($user->email)?$user->email:$user->username; //echo $email;exit; //$pass = md5($body->password); $result = ''; if (!empty($unique_id)) { // $db = getConnection(); // $sql = "SELECT * FROM users WHERE unique_code=:unique_code"; // $stmt = $db->prepare($sql); // $stmt->bindParam("unique_code", $unique_id); // $stmt->execute(); // $count = $stmt->rowCount(); // //echo $count;exit; // $user = $stmt->fetchObject(); // $db = null; $user = json_decode(findByCondition(array('unique_code' => $unique_id), 'users')); $count = count($user); if ($count == 0) { $result = '{"type":"error","message":"You are Not Valid User"}'; } elseif ($count == 1) { //$result = json_encode($user); $user = $user['0']; $logged_in = $user->is_logged_in; $id = $user->id; $email = $user->email; //$arr['is_logged_in'] = 1; $arr['is_active'] = 1; $arr['last_login'] = date('Y-m-d h:m:s'); $updateinfo['save_data'] = $arr; // print_r($updateinfo);exit; $update = edit(json_encode($updateinfo), 'users', $id); if (!empty($update)) { //print_r($update);exit; $user->is_active = 1; //$user->is_logged_in=1; $user->last_login = $arr['last_login']; $user_details = json_encode($user); $db = getConnection(); $sql1 = "SELECT * FROM member_user_map WHERE email=:email order by id desc"; $stmt = $db->prepare($sql1); $stmt->bindParam("email", $email); $stmt->execute(); $membercount = $stmt->rowCount(); //echo $count;exit; //$tempvoucher = $stmt->fetchObject(); $allmember = $stmt->fetchAll(PDO::FETCH_OBJ); //print_r($allmember); //exit; $db = null; if ($membercount != 0) { //$arr['is_active'] = 1; $member_offer_id = $allmember[0]->offer_id; $member_voucher_id = $allmember[0]->voucher_id; $member_name = $allmember[0]->name; $first_name = ''; $last_name = ''; if (!empty($member_name)) { $member_name = explode(' ', $member_name); $first_name = $member_name[0]; $last_name = $member_name[1]; if (isset($member_name[2])) { $last_name = $last_name . ' ' . $member_name[2]; } $arr = array(); $arr['first_name'] = $first_name; $arr['last_name'] = $last_name; $updateinfo = array(); $updateinfo['save_data'] = $arr; // print_r($updateinfo);exit; $update = edit(json_encode($updateinfo), 'users', $id); } $member_voucher_query = "SELECT * FROM `voucher_owner` WHERE offer_id={$member_offer_id} and is_active=1 and voucher_id={$member_voucher_id}"; $memberVoucherDetails = findByQuery($member_voucher_query); //print_r($memberVoucherDetails); //exit; if (!empty($memberVoucherDetails)) { $voucher_owner_id = $memberVoucherDetails[0]['id']; $maparr = array(); $maparr['to_user_id'] = $id; $voucherupdateinfo['save_data'] = $maparr; $cndtn = array(); $cndtn['id'] = $voucher_owner_id; $updatemap = editByField(json_encode($voucherupdateinfo), 'voucher_owner', $cndtn); } $maparr = array(); $maparr['user_id'] = $id; $mapupdateinfo['save_data'] = $maparr; $cndtn = array(); $cndtn['email'] = $email; $updatemap = editByField(json_encode($mapupdateinfo), 'member_user_map', $cndtn); } $db = getConnection(); $sql = "SELECT * FROM gift_voucher_non_user WHERE email=:email"; $stmt = $db->prepare($sql); $stmt->bindParam("email", $email); $stmt->execute(); $tempvouchercount = $stmt->rowCount(); //echo $count;exit; //$tempvoucher = $stmt->fetchObject(); $tempvouchers = $stmt->fetchAll(PDO::FETCH_OBJ); $db = null; $expired_vouchers = 0; if ($tempvouchercount != 0) { foreach ($tempvouchers as $tempvoucher) { $date1 = strtotime($tempvoucher->gift_date); $date2 = time(); $interval = floor(($date2 - $date1) / (60 * 60 * 24)); $tempid = $tempvoucher->id; if ($interval < 3) { $to_user = $id; $from_user = $tempvoucher->user_id; $vid = $tempvoucher->voucher_id; //$vid = $tempvoucher->voucher_id; if (!empty($to_user)) { if (!empty($from_user)) { $db = getConnection(); $sql = "SELECT voucher_owner.id, voucher_owner.is_active, vouchers.id as voucher_id, vouchers.offer_id, vouchers.view_id, vouchers.offer_price, vouchers.offer_percent, vouchers.price, users.first_name, users.last_name, users.email FROM vouchers, voucher_owner, users WHERE voucher_owner.voucher_id = vouchers.id and voucher_owner.voucher_id=:vid and voucher_owner.is_active = '1' and voucher_owner.to_user_id=:userid"; $stmt = $db->prepare($sql); $stmt->bindParam("vid", $vid); $stmt->bindParam("userid", $from_user); $stmt->execute(); $voucherowner = $stmt->fetchObject(); if (!empty($voucherowner)) { $ownerid = $voucherowner->id; $offerid = $voucherowner->offer_id; $viewid = $voucherowner->view_id; $offer_price = $voucherowner->offer_price; $offer_percent = $voucherowner->offer_percent; $price = $voucherowner->price; $vid = $voucherowner->voucher_id; $arr = array(); $arr['is_active'] = 0; //$arr['buy_price'] = $buy_price; $arr['sold_date'] = date('Y-m-d h:i:s'); $allinfo['save_data'] = $arr; $old_owner_details = edit(json_encode($allinfo), 'voucher_owner', $ownerid); if ($old_owner_details) { $data = array(); $data['voucher_id'] = $vid; $data['offer_id'] = $offerid; $data['voucher_view_id'] = $viewid; $data['from_user_id'] = $from_user; $data['to_user_id'] = $to_user; $data['price'] = $price; $data['offer_price'] = $offer_price; $data['offer_percent'] = $offer_percent; $data['is_active'] = '1'; $data['buy_price'] = '0.00'; $data['purchased_date'] = date('Y-m-d h:i:s'); $data['transfer_type'] = 'Gift'; $newinfo['save_data'] = $data; $new_owner_details = add(json_encode($newinfo), 'voucher_owner'); if (!empty($new_owner_details)) { $new = json_decode($new_owner_details); $giveData['voucher_id'] = $vid; $giveData['offer_id'] = $offerid; $giveData['from_user_id'] = $from_user; $giveData['to_user_id'] = $to_user; $giveData['created_on'] = date('Y-m-d h:i:s'); $giveData['is_active'] = 1; $newgiveData['save_data'] = $giveData; $new_owner_details = add(json_encode($newgiveData), 'give_voucher'); } } } } } } else { $expired_vouchers++; } $deletetemptable = delete('gift_voucher_non_user', $tempid); } } if (isset($expired_vouchers) && $expired_vouchers > 0) { $result = '{"type":"success","message":"Logged In Succesfully","user_details":' . $user_details . ',"voucher_message":"Your ' . $expired_vouchers . ' Promo has been expired."}'; } else { $result = '{"type":"success","message":"Logged In Succesfully","user_details":' . $user_details . '}'; } } else { $result = '{"type":"error","message":"Error occured"}'; } } // echo $result; } }
function getSiteSearch() { $keyword = !empty($_GET['keyword']) ? $_GET['keyword'] : ''; $category = !empty($_GET['category']) && $_GET['category'] != 'undefined' ? $_GET['category'] : 'promo'; $page = !empty($_GET['page']) ? $_GET['page'] : 1; $lines = !empty($_GET['lines']) ? $_GET['lines'] : 20; $sort = !empty($_GET['sort']) ? $_GET['sort'] : 'id'; $sort_by = !empty($_GET['sort_by']) ? $_GET['sort_by'] : 'DESC'; if (!empty($keyword) && !empty($category)) { $keyword = addslashes($keyword); $num_rec_per_page = $lines; $start_from = ($page - 1) * $num_rec_per_page; $limit = " LIMIT {$start_from}, {$num_rec_per_page}"; $order = " ORDER BY " . $sort . " " . $sort_by; $db = getConnection(); if ($category == 'promo') { $sql = "SELECT * FROM offers WHERE is_active=1 and (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%'OR benefits LIKE '%{$keyword}%')" . $order . $limit; $stmt = $db->prepare($sql); #$stmt->bindParam("like", "%$keyword%"); $stmt->execute(); $rarray = $stmt->fetchAll(); $db = null; $rarray = array_map(function ($t) { if (!empty($t['image'])) { $t['image_url'] = SITEURL . 'voucher_images/' . $t['image']; } return $t; }, $rarray); } else { if ($category == 'location') { $query = "SELECT * FROM locations where city LIKE '%{$keyword}%' and is_active=1"; $locations = findByQuery($query); $location_ids = ''; $outlet_ids = ''; $offer_ids = ''; if (!empty($locations)) { $location_ids = implode(',', array_column($locations, 'id')); $outlet_query = "SELECT * FROM outlet_location_map WHERE location_id in({$location_ids})"; $outlets = findByQuery($outlet_query); if (!empty($outlets)) { $outlet_ids = implode(',', array_column($outlets, 'outlet_id')); } if (!empty($outlet_ids)) { $offers_query = "SELECT * FROM offer_outlet_map WHERE outlet_id in({$outlet_ids})"; $offers = findByQuery($offers_query); if (!empty($offers)) { $offer_ids = implode(',', array_column($offers, 'offer_id')); } } } if (!empty($offer_ids)) { $sql = "SELECT * FROM offers WHERE is_active=1 and id in({$offer_ids}) " . $order . $limit; $stmt = $db->prepare($sql); #$stmt->bindParam("like", "%$keyword%"); $stmt->execute(); $rarray = $stmt->fetchAll(); $db = null; $rarray = array_map(function ($t) { if (!empty($t['image'])) { $t['image_url'] = SITEURL . 'voucher_images/' . $t['image']; } return $t; }, $rarray); } else { $rarray = array(); } } else { if ($category == 'event') { $sql = "SELECT * FROM events WHERE is_active=1 and status='O' and (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%')" . $order . $limit; $stmt = $db->prepare($sql); #$stmt->bindParam("like", "%$keyword%"); $stmt->execute(); $rarray = $stmt->fetchAll(); $db = null; $rarray = array_map(function ($t) { if (!empty($t['image'])) { $t['image_url'] = SITEURL . 'event_images/' . $t['image']; } return $t; }, $rarray); } else { if ($category == 'news') { $sql = "SELECT * FROM news WHERE is_active=1 and (title LIKE '%{$keyword}%' OR description LIKE '%{$keyword}%')" . $order . $limit; $stmt = $db->prepare($sql); #$stmt->bindParam("like", "%$keyword%"); $stmt->execute(); $rarray = $stmt->fetchAll(); $db = null; $rarray = array_map(function ($t) { if (!empty($t['image'])) { $t['image_url'] = SITEURL . 'news_images/' . $t['image']; } return $t; }, $rarray); } else { if ($category == 'restaurant') { $sql = "SELECT * FROM restaurants WHERE is_active=1 and (title LIKE '%{$keyword}%' OR address LIKE '%{$keyword}%')" . $order . $limit; $stmt = $db->prepare($sql); #$stmt->bindParam("like", "%$keyword%"); $stmt->execute(); $rarray = $stmt->fetchAll(); $db = null; $rarray = array_map(function ($t) { if (!empty($t['logo'])) { $t['logo_url'] = SITEURL . 'restaurant_images/' . $t['logo']; } return $t; }, $rarray); } } } } } $rarray = array('type' => 'success', 'data' => $rarray, 'category' => $category); } else { $rarray = array('type' => 'error', 'message' => 'No match found'); } echo json_encode($rarray); exit; }
function getExpireSoonPoints($user_id) { $rarray = array(); $cur_year = date('Y'); $cur_month = date('m'); $sql = "select * from point_master where MONTH(expire_date)='" . $cur_month . "'"; $point_master_res = findByQuery($sql); $cnt = 0; if (!empty($point_master_res)) { $pointsid = array_column($point_master_res, 'id'); $point_data = array(); $nextsixdays = date('Y-m-d', strtotime(' +6 day')); $today = date('Y-m-d'); //echo '<pre>'; //$pointsid = array_column($point_res, 'id'); foreach ($point_master_res as $point_key => $point_val) { $point_data = array(); $point_id = $point_val['id']; $merchant_name = ''; $point_name = ''; $month_count = 0; $week_count = 0; $year_count = 0; $expired_point = 0; $available_point = 0; $availableweek_point = 0; /*$monthsql = "select * from point_master where MONTH(expire_date)='".$cur_month."' and id='".$point_id."'"; $point_master_month_res = findByQuery($monthsql); if(!empty($point_master_month_res)){ $point_month_sql = "select * from points where user_id='".$user_id."' and point_id='".$point_id."'"; $point_month_res = findByQuery($point_month_sql); //print_r($point_res); if(!empty($point_month_res)){ foreach($point_month_res as $point_month_detail_val){ $month_count = $month_count + $point_month_detail_val['remaining_points']; } } }*/ $point_name = $point_val['name']; if ($point_val['type'] != 0) { $mer_id = $point_val['user_id']; $user_sql = "select merchant_name from users where id='" . $mer_id . "'"; $user_res = findByQuery($user_sql); //print_r($user_res); if (!empty($user_res)) { $merchant_name = $user_res[0]['merchant_name']; } } else { $merchant_name = 'mFoodGate'; } if ($point_val['expire_date'] >= $today && $point_val['expire_date'] <= $nextsixdays) { } $point_sql = "select * from point_details where user_id='" . $user_id . "' and point_id='" . $point_id . "'"; $point_res = findByQuery($point_sql); //print_r($point_res); if (!empty($point_res)) { $total_point = 0; $redeem_point = 0; $totalweek_point = 0; $redeemweek_point = 0; //print_r($point_res); $point_data['id'] = $point_id; $point_data['merchant_name'] = $merchant_name; $point_data['point_name'] = $point_name; $point_data['merchant_name'] = $merchant_name; if ($point_val['expire_date'] >= $today && $point_val['expire_date'] <= $nextsixdays) { foreach ($point_res as $point_detail_val) { //$total_point = $total_point + $point_detail_val['points']; $totalweek_point = $totalweek_point + $point_detail_val['points']; $redeemweek_point = $redeemweek_point + $point_detail_val['redeemed_points']; } $availableweek_point = $total_point - $redeem_point; $week_count = $availableweek_point; } foreach ($point_res as $point_detail_val) { //$total_point = $total_point + $point_detail_val['points']; $total_point = $total_point + $point_detail_val['points']; $redeem_point = $redeem_point + $point_detail_val['redeemed_points']; } $available_point = $total_point - $redeem_point; //$point_data['year_count']=$year_count; $point_data['month_count'] = $available_point; $point_data['week_count'] = $week_count; $rarray[] = $point_data; $cnt = 1; } else { unset($point_master_res[$point_key]); } //print_r($point_detail_res); } //print_r($point_data); //exit; if ($cnt == 1) { $rarray = array('status' => 'success', 'data' => $rarray); } else { $rarray = array(); $rarray = array('status' => 'error', 'data' => $rarray); } } else { $rarray = array(); $rarray = array('status' => 'error', 'data' => $rarray); } echo json_encode($rarray); exit; }
function checkResellPayment() { $cur_date = date('Y-m-d', strtotime("-3 days")); //echo $cur_date; $sql = "select * from voucher_resales where is_sold=1 and ispayment=1 and DATE(sold_on) <= '" . $cur_date . "'"; $res = findByQuery($sql); //echo '<pre>'; //print_r($res); if (!empty($res)) { foreach ($res as $key => $val) { $voucher_id = ''; $resell_id = ''; $voucher_id = $val['voucher_id']; $resell_id = $val['id']; //echo $resell_id; $voucherownerInfo = findByConditionArray(array('voucher_id' => $voucher_id, 'is_active' => 1), 'voucher_owner'); //print_r($voucherownerInfo); if (!empty($voucherownerInfo)) { $last_owner_id = $voucherownerInfo[0]['owner_id']; $owner_id = $voucherownerInfo[0]['id']; //echo $last_owner_id; //echo $owner_id; //exit; $save_data = array(); $save_data['save_data']['is_active'] = 0; $voucher_owner_edit = edit(json_encode($save_data), 'voucher_owner', $owner_id); //print_r($voucher_owner_edit); //exit; $save_data = array(); $save_data['save_data']['is_active'] = 1; $save_data['save_data']['resell_type'] = 0; $last_voucher_owner_edit = edit(json_encode($save_data), 'voucher_owner', $last_owner_id); } //$voucherresellInfo = findByConditionArray(array('id' => $resell_id),'voucher_resales'); //if(!empty($voucherresellInfo)){ $save_data = array(); $save_data['save_data']['is_sold'] = 0; $voucher_owner_edit = edit(json_encode($save_data), 'voucher_resales', $resell_id); //} $voucherResellBidInfo = findByConditionArray(array('voucher_resale_id' => $resell_id, 'is_accepted' => 1), 'voucher_bids'); if (!empty($voucherResellBidInfo)) { $bid_id = $voucherResellBidInfo[0]['id']; $save_data = array(); $save_data['save_data']['is_accepted'] = 0; $voucher_owner_bid_edit = edit(json_encode($save_data), 'voucher_bids', $bid_id); } } } }
function getMyEvents($id) { $rarray = array(); $events = array(); $loc_events = array(); $cat_events = array(); if ($id) { $sql = "SELECT events.id, events.title, events.created_on, events.offer_from_date, events.offer_to_date, events.from_date, events.to_date, events.status, events.image, event_bids.price FROM events, event_bids WHERE event_bids.event_id = events.id and event_bids.user_id='" . $id . "'"; //$event_in = str_repeat('?,', count($events) - 1) . '?'; //$sql = "SELECT * FROM events WHERE id in(".implode(',',$events).")"; //$db = getConnection(); //$stmt = $db->prepare($sql); //$stmt->bindParam("user_id", $user_id); // $stmt->execute($events); $points = findByQuery($sql); //print_r($points); //exit; $count = count($points); for ($i = 0; $i < $count; $i++) { $today = date('Y-m-d'); $checkdate = date('Y-m-d', strtotime($points[$i]['offer_to_date'])); $created_on = date('m/d/Y', strtotime($points[$i]['created_on'])); $points[$i]['created_on'] = $created_on; $from_date = date('m/d/Y', strtotime($points[$i]['offer_from_date'])); $points[$i]['offer_from_date'] = $from_date; $to_date = date('m/d/Y', strtotime($points[$i]['offer_to_date'])); $points[$i]['offer_to_date'] = $to_date; $event_date = date('m/d/Y', strtotime($points[$i]['from_date'])); $points[$i]['event_date'] = $event_date; $event_start_time = date('h:i A', strtotime($points[$i]['from_date'])); $points[$i]['event_start_time'] = $event_start_time; $event_end_time = date('h:i A', strtotime($points[$i]['to_date'])); $points[$i]['event_end_time'] = $event_end_time; $points[$i]['price'] = number_format($points[$i]['price'], 2, '.', ','); if (!empty($points[$i]['image'])) { $points[$i]['image_url'] = SITEURL . 'event_images/' . $points[$i]['image']; } if ($checkdate < $today) { $points[$i]['status'] = 'Expired'; } else { if ($points[$i]['status'] == 'O') { $points[$i]['status'] = 'Open'; } else { if ($points[$i]['status'] == 'E') { $points[$i]['status'] = 'Expired'; } else { $points[$i]['status'] = 'Completed'; } } } } /*if(!empty($points)) { $points = array_map(function($t,$k){ $t->sl = $k+1; //$t->type = ($t->type=='C'?'Credit':'Debit'); $t->date = date('m/d/Y', strtotime($t->date)); $t->expire_date = date('m/d/Y', strtotime($t->expire_date)); return $t; }, $points, array_keys($points)); }*/ $rarray = array('status' => 'success', 'data' => $points); //} } echo json_encode($rarray); }
function getMerResDetail($mid, $rid, $uid, $vid) { $restaurant_details = findByIdArray($rid, 'restaurants'); $merchant_details = findByIdArray($mid, 'users'); $restaurant_id = $restaurant_details['restaurant_id']; $merchant_id = $merchant_details['merchant_id']; //echo "SELECT * FROM `member_user_map` WHERE merchant_id='".$merchant_id."' and user_id=$uid and voucher_id=$vid"; $member_query = "SELECT * FROM `member_user_map` WHERE merchant_id='" . $merchant_id . "' and user_id={$uid} and voucher_id={$vid}"; $memberIdDetails = findByQuery($member_query); //print_r($memberIdDetails); if (!empty($memberIdDetails)) { if (!empty($memberIdDetails[0]['member_id'])) { $member_membership_id = $memberIdDetails[0]['member_id']; $member_membership_end_date = date('d M,Y', strtotime($memberIdDetails[0]['membership_end_date'])); $member_membership_name = $memberIdDetails[0]['name']; } else { $members = "SELECT * FROM `users` WHERE id={$uid}"; $memberDetails = findByQuery($members); $member_membership_id = ''; $member_membership_end_date = ''; $member_membership_name = $memberDetails[0]['first_name'] . ' ' . $memberDetails[0]['last_name']; } } else { $members = "SELECT * FROM `users` WHERE id={$uid}"; $memberDetails = findByQuery($members); $member_membership_id = ''; $member_membership_end_date = ''; $member_membership_name = $memberDetails[0]['first_name'] . ' ' . $memberDetails[0]['last_name']; } $result = array('type' => 'success', 'restaurant_id' => $restaurant_id, 'merchant_id' => $merchant_id, 'member_id' => $member_membership_id, 'expire_date' => $member_membership_end_date, 'memname' => $member_membership_name); echo json_encode($result); }
function getRedeemVoucher($user_id) { $rarray = array(); $conditions = array(); $site_path = SITEURL; $allPromo = findByConditionArray(array('merchant_id' => $user_id), 'offers'); $all_promo_ids = array_column($allPromo, 'id'); //print_r($all_promo_ids); $reddeem_voucher_sql = "select merchantoutlets.title,merchantoutlets.restaurant_id,vouchers.id,vouchers.offer_id,vouchers.price,vouchers.offer_price,vouchers.to_date,vouchers.RedeemDate,vouchers.Status from vouchers,merchantoutlets where vouchers.redeem_outlet = merchantoutlets.outlet_id and vouchers.Status='redeem' and vouchers.offer_id in(" . implode(',', $all_promo_ids) . ")"; $reddeem_voucher_res = findByQuery($reddeem_voucher_sql); if (!empty($reddeem_voucher_res)) { foreach ($reddeem_voucher_res as $reddeem_voucher_res_key => $reddeem_voucher_res_val) { $reddeem_voucher_res[$reddeem_voucher_res_key]['price'] = number_format($reddeem_voucher_res[$reddeem_voucher_res_key]['price'], 0, '.', ','); $reddeem_voucher_res[$reddeem_voucher_res_key]['offer_price'] = number_format($reddeem_voucher_res[$reddeem_voucher_res_key]['offer_price'], 0, '.', ','); $reddeem_voucher_res[$reddeem_voucher_res_key]['to_date'] = date('m-d-Y', strtotime($reddeem_voucher_res[$reddeem_voucher_res_key]['to_date'])); $reddeem_voucher_res[$reddeem_voucher_res_key]['RedeemDate'] = date('m-d-Y', strtotime($reddeem_voucher_res[$reddeem_voucher_res_key]['RedeemDate'])); $offerdetail = findByIdArray($reddeem_voucher_res[$reddeem_voucher_res_key]['offer_id'], 'offers'); $reddeem_voucher_res[$reddeem_voucher_res_key]['offer_title'] = $offerdetail['title']; $reddeem_voucher_res[$reddeem_voucher_res_key]['voucher_number'] = 'MFG-000000000' . $offerdetail['id']; $restaurant_detail = findByIdArray($reddeem_voucher_res[$reddeem_voucher_res_key]['restaurant_id'], 'merchantrestaurants'); $reddeem_voucher_res[$reddeem_voucher_res_key]['restaurant_title'] = $offerdetail['title']; } $rarray = array('type' => 'success', 'data' => $reddeem_voucher_res); } else { $rarray = array('type' => 'success', 'data' => $reddeem_voucher_res); } echo json_encode($rarray); }
function getWebsiteMenuSliderImages($res_id) { $rarray = array(); $query = "SELECT * FROM menus WHERE status=1 and merchantrestaurant_id=" . $res_id . " and image IS NOT NULL"; $details = findByQuery($query); if (!empty($details)) { $details = array_map(function ($t) { $t['image_url'] = SITEURL . 'menu_images/' . $t['image']; return $t; }, $details); $rarray = array('type' => 'success', 'data' => $details); } else { $rarray = array('type' => 'error', 'message' => 'No menu found'); } echo json_encode($rarray); }
function updateCartQuantity() { $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); $rarray = array(); if (!empty($body->item)) { $item = $body->item; $offer_id = $item->offer_id; $promo_details = findByConditionArray(array('id' => $offer_id), 'offers'); //print_r($promo_details); $remaining_promo = $promo_details[0]['quantity'] - $promo_details[0]['buy_count']; $max_purchased = $promo_details[0]['max_purchased']; //$sql = "select * from voucher_owner where offer_id='".$offer_id."' and to_user_id='".$body->user_id."' and is_active=1"; //$voucher_result = findByQuery($sql); //$voucher_count = count($voucher_result); /*if($max_purchased > $voucher_count){ $qty = $max_purchased - $voucher_count; }else{ $qty = 0; }*/ //echo $max_purchased.'a'; //echo $qty.'b'; //echo $voucher_count.'c'; if ($item->quantity <= $remaining_promo) { if ($item->quantity <= $max_purchased) { if ($item->payments == true) { $point_id = $item->point_id; $needed_point = $item->mpoints; $needed_point = $needed_point * $item->quantity; $point_name = $item->point_name; $point_sql = "select * from point_details where user_id='" . $body->user_id . "' and point_id='" . $point_id . "'"; $point_res = findByQuery($point_sql); $available_point = 0; $total_point = 0; $redeem_point = 0; foreach ($point_res as $point_detail_val) { $total_point = $total_point + $point_detail_val['points']; $redeem_point = $redeem_point + $point_detail_val['redeemed_points']; } $available_point = $total_point - $redeem_point; if ($available_point >= $needed_point) { $query = "UPDATE cart set quantity=" . $item->quantity . " where user_id=" . $body->user_id . " and offer_id=" . $item->offer_id; updateByQuery($query); $rarray = array('type' => 'success', 'data' => 'ok'); } else { $rarray = array('type' => 'failure', 'data' => 'You dont have ' . $needed_point . ' ' . $point_name . ' point'); } } else { $query = "UPDATE cart set quantity=" . $item->quantity . " where user_id=" . $body->user_id . " and offer_id=" . $item->offer_id; updateByQuery($query); $rarray = array('type' => 'success', 'data' => 'ok'); } } else { $rarray = array('type' => 'failure', 'data' => 'Quantity must be less than of maximum purchased of this promo'); } } else { $rarray = array('type' => 'failure', 'data' => 'Quantity must be less than of remaining quantity'); } } echo json_encode($rarray); }
function transactionTabDetails() { $rarray = array(); $request = Slim::getInstance()->request(); $body = json_decode($request->getBody()); //print_r($body); //exit; $restaurant_id = array(); $outlet_id = array(); $offer_id = array(); $total_res_ids = array(); $total_outlet_ids = array(); $offers_ids = array(); $merchant_id = $body->merchant_id; $start_date = $body->start_date; $end_date = $body->end_date; if (isset($body->selRes)) { $restaurant_id = $body->selRes; //print_r($restaurant_id); foreach ($restaurant_id as $res_key => $res_value) { $res_ids = array(); $res_sql = "select * from restaurants where restaurant_id='" . $res_value . "'"; $res_sql_res = findByQuery($res_sql); $res_ids = array_column($res_sql_res, 'id'); if (!empty($res_ids)) { $total_res_ids[] = $res_ids[0]; } } } if (isset($body->selout)) { $outlet_id = $body->selout; foreach ($outlet_id as $outlet_key => $outlet_value) { $out_ids = array(); $out_sql = "select * from outlets where outlet_id='" . $outlet_value . "'"; $out_sql_res = findByQuery($out_sql); $out_ids = array_column($out_sql_res, 'id'); if (!empty($out_ids)) { $total_outlet_ids[] = $out_ids[0]; } } } $type = $body->type; if (!empty($total_res_ids)) { $sql = "SELECT * FROM offer_restaurent_map where offer_restaurent_map.restaurent_id in(" . implode(",", $total_res_ids) . ")"; $res_offer_res = findByQuery($sql); $offers_ids = array_column($res_offer_res, 'offer_id'); //print_r($offers_ids); } if (!empty($total_outlet_ids)) { if (!empty($offers_ids)) { $sql = "SELECT * FROM offer_outlet_map where offer_outlet_map.offer_id in(" . implode(",", $offers_ids) . ") and offer_outlet_map.outlet_id in(" . implode(",", $total_outlet_ids) . ")"; $out_offer_res = findByQuery($sql); $offers_ids = array_column($out_offer_res, 'offer_id'); //print_r($offers_ids); } } $allPaymentOffer = 0; $allMenuOffer = 0; $allMembershipOffer = 0; $allRedeemPaymentOffer = 0; $allRedeemMenuOffer = 0; $allRedeemMembershipOffer = 0; $allAvailablePaymentOffer = 0; $allAvailableMenuOffer = 0; $allAvailableMembershipOffer = 0; $offerPaymentOffer = 0; $offerMenuOffer = 0; $offerMembershipOffer = 0; $redeemPaymentOffer = 0; $redeemMenuOffer = 0; $redeemMembershipOffer = 0; $availablePaymentOffer = 0; $availableMenuOffer = 0; $availableMembershipOffer = 0; $willActivePaymentOffer = 0; $willActiveMenuOffer = 0; $willActiveMembershipOffer = 0; $newPaymentOffer = 0; $newMenuOffer = 0; $newMembershipOffer = 0; $hotPaymentOffer = 0; $hotMenuOffer = 0; $hotMembershipOffer = 0; $lastdayPaymentOffer = 0; $lastdayMenuOffer = 0; $lastdayMembershipOffer = 0; $specialPaymentOffer = 0; $specialMenuOffer = 0; $specialMembershipOffer = 0; $viewPaymentOffer = 0; $viewMenuOffer = 0; $viewMembershipOffer = 0; $willActiveNews = 0; $willActiveAddv = 0; $willActiveBanner = 0; $activeNews = 0; $activeAddv = 0; $activeBanner = 0; $targetNews = 0; $targetAddv = 0; $targetBanner = 0; $actualNews = 0; $actualAddv = 0; $actualBanner = 0; $remainingNews = 0; $remainingAddv = 0; $remainingBanner = 0; $exceedNews = 0; $exceedAddv = 0; $exceedBanner = 0; $exceedNews = 0; $exceedAddv = 0; $exceedBanner = 0; $availableEvent = 0; $dealEvent = 0; $openEvent = 0; $feedbackEvent = 0; $myEvent = 0; $myOfferEvent = 0; $generatedPoint = 0; $redeemPoint = 0; $expiredPoint = 0; $balancedPoint = 0; $nextMonthExpPoint = 0; $thisYearExpPoint = 0; //print_r($offers_ids); if (!empty($offers_ids)) { $payment_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=2"; $menu_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=1"; $membership_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=3"; $all_payment_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and offer_type_id=2"; $all_menu_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and offer_type_id=1"; $all_membership_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and offer_type_id=3"; $payment_promo_res = findByQuery($payment_promo_sql); $menu_promo_res = findByQuery($menu_promo_sql); $membership_promo_res = findByQuery($membership_promo_sql); $all_payment_promo_res = findByQuery($all_payment_promo_sql); $all_menu_promo_res = findByQuery($all_menu_promo_sql); $all_membership_promo_res = findByQuery($all_membership_promo_sql); //print_r($all_payment_promo_res); //print_r($all_menu_promo_res); //print_r($all_membership_promo_res); if (!empty($all_payment_promo_res)) { if ($type == 'unit') { $allPaymentOffer = count($all_payment_promo_res); $allRedeemPaymentOffer = 0; $allAvailablePaymentOffer = count($all_payment_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($all_payment_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $allPaymentOffer = $cntt; $allRedeemPaymentOffer = $cntr; $allAvailablePaymentOffer = $cnta; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($all_payment_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $allPaymentOffer = $cntt; $allRedeemPaymentOffer = $cntr; $allAvailablePaymentOffer = $cnta; } } if (!empty($all_menu_promo_res)) { if ($type == 'unit') { $allMenuOffer = count($all_menu_promo_res); $allRedeemMenuOffer = 0; $allAvailableMenuOffer = count($all_menu_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($all_menu_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $allMenuOffer = $cntt; $allRedeemMenuOffer = $cntr; $allAvailableMenuOffer = $cnta; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($all_menu_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $allMenuOffer = $cntt; $allRedeemMenuOffer = $cntr; $allAvailableMenuOffer = $cnta; } } if (!empty($all_membership_promo_res)) { if ($type == 'unit') { $allMembershipOffer = count($all_membership_promo_res); $allRedeemMembershipOffer = 0; $allAvailableMembershipOffer = count($all_membership_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($all_membership_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $allMembershipOffer = $cntt; $allRedeemMembershipOffer = $cntr; $allAvailableMembershipOffer = $cnta; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($all_membership_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $allMembershipOffer = $cntt; $allRedeemMembershipOffer = $cntr; $allAvailableMembershipOffer = $cnta; } } if (!empty($payment_promo_res)) { if ($type == 'unit') { $offerPaymentOffer = count($payment_promo_res); $redeemPaymentOffer = 0; $availablePaymentOffer = count($payment_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $offerPaymentOffer = $cntt; $redeemPaymentOffer = $cntr; $availablePaymentOffer = $cnta; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $offerPaymentOffer = $cntt; $redeemPaymentOffer = $cntr; $availablePaymentOffer = $cnta; } } if (!empty($menu_promo_res)) { if ($type == 'unit') { $offerMenuOffer = count($menu_promo_res); $redeemMenuOffer = 0; $availableMenuOffer = count($menu_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $offerMenuOffer = $cntt; $redeemMenuOffer = $cntr; $availableMenuOffer = $cnta; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $offerMenuOffer = $cntt; $redeemMenuOffer = $cntr; $availableMenuOffer = $cnta; } } if (!empty($membership_promo_res)) { if ($type == 'unit') { $offerMembershipOffer = count($membership_promo_res); $redeemMembershipOffer = 0; $availableMembershipOffer = count($membership_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $offerMembershipOffer = $cntt; $redeemMembershipOffer = $cntr; $availableMembershipOffer = $cnta; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $offerMembershipOffer = $cntt; $redeemMembershipOffer = $cntr; $availableMembershipOffer = $cnta; } } $payment_will_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date)>=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=2"; $menu_will_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date)>=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=1"; $membership_will_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date)>=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=3"; $payment_new_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date)=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=2"; $menu_new_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date)=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=1"; $membership_new_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date)=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=3"; $site_settings = findByIdArray('1', 'site_settings'); if (!empty($site_settings['hot_percentage'])) { $perc = $site_settings['hot_percentage']; } else { $perc = 0; } $payment_hot_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=2 and DATE(offer_from_date) <=CURDATE() and buy_count < quantity and ((buy_count/quantity)*100)>={$perc}"; $menu_hot_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=1 and DATE(offer_from_date) <=CURDATE() and buy_count < quantity and ((buy_count/quantity)*100)>={$perc}"; $membership_hot_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=3 and DATE(offer_from_date) <=CURDATE() and buy_count < quantity and ((buy_count/quantity)*100)>={$perc}"; $payment_last_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_to_date)=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=2"; $menu_last_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_to_date)=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=1"; $membership_last_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_to_date)=CURDATE() and id in(" . implode(',', $offers_ids) . ") and offer_type_id=3"; $payment_special_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=2 and is_special=1"; $menu_special_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=1 and is_special=1"; $membership_special_promo_sql = "select * from offers where merchant_id='" . $merchant_id . "' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and id in(" . implode(',', $offers_ids) . ") and offer_type_id=3 and is_special=1"; $payment_promo_view_sql = "select * from promo_visit where DATE(created_date) between '" . $start_date . "' AND '" . $end_date . "' and merchant_id='" . $merchant_id . "'"; $menu_promo_view_sql = "select * from promo_visit where DATE(created_date) between '" . $start_date . "' AND '" . $end_date . "' and merchant_id='" . $merchant_id . "'"; $membership_promo_view_sql = "select * from promo_visit where DATE(created_date) between '" . $start_date . "' AND '" . $end_date . "' and merchant_id='" . $merchant_id . "'"; $payment_will_promo_res = findByQuery($payment_will_promo_sql); $menu_will_promo_res = findByQuery($menu_will_promo_sql); $membership_will_promo_res = findByQuery($membership_will_promo_sql); $payment_new_promo_res = findByQuery($payment_new_promo_sql); $menu_new_promo_res = findByQuery($menu_new_promo_sql); $membership_new_promo_res = findByQuery($membership_new_promo_sql); $payment_hot_promo_res = findByQuery($payment_hot_promo_sql); $menu_hot_promo_res = findByQuery($menu_hot_promo_sql); $membership_hot_promo_res = findByQuery($membership_hot_promo_sql); $payment_last_promo_res = findByQuery($payment_last_promo_sql); $menu_last_promo_res = findByQuery($menu_last_promo_sql); $membership_last_promo_res = findByQuery($membership_last_promo_sql); $payment_special_promo_res = findByQuery($payment_special_promo_sql); $menu_special_promo_res = findByQuery($menu_special_promo_sql); $membership_special_promo_res = findByQuery($membership_special_promo_sql); $payment_promo_view_res = findByQuery($payment_promo_view_sql); $menu_promo_view_res = findByQuery($menu_promo_view_sql); $membership_promo_view_res = findByQuery($membership_promo_view_sql); if (!empty($payment_will_promo_res)) { if ($type == 'unit') { $willActivePaymentOffer = count($payment_will_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_will_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $willActivePaymentOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_will_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $willActivePaymentOffer = $cntt; } } if (!empty($menu_will_promo_res)) { if ($type == 'unit') { $willActiveMenuOffer = count($menu_will_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_will_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $willActiveMenuOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_will_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $willActiveMenuOffer = $cntt; } } if (!empty($membership_will_promo_res)) { if ($type == 'unit') { $willActiveMembershipOffer = count($membership_will_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_will_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $willActiveMembershipOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_will_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $willActiveMembershipOffer = $cntt; } } if (!empty($payment_new_promo_res)) { if ($type == 'unit') { $newPaymentOffer = count($payment_new_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_new_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $newPaymentOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_new_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $newPaymentOffer = $cntt; } } if (!empty($menu_new_promo_res)) { if ($type == 'unit') { $newMenuOffer = count($menu_new_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_new_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $newMenuOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_new_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $newMenuOffer = $cntt; } } if (!empty($membership_new_promo_res)) { if ($type == 'unit') { $newMembershipOffer = count($membership_new_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_new_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $newMembershipOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_new_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $newMembershipOffer = $cntt; } } if (!empty($payment_hot_promo_res)) { if ($type == 'unit') { $hotPaymentOffer = count($payment_hot_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_hot_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $hotPaymentOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_hot_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $hotPaymentOffer = $cntt; } } if (!empty($menu_hot_promo_res)) { if ($type == 'unit') { $hotMenuOffer = count($menu_hot_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_hot_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $hotMenuOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_hot_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $hotMenuOffer = $cntt; } } if (!empty($membership_hot_promo_res)) { if ($type == 'unit') { $hotMembershipOffer = count($membership_hot_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_hot_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $hotMembershipOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_hot_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $hotMembershipOffer = $cntt; } } if (!empty($payment_last_promo_res)) { if ($type == 'unit') { $lastdayPaymentOffer = count($payment_last_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_last_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $lastdayPaymentOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_last_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $lastdayPaymentOffer = $cntt; } } if (!empty($menu_last_promo_res)) { if ($type == 'unit') { $lastdayMenuOffer = count($menu_last_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_last_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $lastdayMenuOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_last_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $lastdayMenuOffer = $cntt; } } if (!empty($membership_last_promo_res)) { if ($type == 'unit') { $lastdayMembershipOffer = count($membership_last_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_last_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $lastdayMembershipOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_last_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $lastdayMembershipOffer = $cntt; } } if (!empty($payment_special_promo_res)) { if ($type == 'unit') { $specialPaymentOffer = count($payment_special_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_special_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $specialPaymentOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($payment_special_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $specialPaymentOffer = $cntt; } } if (!empty($menu_special_promo_res)) { if ($type == 'unit') { $specialMenuOffer = count($menu_special_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_special_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $specialMenuOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($menu_special_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $specialMenuOffer = $cntt; } } if (!empty($membership_special_promo_res)) { if ($type == 'unit') { $specialMembershipOffer = count($membership_special_promo_res); } elseif ($type == 'quantity') { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_special_promo_res as $key => $value) { $cntr = $cntr + $value['buy_count']; $cntt = $cntt + $value['quantity']; $available = 0; $available = $value['quantity'] - $value['buy_count']; $cnta = $cnta + $available; } $specialMembershipOffer = $cntt; } else { $cntr = 0; $cnta = 0; $cntt = 0; foreach ($membership_special_promo_res as $key => $value) { $cntr = $cntr + $value['offer_price'] * $value['buy_count']; $cntt = $cntt + $value['offer_price'] * $value['quantity']; $available = 0; $available = ($value['quantity'] - $value['buy_count']) * $value['offer_price']; $cnta = $cnta + $available; } $specialMembershipOffer = $cntt; } } if (!empty($payment_promo_view_res)) { if ($type == 'unit') { $viewPaymentOffer = count($payment_promo_view_res); } elseif ($type == 'quantity') { $viewPaymentOffer = count($payment_promo_view_res); } else { $viewPaymentOffer = count($payment_promo_view_res); } } if (!empty($menu_promo_view_res)) { if ($type == 'unit') { $viewMenuOffer = count($menu_promo_view_res); } elseif ($type == 'quantity') { $viewMenuOffer = count($menu_promo_view_res); } else { $viewMenuOffer = count($menu_promo_view_res); } } if (!empty($membership_promo_view_res)) { if ($type == 'unit') { $viewMembershipOffer = count($membership_promo_view_res); } elseif ($type == 'quantity') { $viewMembershipOffer = count($membership_promo_view_res); } else { $viewMembershipOffer = count($membership_promo_view_res); } } if (!empty($total_res_ids)) { $will_active_add_sql = "select * from advertisements where merchant_id='" . $merchant_id . "' and restaurant_id in(" . implode(',', $total_res_ids) . ") and DATE(start_date)>CURDATE() and is_active=1"; $active_add_sql = "select * from advertisements where merchant_id='" . $merchant_id . "' and restaurant_id in(" . implode(',', $total_res_ids) . ") and DATE(start_date) between '" . $start_date . "' AND '" . $end_date . "' and is_active=1"; $will_active_banner_sql = "select * from banners where merchant_id='" . $merchant_id . "' and restaurant_id in(" . implode(',', $total_res_ids) . ") and DATE(start_date)>CURDATE() and is_active=1"; $active_banner_sql = "select * from banners where merchant_id='" . $merchant_id . "' and restaurant_id in(" . implode(',', $total_res_ids) . ") and DATE(start_date) between '" . $start_date . "' AND '" . $end_date . "' and is_active=1"; $will_active_news_sql = "select * from news where user_id='" . $merchant_id . "' and DATE(published_date)>CURDATE()"; $active_news_sql = "select * from news where user_id='" . $merchant_id . "' and DATE(published_date) between '" . $start_date . "' AND '" . $end_date . "'"; $will_active_add_res = findByQuery($will_active_add_sql); $active_add_res = findByQuery($active_add_sql); $will_active_banner_res = findByQuery($will_active_banner_sql); $active_banner_res = findByQuery($active_banner_sql); $will_active_news_res = findByQuery($will_active_news_sql); $active_news_res = findByQuery($active_news_sql); if (!empty($will_active_add_res)) { $willActiveAddv = count($will_active_add_res); } if (!empty($will_active_banner_res)) { $willActiveBanner = count($will_active_banner_res); } if (!empty($will_active_news_res)) { $willActiveNews = count($will_active_news_res); } if (!empty($active_news_res)) { $activeNews = count($active_news_res); $targetNews = count($active_news_res); $actualNews = count($active_news_res); $remainingNews = count($active_news_res); $exceedNews = count($active_news_res); } if (!empty($active_add_res)) { $activeAddv = count($active_add_res); $cntt = 0; $cnta = 0; $cntr = 0; $cnte = 0; foreach ($active_add_res as $key => $value) { $cntt = $cntt + $value['target_click']; $cnta = $cnta + $value['number_of_click']; if ($value['target_click'] > $value['number_of_click']) { $cntr = $cntr + ($value['target_click'] - $value['number_of_click']); } else { $cnte = $cnte + ($value['number_of_click'] - $value['target_click']); } } $targetAddv = $cntt; $actualAddv = $cnta; $remainingAddv = $cntr; $exceedAddv = $cnte; } if (!empty($active_banner_res)) { $activeBanner = count($active_banner_res); $cntt = 0; $cnta = 0; $cntr = 0; $cnte = 0; foreach ($active_banner_res as $key => $value) { $cntt = $cntt + $value['target_click']; $cnta = $cnta + $value['number_of_click']; if ($value['target_click'] > $value['number_of_click']) { $cntr = $cntr + ($value['target_click'] - $value['number_of_click']); } else { $cnte = $cnte + ($value['number_of_click'] - $value['target_click']); } } $targetBanner = $cntt; $actualBanner = $cnta; $remainingBanner = $cntr; $exceedBanner = $cnte; } } } $available_event_sql = "select * from events where status='O' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and is_active=1"; $available_event_res = findByQuery($available_event_sql); $events_ids = array_column($available_event_res, 'id'); $availableEvent = count($available_event_res); //print_r($events_ids); //print_r($available_event_res); $deal_event_sql = "select * from events where status='C' and DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and is_active=1"; $deal_event_res = findByQuery($deal_event_sql); $dealEvent = count($deal_event_res); //print_r($deal_event_res); if (!empty($events_ids)) { $open_event_sql = "select * from event_bids where event_id NOT in(" . implode(',', $events_ids) . ") and is_accepted = 0"; $open_event_res = findByQuery($open_event_sql); $openEvent = count($open_event_res); //print_r($open_event_res); $feedback_event_sql = "select * from event_bids where event_id in(" . implode(',', $events_ids) . ") and is_accepted = 0 and user_id != '" . $merchant_id . "'"; $feedback_event_res = findByQuery($feedback_event_sql); $feedbackEvent = count($feedback_event_res); } $events = array(); $merchant_category = findByConditionArray(array('user_id' => $merchant_id), 'merchant_category_map'); $category_ids = array_column($merchant_category, 'category_id'); $merchant_location = findByConditionArray(array('user_id' => $merchant_id), 'merchant_location_map'); $location_ids = array_column($merchant_location, 'location_id'); $sql = "SELECT * FROM event_location_map WHERE location_id in(" . implode(',', $location_ids) . ")"; $data = findByQuery($sql); if (!empty($data)) { $events = array_column($data, 'event_id'); } $sql = "SELECT * FROM event_category_map WHERE category_id in(" . implode(',', $category_ids) . ")"; $cat_data = findByQuery($sql); if (!empty($cat_data)) { $cat_events = array_column($cat_data, 'event_id'); if (!empty($cat_events)) { foreach ($cat_events as $ta) { $events[] = $ta; } } } $events = array_values(array_unique($events)); if (!empty($events)) { $my_event_sql = "select * from events where DATE(offer_from_date) between '" . $start_date . "' AND '" . $end_date . "' and is_active=1 and id in(" . implode(',', $events) . ")"; $my_event_res = findByQuery($my_event_sql); $myeventsid = array_column($my_event_res, 'id'); $myEvent = count($my_event_res); if (!empty($myeventsid)) { $offer_event_sql = "select * from event_bids where event_id in(" . implode(',', $myeventsid) . ") and user_id = '" . $merchant_id . "'"; $offer_event_res = findByQuery($offer_event_sql); $myOfferEvent = count($offer_event_res); } } $cur_month = date('m'); $next_month = $cur_month + 1; $cur_year = date('Y'); $point_master_sql = "select * from point_master where user_id='" . $merchant_id . "' and DATE(start_date) between '" . $start_date . "' AND '" . $end_date . "'"; $exp_master_sql = "select * from point_master where user_id='" . $merchant_id . "' and DATE(expire_date) < CURDATE()"; $next_month_exp_master_sql = "select * from point_master where user_id='" . $merchant_id . "' and MONTH(expire_date)= '" . $next_month . "'"; $cur_year_exp_master_sql = "select * from point_master where user_id='" . $merchant_id . "' and YEAR(expire_date)= '" . $cur_year . "'"; $point_master_res = findByQuery($point_master_sql); $exp_master_res = findByQuery($exp_master_sql); $next_month_exp_master_res = findByQuery($next_month_exp_master_sql); $cur_year_exp_master_res = findByQuery($cur_year_exp_master_sql); $pointsid = array_column($point_master_res, 'id'); $exppointsid = array_column($exp_master_res, 'id'); $nextmonthpointsid = array_column($next_month_exp_master_res, 'id'); $curyearpointsid = array_column($cur_year_exp_master_res, 'id'); //print_r($pointsid); //print_r($exppointsid); //print_r($nextmonthpointsid); //print_r($curyearpointsid); if (!empty($pointsid)) { $generated_mpoint_sql = "select sum(points) as generated,sum(redeemed_points) as redeem,sum(remaining_points) as balance from point_details where merchant_id='" . $merchant_id . "' and point_id in(" . implode(',', $pointsid) . ")"; $generated_mpoint_res = findByQuery($generated_mpoint_sql); //print_r($generated_mpoint_res); if (!empty($generated_mpoint_res)) { $generatedPoint = $generated_mpoint_res[0]['generated']; $redeemPoint = $generated_mpoint_res[0]['redeem']; $balancedPoint = $generated_mpoint_res[0]['balance']; //echo $generatedPoint; } } if (!empty($exppointsid)) { $expired_mpoint_sql = "select sum(remaining_points) as balance from point_details where merchant_id='" . $merchant_id . "' and point_id in(" . implode(',', $exppointsid) . ")"; $expired_mpoint_res = findByQuery($expired_mpoint_sql); //print_r($expired_mpoint_res); if (!empty($expired_mpoint_res)) { $expiredPoint = $expired_mpoint_res[0]['balance']; //echo $expiredPoint; } } if (!empty($nextmonthpointsid)) { $nextmonth_mpoint_sql = "select sum(remaining_points) as balance from point_details where merchant_id='" . $merchant_id . "' and point_id in(" . implode(',', $nextmonthpointsid) . ")"; $nextmonth_mpoint_res = findByQuery($nextmonth_mpoint_sql); //print_r($nextmonth_mpoint_res); if (!empty($nextmonth_mpoint_res)) { $nextMonthExpPoint = $nextmonth_mpoint_res[0]['balance']; //echo $expiredPoint; } } if (!empty($curyearpointsid)) { $curyear_mpoint_sql = "select sum(remaining_points) as balance from point_details where merchant_id='" . $merchant_id . "' and point_id in(" . implode(',', $curyearpointsid) . ")"; $curyear_mpoint_res = findByQuery($curyear_mpoint_sql); //print_r($curyear_mpoint_res); if (!empty($curyear_mpoint_res)) { $thisYearExpPoint = $curyear_mpoint_res[0]['balance']; //echo $expiredPoint; } } //exit; $data = array('allMenuOffer' => $allMenuOffer, 'allMembershipOffer' => $allMembershipOffer, 'allPaymentOffer' => $allPaymentOffer, 'allRedeemPaymentOffer' => $allRedeemPaymentOffer, 'allRedeemMenuOffer' => $allRedeemMenuOffer, 'allRedeemMembershipOffer' => $allRedeemMembershipOffer, 'allAvailablePaymentOffer' => $allAvailablePaymentOffer, 'allAvailableMenuOffer' => $allAvailableMenuOffer, 'allAvailableMembershipOffer' => $allAvailableMembershipOffer, 'offerPaymentOffer' => $offerPaymentOffer, 'offerMenuOffer' => $offerMenuOffer, 'offerMembershipOffer' => $offerMembershipOffer, 'redeemPaymentOffer' => $redeemPaymentOffer, 'redeemMenuOffer' => $redeemMenuOffer, 'redeemMembershipOffer' => $redeemMembershipOffer, 'availablePaymentOffer' => $availablePaymentOffer, 'availableMenuOffer' => $availableMenuOffer, 'availableMembershipOffer' => $availableMembershipOffer, 'willActivePaymentOffer' => $willActivePaymentOffer, 'willActiveMenuOffer' => $willActiveMenuOffer, 'willActiveMembershipOffer' => $willActiveMembershipOffer, 'newPaymentOffer' => $newPaymentOffer, 'newMenuOffer' => $newMenuOffer, 'newMembershipOffer' => $newMembershipOffer, 'newMembershipOffer' => $newMembershipOffer, 'hotPaymentOffer' => $hotPaymentOffer, 'hotMenuOffer' => $hotMenuOffer, 'hotMembershipOffer' => $hotMembershipOffer, 'lastdayPaymentOffer' => $lastdayPaymentOffer, 'lastdayMenuOffer' => $lastdayMenuOffer, 'lastdayMembershipOffer' => $lastdayMembershipOffer, 'specialPaymentOffer' => $specialPaymentOffer, 'specialMenuOffer' => $specialMenuOffer, 'specialMembershipOffer' => $specialMembershipOffer, 'viewPaymentOffer' => $viewPaymentOffer, 'viewMenuOffer' => $viewMenuOffer, 'viewMembershipOffer' => $viewMembershipOffer, 'willActiveNews' => $willActiveNews, 'willActiveAddv' => $willActiveAddv, 'willActiveBanner' => $willActiveBanner, 'activeNews' => $activeNews, 'activeAddv' => $activeAddv, 'activeBanner' => $activeBanner, 'targetNews' => $targetNews, 'targetAddv' => $targetAddv, 'targetBanner' => $targetBanner, 'actualNews' => $actualNews, 'actualAddv' => $actualAddv, 'actualBanner' => $actualBanner, 'remainingNews' => $remainingNews, 'remainingAddv' => $remainingAddv, 'remainingBanner' => $remainingBanner, 'exceedNews' => $exceedNews, 'exceedAddv' => $exceedAddv, 'exceedBanner' => $exceedBanner, 'availableEvent' => $availableEvent, 'dealEvent' => $dealEvent, 'openEvent' => $openEvent, 'feedbackEvent' => $feedbackEvent, 'myEvent' => $myEvent, 'myOfferEvent' => $myOfferEvent, 'generatedPoint' => $generatedPoint, 'redeemPoint' => $redeemPoint, 'expiredPoint' => $expiredPoint, 'balancedPoint' => $balancedPoint, 'nextMonthExpPoint' => $nextMonthExpPoint, 'thisYearExpPoint' => $thisYearExpPoint); $rarray = array('type' => 'success', 'data' => $data); echo json_encode($rarray); }