dolibarr 22.0.5
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 */
18
19// Protection to avoid direct call of template
20if (empty($conf) || !is_object($conf)) {
21 print "Error, template page can't be called as URL";
22 exit(1);
23}
24
25$objectUrl = $object->getNomUrl(0, '', '0', 1);
26if ($object->element == 'propal') {
27 $objectUrl = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id;
28}
29
30?>
31
32<!-- START TEMPLATE IMPORT OBJECT LINKED LINES -->
33<script>
34
35$(function() {
36 $(document).on('click', '.objectlinked_importbtn', function(e) {
37 e.preventDefault();
38 var page = $(this).attr("href");
39
40 var fromelement = $(this).attr("data-element");
41 var fromelementid = $(this).attr("data-id");
42
43 if( page != undefined && fromelement != undefined && fromelementid != undefined)
44 {
45 var windowWidth = $(window).width()*0.8; //retrieve current window width
46 var windowHeight = $(window).height()*0.8; //retrieve current window height
47 var htmlLines;
48 var formId = "ajaxloaded_tablelinesform_" + fromelement + "_" + fromelementid;
49 $.get(page, function (data) {
50 htmlLines = $(data).find('#tablelines') ;
51 });
52
53
54 var $dialog = $('<form id="' + formId + '" action="<?php print $objectUrl; ?>" method="post" ></form>')
55 .load( page + " #tablelines", function() {
56
57 $("#" + formId + " #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute
58
59 $("#" + formId + " .linecheckbox,#" + formId + " .linecheckboxtoggle").prop("checked", true); // checked by default
60
61 // reload checkbox toggle function
62 $("#" + formId + " .linecheckboxtoggle").click(function(){
63 var checkBoxes = $("#" + formId + " .linecheckbox");
64 checkBoxes.prop("checked", this.checked);
65 });
66
67
68 })
69 .html(htmlLines)
70 .dialog({
71 autoOpen: false,
72 modal: true,
73 height: windowHeight,
74 width: windowWidth,
75 title: "<?php echo $langs->transnoentities('LinesToImport'); ?>",
76 buttons: {
77 "<?php echo $langs->trans('Import'); ?>": function() {
78 $( this ).dialog( "close" );
79 $("#" + formId).append('<input type="hidden" name="action" value="import_lines_from_object" />');
80 $("#" + formId).append('<input type="hidden" name="fromelement" value="' + fromelement + '" />');
81 $("#" + formId).append('<input type="hidden" name="token" value="<?php print dol_escape_htmltag(newToken()); ?>" />');
82 $("#" + formId).append('<input type="hidden" name="fromelementid" value="' + fromelementid + '" />');
83 $("#" + formId).trigger('submit');
84 },
85 "<?php echo $langs->trans("Cancel"); ?>": function() {
86 $( this ).dialog( "close" );
87 }
88 }
89 });
90
91 $dialog.dialog('open');
92 }
93 else
94 {
95 $.jnotify("<?php echo $langs->trans('ErrorNoUrl'); ?>", "error", true);
96 }
97
98 });
99
100
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( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:158