Example #1
0
 function search_more()
 {
     header('Content-Type: text/html; charset=utf-8');
     global $display;
     $keyword = Url::get('keyword');
     $anchor_index = intval(Url::get('anchor_index', 0));
     $sort = Url::get('sort');
     //$keyword = addslashes($keyword);
     $sort = addslashes($sort);
     $order_str = '';
     if ($_COOKIE['lang'] == 1) {
         if ($sort == 'name') {
             $order_str = ' ORDER BY p.name_en ';
         } elseif ($sort == 'price') {
             $order_str = ' ORDER BY p.price ';
         } elseif ($sort == 'rating') {
             $order_str = ' ORDER BY p.rating ';
         } elseif ($sort == 'brand') {
             $order_str = ' ORDER BY b.name_en ';
         }
     } else {
         if ($sort == 'name') {
             $order_str = ' ORDER BY p.name ';
         } elseif ($sort == 'price') {
             $order_str = ' ORDER BY p.price ';
         } elseif ($sort == 'rating') {
             $order_str = ' ORDER BY p.rating ';
         } elseif ($sort == 'brand') {
             $order_str = ' ORDER BY b.name ';
         }
     }
     $where = '';
     if ($keyword != '') {
         if ($_COOKIE['lang'] == 1) {
             $where = ' WHERE (p.name_en LIKE "%' . addslashes($keyword) . '%" OR b.name_en LIKE "%' . addslashes($keyword) . '%" OR c.name_en LIKE "%' . addslashes($keyword) . '%") AND p.hidden = 0 ';
         } else {
             $where = ' WHERE (p.name LIKE "%' . addslashes($keyword) . '%" OR b.name LIKE "%' . addslashes($keyword) . '%" OR c.name LIKE "%' . addslashes($keyword) . '%") AND p.hidden = 0 ';
         }
     }
     $product_list = Product::get_collection(' LIMIT ' . $anchor_index * 60 . ', 61', $where, $order_str);
     if (count($product_list) == 61) {
         $is_next = 1;
         array_pop($product_list);
     } else {
         $is_next = 0;
     }
     if (empty($product_list)) {
         exit;
     }
     $display->add('product_list', $product_list);
     $display->add('anchor_index', $anchor_index);
     $display->add('is_next', $is_next);
     $display->add('lang', $_COOKIE['lang']);
     $display->output('SearchProduct/ajax/ShowMore');
     exit;
 }
Example #2
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);
            }
        }
    }