Beispiel #1
0
<?php

if (isset($GLOBALS['REQAR'][1]) && $GLOBALS['REQAR'][1] == 'clear') {
    unset($_SESSION['Cart']);
}
if (!G::IsLogged()) {
    $_SESSION['from'] = 'cart';
    header('Location: ' . _base_url . '/login/');
    exit;
} else {
    $User = new Users();
    $User->SetUser($_SESSION['member']);
    $current_user = $User->fields;
    $tpl->Assign('User', $User->fields);
}
unset($parsed_res);
$Page = new Page();
$Page->PagesList();
$tpl->Assign('list_menu', $Page->list);
$GLOBALS['IERA_LINKS'] = array();
$GLOBALS['IERA_LINKS'][1]['title'] = "Корзина";
if ($User->fields['gid'] == _ACL_CUSTOMER_ || $User->fields['gid'] == _ACL_ANONYMOUS_ || $User->fields['gid'] == _ACL_DILER_ || $User->fields['gid'] == _ACL_CONTRAGENT_) {
    $Customer = new Customers();
    $Customer->SetFieldsById($User->fields['id_user']);
    $SavedCity = new Citys();
    $SavedCity->GetSavedFields($Customer->fields['id_city']);
    $SavedContragent = new Contragents();
    $SavedContragent->GetSavedFields($Customer->fields['id_contragent']);
    $DeliveryMethod = new Delivery();
    $DeliveryMethod->SetDeliveryList();
    $SavedDeliveryMethod = new Delivery();
Beispiel #2
0
 public static function HasAgent()
 {
     global $db;
     if (G::IsLogged() && $db->GetArray("SELECT * FROM " . _DB_PREFIX_ . "user_agent WHERE id_user = " . $_SESSION['member']['id_user'])) {
         return true;
     }
     return false;
 }
Beispiel #3
0
             $Users->SendPassword($data['passwd'], $data['phone']);
         }
         $data = array('email' => $phone, 'passwd' => $pass);
         // авторизуем покупателя в его новый аккаунт
         if ($Users->CheckUser($data)) {
             G::Login($Users->fields);
             _acl::load($Users->fields['gid']);
             $res['new_user'] = true;
             unset($_POST['phone']);
         }
     } else {
         $res['message'] = 'Пользователь с таким номером телефона уже зарегистрирован!';
         $res['status'] = 501;
     }
 }
 if (G::IsLogged()) {
     if (isset($_POST['phone'])) {
         $unique_phone = $Users->CheckPhoneUniqueness($_POST['phone']);
         if ($unique_phone === true) {
             $date = array('id_user' => $_SESSION['member']['id_user'], 'phone' => $_POST['phone']);
             if (!$Users->UpdateUser($date)) {
                 $res['message'] = 'Возникла ошибка при сохранении телефона!';
                 $res['status'] = 500;
                 echo json_encode($res);
                 exit;
             }
         } else {
             $res['message'] = 'Пользователь с таким номером телефона уже зарегистрирован!';
             $res['status'] = 501;
             echo json_encode($res);
             exit;
Beispiel #4
0
 public function CheckPromo($promo)
 {
     switch (substr($promo, 0, 2)) {
         case 'JO':
             if (!($res = $this->db->GetOneRowArray("SELECT * FROM " . _DB_PREFIX_ . "cart WHERE promo = '" . $promo . "' AND adm = 1 AND status = '10'"))) {
                 return false;
             }
             $status = 10;
             break;
         case 'AG':
             $self = $has_orders = false;
             if (G::IsLogged()) {
                 $self = $_SESSION['member']['id_user'] == substr($promo, 2);
                 $orders = $this->db->GetOneRowArray("SELECT COUNT(*) AS cnt FROM " . _DB_PREFIX_ . "order WHERE id_customer = " . $_SESSION['member']['id_user']);
                 $has_orders = $orders['cnt'] > 0;
             }
             $no_promo = !$this->db->GetOneRowArray("SELECT * FROM " . _DB_PREFIX_ . "promo_code WHERE code = '" . $promo . "' AND active = 1");
             if ($self || $has_orders || G::HasAgent() || $no_promo) {
                 return false;
             }
             $status = 0;
             break;
         default:
             if (!($res = $this->db->GetOneRowArray("SELECT * FROM " . _DB_PREFIX_ . "promo_code WHERE code = '" . $promo . "' AND active = 1"))) {
                 return false;
             }
             break;
     }
     if (!$this->UpdateCart($promo, $status)) {
         return false;
     }
     $_SESSION['cart']['promo'] = $promo;
     return $promo;
 }
Beispiel #5
0
											<div class="buy_buttons">
												<!--удаление товара оптом из корзины-->
												<a href="#" class="icon-font" onClick="ChangeCartQty($(this).closest('.product_buy').data('idproduct'), 0);return false;">remove</a>
												<input type="text" class="qty_js" value="<?=!$in_cart?$item['inbox_qty']:$_SESSION['cart']['products'][$item['id_product']]['quantity'];?>">
												<a href="#"	class="icon-font" onClick="ChangeCartQty($(this).closest('.product_buy').data('idproduct'), 1);return false;">add</a>
												<!--количество заказываемых товаров-->
											</div>
											<?if(!$in_cart){?>
												<div class="buy_btn_block">
													<button class="btn-m-orange buy_btn_js" type="button">Купить</button>
													<a href="<?=_base_url?>/cart/" class="in_cart_js hidden<?=G::IsLogged()?null:' open_modal" data-target="login_form';?>" title="Перейти в корзину">В корзине</a>
												</div>
											<?}else{?>
												<div class="buy_btn_block">
													<button class="btn-m-orange buy_btn_js hidden" type="button">Купить</button>
													<a href="<?=_base_url?>/cart/" class="in_cart_js <?=G::IsLogged()?null:' open_modal" data-target="login_form';?>" title="Перейти в корзину">В корзине</a>
												</div>
											<?}?>
										<?}else{?>
											<!--Если опт НЕ доступен-->
											<div class="not_available">Товара нет в наличии</div>
										<?}?> <!--проверка доступности опта-->
									</div>
									<div class="other_price <?=$item['price_opt'] == 0 && $item['price_mopt'] == 0?'hidden':null?>">
										<input class="mopt_cor_set_js" type="hidden" value="<?=$GLOBALS['CONFIG']['correction_set_'.$item['mopt_correction_set']]?>">
										<input class="price_mopt_js" type="hidden" value="<?=$item['price_mopt']?>">
										<p>
											<span class="price_js"><?=$in_cart?number_format($_SESSION['cart']['products'][$item['id_product']]['other_prices'][$_COOKIE['sum_range']], 2, ".", ""):number_format($item['price_mopt']*explode(';', $GLOBALS['CONFIG']['correction_set_'.$item['mopt_correction_set']])[$_COOKIE['sum_range']], 2, ".", "");?></span>
											<!--noindex--> грн.<!--/noindex-->
											<span class="mode_js"><?=$in_cart && $_SESSION['cart']['products'][$item['id_product']]['mode'] == 'mopt'?'от':'до';?></span>
											<?=$item['inbox_qty'].' '.$item['units']?>
Beispiel #6
0
<?php

if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    if (isset($_POST['action'])) {
        switch ($_POST['action']) {
            case "login":
                if (isset($_COOKIE['PHPSESSID'])) {
                    $to = "cabinet/";
                    if (isset($_POST['to'])) {
                        $to = $_POST['to'];
                    }
                    if (isset($_SESSION['from']) && $_SESSION['from'] != 'login') {
                        $to = $_SESSION['from'] . '/';
                    }
                    if (G::IsLogged() && ($_SESSION['member']['gid'] != _ACL_SUPPLIER_MANAGER_ && !isset($_COOKIE['sm_login']))) {
                        header('Location: ' . _base_url . '/' . $to);
                        exit;
                    }
                    $Customers = new Customers();
                    unset($parsed_res);
                    if (isset($_SESSION['SLGN']['email']) && $_SESSION['SLGN']['passwd']) {
                        $_POST['email'] = $_SESSION['SLGN']['email'];
                        $_POST['passwd'] = $_SESSION['SLGN']['passwd'];
                        $_POST['contr'] = $_SESSION['SLGN']['contr'];
                        unset($_SESSION['SLGN']);
                    }
                    if (isset($_POST['email']) && isset($_POST['passwd'])) {
                        $User = new Users();
                        if (isset($_SESSION['member']['gid']) && $_SESSION['member']['gid'] == _ACL_SUPPLIER_MANAGER_ || isset($_COOKIE['sm_login'])) {
                            if ($User->CheckUserNoPass($_POST)) {
                                if (isset($_COOKIE['sm_login'])) {