[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/include/js/ -> dtlviewajax.js (source)

   1  /*********************************************************************************
   2  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   3   * ("License"); You may not use this file except in compliance with the License
   4   * The Original Code is:  vtiger CRM Open Source
   5   * The Initial Developer of the Original Code is vtiger.
   6   * Portions created by vtiger are Copyright (C) vtiger.
   7   * All Rights Reserved.
   8  *
   9   ********************************************************************************/
  10  var globaldtlviewspanid = "";
  11  var globaleditareaspanid = ""; 
  12  var globaltxtboxid = "";
  13  var itsonview=false;
  14  // to retain the old value if we cancel the ajax edit
  15  var globaltempvalue = '';
  16  var globaluitype = '';
  17  function showHide(showId, hideId)
  18  {
  19      show(showId);
  20      fnhide(hideId);
  21  }
  22  
  23  function hndCancel(valuespanid,textareapanid,fieldlabel)
  24  {
  25  
  26    showHide(valuespanid,textareapanid);
  27    if(globaluitype == '56')
  28    {      
  29        if(globaltempvalue == 1)
  30            getObj(globaltxtboxid).checked = true; 
  31        else        
  32            getObj(globaltxtboxid).checked = false; 
  33    }
  34    else if(globaluitype != '53')      
  35        getObj(globaltxtboxid).value = globaltempvalue; 
  36    globaltempvalue = '';
  37    itsonview=false;
  38    return false;
  39  }
  40  
  41  function hndMouseOver(uitype,fieldLabel)
  42  {
  43        var mouseArea="";
  44        mouseArea="mouseArea_"+ fieldLabel;
  45        if(itsonview)
  46        {
  47              return;
  48        }
  49        
  50        show("crmspanid");
  51        globaluitype = uitype;
  52        globaldtlviewspanid= "dtlview_"+ fieldLabel;//valuespanid;
  53        globaleditareaspanid="editarea_"+ fieldLabel;//textareapanid;
  54        globalfieldlabel = fieldLabel;
  55        if(globaluitype == 53)
  56        {
  57            if(typeof(document.DetailView.assigntype[0]) != 'undefined')
  58            {
  59                var assign_type_U = document.DetailView.assigntype[0].checked;
  60                var assign_type_G = document.DetailView.assigntype[1].checked;
  61                if(assign_type_U == true)
  62                    globaltxtboxid= 'txtbox_U'+fieldLabel;
  63                else if(assign_type_G == true)
  64                    globaltxtboxid= 'txtbox_G'+fieldLabel;
  65            }else
  66            {
  67                globaltxtboxid= 'txtbox_U'+fieldLabel;
  68            }
  69        }else
  70        {
  71              globaltxtboxid="txtbox_"+ fieldLabel;//textboxpanid;
  72        }
  73        divObj = getObj('crmspanid'); 
  74        crmy = findPosY(getObj(mouseArea));
  75        crmx = findPosX(getObj(mouseArea));
  76        if(document.all)
  77        {
  78            divObj.onclick=handleEdit;
  79        }
  80        else
  81        {
  82            divObj.setAttribute('onclick','handleEdit();');
  83        }
  84        divObj.style.left=(crmx+getObj(mouseArea).offsetWidth -divObj.offsetWidth)+"px";
  85        divObj.style.top=crmy+"px";
  86  }
  87  
  88  function handleEdit()
  89  {
  90       show(globaleditareaspanid) ;
  91       fnhide(globaldtlviewspanid);
  92       if(globaluitype != 53)
  93       {
  94          globaltempvalue = getObj(globaltxtboxid).value;
  95          if(getObj(globaltxtboxid).type != 'hidden')
  96                    getObj(globaltxtboxid).focus();
  97       }
  98       fnhide('crmspanid');
  99       itsonview=true;
 100       return false;
 101  }
 102  
 103  function trim(str)
 104  {
 105      return(str.replace(/\s+$/,''));
 106  }
 107  
 108  var genUiType = "";
 109  var genFldValue = "";
 110  
 111  function dtlViewAjaxSave(fieldLabel,module,uitype,tableName,fieldName,crmId)
 112  {
 113      var dtlView = "dtlview_"+ fieldLabel;
 114      var editArea = "editarea_"+ fieldLabel;
 115      var groupurl = "";
 116      
 117      if(globaluitype == 53)
 118      {
 119          if(typeof(document.DetailView.assigntype[0]) != 'undefined')
 120          {
 121              var assign_type_U = document.DetailView.assigntype[0].checked;
 122              var assign_type_G = document.DetailView.assigntype[1].checked;
 123          }else
 124          {
 125              var assign_type_U = document.DetailView.assigntype.checked;
 126          }
 127          if(assign_type_U == true)
 128          {
 129              var txtBox= 'txtbox_U'+fieldLabel;
 130          }
 131          else if(assign_type_G == true)
 132          {
 133              var txtBox= 'txtbox_G'+fieldLabel;
 134              var group_name = $(txtBox).options[$(txtBox).selectedIndex].text; 
 135              var groupurl = "&assigned_group_name="+group_name+"&assigntype=T"
 136          }
 137  
 138      }else if(globaluitype == 33)
 139      {
 140        var txtBox= "txtbox_"+ fieldLabel;
 141        var oMulSelect = $(txtBox);
 142        var r = new Array();
 143        for (iter=0;iter < oMulSelect.options.length ; iter++)
 144        {
 145        if (oMulSelect.options[iter].selected)
 146          r[r.length] = oMulSelect.options[iter].value;
 147        }
 148      }else
 149      {
 150          var txtBox= "txtbox_"+ fieldLabel;
 151      }
 152      
 153      var popupTxt= "popuptxt_"+ fieldLabel;      
 154      var hdTxt = "hdtxt_"+ fieldLabel;
 155  
 156      if(formValidate() == false)
 157      {
 158          return false;
 159      }
 160  
 161  
 162      $("vtbusy_info").style.display="inline";
 163      var isAdmin = document.getElementById("hdtxt_IsAdmin").value; 
 164  
 165  
 166      //overriden the tagValue based on UI Type for checkbox 
 167      if(uitype == '56')
 168      {
 169          if(document.getElementById(txtBox).checked == true)
 170          {
 171              tagValue = "1";
 172          }else
 173          {
 174              tagValue = "0";
 175          }
 176      }else    if(uitype == '156')
 177      {
 178          if(document.getElementById(txtBox).checked == true)
 179          {
 180              tagValue = "on";
 181          }else
 182          {
 183              tagValue = "off";
 184          }
 185      }else if(uitype == '33')
 186      {
 187          tagValue = r.join(" |##| ");
 188        }else
 189      {
 190          tagValue = trim(document.getElementById(txtBox).value);
 191      }
 192  
 193  
 194      var data = "file=DetailViewAjax&module=" + module + "&action=" + module + "Ajax&record=" + crmId+"&recordid=" + crmId ;
 195      data = data + "&fldName=" + fieldName + "&fieldValue=" + escape(tagValue) + "&ajxaction=DETAILVIEW"+groupurl;
 196      new Ajax.Request(
 197          'index.php',
 198                  {queue: {position: 'end', scope: 'command'},
 199                          method: 'post',
 200                          postBody: data,
 201                          onComplete: function(response) {
 202                                    if(response.responseText.indexOf(":#:FAILURE")>-1)
 203                                    {
 204                                        alert("Error while Editing");
 205                                    }
 206                                    else if(response.responseText.indexOf(":#:SUCCESS")>-1)
 207                                 {
 208                                        $("vtbusy_info").style.display="none";
 209                                 }
 210                          }
 211                  }
 212              );
 213      if(uitype == '13' || uitype == '104')
 214      {
 215          getObj(dtlView).innerHTML = "<a href=\"mailto:"+ tagValue+"\" target=\"_blank\">"+tagValue+"&nbsp;</a>";
 216      }else if(uitype == '17')
 217      {
 218          getObj(dtlView).innerHTML = "<a href=\"http://"+ tagValue+"\" target=\"_blank\">"+tagValue+"&nbsp;</a>";
 219      }else if(uitype == '85')
 220          {
 221                  getObj(dtlView).innerHTML = "<a href=\"skype://"+ tagValue+"?call\">"+tagValue+"&nbsp;</a>";
 222          }else if(uitype == '53')
 223      {
 224          var hdObj = getObj(hdTxt);
 225          if(typeof(document.DetailView.assigntype[0]) != 'undefined')
 226          {
 227              var assign_type_U = document.DetailView.assigntype[0].checked;
 228              var assign_type_G = document.DetailView.assigntype[1].checked;
 229          }else
 230          {
 231              var assign_type_U = document.DetailView.assigntype.checked;
 232          }
 233          if(isAdmin == "0")
 234          {
 235              getObj(dtlView).innerHTML = hdObj.value;
 236          }else if(isAdmin == "1" && assign_type_U == true)
 237          {
 238              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";
 239          }else if(isAdmin == "1" && assign_type_G == true)
 240          {
 241              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=GroupDetailView&groupId="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";
 242          }
 243      }else if(uitype == '56')
 244      {
 245          if(tagValue == '1')
 246          {
 247              getObj(dtlView).innerHTML = "yes";
 248          }else
 249          {
 250              getObj(dtlView).innerHTML = "";
 251          }
 252  
 253      }else if(uitype == 116)
 254      {
 255              getObj(dtlView).innerHTML = document.getElementById(txtBox).options[document.getElementById(txtBox).selectedIndex].text; 
 256      }
 257      else if(getObj(popupTxt))
 258      {
 259          var popObj = getObj(popupTxt);
 260          if(uitype == '50' || uitype == '73' || uitype == '51')
 261          {
 262              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Accounts&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 263          }
 264          else if(uitype == '57')
 265          {
 266              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Contacts&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 267          }
 268          else if(uitype == '59')
 269          {
 270              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Products&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 271          }
 272          else if(uitype == '75' || uitype == '81' )
 273          {
 274              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Vendors&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 275  
 276          }
 277          else if(uitype == '76')
 278          {
 279              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Potentials&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 280          }
 281          else if(uitype == '78')
 282          {
 283              getObj(dtlView).innerHTML = "<a href=\"index.php?module=Quotes&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 284          }
 285          else if(uitype == '80')
 286          {
 287              getObj(dtlView).innerHTML = "<a href=\"index.php?module=SalesOrder&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
 288          }
 289          else if(uitype == '53')
 290          {
 291              var hdObj = getObj(hdTxt);
 292              if(isAdmin == "0")
 293              {
 294                  getObj(dtlView).innerHTML = hdObj.value;
 295              }else if(isAdmin == "1")
 296              {
 297                  getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";;
 298              }
 299          }
 300          else if(uitype == '56')
 301          {
 302              if(tagValue == '1')
 303              {
 304                  getObj(dtlView).innerHTML = "yes";
 305              }else
 306              {
 307                  getObj(dtlView).innerHTML = "";
 308              }
 309  
 310          }
 311          else
 312          {
 313              getObj(dtlView).innerHTML = popObj.value;
 314          }
 315      }else if(uitype == '33')
 316        {
 317          /* Wordwrap a long list of multi-select combo box items at the
 318                   * item separator string */
 319                  const DETAILVIEW_WORDWRAP_WIDTH = "70"; // must match value in DetailViewUI.tpl.
 320  
 321                  var lineLength = 0;
 322                  for(var i=0; i < r.length; i++) {
 323                          lineLength += r[i].length + 2; // + 2 for item separator string
 324                          if(lineLength > DETAILVIEW_WORDWRAP_WIDTH && i > 0) {
 325                                  lineLength = r[i].length + 2; // reset.
 326                              r[i] = '<br/>&nbsp;' + r[i]; // prepend newline.
 327                          }
 328                          // Prevent a browser splitting multiword items:
 329                          r[i] = r[i].replace(/ /g, '&nbsp;');
 330                  }
 331                  /* Join items with item separator string (which must match string in DetailViewUI.tpl,
 332                   * EditViewUtils.php and CRMEntity.php)!!
 333                   */
 334                 getObj(dtlView).innerHTML = r.join(", ");
 335      }else
 336      {
 337          getObj(dtlView).innerHTML = tagValue;
 338      }
 339      showHide(dtlView,editArea);  //show,hide
 340      itsonview=false;
 341  }
 342  
 343  function SaveTag(txtBox,crmId,module)
 344  {
 345      var tagValue = document.getElementById(txtBox).value;
 346      document.getElementById(txtBox).value ='';
 347      $("vtbusy_info").style.display="inline";
 348      new Ajax.Request(
 349          'index.php',
 350                  {queue: {position: 'end', scope: 'command'},
 351                          method: 'post',
 352                          postBody: "file=TagCloud&module=" + module + "&action=" + module + "Ajax&recordid=" + crmId + "&ajxaction=SAVETAG&tagfields=" +tagValue,
 353                          onComplete: function(response) {
 354                          getObj('tagfields').innerHTML = response.responseText;
 355                      $("vtbusy_info").style.display="none";
 356                          }
 357                  }
 358          );
 359      
 360  }
 361  function setSelectValue(fieldLabel)
 362  {
 363      if(globaluitype == 53)
 364      {
 365          if(typeof(document.DetailView.assigntype[0]) != 'undefined')
 366          {
 367              var assign_type_U = document.DetailView.assigntype[0].checked;
 368              var assign_type_G = document.DetailView.assigntype[1].checked;
 369              if(assign_type_U == true)
 370                  var selCombo= 'txtbox_U'+fieldLabel;
 371              else if(assign_type_G == true)    
 372                  var selCombo= 'txtbox_G'+fieldLabel;
 373          }else
 374          {
 375              var selCombo= 'txtbox_U'+fieldLabel;
 376          }
 377      }else
 378      {
 379              var selCombo= 'txtbox_'+fieldLabel;
 380      }
 381      var hdTxtBox = 'hdtxt_'+fieldLabel;
 382      var oHdTxtBox = document.getElementById(hdTxtBox);
 383      var oSelCombo = document.getElementById(selCombo);
 384  
 385      oHdTxtBox.value = oSelCombo.options[oSelCombo.selectedIndex].text;
 386  }
 387  


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7