[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['?'], ] ], ], ]; } public function actionInitBddDemo($key = '') { if ($key == '45432df6e842ac71aa0b5bb6b9f25d44' && YII_ENV == 'demo') { $arr_noms = [ 'Martin', 'Bernard', 'Thomas', 'Petit', 'Robert', 'Richard', 'Durand', 'Dubois', 'Moreau', 'Laurent', 'Simon', 'Michel', 'Lefebvre', 'Leroy', 'Roux', 'David', 'Bertrand', 'Morel', 'Fournier', 'Girard', 'Bonnet', 'Dupont', 'Lambert', 'Fontaine', 'Rousseau', 'Vincent', 'Muller', 'Lefevre', 'Faure', 'Andre', 'Mercier', 'Blanc', 'Guerin', 'Boyer', 'Garnier', 'Chevalier', 'François', 'Legrand', 'Gauthier', 'Garcia', 'Perrin', 'Robin', 'Clement', 'Morin', 'Nicolas', 'Henry', 'Roussel', 'Mathieu', 'Gautier', 'Masson', 'Marchand', 'Duval', 'Denis', 'Dumont', 'Marie', 'Lemaire', 'Noël', 'Meyer', 'Dufour', 'Meunier', 'Brun', 'Blanchard', 'Giraud', 'Joly', 'Rivière', 'Lucas', 'Brunet', 'Gaillard', 'Barbier', 'Arnaud', 'Martinez', 'Gerard', 'Roche', 'Renard', 'Schmitt', 'Roy', 'Leroux', 'Colin', 'Vidal', 'Caron', 'Picard', 'Roger', 'Fabre', 'Aubert', 'Lemoine', 'Renaud', 'Dumas', 'Lacroix', 'Olivier', 'Philippe', 'Bourgeois', 'Pierre', 'Benoit', 'Rey', 'Leclerc', 'Payet', 'Rolland', 'Lecomte', 'Lopez', 'Jean', 'Dupuis', 'Guillot', 'Hubert', 'Berger', 'Carpentier', 'Sanchez', 'Dupuis', 'Moulin', 'Louis', 'Deschamps', 'Huet', 'Vasseur', 'Perez', 'Trouillot', 'Fusillier', 'Massenot', 'Boucher', 'Fleury', 'Royer', 'Klein', 'Jacquet', 'Jaquin', 'Adam', 'Paris', 'Poirier', 'Aubry', 'Guyot', 'Carré', 'Charles', 'Charpentier', 'Menard', 'Bailly', 'Bertin', 'Le Gall', 'Collet', 'Leger', 'Bouvier', 'Millet', 'Daniel', 'Langlois', 'Pelletier', 'Perrier', 'Leblanc', 'Lebrun', 'Monnier', 'Michaud', 'Laporte', 'Carlier', 'Pasquier', 'Delaunay', 'Lamy', 'Gilbert', 'Lejeune', 'Pichon', 'Cordier', 'Barthelemy', 'Perret', 'Reynaud', 'Humbert', 'Marechal', 'Bernard', 'Lemaitre', 'Gay', 'Bouchet', 'Da Silva', 'Chauvin', 'Chevalier', 'Tessier', 'Poulain', 'Girondin', 'Gillet', 'Guichard' ]; $arr_prenoms = [ 'Adel', 'Antonin', 'Armand', 'Arnaud', 'Aymeric', 'Baptiste', 'Barnabé', 'Bernard', 'Brice', 'Baudouin', 'Camille', 'Cassandre', 'Célestin', 'Christian', 'Clément', 'Cyril', 'Claude', 'Damien', 'Daniel', 'David', 'Delphin', 'Denis', 'Didier', 'Dimitri', 'Dorothée', 'Désiré', 'Edgard', 'Etienne', 'Eugène', 'Eudes', 'Eric', 'Fabien', 'Fabrice', 'Flavien', 'Florent', 'Francois', 'Frédéric', 'Gabin', 'Gabriel', 'Gautier', 'Gilles', 'Guy', 'Hervé', 'Huvert', 'Hugues', 'Hector', 'Jacques', 'Jason', 'Jean', 'Jeannot', 'Johan', 'Julien', 'Léon', 'Lionel', 'Loïc', 'Lucas', 'Luc', 'Lucien', 'Maurice', 'Maxence', 'Maxime', 'Michel', 'Morgan', 'Nicolas', 'Normand', 'Norbert', 'Olivier,', 'Pascal', 'Patrice', 'Pierrick', 'Raphael', 'Roland', 'Stéphane', 'Sylvain', 'Sylvestre', 'Timothée', 'Thomas', 'Tristan', 'Ulysse', 'Vincent', 'Victor', 'Vivien', 'Adeline', 'Albane', 'Alix', 'Amélie', 'Arielle', 'Aurelle', 'Blandine', 'Blanche', 'Brigitte', 'Berthe', 'Camille', 'Capucine', 'Catherine', 'Cécile', 'Charlotte', 'Chloé', 'Claudine', 'Clémenence', 'Constance', 'Cyrielle', 'Corinne', 'Danielle', 'Delphine', 'Denise', 'Dominique', 'Diane', 'Édith', 'Éliane', 'Éléonore', 'Émilie', 'Emmanuelle', 'Ève', 'Évelyne', 'Fanny', 'Flavie', 'Flore', 'Françoise', 'Gabrielle', 'Gaëlle', 'Geneviève', 'Georgette', 'Germaine', 'Gertrude', 'Gisèle', 'Gwenaëlle', 'Hélène', 'Héloïse', 'Henriette', 'Huguette', 'Inès', 'Isabelle', 'Jacqueline', 'Jeanne', 'Joëlle', 'Joséphine', 'Juliette', 'Justine', 'Julie', 'Laura', 'Laure', 'Léa', 'Léonie', 'Lucie', 'Lucienne', 'Lorraine', 'Lucille', 'Ludivine', 'Lydie', 'Margot', 'Marion', 'Marlène', 'Marthe', 'Mélodie', 'Monique', 'Noémie', 'Nadine', 'Nadège', 'Océane', 'Odette', 'Odile', 'Paulette', 'Rose', 'Roseline', 'Renée', 'Sabine', 'Sophie', 'Suzanne', 'Sylvie', 'Thérèse', ]; $arr_noms_checked = []; $arr_prenoms_checked = []; $users = User::find() ->joinWith('userEtablissement') ->where('user_etablissement.id_etablissement = 1') ->all(); foreach ($users as $u) { if ($u->email != 'boulanger@laboiteapain.net') { do { $i_nom = rand(0, count($arr_noms) - 1); $i_prenom = rand(0, count($arr_prenoms) - 1); } while (isset($arr_noms_checked[$i_nom]) || isset($arr_prenoms_checked[$i_prenom])); $arr_noms_checked[$i_nom] = true; $arr_prenoms_checked[$i_prenom] = true; $nom = $arr_noms[$i_nom]; $prenom = $arr_prenoms[$i_prenom]; $u->nom = $nom; $u->prenom = $prenom; $email = strtolower($prenom) . '.' . strtolower($nom) . '@yopmail.com'; $email = htmlentities($email, ENT_NOQUOTES, 'utf-8'); $email = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $email); $email = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $email); // pour les ligatures e.g. 'œ' $email = preg_replace('#&[^;]+;#', '', $email); // supprime les autres caractères $email = str_replace(' ', '', $email); $u->email = $email; $u->telephone = '0600000000'; } else { /* * Le hash du mot de passe en production est volontairement corrompu * pour empêcher la connexion des utilisateurs via ce compte en prod. * Lors de l'initialisation des utilisateurs sur l'espace de démo, * on remet le bon hash pour que ce compte soit disponible. */ $u->password_hash = '$2y$13$2D5T3Eo0pySmtlAuEGcfmOdTR5mleog8Y6YPGhop/ych6pbj6aN2y'; } $u->save(); } $commandes = Commande::find() ->where('username IS NOT NULL') ->all(); foreach ($commandes as $c) { $nom = $arr_noms[rand(0, count($arr_noms) - 1)]; $prenom = $arr_prenoms[rand(0, count($arr_prenoms) - 1)]; $c->username = $prenom . ' ' . $nom; $c->save(); } $commandes_auto = CommandeAuto::find() ->where('username IS NOT NULL') ->all(); foreach ($commandes_auto as $c) { $nom = $arr_noms[rand(0, count($arr_noms) - 1)]; $prenom = $arr_prenoms[rand(0, count($arr_prenoms) - 1)]; $c->username = $prenom . ' ' . $nom; $c->save(); } } } public function actionSendCommandes($key = '') { if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') { $heure = date('H'); if ($heure == '00') { $date = date('Y-m-d'); } else { $date = date('Y-m-d', time() + 24 * 60 * 60); } $etablissements = Etablissement::find()->all(); foreach ($etablissements as $e) { $production = Production::findOne([ 'date' => $date, 'actif' => 1, 'id_etablissement' => $e['id'], ]); if ($production && $heure == $e['heure_limite_commande']) { $commandes = Commande::find() ->with('commandeProduits', 'user') ->joinWith('production') ->where(['production.date' => $date]) ->andWhere(['production.id_etablissement' => $e['id']]) ->orderBy('date ASC') ->all(); $user = User::findOne([ 'id_etablissement' => $e['id'], 'status' => User::STATUS_BOULANGER ]); $mail = Yii::$app->mailer->compose( [ 'html' => 'cronRecapCommandes-html', 'text' => 'cronRecapCommandes-text', ], [ 'date' => $date, 'commandes' => $commandes ] ) ->setTo($user->email) ->setFrom([Yii::$app->params['adminEmail'] => 'La boîte à pain']); if (count($commandes)) { $sujet = '[La boîte à pain] Commandes du ' . date('d/m', strtotime($date)); // génération du pdf de commande Yii::$app->runAction('commande/report-cron', [ 'date' => $date, 'save' => true, 'id_etablissement' => $e['id'], 'key' => '64ac0bdab7e9f5e48c4d991ec5201d57' ]); $mail->attach(Yii::getAlias('@app/web/pdf/Commandes-' . $date . '-' . $e['id'] . '.pdf')); } else { $sujet = '[La boîte à pain] Aucune commande'; } $mail->setSubject($sujet) ->send(); } } } } }