示例#1
0
文件: apply.php 项目: alex-k/velotur
function apply_discount($user_id, $tour_id)
{
    $tw_user = tw_users::record_by_id($user_id);
    $tw_tour = tw_tours::record_by_id($tour_id);
    $discount = new tw_discount();
    $prs = array();
    if ($tw_user->userCompletedTours >= 1) {
        $prs['retcust'] = $discount->find_records(array('AutoKey' => 'retcust1'))->first();
    }
    if ($tw_user->userType == 'guard') {
        $prs['retcust'] = $discount->find_records(array('AutoKey' => 'retcust2'))->first();
    }
    $friends = new projectfriends();
    $friends->find_records(array('User_id' => $tw_user->get_id()));
    if ($friends->count() > 0) {
        $prs['projectfriends'] = $discount->find_records(array('AutoKey' => 'projectfriends'))->first();
    }
    foreach ($prs as $ppr) {
        $pr = record_by_id($ppr->get_id(), 'tw_discount');
        $pm = new tw_payments();
        $pm->find_records(array('tourID' => $tour_id, 'userID' => $user_id, 'Discount_id' => $pr->get_id()));
        if ($pm->count() > 0) {
            return;
        }
        $r = $pm->new_record();
        $r->Discount_id = $pr->get_id();
        $r->Title = "{$pr->Type} {$pr->Title}";
        $r->Amount = $pr->Amount;
        if ($pr->AmountType == '%') {
            $r->Amount = round($pr->Amount * 0.01 * $tw_tour->tourPrice1);
        }
        $r->Type = "скидка";
        $r->Hidden = 0;
        $r->tourID = $tw_tour->get_id();
        $r->userID = $tw_user->get_id();
        $pm->commit();
    }
}
示例#2
0
文件: module.php 项目: alex-k/velotur
 function calc_total($tourID, $userID, $total = NULL)
 {
     if ($total === NULL) {
         $tw_tour = record_by_id($tourID, 'tw_tours');
         $total = $tw_tour->tourPrice1;
     }
     $ps = new tw_payments();
     $ps->find_records(array('tourID' => $tourID, 'userID' => $userID));
     foreach ($ps as $p) {
         if ($p->Type == 'оплата' || $p->Type == 'скидка') {
             $total -= $p->Amount;
         } else {
             if ($p->Type != 'инфо') {
                 $total += $p->Amount;
             }
         }
     }
     $ps->after($ps->first(), 'after_update');
     return sprintf('%.02f', $total);
 }
