[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
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 class Settings_Vtiger_CustomRecordNumberingModule_Model extends Vtiger_Module_Model { 12 13 /** 14 * Function to get focus of this object 15 * @return <type> 16 */ 17 public function getFocus() { 18 if (!$this->focus) { 19 $this->focus = CRMEntity::getInstance($this->getName()); 20 } 21 return $this->focus; 22 } 23 24 /** 25 * Function to get Instance of this module 26 * @param <String> $moduleName 27 * @return <Settings_Vtiger_CustomRecordNumberingModule_Model> $moduleModel 28 */ 29 public static function getInstance($moduleName, $tabId = false) { 30 $moduleModel = new self(); 31 $moduleModel->name = $moduleName; 32 if ($tabId) { 33 $moduleModel->id = $tabId; 34 } 35 return $moduleModel; 36 } 37 38 /** 39 * Function to ger Supported modules for Custom record numbering 40 * @return <Array> list of supported modules <Vtiger_Module_Model> 41 */ 42 public static function getSupportedModules() { 43 $db = PearDatabase::getInstance(); 44 45 $sql = "SELECT tabid, name FROM vtiger_tab WHERE isentitytype = ? AND presence = ? AND tabid IN (SELECT DISTINCT tabid FROM vtiger_field WHERE uitype = ?)"; 46 $result = $db->pquery($sql, array(1, 0, 4)); 47 $numOfRows = $db->num_rows($result); 48 49 for($i=0; $i<$numOfRows; $i++) { 50 $tabId = $db->query_result($result, $i, 'tabid'); 51 $modulesModels[$tabId] = Settings_Vtiger_CustomRecordNumberingModule_Model::getInstance($db->query_result($result, $i, 'name'), $tabId); 52 } 53 54 return $modulesModels; 55 } 56 57 /** 58 * Function to get module custom numbering data 59 * @return <Array> data of custom numbering data 60 */ 61 public function getModuleCustomNumberingData() { 62 $moduleInfo = $this->getFocus()->getModuleSeqInfo($this->getName()); 63 return array( 64 'prefix' => $moduleInfo[0], 65 'sequenceNumber' => $moduleInfo[1] 66 ); 67 } 68 69 /** 70 * Function to set Module sequence 71 * @return <Array> result of success 72 */ 73 public function setModuleSequence() { 74 $moduleName = $this->getName(); 75 $prefix = $this->get('prefix'); 76 $sequenceNumber = $this->get('sequenceNumber'); 77 78 $status = $this->getFocus()->setModuleSeqNumber('configure', $moduleName, $prefix, $sequenceNumber); 79 80 $success = array('success' => $status); 81 if (!$status) { 82 $db = PearDatabase::getInstance(); 83 $result = $db->pquery("SELECT cur_id FROM vtiger_modentity_num WHERE semodule = ? AND prefix = ?", array($moduleName, $prefix)); 84 $success['sequenceNumber'] = $db->query_result($result, 0, 'cur_id'); 85 } 86 87 return $success; 88 } 89 90 /** 91 * Function to update record sequences which are under this module 92 * @return <Array> result of success 93 */ 94 public function updateRecordsWithSequence() { 95 return $this->getFocus()->updateMissingSeqNumber($this->getName()); 96 } 97 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |