Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplification of display on the store #64

Open
wants to merge 45 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5de32bb
New design
nivcoo Nov 29, 2018
9fe60a3
New design
nivcoo Nov 29, 2018
40b190c
Remove useless function
nivcoo Nov 30, 2018
9ff3e1a
Up version
nivcoo Dec 3, 2018
8ef9565
Fix. Table name
nivcoo Jan 2, 2019
efd65ee
Fix decimal prices error
plagoutte Dec 23, 2018
5d8cfc0
Update DiscountVoucherComponent.php
Eywek Mar 3, 2019
85da2e3
Update DiscountVoucherComponent.php
Eywek Mar 3, 2019
30a006c
Update DiscountVoucherComponent.php
Eywek Mar 3, 2019
02e8b32
Update config.json
Eywek Mar 3, 2019
1ef8e63
Add Event onBuyMoney (Dedipass and Paypal only)
Maathis Apr 9, 2019
2c24c45
feat. Best Donator
nivcoo Apr 27, 2019
057175c
feat. Best Donator
nivcoo Apr 28, 2019
613dae0
add Nano
Javdu10 Oct 31, 2019
297461e
add Brainblocks
Javdu10 Oct 31, 2019
0616530
fix NanoHistory
Javdu10 Oct 31, 2019
1b8ff95
update token schema + money view + ajax result for verif_brainblocks
Javdu10 Oct 31, 2019
22a359b
fix shop button for mobile + Currency display
Javdu10 Oct 31, 2019
4599ac6
verify nano address format
Javdu10 Oct 31, 2019
e74e584
fix nano_histories + Lang + logo
Javdu10 Oct 31, 2019
59681d9
bumping version
Javdu10 Oct 31, 2019
bedf4b5
format
Javdu10 Nov 1, 2019
cff65a9
show ajax-msg
Javdu10 Nov 1, 2019
e7624b5
add a "Getting Started"
Javdu10 Nov 1, 2019
3751ef0
fix brainblocks duplication button
Javdu10 Nov 1, 2019
efd0701
change points without reloading the page
Javdu10 Nov 2, 2019
9bba6b4
fix: nano payment
Javdu10 Nov 13, 2019
284d949
Create ru_RU.json (#47)
stashenko Nov 23, 2019
9b5eebd
Update config.json
Eywek Nov 23, 2019
1a966d5
improv. error 500 without id (#44)
nivcoo Dec 30, 2019
071159d
improv. error 200 failed ipn (#48)
nivcoo Dec 30, 2019
6c1a7a6
Update config.json
Eywek Dec 30, 2019
718eb52
improv. error when reduction was big (#50)
nivcoo Jan 28, 2020
3552b6f
Update config.json
Eywek Jan 28, 2020
b29d077
fix: security issue
Eywek Jul 12, 2020
abde4b7
chore: release 1.2.21
Eywek Jul 12, 2020
2cd91ca
Add Section and sub-categories, new design and duplicate button (#39)
nivcoo Dec 18, 2020
0e5ca51
improv. remove useless code (#62)
nivcoo Dec 23, 2020
175603f
improv. up to adminlte3 (#61)
nivcoo Dec 23, 2020
c9a8d04
improv. fix wrong condition (#63)
nivcoo Dec 24, 2020
9e699ea
Update config.json
Eywek Dec 24, 2020
d40ffe9
Added translation of missing remarks (#66)
SampProject-game Aug 28, 2021
d9796be
Improving Russian translation (#67)
bloodsbro Aug 28, 2021
5ddcb77
improv. fix issue with jquery 3.6.0 (#70)
Sytorex Jul 13, 2022
0a9798a
bump. up to 1.3.3
nivcoo Jul 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 242 additions & 0 deletions Controller/CategoriesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
<?php

class CategoriesController extends ShopAppController
{

public function admin_index()
{
if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) {
$this->set('title_for_layout', $this->Lang->get('SHOP__TITLE'));
$this->layout = 'admin';
$this->loadModel('Shop.Section');
$search_sections = $this->Section->find('all');
$this->loadModel('Shop.Category');
$this->loadModel('Shop.Item');
$search_categories = $this->Category->find('all', array('conditions' => array('section' => 1)));
$i = 0;
if (!empty($search_categories)) foreach ($search_categories as $v) {
if (!$this->Section->find('first', array('conditions' => array('id' => $v['Category']['section_id'])))) {
$search_categories_other[$i] = $this->Category->find('all', array('conditions' => array('id' => $v['Category']['id'])));
if (!empty($search_categories_other)) foreach ($search_categories_other as $value) {
$categories_count_other[$value[0]['Category']['id']] = $this->Item->find('count', array('conditions' => array('category' => $value[0]['Category']['id'])));
}
}
$i++;
}
$this->loadModel('Shop.Item');
$search_categories_no = $this->Category->find('all', array('conditions' => array('section' => 0),'order' => 'order'));
if (!empty($search_categories_no)) foreach ($search_categories_no as $v) {
$categories_count[$v['Category']['id']] = $this->Item->find('count', array('conditions' => array('category' => $v['Category']['id'])));
}
if (!empty($search_sections)) foreach ($search_sections as $va) {
$search_categories[$va["Section"]["id"]] = $this->Category->find('all', array('conditions' => array('section_id' => $va['Section']['id'], 'section' => 1),'order' => 'order'));
if (!empty($search_categories[$va["Section"]["id"]])) foreach ($search_categories[$va["Section"]["id"]] as $v) {
$categories_count[$v['Category']['id']] = $this->Item->find('count', array('conditions' => array('category' => $v['Category']['id'])));
}
}
$this->set(compact('search_categories', 'categories_count', 'search_sections', 'search_categories_other', 'categories_count_other', 'search_categories_no'));

} else {
$this->redirect('/');
}
}


public function admin_edit($id = false)
{
if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) {

$this->layout = 'admin';
$this->set('title_for_layout', $this->Lang->get('SHOP__CATEGORY_EDIT'));
$this->loadModel('Shop.Category');
$category = $this->Category->find('first', array('conditions' => array('id' => $id)));
$this->loadModel('Shop.Section');
$this->loadModel('Shop.Item');
$search_sections = $this->Section->find('all');
if (!empty($search_categories)) foreach ($search_categories as $v) {
$categories_count[$v['Category']['id']] = $this->Item->find('count', array('conditions' => array('category' => $v['Category']['id'])));
}
$this->set(compact('category', 'search_sections'));

if ($this->request->is('post')) {
$section = !$this->request->data['section'] || !empty($this->request->data['section_id']);
if (!empty($this->request->data['name']) AND $section) {

if (!$this->request->data['section']) $this->request->data['section_id'] = 0;

$this->Category->read(null, $id);
$this->Category->set(array(
'name' => $this->request->data['name'],
'section' => $this->request->data['section'],
'section_id' => $this->request->data['section_id']
));
$this->History->set('ADD_CATEGORY', 'shop');
$this->Category->save();
$this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_EDIT_SUCCESS'), 'default.success');
$this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true));

} else {
$this->Session->setFlash($this->Lang->get('ERROR__FILL_ALL_FIELDS'), 'default.error');
}
}
} else {
$this->redirect('/');
}
}

public function admin_edit_section()
{
$this->autoRender = false;
$this->response->type('json');
if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) {
if ($this->request->is('post')) {
if (!empty($this->request->data['name'])) {
$this->loadModel('Shop.Section');
$this->Section->read(null, $this->request->data['id']);
$this->Section->set(array(
'name' => $this->request->data['name'],
));
$this->Section->save();
$this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__SECTION_EDIT_SUCCESS'))));
} else {
$this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
}
} else {
$this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
}
} else {
throw new ForbiddenException();
}
}


public function admin_save_ajax()
{
$this->autoRender = false;
$this->response->type('json');
if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) {

if ($this->request->is('post')) {
if (!empty($this->request->data)) {
$data = $this->request->data['shop_item_order'];
$data = explode('&', $data);
$i = 1;
foreach ($data as $key => $value) {
$data2[] = explode('=', $value);
$data3 = substr($data2[0][0], 0, -2);
$data1[$data3] = $i;
unset($data3);
unset($data2);
$i++;
}
$data = $data1;
$this->loadModel('Shop.Category');
foreach ($data as $key => $value) {
$find = $this->Category->find('first', array('conditions' => array('id' => $key)));
if (!empty($find)) {
$id = $find['Category']['id'];
$this->Category->read(null, $id);
$this->Category->set(array(
'order' => $value,
));
$this->Category->save();
} else {
$error = 1;
}
}
if (empty($error)) {
return $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__SAVE_SUCCESS'))));
} else{
return $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
}
} else {
return $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))));
}
} else {
return $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))));
}
} else {
$this->redirect('/');
}
}

