File size: 10,093 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
{if $printTemplate}
{* this is the xmlform template *}
  <form id="{$form->id}" name="{$form->name}" action="{$form->action}" class="{$form->className}" method="post" encType="multipart/form-data" style="margin:0px;" onsubmit="return validateForm('{$form->objectRequiredFields}');">  <div class="borderForm" style="width:{$form->width}; padding-left:0; padding-right:0; border-width:{$form->border};">
    <div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div>
    <div class="content" style="height:{$form->height};" >
    <table width="99%">
      <tr>
        <td valign='top'>
          <input type="hidden" class="notValidateThisFields" name="__notValidateThisFields__" id="__notValidateThisFields__" value="{$form->objectRequiredFields}" />
          <input type="hidden" name="DynaformRequiredFields" id="DynaformRequiredFields" value="{$form->objectRequiredFields}" />
          <table cellspacing="0" cellpadding="0" border="0" width="100%">
            {foreach from=$form->fields item=field}
            {if ($field->type==='title')}
            <tr>
              <td class='FormTitle' colspan="2" align="{$field->align}">{$field->field}</td>
            </tr>
            {elseif ($field->type==='subtitle')}
            <tr>
              <td class='FormSubTitle' colspan="2" align="{$field->align}" id="form[{$field->name}]">
                <span>{$field->field}</span>
                {if (isset($field->showHide) && $field->showHide)}
                <a style="float:right;" href="#" onclick="contractExpandSubtitle(this);return false;">Hide</a>
                {/if}
              </td>
            </tr>
            {elseif ($field->type==='button') || ($field->type==='submit') || ($field->type==='reset')}
            <!--<tr>
              <td class='FormButton' colspan="2" align="{$field->align}">{$field->field}</td>
            </tr>-->
            {elseif ($field->type==='grid')}
            <tr>
              <td colspan="2">{$field->field}</td>
            </tr>
            {elseif ($field->type==='checkbox') && ($field->labelOnRight)}
            <tr>
              <td class='FormLabel' width="{$form->labelWidth}"></td>
              <td>{$field->field}</td>
            </tr>
            {elseif ($field->type==='phpvariable')}
            {elseif ($field->type==='private')}
            {elseif ($field->type==='javascript')}
            {elseif ($field->type==='pmconnection')}
            {elseif ($field->type==='hidden')}
            <tr style="display: none">
              <td colspan="2">{$field->field}</td>
            </tr>
            {elseif ($field->type==='')}
            {elseif ($field->withoutLabel)}
            <tr style="display:none">
              <td colspan="2" class="withoutLabel">{$field->field}</td>
            </tr>
            {elseif (isset($field->withoutValue) && $field->withoutValue)}
            <tr>
              <td class='FormLabel' colspan="2"><div align="{$field->align}">{$field->label}</div></td>
            </tr>
            {else}
            <tr>
              <td class='FormLabel' width="{$form->labelWidth}">{if (isset($field->required)&&$field->required&&$field->mode==='edit')}<font color="red">*  </font>{/if}{$field->label}</td>
              <td class='FormFieldContent' width='{$form->fieldContentWidth}' {* width="{math equation="parseFloat(x)-parseFloat(y)" x=$form->width y=$form->labelWidth}" *}>{$field->field}</td>
            </tr>
            {/if}
            {/foreach}
          </table>
          <hr/>

          <table width="100%" border="0">
            <tr>
              {if $prevStep_label neq ''}
              <td align="left" width="50%">
                <input type="button" class="module_app_button___gray"  value="{$prevStep_label}" onclick="location.href='{$prevStep_url}'"/>
              </td>
              {/if}
              {foreach from=$form->fields item=field}
                {if ($field->type==='reset')}
                <td align="right">{$field->field}</td>
                {/if}
              {/foreach}
              {foreach from=$form->fields item=field}
                {if ($field->type==='button')}
                <td align="right">{$field->field}</td>
                {/if}
              {/foreach}
              {foreach from=$form->fields item=field}
                {if ($field->type==='submit')}
                <td align="right">{$field->field}</td>
                {/if}
              {/foreach}
            <tr>
          </table>
          
        </td>
      </tr>
    </table>
    {if $hasRequiredFields}<div class="FormRequiredTextMessage"><font color="red">*  </font>{php}echo (G::LoadTranslation('ID_REQUIRED_FIELD'));{/php}</div>{/if}
       </div>
       <div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div>
       </div>
       {foreach from=$form->fields item=field}
         {if ($field->type==='javascript')}
           <script type="text/javascript">
             {$field->field}
           </script>
         {/if}
       {/foreach}
  </form>

