Beispiel #1
0
 /**
  * Move the related records of the specified list of id's to the given record.
  * @param String This module name
  * @param Array List of Entity Id's from which related records need to be transfered
  * @param Integer Id of the the Record to which the related records are to be moved
  */
 function transferRelatedRecords($module, $transferEntityIds, $entityId)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     $log->debug("Entering function transferRelatedRecords ({$module}, {$transferEntityIds}, {$entityId})");
     $rel_table_arr = array("Contacts" => "vtiger_contpotentialrel", "Products" => "vtiger_seproductsrel", "Attachments" => "vtiger_seattachmentsrel", "Quotes" => "vtiger_quotes", "SalesOrder" => "vtiger_salesorder", "Documents" => "vtiger_senotesrel");
     $tbl_field_arr = array("vtiger_contpotentialrel" => "contactid", "vtiger_seproductsrel" => "productid", "vtiger_seattachmentsrel" => "attachmentsid", "vtiger_quotes" => "quoteid", "vtiger_salesorder" => "salesorderid", "vtiger_senotesrel" => "notesid");
     $entity_tbl_field_arr = array("vtiger_contpotentialrel" => "potentialid", "vtiger_seproductsrel" => "crmid", "vtiger_seattachmentsrel" => "crmid", "vtiger_quotes" => "potentialid", "vtiger_salesorder" => "potentialid", "vtiger_senotesrel" => "crmid");
     foreach ($transferEntityIds as $transferId) {
         foreach ($rel_table_arr as $rel_module => $rel_table) {
             $id_field = $tbl_field_arr[$rel_table];
             $entity_id_field = $entity_tbl_field_arr[$rel_table];
             // IN clause to avoid duplicate entries
             $sel_result = $adb->pquery("select {$id_field} from {$rel_table} where {$entity_id_field}=? " . " and {$id_field} not in (select {$id_field} from {$rel_table} where {$entity_id_field}=?)", array($transferId, $entityId));
             $res_cnt = $adb->num_rows($sel_result);
             if ($res_cnt > 0) {
                 for ($i = 0; $i < $res_cnt; $i++) {
                     $id_field_value = $adb->query_result($sel_result, $i, $id_field);
                     $adb->pquery("update {$rel_table} set {$entity_id_field}=? where {$entity_id_field}=? and {$id_field}=?", array($entityId, $transferId, $id_field_value));
                 }
             }
         }
     }
     parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
     $log->debug("Exiting transferRelatedRecords...");
 }
Beispiel #2
0
 /**
  * Move the related records of the specified list of id's to the given record.
  * @param String This module name
  * @param Array List of Entity Id's from which related records need to be transfered
  * @param Integer Id of the the Record to which the related records are to be moved
  */
 function transferRelatedRecords($module, $transferEntityIds, $entityId)
 {
     global $adb, $log;
     $log->debug("Entering function transferRelatedRecords ({$module}, {$transferEntityIds}, {$entityId})");
     parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
     $rel_table_arr = array("Potentials" => "vtiger_contpotentialrel", "Activities" => "vtiger_cntactivityrel", "Emails" => "vtiger_seactivityrel", "HelpDesk" => "vtiger_troubletickets", "Quotes" => "vtiger_quotes", "PurchaseOrder" => "vtiger_purchaseorder", "SalesOrder" => "vtiger_salesorder", "Products" => "vtiger_seproductsrel", "Documents" => "vtiger_senotesrel", "Attachments" => "vtiger_seattachmentsrel", "Campaigns" => "vtiger_campaigncontrel");
     $tbl_field_arr = array("vtiger_contpotentialrel" => "potentialid", "vtiger_cntactivityrel" => "activityid", "vtiger_seactivityrel" => "activityid", "vtiger_troubletickets" => "ticketid", "vtiger_quotes" => "quoteid", "vtiger_purchaseorder" => "purchaseorderid", "vtiger_salesorder" => "salesorderid", "vtiger_seproductsrel" => "productid", "vtiger_senotesrel" => "notesid", "vtiger_seattachmentsrel" => "attachmentsid", "vtiger_campaigncontrel" => "campaignid");
     $entity_tbl_field_arr = array("vtiger_contpotentialrel" => "contactid", "vtiger_cntactivityrel" => "contactid", "vtiger_seactivityrel" => "crmid", "vtiger_troubletickets" => "parent_id", "vtiger_quotes" => "contactid", "vtiger_purchaseorder" => "contactid", "vtiger_salesorder" => "contactid", "vtiger_seproductsrel" => "crmid", "vtiger_senotesrel" => "crmid", "vtiger_seattachmentsrel" => "crmid", "vtiger_campaigncontrel" => "contactid");
     foreach ($transferEntityIds as $transferId) {
         foreach ($rel_table_arr as $rel_module => $rel_table) {
             $id_field = $tbl_field_arr[$rel_table];
             $entity_id_field = $entity_tbl_field_arr[$rel_table];
             // IN clause to avoid duplicate entries
             $sel_result = $adb->pquery("select {$id_field} from {$rel_table} where {$entity_id_field}=? " . " and {$id_field} not in (select {$id_field} from {$rel_table} where {$entity_id_field}=?)", array($transferId, $entityId));
             $res_cnt = $adb->num_rows($sel_result);
             if ($res_cnt > 0) {
                 for ($i = 0; $i < $res_cnt; $i++) {
                     $id_field_value = $adb->query_result($sel_result, $i, $id_field);
                     $adb->pquery("update {$rel_table} set {$entity_id_field}=? where {$entity_id_field}=? and {$id_field}=?", array($entityId, $transferId, $id_field_value));
                 }
             }
         }
         // direct relation with potentials
         $adb->pquery("UPDATE vtiger_potential SET related_to = ? WHERE related_to = ?", array($entityId, $transferId));
     }
     $log->debug("Exiting transferRelatedRecords...");
 }
