dolibarr 23.0.3
objectlinked_lineimport.tpl.php
1<?php
2/* Copyright (C) 2011-2013 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
24// Protection to avoid direct call of template
25if (empty($conf) || !is_object($conf)) {
26 print "Error, template page can't be called as URL";
27 exit(1);
28}
29
30$objectUrl = $object->getNomUrl(0, '', '0', 1);
31if ($object->element == 'propal') {
32 $objectUrl = dolBuildUrl(DOL_URL_ROOT.'/comm/propal/card.php', ['id' => $object->id]);
33}
34
35?>
36
37<!-- START TEMPLATE IMPORT OBJECT LINKED LINES -->
38<script>
39
40$(function() {
41 $(document).on('click', '.objectlinked_importbtn', function(e) {
42 e.preventDefault();
43 var page = $(this).attr("href");
44
45 var fromelement = $(this).attr("data-element");
46 var fromelementid = $(this).attr("data-id");
47
48 if( page != undefined && fromelement != undefined && fromelementid != undefined)
49 {
50 var windowWidth = $(window).width()*0.8; //retrieve current window width
51 var windowHeight = $(window).height()*0.8; //retrieve current window height
52 var htmlLines;
53 var formId = "ajaxloaded_tablelinesform_" + fromelement + "_" + fromelementid;
54 $.get(page, function (data) {
55 htmlLines = $(data).find('#tablelines') ;
56 });
57
58
59 var $dialog = $('<form id="' + formId + '" action="<?php print $objectUrl; ?>" method="post" ></form>')
60 .load( page + " #tablelines", function() {
61
62 $("#" + formId + " #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute
63
64 $("#" + formId + " .linecheckbox,#" + formId + " .linecheckboxtoggle").prop("checked", true); // checked by default
65
66 // reload checkbox toggle function
67 $("#" + formId + " .linecheckboxtoggle").click(function(){
68 var checkBoxes = $("#" + formId + " .linecheckbox");
69 checkBoxes.prop("checked", this.checked);
70 });
71
72
73 })
74 .html(htmlLines)
75 .dialog({
76 autoOpen: false,
77 modal: true,
78 height: windowHeight,
79 width: windowWidth,
80 title: "<?php echo $langs->transnoentities('LinesToImport'); ?>",
81 buttons: {
82 "<?php echo $langs->trans('Import'); ?>": function() {
83 $( this ).dialog( "close" );
84 $("#" + formId).append('<input type="hidden" name="action" value="import_lines_from_object" />');
85 $("#" + formId).append('<input type="hidden" name="fromelement" value="' + fromelement + '" />');
86 $("#" + formId).append('<input type="hidden" name="token" value="<?php print dol_escape_htmltag(newToken()); ?>" />');
87 $("#" + formId).append('<input type="hidden" name="fromelementid" value="' + fromelementid + '" />');
88 $("#" + formId).trigger('submit');
89 },
90 "<?php echo $langs->trans("Cancel"); ?>": function() {
91 $( this ).dialog( "close" );
92 }
93 }
94 });
95
96 $dialog.dialog('open');
97 }
98 else
99 {
100 $.jnotify("<?php echo $langs->trans('ErrorNoUrl'); ?>", "error", true);
101 }
102 });
103});
104
105</script>
106<style type="text/css">
107.objectlinked_importbtn{
108 cursor:pointer;
109}
110</style>
111<!-- END TEMPLATE IMPORT OBJECT LINKED LINES -->
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:125