Exemple #1
0
    static function get_fees($pid = null) {
        $fees = unserialize(self::get_key('fees'));
        if (empty($fees) || !is_array($fees)) {
            return null;
        }
        $list_city = City::get_list(true);

        $list_district = District::get_list(true, $pid);

        $list_fee = array();
        if (!empty($fees)) {
            foreach ($fees as $did => $fee) {
                if (!empty($list_district[$did])) {
                    $fee['city'] = $list_city[$fee['cid']];
                    $fee['district'] = $list_district[$did];
                    $fee['delivery_fee_formatted'] = EClassApi::numberFormat($fee['delivery_fee']);
                    $fee['min_order_formatted'] = EClassApi::numberFormat($fee['min_order']);
                    $fee['min_order_fee_formatted'] = EClassApi::numberFormat($fee['min_order_fee']);
                    $fee['free_delivery_formatted'] = EClassApi::numberFormat($fee['free_delivery']);
                    $list_fee[$did] = $fee;
                }
            }
        }

        return $list_fee;
    }
Exemple #2
0
 public function getDataForMapByLatLng()
 {
     $lat = Url::get('lat');
     $lng = Url::get('lng');
     $val = '{"data":[';
     $km = 2;
     $distance = $km / 111;
     $latitude1 = $lat + $distance;
     $latitude2 = $lat - $distance;
     $longitude1 = $lng + $distance;
     $longitude2 = $lng - $distance;
     $city_res = array();
     $sql = 'SELECT * FROM supplier WHERE latitude > ' . $latitude2 . ' AND latitude < ' . $latitude1 . ' AND longitude > ' . $longitude2 . ' AND longitude < ' . $longitude1;
     $re = DB::query($sql);
     if ($re) {
         while ($row = mysql_fetch_assoc($re)) {
             $row['rating_percent'] = floor(intval($row['vote_point']) * 100 / 5);
             $row['vote_point'] = EClassApi::numberFormat($row['vote_point']);
             $row['introduce'] = htmlspecialchars_decode($row['introduce']);
             $row['introduce_en'] = htmlspecialchars_decode($row['introduce_en']);
             if ($row['logo'] != '') {
                 if (strstr($row['logo'], 'supplier/')) {
                     $row['logo'] = IMAGE_PATH . 'thumb/100_100/' . $row['logo'];
                 } else {
                     $row['logo'] = IMAGE_PATH . $row['logo'];
                 }
             }
             $city_res[] = $row;
         }
     }
     $lengh = 0;
     //Lấy thông tin các khách sạn ở gần
     if (!empty($city_res) && is_array($city_res)) {
         $lengh = sizeof($city_res);
         foreach ($city_res as $h) {
             $rank = $h['id'];
             $val .= '{"rank":' . $rank . ',
                         "id": ' . $h['id'] . ',
                         "name":"' . $h['name'] . '",
                         "address":"' . $h['address'] . '",
                         "img":"' . $h['logo'] . '",
                         "shortcut":"' . $h['shortcut'] . '",
                         "shortcut_en":"' . $h['shortcut_en'] . '",
                         "type":"hotel",
                         "latitude":' . $h['latitude'] . ',
                         "longitude": ' . $h['longitude'] . ',
                         "star": ' . $h['vote_point'] . '},';
         }
     }
     $val = substr_replace($val, "", -1);
     $val .= '], "lengh":' . $lengh . '}';
     echo $val;
 }
