$res = Yii::$app->db->createCommand("SELECT product.name, SUM(product_order.quantity) AS quantity, SUM(product_order.price * product_order.quantity) AS total | $res = Yii::$app->db->createCommand("SELECT product.name, SUM(product_order.quantity) AS quantity, SUM(product_order.price * product_order.quantity) AS total | ||||
FROM `order`, product_order, product | FROM `order`, product_order, product | ||||
WHERE `order`.id = product_order.id_order | WHERE `order`.id = product_order.id_order | ||||
AND product.id_producer = ".((int) Producer::getId())." | |||||
AND product_order.id_product = product.id | AND product_order.id_product = product.id | ||||
AND `order`.date_delete IS NULL | AND `order`.date_delete IS NULL | ||||
".$conditionUsers." | ".$conditionUsers." |
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function actionIndex( | public function actionIndex( | ||||
$idPointSale = 0, $sectionInactiveUsers = false) | |||||
$idPointSale = 0, $sectionSubscribers = false, $sectionInactiveUsers = false) | |||||
{ | { | ||||
$searchModel = new UserSearch ; | $searchModel = new UserSearch ; | ||||
$dataProvider = $searchModel->search([ | $dataProvider = $searchModel->search([ | ||||
'UserSearch' => array_merge( | 'UserSearch' => array_merge( | ||||
[ | [ | ||||
'id_point_sale' => $idPointSale, | 'id_point_sale' => $idPointSale, | ||||
'inactive' => (int) $sectionInactiveUsers | |||||
'inactive' => (int) $sectionInactiveUsers, | |||||
'subscribers' => (int) $sectionSubscribers | |||||
], | ], | ||||
isset(Yii::$app->request->queryParams['UserSearch']) ? | isset(Yii::$app->request->queryParams['UserSearch']) ? | ||||
Yii::$app->request->queryParams['UserSearch'] : | Yii::$app->request->queryParams['UserSearch'] : | ||||
'idPointSaleActive' => $idPointSale, | 'idPointSaleActive' => $idPointSale, | ||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, | ||||
'sectionInactiveUsers' => $sectionInactiveUsers, | 'sectionInactiveUsers' => $sectionInactiveUsers, | ||||
'sectionSubscribers' => $sectionSubscribers, | |||||
]); | ]); | ||||
} | } | ||||
* @param integer $idPointSale | * @param integer $idPointSale | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function actionMail($idPointSale = 0) | |||||
public function actionMail($idPointSale = 0, $sectionSubscribers = 0, $sectionInactiveUsers = 0) | |||||
{ | { | ||||
$users = User::findBy([ | $users = User::findBy([ | ||||
'id_producer' => Producer::getId(), | 'id_producer' => Producer::getId(), | ||||
'id_point_sale' => $idPointSale | |||||
'id_point_sale' => $idPointSale, | |||||
'subscribers' => $sectionSubscribers, | |||||
'inactive' => $sectionInactiveUsers, | |||||
])->all() ; | ])->all() ; | ||||
$usersArray = []; | $usersArray = []; | ||||
'mailForm' => $mailForm, | 'mailForm' => $mailForm, | ||||
'idPointSaleActive' => $idPointSale, | 'idPointSaleActive' => $idPointSale, | ||||
'incomingDistributionsArray' => $incomingDistributionsArray, | 'incomingDistributionsArray' => $incomingDistributionsArray, | ||||
'sectionSubscribers' => $sectionSubscribers, | |||||
'sectionInactiveUsers' => $sectionInactiveUsers, | |||||
]); | ]); | ||||
} | } | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<p>Choisissez à quels utilisateurs vous souhaitez envoyer un email :</p> | <p>Choisissez à quels utilisateurs vous souhaitez envoyer un email :</p> | ||||
<div> | <div> | ||||
<?= Html::a('Tous',['user/mail', 'idPointSale' => 0], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-th-list"></span> Tous',['user/mail', 'idPointSale' => 0], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-repeat"></span> Abonnés',['user/mail', 'sectionSubscribers' => 1], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-time"></span> Inactifs',['user/mail', 'sectionInactiveUsers' => 1], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?php foreach($pointsSaleArray as $pointSale): ?> | <?php foreach($pointsSaleArray as $pointSale): ?> | ||||
<?= Html::a(Html::encode($pointSale->name), ['user/mail', 'idPointSale' => $pointSale->id], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?= Html::a('<span class="glyphicon glyphicon-map-marker"></span> '.Html::encode($pointSale->name), ['user/mail', 'idPointSale' => $pointSale->id], ['class' => 'btn btn-default btn-point-sale']); ?> | |||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
</div> | </div> | ||||
</div> | </div> |
<?= $form->field($model, 'photo')->fileInput() ?> | <?= $form->field($model, 'photo')->fileInput() ?> | ||||
<?php | <?php | ||||
if(strlen($model->photo)) { | if(strlen($model->photo)) { | ||||
echo '<img src="'.Yii::$app->urlManagerProducer->getBaseUrl().'/uploads/'.$model->photo.'" width="200px" /><br />' ; | |||||
$url = Yii::$app->urlManagerProducer->getHostInfo().'/'.Yii::$app->urlManagerProducer->baseUrl ; | |||||
echo '<img class="photo-product" src="'.$url.'/uploads/'.$model->photo.'" width="200px" /><br />' ; | |||||
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />' ; | echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />' ; | ||||
} | } | ||||
?> | ?> |
<div id="menu-users"> | <div id="menu-users"> | ||||
<div id="nav-points-sale"> | <div id="nav-points-sale"> | ||||
<a class="btn <?php if(!$idPointSaleActive && !$sectionInactiveUsers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section]); ?>"> | |||||
Tous <span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
<a class="btn <?php if(!$idPointSaleActive && !$sectionInactiveUsers && !$sectionSubscribers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section]); ?>"> | |||||
<span class="glyphicon glyphicon-th-list"></span> Tous <span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | </a> | ||||
<?php if(isset($sectionSubscribers) && !is_null($sectionSubscribers)): ?> | |||||
<a class="btn <?php if($sectionSubscribers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'sectionSubscribers' => 1]); ?>"> | |||||
<span class="glyphicon glyphicon-repeat"></span> | |||||
Abonnés | |||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php endif; ?> | |||||
<?php if(isset($sectionInactiveUsers) && !is_null($sectionInactiveUsers)): ?> | |||||
<a class="btn <?php if($sectionInactiveUsers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'sectionInactiveUsers' => 1]); ?>"> | |||||
<span class="glyphicon glyphicon-time"></span> | |||||
Inactifs | |||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php endif; ?> | |||||
<?php foreach($pointsSaleArray as $pointSale): ?> | <?php foreach($pointsSaleArray as $pointSale): ?> | ||||
<a class="btn <?php if($idPointSaleActive == $pointSale->id): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'idPointSale' => $pointSale->id]); ?>"> | <a class="btn <?php if($idPointSaleActive == $pointSale->id): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/'.$section,'idPointSale' => $pointSale->id]); ?>"> | ||||
<span class="glyphicon glyphicon-map-marker"></span> | |||||
<?= Html::encode($pointSale->name) ?> | <?= Html::encode($pointSale->name) ?> | ||||
<span class="glyphicon glyphicon-triangle-bottom"></span> | <span class="glyphicon glyphicon-triangle-bottom"></span> | ||||
</a> | </a> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php if(isset($sectionInactiveUsers) && !is_null($sectionInactiveUsers)): ?> | |||||
<a class="btn <?php if($sectionInactiveUsers): ?>btn-primary<?php else: ?>btn-default<?php endif; ?>" href="<?= Yii::$app->urlManager->createUrl(['user/index','sectionInactiveUsers' => 1]); ?>"> | |||||
Inactifs <span class="glyphicon glyphicon-triangle-bottom"></span> | |||||
</a> | |||||
<?php endif; ?> | |||||
</div> | </div> | ||||
<div id="submenu"> | <div id="submenu"> |
$this->render('_menu',[ | $this->render('_menu',[ | ||||
'idPointSaleActive' => $idPointSaleActive, | 'idPointSaleActive' => $idPointSaleActive, | ||||
'sectionInactiveUsers' => isset($sectionInactiveUsers) ? $sectionInactiveUsers : null, | 'sectionInactiveUsers' => isset($sectionInactiveUsers) ? $sectionInactiveUsers : null, | ||||
'sectionSubscribers' => isset($sectionSubscribers) ? $sectionSubscribers: null, | |||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, | ||||
'section' => 'mail' | 'section' => 'mail' | ||||
]) ; | ]) ; |
$this->render('_menu',[ | $this->render('_menu',[ | ||||
'idPointSaleActive' => $idPointSaleActive, | 'idPointSaleActive' => $idPointSaleActive, | ||||
'sectionInactiveUsers' => $sectionInactiveUsers, | 'sectionInactiveUsers' => $sectionInactiveUsers, | ||||
'sectionSubscribers' => $sectionSubscribers, | |||||
'pointsSaleArray' => $pointsSaleArray, | 'pointsSaleArray' => $pointsSaleArray, | ||||
'section' => 'index' | 'section' => 'index' | ||||
]) ; | ]) ; |
margin-bottom: 30px; | margin-bottom: 30px; | ||||
text-align: left; | text-align: left; | ||||
} | } | ||||
/* line 1309, ../sass/screen.scss */ | |||||
#menu-users a { | |||||
margin-bottom: 15px; | |||||
} | |||||
/* line 1311, ../sass/screen.scss */ | |||||
/* line 1315, ../sass/screen.scss */ | |||||
.user-index .input-group { | .user-index .input-group { | ||||
width: 180px; | width: 180px; | ||||
} | } | ||||
/* line 1314, ../sass/screen.scss */ | |||||
/* line 1318, ../sass/screen.scss */ | |||||
.user-index .input-group .input-credit { | .user-index .input-group .input-credit { | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 1321, ../sass/screen.scss */ | |||||
/* line 1325, ../sass/screen.scss */ | |||||
.user-credit .the-credit { | .user-credit .the-credit { | ||||
float: right; | float: right; | ||||
font-weight: bold; | font-weight: bold; | ||||
} | } | ||||
/* facturation */ | /* facturation */ | ||||
/* line 1336, ../sass/screen.scss */ | |||||
/* line 1340, ../sass/screen.scss */ | |||||
#free-price { | #free-price { | ||||
padding: 20px; | padding: 20px; | ||||
background-color: #F9F9F9; | background-color: #F9F9F9; | ||||
} | } | ||||
/* line 1340, ../sass/screen.scss */ | |||||
/* line 1344, ../sass/screen.scss */ | |||||
#free-price h2 { | #free-price h2 { | ||||
font-family: "myriadpro-it"; | font-family: "myriadpro-it"; | ||||
} | } | ||||
/* line 1344, ../sass/screen.scss */ | |||||
/* line 1348, ../sass/screen.scss */ | |||||
#free-price .amount span { | #free-price .amount span { | ||||
font-size: 25px; | font-size: 25px; | ||||
color: white; | color: white; | ||||
padding-top: 7px; | padding-top: 7px; | ||||
font-family: "myriadpro-regular"; | font-family: "myriadpro-regular"; | ||||
} | } | ||||
/* line 1355, ../sass/screen.scss */ | |||||
/* line 1359, ../sass/screen.scss */ | |||||
#free-price label { | #free-price label { | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
font-family: "myriadpro-light"; | font-family: "myriadpro-light"; | ||||
font-size: 20px; | font-size: 20px; | ||||
} | } | ||||
/* line 1360, ../sass/screen.scss */ | |||||
/* line 1364, ../sass/screen.scss */ | |||||
#free-price label span { | #free-price label span { | ||||
font-size: 16px; | font-size: 16px; | ||||
} | } | ||||
/* line 1366, ../sass/screen.scss */ | |||||
/* line 1370, ../sass/screen.scss */ | |||||
#free-price .field-producer-free_price .input-group { | #free-price .field-producer-free_price .input-group { | ||||
width: 200px; | width: 200px; | ||||
} | } | ||||
/* line 1372, ../sass/screen.scss */ | |||||
/* line 1376, ../sass/screen.scss */ | |||||
#free-price .field-user-free_price label { | #free-price .field-user-free_price label { | ||||
display: none; | display: none; | ||||
} | } | ||||
/* line 1377, ../sass/screen.scss */ | |||||
/* line 1381, ../sass/screen.scss */ | |||||
#free-price #producer-free_price { | #free-price #producer-free_price { | ||||
width: 100px; | width: 100px; | ||||
height: 60px; | height: 60px; | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 1387, ../sass/screen.scss */ | |||||
/* line 1391, ../sass/screen.scss */ | |||||
.development-index ul#tabs-status-developments { | .development-index ul#tabs-status-developments { | ||||
margin-bottom: 30px; | margin-bottom: 30px; | ||||
border-bottom: solid 3px #FF7F00; | border-bottom: solid 3px #FF7F00; | ||||
} | } | ||||
/* line 1391, ../sass/screen.scss */ | |||||
/* line 1395, ../sass/screen.scss */ | |||||
.development-index ul#tabs-status-developments a { | .development-index ul#tabs-status-developments a { | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
} | } | ||||
/* line 1394, ../sass/screen.scss */ | |||||
/* line 1398, ../sass/screen.scss */ | |||||
.development-index ul#tabs-status-developments .active { | .development-index ul#tabs-status-developments .active { | ||||
border: 0px none; | border: 0px none; | ||||
background: none; | background: none; | ||||
} | } | ||||
/* line 1397, ../sass/screen.scss */ | |||||
/* line 1401, ../sass/screen.scss */ | |||||
.development-index ul#tabs-status-developments .active a { | .development-index ul#tabs-status-developments .active a { | ||||
background-color: #FF7F00; | background-color: #FF7F00; | ||||
color: white; | color: white; | ||||
} | } | ||||
/* line 1405, ../sass/screen.scss */ | |||||
/* line 1409, ../sass/screen.scss */ | |||||
.development-index #tab-developments .btn-group-priority { | .development-index #tab-developments .btn-group-priority { | ||||
width: 100%; | width: 100%; | ||||
margin-bottom: 5px; | margin-bottom: 5px; | ||||
} | } | ||||
/* line 1409, ../sass/screen.scss */ | |||||
/* line 1413, ../sass/screen.scss */ | |||||
.development-index #tab-developments .btn-group-priority .btn-priority { | .development-index #tab-developments .btn-group-priority .btn-priority { | ||||
display: block; | display: block; | ||||
float: none; | float: none; | ||||
width: 100%; | width: 100%; | ||||
} | } | ||||
/* line 1416, ../sass/screen.scss */ | |||||
/* line 1420, ../sass/screen.scss */ | |||||
.development-index #tab-developments .label-priority { | .development-index #tab-developments .label-priority { | ||||
display: block; | display: block; | ||||
width: 100%; | width: 100%; | ||||
} | } | ||||
/* stats */ | /* stats */ | ||||
/* line 1429, ../sass/screen.scss */ | |||||
/* line 1433, ../sass/screen.scss */ | |||||
.stats-products #nav-year { | .stats-products #nav-year { | ||||
float: right; | float: right; | ||||
} | } | ||||
/* line 1434, ../sass/screen.scss */ | |||||
/* line 1438, ../sass/screen.scss */ | |||||
.stats-products tr.month th { | .stats-products tr.month th { | ||||
text-align: center; | text-align: center; | ||||
} | } | ||||
/* line 1439, ../sass/screen.scss */ | |||||
/* line 1443, ../sass/screen.scss */ | |||||
.stats-products tr.sub-head th { | .stats-products tr.sub-head th { | ||||
font-weight: normal; | font-weight: normal; | ||||
font-size: 12px; | font-size: 12px; | ||||
} | } | ||||
/* line 1445, ../sass/screen.scss */ | |||||
/* line 1449, ../sass/screen.scss */ | |||||
.stats-products td.name { | .stats-products td.name { | ||||
text-transform: uppercase; | text-transform: uppercase; | ||||
} | } | ||||
/* line 1449, ../sass/screen.scss */ | |||||
/* line 1453, ../sass/screen.scss */ | |||||
.stats-products td.align-center { | .stats-products td.align-center { | ||||
text-align: center; | text-align: center; | ||||
} | } |
margin-bottom: 30px ; | margin-bottom: 30px ; | ||||
text-align: left ; | text-align: left ; | ||||
} | } | ||||
a { | |||||
margin-bottom: 15px ; | |||||
} | |||||
} | } | ||||
.user-index { | .user-index { |
} | } | ||||
} | } | ||||
if(isset($params['subscribers']) && $params['subscribers']) { | |||||
$query->innerJoin( | |||||
'subscription', | |||||
'user.id = subscription.id_user AND subscription.id_producer = :id_producer', | |||||
[':id_producer' => Producer::getId()] | |||||
)->groupBy('user.id') ; | |||||
} | |||||
if(isset($params['inactive']) && $params['inactive']) { | if(isset($params['inactive']) && $params['inactive']) { | ||||
$query->innerJoin( | $query->innerJoin( | ||||
'order', | 'order', |
class UserSearch extends User | class UserSearch extends User | ||||
{ | { | ||||
var $id_point_sale ; | var $id_point_sale ; | ||||
var $subscribers ; | |||||
var $inactive ; | var $inactive ; | ||||
var $username ; | var $username ; | ||||
return [ | return [ | ||||
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'], | [['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'], | ||||
[['lastname', 'name', 'phone', 'address'], 'string'], | [['lastname', 'name', 'phone', 'address'], 'string'], | ||||
[['id_point_sale', 'inactive'],'integer'], | |||||
[['id_point_sale', 'inactive', 'subscribers'],'integer'], | |||||
[['date_last_connection', 'id_point_sale', 'username'], 'safe'], | [['date_last_connection', 'id_point_sale', 'username'], 'safe'], | ||||
]; | ]; | ||||
} | } | ||||
$query->innerJoin('user_point_sale','user.id = user_point_sale.id_user AND user_point_sale.id_point_sale = :id_point_sale',[':id_point_sale' => $this->id_point_sale]) ; | $query->innerJoin('user_point_sale','user.id = user_point_sale.id_user AND user_point_sale.id_point_sale = :id_point_sale',[':id_point_sale' => $this->id_point_sale]) ; | ||||
} | } | ||||
if(isset($this->subscribers) && $this->subscribers) { | |||||
$query->innerJoin( | |||||
'subscription', | |||||
'user.id = subscription.id_user AND subscription.id_producer = :id_producer', | |||||
[':id_producer' => Producer::getId()] | |||||
)->groupBy('user.id') ; | |||||
} | |||||
if(isset($this->inactive) && $this->inactive) { | if(isset($this->inactive) && $this->inactive) { | ||||
$query->having([ | $query->having([ | ||||
'count_orders' => 0 | 'count_orders' => 0 |
use common\helpers\Url ; | use common\helpers\Url ; | ||||
/* @var $this yii\web\View */ | /* @var $this yii\web\View */ | ||||
$this->setTitle('Bienvenue sur distrib') ; | |||||
$this->setPageTitle('Plateforme de réservation de pain') ; | |||||
$this->setTitle('Logiciel libre de gestion de commandes') ; | |||||
?> | ?> | ||||