public function index() { if (Session::getActiveClientid() == NULL) { $form = new SimpleForm\Form(array('name' => 'order', 'action' => '', 'method' => 'post')); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_EMAIL')), new SimpleForm\Rules\Email(_('ERR_WRONG_EMAIL')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'orderid', 'label' => _('TXT_ORDER_NUMER'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_ORDER_ID')))))); if ($form->Validate()) { $formData = $form->getSubmitValues(); $order = App::getModel('order')->getOrderStatusByEmailAndId($formData['email'], $formData['orderid']); if ($order != NULL) { $this->registry->template->assign('status', array('orderid' => $formData['orderid'], 'name' => $order)); } else { $this->registry->template->assign('status', NULL); } } $this->registry->template->assign('form', $form->getForm()); return $this->registry->template->fetch($this->loadTemplate('check.tpl')); } else { if ((int) $this->registry->core->getParam() > 0) { $order = App::getModel('order')->getOrderByClient((int) $this->registry->core->getParam()); if (empty($order)) { App::redirectUrl($this->registry->router->generate('frontend.clientorder', true)); } $this->registry->template->assign('order', $order); $this->registry->template->assign('orderproductlist', App::getModel('order')->getOrderProductListByClient((int) $this->registry->core->getParam())); return $this->registry->template->fetch($this->loadTemplate('view.tpl')); } else { $this->registry->template->assign('orderlist', App::getModel('order')->getOrderListByClient()); return $this->registry->template->fetch($this->loadTemplate('index.tpl')); } } }
public function __construct($registry, $box) { parent::__construct($registry, $box); if (Session::getActiveClientid() == NULL) { App::redirectUrl($this->registry->router->generate('frontend.home', true)); } $this->model = App::getModel('client'); }
public function index() { $form = App::getFormModel('clientlogin')->initForm(); if ($form->Validate()) { $formData = $form->getSubmitValues(); $clean = App::getModel('formprotection')->cropDangerousCodeSubmitedValues($formData); if ($clean == true) { $result = App::getModel('clientlogin')->authProccess($formData['login'], $formData['password']); if ($result > 0) { Session::setActiveClientid($result); App::getModel('clientlogin')->checkClientGroup(); App::getModel('clientlogin')->setLoginTime(); $this->model->saveClientData(); $misingCart = App::getModel('missingcart')->checkMissingCartForClient($result); if (isset($formData['autologin']) && $formData['autologin'] == 1) { App::getModel('clientlogin')->setAutologinKey($result); } else { App::getModel('clientlogin')->destroyAutologinKey(); } if (is_array($misingCart) && !empty($misingCart)) { App::getModel('cart')->addProductsToCartFromMissingCart($misingCart); App::getModel('missingcart')->cleanMissingCart(Session::getActiveClientid()); } if (($this->Cart = Session::getActiveCart()) != NULL) { App::redirectUrl($this->registry->router->generate('frontend.cart', true)); } else { App::redirectUrl($this->registry->router->generate('frontend.home', true)); } } elseif ($result < 0) { Session::setVolatileUserLoginError(2, false); } else { Session::setVolatileUserLoginError(1, false); } } } if ($this->getParam() == 'changed') { $this->registry->template->assign('clientChangedMail', _('TXT_LOGGOUT_CHANGED_EMAIL')); } $error = Session::getVolatileUserLoginError(); if ($error[0] == 1) { $this->registry->template->assign('loginerror', _('ERR_BAD_LOGIN_OR_PASSWORD')); } elseif ($error[0] == 2) { $this->registry->template->assign('loginerror', _('TXT_BLOKED_USER')); } $this->registry->template->assign('form', $form->getForm()); return $this->registry->template->fetch($this->loadTemplate('index.tpl')); }
public function getMissingCart($clientid) { $sql = "SELECT \n\t\t\t\t\tMC.idmissingcart, \n\t\t\t\t\tMC.dispatchmethodid, \n\t\t\t\t\tMC.paymentmethodid \n\t\t\t\tFROM missingcart MC\n\t\t\t\tWHERE MC.clientid = :clientid"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('clientid', Session::getActiveClientid()); $Data = array(); try { $stmt->execute(); $rs = $stmt->fetch(); if ($rs) { $Data = array('clientid' => $clientid, 'idmissingcart' => $rs['idmissingcart'], 'dispatchmethodid' => $rs['dispatchmethodid'], 'paymentmethodid' => $rs['paymentmethodid'], 'products' => $this->getProductFromMissingCart($idmissingcart), 'sessionid' => $this['sessionid']); } else { $Data = 0; } } catch (Exception $e) { new Exception($e->message('Error while selecting session content from sessionhandler.')); } return $Data; }
public function getProductsTemplate($model, $controller, $currentParams, $boxAttributes) { // this has to be defined BEFORE // $this->dataset = App::getModel($model)->getDataset(); // in other case layerednavigationbox will be required if ($this->registry->router->getCurrentController() == $controller) { $producer = strlen($currentParams['producers']) > 0 ? array_filter(array_values(explode('_', $currentParams['producers']))) : array(); $attributes = array_filter(strlen($currentParams['attributes']) > 0 ? array_filter(array_values(explode('_', $currentParams['attributes']))) : array()); $Products = App::getModel('layerednavigationbox')->getProductsForAttributes(0, $attributes); } $this->dataset = App::getModel($model)->getDataset(); if ($boxAttributes['productsCount'] > 0) { $this->dataset->setPagination($boxAttributes['productsCount']); } if ($this->registry->router->getCurrentController() == $controller) { // only for product news page use datagrid custom parameters $sqlParams = array('clientid' => Session::getActiveClientid(), 'producer' => $producer, 'pricefrom' => (double) $currentParams['priceFrom'], 'priceto' => (double) $currentParams['priceTo'], 'filterbyproducer' => !empty($producer) ? 1 : 0, 'enablelayer' => !empty($Products) && count($attributes) > 0 ? 1 : 0, 'products' => $Products); if (isset($currentParams['categoryid'])) { $sqlParams['categoryid'] = $currentParams['categoryid']; } if (!empty($currentParams['name'])) { $sqlParams['name'] = $currentParams['name']; } $this->dataset->setSQLParams($sqlParams); $this->dataset->setCurrentPage($currentParams['currentPage']); if ($currentParams['orderBy'] == 'default') { // get order from box settings $this->dataset->setOrderBy('name', $boxAttributes['orderBy']); $this->dataset->setOrderDir('asc', $boxAttributes['orderDir']); } else { // get order from params $this->dataset->setOrderBy('name', $currentParams['orderBy']); $this->dataset->setOrderDir('asc', $currentParams['orderDir']); } } else { $this->dataset->setCurrentPage(1); $this->dataset->setOrderBy('name', $boxAttributes['orderBy']); $this->dataset->setOrderDir('asc', $boxAttributes['orderDir']); } return App::getModel($model)->getProductDataset(); }
/** * Adding an opinion * * @param * integer idproduct * @param * string review * @return id from generator * @throws on error FrontendException object will be returned * @access public */ public function addOpinionAboutProduct($productid, $params) { $sql = 'INSERT INTO productreview (productid, clientid, review, viewid, nick, enable) VALUES (:productid, :clientid, :review, :viewid, :nick, :enable)'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('productid', $productid); if (Session::getActiveClientid() > 0) { $stmt->bindValue('clientid', Session::getActiveClientid()); $stmt->bindValue('enable', 1); } else { $stmt->bindValue('clientid', NULL); $stmt->bindValue('enable', 0); } $stmt->bindValue('viewid', Helper::getViewId()); $stmt->bindValue('nick', $params['nick']); $stmt->bindValue('review', trim(strip_tags($params['htmlopinion']))); try { $stmt->execute(); } catch (Exception $e) { throw new FrontendException($e->getMessage()); } $reviewid = Db::getInstance()->lastInsertId(); foreach ($params as $rangetypeid => $value) { if (is_numeric($rangetypeid) && $value > 0) { $sql = 'INSERT INTO productrange SET productid = :productid, rangetypeid = :rangetypeid, productreviewid = :productreviewid, value = :value'; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('productid', $productid); $stmt->bindValue('rangetypeid', $rangetypeid); $stmt->bindValue('productreviewid', $reviewid); $stmt->bindValue('value', $value); try { $stmt->execute(); } catch (Exception $e) { throw new FrontendException($e->getMessage()); } } } return $reviewid; }
public function isNewsletterButton() { if (isset($_COOKIE['newsletter'])) { return FALSE; } if (Session::getActiveClientid() !== 0 && $this->checkEmailIfExists(Session::getActiveClientEmail()) !== 0) { if (!isset($_COOKIE['newsletter'])) { setcookie('newsletter', 1, time() + 24 * 60 * 60 * 30, '/', null, false, true); } return FALSE; } return TRUE; }
public static function Run() { if (isset(self::$config['profiler']) && self::$config['profiler'] == $_SERVER['REMOTE_ADDR']) { Profiler::start(); } App::init(); self::$registry->router->setVariables(); self::$registry->xajax = new Xajax(); if (self::$registry->router->getMode() == 0) { $url = preg_replace_callback('~[^a-zA-Z0-9:/\\?,_-]+~', function ($s) { return urlencode($s[0]); }, self::$registry->router->getUri()); self::$registry->xajax->configure('requestURI', $url); } else { // force language in admin mode Session::unsetActiveLanguage(); self::$registry->core->setLanguage('pl'); Translation::loadTranslations(); } self::$registry->xajaxInterface = new XajaxInterface(); self::$registry->right = new Right(self::$registry); Session::clearTemp(); DEFINE('URL', App::getHost(1) . '/' . LOCAL_CATALOG); App::checkSSL(); if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { DEFINE('DESIGNPATH', str_replace('http://', 'https://', App::getURLForDesignDirectory())); } else { DEFINE('DESIGNPATH', App::getURLForDesignDirectory()); } // remember login and password if (self::$registry->router->getModeFromRoute() == 'admin') { if ((int) Session::getActiveUserid() === 0) { App::getModel('login')->getAdminAutologinKey(); } } else { if ((int) Session::getActiveClientid() === 0) { App::getModel('clientlogin')->getAutologinKey(); } } self::$registry->template = new Template(self::$registry, self::$registry->router->getMode()); self::$registry->template->setStaticTemplateVariables(); $content = self::$registry->router->controllerLoader(); if (isset(self::$config['profiler']) && self::$config['profiler'] == $_SERVER['REMOTE_ADDR']) { Profiler::stop(); $content .= Profiler::getInfo(); } $response = new Response($content); $response->send(); App::getModel('csrfprotection')->reindex(); }
public function index() { // limit available delivery countries $dispatchmethod = Session::getActiveDispatchmethodChecked(); // list of country ids which are specified for selected delivery method $countryids = App::getModel('delivery')->getDispatchmethodCountries($dispatchmethod['dispatchmethodid']); $clientorder = App::getModel('finalization')->setClientOrder(); if (empty($clientorder['cart'])) { App::redirectUrl($this->registry->router->generate('frontend.cart', true)); } if (Session::getActiveClientid() == NULL) { $formLogin = App::getFormModel('clientlogin')->initForm(); if ($formLogin->Validate()) { $formLoginData = $formLogin->getSubmitValues(); $result = App::getModel('clientlogin')->authProccess($formLoginData['login'], $formLoginData['password']); if ($result > 0) { Session::setActiveClientid($result); App::getModel('clientlogin')->checkClientGroup(); App::getModel('clientlogin')->setLoginTime(); $this->clientModel->saveClientData(); $misingCart = App::getModel('missingcart')->checkMissingCartForClient(Session::getActiveClientid()); if (is_array($misingCart) && $misingCart != 0) { App::getModel('cart')->addProductsToCartFromMissingCart($misingCart); App::getModel('missingcart')->cleanMissingCart(Session::getActiveClientid()); } if (($this->Cart = Session::getActiveCart()) != NULL) { App::redirectUrl($this->registry->router->generate('frontend.checkout', true)); } else { App::redirectUrl($this->registry->router->generate('frontend.home', true)); } } elseif ($result < 0) { Session::setVolatileUserLoginError(2, false); } else { Session::setVolatileUserLoginError(1, false); } } $error = Session::getVolatileUserLoginError(); if ($error[0] == 1) { $this->registry->template->assign('loginerror', _('ERR_BAD_LOGIN_OR_PASSWORD')); } elseif ($error[0] == 2) { $this->registry->template->assign('loginerror', _('TXT_BLOKED_USER')); } $this->registry->template->assign('formLogin', $formLogin->getForm()); } $form = new SimpleForm\Form(array('name' => 'order', 'action' => '', 'method' => 'post')); $billingClientType = $form->AddChild(new SimpleForm\Elements\Radio(array('name' => 'billing_clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT'))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $billingClientType, new SimpleForm\Conditions\Equals('2')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_NIP'), $billingClientType, new SimpleForm\Conditions\Equals('2')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_placeno', 'label' => _('TXT_PLACENO')))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'billing_postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')))))); $form->AddChild(new SimpleForm\Elements\Select(array('name' => 'billing_country', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect($countryids), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY')))))); $otherAddress = $form->AddChild(new SimpleForm\Elements\Checkbox(array('name' => 'other_address', 'label' => _('TXT_OTHER_DELIVERY_ADRESS'), 'default' => 0))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_FIRSTNAME'), $otherAddress, new SimpleForm\Conditions\Equals('1')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_SURNAME'), $otherAddress, new SimpleForm\Conditions\Equals('1')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_companyname', 'label' => _('TXT_COMPANYNAME')))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_STREET'), $otherAddress, new SimpleForm\Conditions\Equals('0')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_STREETNO'), $otherAddress, new SimpleForm\Conditions\Equals('0')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_placeno', 'label' => _('TXT_PLACENO')))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_PLACE'), $otherAddress, new SimpleForm\Conditions\Equals('0')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'shipping_postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_POSTCODE'), $otherAddress, new SimpleForm\Conditions\Equals('0')))))); $form->AddChild(new SimpleForm\Elements\Select(array('name' => 'shipping_country', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect($countryids), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_NAME_OF_COUNTRY'), $otherAddress, new SimpleForm\Conditions\Equals('0')))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PHONE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/'))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'), 'rules' => array(new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/'))))); $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'email', 'label' => _('TXT_EMAIL'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_EMAIL')), new SimpleForm\Rules\Email(_('ERR_WRONG_EMAIL')))))); if ((int) Session::getActiveClientid() == 0) { $createAccount = $form->AddChild(new SimpleForm\Elements\Checkbox(array('name' => 'create_account', 'label' => _('TXT_CHECKOUT_CREATE_ACCOUNT'), 'default' => 1))); $newPassword = $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'password', 'label' => _('TXT_PASSWORD'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_PASSWORD'), $createAccount, new SimpleForm\Conditions\Equals('1')))))); $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'confirmpassword', 'label' => _('TXT_PASSWORD_REPEAT'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_CONFIRM_PASSWORD'), $createAccount, new SimpleForm\Conditions\Equals('1')), new SimpleForm\Rules\Compare(_('ERR_PASSWORDS_NOT_COMPATIBILE'), $newPassword))))); $form->AddChild(new SimpleForm\Elements\Checkbox(array('name' => 'confirmterms', 'label' => sprintf(_('TXT_ACCEPT_TERMS_AND_POLICY_OF_PRIVATE'), App::getModel('staticcontent')->getConditionsLink(), Session::getActiveShopName()), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_TERMS_NOT_AGREED'))), 'default' => 0))); $form->AddChild(new SimpleForm\Elements\Checkbox(array('name' => 'newsletter', 'label' => _('TXT_NEWSLETTER_SIGNUP'), 'default' => 0))); } $clientData = $this->clientModel->getClient(); $clientBillingAddress = $this->clientModel->getClientAddress(1); $clientShippingAddress = $this->clientModel->getClientAddress(0); $form->Populate(array('billing_clienttype' => $clientBillingAddress['clienttype'], 'other_address' => 0, 'create_account' => 1, 'phone' => isset($clientData['phone']) ? $clientData['phone'] : '', 'phone2' => isset($clientData['phone2']) ? $clientData['phone2'] : '', 'email' => isset($clientData['email']) ? $clientData['email'] : '', 'billing_firstname' => $clientBillingAddress['firstname'], 'billing_surname' => $clientBillingAddress['surname'], 'billing_companyname' => $clientBillingAddress['companyname'], 'billing_nip' => $clientBillingAddress['nip'], 'billing_street' => $clientBillingAddress['street'], 'billing_streetno' => $clientBillingAddress['streetno'], 'billing_placeno' => $clientBillingAddress['placeno'], 'billing_placename' => $clientBillingAddress['placename'], 'billing_postcode' => $clientBillingAddress['postcode'], 'billing_country' => $clientBillingAddress['countryid'], 'shipping_firstname' => $clientShippingAddress['firstname'], 'shipping_surname' => $clientShippingAddress['surname'], 'shipping_companyname' => $clientShippingAddress['companyname'], 'shipping_nip' => $clientShippingAddress['nip'], 'shipping_street' => $clientShippingAddress['street'], 'shipping_streetno' => $clientShippingAddress['streetno'], 'shipping_placeno' => $clientShippingAddress['placeno'], 'shipping_placename' => $clientShippingAddress['placename'], 'shipping_postcode' => $clientShippingAddress['postcode'], 'shipping_country' => $clientShippingAddress['countryid'])); if ($form->Validate()) { $formData = $form->getSubmitValues(); $Data['clientaddress'] = array('firstname' => $formData['billing_firstname'], 'surname' => $formData['billing_surname'], 'companyname' => $formData['billing_clienttype'] == 2 ? $formData['billing_companyname'] : '', 'nip' => $formData['billing_clienttype'] == 2 ? $formData['billing_nip'] : '', 'street' => $formData['billing_street'], 'streetno' => $formData['billing_streetno'], 'placeno' => $formData['billing_placeno'], 'placename' => $formData['billing_placename'], 'postcode' => $formData['billing_postcode'], 'countryid' => $formData['billing_country'], 'clienttype' => $formData['billing_clienttype']); if (!empty($formData['other_address'])) { $Data['deliveryAddress'] = array('firstname' => $formData['shipping_firstname'], 'surname' => $formData['shipping_surname'], 'companyname' => $formData['shipping_companyname'], 'street' => $formData['shipping_street'], 'streetno' => $formData['shipping_streetno'], 'placeno' => $formData['shipping_placeno'], 'placename' => $formData['shipping_placename'], 'postcode' => $formData['shipping_postcode'], 'countryid' => $formData['shipping_country']); } else { $Data['deliveryAddress'] = $Data['clientaddress']; } $recurMail = 0; if (!empty($formData['create_account'])) { $recurMail = $this->clientModel->checkClientNewMail($formData); if ($recurMail == 0) { $clientData = $Data['clientaddress']; $clientData['email'] = $formData['email']; $clientData['password'] = $formData['password']; $clientData['newsletter'] = $formData['newsletter']; $clientData['phone'] = $formData['phone']; $clientData['phone2'] = $formData['phone2']; $clientId = $this->clientModel->addNewClient($clientData); $result = App::getModel('clientlogin')->authProccess($formData['email'], $formData['password']); if ($result > 0) { Session::setActiveClientid($result); App::getModel('clientlogin')->checkClientGroup(); $this->clientModel->saveClientData(); $this->clientModel->updateClientAddress($Data['clientaddress'], 1); $this->clientModel->updateClientAddress($Data['deliveryAddress'], 0); } } else { $result = App::getModel('clientlogin')->authProccess($formData['email'], $formData['password']); if ($result > 0) { Session::setActiveClientid($result); App::getModel('clientlogin')->checkClientGroup(); App::getModel('clientlogin')->setLoginTime(); App::getModel('client')->saveClientData(); $misingCart = App::getModel('missingcart')->checkMissingCartForClient($result); if (is_array($misingCart) && !empty($misingCart)) { App::getModel('cart')->addProductsToCartFromMissingCart($misingCart); App::getModel('missingcart')->cleanMissingCart(Session::getActiveClientid()); } $recurMail = 0; } else { $recurMail = -1; } } } else { if (!empty($formData['newsletter'])) { $newId = App::getModel('newsletter')->addClientAboutNewsletter($formData['email']); if ($newId > 0) { App::getModel('newsletter')->changeNewsletterStatus($newId); } } } if ((int) Session::getActiveClientid() > 0) { $this->clientModel->updateClientAddress($Data['clientaddress'], 1); $this->clientModel->updateClientAddress($Data['deliveryAddress'], 0); } if ($recurMail == -1) { $this->registry->template->assign('error', 'Podany adres e-mail jest już przypisany do innego konta użytkownika. Proszę skorzystaj z opcji <a href="' . $this->registry->router->generate('frontend.forgotpassword', true) . '" style="font-size: inherit">przypomnienia hasła</a> jeśli chcesz odzyskać dostęp do konta.'); } else { if ($recurMail == 1) { $this->registry->template->assign('error', _('ERR_DUPLICATE_EMAIL')); } else { if (!$recurMail) { Session::setActiveOrderClientAddress($Data['clientaddress']); Session::setActiveOrderDeliveryAddress($Data['deliveryAddress']); Session::setActiveOrderContactData(array('phone' => $formData['phone'], 'phone2' => $formData['phone2'], 'email' => $formData['email'])); App::getModel('finalization')->setClientOrder(); App::redirectUrl($this->registry->router->generate('frontend.finalization', true)); } } } } $assignData = array('form' => $form->getForm()); foreach ($assignData as $key => $assign) { $this->registry->template->assign($key, $assign); } if (Session::getActiveClientid() > 0) { return $this->registry->template->fetch($this->loadTemplate('client.tpl')); } else { return $this->registry->template->fetch($this->loadTemplate('guest.tpl')); } }
public function controllerLoader() { $namespaces = $this->registry->loader->getNamespaces(); $mode = $this->getModeName(); if ($this->route['mode'] == 'admin' && Session::getActiveUserid() > 0 && $this->baseController == 'login') { App::redirect(__ADMINPANE__ . '/mainside'); } if ($this->route['mode'] == 'admin' && NULL == Session::getActiveUserid() && $this->baseController != 'login') { App::redirect(__ADMINPANE__); } if ($this->route['mode'] != 'admin' && $this->registry->loader->getParam('forcelogin') == 1 && NULL == Session::getActiveClientid() && !in_array($this->baseController, array('clientlogin', 'forgotpassword', 'registration'))) { App::redirectUrl($this->generate('frontend.clientlogin', true)); } if ($this->getAdministrativeMode() && !in_array($this->baseController, array('logout', 'permissionerror')) && in_array($this->action, array_flip($this->registry->right->getRights()))) { try { $this->registry->right->checkPermission($this->baseController, $this->action, App::getModel('users')->getLayerIdByViewId(Helper::getViewId())); } catch (Exception $e) { App::redirect(__ADMINPANE__ . '/permissionerror'); } } $lastNs = ''; foreach ($namespaces as $namespace) { $ns = $namespace . DS . $mode . DS . strtolower($this->baseController . DS . 'controller' . DS . $this->baseController); if (isset($this->classesMap[$ns])) { require_once $this->classesMap[$ns]; $lastNs = $namespace; } } if (!empty($lastNs)) { $controllerFullName = $lastNs . '\\' . $this->baseController . 'Controller'; $controllerObject = new $controllerFullName($this->registry); $controllerObject->setDesignPath(strtolower($this->baseController . DS . $this->action . DS)); } if (isset($controllerObject) && is_object($controllerObject) && is_callable(array($controllerObject, $this->action))) { // force offline if (!$controllerObject instanceof \Gekosale\ErrorController && !$controllerObject instanceof \Gekosale\InstanceReportController && $this->route['mode'] != 'admin' && $this->registry->loader->isOffline() && !(Session::getActiveUserid() > 0)) { require_once ROOTPATH . 'plugin' . DS . 'Gekosale' . DS . 'Frontend' . DS . 'offline' . DS . 'controller' . DS . 'offline.php'; $controllerObject = new OfflineController($this->registry); $controllerObject->setDesignPath(strtolower('offline' . DS . 'index' . DS)); $this->action = 'index'; } $content = call_user_func(array($controllerObject, $this->action)); $response = new Response($content); $response->send(); } else { $exception = new \Gekosale\Router\InvalidUrlException('Niepoprawny adres: ' . App::getUrl()); if ($this->route['mode'] == 'admin') { App::redirectUrl($this->generate('admin', true, array('controller' => 'error', 'param' => '404'))); } } }
public function search($phrase, $producers = 0, $attributes = 0, $priceFrom = 0, $priceTo = 0, $pagination = 5, $currentPage = 1, $categoryId = 0, $orderBy = 'default', $orderDir = 'asc') { $producersArray = strlen($producers) > 0 ? array_filter(array_values(explode('_', $producers))) : array(); $attributesArray = array_filter(strlen($attributes) > 0 ? array_filter(array_values(explode('_', $attributes))) : array()); $Products = App::getModel('layerednavigationbox')->getProductsForAttributes(0, $attributesArray); $dataset = $this->getDataset(); $dataset->setPagination($pagination); // Number of products in livesearch $dataset->setCurrentPage($currentPage); $dataset->setOrderBy($orderBy, $orderBy); $dataset->setOrderDir($orderDir, $orderDir); $dataset->setSQLParams(array('categoryid' => $categoryId, 'clientid' => Session::getActiveClientid(), 'producer' => $producersArray, 'filterbyproducer' => !empty($producers) ? 1 : 0, 'pricefrom' => (double) $priceFrom, 'priceto' => (double) $priceTo, 'name' => '%' . $phrase . '%', 'enablelayer' => !empty($Products) && count($attributesArray) > 0 ? 1 : 0, 'products' => $Products)); return $this->getProductDataset(); }
public function getAutologinKey() { if (!isset($_COOKIE['autologin'])) { return false; } $sql = "SELECT idclient FROM client WHERE SHA1(CONCAT(login, password)) = :hash AND disable = 0"; $stmt = Db::getInstance()->prepare($sql); $stmt->bindValue('hash', (string) $_COOKIE['autologin']); $stmt->execute(); $id = $stmt->fetchColumn(); if (!$id) { // delete cookie setcookie('autologin', '', time() - 3600, '/', null, false, true); return false; } Session::setActiveClientid($id); App::getModel('clientlogin')->checkClientGroup(); App::getModel('clientlogin')->setLoginTime(); App::getModel('client')->saveClientData(); $misingCart = App::getModel('missingcart')->checkMissingCartForClient($id); if (is_array($misingCart) && !empty($misingCart)) { App::getModel('cart')->addProductsToCartFromMissingCart($misingCart); App::getModel('missingcart')->cleanMissingCart(Session::getActiveClientid()); } if (($this->Cart = Session::getActiveCart()) != NULL) { App::redirectUrl($this->registry->router->generate('frontend.cart', true)); } else { App::redirectUrl($this->registry->router->generate('frontend.home', true)); } }
public function setClientOrder($Data = array()) { $customerOpinion = isset($Data['customeropinion']) ? App::getModel('formprotection')->cropDangerousCode($Data['customeropinion']) : ''; Event::notify($this, 'frontend.finalization.setActiveClientOrder', array('dispatchmethod' => Session::getActiveDispatchmethodChecked(), 'cart' => Session::getActiveCart())); $clientOrder = array('cart' => Session::getActiveCart(), 'globalPrice' => App::getModel('cart')->getGlobalPrice(), 'globalPriceWithoutVat' => App::getModel('cart')->getGlobalPriceWithoutVat(), 'priceWithDispatchMethod' => Session::getActiveglobalPriceWithDispatchmethod(), 'priceWithDispatchMethodNetto' => Session::getActiveglobalPriceWithDispatchmethodNetto(), 'count' => App::getModel('cart/cart')->getProductAllCount(), 'clientdata' => App::getModel('client')->getClient(), 'clientaddress' => Session::getActiveOrderClientAddress(), 'deliveryAddress' => Session::getActiveOrderDeliveryAddress(), 'contactData' => Session::getActiveOrderContactData(), 'dispatchmethod' => Session::getActiveDispatchmethodChecked(), 'payment' => Session::getActivePaymentMethodChecked(), 'clientid' => Session::getActiveClientid(), 'customeropinion' => $customerOpinion); $rulesDiscount = $this->getRulesCart($clientOrder); if (is_array($rulesDiscount) && count($rulesDiscount) > 0 && $clientOrder['dispatchmethod'] > 0 && $clientOrder['payment'] > 0) { if ($rulesDiscount['freeshipping'] == 1) { $clientOrder['priceWithDispatchMethod'] = $clientOrder['priceWithDispatchMethod'] - $clientOrder['dispatchmethod']['dispatchmethodcost']; $clientOrder['priceWithDispatchMethodNetto'] = $clientOrder['priceWithDispatchMethodNetto'] - $clientOrder['dispatchmethod']['dispatchmethodcostnetto']; $clientOrder['dispatchmethod']['dispatchmethodcost'] = 0; $clientOrder['dispatchmethod']['dispatchmethodcostnetto'] = 0; } if ($rulesDiscount['symbol'] == '+') { $globalPricePromo = sprintf('%01.2f', $clientOrder['globalPrice'] + $rulesDiscount['discount']); $globalPriceWithoutVatPromo = sprintf('%01.2f', $clientOrder['globalPriceWithoutVat'] + $rulesDiscount['discount']); $priceWithDispatchMethodPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethod'] + $rulesDiscount['discount']); $priceWithDispatchMethodNettoPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethodNetto'] + $rulesDiscount['discount']); $message = $rulesDiscount['symbol'] . $this->registry->core->processPrice($rulesDiscount['discount']); } elseif ($rulesDiscount['symbol'] == '-') { $globalPricePromo = sprintf('%01.2f', $clientOrder['globalPrice'] - $rulesDiscount['discount']); $globalPriceWithoutVatPromo = sprintf('%01.2f', $clientOrder['globalPriceWithoutVat'] - $rulesDiscount['discount']); $priceWithDispatchMethodPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethod'] - $rulesDiscount['discount']); $priceWithDispatchMethodNettoPromo = sprintf('%01.2f', $clientOrder['priceWithDispatchMethodNetto'] - $rulesDiscount['discount']); $message = $rulesDiscount['symbol'] . $this->registry->core->processPrice($rulesDiscount['discount']); } elseif ($rulesDiscount['symbol'] == '%') { $globalPricePromo = sprintf('%01.2f', abs($clientOrder['globalPrice'] * $rulesDiscount['discount'] / 100)); $globalPriceWithoutVatPromo = sprintf('%01.2f', abs($clientOrder['globalPriceWithoutVat'] * $rulesDiscount['discount'] / 100)); $priceWithDispatchMethodPromo = sprintf('%01.2f', abs($clientOrder['priceWithDispatchMethod'] * $rulesDiscount['discount'] / 100)); $priceWithDispatchMethodNettoPromo = sprintf('%01.2f', abs($clientOrder['priceWithDispatchMethodNetto'] * $rulesDiscount['discount'] / 100)); $message = ($rulesDiscount['discount'] - 100 > 0 ? '+' : '-') . abs($rulesDiscount['discount'] - 100) . $rulesDiscount['symbol']; } if ($globalPricePromo > 0 && $globalPriceWithoutVatPromo > 0 && $priceWithDispatchMethodPromo > 0 && $priceWithDispatchMethodNettoPromo > 0) { $clientOrder['globalPricePromo'] = $globalPricePromo; $clientOrder['globalPriceWithoutVatPromo'] = $globalPriceWithoutVatPromo; $clientOrder['priceWithDispatchMethodPromo'] = $priceWithDispatchMethodPromo; $clientOrder['priceWithDispatchMethodNettoPromo'] = $priceWithDispatchMethodNettoPromo; $clientOrder['rulescart'] = $rulesDiscount['name']; $clientOrder['rulescartdescription'] = $rulesDiscount['description']; $clientOrder['rulescartid'] = $rulesDiscount['rulescartid']; $clientOrder['rulescartmessage'] = $message; $clientOrder['rulescartfreeshipping'] = $rulesDiscount['freeshipping']; } } Session::setActiveClientOrder($clientOrder); return $this->getClientOrder(); }