newPwd($_GET['i'], $_GET['t'], $_GET['n']); } else { $user->noResetPwd($_GET['i']); } } $_SESSION['sliders'] = 1; if ($_GET['p'] > -1) { if ($_GET['p'] == 1) { $body_onload = 'alert(' . EC(lang('pay_ok')) . '); window.location.href = ' . EC(BASE_URL) . ';'; $orders = new Shop_orders(); $email = new EmailTemplates(MAIL_PAY); $orders->payed($_GET['o'], $_GET['so']); $user_email = $orders->getEmailFromOrderToken($_GET['o']); $subject_mail = translate($email->emailSubjectFk); $message = translate($email->emailBodyFk); $orderId = $orders->getOrderId($_GET['so']); //$eurowin_ok = insertarPedido($orderId, true); //if ($eurowin_ok) { //$orders->eurowinConfirm($orderId, $eurowin_ok); $item = new Shop_items(); $item->unblockUserItems(); //} $itemList = getItemList($orderId); $email_data = getOrderShippigTable($orderId); $search = array('[PEDIDO]', '[ITEMS]', '[SHIPPING]', '[DATA]'); //$replace = array($eurowin_ok, $itemList, $GLOBALS['settings']['send_free'], $email_data); $replace = array($orderId, $itemList, $GLOBALS['settings']['send_free'], $email_data); $message = str_replace($search, $replace, $message); sendEmail($user_email, PROJECT_NAME, $GLOBALS['settings']['mail_noreply'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject_mail, FALSE, $message); sendEmail($GLOBALS['settings']['mailbox_order_account'], PROJECT_NAME, $GLOBALS['settings']['mail_noreply'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject_mail, FALSE, $message); unset($_SESSION['cart']); unset($_SESSION['public_user']['coupon']); unset($_SESSION['public_user']['coupon_discount']); unset($_SESSION['public_user']['couponManufacturerFk']); unset($_SESSION['public_user']['couponItemFk']); } else { $body_onload = 'alert(' . EC(lang('pay_ko')) . '); window.location.href = ' . EC(BASE_URL) . ';'; $orders = new Shop_orders(); $orders->deleteFromToken($_GET['o']); } } $getSection = new Sections(); if (isset($_GET['url'])) { //Carga la seccion indicada por url $branch = explode('/', $_GET['url']); if (end($branch) == '') { $leaf = $branch[count($branch) - 2]; $mother = $branch[count($branch) - 3]; unset($branch[count($branch) - 1]); } else { $leaf = end($branch); $mother = $branch[count($branch) - 2]; } } else { //Carga la seccion home $sectionId = $getSection->getHomePageId(); $sectionData = new Sections($sectionId); $branch[] = $_GET['url'] = translate($sectionData->sectionUrlFk); $leaf = translate($sectionData->sectionUrlFk); } if (checkURL($branch, $_SESSION['lang']) == FALSE) { error404(); } else { $colorCode = FALSE; $sectionId = $getSection->getSectionId($leaf, $mother); if ($sectionId == '') { $sectionId = $getSection->getSectionId($branch[count($branch) - 2], $branch[count($branch) - 3]); $itemGroupDetails = new Shop_itemgroupdetails(); $productId = $itemGroupDetails->getProductId($branch[count($branch) - 1]); if ($productId == '') { $packsData = new Shop_packs(); $packId = $packsData->getPackId($branch[count($branch) - 1]); if ($packId == '') { $colorCode = $leaf; $productId = $itemGroupDetails->getProductId($branch[count($branch) - 2]); $itemGroupData = new Shop_itemgroupdetails($productId); $sectionId = $getSection->getSectionId($branch[count($branch) - 3], $branch[count($branch) - 4]); } else { $packData = new Shop_packs($packId); } } else { $itemGroupData = new Shop_itemgroupdetails($productId); } } $sectionData = new Sections($sectionId); } if ($sectionId == SECTION_LOGIN && $_SESSION['public_user']['PublicAllowed'] == TRUE) { header('Location:' . BASE_URL); } if ($sectionId == SECTION_REGISTER && $_SESSION['public_user']['PublicAllowed'] == TRUE) { header('Location:' . BASE_URL); } if ($sectionId == SECTION_PROFILE && !$_SESSION['public_user']['PublicAllowed']) { header('Location:' . BASE_URL); } if (($sectionId == SECTION_PAY_TYPE || $sectionId == SECTION_END_TRANSF) && count($_SESSION['cart']) < 1) { header('Location:' . BASE_URL); } switch ($_POST['orders']) { case 'guardar_perfil': $user_db = new Users($_POST['itemid']); $user_db->saveItem($_POST); $_SESSION['public_user']['PublicUserName'] = $_POST['userName']; $_SESSION['public_user']['shippingCountry'] = $_POST['userShippingCountryFk']; break; case 'user_newsletter': $email = new Newsletteremails(); $email_id = $email->saveItem($_POST); $relation = new Newsletterrelation(); foreach ((array) $_POST['newsletter_groups'] as $thegroup) { $relation->saveItem($email_id, $thegroup); } $body_onload = 'alert(' . EC(lang('added_newsletter')) . ')'; break; case 'destruir': $user_db = new Users(); $user_db->logoutPublicUser(); break; case 'unsubscribe': $newsletterrelation = new Newsletterrelation(); if ($_POST['unsubscribe'] != '') { foreach ((array) $_POST['unsubscribe'] as $groupId) { $newsletterrelation->deleteRelation($_POST['userId'], $groupId); } header('Location:' . BASE_URL); } break; case 'guardar': //meta de nuevo usuario $meta = false; $fail = ''; if (checkCaptcha($_POST['code'])) { $newuser = new Users(); if ($newuser->saveItem($_POST)) { $newuser->loginPublicUser($_POST['userEmail'], $_POST['userPassword']); if (count($_SESSION['cart']) > 0) { $meta = generateUrl(SECTION_CART, $_SESSION['lang']); } else { $meta = BASE_URL; } $email = new EmailTemplates(MAIL_REGISTER); $html = '

' . translate($email->emailTitleFk) . '

' . translate($email->emailBodyFk) . ''; sendEmail($_POST['userEmail'], PROJECT_NAME, $GLOBALS['settings']['mailbox_account'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], ttranslate($email->emailSubjectFk), FALSE, $html, 0); } else { $fail .= '* ' . lang('data_error') . ''; } } else { $fail .= '* ' . lang('invalid_captcha') . ''; } break; case 'sendContactEmail': $text = lang('name') . ': ' . $_POST['contact_name'] . '
' . lang('telf') . ': ' . $_POST['contact_telf'] . '
' . lang('empresa') . ': ' . $_POST['contact_empresa'] . '
' . lang('email') . ': ' . $_POST['contact_email'] . '
' . lang('send_query') . ': ' . $_POST['contact_text']; sendEmail($GLOBALS['settings']['mailbox_default_account'], $_POST['contact_name'], $_POST['contact_email'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], PROJECT_NAME . ': ' . lang('contact'), FALSE, $text, 0); break; case 'sendQueryEmail': $item = new Shop_items($_POST['product_id']); $subject = PROJECT_NAME . ': Consulta sobre ' . translate($item->itemModelFk); sendEmail($GLOBALS['settings']['mailbox_stock_account'], $_POST['contact_name'], $_POST['contact_email'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject, FALSE, $_POST['contact_text'], 0); $body_onload = 'alert(' . EC(lang('mail_enviado')) . ')'; break; case 'moreQuantity': $item = new Shop_items(); foreach ((array) $_POST['cart_quantity'] as $cart_id => $element) { if ($cart_id != 'packs') { if ($element < 1) { unset($_SESSION['cart'][$cart_id]); } else { $count = $element - $_SESSION['cart'][$cart_id]['quantity']; if ($item->checkStock($cart_id) < $count && $count > 0) { $body_onload = 'alert(' . EC(lang('only_available') . $item->checkStock($cart_id)) . ')'; } else { $loops = ($count > 0) ? $count : $count * -1; for ($index = 0; $index < $loops; $index++) { if ($count > 0) { $item->blockItem($cart_id); } else { $item->unblockItem($cart_id); } } $_SESSION['cart'][$cart_id]['quantity'] = $element; } } } } break; case 'noregister': $meta = false; $fail = ''; if (checkCaptcha($_POST['code'])) { if (count($_SESSION['cart']) > 0) { $_SESSION['public_user']['noregister'] = TRUE; $_SESSION['public_user']['PublicUserName'] = $_POST['userName']; $_SESSION['public_user']['shippingCountry'] = $_POST['userShippingCountryFk']; $_SESSION['public_user']['userName'] = $_POST['userName']; $_SESSION['public_user']['userFamilyName'] = $_POST['userFamilyName']; $_SESSION['public_user']['userEmail'] = $_POST['userEmail']; $_SESSION['public_user']['userSendAddress'] = $_POST['userSendAddress']; $_SESSION['public_user']['userSendCity'] = $_POST['userSendCity']; $_SESSION['public_user']['userSendRegion'] = $_POST['userSendRegion']; $_SESSION['public_user']['userSendPostal'] = $_POST['userSendPostal']; $_SESSION['public_user']['userSendPhone'] = $_POST['userSendPhone']; $_SESSION['public_user']['userSendCountryFk'] = $_POST['userSendCountryFk']; $_SESSION['public_user']['userShippingAddress'] = $_POST['userShippingAddress']; $_SESSION['public_user']['userShippingCity'] = $_POST['userShippingCity']; $_SESSION['public_user']['userShippingRegion'] = $_POST['userShippingRegion']; $_SESSION['public_user']['userShippingPostal'] = $_POST['userShippingPostal']; $_SESSION['public_user']['userShippingPhone'] = $_POST['userShippingPhone']; $_SESSION['public_user']['userShippingCountryFk'] = $_POST['userShippingCountryFk']; $meta = generateUrl(SECTION_CART, $_SESSION['lang']); } else { $meta = BASE_URL; } } else { $fail .= '* ' . lang('invalid_captcha') . ''; } break; case 'charge': if (count($_SESSION['cart']) <= 0) { break; } $tax = new Shop_tax(); $packitems = new Shop_packitem(); $itemGroup = new Shop_itemgroupdetails(); $item = new Shop_items(); $subtotal = 0; $total_quantity = 0; foreach ((array) $_SESSION['cart'] as $key => $item_data) { if (intval($key)) { $total_quantity = $total_quantity + $item_data['quantity']; $item_price = $item_data['quantity'] * ($item_data['price'] - $item_data['price'] * $item_data['discount'] / 100); $impuesto = $tax->getTaxPercent($item_data['tax'], $_SESSION['public_user']['shippingCountry']); $item->loadItem($key); $itemGroup->loadItemgroupdetails($item->itemGroupDetailFk); $item_price = couponMakeOff($item_price, $itemGroup->detailManufacturerFk, $item->itemGroupDetailFk); $item_price = $item_price + $item_price * $impuesto / 100; $subtotal = $subtotal + $item_price; } else { foreach ((array) $item_data as $key => $pack_in_cart) { $total_quantity++; $item_price = 0; foreach ($pack_in_cart['productos'] as $detail => $item_chosed) { foreach ($item_chosed as $the_itemid => $the_discount) { $item_chosed_price = $packitems->getPackItemFinalPrice($pack_in_cart['packId'], $the_itemid); $item_price = $item_price + $item_chosed_price; } } $item_price = couponMakeOff($item_price); $subtotal = $subtotal + $item_price; } } } $shipping = getShippingCost($subtotal, 0); $total = $subtotal + $shipping; $order = new Shop_orders(); $total = round($total, 2); $order_id = $order->prepareOrder($total, $_SESSION['public_user']['PublicUserId'], $_SESSION['cart'], $_POST['pay_type'], $shipping); if ($order_id === false) { $body_onload = 'alert(' . EC(lang('error_no_stock')) . ')'; break; } if ($_POST['pay_type'] == 2) { echo sermepa($order_id, $total, TPV_URL_TPVV, TPV_CODE, TPV_TERMINAL, TPV_CURRENDY, TPV_CLAVE); exit; } elseif ($_POST['pay_type'] == 1) { //Presupuesto //$eurowin_ok = insertarPedido($order_id, false); //if ($eurowin_ok) { //enviar email de presupuesto aqui $email = new EmailTemplates(MAIL_BUDGET); $user_email = $order->getEmailFromOrderId($order_id); $subject_mail = translate($email->emailSubjectFk); $message = translate($email->emailBodyFk); $itemList = getItemList($order_id); $email_data = getOrderShippigTable($order_id); $search = array('[PEDIDO]', '[ITEMS]', '[SHIPPING]', '[DATA]'); //$replace = array($eurowin_ok, $itemList, $GLOBALS['settings']['send_free'], $email_data); $replace = array($order_id, $itemList, $GLOBALS['settings']['send_free'], $email_data); $message = str_replace($search, $replace, $message); sendEmail($user_email, PROJECT_NAME, $GLOBALS['settings']['mail_noreply'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject_mail, FALSE, $message); sendEmail($GLOBALS['settings']['mailbox_budget_account'], PROJECT_NAME, $GLOBALS['settings']['mail_noreply'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject_mail, FALSE, $message); //$order->eurowinConfirm($order_id, false, $eurowin_ok); $item = new Shop_items(); $item->unblockUserItems(); unset($_SESSION['cart']); unset($_SESSION['public_user']['coupon']); unset($_SESSION['public_user']['coupon_discount']); unset($_SESSION['public_user']['couponManufacturerFk']); unset($_SESSION['public_user']['couponItemFk']); unset($_POST['pay_type']); //} } elseif ($_POST['pay_type'] == 3) { echo paypal($order_id, $_SESSION['cart'], $shipping); exit; } elseif ($_POST['pay_type'] == 4) { //Contra Reembolso //enviar email de contra reembolso aqui $email = new EmailTemplates(MAIL_PAY); $user_email = $order->getEmailFromOrderId($order_id); $subject_mail = translate($email->emailSubjectFk); $message = translate($email->emailBodyFk); $itemList = getItemList($order_id); $email_data = getOrderShippigTable($order_id); $search = array('[PEDIDO]', '[ITEMS]', '[SHIPPING]', '[DATA]'); $replace = array($order_id, $itemList, $GLOBALS['settings']['send_free'], $email_data); $message = str_replace($search, $replace, $message); sendEmail($user_email, PROJECT_NAME, $GLOBALS['settings']['mail_noreply'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject_mail, FALSE, $message); sendEmail($GLOBALS['settings']['mailbox_budget_account'], PROJECT_NAME, $GLOBALS['settings']['mail_noreply'], $GLOBALS['settings']['mailsend_host'], $GLOBALS['settings']['mailsend_user'], $GLOBALS['settings']['mailsend_password'], $subject_mail, FALSE, $message); $item = new Shop_items(); $item->unblockUserItems(); unset($_SESSION['cart']); unset($_SESSION['public_user']['coupon']); unset($_SESSION['public_user']['coupon_discount']); unset($_SESSION['public_user']['couponManufacturerFk']); unset($_SESSION['public_user']['couponItemFk']); unset($_POST['pay_type']); } break; case 'new_comment': $comments = new Comments($_POST['itemid']); $_POST['commentPublish'] = $GLOBALS['settings']['comment_autopublish']; $comments->saveItem($_POST); break; default: break; } insertDebugLog('Fin del pre-html'); ?>