Custom List Template

I'll try, but I'll need access to your site. Can you fill out http://fabrikar.com/you/my-sites. For now I just need a superadmin backend, and either exTplorer installed, or fill out ftp details (I prefer exTplorer for simpler stuff like this, it saves the overhead of adding yet another entry to my FileZilla).

And fill in the notes section with any details I need to find the form, files, etc.

-- hugh
 
ohhh I am not able to as this site is in an intranet zone. The environment is lock down so I am also not able to do remote. Will you be able to give me an illustration or example of similar approach that I can try to follow :)

thank you
 
It would be a LOT easier if I could get at the server.

I just went back and re-read the thread, and it looks like I mis-spoke, not sure why I said you could put the AJAX call into the action of a form button.

What you'll have to do is add a JavaScript action on the submit button. Give your button form ids in your markup, like myButton and myForm, and ...

Code:
<script>
document.id('myButton').addEvent('click', function(e) {
   e.stop();
   var url = $('myFormID').get('action');

   // get any form data you need to send ...
   var someData = document.id('someData').value;

   var request =new Request({
      url: url, 
      someData: someData,
      method:'get',
      onComplete:function(response){
         alert('response: ', response);
      }
   });

   request.send();
});
</script>

Replace the 'someData' with with whatever form data you need to send, adding extra lines for extra input fields.

-- hugh
 
PS - just to be clear, leave the AJAX URL you have as the action for the form. The code above will pick that up and use it. You just have to grab any of the form data you need to send to your PHP method.

-- hugh
 
Revisiting this again....

I added added the following to the default.php of a custom template;
Code:
<button type="button" onclick="AddRecord()">Add To Bus Indent</button>
<script>
function AddRecord() {
    var url = $('listform_44_com_fabrik_44').get('action');
    var sdate = document.id('bookdate').value;
    var booktime = document.id('booktime').value;
    var location = document.id('destination').value;
    var qty = document.id('iqty').value;
    var request =new Request({
       url: url,
       sdate: sdate,
       method:'UpdateBusIndent',
       onComplete:function(response){
          alert('response: ', response);
       }
    });
    request.send();           
}   
</script>

I added the UpdateBusIndent inside user_ajax.php ;

Code:
function UpdateBusIndent(){
        $db = FabrikWorker::getDbo(false, 3);
        $user =& JFactory::getUser();
        $regby=$user->get('username');
        $repby=$user->get('name');   
        echo $repby;
    }

I do a echo $repby is just to test if I am calling the function UpdateBusIndent() but it is not returning anything as I can see anything from the alert('response:',response);

Can you advice which part I am doing wrong.

The url part I had also try using ; but it did not work either.
var url='index.php?option=com_fabrik&format=raw&task=plugin.userAjax';
 
I can't see anything wrong, but spotting issues just by looking at code is very difficult.

I'd need access to your site.

-- hugh
 
So to say my approach and method is correct?

I wish I could do that, but my site is in an intranet and firewall will block anything coming in not within my control :(
 
I managed to get it working , as I recall what you told me earlier that this line
(<form class="fabrikForm form-search" action="index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=AddRecord" method="post" id="<?php echo $this->formid;?>" name="fabrikList">)
should be after my code.
After I make the adjustment I managed to get the result.

Now if I want to print the result back to the form I can't just to a echo as I am inside a javascript. How print it back to the form ?

Code:
<button type="button" onclick="AddRecord()">Add To Bus Indent</button>
<script>
function AddRecord() {
    var sdate = document.id('bookdate').value;
    var booktime = document.id('booktime').value;
    var location = document.id('location').value;
    var url='index.php?option=com_fabrik&format=raw&task=plugin.userAjax';
        new Request(
            {url:url,data:{method:'select','sdate':sdate,'booktime':booktime,'location':location}, 
                onComplete:function(r){
                    alert(r);
                }
            }   
        ).send();
}   
</script>

<form class="fabrikForm form-search" action="index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=AddRecord" method="post" id="<?php echo $this->formid;?>" name="fabrikList">
 
Okay I know how to do that now ;
<p id="busindentreport"></p>

In the return value from ajax call ;

document.getElementById("busindentreport").innerHTML = r;
 
Now that I am able to pass information from form to user_ajax.php , I wanted to run a MySQL query base on what user pick from the form and generate the result.

Once I generated the result I put everything into a $html and I would like to output into a pdf files.

I have the following code in my user_ajax.php

include("mpdf/mpdf.php");
$mpdf=new mPDF('c');
$mpdf->defaultheaderline = 1; /* 1 to include line below header/above footer */
$mpdf->defaultfooterline = 1; /* 1 to include line below header/above footer */
$headerdata = 'Location :'.$yard.'|ST Marine Bus Indent Service Report'.'|Date Printed:'.$Datereg;
$mpdf->SetHeader($headerdata);
$mpdf->SetFooter('|Pg :{PAGENO}|');
$mpdf->WriteHTML('<h2><u> </u></h2>');
$mpdf->WriteHTML($html);
$file='tmp/BusIndentInvoice.pdf';
$mpdf->Output($file,'F');
window.open("<?=site_url($file)?>");

The file was generated and inside the tmp folder of my server but somehow I could not get it to open in the new windows using window.open("<?=site_url($file)?>");

Can you kindly help me with this.
 
Well, you can't run Javascript in a PHP file.

You'll have to echo the URL to the file, so it gets returned to your calling code, and have an onSuccess() function in your AJAX request which then opens that URL.

-- hugh
 
We are in need of some funding.
More details.

Thank you.
Back
Top