diff --git a/Controller/CategoriesController.php b/Controller/CategoriesController.php new file mode 100644 index 0000000..0935ffa --- /dev/null +++ b/Controller/CategoriesController.php @@ -0,0 +1,242 @@ +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('/'); + } + } + + +} diff --git a/Controller/Component/DiscountVoucherComponent.php b/Controller/Component/DiscountVoucherComponent.php index 344befe..1a88e27 100755 --- a/Controller/Component/DiscountVoucherComponent.php +++ b/Controller/Component/DiscountVoucherComponent.php @@ -1,6 +1,10 @@ Voucher = ClassRegistry::init('Shop.Voucher'); $findVoucher = $this->Voucher->find('first', array('conditions' => array('code' => $code))); @@ -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 diff --git a/Controller/GiftallController.php b/Controller/GiftallController.php index 0716787..ccf08bf 100644 --- a/Controller/GiftallController.php +++ b/Controller/GiftallController.php @@ -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"); @@ -31,4 +31,4 @@ public function admin_index() throw new ForbiddenException(); } } -} \ No newline at end of file +} diff --git a/Controller/PaymentController.php b/Controller/PaymentController.php index 351cb4d..fe2648b 100755 --- a/Controller/PaymentController.php +++ b/Controller/PaymentController.php @@ -6,7 +6,7 @@ class PaymentController extends ShopAppController public function beforeFilter() { parent::beforeFilter(); - $this->Security->unlockedActions = array('starpass', 'starpass_verif', 'ipn', 'dedipass_ipn'); + $this->Security->unlockedActions = array('starpass', 'starpass_verif', 'ipn', 'dedipass_ipn', 'verif_brainblocks'); } /* @@ -41,6 +41,17 @@ public function admin_index() $offersByID['paypal'][$value['Paypal']['id']] = $value['Paypal']['name']; } + $this->loadModel('Shop.Nano'); + try { + // si le plugin est update de x.x.15 a x.x.16 ca throw une execption + $offers['nano'] = $this->Nano->find('all'); + foreach ($offers['nano'] as $key => $value) { + $offersByID['nano'][$value['Nano']['id']] = $value['Nano']['name']; + } + } catch (\Throwable $th) { + // ici on cree les tables necessaires et on redirige sur l'index ud controller + $this->Nano->init($this); + } // Les PaySafeCards c'est différents @@ -144,6 +155,32 @@ public function admin_get_paypal_histories() } } + public function admin_get_nano_histories() + { + if ($this->isConnected && $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { + $this->loadModel('Shop.Nano'); + + $this->autoRender = false; + $this->response->type('json'); + + $this->DataTable = $this->Components->load('DataTable'); + $this->modelClass = 'NanoHistory'; + $this->DataTable->initialize($this); + $this->paginate = array( + 'fields' => array('User.pseudo', 'Nano.name', 'NanoHistory.payment_amount', 'NanoHistory.currency', 'NanoHistory.credits_gived', 'NanoHistory.created'), + 'recursive' => 1 + ); + $this->DataTable->mDataProp = true; + + $response = $this->DataTable->getResponse(); + + $this->response->body(json_encode($response)); + + } else { + throw new ForbiddenException(); + } + } + public function admin_get_paysafecard_histories() { if ($this->isConnected && $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { @@ -240,7 +277,7 @@ function transfer_points() if ($this->User->exist($this->request->data['to'])) { if (strtolower($this->User->getKey('pseudo')) != strtolower($this->request->data['to']) && $this->User->getKey('id') != $this->request->data['to']) { $how = floatval($this->request->data['how']); - if ($how > 0) { + if ($how >= 1) { // Avoid to transfer 0.000000009 (-> 9.0E-9) $this->User->cacheQueries = false; $money_user = $this->User->find('first', array('conditions' => array('id' => $this->User->getKey('id'))))['User']['money']; $new_sold_user = $money_user - $how; @@ -472,12 +509,12 @@ public function admin_paysafecard_invalid($id = false) $this->History->set('INVALID_PAYSAFECARD', 'shop'); $this->Session->setFlash($this->Lang->get('SHOP__PAYSAFECARD_INVALID_SUCCESS'), 'default.success'); - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { $this->redirect('/'); @@ -512,6 +549,7 @@ public function paysafecard() 'code' => $codes, 'user_id' => $this->User->getKey('id') )); + $this->Paysafecard->save(); $this->loadModel('Notification'); @@ -611,10 +649,10 @@ public function admin_edit_paypal($id = false) $this->set(compact('id')); $this->set('paypal', $search[0]['Paypal']); } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { $this->redirect('/'); @@ -666,6 +704,127 @@ public function admin_edit_paypal_ajax($id = false) } } + /* + * ======== Ajout d'une offre Nano (affichage) =========== + */ + + public function admin_add_nano() + { + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + $this->set('title_for_layout', $this->Lang->get('SHOP__NANO_OFFER_ADD')); + $this->layout = 'admin'; + } else { + $this->redirect('/'); + } + } + + /* + * ======== Ajout d'une offre Nano (Traitement AJAX) =========== + */ + + public function admin_add_nano_ajax() + { + $this->autoRender = false; + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + if ($this->request->is('ajax')) { + if (!empty($this->request->data['name']) AND !empty($this->request->data['address']) AND !empty($this->request->data['price']) AND !empty($this->request->data['money'])) { + $this->request->data['price'] = number_format($this->request->data['price'], 2, '.', ''); + $this->request->data['money'] = number_format($this->request->data['money'], 2, '.', ''); + if (preg_match("/nano_[13][13-9a-km-uw-z]{59}/",$this->request->data['address'])) { + $this->loadModel('Shop.Nano'); + $this->Nano->read(null, null); + $this->Nano->set($this->request->data); + $this->Nano->save(); + $this->History->set('ADD_NANO_OFFER', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__NANO_OFFER_ADD_SUCCESS'), 'default.success'); + echo json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__NANO_OFFER_ADD_SUCCESS'))); + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('SHOP__ERROR_NANO_ADDRESS_NOT_VALID'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))); + } + } else { + throw new ForbiddenException(); + } + } + + + /* + * ======== Modification d'une offre Nano (affichage) =========== + */ + + public function admin_edit_nano($id = false) + { + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + + $this->set('title_for_layout', $this->Lang->get('SHOP__NANO_OFFER_EDIT')); + $this->layout = 'admin'; + if ($id != false) { + $this->loadModel('Shop.Nano'); + $search = $this->Nano->find('all', array('conditions' => array('id' => $id))); + if (!empty($search)) { + $this->set(compact('id')); + $this->set('nano', $search[0]['Nano']); + } else { + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + } + } else { + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + } + } else { + $this->redirect('/'); + } + } + + + /* + * ======== Modification d'une offre Nano (traitement AJAX) =========== + */ + + public function admin_edit_nano_ajax($id = false) + { + $this->autoRender = false; + if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_PAYMENT')) { + if ($id != false) { + $this->loadModel('Shop.Nano'); + $search = $this->Nano->find('all', array('conditions' => array('id' => $id))); + if (!empty($search)) { + if ($this->request->is('ajax')) { + if (!empty($this->request->data['name']) AND !empty($this->request->data['address']) AND !empty($this->request->data['price']) AND !empty($this->request->data['money'])) { + $this->request->data['price'] = number_format($this->request->data['price'], 2, '.', ''); + $this->request->data['money'] = number_format($this->request->data['money'], 2, '.', ''); + if (preg_match("/nano_[13][13-9a-km-uw-z]{59}/",$this->request->data['address'])) { + $this->loadModel('Shop.Nano'); + $this->Nano->read(null, $id); + $this->Nano->set($this->request->data); + $this->Nano->save(); + $this->History->set('EDIT_NANO_OFFER', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__NANO_OFFER_EDIT_SUCCESS'), 'default.success'); + echo json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__NANO_OFFER_EDIT_SUCCESS'))); + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('SHOP__ERROR_NANO_ADDRESS_NOT_VALID'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST'))); + } + } else { + echo json_encode(array('statut' => false, 'msg' => $this->Lang->get('UNKNONW_ID'))); + } + } else { + throw new NotFoundException(); + } + } else { + throw new ForbiddenException(); + } + } + /* * ======== Ajout d'une offre StarPass (affichage) =========== @@ -732,10 +891,10 @@ public function admin_edit_starpass($id = false) $this->set(compact('id')); $this->set('starpass', $search[0]['Starpass']); } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { $this->redirect('/'); @@ -893,13 +1052,13 @@ public function starpass_verif() $this->StarpassHistory->save(); $this->Session->setFlash($this->Lang->get('SHOP__STARPASS_PAYMENT_SUCCESS'), 'default.success'); - $this->redirect(array('controller' => 'shop', 'action' => 'index')); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index')); + $this->redirect(array('action' => 'index', 'admin' => true)); } } else { - $this->redirect(array('controller' => 'shop', 'action' => 'index')); + $this->redirect(array('action' => 'index', 'admin' => true)); } } @@ -917,7 +1076,7 @@ public function ipn() // On assigne les variables $item_name = $this->request->data['item_name']; $item_number = $this->request->data['item_number']; - $payment_status = $this->request->data['payment_status']; + $payment_status = strtoupper($this->request->data['payment_status']); $payment_amount = $this->request->data['mc_gross']; $payment_currency = $this->request->data['mc_currency']; $txn_id = $this->request->data['txn_id']; @@ -981,7 +1140,7 @@ public function ipn() // On effectue les autres vérifications - if ($payment_status == "Completed") { //Le paiment est complété + if ($payment_status == "COMPLETED") { //Le paiment est complété if ($payment_currency == "EUR") { //Le paiement est bien en euros @@ -1021,14 +1180,18 @@ public function ipn() )); $this->PaypalHistory->save(); + $event = new CakeEvent('onBuyPoints', $this, array('credits' => $findOffer['Paypal']['money'], 'price' => $payment_amount, 'plateform' => 'paypal', 'user_id' => $user_id)); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + $this->loadModel('Notification'); $this->Notification->setToUser($this->Lang->get('NOTIFICATION__PAYPAL_IPN_VALIDED'), $user_id); - $this->response->statusCode(200); - - } else { + } else throw new InternalErrorException('PayPal : Payment already credited'); - } + return $this->response->statusCode(200); } else { throw new InternalErrorException('PayPal : Receiver email invalid'); @@ -1051,6 +1214,130 @@ public function ipn() } } + /* + * ======== Vérification d'une transaction Nano =========== + */ + + public function verif_brainblocks() + { // cf. https://brainblocks.io/ + $this->autoRender = false; + + if ($this->request->is('post')) { //On vérifie l'état de la requête + + // On assigne les variables + $token = $this->request->data['token']; + $user_id = $this->request->data['user_id']; + $nano_id = $this->request->data['nano_id']; + // On vérifie que l'utilisateur contenu dans le champ nano_id existe bien + + $this->loadModel('User'); + if (!$this->User->exist($user_id)) { + throw new InternalErrorException('Nano : Unknown user'); + } + + // On prépare la requête de vérification + // On fais la requête + + $cURL = curl_init(); + curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($cURL, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($cURL, CURLOPT_URL, "https://api.brainblocks.io/api/session/$token/verify"); + curl_setopt($cURL, CURLOPT_ENCODING, 'gzip'); + curl_setopt($cURL, CURLOPT_BINARYTRANSFER, true); + curl_setopt($cURL, CURLOPT_HEADER, false); + curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); + curl_setopt($cURL, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + curl_setopt($cURL, CURLOPT_FORBID_REUSE, true); + curl_setopt($cURL, CURLOPT_FRESH_CONNECT, true); + curl_setopt($cURL, CURLOPT_CONNECTTIMEOUT, 30); + curl_setopt($cURL, CURLOPT_TIMEOUT, 60); + curl_setopt($cURL, CURLINFO_HEADER_OUT, true); + curl_setopt($cURL, CURLOPT_HTTPHEADER, array( + 'Connection: close', + 'Expect: ', + )); + $Response = curl_exec($cURL); + $Status = (int)curl_getinfo($cURL, CURLINFO_HTTP_CODE); + curl_close($cURL); + + // On traite la réponse + + // On vérifie que il y ai pas eu d'erreur + + if (empty($Response) || $Status != 200 || !$Status) { + throw new InternalErrorException('Nano : Error with BrainBlocks Response'); + } + $result = json_decode($Response, true); + + // On effectue les autres vérifications + + // On cherche l'offre avec sont id + $this->loadModel('Shop.Nano'); + $findOffer = $this->Nano->find('first', array('conditions' => array('id' => $nano_id))); + if (!empty($findOffer)) { + // On vérifie que toutes les conditions ont ete remplis + if ($result['destination'] == $findOffer['Nano']['address'] // si l'adresse de destination de Brainblocks corresponds a notre addresse de destination + && $result['currency'] == $findOffer['Nano']['currency'] // si l'equivalence a bien ete calcule avec la monnaie FIAT choisis + && $result['amount'] == $findOffer['Nano']['price'] // si le prix paye corresponds au prix de l'offre + && $result['fulfilled'] == true) { // si le paiement est complet. s'il ne l'est pas, + //apres 20 minutes les cryptomonnaies de l'utilisateur lui seront retourne + // On vérifie que le paiement n'est pas déjà en base de données + $this->loadModel('Shop.NanoHistory'); + $findPayment = $this->NanoHistory->find('first', array('conditions' => array('token' => $token))); + + if (empty($findPayment)) { + + // On récupére le solde de l'utilisateur et on ajoute ses nouveaux crédits + $sold = $this->User->getFromUser('money', $user_id); + $new_sold = floatval($sold + floatval($findOffer['Nano']['money'])); + + // On ajoute l'argent à l'utilisateur + $this->User->setToUser('money', $new_sold, $user_id); + + // On l'ajoute dans l'historique global + $this->HistoryC = $this->Components->load('History'); + $this->HistoryC->set('BUY_MONEY', 'shop', null, $user_id); + + // On l'ajoute dans l'historique des paiements + $this->NanoHistory->create(); + $this->NanoHistory->set(array( + 'token' => $token, + 'user_id' => $user_id, + 'offer_id' => $findOffer['Nano']['id'], + 'payment_amount' => $findOffer['Nano']['price'], + 'currency' => $findOffer['Nano']['currency'], + 'credits_gived' => $findOffer['Nano']['money'] + )); + $this->NanoHistory->save(); + + $event = new CakeEvent('onBuyPoints', $this, array('credits' => $findOffer['Nano']['money'], 'price' => $findOffer['Nano']['price'], 'plateform' => 'nano', 'user_id' => $user_id)); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + + $this->loadModel('Notification'); + $this->Notification->setToUser($this->Lang->get('NOTIFICATION__NANO_VALIDED'), $user_id); + + $this->response->statusCode(200); + echo json_encode(array('statut' => true, 'msg' => $this->Lang->get('NOTIFICATION__NANO_VALIDED'), 'money'=>"$new_sold ".(($new_sold > 1 ? $this->Configuration->getMoneyName() : $this->Configuration->getMoneyName(false))))); + + } else { + throw new InternalErrorException('Nano : Payment already credited'); + } + + } else { + throw new InternalErrorException('Nano : invalid address'); + } + + } else { + throw new InternalErrorException('Nano : Unknown offer'); + } + } else { + throw new InternalErrorException('Nano : Not post'); + } + } + /* * ======== Affichage Dédipass =========== @@ -1200,8 +1487,14 @@ public function dedipass_ipn() )); $this->DedipassHistory->save(); + $event = new CakeEvent('onBuyPoints', $this, array('credits' => $virtual_currency, 'price' => $this->request->data['payout'], 'plateform' => 'dedipass', 'user_id' => $user_id)); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + $this->Session->setFlash($this->Lang->get('SHOP__DEDIPASS_PAYMENT_SUCCESS', array('{MONEY}' => $virtual_currency, '{MONEY_NAME}' => $this->Configuration->getMoneyName())), 'default.success'); - $this->redirect(array('controller' => 'shop', 'action' => 'index')); + $this->redirect(array('action' => 'index', 'admin' => true)); } else { $this->Session->setFlash($this->Lang->get('SHOP__DEDIPASS_PAYMENT_ERROR_INVAID_CODE'), 'default.error'); @@ -1210,7 +1503,7 @@ public function dedipass_ipn() } else { $this->Session->setFlash($this->Lang->get('SHOP__DEDIPASS_PAYMENT_ERROR_NOT_CONNECTED', array('{CODE}' => $code)), 'default.error'); - $this->redirect(array('controller' => 'shop', 'action' => 'index')); + $this->redirect(array('action' => 'index', 'admin' => true)); } } } diff --git a/Controller/ShopController.php b/Controller/ShopController.php index 78e5d7d..cc9b020 100755 --- a/Controller/ShopController.php +++ b/Controller/ShopController.php @@ -16,58 +16,103 @@ function index($category = false) if ($category) { $this->set(compact('category')); } - + $this->layout = $this->Configuration->getKey('layout'); // On charge le thème configuré $this->loadModel('Shop.Item'); // le model des articles $this->loadModel('Shop.Category'); // le model des catégories - $search_items = $this->Item->find('all', array( - 'order' => 'order', + $search_items = $this->Item->find('all', + array( + 'order' => 'order', 'conditions' => array( 'OR' => array( - 'display IS NULL', - 'display = 1' - ) - ) - )); // on cherche tous les items et on envoie à la vue - $vanow = 0; - $this->loadModel('Shop.DedipassHistory'); - $this->loadModel('Shop.PaypalHistory'); - $this->loadModel('Shop.StarpassHistory'); - $this->loadModel('Shop.PaysafecardHistory'); - $histories_dedi = $this->DedipassHistory->find('all',['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); - $histories_paypal = $this->PaypalHistory->find('all',['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); - $histories_pay = $this->PaysafecardHistory->find('all',['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); - $histories_star = $this->StarpassHistory->find('all',['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); - foreach ($histories_dedi as $value){ - $vanow += floatval($value["DedipassHistory"]["credits_gived"]); - } - foreach ($histories_paypal as $value){ - $vanow += floatval($value["PaypalHistory"]["payment_amount"]); - } - foreach ($histories_pay as $value){ - $vanow += floatval($value["PaysafecardHistory"]["credits_gived"]); - } - foreach ($histories_star as $value){ - $vanow += floatval($value["StarpassHistory"]["credits_gived"]); - } - $this->loadModel('Shop.ItemsConfig'); - $vagoal = $this->ItemsConfig->find('all'); - $vagoal = @$vagoal[0]["ItemsConfig"]["goal"]; - if ($vanow > $vagoal){ - $vanow = $vagoal; - } - if ($vagoal != 0){ - $vawidth = round((str_replace(",", '.', $vanow*100/$vagoal))); - } - - $search_categories = $this->Category->find('all'); // on cherche toutes les catégories et on envoie à la vue - - $search_first_category = $this->Category->find('first'); // - $search_first_category = @$search_first_category['Category']['id']; // + 'display IS NULL', + 'display = 1' + ) + ) + )); // on cherche tous les items et on envoie à la vue + $this->loadModel('Shop.DedipassHistory'); + $this->loadModel('Shop.PaypalHistory'); + $this->loadModel('Shop.StarpassHistory'); + $this->loadModel('Shop.PaysafecardHistory'); + + $histories_dedi = $this->DedipassHistory->find('all', ['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); + $histories_paypal = $this->PaypalHistory->find('all', ['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); + $histories_pay = $this->PaysafecardHistory->find('all', ['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); + $histories_star = $this->StarpassHistory->find('all', ['conditions' => ['created LIKE' => date('Y') . '-' . date('m') . '-%']]); + + $best_donator_price = []; + $goal_money = 0; + foreach ($histories_dedi as $value) { + $money = $value["DedipassHistory"]["credits_gived"]; + $goal_money += floatval($money); + $id = $value["DedipassHistory"]["user_id"]; + if (!isset($best_donator_price[$id])) + $best_donator_price[$id] = 0; + $best_donator_price[$id] += $money; + } + foreach ($histories_paypal as $value) { + $money = $value["PaypalHistory"]["payment_amount"]; + $goal_money += floatval($money); + + $id = $value["PaypalHistory"]["user_id"]; + if (!isset($best_donator_price[$id])) + $best_donator_price[$id] = 0; + $best_donator_price[$id] += $money; + } + foreach ($histories_pay as $value) { + $money = $value["PaysafecardHistory"]["credits_gived"]; + $goal_money += floatval($money); + $id = $value["PaysafecardHistory"]["user_id"]; + if (!isset($best_donator_price[$id])) + $best_donator_price[$id] = 0; + $best_donator_price[$id] += $money; + } + + foreach ($histories_star as $value) { + $money = $value["StarpassHistory"]["credits_gived"]; + $goal_money += floatval($money); + $id = $value["StarpassHistory"]["user_id"]; + if (!isset($best_donator_price[$id])) + $best_donator_price[$id] = 0; + $best_donator_price[$id] += $money; + } + $this->loadModel('Shop.ItemsConfig'); + $goal_money_max = $this->ItemsConfig->find('first')["ItemsConfig"]["goal"]; + if ($goal_money > $goal_money_max) { + $goal_money = $goal_money_max; + } + if ($goal_money_max != 0) { + $goal_bar_with = round((str_replace(",", '.', $goal_money * 100 / $goal_money_max))); + } + + $i = 0; + foreach ($best_donator_price as $key => $value) { + if ($i == 3) + break; + $best_donator_id = array_search(max($best_donator_price), $best_donator_price); + $best_donator[] = $this->User->find('first', ['conditions' => ['id' => $best_donator_id]]); + + $best_donator_price = array_diff_key($best_donator_price, [$best_donator_id => $best_donator_price[$best_donator_id]]); + $i++; + } + $this->loadModel('Shop.Section'); + $search_sections = $this->Section->find('all'); + $search_categories_without_section = $this->Category->find('all', array('conditions' => array('section' => 0), 'order' => 'order')); + $search_categories_section = []; + if (!empty($search_sections)) foreach ($search_sections as $v) { + $search_categories_section[$v['Section']['id']] = $this->Category->find('all', array('conditions' => array('section_id' => $v['Section']['id'], 'section' => 1), 'order' => 'order')); + } + $search_categories = $this->Category->find('all'); + + $search_first_category = $this->Category->find('first'); + $search_first_category = @$search_first_category['Category']['id']; $this->loadModel('Shop.Paypal'); $paypal_offers = $this->Paypal->find('all'); + $this->loadModel('Shop.Nano'); + $nano_offers = $this->Nano->find('all'); + $this->loadModel('Shop.Starpass'); $starpass_offers = $this->Starpass->find('all'); @@ -86,25 +131,28 @@ function index($category = false) $money = 0; if ($this->isConnected) { $money = $this->User->getKey('money') . ' '; - $money += ($this->User->getKey('money') == 1 OR $this->User->getKey('money') == 0) ? $this->Configuration->getMoneyName(false) : $this->Configuration->getMoneyName(); + $money .= ($this->User->getKey('money') == 1 OR $this->User->getKey('money') == 0) ? $this->Configuration->getMoneyName(false) : $this->Configuration->getMoneyName(); } $vouchers = $this->DiscountVoucher; $singular_money = $this->Configuration->getMoneyName(false); $plural_money = $this->Configuration->getMoneyName(); + $this->set(compact('best_donator', 'dedipass', 'goal_money_max', 'goal_bar_with', 'paysafecard_enabled', 'money', 'starpass_offers', 'paypal_offers', 'nano_offers', 'search_first_category', 'search_categories', 'search_categories_without_section', 'search_categories_section', 'search_sections', 'search_items', 'title_for_layout', 'vouchers', 'singular_money', 'plural_money')); - $this->set(compact('dedipass', 'vagoal', 'vawidth', 'paysafecard_enabled', 'money', 'starpass_offers', 'paypal_offers', 'search_first_category', 'search_categories', 'search_items', 'title_for_layout', 'vouchers', 'singular_money', 'plural_money')); } /* * ======== Affichage d'un article dans le modal =========== */ - function ajax_get($id) + function ajax_get($id = null) { // Permet d'afficher le contenu du modal avant l'achat (ajax) $this->response->type('json'); $this->autoRender = false; + if (!isset($id)) { + throw new NotFoundException(); + } if ($this->isConnected AND $this->Permissions->can('CAN_BUY')) { // si l'utilisateur est connecté $this->loadModel('Shop.Item'); // je charge le model des articles $search_item = $this->Item->find('all', array('conditions' => array('id' => $id))); // je cherche l'article selon l'id @@ -143,7 +191,7 @@ function ajax_get($id) $reductional_items_list_display = array(); // on parcours tous les articles pour voir si ils ont été achetés $reductional_items = true; // de base on dis que c'est okay - $reduction = 0; // 0 de réduction + $reduction = 0; // 0 de réduction foreach ($reductional_items_list as $key => $value) { $findItem = $this->Item->find('first', array('conditions' => array('id' => $value))); @@ -152,29 +200,38 @@ function ajax_get($id) break; } + $reduction = $this->Item->getReductionWithReductionalItems($search_item[0]['Item'], $this->User->getKey('id')); + if (floatval($reduction) == "0") { + $reductional_items = false; + break; + } + $findHistory = $this->ItemsBuyHistory->find('first', array('conditions' => array('user_id' => $this->User->getKey('id'), 'item_id' => $findItem['Item']['id']))); if (empty($findHistory)) { - $reductional_items = false; break; } - $reduction = +$findItem['Item']['price']; + $reductional_items_list_display[] = $findItem['Item']['name']; unset($findItem); + } + $item_price -= $reduction; if ($reductional_items) { - $item_price = $item_price - $reduction; $reduction = $reduction . ' ' . $this->Configuration->getMoneyName(); $reductional_items_list = '' . implode(', ', $reductional_items_list_display) . ''; + $reductional_items_list = $this->Lang->get('SHOP__ITEM_REDUCTIONAL_ITEMS_LIST', array('{ITEMS_LIST}' => $reductional_items_list, '{REDUCTION}' => $reduction)); } + } + $add_to_cart = (!empty($search_item[0]['Item']['cart']) && $search_item[0]['Item']['cart']) ? true : false; //On récupére l'element @@ -204,7 +261,7 @@ function ajax_get($id) $vars = array( '{ITEM_NAME}' => $search_item['0']['Item']['name'], - '{ITEM_DESCRIPTION}' => nl2br($search_item['0']['Item']['description']), + '{ITEM_DESCRIPTION}' => $search_item['0']['Item']['description'], '{ITEM_SERVERS}' => $servers, '{ITEM_PRICE}' => $item_price, '{SITE_MONEY}' => $money, @@ -250,6 +307,7 @@ function ajax_get($id) } else { $this->response->body(json_encode(array('statut' => false, 'html' => '
' . $this->Lang->get('USER__ERROR_MUST_BE_LOGGED') . '
'))); // si il n'est pas connecté } + } @@ -282,27 +340,29 @@ public function checkVoucher($code = null, $items_id = null, $quantities = 1) $total_price += $findItem['Item']['price'] * $quantity; $i = 0; + + /* + On gère les réductions de prix + */ + + $reduction = $this->Item->getReductionWithReductionalItems($findItem['Item'], $this->User->getKey('id')); while ($i < $quantity) { - $getVoucherPrice = $this->DiscountVoucher->getNewPrice($findItem['Item']['id'], $code); + /* + On gère le nouveau prix + */ + $new_price = $total_price - $reduction; + + + $getVoucherPrice = $this->DiscountVoucher->getNewPrice($findItem['Item']['id'], $new_price, $code); + if ($getVoucherPrice['status']) { - $new_price = $new_price + $getVoucherPrice['price']; - } else { - $new_price = $new_price + $findItem['Item']['price']; // erreur + $new_price = $getVoucherPrice['price']; } $i++; } - - - /* - On gère les réductions de prix - */ - $reduction = $this->Item->getReductionWithReductionalItems($findItem['Item'], $this->User->getKey('id')); - // on effectue la reduction - $new_price = $new_price - $reduction * $quantity; - if ($new_price < 0) { $new_price = 0; } @@ -419,8 +479,12 @@ function buy_ajax() $giveCape = true; // Voucher + // Reductionnal price + $reduction = $this->Item->getReductionWithReductionalItems($item, $this->User->getKey('id')); + $item['price'] -= $reduction; + if (!empty($voucher)) { - $getVoucherPrice = $this->DiscountVoucher->getNewPrice($item['id'], $voucher); + $getVoucherPrice = $this->DiscountVoucher->getNewPrice($item['id'], $item['price'], $voucher); if ($getVoucherPrice['status']) { $voucherUsedCount++; @@ -429,21 +493,18 @@ function buy_ajax() } } - // Reductionnal price - $reduction = $this->Item->getReductionWithReductionalItems($item, $this->User->getKey('id')); - $item['price'] -= $reduction; // Add to items (for quantity) for ($i = 1; $i <= $itemData['quantity']; $i++) { if ($i == $itemData['quantity'] && $item['broadcast_global']) { // Broadcast global only on last (avoid multiple global message) $item['commands'] = "{$item['commands']}[{+}]" . strtr($config['broadcast_global'], [ - '{PLAYER}' => $this->User->getKey('pseudo'), - '{QUANTITY}' => $itemData['quantity'], - '{ITEM_NAME}' => $item['name'], - '{SERVERNAME}' => implode(', ', array_map(function ($server) { - return $server['Server']['name']; - }, ClassRegistry::init('Server')->find('all', ['conditions' => ['id' => $item['servers']]]))) - ]); + '{PLAYER}' => $this->User->getKey('pseudo'), + '{QUANTITY}' => $itemData['quantity'], + '{ITEM_NAME}' => $item['name'], + '{SERVERNAME}' => implode(', ', array_map(function ($server) { + return $server['Server']['name']; + }, ClassRegistry::init('Server')->find('all', ['conditions' => ['id' => $item['servers']]]))) + ]); } $items[] = $item; // Add to total price @@ -523,23 +584,41 @@ public function admin_index() $this->layout = 'admin'; $this->loadModel('Shop.Item'); + $this->loadModel('Shop.Category'); + $this->loadModel('Server'); $search_items = $this->Item->find('all', array('order' => 'order')); $items = array(); - foreach ($search_items as $key => $value) { - $items[$value['Item']['id']] = $value['Item']['name']; + if (!empty($search_items)) foreach ($search_items as $key => $v) { + if (!$this->Category->find('first', array('conditions' => array('id' => $v['Item']['category'])))) { + $search_items_other = $this->Item->find('all', array('conditions' => array('category' => $v['Item']['category']))); + } + $search_server = $this->Server->find('all', array('conditions' => array('id' => unserialize($v['Item']['servers'])))); + $item_server[$v['Item']['id']] = implode(', ', array_map(function ($server) { + return $server['Server']['name']; + }, $search_server)); + $items[$v['Item']['id']] = $v['Item']['name']; } - - $this->loadModel('Shop.Category'); + $this->loadModel('Shop.Section'); + $search_sections = $this->Section->find('all'); $search_categories = $this->Category->find('all'); - foreach ($search_categories as $v) { - $categories[$v['Category']['id']]['name'] = $v['Category']['name']; + if (!empty($search_categories)) foreach ($search_categories as $v) { + $search_items[$v['Category']['id']] = $this->Item->find('all', array('conditions' => array('category' => $v['Category']['id']), 'order' => 'order')); + + } + if (!empty($search_sections)) foreach ($search_sections as $v) { + $search_categories["section-id-" . $v['Section']['id']] = $this->Category->find('all', array('conditions' => array('section' => 1, 'section_id' => $v['Section']['id']), 'order' => 'order')); + } + $search_categories_without_section = $this->Category->find('all', array('conditions' => array('section' => 0), 'order' => 'order')); + if (!empty($search_categories_without_section)) foreach ($search_categories_without_section as $v) { + $search_items[$v['Category']['id']] = $this->Item->find('all', array('conditions' => array('category' => $v['Category']['id']), 'order' => 'order')); } + $this->loadModel('Shop.ItemsConfig'); $findConfig = $this->ItemsConfig->find('first'); $config = (!empty($findConfig)) ? $findConfig['ItemsConfig'] : array(); - $this->set(compact('categories', 'search_categories', 'search_items', 'config', 'items')); + $this->set(compact('categories', 'search_categories', 'search_items', 'config', 'items', 'search_items_other', 'item_server', 'search_sections', 'search_categories_without_section')); } else { $this->redirect('/'); @@ -559,7 +638,7 @@ public function admin_get_histories_buy() $this->modelClass = 'ItemsBuyHistory'; $this->DataTable->initialize($this); $this->paginate = array( - 'fields' => array('ItemsBuyHistory.created', 'Item.name', 'User.pseudo'), + 'fields' => array('ItemsBuyHistory.created', 'Item.name', 'User.pseudo', 'User.UUID'), 'order' => 'ItemsBuyHistory.id DESC', 'recursive' => 1 ); @@ -578,15 +657,16 @@ public function admin_get_histories_buy() /* * ======== Page principale du panel admin =========== */ - public function admin_save_ajax() + public function admin_save_ajax() { $this->autoRender = false; - if ($this->isConnected AND $this->Permissions->can('MANAGE_NAV')) { + $this->response->type('json'); + if ($this->isConnected and $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { if ($this->request->is('post')) { if (!empty($this->request->data)) { - $data = $this->request->data['shop_item_order']; - $data = explode('&', $data); + $data = htmlspecialchars($this->request->data['shop_item_order']); + $data = explode('&', $data); $i = 1; foreach ($data as $key => $value) { $data2[] = explode('=', $value); @@ -599,34 +679,29 @@ public function admin_save_ajax() $data = $data1; $this->loadModel('Shop.Item'); foreach ($data as $key => $value) { - $find = $this->Item->find('first', array('conditions' => array('name' => $key))); - if (!empty($find)) { - $id = $find['Item']['id']; - $this->Item->read(null, $id); - $this->Item->set(array( - 'order' => $value, - )); - $this->Item->save(); - } else { - $error = 1; - } - } - if (empty($error)) { - return $this->sendJSON(['statut' => true, 'msg' => $this->Lang->get('SHOP__SAVE_SUCCESS')]); - } else{ - return $this->sendJSON(['statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')]); + $find = $this->Item->find('first', array('conditions' => array('id' => $key))); + if (empty($find)) + return $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST')))); + $id = $find['Item']['id']; + $this->Item->read(null, $id); + $this->Item->set(array( + 'order' => $value, + )); + $this->Item->save(); } + + return $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__SAVE_SUCCESS')))); } else { - return $this->sendJSON(['statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')]); + return $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__FILL_ALL_FIELDS')))); } } else { - return $this->sendJSON(['statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST')]); - + return $this->response->body(json_encode(array('statut' => false, 'msg' => $this->Lang->get('ERROR__BAD_REQUEST')))); } } else { $this->redirect('/'); } } + public function admin_config_items() { $this->autoRender = false; @@ -643,9 +718,9 @@ public function admin_config_items() $this->ItemsConfig->read(null, 1); } $this->ItemsConfig->set(array( - 'goal' => $this->request->data['goal'], - 'broadcast_global' => $this->request->data['broadcast_global'] - )); + 'goal' => $this->request->data['goal'], + 'broadcast_global' => $this->request->data['broadcast_global'] + )); $this->ItemsConfig->save(); $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__CONFIG_SAVE_SUCCESS')))); @@ -676,17 +751,15 @@ public function admin_edit($id = false) if (!empty($item)) { $item = $item[0]['Item']; $this->loadModel('Shop.Category'); - $item['category'] = $this->Category->find('all', array('conditions' => array('id' => $item['category']))); - $item['category'] = $item['category'][0]['Category']['name']; + $this->loadModel('Shop.Section'); + $item['category'] = $this->Category->find('first', array('conditions' => array('id' => $item['category']))); + $item['category'] = $item['category']['Category']['id']; - $search_categories = $this->Category->find('all', array('fields' => 'name')); - $categories = array(); + $search_categories = $this->Category->find('all', array('order' => 'section_id')); foreach ($search_categories as $v) { - if ($v['Category']['name'] != $item['category']) { - $categories[$v['Category']['name']] = $v['Category']['name']; - } + $section[$v['Category']['section_id']] = $this->Section->find('first', array('conditions' => array('id' => $v['Category']['section_id']))); } - $this->set(compact('categories')); + $this->set(compact('section', 'search_categories')); $search_items = $this->Item->find('all', array('fields' => array('name', 'id'))); $items_available = array(); @@ -762,8 +835,6 @@ public function admin_edit_ajax() } if (!empty($this->request->data['id']) AND !empty($this->request->data['name']) AND !empty($this->request->data['description']) AND !empty($this->request->data['category']) AND strlen($this->request->data['price']) > 0 AND !empty($this->request->data['servers']) AND !empty($this->request->data['commands']) AND !empty($this->request->data['timedCommand'])) { $this->loadModel('Shop.Category'); - $this->request->data['category'] = $this->Category->find('all', array('conditions' => array('name' => $this->request->data['category']))); - $this->request->data['category'] = $this->request->data['category'][0]['Category']['id']; $this->request->data['timedCommand'] = ($this->request->data['timedCommand'] == 'true') ? 1 : 0; if (!$this->request->data['timedCommand']) { $this->request->data['timedCommand_cmd'] = NULL; @@ -829,20 +900,20 @@ public function admin_edit_ajax() /* * ======== Ajout d'un article (affichage) =========== */ - - public function admin_add_item() + + public function admin_add_item($category_id = null) { if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { $this->set('title_for_layout', $this->Lang->get('SHOP__ITEM_ADD')); $this->layout = 'admin'; $this->loadModel('Shop.Category'); - $search_categories = $this->Category->find('all', array('fields' => 'name')); - $categories = array(); + $this->loadModel('Shop.Section'); + $search_categories = $this->Category->find('all', array('order' => 'section_id')); foreach ($search_categories as $v) { - $categories[$v['Category']['name']] = $v['Category']['name']; + $section[$v['Category']['section_id']] = $this->Section->find('first', array('conditions' => array('id' => $v['Category']['section_id']))); } - $this->set(compact('categories')); + $this->set(compact('section', 'search_categories', 'category_id')); $this->loadModel('Shop.Item'); $search_items = $this->Item->find('all', array('fields' => array('name', 'id'))); @@ -860,32 +931,6 @@ public function admin_add_item() $this->redirect('/'); } } - public function admin_edit_category() - { - $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.Category'); - $this->Category->read(null, $this->request->data['id']); - $this->Category->set(array( - 'name' => $this->request->data['name'], - )); - $this->Category->save(); - $this->response->body(json_encode(array('statut' => true, 'msg' => $this->Lang->get('SHOP__CATEGORY_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(); - } - } - /* * ======== Ajout d'un article (Traitement AJAX) =========== */ @@ -899,8 +944,6 @@ public function admin_add_item_ajax() if (!empty($this->request->data['name']) AND !empty($this->request->data['description']) AND !empty($this->request->data['category']) AND strlen($this->request->data['price']) > 0 AND !empty($this->request->data['servers']) AND !empty($this->request->data['commands']) AND !empty($this->request->data['timedCommand'])) { $this->loadModel('Shop.Category'); - $this->request->data['category'] = $this->Category->find('all', array('conditions' => array('name' => $this->request->data['category']))); - $this->request->data['category'] = $this->request->data['category'][0]['Category']['id']; $this->request->data['timedCommand'] = ($this->request->data['timedCommand'] == 'true') ? 1 : 0; if (!$this->request->data['timedCommand']) { $this->request->data['timedCommand_cmd'] = NULL; @@ -963,44 +1006,69 @@ public function admin_add_item_ajax() } } - /* - * ======== Ajout d'une catégorie (affichage & traitement POST) =========== - */ + * ======== Duplication d'un article (Traitement AJAX) =========== + */ - public function admin_add_category() + public function admin_duplicate($id = false) { + $this->autoRender = false; if ($this->isConnected AND $this->Permissions->can('SHOP__ADMIN_MANAGE_ITEMS')) { + if ($id != false) { + $this->loadModel('Shop.Item'); + $this->request->data = $this->Item->find('first', array('conditions' => array('id' => $id)))['Item']; - $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'])) { + if (!empty($this->request->data['name']) AND !empty($this->request->data['description']) AND !empty($this->request->data['category']) AND strlen($this->request->data['price']) > 0 AND !empty($this->request->data['servers']) AND !empty($this->request->data['commands'])) { $this->loadModel('Shop.Category'); - $event = new CakeEvent('beforeAddCategory', $this, array('category' => $this->request->data['name'], 'user' => $this->User->getAllFromCurrentUser())); + $event = new CakeEvent('beforeAddItem', $this, array('data' => $this->request->data, 'user' => $this->User->getAllFromCurrentUser())); $this->getEventManager()->dispatch($event); if ($event->isStopped()) { return $event->result; } - $this->Category->read(null, null); - $this->Category->set(array( + $this->Item->read(null, null); + $this->Item->set(array( 'name' => $this->request->data['name'], + 'description' => $this->request->data['description'], + 'category' => $this->request->data['category'], + 'price' => $this->request->data['price'], + 'servers' => $this->request->data['servers'], + 'commands' => $this->request->data['commands'], + 'img_url' => $this->request->data['img_url'], + 'timedCommand' => $this->request->data['timedCommand'], + 'timedCommand_cmd' => $this->request->data['timedCommand_cmd'], + 'timedCommand_time' => $this->request->data['timedCommand_time'], + 'display_server' => $this->request->data['display_server'], + 'need_connect' => $this->request->data['need_connect'], + 'display' => $this->request->data['display'], + 'multiple_buy' => $this->request->data['multiple_buy'], + 'broadcast_global' => $this->request->data['broadcast_global'], + 'cart' => $this->request->data['cart'], + 'prerequisites_type' => $this->request->data['prerequisites_type'], + 'prerequisites' => $this->request->data['prerequisites'], + 'reductional_items' => $this->request->data['reductional_items'], + 'give_skin' => $this->request->data['give_skin'], + 'give_cape' => $this->request->data['give_cape'], + 'buy_limit' => $this->request->data['buy_limit'], + 'wait_time' => $this->request->data['wait_time'] )); - $this->History->set('ADD_CATEGORY', 'shop'); - $this->Category->save(); - $this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_ADD_SUCCESS'), 'default.success'); + $this->Item->save(); + $this->History->set('ADD_ITEM', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__ITEM_DUPLICATE_SUCCESS'), 'default.success'); $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); } else { $this->Session->setFlash($this->Lang->get('ERROR__FILL_ALL_FIELDS'), 'default.error'); + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); } + + } else { + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); } } else { - $this->redirect('/'); + throw new ForbiddenException(); } } - /* * ======== Suppression d'une catégorie/article/paypal/starpass (traitement) =========== */ @@ -1043,10 +1111,30 @@ public function admin_delete($type = false, $id = false) $this->Category->delete($id); $this->History->set('DELETE_CATEGORY', 'shop'); $this->Session->setFlash($this->Lang->get('SHOP__CATEGORY_DELETE_SUCCESS'), 'default.success'); - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); } else { $this->Session->setFlash($this->Lang->get('UNKNONW_ID'), 'default.error'); - $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); + + } + } elseif ($type == "section") { + $this->loadModel('Shop.Section'); + $find = $this->Section->find('all', array('conditions' => array('id' => $id))); + if (!empty($find)) { + + $event = new CakeEvent('beforeDeleteCategory', $this, array('section_id' => $id, 'user' => $this->User->getAllFromCurrentUser())); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + + $this->Section->delete($id); + $this->History->set('DELETE_SECTION', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__SECTION_DELETE_SUCCESS'), 'default.success'); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); + } else { + $this->Session->setFlash($this->Lang->get('UNKNONW_ID'), 'default.error'); + $this->redirect(array('controller' => 'categories', 'action' => 'index', 'admin' => true)); } } elseif ($type == "paypal") { $this->loadModel('Shop.Paypal'); @@ -1067,7 +1155,26 @@ public function admin_delete($type = false, $id = false) $this->Session->setFlash($this->Lang->get('UNKNONW_ID'), 'default.error'); $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); } - } elseif ($type == "starpass") { + } elseif ($type == "nano") { + $this->loadModel('Shop.Nano'); + $find = $this->Nano->find('all', array('conditions' => array('id' => $id))); + if (!empty($find)) { + + $event = new CakeEvent('beforeDeleteNanoOffer', $this, array('offer_id' => $id, 'user' => $this->User->getAllFromCurrentUser())); + $this->getEventManager()->dispatch($event); + if ($event->isStopped()) { + return $event->result; + } + + $this->Nano->delete($id); + $this->History->set('DELETE_NANO_OFFER', 'shop'); + $this->Session->setFlash($this->Lang->get('SHOP__NANO_OFFER_DELETE_SUCCESS'), 'default.success'); + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + } else { + $this->Session->setFlash($this->Lang->get('UNKNONW_ID'), 'default.error'); + $this->redirect(array('controller' => 'shop', 'action' => 'index', 'admin' => true)); + } + }elseif ($type == "starpass") { $this->loadModel('Shop.Starpass'); $find = $this->Starpass->find('all', array('conditions' => array('id' => $id))); if (!empty($find)) { diff --git a/Model/Item.php b/Model/Item.php index c4b9f60..46c7905 100755 --- a/Model/Item.php +++ b/Model/Item.php @@ -53,11 +53,12 @@ public function checkPrerequisites($item, $user_id) public function getReductionWithReductionalItems($item, $user_id) { $reduction = 0; - if (empty($item['reductional_items']) || !is_array(($reductionsItems = unserialize($item['reductional_items'])))) + if (empty($item['reductional_items']) || !is_array(($reductionsItems = array_reverse(unserialize($item['reductional_items']))))) return $reduction; + foreach ($reductionsItems as $itemId) { - $findItem = $this->find('first', array('conditions' => array('id' => $itemId))); + $findItem = $this->find('first', array( 'conditions' => array('id' => $itemId))); if (empty($findItem)) continue; $findItem = $findItem['Item']; @@ -70,6 +71,7 @@ public function getReductionWithReductionalItems($item, $user_id) if (empty($findHistory)) continue; $reduction += $findItem['price']; + break; } return $reduction; } diff --git a/Model/Nano.php b/Model/Nano.php new file mode 100644 index 0000000..c65e4fe --- /dev/null +++ b/Model/Nano.php @@ -0,0 +1,38 @@ +listSources()) ){ + $this->query("CREATE TABLE IF NOT EXISTS `shop__nanos` ( + `id` int(20) NOT NULL AUTO_INCREMENT, + `address` varchar(65) NOT NULL, + `name` varchar(50) NOT NULL, + `price` varchar(20) NOT NULL, + `currency` varchar(3) DEFAULT NULL, + `money` varchar(20) NOT NULL, + `created` datetime NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + $this->query("CREATE TABLE IF NOT EXISTS `shop__nano_histories` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `token` varchar(300) NOT NULL, + `user_id` int(11) NOT NULL, + `offer_id` int(11) NOT NULL, + `payment_amount` varchar(20) NOT NULL, + `currency` varchar(3) DEFAULT NULL, + `credits_gived` varchar(10) DEFAULT NULL, + `created` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `U_token` (`token`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + } + // puis on clear le cache + App::uses('Folder', 'Utility'); + $folder = new Folder(ROOT . DS . 'app' . DS . 'tmp' . DS . 'cache'); + if (!empty($folder->path)) { + $folder->delete(); + } + // et on redirige sur la meme page comme si de rien etait + $controller->redirect(array('action' => 'index')); + } +} \ No newline at end of file diff --git a/Model/NanoHistory.php b/Model/NanoHistory.php new file mode 100644 index 0000000..aa72d2e --- /dev/null +++ b/Model/NanoHistory.php @@ -0,0 +1,9 @@ + array( + 'foreignKey' => 'offer_id' + ) + ); +} diff --git a/Model/Section.php b/Model/Section.php new file mode 100644 index 0000000..2e58f0b --- /dev/null +++ b/Model/Section.php @@ -0,0 +1,3 @@ + array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__dedipass_configs = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'public_key' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'status' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__dedipass_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'code' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 8, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'rate' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 30, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__items = array( - 'order' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 20, 'unsigned' => false), - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'description' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'price' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'servers' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'commands' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'img_url' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'category' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false), - 'timedCommand' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'timedCommand_cmd' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'timedCommand_time' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false), - 'display_server' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), - 'need_connect' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'display' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), - 'multiple_buy' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'broadcast_global' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), - 'cart' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'prerequisites_type' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 1, 'unsigned' => false, 'comment' => '1= tous les articles, 2 = au moins 1 des articles'), - 'prerequisites' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'reductional_items' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'give_skin' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'give_cape' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'buy_limit' => array('type' => 'integer', 'null' => true, 'default' => '0', 'unsigned' => false), - 'wait_time' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__items_buy_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'item_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__items_configs = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'goal' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => true), - 'broadcast_global' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'sort_by_server' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__paypal_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'payment_id' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'offer_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'payment_amount' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__paypals = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'email' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'price' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'money' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__paysafecard_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'code' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'amount' => array('type' => 'string', 'null' => false, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'credits_gived' => array('type' => 'string', 'null' => false, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'author_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__paysafecard_messages = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'type' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 1, 'unsigned' => false), - 'amount' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 3, 'unsigned' => false), - 'added_points' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__paysafecards = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'amount' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'code' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__points_transfer_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'points' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'author_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__starpass_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'code' => array('type' => 'string', 'null' => false, 'length' => 40, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'offer_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__starpasses = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'money' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false), - 'idd' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), - 'idp' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__vouchers = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), - 'code' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'type' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 1, 'unsigned' => false), - 'reduction' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 3, 'unsigned' => false), - 'effective_on' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'limit' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 10, 'unsigned' => false), + +class ShopAppSchema extends CakeSchema +{ + + public $file = 'schema.php'; + + public function before($event = array()) + { + return true; + } + + public function after($event = array()) + { + } + + public $shop__categories = array( + 'order' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 20, 'unsigned' => false), + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'section' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'section_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 8, 'unsigned' => false), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__sections = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__dedipass_configs = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'public_key' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'status' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__dedipass_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'code' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 8, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'rate' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 30, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__items = array( + 'order' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 20, 'unsigned' => false), + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'description' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'price' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'updated' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'servers' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'commands' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'img_url' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'category' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false), + 'timedCommand' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'timedCommand_cmd' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'timedCommand_time' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false), + 'display_server' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), + 'need_connect' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'display' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), + 'multiple_buy' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'broadcast_global' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), + 'cart' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'prerequisites_type' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 1, 'unsigned' => false, 'comment' => '1= tous les articles, 2 = au moins 1 des articles'), + 'prerequisites' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'reductional_items' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'give_skin' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'give_cape' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'buy_limit' => array('type' => 'integer', 'null' => true, 'default' => '0', 'unsigned' => false), + 'wait_time' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__items_buy_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'item_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__items_configs = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'goal' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => true), + 'broadcast_global' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'sort_by_server' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 1, 'unsigned' => false), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__paypal_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'payment_id' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'offer_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'payment_amount' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__paypals = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'email' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'price' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'money' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__nanos = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'address' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 65, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'price' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'currency' => array('type' => 'string', 'eur' => false, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'money' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__nano_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'token' => array('type' => 'string', 'null' => false, 'length' => 300, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'offer_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'payment_amount' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'currency' => array('type' => 'string', 'eur' => false, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1), + 'U_token' => array('column' => 'token', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__paysafecard_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'code' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'amount' => array('type' => 'string', 'null' => false, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'credits_gived' => array('type' => 'string', 'null' => false, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'author_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__paysafecard_messages = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'type' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 1, 'unsigned' => false), + 'amount' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 3, 'unsigned' => false), + 'added_points' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__paysafecards = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'amount' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'code' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__points_transfer_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'points' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'author_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__starpass_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'code' => array('type' => 'string', 'null' => false, 'length' => 40, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'offer_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'credits_gived' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__starpasses = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 50, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'money' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false), + 'idd' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), + 'idp' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__vouchers = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 20, 'unsigned' => false, 'key' => 'primary'), + 'code' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'type' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 1, 'unsigned' => false), + 'reduction' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 5, 'unsigned' => false), + 'effective_on' => array('type' => 'text', 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'limit' => array('type' => 'integer', 'null' => true, 'default' => '0', 'length' => 10, 'unsigned' => false), 'limit_type' => array('type' => 'integer', 'null' => true, 'default' => '1', 'length' => 1, 'unsigned' => false), // 1 = user, 2 = global - 'start_date' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'end_date' => array('type' => 'datetime', 'null' => false, 'default' => '2100-01-01 00:00:01'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'affich' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 1, 'unsigned' => false), - 'used' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); - - public $shop__vouchers_histories = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), - 'code' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), - 'reduction' => array('type' => 'string', 'null' => false, 'length' => 3, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1) - ), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') - ); + 'start_date' => array('type' => 'datetime', 'null' => true, 'default' => null), + 'end_date' => array('type' => 'datetime', 'null' => false, 'default' => '2100-01-01 00:00:01'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'affich' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 1, 'unsigned' => false), + 'used' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); + + public $shop__vouchers_histories = array( + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => true, 'key' => 'primary'), + 'code' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'user_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false), + 'reduction' => array('type' => 'string', 'null' => false, 'length' => 20, 'collate' => 'latin1_swedish_ci', 'charset' => 'latin1'), + 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), + 'indexes' => array( + 'PRIMARY' => array('column' => 'id', 'unique' => 1) + ), + 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'InnoDB') + ); } diff --git a/View/Categories/admin_add_category.ctp b/View/Categories/admin_add_category.ctp new file mode 100644 index 0000000..9968f32 --- /dev/null +++ b/View/Categories/admin_add_category.ctp @@ -0,0 +1,68 @@ +
+
+
+
+
+

get('SHOP__CATEGORY_ADD') ?>

+
+
+
+ +
+ +
+ + +
+ +
+
+ "> + id="section_checkbox" value="true" + name="section_checkbox" + type="checkbox"> + +
+
+ + + +
> + +

get('SHOP__CATEGORY_EDIT_MESSAGE') ?> get('SHOP__SECTIONS') ?> +

+ +
+ + + +
+ get('GLOBAL__CANCEL') ?> + +
+
+
+
+
+
+
diff --git a/View/Categories/admin_add_section.ctp b/View/Categories/admin_add_section.ctp new file mode 100644 index 0000000..6511d4e --- /dev/null +++ b/View/Categories/admin_add_section.ctp @@ -0,0 +1,30 @@ +
+
+
+
+
+

get('SHOP__SECTION_ADD') ?>

+
+
+
+ +
+ +
+ + +
+ + + +
+ get('GLOBAL__CANCEL') ?> + +
+
+
+
+
+
+
diff --git a/View/Categories/admin_edit.ctp b/View/Categories/admin_edit.ctp new file mode 100644 index 0000000..1317b07 --- /dev/null +++ b/View/Categories/admin_edit.ctp @@ -0,0 +1,68 @@ +
+
+
+
+
+

get('SHOP__CATEGORY_EDIT') ?>

+
+
+
+ +
+ +
+ + +
+ + +
+
+ + > + +
+
+ + + +
+ +

get('SHOP__CATEGORY_EDIT_MESSAGE') ?> get('SHOP__SECTIONS') ?> +

+ +
+ + + +
+ get('GLOBAL__CANCEL') ?> + +
+
+
+
+
+
+
diff --git a/View/Categories/admin_index.ctp b/View/Categories/admin_index.ctp new file mode 100644 index 0000000..6d49791 --- /dev/null +++ b/View/Categories/admin_index.ctp @@ -0,0 +1,173 @@ +
+
+
+

get('SHOP__CATEGORIES') ?>

get('SHOP__CATEGORIES_TIP') ?>
+
+
+

get('SHOP__SECTION') ?>

get('SHOP__SECTION_TIP') ?>
+
+
+
+
+

get('SHOP__SECTION_AND_CATEGORIES') ?>

+
+
+ + + + + + + + + + + $va) {?> + + + + + + + $v) { $a++;?> + -"> + + + + + + + +
get('SHOP__SECTIONS') ?> get('GLOBAL__ADD') ?>get('SHOP__CATEGORIES') ?>get('SHOP__CATEGORY_NUMBER') ?>get('GLOBAL__ACTIONS') ?>
+
+ "> + "> +
true)); ?>" class="btn btn-success ">get('GLOBAL__ADD') ?> + + true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> + +
+ + + true)) ?>" class="btn btn-info">get('GLOBAL__EDIT') ?> + true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> +
+
+
+ +
+
+
+
+

