
                                <div class="form form-forms aif" style="width:auto;">
                                    <!--<link rel="stylesheet" type="text/css" media="screen" 
									href="//formbuilder.online/assets/css/form-builder.min.css">-->

                                    <script src="//formbuilder.online/assets/js/form-builder.min.js"></script>

                                    &nbsp;&nbsp; <a class='editFormLink' href='#editForm'>Edit Form</a> | <a class="viewRecordsLink" href="#customAjaxLoader">View Records</a> | <a href="#" class='deleteRecords'>Delete Records</a>
                                    
                                    <br /><br />
                                    
                                    <div id="fb-editor" style="display:none; height:600px;">
                                    </div>
                                    
                                    <div style="display: none">
                                        <div id="customAjaxLoader" style="max-width: 90%; max-height:90%"></div>
                                    </div>
                                                                                                            
                                    <script>
                                    jQuery(function($) {
                                        $('.deleteRecords').click(function (e) {
                                            e.preventDefault();
                                            
                                            if (confirm("Are you sure you want to erase form records?")) {
                                                $.ajax({
                                                    url: '?deleteFormRecords',
                                                    success: function () {
                                                       alert("Done");
                                                    }
                                                })
                                            }
                                        });
                                        
                                        $('.editFormLink').click(function () {
                                            $('#fb-editor').show();
                                        });
                                        $('.viewRecordsLink').fancybox();
                                        
                                        $('.viewRecordsLink').click(function () {
                                            $.ajax({
                                               url: '?loadFormRecords',
                                               success: function (d) {
                                                   $('#customAjaxLoader').html(d);
                                               }
                                            }); 
                                        });
                                        
                                        var $fbEditor = $(document.getElementById('fb-editor'));
                                        var formData = <?= $form['fields'] ?>;
                                        
                                        if (formData) {
                                            formData = JSON.stringify(formData);
                                        }
                                        
                                        var fbOptions = {};
                                        if (formData && formData != 'undefined') {
                                          fbOptions.formData = formData;
                                        }
                                        var formBuilder = $fbEditor.formBuilder(fbOptions);
                                        $('#fb-editor').on('click', '.save-template', function () {
                                          $.ajax({
                                              url: '?saveForm',
                                              type: 'POST',
                                              data: { formData: formBuilder.formData },
                                              success: function (d) {
                                                  if (d == 'ok') {
                                                      alert("Saved Successfully");
                                                      $.fancybox.close();
                                                  }
//                                                  
                                              }
                                          })
                                          
                                          window.sessionStorage.setItem('formData', formBuilder.formData);
                                          // console.log(window.sessionStorage.getItem('formData'));
                                        });
                                    });
                                    </script>
                                </div>
                            