Exemple #1
0
 public static function get_mentioned_member_ids4body($body)
 {
     if (!preg_match_all(Site_Util::get_match_pattern2mention(), $body, $matches, PREG_SET_ORDER)) {
         return array();
     }
     $member_names = array();
     foreach ($matches as $match) {
         $member_names[] = $match[2];
     }
     if (!($members = \Model_Member::query()->where('name', 'in', $member_names)->get())) {
         array();
     }
     return \Util_Orm::conv_col2array($members, 'id');
 }
Exemple #2
0
 public static function delete($member_id)
 {
     if (!($member = Model_Member::query()->related('member_auth')->where('id', $member_id)->get_one())) {
         throw new FuelException('Member not exists.');
     }
     $name = $member->name;
     $email = !empty($member->member_auth->email) ? $member->member_auth->email : '';
     if (is_enabled('timeline')) {
         \Timeline\Site_NoOrmModel::delete_timeline4member_id($member_id);
     }
     if (is_enabled('album')) {
         \Album\Site_NoOrmModel::delete_album4member_id($member_id);
     }
     if (is_enabled('note')) {
         \Note\Site_NoOrmModel::delete_note4member_id($member_id);
     }
     static::delete_file_all4member_id($member_id);
     static::delete_file_all4member_id($member_id, true);
     DB::start_transaction();
     if (!$member->delete()) {
         throw new FuelException('Delete user error. user_id:' . $member_id);
     }
     DB::commit_transaction();
     if ($name && $email) {
         $mail = new Site_Mail('memberLeave');
         $mail->send($email, array('to_name' => $name));
     }
 }
Exemple #3
0
 public function action_commit()
 {
     $orders = \Session::get(self::ORDER);
     if (count($orders['cart']) == 0) {
         Response::redirect('index.php/controlsystem/order/order');
     }
     $post = $_POST;
     $order = new Model_Order();
     $order->postalcode = $post['postalcode1'] . '-' . $post['postalcode2'];
     $order->destination = $post['address'];
     $order->print_flag = false;
     $order->status = false;
     $date = date("Y-m-d", time());
     $order->order_date = $date;
     $customer = Model_Member::query()->where('name', $post['customer_name'])->get_one();
     if (!empty($customer)) {
         $order->member_id = $customer->id;
     } else {
         $order->member_id = null;
     }
     $order->save();
     $order_id = $order->id;
     //make orderlines
     $orders = \Session::get(self::ORDER);
     foreach ($orders['cart'] as $orderline) {
         $item_id = $orderline['item_id'];
         $item = Model_Item::find($item_id);
         $num = $orderline['num'];
         $size = strtoupper($orderline['size']);
         $neworderline = new Model_Orderline();
         $neworderline->order_id = $order->id;
         $neworderline->item_id = $item_id;
         $neworderline->num = $num;
         $neworderline->size = $size;
         $neworderline->save();
         $earning = new Model_Earning();
         if (!empty($customer)) {
             $earning->member_id = $customer->id;
         } else {
             $earning->member_id = null;
         }
         $earning->item_id = $item_id;
         $earning->size = $size;
         switch ($size) {
             case 'S':
                 $unit_price = $neworderline->item->unit_price_s;
                 break;
             case 'M':
                 $unit_price = $neworderline->item->unit_price_m;
                 break;
             case 'L':
                 $unit_price = $neworderline->item->unit_price_m;
                 break;
             default:
                 $unit_price = $neworderline->item->unit_price;
                 break;
         }
         $earning->unit_price = $unit_price;
         $earning->num = $num;
         $earning->date = $date;
         $earning->category = $item->category;
         $earning->item_name = $item->name;
         $now = date('Ymd');
         if (!empty($customer)) {
             $birthday = date('Ymd', strtotime($customer->birthday));
             $earning->age = (int) floor(($now - $birthday) / 10000);
         } else {
             $birthday = null;
             $earning->age = 0;
         }
         $earning->save();
     }
     return View::forge('controlsystem/order/commit');
 }
Exemple #4
0
<?php

include_once "../../includes/config.inc.php";
include_once "../../includes/login_check.php";
$memberModel = new Model_Member();
//var
$customer_id = (int) $_SESSION['customer_id'];
$status = isset($_REQUEST['status']) ? (int) $_REQUEST['status'] : 1;
$have_cent = isset($_REQUEST['have_cent']) ? (int) $_REQUEST['have_cent'] : 1;
$page = (int) $_REQUEST["p"] > 0 ? (int) $_REQUEST["p"] : 1;
if (method_is('post') && $_POST['act'] == 'upda') {
    $have_cent = (int) $_POST['have_cent'];
    $id = (int) $_POST['id'];
    $memberModel->query("update member set have_cent='{$have_cent}' where customer_id='{$customer_id}' and id='{$id}'");
    echo $have_cent;
    die;
}
//sql
$filter = array();
$filter['where'] = "customer_id = {$customer_id}";
$filter['order'] = "id desc";
$filter['order'] .= $status ? ',status asc' : ',status desc';
if ($have_cent) {
    $filter['order'] .= ',have_cent desc';
}
//result
$result = $memberModel->paginate($filter, '*', $page, 10);
$pager = $result['pager'];
//pager
if ($pager['count'] > $pager['size']) {
    $pagerhtml = new SubPages($pager['size'], $pager['count'], $pager['current'], $pager['range'], 2, '');