// js | // js | ||||
$this->addAsset('js','js/jquery-ui-1.12.1.custom/jquery-ui.min.js') ; | $this->addAsset('js','js/jquery-ui-1.12.1.custom/jquery-ui.min.js') ; | ||||
$this->addAsset('js','js/lechatdesnoisettes.js') ; | |||||
$this->addAsset('js','js/backend.js') ; | |||||
} | } | ||||
} | } |
<?php | |||||
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
namespace backend\controllers; | |||||
use backend\models\MailForm ; | |||||
use yii\web\NotFoundHttpException ; | |||||
use common\models\User ; | |||||
/** | |||||
* UserController implements the CRUD actions for User model. | |||||
*/ | |||||
class CommunicateAdminController extends BackendController | |||||
{ | |||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'verbs' => [ | |||||
'class' => VerbFilter::className(), | |||||
'actions' => [ | |||||
'delete' => ['post'], | |||||
], | |||||
], | |||||
'access' => [ | |||||
'class' => AccessControl::className(), | |||||
'rules' => [ | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return User::getCurrentStatus() == USER::STATUS_ADMIN; | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex($section = 'producers') | |||||
{ | |||||
if($section == 'producers') { | |||||
$producers = Producer::find()->with(['contact'])->all() ; | |||||
$usersArray = []; | |||||
$users = [] ; | |||||
foreach ($producers as $producer) { | |||||
if (isset($producer->contact) && is_array($producer->contact)) { | |||||
foreach($producer->contact as $contact) { | |||||
$usersArray[] = $contact->email ; | |||||
$users[] = [ | |||||
'email' => $contact->email, | |||||
'name' => $contact->name, | |||||
'lastname' => $contact->lastname, | |||||
] ; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
elseif($section == 'users') { | |||||
$users = User::find() | |||||
->where([ | |||||
'user.status' => User::STATUS_ACTIVE | |||||
]) | |||||
->all() ; | |||||
$usersArray = []; | |||||
foreach ($users as $user) { | |||||
if (isset($user['email']) && strlen($user['email'])) { | |||||
$usersArray[] = $user['email']; | |||||
} | |||||
} | |||||
} | |||||
else { | |||||
throw new NotFoundHttpException('Requête incorrecte.'); | |||||
} | |||||
$mailForm = new MailForm() ; | |||||
if ($mailForm->load(Yii::$app->request->post()) && $mailForm->validate()) { | |||||
$resultSendEmail = $mailForm->sendEmail($users, false) ; | |||||
if($resultSendEmail) { | |||||
Yii::$app->getSession()->setFlash('success', 'Votre email a bien été envoyé.'); | |||||
} | |||||
else { | |||||
Yii::$app->getSession()->setFlash('error', 'Un problème est survenu lors de l\'envoi de votre email.'); | |||||
} | |||||
$mailForm->subject = '' ; | |||||
$mailForm->message = '' ; | |||||
} | |||||
return $this->render('index', [ | |||||
'section' => $section, | |||||
'usersArray' => $usersArray, | |||||
'mailForm' => $mailForm, | |||||
]); | |||||
} | |||||
} |
} | } | ||||
/** | /** | ||||
* Envoie un email aux utilisateurs d'un point de vente ou à tous les | |||||
* utilisateurs d'un producteur. | |||||
* Envoie un email aux utilisateurs définis en paramètre. | |||||
* | * | ||||
* @param integer $idPointSale ID du point de vente | |||||
* @param array $usersArray | |||||
* @param boolean $fromProducer | |||||
*/ | */ | ||||
public function sendEmail($usersArray) | |||||
public function sendEmail($usersArray, $fromProducer = true) | |||||
{ | { | ||||
$producer = Producer::getCurrent() ; | |||||
$mj = new \Mailjet\Client( | $mj = new \Mailjet\Client( | ||||
$producer->getApiKeyMailjet('public'), | |||||
$producer->getApiKeyMailjet('private'), | |||||
Mailjet::getApiKey('public'), | |||||
Mailjet::getApiKey('private'), | |||||
true, | true, | ||||
['version' => 'v3.1'] | ['version' => 'v3.1'] | ||||
); | ); | ||||
} | } | ||||
} | } | ||||
if($fromProducer) { | |||||
$producer = Producer::getCurrent() ; | |||||
$fromEmail = $producer->slug.'@opendistrib.net' ; | |||||
$fromName = $producer->name ; | |||||
} | |||||
else { | |||||
$fromEmail = 'contact@opendistrib.net' ; | |||||
$fromName = 'Opendistrib' ; | |||||
} | |||||
foreach($usersArray as $user) { | foreach($usersArray as $user) { | ||||
$body['Messages'][] = [ | $body['Messages'][] = [ | ||||
'From' => [ | 'From' => [ | ||||
'Email' => $producer->slug.'@opendistrib.net', | |||||
'Name' => $producer->name | |||||
'Email' => $fromEmail, | |||||
'Name' => $fromName | |||||
], | ], | ||||
'To' => [ | 'To' => [ | ||||
[ | [ |
<?php | |||||
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
use yii\helpers\Html ; | |||||
use yii\widgets\ActiveForm; | |||||
$this->setTitle('Envoyer un email') ; | |||||
$this->addBreadcrumb(['label' => 'Communiquer', 'url' => ['user/index']]) ; | |||||
$this->addBreadcrumb($this->getTitle()) ; | |||||
?> | |||||
<div class="submenu"> | |||||
<a class="btn <?php if($section == 'producers'): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['communicate-admin/index', 'section' => 'producers']); ?>"> | |||||
<span class="glyphicon glyphicon-grain"></span> Producteurs <span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<a class="btn <?php if($section == 'users'): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['communicate-admin/index', 'section' => 'users']); ?>"> | |||||
<span class="glyphicon glyphicon-user"></span> Utilisateurs <span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
</div> | |||||
<div id=""> | |||||
<div class="col-md-6"> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Envoyer un email</h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<?php $form = ActiveForm::begin(); ?> | |||||
<?= $form->field($mailForm, 'subject')->textInput() ; ?> | |||||
<?= $form->field($mailForm, 'message')->textarea(['rows' => '15']) ; ?> | |||||
<div class="form-group"> | |||||
<?= Html::submitButton( 'Envoyer', ['class' => 'btn btn-primary']) ?> | |||||
</div> | |||||
<?php ActiveForm::end(); ?> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="col-md-6"> | |||||
<div class="panel panel-default"> | |||||
<div class="panel-heading"> | |||||
<h3 class="panel-title">Liste des emails <span class="label label-default"><?= count($usersArray); ?></span></h3> | |||||
</div> | |||||
<div class="panel-body"> | |||||
<?= implode(', ', $usersArray); ?> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
<div class="clr"></div> | |||||
</div> |
['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()], | ['label' => 'Administration', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()], | ||||
['label' => 'Producteurs','icon' => 'th-list','url' => ['/producer-admin/index'], 'visible' => User::isCurrentAdmin()], | ['label' => 'Producteurs','icon' => 'th-list','url' => ['/producer-admin/index'], 'visible' => User::isCurrentAdmin()], | ||||
['label' => 'Communiquer','icon' => 'bullhorn','url' => ['/communicate-admin/index'], 'visible' => User::isCurrentAdmin()], | |||||
['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()], | ['label' => 'Outils', 'options' => ['class' => 'header'], 'visible' => User::isCurrentAdmin()], | ||||
['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => User::isCurrentAdmin()], | ['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii'], 'visible' => User::isCurrentAdmin()], |
body.skin-black .content-wrapper .pagination > li > a:hover, body.skin-black .content-wrapper .pagination > li > span:hover { | body.skin-black .content-wrapper .pagination > li > a:hover, body.skin-black .content-wrapper .pagination > li > span:hover { | ||||
color: #cc6600; | color: #cc6600; | ||||
} | } | ||||
/* line 183, ../sass/_adminlte.scss */ | |||||
/* line 181, ../sass/_adminlte.scss */ | |||||
body.skin-black .content-wrapper .submenu { | |||||
margin-bottom: 25px; | |||||
} | |||||
/* line 187, ../sass/_adminlte.scss */ | |||||
body.skin-black .main-footer a { | body.skin-black .main-footer a { | ||||
color: #FF7F00; | color: #FF7F00; | ||||
} | } | ||||
/* line 189, ../sass/_adminlte.scss */ | |||||
/* line 193, ../sass/_adminlte.scss */ | |||||
body.login-page { | body.login-page { | ||||
background: none; | background: none; | ||||
background-color: white; | background-color: white; | ||||
} | } | ||||
/* line 193, ../sass/_adminlte.scss */ | |||||
/* line 197, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo { | body.login-page .login-box .login-logo { | ||||
text-align: center; | text-align: center; | ||||
font-family: "comfortaalight"; | font-family: "comfortaalight"; | ||||
} | } | ||||
/* line 196, ../sass/_adminlte.scss */ | |||||
/* line 200, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-logo img { | body.login-page .login-box .login-logo img { | ||||
width: 50px; | width: 50px; | ||||
} | } | ||||
/* line 201, ../sass/_adminlte.scss */ | |||||
/* line 205, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary { | body.login-page .login-box .login-box-body .btn-primary { | ||||
background-color: #FF7F00; | background-color: #FF7F00; | ||||
border-color: #FF7F00; | border-color: #FF7F00; | ||||
padding: 5px 10px; | padding: 5px 10px; | ||||
} | } | ||||
/* line 206, ../sass/_adminlte.scss */ | |||||
/* line 210, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body .btn-primary:active { | body.login-page .login-box .login-box-body .btn-primary:active { | ||||
background-color: #ff8c1a; | background-color: #ff8c1a; | ||||
border-color: #FF7F00; | border-color: #FF7F00; | ||||
} | } | ||||
/* line 212, ../sass/_adminlte.scss */ | |||||
/* line 216, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a { | body.login-page .login-box .login-box-body a { | ||||
color: #FF7F00; | color: #FF7F00; | ||||
} | } | ||||
/* line 214, ../sass/_adminlte.scss */ | |||||
/* line 218, ../sass/_adminlte.scss */ | |||||
body.login-page .login-box .login-box-body a:hover { | body.login-page .login-box .login-box-body a:hover { | ||||
color: #ff8c1a; | color: #ff8c1a; | ||||
} | } |
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
$(document).ready(function() { | |||||
opendistrib_datepicker() ; | |||||
$('button[data-toggle=popover]').popover() ; | |||||
opendistrib_commandeauto() ; | |||||
opendistrib_points_vente_acces() ; | |||||
opendistrib_tooltip() ; | |||||
opendistrib_ordre_produits() ; | |||||
opendistrib_products() ; | |||||
}) ; | |||||
var UrlManager = { | |||||
getBaseUrl: function() { | |||||
return $('meta[name=baseurl]').attr('content')+'/' ; | |||||
}, | |||||
getBaseUrlAbsolute: function() { | |||||
return $('meta[name=baseurl-absolute]').attr('content')+'/' ; | |||||
} | |||||
}; | |||||
function opendistrib_products() { | |||||
if($('.product-create').size() || $('.product-update').size()) { | |||||
opendistrib_products_event_unit(false) ; | |||||
$('#product-unit').change(function() { | |||||
opendistrib_products_event_unit(true) ; | |||||
}) ; | |||||
} | |||||
} | |||||
function opendistrib_products_event_unit(change) { | |||||
var unit = $('#product-unit').val() ; | |||||
if(unit == 'piece') { | |||||
$('.field-product-step').hide() ; | |||||
$('.field-product-weight').show() ; | |||||
} | |||||
else { | |||||
$('.field-product-step').show() ; | |||||
$('.field-product-weight').hide() ; | |||||
} | |||||
var label_price = $('.field-product-price .control-label') ; | |||||
var label_step = $('.field-product-step .control-label') ; | |||||
var label_quantity_max = $('.field-product-quantity_max .control-label') ; | |||||
if(unit == 'piece') { | |||||
label_price.html('Prix (la pièce)') ; | |||||
label_quantity_max.html('Quantité max par défaut (pièces)') ; | |||||
} | |||||
else if(unit == 'g' || unit == 'kg') { | |||||
label_price.html('Prix (au kg)') ; | |||||
label_quantity_max.html('Quantité max par défaut (kg)') ; | |||||
label_step.html('Pas ('+unit+')') ; | |||||
} | |||||
else if(unit == 'mL' || unit == 'L') { | |||||
label_price.html('Prix (au litre)') ; | |||||
label_quantity_max.html('Quantité max par défaut (litres)') ; | |||||
label_step.html('Pas ('+unit+')') ; | |||||
} | |||||
if(change) { | |||||
if(unit == 'piece') { | |||||
$('#product-step').val(1) ; | |||||
} | |||||
else { | |||||
$('#product-step').val('') ; | |||||
} | |||||
} | |||||
} | |||||
function opendistrib_tooltip() { | |||||
$('[data-toggle="tooltip"]').tooltip({container:'body'}); | |||||
} | |||||
function opendistrib_nl2br(str, is_xhtml) { | |||||
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>'; | |||||
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); | |||||
} | |||||
function opendistrib_points_vente_acces() { | |||||
// affichage du bloc acces restreint | |||||
$('#pointsale-restricted_access').change(function() { | |||||
opendistrib_points_vente_acces_event() ; | |||||
}) ; | |||||
opendistrib_points_vente_acces_event() ; | |||||
// affichage du champs commentaire | |||||
$('#pointsale-users input[type=checkbox]').change(function() { | |||||
opendistrib_points_vente_commentaire_event() ; | |||||
}) ; | |||||
opendistrib_points_vente_commentaire_event() ; | |||||
} | |||||
function opendistrib_points_vente_commentaire_event() { | |||||
$('#pointsale-users input[type=checkbox]').each(function() { | |||||
if($(this).prop('checked')) { | |||||
$(this).parent().find('.commentaire').fadeIn() ; | |||||
} | |||||
else { | |||||
$(this).parent().find('.commentaire').hide() ; | |||||
} | |||||
}) ; | |||||
} | |||||
function opendistrib_points_vente_acces_event() { | |||||
if($('#pointsale-restricted_access').prop('checked')) { | |||||
$('#pointsale-users').fadeIn() ; | |||||
} | |||||
else { | |||||
$('#pointsale-users').hide() ; | |||||
} | |||||
} | |||||
function opendistrib_commandeauto() { | |||||
$('#subscriptionform-date_begin, #subscriptionform-date_end').datepicker() ; | |||||
} | |||||
function opendistrib_ordre_produits() { | |||||
var fixHelper = function(e, ui) { | |||||
ui.children().each(function() { | |||||
$(this).width($(this).width()); | |||||
}); | |||||
return ui; | |||||
}; | |||||
$(".product-index table tbody").sortable({ | |||||
items: "> tr", | |||||
appendTo: "parent", | |||||
cursor: "move", | |||||
placeholder: "ui-state-highlight", | |||||
handle: '.btn-order', | |||||
//helper: "clone" | |||||
helper: fixHelper, | |||||
stop: function(event, ui) { | |||||
var tab_ordre = {} ; | |||||
var ordre = 1 ; | |||||
if($('ul.pagination').size()) { | |||||
var page = parseInt($('ul.pagination li.active a').html()) ; | |||||
var nb_items_by_page = parseInt($('#page-size').html()) ; | |||||
if(page != 1) { | |||||
ordre = (page - 1) * nb_items_by_page ; | |||||
} | |||||
} | |||||
$(".product-index table tbody tr").each(function() { | |||||
tab_ordre[$(this).attr('data-key')] = ordre ; | |||||
ordre++ ; | |||||
}) ; | |||||
$.post(UrlManager.getBaseUrl()+'product/order',{ | |||||
array: JSON.stringify(tab_ordre) | |||||
}) ; | |||||
} | |||||
}).disableSelection(); | |||||
} | |||||
function opendistrib_datepicker() { | |||||
$('input.datepicker').datepicker({dateFormat:'dd/mm/yy'}) ; | |||||
} | |||||
/* French initialisation for the jQuery UI date picker plugin. */ | |||||
/* Written by Keith Wood (kbwood{at}iinet.com.au), | |||||
Stéphane Nahmani (sholby@sholby.net), | |||||
Stéphane Raimbault <stephane.raimbault@gmail.com> */ | |||||
(function( factory ) { | |||||
if ( typeof define === "function" && define.amd ) { | |||||
// AMD. Register as an anonymous module. | |||||
define([ "../jquery.ui.datepicker" ], factory ); | |||||
} else { | |||||
// Browser globals | |||||
factory( jQuery.datepicker ); | |||||
} | |||||
}(function( datepicker ) { | |||||
datepicker.regional['fr'] = { | |||||
closeText: 'Fermer', | |||||
prevText: 'Précédent', | |||||
nextText: 'Suivant', | |||||
currentText: 'Aujourd\'hui', | |||||
monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', | |||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'], | |||||
monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin', | |||||
'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], | |||||
dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], | |||||
dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], | |||||
dayNamesMin: ['D','L','M','M','J','V','S'], | |||||
weekHeader: 'Sem.', | |||||
dateFormat: 'dd/mm/yy', | |||||
firstDay: 1, | |||||
isRTL: false, | |||||
showMonthAfterYear: false, | |||||
yearSuffix: ''}; | |||||
datepicker.setDefaults(datepicker.regional['fr']); | |||||
return datepicker.regional['fr']; | |||||
})); |
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
$(document).ready(function() { | |||||
//chat_calendar() ; | |||||
chat_datepicker() ; | |||||
chat_vrac() ; | |||||
chat_email_masse() ; | |||||
$('button[data-toggle=popover]').popover() ; | |||||
chat_ordre_produits() ; | |||||
chat_index_commandes_liste_produits() ; | |||||
chat_index_commandes_points_vente() ; | |||||
chat_index_commandes_points_vente_livraison() ; | |||||
chat_btn_plus_moins() ; | |||||
chat_commandeauto() ; | |||||
chat_points_vente_acces() ; | |||||
chat_tooltip() ; | |||||
chat_points_vente_jours_livraison() ; | |||||
chat_index_commandes_maj_points_vente() ; | |||||
// admin | |||||
chat_select_etablissement() ; | |||||
chat_products() ; | |||||
}) ; | |||||
var UrlManager = { | |||||
getBaseUrl: function() { | |||||
return $('meta[name=baseurl]').attr('content')+'/' ; | |||||
}, | |||||
getBaseUrlAbsolute: function() { | |||||
return $('meta[name=baseurl-absolute]').attr('content')+'/' ; | |||||
} | |||||
}; | |||||
function chat_products() { | |||||
if($('.product-create').size() || $('.product-update').size()) { | |||||
chat_products_event_unit(false) ; | |||||
$('#product-unit').change(function() { | |||||
chat_products_event_unit(true) ; | |||||
}) ; | |||||
} | |||||
} | |||||
function chat_products_event_unit(change) { | |||||
var unit = $('#product-unit').val() ; | |||||
if(unit == 'piece') { | |||||
$('.field-product-step').hide() ; | |||||
$('.field-product-weight').show() ; | |||||
} | |||||
else { | |||||
$('.field-product-step').show() ; | |||||
$('.field-product-weight').hide() ; | |||||
} | |||||
var label_price = $('.field-product-price .control-label') ; | |||||
var label_step = $('.field-product-step .control-label') ; | |||||
var label_quantity_max = $('.field-product-quantity_max .control-label') ; | |||||
if(unit == 'piece') { | |||||
label_price.html('Prix (la pièce)') ; | |||||
label_quantity_max.html('Quantité max par défaut (pièces)') ; | |||||
} | |||||
else if(unit == 'g' || unit == 'kg') { | |||||
label_price.html('Prix (au kg)') ; | |||||
label_quantity_max.html('Quantité max par défaut (kg)') ; | |||||
label_step.html('Pas ('+unit+')') ; | |||||
} | |||||
else if(unit == 'mL' || unit == 'L') { | |||||
label_price.html('Prix (au litre)') ; | |||||
label_quantity_max.html('Quantité max par défaut (litres)') ; | |||||
label_step.html('Pas ('+unit+')') ; | |||||
} | |||||
if(change) { | |||||
if(unit == 'piece') { | |||||
$('#product-step').val(1) ; | |||||
} | |||||
else { | |||||
$('#product-step').val('') ; | |||||
} | |||||
} | |||||
} | |||||
function chat_tooltip() { | |||||
$('[data-toggle="tooltip"]').tooltip({container:'body'}); | |||||
} | |||||
function chat_nl2br(str, is_xhtml) { | |||||
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>'; | |||||
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); | |||||
} | |||||
function chat_index_commandes_points_vente_livraison() { | |||||
$('#pointsaledistribution-points_sale_distribution input[type=checkbox]').change(function() { | |||||
var nb = $('#pointsaledistribution-points_sale_distribution input[type=checkbox]:checked').size() ; | |||||
if(nb == 0) { | |||||
$(this).prop('checked',true) ; | |||||
chat_alert('danger','Vous devez avoir au moins un point de vente activé') ; | |||||
} | |||||
else { | |||||
var val = $(this).val() ; | |||||
var arr_val = val.split('-') ; | |||||
var livraison = 0 ; | |||||
if($(this).prop('checked')) | |||||
livraison = 1 ; | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-point-sale-delivery',{ | |||||
idDistribution: arr_val[0], | |||||
idPointSale: arr_val[1], | |||||
boolDelivery: livraison | |||||
}, function(data) { | |||||
chat_alert('success','Point de vente modifié') ; | |||||
}) ; | |||||
chat_index_commandes_maj_points_vente() ; | |||||
} | |||||
}) ; | |||||
} | |||||
function chat_index_commandes_maj_points_vente() { | |||||
if($('#productions-point-vente').size()) { | |||||
var nb = $('#pointsaledistribution-points_sale_distribution input[type=checkbox]:checked').size() ; | |||||
if(nb == 0) | |||||
{ | |||||
$('#panel-commandes #tabs-points-vente, #panel-commandes #commandes-points-vente').hide() ; | |||||
$('#panel-commandes .alert-danger').show(); | |||||
} | |||||
else { | |||||
$('#panel-commandes #tabs-points-vente, #panel-commandes #commandes-points-vente').show() ; | |||||
$('#panel-commandes .alert-danger').hide(); | |||||
} | |||||
} | |||||
var id_production = $('#id-production').val() ; | |||||
if(id_production) { | |||||
$('#tabs-points-vente li').each(function() { | |||||
var id_point_vente = $(this).find('a').attr('id').replace('btn-point-vente-','') ; | |||||
var nb_commandes = parseInt($(this).find('.badge-success').html()) ; | |||||
var checked = $('#pointsaledistribution-points_sale_distribution input[value='+id_production+'-'+id_point_vente+']').prop('checked') ; | |||||
if(checked || nb_commandes > 0) | |||||
{ | |||||
$(this).show() ; | |||||
} | |||||
else { | |||||
$(this).hide() ; | |||||
} | |||||
}) ; | |||||
$('#tabs-points-vente li:visible:first a').click() ; | |||||
} | |||||
} | |||||
function chat_points_vente_jours_livraison() { | |||||
$('#pointvente-point_fabrication').change(function() { | |||||
chat_points_vente_jours_livraison_event() ; | |||||
}) ; | |||||
chat_points_vente_jours_livraison_event(); | |||||
} | |||||
function chat_points_vente_jours_livraison_event() { | |||||
if($('#pointvente-point_fabrication').prop('checked')) { | |||||
$('#jours-livraison').hide() ; | |||||
} | |||||
else { | |||||
$('#jours-livraison').fadeIn() ; | |||||
} | |||||
} | |||||
function chat_points_vente_acces() { | |||||
// affichage du bloc acces restreint | |||||
$('#pointsale-restricted_access').change(function() { | |||||
chat_points_vente_acces_event() ; | |||||
}) ; | |||||
chat_points_vente_acces_event() ; | |||||
// affichage du champs commentaire | |||||
$('#pointsale-users input[type=checkbox]').change(function() { | |||||
chat_points_vente_commentaire_event() ; | |||||
}) ; | |||||
chat_points_vente_commentaire_event() ; | |||||
} | |||||
function chat_points_vente_commentaire_event() { | |||||
$('#pointsale-users input[type=checkbox]').each(function() { | |||||
if($(this).prop('checked')) { | |||||
$(this).parent().find('.commentaire').fadeIn() ; | |||||
} | |||||
else { | |||||
$(this).parent().find('.commentaire').hide() ; | |||||
} | |||||
}) ; | |||||
} | |||||
function chat_points_vente_acces_event() { | |||||
if($('#pointsale-restricted_access').prop('checked')) { | |||||
$('#pointsale-users').fadeIn() ; | |||||
} | |||||
else { | |||||
$('#pointsale-users').hide() ; | |||||
} | |||||
} | |||||
function chat_select_etablissement() { | |||||
$('select[name="select_producer"]').change(function() { | |||||
window.location.href = UrlManager.getBaseUrlAbsolute()+'/site/change-producer?id='+$(this).val() ; | |||||
}) ; | |||||
} | |||||
function chat_commandeauto() { | |||||
// dates | |||||
$('#subscriptionform-date_begin, #subscriptionform-date_end').datepicker() ; | |||||
} | |||||
function chat_index_commandes_points_vente() { | |||||
$('#commandes-points-vente .liste-commandes a').unbind('click').click(function() { | |||||
var id_pv = $(this).data('pv-id') ; | |||||
// affiche la commande | |||||
var id_commande = $(this).data('id-commande') ; | |||||
chat_index_commandes_affiche_commande(id_pv, id_commande) ; | |||||
}) ; | |||||
$('#commandes-points-vente .bloc-point-vente').each(function() { | |||||
var id_pv = $(this).data('id-pv') ; | |||||
// edit | |||||
$('#point-vente-'+id_pv+' .btn-edit').unbind('click').click(function() { | |||||
// boutons | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').hide() ; | |||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').show() ; | |||||
$('#point-vente-'+id_pv+' .tr-total').hide() ; | |||||
// inputs | |||||
chat_index_commandes_inputs_commande(id_pv, true) ; | |||||
}) ; | |||||
// remove | |||||
$('#point-vente-'+id_pv+' .btn-remove').unbind('click').click(function() { | |||||
var id_commande = $(this).data('id-commande') ; | |||||
$(this).attr('disabled', 'disabled') ; | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-delete',{ | |||||
date: $('#date-production').val(), | |||||
idOrder: id_commande | |||||
}, function(data) { | |||||
$('#point-vente-'+id_pv+' .btn-remove').removeAttr('disabled') ; | |||||
if($('#point-vente-'+id_pv+' .liste-commandes li').size()) { | |||||
if($('#point-vente-'+id_pv+' .liste-commandes li:last-child a').is('.active')) { | |||||
var commande_next = $('#point-vente-'+id_pv+' .liste-commandes a.active').parent().prev().find('a') ; | |||||
} | |||||
else { | |||||
var commande_next = $('#point-vente-'+id_pv+' .liste-commandes a.active').parent().next().find('a') ; | |||||
} | |||||
$('#point-vente-'+id_pv+' .liste-commandes a.active').parent().remove() ; | |||||
if($('#point-vente-'+id_pv+' .liste-commandes li').size()) { | |||||
chat_index_commandes_affiche_commande(id_pv, commande_next.data('id-commande')) ; | |||||
} | |||||
else { | |||||
$('#point-vente-'+id_pv+' .liste-commandes').hide() ; | |||||
$('#point-vente-'+id_pv+' .creer-commande').trigger('click') ; | |||||
} | |||||
} | |||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ; | |||||
chat_index_commandes_maj_total_commandes() ; | |||||
chat_alert('success','Commande supprimée') ; | |||||
}, 'json') ; | |||||
}); | |||||
// cancel | |||||
$('#point-vente-'+id_pv+' .btn-cancel').unbind('click').click(function() { | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | |||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | |||||
$('#point-vente-'+id_pv+' .btn-save').removeClass('is-create') ; | |||||
chat_index_commandes_affiche_commande(id_pv, $(this).data('id-commande')) ; | |||||
}) ; | |||||
// save | |||||
$('#point-vente-'+id_pv+' .btn-save').unbind('click').click(function() { | |||||
var tab_produits = {} ; | |||||
var cpt_produits = 0 ; | |||||
$('#point-vente-'+id_pv+' .table-produits tr').each(function() { | |||||
tab_produits[$(this).data('id-produit')] = $(this).find('.quantite').val() ; | |||||
if($(this).find('.quantite').val()) | |||||
cpt_produits ++ ; | |||||
}) ; | |||||
if(cpt_produits) { | |||||
// création | |||||
if($(this).hasClass('is-create')) { | |||||
if($('#point-vente-'+id_pv+' .user-id').val() || $('#point-vente-'+id_pv+' .username').val().length) { | |||||
$(this).attr('disabled', 'disabled') ; | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-create',{ | |||||
date: $('#date-production').val(), | |||||
idPointSale: id_pv, | |||||
idUser: $('#point-vente-'+id_pv+' .user-id').val(), | |||||
username: $('#point-vente-'+id_pv+' .username').val(), | |||||
products: JSON.stringify(tab_produits), | |||||
comment: $('#point-vente-'+id_pv+' .textarea-commentaire').val() | |||||
}, function(data) { | |||||
$('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ; | |||||
$('#point-vente-'+id_pv+' .btn-save').removeClass('is-create') ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes').append(data.order) ; | |||||
chat_index_commandes_points_vente() ; | |||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ; | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | |||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | |||||
$('#point-vente-'+id_pv+' .btn-create').removeClass('is-create') ; | |||||
$('#point-vente-'+id_pv+' .user-id').val(0) ; | |||||
$('#point-vente-'+id_pv+' .user-id').val('') ; | |||||
chat_index_commandes_affiche_commande(id_pv, data.id_commande) ; | |||||
chat_alert('success', 'Commande créée') ; | |||||
}, 'json') ; | |||||
} | |||||
else { | |||||
chat_alert('danger', 'Veuillez choisir ou saisir un nom d\'utilisateur') ; | |||||
} | |||||
} | |||||
// modification | |||||
else { | |||||
var id_commande = $(this).data('id-commande') ; | |||||
$(this).attr('disabled', 'disabled') ; | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-update',{ | |||||
idOrder: id_commande, | |||||
products: JSON.stringify(tab_produits), | |||||
date: $('#date-production').val(), | |||||
comment: $('#point-vente-'+id_pv+' .textarea-commentaire').val() | |||||
}, function(data) { | |||||
$('#point-vente-'+id_pv+' .btn-save').removeAttr('disabled') ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order); | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(data.json_order.str_amount) ; | |||||
chat_index_commandes_affiche_commande(id_pv, id_commande) ; | |||||
chat_index_commandes_maj_recap_pv(id_pv, data.total_point_sale) ; | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | |||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | |||||
chat_alert('success','Commande modifiée') ; | |||||
}, 'json') ; | |||||
} | |||||
} | |||||
else { | |||||
chat_alert('danger', 'Veuillez saisir au moins un produit') ; | |||||
} | |||||
chat_index_commandes_maj_total_commandes() ; | |||||
}) ; | |||||
// create | |||||
$('.creer-commande').unbind('click').click(function() { | |||||
var id_pv = $(this).data('pv-id') ; | |||||
$('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes a.active').removeClass('active') ; | |||||
$('#point-vente-'+id_pv+' .tr-total').hide() ; | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').hide() ; | |||||
$('#point-vente-'+id_pv+' .the-title').hide() ; | |||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').show() ; | |||||
$('#point-vente-'+id_pv+' .choix-user').show() ; | |||||
$('#point-vente-'+id_pv+' .choix-user .user-id').val(0) ; | |||||
$('#point-vente-'+id_pv+' .choix-user .username').val('') ; | |||||
$('#point-vente-'+id_pv+' .commentaire').hide() ; | |||||
$('#point-vente-'+id_pv+' .btn-save').addClass('is-create'); | |||||
$('#point-vente-'+id_pv+' .btn-save').data('id-commande',0) ; | |||||
chat_index_commandes_inputs_commande(id_pv, false) ; | |||||
$('#point-vente-'+id_pv+' .title-user').show() ; | |||||
}) ; | |||||
}) ; | |||||
$('#commandes-points-vente .liste-commandes').each(function() { | |||||
//$(this).find('a:first').trigger('click') ; | |||||
}) ; | |||||
} | |||||
function chat_index_commandes_maj_total_commandes() { | |||||
$.get(UrlManager.getBaseUrl()+'order/ajax-total-orders',{ | |||||
date: $('#date-production').val() | |||||
}, function(data) { | |||||
$('#bloc-totaux').html(data.html_totals) ; | |||||
}, 'json') ; | |||||
} | |||||
function chat_index_commandes_maj_recap_pv(id_pv, total) { | |||||
$('#point-vente-'+id_pv+' .recap-pv .recettes').html(total) ; | |||||
var nb_commandes = $('#point-vente-'+id_pv+' .liste-commandes li').size() ; | |||||
if(nb_commandes == 0) { | |||||
$('#point-vente-'+id_pv+' .recap-pv .commandes').html('Aucune commande') ; | |||||
$('#point-vente-'+id_pv+' .recap-pv .recettes').hide() ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes').addClass('no-commande') ; | |||||
} | |||||
else if(nb_commandes == 1) { | |||||
$('#point-vente-'+id_pv+' .recap-pv .commandes').html('1 commande') ; | |||||
$('#point-vente-'+id_pv+' .recap-pv .recettes').show() ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes').removeClass('no-commande') ; | |||||
} | |||||
else { | |||||
$('#point-vente-'+id_pv+' .recap-pv .commandes').html(nb_commandes+' commandes') ; | |||||
$('#point-vente-'+id_pv+' .recap-pv .recettes').show() ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes').removeClass('no-commande') ; | |||||
} | |||||
$('#btn-point-vente-'+id_pv+' .badge').html(nb_commandes) ; | |||||
} | |||||
function chat_index_commandes_inputs_commande(id_pv, use_quantite) { | |||||
// commentaire | |||||
$('#point-vente-'+id_pv+' .commentaire').hide() ; | |||||
$('#point-vente-'+id_pv+' .textarea-commentaire').show() ; | |||||
var id_commande = $('#point-vente-'+id_pv+' .btn-save').data('id-commande') ; | |||||
if(id_commande) { | |||||
var link = $('a[data-id-commande='+id_commande+']') ; | |||||
if(!$.isPlainObject(link.attr('data-commande'))) { | |||||
var commande = JSON.parse(link.attr('data-commande')) ; | |||||
if(commande.commentaire && commande.commentaire.length) | |||||
$('#point-vente-'+id_pv+' .textarea-commentaire').val(commande.commentaire) ; | |||||
} | |||||
} | |||||
else { | |||||
$('#point-vente-'+id_pv+' .textarea-commentaire').val('') ; | |||||
} | |||||
// produits | |||||
$('#point-vente-'+id_pv+' .table-produits tr').each(function() { | |||||
var quantite = '' ; | |||||
if(use_quantite) | |||||
quantite = $(this).find('.td-commande').html() ; | |||||
var id_produit = $(this).data('id-produit') ; | |||||
$(this).find('.td-commande').html('<div class="input-group">'+ | |||||
'<span class="input-group-btn">'+ | |||||
'<button class="btn btn-default btn-moins" type="button"><span class="glyphicon glyphicon-minus"></span></button>'+ | |||||
'</span>'+ | |||||
'<input type="text" class="form-control quantite" value="'+quantite+'" name="produit_'+id_produit+'">'+ | |||||
'<span class="input-group-btn">'+ | |||||
'<button class="btn btn-default btn-plus" type="button"><span class="glyphicon glyphicon-plus"></span></button>'+ | |||||
'</span>'+ | |||||
'</div>') ; | |||||
}) ; | |||||
// plus / moins | |||||
chat_btn_plus_moins() ; | |||||
} | |||||
function chat_btn_plus_moins() { | |||||
$('.btn-plus').each(function() { | |||||
$(this).click(function() { | |||||
var input = $(this).parent().parent().find('input') ; | |||||
var value = input.val() ; | |||||
if(value) | |||||
value ++ ; | |||||
else | |||||
value = 1 ; | |||||
input.val(value) ; | |||||
}) ; | |||||
}) ; | |||||
$('.btn-moins').each(function() { | |||||
$(this).click(function() { | |||||
var input = $(this).parent().parent().find('input') ; | |||||
var value = input.val() ; | |||||
if(value && value > 1) | |||||
value -- ; | |||||
else | |||||
value = '' ; | |||||
input.val(value) ; | |||||
}) ; | |||||
}) ; | |||||
} | |||||
function chat_index_commandes_affiche_commande(id_pv, id_commande) { | |||||
var link = $("a[data-id-commande="+id_commande+"]") ; | |||||
if(id_commande) { | |||||
$('#point-vente-'+id_pv+' .bloc-commande').hide() ; | |||||
$('#point-vente-'+id_pv+' .liste-commandes a').removeClass('active') ; | |||||
link.addClass('active') ; | |||||
var commande = link.attr('data-commande') ; | |||||
if(!$.isPlainObject(link.attr('data-commande'))) { | |||||
commande = JSON.parse(link.attr('data-commande')) ; | |||||
} | |||||
// maj ligne commande | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').removeClass('paye') ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant .glyphicon').remove() ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html() ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').html(commande.str_amount) ; | |||||
if(commande.paid_amount >= commande.amount) { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').addClass('paye') ; | |||||
if(commande.paid_amount > commande.amount) { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .montant').append(' <span class="glyphicon glyphicon-warning-sign"></span>') ; | |||||
} | |||||
} | |||||
// commentaire | |||||
if(commande.comment && commande.comment.length) { | |||||
if(!$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').size()) { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').append(' <span class="glyphicon glyphicon-comment"></span>') ; | |||||
} | |||||
$('#point-vente-'+id_pv+' .commentaire').html(chat_nl2br(commande.comment)).show() ; | |||||
} | |||||
else { | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+'] .glyphicon-comment').remove() ; | |||||
$('#point-vente-'+id_pv+' .commentaire').hide() ; | |||||
} | |||||
// set id_commande | |||||
$('#point-vente-'+id_pv+' .btn-cancel').data('id-commande',id_commande) ; | |||||
$('#point-vente-'+id_pv+' .btn-save').data('id-commande',id_commande) ; | |||||
$('#point-vente-'+id_pv+' .btn-remove').data('id-commande',id_commande) ; | |||||
$('#point-vente-'+id_pv+' .btn-create').removeClass('is-create') ; | |||||
$('#point-vente-'+id_pv+' .buttons-edit-remove').show() ; | |||||
$('#point-vente-'+id_pv+' .buttons-save-cancel').hide() ; | |||||
$('#point-vente-'+id_pv+' .choix-user').hide() ; | |||||
$('#point-vente-'+id_pv+' .the-title').show() ; | |||||
$('#point-vente-'+id_pv+' .textarea-commentaire').hide() ; | |||||
$('#point-vente-'+id_pv+' .td-commande').html('') ; | |||||
$('#point-vente-'+id_pv+' .td-total').html('') ; | |||||
$('#point-vente-'+id_pv+' tr').removeClass('active') ; | |||||
$.each(commande.products, function(i, item) { | |||||
$('#point-vente-'+id_pv+' .produit-'+i+' .td-commande').html(item) ; | |||||
$('#point-vente-'+id_pv+' .produit-'+i).addClass('active') ; | |||||
}) ; | |||||
$('#point-vente-'+id_pv+' .td-total').html('<span>'+commande.str_amount+'</span>') ; | |||||
$('#point-vente-'+id_pv+' .tr-total').show() ; | |||||
$('#point-vente-'+id_pv+' .title-user span.the-title').html(link.find('.user').html()+" <small>"+link.data('date')+"</small>") ; | |||||
$('#point-vente-'+id_pv+' .bloc-commande').fadeIn() ; | |||||
$('#point-vente-'+id_pv+' .title-user').show() ; | |||||
$('#point-vente-'+id_pv+' .tr-total').show() ; | |||||
// paiement | |||||
$.get(UrlManager.getBaseUrl()+'order/payment-status',{ | |||||
idOrder: id_commande | |||||
}, function(data) { | |||||
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_payment_status) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order) ; | |||||
chat_index_commandes_boutons_paiement(id_pv, id_commande) ; | |||||
},'json') ; | |||||
} | |||||
else { | |||||
$('#point-vente-'+id_pv+' .bloc-commande').hide() ; | |||||
} | |||||
} | |||||
function chat_index_commandes_boutons_paiement(id_pv, id_commande) { | |||||
// boutons paiement/remboursement | |||||
$('#point-vente-'+id_pv+' .payer, #point-vente-'+id_pv+' .rembourser').click(function() { | |||||
$(this).attr('disabled','disabled') ; | |||||
$.get(UrlManager.getBaseUrl()+'order/payment',{ | |||||
idOrder: id_commande, | |||||
type: $(this).data('type'), | |||||
amount: $(this).data('montant') | |||||
}, function(data) { | |||||
$('#point-vente-'+id_pv+' .bloc-commande .td-paiement').html(data.html_payment_status) ; | |||||
$('#point-vente-'+id_pv+' a[data-id-commande='+id_commande+']').attr('data-commande',data.json_order) ; | |||||
chat_index_commandes_affiche_commande(id_pv, id_commande) ; | |||||
chat_index_commandes_boutons_paiement(id_pv, id_commande) ; | |||||
}, 'json') ; | |||||
}) ; | |||||
} | |||||
function chat_index_commandes_liste_produits() { | |||||
$('#produits-production .td-max input').click(function() { | |||||
$(this).select() ; | |||||
}) ; | |||||
$('#produits-production .td-actif input').change(function() { | |||||
if($(this).prop('checked')) { | |||||
$(this).parent().parent().addClass('active') ; | |||||
} | |||||
else { | |||||
$(this).parent().parent().removeClass('active') ; | |||||
} | |||||
}) ; | |||||
} | |||||
function chat_alert(type, message) { | |||||
var id = 'alert-'+$('#alerts-fixed .alert').size() + 1 ; | |||||
$('#alerts-fixed').append('<div id="'+id+'" class="alert alert-'+type+'">'+message+'</div>') ; | |||||
setTimeout('$("#'+id+'").fadeOut();',3000) ; | |||||
} | |||||
function chat_ordre_produits() { | |||||
var fixHelper = function(e, ui) { | |||||
ui.children().each(function() { | |||||
$(this).width($(this).width()); | |||||
}); | |||||
return ui; | |||||
}; | |||||
$(".product-index table tbody").sortable({ | |||||
items: "> tr", | |||||
appendTo: "parent", | |||||
cursor: "move", | |||||
placeholder: "ui-state-highlight", | |||||
handle: '.btn-order', | |||||
//helper: "clone" | |||||
helper: fixHelper, | |||||
stop: function(event, ui) { | |||||
var tab_ordre = {} ; | |||||
var ordre = 1 ; | |||||
if($('ul.pagination').size()) { | |||||
var page = parseInt($('ul.pagination li.active a').html()) ; | |||||
var nb_items_by_page = parseInt($('#page-size').html()) ; | |||||
if(page != 1) { | |||||
ordre = (page - 1) * nb_items_by_page ; | |||||
} | |||||
} | |||||
$(".product-index table tbody tr").each(function() { | |||||
tab_ordre[$(this).attr('data-key')] = ordre ; | |||||
ordre++ ; | |||||
}) ; | |||||
$.post(UrlManager.getBaseUrl()+'product/order',{ | |||||
array: JSON.stringify(tab_ordre) | |||||
}) ; | |||||
} | |||||
}).disableSelection(); | |||||
} | |||||
function chat_email_masse() { | |||||
$('#ids-users .label').click(function() { | |||||
if($(this).hasClass('label-default')) { | |||||
$(this).removeClass('label\-default') ; | |||||
$(this).addClass('label-danger') ; | |||||
} | |||||
else if($(this).hasClass('label-danger')) | |||||
$(this).removeClass('label-danger').addClass('label-default') ; | |||||
}) ; | |||||
$('#email-masse-form button[type=submit]').click(function() { | |||||
$(this).attr('disabled','disabled').html('Envoyer ...') ; | |||||
chat_email_masse_send() ; | |||||
return false ; | |||||
}) ; | |||||
} | |||||
function chat_email_masse_send() { | |||||
var user = $('#ids-users .label-default:first') ; | |||||
if(user.size()) { | |||||
$('input[name=id_user]').val(user.data('id')) ; | |||||
$.post(UrlManager.getBaseUrl()+'user/mail',$('#email-masse-form').serialize(), function(retour) { | |||||
user.removeClass('label-default').addClass('label-success') ; | |||||
setTimeout("chat_email_masse_send()",30000) ; | |||||
}) ; | |||||
} | |||||
else { | |||||
alert('Fini !') ; | |||||
} | |||||
} | |||||
function chat_vrac() { | |||||
$('.edit-vrac').click(function() { | |||||
if($('.vrac').css('display') == 'none') | |||||
$('.vrac').show() ; | |||||
else | |||||
$('.vrac').hide() ; | |||||
}) ; | |||||
} | |||||
function chat_datepicker() { | |||||
$('input.datepicker').datepicker({dateFormat:'dd/mm/yy'}) ; | |||||
} | |||||
function chat_calendar() { | |||||
if($('#page-order').size()) { | |||||
var events = new Array ; | |||||
$('ul#jours-production li').each(function() { | |||||
var date = $(this).html() ; | |||||
events.push({ | |||||
title: 'Production', | |||||
start: date, | |||||
allDay: true | |||||
}) ; | |||||
}) ; | |||||
jQuery('#calendar').fullCalendar({ | |||||
header: { | |||||
left:"prev,next", | |||||
center: "title", | |||||
//right:"month,agendaWeek,agendaDay" | |||||
right:"" | |||||
}, | |||||
lang:"fr-fr", | |||||
loading:function loading(bool) { | |||||
if (bool) $('#loading').show(); | |||||
else $('#loading').hide(); | |||||
}, | |||||
dayClick: function(date, jsEvent, view) { | |||||
var url = $(location).attr('href') ; | |||||
var tab_url = url.split('?') ; | |||||
$(location).attr('href',tab_url[0]+'?r=order/index&date='+date.format()); | |||||
}, | |||||
eventRender: function (event, element) { | |||||
var dataToFind = moment(event.start).format('YYYY-MM-DD'); | |||||
$("td[data-date='"+dataToFind+"']").addClass('dayWithEvent'); | |||||
}, | |||||
//eventBackgroundColor: '#000000', | |||||
events: events, | |||||
id:"calendar" | |||||
}); | |||||
if($('#current-date').val()) | |||||
$('td[data-date='+$('#current-date').val()+']').addClass('current-date') ; | |||||
} | |||||
} | |||||
/* French initialisation for the jQuery UI date picker plugin. */ | |||||
/* Written by Keith Wood (kbwood{at}iinet.com.au), | |||||
Stéphane Nahmani (sholby@sholby.net), | |||||
Stéphane Raimbault <stephane.raimbault@gmail.com> */ | |||||
(function( factory ) { | |||||
if ( typeof define === "function" && define.amd ) { | |||||
// AMD. Register as an anonymous module. | |||||
define([ "../jquery.ui.datepicker" ], factory ); | |||||
} else { | |||||
// Browser globals | |||||
factory( jQuery.datepicker ); | |||||
} | |||||
}(function( datepicker ) { | |||||
datepicker.regional['fr'] = { | |||||
closeText: 'Fermer', | |||||
prevText: 'Précédent', | |||||
nextText: 'Suivant', | |||||
currentText: 'Aujourd\'hui', | |||||
monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', | |||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'], | |||||
monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin', | |||||
'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], | |||||
dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], | |||||
dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], | |||||
dayNamesMin: ['D','L','M','M','J','V','S'], | |||||
weekHeader: 'Sem.', | |||||
dateFormat: 'dd/mm/yy', | |||||
firstDay: 1, | |||||
isRTL: false, | |||||
showMonthAfterYear: false, | |||||
yearSuffix: ''}; | |||||
datepicker.setDefaults(datepicker.regional['fr']); | |||||
return datepicker.regional['fr']; | |||||
})); |
color: darken($color1, 10) ; | color: darken($color1, 10) ; | ||||
} | } | ||||
} | } | ||||
.submenu { | |||||
margin-bottom: 25px ; | |||||
} | |||||
} | } | ||||
.main-footer { | .main-footer { |
<?php | |||||
/** | /** | ||||
Copyright distrib (2018) | Copyright distrib (2018) | ||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | pris connaissance de la licence CeCILL, et que vous en avez accepté les | ||||
termes. | termes. | ||||
*/ | */ | ||||
$(document).ready(function() | |||||
{ | |||||
boulange_signup() ; | |||||
boulange_add_boulangerie() ; | |||||
}); | |||||
function boulange_scroll(id) { | |||||
if($("#"+id).size()) | |||||
$('html,body').animate({ | |||||
scrollTop: $("#"+id).offset().top}, | |||||
1000); | |||||
} | |||||
function boulange_add_boulangerie() | |||||
{ | |||||
$('#bloc-add-etablissement .panel-heading').click(function() { | |||||
var panel_body = $(this).parent().find('.panel-body') ; | |||||
if(panel_body.css('display') == 'none') | |||||
panel_body.fadeIn() ; | |||||
else | |||||
panel_body.hide() ; | |||||
}) ; | |||||
$('#addetablissementform-id_etablissement,#signupform-id_etablissement').change(function() { | |||||
if($(this).find('option:selected').hasClass('lock')) { | |||||
$('#bloc-code-acces').fadeIn() ; | |||||
} | |||||
else { | |||||
$('#bloc-code-acces').hide() ; | |||||
} | |||||
}) ; | |||||
if($('#addetablissementform-id_etablissement option:selected,#signupform-id_etablissement option:selected').hasClass('lock')) { | |||||
$('#bloc-code-acces').show() ; | |||||
} | |||||
else { | |||||
$('#bloc-code-acces').hide() ; | |||||
} | |||||
if($('#bloc-add-etablissement').size()) { | |||||
if($('#bloc-add-etablissement .has-error').size()) { | |||||
$('#bloc-add-etablissement .panel-body').show() ; | |||||
} | |||||
} | |||||
} | |||||
function boulange_signup() | |||||
{ | |||||
if($('#form-signup').size()) | |||||
{ | |||||
boulange_signup_champs_boulanger() ; | |||||
$('#option-user, #option-producer').change(function() { | |||||
boulange_signup_champs_boulanger() ; | |||||
}) ; | |||||
} | |||||
} | |||||
namespace common\helpers; | |||||
function boulange_signup_champs_boulanger() | |||||
class Mailjet | |||||
{ | { | ||||
if($('#option-producer').prop('checked')) | |||||
public static function getApiKey($type = 'private') | |||||
{ | { | ||||
$('#fields-producer').fadeIn() ; | |||||
$('#fields-user').hide() ; | |||||
} | |||||
else { | |||||
$('#fields-producer').hide() ; | |||||
$('#fields-user').fadeIn() ; | |||||
$filename = '../../common/config/mailjet/api.key' ; | |||||
if(file_exists($filename)) { | |||||
$handle = fopen($filename, "r") ; | |||||
$filesize = filesize($filename) ; | |||||
if($handle && $filesize) { | |||||
$apiKeys = fread($handle, $filesize); | |||||
fclose($handle); | |||||
$apiKeysArray = explode(':', $apiKeys) ; | |||||
if(count($apiKeysArray) == 2) { | |||||
if($type == 'private') { | |||||
$key = $apiKeysArray[1] ; | |||||
} | |||||
else { | |||||
$key = $apiKeysArray[0] ; | |||||
} | |||||
return trim($key) ; | |||||
} | |||||
} | |||||
} | |||||
return '' ; | |||||
} | } | ||||
} | |||||
} |
return '' ; | return '' ; | ||||
} | } | ||||
public function getApiKeyMailjet($type = 'private') | |||||
{ | |||||
$filename = '../../common/config/mailjet/api.key' ; | |||||
if(file_exists($filename)) { | |||||
$handle = fopen($filename, "r") ; | |||||
$filesize = filesize($filename) ; | |||||
if($handle && $filesize) { | |||||
$apiKeys = fread($handle, $filesize); | |||||
fclose($handle); | |||||
$apiKeysArray = explode(':', $apiKeys) ; | |||||
if(count($apiKeysArray) == 2) { | |||||
if($type == 'private') { | |||||
$key = $apiKeysArray[1] ; | |||||
} | |||||
else { | |||||
$key = $apiKeysArray[0] ; | |||||
} | |||||
return trim($key) ; | |||||
} | |||||
} | |||||
} | |||||
return '' ; | |||||
} | |||||
} | } | ||||
*/ | */ | ||||
public static function findBy($params = []) | public static function findBy($params = []) | ||||
{ | { | ||||
if (!isset($params['id_producer'])) { | if (!isset($params['id_producer'])) { | ||||
$params['id_producer'] = Producer::getId() ; | $params['id_producer'] = Producer::getId() ; | ||||
} | } |
// js | // js | ||||
$this->addAsset('js','js/frontend.js'); | $this->addAsset('js','js/frontend.js'); | ||||
$this->addAsset('js','js/boulange.js'); | |||||
} | } | ||||
} | } |
/** | /** | ||||
Copyright distrib (2018) | Copyright distrib (2018) | ||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | pris connaissance de la licence CeCILL, et que vous en avez accepté les | ||||
termes. | termes. | ||||
*/ | */ | ||||
$(document).ready(function() | |||||
{ | |||||
opendistrib_signup() ; | |||||
}); | |||||
function opendistrib_signup() | |||||
{ | |||||
if($('#form-signup').size()) | |||||
{ | |||||
opendistrib_signup_fields_producer() ; | |||||
$('#option-user, #option-producer').change(function() { | |||||
opendistrib_signup_fields_producer() ; | |||||
}) ; | |||||
} | |||||
} | |||||
function opendistrib_signup_fields_producer() | |||||
{ | |||||
if($('#option-producer').prop('checked')) | |||||
{ | |||||
$('#fields-producer').fadeIn() ; | |||||
$('#fields-user').hide() ; | |||||
} | |||||
else { | |||||
$('#fields-producer').hide() ; | |||||
$('#fields-user').fadeIn() ; | |||||
} | |||||
} | |||||
$(document).ready(function() { | |||||
}) ; |
$this->addAsset('css','css/screen.css'); | $this->addAsset('css','css/screen.css'); | ||||
// js | // js | ||||
$this->addAsset('js','js/lechatdesnoisettes.js'); | |||||
$this->addAsset('js','js/boulange.js'); | |||||
$this->addAsset('js','js/producer.js'); | |||||
} | } | ||||
} | } |
/** | |||||
Copyright distrib (2018) | |||||
contact@opendistrib.net | |||||
Ce logiciel est un programme informatique servant à aider les producteurs | |||||
à distribuer leur production en circuits courts. | |||||
Ce logiciel est régi par la licence CeCILL soumise au droit français et | |||||
respectant les principes de diffusion des logiciels libres. Vous pouvez | |||||
utiliser, modifier et/ou redistribuer ce programme sous les conditions | |||||
de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA | |||||
sur le site "http://www.cecill.info". | |||||
En contrepartie de l'accessibilité au code source et des droits de copie, | |||||
de modification et de redistribution accordés par cette licence, il n'est | |||||
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, | |||||
seule une responsabilité restreinte pèse sur l'auteur du programme, le | |||||
titulaire des droits patrimoniaux et les concédants successifs. | |||||
A cet égard l'attention de l'utilisateur est attirée sur les risques | |||||
associés au chargement, à l'utilisation, à la modification et/ou au | |||||
développement et à la reproduction du logiciel par l'utilisateur étant | |||||
donné sa spécificité de logiciel libre, qui peut le rendre complexe à | |||||
manipuler et qui le réserve donc à des développeurs et des professionnels | |||||
avertis possédant des connaissances informatiques approfondies. Les | |||||
utilisateurs sont donc invités à charger et tester l'adéquation du | |||||
logiciel à leurs besoins dans des conditions permettant d'assurer la | |||||
sécurité de leurs systèmes et ou de leurs données et, plus généralement, | |||||
à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. | |||||
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez | |||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | |||||
termes. | |||||
*/ | |||||
/* French initialisation for the jQuery UI date picker plugin. */ | |||||
/* Written by Keith Wood (kbwood{at}iinet.com.au), | |||||
Stéphane Nahmani (sholby@sholby.net), | |||||
Stéphane Raimbault <stephane.raimbault@gmail.com> */ | |||||
(function( factory ) { | |||||
if ( typeof define === "function" && define.amd ) { | |||||
// AMD. Register as an anonymous module. | |||||
define([ "../jquery.ui.datepicker" ], factory ); | |||||
} else { | |||||
// Browser globals | |||||
factory( jQuery.datepicker ); | |||||
} | |||||
}(function( datepicker ) { | |||||
datepicker.regional['fr'] = { | |||||
closeText: 'Fermer', | |||||
prevText: 'Précédent', | |||||
nextText: 'Suivant', | |||||
currentText: 'Aujourd\'hui', | |||||
monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', | |||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'], | |||||
monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin', | |||||
'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], | |||||
dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], | |||||
dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], | |||||
dayNamesMin: ['D','L','M','M','J','V','S'], | |||||
weekHeader: 'Sem.', | |||||
dateFormat: 'dd/mm/yy', | |||||
firstDay: 1, | |||||
isRTL: false, | |||||
showMonthAfterYear: false, | |||||
yearSuffix: ''}; | |||||
datepicker.setDefaults(datepicker.regional['fr']); | |||||
return datepicker.regional['fr']; | |||||
})); | |||||
$(document).ready(function() { | |||||
$('[data-toggle="tooltip"]').tooltip() ; | |||||
chat_systeme_commande() ; | |||||
chat_profil_user() ; | |||||
$('.dropdown-toggle').dropdown() ; | |||||
chat_datepicker() ; | |||||
}) ; | |||||
function chat_datepicker() { | |||||
$('input.datepicker').datepicker({dateFormat:'dd/mm/yy'}) ; | |||||
} | |||||
function chat_profil_user() { | |||||
if($('#profil-user').size()) { | |||||
if($('#user-no_mail').is(':checked')) { | |||||
$('#mails-jours-prod').hide() ; | |||||
} | |||||
$('#user-no_mail').change(function() { | |||||
if($('#user-no_mail').is(':checked')) { | |||||
$('#mails-jours-prod').hide() ; | |||||
} | |||||
else { | |||||
$('#mails-jours-prod').fadeIn() ; | |||||
} | |||||
}) ; | |||||
} | |||||
} | |||||
function chat_event_click_point_vente(id, force) { | |||||
if($('.point-sale-'+id).data('code') == 1) { | |||||
$('#modal-code #id-point-sale').val(id) ; | |||||
$('#modal-code').modal('show') ; | |||||
} | |||||
else { | |||||
$('#order-id_point_sale').val(id) ; | |||||
$('#points-sale .point-sale').removeClass('selected') ; | |||||
$('.point-sale-'+id).addClass('selected') ; | |||||
$('.point-sale-'+id).hide().fadeIn('fast') ; | |||||
var pain = parseInt($('.point-sale-'+id).data('pain')) ; | |||||
var vrac = parseInt($('.point-sale-'+id).data('vrac')) ; | |||||
if(pain) { | |||||
$('#pain .table').show() ; | |||||
$('#pain .indisponible').hide() ; | |||||
} | |||||
else { | |||||
$('#pain .table').hide() ; | |||||
$('#pain .indisponible').show() ; | |||||
} | |||||
if(vrac) { | |||||
$('#vrac .table').show() ; | |||||
$('#vrac .indisponible').hide() ; | |||||
} | |||||
else { | |||||
$('#vrac .table').hide() ; | |||||
$('#vrac .indisponible').show() ; | |||||
} | |||||
$('#products, #step-infos-point-sale, .confirm-order, .btn-comment, #bar-fixed').fadeIn() ; | |||||
// credit pain | |||||
chat_systeme_commande_credit_pain_event(chat_systeme_commande_maj_table_prix()) ; | |||||
// scroll | |||||
if(!force) { | |||||
boulange_scroll('step-infos-point-sale') ; | |||||
} | |||||
// infos point de vente | |||||
$('.infos-point-sale').hide() ; | |||||
$('.infos-point-sale-'+id).fadeIn() ; | |||||
} | |||||
} | |||||
function chat_init_horaire_point_vente(date) { | |||||
$('.infos-point-sale .jour').hide() ; | |||||
var selector_jour = '.infos-point-sale .jour-'+date.getDay() ; | |||||
$(selector_jour).show() ; | |||||
$('.select-previous-day').unbind('click').click(function() { | |||||
$('.ui-datepicker-current-day').prev().find('a').click() ; | |||||
}) ; | |||||
} | |||||
function chat_base_url(with_slug) { | |||||
var base_url = $('meta[name=base-url]').attr('content')+'/' ; | |||||
if(with_slug) { | |||||
base_url += $('meta[name=slug-producer]').attr('content')+'/' ; | |||||
} | |||||
return base_url ; | |||||
} | |||||
function chat_systeme_commande() { | |||||
if($('.order-form').size()) { | |||||
// scroll initial | |||||
if($('.producer.selected').size()) | |||||
{ | |||||
boulange_scroll('step-date') ; | |||||
} | |||||
// affichage des différentes parties du formulaire | |||||
if(!$('#order-id_distribution').val()) { | |||||
$('#block-points-sale, #step-infos-point-sale, #points-sale, #products, .confirm-order, .btn-comment, #bar-fixed').hide() ; | |||||
} | |||||
else if(!$('#commande-id_point_vente').val()) { | |||||
$('#products, .confirm-order, .btn-comment, #bar-fixed, #has-order-in-progress').hide() ; | |||||
} | |||||
// points de vente | |||||
if($('#order-id_point_sale').val()) { | |||||
chat_event_click_point_vente($('#order-id_point_sale').val(), true) ; | |||||
} | |||||
$('#modal-code form').submit(function() { | |||||
var id_pv = $('#modal-code #id-point-sale').val() ; | |||||
var code = $('#modal-code #code').val() ; | |||||
$.get(chat_base_url(true)+'order/validate-code-point-sale',{ | |||||
idPointSale: id_pv, | |||||
code: code | |||||
}, function(ok) { | |||||
if(ok) { | |||||
$('.point-sale-'+id_pv).data('code',0) ; | |||||
$('.point-sale-'+id_pv+' .glyphicon').remove() ; | |||||
$('input[name="code_point_sale_'+id_pv+'"]').val(code) ; | |||||
$('#modal-code').modal('hide') ; | |||||
chat_event_click_point_vente($('#modal-code #id-point-sale').val()) ; | |||||
} | |||||
else { | |||||
$('#modal-code .field-code').addClass('has-error') ; | |||||
$('#modal-code .help-block-error').hide().fadeIn() ; | |||||
} | |||||
}) ; | |||||
return false ; | |||||
}) ; | |||||
$('#points-sale .point-sale').click(function() { | |||||
var id = parseInt($(this).find('.id').html()) ; | |||||
chat_event_click_point_vente(id) ; | |||||
}) ; | |||||
// datepicker | |||||
var dates_production = [] ; | |||||
$('#dates div').each(function() { | |||||
dates_production.push($(this).find('.date').html()) ; | |||||
}) ; | |||||
//var var_datepicker = $.datepicker ; | |||||
$('#datepicker-distribution').datepicker({ | |||||
beforeShowDay: function(date){ | |||||
var string = $.datepicker.formatDate('dd/mm/yy', date); | |||||
for(var i=0; i<dates_production.length; i++) { | |||||
//alert(dates_production[i]+' '+string) ; | |||||
if(dates_production[i] == string) | |||||
return [1] ; | |||||
} | |||||
return [0] ; | |||||
// désactivé car internet explorer plante | |||||
//return [ dates_production.indexOf(string) != -1 ] ; | |||||
}, | |||||
onSelect: function(selectedDate) { | |||||
$('.infos-points-sale').hide() ; | |||||
// on remet tout les prix à zéro | |||||
chat_systeme_commande_reset_table_prix() ; | |||||
$('#has-order-in-progress').hide() ; | |||||
var tab_date = selectedDate.split('/') ; | |||||
var date = new Date(tab_date[2],tab_date[1]-1,tab_date[0]) ; | |||||
// set id production | |||||
var id_production = 0 ; | |||||
$('#dates div .date').each(function() { | |||||
if($(this).html() == selectedDate) { | |||||
id_production = $(this).parent().find('.id_distribution').html() ; | |||||
} | |||||
}); | |||||
$('#order-id_distribution').val(id_production) ; | |||||
// verif si le gars a une commande en cours pour cette production | |||||
var has_commande_en_cours = false ; | |||||
$('#orders-in-progress .order').each(function() { | |||||
if($(this).data('iddistribution') == id_production) { | |||||
//alert('bada') ; | |||||
$('#has-order-in-progress a').attr('href',$(this).data('href')) ; | |||||
$('#has-order-in-progress').show() ; | |||||
has_commande_en_cours = true ; | |||||
$('#block-points-sale, #step-infos-point-sale, #points-sale, #products, #bar-fixed').hide() ; | |||||
} | |||||
}) ; | |||||
if(!has_commande_en_cours) { | |||||
chat_systeme_commande_produits_dispos(tab_date[2]+'-'+tab_date[1]+'-'+tab_date[0], date) ; | |||||
$('#products, .confirm-order, .btn-comment, #bar-fixed').hide() ; | |||||
// déselection points de vente | |||||
$('#points-sale .point-sale').removeClass('selected') ; | |||||
$('#order-id_point_sale').val('') ; | |||||
// affichage points de vente | |||||
$('#block-points-sale, #points-sale, #order-infos').fadeIn() ; | |||||
// scroll | |||||
boulange_scroll('step-point-sale') ; | |||||
} | |||||
} | |||||
}) ; | |||||
if($('#order-id_distribution').val()) { | |||||
$("#dates .id_distribution").each(function() { | |||||
if($(this).html() == $('#order-id_distribution').val()) { | |||||
var tab_date = $(this).parent().find('.date').html().split('/') ; | |||||
var date = new Date(tab_date[2],tab_date[1]-1,tab_date[0]); | |||||
$('#datepicker-distribution').datepicker('setDate',date) ; | |||||
chat_systeme_commande_produits_dispos(tab_date[2]+'-'+tab_date[1]+'-'+tab_date[0], date) ; | |||||
chat_init_horaire_point_vente(date) ; | |||||
} | |||||
}) ; | |||||
} | |||||
// tableau produits | |||||
$('.order-form .move-quantity').click(function() { | |||||
var vrac = ($(this).parent().parent().parent().parent().parent().parent().parent().attr('id') == 'vrac') ; | |||||
if(vrac) { | |||||
var quantite = parseInt($(this).parent().parent().find('input.quantity').val()) ; | |||||
if($(this).hasClass('minus') && quantite != 0) | |||||
quantite -= 500 ; | |||||
if($(this).hasClass('plus')) | |||||
quantite += 500 ; | |||||
$(this).parent().parent().find('input.quantity').val(quantite) ; | |||||
chat_systeme_commande_maj_table_prix(); | |||||
} | |||||
else { | |||||
var quantite_totale = 0 ; | |||||
$('.quantity').each(function() { | |||||
quantite_totale += parseInt($(this).val()) ; | |||||
}) ; | |||||
var quantite = parseInt($(this).parent().parent().find('input.quantity').val()) ; | |||||
var quantite_restante = parseInt($(this).parent().parent().parent().find('.quantity-remaining .nb').html()) ; | |||||
var quantite_max = $(this).parent().parent().parent().parent().data('quantity-max') ; | |||||
var no_limit = $(this).parent().parent().parent().parent().data('no-limit') ; | |||||
if($(this).hasClass('minus') && quantite != 0) { | |||||
quantite -- ; | |||||
quantite_restante ++ ; | |||||
} | |||||
if($(this).hasClass('plus') ){ | |||||
if(quantite_restante > 0 || no_limit) { | |||||
quantite ++ ; | |||||
quantite_restante -- ; | |||||
} | |||||
} | |||||
$(this).parent().parent().parent().find('.quantity-remaining .nb').html(quantite_restante) ; | |||||
if(quantite_restante <= 5 && quantite_restante > 0) { | |||||
$(this).parent().parent().parent().find('.quantity-remaining').fadeIn() ; | |||||
} | |||||
else { | |||||
$(this).parent().parent().parent().find('.quantity-remaining').hide() ; | |||||
} | |||||
if(quantite_restante == 0 && !no_limit) { | |||||
$(this).parent().parent().parent().find('.unavailable').fadeIn() ; | |||||
} | |||||
else { | |||||
$(this).parent().parent().parent().find('.unavailable').hide() ; | |||||
} | |||||
$(this).parent().parent().find('input.quantity').val(quantite) ; | |||||
chat_systeme_commande_maj_table_prix(); | |||||
} | |||||
}) ; | |||||
chat_systeme_commande_maj_table_prix() ; | |||||
chat_systeme_commande_credit_pain(); | |||||
} | |||||
// commentaire commande | |||||
$('.order-form .btn-comment').click(function() { | |||||
if($('.field-order-comment').css('display') == 'none') { | |||||
$('.field-order-comment').slideDown() ; | |||||
} | |||||
else { | |||||
$('.field-order-comment').slideUp() ; | |||||
} | |||||
return false ; | |||||
}) ; | |||||
// bar fixed | |||||
if($('#bar-fixed').size()) { | |||||
$(window).scroll(function (event) { | |||||
var scroll = $(window).scrollTop() + $(window).height(); | |||||
var pos_bottom_produits = $('#table-products').offset().top + $('#table-products').height() + 100 ; | |||||
if($(window).height() < 700) { | |||||
if(!$('#bar-fixed').hasClass('not-fixed')) { | |||||
$('#bar-fixed').addClass('not-fixed') ; | |||||
} | |||||
} | |||||
else { | |||||
if(scroll > pos_bottom_produits) { | |||||
if(!$('#bar-fixed').hasClass('not-fixed')) { | |||||
$('#bar-fixed').addClass('not-fixed') ; | |||||
} | |||||
} | |||||
else { | |||||
$('#bar-fixed').removeClass('not-fixed') ; | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
function chat_systeme_commande_produits_dispos(str_date, date) { | |||||
// produits dispos à la vente à cette date | |||||
$.get(chat_base_url(true)+'order/infos-distribution',{ | |||||
idDistribution: $('#order-id_distribution').val() | |||||
}, function(data) { | |||||
if(data.products) { | |||||
$.each(data.products, function( id_produit, produit ) { | |||||
if(produit.active) $('.product-'+id_produit).show() ; | |||||
else $('.product-'+id_produit).hide() ; | |||||
var quantite_restante = produit.quantity_max - produit.quantity_order ; | |||||
var no_limit = 0 ; | |||||
if(!produit.quantity_max) | |||||
no_limit = 1 ; | |||||
$('.product-'+id_produit).attr('data-no-limit',no_limit) ; | |||||
$('.product-'+id_produit).attr('data-quantity-max',produit.quantity_max) ; | |||||
$('.product-'+id_produit+' .quantity-remaining .nb').html(quantite_restante) ; | |||||
if(produit.quantity_max && (!quantite_restante || quantite_restante < 0 || produit.unavailable)) { | |||||
$('.product-'+id_produit+' .unavailable').show() ; | |||||
if(!$('#id-order').val() && $('.product-'+id_produit+' .quantity').val() == 0) | |||||
{ | |||||
$('.product-'+id_produit+' .quantity-remaining').hide() ; | |||||
$('.product-'+id_produit+' .input-group').hide() ; | |||||
} | |||||
} | |||||
else { | |||||
$('.product-'+id_produit+' .unavailable').hide() ; | |||||
$('.product-'+id_produit+' .input-group').show() ; | |||||
$('.product-'+id_produit+' .quantity-remaining .nb').html(quantite_restante) ; | |||||
} | |||||
if($('.product-'+id_produit+' .quantity-remaining').size()) { | |||||
if(parseInt($('.product-'+id_produit+' .quantity-remaining .nb').html()) > 5 || | |||||
parseInt($('.product-'+id_produit+' .quantity-remaining .nb').html()) <= 0) { | |||||
$('.product-'+id_produit+' .quantity-remaining').hide() ; | |||||
} | |||||
else { | |||||
$('.product-'+id_produit+' .quantity-remaining').show() ; | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
$('#points-sale .point-sale').hide() ; | |||||
// init affichage points de vente | |||||
$.each(data.points_sale, function(key, livraison) { | |||||
if(livraison) { | |||||
$('.point-sale-'+key).fadeIn() ; | |||||
} | |||||
else { | |||||
$('.point-sale-'+key).hide() ; | |||||
} | |||||
}) ; | |||||
chat_init_horaire_point_vente(date) ; | |||||
}, 'json') ; | |||||
} | |||||
function chat_systeme_commande_reset_table_prix() { | |||||
$('#table-products tr .column-quantity .quantity').each(function() { | |||||
$(this).val(0) ; | |||||
}) ; | |||||
chat_systeme_commande_maj_table_prix() ; | |||||
} | |||||
function chat_systeme_commande_maj_table_prix() { | |||||
// produits pain | |||||
var prix = 0 ; | |||||
$('.order-form #table-products tbody tr').each(function() { | |||||
var quantite = parseInt($(this).find('.quantity').val()) ; | |||||
var prix_produit = parseFloat($(this).find('.price').html()) ; | |||||
var prix_total_produit = quantite * prix_produit ; | |||||
if(prix_total_produit) | |||||
$(this).find('.total').html(formate_prix(prix_total_produit)+' €') ; | |||||
else | |||||
$(this).find('.total').html('--') ; | |||||
if(quantite > 0) | |||||
prix += prix_total_produit ; | |||||
}) ; | |||||
$('#total-order strong').html(formate_prix(prix)+' €') ; | |||||
var prix_global = prix ; | |||||
// produits vrac | |||||
var prix = 0 ; | |||||
$('.order-form #table-products-vrac tbody tr').each(function() { | |||||
var quantite = parseInt($(this).find('.quantity').val()) ; | |||||
var prix_produit = parseFloat($(this).find('.price').html()) ; | |||||
var prix_total_produit = quantite/1000 * prix_produit ; | |||||
if(prix_total_produit) | |||||
$(this).find('.total').html(formate_prix(prix_total_produit)+' €') ; | |||||
else | |||||
$(this).find('.total').html('--') ; | |||||
if(quantite > 0) | |||||
prix += prix_total_produit ; | |||||
}) ; | |||||
$('#total-order-vrac strong').html(formate_prix(prix)+' €') ; | |||||
prix_global += prix ; | |||||
$('#total-order-bottom span').html(formate_prix(prix_global)) ; | |||||
if(prix_global) | |||||
$('#total-order-bottom').fadeIn() ; | |||||
else | |||||
$('#total-order-bottom').hide() ; | |||||
// maj credit pain | |||||
chat_systeme_commande_credit_pain_event(prix_global) ; | |||||
return prix_global ; | |||||
} | |||||
function chat_systeme_commande_credit_pain() { | |||||
$('input[name=credit]').change(function() { | |||||
var prix_global = chat_systeme_commande_maj_table_prix() ; | |||||
chat_systeme_commande_credit_pain_event(prix_global) ; | |||||
}) ; | |||||
} | |||||
function chat_systeme_commande_credit_pain_event(prix_global) { | |||||
var html = '' ; | |||||
var use_credit_pain = $('input[name=credit]').prop('checked') ; | |||||
var credit_pain = parseFloat($('#montant-credit').val()) ; | |||||
var credit_pain_dispo = credit_pain ; | |||||
var montant_paye = 0 | |||||
if($('#amount-paid').size() && $('#amount-paid').val()) | |||||
montant_paye = parseFloat($('#amount-paid').val()) ; | |||||
if($('#id-order').size() && $('#id-order').val()) { | |||||
credit_pain_dispo = credit_pain + montant_paye ; | |||||
} | |||||
var credit_pain_active = $('.point-sale.selected').data('credit') ; | |||||
if(credit_pain_active || montant_paye) { | |||||
$('#checkbox-credit #info-credit-empty').show() ; | |||||
$('#checkbox-credit label').show() ; | |||||
$('#checkbox-credit #credit-disabled').hide() ; | |||||
if(prix_global > credit_pain_dispo) { | |||||
var reste_payer = prix_global - credit_pain_dispo ; | |||||
if(use_credit_pain) { | |||||
if(montant_paye) { | |||||
html += '<span class="amount-paid">'+montant_paye+' € déjà payé</span><br />' ; | |||||
} | |||||
html += '<strong>'+credit_pain.toFixed(2)+' €</strong> seront débités<br />' ; | |||||
html += 'Restera <strong>'+reste_payer+' €</strong> à payer à la boulangerie' ; | |||||
$('#checkbox-credit .info').html(html) ; | |||||
} | |||||
else { | |||||
$('#checkbox-credit .info').html('') ; | |||||
} | |||||
} | |||||
else { | |||||
$('#checkbox-credit').removeClass('payment-impossible') ; | |||||
$('input[name=credit]').removeAttr('disabled') ; | |||||
if(use_credit_pain) { | |||||
var html = '' ; | |||||
// à payer | |||||
if(prix_global > montant_paye) | |||||
{ | |||||
montant = prix_global - montant_paye ; | |||||
if(montant_paye) { | |||||
html += '<span class="amount-paid">'+montant_paye+' € déjà payé</span><br />' ; | |||||
} | |||||
html += '<strong>'+montant.toFixed(2)+' €</strong> seront débités' ; | |||||
$('#checkbox-credit .info').html(html) ; | |||||
} | |||||
// remboursé | |||||
else if(prix_global < montant_paye) { | |||||
montant = montant_paye - prix_global ; | |||||
if(montant_paye) { | |||||
html += '<span class="amount-paid">'+montant_paye+' € déjà payé</span><br />' ; | |||||
} | |||||
html += '<strong>'+montant+' €</strong> seront remboursés' ; | |||||
$('#checkbox-credit .info').html(html) ; | |||||
} | |||||
else { | |||||
if(montant_paye > 0) | |||||
$('#checkbox-credit .info').html('<span class="amount-paid">'+montant_paye+' € déjà payé</span>') ; | |||||
else | |||||
$('#checkbox-credit .info').html('') ; | |||||
} | |||||
} | |||||
else { | |||||
$('#checkbox-credit .info').html('') | |||||
} | |||||
} | |||||
} | |||||
else { | |||||
$('#checkbox-credit #info-credit-empty').hide() ; | |||||
$('#checkbox-credit label').hide() ; | |||||
$('#checkbox-credit #credit-disabled').show() ; | |||||
} | |||||
} | |||||
function formate_prix(prix) { | |||||
return prix.toFixed(2).replace( ".", "," ) ; | |||||
} | |||||
function chat_slideshow() { | |||||
if($('body').hasClass('home')) { | |||||
var base_url = $('#base_url').val() ; | |||||
$.vegas('slideshow', { | |||||
backgrounds:[ | |||||
//{ src:'./img/background/back2.jpg' }, | |||||
{ src:base_url+'/img/background/four.jpg' }, | |||||
{ src:base_url+'/img/background/gueulard.jpg' } | |||||
], | |||||
walk: function() { | |||||
$('.vegas-loading').css('display','none') ; | |||||
$('.vegas-background').css('position','absolute') ; | |||||
} | |||||
})('overlay'); | |||||
} | |||||
} | |||||
function chat_scroll() { | |||||
if($('body').hasClass('home')) { | |||||
$('#header nav ul a[href^="#"]').click(function(){ | |||||
var the_id = $(this).attr("href"); | |||||
$('html, body').animate({ | |||||
scrollTop: $(the_id).offset().top - 100 | |||||
}, 'normal'); | |||||
return false; | |||||
}); | |||||
$(window).scroll(function() { | |||||
chat_event_scroll() ; | |||||
}) ; | |||||
chat_event_scroll() ; | |||||
} | |||||
} | |||||
function chat_event_scroll() { | |||||
var scroll_top = $(window).scrollTop() ; | |||||
//console.log(scroll_top + ' '+ ($('#horaires').offset().top-100)) ; | |||||
$('#header nav ul a').each(function() { | |||||
var top = $($(this).attr('href')).offset().top ; | |||||
var test = top + $($(this).attr('href')).height() - 150 ; | |||||
//console.log($(this).attr('href')+' : '+scroll_top+ ' | '+ test) ; | |||||
if(scroll_top <= top + $($(this).attr('href')).height() - 150) { | |||||
$('#header a').removeClass('selec') ; | |||||
$(this).addClass('selec') ; | |||||
} | |||||
}) ; | |||||
} | |||||
/** | /** | ||||
Copyright distrib (2018) | Copyright distrib (2018) | ||||
pris connaissance de la licence CeCILL, et que vous en avez accepté les | pris connaissance de la licence CeCILL, et que vous en avez accepté les | ||||
termes. | termes. | ||||
*/ | */ | ||||
$(document).ready(function() | |||||
{ | |||||
boulange_signup() ; | |||||
boulange_add_boulangerie() ; | |||||
boulange_fix_width_sidebar() ; | |||||
}); | |||||
function boulange_fix_width_sidebar() { | |||||
var diffWidth = 20 ; | |||||
$('#left .fixed').width($('#left').width() - diffWidth) ; | |||||
$( window ).resize(function() { | |||||
$('#left .fixed').width($('#left').width() - diffWidth) ; | |||||
}); | |||||
$('#left .fixed').show() ; | |||||
} | |||||
function boulange_scroll(id) { | |||||
if($("#"+id).size()) | |||||
$('html,body').animate({ | |||||
scrollTop: $("#"+id).offset().top}, | |||||
1000); | |||||
} | |||||
/* French initialisation for the jQuery UI date picker plugin. */ | |||||
/* Written by Keith Wood (kbwood{at}iinet.com.au), | |||||
Stéphane Nahmani (sholby@sholby.net), | |||||
Stéphane Raimbault <stephane.raimbault@gmail.com> */ | |||||
(function( factory ) { | |||||
if ( typeof define === "function" && define.amd ) { | |||||
function boulange_add_boulangerie() | |||||
{ | |||||
$('#bloc-add-etablissement .panel-heading').click(function() { | |||||
var panel_body = $(this).parent().find('.panel-body') ; | |||||
if(panel_body.css('display') == 'none') | |||||
panel_body.fadeIn() ; | |||||
else | |||||
panel_body.hide() ; | |||||
}) ; | |||||
$('#addetablissementform-id_etablissement,#signupform-id_etablissement').change(function() { | |||||
if($(this).find('option:selected').hasClass('lock')) { | |||||
$('#bloc-code-acces').fadeIn() ; | |||||
} | |||||
else { | |||||
$('#bloc-code-acces').hide() ; | |||||
} | |||||
}) ; | |||||
if($('#addetablissementform-id_etablissement option:selected,#signupform-id_etablissement option:selected').hasClass('lock')) { | |||||
$('#bloc-code-acces').show() ; | |||||
} | |||||
else { | |||||
$('#bloc-code-acces').hide() ; | |||||
} | |||||
if($('#bloc-add-etablissement').size()) { | |||||
if($('#bloc-add-etablissement .has-error').size()) { | |||||
$('#bloc-add-etablissement .panel-body').show() ; | |||||
} | |||||
} | |||||
} | |||||
// AMD. Register as an anonymous module. | |||||
define([ "../jquery.ui.datepicker" ], factory ); | |||||
} else { | |||||
function boulange_signup() | |||||
{ | |||||
if($('#form-signup').size()) | |||||
{ | |||||
boulange_signup_champs_boulanger() ; | |||||
$('#option-user, #option-producer').change(function() { | |||||
boulange_signup_champs_boulanger() ; | |||||
}) ; | |||||
} | |||||
} | |||||
// Browser globals | |||||
factory( jQuery.datepicker ); | |||||
} | |||||
}(function( datepicker ) { | |||||
datepicker.regional['fr'] = { | |||||
closeText: 'Fermer', | |||||
prevText: 'Précédent', | |||||
nextText: 'Suivant', | |||||
currentText: 'Aujourd\'hui', | |||||
monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', | |||||
'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'], | |||||
monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin', | |||||
'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], | |||||
dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], | |||||
dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], | |||||
dayNamesMin: ['D','L','M','M','J','V','S'], | |||||
weekHeader: 'Sem.', | |||||
dateFormat: 'dd/mm/yy', | |||||
firstDay: 1, | |||||
isRTL: false, | |||||
showMonthAfterYear: false, | |||||
yearSuffix: ''}; | |||||
datepicker.setDefaults(datepicker.regional['fr']); | |||||
function boulange_signup_champs_boulanger() | |||||
{ | |||||
if($('#option-producer').prop('checked')) | |||||
{ | |||||
$('#fields-producer').fadeIn() ; | |||||
$('#fields-user').hide() ; | |||||
} | |||||
else { | |||||
$('#fields-producer').hide() ; | |||||
$('#fields-user').fadeIn() ; | |||||
} | |||||
return datepicker.regional['fr']; | |||||
})); | |||||
$(document).ready(function() { | |||||
opendistrib_datepicker() ; | |||||
opendistrib_dropdown_tooltip() ; | |||||
opendistrib_fix_width_sidebar() ; | |||||
}) ; | |||||
function opendistrib_datepicker() { | |||||
$('input.datepicker').datepicker({dateFormat:'dd/mm/yy'}) ; | |||||
} | } | ||||
function opendistrib_dropdown_tooltip() { | |||||
$('.dropdown-toggle').dropdown() ; | |||||
$('[data-toggle="tooltip"]').tooltip() ; | |||||
} | |||||
function opendistrib_fix_width_sidebar() { | |||||
var diffWidth = 20 ; | |||||
$('#left .fixed').width($('#left').width() - diffWidth) ; | |||||
$( window ).resize(function() { | |||||
$('#left .fixed').width($('#left').width() - diffWidth) ; | |||||
}); | |||||
$('#left .fixed').show() ; | |||||
} |