Преглед изворни кода

Système de paiement

Mise en place d'un système de paiement via Paypal.
master
keun пре 8 година
родитељ
комит
b9ebd2dffc
16 измењених фајлова са 226 додато и 71 уклоњено
  1. +22
    -0
      backend/controllers/BackendController.php
  2. +1
    -1
      backend/controllers/CommandeController.php
  3. +1
    -1
      backend/controllers/EtablissementController.php
  4. +23
    -6
      backend/controllers/PaiementController.php
  5. +1
    -1
      backend/controllers/PointVenteController.php
  6. +1
    -1
      backend/controllers/ProduitController.php
  7. +1
    -1
      backend/controllers/SiteController.php
  8. +1
    -1
      backend/controllers/StatsController.php
  9. +1
    -1
      backend/controllers/UserController.php
  10. +1
    -1
      backend/controllers/VracController.php
  11. +10
    -0
      backend/views/layouts/main.php
  12. BIN
      backend/web/.sass-cache/c8fef7d48da4dc7f024edc2b0fada9d8d6de5dac/screen.scssc
  13. +72
    -57
      backend/web/css/screen.css
  14. +13
    -0
      backend/web/sass/screen.scss
  15. +46
    -0
      common/models/User.php
  16. +32
    -0
      console/migrations/m161113_155900_systeme_paiement.php

+ 22
- 0
backend/controllers/BackendController.php Прегледај датотеку

@@ -0,0 +1,22 @@
<?php

namespace backend\controllers;

use yii ;

class BackendController extends \yii\web\Controller
{
public function beforeAction($event)
{
if(Yii::$app->user->identity->etatPaiementEtablissement() == 'essai-terminee')
{
$this->redirect(['paiement/index']) ;
}
return parent::beforeAction($event);
}
}

?>

+ 1
- 1
backend/controllers/CommandeController.php Прегледај датотеку

@@ -17,7 +17,7 @@ use common\models\User;
use common\models\CommandeProduit;
use kartik\mpdf\Pdf;

class CommandeController extends \yii\web\Controller {
class CommandeController extends BackendController {

var $enableCsrfValidation = false;


+ 1
- 1
backend/controllers/EtablissementController.php Прегледај датотеку

@@ -16,7 +16,7 @@ use common\models\Etablissement ;
/**
* UserController implements the CRUD actions for User model.
*/
class EtablissementController extends Controller
class EtablissementController extends BackendController
{
public function behaviors()
{

+ 23
- 6
backend/controllers/PaiementController.php Прегледај датотеку

@@ -89,20 +89,37 @@ class PaiementController extends Controller
$ipn = new PayPal_Ipn(false);
if ($ipn->init())
{
/* Get any key/value */
$custom = $ipn->getKeyValue('custom');
/*
Add your code here
*/
$txn_type = $ipn->getKeyValue('txn_type');
$message = '' ;
/*$message = '' ;

foreach($_POST as $key => $val) {
$message .= $key.' : '.$val."\n" ;
}

mail('guillaume.bourgeois13@laposte.net','Données IPN', $message) ;
mail('guillaume.bourgeois13@laposte.net','Données IPN', $message) ;*/
if($txn_type == 'subscr_payment' && $custom)
{
$user = User::findOne($custom) ;
if($user)
{
$etablissement = Etablissement::findOne($user->id_etablissement) ;
if($etablissement)
{
$date = $etablissement->date_paiement ;
if(!$date) $date = time() ;
else $date = strtotime($date) ;
$date += 30*24*60*60 ;
$etablissement->date_paiement = date('Y-m-d H:i:s',$date) ;
$etablissement->save() ;
}
}
}
}
}
/* Enable again if you use it */

+ 1
- 1
backend/controllers/PointVenteController.php Прегледај датотеку

@@ -14,7 +14,7 @@ use common\models\User;
/**
* PointVenteController implements the CRUD actions for PointVente model.
*/
class PointVenteController extends Controller
class PointVenteController extends BackendController
{
public function behaviors()
{

+ 1
- 1
backend/controllers/ProduitController.php Прегледај датотеку

@@ -21,7 +21,7 @@ use common\helpers\Upload;
/**
* ProduitController implements the CRUD actions for Produit model.
*/
class ProduitController extends Controller
class ProduitController extends BackendController
{
var $enableCsrfValidation = false ;

+ 1
- 1
backend/controllers/SiteController.php Прегледај датотеку

@@ -11,7 +11,7 @@ use yii\filters\VerbFilter;
/**
* Site controller
*/
class SiteController extends Controller
class SiteController extends BackendController
{
/**
* @inheritdoc

+ 1
- 1
backend/controllers/StatsController.php Прегледај датотеку

@@ -11,7 +11,7 @@ use DateTime;
use DateInterval;
use DatePeriod;

class StatsController extends Controller {
class StatsController extends BackendController {
public function behaviors()
{

+ 1
- 1
backend/controllers/UserController.php Прегледај датотеку

@@ -15,7 +15,7 @@ use common\helpers\Upload ;
/**
* UserController implements the CRUD actions for User model.
*/
class UserController extends Controller
class UserController extends BackendController
{
public function behaviors()
{

+ 1
- 1
backend/controllers/VracController.php Прегледај датотеку

@@ -19,7 +19,7 @@ use yii\web\UploadedFile;
/**
* ProduitController implements the CRUD actions for Produit model.
*/
class VracController extends Controller
class VracController extends BackendController
{
var $enableCsrfValidation = false ;

+ 10
- 0
backend/views/layouts/main.php Прегледај датотеку

@@ -74,6 +74,16 @@ AppAsset::register($this);
<?php if(!Yii::$app->user->isGuest): ?>
<div class="nom-boulange">
<span><?= Html::encode(Yii::$app->user->identity->getNomMagasin()) ; ?></span>
<?php $etat_paiement_etablissement = Yii::$app->user->identity->etatPaiementEtablissement(); ?>
<?php if($etat_paiement_etablissement == 'essai'): ?>
<span id="etat-paiement-etablissement">Période d'essai gratuite
<span class="strong"><?php echo Yii::$app->user->identity->periodeEssai(); ?> jours</span>
</span>
<?php elseif($etat_paiement_etablissement == 'essai-terminee'): ?>
<span id="etat-paiement-etablissement">
<span class="strong">Période d'essai gratuite terminée</span>
</span>
<?php endif; ?>
</div>
<?php endif; ?>
<?= Breadcrumbs::widget([

BIN
backend/web/.sass-cache/c8fef7d48da4dc7f024edc2b0fada9d8d6de5dac/screen.scssc Прегледај датотеку


+ 72
- 57
backend/web/css/screen.css Прегледај датотеку

@@ -79,151 +79,166 @@ a:hover, a:focus, a:active {
font-size: 20px;
padding: 8px 15px;
}
/* line 81, ../sass/screen.scss */
.nom-boulange #etat-paiement-etablissement {
float: right;
text-align: right;
color: #F8F1DD;
}
/* line 85, ../sass/screen.scss */
.nom-boulange #etat-paiement-etablissement .strong {
background-color: white;
color: #BB8757;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
padding: 0px 10px;
}

/* line 83, ../sass/screen.scss */
/* line 96, ../sass/screen.scss */
.table thead th.actions {
width: 220px;
}
/* line 86, ../sass/screen.scss */
/* line 99, ../sass/screen.scss */
.table thead th.order {
width: 58px;
}
/* line 89, ../sass/screen.scss */
/* line 102, ../sass/screen.scss */
.table thead th.actif {
width: 75px;
text-align: center;
}
/* line 95, ../sass/screen.scss */
/* line 108, ../sass/screen.scss */
.table tbody td.center {
text-align: center;
}

/* line 108, ../sass/screen.scss */
/* line 121, ../sass/screen.scss */
#page-commande h1 .btn-group {
float: right;
}
/* line 113, ../sass/screen.scss */
/* line 126, ../sass/screen.scss */
#page-commande #jours-production {
display: none;
}
/* line 119, ../sass/screen.scss */
/* line 132, ../sass/screen.scss */
#page-commande #calendar h2 {
font-size: 20px;
position: relative;
top: 3px;
}
/* line 125, ../sass/screen.scss */
/* line 138, ../sass/screen.scss */
#page-commande #calendar .fc-header-title {
margin-left: 10px;
}
/* line 131, ../sass/screen.scss */
/* line 144, ../sass/screen.scss */
#page-commande #calendar .dayWithEvent {
background-color: #fee48d;
cursor: pointer;
}
/* line 135, ../sass/screen.scss */
/* line 148, ../sass/screen.scss */
#page-commande #calendar .fc-event-container {
display: none;
}
/* line 136, ../sass/screen.scss */
/* line 149, ../sass/screen.scss */
#page-commande #calendar .fc-today {
border-bottom: solid 1px #C9302C;
background-color: white;
}
/* line 140, ../sass/screen.scss */
/* line 153, ../sass/screen.scss */
#page-commande #calendar .fc-today.dayWithEvent {
background-color: #fee48d;
}
/* line 145, ../sass/screen.scss */
/* line 158, ../sass/screen.scss */
#page-commande #calendar .fc-day {
cursor: pointer;
text-align: center;
}
/* line 148, ../sass/screen.scss */
/* line 161, ../sass/screen.scss */
#page-commande #calendar .fc-day:hover {
-moz-box-shadow: 0px 0px 2px black inset;
-webkit-box-shadow: 0px 0px 2px black inset;
box-shadow: 0px 0px 2px black inset;
}
/* line 153, ../sass/screen.scss */
/* line 166, ../sass/screen.scss */
#page-commande #calendar .current-date {
-moz-box-shadow: 0px 0px 2px black inset;
-webkit-box-shadow: 0px 0px 2px black inset;
box-shadow: 0px 0px 2px black inset;
}
/* line 157, ../sass/screen.scss */
/* line 170, ../sass/screen.scss */
#page-commande #calendar .fc-day-number {
float: none;
padding-top: 2px;
}
/* line 169, ../sass/screen.scss */
/* line 182, ../sass/screen.scss */
#page-commande #produits-production .overflow table {
width: 100%;
}
/* line 173, ../sass/screen.scss */
/* line 186, ../sass/screen.scss */
#page-commande #produits-production .overflow thead, #page-commande #produits-production .overflow tbody, #page-commande #produits-production .overflow tr, #page-commande #produits-production .overflow td, #page-commande #produits-production .overflow th {
display: block;
}
/* line 175, ../sass/screen.scss */
/* line 188, ../sass/screen.scss */
#page-commande #produits-production .overflow tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}
/* line 182, ../sass/screen.scss */
/* line 195, ../sass/screen.scss */
#page-commande #produits-production .overflow thead th {
height: 30px;
/*text-align: left;*/
}
/* line 188, ../sass/screen.scss */
/* line 201, ../sass/screen.scss */
#page-commande #produits-production .overflow tbody {
height: 200px;
overflow-y: auto;
}
/* line 196, ../sass/screen.scss */
/* line 209, ../sass/screen.scss */
#page-commande #produits-production .overflow thead th {
width: 32%;
float: left;
}
/* line 201, ../sass/screen.scss */
/* line 214, ../sass/screen.scss */
#page-commande #produits-production .overflow tbody td {
width: 33%;
float: left;
}
/* line 206, ../sass/screen.scss */
/* line 219, ../sass/screen.scss */
#page-commande #produits-production .overflow .td-produit {
width: 60%;
}
/* line 209, ../sass/screen.scss */
/* line 222, ../sass/screen.scss */
#page-commande #produits-production .overflow .td-actif, #page-commande #produits-production .overflow .td-max {
width: 20%;
text-align: center;
}
/* line 215, ../sass/screen.scss */
/* line 228, ../sass/screen.scss */
#page-commande #produits-production .overflow thead .td-produit {
width: 57%;
}
/* line 221, ../sass/screen.scss */
/* line 234, ../sass/screen.scss */
#page-commande #produits-production input.quantite-max {
background-color: white;
border: 1px solid #e0e0e0;
text-align: center;
width: 50px;
}
/* line 229, ../sass/screen.scss */
/* line 242, ../sass/screen.scss */
#page-commande #produits-production td label {
font-weight: normal;
}
/* line 235, ../sass/screen.scss */
/* line 248, ../sass/screen.scss */
#page-commande .form-commandes-point-vente {
margin-top: 20px;
}
/* line 239, ../sass/screen.scss */
/* line 252, ../sass/screen.scss */
#page-commande .form-commandes-point-vente table {
border-bottom: solid 1px #e0e0e0;
}
/* line 243, ../sass/screen.scss */
/* line 256, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .title-point-vente {
background-color: #fff8e2;
border-left: solid 3px #BB8757;
@@ -231,76 +246,76 @@ a:hover, a:focus, a:active {
text-align: left;
padding: 10px;
}
/* line 251, ../sass/screen.scss */
/* line 264, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .title-totaux {
text-align: center;
}
/* line 255, ../sass/screen.scss */
/* line 268, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .border-left {
border-left: solid 1px #e0e0e0;
}
/* line 259, ../sass/screen.scss */
/* line 272, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .border-right {
border-right: solid 1px #e0e0e0;
}
/* line 263, ../sass/screen.scss */
/* line 276, ../sass/screen.scss */
#page-commande .form-commandes-point-vente input.quantite {
width: 30px;
background-color: white;
border: solid 1px #e0e0e0;
text-align: center;
}
/* line 271, ../sass/screen.scss */
/* line 284, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .td-produit {
text-align: center;
}
/* line 275, ../sass/screen.scss */
/* line 288, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .submit-pv {
float: right;
}
/* line 279, ../sass/screen.scss */
/* line 292, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .select-user {
background-color: #F9F9F9;
border: solid 1px #e0e0e0;
}
/* line 284, ../sass/screen.scss */
/* line 297, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .date-commande {
font-size: 12px;
}
/* line 288, ../sass/screen.scss */
/* line 301, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .datepicker, #page-commande .form-commandes-point-vente .text {
background-color: white;
border: solid 1px #e0e0e0;
margin-top: 3px;
width: 100px;
}
/* line 296, ../sass/screen.scss */
/* line 309, ../sass/screen.scss */
#page-commande .form-commandes-point-vente td.center {
text-align: center;
}
/* line 302, ../sass/screen.scss */
/* line 315, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .depasse {
color: #b32815;
}
/* line 306, ../sass/screen.scss */
/* line 319, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .total strong span {
font-weight: normal;
font-size: 13px;
}
/* line 311, ../sass/screen.scss */
/* line 324, ../sass/screen.scss */
#page-commande .form-commandes-point-vente .vrac {
display: none;
}
/* line 315, ../sass/screen.scss */
/* line 328, ../sass/screen.scss */
#page-commande .form-commandes-point-vente td.client {
text-align: left;
padding: 3px;
}
/* line 318, ../sass/screen.scss */
/* line 331, ../sass/screen.scss */
#page-commande .form-commandes-point-vente td.client .date-commande {
color: gray;
}
/* line 329, ../sass/screen.scss */
/* line 342, ../sass/screen.scss */
#page-commande .table-header-rotated td {
width: 20px;
padding: 0px;
@@ -310,7 +325,7 @@ a:hover, a:focus, a:active {
vertical-align: middle;
text-align: center;
}
/* line 339, ../sass/screen.scss */
/* line 352, ../sass/screen.scss */
#page-commande .table-header-rotated th.rotate-45 {
height: 80px;
width: 20px;
@@ -322,7 +337,7 @@ a:hover, a:focus, a:active {
font-size: 12px;
line-height: 0.8;
}
/* line 351, ../sass/screen.scss */
/* line 364, ../sass/screen.scss */
#page-commande .table-header-rotated th.rotate-45 > div {
position: relative;
top: 0px;
@@ -339,7 +354,7 @@ a:hover, a:focus, a:active {
border-right: 1px solid #dddddd;
border-top: 1px solid #dddddd;
}
/* line 367, ../sass/screen.scss */
/* line 380, ../sass/screen.scss */
#page-commande .table-header-rotated th.rotate-45 span {
-ms-transform: skew(45deg, 0deg) rotate(315deg);
-moz-transform: skew(45deg, 0deg) rotate(315deg);
@@ -362,35 +377,35 @@ a:hover, a:focus, a:active {
/*whether to display in one line or not*/
}