Exemple #3
0
 function draw()
 {
     global $display;
     if (!User::is_login()) {
         return;
     }
     $this->beginForm(true, "post", false, "?" . htmlentities($_SERVER['QUERY_STRING']));
     if (CGlobal::$lang == 1) {
         $display->add('lng', language::$LNG['personal']['en']);
     } else {
         $display->add('lng', language::$LNG['personal']['vn']);
     }
     $item_per_page = 6;
     $total_row = DB::fetch('SELECT count(*) AS total_row FROM `order` o WHERE o.uid = ' . User::$current->data['id'] . ' AND o.status <> 0 LIMIT 0,1', 'total_row', 0);
     $list_bill = array();
     $paging = '';
     if ($total_row) {
         $limit = '';
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total_row, $item_per_page, 10, 'page_no', true);
         $sql = 'SELECT *, o.id as oid FROM `order` o WHERE o.uid = ' . User::$current->data['id'] . ' AND o.status <> 0 ORDER BY o.id DESC ' . $limit;
         $re = DB::query($sql);
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 if ($_COOKIE['lang'] == 1) {
                     $row['delivery_time'] = date('H:i:s m-d-Y', $row['delivery_time'] * 60 + $row['time']);
                 } else {
                     $row['delivery_time'] = date('H:i:s d-m-Y', $row['delivery_time'] * 60 + $row['time']);
                 }
                 $row['total'] = EClassApi::numberFormat($row['total']);
                 $list_bill[] = $row;
             }
         }
         $display->add('list_bill', $list_bill);
         $display->add('total_row', $total_row);
         $display->add('paging', $paging);
     }
     $var = null;
     $sql = "SELECT DISTINCT a.*, d.name AS district_name, d.name_en AS district_name_en, p.id AS pid, p.name AS city_name, p.name_en AS city_name_en FROM delivery_address a INNER JOIN district d ON a.did = d.id INNER JOIN city p ON d.pid = p.id WHERE uid = " . User::$current->data['id'];
     //Get city
     $result = DB::query($sql);
     $list_delivery = array();
     $address_default = null;
     if ($result) {
         while ($row = mysql_fetch_assoc($result)) {
             //$address = $row['address'];
             //$city_name = $row['city_name'];
             //$district_name = $row['district_name'];
             //$note = $row['note'];
             if ($row['is_default'] == 1) {
                 $address_default = $row;
             }
             $list_delivery[] = $row;
         }
     }
     $display->add('list_delivery', $list_delivery);
     $display->add('address_default', $address_default);
     $user = PersonalDB::get_account_information();
     $next_reward = 100 - $user['point'] % 100;
     $display->add('next_reward', $next_reward);
     $display->add('list_city', City::get_list());
     if (!empty($address_default) && !empty($address_default['pid'])) {
         $display->add('list_district', City::get_districts($address_default['pid']));
     }
     $display->add('user', $user);
     $display->add('lang', CGlobal::$lang);
     $display->add('error_message', $this->getErrorMessage('personal/change_password'));
     $display->add('success_message', $this->getSuccessMessage('personal/change_password'));
     $display->add('form_data', $this->getSuccessMessage('personal/form_data'));
     $display->setTemplate('ManageOrder', $var);
     $this->endForm();
 }
Exemple #4
0
 function draw()
 {
     global $display;
     $this->beginForm(false, 'post', false, Url::build_current());
     $item_per_page = 15;
     $sql_count = 'SELECT count(*) AS total_row FROM `order` o INNER JOIN account a ON o.uid = a.id';
     $list_orders = array();
     $paging = '';
     // Get Filter Parameters
     $order_code = EClassApi::getParam('order_code');
     $from_date = EClassApi::getParam('from_date');
     $fdo = $from_date;
     $uid = Url::get('id');
     $to_date = EClassApi::getParam('to_date');
     $tdo = $to_date;
     $rid = EClassApi::getParam('rid');
     $scope = EClassApi::getParam('scope');
     if (!empty($from_date)) {
         $from_date = SupplierHelper::get_time_stamp($from_date);
     }
     if (!empty($to_date)) {
         $to_date = SupplierHelper::get_time_stamp($to_date, 1);
     }
     $conditions = '';
     if (intval($uid) > 0) {
         if (strstr($conditions, 'WHERE')) {
             $conditions .= " AND o.uid = " . $uid;
         } else {
             $conditions .= " WHERE o.uid = " . $uid;
         }
     }
     if (!empty($order_code)) {
         if (strstr($conditions, 'WHERE')) {
             $conditions .= " AND order_code LIKE '" . $order_code . "%'";
         } else {
             $conditions .= " WHERE order_code LIKE '" . $order_code . "%'";
         }
     }
     if (!empty($from_date)) {
         if (strstr($conditions, 'WHERE')) {
             $conditions .= " AND time >= " . $from_date;
         } else {
             $conditions .= " WHERE time >= " . $from_date;
         }
     }
     if (!empty($to_date)) {
         if (strstr($conditions, 'WHERE')) {
             $conditions .= " AND time <= " . $to_date;
         } else {
             $conditions .= " WHERE time <= " . $to_date;
         }
     }
     if (strstr($conditions, 'WHERE')) {
         $conditions .= " AND o.status <> 0 ";
     } else {
         $conditions .= " WHERE o.status <> 0 ";
     }
     $sql_count .= $conditions . ' LIMIT 0, 1';
     $total_row = DB::fetch($sql_count, 'total_row', 0);
     if ($total_row) {
         $limit = '';
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total_row, $item_per_page, 10, 'page_no', true);
         $sql = 'SELECT p.name AS city_name, d.name AS district_name, s.name AS cod_name, o.*, a.user_name, a.id as account_id, a.email AS account_email FROM `order` o INNER JOIN account a ON o.uid = a.id LEFT JOIN cod s ON o.cod_id = s.id INNER JOIN district d ON o.ship_district = d.id INNER JOIN city p ON d.pid = p.id' . $conditions . ' ORDER BY id DESC ' . $limit;
         $res = DB::query($sql);
         $today = date('d/m/Y');
         if ($res) {
             while ($row = mysql_fetch_assoc($res)) {
                 $row['order_time'] = trim(date('d/m/Y', $row['time']));
                 if ($today == $row['order_time']) {
                     $row['order_time'] = date('H:i', $row['time']);
                 }
                 $row['total'] = EClassApi::numberFormat($row['total']);
                 $list_orders[] = $row;
             }
         }
         mysql_free_result($res);
     }
     $display->add('list_orders', $list_orders);
     $display->add('total_row', $total_row);
     $display->add('id', $uid);
     $display->add('order_code', $order_code);
     $display->add('from_date', $fdo);
     $display->add('to_date', $tdo);
     $display->add('rid', $rid);
     $display->add('scope', $scope);
     $display->add('paging', $paging);
     $display->output('list_order');
     $this->endForm();
 }