get('SHOP__CATEGORIES_NO') ?>

+
+
+ + + + + + + + + + $v) { $i++;?> + -"> + + + + + + +
get('SHOP__CATEGORIES') ?> get('GLOBAL__ADD') ?>get('SHOP__CATEGORY_NUMBER') ?>get('GLOBAL__ACTIONS') ?>
+ + + true)) ?>" class="btn btn-info">get('GLOBAL__EDIT') ?> + true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> +
+
+
+ +
+
+
+
+

get('SHOP__CATEGORIES_OTHER') ?>

+
+
+ + + + + + + + + + $v) { ?> + + + + + + + +
get('SHOP__CATEGORIES') ?>get('SHOP__CATEGORY_NUMBER') ?>get('GLOBAL__ACTIONS') ?>
+ + + true)) ?>" class="btn btn-info">get('GLOBAL__EDIT') ?> + true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> +
+
+
+
+
+
+ \ No newline at end of file diff --git a/View/Elements/payments_modal.ctp b/View/Elements/payments_modal.ctp index 3068f4a..999a47d 100755 --- a/View/Elements/payments_modal.ctp +++ b/View/Elements/payments_modal.ctp @@ -64,6 +64,79 @@
+ + +
+
+
+
+ + + +
+ +
+
+
+
+
+
+
+
diff --git a/View/Giftall/admin_index.ctp b/View/Giftall/admin_index.ctp index 793dcc0..d550dd9 100644 --- a/View/Giftall/admin_index.ctp +++ b/View/Giftall/admin_index.ctp @@ -1,11 +1,11 @@
-
-
-

