namespace backend\controllers; | namespace backend\controllers; | ||||
use common\models\Order ; | |||||
class SubscriptionController extends BackendController | class SubscriptionController extends BackendController | ||||
{ | { | ||||
var $enableCsrfValidation = false; | var $enableCsrfValidation = false; | ||||
} | } | ||||
/** | /** | ||||
* Crée une commande récurrente. | |||||
* Crée un abonnement. | |||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
public function actionCreate() | |||||
public function actionCreate($idOrder = 0) | |||||
{ | { | ||||
// form | // form | ||||
$model = new SubscriptionForm; | $model = new SubscriptionForm; | ||||
$model->id_producer = Producer::getId(); | $model->id_producer = Producer::getId(); | ||||
if($idOrder) { | |||||
$order = Order::searchOne(['id' => $idOrder]); | |||||
if ($order) { | |||||
$model->id_user = $order->id_user; | |||||
$model->username = $order->username; | |||||
$model->id_point_sale = $order->id_point_sale; | |||||
$model->date_begin = date('d/m/Y') ; | |||||
$dateDay = strtolower(date('l',strtotime($order->distribution->date))) ; | |||||
$model->$dateDay = 1 ; | |||||
$model->week_frequency = 1 ; | |||||
if($model->id_user && Producer::getConfig('credit')) { | |||||
$model->auto_payment = 1 ; | |||||
} | |||||
// produits | |||||
foreach ($order->productOrder as $productOrder) { | |||||
$model->products['product_' . $productOrder->id_product] = $productOrder->quantity; | |||||
} | |||||
} else { | |||||
throw new NotFoundHttpException('La commande est introuvable.', 404); | |||||
} | |||||
} | |||||
// produits | // produits | ||||
$productsArray = Product::searchAll() ; | $productsArray = Product::searchAll() ; | ||||
} | } | ||||
/** | /** | ||||
* Modifie une commande récurrente. | |||||
* Modifie un abonnement. | |||||
* | * | ||||
* @param integer $id | * @param integer $id | ||||
* @return string | * @return string |
<label class="label label-default" v-else-if="order.origin == 'auto'">auto</label> | <label class="label label-default" v-else-if="order.origin == 'auto'">auto</label> | ||||
<label class="label label-warning" v-else>admin</label> | <label class="label label-warning" v-else>admin</label> | ||||
</td> | </td> | ||||
<td> | |||||
<span class="label label-danger" v-if="order.date_delete"><span class="glyphicon glyphicon-trash"></span></span> | |||||
<span class="label label-warning" v-if="order.date_update"><span class="glyphicon glyphicon-pencil"></span></span> | |||||
<span class="label label-success" v-if="!order.date_update && !order.date_delete"><span class="glyphicon glyphicon-check"></span></span> | |||||
</td> | |||||
<td> | <td> | ||||
<span v-if="order.user">{{ order.user.lastname+' '+order.user.name }}</span> | <span v-if="order.user">{{ order.user.lastname+' '+order.user.name }}</span> | ||||
<span v-else>{{ order.username }}</span> | <span v-else>{{ order.username }}</span> | ||||
</td> | </td> | ||||
<td>{{ order.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</td> | <td>{{ order.amount.toFixed(2).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")+' €' }}</td> | ||||
<td> | <td> | ||||
<span class="label label-success" v-if="order.amount_paid == order.amount">payé</span> | |||||
<span class="label label-default" v-else-if="order.amount_paid == 0">non réglé</span> | |||||
<span class="label label-default" v-else-if="order.amount_paid > order.amount">surplus</span> | |||||
<span class="label label-warning" v-else-if="order.amount_paid < order.amount">reste à payer</span> | |||||
<div class="input-group"> | |||||
<span class="label label-success input-group-addon" v-if="order.amount_paid == order.amount">payé</span> | |||||
<span class="label label-default input-group-addon" v-else-if="order.amount_paid == 0">non réglé</span> | |||||
<span class="label label-default input-group-addon" v-else-if="order.amount_paid > order.amount">surplus</span> | |||||
<span class="label label-warning input-group-addon" v-else-if="order.amount_paid < order.amount">reste à payer</span> | |||||
</div> | |||||
</td> | </td> | ||||
<td> | <td> | ||||
<span class="label label-danger" v-if="order.date_delete">annulée</span> | |||||
<span class="label label-warning" v-if="order.date_update">modifiée</span> | |||||
<div class="btn-group" v-if="order.user"> | |||||
<button class="btn btn-xs btn-default" v-if="order.amount_paid == order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount"> | |||||
<span class="glyphicon glyphicon-euro"></span> Rembourser | |||||
</button> | |||||
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid == 0" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount"> | |||||
<span class="glyphicon glyphicon-euro"></span> Payer | |||||
</button> | |||||
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid < order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="payment" :data-amount="order.amount_remaining"> | |||||
<span class="glyphicon glyphicon-euro"></span> Payer | |||||
</button> | |||||
<button class="btn btn-xs btn-default" v-else-if="order.amount_paid > order.amount" @click="orderPaymentClick" :data-id-order="order.id" data-type="refund" :data-amount="order.amount_surplus"> | |||||
<span class="glyphicon glyphicon-euro"></span> Rembourser | |||||
</button> | |||||
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |||||
<span class="caret"></span> | |||||
<span class="sr-only">Toggle Dropdown</span> | |||||
</button> | |||||
<ul class="dropdown-menu"> | |||||
<li><a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">Historique</a></li> | |||||
</ul> | |||||
</div> | |||||
</td> | </td> | ||||
<td class="column-actions"> | <td class="column-actions"> | ||||
<a class="btn btn-default" :href="baseUrl+'/subscription/update?id='+order.id_subscription" v-if="order.id_subscription > 0"><span class="glyphicon glyphicon-repeat"></span></a> | |||||
<button class="btn btn-default" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span></button> | <button class="btn btn-default" :data-id-order="order.id" @click="orderViewClick"><span :class="'glyphicon ' + ((showViewProduct && idOrderView == order.id) ? 'glyphicon-eye-close' : 'glyphicon-eye-open')"></span></button> | ||||
<button class="btn btn-default" :data-id-order="order.id" @click="orderPaymentModalClick" v-show="order.user"><span class="glyphicon glyphicon-euro"></span></button> | |||||
<button class="btn btn-default" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span></button> | <button class="btn btn-default" :data-id-order="order.id" @click="updateOrderClick"><span class="glyphicon glyphicon-pencil"></span></button> | ||||
<button class="btn btn-default" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span></button> | <button class="btn btn-default" :data-id-order="order.id" @click="deleteOrderClick"><span class="glyphicon glyphicon-trash"></span></button> | ||||
<a class="btn btn-default" :href="baseUrl+'/subscription/update?id='+order.id_subscription" v-if="order.id_subscription > 0"><span class="glyphicon glyphicon-repeat"></span></a> | |||||
<a class="btn btn-default add-subscription" :href="baseUrl+'/subscription/create?idOrder='+order.id" v-else><span class="glyphicon glyphicon-plus"></span><span class="glyphicon glyphicon-repeat"></span></a> | |||||
<order-form | <order-form | ||||
v-if="showModalFormOrderUpdate && idOrderUpdate == order.id" | v-if="showModalFormOrderUpdate && idOrderUpdate == order.id" | ||||
:date="date" | :date="date" |
.distribution-index #orders table td.column-actions .modal-payment { | .distribution-index #orders table td.column-actions .modal-payment { | ||||
text-align: left; | text-align: left; | ||||
} | } | ||||
/* line 229, ../sass/distribution/_index.scss */ | |||||
.distribution-index #orders table td.column-actions .add-subscription { | |||||
position: relative; | |||||
} | |||||
/* line 231, ../sass/distribution/_index.scss */ | /* line 231, ../sass/distribution/_index.scss */ | ||||
.distribution-index #orders table td.column-actions .add-subscription .glyphicon-plus { | |||||
position: absolute; | |||||
top: 4px; | |||||
right: 4px; | |||||
font-size: 7px; | |||||
} | |||||
/* line 241, ../sass/distribution/_index.scss */ | |||||
.distribution-index #orders table tr.view ul { | .distribution-index #orders table tr.view ul { | ||||
list-style-type: none; | list-style-type: none; | ||||
margin-left: 0px; | margin-left: 0px; | ||||
padding-left: 15px; | padding-left: 15px; | ||||
} | } | ||||
/* line 240, ../sass/distribution/_index.scss */ | |||||
/* line 250, ../sass/distribution/_index.scss */ | |||||
.distribution-index #orders table tr.view .comment { | .distribution-index #orders table tr.view .comment { | ||||
margin-top: 20px; | margin-top: 20px; | ||||
} | } | ||||
/* line 251, ../sass/distribution/_index.scss */ | |||||
/* line 261, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products .product-ordered td { | .distribution-index .modal-form-order table.table-products .product-ordered td { | ||||
background-color: #e9e9e9; | background-color: #e9e9e9; | ||||
} | } | ||||
/* line 255, ../sass/distribution/_index.scss */ | |||||
/* line 265, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products .product-ordered input { | .distribution-index .modal-form-order table.table-products .product-ordered input { | ||||
font-size: 16px; | font-size: 16px; | ||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
/* line 261, ../sass/distribution/_index.scss */ | |||||
/* line 271, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity { | .distribution-index .modal-form-order table.table-products td.quantity { | ||||
width: 150px; | width: 150px; | ||||
} | } | ||||
/* line 264, ../sass/distribution/_index.scss */ | |||||
/* line 274, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity input { | .distribution-index .modal-form-order table.table-products td.quantity input { | ||||
text-align: center; | text-align: center; | ||||
color: gray; | color: gray; | ||||
} | } | ||||
/* line 270, ../sass/distribution/_index.scss */ | |||||
/* line 280, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order table.table-products td.quantity-remaining { | .distribution-index .modal-form-order table.table-products td.quantity-remaining { | ||||
text-align: right; | text-align: right; | ||||
} | } | ||||
/* line 276, ../sass/distribution/_index.scss */ | |||||
/* line 286, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-form-order .actions-form button { | .distribution-index .modal-form-order .actions-form button { | ||||
margin-left: 15px; | margin-left: 15px; | ||||
} | } | ||||
/* line 284, ../sass/distribution/_index.scss */ | |||||
/* line 294, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-payment .info-box .info-box-icon { | .distribution-index .modal-payment .info-box .info-box-icon { | ||||
width: 50px; | width: 50px; | ||||
} | } | ||||
/* line 286, ../sass/distribution/_index.scss */ | |||||
/* line 296, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-payment .info-box .info-box-icon i { | .distribution-index .modal-payment .info-box .info-box-icon i { | ||||
font-size: 30px; | font-size: 30px; | ||||
} | } | ||||
/* line 290, ../sass/distribution/_index.scss */ | |||||
/* line 300, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-payment .info-box .info-box-content { | .distribution-index .modal-payment .info-box .info-box-content { | ||||
margin-left: 50px; | margin-left: 50px; | ||||
} | } | ||||
/* line 296, ../sass/distribution/_index.scss */ | |||||
/* line 306, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-mask { | .distribution-index .modal-mask { | ||||
position: fixed; | position: fixed; | ||||
z-index: 9998; | z-index: 9998; | ||||
display: table; | display: table; | ||||
transition: opacity .3s ease; | transition: opacity .3s ease; | ||||
} | } | ||||
/* line 308, ../sass/distribution/_index.scss */ | |||||
/* line 318, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-wrapper { | .distribution-index .modal-wrapper { | ||||
display: table-cell; | display: table-cell; | ||||
vertical-align: middle; | vertical-align: middle; | ||||
} | } | ||||
/* line 313, ../sass/distribution/_index.scss */ | |||||
/* line 323, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-container { | .distribution-index .modal-container { | ||||
width: 70%; | width: 70%; | ||||
margin: 0px auto; | margin: 0px auto; | ||||
transition: all .3s ease; | transition: all .3s ease; | ||||
font-family: Helvetica, Arial, sans-serif; | font-family: Helvetica, Arial, sans-serif; | ||||
} | } | ||||
/* line 324, ../sass/distribution/_index.scss */ | |||||
/* line 334, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-header { | .distribution-index .modal-header { | ||||
padding-bottom: 0px; | padding-bottom: 0px; | ||||
} | } | ||||
/* line 326, ../sass/distribution/_index.scss */ | |||||
/* line 336, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-header h3 { | .distribution-index .modal-header h3 { | ||||
margin-top: 0; | margin-top: 0; | ||||
color: #333; | color: #333; | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
margin-bottom: 0px; | margin-bottom: 0px; | ||||
} | } | ||||
/* line 334, ../sass/distribution/_index.scss */ | |||||
/* line 344, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-body { | .distribution-index .modal-body { | ||||
margin: 20px 0; | margin: 20px 0; | ||||
max-height: 300px; | max-height: 300px; | ||||
height: 300px; | height: 300px; | ||||
overflow-y: scroll; | overflow-y: scroll; | ||||
} | } | ||||
/* line 341, ../sass/distribution/_index.scss */ | |||||
/* line 351, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-default-button { | .distribution-index .modal-default-button { | ||||
float: right; | float: right; | ||||
} | } | ||||
/* line 354, ../sass/distribution/_index.scss */ | |||||
/* line 364, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-enter { | .distribution-index .modal-enter { | ||||
opacity: 0; | opacity: 0; | ||||
} | } | ||||
/* line 358, ../sass/distribution/_index.scss */ | |||||
/* line 368, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-leave-active { | .distribution-index .modal-leave-active { | ||||
opacity: 0; | opacity: 0; | ||||
} | } | ||||
/* line 362, ../sass/distribution/_index.scss */ | |||||
/* line 372, ../sass/distribution/_index.scss */ | |||||
.distribution-index .modal-enter .modal-container, | .distribution-index .modal-enter .modal-container, | ||||
.distribution-index .modal-leave-active .modal-container { | .distribution-index .modal-leave-active .modal-container { | ||||
-webkit-transform: scale(1.1); | -webkit-transform: scale(1.1); |
orderPaymentClick: function(event) { | orderPaymentClick: function(event) { | ||||
var app = this ; | var app = this ; | ||||
var idOrder = event.currentTarget.getAttribute('data-id-order') ; | var idOrder = event.currentTarget.getAttribute('data-id-order') ; | ||||
if(!idOrder) { | |||||
idOrder = this.idOrderPayment ; | |||||
} | |||||
axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-payment",{params: { | axios.get(UrlManager.getBaseUrlAbsolute()+"order/ajax-payment",{params: { | ||||
idOrder: this.idOrderPayment, | |||||
idOrder: idOrder, | |||||
type: event.currentTarget.getAttribute('data-type'), | type: event.currentTarget.getAttribute('data-type'), | ||||
amount: event.currentTarget.getAttribute('data-amount') | amount: event.currentTarget.getAttribute('data-amount') | ||||
}}) | }}) |
.modal-payment { | .modal-payment { | ||||
text-align: left ; | text-align: left ; | ||||
} | } | ||||
.add-subscription { | |||||
position: relative ; | |||||
.glyphicon-plus { | |||||
position: absolute ; | |||||
top: 4px ; | |||||
right: 4px ; | |||||
font-size: 7px ; | |||||
} | |||||
} | |||||
} | } | ||||
tr.view { | tr.view { |