Vous êtes sur la page 1sur 5

Changeset 13851 for vtigercrm/branches/6.0.

0/modules vtiger development

Page 1 of 5

Changeset 13851 for vtigercrm/branches/6.0.0/modules


Timestamp: Feb 20, 2013 11:10:18 AM (8 weeks ago)
Author: prasad
Message: Pushing changes as on 2013.02.18 (+migration)
Location: vtigercrm/branches/6.0.0/modules
2 added
1 edited
Files:
Migration/DBChanges/540_to_600.php (3 diffs)
Users/UserSetup.php
Users/UserSetupSave.php

Unmodified

Added

Removed

vtigercrm/branches/6.0.0/modules/Migration/DBChanges/540_to_600.php

Tabular

Unified

r13846 r13851
11
11 //-12
12 $adb = PearDatabase::getInstance();
13 $Vtiger_Utils_log = true;
13
14
14
15 if (!defined('INSTALLATION_MODE')) {

695
696 updateVtlibModule('FieldFormulas', "packages/vtiger/optional/FieldFormulas.zip");
696
697 updateVtlibModule('Import', 'packages/vtiger/mandatory/Import.zip');
698 updateVtlibModule('WSAPP', 'packages/vtiger/mandatory/WSAPP.zip');
697
699
698
700 updateVtlibModule('Services', "packages/vtiger/mandatory/Services.zip");

979
981
980
982 // END 2012.12.02
983
984 // //////////////////////////////////////////////
985 $inventoryModules = array(
'Invoice' => array('LBL_INVOICE_INFORMATION', 'vtiger_invoice', 'invoiceid'),
986
'SalesOrder' => array('LBL_SO_INFORMATION', 'vtiger_salesorder', 'salesorderid'),
987
'PurchaseOrder' => array('LBL_PO_INFORMATION', 'vtiger_purchaseorder',
988
'purchaseorderid'),
'Quotes' => array('LBL_QUOTE_INFORMATION', 'vtiger_quotes', 'quoteid')
989
990 );
991
992 foreach ($inventoryModules as $module => $details) {
$tableName = $details[1];
993
$moduleInstance = Vtiger_Module::getInstance($module);
994
$block = Vtiger_Block::getInstance($details[0], $moduleInstance);
995
996
$preTaxTotalField = new Vtiger_Field();
997
$preTaxTotalField->name = 'pre_tax_total';
998
$preTaxTotalField->label = 'Pre Tax Total';
999
$preTaxTotalField->table = $tableName;
1000
$preTaxTotalField->column = 'pre_tax_total';
1001
$preTaxTotalField->columntype = 'decimal(25,8)';
1002
$preTaxTotalField->typeofdata = 'N~O';
1003
$preTaxTotalField->uitype = '72';
1004
$preTaxTotalField->masseditable = '1';
1005
$preTaxTotalField->displaytype = '3';
1006
$block->addField($preTaxTotalField);
1007
1008
$tableId = $details[2];
1009
1010
1011

http://trac.vtiger.com/cgi-bin/trac.cgi/changeset/13851/vtigercrm/branches/6.0.0/modules

4/17/2013

Changeset 13851 for vtigercrm/branches/6.0.0/modules vtiger development

Page 2 of 5

r13846 r13851
$result = $db->pquery("SELECT $tableId, subtotal, s_h_amount, discount_percent,
discount_amount FROM $tableName", array());
$numOfRows = $db->num_rows($result);
1012
1013
for ($i = 0; $i < $numOfRows; $i++) {
1014
$id = $db->query_result($result, $i, $tableId);
1015
$subTotal = (float) $db->query_result($result, $i, "subtotal");
1016
$shAmount = (float) $db->query_result($result, $i, "s_h_amount");
1017
$discountAmount = (float) $db->query_result($result, $i, "discount_amount");
1018
$discountPercent = (float) $db->query_result($result, $i, "discount_percent");
1019
1020
if ($discountPercent != '0') {
1021
$discountAmount = ($subTotal * $discountPercent) / 100;
1022
}
1023
$preTaxTotalValue = $subTotal + $shAmount - $discountAmount;
1024
1025
$db->pquery("UPDATE $tableName set pre_tax_total = ? WHERE $tableId = ?", array
1026
($preTaxTotalValue, $id));
}
1027
1028 }
1029
1030 $moduleInstance = Vtiger_Module::getInstance('Users');
1031
1032 $calendarSettings = Vtiger_Block::getInstance('LBL_CALENDAR_SETTINGS', $moduleInstance);
1033 $calendarsharedtype = new Vtiger_Field();
1034 $calendarsharedtype->name = 'calendarsharedtype';
1035 $calendarsharedtype->label = 'Calendar Shared Type';
1036 $calendarsharedtype->table ='vtiger_users';
1037 $calendarsharedtype->column = 'calendarsharedtype';
1038 $calendarsharedtype->columntype = 'varchar(100)';
1039 $calendarsharedtype->typeofdata = 'V~O';
1040 $calendarsharedtype->uitype = 16;
1041 $calendarsharedtype->sequence = 2;
1042 $calendarsharedtype->displaytype = 3;
1043 $calendarsharedtype->defaultvalue = 'Public';
1044 $calendarSettings->addField($calendarsharedtype);
1045 $calendarsharedtype->setPicklistValues(array('public','private','seletedusers'));
1046 echo "<br> Calendar Shared type field added <br>";
1047
1048 $allUsers = get_user_array(false);
1049 foreach ($allUsers as $id => $name) {
$query = 'select sharedid from vtiger_sharedcalendar where userid=?';
1050
$result = $db->pquery($query, array($id));
1051
$count = $db->num_rows($result);
1052
if($count > 0){
1053
$db->pquery('UPDATE vtiger_users SET calendarsharedtype = ? WHERE id = ?',
1054
array('selectedusers', $id));
}else{
1055
$db->pquery('UPDATE vtiger_users SET calendarsharedtype = ? WHERE id = ?
1056
', array('public', $id));
foreach ($allUsers as $sharedid => $name) {
1057
if($sharedid != $id){
1058
$sql = "INSERT INTO vtiger_sharedcalendar VALUES (?,?)";
1059
$db->pquery($sql, array($id, $sharedid));
1060
}
1061
}
1062
}
1063
1064 }
1065
1066 // Add Key Metrics widget.
1067 $homeModule = Vtiger_Module::getInstance('Home');
1068 $homeModule->addLink('DASHBOARDWIDGET', 'Key Metrics', 'index.php?
module=Home&view=ShowWidget&name=KeyMetrics');
1069
1070 $moduleArray = array('Accounts' => 'LBL_ACCOUNT_INFORMATION', 'Contacts' =>
'LBL_CONTACT_INFORMATION', 'Potentials' => 'LBL_OPPORTUNITY_INFORMATION');
1071 foreach ($moduleArray as $module => $block) {

http://trac.vtiger.com/cgi-bin/trac.cgi/changeset/13851/vtigercrm/branches/6.0.0/modules

4/17/2013

Changeset 13851 for vtigercrm/branches/6.0.0/modules vtiger development

Page 3 of 5

r13846 r13851
$moduleInstance = Vtiger_Module::getInstance($module);
1072
$blockInstance = Vtiger_Block::getInstance($block, $moduleInstance);
1073
1074
$field = new Vtiger_Field();
1075
$field->name = 'isconvertedfromlead';
1076
$field->label = 'Is Converted From Lead';
1077
$field->uitype = 56;
1078
$field->column = 'isconvertedfromlead';
1079
$field->displaytype = 2;
1080
$field->defaultvalue = 'no';
1081
$field->columntype = 'varchar(3)';
1082
$field->typeofdata = 'C~O';
1083
$blockInstance->addField($field);
1084
echo "Converted From field added to $module <br/>";
1085
1086 }
1087
1088 $homeModule = Vtiger_Module::getInstance('Home');
1089 $homeModule->addLink('DASHBOARDWIDGET', 'Mini List', 'index.php?
module=Home&view=ShowWidget&name=MiniList');
1090
1091 $moduleInstance = Vtiger_Module::getInstance('Users');
1092 $moreInfoBlock = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $moduleInstance);
1093
1094 $viewField = new Vtiger_Field();
1095 $viewField->name = 'default_record_view';
1096 $viewField->label = 'Default Record View';
1097 $viewField->table ='vtiger_users';
1098 $viewField->column = 'default_record_view';
1099 $viewField->columntype = 'VARCHAR(10)';
1100 $viewField->typeofdata = 'V~O';
1101 $viewField->uitype = 16;
1102 $viewField->defaultvalue = 'Summary';
1103
1104 $moreInfoBlock->addField($viewField);
1105 $viewField->setPicklistValues(array('Summary', 'Detail'));
1106
1107 $db->pquery('UPDATE vtiger_users SET default_record_view = ?', array('Summary'));
1108 echo "Default Record View option is added User preferences";
1109
1110
1111 $InvoiceInstance = Vtiger_Module::getInstance('Invoice');
1112 Vtiger_Event::register($InvoiceInstance, 'vtiger.entity.aftersave', 'InvoiceHandler',
'modules/Invoice/InvoiceHandler.php');
1113
1114 $POInstance = Vtiger_Module::getInstance('PurchaseOrder');
1115 Vtiger_Event::register($POInstance, 'vtiger.entity.aftersave', 'PurchaseOrderHandler',
'modules/PurchaseOrder/PurchaseOrderHandler.php');
1116
1117 $InvoiceBlockInstance = Vtiger_Block::getInstance('LBL_INVOICE_INFORMATION',
$InvoiceInstance);
1118 $field1 = Vtiger_Field::getInstance('received', $InvoiceInstance);
1119 if (!$field1) {
$field1 = new Vtiger_Field();
1120
$field1->name = 'received';
1121
$field1->label = 'Received';
1122
$field1->table = 'vtiger_invoice';
1123
$field1->uitype = 72;
1124
$field1->displaytype = 3;
1125
$field1->typeofdata = 'N~O';
1126
$field1->defaultvalue = 0;
1127
$InvoiceBlockInstance->addField($field1);
1128
1129 }
1130 $field2 = Vtiger_Field::getInstance('balance', $InvoiceInstance);
1131 if (!$field2) {
$field2 = new Vtiger_Field();
1132
$field2->name = 'balance';
1133
$field2->label = 'Balance';
1134

http://trac.vtiger.com/cgi-bin/trac.cgi/changeset/13851/vtigercrm/branches/6.0.0/modules

4/17/2013

Changeset 13851 for vtigercrm/branches/6.0.0/modules vtiger development

r13846 r13851
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197

Page 4 of 5

$field1->table = 'vtiger_invoice';
$field2->uitype = 72;
$field2->typeofdata = 'N~O';
$field2->defaultvalue = 0;
$field2->displaytype = 3;
$InvoiceBlockInstance->addField($field2);
}
$POBlockInstance = Vtiger_Block::getInstance('LBL_PO_INFORMATION', $POInstance);
$field3 = Vtiger_Field::getInstance('paid', $POInstance);
if (!$field3) {
$field3 = new Vtiger_Field();
$field3->name = 'paid';
$field3->label = 'Paid';
$field3->table = 'vtiger_purchaseorder';
$field3->uitype = 72;
$field3->displaytype = 3;
$field3->typeofdata = 'N~O';
$field3->defaultvalue = 0;
$POBlockInstance->addField($field3);
}
$field4 = Vtiger_Field::getInstance('balance', $POInstance);
if (!$field4) {
$field4 = new Vtiger_Field();
$field4->name = 'balance';
$field4->label = 'Balance';
$field4->table = 'vtiger_purchaseorder';
$field4->uitype = 72;
$field4->typeofdata = 'N~O';
$field4->defaultvalue = 0;
$field4->displaytype = 3;
$POBlockInstance->addField($field4);
}

$sqltimelogTable = "CREATE TABLE vtiger_sqltimelog ( id integer, type VARCHAR(10),


data text, started decimal(18,2), ended decimal
(18,2), loggedon datetime)";
$db->pquery($sqltimelogTable, array());
$moduleName = 'PurchaseOrder';
$emm = new VTEntityMethodManager($db);
$emm->addEntityMethod
($moduleName,"UpdateInventory","include/InventoryHandler.php","handleInventoryProductRel");
$vtWorkFlow = new VTWorkflowManager($db);
$poWorkFlow = $vtWorkFlow->newWorkFlow($moduleName);
$poWorkFlow->description = "Update Inventory Products On Every Save";
$poWorkFlow->defaultworkflow = 1;
$poWorkFlow->executionCondition = 3;
$vtWorkFlow->save($poWorkFlow);
$tm = new VTTaskManager($db);
$task = $tm->createTask('VTEntityMethodTask', $poWorkFlow->id);
$task->active = true;
$task->summary = "Update Inventory Products";
$task->methodName = "UpdateInventory";
$tm->saveTask($task);
echo "Workflow for Purchase Order Created";

// Add Tag Cloud widget.


$homeModule = Vtiger_Module::getInstance('Home');
$homeModule->addLink('DASHBOARDWIDGET', 'Tag Cloud', 'index.php?
module=Home&view=ShowWidget&name=TagCloud');
1198 echo "successfully added tag cloud widget";

http://trac.vtiger.com/cgi-bin/trac.cgi/changeset/13851/vtigercrm/branches/6.0.0/modules

4/17/2013

Changeset 13851 for vtigercrm/branches/6.0.0/modules vtiger development

Page 5 of 5

r13846 r13851
1199
1200 // Schema changed for capturing Dashboard widget positions
1201 $db->pquery('ALTER TABLE vtiger_module_dashboard_widgets ADD COLUMN position VARCHAR
(50)',array());
1202
1203 $moduleInstance = Vtiger_Module::getInstance('Contacts');
1204 if($moduleInstance) {
$moduleInstance->addLink('LISTVIEWSIDEBARWIDGET','Google Contacts',
1205
'module=Google&view=List&sourcemodule=Contacts', '','', '');
1206
1207 }
1208
1209 $moduleInstance = Vtiger_Module::getInstance('Calendar');
1210 if($moduleInstance) {
$moduleInstance->addLink('LISTVIEWSIDEBARWIDGET','Google Calendar',
1211
'module=Google&view=List&sourcemodule=Calendar', '','', '');
1212
1213 }
1214
1215 $db->pquery('ALTER TABLE vtiger_cvadvfilter MODIFY comparator VARCHAR(20)', array());
1216 $db->pquery('UPDATE vtiger_cvadvfilter SET comparator = ? WHERE comparator = ?', array
('next120days', 'next120day'));
1217 $db->pquery('UPDATE vtiger_cvadvfilter SET comparator = ? WHERE comparator = ?', array
('last120days', 'last120day'));
1218
1219 $db->pquery("UPDATE vtiger_relatedlists SET actions = ? WHERE tabid = ? AND related_tabid
IN (?, ?)",
array('ADD', getTabid('Project'), getTabid('ProjectTask'), getTabid
1220
('ProjectMilestone')));
1221
1222 $db->pquery("UPDATE vtiger_field SET typeofdata = ? WHERE columnname = ? AND tablename
= ?", array("V~O", "company", "vtiger_leaddetails"));
1223
1224 if(Vtiger_Utils::CheckTable('vtiger_cron_task')) {
$db->pquery('ALTER TABLE vtiger_cron_task MODIFY COLUMN laststart INT(11)
1225
UNSIGNED',Array());
$db->pquery('ALTER TABLE vtiger_cron_task MODIFY COLUMN lastend INT(11)
1226
UNSIGNED',Array());
1227 }
1228
1229 if(Vtiger_Utils::CheckTable('vtiger_cron_log')) {
$db->pquery('ALTER TABLE vtiger_cron_log MODIFY COLUMN start INT(11)
1230
UNSIGNED',Array());
$db->pquery('ALTER TABLE vtiger_cron_log MODIFY COLUMN end INT(11) UNSIGNED',Array
1231
());
1232 }
1233
1234 require_once 'vtlib/Vtiger/Cron.php';
1235 Vtiger_Cron::deregister('ScheduleReports');
1236
1237 // END 2013.02.18

http://trac.vtiger.com/cgi-bin/trac.cgi/changeset/13851/vtigercrm/branches/6.0.0/modules

4/17/2013