Results 1 to 1 of 1

Thread: reposting Projected code for the New Case Module

  1. #1
    afidegnum is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    11

    Default reposting Projected code for the New Case Module

    Sugar CRM5.0
    Hi, I posted a thread on needing assistance on the Case Module, and I am reposting it with a sample code that I need to customize. as already said this is what I need to do. Some members due to their slow response of their internet connection speed, come up with an option of customizing the script in such a way, the form will load into a div tab, you quickly fill and submit it live without the whole page refreshes. I tried hard to figure out how best can I do that for more than 4 days, but since I do not have a full documentation at hand, I am perplexed.

    now let's start I am starting with the case module. specially create case. normally, when you hover the mouse over the link create new case, you will see this:index.php?module=Cases&action=EditView&return _module=Cases&return_action=DetailView

    which I found in menu.php in the case module. unfortunately for me, I search for "a href" so I can incorporate the new Ajax code, but I ended up having head ache.

    Below is the script I think will work and I copied it from Dynamic drive.

    <script type="text/javascript">

    /***********************************************
    * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    var bustcacheparameter=""

    function ajaxpage(url, containerid){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    if (bustcachevar) //if bust caching of external page
    bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    page_request.open('GET', url+bustcacheparameter, true)
    page_request.send(null)
    }

    function loadpage(page_request, containerid){
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    document.getElementById(containerid).innerHTML=pag e_request.responseText
    }

    function loadobjs(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src", file);
    }
    else if (file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel", "stylesheet");
    fileref.setAttribute("type", "text/css");
    fileref.setAttribute("href", file);
    }
    }
    if (fileref!=""){
    document.getElementsByTagName("head").item(0).appe ndChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
    }

    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <a href="javascript:ajaxpage('test.htm', 'contentarea');">test</a>
    <div id="contentarea"></div>
    <body>
    </body>
    </html>

    I will be grateful if you can direct me where should I put the Javascript code, and the module link so it will automatically hook and load the content into a DIV layer so I can update the form there. I will be glad if you can also direct me in case I might need to add something else to the script.

    Sincerely,
    Last edited by afidegnum; 2007-11-24 at 03:59 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 2006-03-28, 09:49 AM
  2. Couple new module dev questions.
    By natsirtm in forum Developer Help
    Replies: 4
    Last Post: 2006-02-17, 01:37 AM
  3. Module Loader Limitations
    By ftreml in forum Developer Help
    Replies: 1
    Last Post: 2005-10-28, 11:22 PM
  4. Replies: 1
    Last Post: 2005-10-24, 08:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •