$field8->typeofdata = 'V~O';
$block1->addField($field8);
$field9 = new Vtiger_Field();
$field9->name = 'dn_sequence';
//Sequencial
$field9->label = 'Delivery Note Number';
$field9->table = 'vtiger_deliverynote';
//$module->basetable;
$field9->column = 'dn_sequence';
$field9->columntype = 'VARCHAR(100)';
$field9->uitype = 4;
$field9->typeofdata = 'V~O';
$block1->addField($field9);
// following for auto gen on save
$entity_tmp = new CRMEntity();
$entity_tmp->setModuleSeqNumber("configure", $module->name, "DN", 1);
// Create default custom filter (mandatory)
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$module->addFilter($filter1);
// Add fields to the filter created
$filter1->addField($field1)->addField($field2, 1)->addField($field5, 2);
// Create one more filter
$filter2 = new Vtiger_Filter();
$filter2->name = 'All2';
$module->addFilter($filter2);
// Add fields to the filter
$filter2->addField($field1);
$filter2->addField($field2, 1);
// Add rule to the filter field
Exemple #2
0
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall)
  */
 function vtlib_handler($modulename, $event_type)
 {
     if ($event_type == 'module.postinstall') {
         global $adb;
         // Configure module seq number
         $entity_tmp = new CRMEntity();
         Accounting::checkConfig(0);
         $entity_tmp->setModuleSeqNumber("configure", "Accounting", "PAY", 1);
         // Configure workflow
         Accounting::configure_workflows();
         Accounting::updateConfigParam('customlinks', 'true');
         Accounting::updateCustomLinks(array("Leads", "Contacts", "Vendors", "Accounts", "Invoice", "PurchaseOrder", "SalesOrder", "Invoice"), 'true');
         Accounting::setRelatedModules('false');
         Accounting::setRelatedModules('true');
     } else {
         if ($event_type == 'module.disabled') {
             Accounting::setRelatedModules('false');
             // TODO Handle actions when this module is disabled.
         } else {
             if ($event_type == 'module.enabled') {
                 Accounting::setRelatedModules('true');
                 // TODO Handle actions when this module is enabled.
             } else {
                 if ($event_type == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                     Accounting::setRelatedModules('false');
                 } else {
                     if ($event_type == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($event_type == 'module.postupdate') {
                             Accounting::updateDateFields();
                             Accounting::checkConfig(1);
                             Accounting::setRelatedModules('false');
                             Accounting::setRelatedModules('true');
                             Accounting::configure_workflows();
                             // TODO Handle actions after this module is updated.
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Invoked when special actions are performed on the module.
  * @param String Module name
  * @param String Event Type
  */
 function vtlib_handler($moduleName, $eventType)
 {
     require_once 'include/utils/utils.php';
     require_once 'include/events/include.inc';
     $adb = PearDatabase::getInstance();
     $registerLink = false;
     $addModTracker = false;
     $handlerClass = 'SECURE';
     if ($eventType == 'module.postinstall') {
         //Add OSSPasswords Module to Customer Portal
         require_once 'vtlib/Vtiger/Module.php';
         // add default oss_passwords configuration
         $adb->pquery("INSERT INTO vtiger_passwords_config values(?,?,?,?)", array('10', '15', 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9', '0'));
         // adds record prefix
         $myCustomEntity = new CRMEntity();
         $myCustomPrefix = "PASS";
         // Your custom prefix string for the custom module
         $sequenceStart = 1;
         // The starting sequence number
         $myCustomEntity->setModuleSeqNumber("configure", $moduleName, $myCustomPrefix, $sequenceStart);
         $registerLink = true;
         $addModTracker = true;
         // handler for obscuring password data in "update history"
         $em = new VTEventsManager($adb);
         $em->registerHandler('vtiger.entity.aftersave.final', 'modules/OSSPasswords/handlers/secure.php', $handlerClass);
         // Module icon
         copy('modules/OSSPasswords/OSSPasswords.png', 'layouts/vlayout/skins/images/OSSPasswords.png');
         // block export of module
         $sql = "UPDATE vtiger_tab SET customized=0 WHERE name='{$moduleName}' LIMIT 1;";
         $adb->query($sql, true);
     } else {
         if ($eventType == 'module.disabled') {
             // TODO Handle actions when this module is disabled.
             $registerLink = false;
             $em = new VTEventsManager($adb);
             $em->setHandlerInActive($handlerClass);
         } else {
             if ($eventType == 'module.enabled') {
                 // TODO Handle actions when this module is enabled.
                 $registerLink = true;
                 $em = new VTEventsManager($adb);
                 $em->setHandlerActive($handlerClass);
             } else {
                 if ($eventType == 'module.preuninstall') {
                     // TODO Handle actions when this module is about to be deleted.
                     $this->log->debug('Before starting uninstall script...');
                     require_once 'modules/Settings/' . $moduleName . '/views/uninstall.php';
                     $this->log->debug('After uninstall script.');
                     header('Location: index.php?module=Vtiger&parent=Settings&view=Index');
                 } else {
                     if ($eventType == 'module.preupdate') {
                         // TODO Handle actions before this module is updated.
                     } else {
                         if ($eventType == 'module.postupdate') {
                         }
                     }
                 }
             }
         }
     }
     $displayLabel = 'OSSPassword Configuration';
     if ($registerLink) {
         $blockid = $adb->query_result($adb->pquery("SELECT blockid FROM vtiger_settings_blocks WHERE label='LBL_OTHER_SETTINGS'", array()), 0, 'blockid');
         $sequence = (int) $adb->query_result($adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_field WHERE blockid=?", array($blockid)), 0, 'sequence') + 1;
         $fieldid = $adb->getUniqueId('vtiger_settings_field');
         $adb->pquery("INSERT INTO vtiger_settings_field (fieldid,blockid,sequence,name,iconpath,description,linkto)\n\t\t\t\tVALUES (?,?,?,?,?,?,?)", array($fieldid, $blockid, $sequence, $displayLabel, 'migrate.gif', 'LBL_OSSPASSWORD_CONFIGURATION_DESCRIPTION', 'index.php?module=OSSPasswords&view=ConfigurePass&parent=Settings'));
     } else {
         $adb->pquery("DELETE FROM vtiger_settings_field WHERE name=?", array($displayLabel));
     }
     // register modtracker history updates
     if ($addModTracker) {
         $tabId = getTabid($moduleName);
         include_once 'modules/ModTracker/ModTracker.php';
         $moduleModTrackerInstance = new ModTracker();
         if (!$moduleModTrackerInstance->isModulePresent($tabId)) {
             $res = $adb->pquery("INSERT INTO vtiger_modtracker_tabs VALUES(?,?)", array($tabId, 1));
             $moduleModTrackerInstance->updateCache($tabId, 1);
         } else {
             $updatevisibility = $adb->pquery("UPDATE vtiger_modtracker_tabs SET visible = 1 WHERE tabid = ?", array($tabId));
             $moduleModTrackerInstance->updateCache($tabId, 1);
         }
         if (!$moduleModTrackerInstance->isModTrackerLinkPresent($tabId)) {
             $moduleInstance = Vtiger_Module::getInstance($tabId);
             $moduleInstance->addLink('DETAILVIEWBASIC', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')", '', '', array('path' => 'modules/ModTracker/ModTracker.php', 'class' => 'ModTracker', 'method' => 'isViewPermitted'));
         }
     }
 }