use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\models\Order; | use common\models\Order; | ||||
use yii\base\UserException; | use yii\base\UserException; | ||||
use yii; | |||||
class DocumentController extends BackendController | class DocumentController extends BackendController | ||||
{ | { | ||||
throw new UserException('Vous ne pouvez pas supprimer un document validé.'); | throw new UserException('Vous ne pouvez pas supprimer un document validé.'); | ||||
} | } | ||||
$model->delete() ; | |||||
$model->delete(); | |||||
Order::updateAll([ | Order::updateAll([ | ||||
'order.id_delivery_note' => null | 'order.id_delivery_note' => null | ||||
],[ | |||||
], [ | |||||
'order.id_delivery_note' => $id | 'order.id_delivery_note' => $id | ||||
]) ; | |||||
]); | |||||
Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('delete', $model)); | Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('delete', $model)); | ||||
$this->redirect(['delivery-note/index']) ; | |||||
$this->redirect(['delivery-note/index']); | |||||
} | |||||
public function actionDownload($id) | |||||
{ | |||||
$document = $this->findModel($id); | |||||
$producer = GlobalParam::getCurrentProducer(); | |||||
$content = $this->renderPartial('/document/download', [ | |||||
'producer' => $producer, | |||||
'document' => $document | |||||
]); | |||||
$contentFooter = '<div id="footer">'; | |||||
$contentFooter .= '<div class="infos-bottom">' . Html::encode($producer->document_infos_bottom) . '</div>'; | |||||
if ($document->isStatusValid() || $document->isStatusDraft()) { | |||||
$contentFooter .= '<div class="reference-document">'; | |||||
if ($document->isStatusValid()) { | |||||
$contentFooter .= $document->getType() . ' N°' . $document->reference; | |||||
} | |||||
if ($document->isStatusDraft()) { | |||||
$contentFooter .= $document->getType() . ' non validé'; | |||||
if($document->getType() == 'Facture') { | |||||
$contentFooter .= 'e' ; | |||||
} | |||||
} | |||||
$contentFooter .= '</div>'; | |||||
} | |||||
$contentFooter .= '</div>'; | |||||
$pdf = new Pdf([ | |||||
'mode' => Pdf::MODE_UTF8, | |||||
'format' => Pdf::FORMAT_A4, | |||||
'orientation' => Pdf::ORIENT_PORTRAIT, | |||||
'destination' => Pdf::DEST_BROWSER, | |||||
'content' => $content, | |||||
'cssFile' => Yii::getAlias('@webroot/css/document/download.css'), | |||||
'methods' => [ | |||||
//'SetHeader' => [''], | |||||
//'SetFooter' => [$contentFooter], | |||||
'SetHTMLFooter' => $contentFooter | |||||
] | |||||
]); | |||||
return $pdf->render(); | |||||
} | } | ||||
public function actionAjaxAddressUser($idUser) | public function actionAjaxAddressUser($idUser) | ||||
if ($idUser > 0) { | if ($idUser > 0) { | ||||
$user = User::searchOne([ | $user = User::searchOne([ | ||||
'id' => $idUser | 'id' => $idUser | ||||
]) ; | |||||
]); | |||||
if ($user) { | if ($user) { | ||||
return [ | return [ | ||||
public function actionValidate($id) | public function actionValidate($id) | ||||
{ | { | ||||
$classDocument = $this->getClass() ; | |||||
$classDocument = $this->getClass(); | |||||
if ($id > 0 && Document::isValidClass($classDocument)) { | if ($id > 0 && Document::isValidClass($classDocument)) { | ||||
$document = $classDocument::searchOne([ | $document = $classDocument::searchOne([ | ||||
$document->changeStatus(Document::STATUS_VALID); | $document->changeStatus(Document::STATUS_VALID); | ||||
$document->save(); | $document->save(); | ||||
Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('validate', $document)); | Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('validate', $document)); | ||||
return $this->redirect(['delivery-note/index']) ; | |||||
return $this->redirect(['delivery-note/index']); | |||||
} | } | ||||
} | } | ||||
Yii::$app->getSession()->setFlash('danger', 'Une erreur est survenue lors de la validation du document.'); | Yii::$app->getSession()->setFlash('danger', 'Une erreur est survenue lors de la validation du document.'); | ||||
return $this->redirect(['delivery-note/index']) ; | |||||
return $this->redirect(['delivery-note/index']); | |||||
} | } | ||||
public function actionAjaxValidateDocument($idDocument, $classDocument) | public function actionAjaxValidateDocument($idDocument, $classDocument) | ||||
$order->id_user = $document->id_user; | $order->id_user = $document->id_user; | ||||
$order->id_point_sale = null; | $order->id_point_sale = null; | ||||
$order->id_distribution = null; | $order->id_distribution = null; | ||||
$order->status = 'tmp-order' ; | |||||
$order->origin = Order::ORIGIN_ADMIN; | $order->origin = Order::ORIGIN_ADMIN; | ||||
$order->date = date('Y-m-d H:i:s'); | $order->date = date('Y-m-d H:i:s'); | ||||
$fieldIdDocument = 'id_' . $classDocument::tableName(); | $fieldIdDocument = 'id_' . $classDocument::tableName(); | ||||
$productOrder->save(); | $productOrder->save(); | ||||
return [ | return [ | ||||
'return' => 'error', | |||||
'return' => 'success', | |||||
'alert' => [ | 'alert' => [ | ||||
'type' => 'success', | 'type' => 'success', | ||||
'message' => 'Produit ajouté' | 'message' => 'Produit ajouté' | ||||
]; | ]; | ||||
} | } | ||||
protected function getClass() | |||||
public function getClass() | |||||
{ | { | ||||
$class = get_class($this); | $class = get_class($this); | ||||
$class = str_replace('Controller', '', $class); | $class = str_replace('Controller', '', $class); | ||||
return $class; | return $class; | ||||
} | } | ||||
protected function getDocumentType() | |||||
public function getDocumentType() | |||||
{ | { | ||||
$class = $this->getClass(); | $class = $this->getClass(); | ||||
if ($type == 'create') { | if ($type == 'create') { | ||||
$message .= 'ajouté'; | $message .= 'ajouté'; | ||||
} | |||||
elseif ($type == 'update') { | |||||
} elseif ($type == 'update') { | |||||
$message .= 'modifié'; | $message .= 'modifié'; | ||||
} | |||||
elseif ($type == 'delete') { | |||||
} elseif ($type == 'delete') { | |||||
$message .= 'supprimé'; | $message .= 'supprimé'; | ||||
} | |||||
elseif ($type == 'validate') { | |||||
} elseif ($type == 'validate') { | |||||
$message .= 'validé'; | $message .= 'validé'; | ||||
} | } | ||||
* Recherche un Document en fonction de son ID. | * Recherche un Document en fonction de son ID. | ||||
* | * | ||||
* @param integer $id | * @param integer $id | ||||
* @return Produit | |||||
* @return Document | |||||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | * @throws NotFoundHttpException si le modèle n'est pas trouvé | ||||
*/ | */ | ||||
protected function findModel($id) | protected function findModel($id) | ||||
$model = $class::searchOne([ | $model = $class::searchOne([ | ||||
'id' => $id | 'id' => $id | ||||
]) ; | |||||
]); | |||||
if ($model) { | if ($model) { | ||||
return $model; | return $model; |
], | ], | ||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'template' => '{validate} {update} {delete}', | |||||
'template' => '{validate} {update} {delete} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | 'buttons' => [ | ||||
'download' => function($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Télécharger'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'validate' => function ($url, $model) { | 'validate' => function ($url, $model) { | ||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | ||||
'title' => Yii::t('app', 'Valider'), 'class' => 'btn btn-default' | 'title' => Yii::t('app', 'Valider'), 'class' => 'btn btn-default' |
<div id="" class="info-box"> | <div id="" class="info-box"> | ||||
<span class="info-box-icon bg-blue"><i class="fa fa-download"></i></span> | <span class="info-box-icon bg-blue"><i class="fa fa-download"></i></span> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<a href="#" class="btn btn-default">Télécharger (PDF)</a> | |||||
<a href="<?= Yii::$app->urlManager->createUrl([$model->getControllerUrlPath().'/download', 'id' => $model->id]) ?>" class="btn btn-default">Télécharger (PDF)</a> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div id="" class="info-box"> | <div id="" class="info-box"> |
<?php | |||||
?> | |||||
<div class="document-download"> | |||||
<div id="block-addresses"> | |||||
<div class="producer"> | |||||
<?php if(strlen($producer->logo)) : ?> | |||||
<div class="logo"><?= $producer->getHtmlLogo() ; ?></div> | |||||
<?php endif; ?> | |||||
<div class="address"><?= $producer->getFullAddress(true) ; ?></div> | |||||
</div> | |||||
<div class="user"> | |||||
<?= $document->user->getFullAddress(true) ; ?> | |||||
</div> | |||||
</div> | |||||
<div id="block-infos-document"> | |||||
<div class="date"> | |||||
Le <?= strftime('%d %B %Y', strtotime($document->date)) ?> | |||||
</div> | |||||
<div class="reference"> | |||||
<?php if(strlen($document->reference)) : ?> | |||||
<?= $document->getType(); ?> N°<?= $document->reference ; ?> | |||||
<?php else: ?> | |||||
<div class="block-is-draft"><?= $document->getType(); ?> non validé<?= ($document->getType() == 'Facture') ? 'e' : '' ?></div> | |||||
<?php endif; ?> | |||||
</div> | |||||
<div class="name"> | |||||
<strong>Libellé : </strong><?= $document->name ; ?> | |||||
</div> | |||||
</div> | |||||
<div id="block-products"> | |||||
<?php if(count($document->orders) > 0) : ?> | |||||
<table class="table table-bordered"> | |||||
<thead> | |||||
<tr> | |||||
<th class="align-left">Produit</th> | |||||
<th>Prix unitaire HT</th> | |||||
<th>Quantité</th> | |||||
<th>Unité</th> | |||||
<th>Prix HT</th> | |||||
</tr> | |||||
</thead> | |||||
<tbody> | |||||
<?php foreach($document->orders as $order): ?> | |||||
<?php foreach($order->productOrder as $productOrder): ?> | |||||
<tr> | |||||
<td class="align-left"><?= Html::encode($productOrder->product->name) ?></td> | |||||
<td class="align-center"><?= Price::format($productOrder->product->getPrice()) ?></td> | |||||
<td class="align-center"><?= $productOrder->quantity ?></td> | |||||
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | |||||
<td class="align-center"><?= Price::format($productOrder->product->getPrice() * $productOrder->quantity) ?></td> | |||||
</tr> | |||||
<?php endforeach; ?> | |||||
<?php endforeach; ?> | |||||
<tr> | |||||
<td class="align-right" colspan="4"><strong>Total HT</strong></td> | |||||
<td class="align-center"><?= Price::format($document->getAmount()) ?></td> | |||||
</tr> | |||||
<tr> | |||||
<td class="align-right" colspan="4"><strong>TVA</strong></td> | |||||
<td class="align-center"><?= Price::format($document->getAmountWithTax() - $document->getAmount()) ?></td> | |||||
</tr> | |||||
<tr> | |||||
<td class="align-right" colspan="4"><strong>Total TTC</strong></td> | |||||
<td class="align-center"><?= Price::format($document->getAmountWithTax()) ?></td> | |||||
</tr> | |||||
</tbody> | |||||
</table> | |||||
<?php else : ?> | |||||
<div id="block-no-product"> | |||||
<strong>Aucun produit</strong> | |||||
</div> | |||||
<?php endif; ?> | |||||
</div> | |||||
<?php | |||||
$fieldProducerDocumentInfo = 'document_infos_'.str_replace('deliverynote','delivery_note',strtolower($document->getClass())) ; ?> | |||||
<?php if(strlen($producer->$fieldProducerDocumentInfo)): ?> | |||||
<div id="block-infos"> | |||||
<?= nl2br(Html::encode($producer->$fieldProducerDocumentInfo)) ?> | |||||
</div> | |||||
<?php endif; ?> | |||||
</div> |
], | ], | ||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'template' => '{update} {delete}', | |||||
'template' => '{update} {delete} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | 'buttons' => [ | ||||
'download' => function($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Télécharger'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'update' => function ($url, $model) { | 'update' => function ($url, $model) { | ||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | ||||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' |
<?= $form->field($model, 'name') ?> | <?= $form->field($model, 'name') ?> | ||||
<?= $form->field($model, 'type') ?> | <?= $form->field($model, 'type') ?> | ||||
<?= $form->field($model, 'description') | <?= $form->field($model, 'description') | ||||
->textarea(['rows' => 6]) | |||||
->textarea(['rows' => 4]) | |||||
->hint('Affiché sur la page d\'accueil') ?> | ->hint('Affiché sur la page d\'accueil') ?> | ||||
<?= $form->field($model, 'address') | |||||
->textarea(['rows' => 4]) ?> | |||||
<?= $form->field($model, 'postcode') ?> | <?= $form->field($model, 'postcode') ?> | ||||
<?= $form->field($model, 'city') ?> | <?= $form->field($model, 'city') ?> | ||||
], | ], | ||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | 'class' => 'yii\grid\ActionColumn', | ||||
'template' => '{update} {delete}', | |||||
'template' => '{update} {delete} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | 'buttons' => [ | ||||
'download' => function($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Télécharger'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'update' => function ($url, $model) { | 'update' => function ($url, $model) { | ||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | ||||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' |
/* line 5, ../../sass/document/download.scss */ | |||||
.document-download { | |||||
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; | |||||
} | |||||
/* line 9, ../../sass/document/download.scss */ | |||||
.document-download #block-addresses .producer { | |||||
text-align: left; | |||||
margin-bottom: 20px; | |||||
} | |||||
/* line 13, ../../sass/document/download.scss */ | |||||
.document-download #block-addresses .producer .logo { | |||||
margin-bottom: 20px; | |||||
} | |||||
/* line 20, ../../sass/document/download.scss */ | |||||
.document-download #block-addresses .user { | |||||
text-align: right; | |||||
} | |||||
/* line 25, ../../sass/document/download.scss */ | |||||
.document-download #block-infos-document { | |||||
padding-top: 30px; | |||||
} | |||||
/* line 28, ../../sass/document/download.scss */ | |||||
.document-download #block-infos-document .date { | |||||
padding-bottom: 10px; | |||||
} | |||||
/* line 31, ../../sass/document/download.scss */ | |||||
.document-download #block-infos-document .reference { | |||||
padding-bottom: 10px; | |||||
font-size: 15px; | |||||
font-weight: bold; | |||||
} | |||||
/* line 36, ../../sass/document/download.scss */ | |||||
.document-download #block-infos-document .reference .block-is-draft { | |||||
border: solid 2px black; | |||||
padding: 10px; | |||||
text-transform: uppercase; | |||||
} | |||||
/* line 47, ../../sass/document/download.scss */ | |||||
.document-download #block-no-product { | |||||
font-weight: bold; | |||||
border: solid 2px black; | |||||
text-transform: uppercase; | |||||
padding: 10px; | |||||
} | |||||
/* line 54, ../../sass/document/download.scss */ | |||||
.document-download #block-products { | |||||
padding-top: 20px; | |||||
} | |||||
/* line 57, ../../sass/document/download.scss */ | |||||
.document-download #block-products table { | |||||
width: 100%; | |||||
padding: 0px; | |||||
margin: 0px; | |||||
border-bottom: solid 1px #c0c0c0; | |||||
border-right: solid 1px #c0c0c0; | |||||
border-collapse: collapse; | |||||
} | |||||
/* line 65, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td, .document-download #block-products table th { | |||||
padding: 5px; | |||||
border-top: solid 1px #c0c0c0; | |||||
border-left: solid 1px #c0c0c0; | |||||
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; | |||||
} | |||||
/* line 71, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.align-left, .document-download #block-products table th.align-left { | |||||
text-align: left; | |||||
} | |||||
/* line 74, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.align-center, .document-download #block-products table th.align-center { | |||||
text-align: center; | |||||
} | |||||
/* line 77, ../../sass/document/download.scss */ | |||||
.document-download #block-products table td.align-right, .document-download #block-products table th.align-right { | |||||
text-align: right; | |||||
} | |||||
/* line 84, ../../sass/document/download.scss */ | |||||
.document-download #block-infos { | |||||
margin-top: 20px; | |||||
padding: 10px; | |||||
border: solid 1px #c0c0c0; | |||||
} | |||||
/* line 91, ../../sass/document/download.scss */ | |||||
#footer { | |||||
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; | |||||
text-align: center; | |||||
padding-top: 20px; | |||||
border-top: solid 1px gray; | |||||
} | |||||
/* line 97, ../../sass/document/download.scss */ | |||||
#footer .infos-bottom { | |||||
padding-bottom: 20px; | |||||
margin-bottom: 40px; | |||||
font-size: 12px; | |||||
line-height: 18px; | |||||
} | |||||
/* line 103, ../../sass/document/download.scss */ | |||||
#footer .reference-document { | |||||
font-weight: bold; | |||||
} |
$font-family: 'Source Sans Pro','Helvetica Neue',Helvetica,Arial,sans-serif ; | |||||
$border-color: #c0c0c0 ; | |||||
.document-download { | |||||
font-family: $font-family ; | |||||
#block-addresses { | |||||
.producer { | |||||
text-align: left ; | |||||
margin-bottom: 20px ; | |||||
.logo { | |||||
margin-bottom: 20px ; | |||||
} | |||||
.address { | |||||
} | |||||
} | |||||
.user { | |||||
text-align: right ; | |||||
} | |||||
} | |||||
#block-infos-document { | |||||
padding-top: 30px ; | |||||
.date { | |||||
padding-bottom: 10px ; | |||||
} | |||||
.reference { | |||||
padding-bottom: 10px ; | |||||
font-size: 15px ; | |||||
font-weight: bold ; | |||||
.block-is-draft { | |||||
border: solid 2px black ; | |||||
padding: 10px ; | |||||
text-transform: uppercase ; | |||||
} | |||||
} | |||||
.name { | |||||
} | |||||
} | |||||
#block-no-product { | |||||
font-weight: bold ; | |||||
border: solid 2px black ; | |||||
text-transform: uppercase ; | |||||
padding: 10px ; | |||||
} | |||||
#block-products { | |||||
padding-top: 20px ; | |||||
table { | |||||
width: 100% ; | |||||
padding: 0px ; | |||||
margin: 0px ; | |||||
border-bottom: solid 1px $border-color ; | |||||
border-right: solid 1px $border-color ; | |||||
border-collapse: collapse ; | |||||
td, th { | |||||
padding: 5px ; | |||||
border-top: solid 1px $border-color ; | |||||
border-left: solid 1px $border-color ; | |||||
font-family: $font-family ; | |||||
&.align-left { | |||||
text-align: left ; | |||||
} | |||||
&.align-center { | |||||
text-align: center ; | |||||
} | |||||
&.align-right { | |||||
text-align: right ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
#block-infos { | |||||
margin-top: 20px ; | |||||
padding: 10px ; | |||||
border: solid 1px $border-color ; | |||||
} | |||||
} | |||||
#footer { | |||||
font-family: $font-family ; | |||||
text-align: center ; | |||||
padding-top: 20px ; | |||||
border-top: solid 1px gray ; | |||||
.infos-bottom { | |||||
padding-bottom: 20px ; | |||||
margin-bottom: 40px ; | |||||
font-size: 12px ; | |||||
line-height: 18px ; | |||||
} | |||||
.reference-document { | |||||
font-weight: bold ; | |||||
} | |||||
} |
public static function format($number) | public static function format($number) | ||||
{ | { | ||||
return number_format($number, 2) . ' €'; | |||||
return str_replace('.', ',',number_format($number, 2)) . ' €'; | |||||
} | } | ||||
public static function getPrice($priceWithTax, $taxRate) | public static function getPrice($priceWithTax, $taxRate) |
return str_replace('common\models\\','',get_class($this)) ; | return str_replace('common\models\\','',get_class($this)) ; | ||||
} | } | ||||
public function getControllerUrlPath() | |||||
public function getType() | |||||
{ | { | ||||
$class = $this->getClass() ; | |||||
$path = strtolower($class) ; | |||||
$class = $this->getClass(); | |||||
if ($class == 'Invoice') { | |||||
$documentType = 'Facture'; | |||||
} elseif ($class == 'DeliveryNote') { | |||||
$documentType = 'Bon de livraison'; | |||||
} elseif ($class == 'Quotation') { | |||||
$documentType = 'Devis'; | |||||
} | |||||
if($path == 'deliverynote') { | |||||
$path = 'delivery_note' ; | |||||
if (isset($documentType)) { | |||||
return $documentType; | |||||
} | } | ||||
return ''; | |||||
} | |||||
public function getControllerUrlPath() | |||||
{ | |||||
$path = strtolower($this->getClass()); | |||||
$path = str_replace('deliverynote', 'delivery-note', $path) ; | |||||
return $path ; | return $path ; | ||||
} | } | ||||
public function rules() | public function rules() | ||||
{ | { | ||||
return [ | return [ | ||||
[['id_user', 'date', 'id_point_sale', 'id_distribution', 'status'], 'required', 'message' => ''], | |||||
[['id_user', 'date', 'status'], 'required', 'message' => ''], | |||||
[['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | [['id_user', 'id_point_sale', 'id_distribution', 'id_subscription', 'id_invoice', 'id_quotation', 'id_delivery_note'], 'integer'], | ||||
[['auto_payment', 'tiller_synchronization'], 'boolean'], | [['auto_payment', 'tiller_synchronization'], 'boolean'], | ||||
[['status'], 'string'], | [['status'], 'string'], |
} | } | ||||
}], | }], | ||||
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', | [['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status', | ||||
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note'], 'string'], | |||||
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address'], 'string'], | |||||
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller'], 'boolean'], | [['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller'], 'boolean'], | ||||
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255], | [['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255], | ||||
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'], | [['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'], | ||||
'document_infos_quotation' => 'Informations affichées en bas des devis', | 'document_infos_quotation' => 'Informations affichées en bas des devis', | ||||
'document_infos_invoice' => 'Informations affichées en bas des factures', | 'document_infos_invoice' => 'Informations affichées en bas des factures', | ||||
'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison', | 'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison', | ||||
'address' => 'Adresse' | |||||
]; | ]; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
public function getFullAddress($nl2br = false) | |||||
{ | |||||
$address = '' ; | |||||
$address .= $this->name."\n" ; | |||||
if(strlen($this->address)) { | |||||
$address .= $this->address."\n" ; | |||||
} | |||||
if(strlen($this->postcode) || strlen($this->city)) { | |||||
$address .= $this->postcode.' '.$this->city ; | |||||
} | |||||
if($nl2br) { | |||||
$address = nl2br($address) ; | |||||
} | |||||
return $address ; | |||||
} | |||||
public function getHtmlLogo() | |||||
{ | |||||
$html = '' ; | |||||
if(strlen($this->logo)) { | |||||
$html = '<img src="'.Yii::$app->urlManagerProducer->getHostInfo().'/'.Yii::$app->urlManagerProducer->baseUrl.'/uploads/'.$this->logo.'" class="producer-logo" />' ; | |||||
} | |||||
return $html ; | |||||
} | |||||
} | } | ||||
return $strUnit; | return $strUnit; | ||||
} | } | ||||
public function getPrice() | |||||
{ | |||||
return $this->price ; | |||||
} | |||||
/** | /** | ||||
* Retourne le prix du produit avec taxe | * Retourne le prix du produit avec taxe | ||||
*/ | */ |
} | } | ||||
} | } | ||||
public function getFullAddress() | |||||
public function getFullAddress($nl2br = false) | |||||
{ | { | ||||
$address = ''; | $address = ''; | ||||
if(isset($this->lastname) && isset($this->name) && strlen($this->lastname) && strlen($this->name)) { | if(isset($this->lastname) && isset($this->name) && strlen($this->lastname) && strlen($this->name)) { | ||||
$address .= $this->name_legal_person. "\n"; | $address .= $this->name_legal_person. "\n"; | ||||
} | } | ||||
$address .= $this->address; | $address .= $this->address; | ||||
if($nl2br) { | |||||
$address = nl2br($address) ; | |||||
} | |||||
return $address; | return $address; | ||||
} | } | ||||
<?php | |||||
use yii\db\Migration; | |||||
use yii\db\Schema; | |||||
class m200118_134323_ajout_champs_producer_address extends Migration | |||||
{ | |||||
public function safeUp() | |||||
{ | |||||
$this->addColumn('producer', 'address', Schema::TYPE_TEXT) ; | |||||
} | |||||
public function safeDown() | |||||
{ | |||||
$this->dropColumn('producer', 'address') ; | |||||
} | |||||
} |