dolibarr 21.0.4
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$(function() {
35 $(document).on('click', '.objectlinked_importbtn', function(e) {
36 e.preventDefault();
37 var page = $(this).attr("href");
38
39 var fromelement = $(this).attr("data-element");
40 var fromelementid = $(this).attr("data-id");
41
42 if( page != undefined && fromelement != undefined && fromelementid != undefined)
43 {
44 var windowWidth = $(window).width()*0.8; //retrieve current window width
45 var windowHeight = $(window).height()*0.8; //retrieve current window height
46 var htmlLines;
47 var formId = "ajaxloaded_tablelinesform_" + fromelement + "_" + fromelementid;
48 $.get(page, function (data) {
49 htmlLines = $(data).find('#tablelines') ;
50 });
51
52
53 var $dialog = $('<form id="' + formId + '" action="<?php print $objectUrl; ?>" method="post" ></form>')
54 .load( page + " #tablelines", function() {
55
56 $("#" + formId + " #tablelines").prop("id", "ajaxloaded_tablelines"); // change id attribute
57
58 $("#" + formId + " .linecheckbox,#" + formId + " .linecheckboxtoggle").prop("checked", true); // checked by default
59
60 // reload checkbox toggle function
61 $("#" + formId + " .linecheckboxtoggle").click(function(){
62 var checkBoxes = $("#" + formId + " .linecheckbox");
63 checkBoxes.prop("checked", this.checked);
64 });
65
66
67 })
68 .html(htmlLines)
69 .dialog({
70 autoOpen: false,
71 modal: true,
72 height: windowHeight,
73 width: windowWidth,
74 title: "<?php echo $langs->transnoentities('LinesToImport'); ?>",
75 buttons: {
76 "<?php echo $langs->trans('Import'); ?>": function() {
77 $( this ).dialog( "close" );
78 $("#" + formId).append('<input type="hidden" name="action" value="import_lines_from_object" />');
79 $("#" + formId).append('<input type="hidden" name="fromelement" value="' + fromelement + '" />');
80 $("#" + formId).append('<input type="hidden" name="token" value="<?php print dol_escape_htmltag(newToken()); ?>" />');
81 $("#" + formId).append('<input type="hidden" name="fromelementid" value="' + fromelementid + '" />');
82 $("#" + formId).trigger('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:66
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:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:150