@@ -345,6 +345,8 @@ class DistributionController extends BackendController | |||
// bons de livraison | |||
$deliveryNotesArray = DeliveryNote::searchAll([ | |||
'distribution.date' => $date, | |||
], [ | |||
'join_with' => ['user AS user_delivery_note', 'orders', 'producer'] | |||
]); | |||
$deliveryNotesByPointSaleArray = []; | |||
foreach ($deliveryNotesArray as $deliveryNote) { | |||
@@ -534,8 +536,11 @@ class DistributionController extends BackendController | |||
if ($invoicePrice != $productOrder->price) { | |||
$productOrder->invoice_price = $invoicePrice; | |||
$productOrder->save(); | |||
} | |||
else { | |||
$productOrder->invoice_price = null; | |||
} | |||
$productOrder->save(); | |||
} | |||
} | |||
} |
@@ -316,6 +316,14 @@ class DocumentController extends BackendController | |||
return $document->downloadPdf(); | |||
} | |||
public function actionRegenerate($id) | |||
{ | |||
$document = $this->findModel($id); | |||
$document->downloadPdf(true); | |||
Yii::$app->getSession()->setFlash('success', 'Le document PDF a bien été regénéré.'); | |||
return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]); | |||
} | |||
public function actionSend($id, $backUpdateForm = false) | |||
{ | |||
$document = $this->findModel($id); | |||
@@ -367,7 +375,8 @@ class DocumentController extends BackendController | |||
if ($classDocument == 'Invoice') { | |||
$options = [ | |||
'orderby' => 'distribution.date ASC' | |||
'orderby' => 'distribution.date ASC', | |||
'join_with' => ['user AS user_delivery_note', 'orders', 'producer'] | |||
]; | |||
$deliveryNotesCreateArray = DeliveryNote::searchAll([ | |||
'id_user' => $user->id, |
@@ -178,12 +178,37 @@ class PointSaleController extends BackendController | |||
$pointSale = $this->findModel($id) ; | |||
if($confirm) { | |||
$pointSale->delete(); | |||
$pointSale->status = -1; | |||
$pointSale->save(); | |||
// Suppression du lien entre les utilisateurs et le point de vente | |||
UserPointSale::deleteAll(['id_point_sale' => $id]); | |||
PointSaleDistribution::deleteAll(['id_point_sale' => $id]) ; | |||
Order::updateAll(['id_point_sale' => 0], 'id_point_sale = :id_point_sale', [':id_point_sale' => $id]) ; | |||
// Suppression du lien PointSaleDistribution pour toutes les distributions à venir | |||
$incomingDistributions = Distribution::getIncomingDistributions(); | |||
foreach ($incomingDistributions as $distribution) { | |||
PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]); | |||
} | |||
// Suppression de toutes les commandes à venir de ce point de vente | |||
$ordersArray = Order::searchAll( | |||
[ | |||
'id_point_sale' => $id, | |||
], | |||
[ | |||
'conditions' => 'date_delete IS NULL AND distribution.date > :today', | |||
'params' => [':today' => date('Y-m-d')] | |||
] | |||
); | |||
if($ordersArray) { | |||
foreach($ordersArray as $order) { | |||
$order->delete(true); | |||
} | |||
} | |||
Yii::$app->getSession()->setFlash('success', 'Point de vente <strong>'.Html::encode($pointSale->name).'</strong> supprimé.'); | |||
} | |||
} | |||
else { | |||
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le point de vente <strong>'.Html::encode($pointSale->name).'</strong> ? ' | |||
. Html::a('Oui',['point-sale/delete','id' => $id, 'confirm' => 1], ['class' => 'btn btn-default']).' '.Html::a('Non', ['point-sale/index'], ['class' => 'btn btn-default'])); |
@@ -154,6 +154,7 @@ class UserController extends BackendController | |||
$pointsSaleArray = PointSale::find() | |||
->where([ | |||
'id_producer' => GlobalParam::getCurrentProducerId(), | |||
'status' => 1 | |||
]) | |||
->joinWith(['userPointSale' => function ($query) use ($model) { | |||
if ($model->id) { |
@@ -175,7 +175,7 @@ $this->setPageTitle('Distributions') ; | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr v-for="pointSale in pointsSale"> | |||
<tr v-for="pointSale in pointsSale" v-if="pointSale.status == 1"> | |||
<td> | |||
<button class="btn btn-success" v-if="pointSale.pointSaleDistribution[0].delivery == 1"><span class="glyphicon glyphicon-ok"></span></button> | |||
<button class="btn btn-default" v-else data-delivery-point-sale="1" :data-id-point-sale="pointSale.id" @click="pointSaleActiveClick"><span class="glyphicon glyphicon-ok"></span></button> |
@@ -209,6 +209,12 @@ use common\models\Producer; | |||
<div class="info-box-content"> | |||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/download', 'id' => $model->id]) ?>" | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger (PDF)</a> | |||
<?php if($model->isStatusValid()): ?> | |||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/regenerate', 'id' => $model->id]) ?>" | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a> | |||
<?php endif; ?> | |||
<?php if ($model->getClass() == 'Invoice' && Producer::getConfig('option_export_evoliz')): ?> | |||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>" | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz |
@@ -64,7 +64,7 @@ use common\helpers\GlobalParam ; | |||
<div class="clr"></div> | |||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::find()->where('id_producer = '.GlobalParam::getCurrentProducerId())->all(), 'id', function($model, $defaultValue) { | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::searchAll(), 'id', function($model, $defaultValue) { | |||
return $model['name']; | |||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | |||
<?= $form->field($model, 'date_begin') ?> |
@@ -1657,7 +1657,7 @@ body.skin-black .content-wrapper .alert a.btn { | |||
body.skin-black .content-wrapper .alert .close { | |||
font-size: 30px; | |||
position: relative; | |||
top: -25px; | |||
top: -15px; | |||
text-decoration: none; | |||
color: white; | |||
opacity: 0.6; |
@@ -142,7 +142,7 @@ body.skin-black { | |||
.close { | |||
font-size: 30px; | |||
position: relative; | |||
top: -25px; | |||
top: -15px; | |||
text-decoration: none; | |||
color: white; | |||
opacity: 0.6; |
@@ -81,6 +81,10 @@ class ActiveRecordCommon extends \yii\db\ActiveRecord | |||
$options['type_search'] = self::SEARCH_ALL; | |||
} | |||
if($class == 'common\models\PointSale' && !isset($options['status'])) { | |||
$params['status'] = 1; | |||
} | |||
$records = $class::find(); | |||
// With |
@@ -37,7 +37,7 @@ | |||
*/ | |||
return [ | |||
'version' => '22.12.A', | |||
'version' => '23.1.A', | |||
'adminEmail' => 'contact@opendistrib.net', | |||
'supportEmail' => 'contact@opendistrib.net', | |||
'user.passwordResetTokenExpire' => 3600, |
@@ -84,7 +84,7 @@ class DeliveryNote extends Document | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['user AS user_delivery_note', 'orders', 'producer'], | |||
'join_with' => ['user AS user_delivery_note', 'producer'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'delivery_note.id_producer' | |||
]; |
@@ -283,11 +283,11 @@ class Document extends ActiveRecordCommon | |||
} | |||
} | |||
public function downloadPdf() | |||
public function downloadPdf($regenerate = false) | |||
{ | |||
$filenameComplete = $this->getFilenameComplete(); | |||
if (!file_exists($filenameComplete) || $this->isStatusDraft()) { | |||
if (!file_exists($filenameComplete) || $this->isStatusDraft() || $regenerate) { | |||
$this->generatePdf(Pdf::DEST_FILE); | |||
} | |||
@@ -85,7 +85,7 @@ class Invoice extends Document | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['user AS user_invoice', 'orders', 'producer'], | |||
'join_with' => ['user AS user_invoice', 'producer'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'invoice.id_producer' | |||
]; |
@@ -88,7 +88,7 @@ class PointSale extends ActiveRecordCommon | |||
'delivery_wednesday', 'delivery_thursday', 'delivery_friday', | |||
'delivery_saturday', 'delivery_sunday', 'default', 'is_bread_box'], 'boolean'], | |||
['point_production', 'default', 'value' => 0], | |||
[['id_producer', 'id_user', 'maximum_number_orders'], 'integer'], | |||
[['id_producer', 'id_user', 'maximum_number_orders', 'status'], 'integer'], | |||
['id_producer', 'required'], | |||
[['users', 'users_comment', 'code'], 'safe'], | |||
[['product_price_percent'], 'double'], | |||
@@ -130,6 +130,7 @@ class PointSale extends ActiveRecordCommon | |||
'maximum_number_orders' => 'Nombre maximum de commandes', | |||
'is_bread_box' => 'Boîte à pain', | |||
'bread_box_code' => 'Code boîte à pain', | |||
'status' => 'Statut' | |||
]; | |||
} | |||
@@ -69,9 +69,11 @@ class PointSaleSearch extends PointSale | |||
$query = PointSale::find() | |||
->with($optionsSearch['with']) | |||
->innerJoinWith($optionsSearch['join_with'], true) | |||
->where(['point_sale.id_producer' => GlobalParam::getCurrentProducerId()]) | |||
->orderBy('is_bread_box ASC, name ASC') | |||
; | |||
->where([ | |||
'status' => 1, | |||
'point_sale.id_producer' => GlobalParam::getCurrentProducerId() | |||
]) | |||
->orderBy('is_bread_box ASC, name ASC'); | |||
$dataProvider = new ActiveDataProvider([ | |||
'query' => $query, |
@@ -82,7 +82,7 @@ class Quotation extends Document | |||
{ | |||
return [ | |||
'with' => [], | |||
'join_with' => ['user AS user_quotation', 'orders', 'producer'], | |||
'join_with' => ['user AS user_quotation', 'producer'], | |||
'orderby' => 'date ASC', | |||
'attribute_id_producer' => 'quotation.id_producer' | |||
]; |
@@ -0,0 +1,16 @@ | |||
<h4>Date de sortie</h4> | |||
<ul> | |||
<li>23/01/2023</li> | |||
</ul> | |||
<h4>Évolutions</h4> | |||
<ul> | |||
<li>[Administration] Documents : possibilité de regénérer les PDF</li> | |||
</ul> | |||
<h4>Maintenance</h4> | |||
<ul> | |||
<li>[Administration] Documents > listes : optimisation chargement</li> | |||
<li>[Espace producteur] Commander : ajustement ordre des points de vente</li> | |||
</ul> |
@@ -0,0 +1,26 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\Schema; | |||
/** | |||
* Class m230119_083942_point_sale_add_status | |||
*/ | |||
class m230119_083942_point_sale_add_status extends Migration | |||
{ | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeUp() | |||
{ | |||
$this->addColumn('point_sale', 'status', Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 1'); | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeDown() | |||
{ | |||
$this->dropColumn('point_sale', 'status'); | |||
} | |||
} |
@@ -955,10 +955,10 @@ class OrderController extends ProducerBaseController | |||
$pointsSaleArray = $pointsSaleArray->where(['id_producer' => $idProducer]) | |||
->andWhere( | |||
'restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0)' | |||
'status = 1 AND (restricted_access = 0 OR (restricted_access = 1 AND (SELECT COUNT(*) FROM user_point_sale WHERE point_sale.id = user_point_sale.id_point_sale AND user_point_sale.id_user = :id_user) > 0))' | |||
) | |||
->params([':id_user' => User::getCurrentId()]) | |||
->orderBy('default DESC, code ASC, restricted_access ASC, is_bread_box ASC, name ASC') | |||
->orderBy('code ASC, restricted_access ASC, is_bread_box ASC, `default` DESC, name ASC') | |||
->all(); | |||
$creditFunctioningProducer = Producer::getConfig('credit_functioning'); |
@@ -98,7 +98,8 @@ class SiteController extends ProducerBaseController | |||
->where([ | |||
'id_producer' => $this->getProducer( | |||
)->id, | |||
'restricted_access' => 0 | |||
'restricted_access' => 0, | |||
'status' => 1 | |||
])->orderBy( | |||
'default DESC, is_bread_box ASC, name ASC' | |||
), |