[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/layouts/vlayout/modules/PriceBooks/resources/ -> Detail.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  Vtiger_Detail_Js("PriceBooks_Detail_Js",{},{
  11      
  12      listPriceUpdateContainer : false,
  13      
  14      /**
  15       * Function to get listPrice update container
  16       */
  17      getListPriceUpdateContainer : function(){
  18          return this.listPriceUpdateContainer;
  19      },
  20      
  21      /**
  22       * Function to register event for select button click on pricebooks related list
  23       */
  24      
  25      registerEventForSelectRecords : function(){
  26          var thisInstance = this;
  27          var detailContentsHolder = this.getContentHolder();
  28          detailContentsHolder.on('click', 'button.selectRelation', function(e){
  29              var selectedTabElement = thisInstance.getSelectedTab();
  30              var relatedModuleName = thisInstance.getRelatedModuleName();
  31              var relatedController = new PriceBooks_RelatedList_Js(thisInstance.getRecordId(), app.getModuleName(), selectedTabElement, relatedModuleName);
  32              relatedController.showSelectRelationPopup();
  33          });
  34      },
  35      
  36      /**
  37       * Function to registerevent for updatelistprice in modal window on click of save
  38       */
  39      
  40      registerEventforUpdateListPrice : function(){
  41          var thisInstance = this;
  42          var container = jQuery('#listPriceUpdate');
  43          container.on('submit',function(e){
  44              e.preventDefault();
  45              var invalidFields = container.data('jqv').InvalidFields;
  46              if((invalidFields.length) == 0){
  47                  var idList = new Array();
  48                  var relid = container.find('input[name="relid"]').val();
  49                  var listPriceVal = container.find('input[name="currentPrice"]').val();
  50                  idList.push({'id' : relid,'price' : listPriceVal});
  51                  var relatedListInstance = new PriceBooks_RelatedList_Js(thisInstance.getRecordId(), app.getModuleName(), thisInstance.getSelectedTab(), thisInstance.getRelatedModuleName());
  52                  relatedListInstance.addRelations(idList);
  53                  app.hideModalWindow();
  54                  var relatedCurrentPage = relatedListInstance.getCurrentPageNum();
  55                  var params = {'page':relatedCurrentPage};
  56                  relatedListInstance.loadRelatedList(params);
  57              }
  58          })
  59      },
  60      /**
  61       * Function to show listprice update form
  62       */
  63      showListPriceUpdate : function(data){
  64          app.showModalWindow(data,{'text-align':'left'});
  65          jQuery('#listPriceUpdate').validationEngine(app.validationEngineOptions);
  66          this.registerEventforUpdateListPrice();
  67      },
  68      
  69      /**
  70       * Function to get listprice edit form
  71       */
  72      getListPriceEditForm : function(requestUrl){
  73          var aDeferred = jQuery.Deferred();
  74          var thisInstance = this;
  75          var listPriceContainer = this.getListPriceUpdateContainer();
  76          if(listPriceContainer != false){
  77              aDeferred.resolve(listPriceContainer);
  78          }else{
  79              AppConnector.request(requestUrl).then(
  80                  function(data){
  81                      thisInstance.listPriceUpdateContainer = data;
  82                      aDeferred.resolve(data);
  83                  },
  84                  function(textStatus, errorThrown){
  85                      aDeferred.reject(textStatus, errorThrown);
  86                  }
  87              );
  88          }
  89          return aDeferred.promise();
  90      },
  91      
  92      /**
  93       * function to register event for editing the list price in related list 
  94       */
  95      
  96      registerEventForEditListPrice : function(){
  97          var thisInstance = this;
  98          var detailContentsHolder = this.getContentHolder();
  99          detailContentsHolder.on('click', 'a.editListPrice', function(e){
 100              e.stopPropagation();
 101              var elem = jQuery(e.currentTarget);
 102              var requestUrl = elem.data('url');
 103              thisInstance.getListPriceEditForm(requestUrl).then(
 104                  function(data){
 105                      var relid = elem.data('relatedRecordid');
 106                      var listPrice = elem.data('listPrice');
 107                      var form = jQuery(data);
 108                      form.find('input[name="relid"]').val(relid);
 109                      form.find('input[name="currentPrice"]').val(listPrice);
 110                      thisInstance.showListPriceUpdate(form);
 111                  },
 112                  function(error,err){
 113  
 114                  }
 115              );
 116          });
 117      },
 118      /**
 119       * Function to register events
 120       */
 121      
 122      registerEvents : function(){
 123          this._super();
 124          this.registerEventForSelectRecords();
 125          this.registerEventForEditListPrice();
 126      }
 127  })


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1