Exemplo n.º 1
0
 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'));
         }
     }
 }
Exemplo n.º 2
0
 public function __construct($registry, $box)
 {
     parent::__construct($registry, $box);
     $this->productid = App::getModel('product')->getProductIdBySeo($this->getParam());
     $this->productModel = App::getModel('product/product');
     $this->product = $this->productModel->getProductAndAttributesById((int) $this->productid);
     if (empty($this->product)) {
         App::redirectUrl($this->registry->router->generate('frontend.home', true));
     }
     $this->heading = $this->product['productname'];
 }
Exemplo n.º 3
0
 public function index()
 {
     $contacts = App::getModel('Contact')->getContactToSelect();
     $contactList = App::getModel('Contact')->getContactList();
     $form = new SimpleForm\Form(array('name' => 'contactform', 'action' => '', 'method' => 'post'));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $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' => 'phone', 'label' => _('TXT_PHONE'))));
     if ((int) $this->registry->core->getParam() == 0) {
         $form->AddChild(new SimpleForm\Elements\TextField(array('name' => 'topic', 'label' => _('TXT_TOPIC'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_TOPIC'))))));
     }
     $form->AddChild(new SimpleForm\Elements\TextArea(array('name' => 'content', 'label' => _('TXT_CONTENT'), 'rows' => 10, 'cols' => 100, 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_CONTACT_CONTENT'))))));
     $client = App::getModel('client')->getClient();
     if (!empty($client)) {
         $form->Populate(array('firstname' => $client['firstname'], 'surname' => $client['surname'], 'phone' => $client['phone'], 'email' => $client['email']));
     }
     if ($form->Validate()) {
         $formData = $form->getSubmitValues();
         $emails = array($formData['email']);
         if (isset($formData['contactsubject'])) {
             $emails[] = App::getModel('Contact')->getDepartmentMail($formData['contactsubject']);
         }
         $content = $formData['content'];
         if ((int) $this->registry->core->getParam() > 0) {
             $subject = _('TXT_PRODUCT_QUOTE') . ' ' . $this->product['productname'];
             $this->registry->template->assign('productLink', $this->registry->router->generate('frontend.productcart', true, array('param' => $this->product['seo'])));
         } else {
             $subject = $formData['topic'];
         }
         $this->registry->template->assign('CONTACT_CONTENT', $formData['content']);
         $this->registry->template->assign('firstname', $formData['firstname']);
         $this->registry->template->assign('surname', $formData['surname']);
         $this->registry->template->assign('email', $formData['email']);
         $this->registry->template->assign('phone', $formData['phone']);
         App::getModel('mailer')->sendEmail(array('template' => 'contact', 'email' => $emails, 'bcc' => true, 'subject' => $subject, 'viewid' => Helper::getViewId()));
         Session::setVolatileSendContact(1, false);
         App::redirectUrl($this->registry->router->generate('frontend.contact', true));
     }
     $sendContact = Session::getVolatileSendContact();
     if ($sendContact[0] == 1) {
         $this->registry->template->assign('sendContact', _('TXT_CONTACT_SENT'));
     }
     $this->registry->template->assign('form', $form->getForm());
     if ((int) $this->registry->core->getParam() > 0) {
         $this->registry->template->assign('productid', $this->getParam());
     }
     $this->registry->template->assign('content', App::getModel('staticcontent')->getContentByRoute('frontend.contact'));
     $this->registry->template->assign('contactList', $contactList);
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Exemplo n.º 4
0
 public function index()
 {
     $clientBillingAddress = $this->model->getClientAddress(1);
     $clientShippingAddress = $this->model->getClientAddress(0);
     $formBilling = new SimpleForm\Form(array('name' => 'billingForm', 'action' => '', 'method' => 'post'));
     $clientType = $formBilling->AddChild(new SimpleForm\Elements\Radio(array('name' => 'clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT')))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_NIP'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formBilling->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $formBilling->Populate(array('clienttype' => $clientBillingAddress['clienttype'], 'firstname' => $clientBillingAddress['firstname'], 'surname' => $clientBillingAddress['surname'], 'companyname' => $clientBillingAddress['companyname'], 'nip' => $clientBillingAddress['nip'], 'street' => $clientBillingAddress['street'], 'streetno' => $clientBillingAddress['streetno'], 'postcode' => $clientBillingAddress['postcode'], 'placename' => $clientBillingAddress['placename'], 'placeno' => $clientBillingAddress['placeno'], 'countryid' => $clientBillingAddress['countryid']));
     if ($formBilling->Validate()) {
         $formData = $formBilling->getSubmitValues();
         $this->model->updateClientAddress($formData, 1);
         if ($clientShippingAddress['idclientaddress'] == 0) {
             $this->model->updateClientAddress($formData, 0);
         }
         App::redirectUrl($this->registry->router->generate('frontend.clientaddress', true));
     }
     $formShipping = new SimpleForm\Form(array('name' => 'shippingForm', 'action' => '', 'method' => 'post'));
     $clientType = $formShipping->AddChild(new SimpleForm\Elements\Radio(array('name' => 'clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT')))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formShipping->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $clientShippingAddress = $this->model->getClientAddress(0);
     $formShipping->Populate(array('clienttype' => $clientShippingAddress['clienttype'], 'firstname' => $clientShippingAddress['firstname'], 'surname' => $clientShippingAddress['surname'], 'companyname' => $clientShippingAddress['companyname'], 'nip' => $clientShippingAddress['nip'], 'street' => $clientShippingAddress['street'], 'streetno' => $clientShippingAddress['streetno'], 'postcode' => $clientShippingAddress['postcode'], 'placename' => $clientShippingAddress['placename'], 'placeno' => $clientShippingAddress['placeno'], 'countryid' => $clientShippingAddress['countryid']));
     if ($formShipping->Validate()) {
         $formData = $formShipping->getSubmitValues();
         $this->model->updateClientAddress($formData, 0);
         Session::setVolatileMessage("Zapisano zmiany w adresie dostawy.");
         App::redirectUrl($this->registry->router->generate('frontend.clientaddress', true));
     }
     $this->registry->template->assign('clientBillingAddress', $clientBillingAddress);
     $this->registry->template->assign('clientShippingAddress', $clientShippingAddress);
     $this->registry->template->assign('formBilling', $formBilling->getForm());
     $this->registry->template->assign('formShipping', $formShipping->getForm());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Exemplo n.º 5
0
 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'));
 }
Exemplo n.º 6
0
 public function confirm()
 {
     $result = App::getModel('forgotpassword')->validateLink($this->getParam());
     if ($result > 0) {
         $form = new SimpleForm\Form(array('name' => 'forgotpassword', 'action' => '', 'method' => 'post'));
         $newPassword = $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'newpassword', 'label' => _('TXT_PASSWORD_NEW'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PASSWORD')), new SimpleForm\Rules\MinLength(_('ERR_PASSWORD_NEW_INVALID'), 6)))));
         $form->AddChild(new SimpleForm\Elements\Password(array('name' => 'confirmpassword', 'label' => _('TXT_PASSWORD_REPEAT'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_CONFIRM_PASSWORD')), new SimpleForm\Rules\Compare(_('ERR_PASSWORDS_NOT_COMPATIBILE'), $newPassword)))));
         if ($form->Validate()) {
             $formData = $form->getSubmitValues();
             App::getModel('forgotpassword')->forgotPassword($result, $formData['newpassword']);
             Session::setActiveClientid($result);
             App::getModel('clientlogin')->checkClientGroup();
             App::getModel('client')->saveClientData();
             Session::setVolatilePasswordChanged(1, false);
             App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
         }
         $this->registry->template->assign('form', $form->getForm());
         return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
     } else {
         return $this->registry->template->fetch($this->loadTemplate('error.tpl'));
     }
 }
Exemplo n.º 7
0
 public function index()
 {
     $clientorder = App::getModel('finalization')->setClientOrder();
     if (App::getModel('cart')->getMinimumOrderValue() > 0 || empty($clientorder['cart'])) {
         App::redirectUrl($this->registry->router->generate('frontend.cart', true));
     }
     $this->registry->xajax->registerFunction(array('saveOrder', App::getModel('finalization'), 'saveOrder'));
     $formContact = new SimpleForm\Form(array('name' => 'contactForm', 'action' => '', 'method' => 'post'));
     $formContact->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone', 'label' => _('TXT_PHONE'))));
     $formContact->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'))));
     $formContact->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'))))));
     $clientContact = Session::getActiveOrderContactData();
     $formContact->Populate(array('phone' => $clientContact['phone'], 'phone2' => $clientContact['phone2'], 'email' => $clientContact['email']));
     if ($formContact->Validate()) {
         $formData = $formContact->getSubmitValues();
         Session::setActiveOrderContactData($formData);
         App::redirectUrl($this->registry->router->generate('frontend.finalization', true));
     }
     $formBilling = new SimpleForm\Form(array('name' => 'billingForm', 'action' => '', 'method' => 'post'));
     $clientType = $formBilling->AddChild(new SimpleForm\Elements\Radio(array('name' => 'clienttype', 'label' => _('TXT_CLIENT_TYPE'), 'options' => array('1' => _('TXT_INDIVIDUAL_CLIENT'), '2' => _('TXT_COMPANY_CLIENT')))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_COMPANYNAME'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'nip', 'label' => _('TXT_NIP'), 'rules' => array(new SimpleForm\Rules\RequiredDependency(_('ERR_EMPTY_NIP'), $clientType, new SimpleForm\Conditions\Equals('2'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formBilling->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formBilling->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $clientBillingAddress = Session::getActiveOrderClientAddress();
     $formBilling->Populate(array('clienttype' => $clientBillingAddress['clienttype'], 'firstname' => $clientBillingAddress['firstname'], 'surname' => $clientBillingAddress['surname'], 'companyname' => $clientBillingAddress['companyname'], 'nip' => $clientBillingAddress['nip'], 'street' => $clientBillingAddress['street'], 'streetno' => $clientBillingAddress['streetno'], 'postcode' => $clientBillingAddress['postcode'], 'placename' => $clientBillingAddress['placename'], 'placeno' => $clientBillingAddress['placeno'], 'countryid' => $clientBillingAddress['countryid']));
     if ($formBilling->Validate()) {
         $formData = $formBilling->getSubmitValues();
         if ($formData['clienttype'] == 1) {
             $formData['companyname'] = '';
             $formData['nip'] = '';
         }
         Session::setActiveOrderClientAddress($formData);
         App::redirectUrl($this->registry->router->generate('frontend.finalization', true));
     }
     $formShipping = new SimpleForm\Form(array('name' => 'shippingForm', 'action' => '', 'method' => 'post'));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'firstname', 'label' => _('TXT_FIRSTNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_FIRSTNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'surname', 'label' => _('TXT_SURNAME'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_SURNAME'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'companyname', 'label' => _('TXT_COMPANYNAME'))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'street', 'label' => _('TXT_STREET'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREET'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'streetno', 'label' => _('TXT_STREETNO'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_STREETNO'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placeno', 'label' => _('TXT_PLACENO'))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'placename', 'label' => _('TXT_PLACE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PLACE'))))));
     $formShipping->AddChild(new SimpleForm\Elements\TextField(array('name' => 'postcode', 'label' => _('TXT_POSTCODE'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_POSTCODE')), new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT_POSTCODE'), '/^\\d{2}-\\d{3}?$/')))));
     $formShipping->AddChild(new SimpleForm\Elements\Select(array('name' => 'countryid', 'label' => _('TXT_NAME_OF_COUNTRY'), 'options' => App::getModel('lists')->getCountryForSelect(), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_NAME_OF_COUNTRY'))))));
     $clientShippingAddress = Session::getActiveOrderDeliveryAddress();
     $formShipping->Populate(array('firstname' => $clientShippingAddress['firstname'], 'surname' => $clientShippingAddress['surname'], 'companyname' => $clientShippingAddress['companyname'], 'street' => $clientShippingAddress['street'], 'streetno' => $clientShippingAddress['streetno'], 'postcode' => $clientShippingAddress['postcode'], 'placename' => $clientShippingAddress['placename'], 'placeno' => $clientShippingAddress['placeno'], 'countryid' => $clientShippingAddress['countryid']));
     if ($formShipping->Validate()) {
         $formData = $formShipping->getSubmitValues();
         Session::setActiveOrderDeliveryAddress($formData);
         App::redirectUrl($this->registry->router->generate('frontend.finalization', true));
     }
     $this->registry->template->assign('formContact', $formContact->getForm());
     $this->registry->template->assign('formBilling', $formBilling->getForm());
     $this->registry->template->assign('formShipping', $formShipping->getForm());
     $this->registry->template->assign('clientOrder', Session::getActiveClientOrder());
     $this->registry->template->assign('summary', App::getModel('finalization')->getOrderSummary());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Exemplo n.º 8
0
 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'));
     }
 }
Exemplo n.º 9
0
 protected function checkSSLPattern()
 {
     $trace = new TraceableUrlMatcher($this->routes, $this->context);
     $paths = $trace->getTraces($this->request->getPathInfo());
     foreach ($paths as $path) {
         if ($path['level'] == 1) {
             App::redirectUrl($this->generate($path['name'], true));
         }
     }
 }
Exemplo n.º 10
0
 public function index()
 {
     // support for enable/disable registration
     if (isset($this->layer['enableregistration']) && $this->layer['enableregistration'] == 1) {
         if (strlen($this->registry->core->getParam()) > 10) {
             $checkClient = $this->model->checkClientLink($this->registry->core->getParam());
             if (count($checkClient > 0)) {
                 $result = App::getModel('clientlogin')->authProccessConfirmation($checkClient['email'], $checkClient['password']);
                 if ($result != 0) {
                     Session::setActiveClientid($result);
                     App::getModel('clientlogin')->checkClientGroup();
                     $this->model->saveClientData();
                 }
                 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));
                 }
             }
         }
         $form = App::getFormModel('registration')->initForm();
         if ($form->Validate()) {
             $formData = $form->getSubmitValues();
             $recurMail = $this->model->checkClientNewMail($formData);
             if ($recurMail == 0) {
                 $clientId = $this->model->addNewClient($formData);
                 if (isset($this->layer['confirmregistration']) && $this->layer['confirmregistration'] == 1) {
                     $link = $this->model->updateClientDisable($clientId, 1, sha1($formData['email'] . time()));
                     $this->registry->template->assign('activelink', $link);
                 }
                 $this->registry->template->assign('address', $formData);
                 App::getModel('mailer')->sendEmail(array('template' => 'addClient', 'email' => array($formData['email']), 'bcc' => false, 'subject' => _('TXT_REGISTRATION_NEW'), 'viewid' => Helper::getViewId()));
                 if (isset($this->layer['confirmregistration']) && $this->layer['confirmregistration'] == 1) {
                     Session::setVolatileActivationRequired(1, false);
                 } else {
                     Session::setVolatileRegistrationOk(1, false);
                     $result = App::getModel('clientlogin')->authProccess($formData['email'], $formData['password']);
                     if ($result > 0) {
                         Session::setActiveClientid($result);
                         App::getModel('clientlogin')->checkClientGroup();
                         $this->model->saveClientData();
                     }
                     if ($result < 0) {
                         Session::setVolatileActivationRequired(1, false);
                     } else {
                         Session::setVolatileRegistrationOk(1, false);
                         App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
                     }
                 }
             } else {
                 $result = App::getModel('clientlogin')->authProccess($formData['email'], $formData['password']);
                 if ($result != 0) {
                     Session::setActiveClientid($result);
                     App::getModel('clientlogin')->checkClientGroup();
                     $this->model->saveClientData();
                     Session::setVolatileRegistrationOk(1, false);
                     App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
                 } elseif ($result < 0) {
                     Session::setVolatileActivationRequired(1, false);
                 } else {
                     Session::setVolatileRecureMail(1, false);
                 }
             }
         }
         $this->registry->template->assign('form', $form->getForm());
         $activationrequired = Session::getVolatileActivationRequired();
         if ($activationrequired[0] == 1) {
             $this->registry->template->assign('error', _('TXT_ACTIVATION_REQUIRED'));
             $this->registry->template->assign('error_msg', _('TXT_ACTIVATION_REQUIRED_MSG'));
         }
         $recureMailError = Session::getVolatileRecureMail();
         if ($recureMailError[0] == 1) {
             $this->registry->template->assign('error', _('ERR_DUPLICATE_EMAIL'));
             $this->registry->template->assign('error', _('ERR_DUPLICATE_EMAIL_MSG'));
         }
         $forbiddenCode = Session::getVolatileForbiddenCode();
         if ($forbiddenCode[0] == 1) {
             $this->registry->template->assign('error', _('TXT_ERROR_FORBIDDEN_CODE'));
             $this->registry->template->assign('error', _('TXT_ERROR_FORBIDDEN_CODE_MSG'));
         }
         $passwdGenError = Session::getVolatilePasswordGenerateError();
         if ($passwdGenError[0] == 1) {
             $this->registry->template->assign('error', _('ERROR_PASSWORD_GENERATE'));
             $this->registry->template->assign('error', _('ERROR_PASSWORD_GENERATE_MSG'));
         }
         return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
     } else {
         $this->registry->template->assign('error', _('TXT_REGISTRATION_DISABLED_HELP'));
     }
 }
Exemplo n.º 11
0
    public function reportPayment()
    {
        if (isset($_POST['p24_session_id']) && $_POST['p24_session_id'] != '') {
            $sessionid = base64_decode($_POST['p24_session_id']);
            $sql = 'SELECT 
						*
					FROM `order`
					WHERE sessionid = :crc';
            $stmt = Db::getInstance()->prepare($sql);
            $stmt->bindValue('crc', base64_decode($_POST['p24_session_id']));
            $stmt->execute();
            $rs = $stmt->fetch();
            if ($rs) {
                $settings = $this->registry->core->loadModuleSettings('przelewy24', $rs['viewid']);
                $p24_session_id = $_POST["p24_session_id"];
                $p24_order_id = $_POST["p24_order_id"];
                $p24_kwota = number_format($rs['globalprice'] * 100, 0, '', '');
                $P = array();
                $RET = array();
                $url = "https://secure.przelewy24.pl/transakcja.php";
                $P[] = "p24_id_sprzedawcy=" . $settings['idsprzedawcy'];
                $P[] = "p24_session_id=" . $p24_session_id;
                $P[] = "p24_order_id=" . $p24_order_id;
                $P[] = "p24_kwota=" . $p24_kwota;
                $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, join("&", $P));
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                $result = curl_exec($ch);
                curl_close($ch);
                $T = explode(chr(13) . chr(10), $result);
                $res = false;
                foreach ($T as $line) {
                    $line = ereg_replace("[\n\r]", "", $line);
                    if ($line != "RESULT" and !$res) {
                        continue;
                    }
                    if ($res) {
                        $RET[] = $line;
                    } else {
                        $res = true;
                    }
                }
                if ($RET[0] == 'TRUE') {
                    $status = $settings['positiveorderstatusid'];
                    $comment = 'Płatność zakończona sukcesem';
                    $url = $this->registry->router->generate('frontend.payment', true, array('action' => 'confirm', 'param' => 'przelewy24'));
                } else {
                    $status = $settings['negativeorderstatusid'];
                    $comment = 'Płatność zakończona niepowodzeniem';
                    $url = $this->registry->router->generate('frontend.payment', true, array('action' => 'cancel', 'param' => 'przelewy24'));
                }
                $sql = "UPDATE `order` SET orderstatusid = :status WHERE idorder = :idorder";
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('status', $status);
                $stmt->bindValue('idorder', $rs['idorder']);
                $stmt->execute();
                $sql = 'INSERT INTO orderhistory SET
							content = :content,
							orderstatusid = :status,
							orderid = :idorder,
							inform = 0';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('content', $comment);
                $stmt->bindValue('idorder', $rs['idorder']);
                $stmt->bindValue('status', $status);
                $stmt->execute();
                if (Session::getActivePaymentData() != NULL) {
                    App::redirectUrl($url);
                }
            }
        }
    }
Exemplo n.º 12
0
 public function index()
 {
     $formPass = new SimpleForm\Form(array('name' => 'changePassword', 'action' => '', 'method' => 'post'));
     $oldPassword = $formPass->AddChild(new SimpleForm\Elements\Password(array('name' => 'password', 'label' => _('TXT_PASSWORD'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PASSWORD'))))));
     $newPassword = $formPass->AddChild(new SimpleForm\Elements\Password(array('name' => 'newpassword', 'label' => _('TXT_PASSWORD_NEW'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_PASSWORD')), new SimpleForm\Rules\MinLength(_('ERR_PASSWORD_NEW_INVALID'), 6)))));
     $formPass->AddChild(new SimpleForm\Elements\Password(array('name' => 'confirmpassword', 'label' => _('TXT_PASSWORD_REPEAT'), 'rules' => array(new SimpleForm\Rules\Required(_('ERR_EMPTY_CONFIRM_PASSWORD')), new SimpleForm\Rules\Compare(_('ERR_PASSWORDS_NOT_COMPATIBILE'), $newPassword)))));
     if ($formPass->Validate()) {
         $formData = $formPass->getSubmitValues();
         $BaseTable = $this->model->getClientPass();
         $PostValidatePass = $formData['password'];
         $hash = new \PasswordHash\PasswordHash();
         if ($hash->CheckPassword($PostValidatePass, $BaseTable['password'])) {
             $this->model->updateClientPass($formData['newpassword']);
             $email = Session::getActiveClientEmail();
             $this->registry->template->assign('PASS_NEW', $formData['newpassword']);
             App::getModel('mailer')->sendEmail(array('template' => 'editPassword', 'email' => array($email), 'bcc' => false, 'subject' => _('TXT_PASSWORD_EDIT'), 'viewid' => Helper::getViewId()));
             Session::setVolatileChangePassOk(1, false);
             App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
         } else {
             Session::setVolatileOldPassError(1, false);
         }
     }
     $this->registry->template->assign('formPass', $formPass->getForm());
     $erroroldpass = Session::getVolatileOldPassError();
     if ($erroroldpass[0] == 1) {
         $this->registry->template->assign('error', _('TXT_ERROR_OLD_PASSWORD'));
     }
     $changepassok = Session::getVolatileChangePassOk();
     if ($changepassok[0] == 1) {
         $this->registry->template->assign('success', _('TXT_DATA_CHANGED_MAIL_SEND'));
     }
     $formUserEmail = new SimpleForm\Form(array('name' => 'changeEmail', 'action' => '', 'method' => 'post'));
     $newEmail = $formUserEmail->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'))))));
     $formUserEmail->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 -+]+$/')))));
     $formUserEmail->AddChild(new SimpleForm\Elements\TextField(array('name' => 'phone2', 'label' => _('TXT_ADDITIONAL_PHONE'), 'rules' => array(new SimpleForm\Rules\Format(_('ERR_WRONG_FORMAT'), '/^[0-9 -+]+$/')))));
     $clientData = App::getModel('client')->getClient();
     $formUserEmail->Populate(array('email' => $clientData['email'], 'phone' => $clientData['phone'], 'phone2' => $clientData['phone2']));
     if ($formUserEmail->Validate()) {
         $formData = $formUserEmail->getSubmitValues();
         $this->model->updateClientPhone($formData['phone'], $formData['phone2']);
         if ($clientData['email'] != $formData['email']) {
             $result = $this->model->checkClientNewMail($formData);
             if ($result == 0) {
                 $changedMail = $this->model->updateClientEmail($formData);
                 $changedLogin = $this->model->updateClientLogin($formData['email']);
                 Session::killSession();
                 App::redirectUrl($this->registry->router->generate('frontend.clientlogin', true, array('param' => 'changed')));
             } else {
                 Session::setVolatileUserEmailDuplicateError(1, false);
             }
         } else {
             Session::setVolatileUserSettingsSaved(1, false);
         }
         App::redirectUrl($this->registry->router->generate('frontend.clientsettings', true));
     }
     $registrationok = Session::getVolatileRegistrationOk();
     if ($registrationok[0] == 1) {
         $this->registry->template->assign('registrationok', _('TXT_REGISTER_USER_OK'));
     }
     $errorMail = Session::getVolatileUserEmailDuplicateError();
     if ($errorMail[0] == 1) {
         $this->registry->template->assign('duplicateMailError', _('ERR_DUPLICATE_EMAIL'));
     }
     $settingsChanged = Session::getVolatileUserSettingsSaved();
     if ($settingsChanged[0] == 1) {
         $this->registry->template->assign('settingsSaved', _('TXT_SETTINGS_SAVED'));
     }
     $this->registry->template->assign('formEmail', $formUserEmail->getForm());
     $changedPasswd = Session::getVolatilePasswordChanged();
     if ($changedPasswd[0] == 1) {
         $this->registry->template->assign('changedPasswd', _('TXT_PASSWORD_CHANGED'));
     }
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }
Exemplo n.º 13
0
 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));
     }
 }