namespace backend\models; | namespace backend\models; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\helpers\Mailjet; | |||||
use common\logic\Distribution\Distribution\Model\Distribution; | |||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use common\logic\Product\Product\Model\Product; | |||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
use common\helpers\Price ; | use common\helpers\Price ; | ||||
use yii\helpers\Html; | |||||
/** | /** | ||||
* ContactForm is the model behind the contact form. | * ContactForm is the model behind the contact form. | ||||
*/ | */ | ||||
class MailForm extends Model | class MailForm extends Model | ||||
{ | { | ||||
public $id_distribution ; | public $id_distribution ; | ||||
public $subject; | public $subject; | ||||
public $message; | public $message; | ||||
*/ | */ | ||||
public function sendEmail($usersArray, $fromProducer = true) | public function sendEmail($usersArray, $fromProducer = true) | ||||
{ | { | ||||
$productManager = ProductManager::getInstance(); | |||||
$producerManager = ProducerManager::getInstance(); | |||||
$mj = new \Mailjet\Client( | $mj = new \Mailjet\Client( | ||||
Mailjet::getApiKey('public'), | Mailjet::getApiKey('public'), | ||||
Mailjet::getApiKey('private'), | Mailjet::getApiKey('private'), | ||||
' ; | ' ; | ||||
$messageAutoHtml = '<br /><br />' ; | $messageAutoHtml = '<br /><br />' ; | ||||
$distribution = DistributionModel::searchOne(['id' => $this->id_distribution]) ; | |||||
$distribution = Distribution::searchOne(['id' => $this->id_distribution]) ; | |||||
if($distribution) { | if($distribution) { | ||||
} | } | ||||
if($product->price) { | if($product->price) { | ||||
$productDescription .= ' / '.Price::format($product->getPriceWithTax()) ; | $productDescription .= ' / '.Price::format($product->getPriceWithTax()) ; | ||||
$productDescription .= ' ('. Product::strUnit($product->unit, 'wording_unit').')' ; | |||||
$productDescription .= ' ('. $productManager->strUnit($product->unit, 'wording_unit').')' ; | |||||
} | } | ||||
$messageAutoText .= '- '.$productDescription.' | $messageAutoText .= '- '.$productDescription.' | ||||
if($fromProducer) { | if($fromProducer) { | ||||
$producer = GlobalParam::getCurrentProducer() ; | $producer = GlobalParam::getCurrentProducer() ; | ||||
$fromEmail = $producer->getEmailOpendistrib() ; | |||||
$fromEmail = $producerManager->getEmailOpendistrib($producer) ; | |||||
$fromName = $producer->name ; | $fromName = $producer->name ; | ||||
} | } | ||||
else { | else { | ||||
return $response ; | return $response ; | ||||
} | } | ||||
} | } |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||||
use yii\grid\GridView; | |||||
use common\logic\PointSale\PointSale\Model\PointSale; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use yii\helpers\Html; | |||||
use yii\helpers\ArrayHelper; | |||||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | |||||
$this->setTitle('Bons de livraison'); | $this->setTitle('Bons de livraison'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
$this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon glyphicon-plus"></span>', 'url' => ['distribution/index', 'message_generate_bl' => 1], 'class' => 'btn btn-primary']); | $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon glyphicon-plus"></span>', 'url' => ['distribution/index', 'message_generate_bl' => 1], 'class' => 'btn btn-primary']); | ||||
?> | ?> | ||||
<div class="delivery-note-index"> | <div class="delivery-note-index"> | ||||
<?php if(DeliveryNote::searchCount()): ?> | |||||
<?= GridView::widget([ | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'status', | |||||
'label' => 'Statut', | |||||
'filter' => [ | |||||
'draft' => 'Brouillon', | |||||
'valid' => 'Valide', | |||||
], | |||||
'format' => 'raw', | |||||
'value' => function($model) { | |||||
return $model->getHtmlLabel() ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'reference', | |||||
'value' => function($model) { | |||||
if(strlen($model->reference) > 0) { | |||||
return $model->reference ; | |||||
} | |||||
return '' ; | |||||
} | |||||
], | |||||
'name', | |||||
[ | |||||
'attribute' => 'date_distribution', | |||||
'header' => 'Jour de distribution', | |||||
'filter' => \yii\jui\DatePicker::widget([ | |||||
'language' => 'fr', | |||||
'dateFormat' => 'dd/MM/yyyy', | |||||
'model' => $searchModel, | |||||
'attribute' => 'date_distribution', | |||||
'options' => ['class' => 'form-control'] | |||||
]), | |||||
'value' => function($model) { | |||||
$distribution = $model->getDistribution() ; | |||||
if($distribution) { | |||||
return date('d/m/Y',strtotime($distribution->date)) ; | |||||
} | |||||
return '' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_point_sale', | |||||
'header' => 'Point de vente', | |||||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array'=>true]), 'id', 'name'), | |||||
'format' => 'html', | |||||
'value' => function($model) { | |||||
$pointSale = $model->getPointSale() ; | |||||
if($pointSale) { | |||||
return Html::encode($pointSale->name); | |||||
} | |||||
return '' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'amount', | |||||
'header' => 'Montant', | |||||
'value' => function($deliveryNote) { | |||||
return $deliveryNote->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{validate} {update} {delete} {send} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'send' => function($url, $model) { | |||||
return ((isset($model->user) && strlen($model->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||||
'title' => 'Envoyer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'download' => function($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'validate' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'title' => 'Valider', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'update' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); ?> | |||||
<?php else: ?> | |||||
<div class="alert alert-info">Aucun bon de livraison enregistré</div> | |||||
<?php endif; ?> | |||||
<?php if (DeliveryNote::searchCount()): ?> | |||||
<?= GridView::widget([ | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'status', | |||||
'label' => 'Statut', | |||||
'filter' => [ | |||||
'draft' => 'Brouillon', | |||||
'valid' => 'Valide', | |||||
], | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
return $deliveryNoteManager->getHtmlLabel($model); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'reference', | |||||
'value' => function ($model) { | |||||
if (strlen($model->reference) > 0) { | |||||
return $model->reference; | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
'name', | |||||
[ | |||||
'attribute' => 'date_distribution', | |||||
'header' => 'Jour de distribution', | |||||
'filter' => \yii\jui\DatePicker::widget([ | |||||
'language' => 'fr', | |||||
'dateFormat' => 'dd/MM/yyyy', | |||||
'model' => $searchModel, | |||||
'attribute' => 'date_distribution', | |||||
'options' => ['class' => 'form-control'] | |||||
]), | |||||
'value' => function ($model) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
$distribution = $deliveryNoteManager->getDistribution($model); | |||||
if ($distribution) { | |||||
return date('d/m/Y', strtotime($distribution->date)); | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_point_sale', | |||||
'header' => 'Point de vente', | |||||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'), | |||||
'format' => 'html', | |||||
'value' => function ($model) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
$pointSale = $deliveryNoteManager->getPointSale($model); | |||||
if ($pointSale) { | |||||
return Html::encode($pointSale->name); | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'amount', | |||||
'header' => 'Montant', | |||||
'value' => function ($deliveryNote) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
return $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true); | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{validate} {update} {delete} {send} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'send' => function ($url, $model) { | |||||
return ((isset($model->user) && strlen($model->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||||
'title' => 'Envoyer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'download' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'validate' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'title' => 'Valider', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'update' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); ?> | |||||
<?php else: ?> | |||||
<div class="alert alert-info">Aucun bon de livraison enregistré</div> | |||||
<?php endif; ?> | |||||
</div> | </div> |
\backend\assets\VuejsDocumentFormAsset::register($this); | \backend\assets\VuejsDocumentFormAsset::register($this); | ||||
$producerManager = $this->getProducerManager(); | |||||
?> | ?> | ||||
<div class="document-form" id="app-document-form" data-class-document="<?= $model->getClass() ?>" | <div class="document-form" id="app-document-form" data-class-document="<?= $model->getClass() ?>" | ||||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a> | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if ($model->getClass() == 'Invoice' && Producer::getConfig('option_export_evoliz')): ?> | |||||
<?php if ($model->getClass() == 'Invoice' && $producerManager->getConfig('option_export_evoliz')): ?> | |||||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>" | <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 | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz | ||||
(CSV)</a> | (CSV)</a> |
<?php | <?php | ||||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note')); | |||||
$displayProductDescription = Producer::getConfig('document_display_product_description'); | |||||
$documentPriceDecimals = (int) Producer::getConfig('option_document_price_decimals'); | |||||
$producerManager = $this->getProducerManager(); | |||||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && $producerManager->getConfig('document_display_prices_delivery_note')); | |||||
$displayProductDescription = $producerManager->getConfig('document_display_product_description'); | |||||
$documentPriceDecimals = (int) $producerManager->getConfig('option_document_price_decimals'); | |||||
?> | ?> | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
use common\logic\User\User\Wrapper\UserManager; | |||||
$producerManager = $this->getProducerManager(); | |||||
$userManager = $this->getUserManager(); | |||||
?> | ?> | ||||
<?= $form->field($model, 'id_user', [ | <?= $form->field($model, 'id_user', [ | ||||
'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | 'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}', | ||||
]) | ]) | ||||
->dropDownList( User::populateDropdownList(), ['class' => 'select2']) | |||||
->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']) | |||||
->hint('Utilisé lors de la facturation'); ?> | ->hint('Utilisé lors de la facturation'); ?> | ||||
<?php | <?php | ||||
$addHintCredit = ''; | $addHintCredit = ''; | ||||
if (!ProducerModel::getConfig('credit')): | |||||
if (!$producerManager->getConfig('credit')): | |||||
$addHintCredit = '<br /><strong>Attention, le système de Crédit est désactivé au niveau des ' . Html::a('paramètres globaux', ['producer/update']) . '.</strong>'; | $addHintCredit = '<br /><strong>Attention, le système de Crédit est désactivé au niveau des ' . Html::a('paramètres globaux', ['producer/update']) . '.</strong>'; | ||||
endif; | endif; | ||||
<?= $form->field($model, 'credit_functioning') | <?= $form->field($model, 'credit_functioning') | ||||
->dropDownList([ | ->dropDownList([ | ||||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[ProducerModel::getConfig('credit_functioning')] . ')', | |||||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL], | |||||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY], | |||||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER], | |||||
], [])->hint(ProducerModel::HINT_CREDIT_FUNCTIONING); ?> | |||||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[$producerManager->getConfig('credit_functioning')] . ')', | |||||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL], | |||||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY], | |||||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER], | |||||
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING); ?> | |||||
<?php /*$form->field($model, 'product_price_percent') | <?php /*$form->field($model, 'product_price_percent') | ||||
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?> | ->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?> | ||||
<div id="users"> | <div id="users"> | ||||
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | <?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | ||||
return Html::encode( User::getUsernameFromArray($model_user)) . '<br />' | |||||
$userManager = UserManager::getInstance(); | |||||
return Html::encode($userManager->getUsernameFromArray($model_user)) . '<br />' | |||||
. Html::activeTextInput( | . Html::activeTextInput( | ||||
$model, | $model, | ||||
'users_comment[' . $model_user['user_id'] . ']', | 'users_comment[' . $model_user['user_id'] . ']', |
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\Product\Product\Model\Product; | |||||
use common\logic\PointSale\PointSale\Model\PointSale; | |||||
$productCategoryManager = $this->getProductCategoryManager(); | |||||
$taxRateManager = $this->getTaxRateManager(); | |||||
?> | ?> | ||||
<?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?> | <?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?> | ||||
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | <?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | ||||
<?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?> | <?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?> | ||||
<?= $form->field($model, 'id_product_category')->dropDownList( ProductCategory::populateDropdownList()); ?> | |||||
<?= $form->field($model, 'id_product_category')->dropDownList($productCategoryManager->populateProductCategoriesDropdownList()); ?> | |||||
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?> | <?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?> | ||||
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | <?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | ||||
<?= $form->field($model, 'unit') | <?= $form->field($model, 'unit') | ||||
->dropDownList(ArrayHelper::map( Product::$unitsArray, 'unit', 'wording')) | |||||
->dropDownList(ArrayHelper::map(Product::$unitsArray, 'unit', 'wording')) | |||||
->label('Unité (pièce, poids ou volume)'); ?> | ->label('Unité (pièce, poids ou volume)'); ?> | ||||
$producer = \common\helpers\GlobalParam::getCurrentProducer(); | $producer = \common\helpers\GlobalParam::getCurrentProducer(); | ||||
$taxRateDefault = $producer->taxRate; | $taxRateDefault = $producer->taxRate; | ||||
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) { | |||||
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateManager->findTaxRates(), 'id', function ($model) { | |||||
return $model->name; | return $model->name; | ||||
})); | })); | ||||
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) { | |||||
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateManager->findTaxRates(), 'id', function ($model) { | |||||
return $model->value; | return $model->value; | ||||
})); | })); | ||||
foreach ($taxRateValuesArray as $key => $taxRateValue) { | foreach ($taxRateValuesArray as $key => $taxRateValue) { |
<?php | |||||
use common\helpers\Price; | |||||
$productManager = $this->getProductManager(); | |||||
?> | |||||
<div class="alert alert-warning"> | <div class="alert alert-warning"> | ||||
Prix de base : <strong><?= Price::format($model->getPrice()); ?> HT</strong> / <strong><?= Price::format($model->getPriceWithTax()); ?> TTC</strong><br /> | |||||
Prix de base : <strong><?= Price::format($productManager->getPrice($model)); ?> HT</strong> / <strong><?= Price::format($productManager->getPriceWithTax($model)); ?> TTC</strong><br /> | |||||
</div> | </div> |
use yii\bootstrap\ActiveForm; | use yii\bootstrap\ActiveForm; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
$userManager = $this->getUserManager(); | |||||
$userGroupManager = $this->getUserGroupManager(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
$productManager = $this->getProductManager(); | |||||
?> | ?> | ||||
<div class="product-form"> | <div class="product-form"> | ||||
<?= | <?= | ||||
$this->render('_base_price', [ | $this->render('_base_price', [ | ||||
'model' => $modelProduct, | 'model' => $modelProduct, | ||||
]) ; | ]) ; | ||||
?> | ?> | ||||
<?php $form = ActiveForm::begin([ | <?php $form = ActiveForm::begin([ | ||||
'options' => ['enctype' => 'multipart/form-data'] | 'options' => ['enctype' => 'multipart/form-data'] | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'id_user')->dropDownList( User::populateDropdownList()); ?> | |||||
<?= $form->field($model, 'id_user_group')->dropDownList( UserGroup::populateDropdownList()); ?> | |||||
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSale::populateDropdownList()); ?> | |||||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||||
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList()); ?> | |||||
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?> | |||||
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?> | |||||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||||
<?php | <?php | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
'template' => ' | 'template' => ' | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-xs-6"> | <div class="col-xs-6"> | ||||
<label for="product-price" class="control-label without-tax">Prix ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||||
<label for="product-price" class="control-label without-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||||
<div class="input-group"> | <div class="input-group"> | ||||
{input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | {input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="col-xs-6"> | <div class="col-xs-6"> | ||||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||||
<div class="input-group"> | <div class="input-group"> | ||||
<input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'"> | <input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'"> | ||||
<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | ||||
</div> | </div> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> | ||||
</div> | </div> |
<?php | <?php | ||||
use common\helpers\Price ; | |||||
/** | /** | ||||
* Copyright distrib (2018) | * Copyright distrib (2018) | ||||
* | * | ||||
* termes. | * termes. | ||||
*/ | */ | ||||
$this->setTitle('Liste des prix ('.Html::encode($model->name).')'); | |||||
use yii\helpers\Html; | |||||
use common\helpers\Price; | |||||
use yii\grid\GridView; | |||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
$productManager = $this->getProductManager(); | |||||
$this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | |||||
$this->addBreadcrumb(['label' => 'Produits', 'url' => ['index']]); | $this->addBreadcrumb(['label' => 'Produits', 'url' => ['index']]); | ||||
$this->addBreadcrumb(['label' => $model->name, 'url' => ['update', 'id' => $model->id]]); | $this->addBreadcrumb(['label' => $model->name, 'url' => ['update', 'id' => $model->id]]); | ||||
$this->addBreadcrumb('Modifier'); | $this->addBreadcrumb('Modifier'); | ||||
//$this->addButton(['label' => 'Nouveau prix <span class="glyphicon glyphicon-plus"></span>', 'url' => ['product/prices-create', 'idProduct' => $model->id ], 'class' => 'btn btn-primary']); | |||||
?> | ?> | ||||
<?= | <?= | ||||
$this->render('../_nav', [ | |||||
'model' => $model, | |||||
'action' => $action, | |||||
]) ; | |||||
$this->render('../_nav', [ | |||||
'model' => $model, | |||||
'action' => $action, | |||||
]); | |||||
?> | ?> | ||||
<div class="col-md-12"> | <div class="col-md-12"> | ||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title"> | |||||
Prix spécifiques à ce produit | |||||
<a href="<?= Yii::$app->urlManager->createUrl(['product/prices-create', 'idProduct' => $model->id ]) ?>" class="btn btn-default btn-xs"> | |||||
Nouveau prix | |||||
<span class="glyphicon glyphicon-plus"></span> | |||||
</a> | |||||
</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<?php | |||||
echo GridView::widget([ | |||||
//'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'id_user', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if($model->user) { | |||||
return $model->user->getUsername() ; | |||||
} | |||||
return '<span class="label label-success">Tous</span>' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_user_group', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if($model->userGroup) { | |||||
return $model->userGroup->name ; | |||||
} | |||||
return '<span class="label label-success">Tous</span>' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_point_sale', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if($model->pointSale) { | |||||
return $model->pointSale->name ; | |||||
} | |||||
return '<span class="label label-success">Tous</span>' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'from_quantity', | |||||
'value' => function ($productPrice) { | |||||
if($productPrice->from_quantity) { | |||||
return $productPrice->from_quantity.' '. Product::strUnit( Product::getRefUnit($productPrice->product->unit), 'wording'); | |||||
} | |||||
return '' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'price', | |||||
'value' => function ($productPrice) { | |||||
return Price::numberTwoDecimals($productPrice->price).' €' ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'price', | |||||
'header' => 'Prix (TTC)', | |||||
'value' => function ($productPrice) use ($model) { | |||||
return Price::numberTwoDecimals(Price::getPriceWithTax($productPrice->price, $model->taxRate->value)).' €' ; | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{update} {delete}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'update' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['product/prices-update', 'id' => $model->id], [ | |||||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['product/prices-delete', 'id' => $model->id], [ | |||||
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' | |||||
]); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); | |||||
?> | |||||
</div> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title"> | |||||
Prix spécifiques à ce produit | |||||
<a href="<?= Yii::$app->urlManager->createUrl(['product/prices-create', 'idProduct' => $model->id]) ?>" | |||||
class="btn btn-default btn-xs"> | |||||
Nouveau prix | |||||
<span class="glyphicon glyphicon-plus"></span> | |||||
</a> | |||||
</h3> | |||||
</div> | </div> | ||||
<div class="panel-body"> | |||||
<?php | |||||
<!-- | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Pourcentage global / Utilisateurs</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<table class="table table-bordered"> | |||||
<thead> | |||||
<tr> | |||||
<th>Utilisateur</th> | |||||
<th>Pourcentage</th> | |||||
<th>Prix (HT)</th> | |||||
<th>Prix (TTC)</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<?php if($userProducerWithProductPercent && count($userProducerWithProductPercent) > 0): ?> | |||||
<?php foreach($userProducerWithProductPercent as $userProducer): ?> | |||||
<?php if($userProducer->user): ?> | |||||
<tr> | |||||
<td><?= $userProducer->user->getUsername() ?></td> | |||||
<td><?= $userProducer->product_price_percent ?> %</td> | |||||
<td><?= Price::format($model->getPrice(['user_producer' => $userProducer])) ?></td> | |||||
<td><?= Price::format($model->getPriceWithTax(['user_producer' => $userProducer])) ?></td> | |||||
</tr> | |||||
<?php endif; ?> | |||||
<?php endforeach; ?> | |||||
<?php else: ?> | |||||
<tr><td colspan="4">Aucun résultat</td></tr> | |||||
<?php endif; ?> | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
</div> | |||||
echo GridView::widget([ | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'id_user', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if ($model->user) { | |||||
return $model->user->getUsername(); | |||||
} | |||||
return '<span class="label label-success">Tous</span>'; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_user_group', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if ($model->userGroup) { | |||||
return $model->userGroup->name; | |||||
} | |||||
return '<span class="label label-success">Tous</span>'; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_point_sale', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if ($model->pointSale) { | |||||
return $model->pointSale->name; | |||||
} | |||||
return '<span class="label label-success">Tous</span>'; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'from_quantity', | |||||
'value' => function ($productPrice) { | |||||
$productManager = ProductManager::getInstance(); | |||||
if ($productPrice->from_quantity) { | |||||
return $productPrice->from_quantity . ' ' . $productManager->strUnit($productManager->getRefUnit($productPrice->product->unit), 'wording'); | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'price', | |||||
'value' => function ($productPrice) { | |||||
return Price::numberTwoDecimals($productPrice->price) . ' €'; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'price', | |||||
'header' => 'Prix (TTC)', | |||||
'value' => function ($productPrice) use ($model) { | |||||
return Price::numberTwoDecimals(Price::getPriceWithTax($productPrice->price, $model->taxRate->value)) . ' €'; | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{update} {delete}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'update' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['product/prices-update', 'id' => $model->id], [ | |||||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['product/prices-delete', 'id' => $model->id], [ | |||||
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' | |||||
]); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Pourcentage global / Points de vente</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<table class="table table-bordered"> | |||||
<thead> | |||||
<tr> | |||||
<th>Point de vente</th> | |||||
<th>Pourcentage</th> | |||||
<th>Prix (HT)</th> | |||||
<th>Prix (TTC)</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<?php if($pointSaleWithProductPercent && count($pointSaleWithProductPercent) > 0): ?> | |||||
<?php foreach($pointSaleWithProductPercent as $pointSale): ?> | |||||
<tr> | |||||
<td><?= Html::encode($pointSale->name) ?></td> | |||||
<td><?= $pointSale->product_price_percent ?> %</td> | |||||
<td><?= Price::format($model->getPrice(['point_sale' => $pointSale])) ?></td> | |||||
<td><?= Price::format($model->getPriceWithTax(['point_sale' => $pointSale])) ?></td> | |||||
</tr> | |||||
<?php endforeach; ?> | |||||
<?php else: ?> | |||||
<tr><td colspan="4">Aucun résultat</td></tr> | |||||
<?php endif; ?> | |||||
</tbody> | |||||
</table> | |||||
</div> | |||||
?> | |||||
</div> | </div> | ||||
--> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Rappel du prix de base</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<p>Prix de base : <strong><?= Price::format($model->getPrice()); ?> HT</strong> / <strong><?= Price::format($model->getPriceWithTax()); ?> TTC</strong><br /></p> | |||||
</div> | |||||
</div> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Rappel du prix de base</h3> | |||||
</div> | </div> | ||||
</div> | |||||
<!-- | |||||
<div class="col-md-4"> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Priorités de résolution</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<p>Le prix d'un produit se déduit dans un ordre précis de résolution, le voici : </p> | |||||
<ul> | |||||
<li>Les prix spécifiques définis au niveau du produit</li> | |||||
<li>Les pourcentages globaux définis au niveau des utilisateurs et points de vente</li> | |||||
<li>Le prix de base défini au niveau du produit</li> | |||||
</ul> | |||||
<p>À chaque étape de résolution, on vérifie si le contexte courant (utilisateur / point de vente) correspond à un prix. | |||||
Si c'est le cas, on l'utilise, sinon on passe à l'étape suivante jusqu'à arriver au prix de base | |||||
défini dans "Général". | |||||
</p> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<p>Prix de base : <strong><?= Price::format($productManager->getPrice($model)); ?> HT</strong> / | |||||
<strong><?= Price::format($productManager->getPriceWithTax($model)); ?> TTC</strong><br/></p> | |||||
</div> | </div> | ||||
</div> | |||||
--> | |||||
</div> | |||||
</div> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | use yii\helpers\ArrayHelper ; | ||||
use common\models\ User ; | |||||
use common\models\PointSale ; | |||||
use common\helpers\GlobalParam ; | |||||
use common\logic\Subscription\Subscription\Model\Subscription; | |||||
\backend\assets\VuejsSubscriptionFormAsset::register($this); | \backend\assets\VuejsSubscriptionFormAsset::register($this); | ||||
$userManager = $this->getUserManager(); | |||||
$pointSaleManager = $this->getPointSaleManager(); | |||||
?> | ?> | ||||
<div class="subscription-form" id="app-subscription-form"> | <div class="subscription-form" id="app-subscription-form"> | ||||
<?= $form->field($model, 'id')->hiddenInput() ?> | <?= $form->field($model, 'id')->hiddenInput() ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="col-md-5" id="bloc-select-user"> | <div class="col-md-5" id="bloc-select-user"> | ||||
<?= $form->field($model, 'id_user')->dropDownList( User::populateDropdownList(), ['class' => 'select2']); ?> | |||||
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']); ?> | |||||
</div> | </div> | ||||
<div class="col-md-1" id="or-user"> | <div class="col-md-1" id="or-user"> | ||||
<span>OU</span> | <span>OU</span> | ||||
<div class="clr"></div> | <div class="clr"></div> | ||||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | <?= $form->field($model, 'id_producer')->hiddenInput() ?> | ||||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::searchAll(), 'id', function($model, $defaultValue) { | |||||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map($pointSaleManager->findPointSales(), 'id', function($model, $defaultValue) { | |||||
return $model['name']; | return $model['name']; | ||||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | }), ['prompt' => '--','class' => 'form-control user-id']) ?> | ||||
<?= $form->field($model, 'date_begin') ?> | <?= $form->field($model, 'date_begin') ?> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\models\Product ; | |||||
use common\helpers\GlobalParam ; | use common\helpers\GlobalParam ; | ||||
use common\logic\Subscription\Subscription\Model\Subscription; | |||||
use common\logic\PointSale\PointSale\Model\PointSale; | |||||
use common\logic\Product\Product\Wrapper\ProductManager; | |||||
use yii\helpers\ArrayHelper; | |||||
use common\logic\Product\Product\Model\Product; | |||||
$this->setTitle('Abonnements') ; | $this->setTitle('Abonnements') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
$subscriptionsArray = Subscription::searchAll() ; | $subscriptionsArray = Subscription::searchAll() ; | ||||
?> | ?> | ||||
<div class="subscription-index"> | <div class="subscription-index"> | ||||
'label' => 'Produits', | 'label' => 'Produits', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
$productManager = ProductManager::getInstance(); | |||||
$html = '' ; | $html = '' ; | ||||
foreach($model->productSubscription as $productSubscription) | foreach($model->productSubscription as $productSubscription) | ||||
{ | { | ||||
if(isset($productSubscription->product)) { | if(isset($productSubscription->product)) { | ||||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. Product::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. $productManager->strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||||
} | } | ||||
else { | else { | ||||
$html .= 'Produit non défini<br />' ; | $html .= 'Produit non défini<br />' ; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\models\ User; | |||||
use common\models\Order; | |||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | |||||
use common\logic\User\User\Model\User; | |||||
$this->setTitle('Utilisateurs'); | $this->setTitle('Utilisateurs'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
'attribute' => 'username', | 'attribute' => 'username', | ||||
'label' => 'Nom', | 'label' => 'Nom', | ||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
return User::getUsernameFromArray($model); | |||||
$userManager = UserManager::getInstance(); | |||||
return $userManager->getUsername($model); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'type', | 'attribute' => 'type', | ||||
'label' => 'Type', | 'label' => 'Type', | ||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
$typeArray = User::getTypeChoicesArray(); | |||||
$userManager = UserManager::getInstance(); | |||||
$typeArray = $userManager->getTypeChoicesArray(); | |||||
if(isset($typeArray[$model['type']])) { | if(isset($typeArray[$model['type']])) { | ||||
return $typeArray[$model['type']]; | return $typeArray[$model['type']]; | ||||
} | } | ||||
'attribute' => 'credit', | 'attribute' => 'credit', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) use ($producer) { | 'value' => function ($model) use ($producer) { | ||||
$userProducer = UserProducer::searchOne([ | $userProducer = UserProducer::searchOne([ | ||||
'id_user' => $model->id | 'id_user' => $model->id | ||||
]); | ]); |
$this->getTaxRateContainer(), | $this->getTaxRateContainer(), | ||||
$this->getUserUserGroupContainer(), | $this->getUserUserGroupContainer(), | ||||
$this->getUserGroupContainer(), | $this->getUserGroupContainer(), | ||||
$this->getDocumentContainer(), | |||||
$this->getCreditHistoryContainer(), | $this->getCreditHistoryContainer(), | ||||
$this->getProducerPriceRangeContainer(), | $this->getProducerPriceRangeContainer(), | ||||
$this->getUserProducerContainer(), | $this->getUserProducerContainer(), | ||||
$this->getProductPriceContainer(), | $this->getProductPriceContainer(), | ||||
$this->getProductSubscriptionContainer(), | $this->getProductSubscriptionContainer(), | ||||
$this->getUserPointSaleContainer(), | $this->getUserPointSaleContainer(), | ||||
$this->getQuotationContainer(), | |||||
$this->getInvoiceContainer(), | |||||
$this->getDeliveryNoteContainer(), | |||||
$this->getDocumentContainer(), | |||||
$this->getPointSaleContainer(), | $this->getPointSaleContainer(), | ||||
$this->getSubscriptionContainer(), | $this->getSubscriptionContainer(), | ||||
$this->getProductContainer(), | $this->getProductContainer(), | ||||
} | } | ||||
} | } | ||||
throw new ErrorException('Service '.$serviceClass.' introuvable dans le container.'); | |||||
throw new ErrorException('Service '.$serviceClass.' introuvable dans les containers.'); | |||||
} | } | ||||
} | } |
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionManager; | use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionManager; | ||||
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionContainer; | use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionContainer; | ||||
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionManager; | use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionManager; | ||||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteContainer; | |||||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | ||||
use common\logic\Document\Document\Wrapper\DocumentContainer; | use common\logic\Document\Document\Wrapper\DocumentContainer; | ||||
use common\logic\Document\Document\Wrapper\DocumentManager; | use common\logic\Document\Document\Wrapper\DocumentManager; | ||||
use common\logic\Document\Invoice\Wrapper\InvoiceContainer; | |||||
use common\logic\Document\Invoice\Wrapper\InvoiceManager; | use common\logic\Document\Invoice\Wrapper\InvoiceManager; | ||||
use common\logic\Document\Quotation\Wrapper\QuotationContainer; | |||||
use common\logic\Document\Invoice\Wrapper\QuotationManager; | use common\logic\Document\Invoice\Wrapper\QuotationManager; | ||||
use common\logic\Order\Order\Wrapper\OrderContainer; | use common\logic\Order\Order\Wrapper\OrderContainer; | ||||
use common\logic\Order\Order\Wrapper\OrderManager; | use common\logic\Order\Order\Wrapper\OrderManager; | ||||
return DocumentContainer::getInstance(); | return DocumentContainer::getInstance(); | ||||
} | } | ||||
public function getDeliveryNoteContainer(): DeliveryNoteContainer | |||||
{ | |||||
return DeliveryNoteContainer::getInstance(); | |||||
} | |||||
public function getInvoiceContainer(): InvoiceContainer | |||||
{ | |||||
return InvoiceContainer::getInstance(); | |||||
} | |||||
public function getQuotationContainer(): QuotationContainer | |||||
{ | |||||
return QuotationContainer::getInstance(); | |||||
} | |||||
public function getUserGroupContainer(): UserGroupContainer | public function getUserGroupContainer(): UserGroupContainer | ||||
{ | { | ||||
return UserGroupContainer::getInstance(); | return UserGroupContainer::getInstance(); |
namespace common\forms; | namespace common\forms; | ||||
use common\logic\Product\Product\Model\Product; | |||||
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | |||||
use common\logic\Subscription\Subscription\Model\Subscription; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
use common\models\Subscription; | |||||
use common\models\SubscriptionProduct; | |||||
/** | /** | ||||
* Login form | * Login form |
namespace common\logic\Config\TaxRate\Repository; | namespace common\logic\Config\TaxRate\Repository; | ||||
use common\logic\AbstractRepository; | use common\logic\AbstractRepository; | ||||
use common\logic\Config\TaxRate\Model\TaxRate; | |||||
class TaxRateRepository extends AbstractRepository | class TaxRateRepository extends AbstractRepository | ||||
{ | { |
]; | ]; | ||||
} | } | ||||
public function getFactory(): DeliveryNoteBuilder | |||||
public function getBuilder(): DeliveryNoteBuilder | |||||
{ | { | ||||
return DeliveryNoteBuilder::getInstance(); | return DeliveryNoteBuilder::getInstance(); | ||||
} | } |
use common\logic\Document\Document\Model\Document; | use common\logic\Document\Document\Model\Document; | ||||
use common\logic\Document\Document\Model\DocumentInterface; | use common\logic\Document\Document\Model\DocumentInterface; | ||||
use common\logic\Order\Order\Model\Order; | use common\logic\Order\Order\Model\Order; | ||||
use common\logic\Order\ProductOrder\Service\ProductOrderSolver; | |||||
use common\logic\PointSale\PointSale\Model\PointSale; | use common\logic\PointSale\PointSale\Model\PointSale; | ||||
use common\logic\SolverInterface; | use common\logic\SolverInterface; | ||||
class DocumentSolver extends AbstractService implements SolverInterface | class DocumentSolver extends AbstractService implements SolverInterface | ||||
{ | { | ||||
protected ProductOrderSolver $productOrderSolver; | |||||
public function loadDependencies(): void | |||||
{ | |||||
$this->productOrderSolver = $this->loadService(ProductOrderSolver::class); | |||||
} | |||||
public function getAmount(DocumentInterface $document, string $type = Order::AMOUNT_TOTAL, bool $format = false) | public function getAmount(DocumentInterface $document, string $type = Order::AMOUNT_TOTAL, bool $format = false) | ||||
{ | { | ||||
return $this->_getAmountGeneric($document, $type, false, $format); | return $this->_getAmountGeneric($document, $type, false, $format); | ||||
foreach($this->getProductsOrders($document) as $productOrderArray) { | foreach($this->getProductsOrders($document) as $productOrderArray) { | ||||
foreach($productOrderArray as $productOrder) { | foreach($productOrderArray as $productOrder) { | ||||
$priceLine = $productOrder->getPriceByTypeTotal($type) * $productOrder->quantity; | |||||
$priceLine = $this->productOrderSolver->getPriceByTypeTotal($productOrder, $type) * $productOrder->quantity; | |||||
$amount += $priceLine; | $amount += $priceLine; | ||||
$totalVat += Price::getVat($priceLine, $productOrder->taxRate->value, $document->tax_calculation_method); | $totalVat += Price::getVat($priceLine, $productOrder->taxRate->value, $document->tax_calculation_method); | ||||
} | } |
<?php | <?php | ||||
namespace common\logic\Document\Invoice\Wrapper; | |||||
namespace common\logic\Document\Quotation\Wrapper; | |||||
use common\logic\AbstractContainer; | use common\logic\AbstractContainer; | ||||
use common\logic\Document\Document\Service\DocumentSolver; | use common\logic\Document\Document\Service\DocumentSolver; |
$productPointSale = $this->instanciateProductPointSale(); | $productPointSale = $this->instanciateProductPointSale(); | ||||
$productPointSale->populateProduct($product); | $productPointSale->populateProduct($product); | ||||
$productPointSale->populatePointSale($pointSale); | $productPointSale->populatePointSale($pointSale); | ||||
$productPointSale->availability = $available; | |||||
$productPointSale->available = $available; | |||||
$this->saveCreate($productPointSale); | $this->saveCreate($productPointSale); | ||||
return $this->queryUsersBy()->all(); | return $this->queryUsersBy()->all(); | ||||
} | } | ||||
public static function populateUserDropdownList() | |||||
public function populateUserDropdownList() | |||||
{ | { | ||||
$usersArray = | |||||
$usersArray = $this->findUsers(); | |||||
$usersArrayDropdown = ['' => '--']; | $usersArrayDropdown = ['' => '--']; | ||||
foreach ($usersArray as $user) { | foreach ($usersArray as $user) { | ||||
$usersArrayDropdown[$user['user_id']] = User::getUsernameFromArray($user, true); | |||||
$usersArrayDropdown[$user['user_id']] = $this->userSolver->getUsernameFromArray($user, true); | |||||
} | } | ||||
return $usersArrayDropdown;; | |||||
return $usersArrayDropdown; | |||||
} | } | ||||
/** | /** |