[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/Webservices/ -> RelatedModuleMeta.php (source)

   1  <?php
   2  /*+*******************************************************************************
   3   *  The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9   *
  10   *********************************************************************************/
  11  
  12  /**
  13   * Description of RelatedModuleMeta
  14   * TODO to add and extend a way to track many-many and many-one relationships.
  15   * @author MAK
  16   */
  17  class RelatedModuleMeta {
  18      private $module;
  19      private $relatedModule;
  20      private $CAMPAIGNCONTACTREL = 1;
  21      private $PRODUCTQUOTESREL = 2;
  22      private $PRODUCTINVOICEREL = 3;
  23      private $PRODUCTPURCHASEORDERREL = 4;
  24      
  25  	private function  __construct($module, $relatedModule) {
  26          $this->module = $module;
  27          $this->relatedModule = $relatedModule;
  28      }
  29  
  30      /**
  31       *
  32       * @param <type> $module
  33       * @param <type> $relatedModule
  34       * @return RelatedModuleMeta 
  35       */
  36  	public static function getInstance($module, $relatedModule) {
  37          return new RelatedModuleMeta($module, $relatedModule);
  38      }
  39  
  40  	public function getRelationMeta() {
  41          $campaignContactRel = array('Campaigns','Contacts');
  42          $productInvoiceRel = array('Products','Invoice');
  43          $productQuotesRel = array('Products','Quotes');
  44          $productPurchaseOrder = array('Products','PurchaseOrder');
  45          if(in_array($this->module, $campaignContactRel) && in_array($this->relatedModule,
  46                  $campaignContactRel)) {
  47              return $this->getRelationMetaInfo($this->CAMPAIGNCONTACTREL);
  48          }
  49          if(in_array($this->module, $productInvoiceRel) && in_array($this->relatedModule,
  50                  $productInvoiceRel)) {
  51              return $this->getRelationMetaInfo($this->PRODUCTINVOICEREL);
  52          }
  53          if(in_array($this->module, $productQuotesRel) && in_array($this->relatedModule,
  54                  $productQuotesRel)) {
  55              return $this->getRelationMetaInfo($this->PRODUCTQUOTESREL);
  56          }
  57          if(in_array($this->module, $productPurchaseOrder) && in_array($this->relatedModule,
  58                  $productPurchaseOrder)) {
  59              return $this->getRelationMetaInfo($this->PRODUCTPURCHASEORDERREL);
  60          }
  61      }
  62  
  63  	private function getRelationMetaInfo($relationId) {
  64          switch($relationId) {
  65              case $this->CAMPAIGNCONTACTREL: return array(
  66                      'relationTable' => 'vtiger_campaigncontrel',
  67                      'Campaigns' => 'campaignid',
  68                      'Contacts' => 'contactid'
  69                  );
  70              case $this->PRODUCTINVOICEREL: return array(
  71                      'relationTable' => 'vtiger_inventoryproductrel',
  72                      'Products' => 'productid',
  73                      'Invoice' => 'id'
  74                  );
  75              case $this->PRODUCTQUOTESREL: return array(
  76                      'relationTable' => 'vtiger_inventoryproductrel',
  77                      'Products' => 'productid',
  78                      'Quotes' => 'id'
  79                  );
  80              case $this->PRODUCTPURCHASEORDERREL: return array(
  81                      'relationTable' => 'vtiger_inventoryproductrel',
  82                      'Products' => 'productid',
  83                      'PurchaseOrder' => 'id'
  84                  );
  85          }
  86      }
  87  }
  88  ?>


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