add indexes, add messagedetsta

This commit is contained in:
2016-01-29 17:13:33 +01:00
parent ad59cbb940
commit a00331ce7c
65 changed files with 3195 additions and 92 deletions

View File

@@ -228,7 +228,7 @@ class CardController extends \backend\controllers\BackendController {
$card = Card::find()->andWhere(['number' => $item['number']])->one();
if ( $card != null ){
$card->rfid_key = $item['key'];
$sql = "update card set rfid_key = '" .$item['key'] ."' where id_card = " .$card->id_card .";";
$sql = "update card set rfid_key = '" . strtolower( $item['key'] )."' where id_card = " .$card->id_card .";";
$sqls[] = $sql;
$i++;
}else{

View File

@@ -0,0 +1,143 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Contract;
use backend\models\ContractSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use backend\models\ContractCustomerSearch;
use common\models\Customer;
/**
* ContractController implements the CRUD actions for Contract model.
*/
class ContractController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Contract models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ContractSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Lists all Contract models.
* @return mixed
*/
public function actionIndexCustomer($id)
{
$model = Customer::findOne($id);
if ( !isset($model)){
throw new NotFoundHttpException('The requested page does not exist.');
}
$searchModel = new ContractCustomerSearch(['customer' => $model]);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index-customer', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Contract model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Contract model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Contract();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_contract]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Contract model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_contract]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Contract model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Contract model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Contract the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Contract::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@@ -8,6 +8,8 @@ use backend\models\KeySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Customer;
use backend\models\KeyCustomerSearch;
/**
* KeyController implements the CRUD actions for Key model.
@@ -41,6 +43,28 @@ class KeyController extends Controller
'dataProvider' => $dataProvider, //csomagoló osztály a queryhez
]);
}
/**
* Lists all Key models.
* @return mixed
*/
public function actionIndexCustomer($id)
{
$model = Customer::findOne($id);
if ( !isset($model)){
throw new NotFoundHttpException('The requested page does not exist.');
}
$searchModel = new KeyCustomerSearch(['customer' => $model]);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
// backend/views/kex/index.php
return $this->render('index-customer', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider, //csomagoló osztály a queryhez
]);
}
/**
* Displays a single Key model.

View File

@@ -0,0 +1,137 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\MessageDetsta;
use backend\models\MessageDetstaSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\components\giro\GiroDETSTA;
use common\components\DetStaDBSave;
/**
* MessageDetstaController implements the CRUD actions for MessageDetsta model.
*/
class MessageDetstaController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all MessageDetsta models.
* @return mixed
*/
public function actionIndex()
{
$filename = \Yii::getAlias("@backend") ."/web/giro/valasz/detsta.txt";
$ugiro = GiroDETSTA::parse(file_get_contents($filename));
file_put_contents("c:\\tmp\\detsta.txt", $ugiro->toString());
$saver = new DetStaDBSave(
[
'giroDETSTA' => $ugiro,
'koteg' => null,
'idUser' =>\Yii::$app->user->id
]);
$saver->run();
$searchModel = new MessageDetstaSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single MessageDetsta model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new MessageDetsta model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new MessageDetsta();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_message]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing MessageDetsta model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_message]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing MessageDetsta model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the MessageDetsta model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return MessageDetsta the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = MessageDetsta::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@@ -12,6 +12,7 @@ use common\models\Warehouse;
use common\models\Product;
use common\models\User;
use common\components\Helper;
use common\models\Account;
/**
* ProcurementController implements the CRUD actions for Procurement model.
@@ -92,6 +93,8 @@ class ProcurementController extends \backend\controllers\BackendController
$model = new Procurement();
$model->scenario = 'create_general';
$accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->andWhere(['type' => Account::TYPE_ALL])->all();
$model->id_user = Yii::$app->user->id;
$warehouses = Warehouse::read(null);
@@ -137,7 +140,8 @@ class ProcurementController extends \backend\controllers\BackendController
} else {
return $this->render('create', [
'model' => $model,
'warehouses' =>$warehouses
'warehouses' =>$warehouses,
'accounts' => $accounts
]);
}
}

View File

@@ -10,6 +10,8 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account;
use common\models\ProductCategory;
use backend\models\ProductStatisticsSearch;
use PHPExcel;
/**
* ProductController implements the CRUD actions for Product model.
@@ -17,6 +19,24 @@ use common\models\ProductCategory;
class ProductController extends \backend\controllers\BackendController
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// allow authenticated users
[
'actions' => ['create','index','view','update','statistics'],
'allow' => true,
'roles' => ['admin','employee','reception'],
],
// everything else is denied
],
],
];
}
/**
* Lists all Product models.
@@ -106,6 +126,60 @@ class ProductController extends \backend\controllers\BackendController
return $this->redirect(['index']);
}
public function actionStatistics(){
$searchModel = new ProductStatisticsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
if ( $searchModel->output == 'xls' ){
$models = $dataProvider->getModels();
$objPHPExcel = new \PHPExcel();
$sheet = $objPHPExcel->setActiveSheetIndex(0);
$row = 1;
$sheet->setCellValue('A'.$row, "Termék név")
->setCellValue('B'.$row, "Eladási ár")
->setCellValue('C'.$row, "Kassza")
->setCellValue('D'.$row, "Eladott mennyiség")
->setCellValue('E'.$row, "Eladás összege");
foreach ($models as $model ){
$row++;
$sheet->setCellValue('A'.$row, $model['product_name'])
->setCellValue('B'.$row, $model['product_sale_price'])
->setCellValue('C'.$row, $model['father_account_name'])
->setCellValue('D'.$row, $model['transfer_count'])
->setCellValue('E'.$row, $model['transfer_money']);
}
// Redirect output to a clients web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="termek_statisztika.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
return $this->render('statistics', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Finds the Product model based on its primary key value.

View File

@@ -15,6 +15,7 @@ use common\models\User;
use common\models\Customer;
use common\models\Card;
use backend\models\TicketSearchStatisitcs;
use backend\models\TicketSearchCustomer;
/**
* TicketController implements the CRUD actions for Ticket model.
@@ -128,7 +129,7 @@ class TicketController extends \backend\controllers\BackendController {
throw new NotFoundHttpException ( 'The requested page does not exist.' );
}
$searchModel = new TicketSearch ();
$searchModel = new TicketSearchCustomer(['customer' => $customer]);
$searchModel->id_card = $customer->id_customer_card;
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
$searchModel->searchTotals ();