[ SYSTEM ]: Windows NT SWD-ELEARN-11 10.0 build 20348 (Windows Server 2016) AMD64
[ SERVER ]: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.9 | PHP: 7.3.9
[ USER ]: Elearn | IP: 10.201.204.156
GEFORCE FILE MANAGER
/
C:
/
xampp
/
htdocs
/
Ajaji
/
backup
/
administrator
/
components
/
com_gridbox
/
models
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📁 fields
SET
[ DEL ]
📁 forms
SET
[ DEL ]
📄 appslist.php
7,284 B
SET
[ EDIT ]
|
[ DEL ]
📄 authors.php
10,277 B
SET
[ EDIT ]
|
[ DEL ]
📄 category.php
11,817 B
SET
[ EDIT ]
|
[ DEL ]
📄 gridbox.php
53,058 B
SET
[ EDIT ]
|
[ DEL ]
📄 orders.php
29,865 B
SET
[ EDIT ]
|
[ DEL ]
📄 pages.php
9,967 B
SET
[ EDIT ]
|
[ DEL ]
📄 productoptions.php
10,089 B
SET
[ EDIT ]
|
[ DEL ]
📄 shipping.php
5,535 B
SET
[ EDIT ]
|
[ DEL ]
📄 single.php
8,384 B
SET
[ EDIT ]
|
[ DEL ]
📄 tags.php
11,452 B
SET
[ EDIT ]
|
[ DEL ]
📄 themes.php
2,326 B
SET
[ EDIT ]
|
[ DEL ]
📄 trashed.php
3,982 B
SET
[ EDIT ]
|
[ DEL ]
📄 uploader.php
531 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: orders.php
<?php /** * @package Gridbox * @author Balbooa http://www.balbooa.com/ * @copyright Copyright @ Balbooa * @license http://www.gnu.org/licenses/gpl.html GNU/GPL */ defined('_JEXEC') or die; // import Joomla modelform library jimport('joomla.application.component.modeladmin'); jimport('joomla.filesystem.path'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); use Joomla\Registry\Registry; class gridboxModelOrders extends JModelList { public function __construct($config = []) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'state', 'publish_up', 'publish_down' ); } parent::__construct($config); } public function getUserInfo($id) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_user_info') ->where('user_id = '.$id); $db->setQuery($query); $list = $db->loadObjectList(); $info = new stdClass(); foreach ($list as $value) { $info->{$value->customer_id} = $value; } return $info; } public function getItem() { $input = JFactory::getApplication()->input; $id = $input->get('id', 0, 'string'); $order = $this->getOrder($id); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_customer_info') ->order('order_list ASC'); $db->setQuery($query); $info = $db->loadObjectList(); $obj = new stdClass(); $empty = new stdClass(); $empty->title = ''; $empty->items = []; $array = []; $object = null; foreach ($order->info as $value) { $value->empty = true; $obj->{$value->customer_id} = $value; } foreach ($info as $value) { if (!$object || $value->type == 'headline') { $array[] = new stdClass(); $object = end($array); $object->title = $value->type == 'headline' && $value->invoice == 1 ? $value->title : ''; $object->items = []; } if ($value->type != 'headline' && $value->type != 'acceptance' && isset($obj->{$value->id})) { $obj->{$value->id}->empty = false; $obj->{$value->id}->invoice = $value->invoice; if ($obj->{$value->id}->value === '' || $obj->{$value->id}->invoice == 0) { continue; } $object->items[] = $obj->{$value->id}; } } foreach ($obj as $value) { if ($value->empty && $value->type != 'headline' && $value->type != 'acceptance') { if ($value->value === '' || $value->invoice == 0) { continue; } $empty->items[] = $value; } } $array[] = $empty; $order->contact_info = $array; return $order; } public function getOrder($id) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_orders') ->where('id = '.$id); $db->setQuery($query); $order = $db->loadObject(); if (!empty($order->user_id)) { $query = $db->getQuery(true) ->select('id, username') ->from('#__users') ->where('id = '.$order->user_id); $db->setQuery($query); $order->user = $db->loadObject(); } if ($order->unread == 1) { $query = $db->getQuery(true) ->update('#__gridbox_store_orders') ->set('unread = 0') ->where('id = '.$id); $db->setQuery($query) ->execute(); } $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_orders_discount') ->where('order_id = '.$id); $db->setQuery($query); $order->promo = $db->loadObject(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_orders_shipping') ->where('order_id = '.$id); $db->setQuery($query); $order->shipping = $db->loadObject(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_orders_payment') ->where('order_id = '.$id); $db->setQuery($query); $order->payment = $db->loadObject(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_order_products') ->where('order_id = '.$id); $db->setQuery($query); $order->products = $db->loadObjectList(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_products_fields'); $db->setQuery($query); $fields = $db->loadObjectList(); $fieldsData = []; foreach ($fields as $field) { $options = json_decode($field->options); foreach ($options as $option) { $option->value = $option->title; $option->title = $field->title; $option->type = $field->field_type; $fieldsData[$option->key] = $option; } } foreach ($order->products as $product) { $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_order_product_variations') ->where('product_id = '.$product->id); $db->setQuery($query); $product->variations = $db->loadObjectList(); $info = []; foreach ($product->variations as $variation) { $info[] = '<span>'.$variation->title.' '.$variation->value.'</span>'; } $product->info = implode('/', $info); $query = $db->getQuery(true) ->select('p.title, p.intro_image AS image, d.*') ->from('#__gridbox_pages AS p') ->where('d.product_id = '.$product->product_id) ->where('p.page_category <> '.$db->quote('trashed')) ->leftJoin('#__gridbox_store_product_data AS d ON d.product_id = p.id'); $db->setQuery($query); $obj = $db->loadObject(); if (!$obj) { continue; } $variations = json_decode($obj->variations); if (!empty($product->variation) && !isset($variations->{$product->variation})) { continue; } if (!empty($product->variation)) { $data = $variations->{$product->variation}; } else { $data = new stdClass(); $data->price = $obj->price; $data->sale_price = $obj->sale_price; $data->sku = $obj->sku; $data->stock = $obj->stock; } $min = !empty($obj->min) ? $obj->min * 1 : 1; if ($data->stock != '' && $data->stock * 1 < $min) { continue; } $data->min = $obj->min; $data->id = $obj->product_id; $data->dimensions = !empty($obj->dimensions) ? json_decode($obj->dimensions) : new stdClass(); $data->title = $obj->title; $data->image = $obj->image; $data->prices = new stdClass(); $data->prices->price = gridboxHelper::preparePrice($data->price); $data->product_type = $obj->product_type; if (!empty($data->sale_price)) { $data->prices->sale = gridboxHelper::preparePrice($data->sale_price); } $data->categories = gridboxHelper::getProductCategoryId($obj->product_id); $data->variations = []; $product->extra = gridboxHelper::getProductExtraOptions($obj->extra_options); $product->extra_options = !empty($product->extra_options) ? json_decode($product->extra_options) : new stdClass(); if (isset($product->extra_options->price)) { $product->price -= $product->extra_options->price * $product->quantity; } if ($product->sale_price && isset($product->extra_options->price)) { $product->sale_price -= $product->extra_options->price * $product->quantity; } $data->extra_options = new stdClass(); $data->extra_options->count = $data->extra_options->price = 0; $data->extra_options->items = new stdClass(); if (isset($product->extra_options->items)) { foreach ($product->extra_options->items as $ind => $item) { if (!isset($product->extra->{$ind})) { continue; } $count = 0; $object = $product->extra->{$ind}; $extra = new stdClass(); $extra->title = $object->title; $extra->required = $object->required == '1'; $extra->values = new stdClass(); if (isset($item->attachments) && $object->type == 'file') { $extra->attachments = $item->attachments; $extra->price = $object->items->{0}->price; $extra->charge = $object->file->charge; $extra->quantity = $object->file->quantity; if ($extra->price != '') { $data->extra_options->price += $extra->price * ($extra->charge ? count($extra->attachments) : 1); } $count++; } foreach ($item->values as $key => $value) { if (!isset($object->items->{$key})) { continue; } $value->value = $value->value; $value->price = $object->items->{$key}->price; $count++; if ($value->price != '') { $data->extra_options->price += $value->price * 1; } $extra->values->{$key} = $value; } if ($count == 0) { continue; } $data->extra_options->count += $count; $data->extra_options->items->{$ind} = $extra; } } $data->extra = $product->extra; $data->variation = $product->variation; if (!empty($data->variation)) { $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_product_variations_map') ->where('product_id = '.$obj->product_id); $db->setQuery($query); $map = $db->loadObjectList(); $images = new stdClass(); foreach ($map as $variation) { $images->{$variation->option_key} = json_decode($variation->images); } $info = []; $array = explode('+', $product->variation); foreach ($array as $var) { if (isset($fieldsData[$var])) { $info[] = '<span>'.$fieldsData[$var]->title.' '.$fieldsData[$var]->value.'</span>'; $data->variations[] = $fieldsData[$var]; } if (!empty($images->{$var})) { $data->image = $images->{$var}[0]; } } $data->info = implode('/', $info); } $data->subscription = !empty($obj->subscription) ? json_decode($obj->subscription) : new stdClass(); $product->data = $data; } $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_order_customer_info') ->where('order_id = '.$id) ->order('order_list ASC, id ASC'); $db->setQuery($query); $order->info = $db->loadObjectList(); $order->tracking = gridboxHelper::$storeHelper->getTracking($id); return $order; } public function setTracking($obj) { $db = JFactory::getDbo(); if (empty($obj->id)) { $db->insertObject('#__gridbox_store_order_tracking', $obj); $obj->id = $db->insertid(); } else { $db->updateObject('#__gridbox_store_order_tracking', $obj, 'id'); } return $obj; } public function removeAttached($where) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('a.*') ->from('#__gridbox_store_product_attachments AS a') ->leftJoin('#__gridbox_store_cart_attachments_map AS m ON m.id = a.attachment_id') ->where($where); $db->setQuery($query); $files = $db->loadObjectList(); $ids = []; foreach ($files as $obj) { $file = JPATH_ROOT.'/'.gridboxHelper::$storeHelper->attachments.'/'.$obj->filename; JFile::delete($file); $ids[] = $obj->id; } if (!empty($ids)) { $str = implode(', ', $ids); $query = $db->getQuery(true) ->delete('#__gridbox_store_product_attachments') ->where('id IN ('.$str.')'); $db->setQuery($query) ->execute(); } } public function updateOrder($cart, $user_id) { $db = JFactory::getDbo(); $order = new stdClass(); $order->id = $cart->order_id; $order->subtotal = $cart->subtotal; $order->tax = $cart->tax; $order->total = $cart->total; $order->user_id = $user_id; $order->currency_symbol = gridboxHelper::$store->currency->symbol; $order->currency_position = gridboxHelper::$store->currency->position; $db->updateObject('#__gridbox_store_orders', $order, 'id'); if ($cart->validPromo) { $discount = new stdClass(); $discount->order_id = $order->id; $discount->promo_id = $cart->promo->id; $discount->title = $cart->promo->title; $discount->code = $cart->promo->code; $discount->unit = $cart->promo->unit; $discount->discount = $cart->promo->discount; $discount->value = $cart->discount; $order->discount = $discount; if (isset($cart->promo->db_id)) { $discount->id = $cart->promo->db_id; $db->updateObject('#__gridbox_store_orders_discount', $discount, 'id'); } else { $this->deleteTable($db, '#__gridbox_store_orders_discount', 'order_id = '.$order->id); $db->insertObject('#__gridbox_store_orders_discount', $discount); } } if ($cart->shipping) { $shipping = new stdClass(); $shipping->order_id = $order->id; $params = json_decode($cart->shipping->options); $shipping->type = $params->type; $shipping->title = $cart->shipping->title; $shipping->price = $cart->shipping->price; $shipping->tax = $cart->shipping->tax; $shipping->shipping_id = $cart->shipping->id; if (isset($cart->shipping->db_id)) { $shipping->id = $cart->shipping->db_id; $db->updateObject('#__gridbox_store_orders_shipping', $shipping, 'id'); } else { $this->deleteTable($db, '#__gridbox_store_orders_shipping', 'order_id = '.$order->id); $db->insertObject('#__gridbox_store_orders_shipping', $shipping); } } $pids = []; $vids = []; $files = []; foreach ($cart->products as $obj) { foreach ($obj->extra_options->items as $extra) { if (isset($extra->attachments)) { foreach ($extra->attachments AS $attachment) { $files[] = $attachment->id; } } } $product = gridboxHelper::$storeHelper->getProductObject($obj, $order->id); if (isset($obj->db_id)) { $product->id = $obj->db_id; $db->updateObject('#__gridbox_store_order_products', $product, 'id'); } else { gridboxHelper::$storeHelper->insertProduct($product, $obj); } $pids[] = $product->id; foreach ($obj->variations as $object) { $variation = new stdClass(); $variation->product_id = $product->id; $variation->order_id = $order->id; $variation->title = $object->title; $variation->value = $object->value; $variation->color = $object->color; $variation->image = $object->image; $variation->type = $object->type; if (isset($object->id)) { $variation->id = $obj->id; $db->updateObject('#__gridbox_store_order_product_variations', $variation, 'id'); } else { $db->insertObject('#__gridbox_store_order_product_variations', $variation); $variation->id = $db->insertid(); } $vids[] = $variation->id; } } $str = 'm.order_id = '.$order->id; if (!empty($files)) { $str .= ' AND a.id NOT IN ('.implode(', ', $files).')'; } $this->removeAttached($str); $str = ' NOT IN ('.implode(', ', $pids).') AND order_id = '.$order->id; gridboxHelper::$storeHelper->removeSubscriptionProducts($pids, $order->id); $this->deleteTable($db, '#__gridbox_store_order_products', 'id'.$str); $this->deleteTable($db, '#__gridbox_store_order_license', 'product_id'.$str); $str = !empty($vids) ? 'id NOT IN ('.implode(', ', $vids).') AND ' : ''; $str .= 'order_id = '.$order->id; $this->deleteTable($db, '#__gridbox_store_order_product_variations', $str); foreach ($cart->info as $key => $value) { $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_order_customer_info') ->where('id = '.$key); $db->setQuery($query); $customer = $db->loadObject(); $customer->value = $value; if ($customer->type == 'country' && !empty($customer->value)) { $customer->value = gridboxHelper::$storeHelper->setCountryValue($customer->value); } $db->updateObject('#__gridbox_store_order_customer_info', $customer, 'id'); } } public function createOrder($cart, $user_id) { gridboxHelper::$storeHelper->createAdminOrder($cart, $user_id); } public function getStatus($id) { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('id, status, user_id, date') ->from('#__gridbox_store_orders') ->where('id = '.$id); $db->setQuery($query); $obj = $db->loadObject(); $query = $db->getQuery(true) ->select('h.*, u.username') ->from('#__gridbox_store_orders_status_history AS h') ->where('h.order_id = '.$id) ->leftJoin('#__users AS u on u.id = h.user_id') ->order('h.id DESC'); $db->setQuery($query); $obj->history = $db->loadObjectList(); foreach ($obj->history as $record) { $record->date = JDate::getInstance($record->date)->format('M d, Y, H:i'); } return $obj; } public function updateStatus($id, $status, $comment) { gridboxHelper::$storeHelper->updateStatus($id, $status, $comment); } public function delete($cid) { $db = JFactory::getDbo(); foreach ($cid as $id) { gridboxHelper::$storeHelper->removeSubscriptionProducts([], $id); $this->deleteTable($db, '#__gridbox_store_order_products', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_orders', 'id = '.$id); $this->deleteTable($db, '#__gridbox_store_orders_status_history', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_orders_discount', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_orders_shipping', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_orders_payment', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_order_customer_info', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_order_license', 'order_id = '.$id); $this->deleteTable($db, '#__gridbox_store_order_product_variations', 'order_id = '.$id); $str = 'm.order_id = '.$id; $this->removeAttached($str); } } protected function updateProductUsed($db, $where) { $query = $db->getQuery(true) ->select('d.id, d.stock, p.variation, d.variations, p.quantity') ->from('#__gridbox_store_order_products AS p') ->where('p.'.$where) ->leftJoin('#__gridbox_store_product_data AS d ON p.product_id = d.product_id') ->leftJoin('#__gridbox_store_orders AS o ON o.id = p.order_id') ->where('o.status <> '.$db->quote('refunded')); $db->setQuery($query); $products = $db->loadObjectList(); foreach ($products as $product) { gridboxHelper::$storeHelper->updateProductUsed($product, '-'); } } public function deleteTable($db, $table, $where) { if ($table == '#__gridbox_store_order_products') { $this->updateProductUsed($db, $where); } $query = $db->getQuery(true) ->delete($table) ->where($where); $db->setQuery($query) ->execute(); } public function setGridboxFilters() { $app = JFactory::getApplication(); $ordering = $app->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', null); $direction = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', null); gridboxHelper::setGridboxFilters($ordering, $direction, $this->context); } public function getGridboxFilters() { $array = gridboxHelper::getGridboxFilters($this->context); if (!empty($array)) { foreach ($array as $obj) { $name = str_replace($this->context.'.', '', $obj->name); $this->setState($name, $obj->value); } } } public function setFilters() { $this->setGridboxFilters(); $this::populateState(); } public function getShipping() { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_shipping') ->where('published = 1') ->order('order_list ASC'); $db->setQuery($query); $shipping = $db->loadObjectList(); return $shipping; } public function getPromo() { $db = JFactory::getDbo(); $date = JDate::getInstance()->format('Y-m-d H:i:s'); $date = $db->quote($date); $nullDate = $db->quote($db->getNullDate()); $query = $db->getQuery(true) ->select('COUNT(p.id)') ->from('#__gridbox_store_promo_codes AS p') ->where('p.published = 1') ->where('(p.publish_down = '.$nullDate.' OR p.publish_down >= '.$date.')') ->where('(p.publish_up = '.$nullDate.' OR p.publish_up <= '.$date.')') ->where('(p.limit = 0 OR p.used < pc.limit)') ->leftJoin('#__gridbox_store_promo_codes AS pc ON pc.id = p.id'); $db->setQuery($query); $count = $db->loadResult(); return $count; } public function getCustomerInfo() { $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('*') ->from('#__gridbox_store_customer_info') ->order('order_list ASC'); $db->setQuery($query); $info = $db->loadObjectList(); foreach ($info as $value) { $value->settings = json_decode($value->options); } return $info; } public function getStatuses() { $data = gridboxHelper::getStatuses(); return $data; } protected function getListQuery() { $this->getGridboxFilters(); $app = JFactory::getApplication(); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('o.*') ->from('#__gridbox_store_orders AS o') ->where('o.published = 1'); $status = $this->getState('filter.state'); if (!empty($status)) { $query->where('o.status = '.$db->quote($status)); } $publish_up = $this->getState('filter.publish_up'); if (!empty($publish_up)) { $publish_up = $publish_up.' 00:00:01'; $query->where('o.date > '.$db->quote($publish_up)); } $publish_down = $this->getState('filter.publish_down'); if (!empty($publish_down)) { $publish_down = $publish_down.' 23:59:59'; $query->where('o.date < '.$db->quote($publish_down)); } $orderCol = $this->state->get('list.ordering', 'date'); $orderDirn = $this->state->get('list.direction', 'desc'); $query->order('o.'.$orderCol.' '.$orderDirn.', o.id DESC'); return $query; } public function getSearchCustomer($pks, $where, $search) { $db = JFactory::getDbo(); $q = $db->getQuery(true) ->select('order_id') ->from('#__gridbox_store_order_customer_info') ->where($where) ->where('value LIKE '.$search); $db->setQuery($q); $ids = $db->loadObjectList(); foreach ($ids as $obj) { if (!in_array($obj->order_id, $pks)) { $pks[] = $obj->order_id; } } return $pks; } public function getCustomerInfoValue($item, $where, $key) { $db = JFactory::getDbo(); $q = $db->getQuery(true) ->select('value') ->from('#__gridbox_store_order_customer_info') ->where('order_id = '.$item->id) ->where($where); $db->setQuery($q); $result = $db->loadResult(); $item->{$key} = $result ? $result : ''; } public function getItems() { $store = $this->getStoreId(); $app = JFactory::getApplication(); $db = JFactory::getDbo(); if (isset($this->cache[$store])) { return $this->cache[$store]; } $query = $this->_getListQuery(); try { $search = $this->getState('filter.search'); if (!empty($search)) { $search = $db->quote('%'.$db->escape($search, true).'%', false); $pks = []; $q = $db->getQuery(true) ->select('id') ->from('#__gridbox_store_orders') ->where('order_number LIKE '.$search); $db->setQuery($q); $ids = $db->loadObjectList(); foreach ($ids as $obj) { $pks[] = $obj->id; } $pks = $this->getSearchCustomer($pks, 'customer_id = 1', $search); $pks = $this->getSearchCustomer($pks, 'type = '.$db->quote('email'), $search); if (!empty($pks)) { $str = implode(',', $pks); $query->where('o.id in ('.$str.')'); } } $items = $this->_getList($query, $this->getStart(), $this->getState('list.limit')); } catch (RuntimeException $e) { $this->setError($e->getMessage()); return false; } foreach ($items as $item) { $this->getCustomerInfoValue($item, 'customer_id = 1', 'customer_name'); $this->getCustomerInfoValue($item, 'type = '.$db->quote('email'), 'email'); } $this->cache[$store] = $items; return $this->cache[$store]; } protected function getStoreId($id = '') { $id .= ':'.$this->getState('filter.search'); $id .= ':'.$this->getState('filter.state'); return parent::getStoreId($id); } protected function populateState($ordering = null, $direction = null) { $search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $published = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_state', '', 'string'); $this->setState('filter.state', $published); $publish_up = $this->getUserStateFromRequest($this->context.'.filter.publish_up', 'publish_up', '', 'string'); $publish_down = $this->getUserStateFromRequest($this->context.'.filter.publish_down', 'publish_down', '', 'string'); $this->setState('filter.publish_up', $publish_up); $this->setState('filter.publish_down', $publish_down); parent::populateState('id', 'desc'); } }