{/if}
{if $printJSFile}
  {* TODO: include file='xmlformScript.html' *}
  var form_{$form->id};
  var object_{$form->name};
  var i;
  if (typeof(__aObjects__) === 'undefined') {literal}{{/literal}
    var __aObjects__ = [];
    {literal}}{/literal}
    function loadForm_{$form->id}(ajaxServer)
    {literal}{{/literal}
    if (typeof(G_Form)==='undefined') return alert('form.js was not loaded');
      form_{$form->id}=new G_Form(document.getElementById('{$form->id}'),'{$form->id}');
      object_{$form->name} = form_{$form->id};
      __aObjects__.push(object_{$form->name});
      var myForm=form_{$form->id};
      if (myForm.aElements===undefined) alert("{$form->name}");
        myForm.ajaxServer=ajaxServer;
        //{$form->ajaxSubmit}
        {if isset($form->ajaxSubmit) && ($form->ajaxSubmit)}
          {literal}
            var sub = new leimnud.module.app.submit({
              form    : myForm.element,{/literal}
              inProgress: {$form->in_progress},
              callback: {$form->callback}
              {literal}
            });
            sub.sendObj = false;
          {/literal}
        {/if}
        {foreach from=$form->fields item=field key=name}
          i = myForm.aElements.length;
          {if (($field->type==='dropdown') || $field->type==='listbox')}
            myForm.aElements[i] = new G_DropDown(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='text')}
            myForm.aElements[i] = new G_Text(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            //alert('{$field->getAttributes()}');
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='percentage')}
            myForm.aElements[i] = new G_Percentage(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='currency')}
            myForm.aElements[i] = new G_Currency(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='textarea')}
            myForm.aElements[i] = new G_TextArea(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='date')}
            myForm.aElements[i] = new G_Date(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            myForm.aElements[i].mask = 'yyyy-mm-dd';
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='hidden')}
            myForm.aElements[i] = new G_Text(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
            myForm.aElements[i].setAttributes({$field->getAttributes()});
            {$field->attachEvents("myForm.aElements[i].element")}
          {elseif ($field->type==='grid')}
            myForm.aElements[i] = new G_Grid(myForm, '{$name}');
            grid_{$field->id}(myForm.aElements[i]);
            grid_{$name} = myForm.aElements[i];
            {$field->attachEvents("myForm.aElements[i].element")}
          {else}
            var element = getField("{$name}");
            {$field->attachEvents("element")}
        {/if}
      {/foreach}
      {foreach from=$form->fields item=field key=name}
        {if isset($field->dependentFields) && ($field->dependentFields!='')}
          {if ($field->type==='dropdown')}
              myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
            {elseif ($field->type==='text')}
              myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
            {elseif ($field->type==='percentage')}
              myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
            {elseif ($field->type==='currency')}
              myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
            {elseif ($field->type==='date')}
              myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
          {/if}
        {/if}
      {/foreach}
      {literal}}{/literal}
    {/if}
    {if $printJavaScript}
      leimnud.event.add(window,'load',function(){literal}{{/literal}loadForm_{$form->id}('{$form->ajaxServer}');if (typeof(dynaformOnload) !== 'undefined') {literal}{dynaformOnload();}}{/literal});
    {/if}