/*
* ======== Ajout d'une catégorie (affichage & traitement POST) ===========
*/

public function admin_add_category($section_id = null)
{
if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) {

$this->layout = 'admin';
$this->set('title_for_layout', $this->Lang->get('SHOP__CATEGORY_ADD'));
$this->loadModel('Shop.Section');
$search_sections = $this->Section->find('all');
$this->set(compact('search_sections', 'section_id'));

if ($this->request->is('post')) {
$section = !$this->request->data['section'] || !empty($this->request->data['section_id']);
if (!empty($this->request->data['name']) AND $section) {

$this->loadModel('Shop.Category');
if (!$this->request->data['section']) $this->request->data['section_id'] = 0;

$this->Category->read(null, null);
$this->Category->set(array(
'name' => $this->request->data['name'],
'section' => $this->request->data['section'],
'section_id' => $this->request->data['section_id']
));
$this->History->set('ADD_CATEGORY', 'shop');
$this->Category->save();
$this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_ADD_SUCCESS'), 'default.success');
$this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true));

} else {
$this->Session->setFlash($this->Lang->get('ERROR__FILL_ALL_FIELDS'), 'default.error');
}
}
} else {
$this->redirect('/');
}
}

/*
* ======== Ajout d'une catégorie (affichage & traitement POST) ===========
*/