Exemple #5
0
 function addOptionFood()
 {
     $id = (int) Url::get('id');
     $fid = (int) Url::get('fid');
     $group_name = Url::get('group_name');
     $group_name_en = Url::get('group_name_en');
     $group_alias = Url::get('group_alias');
     $opt_desc = Url::get('opt_desc');
     $opt_desc_en = Url::get('opt_desc_en');
     $opt_price = Url::get('opt_price');
     $opt_type = Url::get('opt_type');
     $opt_enable = Url::get('opt_enable');
     if (empty($group_name)) {
         $group_name = 'Lựa chọn';
     }
     if (empty($group_alias)) {
         if (!empty($group_name)) {
             $group_alias = strtolower(EClassApi::safe_title($group_name));
         }
     } else {
         $group_alias = strtolower(EClassApi::safe_title($group_alias));
     }
     $num_item = count($opt_desc);
     if ($num_item > 0) {
         for ($index = 0; $index < $num_item; $index++) {
             if (empty($opt_desc[$index]) || empty($opt_desc_en[$index])) {
                 continue;
             }
             if (intval($opt_type[$index]) == 0 && strtoupper($opt_desc_en[$index]) != 'YES' && strtoupper($opt_desc_en[$index]) != 'NO') {
                 continue;
             }
             if (!isset($opt_enable[$index])) {
                 $opt_enable[$index] = 0;
             } else {
                 $opt_enable[$index] = 1;
             }
             $option = array('fid' => $id, 'description' => $opt_desc[$index], 'description_en' => $opt_desc_en[$index], 'group_name' => $group_name, 'group_name_en' => $group_name_en, 'group_alias' => $group_alias, 'type' => intval($opt_type[$index]), 'price' => intval($opt_price[$index]), 'enable' => intval($opt_enable[$index]));
             DB::insert('food_option', $option);
             if (MEMCACHE_ON) {
                 $r = mysql_fetch_assoc(DB::query("SELECT * FROM food_res WHERE id=" . $fid));
                 eb_memcache::do_remove('supplier_food_' . $r['rid']);
             }
         }
     }
     // Get Food Options
     $query = DB::query('SELECT * FROM food_option WHERE fid = ' . $id);
     $list_option = array();
     $count = 0;
     while ($row = mysql_fetch_assoc($query)) {
         $count++;
         $row['price'] = EClassApi::numberFormat($row['price']);
         $list_option[$row['group_name']][] = $row;
     }
     mysql_free_result($query);
     // Get Food Item
     $query = DB::query('SELECT * FROM food_res fr INNER JOIN food f ON fr.fid = f.id AND f.id = ' . $id);
     $f = mysql_fetch_assoc($query);
     $f['food_options'] = $list_option;
     mysql_free_result($query);
     // Update Cached Version
     Restaurant::update_cached_version($fid);
     global $display;
     $display->add('f', $f);
     $display->add('id', $id);
     $display->output('AdminRestaurant/FoodOptions');
     exit;
 }
