作者:marger
项目:theli
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::getCustomerByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
}
}
作者:alex6353
项目:theli
public function testRenderLoop()
{
$customerId = CustomerQuery::create()->findOne()->getId();
$this->handler->expects($this->any())->method("buildDataSet")->willReturn($this->handler->renderLoop("address", ["customer" => $customerId]));
$lang = Lang::getDefaultLanguage();
$loop = $this->handler->buildDataSet($lang);
$this->assertInstanceOf("Thelia\\Core\\Template\\Loop\\Address", $loop);
$data = $this->handler->buildData($lang);
$addresses = AddressQuery::create()->filterByCustomerId($customerId)->find()->toArray("Id");
foreach ($data->getData() as $row) {
$this->assertArrayHasKey("id", $row);
$this->assertArrayHasKey($row["id"], $addresses);
$this->assertEquals(count($addresses), $row["loop_total"]);
$address = $addresses[$row["id"]];
$this->assertEquals($row["address1"], $address["Address1"]);
$this->assertEquals($row["address2"], $address["Address2"]);
$this->assertEquals($row["address3"], $address["Address3"]);
$this->assertEquals($row["cellphone"], $address["Cellphone"]);
$this->assertEquals($row["city"], $address["City"]);
$this->assertEquals($row["company"], $address["Company"]);
$this->assertEquals($row["country"], $address["CountryId"]);
$this->assertEquals($row["create_date"], $address["CreatedAt"]);
$this->assertEquals($row["update_date"], $address["UpdatedAt"]);
$this->assertEquals($row["firstname"], $address["Firstname"]);
$this->assertEquals($row["lastname"], $address["Lastname"]);
$this->assertEquals($row["id"], $address["Id"]);
$this->assertEquals($row["label"], $address["Label"]);
$this->assertEquals($row["phone"], $address["Phone"]);
$this->assertEquals($row["title"], $address["TitleId"]);
$this->assertEquals($row["zipcode"], $address["Zipcode"]);
}
}
作者:badela
项目:theli
public function loadStatsAjaxAction()
{
if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW))) {
return $response;
}
$data = new \stdClass();
$data->title = $this->getTranslator()->trans("Stats on %month/%year", array('%month' => $this->getRequest()->query->get('month', date('m')), '%year' => $this->getRequest()->query->get('year', date('Y'))));
/* sales */
$saleSeries = new \stdClass();
$saleSeries->color = $this->getRequest()->query->get('sales_color', '#adadad');
$saleSeries->data = OrderQuery::getMonthlySaleStats($this->getRequest()->query->get('month', date('m')), $this->getRequest()->query->get('year', date('Y')));
/* new customers */
$newCustomerSeries = new \stdClass();
$newCustomerSeries->color = $this->getRequest()->query->get('customers_color', '#f39922');
$newCustomerSeries->data = CustomerQuery::getMonthlyNewCustomersStats($this->getRequest()->query->get('month', date('m')), $this->getRequest()->query->get('year', date('Y')));
/* orders */
$orderSeries = new \stdClass();
$orderSeries->color = $this->getRequest()->query->get('orders_color', '#5cb85c');
$orderSeries->data = OrderQuery::getMonthlyOrdersStats($this->getRequest()->query->get('month', date('m')), $this->getRequest()->query->get('year', date('Y')));
/* first order */
$firstOrderSeries = new \stdClass();
$firstOrderSeries->color = $this->getRequest()->query->get('first_orders_color', '#5bc0de');
$firstOrderSeries->data = OrderQuery::getFirstOrdersStats($this->getRequest()->query->get('month', date('m')), $this->getRequest()->query->get('year', date('Y')));
/* cancelled orders */
$cancelledOrderSeries = new \stdClass();
$cancelledOrderSeries->color = $this->getRequest()->query->get('cancelled_orders_color', '#d9534f');
$cancelledOrderSeries->data = OrderQuery::getMonthlyOrdersStats($this->getRequest()->query->get('month', date('m')), $this->getRequest()->query->get('year', date('Y')), array(5));
$data->series = array($saleSeries, $newCustomerSeries, $orderSeries, $firstOrderSeries, $cancelledOrderSeries);
$json = json_encode($data);
return $this->jsonResponse($json);
}
作者:adirkuh
项目:theli
/**
* @param OrderQuery $search
* @param $searchTerm
* @param $searchIn
* @param $searchCriteria
*/
public function doSearch(&$search, $searchTerm, $searchIn, $searchCriteria)
{
$search->_and();
foreach ($searchIn as $index => $searchInElement) {
if ($index > 0) {
$search->_or();
}
switch ($searchInElement) {
case 'ref':
$search->filterByRef($searchTerm, $searchCriteria);
break;
case 'invoice_ref':
$search->filterByInvoiceRef($searchTerm, $searchCriteria);
break;
case 'customer_ref':
$search->filterByCustomer(CustomerQuery::create()->filterByRef($searchTerm, $searchCriteria)->find());
break;
case 'customer_firstname':
$search->filterByOrderAddressRelatedByInvoiceOrderAddressId(OrderAddressQuery::create()->filterByFirstname($searchTerm, $searchCriteria)->find());
break;
case 'customer_lastname':
$search->filterByOrderAddressRelatedByInvoiceOrderAddressId(OrderAddressQuery::create()->filterByLastname($searchTerm, $searchCriteria)->find());
break;
case 'customer_email':
$search->filterByCustomer(CustomerQuery::create()->filterByEmail($searchTerm, $searchCriteria)->find());
break;
}
}
}
作者:JumBa
项目:ImportT
public function loginAction()
{
$customerController = new BaseCustomerController();
$customerController->setContainer($this->container);
$response = $customerController->loginAction();
if (!$this->getSecurityContext()->hasCustomerUser()) {
$request = $this->getRequest();
$customerLoginForm = new CustomerLogin($request);
try {
$form = $this->validateForm($customerLoginForm, "post");
$request = CustomerTempQuery::create();
$customerTemp = $request->where('`customer_temp`.email = ?', $form->get('email')->getData(), \PDO::PARAM_STR)->where('`customer_temp`.password = PASSWORD(?)', $form->get('password')->getData(), \PDO::PARAM_STR)->where('`customer_temp`.processed = 0')->findOne();
if (null !== $customerTemp) {
$customer = CustomerQuery::create()->findOneByEmail($form->get('email')->getData());
$customer->setPassword($form->get('password')->getData())->save();
$customerTemp->setProcessed(true)->save();
$this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer));
$successUrl = $customerLoginForm->getSuccessUrl();
$response = RedirectResponse::create($successUrl);
}
} catch (\Exception $e) {
}
}
return $response;
}
作者:badela
项目:theli
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::create()->findOneByEmail($value);
if (null === $customer) {
$context->addViolation(Translator::getInstance()->trans("This email does not exists"));
}
}
作者:vigourouxjulie
项目:theli
/**
* @param $value
* @param ExecutionContextInterface $context
*/
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::getCustomerByEmail($value);
// If there is already a customer for this email address and if the customer is different from the current user, do a violation
if ($customer && $customer->getId() != $this->getRequest()->getSession()->getCustomerUser()->getId()) {
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
}
}
作者:ThomasArnau
项目:ShoppingFlu
/**
* @return Customer
*/
public static function createShoppingFluxCustomer()
{
$shoppingFluxCustomer = CustomerQuery::create()->findOneByRef("ShoppingFlux");
if (null === $shoppingFluxCustomer) {
$shoppingFluxCustomer = new Customer();
$shoppingFluxCustomer->setRef("ShoppingFlux")->setCustomerTitle(CustomerTitleQuery::create()->findOne())->setLastname("ShoppingFlux")->setFirstname("ShoppingFlux")->save();
}
return $shoppingFluxCustomer;
}
作者:marger
项目:theli
/**
* If the user select "I'am a new customer", we make sure is email address does not exit in the database.
*/
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if ($data["account"] == 0) {
$customer = CustomerQuery::create()->findOneByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("A user already exists with this email address. Please login or if you've forgotten your password, go to Reset Your Password."));
}
}
}
作者:vigourouxjulie
项目:theli
public function verifyCurrentPasswordField($value, ExecutionContextInterface $context)
{
/**
* Retrieve the user recording, because after the login action, the password is deleted in the session
*/
$userId = $this->getRequest()->getSession()->getCustomerUser()->getId();
$user = CustomerQuery::create()->findPk($userId);
// Check if value of the old password match the password of the current user
if (!password_verify($value, $user->getPassword())) {
$context->addViolation(Translator::getInstance()->trans("Your current password does not match."));
}
}
作者:marger
项目:theli
public function loadStatsAjaxAction()
{
if (null !== ($response = $this->checkAuth(self::RESOURCE_CODE, array(), AccessManager::VIEW))) {
return $response;
}
$cacheExpire = ConfigQuery::getAdminCacheHomeStatsTTL();
$cacheContent = false;
$month = (int) $this->getRequest()->query->get('month', date('m'));
$year = (int) $this->getRequest()->query->get('year', date('Y'));
if ($cacheExpire) {
$context = "_" . $month . "_" . $year;
$cacheKey = self::STATS_CACHE_KEY . $context;
$cacheDriver = new FilesystemCache($this->getCacheDir());
if (!$this->getRequest()->query->get('flush', "0")) {
$cacheContent = $cacheDriver->fetch($cacheKey);
} else {
$cacheDriver->delete($cacheKey);
}
}
if ($cacheContent === false) {
$data = new \stdClass();
$data->title = $this->getTranslator()->trans("Stats on %month/%year", ['%month' => $month, '%year' => $year]);
/* sales */
$saleSeries = new \stdClass();
$saleSeries->color = self::testHexColor('sales_color', '#adadad');
$saleSeries->data = OrderQuery::getMonthlySaleStats($month, $year);
/* new customers */
$newCustomerSeries = new \stdClass();
$newCustomerSeries->color = self::testHexColor('customers_color', '#f39922');
$newCustomerSeries->data = CustomerQuery::getMonthlyNewCustomersStats($month, $year);
/* orders */
$orderSeries = new \stdClass();
$orderSeries->color = self::testHexColor('orders_color', '#5cb85c');
$orderSeries->data = OrderQuery::getMonthlyOrdersStats($month, $year);
/* first order */
$firstOrderSeries = new \stdClass();
$firstOrderSeries->color = self::testHexColor('first_orders_color', '#5bc0de');
$firstOrderSeries->data = OrderQuery::getFirstOrdersStats($month, $year);
/* cancelled orders */
$cancelledOrderSeries = new \stdClass();
$cancelledOrderSeries->color = self::testHexColor('cancelled_orders_color', '#d9534f');
$cancelledOrderSeries->data = OrderQuery::getMonthlyOrdersStats($month, $year, array(5));
$data->series = array($saleSeries, $newCustomerSeries, $orderSeries, $firstOrderSeries, $cancelledOrderSeries);
$cacheContent = json_encode($data);
if ($cacheExpire) {
$cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
}
}
return $this->jsonResponse($cacheContent);
}
作者:JumBa
项目:ImportT
public function preImport()
{
// Empty address, customer and customer title table
OrderQuery::create()->deleteAll();
AddressQuery::create()->deleteAll();
OrderAddressQuery::create()->deleteAll();
CustomerQuery::create()->deleteAll();
// Also empty url rewriting table
$con = Propel::getConnection(RewritingUrlTableMap::DATABASE_NAME);
$con->exec('SET FOREIGN_KEY_CHECKS=0');
RewritingUrlQuery::create()->deleteAll();
$con->exec('SET FOREIGN_KEY_CHECKS=1');
$this->cust_corresp->reset();
if ($this->thelia_version > 150) {
$this->importCustomerTitle();
}
}
作者:gillesbourgea
项目:CreditAccoun
public function addAmount()
{
if (null !== ($response = $this->checkAuth(array(AdminResources::CUSTOMER), array('CreditAccount'), AccessManager::UPDATE))) {
return $response;
}
$form = new CreditAccountForm($this->getRequest());
try {
$creditForm = $this->validateForm($form);
$customer = CustomerQuery::create()->findPk($creditForm->get('customer_id')->getData());
$event = new CreditAccountEvent($customer, $creditForm->get('amount')->getData());
/** @var Admin $admin */
$admin = $this->getSession()->getAdminUser();
$event->setWhoDidIt($admin->getFirstname() . " " . $admin->getLastname());
$this->dispatch(CreditAccount::CREDIT_ACCOUNT_ADD_AMOUNT, $event);
} catch (\Exception $ex) {
$this->setupFormErrorContext($this->getTranslator()->trans("Add amount to credit account"), $ex->getMessage(), $form, $ex);
}
return $this->generateRedirect($form->getSuccessUrl());
}
作者:badela
项目:theli
protected function getExistingObject()
{
return CustomerQuery::create()->findPk($this->getRequest()->get('customer_id', 0));
}
作者:badela
项目:theli
public function deleteAction($entityId)
{
$query = CustomerQuery::create()->joinOrder()->filterById($entityId)->findOne();
if (null !== $query) {
throw new HttpException(403, json_encode(["error" => sprintf("You can't delete the customer %d as he has orders", $entityId)]));
}
return parent::deleteAction($entityId);
}
作者:shiron
项目:theli
/**
* Checks whether the current state must be recorded as a version
*
* @return boolean
*/
public function isVersioningNecessary($con = null)
{
if ($this->alreadyInSave) {
return false;
}
if ($this->enforceVersion) {
return true;
}
if (ChildCustomerQuery::isVersioningEnabled() && ($this->isNew() || $this->isModified()) || $this->isDeleted()) {
return true;
}
// to avoid infinite loops, emulate in save
$this->alreadyInSave = true;
foreach ($this->getOrders(null, $con) as $relatedObject) {
if ($relatedObject->isVersioningNecessary($con)) {
$this->alreadyInSave = false;
return true;
}
}
$this->alreadyInSave = false;
return false;
}
作者:NandoKstroNe
项目:theli
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected function getCreationEvent($formData)
{
$event = $this->getCreateOrUpdateEvent($formData);
$customer = CustomerQuery::create()->findPk($this->getRequest()->get("customer_id"));
$event->setCustomer($customer);
return $event;
}
作者:marger
项目:theli
/**
* @covers \Thelia\Controller\Api\CustomerController::checkLoginAction
*/
public function testCheckLoginWithWrongPassword()
{
$logins = ['email' => CustomerQuery::create()->findPk(1)->getEmail(), 'password' => 'notthis'];
$requestContent = json_encode($logins);
$client = static::createClient();
$servers = $this->getServerParameters();
$servers['CONTENT_TYPE'] = 'application/json';
$client->request('POST', '/api/customers/checkLogin?&sign=' . $this->getSignParameter($requestContent), [], [], $servers, $requestContent);
$this->assertEquals(404, $client->getResponse()->getStatusCode());
}
作者:marger
项目:theli
function clearTables($con)
{
echo "Clearing tables\n";
$productAssociatedContent = Thelia\Model\ProductAssociatedContentQuery::create()->find($con);
$productAssociatedContent->delete($con);
$categoryAssociatedContent = Thelia\Model\CategoryAssociatedContentQuery::create()->find($con);
$categoryAssociatedContent->delete($con);
$featureProduct = Thelia\Model\FeatureProductQuery::create()->find($con);
$featureProduct->delete($con);
$attributeCombination = Thelia\Model\AttributeCombinationQuery::create()->find($con);
$attributeCombination->delete($con);
$feature = Thelia\Model\FeatureQuery::create()->find($con);
$feature->delete($con);
$feature = Thelia\Model\FeatureI18nQuery::create()->find($con);
$feature->delete($con);
$featureAv = Thelia\Model\FeatureAvQuery::create()->find($con);
$featureAv->delete($con);
$featureAv = Thelia\Model\FeatureAvI18nQuery::create()->find($con);
$featureAv->delete($con);
$attribute = Thelia\Model\AttributeQuery::create()->find($con);
$attribute->delete($con);
$attribute = Thelia\Model\AttributeI18nQuery::create()->find($con);
$attribute->delete($con);
$attributeAv = Thelia\Model\AttributeAvQuery::create()->find($con);
$attributeAv->delete($con);
$attributeAv = Thelia\Model\AttributeAvI18nQuery::create()->find($con);
$attributeAv->delete($con);
$brand = Thelia\Model\BrandQuery::create()->find($con);
$brand->delete($con);
$brand = Thelia\Model\BrandI18nQuery::create()->find($con);
$brand->delete($con);
$category = Thelia\Model\CategoryQuery::create()->find($con);
$category->delete($con);
$category = Thelia\Model\CategoryI18nQuery::create()->find($con);
$category->delete($con);
$product = Thelia\Model\ProductQuery::create()->find($con);
$product->delete($con);
$product = Thelia\Model\ProductI18nQuery::create()->find($con);
$product->delete($con);
$folder = Thelia\Model\FolderQuery::create()->find($con);
$folder->delete($con);
$folder = Thelia\Model\FolderI18nQuery::create()->find($con);
$folder->delete($con);
$content = Thelia\Model\ContentQuery::create()->find($con);
$content->delete($con);
$content = Thelia\Model\ContentI18nQuery::create()->find($con);
$content->delete($con);
$accessory = Thelia\Model\AccessoryQuery::create()->find($con);
$accessory->delete($con);
$stock = \Thelia\Model\ProductSaleElementsQuery::create()->find($con);
$stock->delete($con);
$productPrice = \Thelia\Model\ProductPriceQuery::create()->find($con);
$productPrice->delete($con);
\Thelia\Model\ProductImageQuery::create()->find($con)->delete($con);
$customer = \Thelia\Model\CustomerQuery::create()->find($con);
$customer->delete($con);
$sale = \Thelia\Model\SaleQuery::create()->find($con);
$sale->delete($con);
$saleProduct = \Thelia\Model\SaleProductQuery::create()->find($con);
$saleProduct->delete($con);
echo "Tables cleared with success\n";
}
作者:vigourouxjulie
项目:theli
public static function setUpBeforeClass()
{
CustomerQuery::create()->filterByRef('testRef')->delete();
}