示例#3
0
            $message .= $user->Tours[$tour->getID()]->tourUserAddEmail1 . ": mail sent<br>";
        }
        if ($user->Tours[$tour->getID()]->tourUserAddEmail2) {
            pmail($user->Tours[$tour->getID()]->tourUserAddEmail2, $body, $subject, false, $gmail);
            $message .= $user->Tours[$tour->getID()]->tourUserAddEmail2 . ": mail sent<br>";
        }
    }
    $user->storeLinkedInDB();
    $tour->loadLinkedFromDB();
    $tour->updateDB();
    header("Location:" . $_SERVER["REQUEST_URI"]);
    die;
}
$t = new Tours((int) $_POST['tourID']);
$t->loadLinkedFromDB();
$tw_tour = record_by_id($t->getID(), 'tw_tours');
$ps = new tw_payments();
if (is_array($t->Users)) {
    foreach ($t->Users as $k => $u) {
        $u->loadLinkedFromDB();
    }
}
/*if (is_array($t->Users)) foreach ($t->Users as $k=>$u) {
	 $u->loadLinkedFromDB();
	 $u->payments_pay=$tw_tour->Payments->find(array('userID'=>$k,array('field'=>'Type','case'=>'!=','value'=>'скидка')));
	 $u->payments_discounts=$tw_tour->Payments->find(array('userID'=>$k,'Type'=>'скидка'));
	 foreach (array('payments_pay','payments_discounts') as $p) {
		$s=0;
		if (!$u->$p) continue;
		foreach($u->$p as $o) {
			$s+=$o->Amount;
示例#4
0
mlog('1');
$init = new gs_init('auto');
cfg_set('tpl_data_dir', array(cfg('tpl_data_dir'), realpath(cfg('root_dir') . '../html')));
$init->init(LOAD_CORE);
$init->load_modules();
include_once 'classes/base.php';
include_once 'classes/Users_class.php';
include_once 'classes/Guides_class.php';
session_start();
if (stripos($_SERVER['REQUEST_URI'], '/admin') === 0) {
    if (isset($_SESSION['guide'])) {
        $guide = $_SESSION['guide'];
        $tpl = gs_tpl::get_instance();
        $tpl->assign('Guide', get_object_vars($guide));
    } else {
        header('Location: /admin/');
        exit;
    }
}
if (isset($_SESSION['user'])) {
    $myuser = $_SESSION['user'];
    $myuser = record_by_id($myuser->userID, 'tw_users');
    $smarty = gs_tpl::get_instance();
    $smarty->assign('User', $myuser);
}
$tpl = gs_tpl::get_instance();
$tplDir = realpath(getcwd() . '/html/') . '/';
$tpl->addTemplateDir($tplDir);
cfg_set('tpl_data_dir', $tplDir);
$o_h = new gs_parser($init->data);
$o_h->process();
示例#5
0
<?php

require_once "../config/init.php";
include "auth.php";
include "restricted.php";
if (isset($_POST['_action'])) {
    if ($_POST['tourUserType'] == 'deleted') {
        $tour = new Tours($_POST['applyTourID']);
        $tour->loadLinkedFromDB();
        if ($_POST['deleteLinkedUsers']) {
            $twt = record_by_id($tour->getID(), 'tw_tours');
            foreach ($twt->Users as $t) {
                $tu = record_by_id($t->userID, 'tw_users');
                if (!$tu || $tu->userReferalID != $user->getID()) {
                    continue;
                }
                $t->tourUserType = 'deleted';
                $t->tourUserModifyDate = date('Y-m-d H:i:s');
            }
            $twt->commit();
        }
        $user->Tours[$_POST['applyTourID']]->tourUserType = 'deleted';
        $user->Tours[$_POST['applyTourID']]->tourUserModifyDate = date('Y-m-d H:i:s');
        $subject = "отказ от тура {$tour->tourTitle}";
        $body = "\n\t\tваш статус изменен. \n\t\tподробнее по ссылке 'http://www.velotur.ru/usertours.php'\n\t\t";
        pmail($user->userEmail, $body, $subject, false, $gmail);
        $subject = "отказ от тура {$tour->tourTitle}";
        $body = "\n\t\t\tПользователь {$user->userRussianName} {$user->userEmail} отказался от тура {$tour->tourTitle}\n\t\t\t<a href=\"http://velotur.ru/admin/tourinfo.php?tourID={$tour->tourID}&showUser={$user->userID}#showUser\">\n\t\t\thttp://velotur.ru/admin/tourinfo.php?tourID={$tour->tourID}&showUser={$user->userID}#showUser\n\t\t\t</a>\n\t\t";
        pmail($tour->Guides->guideEmail1, $body, $subject, false, $gmail);
        pmail($tour->Guides->guideEmail2, $body, $subject, false, $gmail);
        $message .= "{$user->userEmail}: mail sent<br>";
示例#6
0
    $options['ORDERBY'] = array('field' => 'tourStartDate', 'eq' => 'ORDERBY', 'value' => 'tourStartDate desc');
}
if (!isset($_POST['tripID'])) {
    if (!isset($_POST['tourStatus'])) {
        $options[] = array('field' => 'tourStatus', 'eq' => '!=', 'value' => 'hidden');
    } else {
        $options['tourStatus'] = $_POST['tourStatus'];
    }
}
if ($guide->guideType !== 'admin') {
    $options['strings_OR']['guideID'] = $guide->getID();
    $options['strings_OR']['guideID2'] = $guide->getID();
}
$tours = $t->searchFromDB($options);
foreach ($tours as $k => $t) {
    $tw_tour = record_by_id($t['tourID'], 'tw_tours');
    $tw_apply_users = $tw_tour->Users->find(array('tourUserType' => 'apply'))->array_keys();
    $pa = array();
    foreach ($tw_tour->Payments->find(array('Type' => 'оплата')) as $p) {
        if ($pu = record_by_id($p->userID, 'tw_users') && in_array($p->userID, $tw_apply_users)) {
            $pa[$p->userID] = $p->userID;
        }
    }
    $t['completedUsersCount'] = $tw_tour->Users->find(array('tourID' => $tw_tour->get_id(), 'tourUserType' => 'completed'))->count();
    $t['tourUsersPayed'] = count($pa);
    $tours[$k] = $t;
}
$smarty->assign('Tours', $tours);
$smarty->assign($_POST);
$smarty->assign('title', "- календарь " . (int) $_POST['year']);
$smarty->display("calendar.html");