get('SHOP__GIFTALL') ?>

+
+
+

get('SHOP__GIFTALL') ?>

-
+
diff --git a/View/Payment/admin_add_nano.ctp b/View/Payment/admin_add_nano.ctp new file mode 100644 index 0000000..4ea6710 --- /dev/null +++ b/View/Payment/admin_add_nano.ctp @@ -0,0 +1,53 @@ +
+
+
+
+
+

get('SHOP__NANO_OFFER_ADD') ?>

+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ get('GLOBAL__CANCEL') ?> + +
+ +
+
+
+
+
diff --git a/View/Payment/admin_add_paypal.ctp b/View/Payment/admin_add_paypal.ctp index 6c8b9c7..6bc3adc 100755 --- a/View/Payment/admin_add_paypal.ctp +++ b/View/Payment/admin_add_paypal.ctp @@ -1,11 +1,11 @@
-
-
-

get('SHOP__PAYPAL_OFFER_ADD') ?>

+
+
+

get('SHOP__PAYPAL_OFFER_ADD') ?>

-
+
diff --git a/View/Payment/admin_add_starpass.ctp b/View/Payment/admin_add_starpass.ctp index 979ae4e..667543d 100755 --- a/View/Payment/admin_add_starpass.ctp +++ b/View/Payment/admin_add_starpass.ctp @@ -6,11 +6,11 @@
-
-
-

get('SHOP__STARPASS_OFFER_ADD') ?>

+
+
+

get('SHOP__STARPASS_OFFER_ADD') ?>

-
+
diff --git a/View/Payment/admin_edit_nano.ctp b/View/Payment/admin_edit_nano.ctp new file mode 100644 index 0000000..4ebda81 --- /dev/null +++ b/View/Payment/admin_edit_nano.ctp @@ -0,0 +1,53 @@ +
+
+
+
+
+

get('SHOP__NANO_OFFER_EDIT') ?>

+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ get('GLOBAL__CANCEL') ?> + +
+ +
+
+
+
+
diff --git a/View/Payment/admin_edit_paypal.ctp b/View/Payment/admin_edit_paypal.ctp index 9de290e..d1148e9 100755 --- a/View/Payment/admin_edit_paypal.ctp +++ b/View/Payment/admin_edit_paypal.ctp @@ -1,11 +1,11 @@
-
-
-

get('SHOP__PAYPAL_OFFER_EDIT') ?>

+
+
+

get('SHOP__PAYPAL_OFFER_EDIT') ?>

-
+
diff --git a/View/Payment/admin_edit_starpass.ctp b/View/Payment/admin_edit_starpass.ctp index ccad8a7..7c50f12 100755 --- a/View/Payment/admin_edit_starpass.ctp +++ b/View/Payment/admin_edit_starpass.ctp @@ -6,11 +6,11 @@
-
-
-

