dolibarr 20.0.2
objectlinked_lineimport.tpl.php
1<?php
2/* Copyright (C) 2011-2013 Regis Houssin <regis.houssin@inodbox.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18// Protection to avoid direct call of template
19if (empty($conf) || !is_object($conf)) {
20 print "Error, template page can't be called as URL";
21 exit(1);
22}
23
24$objectUrl = $object->getNomUrl(0, '', 0, 1);
25if ($object->element == 'propal') {
26 $objectUrl = DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id;
27}
28
29?>
30
31<!-- START TEMPLATE IMPORT OBJECT LINKED LINES -->
32<script>
33
34$(document).ready(function(){
35 $('.objectlinked_importbtn').click(function (e) {
36
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="fromelementid" value="' + fromelementid + '" />');
82 $("#" + formId).submit();
83 },
84 "<?php echo $langs->trans("Cancel"); ?>": function() {
85 $( this ).dialog( "close" );
86 }
87 }
88 });
89
90 $dialog.dialog('open');
91 }
92 else
93 {
94 $.jnotify("<?php echo $langs->trans('ErrorNoUrl'); ?>", "error", true);
95 }
96
97 });
98
99
100
101
102});
103
104</script>
105<style type="text/css">
106.objectlinked_importbtn{
107 cursor:pointer;
108}
109</style>
110<!-- END TEMPLATE IMPORT OBJECT LINKED LINES -->
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137