function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $moduleInstance = Vtiger_Module::getInstance('Users'); $block = Vtiger_Block::getInstance('LBL_CALENDAR_SETTINGS', $moduleInstance); if (!$block) { $block = new Vtiger_Block(); $block->label = 'LBL_CALENDAR_SETTINGS'; $block->sequence = 2; $moduleInstance->addBlock($block); } $this->ExecuteQuery("delete from vtiger_picklist where name='hour_format'"); $this->ExecuteQuery("delete from vtiger_picklist where name='start_hour'"); $field = Vtiger_Field::getInstance('hour_format', $moduleInstance); $this->ExecuteQuery('update vtiger_field set presence=2,uitype=16 where fieldid=' . $field->id); $field->setPicklistValues(array('am/pm', '12', '24')); $start_hour = Vtiger_Field::getInstance('start_hour', $moduleInstance); $this->ExecuteQuery('update vtiger_field set presence=2,uitype=16 where fieldid=' . $start_hour->id); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset assignto_mailscanner already applied!'); } else { $mod_hd = Vtiger_Module::getInstance('HelpDesk'); $block_hd = Vtiger_Block::getInstance('LBL_TICKET_INFORMATION', $mod_hd); $field1 = new Vtiger_Field(); $field1->name = 'from_mailscanner'; $field1->label = 'From mailscanner'; $field1->column = 'from_mailscanner'; $field1->columntype = 'VARCHAR(3)'; $field1->sequence = 1; $field1->uitype = 56; $field1->typeofdata = 'C~O'; $field1->displaytype = 3; $field1->presence = 0; $field1->readonly = 1; $block_hd->addField($field1); $this->ExecuteQuery('ALTER TABLE vtiger_mailscanner_rules ADD assign_to INT(11)'); $this->sendMsg('Changeset assignto_mailscanner applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $moduleInstance = Vtiger_Module::getInstance('Users'); $block = Vtiger_Block::getInstance('LBL_USER_ADV_OPTIONS', $moduleInstance); $field = Vtiger_Field::getInstance('failed_login_attempts', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $user_field = new Vtiger_Field(); $user_field->name = 'failed_login_attempts'; $user_field->label = 'LBL_FAILED_LOGIN_ATTEMPTS'; $user_field->table = 'vtiger_users'; $user_field->column = 'failed_login_attempts'; $user_field->columntype = 'int(11)'; $user_field->typeofdata = 'I~O'; $user_field->uitype = '7'; $user_field->masseditable = '0'; $block->addField($user_field); $this->ExecuteQuery('update vtiger_users set failed_login_attempts=0'); RecalculateSharingRules(); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $moduleInstance = Vtiger_Module::getInstance('Users'); $block = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $moduleInstance); $field = Vtiger_Field::getInstance('send_email_to_sender', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $user_field = new Vtiger_Field(); $user_field->name = 'send_email_to_sender'; $user_field->label = 'LBL_SEND_EMAIL_TO_SENDER'; $user_field->table = 'vtiger_users'; $user_field->column = 'send_email_to_sender'; $user_field->columntype = 'varchar(3)'; $user_field->typeofdata = 'C~O'; $user_field->uitype = '56'; $user_field->masseditable = '0'; $block->addField($user_field); $this->ExecuteQuery("update vtiger_users set send_email_to_sender='1'"); RecalculateSharingRules(); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $moduleInstance = Vtiger_Module::getInstance('Users'); $block = Vtiger_Block::getInstance('LBL_CALENDAR_SETTINGS', $moduleInstance); if (!$block) { $block = new Vtiger_Block(); $block->label = 'LBL_CALENDAR_SETTINGS'; $block->sequence = 2; $moduleInstance->addBlock($block); } $this->ExecuteQuery('drop table if exists vtiger_hour_format'); $this->ExecuteQuery('drop table if exists vtiger_start_hour'); $field = Vtiger_Field::getInstance('hour_format', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2,uitype=16 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'hour_format'; $field->label = 'Calendar Hour Format'; $field->table = 'vtiger_users'; $field->column = 'hour_format'; $field->columntype = 'varchar(4)'; $field->typeofdata = 'V~O'; $field->uitype = '16'; $field->masseditable = '0'; $block->addField($field); } $field->setPicklistValues(array('12', '24')); $start_hour = Vtiger_Field::getInstance('start_hour', $moduleInstance); if ($start_hour) { $this->ExecuteQuery('update vtiger_field set presence=2,uitype=16 where fieldid=' . $start_hour->id); } else { $start_hour = new Vtiger_Field(); $start_hour->name = 'start_hour'; $start_hour->label = 'Day starts at'; $start_hour->table = 'vtiger_users'; $start_hour->column = 'start_hour'; $start_hour->columntype = 'varchar(5)'; $start_hour->typeofdata = 'V~O'; $start_hour->uitype = '16'; $start_hour->masseditable = '0'; $block->addField($start_hour); } $start_hour->setPicklistValues(array('00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00')); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $chktbl = $adb->query('select 1 from com_vtiger_workflow_tasktypes limit 1'); if ($chktbl) { $moduleInstance = Vtiger_Module::getInstance('Potentials'); $block = Vtiger_Block::getInstance('LBL_OPPORTUNITY_INFORMATION', $moduleInstance); $field = Vtiger_Field::getInstance('forecast_amount', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $forecast_field = new Vtiger_Field(); $forecast_field->name = 'forecast_amount'; $forecast_field->label = 'Forecast Amount'; $forecast_field->table = 'vtiger_potential'; $forecast_field->column = 'forecast_amount'; $forecast_field->columntype = 'decimal(25,4)'; $forecast_field->typeofdata = 'N~O'; $forecast_field->uitype = '71'; $forecast_field->masseditable = '0'; $block->addField($forecast_field); } $wfrs = $adb->query("SELECT workflow_id FROM com_vtiger_workflows WHERE summary='Calculate or Update forecast amount'"); if ($wfrs and $adb->num_rows($wfrs) == 1) { $this->sendMsg('Workfolw already exists!'); } else { $workflowManager = new VTWorkflowManager($adb); $taskManager = new VTTaskManager($adb); $potentailsWorkFlow = $workflowManager->newWorkFlow("Potentials"); $potentailsWorkFlow->test = ''; $potentailsWorkFlow->description = "Calculate or Update forecast amount"; $potentailsWorkFlow->executionCondition = VTWorkflowManager::$ON_EVERY_SAVE; $potentailsWorkFlow->defaultworkflow = 1; $workflowManager->save($potentailsWorkFlow); $task = $taskManager->createTask('VTUpdateFieldsTask', $potentailsWorkFlow->id); $task->active = true; $task->summary = 'update forecast amount'; $task->field_value_mapping = '[{"fieldname":"forecast_amount","valuetype":"expression","value":"amount * probability / 100"}]'; $taskManager->saveTask($task); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } else { $this->sendMsgError('This changeset could not be applied because it depends on create_workflow_tasktype which probably has not been applied yet. Apply that changeset and try this one again.'); } } $this->finishExecution(); }
/** * Initialize this instance * @param Array * @param Vtiger_Module Instance of module to which this field belongs * @param Vtiger_Block Instance of block to which this field belongs * @access private */ function initialize($valuemap, $moduleInstance = false, $blockInstance = false) { $this->id = $valuemap['fieldid']; $this->name = $valuemap['fieldname']; $this->label = $valuemap['fieldlabel']; $this->column = $valuemap['columnname']; $this->table = $valuemap['tablename']; $this->uitype = $valuemap['uitype']; $this->typeofdata = $valuemap['typeofdata']; $this->helpinfo = $valuemap['helpinfo']; $this->masseditable = $valuemap['masseditable']; $this->block = $blockInstance ? $blockInstance : Vtiger_Block::getInstance($valuemap['block'], $moduleInstance); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $modname = 'Products'; $module = Vtiger_Module::getInstance($modname); $block = Vtiger_Block::getInstance('LBL_PRICING_INFORMATION', $module); $field = Vtiger_Field::getInstance('cost_price', $module); if (!$field) { $field1 = new Vtiger_Field(); $field1->name = 'cost_price'; $field1->label = 'Cost Price'; $field1->column = 'cost_price'; $field1->columntype = 'DECIMAL(28,6)'; $field1->uitype = 71; $field1->typeofdata = 'N~O'; $field1->displaytype = 1; $field1->presence = 0; $block->addField($field1); } $modname = 'Services'; $module = Vtiger_Module::getInstance($modname); $block = Vtiger_Block::getInstance('LBL_PRICING_INFORMATION', $module); $field = Vtiger_Field::getInstance('cost_price', $module); if (!$field) { $field1 = new Vtiger_Field(); $field1->name = 'cost_price'; $field1->label = 'Cost Price'; $field1->column = 'cost_price'; $field1->columntype = 'DECIMAL(28,6)'; $field1->uitype = 71; $field1->typeofdata = 'N~O'; $field1->displaytype = 1; $field1->presence = 0; $block->addField($field1); } } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); $this->finishExecution(); }
/** * Initialize this instance * @param Array * @param Vtiger_Module Instance of module to which this field belongs * @param Vtiger_Block Instance of block to which this field belongs * @access private */ function initialize($valuemap, $moduleInstance = false, $blockInstance = false) { $this->id = $valuemap['fieldid']; $this->name = $valuemap['fieldname']; $this->label = $valuemap['fieldlabel']; $this->column = $valuemap['columnname']; $this->table = $valuemap['tablename']; $this->uitype = $valuemap['uitype']; $this->typeofdata = $valuemap['typeofdata']; $this->helpinfo = $valuemap['helpinfo']; $this->masseditable = $valuemap['masseditable']; $this->displaytype = $valuemap['displaytype']; $this->generatedtype = $valuemap['generatedtype']; $this->readonly = $valuemap['readonly']; $this->presence = $valuemap['presence']; $this->defaultvalue = $valuemap['defaultvalue']; $this->quickcreate = $valuemap['quickcreate']; $this->sequence = $valuemap['sequence']; $this->summaryfield = $valuemap['summaryfield']; $this->block = $blockInstance ? $blockInstance : Vtiger_Block::getInstance($valuemap['block'], $moduleInstance); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $vendorsInstance = Vtiger_Module::getInstance('Vendors'); $blockInstance = Vtiger_Block::getInstance('LBL_VENDOR_INFORMATION', $vendorsInstance); $field = Vtiger_Field::getInstance('assigned_user_id', $vendorsInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'assigned_user_id'; $field->label = 'Assigned To'; $field->table = 'vtiger_crmentity'; $field->column = 'smownerid'; $field->columntype = 'INT(11)'; $field->uitype = 53; $field->displaytype = 1; $field->typeofdata = 'V~M'; $field->presence = 2; $field->quickcreate = 0; $field->quicksequence = 5; $blockInstance->addField($field); // Allow Sharing access and role-based security for Vendors Vtiger_Access::deleteSharing($vendorsInstance); Vtiger_Access::initSharing($vendorsInstance); Vtiger_Access::allowSharing($vendorsInstance); Vtiger_Access::setDefaultSharing($vendorsInstance); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $moduleInstance = Vtiger_Module::getInstance('ModComments'); $block = Vtiger_Block::getInstance('LBL_OTHER_INFORMATION', $moduleInstance); $field = Vtiger_Field::getInstance('relatedassignedemail', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $modfield = new Vtiger_Field(); $modfield->name = 'relatedassignedemail'; $modfield->label = 'Related Assigned Email'; $modfield->table = $moduleInstance->basetable; $modfield->column = 'relatedassignedemail'; $modfield->columntype = 'varchar(254)'; $modfield->typeofdata = 'E~O'; $modfield->uitype = '13'; $modfield->displaytype = 2; // read only $modfield->masseditable = '0'; $block->addField($modfield); } $this->ExecuteQuery('UPDATE vtiger_modcomments INNER JOIN vtiger_crmentity on crmid=related_to INNER JOIN vtiger_users on id = smownerid SET relatedassignedemail = email1'); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $moduleInstance = Vtiger_Module::getInstance('cbMap'); $block = Vtiger_Block::getInstance('LBL_MAP_INFORMATION', $moduleInstance); $field = Vtiger_Field::getInstance('targetname', $moduleInstance); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'targetname'; $field->label = 'Target Module'; $field->table = 'vtiger_cbmap'; $field->column = 'targetname'; $field->columntype = 'varchar(200)'; $field->typeofdata = 'V~O'; $field->uitype = '1613'; $field->masseditable = '0'; $field->sequence = 4; $block->addField($field); } $field = Vtiger_Field::getInstance('assigned_user_id', $moduleInstance); $this->ExecuteQuery('update vtiger_field set sequence=6 where fieldid=' . $field->id); $field = Vtiger_Field::getInstance('createdtime', $moduleInstance); $this->ExecuteQuery('update vtiger_field set sequence=7 where fieldid=' . $field->id); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
/** * 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) { global $adb; require_once 'include/events/include.inc'; include_once 'vtlib/Vtiger/Module.php'; if ($event_type == 'module.postinstall') { // TODO Handle post installation actions $modAccounts = Vtiger_Module::getInstance('Accounts'); $modContacts = Vtiger_Module::getInstance('Contacts'); $modInvD = Vtiger_Module::getInstance('InventoryDetails'); $modIss = Vtiger_Module::getInstance('Issuecards'); if ($modAccounts) { $modAccounts->setRelatedList($modIss, 'Issuecards', array('ADD'), 'get_dependents_list'); } if ($modContacts) { $modContacts->setRelatedList($modIss, 'Issuecards', array('ADD'), 'get_dependents_list'); } if ($modInvD) { $field = Vtiger_Field::getInstance('related_to', $modInvD); $field->setRelatedModules(array('Issuecards')); $modIss->setRelatedList($modInvD, 'InventoryDetails', array(''), 'get_dependents_list'); } //Add Gendoc to Issuecards if (vtlib_isModuleActive("evvtgendoc")) { $modIss->addLink('LISTVIEWBASIC', 'Generate Document', "javascript:showgendoctemplates('\$MODULE\$');"); $modIss->addLink('DETAILVIEWWIDGET', 'Generate Document', "module=evvtgendoc&action=evvtgendocAjax&file=DetailViewWidget&formodule=\$MODULE\$&forrecord=\$RECORD\$", 'modules/evvtgendoc/evvtgendoc.gif'); } $emm = new VTEntityMethodManager($adb); // Adding EntityMethod for Updating Products data after updating PurchaseOrder $emm->addEntityMethod("Issuecards", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel"); // Creating Workflow for Updating Inventory Stock on Issuecards $vtWorkFlow = new VTWorkflowManager($adb); $invWorkFlow = $vtWorkFlow->newWorkFlow("Issuecards"); $invWorkFlow->test = '[{"fieldname":"pslip_no","operation":"does not contain","value":"`!`"}]'; $invWorkFlow->description = "UpdateInventoryProducts On Every Save"; $invWorkFlow->defaultworkflow = 1; $vtWorkFlow->save($invWorkFlow); $tm = new VTTaskManager($adb); $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id); $task->active = true; $task->methodName = "UpdateInventory"; $task->summary = "Update product stock"; $tm->saveTask($task); $this->setModuleSeqNumber('configure', $modulename, 'pslip-', '0000001'); } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // 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. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { // TODO Handle actions after this module is updated. $modInvD = Vtiger_Module::getInstance('InventoryDetails'); $modIss = Vtiger_Module::getInstance('Issuecards'); //Add subject field to can import and export $block = Vtiger_Block::getInstance('LBL_ISSUECARDS_INFO', $modIss); $field = Vtiger_Field::getInstance('subject', $modIss); if (!$field) { $field1 = new Vtiger_Field(); $field1->name = 'subject'; $field1->label = 'subject'; $field1->table = 'vtiger_issuecards'; $field1->column = 'subject'; $field1->columntype = 'VARCHAR(100)'; $field1->sequence = 3; $field1->uitype = 1; $field1->typeofdata = 'V~O'; $field1->displaytype = 1; $field1->presence = 0; $block->addField($field1); } if ($modInvD) { $field = Vtiger_Field::getInstance('related_to', $modInvD); $field->setRelatedModules(array('Issuecards')); $modIss->setRelatedList($modInvD, 'InventoryDetails', array(''), 'get_dependents_list'); } //Add Gendoc to Issuecards if (vtlib_isModuleActive("evvtgendoc")) { $modIss->addLink('LISTVIEWBASIC', 'Generate Document', "javascript:showgendoctemplates('\$MODULE\$');"); $modIss->addLink('DETAILVIEWWIDGET', 'Generate Document', "module=evvtgendoc&action=evvtgendocAjax&file=DetailViewWidget&formodule=\$MODULE\$&forrecord=\$RECORD\$", 'modules/evvtgendoc/evvtgendoc.gif'); } $emm = new VTEntityMethodManager($adb); // Adding EntityMethod for Updating Products data after updating Issuecards $emm->addEntityMethod("Issuecards", "UpdateInventory", "include/InventoryHandler.php", "handleInventoryProductRel"); // Creating Workflow for Updating Inventory Stock on Issuecards $vtWorkFlow = new VTWorkflowManager($adb); $invWorkFlow = $vtWorkFlow->newWorkFlow("Issuecards"); $invWorkFlow->test = '[{"fieldname":"pslip_no","operation":"does not contain","value":"`!`"}]'; $invWorkFlow->description = "UpdateInventoryProducts On Every Save"; $invWorkFlow->defaultworkflow = 1; $vtWorkFlow->save($invWorkFlow); $tm = new VTTaskManager($adb); $task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id); $task->active = true; $task->methodName = "UpdateInventory"; $task->summary = "Update product stock"; $tm->saveTask($task); } } } } } } }
public function addFields() { global $log, $adb; $log->debug("Entering YetiForceUpdate::addFields() method ..."); include_once 'vtlib/Vtiger/Module.php'; $columnName = array("tabid", "id", "column", "table", "generatedtype", "uitype", "name", "label", "readonly", "presence", "defaultvalue", "maximumlength", "sequence", "block", "displaytype", "typeofdata", "quickcreate", "quicksequence", "info_type", "masseditable", "helpinfo", "summaryfield", "fieldparams", "columntype", "blocklabel", "setpicklistvalues", "setrelatedmodules"); $OSSMailTemplates = array(array('49', '1739', 'ossmailtemplates_type', 'vtiger_ossmailtemplates', '1', '16', 'ossmailtemplates_type', 'LBL_TYPE', '1', '2', '', '100', '8', '126', '1', 'V~M', '1', NULL, 'BAS', '1', '', '0', '', "varchar(255)", "LBL_OSSMAILTEMPLATES_INFORMATION", array('PLL_MODULE', 'PLL_RECORD'), array())); $Users = array(array('29', '1740', 'emailoptout', 'vtiger_users', '1', '56', 'emailoptout', 'Approval for email', '1', '0', '', '50', '22', '79', '1', 'V~O', '1', NULL, 'BAS', '1', '', '0', '', "varchar(3)", "LBL_MORE_INFORMATION", array(), array())); $ProjectMilestone = array(array('41', '1741', 'projectmilestone_priority', 'vtiger_projectmilestone', '1', '15', 'projectmilestone_priority', 'LBL_PRIORITY', '1', '2', '', '100', '10', '101', '1', 'V~O', '1', NULL, 'BAS', '1', '', '0', '', "varchar(255)", "LBL_PROJECT_MILESTONE_INFORMATION", array('PLL_LOW', 'PLL_NORMAL', 'PLL_HIGH'), array()), array('41', '1743', 'projectmilestone_progress', 'vtiger_projectmilestone', '1', '1', 'projectmilestone_progress', 'LBL_PROGRESS', '1', '2', '', '100', '11', '101', '10', 'V~O', '1', NULL, 'BAS', '1', '', '0', '', "varchar(10)", "LBL_PROJECT_MILESTONE_INFORMATION", array(), array())); $ProjectTask = array(array('42', '1742', 'estimated_work_time', 'vtiger_projecttask', '1', '7', 'estimated_work_time', 'LBL_ESTIMATED_WORK_TIME', '1', '2', '', '100', '9', '105', '1', 'NN~M', '1', 3, 'BAS', '1', '', '0', '', "decimal(8,2)", "LBL_CUSTOM_INFORMATION", array(), array())); $Contacts = array(array('4', '1744', 'jobtitle', 'vtiger_contactdetails', '1', '1', 'jobtitle', 'Job title', '1', '2', '', '100', '31', '4', '1', 'V~O', '1', NULL, 'BAS', '1', '', '0', '', "varchar(100)", "LBL_CONTACT_INFORMATION", array(), array()), array(4, 1746, 'decision_maker', 'vtiger_contactdetails', 1, '56', 'decision_maker', 'Decision maker', 1, 2, '', 100, 9, 5, 1, 'C~O', 1, NULL, 'BAS', 1, '', 0, '', "tinyint(1)", "LBL_CUSTOM_INFORMATION", array(), array())); $OSSMailView = array(array('54', '1745', 'date', 'vtiger_ossmailview', '1', '70', 'date', 'Date of receipt', '1', '2', '', '100', '24', '134', '2', 'DT~O', '1', NULL, 'BAS', '1', '', '0', '', "datetime", "LBL_INFORMATION", array(), array())); $setToCRM = array('OSSMailTemplates' => $OSSMailTemplates, 'Users' => $Users, 'ProjectMilestone' => $ProjectMilestone, 'ProjectTask' => $ProjectTask, 'Contacts' => $Contacts, 'OSSMailView' => $OSSMailView); $setToCRMAfter = array(); foreach ($setToCRM as $nameModule => $module) { if (!$module) { continue; } foreach ($module as $key => $fieldValues) { for ($i = 0; $i < count($fieldValues); $i++) { $setToCRMAfter[$nameModule][$key][$columnName[$i]] = $fieldValues[$i]; } } } foreach ($setToCRMAfter as $moduleName => $fields) { foreach ($fields as $field) { if (self::checkFieldExists($field, $moduleName)) { continue; } $moduleInstance = Vtiger_Module::getInstance($moduleName); $blockInstance = Vtiger_Block::getInstance($field['blocklabel'], $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->column = $field['column']; $fieldInstance->name = $field['name']; $fieldInstance->label = $field['label']; $fieldInstance->table = $field['table']; $fieldInstance->uitype = $field['uitype']; $fieldInstance->typeofdata = $field['typeofdata']; $fieldInstance->readonly = $field['readonly']; $fieldInstance->displaytype = $field['displaytype']; $fieldInstance->masseditable = $field['masseditable']; $fieldInstance->quickcreate = $field['quickcreate']; $fieldInstance->columntype = $field['columntype']; $fieldInstance->presence = $field['presence']; $fieldInstance->maximumlength = $field['maximumlength']; $fieldInstance->quicksequence = $field['quicksequence']; $fieldInstance->info_type = $field['info_type']; $fieldInstance->helpinfo = $field['helpinfo']; $fieldInstance->summaryfield = $field['summaryfield']; $fieldInstance->generatedtype = $field['generatedtype']; $fieldInstance->defaultvalue = $field['defaultvalue']; $blockInstance->addField($fieldInstance); if ($field['setpicklistvalues'] && ($field['uitype'] == 15 || $field['uitype'] == 16 || $field['uitype'] == 33)) { $fieldInstance->setPicklistValues($field['setpicklistvalues']); } if ($field['setrelatedmodules'] && $field['uitype'] == 10) { $fieldInstance->setRelatedModules($field['setrelatedmodules']); } } } $result = $adb->query("SHOW TABLES LIKE 'vtiger_ossmailtemplates_type';"); if ($adb->num_rows($result) == 1) { $adb->pquery("UPDATE `vtiger_ossmailtemplates_type` SET `presence` = ? WHERE `ossmailtemplates_type` = ?;", array(0, 'PLL_MODULE')); } }
/** * Update Blocks of the module * @access private */ function update_Blocks($modulenode, $moduleInstance) { if (empty($modulenode->blocks) || empty($modulenode->blocks->block)) { return; } foreach ($modulenode->blocks->block as $blocknode) { $this->listBlocks[] = strval($blocknode->label); $blockInstance = Vtiger_Block::getInstance((string) $blocknode->label, $moduleInstance); if (!$blockInstance) { $blockInstance = $this->import_Block($modulenode, $moduleInstance, $blocknode); } else { $this->update_Block($modulenode, $moduleInstance, $blocknode, $blockInstance); } $this->update_Fields($blocknode, $blockInstance, $moduleInstance); } // Deleting removed blocks $listBlockBeforeUpdate = Vtiger_Block::getAllForModule($moduleInstance); foreach ($listBlockBeforeUpdate as $blockInstance) { if (!in_array($blockInstance->label, $this->listBlocks)) { $blockInstance->delete(); } } }
function addFields() { global $log, $adb; $columnName = array("tabid", "id", "column", "table", "generatedtype", "uitype", "name", "label", "readonly", "presence", "defaultvalue", "maximumlength", "sequence", "block", "displaytype", "typeofdata", "quickcreate", "quicksequence", "info_type", "masseditable", "helpinfo", "summaryfield", "columntype", "blocklabel", "setpicklistvalues", "setrelatedmodules"); $HelpDesk = array(array('13', '1482', 'pssold_id', 'vtiger_troubletickets', '2', '10', 'pssold_id', 'P&S Sold', '1', '2', '', '100', '25', '25', '1', 'V~O', '1', '', 'BAS', '1', '0', '0', "int(19)", "LBL_TICKET_INFORMATION"), array('13', '1483', 'ordertime', 'vtiger_troubletickets', '2', '7', 'ordertime', 'Czas realizacji', '1', '2', '', '100', '26', '25', '1', 'NN~O', '1', '', 'BAS', '1', '0', '0', "decimal(10,2)", "LBL_TICKET_INFORMATION")); $Assets = array(array('37', '1484', 'ordertime', 'vtiger_assets', '2', '7', 'ordertime', 'Czas realizacji', '1', '2', '', '100', '7', '192', '1', 'NN~O', '1', '', 'BAS', '1', '0', '0', "decimal(10,2)", "BLOCK_INFORMATION_TIME", array())); $Contacts = array(array('4', '1503', 'contactstatus', 'vtiger_contactdetails', '2', '15', 'contactstatus', 'Status', '1', '2', '', '100', '29', '4', '1', 'V~O', '1', NULL, 'BAS', '1', '0', '0', "varchar(255)", "LBL_CONTACT_INFORMATION", array('Active', 'Inactive'))); $OSSSoldServices = array(array('58', '1483', 'ordertime', 'vtiger_osssoldservices', '2', '7', 'ordertime', 'Czas realizacji', '1', '2', '', '100', '26', '25', '1', 'NN~O', '1', '', 'BAS', '1', '0', '0', "decimal(10,2)", "LBL_CUSTOM_INFORMATION")); $setToCRM = array('HelpDesk' => $HelpDesk, 'Assets' => $Assets, 'OSSSoldServices' => $OSSSoldServices, 'Contacts' => $Contacts); $setToCRMAfter = array(); foreach ($setToCRM as $nameModule => $module) { if (!$module) { continue; } foreach ($module as $key => $fieldValues) { for ($i = 0; $i < count($fieldValues); $i++) { $setToCRMAfter[$nameModule][$key][$columnName[$i]] = $fieldValues[$i]; } } } foreach ($setToCRMAfter as $moduleName => $fields) { foreach ($fields as $field) { if ($this->checkFieldExists($field, $moduleName)) { continue; } try { $moduleInstance = Vtiger_Module::getInstance($moduleName); $blockInstance = Vtiger_Block::getInstance($field['blocklabel'], $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->column = $field['column']; $fieldInstance->name = $field['name']; $fieldInstance->label = $field['label']; $fieldInstance->table = $field['table']; $fieldInstance->uitype = $field['uitype']; $fieldInstance->typeofdata = $field['typeofdata']; $fieldInstance->readonly = $field['readonly']; $fieldInstance->displaytype = $field['displaytype']; $fieldInstance->masseditable = $field['masseditable']; $fieldInstance->quickcreate = $field['quickcreate']; $fieldInstance->columntype = $field['columntype']; $fieldInstance->presence = $field['presence']; $fieldInstance->maximumlength = $field['maximumlength']; $fieldInstance->info_type = $field['info_type']; $fieldInstance->helpinfo = $field['helpinfo']; $fieldInstance->summaryfield = $field['summaryfield']; $fieldInstance->generatedtype = $field['generatedtype']; $fieldInstance->defaultvalue = $field['defaultvalue']; $blockInstance->addField($fieldInstance); if ($field['setpicklistvalues'] && ($field['uitype'] == 15 || $field['uitype'] == 16 || $field['uitype'] == 33)) { $fieldInstance->setPicklistValues($field['setpicklistvalues']); } } catch (Exception $e) { //$e->getMessage() } } } }
$insertQuery = "INSERT INTO vtiger_fieldmodulerel (fieldid,module,relmodule,status,sequence) VALUES(?,?,?,?,?)"; $relModule = 'Calendar'; foreach ($moduleArray as $module) { $adb->pquery($insertQuery, array($fieldId, $module, $relModule, NULL, NULL)); } //For contacts the fieldname is contact_id $contactsRelatedToQuery = "SELECT fieldid FROM vtiger_field WHERE tabid=? AND fieldname=?"; $contactsResult = $adb->pquery($contactsRelatedToQuery, array($tabId, 'contact_id')); $contactsFieldId = $adb->query_result($contactsResult, 0, 'fieldid'); $insertContactsQuery = "INSERT INTO vtiger_fieldmodulerel (fieldid,module,relmodule,status,sequence) VALUES(?,?,?,?,?)"; $module = 'Contacts'; $adb->pquery($insertContactsQuery, array($contactsFieldId, $module, $relModule, NULL, NULL)); ##--http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7635--## //Adding is_owner to existing vtiger users $usersModuleInstance = Vtiger_Module::getInstance('Users'); $usersBlockInstance = Vtiger_Block::getInstance('LBL_USERLOGIN_ROLE', $usersModuleInstance); $usersFieldInstance = Vtiger_Field::getInstance('is_owner', $usersModuleInstance); if (!$usersFieldInstance) { $field = new Vtiger_Field(); $field->name = 'is_owner'; $field->label = 'Account Owner'; $field->column = 'is_owner'; $field->table = 'vtiger_users'; $field->uitype = 1; $field->typeofdata = 'V~O'; $field->readonly = '0'; $field->displaytype = '5'; $field->masseditable = '0'; $field->quickcreate = '0'; $field->columntype = 'VARCHAR(5)'; $field->defaultvalue = 0;
$field->name = 'rowheight'; $field->label = 'Row Height'; $field->table = 'vtiger_users'; $field->uitype = 16; $field->typeofdata = 'V~O'; $field->readonly = 1; $field->displaytype = 1; $field->masseditable = 1; $field->quickcreate = 1; $field->columntype = 'VARCHAR(10)'; $field->defaultvalue = 'medium'; $blockInstance->addField($field); $field->setPicklistValues(array('wide', 'medium', 'narrow')); } $moduleInstance = Vtiger_Module::getInstance('HelpDesk'); $block = Vtiger_Block::getInstance('LBL_TICKET_INFORMATION', $moduleInstance); $fromPortal = Vtiger_Field_Model::getInstance('from_portal', $moduleInstance); if (!$fromPortal) { $field = new Vtiger_Field(); $field->name = 'from_portal'; $field->label = 'From Portal'; $field->table = 'vtiger_ticketcf'; $field->column = 'from_portal'; $field->columntype = 'varchar(3)'; $field->typeofdata = 'C~O'; $field->uitype = 56; $field->displaytype = 3; $field->presence = 0; $block->addField($field); } //Start: Customer - Feature #10254 Configuring all Email notifications including Ticket notifications
/** Function used to add the tax type which will do database alterations * @param string $taxlabel - tax label name to be added * @param string $taxvalue - tax value to be added * @param string $sh - sh or empty , if sh passed then the tax will be added in shipping and handling related table * @return void */ public function addTax() { $adb = PearDatabase::getInstance(); $tableName = $this->getTableNameFromType(); $taxid = $adb->getUniqueID($tableName); $taxLabel = $this->getName(); $percentage = $this->get('percentage'); //if the tax is not available then add this tax. //Add this tax as a column in related table if ($this->isShippingTax()) { $taxname = "shtax" . $taxid; $query = "ALTER TABLE vtiger_inventoryshippingrel ADD COLUMN {$taxname} decimal(7,3) DEFAULT NULL"; } else { $taxname = "tax" . $taxid; $query = "ALTER TABLE vtiger_inventoryproductrel ADD COLUMN {$taxname} decimal(7,3) DEFAULT NULL"; } $res = $adb->pquery($query, array()); vimport('~~/include/utils/utils.php'); if ($this->isProductTax()) { // TODO Review: if field addition is required in shipping-tax case too. // NOTE: shtax1, shtax2, shtax3 that is added as default should also be taken care. $inventoryModules = getInventoryModules(); foreach ($inventoryModules as $moduleName) { // SalesPlatform.ru begin Fix save tax for Products/Services if ($moduleName == 'Act' || $moduleName == 'Consignment') { continue; } // SalesPlatform.ru end $moduleInstance = Vtiger_Module::getInstance($moduleName); $blockInstance = Vtiger_Block::getInstance('LBL_ITEM_DETAILS', $moduleInstance); $field = new Vtiger_Field(); $field->name = $taxname; $field->label = $taxLabel; $field->column = $taxname; $field->table = 'vtiger_inventoryproductrel'; $field->uitype = '83'; $field->typeofdata = 'V~O'; $field->readonly = '0'; $field->displaytype = '5'; $field->masseditable = '0'; $blockInstance->addField($field); } } //if the tax is added as a column then we should add this tax in the list of taxes if ($res) { $query = 'INSERT INTO ' . $tableName . ' values(?,?,?,?,?)'; $params = array($taxid, $taxname, $taxLabel, $percentage, 0); $adb->pquery($query, $params); return $taxid; } throw new Error('Error occurred while adding tax'); }
Migration_Index_View::ExecuteQuery("alter table `vtiger_organizationdetails` add `entrepreneurreg` varchar(100) default ''", array()); Migration_Index_View::ExecuteQuery("alter table `vtiger_organizationdetails` add `okpo` varchar(100) default ''", array()); // 5.2.1-20110824 Migration_Index_View::ExecuteQuery("alter table `vtiger_systems` add `server_tls` varchar(20) default NULL", array()); Migration_Index_View::ExecuteQuery("alter table `vtiger_systems` add `from_name` varchar(200) DEFAULT ''", array()); Migration_Index_View::ExecuteQuery("alter table `vtiger_systems` add `use_sendmail` varchar(5) DEFAULT 'false'", array()); // 5.3.0-201207 // Add units code to Products $productsModuleInstance = Vtiger_Module::getInstance('Products'); $blockInstance = Vtiger_Block::getInstance('LBL_STOCK_INFORMATION', $productsModuleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'unit_code'; $fieldInstance->label = 'Unit Code'; $fieldInstance->table = 'vtiger_products'; $fieldInstance->column = 'unit_code'; $fieldInstance->columntype = 'VARCHAR(100)'; $fieldInstance->uitype = 1; $blockInstance->addField($fieldInstance); // Add units code to Services $servicesModuleInstance = Vtiger_Module::getInstance('Services'); $blockInstance = Vtiger_Block::getInstance('LBL_SERVICE_INFORMATION', $servicesModuleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'unit_code'; $fieldInstance->label = 'Unit Code'; $fieldInstance->table = 'vtiger_service'; $fieldInstance->column = 'unit_code'; $fieldInstance->columntype = 'VARCHAR(100)'; $fieldInstance->uitype = 1; $blockInstance->addField($fieldInstance); // Create sp_custom_reports table Migration_Index_View::ExecuteQuery("CREATE TABLE IF NOT EXISTS sp_custom_reports (\n reporttype varchar(50) NOT NULL,\n datefilter int(1) default 0,\n ownerfilter int(1) default 0,\n accountfilter int(1) default 0,\n functionname varchar(255) NOT NULL,\n PRIMARY KEY (reporttype)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci", array());
static function updateDateFields() { require_once 'vtlib/Vtiger/Module.php'; $module = Vtiger_Module::getInstance('Accounting'); $generalBlock = Vtiger_Block::getInstance('LBL_GENERAL_INFO', $module); global $adb; $adb->pquery("DELETE FROM vtiger_field WHERE tabid=? AND (columnname=? OR columnname=? OR columnname=? OR columnname=? OR columnname=? OR columnname=? OR columnname=? OR columnname=? OR columnname=?)", array($module->id, 'accountingduedate', 'accountingpaymentdate', 'accountingpaymentmethod', 'accountingamountpartial', 'paymentrefpartial', 'paymentpaidpartial', 'paymentvatpartial', 'paymentassocpartial', 'accountingmethod')); $col_drop = array('accountingduedate', 'accountingpaymentdate', 'accountingpaymentmethod', 'accountingamountpartial', 'paymentrefpartial', 'paymentpaidpartial', 'paymentvatpartial', 'paymentassocpartial', 'accountingmethod'); foreach ($col_drop as $col) { $adb->pquery("ALTER TABLE vtiger_accounting DROP COLUMN {$col}", array()); } $adb->pquery("ALTER TABLE vtiger_accounting ADD COLUMN accountingduedate DATE, ADD COLUMN accountingpaymentdate DATE, " . "ADD COLUMN accountingpaymentmethod VARCHAR(255), ADD COLUMN accountingamountpartial DOUBLE, " . "ADD COLUMN paymentrefpartial VARCHAR(255), ADD COLUMN paymentpaidpartial VARCHAR(255), ADD COLUMN paymentvatpartial DOUBLE, " . "ADD COLUMN paymentassocpartial VARCHAR(255)", array()); $adb->pquery("ALTER TABLE vtiger_accounting MODIFY COLUMN accountingamount DOUBLE, MODIFY COLUMN accountingpaidamount DOUBLE, " . "MODIFY COLUMN accountingpaidoustanding DOUBLE", array()); $adb->pquery("ALTER TABLE vtiger_accounting_payments MODIFY COLUMN tax DOUBLE", array()); $adb->pquery("update vtiger_field set typeofdata=? where columnname=? and tablename=?", array('V~M', 'paymentref', 'vtiger_accounting')); $adb->pquery("UPDATE vtiger_accounting SET paymentref=? WHERE paymentref=?", array('---', '')); $duedate = new Vtiger_Field(); $duedate->name = 'accountingduedate'; $duedate->label = "DueDate"; $duedate->column = 'accountingduedate'; $duedate->uitype = 5; $duedate->typeofdata = 'D~O'; $duedate->displaytype = 3; $generalBlock->addField($duedate); $paymentdate = new Vtiger_Field(); $paymentdate->name = 'accountingpaymentdate'; $paymentdate->label = "PaymentDate"; $paymentdate->column = 'accountingpaymentdate'; $paymentdate->uitype = 5; $paymentdate->typeofdata = 'D~O'; $paymentdate->displaytype = 3; $generalBlock->addField($paymentdate); $paymentmethod = new Vtiger_Field(); $paymentmethod->name = 'accountingpaymentmethod'; $paymentmethod->label = "Method"; $paymentmethod->column = 'accountingpaymentmethod'; $paymentmethod->uitype = 2; $paymentmethod->typeofdata = 'V~O'; $paymentmethod->displaytype = 3; $generalBlock->addField($paymentmethod); $paymentamount = new Vtiger_Field(); $paymentamount->name = 'accountingamountpartial'; $paymentamount->label = "PartialAmount"; $paymentamount->column = 'accountingamountpartial'; $paymentamount->uitype = 7; $paymentamount->typeofdata = 'N~O'; $paymentamount->displaytype = 3; $generalBlock->addField($paymentamount); $paymentref = new Vtiger_Field(); $paymentref->name = 'paymentrefpartial'; $paymentref->label = "PaymentReferencePartial"; $paymentref->column = 'paymentrefpartial'; $paymentref->uitype = 2; $paymentref->typeofdata = 'V~O'; $paymentref->displaytype = 3; $generalBlock->addField($paymentref); $paymentpaid = new Vtiger_Field(); $paymentpaid->name = 'paymentpaidpartial'; $paymentpaid->label = "PaymentPaidPartial"; $paymentpaid->column = 'paymentpaidpartial'; $paymentpaid->uitype = 56; $paymentpaid->typeofdata = 'C~O'; $paymentpaid->displaytype = 3; $generalBlock->addField($paymentpaid); $paymentvat = new Vtiger_Field(); $paymentvat->name = 'paymentvatpartial'; $paymentvat->label = "PartialVat"; $paymentvat->column = 'paymentvatpartial'; $paymentvat->uitype = 7; $paymentvat->typeofdata = 'N~O'; $paymentvat->displaytype = 3; $generalBlock->addField($paymentvat); $paymentassoc = new Vtiger_Field(); $paymentassoc->name = 'paymentassocpartial'; $paymentassoc->label = "PartialAssoc"; $paymentassoc->column = 'paymentassocpartial'; $paymentassoc->uitype = 2; $paymentassoc->typeofdata = 'V~O'; $paymentassoc->displaytype = 3; $generalBlock->addField($paymentassoc); $fldlabel_arr = array("LBL-PAYMENT-REFERENCE" => "PaymentReference", "LBL-PAYMENT-ID" => "PaymentId", "LBL-ASSIGNED-TO" => "Assigned To", "LBL-TRANSACTION-TYPE" => "TransactionType", "LBL-TRANSACTION-DATE" => "PaymentDate", "LBL-TRANSACTION-DUE-DATE" => "DueDate", "LBL-RELATED-TO-1" => "RelatedTo", "LBL-RELATED-TO-2" => "RelatedToInvoiceOrder", "LBL-TRANSACTION-STATE" => "TransactionStatus", "LBL-TRANSACTION-METHOD-PARTIAL" => "Method", "LBL-CATEGORY" => "Category", "LBL-AMOUNT" => "TotalAmount", "LBL-AMOUNT-PARTIAL" => "PartialAmount", "LBL-VAT" => "PartialVat", "LBL-CURRENCY" => "Currency", "LBL-PAID-AMOUNT" => "TotalPaid", "LBL-OUSTANDING-BALANCE" => "OustandingBalance", "LBL-DESCRIPTION" => "Description"); foreach ($fldlabel_arr as $old => $new) { $adb->pquery("UPDATE vtiger_field SET fieldlabel=?" . "WHERE fieldlabel=? and tabid=?", array($new, $old, getTabid("Accounting"))); $adb->pquery("UPDATE vtiger_cvadvfilter SET columnname=REPLACE(columnname, ?, ?)", array($old, $new)); $adb->pquery("UPDATE vtiger_cvcolumnlist SET columnname=REPLACE(columnname, ?, ?)", array($old, $new)); $adb->pquery("UPDATE vtiger_cvstdfilter SET columnname=REPLACE(columnname, ?, ?)", array($old, $new)); } /* $adb->pquery( "UPDATE vtiger_accounting SET accountingduedate = ". "(SELECT MIN(vtiger_accounting_payments.paymentduedate) FROM vtiger_accounting_payments ". "WHERE vtiger_accounting_payments.idtransaction = vtiger_accounting.accountingid AND ". "vtiger_accounting_payments.paymentduedate <> '0000-00-00')", array()); $adb->pquery( "UPDATE vtiger_accounting SET accountingpaymentdate = ". "(SELECT MIN(vtiger_accounting_payments.paymentdate) FROM vtiger_accounting_payments ". "WHERE vtiger_accounting_payments.idtransaction = vtiger_accounting.accountingid AND ". "vtiger_accounting_payments.paymentdate <> '0000-00-00')", array()); */ }
/** * Add new field to $module * @param type $module * @param type $params */ function addNewField($module, $params) { $moduleInstance = Vtiger_Module::getInstance($module); $blockInstance = Vtiger_Block::getInstance($params['block'], $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->label = $params['label']; $fieldInstance->name = $params['name']; $fieldInstance->table = $params['table']; $fieldInstance->column = $params['column']; $fieldInstance->columntype = 'varchar'; $fieldInstance->uitype = 17; $fieldInstance->typeofdata = 'V~O'; $blockInstance->addField($fieldInstance); $fieldInstance->setRelatedModules(array('SPSocialConnector')); }
function applyChange() { if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; //Currency Decimal places handling $this->ExecuteQuery("ALTER TABLE vtiger_account MODIFY COLUMN annualrevenue decimal(25," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_leaddetails MODIFY COLUMN annualrevenue decimal(25," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_currency_info MODIFY COLUMN conversion_rate decimal(12," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_productcurrencyrel MODIFY COLUMN actual_price decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_productcurrencyrel MODIFY COLUMN converted_price decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_pricebookproductrel MODIFY COLUMN listprice decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventoryproductrel MODIFY COLUMN listprice decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventoryproductrel MODIFY COLUMN discount_amount decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); // Inventory Details $this->ExecuteQuery("ALTER TABLE vtiger_inventorydetails MODIFY COLUMN listprice decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventorydetails MODIFY COLUMN extgross decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventorydetails MODIFY COLUMN discount_amount decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventorydetails MODIFY COLUMN extnet decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventorydetails MODIFY COLUMN linetax decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("ALTER TABLE vtiger_inventorydetails MODIFY COLUMN linetotal decimal(28," . CurrencyField::$maxNumberOfDecimals . ")", array()); $this->ExecuteQuery("UPDATE vtiger_field SET uitype=71 where tablename='vtiger_inventorydetails' and \n\t\t\t\tcolumnname in ('listprice','extgross','discount_amount','extnet','linetax','linetotal')", array()); // all the others $result = $adb->pquery("SELECT fieldname,tablename,columnname FROM vtiger_field WHERE uitype IN (?,?)", array('71', '72')); $count = $adb->num_rows($result); for ($i = 0; $i < $count; $i++) { $fieldName = $adb->query_result($result, $i, 'fieldname'); $tableName = $adb->query_result($result, $i, 'tablename'); $columnName = $adb->query_result($result, $i, 'columnname'); $tableAndColumnSize = array(); $tableInfo = $adb->database->MetaColumns($tableName); foreach ($tableInfo as $column) { $max_length = $column->max_length; $scale = $column->scale; $tableAndColumnSize[$tableName][$column->name]['max_length'] = $max_length; $tableAndColumnSize[$tableName][$column->name]['scale'] = $scale; } if (!empty($tableAndColumnSize[$tableName][$columnName]['scale'])) { $decimalsToChange = CurrencyField::$maxNumberOfDecimals - $tableAndColumnSize[$tableName][$columnName]['scale']; if ($decimalsToChange != 0) { $maxlength = $tableAndColumnSize[$tableName][$columnName]['max_length'] + $decimalsToChange; $decimalDigits = $tableAndColumnSize[$tableName][$columnName]['scale'] + $decimalsToChange; $this->ExecuteQuery("ALTER TABLE " . $tableName . " MODIFY COLUMN " . $columnName . " decimal(?,?)", array($maxlength, $decimalDigits)); } } } // User configuration field $moduleInstance = Vtiger_Module::getInstance('Users'); $currencyBlock = Vtiger_Block::getInstance('LBL_CURRENCY_CONFIGURATION', $moduleInstance); $currency_decimals_field = new Vtiger_Field(); $currency_decimals_field->name = 'no_of_currency_decimals'; $currency_decimals_field->label = 'Number Of Currency Decimals'; $currency_decimals_field->table = 'vtiger_users'; $currency_decimals_field->column = 'no_of_currency_decimals'; $currency_decimals_field->columntype = 'VARCHAR(2)'; $currency_decimals_field->typeofdata = 'V~O'; $currency_decimals_field->uitype = 16; $currency_decimals_field->defaultvalue = '2'; $currency_decimals_field->sequence = 6; $currency_decimals_field->helpinfo = "<b>Currency - Number of Decimal places</b> <br/><br/>" . "Number of decimal places specifies how many number of decimals will be shown after decimal separator.<br/>" . "<b>Eg:</b> 123.99"; $currencyBlock->addField($currency_decimals_field); $currency_decimals_field->setPicklistValues(array('2', '3', '4', '5', '6')); $this->ExecuteQuery("UPDATE vtiger_users SET no_of_currency_decimals='2'", array()); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(false); } $this->finishExecution(); }
ExecuteQuery($sql); $calendarTabId = getTabid('Calendar'); $eventsTabId = getTabid('Events'); ExecuteQuery("UPDATE vtiger_field SET quickcreate=0 WHERE fieldname='time_start' AND (tabid={$calendarTabId} OR tabid={$eventsTabId})"); vt530_changeDataType('vtiger_crmentity', 'createdtime', 'createdtime', 'DT', 'DT~O'); vt530_changeDataType('vtiger_crmentity', 'modifiedtime', 'modifiedtime', 'DT', 'DT~O'); $moduleInstance = Vtiger_Module::getInstance('Users'); // Update/Increment the sequence for the succeeding blocks of Users module, with starting sequence 2 $usersTabId = getTabid('Users'); $blocksListResult = ExecuteQuery("UPDATE vtiger_blocks SET sequence = sequence+1 WHERE tabid={$usersTabId} AND sequence >= 2"); // Create Currency Configuration block placing at position 2 $currencyBlock = new Vtiger_Block(); $currencyBlock->label = 'LBL_CURRENCY_CONFIGURATION'; $currencyBlock->sequence = 2; $moduleInstance->addBlock($currencyBlock); $currencyBlock = Vtiger_Block::getInstance('LBL_CURRENCY_CONFIGURATION', $moduleInstance); $currencyPattern = new Vtiger_Field(); $currencyPattern->name = 'currency_grouping_pattern'; $currencyPattern->label = 'Digit Grouping Pattern'; $currencyPattern->table = 'vtiger_users'; $currencyPattern->column = 'currency_grouping_pattern'; $currencyPattern->columntype = 'varchar(100)'; $currencyPattern->typeofdata = 'V~O'; $currencyPattern->uitype = 16; $currencyPattern->defaultvalue = '123,456,789'; $currencyPattern->sequence = 2; $currencyPattern->helpinfo = "<b>Currency - Digit Grouping Pattern</b> <br/><br/>" . "This pattern specifies the format in which the currency separator will be placed."; $currencyBlock->addField($currencyPattern); $currencyPattern->setPicklistValues(array('123,456,789', '123456789', '123456,789', '12,34,56,789')); $currencyDecimalSeparator = new Vtiger_Field(); $currencyDecimalSeparator->name = 'currency_decimal_separator';
/** * Dodaje od modułu pole uitype 10 * * @param string $moduleName nazwa modułu * @param string $blockLabel etykieta bloku * @param array $relModuleList tablica zawierająca listę modułów powiązanych * @param string $fieldName nazwa pola * @param bool $mandatory czy pole ma być obowiązkowe * @param string $fieldLabel etykieta pola, jeśli nie jest podany etykieta jest taka jak nazwa pola */ public static function addUitype10Field($moduleName, $blockLabel, $relModuleList, $fieldName, $mandatory = false, $fieldLabel = NULL) { if (self::checkArg(func_get_args(), 4)) { vglobal('Vtiger_Utils_Log', TRUE); $tabid = Vtiger_Functions::getModuleId($moduleName); $blockId = getBlockId($tabid, $blockLabel); $moduleInstance = Vtiger_Module::getInstance($moduleName); $blockInstance = Vtiger_Block::getInstance($blockId, $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = strtolower($fieldName); if ($moduleInstance->table_name) { $fieldInstance->table = $moduleInstance->table_name; } else { $fieldInstance->table = 'vtiger_' . strtolower($moduleName); } if ($fieldLabel) { $fieldInstance->label = $fieldLabel; } else { $fieldInstance->label = $fieldName; } $fieldInstance->column = $fieldName; $fieldInstance->columntype = 'int(19)'; $fieldInstance->uitype = 10; if ($mandatory) { $fieldInstance->typeofdata = 'V~M'; } else { $fieldInstance->typeofdata = 'V~O'; } $blockInstance->addField($fieldInstance); $fieldInstance->setRelatedModules($relModuleList); } }
/** * Update Blocks of the module * @access private */ function update_Blocks($modulenode, $moduleInstance) { if (empty($modulenode->blocks) || empty($modulenode->blocks->block)) { return; } foreach ($modulenode->blocks->block as $blocknode) { $blockInstance = Vtiger_Block::getInstance((string) $blocknode->label, $moduleInstance); if (!$blockInstance) { $blockInstance = $this->import_Block($modulenode, $moduleInstance, $blocknode); } else { $this->update_Block($modulenode, $moduleInstance, $blocknode, $blockInstance); } $this->update_Fields($blocknode, $blockInstance, $moduleInstance); } }
/** * 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) { $adb = PearDatabase::getInstance(); if ($event_type == 'module.postinstall') { $ModuleInstance = CRMEntity::getInstance($modulename); $ModuleInstance->setModuleSeqNumber("configure", $modulename, '', '1'); $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments'); if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) { include_once 'modules/ModComments/ModComments.php'; if (class_exists('ModComments')) { ModComments::addWidgetTo(array('Payments')); } } $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($modulename)); $tabid = Vtiger_Functions::getModuleId($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')); } vimport('~~vtlib/Vtiger/Module.php'); $moduleInstance = Vtiger_Module::getInstance('Invoice'); $blockInstance = Vtiger_Block::getInstance('LBL_INVOICE_INFORMATION', $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'payment_balance'; $fieldInstance->table = 'vtiger_invoice'; $fieldInstance->label = 'Payment balance'; $fieldInstance->column = 'payment_balance'; $fieldInstance->columntype = 'decimal(25,8)'; $fieldInstance->uitype = 7; $fieldInstance->typeofdata = 'NN~O'; $fieldInstance->displaytype = 2; $blockInstance->addField($fieldInstance); $moduleInstance = Vtiger_Module::getInstance('Accounts'); $blockInstance = Vtiger_Block::getInstance('LBL_ACCOUNT_INFORMATION', $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'payment_balance'; $fieldInstance->table = 'vtiger_account'; $fieldInstance->label = 'Payment balance'; $fieldInstance->column = 'payment_balance'; $fieldInstance->columntype = 'decimal(25,8)'; $fieldInstance->uitype = 7; $fieldInstance->typeofdata = 'NN~O'; $fieldInstance->displaytype = 2; $blockInstance->addField($fieldInstance); $moduleInstance = Vtiger_Module::getInstance('Potentials'); $blockInstance = Vtiger_Block::getInstance('LBL_OPPORTUNITY_INFORMATION', $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'payment_balance'; $fieldInstance->table = 'vtiger_potential'; $fieldInstance->label = 'Payment balance'; $fieldInstance->column = 'payment_balance'; $fieldInstance->columntype = 'decimal(25,8)'; $fieldInstance->uitype = 7; $fieldInstance->typeofdata = 'NN~O'; $fieldInstance->displaytype = 2; $blockInstance->addField($fieldInstance); $this->addWorkflow($modulename); $this->addWorkflow('Invoice'); } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // 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. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { } } } } } } }
public function process(Vtiger_Request $request) { $recordId = $request->get('record'); $blockId = $request->get('blockid'); $views = $request->get('views'); $qualifiedModuleName = $request->getModule(false); $mode = ''; $viewer = $this->getViewer($request); if ($views != '') { $views = implode($views, ','); } if ($recordId) { $mode = 'edit'; } else { } $moduleModel = Settings_HideBlocks_Record_Model::getModuleInstanceByBlockId($blockId); $recordStrucure = Vtiger_RecordStructure_Model::getInstanceForModule($moduleModel); $structuredValues = $recordStrucure->getStructure(); $viewer->assign('RECORD_STRUCTURE', $structuredValues); $blockInstance = Vtiger_Block::getInstance($blockId, $moduleModel); $blockLabel = $blockInstance->label; $blockModelList = $moduleModel->getBlocks(); $blockModel = $blockModelList[$blockLabel]; $fieldModelList = $blockModel->getFields(); $mandatoryFields = array(); if (!empty($fieldModelList)) { $values[$blockLabel] = array(); foreach ($fieldModelList as $fieldName => $fieldModel) { if ($fieldModel->isMandatory()) { $mandatoryFields[$fieldName] = $fieldModel; } } } $viewer->assign('MANDATORY_FIELDS', $mandatoryFields); //var_dump($structuredValues); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $qualifiedModuleName); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('ADVANCED_FILTER_OPTIONS', Settings_Workflows_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', Settings_Workflows_Field_Model::getAdvancedFilterOpsByFieldType()); $viewer->assign('COLUMNNAME_API', 'getName'); $recordModel = Settings_HideBlocks_Record_Model::getInstanceById($recordId, $qualifiedModuleName); if ($recordModel) { $viewer->assign('ADVANCE_CRITERIA', $this->transformToAdvancedFilterCondition($recordModel->get('conditions'))); } $viewer->assign('MODE', $mode); $viewer->assign('RECORD_ID', $recordId); $viewer->assign('MODULE', 'HideBlocks'); $viewer->assign('SOURCE_MODULE', $moduleModel->get('name')); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->assign('BLOCKID', $blockId); $viewer->assign('ENABLED', $request->get('enabled')); $viewer->assign('VIEWS', $views); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->view('Conditions.tpl', $qualifiedModuleName); }
public static function getInstance($value, $moduleInstance = false) { $blockInstance = parent::getInstance($value, $moduleInstance); $blockModel = self::getInstanceFromBlockObject($blockInstance); return $blockModel; }
<?php $Vtiger_Utils_Log = true; ini_set('display_errors', true); ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_DEPRECATED); require_once 'vtlib/Vtiger/Module.php'; include_once 'vtlib/Vtiger/Utils.php'; include_once 'vtlib/Vtiger/Menu.php'; require_once 'vtlib/Vtiger/Block.php'; require_once 'vtlib/Vtiger/Field.php'; $Vtiger_Utils_Log = true; // Define instances $users = Vtiger_Module::getInstance('Contacts'); // Nouvelle instance pour le nouveau bloc $block = Vtiger_Block::getInstance('LBL_CONTACT_INFORMATION', $users); // Add field $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'firma'; //Usually matches column name $fieldInstance->table = 'vtiger_contactdetails'; $fieldInstance->column = 'firmas_satelite'; //Must be lower case $fieldInstance->label = 'Firmas Satelite'; //Upper case preceeded by LBL_ $fieldInstance->columntype = 'VARCHAR(100)'; // $fieldInstance->uitype = 33; //textCampo mandatory $fieldInstance->displaytype = 2; //readonly $fieldInstance->typeofdata = 'V~O';