コード例 #1
0
ファイル: Shop.class.php プロジェクト: nahakiole/cloudrexx
 static function view_account()
 {
     global $_ARRAYLANG;
     // hide currency navbar
     self::$show_currency_navbar = false;
     self::account_to_session();
     // Only verify the form after it has been posted
     if (isset($_POST['lastname'])) {
         if (self::verify_account()) {
             self::_gotoPaymentPage();
         }
     }
     \JS::activate('jquery');
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     // Use the details stored in the database as default.
     // Once the (changed) values are posted back, they are stored
     // in the session
     $company = isset($_SESSION['shop']['company']) ? $_SESSION['shop']['company'] : (self::$objCustomer ? self::$objCustomer->company() : '');
     $gender = isset($_SESSION['shop']['gender']) ? $_SESSION['shop']['gender'] : (self::$objCustomer ? self::$objCustomer->gender() : '');
     $lastname = isset($_SESSION['shop']['lastname']) ? $_SESSION['shop']['lastname'] : (self::$objCustomer ? self::$objCustomer->lastname() : '');
     $firstname = isset($_SESSION['shop']['firstname']) ? $_SESSION['shop']['firstname'] : (self::$objCustomer ? self::$objCustomer->firstname() : '');
     $address = isset($_SESSION['shop']['address']) ? $_SESSION['shop']['address'] : (self::$objCustomer ? self::$objCustomer->address() : '');
     $zip = isset($_SESSION['shop']['zip']) ? $_SESSION['shop']['zip'] : (self::$objCustomer ? self::$objCustomer->zip() : '');
     $city = isset($_SESSION['shop']['city']) ? $_SESSION['shop']['city'] : (self::$objCustomer ? self::$objCustomer->city() : '');
     $country_id = isset($_SESSION['shop']['countryId']) ? $_SESSION['shop']['countryId'] : (self::$objCustomer ? self::$objCustomer->country_id() : 0);
     $email = isset($_SESSION['shop']['email']) ? $_SESSION['shop']['email'] : (self::$objCustomer ? self::$objCustomer->email() : '');
     $phone = isset($_SESSION['shop']['phone']) ? $_SESSION['shop']['phone'] : (self::$objCustomer ? self::$objCustomer->phone() : '');
     $fax = isset($_SESSION['shop']['fax']) ? $_SESSION['shop']['fax'] : (self::$objCustomer ? self::$objCustomer->fax() : '');
     self::$objTemplate->setVariable(array('SHOP_ACCOUNT_COMPANY' => htmlentities($company, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_PREFIX' => Customers::getGenderMenuoptions($gender), 'SHOP_ACCOUNT_LASTNAME' => htmlentities($lastname, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_FIRSTNAME' => htmlentities($firstname, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ADDRESS' => htmlentities($address, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ZIP' => htmlentities($zip, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_CITY' => htmlentities($city, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_PHONE' => htmlentities($phone, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_FAX' => htmlentities($fax, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ACTION' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account'), 'SHOP_ACCOUNT_COUNTRY_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($country_id), 'SHOP_ACCOUNT_COUNTRY' => \Cx\Core\Country\Controller\Country::getMenu('countryId', $country_id)));
     $register = \Cx\Core\Setting\Controller\Setting::getValue('register', 'Shop');
     /**
      * @internal  Heavy logic ahead!
      * Some optional parts are visible only in certain cases:
      * - When the setting "register" is set to "optional":
      *   - Checkbox "Don't register"
      * - When no Customer is logged in:
      *   - Input "E-mail"
      *   - When registration is mandatory, or if optional and "Don't register"
      *     is unchecked:
      *     - Input "Password"
      * Here's an overview of all cases:
      * ----------------------------------------------------------------
      *           |     Optional parts visible when registration is
      * Customer  |        off        |     optional      |  mandatory
      * ----------------------------------------------------------------
      * Logged in |         -         |         -         |      -
      *           | (Accounts may     |                   |
      *           | still be created  |                   |
      *           | in the backend)   |                   |
      * ----------------------------------------------------------------
      * Guest     | "E-mail"          | "E-mail",         | "E-mail"
      *           |                   | Checkbox          | Input
      *           | (Noone can        | "Don't register"; | "Password"
      *           | register)         | If not checked:   |
      *           |                   | Input "Password"  |
      * ----------------------------------------------------------------
      * Notes:
      *  - "Don't register" is only parsed into the page when applicable, namely
      *    in the combination "guest/optional".
      *  - "Password" is parsed into the page along with the "E-Mail" field,
      *    but hidden when not applicable.
      */
     $block_password = false;
     $dontRegisterChecked = false;
     // Touches the entire surrounding block
     self::$objTemplate->setVariable('SHOP_ACCOUNT_EMAIL', contrexx_raw2xhtml($email));
     if (!self::$objCustomer) {
         if ($register == ShopLibrary::REGISTER_OPTIONAL) {
             //\DBG::log("Shop::view_account(): Optional -> e-mail, touch 'dont_register'");
             self::$objTemplate->touchBlock('dont_register');
             if (empty($_SESSION['shop']['dont_register'])) {
                 //\DBG::log("Shop::view_account(): Register -> block password");
                 $block_password = true;
             } else {
                 $dontRegisterChecked = true;
             }
         }
         if ($register == ShopLibrary::REGISTER_NONE) {
             $_SESSION['shop']['dont_register'] = true;
         }
         if ($register == ShopLibrary::REGISTER_MANDATORY) {
             //\DBG::log("Shop::view_account(): Mandatory/None -> div password");
             $block_password = true;
         }
     } else {
         //\DBG::log("Shop::view_account(): Got Customer -> no block");
     }
     //\DBG::log("Shop::view_account(): block_password ".var_export($block_password, true));
     self::$objTemplate->setGlobalVariable(array('SHOP_ACCOUNT_PASSWORD_DISPLAY' => $block_password ? \Html::CSS_DISPLAY_BLOCK : \Html::CSS_DISPLAY_NONE, 'SHOP_DONT_REGISTER_CHECKED' => $dontRegisterChecked ? \Html::ATTRIBUTE_CHECKED : '', 'TXT_SHOP_ACCOUNT_PASSWORD_HINT' => \Cx\Core_Modules\Access\Controller\AccessLib::getPasswordInfo()));
     if (!Cart::needs_shipment()) {
         return;
     }
     if (!isset($_SESSION['shop']['equal_address'])) {
         $_SESSION['shop']['equal_address'] = true;
     }
     self::$objTemplate->setVariable(array('SHOP_ACCOUNT_COMPANY2' => empty($_SESSION['shop']['company2']) ? '' : htmlentities($_SESSION['shop']['company2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_PREFIX2' => Customers::getGenderMenuoptions(empty($_SESSION['shop']['gender2']) ? '' : $_SESSION['shop']['gender2']), 'SHOP_ACCOUNT_LASTNAME2' => empty($_SESSION['shop']['lastname2']) ? '' : htmlentities($_SESSION['shop']['lastname2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_FIRSTNAME2' => empty($_SESSION['shop']['firstname2']) ? '' : htmlentities($_SESSION['shop']['firstname2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ADDRESS2' => empty($_SESSION['shop']['address2']) ? '' : htmlentities($_SESSION['shop']['address2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ZIP2' => empty($_SESSION['shop']['zip2']) ? '' : htmlentities($_SESSION['shop']['zip2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_CITY2' => empty($_SESSION['shop']['city2']) ? '' : htmlentities($_SESSION['shop']['city2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_COUNTRY2' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId2']), 'SHOP_ACCOUNT_COUNTRY2_ID' => $_SESSION['shop']['countryId2'], 'SHOP_ACCOUNT_PHONE2' => empty($_SESSION['shop']['phone2']) ? '' : htmlentities($_SESSION['shop']['phone2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_EQUAL_ADDRESS' => empty($_SESSION['shop']['equal_address']) ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_EQUAL_ADDRESS_CHECKED' => empty($_SESSION['shop']['equal_address']) ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_SHIPPING_ADDRESS_DISPLAY' => empty($_SESSION['shop']['equal_address']) ? \Html::CSS_DISPLAY_BLOCK : \Html::CSS_DISPLAY_NONE));
 }
コード例 #2
0
ファイル: ShopManager.class.php プロジェクト: Niggu/cloudrexx
 /**
  * Edit a Customer
  * @author    Reto Kohli <*****@*****.**>
  */
 function view_customer_edit()
 {
     global $_ARRAYLANG;
     self::$objTemplate->loadTemplateFile("module_shop_edit_customer.html");
     $customer_id = isset($_REQUEST['customer_id']) ? intval($_REQUEST['customer_id']) : null;
     if (isset($_POST['store'])) {
         $customer_id = $this->storeCustomerFromPost();
     }
     $username = isset($_POST['username']) ? trim(strip_tags(contrexx_input2raw($_POST['username']))) : null;
     $password = isset($_POST['password']) ? trim(strip_tags(contrexx_input2raw($_POST['password']))) : null;
     $company = isset($_POST['company']) ? trim(strip_tags(contrexx_input2raw($_POST['company']))) : null;
     $gender = isset($_POST['gender']) ? trim(strip_tags(contrexx_input2raw($_POST['gender']))) : null;
     $firstname = isset($_POST['firstname']) ? trim(strip_tags(contrexx_input2raw($_POST['firstname']))) : null;
     $lastname = isset($_POST['lastname']) ? trim(strip_tags(contrexx_input2raw($_POST['lastname']))) : null;
     $address = isset($_POST['address']) ? trim(strip_tags(contrexx_input2raw($_POST['address']))) : null;
     $city = isset($_POST['city']) ? trim(strip_tags(contrexx_input2raw($_POST['city']))) : null;
     $zip = isset($_POST['zip']) ? trim(strip_tags(contrexx_input2raw($_POST['zip']))) : null;
     $country_id = isset($_POST['country_id']) ? intval($_POST['country_id']) : null;
     $phone = isset($_POST['phone']) ? trim(strip_tags(contrexx_input2raw($_POST['phone']))) : null;
     $fax = isset($_POST['fax']) ? trim(strip_tags(contrexx_input2raw($_POST['fax']))) : null;
     $email = isset($_POST['email']) ? trim(strip_tags(contrexx_input2raw($_POST['email']))) : null;
     $companynote = isset($_POST['companynote']) ? trim(strip_tags(contrexx_input2raw($_POST['companynote']))) : null;
     $is_reseller = isset($_POST['customer_type']) ? intval($_POST['customer_type']) : null;
     $registerdate = time();
     $active = !empty($_POST['active']);
     $customer_group_id = isset($_POST['customer_group_id']) ? intval($_POST['customer_group_id']) : null;
     $lang_id = isset($_POST['customer_lang_id']) ? intval($_POST['customer_lang_id']) : FRONTEND_LANG_ID;
     if ($customer_id) {
         $objCustomer = Customer::getById($customer_id);
         if (!$objCustomer) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_LOADING']);
         }
         self::$pageTitle = $_ARRAYLANG['TXT_EDIT_CUSTOMER'];
         $username = $objCustomer->username();
         $password = '';
         $company = $objCustomer->company();
         $gender = $objCustomer->gender();
         $firstname = $objCustomer->firstname();
         $lastname = $objCustomer->lastname();
         $address = $objCustomer->address();
         $city = $objCustomer->city();
         $zip = $objCustomer->zip();
         $country_id = $objCustomer->country_id();
         $phone = $objCustomer->phone();
         $fax = $objCustomer->fax();
         $email = $objCustomer->email();
         $companynote = $objCustomer->companynote();
         $is_reseller = $objCustomer->is_reseller();
         $registerdate = $objCustomer->getRegistrationDate();
         $active = $objCustomer->active();
         $customer_group_id = $objCustomer->group_id();
         $lang_id = $objCustomer->getFrontendLanguage();
     } else {
         self::$pageTitle = $_ARRAYLANG['TXT_ADD_NEW_CUSTOMER'];
         self::$objTemplate->setVariable('SHOP_SEND_LOGING_DATA_STATUS', \Html::ATTRIBUTE_CHECKED);
         $customer_id = null;
     }
     self::$objTemplate->setVariable(array('SHOP_CUSTOMERID' => $customer_id, 'SHOP_COMPANY' => $company, 'SHOP_GENDER_MENUOPTIONS' => Customers::getGenderMenuoptions($gender), 'SHOP_LASTNAME' => $lastname, 'SHOP_FIRSTNAME' => $firstname, 'SHOP_ADDRESS' => $address, 'SHOP_ZIP' => $zip, 'SHOP_CITY' => $city, 'SHOP_EMAIL' => $email, 'SHOP_PHONE' => $phone, 'SHOP_FAX' => $fax, 'SHOP_USERNAME' => $username, 'SHOP_PASSWORD' => $password, 'SHOP_COMPANY_NOTE' => $companynote, 'SHOP_REGISTER_DATE' => date(ASCMS_DATE_FORMAT_DATETIME, $registerdate), 'SHOP_COUNTRY_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($country_id), 'SHOP_DISCOUNT_GROUP_CUSTOMER_MENUOPTIONS' => Discount::getMenuOptionsGroupCustomer($customer_group_id), 'SHOP_CUSTOMER_TYPE_MENUOPTIONS' => Customers::getTypeMenuoptions($is_reseller), 'SHOP_CUSTOMER_ACTIVE_MENUOPTIONS' => Customers::getActiveMenuoptions($active), 'SHOP_LANG_ID_MENUOPTIONS' => \FWLanguage::getMenuoptions($lang_id)));
     return true;
 }