Hardcodierte Pfade gefixt
This commit is contained in:
parent
770a2b6416
commit
458f393612
6 changed files with 46 additions and 30 deletions
|
|
@ -180,6 +180,8 @@ class ActionsSubtotalTitle extends CommonHookActions
|
|||
echo '<script type="text/javascript">'."\n";
|
||||
echo 'var subtotalTitleIsDraft = '.($this->isDraft ? 'true' : 'false').';'."\n";
|
||||
echo 'var subtotalTitleHasSections = '.($hasSections ? 'true' : 'false').';'."\n";
|
||||
// AJAX-URL-Pfad für alle AJAX-Aufrufe
|
||||
echo 'var subtotaltitleAjaxUrl = "'.dol_buildpath('/subtotaltitle/ajax/', 1).'";'."\n";
|
||||
// Grip-Bild-Pfad für Drag&Drop (wie Dolibarr es macht)
|
||||
echo 'var subtotalTitleGripUrl = "'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/grip.png";'."\n";
|
||||
echo 'var subtotalTitleLang = {'."\n";
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class modSubtotalTitle extends DolibarrModules
|
|||
$this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@subtotaltitle'
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
|
||||
$this->version = '1.0';
|
||||
$this->version = '4.0';
|
||||
// Url to the file with your last numberversion of this module
|
||||
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ $(document).ready(function() {
|
|||
var factureId = getFactureId();
|
||||
if (!factureId) return;
|
||||
|
||||
$.get('/dolibarr/custom/subtotaltitle/ajax/get_line_orders.php', {
|
||||
$.get(subtotaltitleAjaxUrl + 'get_line_orders.php', {
|
||||
facture_id: factureId
|
||||
}, function(response) {
|
||||
if (!response.success) return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,24 @@
|
|||
// DEBUG FLAG - true für Debug-Ausgaben, false für Produktiv
|
||||
var SUBTOTAL_DEBUG = false;
|
||||
|
||||
// Fallback für AJAX-URL wenn nicht von PHP gesetzt (z.B. bei direktem JS-Include)
|
||||
if (typeof subtotaltitleAjaxUrl === 'undefined') {
|
||||
// Versuche URL aus aktuellem Script-Pfad abzuleiten
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
var src = scripts[i].src || '';
|
||||
if (src.indexOf('subtotaltitle') !== -1 && src.indexOf('/js/') !== -1) {
|
||||
// Pfad: .../subtotaltitle/js/subtotaltitle.js -> .../subtotaltitle/ajax/
|
||||
var subtotaltitleAjaxUrl = src.replace(/\/js\/.*$/, '/ajax/');
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Letzter Fallback
|
||||
if (typeof subtotaltitleAjaxUrl === 'undefined') {
|
||||
var subtotaltitleAjaxUrl = '/custom/subtotaltitle/ajax/';
|
||||
}
|
||||
}
|
||||
|
||||
function debugLog(message) {
|
||||
if (SUBTOTAL_DEBUG) {
|
||||
console.log(message);
|
||||
|
|
@ -202,7 +220,7 @@ function cleanupOrphanedSubtotals() {
|
|||
var docInfo = getDocumentInfo();
|
||||
if (!docInfo.id) return;
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/cleanup_subtotals.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'cleanup_subtotals.php', {
|
||||
facture_id: docInfo.id,
|
||||
document_type: docInfo.type
|
||||
}, function(response) {
|
||||
|
|
@ -333,7 +351,7 @@ function createNewSection() {
|
|||
function(title) {
|
||||
debugLog('Erstelle Section: ' + title + ' für ' + docInfo.type + ' ID ' + docInfo.id);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/create_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'create_section.php', {
|
||||
facture_id: docInfo.id,
|
||||
document_type: docInfo.type,
|
||||
title: title
|
||||
|
|
@ -362,7 +380,7 @@ function moveSection(sectionId, direction) {
|
|||
var docInfo = getDocumentInfo();
|
||||
debugLog('🔄 Verschiebe Section ' + sectionId + ' ' + direction + ' (docType: ' + docInfo.type + ')');
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/move_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'move_section.php', {
|
||||
section_id: sectionId,
|
||||
direction: direction,
|
||||
document_type: docInfo.type
|
||||
|
|
@ -402,7 +420,7 @@ function renameSection(sectionId, currentTitle) {
|
|||
function(newTitle) {
|
||||
debugLog('✏️ Benenne Section ' + sectionId + ' um zu: ' + newTitle);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/rename_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'rename_section.php', {
|
||||
section_id: sectionId,
|
||||
title: newTitle
|
||||
}, function(response) {
|
||||
|
|
@ -434,7 +452,7 @@ function deleteSection(sectionId) {
|
|||
function() {
|
||||
debugLog('🗑️ Lösche leere Section ' + sectionId);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/delete_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'delete_section.php', {
|
||||
section_id: sectionId,
|
||||
force: 0,
|
||||
document_type: getDocumentType()
|
||||
|
|
@ -478,7 +496,7 @@ function deleteSectionForce(sectionId) {
|
|||
function() {
|
||||
debugLog('Force-Delete Section ' + sectionId + ' mit Produkten: ' + JSON.stringify(productIds));
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/delete_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'delete_section.php', {
|
||||
section_id: sectionId,
|
||||
force: 1,
|
||||
product_ids: JSON.stringify(productIds),
|
||||
|
|
@ -512,7 +530,7 @@ function insertEmptySections() {
|
|||
|
||||
debugLog('📦 Lade alle Sections für ' + docInfo.type + ' ID ' + docInfo.id);
|
||||
|
||||
$.get('/dolibarr/custom/subtotaltitle/ajax/get_sections.php', {
|
||||
$.get(subtotaltitleAjaxUrl + 'get_sections.php', {
|
||||
facture_id: docInfo.id,
|
||||
document_type: docInfo.type
|
||||
}, function(response) {
|
||||
|
|
@ -751,7 +769,7 @@ function saveCurrentOrder() {
|
|||
debugLog('🚀 Sende ' + updates.length + ' Updates...');
|
||||
|
||||
var docInfo = getDocumentInfo();
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/reorder_all.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'reorder_all.php', {
|
||||
facture_id: getFactureId(),
|
||||
document_type: docInfo.type,
|
||||
new_order: JSON.stringify(updates)
|
||||
|
|
@ -775,7 +793,7 @@ function moveProductToSection(productId, sectionId, newLineOrder) {
|
|||
var lang = (typeof subtotalTitleLang !== 'undefined') ? subtotalTitleLang : {};
|
||||
debugLog('🚀 Verschiebe Produkt ' + productId + ' zu Section ' + (sectionId || 'FREI') + ' auf Position ' + newLineOrder);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/move_product.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'move_product.php', {
|
||||
product_id: productId,
|
||||
new_section_id: sectionId || 0,
|
||||
new_line_order: newLineOrder
|
||||
|
|
@ -904,7 +922,7 @@ function assignLastProductToSection(sectionId, factureId) {
|
|||
var docInfo = getDocumentInfo();
|
||||
debugLog('🎯 Weise neustes Produkt zu Section ' + sectionId + ' zu (docType: ' + docInfo.type + ')...');
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/assign_last_product.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'assign_last_product.php', {
|
||||
facture_id: factureId,
|
||||
section_id: sectionId,
|
||||
document_type: docInfo.type
|
||||
|
|
@ -1127,7 +1145,7 @@ function insertLastSectionSubtotal() {
|
|||
// Hole Subtotal-ID aus Datenbank (oder erstelle ihn falls nötig)
|
||||
var docType = getDocumentType();
|
||||
$.ajax({
|
||||
url: '/dolibarr/custom/subtotaltitle/ajax/check_subtotal.php',
|
||||
url: subtotaltitleAjaxUrl + 'check_subtotal.php',
|
||||
method: 'GET',
|
||||
data: {
|
||||
section_id: sectionId,
|
||||
|
|
@ -1203,7 +1221,7 @@ function insertTextLines() {
|
|||
|
||||
debugLog('📝 Lade Textzeilen für ' + docInfo.type + ' ID ' + docInfo.id);
|
||||
|
||||
$.get('/dolibarr/custom/subtotaltitle/ajax/get_textlines.php', {
|
||||
$.get(subtotaltitleAjaxUrl + 'get_textlines.php', {
|
||||
facture_id: docInfo.id,
|
||||
document_type: docInfo.type
|
||||
}, function(response) {
|
||||
|
|
@ -1232,7 +1250,7 @@ function toggleSubtotal(sectionId, checkbox) {
|
|||
debugLog('🔢 Toggle Subtotal für Section ' + sectionId + ': ' + show + ', docType: ' + docType);
|
||||
|
||||
$.ajax({
|
||||
url: '/dolibarr/custom/subtotaltitle/ajax/toggle_subtotal.php',
|
||||
url: subtotaltitleAjaxUrl + 'toggle_subtotal.php',
|
||||
method: 'POST',
|
||||
data: {
|
||||
section_id: sectionId,
|
||||
|
|
@ -1383,7 +1401,7 @@ function createTextLine() {
|
|||
function(text) {
|
||||
debugLog('Erstelle Textzeile für ' + docInfo.type + ' ID ' + docInfo.id);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/create_textline.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'create_textline.php', {
|
||||
facture_id: docInfo.id,
|
||||
document_type: docInfo.type,
|
||||
text: text
|
||||
|
|
@ -1417,7 +1435,7 @@ function editTextLine(textlineId, currentText) {
|
|||
function(newText) {
|
||||
debugLog('✏️ Bearbeite Textzeile ' + textlineId);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/edit_textline.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'edit_textline.php', {
|
||||
textline_id: textlineId,
|
||||
text: newText
|
||||
}, function(response) {
|
||||
|
|
@ -1449,7 +1467,7 @@ function deleteTextLine(textlineId) {
|
|||
function() {
|
||||
debugLog('Lösche Textzeile ' + textlineId);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/delete_textline.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'delete_textline.php', {
|
||||
textline_id: textlineId,
|
||||
document_type: getDocumentType()
|
||||
}, function(response) {
|
||||
|
|
@ -1482,7 +1500,7 @@ function removeFromSection(productId) {
|
|||
var docType = getDocumentType();
|
||||
debugLog('Entferne Produkt ' + productId + ' aus Section (docType: ' + docType + ')');
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/remove_from_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'remove_from_section.php', {
|
||||
product_id: productId,
|
||||
document_type: docType
|
||||
}, function(response) {
|
||||
|
|
@ -1560,7 +1578,7 @@ function deleteMassSelected() {
|
|||
|
||||
showConfirmDialog('Letzte Warnung', '<div style="color:#c00;font-weight:bold;">' + msg2 + '</div>', function() {
|
||||
// Zweite Bestätigung OK - jetzt löschen
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/mass_delete.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'mass_delete.php', {
|
||||
line_ids: JSON.stringify(selectedIds),
|
||||
facture_id: getFactureId(),
|
||||
document_type: getDocumentType()
|
||||
|
|
@ -1740,7 +1758,7 @@ function linkToNearestSection(lineId) {
|
|||
debugLog(' AJAX Call: add_to_section.php');
|
||||
|
||||
// AJAX Call zum Backend
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/add_to_section.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'add_to_section.php', {
|
||||
line_id: lineId,
|
||||
section_id: targetSection.id,
|
||||
document_id: docInfo.id,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function syncToFacturedet(lineId, lineType) {
|
|||
var docType = getDocumentTypeForSync();
|
||||
debugLog('Document type: ' + docType);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/sync_to_facturedet.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'sync_to_facturedet.php', {
|
||||
action: 'add',
|
||||
line_id: lineId,
|
||||
line_type: lineType,
|
||||
|
|
@ -64,7 +64,7 @@ function removeFromFacturedet(lineId, lineType) {
|
|||
var docType = getDocumentTypeForSync();
|
||||
debugLog('Document type: ' + docType);
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/sync_to_facturedet.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'sync_to_facturedet.php', {
|
||||
action: 'remove',
|
||||
line_id: lineId,
|
||||
line_type: lineType,
|
||||
|
|
@ -148,7 +148,7 @@ function syncAllToFacturedet() {
|
|||
var lineId = $(this).data('line-id');
|
||||
var lineType = $(this).data('line-type');
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/sync_to_facturedet.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'sync_to_facturedet.php', {
|
||||
action: 'add',
|
||||
line_id: lineId,
|
||||
line_type: lineType,
|
||||
|
|
@ -207,7 +207,7 @@ function removeAllFromFacturedet() {
|
|||
var lineId = $(this).data('line-id');
|
||||
var lineType = $(this).data('line-type');
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/sync_to_facturedet.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'sync_to_facturedet.php', {
|
||||
action: 'remove',
|
||||
line_id: lineId,
|
||||
line_type: lineType,
|
||||
|
|
@ -258,7 +258,7 @@ function updateAllSubtotals() {
|
|||
$subtotals.each(function() {
|
||||
var lineId = $(this).data('line-id');
|
||||
|
||||
$.post('/dolibarr/custom/subtotaltitle/ajax/sync_to_facturedet.php', {
|
||||
$.post(subtotaltitleAjaxUrl + 'sync_to_facturedet.php', {
|
||||
action: 'update_subtotal',
|
||||
line_id: lineId,
|
||||
document_type: docType
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
[Project]
|
||||
CreatedFrom=
|
||||
Manager=KDevCustomBuildSystem
|
||||
Name=subtotaltitle
|
||||
Loading…
Reference in a new issue