@@ -74,7 +74,7 @@ return [ | |||
], | |||
], | |||
'view' => [ | |||
'class' => 'common\components\MyView', | |||
'class' => 'common\components\ViewBackend', | |||
], | |||
], | |||
'params' => $params, |
@@ -91,7 +91,8 @@ class CronController extends BackendController | |||
public function actionInitDemo($key = '') | |||
{ | |||
if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') { | |||
$producer = Producer::getDemoAccount(); | |||
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | |||
$producer = $producerRepository->getOneDemoAccount(); | |||
if ($producer) { | |||
// initialisation de la distribution à J+7 |
@@ -38,7 +38,7 @@ termes. | |||
namespace common\components ; | |||
class MyView extends \yii\web\View | |||
class View extends \yii\web\View | |||
{ | |||
var $title ; | |||
var $page_title ; | |||
@@ -92,4 +92,19 @@ class MyView extends \yii\web\View | |||
'content' => $content | |||
]); | |||
} | |||
public function getUrlManagerFrontend() | |||
{ | |||
return Yii::$app->urlManagerFrontend; | |||
} | |||
public function getUrlManagerProducer() | |||
{ | |||
return Yii::$app->urlManagerProducer; | |||
} | |||
public function getUrlManagerBackend() | |||
{ | |||
return Yii::$app->urlManagerBackend; | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
<?php | |||
namespace common\components; | |||
class ViewBackend extends View | |||
{ | |||
public function getUrlManager() | |||
{ | |||
return $this->getUrlManagerBackend(); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
<?php | |||
namespace common\components; | |||
class ViewFrontend extends View | |||
{ | |||
public function getUrlManager() | |||
{ | |||
return $this->getUrlManagerFrontend(); | |||
} | |||
} |
@@ -56,6 +56,31 @@ class CommonController extends \yii\web\Controller | |||
return Yii::$app->logic; | |||
} | |||
public function getUrlManagerProducer() | |||
{ | |||
return Yii::$app->urlManagerProducer; | |||
} | |||
public function getUrlManagerFrontend() | |||
{ | |||
return Yii::$app->urlManagerFrontend; | |||
} | |||
public function getUrlManagerBackend() | |||
{ | |||
return Yii::$app->urlManagerBackend; | |||
} | |||
public function getUser() | |||
{ | |||
return Yii::$app->getUser(); | |||
} | |||
public function getRequest() | |||
{ | |||
return Yii::$app->request; | |||
} | |||
public function setFlash($key, $value = true, $removeAfterAccess = true) | |||
{ | |||
Yii::$app->session->setFlash($key, $value, $removeAfterAccess); |
@@ -78,9 +78,9 @@ class Producer extends ActiveRecordCommon | |||
. '</ul>'; | |||
public static $creditFunctioningArray = [ | |||
self::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||
self::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||
self::CREDIT_FUNCTIONING_USER => 'Basée sur l\'utilisateur', | |||
self::CREDIT_FUNCTIONING_MANDATORY => 'Obligatoire', | |||
self::CREDIT_FUNCTIONING_OPTIONAL => 'Optionnelle', | |||
self::CREDIT_FUNCTIONING_USER => 'Basée sur l\'utilisateur', | |||
]; | |||
const BEHAVIOR_DELETE_ORDER_DELETE = 'delete'; | |||
@@ -134,174 +134,174 @@ class Producer extends ActiveRecordCommon | |||
public function rules() | |||
{ | |||
return [ | |||
[['name', 'type', 'id_tax_rate_default'], 'required'], | |||
[ | |||
['tiller_provider_token', 'tiller_restaurant_token'], | |||
'required', | |||
'when' => function ($model) { | |||
return $model->tiller == true; | |||
} | |||
], | |||
[ | |||
[ | |||
'order_delay', | |||
'order_deadline', | |||
'order_delay_monday', | |||
'order_deadline_monday', | |||
'order_delay_tuesday', | |||
'order_deadline_tuesday', | |||
'order_delay_wednesday', | |||
'order_deadline_wednesday', | |||
'order_delay_thursday', | |||
'order_deadline_thursday', | |||
'order_delay_friday', | |||
'order_deadline_friday', | |||
'order_delay_saturday', | |||
'order_deadline_saturday', | |||
'order_delay_sunday', | |||
'order_deadline_sunday', | |||
'id_tax_rate_default', | |||
'document_quotation_duration', | |||
'option_dashboard_number_distributions', | |||
'option_online_payment_minimum_amount', | |||
'option_document_price_decimals', | |||
'option_billing_reduction_percentage', | |||
'option_billing_permanent_transfer_amount', | |||
], | |||
'integer' | |||
], | |||
[ | |||
[ | |||
'order_deadline', | |||
'order_deadline_monday', | |||
'order_deadline_tuesday', | |||
'order_deadline_wednesday', | |||
'order_deadline_thursday', | |||
'order_deadline_friday', | |||
'order_deadline_saturday', | |||
'order_deadline_sunday', | |||
], | |||
'in', | |||
'range' => [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] | |||
], | |||
['order_delay', 'in', 'range' => [1, 2, 3, 4, 5, 6, 7]], | |||
['option_csv_separator', 'in', 'range' => [',', ';']], | |||
[ | |||
'code', | |||
function ($attribute, $params) { | |||
$code = $this->$attribute; | |||
$producer = Producer::findOne(['code' => $code]); | |||
if ($producer && $producer->id != $this->id) { | |||
$this->addError($attribute, 'Ce code est déjà utilisé par un autre producteur.'); | |||
} | |||
} | |||
], | |||
[['name', 'type', 'id_tax_rate_default'], 'required'], | |||
[ | |||
['tiller_provider_token', 'tiller_restaurant_token'], | |||
'required', | |||
'when' => function ($model) { | |||
return $model->tiller == true; | |||
} | |||
], | |||
[ | |||
[ | |||
['document_quotation_prefix', 'document_invoice_prefix', 'document_delivery_note_prefix'], | |||
function ($attribute, $params) { | |||
if (!ctype_upper($this->$attribute)) { | |||
$this->addError($attribute, 'Ne doit contenir que des majuscules'); | |||
} | |||
} | |||
'order_delay', | |||
'order_deadline', | |||
'order_delay_monday', | |||
'order_deadline_monday', | |||
'order_delay_tuesday', | |||
'order_deadline_tuesday', | |||
'order_delay_wednesday', | |||
'order_deadline_wednesday', | |||
'order_delay_thursday', | |||
'order_deadline_thursday', | |||
'order_delay_friday', | |||
'order_deadline_friday', | |||
'order_delay_saturday', | |||
'order_deadline_saturday', | |||
'order_delay_sunday', | |||
'order_deadline_sunday', | |||
'id_tax_rate_default', | |||
'document_quotation_duration', | |||
'option_dashboard_number_distributions', | |||
'option_online_payment_minimum_amount', | |||
'option_document_price_decimals', | |||
'option_billing_reduction_percentage', | |||
'option_billing_permanent_transfer_amount', | |||
], | |||
'integer' | |||
], | |||
[ | |||
[ | |||
[ | |||
'description', | |||
'mentions', | |||
'gcs', | |||
'order_infos', | |||
'slug', | |||
'secret_key_payplug', | |||
'background_color_logo', | |||
'option_behavior_cancel_order', | |||
'tiller_provider_token', | |||
'tiller_restaurant_token', | |||
'status', | |||
'document_infos_bottom', | |||
'document_infos_quotation', | |||
'document_infos_invoice', | |||
'document_infos_delivery_note', | |||
'address', | |||
'behavior_home_point_sale_day_list', | |||
'behavior_order_select_distribution', | |||
'option_payment_info', | |||
'option_order_reference_type', | |||
'option_order_entry_point', | |||
'option_stripe_public_key', | |||
'option_stripe_private_key', | |||
'option_stripe_endpoint_secret', | |||
'option_online_payment_type', | |||
'option_tax_calculation_method', | |||
'latest_version_opendistrib', | |||
'option_csv_separator' | |||
], | |||
'string' | |||
'order_deadline', | |||
'order_deadline_monday', | |||
'order_deadline_tuesday', | |||
'order_deadline_wednesday', | |||
'order_deadline_thursday', | |||
'order_deadline_friday', | |||
'order_deadline_saturday', | |||
'order_deadline_sunday', | |||
], | |||
'in', | |||
'range' => [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24] | |||
], | |||
['order_delay', 'in', 'range' => [1, 2, 3, 4, 5, 6, 7]], | |||
['option_csv_separator', 'in', 'range' => [',', ';']], | |||
[ | |||
'code', | |||
function ($attribute, $params) { | |||
$code = $this->$attribute; | |||
$producer = Producer::findOne(['code' => $code]); | |||
if ($producer && $producer->id != $this->id) { | |||
$this->addError($attribute, 'Ce code est déjà utilisé par un autre producteur.'); | |||
} | |||
} | |||
], | |||
[ | |||
['document_quotation_prefix', 'document_invoice_prefix', 'document_delivery_note_prefix'], | |||
function ($attribute, $params) { | |||
if (!ctype_upper($this->$attribute)) { | |||
$this->addError($attribute, 'Ne doit contenir que des majuscules'); | |||
} | |||
} | |||
], | |||
[ | |||
[ | |||
[ | |||
'negative_balance', | |||
'credit', | |||
'active', | |||
'online_payment', | |||
'user_manage_subscription', | |||
'option_allow_user_gift', | |||
'use_credit_checked_default', | |||
'tiller', | |||
'document_display_orders_invoice', | |||
'document_display_orders_delivery_note', | |||
'document_display_prices_delivery_note', | |||
'document_display_product_description', | |||
'option_email_confirm', | |||
'option_email_confirm_producer', | |||
'option_csv_export_all_products', | |||
'option_csv_export_by_piece', | |||
'option_export_display_product_reference', | |||
'option_allow_order_guest', | |||
'option_delivery', | |||
'option_display_export_grid', | |||
'option_stripe_mode_test', | |||
'option_notify_producer_order_summary', | |||
'option_billing_reduction', | |||
'option_export_evoliz', | |||
'option_display_message_new_opendistrib_version', | |||
'option_billing_permanent_transfer' | |||
], | |||
'boolean' | |||
'description', | |||
'mentions', | |||
'gcs', | |||
'order_infos', | |||
'slug', | |||
'secret_key_payplug', | |||
'background_color_logo', | |||
'option_behavior_cancel_order', | |||
'tiller_provider_token', | |||
'tiller_restaurant_token', | |||
'status', | |||
'document_infos_bottom', | |||
'document_infos_quotation', | |||
'document_infos_invoice', | |||
'document_infos_delivery_note', | |||
'address', | |||
'behavior_home_point_sale_day_list', | |||
'behavior_order_select_distribution', | |||
'option_payment_info', | |||
'option_order_reference_type', | |||
'option_order_entry_point', | |||
'option_stripe_public_key', | |||
'option_stripe_private_key', | |||
'option_stripe_endpoint_secret', | |||
'option_online_payment_type', | |||
'option_tax_calculation_method', | |||
'latest_version_opendistrib', | |||
'option_csv_separator' | |||
], | |||
'string' | |||
], | |||
[ | |||
[ | |||
[ | |||
'name', | |||
'siret', | |||
'logo', | |||
'photo', | |||
'postcode', | |||
'city', | |||
'code', | |||
'type', | |||
'credit_functioning', | |||
'option_behavior_cancel_order', | |||
'document_quotation_prefix', | |||
'document_quotation_first_reference', | |||
'document_invoice_prefix', | |||
'document_invoice_first_reference', | |||
'document_delivery_note_prefix', | |||
'document_delivery_note_first_reference', | |||
'option_billing_type', | |||
'option_billing_frequency', | |||
], | |||
'string', | |||
'max' => 255 | |||
'negative_balance', | |||
'credit', | |||
'active', | |||
'online_payment', | |||
'user_manage_subscription', | |||
'option_allow_user_gift', | |||
'use_credit_checked_default', | |||
'tiller', | |||
'document_display_orders_invoice', | |||
'document_display_orders_delivery_note', | |||
'document_display_prices_delivery_note', | |||
'document_display_product_description', | |||
'option_email_confirm', | |||
'option_email_confirm_producer', | |||
'option_csv_export_all_products', | |||
'option_csv_export_by_piece', | |||
'option_export_display_product_reference', | |||
'option_allow_order_guest', | |||
'option_delivery', | |||
'option_display_export_grid', | |||
'option_stripe_mode_test', | |||
'option_notify_producer_order_summary', | |||
'option_billing_reduction', | |||
'option_export_evoliz', | |||
'option_display_message_new_opendistrib_version', | |||
'option_billing_permanent_transfer' | |||
], | |||
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'], | |||
'boolean' | |||
], | |||
[ | |||
[ | |||
'free_price', | |||
'compare', | |||
'compareValue' => 0, | |||
'operator' => '>=', | |||
'type' => 'number', | |||
'message' => 'Prix libre doit être supérieur ou égal à 0' | |||
'name', | |||
'siret', | |||
'logo', | |||
'photo', | |||
'postcode', | |||
'city', | |||
'code', | |||
'type', | |||
'credit_functioning', | |||
'option_behavior_cancel_order', | |||
'document_quotation_prefix', | |||
'document_quotation_first_reference', | |||
'document_invoice_prefix', | |||
'document_invoice_first_reference', | |||
'document_delivery_note_prefix', | |||
'document_delivery_note_first_reference', | |||
'option_billing_type', | |||
'option_billing_frequency', | |||
], | |||
[['option_dashboard_date_start', 'option_dashboard_date_end'], 'safe'], | |||
'string', | |||
'max' => 255 | |||
], | |||
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'], | |||
[ | |||
'free_price', | |||
'compare', | |||
'compareValue' => 0, | |||
'operator' => '>=', | |||
'type' => 'number', | |||
'message' => 'Prix libre doit être supérieur ou égal à 0' | |||
], | |||
[['option_dashboard_date_start', 'option_dashboard_date_end'], 'safe'], | |||
]; | |||
} | |||
@@ -311,105 +311,105 @@ class Producer extends ActiveRecordCommon | |||
public function attributeLabels() | |||
{ | |||
return [ | |||
'id' => 'ID', | |||
'name' => 'Nom', | |||
'siret' => 'Siret', | |||
'logo' => 'Logo', | |||
'photo' => 'Photo', | |||
'description' => 'Description', | |||
'postcode' => 'Code postal', | |||
'city' => 'Ville', | |||
'code' => "Code d'accès", | |||
'order_delay' => 'Délai de commande', | |||
'order_deadline' => 'Heure limite de commande', | |||
'order_delay_monday' => 'Délai de commande (lundi)', | |||
'order_deadline_monday' => 'Heure limite de commande (lundi)', | |||
'order_delay_tuesday' => 'Délai de commande (mardi)', | |||
'order_deadline_tuesday' => 'Heure limite de commande (mardi)', | |||
'order_delay_wednesday' => 'Délai de commande (mercredi)', | |||
'order_deadline_wednesday' => 'Heure limite de commande (mercredi)', | |||
'order_delay_thursday' => 'Délai de commande (jeudi)', | |||
'order_deadline_thursday' => 'Heure limite de commande (jeudi)', | |||
'order_delay_friday' => 'Délai de commande (vendredi)', | |||
'order_deadline_friday' => 'Heure limite de commande (vendredi)', | |||
'order_delay_saturday' => 'Délai de commande (samedi)', | |||
'order_deadline_saturday' => 'Heure limite de commande (samedi)', | |||
'order_delay_sunday' => 'Délai de commande (dimanche)', | |||
'order_deadline_sunday' => 'Heure limite de commande (dimanche)', | |||
'negative_balance' => 'Solde négatif', | |||
'credit' => 'Crédit pain', | |||
'active' => 'Actif', | |||
'date_creation' => 'Date de création', | |||
'order_infos' => 'Informations', | |||
'slug' => 'Slug', | |||
'type' => 'Type de producteur', | |||
'credit_limit_reminder' => 'Seuil de crédit limite avant relance', | |||
'online_payment' => 'Activer le paiement en ligne (Stripe)', | |||
'option_online_payment_type' => 'Type de paiement', | |||
'option_stripe_mode_test' => 'Mode test', | |||
'option_stripe_public_key' => 'Clé publique', | |||
'option_stripe_private_key' => 'Clé secrète', | |||
'option_stripe_endpoint_secret' => 'Clé secrète (endpoint)', | |||
'user_manage_subscription' => 'Autoriser les utilisateurs à gérer leurs abonnements', | |||
'mentions' => 'Mentions légales', | |||
'gcs' => 'Conditions générales de vente', | |||
'option_allow_user_gift' => 'Autoriser les utilisateurs à effectuer un don à la plateforme lors de leur commande', | |||
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur', | |||
'credit_limit' => 'Crédit limite', | |||
'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser mon crédit" lors de la commande de l\'utilisateur', | |||
'background_color_logo' => 'Couleur de fond du logo', | |||
'option_behavior_cancel_order' => 'Comportement lors de la suppression d\'une commande', | |||
'tiller' => 'Tiller', | |||
'tiller_provider_token' => 'Token provider', | |||
'tiller_restaurant_token' => 'Token restaurant', | |||
'status' => 'Statut', | |||
'id_tax_rate_default' => 'Taxe', | |||
'document_quotation_prefix' => 'Préfixe des devis', | |||
'document_quotation_first_reference' => 'Première référence des devis', | |||
'document_quotation_duration' => 'Durée du devis', | |||
'document_invoice_prefix' => 'Préfixe des factures', | |||
'document_invoice_first_reference' => 'Première référence des factures', | |||
'document_delivery_note_prefix' => 'Préfixe des bons de livraison', | |||
'document_delivery_note_first_reference' => 'Première référence des bons de livraison', | |||
'document_infos_bottom' => 'Informations affichées en bas des documents', | |||
'document_infos_quotation' => 'Informations affichées en bas des devis', | |||
'document_infos_invoice' => 'Informations affichées en bas des factures', | |||
'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison', | |||
'address' => 'Adresse', | |||
'document_display_orders_invoice' => 'Afficher le détail des commandes dans les factures', | |||
'document_display_orders_delivery_note' => 'Afficher le détail des commandes dans les bons de livraison', | |||
'document_display_prices_delivery_note' => 'Afficher le chiffrage dans les bons de livraison', | |||
'behavior_home_point_sale_day_list' => 'Accueil : affichage des jours de distribution', | |||
'behavior_order_select_distribution' => 'Sélection de la date de distribution', | |||
'option_payment_info' => 'Informations liées au paiement', | |||
'option_email_confirm' => 'Envoyer un email de confirmation au client', | |||
'option_email_confirm_producer' => 'Envoyer un email de confirmation au producteur', | |||
'option_dashboard_number_distributions' => 'Nombre de distributions affichées sur le tableau de board', | |||
'option_dashboard_date_start' => 'Date de début', | |||
'option_dashboard_date_end' => 'Date de fin', | |||
'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)', | |||
'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', | |||
'option_order_reference_type' => 'Type de référence', | |||
'option_export_display_product_reference' => 'Afficher la référence des produits au moment de l\'export', | |||
'option_allow_order_guest' => 'Autoriser les visiteurs à passer commande (création de compte à la fin du tunnel)', | |||
'option_order_entry_point' => 'Point d\'entrée par point de vente ou par date', | |||
'option_delivery' => 'Proposer la livraison à domicile', | |||
'option_display_export_grid' => 'Afficher l\'export grille dans les distributions', | |||
'document_display_product_description' => 'Documents : afficher la description des produits', | |||
'option_notify_producer_order_summary' => 'Recevoir les récapitulatifs de commande par email', | |||
'option_billing_type' => 'Type de facturation', | |||
'option_billing_frequency' => 'Fréquence de facturation', | |||
'option_billing_reduction' => 'Réduction appliquée au moment de la facturation', | |||
'option_tax_calculation_method' => 'Méthode de calcul de la TVA', | |||
'option_export_evoliz' => 'Activer l\'export vers Evoliz', | |||
'latest_version_opendistrib' => 'Dernière version d\'Opendistrib', | |||
'option_csv_separator' => 'Séparateur de colonnes (CSV)', | |||
'option_display_message_new_opendistrib_version' => 'Afficher les messages de mise à jour du logiciel Opendistrib', | |||
'option_online_payment_minimum_amount' => 'Paiement en ligne : montant minimum', | |||
'option_document_price_decimals' => 'Prix : nombre de décimales affichées', | |||
'option_billing_reduction_percentage' => 'Réduction : pourcentage', | |||
'option_billing_permanent_transfer' => 'Virement permanent', | |||
'option_billing_permanent_transfer_amount' => 'Virement permanent : montant', | |||
'id' => 'ID', | |||
'name' => 'Nom', | |||
'siret' => 'Siret', | |||
'logo' => 'Logo', | |||
'photo' => 'Photo', | |||
'description' => 'Description', | |||
'postcode' => 'Code postal', | |||
'city' => 'Ville', | |||
'code' => "Code d'accès", | |||
'order_delay' => 'Délai de commande', | |||
'order_deadline' => 'Heure limite de commande', | |||
'order_delay_monday' => 'Délai de commande (lundi)', | |||
'order_deadline_monday' => 'Heure limite de commande (lundi)', | |||
'order_delay_tuesday' => 'Délai de commande (mardi)', | |||
'order_deadline_tuesday' => 'Heure limite de commande (mardi)', | |||
'order_delay_wednesday' => 'Délai de commande (mercredi)', | |||
'order_deadline_wednesday' => 'Heure limite de commande (mercredi)', | |||
'order_delay_thursday' => 'Délai de commande (jeudi)', | |||
'order_deadline_thursday' => 'Heure limite de commande (jeudi)', | |||
'order_delay_friday' => 'Délai de commande (vendredi)', | |||
'order_deadline_friday' => 'Heure limite de commande (vendredi)', | |||
'order_delay_saturday' => 'Délai de commande (samedi)', | |||
'order_deadline_saturday' => 'Heure limite de commande (samedi)', | |||
'order_delay_sunday' => 'Délai de commande (dimanche)', | |||
'order_deadline_sunday' => 'Heure limite de commande (dimanche)', | |||
'negative_balance' => 'Solde négatif', | |||
'credit' => 'Crédit pain', | |||
'active' => 'Actif', | |||
'date_creation' => 'Date de création', | |||
'order_infos' => 'Informations', | |||
'slug' => 'Slug', | |||
'type' => 'Type de producteur', | |||
'credit_limit_reminder' => 'Seuil de crédit limite avant relance', | |||
'online_payment' => 'Activer le paiement en ligne (Stripe)', | |||
'option_online_payment_type' => 'Type de paiement', | |||
'option_stripe_mode_test' => 'Mode test', | |||
'option_stripe_public_key' => 'Clé publique', | |||
'option_stripe_private_key' => 'Clé secrète', | |||
'option_stripe_endpoint_secret' => 'Clé secrète (endpoint)', | |||
'user_manage_subscription' => 'Autoriser les utilisateurs à gérer leurs abonnements', | |||
'mentions' => 'Mentions légales', | |||
'gcs' => 'Conditions générales de vente', | |||
'option_allow_user_gift' => 'Autoriser les utilisateurs à effectuer un don à la plateforme lors de leur commande', | |||
'credit_functioning' => 'Utilisation du Crédit par l\'utilisateur', | |||
'credit_limit' => 'Crédit limite', | |||
'use_credit_checked_default' => 'Cocher par défaut l\'option "Utiliser mon crédit" lors de la commande de l\'utilisateur', | |||
'background_color_logo' => 'Couleur de fond du logo', | |||
'option_behavior_cancel_order' => 'Comportement lors de la suppression d\'une commande', | |||
'tiller' => 'Tiller', | |||
'tiller_provider_token' => 'Token provider', | |||
'tiller_restaurant_token' => 'Token restaurant', | |||
'status' => 'Statut', | |||
'id_tax_rate_default' => 'Taxe', | |||
'document_quotation_prefix' => 'Préfixe des devis', | |||
'document_quotation_first_reference' => 'Première référence des devis', | |||
'document_quotation_duration' => 'Durée du devis', | |||
'document_invoice_prefix' => 'Préfixe des factures', | |||
'document_invoice_first_reference' => 'Première référence des factures', | |||
'document_delivery_note_prefix' => 'Préfixe des bons de livraison', | |||
'document_delivery_note_first_reference' => 'Première référence des bons de livraison', | |||
'document_infos_bottom' => 'Informations affichées en bas des documents', | |||
'document_infos_quotation' => 'Informations affichées en bas des devis', | |||
'document_infos_invoice' => 'Informations affichées en bas des factures', | |||
'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison', | |||
'address' => 'Adresse', | |||
'document_display_orders_invoice' => 'Afficher le détail des commandes dans les factures', | |||
'document_display_orders_delivery_note' => 'Afficher le détail des commandes dans les bons de livraison', | |||
'document_display_prices_delivery_note' => 'Afficher le chiffrage dans les bons de livraison', | |||
'behavior_home_point_sale_day_list' => 'Accueil : affichage des jours de distribution', | |||
'behavior_order_select_distribution' => 'Sélection de la date de distribution', | |||
'option_payment_info' => 'Informations liées au paiement', | |||
'option_email_confirm' => 'Envoyer un email de confirmation au client', | |||
'option_email_confirm_producer' => 'Envoyer un email de confirmation au producteur', | |||
'option_dashboard_number_distributions' => 'Nombre de distributions affichées sur le tableau de board', | |||
'option_dashboard_date_start' => 'Date de début', | |||
'option_dashboard_date_end' => 'Date de fin', | |||
'option_csv_export_all_products' => 'Exporter tous les produits dans le fichier récapitulatif (CSV)', | |||
'option_csv_export_by_piece' => 'Exporter les produits par pièce dans le fichier récapitulatif (CSV)', | |||
'option_order_reference_type' => 'Type de référence', | |||
'option_export_display_product_reference' => 'Afficher la référence des produits au moment de l\'export', | |||
'option_allow_order_guest' => 'Autoriser les visiteurs à passer commande (création de compte à la fin du tunnel)', | |||
'option_order_entry_point' => 'Point d\'entrée par point de vente ou par date', | |||
'option_delivery' => 'Proposer la livraison à domicile', | |||
'option_display_export_grid' => 'Afficher l\'export grille dans les distributions', | |||
'document_display_product_description' => 'Documents : afficher la description des produits', | |||
'option_notify_producer_order_summary' => 'Recevoir les récapitulatifs de commande par email', | |||
'option_billing_type' => 'Type de facturation', | |||
'option_billing_frequency' => 'Fréquence de facturation', | |||
'option_billing_reduction' => 'Réduction appliquée au moment de la facturation', | |||
'option_tax_calculation_method' => 'Méthode de calcul de la TVA', | |||
'option_export_evoliz' => 'Activer l\'export vers Evoliz', | |||
'latest_version_opendistrib' => 'Dernière version d\'Opendistrib', | |||
'option_csv_separator' => 'Séparateur de colonnes (CSV)', | |||
'option_display_message_new_opendistrib_version' => 'Afficher les messages de mise à jour du logiciel Opendistrib', | |||
'option_online_payment_minimum_amount' => 'Paiement en ligne : montant minimum', | |||
'option_document_price_decimals' => 'Prix : nombre de décimales affichées', | |||
'option_billing_reduction_percentage' => 'Réduction : pourcentage', | |||
'option_billing_permanent_transfer' => 'Virement permanent', | |||
'option_billing_permanent_transfer_amount' => 'Virement permanent : montant', | |||
]; | |||
} | |||
@@ -420,8 +420,8 @@ class Producer extends ActiveRecordCommon | |||
public function getUserProducer() | |||
{ | |||
return $this->hasMany( | |||
UserProducer::className(), | |||
['id_producer' => 'id'] | |||
UserProducer::className(), | |||
['id_producer' => 'id'] | |||
); | |||
} | |||
@@ -433,7 +433,7 @@ class Producer extends ActiveRecordCommon | |||
public function getContact() | |||
{ | |||
return $this->hasMany(User::className(), ['id_producer' => 'id']) | |||
->where(['status' => User::STATUS_PRODUCER]); | |||
->where(['status' => User::STATUS_PRODUCER]); | |||
} | |||
public function getTaxRate() | |||
@@ -449,58 +449,19 @@ class Producer extends ActiveRecordCommon | |||
public static function defaultOptionsSearch() | |||
{ | |||
return [ | |||
'with' => ['taxRate'], | |||
'join_with' => [], | |||
'orderby' => 'name ASC', | |||
'attribute_id_producer' => 'id' | |||
'with' => ['taxRate'], | |||
'join_with' => [], | |||
'orderby' => 'name ASC', | |||
'attribute_id_producer' => 'id' | |||
]; | |||
} | |||
public function addUser($idUser, $idProducer) { | |||
public function addUser($idUser, $idProducer) | |||
{ | |||
$producerContainer = Yii::$app->logic->getProducerContainer(); | |||
$producerContainer->getService()->addUser($idUser, $idProducer); | |||
} | |||
/** | |||
* Retourne la liste des établissements pour l'initialisation d'une liste | |||
* sélective. | |||
* | |||
* @return array | |||
*/ | |||
public static function getProducerPopulateDropdown() | |||
{ | |||
$producers = Producer::find() | |||
->where([ | |||
'active' => true, | |||
]) | |||
->orderBy('postcode, city ASC') | |||
->all(); | |||
$departments = Departments::get(); | |||
$dataProducers = []; | |||
$optionsProducers = []; | |||
foreach ($producers as $p) { | |||
$departmentCode = substr($p->postcode, 0, 2); | |||
if (!key_exists('d' . $departmentCode, $dataProducers) && isset($departments[$departmentCode])) { | |||
$dataProducers['d' . $departmentCode] = '<strong>' . $departments[$departmentCode] . '</strong>'; | |||
$optionsProducers['d' . $departmentCode] = ['disabled' => true]; | |||
} | |||
$dataProducers[$p->id] = '<span class="glyphicon glyphicon-lock"></span> ' . Html::encode( | |||
$p->name | |||
) . ' - ' . Html::encode($p->postcode) . ' ' . Html::encode( | |||
$p->city | |||
) . ' <span class="glyphicon glyphicon-lock"></span>'; | |||
if (strlen($p->code)) { | |||
$optionsProducers[$p->id] = ['class' => 'lock']; | |||
} | |||
} | |||
return ['data' => $dataProducers, 'options' => $optionsProducers]; | |||
} | |||
/** | |||
* Retourne le CA de l'établissement pour un mois donné. | |||
* | |||
@@ -516,7 +477,7 @@ class Producer extends ActiveRecordCommon | |||
$connection = Yii::$app->getDb(); | |||
$command = $connection->createCommand( | |||
' | |||
' | |||
SELECT SUM(product_order.price * product_order.quantity) AS turnover | |||
FROM `order`, product_order, distribution, product | |||
WHERE `order`.id = product_order.id_order | |||
@@ -525,11 +486,11 @@ class Producer extends ActiveRecordCommon | |||
AND product_order.id_product = product.id | |||
AND distribution.date > :date_begin | |||
AND distribution.date < :date_end', | |||
[ | |||
':date_begin' => date('Y-m-31', strtotime("-1 month", strtotime($period))), | |||
':date_end' => date('Y-m-01', strtotime("+1 month", strtotime($period))), | |||
':id_producer' => $this->id | |||
] | |||
[ | |||
':date_begin' => date('Y-m-31', strtotime("-1 month", strtotime($period))), | |||
':date_end' => date('Y-m-01', strtotime("+1 month", strtotime($period))), | |||
':id_producer' => $this->id | |||
] | |||
); | |||
$result = $command->queryOne(); | |||
@@ -546,16 +507,15 @@ class Producer extends ActiveRecordCommon | |||
{ | |||
$amountToBeBilled = 0; | |||
$producerPriceRangeArray = ProducerPriceRange::find()->all(); | |||
foreach($producerPriceRangeArray as $priceRange) { | |||
if($turnover >= $priceRange->range_begin && $turnover < $priceRange->range_end) { | |||
foreach ($producerPriceRangeArray as $priceRange) { | |||
if ($turnover >= $priceRange->range_begin && $turnover < $priceRange->range_end) { | |||
$amountToBeBilled = $priceRange->price; | |||
} | |||
} | |||
if($format) { | |||
if ($format) { | |||
return Price::format($amountToBeBilled, 0); | |||
} | |||
else { | |||
} else { | |||
return $amountToBeBilled; | |||
} | |||
} | |||
@@ -571,7 +531,7 @@ class Producer extends ActiveRecordCommon | |||
$text = ''; | |||
$numMonthCurrent = date('m'); | |||
if($numberOfMonths == 1 | |||
if ($numberOfMonths == 1 | |||
|| ($numberOfMonths == 3 && (in_array($numMonthCurrent, [1, 4, 7, 10]))) | |||
|| ($numberOfMonths == 6 && (in_array($numMonthCurrent, [1, 7])))) { | |||
@@ -584,7 +544,7 @@ class Producer extends ActiveRecordCommon | |||
if ($isBold) $text .= '<strong>'; | |||
$text .= $this->getAmountToBeBilledByTurnover($turnover, true); | |||
if ($isBold) $text .= '</strong>'; | |||
$text .= ' / '.Price::format($turnover, 0); | |||
$text .= ' / ' . Price::format($turnover, 0); | |||
$text .= '<br />'; | |||
} | |||
} | |||
@@ -600,11 +560,10 @@ class Producer extends ActiveRecordCommon | |||
public function getAmountBilledLastMonth() | |||
{ | |||
if($this->isBillingTypeClassic()) { | |||
if ($this->isBillingTypeClassic()) { | |||
$month = date('Y-m', strtotime('-1 month')); | |||
return $this->getAmountToBeBilledByMonth($month); | |||
} | |||
elseif($this->isBillingTypeFreePrice()) { | |||
} elseif ($this->isBillingTypeFreePrice()) { | |||
return $this->free_price; | |||
} | |||
@@ -641,8 +600,8 @@ class Producer extends ActiveRecordCommon | |||
} | |||
$invoice = Invoice::searchOne( | |||
['id_producer' => $this->id, 'period' => ':period'], | |||
['params' => [':period' => $period]] | |||
['id_producer' => $this->id, 'period' => ':period'], | |||
['params' => [':period' => $period]] | |||
); | |||
return $invoice; | |||
@@ -703,13 +662,13 @@ class Producer extends ActiveRecordCommon | |||
{ | |||
$array = []; | |||
$daysArray = [ | |||
'monday', | |||
'tuesday', | |||
'wednesday', | |||
'thursday', | |||
'friday', | |||
'saturday', | |||
'sunday' | |||
'monday', | |||
'tuesday', | |||
'wednesday', | |||
'thursday', | |||
'friday', | |||
'saturday', | |||
'sunday' | |||
]; | |||
@@ -727,8 +686,8 @@ class Producer extends ActiveRecordCommon | |||
} | |||
$array[$day] = [ | |||
'order_delay' => $delay, | |||
'order_deadline' => $deadline, | |||
'order_delay' => $delay, | |||
'order_deadline' => $deadline, | |||
]; | |||
} | |||
@@ -738,13 +697,13 @@ class Producer extends ActiveRecordCommon | |||
public function hasSpecificDelays() | |||
{ | |||
$daysArray = [ | |||
'monday', | |||
'tuesday', | |||
'wednesday', | |||
'thursday', | |||
'friday', | |||
'saturday', | |||
'sunday' | |||
'monday', | |||
'tuesday', | |||
'wednesday', | |||
'thursday', | |||
'friday', | |||
'saturday', | |||
'sunday' | |||
]; | |||
foreach ($daysArray as $day) { | |||
@@ -787,16 +746,16 @@ class Producer extends ActiveRecordCommon | |||
public function savePrivateKeyApiStripe() | |||
{ | |||
$this->savePrivateKeyStripe( | |||
$this->getFilenamePrivateKeyApiStripe(), | |||
$this->option_stripe_private_key | |||
$this->getFilenamePrivateKeyApiStripe(), | |||
$this->option_stripe_private_key | |||
); | |||
} | |||
public function savePrivateKeyEndpointStripe() | |||
{ | |||
$this->savePrivateKeyStripe( | |||
$this->getFilenamePrivateKeyEndpointStripe(), | |||
$this->option_stripe_endpoint_secret | |||
$this->getFilenamePrivateKeyEndpointStripe(), | |||
$this->option_stripe_endpoint_secret | |||
); | |||
} | |||
@@ -877,8 +836,7 @@ class Producer extends ActiveRecordCommon | |||
public function getUrlLogo() | |||
{ | |||
return Yii::$app->urlManagerProducer->getHostInfo( | |||
) . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/' . $this->logo; | |||
return Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/' . $this->logo; | |||
} | |||
public function getEmailOpendistrib() | |||
@@ -906,7 +864,7 @@ class Producer extends ActiveRecordCommon | |||
public function isOnlinePaymentActiveAndTypeOrder() | |||
{ | |||
return $this->isOnlinePaymentActive() && $this->option_online_payment_type == 'order' ; | |||
return $this->isOnlinePaymentActive() && $this->option_online_payment_type == 'order'; | |||
} | |||
public static function getBillingFrequencyPopulateDropdown() | |||
@@ -949,7 +907,8 @@ class Producer extends ActiveRecordCommon | |||
return $this->latest_version_opendistrib == GlobalParam::getOpendistribVersion(); | |||
} | |||
public function updateOpendistribVersion() { | |||
public function updateOpendistribVersion() | |||
{ | |||
$versionsArray = Opendistrib::getVersions(); | |||
$this->latest_version_opendistrib = array_values($versionsArray)[0]; | |||
$this->save(); | |||
@@ -958,7 +917,7 @@ class Producer extends ActiveRecordCommon | |||
public function getOnlinePaymentMinimumAmount() | |||
{ | |||
$onlinePaymentMinimumAmount = self::getConfig('option_online_payment_minimum_amount'); | |||
if(!$onlinePaymentMinimumAmount) { | |||
if (!$onlinePaymentMinimumAmount) { | |||
$onlinePaymentMinimumAmount = self::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT; | |||
} | |||
@@ -2,7 +2,9 @@ | |||
namespace common\repositories; | |||
use common\helpers\Departments; | |||
use common\models\Producer; | |||
use yii\helpers\Html; | |||
class ProducerRepository | |||
{ | |||
@@ -30,8 +32,51 @@ class ProducerRepository | |||
* | |||
* @return Producer | |||
*/ | |||
public function getDemoAccount() | |||
public function getOneDemoAccount() | |||
{ | |||
return Producer::find()->where('name LIKE \'Démo\'')->one(); | |||
} | |||
/** | |||
* Retourne la liste des établissements pour l'initialisation d'une liste | |||
* sélective. | |||
* | |||
* @return array | |||
*/ | |||
public static function getPopulateDropdown() | |||
{ | |||
$producers = Producer::find() | |||
->where([ | |||
'active' => true, | |||
]) | |||
->orderBy('postcode, city ASC') | |||
->all(); | |||
$departments = Departments::get(); | |||
$dataProducers = []; | |||
$optionsProducers = []; | |||
foreach ($producers as $p) { | |||
$departmentCode = substr($p->postcode, 0, 2); | |||
if (!key_exists('d' . $departmentCode, $dataProducers) && isset($departments[$departmentCode])) { | |||
$dataProducers['d' . $departmentCode] = '<strong>' . $departments[$departmentCode] . '</strong>'; | |||
$optionsProducers['d' . $departmentCode] = ['disabled' => true]; | |||
} | |||
$dataProducers[$p->id] = '<span class="glyphicon glyphicon-lock"></span> ' . Html::encode( | |||
$p->name | |||
) . ' - ' . Html::encode($p->postcode) . ' ' . Html::encode( | |||
$p->city | |||
) . ' <span class="glyphicon glyphicon-lock"></span>'; | |||
if (strlen($p->code)) { | |||
$optionsProducers[$p->id] = ['class' => 'lock']; | |||
} | |||
} | |||
return [ | |||
'data' => $dataProducers, | |||
'options' => $optionsProducers | |||
]; | |||
} | |||
} |
@@ -2,7 +2,13 @@ | |||
namespace common\repositories; | |||
use common\models\User; | |||
class UserRepository | |||
{ | |||
public function getOneById($id) | |||
{ | |||
return User::searchOne(['id' => $id]); | |||
} | |||
} |
@@ -74,7 +74,7 @@ return [ | |||
], | |||
], | |||
'view' => [ | |||
'class' => 'common\components\MyView', | |||
'class' => 'common\components\ViewFrontend', | |||
], | |||
'urlManager' => $common_config_main['components']['urlManagerFrontend'], | |||
], |
@@ -38,7 +38,6 @@ termes. | |||
namespace frontend\controllers; | |||
use yii; | |||
use common\controllers\CommonController; | |||
class FrontendController extends CommonController |
@@ -39,11 +39,11 @@ | |||
namespace frontend\controllers; | |||
use common\models\User; | |||
use frontend\forms\ProducerCodeForm; | |||
use Yii; | |||
use common\models\Producer; | |||
use frontend\models\PasswordResetRequestForm; | |||
use frontend\models\ResetPasswordForm; | |||
use frontend\models\SignupForm; | |||
use frontend\forms\PasswordResetRequestForm; | |||
use frontend\forms\ResetPasswordForm; | |||
use frontend\forms\SignupForm; | |||
use common\forms\ContactForm; | |||
use yii\base\InvalidParamException; | |||
use yii\data\ActiveDataProvider; | |||
@@ -130,7 +130,7 @@ class SiteController extends FrontendController | |||
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | |||
return $this->render('index', [ | |||
'producerDemoAccount' => $producerRepository->getDemoAccount(), | |||
'producerDemoAccount' => $producerRepository->getOneDemoAccount(), | |||
'dataProviderPrices' => $this->getDataProviderPrices() | |||
]); | |||
} | |||
@@ -180,16 +180,6 @@ class SiteController extends FrontendController | |||
]); | |||
} | |||
/** | |||
* Affiche les mentions légales. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionMentions() | |||
{ | |||
return $this->render('mentions'); | |||
} | |||
/** | |||
* Affiche la page de connexion et traite le formulaire de connexion. | |||
* | |||
@@ -204,15 +194,23 @@ class SiteController extends FrontendController | |||
$model = new LoginForm(); | |||
if ($model->load(Yii::$app->request->post()) && $model->login()) { | |||
$returnUrl = Yii::$app->request->get('return_url'); | |||
if ($returnUrl) { | |||
return $this->redirect($returnUrl); | |||
} | |||
else { | |||
$userProducerArray = $this->getLogic()->getUserProducerContainer()->getBy(User::getCurrentId()); | |||
$userProducerArray = $this->getLogic() | |||
->getUserProducerContainer() | |||
->getRepository() | |||
->getBy(User::getCurrentId()); | |||
if ($userProducerArray && is_array($userProducerArray) && count($userProducerArray) == 1) { | |||
return $this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $userProducerArray[0]->producer->slug])); | |||
} else { | |||
if ($userProducerArray | |||
&& is_array($userProducerArray) | |||
&& count($userProducerArray) == 1) { | |||
return $this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $userProducerArray[0]->producer->slug])); | |||
} | |||
else { | |||
return $this->goBack(); | |||
} | |||
} | |||
@@ -231,6 +229,7 @@ class SiteController extends FrontendController | |||
public function actionLogout() | |||
{ | |||
Yii::$app->user->logout(); | |||
return $this->goHome(); | |||
} | |||
@@ -268,18 +267,22 @@ class SiteController extends FrontendController | |||
public function actionSignup() | |||
{ | |||
$model = new SignupForm(); | |||
$producerRepository = Yii::$app->logic->getProducerContainer()->getRepository(); | |||
if ($model->load(Yii::$app->request->post())) { | |||
$user = $model->signup(); | |||
if ($user) { | |||
if (Yii::$app->getUser()->login($user)) { | |||
if ($model->option_user_producer == 'producer') { | |||
if ($this->getUser()->login($user)) { | |||
if ($model->isProducer()) { | |||
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index'])); | |||
} else { | |||
$producer = Producer::findOne($model->id_producer); | |||
} | |||
else { | |||
$producer = $producerRepository->getOneById($model->id_producer); | |||
if ($producer) { | |||
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | |||
} else { | |||
} | |||
else { | |||
$this->redirect(['site/index']); | |||
} | |||
} | |||
@@ -287,8 +290,8 @@ class SiteController extends FrontendController | |||
} | |||
} | |||
// liste des producteurs disponibles | |||
$producersArray = Producer::getProducerPopulateDropdown(); | |||
// Liste des producteurs disponibles | |||
$producersArray = $producerRepository->getPopulateDropdown(); | |||
$dataProducers = $producersArray['data']; | |||
$optionsProducers = $producersArray['options']; | |||
@@ -309,13 +312,15 @@ class SiteController extends FrontendController | |||
public function actionRequestPasswordReset() | |||
{ | |||
$model = new PasswordResetRequestForm(); | |||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { | |||
if ($model->sendEmail()) { | |||
Yii::$app->getSession()->setFlash('success', 'Un lien vous permettant de réinitialiser votre mot de passe vient d\'être envoyé sur votre boîte mail.'); | |||
$this->setFlash('success', 'Un lien vous permettant de réinitialiser votre mot de passe | |||
vient d\'être envoyé sur votre boîte mail.'); | |||
return $this->goHome(); | |||
} else { | |||
Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); | |||
} | |||
else { | |||
$this->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); | |||
} | |||
} | |||
@@ -339,8 +344,11 @@ class SiteController extends FrontendController | |||
throw new BadRequestHttpException($e->getMessage()); | |||
} | |||
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { | |||
Yii::$app->getSession()->setFlash('success', 'Votre nouveau mot de passe vient d\'être sauvegardé.'); | |||
if ($model->load($this->getRequest()->post()) | |||
&& $model->validate() | |||
&& $model->resetPassword()) { | |||
$this->setFlash('success', 'Votre nouveau mot de passe vient d\'être sauvegardé.'); | |||
return $this->goHome(); | |||
} | |||
@@ -350,26 +358,6 @@ class SiteController extends FrontendController | |||
]); | |||
} | |||
/** | |||
* Affiche les conditions générale de service. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionCgv() | |||
{ | |||
return $this->render('cgv'); | |||
} | |||
/** | |||
* Affiche les précisions concernant l'utilisation du crédit. | |||
* | |||
* @return string | |||
*/ | |||
public function actionCredit() | |||
{ | |||
return $this->render('credit'); | |||
} | |||
/** | |||
* Affiche le formulaire de demande de code pour accéder à certains | |||
* producteurs. | |||
@@ -380,18 +368,22 @@ class SiteController extends FrontendController | |||
*/ | |||
public function actionProducerCode($id) | |||
{ | |||
$producer = Producer::findOne($id); | |||
$producerContainer = $this->getLogic()->getProducerContainer(); | |||
$producer = $producerContainer->getRepository()->getOneById($id); | |||
if (!$producer) { | |||
throw new \yii\web\HttpException(404, 'Producteur introuvable'); | |||
} | |||
$producerCodeForm = new ProducerCodeForm; | |||
$producerCodeForm = new ProducerCodeForm(); | |||
$producerCodeForm->id_producer = $id; | |||
if ($producerCodeForm->load(Yii::$app->request->post()) && $producerCodeForm->validate()) { | |||
Producer::addUser(User::getCurrentId(), $id); | |||
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | |||
if ($producerCodeForm->load($this->getRequest()->post()) | |||
&& $producerCodeForm->validate()) { | |||
$producerContainer->getService()->addUser(User::getCurrentId(), $id); | |||
$this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | |||
} | |||
return $this->render('producer_code', [ | |||
@@ -411,33 +403,31 @@ class SiteController extends FrontendController | |||
{ | |||
$loginForm = new LoginForm(); | |||
$signupForm = new SignupForm(); | |||
$producerContainer = $this->getLogic()->getProducerContainer(); | |||
$producer = Producer::searchOne([ | |||
'id' => $id | |||
]); | |||
$producer = $producerContainer->getRepository()->getOneById($id); | |||
$loginForm->id_producer = $id; | |||
$signupForm->id_producer = $id; | |||
$signupForm->option_user_producer = 'user'; | |||
$returnUrl = $this->getRequest()->get('returnUrl', $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | |||
$returnUrl = Yii::$app->request->get('returnUrl', Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | |||
if (Yii::$app->user->isGuest) { | |||
if ($loginForm->load(Yii::$app->request->post()) && $loginForm->login()) { | |||
if ($this->getUser()->isGuest) { | |||
if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) { | |||
if (!strlen($producer->code)) { | |||
Producer::addUser(User::getCurrentId(), $id); | |||
$producerContainer->getService()->addUser(User::getCurrentId(), $id); | |||
} | |||
$this->redirect($returnUrl); | |||
} | |||
if ($signupForm->load(Yii::$app->request->post())) { | |||
if ($user = $signupForm->signup()) { | |||
if (Yii::$app->getUser()->login($user)) { | |||
$this->redirect($returnUrl); | |||
} | |||
} | |||
if ($signupForm->load($this->getRequest()->post()) | |||
&& ($user = $signupForm->signup()) | |||
&& $this->getUser()->login($user)) { | |||
$this->redirect($returnUrl); | |||
} | |||
} else { | |||
} | |||
else { | |||
$this->redirect($returnUrl); | |||
} | |||
@@ -457,9 +447,39 @@ class SiteController extends FrontendController | |||
public function actionProducerOffline($id) | |||
{ | |||
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | |||
return $this->render('producer_offline', [ | |||
'producer' => $producerRepository->getOneById($id), | |||
]); | |||
} | |||
/** | |||
* Affiche les mentions légales. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionMentions() | |||
{ | |||
return $this->render('mentions'); | |||
} | |||
/** | |||
* Affiche les conditions générale de service. | |||
* | |||
* @return mixed | |||
*/ | |||
public function actionCgv() | |||
{ | |||
return $this->render('cgv'); | |||
} | |||
/** | |||
* Affiche les précisions concernant l'utilisation du crédit. | |||
* | |||
* @return string | |||
*/ | |||
public function actionCredit() | |||
{ | |||
return $this->render('credit'); | |||
} | |||
} |
@@ -81,17 +81,18 @@ class UserController extends FrontendController | |||
*/ | |||
public function actionUpdate() | |||
{ | |||
$model = $this->findModel(User::getCurrentId()); | |||
$idUser = User::getCurrentId(); | |||
$model = $this->findModel($idUser); | |||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { | |||
if ($model->load($this->getRequest()->post()) | |||
&& $model->validate()) { | |||
// l'utilisateur ne peut pas changer d'adresse email | |||
$oldModel = $this->findModel(User::getCurrentId()); | |||
$oldModel = $this->findModel($idUser); | |||
$model->email = $oldModel->email; | |||
// modification du mot de passe | |||
if (strlen($model->password_new)) { | |||
//$model->setPassword($model->password_new) ; | |||
$model->password_hash = Yii::$app->security->generatePasswordHash($model->password_new); | |||
$model->password_old = ''; | |||
@@ -101,15 +102,15 @@ class UserController extends FrontendController | |||
$model->save(); | |||
Yii::$app->session->setFlash('success', 'Votre profil a bien été modifié.'); | |||
$this->setFlash('success', 'Votre profil a bien été modifié.'); | |||
return $this->render('update', [ | |||
'model' => $model, | |||
]); | |||
} else { | |||
} | |||
else { | |||
if (!$model->validate()) { | |||
Yii::$app->session->setFlash('error', 'Le formulaire comporte des erreurs.'); | |||
$this->setFlash('error', 'Le formulaire comporte des erreurs.'); | |||
} | |||
return $this->render('update', [ | |||
@@ -127,9 +128,12 @@ class UserController extends FrontendController | |||
*/ | |||
protected function findModel($id) | |||
{ | |||
if (($model = User::findOne($id)) !== null) { | |||
$userRepository = $this->getLogic()->getUserContainer()->getRepository(); | |||
if (($model = $userRepository->getOneById($id)) !== null) { | |||
return $model; | |||
} else { | |||
} | |||
else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); | |||
} | |||
} |
@@ -36,7 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
namespace frontend\models; | |||
namespace frontend\forms; | |||
use common\models\User; | |||
use yii\base\Model; |
@@ -36,9 +36,8 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
namespace frontend\models; | |||
namespace frontend\forms; | |||
use Yii; | |||
use yii\base\Model; | |||
/** | |||
@@ -46,7 +45,6 @@ use yii\base\Model; | |||
*/ | |||
class ProducerCodeForm extends Model | |||
{ | |||
public $id_producer ; | |||
public $code; | |||
@@ -36,7 +36,7 @@ pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
namespace frontend\models; | |||
namespace frontend\forms; | |||
use common\models\User; | |||
use yii\base\InvalidParamException; |
@@ -36,7 +36,7 @@ | |||
* termes. | |||
*/ | |||
namespace frontend\models; | |||
namespace frontend\forms; | |||
use Yii; | |||
use common\models\User; |
@@ -1,141 +0,0 @@ | |||
<?php | |||
/** | |||
Copyright distrib (2018) | |||
contact@opendistrib.net | |||
Ce logiciel est un programme informatique servant à aider les producteurs | |||
à distribuer leur production en circuits courts. | |||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
sur le site "http://www.cecill.info". | |||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||
de modification et de redistribution accordés par cette licence, il n'est | |||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
titulaire des droits patrimoniaux et les concédants successifs. | |||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
associés au chargement, à l'utilisation, à la modification et/ou au | |||
développement et à la reproduction du logiciel par l'utilisateur étant | |||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||
avertis possédant des connaissances informatiques approfondies. Les | |||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
namespace frontend\models; | |||
use Yii; | |||
use yii\base\Model; | |||
use common\models\UserProducer; | |||
use common\models\Producer; | |||
use yii\helpers\Html; | |||
/** | |||
* ContactForm is the model behind the contact form. | |||
*/ | |||
class AddProducerForm extends Model | |||
{ | |||
public $id_producer; | |||
public $code; | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function rules() | |||
{ | |||
return [ | |||
['id_producer', 'integer'], | |||
['id_producer', 'required'], | |||
['id_producer', function($attribute, $params) { | |||
$producer = Producer::findOne($this->id_producer); | |||
if (!$producer) { | |||
$this->addError($attribute, 'Ce producteur n\'existe pas.'); | |||
} | |||
$userProducerExist = UserProducer::searchOne([ | |||
'id_user' => Yii::$app->user->identity->id, | |||
'active' => 1 | |||
]) ; | |||
if ($userProducerExist) { | |||
$this->addError($attribute, 'Ce producteur est déjà sur votre tableau de bord.'); | |||
} | |||
}], | |||
['code', 'required', 'message' => 'Champs obligatoire', 'when' => function($model) { | |||
$producer = Producer::findOne($this->id_producer); | |||
if ($producer) { | |||
return strlen($producer->code); | |||
} else { | |||
return false; | |||
} | |||
}], | |||
['code', function($attribute, $params) { | |||
$code = $this->$attribute; | |||
$producer = Producer::findOne($this->id_producer); | |||
if ($producer && strtolower(trim($code)) != strtolower(trim($producer->code))) { | |||
$this->addError($attribute, 'Code incorrect'); | |||
} | |||
}], | |||
]; | |||
} | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function attributeLabels() | |||
{ | |||
return [ | |||
'id_producer' => 'Producteur', | |||
'code' => 'Code', | |||
]; | |||
} | |||
/** | |||
* Sends an email to the specified email address using the information collected by this model. | |||
* | |||
* @param string $email the target email address | |||
* @return boolean whether the email was sent | |||
*/ | |||
public function add() | |||
{ | |||
$producer = Producer::findOne($this->id_producer); | |||
$userProducerExist = UserProducer::searchOne([ | |||
'id_user' => User::getCurrentId(), | |||
'active' => 0 | |||
]) ; | |||
if ($userProducerExist) { | |||
$userProducerExist->active = 1; | |||
$userProducerExist->save(); | |||
} else { | |||
$userProducer = new UserProducer(); | |||
$userProducer->id_user = User::getCurrentId(); | |||
$userProducer->id_producer = $this->id_producer; | |||
$userProducer->credit = 0; | |||
$userProducer->actif = 1; | |||
$userProducer->save(); | |||
} | |||
Yii::$app->session->setFlash('success', 'Le producteur <strong>' . Html::encode($producer->name) . '</strong> a bien été ajoutée à votre tableau de bord.'); | |||
} | |||
} | |||
@@ -1,244 +1,246 @@ | |||
<?php | |||
/** | |||
Copyright distrib (2018) | |||
contact@opendistrib.net | |||
Ce logiciel est un programme informatique servant à aider les producteurs | |||
à distribuer leur production en circuits courts. | |||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
sur le site "http://www.cecill.info". | |||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||
de modification et de redistribution accordés par cette licence, il n'est | |||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
titulaire des droits patrimoniaux et les concédants successifs. | |||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
associés au chargement, à l'utilisation, à la modification et/ou au | |||
développement et à la reproduction du logiciel par l'utilisateur étant | |||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||
avertis possédant des connaissances informatiques approfondies. Les | |||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
termes. | |||
*/ | |||
* Copyright distrib (2018) | |||
* | |||
* contact@opendistrib.net | |||
* | |||
* Ce logiciel est un programme informatique servant à aider les producteurs | |||
* à distribuer leur production en circuits courts. | |||
* | |||
* Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||
* respectant les principes de diffusion des logiciels libres. Vous pouvez | |||
* utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||
* de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||
* sur le site "http://www.cecill.info". | |||
* | |||
* En contrepartie de l'accessibilité au code source et des droits de copie, | |||
* de modification et de redistribution accordés par cette licence, il n'est | |||
* offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||
* seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||
* titulaire des droits patrimoniaux et les concédants successifs. | |||
* | |||
* A cet égard l'attention de l'utilisateur est attirée sur les risques | |||
* associés au chargement, à l'utilisation, à la modification et/ou au | |||
* développement et à la reproduction du logiciel par l'utilisateur étant | |||
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||
* manipuler et qui le réserve donc à des développeurs et des professionnels | |||
* avertis possédant des connaissances informatiques approfondies. Les | |||
* utilisateurs sont donc invités à charger et tester l'adéquation du | |||
* logiciel à leurs besoins dans des conditions permettant d'assurer la | |||
* sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||
* à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||
* | |||
* Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||
* pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||
* termes. | |||
*/ | |||
use yii\helpers\Html; | |||
use yii\bootstrap\Nav; | |||
use yii\bootstrap\NavBar; | |||
use yii\widgets\Breadcrumbs; | |||
use common\widgets\Alert; | |||
use common\helpers\Url ; | |||
use common\helpers\Url; | |||
/* @var $this \yii\web\View */ | |||
/* @var $content string */ | |||
$isHome = (Yii::$app->controller->id == 'site' && Yii::$app->controller->action->id == 'index') ; | |||
$isHome = (Yii::$app->controller->id == 'site' && Yii::$app->controller->action->id == 'index'); | |||
\common\assets\CommonAsset::register($this); | |||
\frontend\assets\AppAsset::register($this); | |||
$producer = null ; | |||
if(!Yii::$app->user->isGuest && Yii::$app->user->identity->id_producer > 0) { | |||
$producer = Producer::searchOne(['id' => Yii::$app->user->identity->id_producer]) ; | |||
$producer = null; | |||
if (!Yii::$app->user->isGuest && Yii::$app->user->identity->id_producer > 0) { | |||
$producer = Producer::searchOne(['id' => Yii::$app->user->identity->id_producer]); | |||
} | |||
?> | |||
<?php $this->beginPage() ?> | |||
<!DOCTYPE html> | |||
<head> | |||
<title><?php if($isHome): ?>Opendistrib | <?= Html::encode($this->title) ?> <?php else: ?><?= Html::encode($this->title) ?> | Opendistrib<?php endif; ?></title> | |||
<title><?php if ($isHome): ?>Opendistrib | <?= Html::encode($this->title) ?><?php else: ?><?= Html::encode($this->title) ?> | Opendistrib<?php endif; ?></title> | |||
<meta charset="utf-8"> | |||
<meta name="viewport" content="width=device-width, initial-scale=1"> | |||
<?= Html::csrfMetaTags() ?> | |||
<link rel="icon" type="image/png" href="<?= Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon-distrib.png" /> | |||
<link rel="icon" type="image/png" href="<?= $this->getUrlManager()->getBaseUrl(); ?>/img/favicon-distrib.png"/> | |||
<!--[if IE]><link rel="shortcut icon" type="image/x-icon" href="<?= Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon.ico" /><![endif]--> | |||
<?php $this->head() ?> | |||
<!--[if lt IE 9]> | |||
<script src="<?= Yii::$app->urlManager->getBaseUrl(); ?>/js/html5shiv.min.js"></script> | |||
<link href="<?= Yii::$app->urlManager->getBaseUrl(); ?>/css/ie.css" rel="stylesheet"> | |||
<script src="<?= $this->getUrlManager()->getBaseUrl(); ?>/js/html5shiv.min.js"></script> | |||
<link href="<?= $this->getUrlManager()->getBaseUrl(); ?>/css/ie.css" rel="stylesheet"> | |||
<![endif]--> | |||
<!--[if IE 7]> | |||
<link href="<?= Yii::$app->urlManager->getBaseUrl(); ?>/css/ie7.css" rel="stylesheet"> | |||
<link href="<?= $this->getUrlManager()->getBaseUrl(); ?>/css/ie7.css" rel="stylesheet"> | |||
<![endif]--> | |||
</head> | |||
<body class="<?php if($isHome): echo 'home' ; endif; ?><?php if(!Yii::$app->user->isGuest): ?> connected<?php endif; ?>"> | |||
<?php $this->beginBody() ?> | |||
<div id="back"></div> | |||
<?php if(YII_ENV == 'demo'): ?> | |||
<div id="block-demo"> | |||
<div class="container"> | |||
<span class="glyphicon glyphicon-eye-open"></span> <strong>Espace de démonstration</strong> : | |||
Testez la plateforme sans avoir à vous inscrire. Les données sont réinitialisées quotidiennement • <?= Html::a('Retour', Url::env('prod', 'frontend')) ?> | |||
</div> | |||
</div> | |||
<?php endif; ?> | |||
<header id="header"> | |||
<nav class="navbar navbar-default"> | |||
<div id="the-header" class="container"> | |||
<div class="navbar-header"> | |||
<a id="link-home" href="<?= Yii::$app->urlManager->createUrl('site/index') ; ?>"> | |||
<img src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-distrib.png" alt="" /> | |||
</a> | |||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w0-collapse"><span class="sr-only">Toggle navigation</span> | |||
<span class="icon-bar"></span> | |||
<span class="icon-bar"></span> | |||
<span class="icon-bar"></span> | |||
</button> | |||
</div> | |||
<div id="w0-collapse" class="collapse navbar-collapse"> | |||
<?php | |||
echo Nav::widget([ | |||
'encodeLabels' => false, | |||
'options' => ['class' =>'nav nav-pills navbar-nav navbar-right'], | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-home"></span> Accueil', | |||
'url' => Yii::$app->urlManager->createUrl(['site/index']), | |||
'active' => $this->getControllerAction() == 'site/index', | |||
'options' => ['id' => 'li-home'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-search"></span> Producteurs', | |||
'url' => Yii::$app->urlManager->createUrl(['site/producers']), | |||
'active' => $this->getControllerAction() == 'site/producers', | |||
'options' => ['id' => 'li-producteurs'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-eur"></span> Tarifs', | |||
'url' => Yii::$app->urlManager->createUrl(['site/prices']), | |||
'active' => $this->getControllerAction() == 'site/prices', | |||
'options' => ['id' => 'li-producteurs'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact', | |||
'url' => Yii::$app->urlManager->createUrl(['site/contact']), | |||
'active' => $this->getControllerAction() == 'site/contact', | |||
'options' => ['id' => 'li-contact'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-flag"></span> '.($producer ? Html::encode($producer->name) : ''), | |||
'url' => '#', | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-th-large"></span> Mon espace', | |||
'url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-cog"></span> Administration', | |||
'url' => Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']), | |||
] | |||
], | |||
'visible' => !Yii::$app->user->isGuest && $producer | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion', | |||
'url' => Yii::$app->urlManager->createUrl(['site/login']), | |||
'visible' => Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'site/login' | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-user"></span> Inscription', | |||
'url' => Yii::$app->urlManager->createUrl(['site/signup']), | |||
'visible' => Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'site/signup' | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-user"></span> '.((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name .' '.strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '').'. ', | |||
'options' => ['id' => 'label1'], | |||
'url' => '#', | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-user"></span> Profil', | |||
'url' => Yii::$app->urlManager->createUrl(['user/update']), | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion', | |||
'url' => Yii::$app->urlManager->createUrl(['site/logout']), | |||
] | |||
], | |||
'visible' => !Yii::$app->user->isGuest | |||
], | |||
] | |||
]); | |||
?> | |||
</div> | |||
</div> | |||
</nav> | |||
</header> | |||
<?php if(!Yii::$app->user->isGuest): ?> | |||
<section id="bookmarked-producers"> | |||
<div class="container"> | |||
<?php | |||
$producersArray = Producer::find() | |||
->joinWith(['userProducer user_producer']) | |||
->where([ | |||
'user_producer.id_user' => User::getCurrentId(), | |||
'user_producer.bookmark' => 1, | |||
]) | |||
->all() ; | |||
?> | |||
<?php if(count($producersArray)): ?> | |||
<h2>Mes producteurs ></h2> | |||
<div id="producers"> | |||
<?php foreach($producersArray as $producer): ?> | |||
<a class="btn btn-xs btn-default" href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index','slug_producer' => $producer->slug]); ?>"><?= Html::encode($producer->name); ?></a> | |||
<?php endforeach; ?> | |||
</div> | |||
<?php else: ?> | |||
<div id="discover"> | |||
<p>Vous n'avez aucun producteur dans vos favoris : </p> | |||
<a class="btn btn-default btn-lg" href="<?= Yii::$app->urlManager->createUrl(['site/producers']); ?>"><span class="glyphicon glyphicon-grain"></span> Découvrez les producteurs</a> | |||
</div> | |||
<?php endif; ?> | |||
<div class="clr"></div> | |||
</div> | |||
</section> | |||
<?php endif; ?> | |||
<div id="main"> | |||
<section class="container" id="content"> | |||
<?php if(Yii::$app->session->hasFlash('error')): ?> | |||
<div class="alert alert-danger" role="alert"> | |||
<?= Yii::$app->session->getFlash('error') ?> | |||
</div> | |||
<?php endif; ?> | |||
<?php if(Yii::$app->session->hasFlash('success')): ?> | |||
<div class="alert alert-success" role="alert"> | |||
<?= Yii::$app->session->getFlash('success') ?> | |||
</div> | |||
<?php endif; ?> | |||
<?= $content ?> | |||
</section> | |||
</div> | |||
<footer id="footer"> | |||
<div class="container"> | |||
<a href="<?php echo Yii::$app->urlManager->createUrl('site/contact') ; ?>">Contact</a> • | |||
<a href="<?php echo Yii::$app->urlManager->createUrl('site/mentions') ; ?>">Mentions légales</a> • | |||
<a href="<?php echo Yii::$app->urlManager->createUrl('site/cgv') ; ?>">CGS</a> • | |||
<a id="code-source" href="https://framagit.org/guillaume-bourgeois/distrib">Code source <img src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-framagit.png" alt="Hébergé par Framasoft" /> <img src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-gitlab.png" alt="Propulsé par Gitlab" /></a> • | |||
<a id="social-mastodon" href="https://mastodon.social/@opendistrib">Mastodon <img src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-mastodon.png" alt="Mastodon" /></a> • | |||
<a id="social-diaspora" href="https://framasphere.org/people/db12d640c64c0137f1d52a0000053625">Diaspora <img src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-diaspora.png" alt="Diaspora" /></a> | |||
</div> | |||
</footer> | |||
<?php $this->endBody() ?> | |||
<body class="<?php if ($isHome): echo 'home'; endif; ?><?php if (!Yii::$app->user->isGuest): ?> connected<?php endif; ?>"> | |||
<?php $this->beginBody() ?> | |||
<div id="back"></div> | |||
<?php if (YII_ENV == 'demo'): ?> | |||
<div id="block-demo"> | |||
<div class="container"> | |||
<span class="glyphicon glyphicon-eye-open"></span> <strong>Espace de démonstration</strong> : | |||
Testez la plateforme sans avoir à vous inscrire. Les données sont réinitialisées quotidiennement | |||
• <?= Html::a('Retour', Url::env('prod', 'frontend')) ?> | |||
</div> | |||
</div> | |||
<?php endif; ?> | |||
<header id="header"> | |||
<nav class="navbar navbar-default"> | |||
<div id="the-header" class="container"> | |||
<div class="navbar-header"> | |||
<a id="link-home" href="<?= $this->getUrlManager()->createUrl('site/index'); ?>"> | |||
<img src="<?php echo $this->getUrlManager()->getBaseUrl(); ?>/img/logo-distrib.png" alt=""/> | |||
</a> | |||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w0-collapse"><span | |||
class="sr-only">Toggle navigation</span> | |||
<span class="icon-bar"></span> | |||
<span class="icon-bar"></span> | |||
<span class="icon-bar"></span> | |||
</button> | |||
</div> | |||
<div id="w0-collapse" class="collapse navbar-collapse"> | |||
<?php | |||
echo Nav::widget([ | |||
'encodeLabels' => false, | |||
'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'], | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-home"></span> Accueil', | |||
'url' => $this->getUrlManager()->createUrl(['site/index']), | |||
'active' => $this->getControllerAction() == 'site/index', | |||
'options' => ['id' => 'li-home'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-search"></span> Producteurs', | |||
'url' => $this->getUrlManager()->createUrl(['site/producers']), | |||
'active' => $this->getControllerAction() == 'site/producers', | |||
'options' => ['id' => 'li-producteurs'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-eur"></span> Tarifs', | |||
'url' => $this->getUrlManager()->createUrl(['site/prices']), | |||
'active' => $this->getControllerAction() == 'site/prices', | |||
'options' => ['id' => 'li-producteurs'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-envelope"></span> Contact', | |||
'url' => $this->getUrlManager()->createUrl(['site/contact']), | |||
'active' => $this->getControllerAction() == 'site/contact', | |||
'options' => ['id' => 'li-contact'] | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-flag"></span> ' . ($producer ? Html::encode($producer->name) : ''), | |||
'url' => '#', | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-th-large"></span> Mon espace', | |||
'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']), | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-cog"></span> Administration', | |||
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']), | |||
] | |||
], | |||
'visible' => !Yii::$app->user->isGuest && $producer | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion', | |||
'url' => $this->getUrlManager()->createUrl(['site/login']), | |||
'visible' => Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'site/login' | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-user"></span> Inscription', | |||
'url' => $this->getUrlManager()->createUrl(['site/signup']), | |||
'visible' => Yii::$app->user->isGuest, | |||
'active' => $this->getControllerAction() == 'site/signup' | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-user"></span> ' . ((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '') . '. ', | |||
'options' => ['id' => 'label1'], | |||
'url' => '#', | |||
'items' => [ | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-user"></span> Profil', | |||
'url' => $this->getUrlManager()->createUrl(['user/update']), | |||
], | |||
[ | |||
'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion', | |||
'url' => $this->getUrlManager()->createUrl(['site/logout']), | |||
] | |||
], | |||
'visible' => !Yii::$app->user->isGuest | |||
], | |||
] | |||
]); | |||
?> | |||
</div> | |||
</div> | |||
</nav> | |||
</header> | |||
<?php if (!Yii::$app->user->isGuest): ?> | |||
<section id="bookmarked-producers"> | |||
<div class="container"> | |||
<?php | |||
$producersArray = Producer::find() | |||
->joinWith(['userProducer user_producer']) | |||
->where([ | |||
'user_producer.id_user' => User::getCurrentId(), | |||
'user_producer.bookmark' => 1, | |||
]) | |||
->all(); | |||
?> | |||
<?php if (count($producersArray)): ?> | |||
<h2>Mes producteurs ></h2> | |||
<div id="producers"> | |||
<?php foreach ($producersArray as $producer): ?> | |||
<a class="btn btn-xs btn-default" | |||
href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]); ?>"><?= Html::encode($producer->name); ?></a> | |||
<?php endforeach; ?> | |||
</div> | |||
<?php else: ?> | |||
<div id="discover"> | |||
<p>Vous n'avez aucun producteur dans vos favoris : </p> | |||
<a class="btn btn-default btn-lg" | |||
href="<?= $this->getUrlManager()->createUrl(['site/producers']); ?>"><span | |||
class="glyphicon glyphicon-grain"></span> Découvrez les producteurs</a> | |||
</div> | |||
<?php endif; ?> | |||
<div class="clr"></div> | |||
</div> | |||
</section> | |||
<?php endif; ?> | |||
<div id="main"> | |||
<section class="container" id="content"> | |||
<?php if (Yii::$app->session->hasFlash('error')): ?> | |||
<div class="alert alert-danger" role="alert"> | |||
<?= Yii::$app->session->getFlash('error') ?> | |||
</div> | |||
<?php endif; ?> | |||
<?php if (Yii::$app->session->hasFlash('success')): ?> | |||
<div class="alert alert-success" role="alert"> | |||
<?= Yii::$app->session->getFlash('success') ?> | |||
</div> | |||
<?php endif; ?> | |||
<?= $content ?> | |||
</section> | |||
</div> | |||
<footer id="footer"> | |||
<div class="container"> | |||
<a href="<?php echo $this->getUrlManager()->createUrl('site/contact'); ?>">Contact</a> • | |||
<a href="<?php echo $this->getUrlManager()->createUrl('site/mentions'); ?>">Mentions légales</a> • | |||
<a href="<?php echo $this->getUrlManager()->createUrl('site/cgv'); ?>">CGS</a> • | |||
<a id="code-source" href="https://forge.laclic.fr/Laclic/Opendistrib">Code source</a> | |||
</div> | |||
</footer> | |||
<?php $this->endBody() ?> | |||
</body> | |||
</html> | |||
<?php $this->endPage() ?> |
@@ -47,24 +47,21 @@ $this->setMeta('description', 'Prenez connaissance de nos mentions légales.') ; | |||
<h1>Mentions légales</h1> | |||
<h2>Éditeur</h2> | |||
<p><strong>distrib</strong><br /> | |||
42 Grande Rue<br /> | |||
25320 Vorges-les-Pins<br /> | |||
<p><strong>Opendistrib</strong><br /> | |||
6 rue de la Prévoyance<br /> | |||
25000 Besançon<br /> | |||
Responsable de publication : Guillaume BOURGEOIS</p> | |||
<p>Société hébergée par Cap'Entreprendre située 12 PLACE ROBERT SCHUMAN 57600 FORBACH<br /> | |||
Siret : 47784404700019.</p> | |||
<p>Micro-entreprise : Guillaume Bourgeois - Développeur web<br /> | |||
Siret : 51442998400024</p> | |||
<h2>Développement</h2> | |||
<p>Guillaume Bourgeois<br /> | |||
<a href="http://www.guillaume-bourgeois.fr/">www.guillaume-bourgeois.fr</a><br /> | |||
42 Grande Rue, 25320 Vorges-les-Pins | |||
6 rue de la Prévoyance, 25000 Besançon | |||
</p> | |||
<h2>Graphisme</h2> | |||
<p>Sébastien Bourgeois<br /> | |||
25290 Ornans | |||
</p> | |||
<p>Sébastien Bourgeois</p> | |||
<h2>Hébergement</h2> | |||
<p>La société <strong>Alwaysdata</strong>, SARL au capital de 5.000 € immatriculée au RCS de |
@@ -38,7 +38,7 @@ termes. | |||
namespace producer\components ; | |||
class ProducerView extends \common\components\MyView { | |||
class ProducerView extends \common\components\View { | |||
@@ -320,16 +320,7 @@ if (!Yii::$app->user->isGuest) { | |||
<a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions | |||
légales</a> • | |||
<a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/cgv']); ?>">CGS</a> • | |||
<a id="code-source" href="https://framagit.org/guillaume-bourgeois/distrib">Code source <img | |||
src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-framagit.png" | |||
alt="Hébergé par Framasoft"/> <img | |||
src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-gitlab.png" | |||
alt="Propulsé par Gitlab"/></a> • | |||
<a id="social-mastodon" href="https://mastodon.social/@opendistrib">Mastodon <img | |||
src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-mastodon.png" alt="Mastodon"/></a> | |||
• | |||
<a id="social-diaspora" href="https://framasphere.org/people/db12d640c64c0137f1d52a0000053625">Diaspora <img | |||
src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-diaspora.png" alt="Diaspora"/></a> | |||
<a id="code-source" href="https://forge.laclic.fr/Laclic/Opendistrib">Code source</a> | |||
</div> | |||
</footer> | |||
<script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script> |