Beispiel #3
0
 /**
  * Move the related records of the specified list of id's to the given record.
  * @param String This module name
  * @param Array List of Entity Id's from which related records need to be transfered
  * @param Integer Id of the the Record to which the related records are to be moved
  */
 function transferRelatedRecords($module, $transferEntityIds, $entityId)
 {
     global $adb, $log;
     $log->debug("Entering function transferRelatedRecords ({$module}, {$transferEntityIds}, {$entityId})");
     $rel_table_arr = array("Quotes" => "vtiger_inventoryproductrel", "PurchaseOrder" => "vtiger_inventoryproductrel", "SalesOrder" => "vtiger_inventoryproductrel", "Invoice" => "vtiger_inventoryproductrel", "PriceBooks" => "vtiger_pricebookproductrel", "Documents" => "vtiger_senotesrel");
     $tbl_field_arr = array("vtiger_inventoryproductrel" => "id", "vtiger_pricebookproductrel" => "pricebookid", "vtiger_senotesrel" => "notesid");
     $entity_tbl_field_arr = array("vtiger_inventoryproductrel" => "productid", "vtiger_pricebookproductrel" => "productid", "vtiger_senotesrel" => "crmid");
     foreach ($transferEntityIds as $transferId) {
         foreach ($rel_table_arr as $rel_module => $rel_table) {
             $id_field = $tbl_field_arr[$rel_table];
             $entity_id_field = $entity_tbl_field_arr[$rel_table];
             // IN clause to avoid duplicate entries
             $sel_result = $adb->pquery("select {$id_field} from {$rel_table} where {$entity_id_field}=? " . " and {$id_field} not in (select {$id_field} from {$rel_table} where {$entity_id_field}=?)", array($transferId, $entityId));
             $res_cnt = $adb->num_rows($sel_result);
             if ($res_cnt > 0) {
                 for ($i = 0; $i < $res_cnt; $i++) {
                     $id_field_value = $adb->query_result($sel_result, $i, $id_field);
                     $adb->pquery("update {$rel_table} set {$entity_id_field}=? where {$entity_id_field}=? and {$id_field}=?", array($entityId, $transferId, $id_field_value));
                 }
             }
         }
     }
     parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
     $log->debug("Exiting transferRelatedRecords...");
 }