Exemple #6
0
    public static function prepareForCron($cart, $info)
    {
        global $display;

        //Send to customer
        $display->add('cart', $cart);
        $display->add('info', $info);

        $date_en = date("m-d-Y", time());
        $date_vn = date("d-m-Y", time());

        if ($_COOKIE['lang'] == 1) {
            $time = date("H:i m-d-Y", time());
            $delivery_time = date('H:i m-d-Y', strtotime($info[0]));
        } else {
            $delivery_time = date('H:i d-m-Y', strtotime($info[0]));
            $time = date("H:i d-m-Y", time());
        }

        $display->add('date_vn', $date_vn);
        $display->add('date_en', $date_en);
        $display->add('time', $time);
        $display->add('delivery_time', $delivery_time);

        $lang = $_COOKIE['lang'];

        $display->add('lang', $lang);

        $point = User::$current->data['point'];

        $display->add('point', $point);

        $str_id = '';
        for ($i = 0; $i < count($cart); $i++) {
            $str_id .= ($str_id == '') ? $cart[$i]['id'] : ','.$cart[$i]['id'];
        }

        $list_products = Product::get_collection(null, ' WHERE p.id IN ('.$str_id.') ');

        $total = 0;

        $supplier_ids = array();

        for ($i = 0; $i < count($list_products); $i++) {
            for($j = 0; $j < count($cart); $j++) {
                if ($list_products[$i]['id'] == $cart[$j]['id']) {
                    $list_products[$i]['number'] = $cart[$j]['number'];
                    $list_products[$i]['total'] = EClassApi::numberFormat($list_products[$i]['number']*$list_products[$i]['price']);
                    $total += $list_products[$i]['number']*$list_products[$i]['price'];
                }
            }
            $supplier_ids[$list_products[$i]['sid']][] = $list_products[$i];
        }

        $display->add('list_products', $list_products);
        $display->add('total', EClassApi::numberFormat($total));

        $content = $display->output('../Payment/mail/mail', true);

        if ($_COOKIE['lang'] != 1)
            $message_subject = 'Suma.vn Đơn hàng ' . $info[5];
        else
            $message_subject = 'Suma.vn Order ' . $info[5];

        $mailData = array(
            'message_to' => $info[3],
            'message_subject' => $message_subject,
            'message_content' => $content,
            'status' => 0,
            'message_action' => 'MAIL',
            'message_time' => date('Y-m-d'),
            'source' => 'suma',
            'oid' => $info[11],
        );

        DB::insert('message', $mailData);
        //Send to ncc
        foreach($supplier_ids as $key => $value) {
            $total = 0;

            for ($i = 0; $i < count($value); $i++) {
                $value[$i]['total'] = EClassApi::numberFormat($value[$i]['number']*$value[$i]['supplier_price']);
                $total += $value[$i]['number']*$value[$i]['supplier_price'];
            }

            $display->add('list_products', $value);
            $display->add('total', EClassApi::numberFormat($total));

            if ($value[0]['sms_lang'] == 1)
                $supplier_name = $value[0]['sname_en'];
            else
                $supplier_name = $value[0]['sname'];

            $display->add('supplier_name', $supplier_name);

            $display->add('lang', $value[0]['sms_lang']);

            $content = $display->output('../Payment/mail/mailncc', true);

            if ($value[0]['sms_lang'] == 1)
                $message_subject = 'Suma.vn Order ' . $info[5];
            else
                $message_subject = 'Suma.vn Đơn hàng ' . $info[5];

            $list_email = explode(',', $value[0]['semail']);

            for ($i = 0; $i < count($list_email); $i++) {
                $mailData = array(
                    'message_to' => $list_email[$i],
                    'message_subject' => $message_subject,
                    'message_content' => $content,
                    'status' => 0,
                    'message_action' => 'MAIL',
                    'message_time' => date('Y-m-d'),
                    'source' => 'suma',
                    'oid' => $info[11],
                );

                DB::insert('message', $mailData);
            }
        }
    }
Exemple #7
0
 public function getItemAdvertiseById($id)
 {
     $item = '';
     if (MEMCACHE_ON) {
         $item = eb_memcache::do_get('item_advertise_widget_' . $id);
     }
     if (!$item) {
         $result = DB::query("SELECT * FROM advertise WHERE status = 1 AND id = {$id}");
         $item = array();
         if ($result) {
             while ($row = mysql_fetch_assoc($result)) {
                 $row['image'] = EClassApi::getImageThumb($row['images'], 130, 110, 0, IMAGE_SERVER_NO);
                 $row['price'] = EClassApi::numberFormat($row['price']);
                 $item = $row;
             }
             eb_memcache::do_put('item_advertise_widget_' . $id, $item);
         }
     }
     return $item;
 }