change the way product is created

This commit is contained in:
Manuel Raynaud
2014-03-13 09:56:11 +01:00
parent d8e1f24fda
commit e4ba7d8d11
13 changed files with 259 additions and 107 deletions

View File

@@ -6,14 +6,17 @@ return array(
'%obj modification' => '%obj modification',
'A currency with code "%name" already exists.' => 'A currency with code "%name" already exists.',
'A message with name "%name" already exists.' => 'A message with name "%name" already exists.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.',
'A variable with name "%name" already exists.' => 'A variable with name "%name" already exists.',
'Activate logs only for these IP Addresses' => 'Activate logs only for these IP Addresses',
'Activate logs only for these files' => 'Activate logs only for these files',
'Add to all product templates' => 'Add to all product templates',
'Additional address' => 'Additional address',
'Address ID not found' => 'Address ID not found',
'Address Line 2' => 'Address Line 2',
'Address Line 3' => 'Address Line 3',
'Address label' => 'Address label',
'Administrator ID not found' => 'Administrator ID not found',
'Advertise this product as new' => 'Advertise this product as new',
'Alerts' => 'Alerts',
'Alpha code 2 *' => 'Alpha code 2 *',
@@ -25,6 +28,7 @@ return array(
'Auth mode' => 'Auth mode',
'Available quantity' => 'Available quantity',
'Available quantity *' => 'Available quantity *',
'Bad tax list JSON' => 'Bad tax list JSON',
'Business ID' => 'Business ID',
'Cannot find a default country. Please define one.' => 'Cannot find a default country. Please define one.',
'Cannot find the shop country. Please select a shop country.' => 'Cannot find the shop country. Please select a shop country.',
@@ -41,6 +45,7 @@ return array(
'Constant amount found in one of the product\'s feature' => 'Constant amount found in one of the product\'s feature',
'Content title *' => 'Content title *',
'Country' => 'Country',
'Country ID not found' => 'Country ID not found',
'Country area' => 'Country area',
'Country title *' => 'Country title *',
'Critical' => 'Critical',
@@ -49,6 +54,7 @@ return array(
'Default folder *' => 'Default folder *',
'Default product category *' => 'Default product category *',
'Default product sale element' => 'Default product sale element',
'Delivery module ID not found' => 'Delivery module ID not found',
'Description' => 'Description',
'Detailed description' => 'Detailed description',
'Disabled' => 'Disabled',
@@ -73,6 +79,7 @@ return array(
'ISO 639-1 Code' => 'ISO 639-1 Code',
'ISO Code *' => 'ISO Code *',
'If a translation is missing or incomplete :' => 'If a translation is missing or incomplete :',
'Impossible to delete a customer who already have orders' => 'Impossible to delete a customer who already have orders',
'Information' => 'Information',
'Invalid product_sale_elements' => 'Invalid product_sale_elements',
'Invalid value for walkMode parameter: %value' => 'Invalid value for walkMode parameter: %value',
@@ -88,6 +95,7 @@ return array(
'Message subject' => 'Message subject',
'Meta Description' => 'Meta Description',
'Meta Keywords' => 'Meta Keywords',
'Module ID not found' => 'Module ID not found',
'Name' => 'Name',
'Name *' => 'Name *',
'Name of the HTML layout file' => 'Name of the HTML layout file',
@@ -99,6 +107,7 @@ return array(
'No %obj was updated.' => 'No %obj was updated.',
'No, I am a new customer.' => 'No, I am a new customer.',
'Notices' => 'Notices',
'Order address ID not found' => 'Order address ID not found',
'Page Title' => 'Page Title',
'Parent category *' => 'Parent category *',
'Parent folder *' => 'Parent folder *',
@@ -108,6 +117,7 @@ return array(
'Percentage of the product price' => 'Percentage of the product price',
'Percentage removed from the cart' => 'Percentage removed from the cart',
'Phone' => 'Phone',
'Please accept the Terms and conditions in order to register.' => 'Please accept the Terms and conditions in order to register.',
'Please enter your email address' => 'Please enter your email address',
'Please enter your password' => 'Please enter your password',
'Please specify either \'path\' or \'file\' parameter in {url} function.' => 'Please specify either \'path\' or \'file\' parameter in {url} function.',
@@ -123,6 +133,7 @@ return array(
'Product ID' => 'Product ID',
'Product ID *' => 'Product ID *',
'Product base price excluding taxes *' => 'Product base price excluding taxes *',
'Product base price with taxes' => 'Product base price with taxes',
'Product price excluding taxes' => 'Product price excluding taxes',
'Product price excluding taxes *' => 'Product price excluding taxes *',
'Product price including taxes' => 'Product price including taxes',
@@ -133,6 +144,8 @@ return array(
'ProductSaleElement modification' => 'ProductSaleElement modification',
'Profile' => 'Profile',
'Profile Code' => 'Profile Code',
'Profile ID not found' => 'Profile ID not found',
'Profile `code` already exists' => 'Profile `code` already exists',
'Purpose *' => 'Purpose *',
'Quantity' => 'Quantity',
'Rate from € *' => 'Rate from € *',
@@ -167,20 +180,31 @@ return array(
'Summary' => 'Summary',
'Symbol *' => 'Symbol *',
'System log configuration failed.' => 'System log configuration failed.',
'Tax ID not found in tax list JSON' => 'Tax ID not found in tax list JSON',
'Tax list is not valid JSON' => 'Tax list is not valid JSON',
'Tax rule ID not found' => 'Tax rule ID not found',
'Tax rule for this product *' => 'Tax rule for this product *',
'Template Name *' => 'Template Name *',
'Template file %file cannot be found.' => 'Template file %file cannot be found.',
'Text File' => 'Text File',
'Text Message' => 'Text Message',
'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.',
'This category is online.' => 'This category is online.',
'This content is online.' => 'This content is online.',
'This coupon does not exists' => 'This coupon does not exists',
'This email already exists.' => 'This email already exists.',
'This email does not exists' => 'This email does not exists',
'This extension must be installed and loaded' => 'This extension must be installed and loaded',
'This folder is online.' => 'This folder is online.',
'This login already exists' => 'This login already exists',
'This product is on sale' => 'This product is on sale',
'This product is online' => 'This product is online',
'This product_sale_elements_id does not exists for this product : %d' => 'This product_sale_elements_id does not exists for this product : %d',
'This value should not be blank.' => 'This value should not be blank.',
'Timeout' => 'Timeout',
'Title' => 'Title',
'Title *' => 'Title *',
'Title ID not found' => 'Title ID not found',
'Type' => 'Type',
'Username' => 'Username',
'Username *' => 'Username *',
@@ -190,42 +214,20 @@ return array(
'Weight' => 'Weight',
'Weight *' => 'Weight *',
'Yes, I have a password :' => 'Yes, I have a password :',
'You are already registered!' => 'You are already registered!',
'Your Email Address' => 'Your Email Address',
'Your Message' => 'Your Message',
'Your current password does not match.' => 'Your current password does not match.',
'Zip code' => 'Zip code',
'date format' => 'date format',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'payment module %s is not a Thelia\Module\PaymentModuleInterface',
'language locale' => 'language locale',
'mailing system modification' => 'mailing system modification',
'shipping area name' => 'shipping area name',
'time format' => 'time format',
'This value should not be blank.' => 'This value should not be blank.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.',
'Administrator ID not found' => 'Administrator ID not found',
'This login already exists' => 'This login already exists',
'password confirmation is not the same as password field' => 'password confirmation is not the same as password field',
'password must be composed of at least 4 characters' => 'password must be composed of at least 4 characters',
'this product id does not exists : %d' => 'this product id does not exists : %d',
'This product_sale_elements_id does not exists for this product : %d' => 'This product_sale_elements_id does not exists for this product : %d',
'quantity value is not valid' => 'quantity value is not valid',
'Please accept the Terms and conditions in order to register.' => 'Please accept the Terms and conditions in order to register.',
'This email already exists.' => 'This email already exists.',
'This email does not exists' => 'This email does not exists',
'Your current password does not match.' => 'Your current password does not match.',
'Module ID not found' => 'Module ID not found',
'You are already registered!' => 'You are already registered!',
'Address ID not found' => 'Address ID not found',
'Delivery module ID not found' => 'Delivery module ID not found',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface',
'Order address ID not found' => 'Order address ID not found',
'Title ID not found' => 'Title ID not found',
'Country ID not found' => 'Country ID not found',
'Profile `code` already exists' => 'Profile `code` already exists',
'Profile ID not found' => 'Profile ID not found',
'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.',
'Tax rule ID not found' => 'Tax rule ID not found',
'Tax list is not valid JSON' => 'Tax list is not valid JSON',
'Bad tax list JSON' => 'Bad tax list JSON',
'Tax ID not found in tax list JSON' => 'Tax ID not found in tax list JSON',
'Please check your input: %s' => 'Please check your input: %s',
'Sorry, an error occured: %s' => 'Sorry, an error occured: %s',
'shipping area name' => 'shipping area name',
'this product id does not exists : %d' => 'this product id does not exists : %d',
'time format' => 'time format',
);

View File

@@ -6,14 +6,17 @@ return array(
'%obj modification' => 'Modification de %obj',
'A currency with code "%name" already exists.' => 'Une devise avec la code "%name" existe déjà',
'A message with name "%name" already exists.' => 'Un message avec le nom "%name" existe déjà.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.',
'A variable with name "%name" already exists.' => 'Une variable avec le nom "%name" existe déjà.',
'Activate logs only for these IP Addresses' => 'Activer les logs uniquement pour ces adresses IP',
'Activate logs only for these files' => 'Activer les logs uniquement pour ces fichiers',
'Add to all product templates' => 'Ajouter à tous les templates produit',
'Additional address' => 'Adresse complémentaire',
'Address ID not found' => 'ID de l\'adresse non trouvé',
'Address Line 2' => 'Adresse 1',
'Address Line 3' => 'Adresse 2',
'Address label' => 'Adresse',
'Administrator ID not found' => 'ID de l\'administrateur not trouvé',
'Advertise this product as new' => 'Afficher ce produit comme nouveau',
'Alerts' => 'Alertes',
'Alpha code 2 *' => 'Code Alpha 2 *',
@@ -25,6 +28,7 @@ return array(
'Auth mode' => 'Mode d\'authentification',
'Available quantity' => 'Quantité disponible',
'Available quantity *' => 'Quantité disponible *',
'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes',
'Business ID' => 'ID du business',
'Cannot find a default country. Please define one.' => 'Impossible de trouver un pays par défaut. Veuillez en définir un.',
'Cannot find the shop country. Please select a shop country.' => 'Impossible de trouver le pays du magasin. Veuillez en sélectionner un.',
@@ -41,6 +45,7 @@ return array(
'Constant amount found in one of the product\'s feature' => 'Montant fixe trouvé depuis une caractéristique produit',
'Content title *' => 'Titre du contenu *',
'Country' => 'Pays',
'Country ID not found' => 'ID du pays non trouvé',
'Country area' => 'Zone du pays',
'Country title *' => 'Pays *',
'Critical' => 'Critique',
@@ -49,6 +54,7 @@ return array(
'Default folder *' => 'Dossier par défaut *',
'Default product category *' => 'Catégorie du produit par défaut *',
'Default product sale element' => 'Product Sale Element par défaut',
'Delivery module ID not found' => 'Id du module de livraison non trouvé',
'Description' => 'Description',
'Detailed description' => 'Description détaillée',
'Disabled' => 'Désactivé',
@@ -73,6 +79,7 @@ return array(
'ISO 639-1 Code' => 'Code ISO 639-1',
'ISO Code *' => 'Code ISO *',
'If a translation is missing or incomplete :' => 'Si une traduction est manquante ou incomplète :',
'Impossible to delete a customer who already have orders' => 'Impossible de supprimer un client si celui-ci a déjà une commande',
'Information' => 'Information',
'Invalid product_sale_elements' => 'product_sale_elements invalide',
'Invalid value for walkMode parameter: %value' => 'Valeur incorrecte pour le paramètre walkMode : %value',
@@ -88,6 +95,7 @@ return array(
'Message subject' => 'Sujet',
'Meta Description' => 'Meta description',
'Meta Keywords' => 'Meta keywords',
'Module ID not found' => 'Id du module non trouvé',
'Name' => 'Nom',
'Name *' => 'Nom *',
'Name of the HTML layout file' => 'Nom du layout HTML',
@@ -99,6 +107,7 @@ return array(
'No %obj was updated.' => 'Aucun %obj mis à jour',
'No, I am a new customer.' => 'Non, je suis un nouveau client.',
'Notices' => 'Notices',
'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé',
'Page Title' => 'Titre de la page',
'Parent category *' => 'Catégorie parente *',
'Parent folder *' => 'Dossier parent *',
@@ -108,6 +117,7 @@ return array(
'Percentage of the product price' => 'Pourcentage du prix du produit',
'Percentage removed from the cart' => 'Pourcentage déduit du panier',
'Phone' => 'Téléphone',
'Please accept the Terms and conditions in order to register.' => 'Veuillez accepter les termes et conditions pour vous inscrire.',
'Please enter your email address' => 'Renseignez votre adresse mail',
'Please enter your password' => 'Entrez votre mot de passe.',
'Please specify either \'path\' or \'file\' parameter in {url} function.' => 'Veuillez spécifier soit le paramètre \'chemin\' ou \'fichier\' dans la fonction {url}',
@@ -123,6 +133,7 @@ return array(
'Product ID' => 'ID produit',
'Product ID *' => 'ID produit *',
'Product base price excluding taxes *' => 'Prix du produit Hors Taxe *',
'Product base price with taxes' => 'Prix du produit TTC',
'Product price excluding taxes' => 'Prix du produit Hors Taxes',
'Product price excluding taxes *' => 'prix HT',
'Product price including taxes' => 'Prix du produit taxes incluses',
@@ -133,6 +144,8 @@ return array(
'ProductSaleElement modification' => 'Modification de ProductSaleElement.',
'Profile' => 'Profil',
'Profile Code' => 'Profil',
'Profile ID not found' => 'ID du profil non trouvé',
'Profile `code` already exists' => 'Le `code` du profil existe déjà',
'Purpose *' => 'Objet',
'Rate from € *' => 'Taux à partie de l\'€ *',
'Redirecting ...' => 'Redirection ...',
@@ -166,20 +179,31 @@ return array(
'Summary' => 'Résumé',
'Symbol *' => 'Symbole *',
'System log configuration failed.' => 'Erreur du configurateur de log system.',
'Tax ID not found in tax list JSON' => 'ID de la taxe non trouvé dans le JSON de la liste des taxes',
'Tax list is not valid JSON' => 'Le JSON de la liste des taxes n\'est pas valide',
'Tax rule ID not found' => 'ID de la règle de taxe non trouvé',
'Tax rule for this product *' => 'Règle de taxe pour ce produit *',
'Template Name *' => 'Nom du template *',
'Template file %file cannot be found.' => 'Le fichier %file n\'a pas été trouvé dans le template. ',
'Text File' => 'Fichier texte',
'Text Message' => 'Message au format texte',
'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.',
'This category is online.' => 'Cette catégorie est en ligne.',
'This content is online.' => 'Ce contenu est en ligne.',
'This coupon does not exists' => 'Ce code promo n\'existe pas',
'This email already exists.' => 'Cette adresse email existe déjà',
'This email does not exists' => 'Cette adresse email n\'existe pas',
'This extension must be installed and loaded' => 'Cette extension doit être installée et chargée.',
'This folder is online.' => 'Ce dossier est en ligne.',
'This login already exists' => 'Cet identifiant existe déjà',
'This product is on sale' => 'Ce produit est en promo',
'This product is online' => 'Ce produit est en ligne',
'This product_sale_elements_id does not exists for this product : %d' => 'Le product_sale_elements_id n\'existe pas pour ce produit : %d',
'This value should not be blank.' => 'Cette valeur ne doit pas être vide.',
'Timeout' => 'Délai d\'attente expiré',
'Title' => 'Titre',
'Title *' => 'Titre *',
'Title ID not found' => 'ID de la civilité non trouvé',
'Type' => 'Type',
'Username' => 'Nom d\'utilisateur',
'Username *' => 'Nom d\'utilisateur *',
@@ -189,42 +213,20 @@ return array(
'Weight' => 'Poids',
'Weight *' => 'Poids *',
'Yes, I have a password :' => 'Oui, j\'ai un mot de passe :',
'You are already registered!' => 'Vous êtes déjà enregistré !',
'Your Email Address' => 'Votre adresse mail',
'Your Message' => 'Votre message',
'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas',
'Zip code' => 'Code postal',
'date format' => 'Format de date',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface',
'language locale' => 'Langue locale',
'mailing system modification' => 'Modification du système d\'envoi de mail.',
'shipping area name' => 'Nom de la zone de livraison',
'time format' => 'Format d\'heure',
'This value should not be blank.' => 'Cette valeur ne doit pas être vide.',
'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.',
'Administrator ID not found' => 'ID de l\'administrateur not trouvé',
'This login already exists' => 'Cet identifiant existe déjà',
'password confirmation is not the same as password field' => 'le mot de passe de confirmation n\'est pas le même que le champ mot de passe',
'password must be composed of at least 4 characters' => 'le mot de passe doit être composé d\'au moins 4 caractères',
'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas',
'This product_sale_elements_id does not exists for this product : %d' => 'Le product_sale_elements_id n\'existe pas pour ce produit : %d',
'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'Le module de paiement %s n\'est pas une instance de Thelia\Module\PaymentModuleInterface ',
'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide',
'Please accept the Terms and conditions in order to register.' => 'Veuillez accepter les termes et conditions pour vous inscrire.',
'This email already exists.' => 'Cette adresse email existe déjà',
'This email does not exists' => 'Cette adresse email n\'existe pas',
'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas',
'Module ID not found' => 'Id du module non trouvé',
'You are already registered!' => 'Vous êtes déjà enregistré !',
'Address ID not found' => 'ID de l\'adresse non trouvé',
'Delivery module ID not found' => 'Id du module de livraison non trouvé',
'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface',
'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé',
'Title ID not found' => 'ID de la civilité non trouvé',
'Country ID not found' => 'ID du pays non trouvé',
'Profile `code` already exists' => 'Le `code` du profil existe déjà',
'Profile ID not found' => 'ID du profil non trouvé',
'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.',
'Tax rule ID not found' => 'ID de la règle de taxe non trouvé',
'Tax list is not valid JSON' => 'Le JSON de la liste des taxes n\'est pas valide',
'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes',
'Tax ID not found in tax list JSON' => 'ID de la taxe non trouvé dans le JSON de la liste des taxes',
'Please check your input: %s' => 'Veuillez vérifier votre saisie: %s',
'Sorry, an error occured: %s' => 'Désolé, une erreur est survenue: %s',
'shipping area name' => 'Nom de la zone de livraison',
'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas',
'time format' => 'Format d\'heure',
);

View File

@@ -340,6 +340,10 @@
<default key="_controller">Thelia\Controller\Admin\ProductController::priceCaclulator</default>
</route>
<route id="admin.product.calculate-raw-price" path="/admin/product/calculate-raw-price">
<default key="_controller">Thelia\Controller\Admin\ProductController::calculatePrice</default>
</route>
<route id="admin.product.load-converted-prices" path="/admin/product/load-converted-prices">
<default key="_controller">Thelia\Controller\Admin\ProductController::loadConvertedPrices</default>
</route>

View File

@@ -73,6 +73,7 @@ use Thelia\Form\ProductSaleElementUpdateForm;
use Thelia\Form\ProductDefaultSaleElementUpdateForm;
use Thelia\Form\ProductCombinationGenerationForm;
use Thelia\Model\TaxRuleQuery;
use Thelia\TaxEngine\Calculator;
use Thelia\Tools\NumberFormat;
@@ -1155,10 +1156,10 @@ class ProductController extends AbstractSeoCrudController
{
$return_price = 0;
$price = floatval($this->getRequest()->get('price', 0));
$product_id = intval($this->getRequest()->get('product_id', 0));
$action = $this->getRequest()->get('action', ''); // With ot without tax
$convert = intval($this->getRequest()->get('convert_from_default_currency', 0));
$price = floatval($this->getRequest()->query->get('price', 0));
$product_id = intval($this->getRequest()->query->get('product_id', 0));
$action = $this->getRequest()->query->get('action', ''); // With ot without tax
$convert = intval($this->getRequest()->query->get('convert_from_default_currency', 0));
if (null !== $product = ProductQuery::create()->findPk($product_id)) {
@@ -1171,7 +1172,46 @@ class ProductController extends AbstractSeoCrudController
}
if ($convert != 0) {
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
$return_price = $price * Currency::getDefaultCurrency()->getRate();
}
}
return new JsonResponse(array('result' => $return_price));
}
/**
*
* Calculate tax or untax price for a non existing product.
*
* For an existing product, use self::priceCaclulator
*
* @return JsonResponse
*/
public function calculatePrice()
{
$return_price = 0;
$price = floatval($this->getRequest()->query->get('price'));
$tax_rule_id = intval($this->getRequest()->query->get('tax_rule'));
$action = $this->getRequest()->query->get('action'); // With ot without tax
$taxRule = TaxRuleQuery::create()->findPk($tax_rule_id);
if (null !== $price && null !== $taxRule) {
$calculator = new Calculator();
$calculator->loadTaxRuleWithoutProduct(
$taxRule,
Country::getShopLocation()
);
if ($action == 'to_tax') {
$return_price = $calculator->getTaxedPrice($price);
} elseif ($action == 'from_tax') {
$return_price = $calculator->getUntaxedPrice($price);
} else {
$return_price = $price;
}
}
@@ -1251,7 +1291,7 @@ class ProductController extends AbstractSeoCrudController
}
if ($convert != 0) {
$return_price = $prix * Currency::getDefaultCurrency()->getRate();
$return_price = $price * Currency::getDefaultCurrency()->getRate();
}
// Format the number using '.', to perform further calculation

View File

@@ -88,7 +88,7 @@ class OrderPayment extends BaseForm
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
$context->addViolation(
sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode())
sprintf(Translator::getInstance()->trans("payment module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode())
);
}
}

View File

@@ -70,7 +70,11 @@ class ProductCreationForm extends BaseForm
->add("price", "number", array(
"constraints" => array(new NotBlank()),
"label" => Translator::getInstance()->trans("Product base price excluding taxes *"),
"label_attr" => array("for" => "price_field")
"label_attr" => array("for" => "price_without_tax")
))
->add("tax_price", "number", array(
"label" => Translator::getInstance()->trans("Product base price with taxes"),
"label_attr" => array("for" => "price_with_tax")
))
->add("currency", "integer", array(
"constraints" => array(new NotBlank()),
@@ -83,7 +87,7 @@ class ProductCreationForm extends BaseForm
"label_attr" => array("for" => "tax_rule_field")
))
->add("weight", "number", array(
"label" => Translator::getInstance()->trans("Weight *"),
"label" => Translator::getInstance()->trans("Weight"),
"label_attr" => array("for" => "weight_field")
))
;

View File

@@ -100,6 +100,27 @@ class Calculator
return $this;
}
public function loadTaxRuleWithoutProduct(TaxRule $taxRule, Country $country)
{
$this->product = null;
$this->country = null;
$this->taxRulesCollection = null;
if ($taxRule->getId() === null) {
throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE);
}
if ($country->getId() === null) {
throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY);
}
$this->country = $country;
$this->product = new Product();
$this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country);
return $this;
}
public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null)
{
return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice;

View File

@@ -47,6 +47,7 @@ class FeatureFixAmountTaxType extends BaseTaxType
public function fixAmountRetriever(Product $product)
{
$taxAmount = 0;
$featureId = $this->getRequirement("feature");
$query = FeatureProductQuery::create()
@@ -54,6 +55,7 @@ class FeatureFixAmountTaxType extends BaseTaxType
->filterByFeatureId($featureId)
->findOne();
if (null !== $query) {
$taxAmount = $query->getFreeTextValue();
$testInt = new FloatType();
@@ -64,6 +66,8 @@ class FeatureFixAmountTaxType extends BaseTaxType
);
}
}
return $taxAmount;
}

13
templates/backOffice/default/I18n/en_US.php Executable file → Normal file
View File

@@ -6,6 +6,9 @@ return array(
'(edit)' => '(edit)',
'<a href="http://en.wikipedia.org/wiki/ISO_639-1_language_matrix" target="_other">Check the list</a> of ISO 639-1 codes' => '<a href="http://en.wikipedia.org/wiki/ISO_639-1_language_matrix" target="_other">Check the list</a> of ISO 639-1 codes',
'<span id="number_of_generated_combinations">0</span> combinations' => '<span id="number_of_generated_combinations">0</span> combinations',
'<strong>Cannot translate all fields.</strong> According to your PHP configuration, forms cannot contains more than
%current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration
of change the translation file by hand.' => '<strong>Cannot translate all fields.</strong> According to your PHP configuration, forms cannot contains more than %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration of change the translation file by hand.',
'<strong>Congratulations</strong>, all text is now translated !' => '<strong>Congratulations</strong>, all text is now translated !',
'<strong>Did not found any text to translate</strong>. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.' => '<strong>Did not found any text to translate</strong>. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.',
'A content could be attached to more than one folder. Select here the additional folders for this content.' => 'A content could be attached to more than one folder. Select here the additional folders for this content.',
@@ -70,7 +73,6 @@ return array(
'Back-office home' => 'Back-office home',
'Back-office templates' => 'Back-office templates',
'Back-office users' => 'Back-office users',
'Browse' => 'Browse',
'Browse files' => 'Browse files',
'Browse this category' => 'Browse this category',
'Browse this folder' => 'Browse this folder',
@@ -122,7 +124,6 @@ return array(
'Combination builder' => 'Combination builder',
'Combination reference' => 'Combination reference',
'Company' => 'Company',
'Condition type :' => 'Condition type :',
'Condition\'s category :' => 'Condition\'s category :',
'Conditions' => 'Conditions',
'Configuration' => 'Configuration',
@@ -142,7 +143,6 @@ return array(
'Country short description' => 'Country short description',
'Country title' => 'Country title',
'Coupon' => 'Coupon',
'Coupon : ' => 'Coupon : ',
'Coupon code' => 'Coupon code',
'Coupons' => 'Coupons',
'Coupons : ' => 'Coupons : ',
@@ -324,6 +324,7 @@ return array(
'EAN Code' => 'EAN Code',
'Ecotax is a tax wich add a defined amount (throug a product feature) to the product price.' => 'Ecotax is a tax wich add a defined amount (throug a product feature) to the product price.',
'Edit' => 'Edit',
'Edit %title' => 'Edit %title',
'Edit a country' => 'Edit a country',
'Edit a currency' => 'Edit a currency',
'Edit a customer' => 'Edit a customer',
@@ -424,6 +425,7 @@ return array(
'Enter here the product name in the default language (%title)' => 'Enter here the product name in the default language (%title)',
'Enter here the product price in the default currency (%title)' => 'Enter here the product price in the default currency (%title)',
'Enter here the product reference' => 'Enter here the product reference',
'Enter here the product tax price in the default currency (%title)' => 'Enter here the product tax price in the default currency (%title)',
'Enter here the product weight, in Kilogrammes' => 'Enter here the product weight, in Kilogrammes',
'Enter here the template name in the default language (%title)' => 'Enter here the template name in the default language (%title)',
'Enter here the value in the current edit language (%language_name)' => 'Enter here the value in the current edit language (%language_name)',
@@ -457,7 +459,6 @@ return array(
'Features' => 'Features',
'File' => 'File',
'File names' => 'File names',
'Files manager' => 'Files manager',
'First Name' => 'First Name',
'First name' => 'First name',
'First orders' => 'First orders',
@@ -524,7 +525,6 @@ return array(
'Latest version available' => 'Latest version available',
'Leave empty to keep current password' => 'Leave empty to keep current password',
'Lire la suite' => 'Lire la suite',
'List' => 'List',
'Loading Thelia lastest news...' => 'Loading Thelia lastest news...',
'Locale' => 'Locale',
'Log lines format' => 'Log lines format',
@@ -578,7 +578,6 @@ return array(
'Online' => 'Online',
'Online products' => 'Online products',
'Oops! An Error Occurred' => 'Oops! An Error Occurred',
'Or' => 'Or',
'Order #' => 'Order #',
'Order %ref' => 'Order %ref',
'Order n°' => 'Order n°',
@@ -644,6 +643,7 @@ return array(
'Product features' => 'Product features',
'Product price' => 'Product price',
'Product price including taxes' => 'Product price including taxes',
'Product tax price' => 'Product tax price',
'Product templates' => 'Product templates',
'Product title' => 'Product title',
'Product weight' => 'Product weight',
@@ -814,6 +814,7 @@ return array(
'Thelia support forum' => 'Thelia support forum',
'Thelia system variables' => 'Thelia system variables',
'Thelia, the open source e-commerce solution' => 'Thelia, the open source e-commerce solution',
'There is currently no active module here.' => 'There is currently no active module here.',
'There is no documents attached to this %type.' => 'There is no documents attached to this %type.',
'There is no images attached to this %type.' => 'There is no images attached to this %type.',
'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.' => 'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.',

14
templates/backOffice/default/I18n/fr_FR.php Executable file → Normal file
View File

@@ -6,6 +6,9 @@ return array(
'(edit)' => '(modification)',
'<a href="http://en.wikipedia.org/wiki/ISO_639-1_language_matrix" target="_other">Check the list</a> of ISO 639-1 codes' => '<a href="http://en.wikipedia.org/wiki/ISO_639-1_language_matrix" target="_other">Consulter la liste</a> des codes ISO 639-1',
'<span id="number_of_generated_combinations">0</span> combinations' => '<span id="number_of_generated_combinations">0</span> combinaisons',
'<strong>Cannot translate all fields.</strong> According to your PHP configuration, forms cannot contains more than
%current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration
of change the translation file by hand.' => '<strong>Cannot translate all fields.</strong> According to your PHP configuration, forms cannot contains more than %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration of change the translation file by hand.',
'<strong>Congratulations</strong>, all text is now translated !' => '<strong>Félicitations</strong>, Toute la traduction a été effectué',
'<strong>Did not found any text to translate</strong>. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.' => '<streong>Aucun texte à traduire</strong>. C\'est probablement normal. Si ce n\'est pas le cas vérifiez que vous utilisez bien la fonction Smarty "intl" ou bien le translator Translator::trans dans un fichier php',
'A content could be attached to more than one folder. Select here the additional folders for this content.' => 'Un contenu peut être rattaché à plusieurs dossiers. Sélectionnez ici les dossiers dans lesquels ce contenu apparaîtra',
@@ -70,7 +73,6 @@ return array(
'Back-office home' => 'Accueil administration',
'Back-office templates' => 'templates Back-office',
'Back-office users' => 'Utilisateur du B.O',
'Browse' => 'Parcourir',
'Browse files' => 'Parcourir les fichiers',
'Browse this category' => 'Parcourir cette catégorie',
'Browse this folder' => 'Parcourir ce dossier',
@@ -122,7 +124,6 @@ return array(
'Combination builder' => 'générateur de combinaison',
'Combination reference' => 'Référence de la combinaison',
'Company' => 'Entreprise',
'Condition type :' => 'Type de condition',
'Condition\'s category :' => 'Rubrique de la condition',
'Conditions' => 'Conditions',
'Configuration' => 'Configuration',
@@ -142,7 +143,6 @@ return array(
'Country short description' => 'Courte description du pays',
'Country title' => 'Titre du pays',
'Coupon' => 'Code promo',
'Coupon : ' => 'Code promo :',
'Coupon code' => 'Code promo',
'Coupons' => 'Codes Promo',
'Coupons : ' => 'Codes promo : ',
@@ -324,6 +324,7 @@ return array(
'EAN Code' => 'Code EAN',
'Ecotax is a tax wich add a defined amount (throug a product feature) to the product price.' => 'L\'écotaxe est une taxe qui ajoute un montant défini (grâce à une caractéristique produit) au prix du produit.',
'Edit' => 'Editer',
'Edit %title' => 'Modifier %title',
'Edit a country' => 'Modifier un pays',
'Edit a currency' => 'Modifier une devise',
'Edit a customer' => 'Éditer un client',
@@ -420,9 +421,11 @@ return array(
'Enter here the feature name in the default language (%title)' => 'Renseigner le nom de la caractéristique dans la langue par défaut (%title)',
'Enter here the feature value as free text' => 'Indiquez ici la valeur de la caractéristique',
'Enter here the folder name in the default language (%title)' => 'Entrez ici le nom du dossier dans la langue par défaut (%title)',
'Enter here the mailing template purpose in the default language (%title)' => 'Renseigner l\'objet du mail dans la langue par défaut (%title)',
'Enter here the product name in the default language (%title)' => 'Entrez ici le nom du produit dans la langue par défaut (%title)',
'Enter here the product price in the default currency (%title)' => 'entrez ici le prix du produit dans la langue par défaut (%title)',
'Enter here the product reference' => 'Entrez ici la nouvelle référence produit',
'Enter here the product tax price in the default currency (%title)' => 'Renseignez le prox TTC dans la devise par défaut (%title)',
'Enter here the product weight, in Kilogrammes' => 'Entrez ici le poids du produit, en Kilogrammes',
'Enter here the template name in the default language (%title)' => 'Renseignez le nom du template dans la langue par défaut (%title)',
'Enter here the value in the current edit language (%language_name)' => 'Rensignez la valeur dans la langue d\'édition actuelle (%language_name)',
@@ -456,7 +459,6 @@ return array(
'Features' => 'Caractéristiques',
'File' => 'Fichier',
'File names' => 'Nom du fichier',
'Files manager' => 'Gestionnaire de fichiers',
'First Name' => 'Prénom',
'First name' => 'Prénom',
'First orders' => 'Premières commandes',
@@ -523,7 +525,6 @@ return array(
'Latest version available' => 'Dernière version disponible',
'Leave empty to keep current password' => 'Laisser ce champ vide pour ne pas modifier le mot de passe',
'Lire la suite' => 'Lire la suite',
'List' => 'Liste',
'Loading Thelia lastest news...' => 'Chargement des dernières information Thelia...',
'Locale' => 'Paramètre régional',
'Log lines format' => 'Format d\'une ligne de log',
@@ -577,7 +578,6 @@ return array(
'Online' => 'En ligne',
'Online products' => 'Produits en ligne',
'Oops! An Error Occurred' => 'Oops ! Une erreur est survenue',
'Or' => 'Ou',
'Order #' => 'Commande #',
'Order %ref' => 'Commande %ref',
'Order n°' => 'Commande n°',
@@ -643,6 +643,7 @@ return array(
'Product features' => 'Caractéristiques produit',
'Product price' => 'Prix du produit',
'Product price including taxes' => 'Prix du produit taxes incluses',
'Product tax price' => 'prix TTC',
'Product templates' => 'Template produit',
'Product title' => 'Titre du produit',
'Product weight' => 'Poids du produit',
@@ -812,6 +813,7 @@ return array(
'Thelia support forum' => 'Forum de Thelia',
'Thelia system variables' => 'Variables Thelia',
'Thelia, the open source e-commerce solution' => 'Thelia, la solution e-commerce libre',
'There is currently no active module here.' => 'Il n\'y a aucun module actif ici',
'There is no documents attached to this %type.' => 'Il n\'y a aucun document lié à ce %type.',
'There is no images attached to this %type.' => 'Il n\'y a pas d\'image liée à ce %type.',
'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.' => 'Cet administrateur est lié avec un ou plusieurs autres administrateurs. Supprimez ou modifiez ces administrateurs d\'abord.',

View File

@@ -472,29 +472,7 @@
</div>
{/form_field}
{form_field form=$form field='price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="currency" name="default-currency" default_only="1" backend_context="1"}
<div class="row">
<div class="col-lg-4">
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="col-lg-2 form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
<span class="input-group-addon">{$SYMBOL}</span>
</div>
</div>
</div>
<div class="help-block">{intl l='Enter here the product price in the default currency (%title)' title=$NAME}</div>
{form_field form=$form field='currency'}
<input type="hidden" name="{$name}" value="{$ID}" />
{/form_field}
{/loop}
</div>
{/form_field}
{form_field form=$form field='tax_rule'}
<div class="form-group {if $error}has-error{/if}">
@@ -513,6 +491,49 @@
</div>
{/form_field}
{form_field form=$form field='price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="currency" name="default-currency" default_only="1" backend_context="1"}
<div class="row">
<div class="col-lg-4">
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="col-lg-2 form-control automatic_price_field" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}" data-price-type="price-without-tax" data-rel-price="price_with_tax">
<span class="input-group-addon">{$SYMBOL}</span>
</div>
</div>
</div>
<div class="help-block">{intl l='Enter here the product price in the default currency (%title)' title=$NAME}</div>
{form_field form=$form field='currency'}
<input type="hidden" name="{$name}" value="{$ID}" />
{/form_field}
{/loop}
</div>
{/form_field}
{form_field form=$form field='tax_price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{loop type="currency" name="default-currency" default_only="1" backend_context="1"}
<div class="row">
<div class="col-lg-4">
<div class="input-group">
<input type="text" id="{$label_attr.for}" name="{$name}" class="col-lg-2 form-control automatic_price_field" value="{$value}" title="{$label}" placeholder="{intl l='Product tax price'}" data-price-type="price-with-tax" data-rel-price="price_without_tax">
<span class="input-group-addon">{$SYMBOL}</span>
</div>
</div>
</div>
<div class="help-block">{intl l='Enter here the product tax price in the default currency (%title)' title=$NAME}</div>
{/loop}
</div>
{/form_field}
{form_field form=$form field='weight'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
@@ -611,7 +632,9 @@
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/jquery.typewatch.js'}
<script src="{$asset_url}"></script>
{/javascripts}
<script>
$(function() {
@@ -713,6 +736,49 @@
location.href = url;
});
function update_price(price, price_type, dest_field_id) {
var tax_rule_id = $('#tax_rule_field').val();
if (tax_rule_id != "") {
var operation;
if (price_type.indexOf('with-tax') != -1)
operation = 'from_tax';
else if (price_type.indexOf('without-tax') != -1)
operation = 'to_tax';
else
operation = '';
$.ajax({
url : '{url path="/admin/product/calculate-raw-price"}',
data : {
price : price,
action : operation,
tax_rule : tax_rule_id
},
type : 'get',
dataType : 'json',
success : function(json) {
$('#' + dest_field_id).val(json.result);
},
error : function(jqXHR, textStatus, errorThrown) {
alert("{intl l='Failed to get prices. Please try again.'} (" +errorThrown+ ")");
}
});
}
}
// Automatic update of price fields: any change in the taxed (resp. untaxed) price
// will update the untaxed (resp. taxed) one
$('.automatic_price_field').typeWatch({
captureLength: 1,
wait : 300,
callback : function () {
update_price($(this).val(), $(this).data('price-type'), $(this).data('rel-price'));
}
});
});
</script>
{/block}

3
templates/frontOffice/default/I18n/en_US.php Executable file → Normal file
View File

@@ -7,6 +7,7 @@ return array(
'+ View All' => '+ View All',
'404' => '404',
'<strong>Sorry!</strong> We are not able to give you a delivery method for your order.' => '<strong>Sorry!</strong> We are not able to give you a delivery method for your order.',
'A problem occured' => 'A problem occured',
'A summary of your order email has been sent to the following address' => 'A summary of your order email has been sent to the following address',
'Account' => 'Account',
'Add a new address' => 'Add a new address',
@@ -129,6 +130,7 @@ return array(
'Placeholder phone' => 'Phone number',
'Placeholder zipcode' => 'NY 10011',
'Please enter your email address below.' => 'Please enter your email address below.',
'Please try again to order' => 'Please try again to order',
'Position' => 'Position',
'Previous' => 'Previous',
'Previous product' => 'Previous product',
@@ -150,6 +152,7 @@ return array(
'Questions ? See our F.A.Q.' => 'Questions ? See our F.A.Q.',
'RSS' => 'RSS',
'Rating' => 'Rating',
'Redirect to bank service' => 'Redirect to bank service',
'Ref.' => 'Ref.',
'Register' => 'Register',
'Register!' => 'Register!',

3
templates/frontOffice/default/I18n/fr_FR.php Executable file → Normal file
View File

@@ -7,6 +7,7 @@ return array(
'+ View All' => '+ Voir tout',
'404' => '404',
'<strong>Sorry!</strong> We are not able to give you a delivery method for your order.' => '<strong>Désolé !</strong>Nous ne pouvons pas trouver de mode de livraison pour votre commande.',
'A problem occured' => 'Un problème est survenu',
'A summary of your order email has been sent to the following address' => 'Un récapitulatif de commande vows a été envoyé par e-mail à l\'adresse suivante : ',
'Account' => 'Mon compte',
'Add a new address' => 'Ajouter une nouvelle adresse',
@@ -129,6 +130,7 @@ return array(
'Placeholder phone' => 'Téléphone',
'Placeholder zipcode' => 'Code postal',
'Please enter your email address below.' => 'Veuillez saisir votre adresse e-mail ci-dessous.',
'Please try again to order' => 'Merci de réessayer',
'Position' => 'Position',
'Previous' => 'Précédent',
'Previous product' => 'Produit précédent.',
@@ -145,6 +147,7 @@ return array(
'Questions ? See our F.A.Q.' => 'Questions ? Voir notre FAQ',
'RSS' => 'RSS',
'Rating' => 'Avis',
'Redirect to bank service' => 'Redirection vers le service bancaire',
'Ref.' => 'Ref.',
'Register' => 'S\'inscrire',
'Register!' => 'Enregistrez-vous !',