Beispiel #4
0
 /**
  * Move the related records of the specified list of id's to the given record.
  * @param String This module name
  * @param Array List of Entity Id's from which related records need to be transfered
  * @param Integer Id of the the Record to which the related records are to be moved
  */
 function transferRelatedRecords($module, $transferEntityIds, $entityId)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     $log->debug("Entering function transferRelatedRecords ({$module}, {$transferEntityIds}, {$entityId})");
     $rel_table_arr = array("Potentials" => "vtiger_contpotentialrel", "Potentials" => "vtiger_potential", "HelpDesk" => "vtiger_troubletickets", "Quotes" => "vtiger_quotes", "PurchaseOrder" => "vtiger_purchaseorder", "SalesOrder" => "vtiger_salesorder", "Products" => "vtiger_seproductsrel", "Documents" => "vtiger_senotesrel", "Attachments" => "vtiger_seattachmentsrel", "Campaigns" => "vtiger_campaigncontrel", 'Invoice' => 'vtiger_invoice', 'ServiceContracts' => 'vtiger_servicecontracts', 'Project' => 'vtiger_project', 'Assets' => 'vtiger_assets');
     $tbl_field_arr = array("vtiger_contpotentialrel" => "potentialid", "vtiger_potential" => "potentialid", "vtiger_troubletickets" => "ticketid", "vtiger_quotes" => "quoteid", "vtiger_purchaseorder" => "purchaseorderid", "vtiger_salesorder" => "salesorderid", "vtiger_seproductsrel" => "productid", "vtiger_senotesrel" => "notesid", "vtiger_seattachmentsrel" => "attachmentsid", "vtiger_campaigncontrel" => "campaignid", 'vtiger_invoice' => 'invoiceid', 'vtiger_servicecontracts' => 'servicecontractsid', 'vtiger_project' => 'projectid', 'vtiger_assets' => 'assetsid', 'vtiger_payments' => 'paymentsid');
     $entity_tbl_field_arr = array("vtiger_contpotentialrel" => "contactid", "vtiger_potential" => "contact_id", "vtiger_troubletickets" => "contact_id", "vtiger_quotes" => "contactid", "vtiger_purchaseorder" => "contactid", "vtiger_salesorder" => "contactid", "vtiger_seproductsrel" => "crmid", "vtiger_senotesrel" => "crmid", "vtiger_seattachmentsrel" => "crmid", "vtiger_campaigncontrel" => "contactid", 'vtiger_invoice' => 'contactid', 'vtiger_servicecontracts' => 'sc_related_to', 'vtiger_project' => 'linktoaccountscontacts', 'vtiger_assets' => 'contact', 'vtiger_payments' => 'relatedcontact');
     foreach ($transferEntityIds as $transferId) {
         foreach ($rel_table_arr as $rel_module => $rel_table) {
             $id_field = $tbl_field_arr[$rel_table];
             $entity_id_field = $entity_tbl_field_arr[$rel_table];
             // IN clause to avoid duplicate entries
             $sel_result = $adb->pquery("select {$id_field} from {$rel_table} where {$entity_id_field}=? " . " and {$id_field} not in (select {$id_field} from {$rel_table} where {$entity_id_field}=?)", array($transferId, $entityId));
             $res_cnt = $adb->num_rows($sel_result);
             if ($res_cnt > 0) {
                 for ($i = 0; $i < $res_cnt; $i++) {
                     $id_field_value = $adb->query_result($sel_result, $i, $id_field);
                     $adb->pquery("update {$rel_table} set {$entity_id_field}=? where {$entity_id_field}=? and {$id_field}=?", array($entityId, $transferId, $id_field_value));
                 }
             }
         }
         $adb->pquery("UPDATE vtiger_potential SET related_to = ? WHERE related_to = ?", array($entityId, $transferId));
     }
     parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
     $log->debug("Exiting transferRelatedRecords...");
 }
Beispiel #5
0
 /**
  * Move the related records of the specified list of id's to the given record.
  * @param String This module name
  * @param Array List of Entity Id's from which related records need to be transfered
  * @param Integer Id of the the Record to which the related records are to be moved
  */
 function transferRelatedRecords($module, $transferEntityIds, $entityId)
 {
     global $adb, $log;
     $log->debug("Entering function transferRelatedRecords ({$module}, {$transferEntityIds}, {$entityId})");
     $rel_table_arr = array("Contacts" => "vtiger_campaigncontrel", "Potentials" => "vtiger_potential", "Leads" => "vtiger_campaignleadrel", "Activities" => "vtiger_seactivityrel", "Documents" => "vtiger_senotesrel", "Attachments" => "vtiger_seattachmentsrel", "Campaigns" => "vtiger_campaignaccountrel", "CobroPago" => "vtiger_cobropago");
     $tbl_field_arr = array("vtiger_campaigncontrel" => "contactid", "vtiger_potential" => "potentialid", "vtiger_campaignleadrel" => "leadid", "vtiger_seactivityrel" => "activityid", "vtiger_senotesrel" => "notesid", "vtiger_seattachmentsrel" => "attachmentsid", "vtiger_campaignaccountrel" => "accountid", "vtiger_cobropago" => "cobropagoid");
     $entity_tbl_field_arr = array("vtiger_campaigncontrel" => "campaignid", "vtiger_potential" => "campaignid", "vtiger_campaignleadrel" => "campaignid", "vtiger_seactivityrel" => "crmid", "vtiger_senotesrel" => "crmid", "vtiger_seattachmentsrel" => "crmid", "vtiger_campaignaccountrel" => "campaignid", "vtiger_cobropago" => "related_id");
     foreach ($transferEntityIds as $transferId) {
         foreach ($rel_table_arr as $rel_module => $rel_table) {
             $id_field = $tbl_field_arr[$rel_table];
             $entity_id_field = $entity_tbl_field_arr[$rel_table];
             // IN clause to avoid duplicate entries
             $sel_result = $adb->pquery("select {$id_field} from {$rel_table} where {$entity_id_field}=? " . " and {$id_field} not in (select {$id_field} from {$rel_table} where {$entity_id_field}=?)", array($transferId, $entityId));
             $res_cnt = $adb->num_rows($sel_result);
             if ($res_cnt > 0) {
                 for ($i = 0; $i < $res_cnt; $i++) {
                     $id_field_value = $adb->query_result($sel_result, $i, $id_field);
                     $adb->pquery("update {$rel_table} set {$entity_id_field}=? where {$entity_id_field}=? and {$id_field}=?", array($entityId, $transferId, $id_field_value));
                 }
             }
         }
     }
     parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
     $log->debug("Exiting transferRelatedRecords...");
 }