/* line 392, ../sass/screen.scss */
/* line 405, ../sass/screen.scss */
#email-masse-form #ids-users {
line-height: 30px;
}
/* line 394, ../sass/screen.scss */
/* line 407, ../sass/screen.scss */
#email-masse-form #ids-users .label {
text-transform: capitalize;
}

/* line 402, ../sass/screen.scss */
/* line 415, ../sass/screen.scss */
.produit-create #jours-production .form-group {
float: left;
margin-right: 15px;
}
/* line 406, ../sass/screen.scss */
/* line 419, ../sass/screen.scss */
.produit-create #jours-production .form-group label {
font-weight: normal;
}
/* line 411, ../sass/screen.scss */
/* line 424, ../sass/screen.scss */
.produit-create .field-produit-id_etablissement {
display: none;
}

/* line 417, ../sass/screen.scss */
/* line 430, ../sass/screen.scss */
.produit-index .td-photo {
max-width: 100px;
width: 100px;
}
/* line 421, ../sass/screen.scss */
/* line 434, ../sass/screen.scss */
.produit-index .photo-produit {
max-width: 100px;
}

+ 13
- 0
backend/web/sass/screen.scss Прегледај датотеку

@@ -65,6 +65,7 @@ a {
}

.nom-boulange {
//font-family: 'Georgia' ;
margin-bottom: 15px ;
text-align: left ;
position: fixed ;
@@ -76,6 +77,18 @@ a {
z-index: 100 ;
font-size: 20px ;
padding: 8px 15px ;
#etat-paiement-etablissement {
float: right ;
text-align: right ;
color: $color2;
.strong {
background-color: white ;
color: $color1 ;
@include border-radius(10px) ;
padding: 0px 10px ;
}
}
}

.table {

+ 46
- 0
common/models/User.php Прегледај датотеку

@@ -248,4 +248,50 @@ class User extends ActiveRecord implements IdentityInterface
->all();
}
public function etatPaiementEtablissement()
{
$etablissement = Etablissement::findOne($this->id_etablissement) ;
if($etablissement)
{
$date_limite = strtotime($etablissement->date_creation) + 30*24*60*60 ;
$date = time() ;
if($etablissement->gratuit)
{
return 'gratuit' ;
}
else {
if($date < $date_limite)
{
return 'essai' ;
}
else {
return 'essai-terminee' ;
}
}
}
}
public function periodeEssai()
{
$etablissement = Etablissement::findOne($this->id_etablissement) ;
if($etablissement)
{
$date_limite = strtotime($etablissement->date_creation) + 30*24*60*60 ;
$date = time() ;
if($date < $date_limite)
{
$date = $date_limite - $date ;
return (int) ($date / (24*60*60)) ;
}
else {
return 0 ;
}
}
}
}

+ 32
- 0
console/migrations/m161113_155900_systeme_paiement.php Прегледај датотеку

@@ -0,0 +1,32 @@
<?php

use yii\db\Schema;
use yii\db\Migration;

class m161113_155900_systeme_paiement extends Migration
{
public function up()
{
$this->addColumn('etablissement', 'date_creation', Schema::TYPE_DATETIME.' NOT NULL DEFAULT CURRENT_TIMESTAMP') ;
$this->addColumn('etablissement', 'date_paiement', Schema::TYPE_DATETIME) ;
$this->addColumn('etablissement', 'gratuit', Schema::TYPE_BOOLEAN.' DEFAULT 0') ;
}

public function down()
{
$this->dropColumn('etablissement', 'date_creation') ;
$this->dropColumn('etablissement', 'date_paiement') ;
$this->dropColumn('etablissement', 'gratuit') ;
}

/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}

public function safeDown()
{
}
*/
}

Loading…
Откажи
Сачувај