*/ | */ | ||||
class ProductController extends BackendController | class ProductController extends BackendController | ||||
{ | { | ||||
var $enableCsrfValidation = false; | |||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'verbs' => [ | |||||
'class' => VerbFilter::className(), | |||||
'actions' => [ | |||||
], | |||||
], | |||||
'access' => [ | |||||
'class' => AccessControl::className(), | |||||
'rules' => [ | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return User::hasAccessBackend(); | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
var $enableCsrfValidation = false; | |||||
public function behaviors() | |||||
{ | |||||
return [ | |||||
'verbs' => [ | |||||
'class' => VerbFilter::className(), | |||||
'actions' => [ | |||||
], | |||||
], | |||||
'access' => [ | |||||
'class' => AccessControl::className(), | |||||
'rules' => [ | |||||
[ | |||||
'allow' => true, | |||||
'roles' => ['@'], | |||||
'matchCallback' => function ($rule, $action) { | |||||
return User::hasAccessBackend(); | |||||
} | |||||
] | |||||
], | |||||
], | |||||
]; | |||||
} | |||||
/** | |||||
* Liste les modèles Produit. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$searchModel = new ProductSearch(); | |||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |||||
return $this->render('index', [ | |||||
'searchModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
]); | |||||
} | |||||
/** | |||||
* Liste les modèles Produit. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionIndex() | |||||
{ | |||||
$searchModel = new ProductSearch(); | |||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |||||
return $this->render('index', [ | |||||
'searchModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
]); | |||||
} | |||||
/** | |||||
* Crée un modèle Produit. | |||||
* Si la création réussit, le navigateur est redirigé vers la page 'index'. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionCreate() | |||||
{ | |||||
$model = new Product(); | |||||
$model->active = 1; | |||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||||
$model->monday = 1 ; | |||||
$model->tuesday = 1 ; | |||||
$model->wednesday = 1 ; | |||||
$model->thursday = 1 ; | |||||
$model->friday = 1 ; | |||||
$model->saturday = 1 ; | |||||
$model->sunday = 1 ; | |||||
$model->available_on_points_sale = 1 ; | |||||
/** | |||||
* Crée un modèle Produit. | |||||
* Si la création réussit, le navigateur est redirigé vers la page 'index'. | |||||
* | |||||
* @return mixed | |||||
*/ | |||||
public function actionCreate() | |||||
{ | |||||
$model = new Product(); | |||||
$model->active = 1; | |||||
$model->id_producer = GlobalParam::getCurrentProducerId(); | |||||
$model->monday = 1; | |||||
$model->tuesday = 1; | |||||
$model->wednesday = 1; | |||||
$model->thursday = 1; | |||||
$model->friday = 1; | |||||
$model->saturday = 1; | |||||
$model->sunday = 1; | |||||
$model->available_on_points_sale = 1; | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | if ($model->load(Yii::$app->request->post()) && $model->save()) { | ||||
$lastProductOrder = Product::find()->where('id_producer = :id_producer')->params([':id_producer' => GlobalParam::getCurrentProducerId()])->orderBy('order DESC')->one() ; | |||||
if($lastProductOrder) { | |||||
$model->order = ++ $lastProductOrder->order ; | |||||
$lastProductOrder = Product::find()->where('id_producer = :id_producer')->params([':id_producer' => GlobalParam::getCurrentProducerId()])->orderBy('order DESC')->one(); | |||||
if ($lastProductOrder) { | |||||
$model->order = ++$lastProductOrder->order; | |||||
} | } | ||||
Upload::uploadFile($model, 'photo'); | Upload::uploadFile($model, 'photo'); | ||||
$model->save(); | $model->save(); | ||||
$this->processAvailabilityPointsSale($model); | $this->processAvailabilityPointsSale($model); | ||||
// link product / distribution | // link product / distribution | ||||
Distribution::linkProductIncomingDistributions($model) ; | |||||
Distribution::linkProductIncomingDistributions($model); | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>'.Html::encode($model->name).'</strong> ajouté'); | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> ajouté'); | |||||
return $this->redirect(['index']); | return $this->redirect(['index']); | ||||
} | |||||
else { | |||||
} else { | |||||
return $this->render('create', [ | return $this->render('create', [ | ||||
'model' => $model, | 'model' => $model, | ||||
]); | ]); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Modifie un modèle Produit existant. | |||||
* Si la modification réussit, le navigateur est redirigé vers la page 'index'. | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionUpdate($id) | |||||
{ | |||||
$request = Yii::$app->request; | |||||
$model = $this->findModel($id); | |||||
foreach ($model->productPointSale as $productPointSale) { | |||||
$model->pointsSale[] = $productPointSale->id_point_sale; | |||||
} | |||||
$photoFilenameOld = $model->photo; | |||||
/** | |||||
* Modifie un modèle Produit existant. | |||||
* Si la modification réussit, le navigateur est redirigé vers la page 'index'. | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionUpdate($id) | |||||
{ | |||||
$request = Yii::$app->request; | |||||
$model = $this->findModel($id); | |||||
foreach ($model->productPointSale as $productPointSale) { | |||||
$model->pointsSale[] = $productPointSale->id_point_sale; | |||||
} | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
$photoFilenameOld = $model->photo; | |||||
Upload::uploadFile($model, 'photo', $photoFilenameOld); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
$deletePhoto = $request->post('delete_photo', 0); | |||||
if ($deletePhoto) { | |||||
$model->photo = ''; | |||||
$model->save(); | |||||
} | |||||
Upload::uploadFile($model, 'photo', $photoFilenameOld); | |||||
// availability on points sale | |||||
$this->processAvailabilityPointsSale($model); | |||||
$deletePhoto = $request->post('delete_photo', 0); | |||||
if ($deletePhoto) { | |||||
$model->photo = ''; | |||||
$model->save(); | |||||
} | |||||
if ($model->apply_distributions) { | |||||
// link product / distribution | |||||
Distribution::linkProductIncomingDistributions($model); | |||||
} | |||||
// availability on points sale | |||||
$this->processAvailabilityPointsSale($model); | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié'); | |||||
return $this->redirect(['index']); | |||||
} | |||||
if ($model->apply_distributions) { | |||||
// link product / distribution | |||||
Distribution::linkProductIncomingDistributions($model); | |||||
} | |||||
return $this->render('update/update', [ | |||||
'model' => $model, | |||||
'action' => 'update', | |||||
]); | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($model->name) . '</strong> modifié'); | |||||
return $this->redirect(['index']); | |||||
} | } | ||||
/** | |||||
* Traite les accès restreints d'un point de vente. | |||||
*/ | |||||
public function processAvailabilityPointsSale($model) | |||||
{ | |||||
ProductPointSale::deleteAll(['id_product' => $model->id]); | |||||
if (is_array($model->pointsSale) && count($model->pointsSale)) { | |||||
foreach ($model->pointsSale as $key => $val) { | |||||
$pointSale = PointSale::findOne($val); | |||||
if ($pointSale) { | |||||
$productPointSale = new ProductPointSale; | |||||
$productPointSale->id_product = $model->id; | |||||
$productPointSale->id_point_sale = $pointSale->id; | |||||
$productPointSale->available = ($model->available_on_points_sale) ? 0 : 1; | |||||
$productPointSale->save(); | |||||
} | |||||
return $this->render('update/update', [ | |||||
'model' => $model, | |||||
'action' => 'update', | |||||
]); | |||||
} | |||||
/** | |||||
* Traite les accès restreints d'un point de vente. | |||||
*/ | |||||
public function processAvailabilityPointsSale($model) | |||||
{ | |||||
ProductPointSale::deleteAll(['id_product' => $model->id]); | |||||
if (is_array($model->pointsSale) && count($model->pointsSale)) { | |||||
foreach ($model->pointsSale as $key => $val) { | |||||
$pointSale = PointSale::findOne($val); | |||||
if ($pointSale) { | |||||
$productPointSale = new ProductPointSale; | |||||
$productPointSale->id_product = $model->id; | |||||
$productPointSale->id_point_sale = $pointSale->id; | |||||
$productPointSale->available = ($model->available_on_points_sale) ? 0 : 1; | |||||
$productPointSale->save(); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
public function actionPricesList($id) | |||||
{ | |||||
$request = Yii::$app->request; | |||||
$model = $this->findModel($id); | |||||
$searchModel = new ProductPriceSearch(); | |||||
$searchModel->id_product = $id ; | |||||
$dataProvider = $searchModel->search(array_merge(Yii::$app->request->queryParams, [ | |||||
'id_product' => $id | |||||
])); | |||||
$userProducerWithProductPercent = UserProducer::searchAll([], [ | |||||
'join_with' => ['user'], | |||||
'conditions' => 'user_producer.product_price_percent != 0', | |||||
]) ; | |||||
$pointSaleWithProductPercent = PointSale::searchAll([], [ | |||||
'conditions' => 'point_sale.product_price_percent != 0' | |||||
]) ; | |||||
return $this->render('update/prices/list', [ | |||||
'model' => $model, | |||||
'action' => 'prices-list', | |||||
'searchModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'userProducerWithProductPercent' => $userProducerWithProductPercent, | |||||
'pointSaleWithProductPercent' => $pointSaleWithProductPercent, | |||||
]); | |||||
} | |||||
public function actionPricesCreate($idProduct) | |||||
{ | |||||
$model = new ProductPrice(); | |||||
$model->id_product = $idProduct; | |||||
$modelProduct = $this->findModel($idProduct) ; | |||||
public function actionPricesList($id) | |||||
{ | |||||
$request = Yii::$app->request; | |||||
$model = $this->findModel($id); | |||||
$searchModel = new ProductPriceSearch(); | |||||
$searchModel->id_product = $id; | |||||
$dataProvider = $searchModel->search(array_merge(Yii::$app->request->queryParams, [ | |||||
'id_product' => $id | |||||
])); | |||||
$userProducerWithProductPercent = UserProducer::searchAll([], [ | |||||
'join_with' => ['user'], | |||||
'conditions' => 'user_producer.product_price_percent != 0', | |||||
]); | |||||
$pointSaleWithProductPercent = PointSale::searchAll([], [ | |||||
'conditions' => 'point_sale.product_price_percent != 0' | |||||
]); | |||||
return $this->render('update/prices/list', [ | |||||
'model' => $model, | |||||
'action' => 'prices-list', | |||||
'searchModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'userProducerWithProductPercent' => $userProducerWithProductPercent, | |||||
'pointSaleWithProductPercent' => $pointSaleWithProductPercent, | |||||
]); | |||||
} | |||||
if ($model->load(Yii::$app->request->post())) { | |||||
public function actionPricesCreate($idProduct) | |||||
{ | |||||
$model = new ProductPrice(); | |||||
$model->id_product = $idProduct; | |||||
$modelProduct = $this->findModel($idProduct); | |||||
$conditionsProductPriceExist = [ | |||||
'id_product' => $idProduct, | |||||
'id_user' => $model->id_user ? $model->id_user : null, | |||||
'id_user_group' => $model->id_user_group ? $model->id_user_group : null, | |||||
'id_point_sale' => $model->id_point_sale ? $model->id_point_sale : null, | |||||
'from_quantity' => $model->from_quantity ? $model->from_quantity : null, | |||||
] ; | |||||
if ($model->load(Yii::$app->request->post())) { | |||||
$productPriceExist = ProductPrice::findOne($conditionsProductPriceExist) ; | |||||
$conditionsProductPriceExist = [ | |||||
'id_product' => $idProduct, | |||||
'id_user' => $model->id_user ? $model->id_user : null, | |||||
'id_user_group' => $model->id_user_group ? $model->id_user_group : null, | |||||
'id_point_sale' => $model->id_point_sale ? $model->id_point_sale : null, | |||||
'from_quantity' => $model->from_quantity ? $model->from_quantity : null, | |||||
]; | |||||
if($productPriceExist) { | |||||
$productPriceExist->delete() ; | |||||
Yii::$app->getSession()->setFlash('warning', 'Un prix existait déjà pour cet utilisateur / point de vente, il a été supprimé.'); | |||||
} | |||||
$productPriceExist = ProductPrice::findOne($conditionsProductPriceExist); | |||||
if($model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', 'Le prix a bien été ajouté.'); | |||||
return $this->redirect(['product/prices-list', 'id' => $idProduct]); | |||||
} | |||||
} | |||||
if ($productPriceExist) { | |||||
$productPriceExist->delete(); | |||||
Yii::$app->getSession()->setFlash('warning', 'Un prix existait déjà pour cet utilisateur / point de vente, il a été supprimé.'); | |||||
} | |||||
return $this->render('update/prices/create', [ | |||||
'model' => $model, | |||||
'modelProduct' => $modelProduct, | |||||
]); | |||||
if ($model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', 'Le prix a bien été ajouté.'); | |||||
return $this->redirect(['product/prices-list', 'id' => $idProduct]); | |||||
} | |||||
} | } | ||||
public function actionPricesUpdate($id) | |||||
{ | |||||
$request = Yii::$app->request; | |||||
return $this->render('update/prices/create', [ | |||||
'model' => $model, | |||||
'modelProduct' => $modelProduct, | |||||
]); | |||||
} | |||||
$model = $this->findModelProductPrice($id); | |||||
$modelProduct = $this->findModel($model->id_product) ; | |||||
public function actionPricesUpdate($id) | |||||
{ | |||||
$request = Yii::$app->request; | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', 'Prix modifié'); | |||||
return $this->redirect(['product/prices-list', 'id' => $model->id_product]); | |||||
} | |||||
$model = $this->findModelProductPrice($id); | |||||
$modelProduct = $this->findModel($model->id_product); | |||||
return $this->render('update/prices/update', [ | |||||
'model' => $model, | |||||
'modelProduct' => $modelProduct, | |||||
'action' => 'prices-update', | |||||
]); | |||||
if ($model->load(Yii::$app->request->post()) && $model->save()) { | |||||
Yii::$app->getSession()->setFlash('success', 'Prix modifié'); | |||||
return $this->redirect(['product/prices-list', 'id' => $model->id_product]); | |||||
} | } | ||||
public function actionPricesDelete($id) | |||||
{ | |||||
$productPrice = $this->findModelProductPrice($id); | |||||
$productPrice->delete(); | |||||
Yii::$app->getSession()->setFlash('success', 'Prix supprimé'); | |||||
return $this->redirect(['product/prices-list', 'id' => $productPrice->id_product]); | |||||
} | |||||
return $this->render('update/prices/update', [ | |||||
'model' => $model, | |||||
'modelProduct' => $modelProduct, | |||||
'action' => 'prices-update', | |||||
]); | |||||
} | |||||
/** | |||||
* Supprime un modèle Produit. | |||||
* Si la suppression réussit, le navigateur est redirigé vers la page | |||||
* 'index'. | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionDelete($id, $confirm = false) | |||||
{ | |||||
$product = $this->findModel($id); | |||||
if ($confirm) { | |||||
$product->delete(); | |||||
ProductDistribution::deleteAll(['id_product' => $id]); | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($product->name) . '</strong> supprimé'); | |||||
} else { | |||||
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le produit <strong>' . Html::encode($product->name) . '</strong> ? ' | |||||
. Html::a('Oui', ['product/delete', 'id' => $id, 'confirm' => 1], ['class' => 'btn btn-default']) . ' ' . Html::a('Non', ['product/index'], ['class' => 'btn btn-default'])); | |||||
} | |||||
public function actionPricesDelete($id) | |||||
{ | |||||
$productPrice = $this->findModelProductPrice($id); | |||||
$productPrice->delete(); | |||||
Yii::$app->getSession()->setFlash('success', 'Prix supprimé'); | |||||
return $this->redirect(['product/prices-list', 'id' => $productPrice->id_product]); | |||||
} | |||||
return $this->redirect(['index']); | |||||
/** | |||||
* Supprime un modèle Produit. | |||||
* Si la suppression réussit, le navigateur est redirigé vers la page | |||||
* 'index'. | |||||
* | |||||
* @param integer $id | |||||
* @return mixed | |||||
*/ | |||||
public function actionDelete($id, $confirm = false) | |||||
{ | |||||
$product = $this->findModel($id); | |||||
if ($confirm) { | |||||
$product->delete(); | |||||
ProductDistribution::deleteAll(['id_product' => $id]); | |||||
Yii::$app->getSession()->setFlash('success', 'Produit <strong>' . Html::encode($product->name) . '</strong> supprimé'); | |||||
} else { | |||||
Yii::$app->getSession()->setFlash('info', 'Souhaitez-vous vraiment supprimer le produit <strong>' . Html::encode($product->name) . '</strong> ? ' | |||||
. Html::a('Oui', ['product/delete', 'id' => $id, 'confirm' => 1], ['class' => 'btn btn-default']) . ' ' . Html::a('Non', ['product/index'], ['class' => 'btn btn-default'])); | |||||
} | } | ||||
/** | |||||
* Modifie l'ordre des produits. | |||||
* | |||||
* @param array $array | |||||
*/ | |||||
public function actionOrder() | |||||
{ | |||||
$array = Yii::$app->request->post('array'); | |||||
$orderArray = json_decode(stripslashes($array)); | |||||
foreach ($orderArray as $id => $order) { | |||||
$product = $this->findModel($id); | |||||
$product->order = $order; | |||||
$product->save(); | |||||
} | |||||
return $this->redirect(['index']); | |||||
} | |||||
/** | |||||
* Modifie l'ordre des produits. | |||||
* | |||||
* @param array $array | |||||
*/ | |||||
public function actionOrder() | |||||
{ | |||||
$array = Yii::$app->request->post('array'); | |||||
$orderArray = json_decode(stripslashes($array)); | |||||
foreach ($orderArray as $id => $order) { | |||||
$product = $this->findModel($id); | |||||
$product->order = $order; | |||||
$product->save(); | |||||
} | } | ||||
} | |||||
/** | |||||
* Recherche un produit en fonction de son ID. | |||||
* | |||||
* @param integer $id | |||||
* @return Produit | |||||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | |||||
*/ | |||||
protected function findModel($id) | |||||
{ | |||||
if (($model = Product::findOne($id)) !== null) { | |||||
return $model; | |||||
} else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | |||||
} | |||||
public function actionAjaxToggleActive($id, $active) | |||||
{ | |||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |||||
$product = $this->findModel($id); | |||||
$product->active = (int) $active; | |||||
return ['success', 'id' => $id, 'active' => $active]; | |||||
} | |||||
/** | |||||
* Recherche un produit en fonction de son ID. | |||||
* | |||||
* @param integer $id | |||||
* @return Produit | |||||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | |||||
*/ | |||||
protected function findModel($id) | |||||
{ | |||||
if (($model = Product::findOne($id)) !== null) { | |||||
return $model; | |||||
} else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | |||||
} | } | ||||
} | |||||
protected function findModelProductPrice($id) | |||||
{ | |||||
if (($model = ProductPrice::findOne($id)) !== null) { | |||||
return $model; | |||||
} else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | |||||
} | |||||
protected function findModelProductPrice($id) | |||||
{ | |||||
if (($model = ProductPrice::findOne($id)) !== null) { | |||||
return $model; | |||||
} else { | |||||
throw new NotFoundHttpException('The requested page does not exist.'); | |||||
} | } | ||||
} | |||||
} | } |
use common\models\TaxRate; | use common\models\TaxRate; | ||||
use common\models\Producer; | use common\models\Producer; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use \lo\widgets\Toggle; | |||||
$this->setTitle('Produits'); | $this->setTitle('Produits'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
<span style="display: none;" id="page-size"><?= $dataProvider->pagination->pageSize; ?></span> | <span style="display: none;" id="page-size"><?= $dataProvider->pagination->pageSize; ?></span> | ||||
<div class="product-index"> | <div class="product-index"> | ||||
<?= GridView::widget([ | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'order', | |||||
'headerOptions' => ['class' => 'order'], | |||||
'format' => 'raw', | |||||
'filter' => '', | |||||
'value' => function ($model) { | |||||
return '<a class="btn-order btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>'; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'photo', | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'td-photo'], | |||||
'filter' => '', | |||||
'value' => function ($model) { | |||||
if (strlen($model->photo)) { | |||||
$url = Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/'.$model->photo ; | |||||
$url = str_replace('//uploads','/uploads', $url) ; | |||||
return '<img class="photo-product" src="' . $url . '" />'; | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
'name', | |||||
'description', | |||||
[ | |||||
'attribute' => 'id_product_category', | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'td-product-category'], | |||||
'filter' => '', | |||||
'value' => function ($model) { | |||||
if ($model->productCategory) { | |||||
return $model->productCategory->name ; | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_tax_rate', | |||||
'value' => function ($model) { | |||||
if ($model->id_tax_rate == 0 || $model->id_tax_rate == null) { | |||||
<?= GridView::widget([ | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'order', | |||||
'headerOptions' => ['class' => 'order'], | |||||
'format' => 'raw', | |||||
'filter' => '', | |||||
'value' => function ($model) { | |||||
return '<a class="btn-order btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>'; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'photo', | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'td-photo'], | |||||
'filter' => '', | |||||
'value' => function ($model) { | |||||
if (strlen($model->photo)) { | |||||
$url = Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/' . $model->photo; | |||||
$url = str_replace('//uploads', '/uploads', $url); | |||||
return '<img class="photo-product" src="' . $url . '" />'; | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
'name', | |||||
'description', | |||||
[ | |||||
'attribute' => 'id_product_category', | |||||
'format' => 'raw', | |||||
'headerOptions' => ['class' => 'td-product-category'], | |||||
'filter' => '', | |||||
'value' => function ($model) { | |||||
if ($model->productCategory) { | |||||
return $model->productCategory->name; | |||||
} | |||||
return ''; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'id_tax_rate', | |||||
'value' => function ($model) { | |||||
if ($model->id_tax_rate == 0 || $model->id_tax_rate == null) { | |||||
//Récupère la tva par défaut du producteur courant | |||||
$taxRateDefault = GlobalParam::getCurrentProducer()->taxRate; | |||||
//Récupère la tva par défaut du producteur courant | |||||
$taxRateDefault = GlobalParam::getCurrentProducer()->taxRate; | |||||
$return = $taxRateDefault->name; | |||||
} else { | |||||
$return = $taxRateDefault->name; | |||||
} else { | |||||
$return = $model->taxRate->name; | |||||
} | |||||
return $return; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'price', | |||||
'value' => function ($model) { | |||||
$return = ''; | |||||
if ($model->price) { | |||||
$return = Price::format($model->getPriceWithTax()) . ' (' . Product::strUnit($model->unit, 'wording_unit', true) . ')'; | |||||
} | |||||
return $return; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'active', | |||||
'headerOptions' => ['class' => 'active'], | |||||
'contentOptions' => ['class' => 'center'], | |||||
'format' => 'raw', | |||||
'filter' => [0 => 'Non', 1 => 'Oui'], | |||||
'value' => function ($model) { | |||||
if ($model->active) { | |||||
return '<span class="label label-success">oui</span>'; | |||||
} else { | |||||
return '<span class="label label-danger">non</span>'; | |||||
} | |||||
} | |||||
], | |||||
$return = $model->taxRate->name; | |||||
} | |||||
return $return; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'price', | |||||
'value' => function ($model) { | |||||
$return = ''; | |||||
if ($model->price) { | |||||
$return = Price::format($model->getPriceWithTax()) . ' (' . Product::strUnit($model->unit, 'wording_unit', true) . ')'; | |||||
} | |||||
return $return; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'active', | |||||
'headerOptions' => ['class' => 'active'], | |||||
'contentOptions' => ['class' => 'center'], | |||||
'format' => 'raw', | |||||
'filter' => [0 => 'Non', 1 => 'Oui'], | |||||
'value' => function ($model) { | |||||
return Toggle::widget( | |||||
[ | [ | ||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{update} {delete}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'update' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' | |||||
]); | |||||
} | |||||
], | |||||
], | |||||
'name' => 'active', | |||||
'checked' => $model->active, | |||||
'options' => [ | |||||
'data-id' => $model->id, | |||||
'data-on' => 'Oui', | |||||
'data-off' => 'Non', | |||||
], | |||||
] | |||||
); | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{update} {delete}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'update' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $model) { | |||||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' | |||||
]); | |||||
} | |||||
], | ], | ||||
]); ?> | |||||
], | |||||
], | |||||
]); ?> | |||||
</div> | </div> |
/** | |||||
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_ordre_categories() ; | |||||
opendistrib_products() ; | |||||
opendistrib_product_prices() ; | |||||
opendistrib_confirm_delete() ; | |||||
opendistrib_product_availability_points_sale(); | |||||
opendistrib_user_index(); | |||||
opendistrib_menu_treeview(); | |||||
}) ; | |||||
/** | |||||
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_ordre_categories(); | |||||
opendistrib_products(); | |||||
opendistrib_product_prices(); | |||||
opendistrib_product_index(); | |||||
opendistrib_confirm_delete(); | |||||
opendistrib_product_availability_points_sale(); | |||||
opendistrib_user_index(); | |||||
opendistrib_menu_treeview(); | |||||
}); | |||||
var UrlManager = { | var UrlManager = { | ||||
getBaseUrl: function() { | |||||
return $('meta[name=baseurl]').attr('content')+'/' ; | |||||
getBaseUrl: function () { | |||||
return $('meta[name=baseurl]').attr('content') + '/'; | |||||
}, | }, | ||||
getBaseUrlAbsolute: function() { | |||||
return $('meta[name=baseurl-absolute]').attr('content')+'/' ; | |||||
getBaseUrlAbsolute: function () { | |||||
return $('meta[name=baseurl-absolute]').attr('content') + '/'; | |||||
} | } | ||||
}; | }; | ||||
function opendistrib_user_index() { | function opendistrib_user_index() { | ||||
if($('body').hasClass('user-index')) { | |||||
if ($('body').hasClass('user-index')) { | |||||
$('#w0-filters input:first').focus(); | $('#w0-filters input:first').focus(); | ||||
} | } | ||||
} | } | ||||
function opendistrib_menu_treeview() { | function opendistrib_menu_treeview() { | ||||
$('li.treeview a').unbind('click').click(function() { | |||||
$('li.treeview a').unbind('click').click(function () { | |||||
var href = $(this).attr('href'); | var href = $(this).attr('href'); | ||||
if(href != '#') { | |||||
if (href != '#') { | |||||
$(location).attr('href', href); | $(location).attr('href', href); | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
function opendistrib_product_index() { | |||||
$('body.product-index .toggle input').change(function() { | |||||
var id = $(this).data('id'); | |||||
var checked = $(this).prop('checked'); | |||||
var active = 0; | |||||
if(checked) { | |||||
active = 1; | |||||
} | |||||
$.get(UrlManager.getBaseUrl() + 'product/ajax-toggle-active', { | |||||
id: id, | |||||
active: active | |||||
}); | |||||
}) | |||||
} | |||||
function opendistrib_product_availability_points_sale() { | function opendistrib_product_availability_points_sale() { | ||||
$('input[name="Product[available_on_points_sale]"]').change(function() { | |||||
$('input[name="Product[available_on_points_sale]"]').change(function () { | |||||
var available = parseInt($(this).val()); | var available = parseInt($(this).val()); | ||||
var label = 'disponible'; | var label = 'disponible'; | ||||
if(available == 1) { | |||||
if (available == 1) { | |||||
label = 'indisponible'; | label = 'indisponible'; | ||||
} | } | ||||
} | } | ||||
function opendistrib_confirm_delete() { | function opendistrib_confirm_delete() { | ||||
$('.btn-confirm-delete').click(function(event) { | |||||
if(!confirm('Souhaitez-vous vraiment supprimer cette entrée ?')) { | |||||
event.stopPropagation() ; | |||||
return false ; | |||||
$('.btn-confirm-delete').click(function (event) { | |||||
if (!confirm('Souhaitez-vous vraiment supprimer cette entrée ?')) { | |||||
event.stopPropagation(); | |||||
return false; | |||||
} | } | ||||
}) ; | |||||
}); | |||||
} | } | ||||
function opendistrib_products() { | function opendistrib_products() { | ||||
if($('.product-create').size() || $('.product-update').size()) { | |||||
opendistrib_products_event_unit(false) ; | |||||
if ($('.product-create').size() || $('.product-update').size()) { | |||||
opendistrib_products_event_unit(false); | |||||
$('#product-unit').change(function() { | |||||
opendistrib_products_event_unit(true) ; | |||||
}) ; | |||||
$('#product-unit').change(function () { | |||||
opendistrib_products_event_unit(true); | |||||
}); | |||||
opendistrib_products_event_price_with_tax() ; | |||||
opendistrib_products_event_price_with_tax(); | |||||
$('#product-price').change(opendistrib_products_event_price_with_tax); | $('#product-price').change(opendistrib_products_event_price_with_tax); | ||||
$('#product-price-with-tax').change(opendistrib_products_event_price); | $('#product-price-with-tax').change(opendistrib_products_event_price); | ||||
function opendistrib_products_event_price_with_tax() { | function opendistrib_products_event_price_with_tax() { | ||||
taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value'); | taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value'); | ||||
if(typeof taxRateSelected == 'undefined') { | |||||
taxRateSelected = 0 ; | |||||
if (typeof taxRateSelected == 'undefined') { | |||||
taxRateSelected = 0; | |||||
} | } | ||||
var price = $('#product-price').val() ; | |||||
if(price) { | |||||
var price = $('#product-price').val(); | |||||
if (price) { | |||||
$('#product-price-with-tax').val(getPriceWithTax(price, taxRateSelected)); | $('#product-price-with-tax').val(getPriceWithTax(price, taxRateSelected)); | ||||
// formattage | // formattage | ||||
$('#product-price').val(parseFloat(price).toFixed(3)); | $('#product-price').val(parseFloat(price).toFixed(3)); | ||||
} | } | ||||
} | } | ||||
function opendistrib_products_event_price(){ | |||||
function opendistrib_products_event_price() { | |||||
taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value'); | taxRateSelected = $('#product-id_tax_rate').find('option:selected').data('tax-rate-value'); | ||||
var priceWithTax = $('#product-price-with-tax').val() ; | |||||
if(priceWithTax) { | |||||
var priceWithTax = $('#product-price-with-tax').val(); | |||||
if (priceWithTax) { | |||||
$('#product-price').val(getPrice(priceWithTax, taxRateSelected)); | $('#product-price').val(getPrice(priceWithTax, taxRateSelected)); | ||||
// formattage | // formattage | ||||
$('#product-price-with-tax').val(parseFloat(priceWithTax).toFixed(2)); | $('#product-price-with-tax').val(parseFloat(priceWithTax).toFixed(2)); | ||||
function opendistrib_products_event_unit(change) { | function opendistrib_products_event_unit(change) { | ||||
var unit = $('#product-unit').val() ; | |||||
if(unit == 'piece') { | |||||
$('.field-product-step').hide() ; | |||||
$('.field-product-weight label').html('Poids (g)') ; | |||||
$('.field-product-weight').show() ; | |||||
var unit = $('#product-unit').val(); | |||||
if (unit == 'piece') { | |||||
$('.field-product-step').hide(); | |||||
$('.field-product-weight label').html('Poids (g)'); | |||||
$('.field-product-weight').show(); | |||||
} else { | |||||
$('.field-product-step').show(); | |||||
$('.field-product-weight label').html('Poids (' + $('#product-unit').val() + ')'); | |||||
$('.field-product-weight').hide(); | |||||
} | } | ||||
else { | |||||
$('.field-product-step').show() ; | |||||
$('.field-product-weight label').html('Poids ('+$('#product-unit').val()+')') ; | |||||
$('.field-product-weight').hide() ; | |||||
} | |||||
var label_price_ttc = $('.field-product-price .control-label.with-tax') ; | |||||
var label_price_ht = $('.field-product-price .control-label.without-tax') ; | |||||
var label_step = $('.field-product-step .control-label') ; | |||||
var label_quantity_max = $('.field-product-quantity_max .control-label') ; | |||||
if(unit == 'piece') { | |||||
label_price_ttc.html('Prix (la pièce) TTC') ; | |||||
label_price_ht.html('Prix (la pièce) HT') ; | |||||
label_quantity_max.html('Quantité max par défaut (pièces)') ; | |||||
} | |||||
else if(unit == 'g' || unit == 'kg') { | |||||
label_price_ttc.html('Prix (au kg) TTC') ; | |||||
label_price_ht.html('Prix (au kg) HT') ; | |||||
label_quantity_max.html('Quantité max par défaut (kg)') ; | |||||
label_step.html('Pas ('+unit+')') ; | |||||
} | |||||
else if(unit == 'mL' || unit == 'L') { | |||||
label_price_ttc.html('Prix (au litre) TTC') ; | |||||
label_price_ht.html('Prix (au litre) HT') ; | |||||
label_quantity_max.html('Quantité max par défaut (litres)') ; | |||||
label_step.html('Pas ('+unit+')') ; | |||||
var label_price_ttc = $('.field-product-price .control-label.with-tax'); | |||||
var label_price_ht = $('.field-product-price .control-label.without-tax'); | |||||
var label_step = $('.field-product-step .control-label'); | |||||
var label_quantity_max = $('.field-product-quantity_max .control-label'); | |||||
if (unit == 'piece') { | |||||
label_price_ttc.html('Prix (la pièce) TTC'); | |||||
label_price_ht.html('Prix (la pièce) HT'); | |||||
label_quantity_max.html('Quantité max par défaut (pièces)'); | |||||
} else if (unit == 'g' || unit == 'kg') { | |||||
label_price_ttc.html('Prix (au kg) TTC'); | |||||
label_price_ht.html('Prix (au kg) HT'); | |||||
label_quantity_max.html('Quantité max par défaut (kg)'); | |||||
label_step.html('Pas (' + unit + ')'); | |||||
} else if (unit == 'mL' || unit == 'L') { | |||||
label_price_ttc.html('Prix (au litre) TTC'); | |||||
label_price_ht.html('Prix (au litre) HT'); | |||||
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('') ; | |||||
if (change) { | |||||
if (unit == 'piece') { | |||||
$('#product-step').val(1); | |||||
} else { | |||||
$('#product-step').val(''); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
function opendistrib_product_prices() { | function opendistrib_product_prices() { | ||||
if($('.product-prices-create').size() || $('.product-prices-update').size()) { | |||||
opendistrib_product_prices_event_price_with_tax() ; | |||||
if ($('.product-prices-create').size() || $('.product-prices-update').size()) { | |||||
opendistrib_product_prices_event_price_with_tax(); | |||||
$('#productprice-price').change(opendistrib_product_prices_event_price_with_tax); | $('#productprice-price').change(opendistrib_product_prices_event_price_with_tax); | ||||
$('#productprice-price-with-tax').change(opendistrib_product_prices_event_price); | $('#productprice-price-with-tax').change(opendistrib_product_prices_event_price); | ||||
} | } | ||||
function opendistrib_product_prices_event_price_with_tax() { | function opendistrib_product_prices_event_price_with_tax() { | ||||
var taxRateValue = $('#productprice-price-with-tax').data('tax-rate-value'); | var taxRateValue = $('#productprice-price-with-tax').data('tax-rate-value'); | ||||
var price = $('#productprice-price').val() ; | |||||
if(price) { | |||||
var price = $('#productprice-price').val(); | |||||
if (price) { | |||||
$('#productprice-price-with-tax').val(getPriceWithTax(price, taxRateValue)); | $('#productprice-price-with-tax').val(getPriceWithTax(price, taxRateValue)); | ||||
// formattage | // formattage | ||||
$('#productprice-price').val(parseFloat(price).toFixed(3)); | $('#productprice-price').val(parseFloat(price).toFixed(3)); | ||||
function opendistrib_product_prices_event_price() { | function opendistrib_product_prices_event_price() { | ||||
var taxRateValue = $('#productprice-price-with-tax').data('tax-rate-value'); | var taxRateValue = $('#productprice-price-with-tax').data('tax-rate-value'); | ||||
var priceWithTax = $('#productprice-price-with-tax').val() ; | |||||
if(priceWithTax) { | |||||
var priceWithTax = $('#productprice-price-with-tax').val(); | |||||
if (priceWithTax) { | |||||
$('#productprice-price').val(getPrice(priceWithTax, taxRateValue)); | $('#productprice-price').val(getPrice(priceWithTax, taxRateValue)); | ||||
// formattage | // formattage | ||||
$('#productprice-price-with-tax').val(parseFloat(priceWithTax).toFixed(2)); | $('#productprice-price-with-tax').val(parseFloat(priceWithTax).toFixed(2)); | ||||
} | } | ||||
function opendistrib_tooltip() { | function opendistrib_tooltip() { | ||||
$('[data-toggle="tooltip"]').tooltip({container:'body'}); | |||||
$('[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_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() { | function opendistrib_points_vente_acces() { | ||||
// affichage du bloc acces restreint | // affichage du bloc acces restreint | ||||
$('#pointsale-restricted_access').change(function() { | |||||
opendistrib_points_vente_acces_event() ; | |||||
}) ; | |||||
opendistrib_points_vente_acces_event() ; | |||||
$('#pointsale-restricted_access').change(function () { | |||||
opendistrib_points_vente_acces_event(); | |||||
}); | |||||
opendistrib_points_vente_acces_event(); | |||||
// affichage du champs commentaire | // affichage du champs commentaire | ||||
$('#pointsale-users input[type=checkbox]').change(function() { | |||||
opendistrib_points_vente_commentaire_event() ; | |||||
}) ; | |||||
opendistrib_points_vente_commentaire_event() ; | |||||
$('#pointsale-users input[type=checkbox]').change(function () { | |||||
opendistrib_points_vente_commentaire_event(); | |||||
}); | |||||
opendistrib_points_vente_commentaire_event(); | |||||
} | } | ||||
function 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() ; | |||||
$('#pointsale-users input[type=checkbox]').each(function () { | |||||
if ($(this).prop('checked')) { | |||||
$(this).parent().find('.commentaire').fadeIn(); | |||||
} else { | |||||
$(this).parent().find('.commentaire').hide(); | |||||
} | } | ||||
else { | |||||
$(this).parent().find('.commentaire').hide() ; | |||||
} | |||||
}) ; | |||||
}); | |||||
} | } | ||||
function opendistrib_points_vente_acces_event() { | function opendistrib_points_vente_acces_event() { | ||||
if($('#pointsale-restricted_access').prop('checked')) { | |||||
$('#pointsale-users').fadeIn() ; | |||||
} | |||||
else { | |||||
$('#pointsale-users').hide() ; | |||||
if ($('#pointsale-restricted_access').prop('checked')) { | |||||
$('#pointsale-users').fadeIn(); | |||||
} else { | |||||
$('#pointsale-users').hide(); | |||||
} | } | ||||
} | } | ||||
function opendistrib_commandeauto() { | function opendistrib_commandeauto() { | ||||
$('#subscriptionform-date_begin, #subscriptionform-date_end').datepicker() ; | |||||
$('#subscriptionform-date_begin, #subscriptionform-date_end').datepicker(); | |||||
} | } | ||||
function opendistrib_sortable_list(element_selector, button_selector, route_ajax) { | function opendistrib_sortable_list(element_selector, button_selector, route_ajax) { | ||||
var fixHelper = function(e, ui) { | |||||
ui.children().each(function() { | |||||
var fixHelper = function (e, ui) { | |||||
ui.children().each(function () { | |||||
$(this).width($(this).width()); | $(this).width($(this).width()); | ||||
}); | }); | ||||
return ui; | return ui; | ||||
}; | }; | ||||
$(element_selector+" table tbody").sortable({ | |||||
$(element_selector + " table tbody").sortable({ | |||||
items: "> tr", | items: "> tr", | ||||
appendTo: "parent", | appendTo: "parent", | ||||
cursor: "move", | cursor: "move", | ||||
placeholder: "ui-state-highlight", | placeholder: "ui-state-highlight", | ||||
handle: button_selector, | handle: button_selector, | ||||
helper: fixHelper, | 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 ; | |||||
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; | |||||
} | } | ||||
} | } | ||||
$(element_selector+" table tbody tr").each(function() { | |||||
tab_ordre[$(this).attr('data-key')] = ordre ; | |||||
ordre++ ; | |||||
}) ; | |||||
$(element_selector + " table tbody tr").each(function () { | |||||
tab_ordre[$(this).attr('data-key')] = ordre; | |||||
ordre++; | |||||
}); | |||||
$.post(UrlManager.getBaseUrl() + route_ajax,{ | |||||
$.post(UrlManager.getBaseUrl() + route_ajax, { | |||||
array: JSON.stringify(tab_ordre) | array: JSON.stringify(tab_ordre) | ||||
}) ; | |||||
}); | |||||
} | } | ||||
}).disableSelection(); | }).disableSelection(); | ||||
} | } | ||||
'.product-category-index', | '.product-category-index', | ||||
'.btn-position', | '.btn-position', | ||||
'product-category/position' | 'product-category/position' | ||||
) ; | |||||
); | |||||
} | } | ||||
function opendistrib_ordre_produits() { | function opendistrib_ordre_produits() { | ||||
'.product-index', | '.product-index', | ||||
'.btn-order', | '.btn-order', | ||||
'product/order' | 'product/order' | ||||
) ; | |||||
); | |||||
/*var fixHelper = function(e, ui) { | /*var fixHelper = function(e, ui) { | ||||
ui.children().each(function() { | ui.children().each(function() { | ||||
} | } | ||||
function opendistrib_datepicker() { | function opendistrib_datepicker() { | ||||
$('input.datepicker').datepicker({dateFormat:'dd/mm/yy'}) ; | |||||
$('input.datepicker').datepicker({dateFormat: 'dd/mm/yy'}); | |||||
} | } | ||||
/* French initialisation for the jQuery UI date picker plugin. */ | /* French initialisation for the jQuery UI date picker plugin. */ | ||||
/* Written by Keith Wood (kbwood{at}iinet.com.au), | /* Written by Keith Wood (kbwood{at}iinet.com.au), | ||||
Stéphane Nahmani (sholby@sholby.net), | Stéphane Nahmani (sholby@sholby.net), | ||||
Stéphane Raimbault <stephane.raimbault@gmail.com> */ | 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']; | |||||
(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']; | |||||
})); | })); | ||||
"yiisoft/yii2-jui": "^2.0", | "yiisoft/yii2-jui": "^2.0", | ||||
"bower-asset/jquery": "^3.6", | "bower-asset/jquery": "^3.6", | ||||
"yidas/yii2-bower-asset": "2.0.13.1", | "yidas/yii2-bower-asset": "2.0.13.1", | ||||
"stripe/stripe-php": "^7.95" | |||||
"stripe/stripe-php": "^7.95", | |||||
"loveorigami/yii2-bootstrap-toggle": "*" | |||||
}, | }, | ||||
"require-dev": { | "require-dev": { | ||||
"yiisoft/yii2-codeception": "*", | "yiisoft/yii2-codeception": "*", |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||
"This file is @generated automatically" | "This file is @generated automatically" | ||||
], | ], | ||||
"content-hash": "bbfd502bb99ed522c5f181c9e809790f", | |||||
"content-hash": "96d4dfea93de951d74c4d1d099ed27ed", | |||||
"packages": [ | "packages": [ | ||||
{ | { | ||||
"name": "2amigos/yii2-chartjs-widget", | "name": "2amigos/yii2-chartjs-widget", | ||||
}, | }, | ||||
"time": "2019-08-29T08:20:20+00:00" | "time": "2019-08-29T08:20:20+00:00" | ||||
}, | }, | ||||
{ | |||||
"name": "bower-asset/bootstrap-toggle", | |||||
"version": "2.2.2", | |||||
"source": { | |||||
"type": "git", | |||||
"url": "git@github.com:minhur/bootstrap-toggle.git", | |||||
"reference": "187e332b7431afe3d0c07eeef92782ce59a77d66" | |||||
}, | |||||
"dist": { | |||||
"type": "zip", | |||||
"url": "https://api.github.com/repos/minhur/bootstrap-toggle/zipball/187e332b7431afe3d0c07eeef92782ce59a77d66", | |||||
"reference": "187e332b7431afe3d0c07eeef92782ce59a77d66" | |||||
}, | |||||
"type": "bower-asset", | |||||
"license": [ | |||||
"MIT" | |||||
] | |||||
}, | |||||
{ | { | ||||
"name": "bower-asset/chartjs", | "name": "bower-asset/chartjs", | ||||
"version": "v2.1.6", | "version": "v2.1.6", | ||||
}, | }, | ||||
"time": "2020-05-03T11:44:34+00:00" | "time": "2020-05-03T11:44:34+00:00" | ||||
}, | }, | ||||
{ | |||||
"name": "loveorigami/yii2-bootstrap-toggle", | |||||
"version": "1.1", | |||||
"source": { | |||||
"type": "git", | |||||
"url": "https://github.com/loveorigami/yii2-bootstrap-toggle.git", | |||||
"reference": "27ee6469f784b9163c03ee760e34c7ef751be148" | |||||
}, | |||||
"dist": { | |||||
"type": "zip", | |||||
"url": "https://api.github.com/repos/loveorigami/yii2-bootstrap-toggle/zipball/27ee6469f784b9163c03ee760e34c7ef751be148", | |||||
"reference": "27ee6469f784b9163c03ee760e34c7ef751be148", | |||||
"shasum": "" | |||||
}, | |||||
"require": { | |||||
"bower-asset/bootstrap-toggle": "*", | |||||
"yiisoft/yii2": "2.0.*" | |||||
}, | |||||
"require-dev": { | |||||
"yiisoft/yii2-debug": "2.0.*" | |||||
}, | |||||
"type": "yii2-extension", | |||||
"autoload": { | |||||
"psr-4": { | |||||
"lo\\widgets\\": "" | |||||
} | |||||
}, | |||||
"notification-url": "https://packagist.org/downloads/", | |||||
"license": [ | |||||
"GPL-3.0+" | |||||
], | |||||
"authors": [ | |||||
{ | |||||
"name": "Andrey Lukyanov", | |||||
"email": "loveorigami@mail.ru" | |||||
} | |||||
], | |||||
"description": "Yii2 bootstrap-toggle widget", | |||||
"keywords": [ | |||||
"bootstrap", | |||||
"toggle", | |||||
"widget", | |||||
"yii2" | |||||
], | |||||
"support": { | |||||
"issues": "https://github.com/loveorigami/yii2-bootstrap-toggle/issues", | |||||
"source": "https://github.com/loveorigami/yii2-bootstrap-toggle/tree/master" | |||||
}, | |||||
"time": "2016-05-12T15:57:40+00:00" | |||||
}, | |||||
{ | { | ||||
"name": "mailjet/mailjet-apiv3-php", | "name": "mailjet/mailjet-apiv3-php", | ||||
"version": "v1.5.1", | "version": "v1.5.1", | ||||
"php": ">=5.4.0" | "php": ">=5.4.0" | ||||
}, | }, | ||||
"platform-dev": [], | "platform-dev": [], | ||||
"plugin-api-version": "2.0.0" | |||||
"plugin-api-version": "2.3.0" | |||||
} | } |