Add ContractForm, Add contract pdf, Add Display all Transfer option
This commit is contained in:
@@ -28,6 +28,8 @@ use frontend\components\DefaultAccountBehavior;
|
||||
use frontend\components\CassaOpenBehavior;
|
||||
use common\components\ProductInventory;
|
||||
use frontend\models\ProductInventorySearch;
|
||||
use common\components\Helper;
|
||||
use common\components\TransferPayout;
|
||||
|
||||
/**
|
||||
* ProductController implements the CRUD actions for Product model.
|
||||
@@ -62,17 +64,17 @@ class ProductController extends Controller {
|
||||
'@'
|
||||
]
|
||||
]
|
||||
]
|
||||
// everything else is denied
|
||||
|
||||
] ,
|
||||
]
|
||||
],
|
||||
// everything else is denied
|
||||
|
||||
// named behavior, configuration array
|
||||
'defaultAccount' => [
|
||||
'class' => DefaultAccountBehavior::className(),
|
||||
],
|
||||
'cassaIsOpen' => [
|
||||
'class' => CassaOpenBehavior::className(),
|
||||
'defaultAccount' => [
|
||||
'class' => DefaultAccountBehavior::className ()
|
||||
],
|
||||
'cassaIsOpen' => [
|
||||
'class' => CassaOpenBehavior::className ()
|
||||
]
|
||||
];
|
||||
}
|
||||
public function actionSale($number = null) {
|
||||
@@ -156,100 +158,86 @@ class ProductController extends Controller {
|
||||
}
|
||||
}
|
||||
public function actionPayoutUserCart() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
// $result = [ ];
|
||||
// \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
$model = new UserCartPayoutForm ();
|
||||
$user = User::findOne ( Yii::$app->user->id );
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->validate () && isset ( $user ) && count ( $model->transfers ) > 0) {
|
||||
|
||||
// $user = User::findOne ( Yii::$app->user->id );
|
||||
// UserSoldItem::payout ( $user );
|
||||
|
||||
// $userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
|
||||
// $result ['transfers'] = $userTransfers;
|
||||
// $result ['code'] = 'success';
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
$model = new UserCartPayoutForm ();
|
||||
$user = User::findOne ( Yii::$app->user->id );
|
||||
|
||||
if ( $model->load ( Yii::$app->request->post () ) && $model->validate () &&isset ( $user ) && count ( $model->transfers ) > 0) {
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
$tp = new TransferPayout ( [
|
||||
'idUser' => \Yii::$app->user->id,
|
||||
'idTransfers' => $model->transfers,
|
||||
'cartType' => 'user',
|
||||
'idAccount' => Account::readDefault ()
|
||||
] );
|
||||
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
UserSoldItem::payout ( $user, $model->transfers );
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', 'Recepicó kosár fizetve' );
|
||||
} catch ( Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
}
|
||||
} else {
|
||||
Yii::error ( "faled to save : transfer" );
|
||||
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||
$tp->payout ();
|
||||
|
||||
// UserSoldItem::payout ( $user, $model->transfers );
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', 'Recepicó kosár fizetve' );
|
||||
} catch ( Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
} catch ( \Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
}
|
||||
} else {
|
||||
Yii::error ( "faled to save : transfer" );
|
||||
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||
}
|
||||
|
||||
return $this->redirect ( Yii::$app->request->referrer );
|
||||
}
|
||||
|
||||
|
||||
public function actionPayoutCustomerCart($number) {
|
||||
$cart = [ ];
|
||||
$code = 'error';
|
||||
$message = 'Hiba történt';
|
||||
|
||||
if (Yii::$app->request->isAjax) {
|
||||
$result = [ ];
|
||||
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
||||
// post
|
||||
$model = new CustomerCartPayoutForm ();
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||
|
||||
$this->findByNumber ( $number );
|
||||
|
||||
if (isset ( $this->customer )) {
|
||||
if (isset ( $this->customer ) && count ( $model->transfers ) > 0) {
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
ShoppingCart::payout ( $this->customer );
|
||||
$tp = new TransferPayout ( [
|
||||
'idUser' => \Yii::$app->user->id,
|
||||
'idTransfers' => $model->transfers,
|
||||
'cartType' => 'customer',
|
||||
'idAccount' => Account::readDefault (),
|
||||
'idCustomer' => $this->customer->id_customer
|
||||
] );
|
||||
|
||||
$tp->payout ();
|
||||
|
||||
// UserSoldItem::payout ( $user, $model->transfers );
|
||||
$transaction->commit ();
|
||||
$cart = Transfer::modelsToArray ( Transfer::readCustomerCart ( $this->customer ) );
|
||||
$code = 'success';
|
||||
$message = 'Bevásárlókosár fizetve: ' . $this->card->number;
|
||||
\Yii::$app->session->setFlash ( 'success', 'Vendég kosár fizetve : ' . $this->customer->name );
|
||||
} catch ( Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
} catch ( \Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
}
|
||||
} else {
|
||||
Yii::error ( "faled to save : no customer or transfer" );
|
||||
\Yii::$app->session->setFlash ( 'warning', 'Nem történt kifizetés' );
|
||||
}
|
||||
$result ['customer_cart'] = $cart;
|
||||
$result ['code'] = $code;
|
||||
$result ['message'] = $message;
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
// post
|
||||
$model = new CustomerCartPayoutForm ();
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||
|
||||
$this->findByNumber ( $number );
|
||||
|
||||
if (isset ( $this->customer ) && count ( $model->transfers ) > 0) {
|
||||
$connection = \Yii::$app->db;
|
||||
$transaction = $connection->beginTransaction ();
|
||||
try {
|
||||
ShoppingCart::payout ( $this->customer, $model->transfers , Account::readDefault());
|
||||
$transaction->commit ();
|
||||
\Yii::$app->session->setFlash ( 'success', 'Vendég kosár kifizetve' );
|
||||
} catch ( Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
\Yii::$app->session->setFlash ( 'danger', 'Hiba történt a mentés során' );
|
||||
}
|
||||
} else {
|
||||
Yii::error ( "faled to save : no customer or transfer" );
|
||||
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||
}
|
||||
}else{
|
||||
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||
}
|
||||
return $this->redirect ( Yii::$app->request->referrer );
|
||||
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
|
||||
}
|
||||
return $this->redirect ( Yii::$app->request->referrer );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,102 +267,84 @@ class ProductController extends Controller {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionInventory( ) {
|
||||
public function actionInventory() {
|
||||
$searchModel = new ProductInventorySearch ( [
|
||||
'account' => Account::readDefaultObject ()
|
||||
] );
|
||||
|
||||
$searchModel = new ProductInventorySearch(
|
||||
['account' => Account::readDefaultObject()]
|
||||
);
|
||||
// $searchModel->search(\Yii::$app->request->params);
|
||||
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||
|
||||
// $searchModel->search(\Yii::$app->request->params);
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
// $inventory = new ProductInventory([
|
||||
// ]);
|
||||
// if ( $output == 'xls'){
|
||||
// $inventory->pagination = false;
|
||||
// }
|
||||
|
||||
// $inventory->createDataProvider();
|
||||
// $dp = $inventory->dataProvider;
|
||||
|
||||
// $inventory = new ProductInventory([
|
||||
// ]);
|
||||
// if ( $output == 'xls'){
|
||||
// $inventory->pagination = false;
|
||||
// }
|
||||
|
||||
// $inventory->createDataProvider();
|
||||
// $dp = $inventory->dataProvider;
|
||||
|
||||
if ( $searchModel->output == 'xls' ){
|
||||
|
||||
$models = $dataProvider->getModels();
|
||||
$objPHPExcel = new \PHPExcel();
|
||||
|
||||
$sheet = $objPHPExcel->setActiveSheetIndex(0);
|
||||
/**
|
||||
*
|
||||
Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
|
||||
* */
|
||||
if ($searchModel->output == 'xls') {
|
||||
|
||||
$models = $dataProvider->getModels ();
|
||||
$objPHPExcel = new \PHPExcel ();
|
||||
|
||||
$sheet = $objPHPExcel->setActiveSheetIndex ( 0 );
|
||||
/**
|
||||
* Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
|
||||
*/
|
||||
$row = 1;
|
||||
$sheet
|
||||
->setCellValue('A'.$row, "Termék azonosító")
|
||||
->setCellValue('B'.$row, "Termék név")
|
||||
->setCellValue('C'.$row, "Termék szám")
|
||||
->setCellValue('D'.$row, "Termék vonalkód")
|
||||
->setCellValue('E'.$row, "Termék raktáron");
|
||||
// ->setCellValue('F'.$row, "Eladott mennyiség");
|
||||
|
||||
foreach ($models as $model ){
|
||||
$row++;
|
||||
$sheet->setCellValue('A'.$row, $model['product_id'])
|
||||
->setCellValue('B'.$row, $model['product_name'])
|
||||
->setCellValue('C'.$row, $model['product_number'])
|
||||
->setCellValue('D'.$row, $model['product_barcode'])
|
||||
->setCellValue('E'.$row, $model['product_stock']);
|
||||
// ->setCellValue('F'.$row, $model['product_sold']);
|
||||
$sheet->setCellValue ( 'A' . $row, "Termék azonosító" )->setCellValue ( 'B' . $row, "Termék név" )->setCellValue ( 'C' . $row, "Termék szám" )->setCellValue ( 'D' . $row, "Termék vonalkód" )->setCellValue ( 'E' . $row, "Termék raktáron" );
|
||||
// ->setCellValue('F'.$row, "Eladott mennyiség");
|
||||
|
||||
foreach ( $models as $model ) {
|
||||
$row ++;
|
||||
$sheet->setCellValue ( 'A' . $row, $model ['product_id'] )->setCellValue ( 'B' . $row, $model ['product_name'] )->setCellValue ( 'C' . $row, $model ['product_number'] )->setCellValue ( 'D' . $row, $model ['product_barcode'] )->setCellValue ( 'E' . $row, $model ['product_stock'] );
|
||||
// ->setCellValue('F'.$row, $model['product_sold']);
|
||||
}
|
||||
|
||||
$styleArray = array(
|
||||
'font' => array(
|
||||
'bold' => true,
|
||||
// 'color' => array('rgb' => 'FF0000'),
|
||||
// 'size' => 15,
|
||||
// 'name' => 'Verdana'
|
||||
));
|
||||
$styleArray = array (
|
||||
'font' => array (
|
||||
'bold' => true
|
||||
)
|
||||
);
|
||||
// 'color' => array('rgb' => 'FF0000'),
|
||||
// 'size' => 15,
|
||||
// 'name' => 'Verdana'
|
||||
|
||||
foreach(range('A','E') as $columnID)
|
||||
{
|
||||
$sheet->getColumnDimension($columnID)->setAutoSize(true);
|
||||
$sheet->getStyle($columnID.'1')->applyFromArray($styleArray);
|
||||
|
||||
|
||||
foreach ( range ( 'A', 'E' ) as $columnID ) {
|
||||
$sheet->getColumnDimension ( $columnID )->setAutoSize ( true );
|
||||
$sheet->getStyle ( $columnID . '1' )->applyFromArray ( $styleArray );
|
||||
}
|
||||
|
||||
|
||||
// Redirect output to a client’s web browser (Excel5)
|
||||
header('Content-Type: application/vnd.ms-excel');
|
||||
header('Content-Disposition: attachment;filename="leltar.xls"');
|
||||
header('Cache-Control: max-age=0');
|
||||
header ( 'Content-Type: application/vnd.ms-excel' );
|
||||
header ( 'Content-Disposition: attachment;filename="leltar.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');
|
||||
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;
|
||||
|
||||
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('inventory',[ 'searchModel' =>$searchModel, 'dataProvider' => $dataProvider]);
|
||||
return $this->render ( 'inventory', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Finds the Product model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
*
|
||||
*
|
||||
* @param integer $id
|
||||
* @return Product the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
@@ -398,12 +368,10 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lists all Product models.
|
||||
*
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
@@ -420,7 +388,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
|
||||
*/
|
||||
/**
|
||||
* Displays a single Product model.
|
||||
*
|
||||
*
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -435,7 +403,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
|
||||
/**
|
||||
* Updates an existing Product model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
*
|
||||
*
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -456,7 +424,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
|
||||
/**
|
||||
* Deletes an existing Product model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
*
|
||||
*
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -471,7 +439,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
|
||||
/**
|
||||
* Creates a new Product model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
*
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user