get('SHOP__STARPASS_OFFER_EDIT') ?>

+
+
+

get('SHOP__STARPASS_OFFER_EDIT') ?>

-
+
diff --git a/View/Payment/admin_index.ctp b/View/Payment/admin_index.ctp index 4a2cf45..f0b1f43 100755 --- a/View/Payment/admin_index.ctp +++ b/View/Payment/admin_index.ctp @@ -1,410 +1,560 @@
-
-
-
-
-

get('SHOP__ADMIN_MANAGE_PAYMENT') ?>

-
-
- -
diff --git a/View/Shop/admin_add_category.ctp b/View/Shop/admin_add_category.ctp deleted file mode 100755 index c476893..0000000 --- a/View/Shop/admin_add_category.ctp +++ /dev/null @@ -1,29 +0,0 @@ -
-
-
-
-
-

get('SHOP__CATEGORY_ADD') ?>

-
-
-
- -
- -
- - -
- - - -
- get('GLOBAL__CANCEL') ?> - -
-
-
-
-
-
-
diff --git a/View/Shop/admin_add_item.ctp b/View/Shop/admin_add_item.ctp index 2f70612..17e02ad 100755 --- a/View/Shop/admin_add_item.ctp +++ b/View/Shop/admin_add_item.ctp @@ -1,318 +1,330 @@
-
-
-
-
-