public function admin_add_section()
{
if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_CATEGORIES')) {

$this->layout = 'admin';
$this->set('title_for_layout', $this->Lang->get('SHOP__CATEGORY_ADD'));
if ($this->request->is('post')) {
if (!empty($this->request->data['name'])) {
$this->loadModel('Shop.Section');

$event = new CakeEvent('beforeAddCategory', $this, array('section' => $this->request->data['name'], 'user' => $this->User->getAllFromCurrentUser()));
$this->getEventManager()->dispatch($event);
if ($event->isStopped()) {
return $event->result;
}

$this->Section->read(null, null);
$this->Section->set(array(
'name' => $this->request->data['name']
));
$this->History->set('ADD_SECTION', 'shop');
$this->Section->save();
$this->Session->setFlash($this->Lang->get('SHOP__SECTION_ADD_SUCCESS'), 'default.success');
$this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true));
} else {
$this->Session->setFlash($this->Lang->get('ERROR__FILL_ALL_FIELDS'), 'default.error');
}
}
} else {
$this->redirect('/');
}
}


}
11 changes: 7 additions & 4 deletions Controller/Component/DiscountVoucherComponent.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?php

class DiscountVoucherComponent extends Object
if (file_exists(ROOT . DS . 'lib' . DS . 'Cake' . DS . 'Core' . DS . 'CakeObject.php')) {
App::uses('CakeObject', 'Core');
} else {
class CakeObject extends Object {}
}
class DiscountVoucherComponent extends CakeObject
{

static private $items;
Expand Down Expand Up @@ -178,7 +182,7 @@ private function canUse($voucher)
return false;
}

function getNewPrice($item_id, $code)
function getNewPrice($item_id, $itemPrice, $code)
{ // donne le nouveau prix de l'item si il est concerné par une réduction
$this->Voucher = ClassRegistry::init('Shop.Voucher');
$findVoucher = $this->Voucher->find('first', array('conditions' => array('code' => $code)));
Expand All @@ -196,7 +200,6 @@ function getNewPrice($item_id, $code)
return array('status' => false, 'error' => 3); // on trouve pas l'article
}

$itemPrice = $findItem['Item']['price'];
$itemCategoryID = $findItem['Item']['category'];

// On prépare le prix si pas de modifications
Expand Down
4 changes: 2 additions & 2 deletions Controller/GiftallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function admin_index()

$db = ConnectionManager::getDataSource('default');
$number = $db->value($number, 'integer');
$db->query("UPDATE Users SET money = money + $number");
$db->query("UPDATE users SET money = money + $number");

$this->History->set("GIFTALL_$number", "shop");

Expand All @@ -31,4 +31,4 @@ public function admin_index()
throw new ForbiddenException();
}
}
}
}
Loading