Fix hide reception cart

- add property user_cart_on
- add property product_sale_default_focus
- add property ticket_create-price_editable
- add discount product/ticket enabled
This commit is contained in:
Roland Schneider 2016-02-28 15:48:30 +01:00
parent b476febb10
commit 2e3a8d53ca
18 changed files with 175 additions and 143 deletions

View File

@ -66,7 +66,7 @@ class AdminMenuStructure{
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
$items[] = ['label' => 'Kulcsok', 'url' =>['/key/index']];
// $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
$this->menuItems[] = ['label' => 'Törszadatok', 'url' =>$this->emptyUrl,
$this->menuItems[] = ['label' => 'Törzsadatok', 'url' =>$this->emptyUrl,
'items' => $items
];

View File

@ -19,9 +19,12 @@ use common\models\Discount;
<?= $form->field($model, 'type')->dropDownList(Discount::types()) ?>
<?= $form->field($model, 'value')->textInput() ?>
<?= $form->field($model, 'product_enabled')->checkbox() ?>
<?= $form->field($model, 'ticket_enabled')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/discount', 'Create') : Yii::t('common/discount', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

View File

@ -33,8 +33,17 @@ $this->params['breadcrumbs'][] = $this->title;
[
'attribute' => 'type',
'value' => 'typeHuman',
],
[
'attribute' => 'ticket_enabled',
'value' => 'ticketEnabledHuman',
],
[
'attribute' => 'product_enabled',
'value' => 'procutEnabledHuman',
],
'value',
'created_at:datetime',
'updated_at:datetime',

View File

@ -34,6 +34,14 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'type',
'value' => $model->typeHuman
],
[
'attribute' => 'product_enabled',
'value' => $model->getProcutEnabledHuman()
],
[
'attribute' => 'ticket_enabled',
'value' => $model->getTicketEnabledHuman()
],
// 'status',
// 'type',
'value',

View File

@ -1,3 +1,8 @@
-0.0.42
- add property user_cart_on
- add property product_sale_default_focus
- add property ticket_create_price_editable
- add discount visibility for ticket/product
-0.0.42
- add detsta import improvements
- add procurement/create-product , translations, redirects

View File

@ -278,6 +278,13 @@ class Helper {
return \Yii::$app->params ['company'] == 'movar';
}
public static function isUserCartOn() {
return \Yii::$app->params ['user_cart_on'] == true;
}
public static function getProductSaleDefaultFocus() {
return \Yii::$app->params ['product_sale_default_focus'] ;
}
public static function isProductVisibilityAccount() {
return \Yii::$app->params ['product_visiblity'] == 'account';
}
@ -298,6 +305,11 @@ class Helper {
return \Yii::$app->params ['reception_visibility_days'] ;
}
public static function isTicketCreatePriceEditable() {
return \Yii::$app->params ['ticket_create_price_editable'] == true ;
}
public static function getRealUserIp() {
$client = @$_SERVER ['HTTP_CLIENT_IP'];
$forward = @$_SERVER ['HTTP_X_FORWARDED_FOR'];

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.42',
'version' => 'v0.0.43',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
@ -30,12 +30,17 @@ return [
* */
'reception_visibility_days' => 3,
'backend_skin' => 'skin-red', //skin-green
/**User cart module on/off*/
'user_cart_on' => true,
/**
* if products in carts are visible for everyone or only for the user
* possible values :
* - user: a felhasználó csak azokat a termékeket látja a kosrába, amiket ő rakott bele
* - global: a felhasználó minden kosrában lévő terméket lát, még azokat is , amiket nem ő rakott bele
*
**/
* a termék eladás oldalon hol legyen az alaéprtelmezett focus
* a vonalkód mezőn vagy az autocomplete mezőn
barcode | autocomplete */
'product_sale_default_focus' => 'barcode',
/**
* Bérlet eladásnál módosítható e az ár
* */
'ticket_create_price_editable' => true,
];

View File

@ -14,6 +14,8 @@ use yii\helpers\ArrayHelper;
* @property integer $status
* @property integer $type
* @property integer $value
* @property integer $product_enabled
* @property integer $ticket_enabled
* @property string $created_at
* @property string $updated_at
*/
@ -51,7 +53,7 @@ class Discount extends \yii\db\ActiveRecord
{
return [
[['name','value'], 'required'],
[['status', 'type', 'value'], 'integer'],
[['status', 'type', 'value','product_enabled','ticket_enabled'], 'integer'],
[['name'], 'string', 'max' => 64]
];
}
@ -69,6 +71,8 @@ class Discount extends \yii\db\ActiveRecord
'value' => Yii::t('common/discount', 'Value'),
'created_at' => Yii::t('common/discount', 'Created At'),
'updated_at' => Yii::t('common/discount', 'Updated At'),
'product_enabled' => "Termékre adható",
'ticket_enabled' => "Bérletre adható",
];
}
@ -104,10 +108,28 @@ class Discount extends \yii\db\ActiveRecord
return $result;
}
public function getProcutEnabledHuman(){
return $this->product_enabled == 1 ? 'Igen' : 'Nem';
}
public function getTicketEnabledHuman(){
return $this->ticket_enabled == 1 ? 'Igen' : 'Nem';
}
public static function read(){
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE ])->all();
}
public static function readProductDiscounts(){
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'product_enabled' => 1 ])->all();
}
public static function readTicketDiscounts(){
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'ticket_enabled' => 1 ])->all();
}
/**
* @param integer $money
* @param common\models\Discount $discount

View File

@ -0,0 +1,33 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160228_111209_alter__table__discount__add__columns__product_on__ticket__on extends Migration
{
public function up()
{
$this->addColumn("discount", "product_enabled", "int default 0");
$this->addColumn("discount", "ticket_enabled", "int default 0");
$this->execute("update discount set product_enabled = 1 , ticket_enabled = 1;");
}
public function down()
{
echo "m160228_111209_alter__table__discount__add__columns__product_on__ticket__on cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -95,7 +95,7 @@ class ProductController extends Controller {
$accounts = Account::read ();
$discounts = Discount::read ();
$discounts = Discount::readProductDiscounts();
$user = User::findOne ( Yii::$app->user->id );

View File

@ -104,7 +104,7 @@ class TicketController extends FrontendController
$model = new TicketCreate();
$discounts = Discount::read();
$discounts = Discount::readTicketDiscounts();
$ticketTypes = TicketType::read(null, null);

View File

@ -20,7 +20,7 @@ use common\models\Discount;
$types = TicketType::findAll(['status' => TicketType::STATUS_ACTIVE ,'installment_enabled' => '1']);
$types = HtmlHelper::mkTicketTypeOptions($types);
$discounts = Discount::read();
$discounts = Discount::readTicketDiscounts();
$discounts = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts);
?>

View File

@ -3,6 +3,7 @@ use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Transfer;
use common\components\Helper;
/* @var $this yii\web\View */
/* @var $model frontend\models\ProductSaleForm */
@ -110,7 +111,9 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
<?php echo Html::a(Yii::t("frontend/product","Sell"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
</div>
<div class='col-md-4'>
<?php if ( Helper::isUserCartOn()){ ?>
<?php echo Html::a(Yii::t("frontend/product","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_sell_append'] );?>
<?php }?>
</div>
<div class='col-md-4'>
<?php

View File

@ -7,6 +7,7 @@ use frontend\components\ReceptionWidget;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use common\components\Helper;
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
@ -30,6 +31,9 @@ if ( isset($model->card) ){
$options['discounts'] = Discount::modelsToArray($discounts);
$options['id_account'] = Account::readDefault();
$options['product_sale_default_focus'] = Helper::getProductSaleDefaultFocus();
$options['user_cart_on'] = Helper::isUserCartOn();
$this->registerJs ( 'new ProductSell( '. json_encode($options).');' );
@ -97,7 +101,9 @@ $this->params['breadcrumbs'][] = Yii::t('frontend/product', 'Sale');
<?php if ( $receptionForm->isCardWithCustomer() ){ ?>
<?php echo $this->render('_customer_cart' , ['model' => $model]) ?>
<?php }?>
<?php if ( Helper::isUserCartOn()) {?>
<?php echo $this->render('_user_cart' ) ?>
<?php }?>
</div>
</div>

View File

@ -6,6 +6,7 @@ use frontend\components\HtmlHelper;
use kartik\widgets\DatePicker;
use common\models\Account;
use common\models\Transfer;
use common\components\Helper;
/* @var $this yii\web\View */
/* @var $model common\models\Ticket */
@ -65,7 +66,15 @@ use common\models\Transfer;
<?= $form->field($model, 'max_usage_count')->input('number') ?>
<?= $form->field($model, 'price_brutto')->input('number') ?>
<?php
if ( Helper::isTicketCreatePriceEditable()){
echo $form->field($model, 'price_brutto')->input('number' );
}else{
echo $form->field($model, 'price_brutto')->input('number' ,['readonly' => true] );
}
?>
<?= $form->field($model, 'comment')->textarea(['maxlength' => true]) ?>
@ -74,7 +83,12 @@ use common\models\Transfer;
<?php echo Html::a(Yii::t("frontend/ticket","Fizetve"),null,['class' => 'btn btn-danger btn-block', 'id' => 'btn_sell'] );?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/ticket","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] );?>
<?php
if ( Helper::isUserCartOn()){
echo Html::a(Yii::t("frontend/ticket","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_user_cart'] );
}
?>
</div>
<div class='col-md-4'>
<?php

View File

@ -7,6 +7,7 @@ use frontend\assets\TicketSellAsset;
use common\models\TicketType;
use yii\helpers\Url;
use frontend\components\ReceptionWidget;
use common\components\Helper;
/* @var $this yii\web\View */
@ -68,7 +69,11 @@ $this->registerJs ( 'new TicketSell( '. json_encode($options).');' );
<?php if ( $receptionForm->isCardWithCustomer() ){ ?>
<?php echo $this->render('_customer_cart' ,['model' => $receptionForm]) ?>
<?php }?>
<?php echo $this->render('_user_cart' ) ?>
<?php
if ( Helper::isUserCartOn() ) {
echo $this->render('_user_cart' ) ;
}
?>
</div>
</div>
</div>

View File

@ -34,6 +34,12 @@ function ProductSell(o){
url_pay_transaction : '',
value_number: '',
name_number: '',
user_cart_on: true,
//if enter pressed in count field, what to submet: 'paid' or 'add_to_user_cart' action
product_count_enter_action: 'user_cart',
//barcode or autocomplete
product_sale_default_focus: 'barcode',
};
@ -53,10 +59,7 @@ function ProductSell(o){
createCarts();
addPayoutButtons();
productChanged();
// addDocumentKeypressedListener();
initAutocomplete();
disalbeMousewheelSpinOnNumberInput();
@ -68,13 +71,6 @@ function ProductSell(o){
});
}
/**
* payout out user or customer cart
* */
function addPayoutButtons(){
// addBehaviourPayoutUserCart();
// addBehaviourPayoutCustomerCart();
}
/**
* display user and customer cart on page load
* */
@ -111,41 +107,6 @@ function ProductSell(o){
$("#productsaleform-id_discount").change(refreshCalculatedValues);
}
function addDocumentKeypressedListener(){
$( document ).keypress(function( event ) {
var tag = event.target.tagName.toLowerCase();
if ( tag != 'input' && tag != 'textarea') {
resetSequenceIfToMuchTimePassedOrEnterWasPressed(event);
if ( event.which == 13 ) {
app.enterPressed = 1;
$( document ).trigger( "wordtyped", [ { originalEvent: event, 'word': app.seq } ] );
}else {
appendCharToSeq(event);
}
}
});
$( document ).on( "wordtyped", function( event, data ) {
var word;
word = data.word;
if ( word.length > 0){
if ( word.length >= 6 && word.length <= 9 ){
//lookupuser
}else{
$("#filter_text").val(data.word);
_lookupProduct(data.word);
}
}
});
}
function resetSequenceIfToMuchTimePassedOrEnterWasPressed(){
var prevDate, timePassed;
prevDate= app.keyDate;
@ -181,7 +142,11 @@ function ProductSell(o){
* set the focus for text input #filter_text
* */
function setFocus(){
if ( app.defaults.product_sale_default_focus == 'barcode'){
$("#filter_text").focus();
}else{
$("#product_search").focus();
}
}
@ -210,7 +175,18 @@ function ProductSell(o){
if ( event.which == 13 ) {
event.preventDefault();
event.stopImmediatePropagation();
if ( app.defaults.user_cart_on ){
if ( app.defaults.product_count_enter_action == 'user_cart'){
submitSellAndAppend();
}else{
submitSell();
}
}else{
submitSell();
}
}
});
}
@ -445,44 +421,6 @@ function ProductSell(o){
$(app.defaults.selector_customer_cart ).transferList( 'option', 'transfers' , app.defaults.customer_cart );
}
function addBehaviourPayoutUserCart( ){
$( app.defaults.selector_btn_pay_user_cart ).on('click',function(){
$.ajax({
url: app.defaults.url_pay_user_cart,
type: 'post',
data: {},
success: function (response) {
if ( response.code == 'success'){
app.defaults.user_cart = response.transfers;
refreshUserCart();
$.notify(app.defaults.message_paid, { 'type' : 'success' });
}
}
}
);
});
}
function addBehaviourPayoutCustomerCart( ){
$( app.defaults.selector_btn_pay_customer_cart ).on('click',function(){
$.ajax({
url: app.defaults.url_pay_customer_card,
type: 'post',
data: {},
success: function (response) {
if ( response.code == 'success'){
app.defaults.customer_cart = response.customer_cart;
refreshCustomerCart();
}
$.notify(response.message, { 'type' : response.code });
},
error: function(){
alert('Hiba történt');
}
}
);
});
}
function createUserCartTable(){
$(app.defaults.selector_user_cart).transferList({

View File

@ -50,6 +50,8 @@ function TicketSell(o){
url_pay_transaction: '',
discounts : [],
discount: null,
//if user cart module is on or off
user_cart_on: true
};
@ -61,7 +63,7 @@ function TicketSell(o){
addBehaviourDiscountChangedListener();
useDefaults();
createCarts();
addPayoutButtons();
// addPayoutButtons();
addSellButtons();
// addBehaviourBtnCartPaid();
}
@ -82,16 +84,19 @@ function TicketSell(o){
/**
* payout out user or customer cart
* */
/*
function addPayoutButtons(){
// addBehaviourPayoutUserCart();
// addBehaviourPayoutCustomerCart();
}
*/
/**
* display user and customer cart on page load
* */
function createCarts(){
if ( app.defaults.user_cart_on ){
createUserCartTable();
}
createCustomerCartTable();
}
@ -117,7 +122,9 @@ function TicketSell(o){
}
function addSellButtons(){
if ( app.defaults.user_cart_on ){
addBehaviourBtnSellAndAppendToUserCart();
}
addBehaviourBtnAddToCustomerCart();
addBehaviourBtnSell();
}
@ -148,44 +155,6 @@ function TicketSell(o){
$('#btn_sell').on('click',submitSell);
}
function addBehaviourPayoutUserCart( ){
// $( app.defaults.selector_btn_pay_user_cart ).on('click',function(){
//
// $.ajax({
// url: app.defaults.url_pay_user_cart,
// type: 'post',
// data: {},
// success: function (response) {
// if ( response.code == 'success'){
// app.defaults.user_cart = response.transfers;
// refreshUserCart();
// $.notify(app.defaults.message_paid, { 'type' : 'success' });
// }
// }
// }
// );
// });
}
function addBehaviourPayoutCustomerCart( ){
// $( app.defaults.selector_btn_pay_customer_cart ).on('click',function(){
// $.ajax({
// url: app.defaults.url_pay_customer_card,
// type: 'post',
// data: {},
// success: function (response) {
// if ( response.code == 'success'){
// app.defaults.customer_cart = response.customer_cart;
// refreshCustomerCart();
// }
// $.notify(response.message, { 'type' : response.code });
// },
// error: function(){
// alert('Hiba történt');
// }
// }
// );
// });
}
function addBehaviourTypeChangedListener(){