], | ], | ||||
], | ], | ||||
'view' => [ | 'view' => [ | ||||
'class' => 'common\components\MyView', | |||||
'class' => 'common\components\ViewBackend', | |||||
], | ], | ||||
], | ], | ||||
'params' => $params, | 'params' => $params, |
public function actionInitDemo($key = '') | public function actionInitDemo($key = '') | ||||
{ | { | ||||
if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') { | if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') { | ||||
$producer = Producer::getDemoAccount(); | |||||
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | |||||
$producer = $producerRepository->getOneDemoAccount(); | |||||
if ($producer) { | if ($producer) { | ||||
// initialisation de la distribution à J+7 | // initialisation de la distribution à J+7 |
namespace common\components ; | namespace common\components ; | ||||
class MyView extends \yii\web\View | |||||
class View extends \yii\web\View | |||||
{ | { | ||||
var $title ; | var $title ; | ||||
var $page_title ; | var $page_title ; | ||||
'content' => $content | 'content' => $content | ||||
]); | ]); | ||||
} | } | ||||
public function getUrlManagerFrontend() | |||||
{ | |||||
return Yii::$app->urlManagerFrontend; | |||||
} | |||||
public function getUrlManagerProducer() | |||||
{ | |||||
return Yii::$app->urlManagerProducer; | |||||
} | |||||
public function getUrlManagerBackend() | |||||
{ | |||||
return Yii::$app->urlManagerBackend; | |||||
} | |||||
} | } |
<?php | |||||
namespace common\components; | |||||
class ViewBackend extends View | |||||
{ | |||||
public function getUrlManager() | |||||
{ | |||||
return $this->getUrlManagerBackend(); | |||||
} | |||||
} |
<?php | |||||
namespace common\components; | |||||
class ViewFrontend extends View | |||||
{ | |||||
public function getUrlManager() | |||||
{ | |||||
return $this->getUrlManagerFrontend(); | |||||
} | |||||
} |
return Yii::$app->logic; | 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) | public function setFlash($key, $value = true, $removeAfterAccess = true) | ||||
{ | { | ||||
Yii::$app->session->setFlash($key, $value, $removeAfterAccess); | Yii::$app->session->setFlash($key, $value, $removeAfterAccess); |
. '</ul>'; | . '</ul>'; | ||||
public static $creditFunctioningArray = [ | 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'; | const BEHAVIOR_DELETE_ORDER_DELETE = 'delete'; | ||||
public function rules() | public function rules() | ||||
{ | { | ||||
return [ | 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'], | |||||
]; | ]; | ||||
} | } | ||||
public function attributeLabels() | public function attributeLabels() | ||||
{ | { | ||||
return [ | 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', | |||||
]; | ]; | ||||
} | } | ||||
public function getUserProducer() | public function getUserProducer() | ||||
{ | { | ||||
return $this->hasMany( | return $this->hasMany( | ||||
UserProducer::className(), | |||||
['id_producer' => 'id'] | |||||
UserProducer::className(), | |||||
['id_producer' => 'id'] | |||||
); | ); | ||||
} | } | ||||
public function getContact() | public function getContact() | ||||
{ | { | ||||
return $this->hasMany(User::className(), ['id_producer' => 'id']) | return $this->hasMany(User::className(), ['id_producer' => 'id']) | ||||
->where(['status' => User::STATUS_PRODUCER]); | |||||
->where(['status' => User::STATUS_PRODUCER]); | |||||
} | } | ||||
public function getTaxRate() | public function getTaxRate() | ||||
public static function defaultOptionsSearch() | public static function defaultOptionsSearch() | ||||
{ | { | ||||
return [ | 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 = Yii::$app->logic->getProducerContainer(); | ||||
$producerContainer->getService()->addUser($idUser, $idProducer); | $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é. | * Retourne le CA de l'établissement pour un mois donné. | ||||
* | * | ||||
$connection = Yii::$app->getDb(); | $connection = Yii::$app->getDb(); | ||||
$command = $connection->createCommand( | $command = $connection->createCommand( | ||||
' | |||||
' | |||||
SELECT SUM(product_order.price * product_order.quantity) AS turnover | SELECT SUM(product_order.price * product_order.quantity) AS turnover | ||||
FROM `order`, product_order, distribution, product | FROM `order`, product_order, distribution, product | ||||
WHERE `order`.id = product_order.id_order | WHERE `order`.id = product_order.id_order | ||||
AND product_order.id_product = product.id | AND product_order.id_product = product.id | ||||
AND distribution.date > :date_begin | AND distribution.date > :date_begin | ||||
AND distribution.date < :date_end', | 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(); | $result = $command->queryOne(); | ||||
{ | { | ||||
$amountToBeBilled = 0; | $amountToBeBilled = 0; | ||||
$producerPriceRangeArray = ProducerPriceRange::find()->all(); | $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; | $amountToBeBilled = $priceRange->price; | ||||
} | } | ||||
} | } | ||||
if($format) { | |||||
if ($format) { | |||||
return Price::format($amountToBeBilled, 0); | return Price::format($amountToBeBilled, 0); | ||||
} | |||||
else { | |||||
} else { | |||||
return $amountToBeBilled; | return $amountToBeBilled; | ||||
} | } | ||||
} | } | ||||
$text = ''; | $text = ''; | ||||
$numMonthCurrent = date('m'); | $numMonthCurrent = date('m'); | ||||
if($numberOfMonths == 1 | |||||
if ($numberOfMonths == 1 | |||||
|| ($numberOfMonths == 3 && (in_array($numMonthCurrent, [1, 4, 7, 10]))) | || ($numberOfMonths == 3 && (in_array($numMonthCurrent, [1, 4, 7, 10]))) | ||||
|| ($numberOfMonths == 6 && (in_array($numMonthCurrent, [1, 7])))) { | || ($numberOfMonths == 6 && (in_array($numMonthCurrent, [1, 7])))) { | ||||
if ($isBold) $text .= '<strong>'; | if ($isBold) $text .= '<strong>'; | ||||
$text .= $this->getAmountToBeBilledByTurnover($turnover, true); | $text .= $this->getAmountToBeBilledByTurnover($turnover, true); | ||||
if ($isBold) $text .= '</strong>'; | if ($isBold) $text .= '</strong>'; | ||||
$text .= ' / '.Price::format($turnover, 0); | |||||
$text .= ' / ' . Price::format($turnover, 0); | |||||
$text .= '<br />'; | $text .= '<br />'; | ||||
} | } | ||||
} | } | ||||
public function getAmountBilledLastMonth() | public function getAmountBilledLastMonth() | ||||
{ | { | ||||
if($this->isBillingTypeClassic()) { | |||||
if ($this->isBillingTypeClassic()) { | |||||
$month = date('Y-m', strtotime('-1 month')); | $month = date('Y-m', strtotime('-1 month')); | ||||
return $this->getAmountToBeBilledByMonth($month); | return $this->getAmountToBeBilledByMonth($month); | ||||
} | |||||
elseif($this->isBillingTypeFreePrice()) { | |||||
} elseif ($this->isBillingTypeFreePrice()) { | |||||
return $this->free_price; | return $this->free_price; | ||||
} | } | ||||
} | } | ||||
$invoice = Invoice::searchOne( | $invoice = Invoice::searchOne( | ||||
['id_producer' => $this->id, 'period' => ':period'], | |||||
['params' => [':period' => $period]] | |||||
['id_producer' => $this->id, 'period' => ':period'], | |||||
['params' => [':period' => $period]] | |||||
); | ); | ||||
return $invoice; | return $invoice; | ||||
{ | { | ||||
$array = []; | $array = []; | ||||
$daysArray = [ | $daysArray = [ | ||||
'monday', | |||||
'tuesday', | |||||
'wednesday', | |||||
'thursday', | |||||
'friday', | |||||
'saturday', | |||||
'sunday' | |||||
'monday', | |||||
'tuesday', | |||||
'wednesday', | |||||
'thursday', | |||||
'friday', | |||||
'saturday', | |||||
'sunday' | |||||
]; | ]; | ||||
} | } | ||||
$array[$day] = [ | $array[$day] = [ | ||||
'order_delay' => $delay, | |||||
'order_deadline' => $deadline, | |||||
'order_delay' => $delay, | |||||
'order_deadline' => $deadline, | |||||
]; | ]; | ||||
} | } | ||||
public function hasSpecificDelays() | public function hasSpecificDelays() | ||||
{ | { | ||||
$daysArray = [ | $daysArray = [ | ||||
'monday', | |||||
'tuesday', | |||||
'wednesday', | |||||
'thursday', | |||||
'friday', | |||||
'saturday', | |||||
'sunday' | |||||
'monday', | |||||
'tuesday', | |||||
'wednesday', | |||||
'thursday', | |||||
'friday', | |||||
'saturday', | |||||
'sunday' | |||||
]; | ]; | ||||
foreach ($daysArray as $day) { | foreach ($daysArray as $day) { | ||||
public function savePrivateKeyApiStripe() | public function savePrivateKeyApiStripe() | ||||
{ | { | ||||
$this->savePrivateKeyStripe( | $this->savePrivateKeyStripe( | ||||
$this->getFilenamePrivateKeyApiStripe(), | |||||
$this->option_stripe_private_key | |||||
$this->getFilenamePrivateKeyApiStripe(), | |||||
$this->option_stripe_private_key | |||||
); | ); | ||||
} | } | ||||
public function savePrivateKeyEndpointStripe() | public function savePrivateKeyEndpointStripe() | ||||
{ | { | ||||
$this->savePrivateKeyStripe( | $this->savePrivateKeyStripe( | ||||
$this->getFilenamePrivateKeyEndpointStripe(), | |||||
$this->option_stripe_endpoint_secret | |||||
$this->getFilenamePrivateKeyEndpointStripe(), | |||||
$this->option_stripe_endpoint_secret | |||||
); | ); | ||||
} | } | ||||
public function getUrlLogo() | 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() | public function getEmailOpendistrib() | ||||
public function isOnlinePaymentActiveAndTypeOrder() | 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() | public static function getBillingFrequencyPopulateDropdown() | ||||
return $this->latest_version_opendistrib == GlobalParam::getOpendistribVersion(); | return $this->latest_version_opendistrib == GlobalParam::getOpendistribVersion(); | ||||
} | } | ||||
public function updateOpendistribVersion() { | |||||
public function updateOpendistribVersion() | |||||
{ | |||||
$versionsArray = Opendistrib::getVersions(); | $versionsArray = Opendistrib::getVersions(); | ||||
$this->latest_version_opendistrib = array_values($versionsArray)[0]; | $this->latest_version_opendistrib = array_values($versionsArray)[0]; | ||||
$this->save(); | $this->save(); | ||||
public function getOnlinePaymentMinimumAmount() | public function getOnlinePaymentMinimumAmount() | ||||
{ | { | ||||
$onlinePaymentMinimumAmount = self::getConfig('option_online_payment_minimum_amount'); | $onlinePaymentMinimumAmount = self::getConfig('option_online_payment_minimum_amount'); | ||||
if(!$onlinePaymentMinimumAmount) { | |||||
if (!$onlinePaymentMinimumAmount) { | |||||
$onlinePaymentMinimumAmount = self::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT; | $onlinePaymentMinimumAmount = self::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT; | ||||
} | } | ||||
namespace common\repositories; | namespace common\repositories; | ||||
use common\helpers\Departments; | |||||
use common\models\Producer; | use common\models\Producer; | ||||
use yii\helpers\Html; | |||||
class ProducerRepository | class ProducerRepository | ||||
{ | { | ||||
* | * | ||||
* @return Producer | * @return Producer | ||||
*/ | */ | ||||
public function getDemoAccount() | |||||
public function getOneDemoAccount() | |||||
{ | { | ||||
return Producer::find()->where('name LIKE \'Démo\'')->one(); | 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 | |||||
]; | |||||
} | |||||
} | } |
namespace common\repositories; | namespace common\repositories; | ||||
use common\models\User; | |||||
class UserRepository | class UserRepository | ||||
{ | { | ||||
public function getOneById($id) | |||||
{ | |||||
return User::searchOne(['id' => $id]); | |||||
} | |||||
} | } |
], | ], | ||||
], | ], | ||||
'view' => [ | 'view' => [ | ||||
'class' => 'common\components\MyView', | |||||
'class' => 'common\components\ViewFrontend', | |||||
], | ], | ||||
'urlManager' => $common_config_main['components']['urlManagerFrontend'], | 'urlManager' => $common_config_main['components']['urlManagerFrontend'], | ||||
], | ], |
namespace frontend\controllers; | namespace frontend\controllers; | ||||
use yii; | |||||
use common\controllers\CommonController; | use common\controllers\CommonController; | ||||
class FrontendController extends CommonController | class FrontendController extends CommonController |
namespace frontend\controllers; | namespace frontend\controllers; | ||||
use common\models\User; | use common\models\User; | ||||
use frontend\forms\ProducerCodeForm; | |||||
use Yii; | 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 common\forms\ContactForm; | ||||
use yii\base\InvalidParamException; | use yii\base\InvalidParamException; | ||||
use yii\data\ActiveDataProvider; | use yii\data\ActiveDataProvider; | ||||
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | $producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | ||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'producerDemoAccount' => $producerRepository->getDemoAccount(), | |||||
'producerDemoAccount' => $producerRepository->getOneDemoAccount(), | |||||
'dataProviderPrices' => $this->getDataProviderPrices() | 'dataProviderPrices' => $this->getDataProviderPrices() | ||||
]); | ]); | ||||
} | } | ||||
]); | ]); | ||||
} | } | ||||
/** | |||||
* 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. | * Affiche la page de connexion et traite le formulaire de connexion. | ||||
* | * | ||||
$model = new LoginForm(); | $model = new LoginForm(); | ||||
if ($model->load(Yii::$app->request->post()) && $model->login()) { | if ($model->load(Yii::$app->request->post()) && $model->login()) { | ||||
$returnUrl = Yii::$app->request->get('return_url'); | $returnUrl = Yii::$app->request->get('return_url'); | ||||
if ($returnUrl) { | if ($returnUrl) { | ||||
return $this->redirect($returnUrl); | return $this->redirect($returnUrl); | ||||
} | } | ||||
else { | 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(); | return $this->goBack(); | ||||
} | } | ||||
} | } | ||||
public function actionLogout() | public function actionLogout() | ||||
{ | { | ||||
Yii::$app->user->logout(); | Yii::$app->user->logout(); | ||||
return $this->goHome(); | return $this->goHome(); | ||||
} | } | ||||
public function actionSignup() | public function actionSignup() | ||||
{ | { | ||||
$model = new SignupForm(); | $model = new SignupForm(); | ||||
$producerRepository = Yii::$app->logic->getProducerContainer()->getRepository(); | |||||
if ($model->load(Yii::$app->request->post())) { | if ($model->load(Yii::$app->request->post())) { | ||||
$user = $model->signup(); | $user = $model->signup(); | ||||
if ($user) { | 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'])); | $this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index'])); | ||||
} else { | |||||
$producer = Producer::findOne($model->id_producer); | |||||
} | |||||
else { | |||||
$producer = $producerRepository->getOneById($model->id_producer); | |||||
if ($producer) { | if ($producer) { | ||||
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | $this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); | ||||
} else { | |||||
} | |||||
else { | |||||
$this->redirect(['site/index']); | $this->redirect(['site/index']); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// liste des producteurs disponibles | |||||
$producersArray = Producer::getProducerPopulateDropdown(); | |||||
// Liste des producteurs disponibles | |||||
$producersArray = $producerRepository->getPopulateDropdown(); | |||||
$dataProducers = $producersArray['data']; | $dataProducers = $producersArray['data']; | ||||
$optionsProducers = $producersArray['options']; | $optionsProducers = $producersArray['options']; | ||||
public function actionRequestPasswordReset() | public function actionRequestPasswordReset() | ||||
{ | { | ||||
$model = new PasswordResetRequestForm(); | $model = new PasswordResetRequestForm(); | ||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { | if ($model->load(Yii::$app->request->post()) && $model->validate()) { | ||||
if ($model->sendEmail()) { | 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(); | 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.'); | |||||
} | } | ||||
} | } | ||||
throw new BadRequestHttpException($e->getMessage()); | 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(); | return $this->goHome(); | ||||
} | } | ||||
]); | ]); | ||||
} | } | ||||
/** | |||||
* 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 | * Affiche le formulaire de demande de code pour accéder à certains | ||||
* producteurs. | * producteurs. | ||||
*/ | */ | ||||
public function actionProducerCode($id) | public function actionProducerCode($id) | ||||
{ | { | ||||
$producer = Producer::findOne($id); | |||||
$producerContainer = $this->getLogic()->getProducerContainer(); | |||||
$producer = $producerContainer->getRepository()->getOneById($id); | |||||
if (!$producer) { | if (!$producer) { | ||||
throw new \yii\web\HttpException(404, 'Producteur introuvable'); | throw new \yii\web\HttpException(404, 'Producteur introuvable'); | ||||
} | } | ||||
$producerCodeForm = new ProducerCodeForm; | |||||
$producerCodeForm = new ProducerCodeForm(); | |||||
$producerCodeForm->id_producer = $id; | $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', [ | return $this->render('producer_code', [ | ||||
{ | { | ||||
$loginForm = new LoginForm(); | $loginForm = new LoginForm(); | ||||
$signupForm = new SignupForm(); | $signupForm = new SignupForm(); | ||||
$producerContainer = $this->getLogic()->getProducerContainer(); | |||||
$producer = Producer::searchOne([ | |||||
'id' => $id | |||||
]); | |||||
$producer = $producerContainer->getRepository()->getOneById($id); | |||||
$loginForm->id_producer = $id; | $loginForm->id_producer = $id; | ||||
$signupForm->id_producer = $id; | $signupForm->id_producer = $id; | ||||
$signupForm->option_user_producer = 'user'; | $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)) { | if (!strlen($producer->code)) { | ||||
Producer::addUser(User::getCurrentId(), $id); | |||||
$producerContainer->getService()->addUser(User::getCurrentId(), $id); | |||||
} | } | ||||
$this->redirect($returnUrl); | $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); | $this->redirect($returnUrl); | ||||
} | } | ||||
public function actionProducerOffline($id) | public function actionProducerOffline($id) | ||||
{ | { | ||||
$producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | $producerRepository = $this->getLogic()->getProducerContainer()->getRepository(); | ||||
return $this->render('producer_offline', [ | return $this->render('producer_offline', [ | ||||
'producer' => $producerRepository->getOneById($id), | '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'); | |||||
} | |||||
} | } |
*/ | */ | ||||
public function actionUpdate() | 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 | // l'utilisateur ne peut pas changer d'adresse email | ||||
$oldModel = $this->findModel(User::getCurrentId()); | |||||
$oldModel = $this->findModel($idUser); | |||||
$model->email = $oldModel->email; | $model->email = $oldModel->email; | ||||
// modification du mot de passe | // modification du mot de passe | ||||
if (strlen($model->password_new)) { | if (strlen($model->password_new)) { | ||||
//$model->setPassword($model->password_new) ; | |||||
$model->password_hash = Yii::$app->security->generatePasswordHash($model->password_new); | $model->password_hash = Yii::$app->security->generatePasswordHash($model->password_new); | ||||
$model->password_old = ''; | $model->password_old = ''; | ||||
$model->save(); | $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', [ | return $this->render('update', [ | ||||
'model' => $model, | 'model' => $model, | ||||
]); | ]); | ||||
} else { | |||||
} | |||||
else { | |||||
if (!$model->validate()) { | 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', [ | return $this->render('update', [ | ||||
*/ | */ | ||||
protected function findModel($id) | protected function findModel($id) | ||||
{ | { | ||||
if (($model = User::findOne($id)) !== null) { | |||||
$userRepository = $this->getLogic()->getUserContainer()->getRepository(); | |||||
if (($model = $userRepository->getOneById($id)) !== null) { | |||||
return $model; | return $model; | ||||
} else { | |||||
} | |||||
else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | throw new NotFoundHttpException('The requested page does not exist.'); | ||||
} | } | ||||
} | } |
termes. | termes. | ||||
*/ | */ | ||||
namespace frontend\models; | |||||
namespace frontend\forms; | |||||
use common\models\User; | use common\models\User; | ||||
use yii\base\Model; | use yii\base\Model; |
termes. | termes. | ||||
*/ | */ | ||||
namespace frontend\models; | |||||
namespace frontend\forms; | |||||
use Yii; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
/** | /** | ||||
*/ | */ | ||||
class ProducerCodeForm extends Model | class ProducerCodeForm extends Model | ||||
{ | { | ||||
public $id_producer ; | public $id_producer ; | ||||
public $code; | public $code; | ||||
termes. | termes. | ||||
*/ | */ | ||||
namespace frontend\models; | |||||
namespace frontend\forms; | |||||
use common\models\User; | use common\models\User; | ||||
use yii\base\InvalidParamException; | use yii\base\InvalidParamException; |
* termes. | * termes. | ||||
*/ | */ | ||||
namespace frontend\models; | |||||
namespace frontend\forms; | |||||
use Yii; | use Yii; | ||||
use common\models\User; | use common\models\User; |
<?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.'); | |||||
} | |||||
} | |||||
<?php | <?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\helpers\Html; | ||||
use yii\bootstrap\Nav; | use yii\bootstrap\Nav; | ||||
use yii\bootstrap\NavBar; | use yii\bootstrap\NavBar; | ||||
use yii\widgets\Breadcrumbs; | use yii\widgets\Breadcrumbs; | ||||
use common\widgets\Alert; | use common\widgets\Alert; | ||||
use common\helpers\Url ; | |||||
use common\helpers\Url; | |||||
/* @var $this \yii\web\View */ | /* @var $this \yii\web\View */ | ||||
/* @var $content string */ | /* @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); | \common\assets\CommonAsset::register($this); | ||||
\frontend\assets\AppAsset::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() ?> | <?php $this->beginPage() ?> | ||||
<!DOCTYPE html> | <!DOCTYPE html> | ||||
<head> | <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 charset="utf-8"> | ||||
<meta name="viewport" content="width=device-width, initial-scale=1"> | <meta name="viewport" content="width=device-width, initial-scale=1"> | ||||
<?= Html::csrfMetaTags() ?> | <?= 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]--> | <!--[if IE]><link rel="shortcut icon" type="image/x-icon" href="<?= Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon.ico" /><![endif]--> | ||||
<?php $this->head() ?> | <?php $this->head() ?> | ||||
<!--[if lt IE 9]> | <!--[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]--> | <![endif]--> | ||||
<!--[if IE 7]> | <!--[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]--> | <![endif]--> | ||||
</head> | </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> | </body> | ||||
</html> | </html> | ||||
<?php $this->endPage() ?> | <?php $this->endPage() ?> |
<h1>Mentions légales</h1> | <h1>Mentions légales</h1> | ||||
<h2>Éditeur</h2> | <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> | 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> | <h2>Développement</h2> | ||||
<p>Guillaume Bourgeois<br /> | <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> | </p> | ||||
<h2>Graphisme</h2> | <h2>Graphisme</h2> | ||||
<p>Sébastien Bourgeois<br /> | |||||
25290 Ornans | |||||
</p> | |||||
<p>Sébastien Bourgeois</p> | |||||
<h2>Hébergement</h2> | <h2>Hébergement</h2> | ||||
<p>La société <strong>Alwaysdata</strong>, SARL au capital de 5.000 € immatriculée au RCS de | <p>La société <strong>Alwaysdata</strong>, SARL au capital de 5.000 € immatriculée au RCS de |
namespace producer\components ; | namespace producer\components ; | ||||
class ProducerView extends \common\components\MyView { | |||||
class ProducerView extends \common\components\View { | |||||
<a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions | <a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/mentions']); ?>">Mentions | ||||
légales</a> • | légales</a> • | ||||
<a href="<?php echo Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/cgv']); ?>">CGS</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> | </div> | ||||
</footer> | </footer> | ||||
<script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script> | <script type="text/javascript" src="https://cdn.polyfill.io/v3/polyfill.min.js?features=Intl.~locale.fr"></script> |