Beispiel #6
0
	/**
	 * Move the related records of the specified list of id's to the given record.
	 * @param String This module name
	 * @param Array List of Entity Id's from which related records need to be transfered
	 * @param Integer Id of the the Record to which the related records are to be moved
	 */
	function transferRelatedRecords($module, $transferEntityIds, $entityId)
	{
		$adb = PearDatabase::getInstance();
		$log = vglobal('log');
		$log->debug("Entering function transferRelatedRecords ($module, $transferEntityIds, $entityId)");

		$rel_table_arr = Array("Contacts" => "vtiger_contactdetails", "Potentials" => "vtiger_potential", "Quotes" => "vtiger_quotes",
			"SalesOrder" => "vtiger_salesorder", "Invoice" => "vtiger_invoice",
			"Documents" => "vtiger_senotesrel", "Attachments" => "vtiger_seattachmentsrel", "HelpDesk" => "vtiger_troubletickets",
			"Products" => "vtiger_seproductsrel", "ServiceContracts" => "vtiger_servicecontracts", "Campaigns" => "vtiger_campaignaccountrel",
			"Assets" => "vtiger_assets", "Project" => "vtiger_project");

		$tbl_field_arr = Array("vtiger_contactdetails" => "contactid", "vtiger_potential" => "potentialid", "vtiger_quotes" => "quoteid",
			"vtiger_salesorder" => "salesorderid", "vtiger_invoice" => "invoiceid",
			"vtiger_senotesrel" => "notesid", "vtiger_seattachmentsrel" => "attachmentsid", "vtiger_troubletickets" => "ticketid",
			"vtiger_seproductsrel" => "productid", "vtiger_servicecontracts" => "servicecontractsid", "vtiger_campaignaccountrel" => "campaignid",
			"vtiger_assets" => "assetsid", "vtiger_project" => "projectid", "vtiger_payments" => "paymentsid");

		$entity_tbl_field_arr = Array("vtiger_contactdetails" => "parentid", "vtiger_potential" => "related_to", "vtiger_quotes" => "accountid",
			"vtiger_salesorder" => "accountid", "vtiger_invoice" => "accountid",
			"vtiger_senotesrel" => "crmid", "vtiger_seattachmentsrel" => "crmid", "vtiger_troubletickets" => "parent_id",
			"vtiger_seproductsrel" => "crmid", "vtiger_servicecontracts" => "sc_related_to", "vtiger_campaignaccountrel" => "accountid",
			"vtiger_assets" => "parent_id", "vtiger_project" => "linktoaccountscontacts", "vtiger_payments" => "relatedorganization");

		foreach ($transferEntityIds as $transferId) {
			foreach ($rel_table_arr as $rel_module => $rel_table) {
				$id_field = $tbl_field_arr[$rel_table];
				$entity_id_field = $entity_tbl_field_arr[$rel_table];
				// IN clause to avoid duplicate entries
				$sel_result = $adb->pquery("select $id_field from $rel_table where $entity_id_field=? " .
					" and $id_field not in (select $id_field from $rel_table where $entity_id_field=?)", array($transferId, $entityId));
				$res_cnt = $adb->num_rows($sel_result);
				if ($res_cnt > 0) {
					for ($i = 0; $i < $res_cnt; $i++) {
						$id_field_value = $adb->query_result($sel_result, $i, $id_field);
						$adb->pquery("update $rel_table set $entity_id_field=? where $entity_id_field=? and $id_field=?", array($entityId, $transferId, $id_field_value));
					}
				}
			}
		}
		parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
		$log->debug("Exiting transferRelatedRecords...");
	}
Beispiel #7
0
 /**
  * Move the related records of the specified list of id's to the given record.
  * @param String This module name
  * @param Array List of Entity Id's from which related records need to be transfered
  * @param Integer Id of the the Record to which the related records are to be moved
  */
 function transferRelatedRecords($module, $transferEntityIds, $entityId)
 {
     global $adb, $log;
     $log->debug("Entering function transferRelatedRecords ({$module}, {$transferEntityIds}, {$entityId})");
     $rel_table_arr = array("ProjectTask" => "vtiger_projecttask", 'ProjectMilestone' => 'vtiger_projectmilestone', "Documents" => "vtiger_senotesrel", "Attachments" => "vtiger_seattachmentsrel");
     $tbl_field_arr = array("vtiger_projecttask" => "projecttaskid", 'vtiger_projectmilestone' => 'projectmilestoneid', "vtiger_senotesrel" => "notesid", "vtiger_seattachmentsrel" => "attachmentsid");
     $entity_tbl_field_arr = array("vtiger_projecttask" => "projectid", 'vtiger_projectmilestone' => 'projectid', "vtiger_senotesrel" => "crmid", "vtiger_seattachmentsrel" => "crmid");
     foreach ($transferEntityIds as $transferId) {
         foreach ($rel_table_arr as $rel_module => $rel_table) {
             $id_field = $tbl_field_arr[$rel_table];
             $entity_id_field = $entity_tbl_field_arr[$rel_table];
             // IN clause to avoid duplicate entries
             $sel_result = $adb->pquery("select {$id_field} from {$rel_table} where {$entity_id_field}=? " . " and {$id_field} not in (select {$id_field} from {$rel_table} where {$entity_id_field}=?)", array($transferId, $entityId));
             $res_cnt = $adb->num_rows($sel_result);
             if ($res_cnt > 0) {
                 for ($i = 0; $i < $res_cnt; $i++) {
                     $id_field_value = $adb->query_result($sel_result, $i, $id_field);
                     $adb->pquery("update {$rel_table} set {$entity_id_field}=? where {$entity_id_field}=? and {$id_field}=?", array($entityId, $transferId, $id_field_value));
                 }
             }
         }
     }
     parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
     $log->debug("Exiting transferRelatedRecords...");
 }
Beispiel #8
0
    /**
	 * Move the related records of the specified list of id's to the given record.
	 * @param String This module name
	 * @param Array List of Entity Id's from which related records need to be transfered
	 * @param Integer Id of the the Record to which the related records are to be moved
	 */
	function transferRelatedRecords($module, $transferEntityIds, $entityId) {
		global $adb,$log;
		$log->debug("Entering function transferRelatedRecords ($module, $transferEntityIds, $entityId)");

		$rel_table_arr = Array("Documents"=>"vtiger_senotesrel","Attachments"=>"vtiger_seattachmentsrel");

		$tbl_field_arr = Array("vtiger_senotesrel"=>"notesid","vtiger_seattachmentsrel"=>"attachmentsid");

		$entity_tbl_field_arr = Array("vtiger_senotesrel"=>"crmid","vtiger_seattachmentsrel"=>"crmid");

		foreach($transferEntityIds as $transferId) {
			foreach($rel_table_arr as $rel_module=>$rel_table) {
				$id_field = $tbl_field_arr[$rel_table];
				$entity_id_field = $entity_tbl_field_arr[$rel_table];
				// IN clause to avoid duplicate entries
				$sel_result =  $adb->pquery("select $id_field from $rel_table where $entity_id_field=? " .
						" and $id_field not in (select $id_field from $rel_table where $entity_id_field=?)",
						array($transferId,$entityId));
				$res_cnt = $adb->num_rows($sel_result);
				if($res_cnt > 0) {
					for($i=0;$i<$res_cnt;$i++) {
						$id_field_value = $adb->query_result($sel_result,$i,$id_field);
						$adb->pquery("update $rel_table set $entity_id_field=? where $entity_id_field=? and $id_field=?",
							array($entityId,$transferId,$id_field_value));
					}
				}
			}
		}
		parent::transferRelatedRecords($module, $transferEntityIds, $entityId);
		$log->debug("Exiting transferRelatedRecords...");
	}