get('SHOP__ITEM_ADD') ?>

-
-
-
- -
- -
- - -
- -
- - - Html->script('admin/tinymce/tinymce.min.js') ?> - -
- -
- - -
- - -
- - -
- -
- -
-
- - -
-
- -
- -
-
- - -
-
- -
- -
- - -
- -
- -
- - -
- -
-
- - -
-
- -
- -
- -
- -
-
-
- {PLAYER} = Pseudo
get('GLOBAL__EXAMPLE') ?>: give {PLAYER} 1 1
-
- -
-
- - -
-
- -
-
- - -
-
- -
- -
-
- - -
-
- -
-
- - -
-
- -
- -
- -
- - -
-
- - -
- get('SHOP__ITEM_TIMED_COMMAND_DESC') ?> -
- - -
- -
-
- - -
-
- -
- -
- - -
- - - - - -
- -
-
- - -
-
- - - - - -
- -
- - -
- -
- -
- -
-
- +
+
+
+
+

get('SHOP__ITEM_ADD') ?>

-
- +
+ + +
+ +
+ + +
+ +
+ + + Html->script('admin/tinymce/tinymce.min.js') ?> + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+
+ + +
+
+
+ +
+ +
+ +
+
+
+ {PLAYER} = Pseudo
get('GLOBAL__EXAMPLE') ?>: give + {PLAYER} 1 1
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ +
+ +
+ + +
+
+ + +
+ get('SHOP__ITEM_TIMED_COMMAND_DESC') ?> +
+ + +
+ +
+
+ + +
+
+ +
+ +
+ + +
+ + + + + +
+ +
+
+ + +
+
+ + + + + +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+ get('GLOBAL__CANCEL') ?> + +
+
-
-
- -
- get('GLOBAL__CANCEL') ?> -
-
-
-
diff --git a/View/Shop/admin_add_voucher.ctp b/View/Shop/admin_add_voucher.ctp index 3382b0b..70335b0 100755 --- a/View/Shop/admin_add_voucher.ctp +++ b/View/Shop/admin_add_voucher.ctp @@ -1,11 +1,11 @@
-
-
-

