From d5826fccdbcceaf31ae4b7303097689e41fe247f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Fri, 21 Feb 2025 17:10:15 +0100 Subject: [PATCH] CMXX - Uploader tool --- api/v2/get/transactions.php | 2 - api/v2/post/translations_details.php | 2 + assets/functions.php | 18 +- order_old.php | 290 ----------------------- settings/settingsmenu.php | 20 +- settings/settingsprofiles.php | 4 +- settings/settingsviews.php | 1 + translation_manage.php | 4 +- uploader.php | 329 +++++++++++++++++++++++++++ 9 files changed, 357 insertions(+), 313 deletions(-) delete mode 100644 order_old.php create mode 100644 uploader.php diff --git a/api/v2/get/transactions.php b/api/v2/get/transactions.php index 7d286e4..30b0e9b 100644 --- a/api/v2/get/transactions.php +++ b/api/v2/get/transactions.php @@ -18,8 +18,6 @@ list($whereclause,$condition) = getWhereclauselvl2("transactions",$permission,$p $criterias = []; $clause = ''; -var_dump($w) - //Check for $_GET variables and build up clause if(isset($get_content) && $get_content!=''){ //GET VARIABLES FROM URL diff --git a/api/v2/post/translations_details.php b/api/v2/post/translations_details.php index 040d4a2..cf32181 100644 --- a/api/v2/post/translations_details.php +++ b/api/v2/post/translations_details.php @@ -76,6 +76,8 @@ elseif ($command == 'insert' && isAllowed('translation_manage',$profile,$permiss $sql = 'INSERT INTO text_variables_translations ('.$clause_insert.') VALUES ('.$input_insert.')'; $stmt = $pdo->prepare($sql); $stmt->execute($execute_input); + // Return ID + echo json_encode(array('rowID'=> $pdo->lastInsertId())); } elseif ($command == 'delete' && isAllowed('translation_manage',$profile,$permission,'D') === 1){ $stmt = $pdo->prepare('DELETE FROM text_variables_translations WHERE rowID = ? '.$whereclause.''); diff --git a/assets/functions.php b/assets/functions.php index 9e89a40..84dbeab 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -175,7 +175,12 @@ function filterMenuByProfile($menu, $profileString) { // Add main_menu - if section not in profile but submenu found, use first submenu as main_menu if (!$sectionIncluded && $submenuFound && $firstSubmenuItem !== null) { - $filteredMenu[$sectionKey]['main_menu'] = $firstSubmenuItem; + // Create hybrid main_menu - keep name and icon from original, but use URL and selected from submenu + $hybridMainMenu = $section['main_menu']; + $hybridMainMenu['url'] = $firstSubmenuItem['url']; + $hybridMainMenu['selected'] = $firstSubmenuItem['selected']; + + $filteredMenu[$sectionKey]['main_menu'] = $hybridMainMenu; } else { $filteredMenu[$sectionKey]['main_menu'] = $section['main_menu']; } @@ -223,15 +228,14 @@ function menu($selected,$selected_child){ $menu .= '
'; foreach ($menu_item as $key => $item){ - //filter out main_menu - if($key !='main_menu'){ - $menu .= ''.ucfirst((${$item['name']}?? 'not specified')).''; - } - } + //filter out main_menu + if($key !='main_menu'){ + $menu .= ''.ucfirst((${$item['name']}?? 'not specified')).''; + } + } $menu .= '
'; } } - return $menu; } diff --git a/order_old.php b/order_old.php deleted file mode 100644 index 49b5ae3..0000000 --- a/order_old.php +++ /dev/null @@ -1,290 +0,0 @@ -prepare('SELECT ti.*, p.productcode, p.name FROM transactions t JOIN transactions_items ti ON ti.txn_id = t.txn_id LEFT JOIN products p ON p.id = ti.item_id WHERE t.id = ?'); -$stmt->execute([ $_GET['id'] ]); -$order_items = $stmt->fetchAll(PDO::FETCH_ASSOC); -// Retrieve order details -$stmt = $pdo->prepare('SELECT a.email, a.id AS a_id, a.first_name AS a_first_name, a.last_name AS a_last_name, a.address_street AS a_address_street, a.address_city AS a_address_city, a.address_state AS a_address_state, a.address_zip AS a_address_zip, a.address_country AS a_address_country, a.address_phone AS a_address_phone, t.* FROM transactions t LEFT JOIN transactions_items ti ON ti.txn_id = t.txn_id LEFT JOIN accounts a ON a.id = t.account_id WHERE t.id = ?'); -$stmt->execute([ $_GET['id'] ]); -$order = $stmt->fetch(PDO::FETCH_ASSOC); - -// Get tax -$stmt = $pdo->prepare('SELECT * FROM taxes WHERE country = ?'); -$stmt->execute([$order['a_address_country']]); -$tax = $stmt->fetch(PDO::FETCH_ASSOC); -$tax_rate = $tax ? $tax['rate'] : 0.00; - -//Add giftcards -if (isset($_GET['add_giftcard'])){ - createGiftCart($pdo, $order['txn_id']); -} - -//Get connected giftcards -$giftcards_template = $order['txn_id'].'#%#%'; -$stmt = $pdo->prepare('SELECT * from discounts WHERE discount_code like ?'); -$stmt->execute([$giftcards_template]); -$giftcards = $stmt->fetchAll(PDO::FETCH_ASSOC); - -// Get the current date -$current_date = strtotime((new DateTime())->format('Y-m-d H:i:s')); - -// Delete transaction -if (isset($_GET['delete'])) { - // Delete the transaction - $stmt = $pdo->prepare('DELETE t, ti FROM transactions t LEFT JOIN transactions_items ti ON ti.txn_id = t.txn_id WHERE t.id = ?'); - $stmt->execute([ $_GET['id'] ]); - - // Deactive giftcards - removeGiftCart($pdo, $_GET['txn']); - - header('Location: index.php?page=orders&success_msg=3'); - exit; -} -if (!$order) { - exit('Invalid ID!'); -} - -?> - - -
-

Order #

- Cancel - Delete - Edit -
- -
-
-
- Order Details -
-
-

Order ID

-

-
-
-

Transaction ID

-

-
- -
-

Shipping Method

-

-
- -
-

Payment Method

-

-
-
-

Payment Status

-

-
-
-

Date

-

-
- -
-

Discount Code

-

-
- -
- -
-
- Account Details -
- -
-

Email

-

-
-
-

Name

-

-
-
-

Address

-


-
-
-
- -

-
-
-

Contact

-

-

-
- -

The order is not associated with an account.

- -
- -
-
- Customer Details -
-
-

Email

-

-
-
-

Name

-

-
-
-

Address

-


-
-
-
- -

-
-
-

Contact

-

-

-
-
-
- -
-
- Order -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ProductOptionsQtyPriceTotal
There are no order items
Subtotal
Shipping
Discount
VAT
Total
-
-
- -
-
- Giftcards -
-
- Relate giftcards - - - - - - - - - - - - - - - - - - - - - - - - - - -
GiftcardValidValue
There are no order items
= strtotime($giftcard['start_date']) && $current_date <= strtotime($giftcard['end_date']) ? 'Yes' : 'No'?>
-
-
- -
-
- Invoice -
-
- - - - - - -
-
- - -
-
-
- - -
-
-
- - -
-
-
-
- - \ No newline at end of file diff --git a/settings/settingsmenu.php b/settings/settingsmenu.php index bf1b1d0..860df6c 100644 --- a/settings/settingsmenu.php +++ b/settings/settingsmenu.php @@ -185,7 +185,7 @@ $main_menu = [ "url" => "partners", "selected" => "partners", "icon" => "fa-solid fa-bars", - "name" => "menu_admin" + "name" => "menu_admin_partners" ], "users" => [ "url" => "users", @@ -230,12 +230,6 @@ $main_menu = [ "selected" => "settings", "icon" => "fas fa-tools", "name" => "menu_settings" - ], - "settings" => [ - "url" => "settings", - "selected" => "settings", - "icon" => "fas fa-tools", - "name" => "menu_settings" ], "config" => [ "url" => "settings", @@ -248,19 +242,25 @@ $main_menu = [ "selected" => "translations", "icon" => "fas fa-tachometer-alt", "name" => "menu_translations" - ], + ], + "uploader" => [ + "url" => "uploader", + "selected" => "uploader", + "icon" => "fas fa-tachometer-alt", + "name" => "menu_uploader" + ], "logfile" => [ "url" => "logfile", "selected" => "logfile", "icon" => "fas fa-tachometer-alt", "name" => "menu_logfile" - ], + ], "maintenance" => [ "url" => "maintenance", "selected" => "maintenance", "icon" => "fas fa-tachometer-alt", "name" => "menu_maintenance" - ], + ], "profiles" => [ "url" => "profiles", "selected" => "profiles", diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php index 571b2b1..6cc953b 100644 --- a/settings/settingsprofiles.php +++ b/settings/settingsprofiles.php @@ -6,11 +6,11 @@ define('superuser_profile','dashboard,profile,assets,equipments,equipment,equipm /*Admin*/ define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,changelog,application'); /*AdminPlus*/ -define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,billing,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,products_configurations,products_categories,products_media,product,product_manage,pricelists,pricelists_items,pricelists_manage,catalog,categories,category,discounts,discount,shipping,shipping_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,translations,translations_details,translation_manage,media,media_manage,application,maintenance,profiles,vin,shopping_cart,checkout,placeorder,taxes,transactions,transactions_items,invoice,order,orders'); +define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,billing,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,products_configurations,products_categories,products_media,product,product_manage,pricelists,pricelists_items,pricelists_manage,catalog,categories,category,discounts,discount,shipping,shipping_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,translations,translations_details,translation_manage,media,media_manage,application,maintenance,uploader,profiles,vin,shopping_cart,checkout,placeorder,taxes,transactions,transactions_items,invoice,order,orders'); /*Build*/ define('build','dashboard,profile,buildtool,firmwaretool,buildtool,products_software,application'); /*Commerce*/ -define('commerce','dashboard,profile,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,products_configurations,products_categories,products_media,product,product_manage,pricelists,pricelists_items,pricelists_manage,catalog,categories,category,discounts,discount,shipping,shipping_manage,admin,users,user,user_manage,translations,translations_details,translation_manage,media,media_manage,application,profiles,shopping_cart,checkout,placeorder,taxes,transactions,transactions_items,invoice,order,orders'); +define('commerce','dashboard,profile,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,products_configurations,products_categories,products_media,product,product_manage,pricelists,pricelists_items,pricelists_manage,catalog,categories,category,discounts,discount,shipping,shipping_manage,admin,partners,partner,users,user,user_manage,translations,translations_details,translation_manage,media,media_manage,application,shopping_cart,checkout,placeorder,taxes,transactions,transactions_items,invoice,order,orders'); /*Distribution*/ define('distribution','dashboard,profile,assets,equipments,equipment,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,marketing,application'); /*Firmware*/ diff --git a/settings/settingsviews.php b/settings/settingsviews.php index 4c13fbc..a0425f0 100644 --- a/settings/settingsviews.php +++ b/settings/settingsviews.php @@ -85,6 +85,7 @@ $all_views = [ "media_manage", "application", "maintenance", + "uploader", "profiles", "vin", "shopping_cart", diff --git a/translation_manage.php b/translation_manage.php index e7d46c6..351295e 100644 --- a/translation_manage.php +++ b/translation_manage.php @@ -243,7 +243,7 @@ $view .= ' $view .=''; } $view .=' - + '.getRelativeTime($translation['created']).' @@ -271,7 +271,7 @@ $view .= ' } $view .=' - + diff --git a/uploader.php b/uploader.php new file mode 100644 index 0000000..b06cdfc --- /dev/null +++ b/uploader.php @@ -0,0 +1,329 @@ + CREATE + $payload = json_encode(array("variable" => $content['variable']), JSON_UNESCAPED_UNICODE); + //API call + $text_variable_new = ioServer('/v2/translations',$payload); + //returns results + $text_variable_new = json_decode($text_variable_new ,true); + //Provide feedback + $log_results[$content['variable']]['rowID'] = $text_variable_new['rowID'].' created'; + } + + $text_variable = $text_variable[0] ?? 'new'; + //VARIABLE ROWID + $text_variable_rowid = ($text_variable != 'new') ? $text_variable['rowID'] : $text_variable_new['rowID']; + + foreach ($content as $key => $var){ + + if ($var != $content['variable']){ + $language_key = strtoupper($key); + + //check if variable_id and language_key combination already exists + $text_translation = ioServer('/v2/translations_details/variable_ID='.$text_variable_rowid.'&language_key='.$language_key,''); + if (!empty($text_translation)){$text_translation = json_decode($text_translation,true);}else{$text_translation = null;} + + + if (count($text_translation) == 0){ + //TRANSLATION NOT FOUND ->CREATE + $payload = json_encode(array("variable_ID" => $text_variable_rowid, "language_key" => $language_key, "translation" => $var), JSON_UNESCAPED_UNICODE); + $text_translation_new = ioServer('/v2/translations_details',$payload); + $text_translation_new = json_decode($text_translation_new ,true); + //Provide feedback + $log_results[$content['variable']][$language_key] = $text_translation_new['rowID'].' created'; + } + elseif(count($text_translation) > 0){ + + $text_translation = $text_translation[0]; + //TRANSLATION FOUND -> UPDATE + $payload = json_encode(array("rowID" => $text_translation['rowID'] , "translation" => $var), JSON_UNESCAPED_UNICODE); + $text_translation = ioServer('/v2/translations_details',$payload); + $text_translation = json_decode($text_translation ,true); + //Provide feedback + $log_results[$content['variable']][$language_key] = $text_translation['rowID'].' updated'; + + } else { + $log_results[$content['variable']][$language_key] = 'not updated'; + } + + } + } + } else { + $log_results[$content['variable']] = 'error'; + } + } + } + print_r($log_results); + return $log_results; +} +template_header('Uploader', 'uploader', 'manage'); + +$view =' + + +
+

Excel Data Processor

+ +
+ Copy data from Excel and paste it into the textarea below. + Use Ctrl+C in Excel and Ctrl+V here to preserve the tab/column formatting. +
+ +
+ + +
+ + +
+ + +'; + +//Output +echo $view; + +template_footer(); +?> \ No newline at end of file