Esempio n. 1
0
 function after($rec, $type)
 {
     $tourID = $rec->tourID;
     $userID = $rec->userID;
     $ps = new tw_payments();
     $ps->find_records(array('tourID' => $tourID, 'userID' => $userID, 'Hidden' => 0));
     if ($type == 'before_delete') {
         $ps = $ps->find(array(array('field' => 'id', 'case' => '!=', 'value' => $rec->get_id())));
     }
     $tus = new tw_tour_users();
     $tus->find_records(array('tourID' => $tourID, 'userID' => $userID));
     $tu = $tus->first();
     $tu->tourUserCommentsPrepay = trim($ps);
     $tu->commit();
 }
Esempio n. 2
0
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();
    }
}
Esempio n. 3
0
 if (isset($_POST['tourUserCommentsRegVia'])) {
     $user->Tours[$tour->getID()]->tourUserCommentsRegVia = $_POST['tourUserCommentsRegVia'];
 }
 if (isset($_POST['newTourID']) && is_numeric($_POST['newTourID'])) {
     $newtour = new Tours((int) $_POST['newTourID']);
     if (!$newtour->getID()) {
         break;
     }
     $user->Tours[$newtour->getID()] = $user->Tours[$tour->getID()];
     $user->Tours[$newtour->getID()]->tourID = $newtour->getID();
     unset($user->Tours[$tour->getID()]);
     unset($tour->Users[$user->getID()]);
     $user->storeLinkedInDB();
     $tour->updateDB();
     $newtour->updateDB();
     $payments = new tw_payments();
     $payments->find_records(array('tourID' => $tour->getID(), 'userID' => $user->getID()));
     foreach ($payments as $p) {
         $p->tourID = $newtour->getID();
     }
     $payments->commit();
 }
 for ($i = 1; $i <= 5; $i++) {
     $n = "tourUserAddValue{$i}";
     if (isset($_POST[$n])) {
         $user->Tours[$tour->getID()]->{$n} = trim($_POST[$n]);
     }
 }
 if (isset($_POST['tourUserRoomingType'])) {
     $user->Tours[$tour->getID()]->tourUserRoomingType = $_POST['tourUserRoomingType'];
 }