get('SHOP__VOUCHER_ADD') ?>

+
+
+

get('SHOP__VOUCHER_ADD') ?>

-
+
-
+
- - - +
+ +
@@ -80,29 +80,38 @@
-
-
- +
+ +
+
-
- get('SHOP__VOUCHER_START_DATE_EXPLAIN') ?> + + get('SHOP__VOUCHER_START_DATE_EXPLAIN') ?>
+
-
-
- +
+ +
+
-
+
+
@@ -174,9 +184,7 @@ return Chaine; } -Html->script('moment') ?> -Html->script('bootstrap-datetimepicker') ?> -Html->css('bootstrap-datetimepicker') ?> + -
- -
- - -
- - -
- - -
- -
- -
-
- > - -
-
- -
- -
-
- > - -
-
- -
- -
- - -
- -
- -
- - -
- -
-
- > - -
-
- -
- -
- -
- +
+
+
+
+

get('SHOP__ITEM_EDIT') ?>

-
-
- $value) { - $i++; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'; - } - ?> -
- {PLAYER} = Pseudo
[{+}] get('SERVER__PARSE_NEW_COMMAND') ?>
get('GLOBAL__EXAMPLE') ?>: give {PLAYER} 1 1[{+}]broadcast {PLAYER} ...
-
- -
-
- > - -
-
- -
-
- > - -
-
- -
- -
-
- > - -
-
- -
-
- > - -
-
- -
- -
- -
- > - -
-
- > - -
- get('SHOP__ITEM_TIMED_COMMAND_DESC') ?> -
-
-
- - - {PLAYER} = Pseudo
[{+}] get('SERVER__PARSE_NEW_COMMAND') ?>
get('GLOBAL__EXAMPLE') ?>: give {PLAYER} 1 1[{+}]broadcast {PLAYER} ...
-
-
- - -
-
- -
- -
-
- > - -
-
- -
- -
- - -
- - - -
- - -
- -
- -
-
- > - -
-
- - - -
- - -
- -
- -
- - -
- -
- -
- -
-
- -
-
- +
+ + +
+ + + +
+ + +
+ +
+ + + Html->script('admin/tinymce/tinymce.min.js') ?> + + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+
+ > + +
+
+ +
+ +
+
+ > + +
+
+ +
+ +
+ + +
+ +
+ +
+ + +
+ +
+
+ > + +
+
+ +
+ +
+ +
+ +
+
+ +
+ $value) { + $i++; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + } + ?> +
+ {PLAYER} = Pseudo
+ [{+}] get('SERVER__PARSE_NEW_COMMAND') ?> +
get('GLOBAL__EXAMPLE') ?>: give {PLAYER} 1 1[{+}]broadcast + {PLAYER} ...
+
+ +
+
+ > + +
+
+ +
+
+ > + +
+
+ +
+ +
+
+ > + +
+
+ +
+
+ > + +
+
+ +
+ +
+ +
+ > + +
+
+ > + +
+ get('SHOP__ITEM_TIMED_COMMAND_DESC') ?> +
+
+
+ + + {PLAYER} = Pseudo
+ [{+}] get('SERVER__PARSE_NEW_COMMAND') ?> +
get('GLOBAL__EXAMPLE') ?>: give {PLAYER} 1 1[{+}]broadcast + {PLAYER} ...
+
+
+ + +
+
+ +
+ +
+
+ > + +
+
+ +
+ +
+ + +
+ + + +
+ + +
+ +
+ +
+
+ > + +
+
+ + + +
+ + +
+ +
+ +
+ + +
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+ get('GLOBAL__CANCEL') ?> + +
+
-
-
- -
- get('GLOBAL__CANCEL') ?> -
-
-
-
diff --git a/View/Shop/admin_index.ctp b/View/Shop/admin_index.ctp index d506c2a..4b164dc 100755 --- a/View/Shop/admin_index.ctp +++ b/View/Shop/admin_index.ctp @@ -1,184 +1,257 @@
-
-
-
-
-

get('SHOP__CONFIG') ?>

-
-
-
+
+
+
+
+

get('SHOP__CONFIG') ?>

+
-
- - > -
-
- -

get('SHOP__CONFIG_GOAL_DESC') ?>

- > -
+
+ - +
+ + > +
+
+ +

get('SHOP__CONFIG_GOAL_DESC') ?>

+ > +
-
- -
+
+ +
- -
-
-
-
-
-
-

get('SHOP__CONFIG_EXPLAIN_TITLE') ?>

+ +
+
-
-
-

get('SHOP__CONFIG_EXPLAIN') ?>

-
-

get('SHOP__CONFIG_VARIABLES') ?> :

-

{ITEM_NAME} : get('SHOP__CONFIG_VARIABLE_ITEM') ?>

-

{QUANTITY} : get('SHOP__CONFIG_VARIABLE_QUANTITY') ?>

-

{PLAYER} : get('SHOP__CONFIG_VARIABLE_PLAYER') ?>

-

{SERVERNAME} : get('SHOP__CONFIG_VARIABLE_SERVERNAME') ?>

+
+
+
+

get('SHOP__CONFIG_EXPLAIN_TITLE') ?>

+
+
+
+

get('SHOP__CONFIG_EXPLAIN') ?>

+
+

get('SHOP__CONFIG_VARIABLES') ?> :

+

{ITEM_NAME} : get('SHOP__CONFIG_VARIABLE_ITEM') ?>

+

{QUANTITY} : get('SHOP__CONFIG_VARIABLE_QUANTITY') ?>

+

{PLAYER} : get('SHOP__CONFIG_VARIABLE_PLAYER') ?>

+

{SERVERNAME} : get('SHOP__CONFIG_VARIABLE_SERVERNAME') ?>

+
+
-
-
-
-
-
-

get('SHOP__ITEMS_AVAILABLE') ?>   get('GLOBAL__ADD') ?>

-
-
-

get('SHOP__CATEGORIES') ?>   get('GLOBAL__ADD') ?>

-
-
+
+
+
+

get("SHOP__MENU_ITEMS") ?>

+
+
- - - - - - - - - - - $v) {?> - - - - - - - $va) { $i++; - if ($categories[$va["Item"]["category"]]['name'] == $v["Category"]["name"]) { - ?> - -"> - - - - - - - - -
get('GLOBAL__NAME') ?>get('SHOP__ITEMS_AVAILABLE') ?>get('SHOP__ITEM_PRICE') ?>get('GLOBAL__ACTIONS') ?>
-
- "> - "> -
- - true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> -
getMoneyName() ?> - true)) ?>" class="btn btn-info">get('GLOBAL__EDIT') ?> - true)) ?>')" class="btn btn-danger">get('GLOBAL__DELETE') ?> -
-
-
- -
+ + +
+
-
-
-
-
-
-
-

get('SHOP__HISTORY_PURCHASES') ?>

-
-
- - - - - - - - - - -
get('SHOP__ITEM') ?>Pseudoget('GLOBAL__CREATED') ?>
+
+
+
+

get('SHOP__HISTORY_PURCHASES') ?>

+
+
-
+ + + + + + + + + + + +
get('SHOP__ITEM') ?>PseudoUUIDget('GLOBAL__CREATED') ?>
+ +
+
-
+
-
- diff --git a/View/Shop/admin_vouchers.ctp b/View/Shop/admin_vouchers.ctp index 0480f22..075cecc 100755 --- a/View/Shop/admin_vouchers.ctp +++ b/View/Shop/admin_vouchers.ctp @@ -5,11 +5,11 @@ $this->DiscountVoucher = new DiscountVoucherComponent;
-
-
-

get('SHOP__VOUCHERS_MANAGE') ?>   get('GLOBAL__ADD') ?>

+
+
+

get('SHOP__VOUCHERS_MANAGE') ?>   get('GLOBAL__ADD') ?>

-
+
@@ -54,11 +54,11 @@ $this->DiscountVoucher = new DiscountVoucherComponent;
-
-
-

get('SHOP__VOUCHERS_HISTORIES') ?>

+
+
+

get('SHOP__VOUCHERS_HISTORIES') ?>

-
+
diff --git a/View/Shop/index.ctp b/View/Shop/index.ctp index b350b35..7145a2b 100755 --- a/View/Shop/index.ctp +++ b/View/Shop/index.ctp @@ -1,89 +1,85 @@ Html->css('Shop.shop-homepage.css') ?> Html->css('Shop.jquery.bootstrap-touchspin.css') ?>
-
-
-

getMoneyName() : $Lang->get('SHOP__TITLE'); ?>

-
- $v) { - $i++; - ?> - - -
- can('CREDIT_ACCOUNT')) { ?> - -
-

get('SHOP__CONFIG_GOAL_TITLE') ?>

-
-
- % -
+
+
+

get('SHOP__TITLE'); ?>

+
+
-
- - get('SHOP__ADD_MONEY') ?> - + can('CREDIT_ACCOUNT')) { ?> + +
+

get('SHOP__CONFIG_GOAL_TITLE') ?>

+
+
+ % +
+
+
+ + get('SHOP__ADD_MONEY') ?> + - get('SHOP__BUY_CART') ?> + get('SHOP__BUY_CART') ?>
-
-
- get_vouchers() // Les promotions en cours ?> -
- -
- $v) { - if(!isset($category) AND $v['Item']['category'] == $search_first_category OR isset($category) AND $v['Item']['category'] == $category) { - $i++; - $newRow = ( ( $i % ( (12 / $col) ) ) == 0); - ?> -
-
- -
-

-

-

-

Text->truncate( - strip_tags($v['Item']['description']), - 140, - array('ellipsis' => '...', 'html' => true) - ) - ?>

- can('CAN_BUY')) { ?> +
+
get_vouchers() // Current promotions ?>
+
+ $v) { + if(!isset($category) AND $v['Item']['category'] == $search_first_category OR isset($category) AND $v['Item']['category'] == $category) { + $i++; + $newRow = ( ( $i % ( (12 / $col) ) ) == 0); ?> +
+
+ +
+

+

+

Text->truncate(strip_tags($v['Item']['description']), 140, ['ellipsis' => '...', 'html' => true]) ?>

+ can('CAN_BUY')) { ?> +
+
-
-
- - ' : '' ?> - ' : '' ?> - - + ' : '' ?> + ' : '' ?> + + +
-
@@ -91,34 +87,34 @@ Html->script('Shop.shop') ?> Html->script('Shop.jquery.bootstrap-touchspin.js') ?>
'; - table += ''; + // We open the table + var table = '
'; + table += ''; table += ''; - table += ''; - table += ''; - table += ''; - table += ''; + table += ''; + table += ''; + table += ''; + table += ''; table += ''; - table += ''; - table += ''; - - // On récupère les cookies - $.cookie.json = true; - - var cart = $.cookie('cart'); - - var notEmpty = false; - - var total = 0; - - for (var key in cart) { - - if(cart[key] !== null) { - - notEmpty = true; - - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - - total += parseFloat(cart[key]['item_price']) * cart[key]['quantity']; - - } - - } - - // On ferme la table - table += ''; - table += ''; - - if(notEmpty) { - $('#cart-total-price').html(total); - $('#buy-cart').attr('disabled', false); - $('#buy-cart').removeClass('disabled'); - $('#cart-modal .modal-body').html(table); - } else { - $('#cart-total-price').html('0'); - $('#buy-cart').attr('disabled', true); - $('#buy-cart').addClass('disabled'); - $('#cart-modal .modal-body').html('
'+CART_EMPTY_MSG+'
'); - } - - // On gère la suppression - $('.remove-from-cart').unbind('click'); - $('.remove-from-cart').click(function(e) { - - e.preventDefault(); - - var cartContent = $.cookie('cart'); // on récupère le panier - var newCart = [];// le nouveau panier (pour éviter les values null) - - var item_id = $(this).attr('data-item-id'); + table += ''; + table += '
'; + // We get cookies + $.cookie.json = true; + var cart = $.cookie('cart'); + var notEmpty = false; var total = 0; - for (var k in cartContent) { - if(cartContent[k] !== null && cartContent[k]['item_id'] != item_id) { // si c'est pas l'article qu'on cherche - - newCart.push(cartContent[k]); + for (var key in cart) { + if (cart[key] !== null) { + notEmpty = true; - total += parseFloat(cartContent[k]['item_price']) * cartContent[k]['quantity']; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; - } + total += parseFloat(cart[key]['item_price']) * cart[key]['quantity']; + } } - $.cookie('cart', newCart); // On le met dans les cookies maintenant + // We close the table + table += ''; + table += ''; - if(newCart.length > 0) { - $('#cart-total-price').html(total); - $('#cart-modal .modal-body').find('tr[data-item-id="'+item_id+'"]').slideUp(150); // On l'enlève de la table + if (notEmpty) { + $('#cart-total-price').html(total.toFixed(2)); + $('#buy-cart').attr('disabled', false); + $('#buy-cart').removeClass('disabled'); + $('#cart-modal .modal-body').html(table); } else { - $('#buy-cart').attr('disabled', true); - $('#buy-cart').addClass('disabled'); - $('#cart-total-price').html('0'); - $('#cart-modal .modal-body').html('
'+CART_EMPTY_MSG+'
'); + $('#cart-total-price').html('0'); + $('#buy-cart').attr('disabled', true); + $('#buy-cart').addClass('disabled'); + if (response_msg === false) { + $('#cart-modal .modal-body').html('
' + CART_EMPTY_MSG + '
'); + } else { + $("#cart-modal .modal-body").html('
' + response_msg + '
').fadeIn('150'); + } } - newCart = undefined; - - }); - - // on gère le code promo - $("input[name='cart-voucher']").unbind('keyup'); - $("input[name='cart-voucher']").on('keyup', function(e) { - - var code = $('input[name="cart-voucher"]').val(); + // Removing an item from the cart + $('.remove-from-cart').unbind('click'); + $('.remove-from-cart').click(function(e) { + e.preventDefault(); - $("#cart-modal .modal-footer").find('#cart-total-price').html(''+LOADING_MSG+'...'); - $("#cart-modal .modal-footer").find('#buy-cart').addClass('disabled').attr('disabled', true); + var cartContent = $.cookie('cart'); // we get the basket + var newCart = []; // the new basket (to avoid null values) + var item_id = $(this).attr('data-item-id'); + var total = 0; - if(code.length == 0) { //si y'a pas de code promo - - var total_price = 0; - var cartContent = $.cookie('cart'); - for (var key in cartContent) { - i++; - total_price += cartContent[key]['item_price'] * cartContent[key]['quantity']; - } - - $("#cart-modal .modal-footer").find('#buy-cart').removeClass('disabled').attr('disabled', false); - - $("#cart-modal .modal-footer").find('#cart-total-price').html(total_price); - } else { // si y'a un code promo - on re-calcule le prix selon la quantité - - var cartContent = $.cookie('cart'); - var ids = ''; - var quantities = ''; - var i = 0; - for (var key in cartContent) { - i++; - ids += cartContent[key]['item_id']; - quantities += cartContent[key]['quantity']; - if(i < cartContent.length) { - ids += ','; - quantities += ','; + for (var k in cartContent) { + if (cartContent[k] !== null && cartContent[k]['item_id'] != item_id) { // if this is not the item you are looking for + newCart.push(cartContent[k]); + total += parseFloat(cartContent[k]['item_price']) * cartContent[k]['quantity']; + } } - } - $.get(VOUCHER_CHECK_URL+code+'/'+ids+'/'+quantities, function(data) { - if(data.price !== undefined) { - $("#cart-modal .modal-footer").find('#cart-total-price').html(data.price); - } - $("#cart-modal .modal-footer").find('#buy-cart').removeClass('disabled').attr('disabled', false); - }); + $.cookie('cart', newCart); // We put it in the cookies now - } + if (newCart.length > 0) { + $('#cart-total-price').html(total.toFixed(2)); + $('#cart-modal .modal-body').find('tr[data-item-id="' + item_id + '"]').slideUp(150); // We take it off the table + } else { + $('#buy-cart').attr('disabled', true); + $('#buy-cart').addClass('disabled'); + $('#cart-total-price').html('0'); + $('#cart-modal .modal-body').html('
' + CART_EMPTY_MSG + '
'); + } + }); - }); + // Promo code input + $("input[name='cart-voucher']").unbind('keyup'); + $("input[name='cart-voucher']").on('keyup', function(e) { + var code = $('input[name="cart-voucher"]').val(); + + $("#cart-modal .modal-footer").find('#cart-total-price').html('' + LOADING_MSG + '...'); + $("#cart-modal .modal-footer").find('#buy-cart').addClass('disabled').attr('disabled', true); + + if (code.length == 0) { // if there is no promo code + var cartContent = $.cookie('cart'); + var total_price = 0; + for (var key in cartContent) total_price += cartContent[key]['item_price'] * cartContent[key]['quantity']; + + $("#cart-modal .modal-footer").find('#buy-cart').removeClass('disabled').attr('disabled', false); + $("#cart-modal .modal-footer").find('#cart-total-price').html(total_price.toFixed(2)); + + } else { // if there is a promo code - we re-calculate the price according to the quantity + + var cartContent = $.cookie('cart'); + var ids = ''; + var quantities = ''; + var i = 0; + for (var key in cartContent) { + i++; + ids += cartContent[key]['item_id']; + quantities += cartContent[key]['quantity']; + if (i < cartContent.length) { + ids += ','; + quantities += ','; + } + } + $.get(VOUCHER_CHECK_URL + code + '/' + ids + '/' + quantities, function(data) { + if (data.price !== undefined) $("#cart-modal .modal-footer").find('#cart-total-price').html(data.price.toFixed(2)); + $("#cart-modal .modal-footer").find('#buy-cart').removeClass('disabled').attr('disabled', false); + }); + } + }); }
'+CART_ITEM_NAME_MSG+''+CART_ITEM_PRICE_MSG+''+CART_ITEM_QUANTITY_MSG+''+CART_ACTIONS_MSG+'' + CART_ITEM_NAME_MSG + '' + CART_ITEM_PRICE_MSG + '' + CART_ITEM_QUANTITY_MSG + '' + CART_ACTIONS_MSG + '
'+cart[key]['item_name']+''+cart[key]['item_price']+''+cart[key]['quantity']+'
' + cart[key]['item_name'] + '' + cart[key]['item_price'] + '' + cart[key]['quantity'] + '