本文整理汇总了PHP中Customer类的典型用法代码示例。如果您正苦于以下问题:PHP Customer类的具体用法?PHP Customer怎么用?PHP Customer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Customer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize order confirmation controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
$this->id_cart = (int) Tools::getValue('id_cart', 0);
$is_guest = false;
/* check if the cart has been made by a Guest customer, for redirect link */
if (Cart::isGuestCartByCartId($this->id_cart)) {
$is_guest = true;
$redirectLink = 'index.php?controller=guest-tracking';
} else {
$redirectLink = 'index.php?controller=history';
}
$this->id_module = (int) Tools::getValue('id_module', 0);
$this->id_order = Order::getOrderByCartId((int) $this->id_cart);
$this->secure_key = Tools::getValue('key', false);
$order = new Order((int) $this->id_order);
if ($is_guest) {
$customer = new Customer((int) $order->id_customer);
$customer->transformToCustomer(2);
//nox
$redirectLink .= '&id_order=' . $order->reference . '&email=' . urlencode($customer->email);
}
if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) {
Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
}
$this->reference = $order->reference;
if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) {
Tools::redirect($redirectLink);
}
$module = Module::getInstanceById((int) $this->id_module);
if ($order->payment != $module->displayName) {
Tools::redirect($redirectLink);
}
}
开发者ID:h0n24,项目名称:leodig,代码行数:38,代码来源:OrderConfirmationController.php
示例2: __construct
public function __construct()
{
parent::__construct();
try {
TTransaction::open('samples');
// abre uma transação
// cria novo objeto
$giovani = new Customer();
$giovani->name = 'Giovanni Dall Oglio';
$giovani->address = 'Rua da Conceicao';
$giovani->phone = '(51) 8111-2222';
$giovani->birthdate = '2013-02-15';
$giovani->status = 'S';
$giovani->email = '[email protected]';
$giovani->gender = 'M';
$giovani->category_id = '1';
$giovani->city_id = '1';
$giovani->store();
// armazena o objeto
new TMessage('info', 'Objeto armazenado com sucesso');
TTransaction::close();
// fecha a transação.
} catch (Exception $e) {
new TMessage('error', $e->getMessage());
}
}
开发者ID:jfrank1500,项目名称:curso_php,代码行数:26,代码来源:ObjectStore.class.php
示例3: changePassword
protected function changePassword()
{
$token = Tools::getValue('token');
$id_customer = (int) Tools::getValue('id_customer');
if ($email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . $id_customer)) {
$customer = new Customer();
$customer->getByEmail($email);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = $this->trans('Customer account not found', array(), 'Shop.Notifications.Error');
} elseif (!$customer->active) {
$this->errors[] = $this->trans('You cannot regenerate the password for this account.', array(), 'Shop.Notifications.Error');
}
// Case if both password params not posted or different, then "change password" form is not POSTED, show it.
if (!Tools::isSubmit('passwd') || !Tools::isSubmit('confirmation') || ($passwd = Tools::getValue('passwd')) !== ($confirmation = Tools::getValue('confirmation')) || !Validate::isPasswd($passwd) || !Validate::isPasswd($confirmation)) {
// Check if passwords are here anyway, BUT does not match the password validation format
if (Tools::isSubmit('passwd') || Tools::isSubmit('confirmation')) {
$this->errors[] = $this->trans('The password and its confirmation do not match.', array(), 'Shop.Notifications.Error');
}
$this->context->smarty->assign(['customer_email' => $customer->email, 'customer_token' => $token, 'id_customer' => $id_customer, 'reset_token' => Tools::getValue('reset_token')]);
$this->setTemplate('customer/password-new');
} else {
// Both password fields posted. Check if all is right and store new password properly.
if (!Tools::getValue('reset_token') || strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) {
Tools::redirect('index.php?controller=authentication&error_regen_pwd');
} else {
// To update password, we must have the temporary reset token that matches.
if ($customer->getValidResetPasswordToken() !== Tools::getValue('reset_token')) {
$this->errors[] = $this->trans('The password change request expired. You should ask for a new one.', array(), 'Shop.Notifications.Error');
} else {
try {
$crypto = new Hashing();
} catch (\PrestaShop\PrestaShop\Adapter\CoreException $e) {
$this->errors[] = $this->trans('An error occurred with your account, which prevents us from updating the new password. Please report this issue using the contact form.', array(), 'Shop.Notifications.Error');
return false;
}
$customer->passwd = $crypto->encrypt($password = Tools::getValue('passwd'), _COOKIE_KEY_);
$customer->last_passwd_gen = date('Y-m-d H:i:s', time());
if ($customer->update()) {
Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
$customer->removeResetPasswordToken();
$customer->update();
$mail_params = ['{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname];
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(['customer_email' => $customer->email]);
$this->success[] = $this->trans('Your password has been successfully reset and a confirmation has been sent to your email address: %s', array($customer->email), 'Shop.Notifications.Success');
$this->context->updateCustomer($customer);
$this->redirectWithNotifications('index.php?controller=my-account');
} else {
$this->errors[] = $this->trans('An error occurred while sending the email.', array(), 'Shop.Notifications.Error');
}
} else {
$this->errors[] = $this->trans('An error occurred with your account, which prevents us from updating the new password. Please report this issue using the contact form.', array(), 'Shop.Notifications.Error');
}
}
}
}
} else {
$this->errors[] = $this->trans('We cannot regenerate your password with the data you\'ve submitted', array(), 'Shop.Notifications.Error');
}
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:60,代码来源:PasswordController.php
示例4: testSetExternalIdValid
public function testSetExternalIdValid()
{
$externalId = 'abc';
$customer = new Customer('[email protected]');
$customer->setExternalId($externalId);
$this->assertEquals($externalId, $customer->getExternalId());
}
开发者ID:purchased-at,项目名称:sdk-php,代码行数:7,代码来源:CustomerTest.php
示例5: getContent
public function getContent()
{
if (Tools::isSubmit('submitUpdate')) {
Configuration::updateValue('NW_CONFIRMATION_EMAIL', (bool) Tools::getValue('NW_CONFIRMATION_EMAIL'));
Configuration::updateValue('NW_VERIFICATION_EMAIL', (bool) Tools::getValue('NW_VERIFICATION_EMAIL'));
$voucher = Tools::getValue('NW_VOUCHER_CODE');
if ($voucher && !Validate::isDiscountName($voucher)) {
$this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
} else {
Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
$this->_html .= $this->displayConfirmation($this->l('Settings updated'));
}
} elseif (Tools::isSubmit('subscribedmerged')) {
$id = Tools::getValue('id');
if (preg_match('/(^N)/', $id)) {
$id = (int) substr($id, 1);
$sql = 'UPDATE ' . _DB_PREFIX_ . 'newsletter SET active = 0 WHERE id = ' . $id;
Db::getInstance()->execute($sql);
} else {
$c = new Customer((int) $id);
$c->newsletter = (int) (!$c->newsletter);
$c->update();
}
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&conf=4&token=' . Tools::getAdminTokenLite('AdminModules'));
} elseif (Tools::isSubmit('exportSubscribers')) {
$header = array('id', 'shop_name', 'gender', 'lastname', 'firstname', 'email', 'subscribed', 'subscribed_on');
// TODO
$array_to_export = array_merge(array($header), $this->getSubscribers());
$file_name = time() . '.csv';
$fd = fopen($this->getLocalPath() . $file_name, 'w+');
foreach ($array_to_export as $tab) {
$line = implode(';', $tab);
$line .= "\n";
fwrite($fd, $line, 4096);
}
fclose($fd);
Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
} elseif (Tools::isSubmit('exportOnlyBlockNews')) {
$array_to_export = $this->getBlockNewsletterSubscriber();
$file_name = time() . '.csv';
$fd = fopen($this->getLocalPath() . $file_name, 'w+');
foreach ($array_to_export as $tab) {
$line = implode(';', $tab);
$line .= "\n";
fwrite($fd, $line, 4096);
}
fclose($fd);
Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
} elseif (Tools::isSubmit('searchEmail')) {
$this->_searched_email = Tools::getValue('searched_email');
}
$this->_html .= $this->renderForm();
$this->_html .= $this->renderSearchForm();
$this->_html .= $this->renderList();
$this->_html .= '<div class="panel"><a href="' . $this->context->link->getAdminLink('AdminModules', false) . '&exportSubscribers&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
<button class="btn btn-default btn-lg"><span class="icon icon-share"></span> ' . $this->l('Export as CSV') . '</button>
</a></div>';
$this->_html .= $this->renderExportForm();
return $this->_html;
}
开发者ID:jpodracky,项目名称:dogs,代码行数:60,代码来源:blocknewsletter.php
示例6: postProcess
/**
* Start forms process.
*
* @see FrontController::postProcess()
*/
public function postProcess()
{
$order_reference = current(explode('#', Tools::getValue('order_reference')));
$email = Tools::getValue('email');
if (!$email && !$order_reference) {
return;
} elseif (!$email || !$order_reference) {
$this->errors[] = $this->getTranslator()->trans('Please provide the required information', array(), 'Shop.Notifications.Error');
return;
}
$isCustomer = Customer::customerExists($email, false, true);
if ($isCustomer) {
$this->info[] = $this->trans('Please log in to your customer account to view the order', array(), 'Shop.Notifications.Info');
$this->redirectWithNotifications($this->context->link->getPageLink('history'));
} else {
$this->order = Order::getByReferenceAndEmail($order_reference, $email);
if (!Validate::isLoadedObject($this->order)) {
$this->errors[] = $this->getTranslator()->trans('We couldn\'t find your order with the information provided, please try again', array(), 'Shop.Notifications.Error');
}
}
if (Tools::isSubmit('submitTransformGuestToCustomer') && Tools::getValue('password')) {
$customer = new Customer((int) $this->order->id_customer);
$password = Tools::getValue('password');
if (strlen($password) < Validate::PASSWORD_LENGTH) {
$this->errors[] = $this->trans('Your password must be at least %min% characters long.', array('%min%' => Validate::PASSWORD_LENGTH), 'Shop.Forms.Help');
} elseif ($customer->transformToCustomer($this->context->language->id, $password)) {
$this->success[] = $this->trans('Your guest account has been successfully transformed into a customer account. You can now log in as a registered shopper.', array(), 'Shop.Notifications.Success');
} else {
$this->success[] = $this->trans('An unexpected error occurred while creating your account.', array(), 'Shop.Notifications.Error');
}
}
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:37,代码来源:GuestTrackingController.php
示例7: run
public function run()
{
$this->init();
$this->preProcess();
if (Tools::getValue('ajax') == 'true') {
if (Tools::getIsset('summary')) {
if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
if (self::$cookie->id_customer) {
$customer = new Customer((int) self::$cookie->id_customer);
$groups = $customer->getGroups();
} else {
$groups = array(1);
}
if ((int) self::$cart->id_address_delivery) {
$deliveryAddress = new Address((int) self::$cart->id_address_delivery);
}
$result = array('carriers' => Carrier::getCarriersForOrder((int) Country::getIdZone((isset($deliveryAddress) and (int) $deliveryAddress->id) ? (int) $deliveryAddress->id_country : (int) Configuration::get('PS_COUNTRY_DEFAULT')), $groups));
}
$result['summary'] = self::$cart->getSummaryDetails();
$result['customizedDatas'] = Product::getAllCustomizedDatas((int) self::$cart->id);
$result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']);
$result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
die(Tools::jsonEncode($result));
} else {
$this->includeCartModule();
}
} else {
$this->setMedia();
$this->displayHeader();
$this->process();
$this->displayContent();
$this->displayFooter();
}
}
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:34,代码来源:CartController.php
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$rules = array("customerId" => "required", "firstAddress" => "required", "secondAddress" => "required", "thirdAddress" => "required", "fourthAddress" => "required", "area" => "required", "region" => "required", "customerPhone" => "required|numeric", "customerFax" => "required|numeric", "customerEmail" => "required|email", "customerContact" => "required", "poBirth" => "required|date", "doBirth" => "required|date", "customerReligion" => "required", "customerPosition" => "required", "customerStatus" => "required", "customerChildren" => "required|integer", "customerPhoneHome" => "required|numeric", "customerMobile" => "required|numeric", "customerPinBB" => "required");
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/customer/create')->withErrors($validator);
}
//
$customer = new Customer();
$customer->customerID = Input::get('customerId');
$customer->customerAddress1 = Input::get('firstAddress');
$customer->customerAddress2 = Input::get('secondAddress');
$customer->customerAddress3 = Input::get('thirdAddress');
$customer->customerAddress4 = Input::get('fourthAddress');
$customer->areaID = Input::get('area');
$customer->regionID = Input::get('region');
$customer->customerPhone = Input::get('customerPhone');
$customer->customerFax = Input::get('customerFax');
$customer->customerEmail = Input::get('customerEmail');
$customer->customerContact = Input::get('customerContact');
$customer->POBirth = Input::get('poBirth');
$customer->DOBirth = Input::get('doBirth');
$customer->customerReligion = Input::get('customerReligion');
$customer->customerPosition = Input::get('customerPosition');
$customer->customerStatus = Input::get('customerStatus');
$customer->customerChildren = Input::get('customerChildren');
$customer->customerPhoneHome = Input::get('customerPhoneHome');
$customer->customerMobile = Input::get('customerMobile');
$customer->customerPinBB = Input::get('customerPinBB');
$customer->save();
return Redirect::to('/customer');
}
开发者ID:NathanaelFebrianto,项目名称:Citramas,代码行数:38,代码来源:CustomerController.php
示例9: init
public function init()
{
parent::init();
/*
* Piqué dans le AuthController. J'aurais bien aimé utiliser le AuthController, mais le premier contrôle dans son init()
* c'est pour vérifier si l'utilisateur est loggé ou non, ce qui mettait à plat ma stratégie.
*
* Je me suis posé la question 'Faut il que ca marche pour des admin ?', j'ai supposé que non,
* mais s'il avait fallu, il suffisait de tester un 'Employee' en plus d'un 'Customer'
*/
$passwd = trim(Tools::getValue('passwd'));
$_POST['passwd'] = null;
$email = trim(Tools::getValue('email'));
if (!empty($email) && Validate::isEmail($email) && !empty($passwd) && Validate::isPasswd($passwd)) {
$customer = new Customer();
$authentication = $customer->getByEmail(trim($email), trim($passwd));
if (isset($authentication->active) && $authentication->active && $customer->id) {
Tools::redirect(Configuration::get("ADMIN_TAB_MODULE_URLBACK"));
}
}
/*
* Ici, je ne suis vraiment pas satisfait de la méthode employée, je trouve ça plutôt crade
* de transmettre des infos sur les erreurs via un param en GET, mais dans l'immédiat je n'ai pas trouvé mieux
*/
Tools::redirect("index.php?urlback_haserror=1");
}
开发者ID:ArnaudBenassy,项目名称:abenassyurlback,代码行数:26,代码来源:URLBack.php
示例10: get
public function get($customerId = null, $carId = null)
{
$sql = "SELECT * FROM {$this->tableName} WHERE 1=1";
if (!empty($customerId)) {
$sql .= " AND `owner` = " . $this->db->escape($customerId);
}
if (!empty($carId)) {
$sql .= " AND `id` = " . $this->db->escape($carId);
}
$result = array();
$service = new Service();
if (!empty($carId)) {
$result = $this->db->fetchOne($sql);
$customer = new Customer(false);
$owner = $customer->get($result['owner']);
if (!empty($owner)) {
$result['owner'] = $owner;
}
$result['services'] = $service->getForCar($carId);
} else {
$result = $this->db->fetchAll($sql);
$customer = new Customer(false);
foreach ($result as $index => $car) {
$owner = $customer->get($car['owner']);
if (!empty($owner)) {
$result[$index]['owner'] = $owner;
}
$result[$index]['services'] = $service->getForCar($car['id']);
}
}
new Respond($result);
}
开发者ID:BradlySharpe,项目名称:Sharpies-Auto-Services,代码行数:32,代码来源:Car.php
示例11: preProcess
public function preProcess()
{
parent::preProcess();
$customer = new Customer((int) self::$cookie->id_customer);
if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) {
$customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (Module::getInstanceByName('blocknewsletter')->active) {
if (!isset($_POST['optin'])) {
$customer->optin = 0;
}
if (!isset($_POST['newsletter'])) {
$customer->newsletter = 0;
}
}
if (!isset($_POST['id_gender'])) {
$_POST['id_gender'] = 9;
}
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
} else {
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$id_customer_exists = (int) Customer::customerExists(Tools::getValue('email'), true, false);
if ($id_customer_exists && $id_customer_exists != (int) self::$cookie->id_customer) {
$this->errors[] = Tools::displayError('An account is already registered with this e-mail.');
}
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
$this->errors[] = Tools::displayError('Your password is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('Password and confirmation do not match');
} else {
$prev_id_default_group = $customer->id_default_group;
$this->errors = array_unique(array_merge($this->errors, $customer->validateController(true, true)));
}
if (!count($this->errors)) {
$customer->id_default_group = (int) $prev_id_default_group;
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd')) {
self::$cookie->passwd = $customer->passwd;
}
if ($customer->update()) {
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('Cannot update information');
}
}
}
} else {
$_POST = array_map('stripslashes', $customer->getFields());
}
$birthday = $customer->birthday ? explode('-', $customer->birthday) : array('-', '-', '-');
/* Generate years, months and days */
self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors));
self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
}
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:59,代码来源:IdentityController.php
示例12: savedbAction
public function savedbAction(array $data)
{
$customer = new Customer();
$customer->exchangeArray($data);
$customersTable = $this->getServiceLocator()->get('CustomersTable');
$customersTable->saveCustomer($customer);
return true;
}
开发者ID:AlexandrKozyr,项目名称:ver_site,代码行数:8,代码来源:LoginController.php
示例13: delete
public function delete()
{
if ($this->f3->exists('PARAMS.id')) {
$user = new Customer($this->db);
$user->delete($this->f3->get('PARAMS.id'));
}
$this->f3->reroute('/customer');
}
开发者ID:srccn,项目名称:f3,代码行数:8,代码来源:CustomerController.php
示例14: getCustomerIdByEmailAndPassword
/**
* @param $email
* @param $password
* @return int
*/
public function getCustomerIdByEmailAndPassword($email, $password)
{
/** @var CustomerCore $customer */
$customer = new Customer();
/** @var CustomerCore $authentication */
$authentication = $customer->getByEmail(trim($email), trim($password));
return $authentication->id;
}
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:13,代码来源:Customer.php
示例15: addCustomer
public function addCustomer($company, $firstname, $lastname, $address, $zip, $city)
{
$person = new Person();
$person->setCompany($company)->setFirstname($firstname)->setLastname($lastname)->setAddress($address)->setCity($city)->setZip($zip)->save();
$customer = new Customer();
$customer->setPerson($person)->save();
return $customer;
}
开发者ID:xama5,项目名称:uver-erp,代码行数:8,代码来源:PersonModel.php
示例16: testMarshalling
public function testMarshalling()
{
$expectedXml = <<<XML
<?xml version="1.0"?>
<purchase-order xmlns="http://openuri.org/easypo">
<customer>
<name>Gladys Kravitz</name>
<address>Anytown, PA</address>
</customer>
<date>2003-01-07T14:16:00-05:00</date>
<line-item>
<description>Burnham's Celestial Handbook, Vol 1</description>
<per-unit-ounces>5</per-unit-ounces>
<price>21.79</price>
<quantity>2</quantity>
</line-item>
<line-item>
<description>Burnham's Celestial Handbook, Vol 2</description>
<per-unit-ounces>5</per-unit-ounces>
<price>19.89</price>
<quantity>2</quantity>
</line-item>
<shipper>
<name>ZipShip</name>
<per-ounce-rate>0.74</per-ounce-rate>
</shipper>
</purchase-order>
XML;
$filepath = dirname(__FILE__) . '/../../_files/EasyPO/';
$binding = new PiBX_Runtime_Binding($filepath . '/binding.xml');
$marshaller = new PiBX_Runtime_Marshaller($binding);
$po = new PurchaseOrder();
$po->setDate('2003-01-07T14:16:00-05:00');
$customer = new Customer();
$customer->setName('Gladys Kravitz');
$customer->setAddress('Anytown, PA');
$lineItem1 = new LineItem();
$lineItem1->setDescription('Burnham\'s Celestial Handbook, Vol 1');
$lineItem1->setPerUnitOunces('5');
$lineItem1->setPrice(21.79);
$lineItem1->setQuantity(2);
$lineItem2 = new LineItem();
$lineItem2->setDescription('Burnham\'s Celestial Handbook, Vol 2');
$lineItem2->setPerUnitOunces('5');
$lineItem2->setPrice(19.89);
$lineItem2->setQuantity(2);
$shipper = new Shipper();
$shipper->setName('ZipShip');
$shipper->setPerOunceRate(0.74);
$po->setCustomer($customer);
$po->setLineItems(array($lineItem1, $lineItem2));
$po->setShipper($shipper);
$xml = $marshaller->marshal($po);
$this->assertEquals($expectedXml, $xml);
$dom = new DOMDocument();
$dom->loadXML($xml);
$this->assertTrue($dom->schemaValidate($filepath . '/easypo.xsd'));
}
开发者ID:rocksolid-tn,项目名称:pibx,代码行数:58,代码来源:MarshallerTest.php
示例17: preProcess
public function preProcess()
{
parent::preProcess();
$customer = new Customer((int) self::$cookie->id_customer);
if (sizeof($_POST)) {
$exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add', 'id_default_group');
$fields = $customer->getFields();
foreach ($fields as $key => $value) {
if (!in_array($key, $exclusion)) {
$customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
}
}
}
if (isset($_POST['years']) and isset($_POST['months']) and isset($_POST['days'])) {
$customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
}
if (Tools::isSubmit('submitIdentity')) {
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
} else {
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) or Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) {
$this->errors[] = Tools::displayError('Your password is incorrect.');
} elseif ($_POST['passwd'] != $_POST['confirmation']) {
$this->errors[] = Tools::displayError('Password and confirmation do not match');
} else {
$prev_id_default_group = $customer->id_default_group;
$this->errors = $customer->validateControler();
}
if (!sizeof($this->errors)) {
$customer->id_default_group = (int) $prev_id_default_group;
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd')) {
self::$cookie->passwd = $customer->passwd;
}
if ($customer->update()) {
self::$cookie->customer_lastname = $customer->lastname;
self::$cookie->customer_firstname = $customer->firstname;
self::$smarty->assign('confirmation', 1);
} else {
$this->errors[] = Tools::displayError('Cannot update information');
}
}
}
} else {
$_POST = array_map('stripslashes', $customer->getFields());
}
if ($customer->birthday) {
$birthday = explode('-', $customer->birthday);
} else {
$birthday = array('-', '-', '-');
}
/* Generate years, months and days */
self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors));
self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active);
}
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:57,代码来源:IdentityController.php
示例18: actionAdmin
public function actionAdmin()
{
$model = new Customer('search');
$model->unsetAttributes();
if (isset($_GET['Customer'])) {
$model->setAttributes($_GET['Customer']);
}
$this->render('admin', array('model' => $model));
}
开发者ID:schmunk42,项目名称:yii-sakila-crud,代码行数:9,代码来源:CustomerController.php
示例19: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('email')) {
if (!($email = Tools::getValue('email')) || !Validate::isEmail($email)) {
$this->errors[] = Tools::displayError('Invalid e-mail address');
} else {
$customer = new Customer();
$customer->getByemail($email);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
} elseif (!$customer->active) {
$this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
} elseif (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
$this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int) $min_time);
} else {
$mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id));
if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
} else {
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
}
}
} elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
$email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer);
if ($email) {
$customer = new Customer();
$customer->getByemail($email);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('Customer account not found');
} elseif (!$customer->active) {
$this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
} elseif (strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) {
Tools::redirect('index.php?controller=authentication&error_regen_pwd');
} else {
$customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH));
$customer->last_passwd_gen = date('Y-m-d H:i:s', time());
if ($customer->update()) {
Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
$mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password);
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
} else {
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
}
}
} else {
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
} elseif (Tools::getValue('token') || Tools::getValue('id_customer')) {
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
}
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:60,代码来源:PasswordController.php
示例20: executeNew
public function executeNew(sfWebRequest $request)
{
$i18n = $this->getContext()->getI18N();
$customer = new Customer();
$customer->fromArray(array('name' => $i18n->
|
请发表评论