[Vtigercrm-commits] [vtiger-commits] r10697 - in /vtigercrm/branches/5.1_jens: ./ Image/Canvas/ Smarty/templates/ Smarty/templates/Inventory/ Smarty/templates/Settings/ cron/ data/ include/ include/Ajax/ include/clock/ include/fpdf/ include/fpdf/templates/ include/freetag/ include/images/ include/js/ include/language/ include/magpierss/ include/nusoap/ include/php_writeexcel/ include/utils/ install/ jscalendar/lang/ log4php/appenders/ modules/Accounts/ modules/Calendar/ modules/Calendar/language/ modules/Campaigns/ modules/Campaigns/language/ modules/Contacts/ modules/Contacts/language/ modules/CustomView/ modules/CustomView/language/ modules/Dashboard/ modules/Emails/ modules/Emails/language/ modules/Faq/ modules/HelpDesk/ modules/HelpDesk/language/ modules/Home/ modules/Import/ modules/Import/language/ modules/Invoice/ modules/Invoice/language/ modules/Invoice/pdf_templates/ modules/Invoice/pdf_templates/Default/_default/ modules/Invoice/pdf_templates/lastpage/ modules/Leads/ modules/Migration/ modules/Migration/DBChanges/ modules/Migration/ModifyDatabase/ modules/Migration/language/ modules/Notes/ modules/Portal/ modules/Portal/language/ modules/Potentials/ modules/PriceBooks/ modules/Products/ modules/Products/language/ modules/PurchaseOrder/ modules/PurchaseOrder/pdf_templates/ modules/PurchaseOrder/pdf_templates/Default/_default/ modules/PurchaseOrder/pdf_templates/lastpage/ modules/Quotes/ modules/Quotes/language/ modules/Quotes/pdf_templates/ modules/Quotes/pdf_templates/Default/_default/ modules/Quotes/pdf_templates/lastpage/ modules/Reports/ modules/Reports/language/ modules/Rss/ modules/Rss/language/ modules/SalesOrder/ modules/SalesOrder/pdf_templates/ modules/SalesOrder/pdf_templates/Default/_default/ modules/SalesOrder/pdf_templates/lastpage/ modules/Settings/ modules/Settings/language/ modules/System/ modules/System/includes/ modules/Users/ modules/Users/language/ modules/Vendors/ modules/Webmails/ modules/Webmails/language/ modules/uploads/ modules/uploads/language/ pkg/bin/ schema/ soap/ test/user/ themes/alphagrey/ themes/alphagrey/images/ themes/bluelagoon/ themes/bluelagoon/images/ themes/images/ themes/woodspice/ themes/woodspice/images/ user_privileges/

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon Apr 16 14:38:15 EDT 2007


Author: jensh
Date: Mon Apr 16 12:27:44 2007
New Revision: 10697

Log:
Upgrade to version 5.0.3 rc2

Added:
    vtigercrm/branches/5.1_jens/Smarty/templates/JsArray.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Migration.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/CompanyInfo.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/CustomInvoiceNo.tpl   (with props)
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EditCompanyInfo.tpl   (with props)
    vtigercrm/branches/5.1_jens/include/fpdf/pdfconfig.php
    vtigercrm/branches/5.1_jens/include/images/topBg.gif   (with props)
    vtigercrm/branches/5.1_jens/include/js/en_us.lang.js   (with props)
    vtigercrm/branches/5.1_jens/modules/Accounts/Accounts.js
    vtigercrm/branches/5.1_jens/modules/Accounts/AddressChange.php
    vtigercrm/branches/5.1_jens/modules/Accounts/updateRelations.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Calendar.js
    vtigercrm/branches/5.1_jens/modules/Campaigns/Campaigns.js
    vtigercrm/branches/5.1_jens/modules/Contacts/Contacts.js
    vtigercrm/branches/5.1_jens/modules/Emails/Emails.js
    vtigercrm/branches/5.1_jens/modules/Emails/class.phpmailer.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/footer.php
    vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/header.php
    vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/lastpage/body.php
    vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/lastpage/footer.php
    vtigercrm/branches/5.1_jens/modules/Leads/Leads.js
    vtigercrm/branches/5.1_jens/modules/Migration/DBChanges/
    vtigercrm/branches/5.1_jens/modules/Migration/DBChanges/42P2_to_50.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Migration/DBChanges/501_to_502.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Migration/DBChanges/502_to_503rc2.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Migration/DBChanges/503rc2_to_503.php
    vtigercrm/branches/5.1_jens/modules/Migration/MigrationInfo.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Migration/PatchApply.php
    vtigercrm/branches/5.1_jens/modules/Migration/deleteCustomFields.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Migration/index.php
    vtigercrm/branches/5.1_jens/modules/Migration/rename_tables.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Migration/versions.php
    vtigercrm/branches/5.1_jens/modules/Notes/Notes.js
    vtigercrm/branches/5.1_jens/modules/Potentials/Potentials.js
    vtigercrm/branches/5.1_jens/modules/PriceBooks/PriceBooks.js
    vtigercrm/branches/5.1_jens/modules/Products/CallDependencyList.php
    vtigercrm/branches/5.1_jens/modules/Products/DeleteProductProductRel.php
    vtigercrm/branches/5.1_jens/modules/Products/Products.js
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/footer.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/header.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/lastpage/body.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/lastpage/footer.php
    vtigercrm/branches/5.1_jens/modules/Quotes/Quotes.js
    vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/footer.php
    vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/header.php
    vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/lastpage/body.php
    vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/lastpage/footer.php
    vtigercrm/branches/5.1_jens/modules/Reports/CheckReport.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Reports/Reports.js
    vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/footer.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/header.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/lastpage/body.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/lastpage/footer.php
    vtigercrm/branches/5.1_jens/modules/Settings/Announcements.php
    vtigercrm/branches/5.1_jens/modules/Settings/AuditTrail.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/AuditTrailList.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/CreateSharingRule.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/CustomInvoiceNo.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/DefModuleView.php
    vtigercrm/branches/5.1_jens/modules/Settings/DefaultFieldPermissions.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/EditCompanyDetails.php
    vtigercrm/branches/5.1_jens/modules/Settings/EditDefOrgFieldLevelAccess.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/EditInventoryNotification.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/EditNotification.php
    vtigercrm/branches/5.1_jens/modules/Settings/GroupDetailView.php
    vtigercrm/branches/5.1_jens/modules/Settings/ListLoginHistory.php
    vtigercrm/branches/5.1_jens/modules/Settings/ListProfiles.php
    vtigercrm/branches/5.1_jens/modules/Settings/OrgSharingDetailView.php
    vtigercrm/branches/5.1_jens/modules/Settings/OrganizationConfig.php
    vtigercrm/branches/5.1_jens/modules/Settings/OrganizationTermsandConditions.php
    vtigercrm/branches/5.1_jens/modules/Settings/RoleDeleteStep1.php
    vtigercrm/branches/5.1_jens/modules/Settings/RoleDetailView.php
    vtigercrm/branches/5.1_jens/modules/Settings/SaveAuditTrail.php
    vtigercrm/branches/5.1_jens/modules/Settings/SaveCompany.php
    vtigercrm/branches/5.1_jens/modules/Settings/SaveInventoryNotification.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/SaveNotification.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/SaveRole.php
    vtigercrm/branches/5.1_jens/modules/Settings/SaveSharingRule.php
    vtigercrm/branches/5.1_jens/modules/Settings/ShowAuditTrail.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/UpdateDefaultFieldLevelAccess.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/add2db.php
    vtigercrm/branches/5.1_jens/modules/Settings/createemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Settings/createnewgroup.php
    vtigercrm/branches/5.1_jens/modules/Settings/createrole.php
    vtigercrm/branches/5.1_jens/modules/Settings/deleteemailtemplate.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/deletewordtemplate.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/detailviewemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Settings/downloadfile.php
    vtigercrm/branches/5.1_jens/modules/Settings/editemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Settings/listemailtemplates.php
    vtigercrm/branches/5.1_jens/modules/Settings/listgroups.php
    vtigercrm/branches/5.1_jens/modules/Settings/listinventorynotifications.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/listnotificationschedulers.php
    vtigercrm/branches/5.1_jens/modules/Settings/listroles.php
    vtigercrm/branches/5.1_jens/modules/Settings/listwordtemplates.php
    vtigercrm/branches/5.1_jens/modules/Settings/mailmergedownloadfile.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/profilePrivileges.php
    vtigercrm/branches/5.1_jens/modules/Settings/saveemailtemplate.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/savetermsandconditions.php
    vtigercrm/branches/5.1_jens/modules/Settings/savewordtemplate.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Settings/upload.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Users/AddMailAccount.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveMailAccount.php
    vtigercrm/branches/5.1_jens/modules/Users/UpdateCustomInvoiceNo.php   (with props)
    vtigercrm/branches/5.1_jens/modules/Vendors/Vendors.js
    vtigercrm/branches/5.1_jens/modules/Webmails/Webmails.js
    vtigercrm/branches/5.1_jens/modules/Webmails/Webmails.php
    vtigercrm/branches/5.1_jens/modules/Webmails/conf.php
    vtigercrm/branches/5.1_jens/modules/Webmails/download.php
    vtigercrm/branches/5.1_jens/modules/Webmails/functions.php
    vtigercrm/branches/5.1_jens/modules/Webmails/get_img.php
    vtigercrm/branches/5.1_jens/robots.txt
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/AddEvent.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/AddToDo.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/Recurring.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/actionGenPurchaseOrder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/actionGenerateInvoice.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/actionGeneratePDF.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/actionGenerateQuote.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/actionGenerateSalesOrder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/actionPrintNow.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/alphagrayHomeMark.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/emailDelete.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/emailInFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/emailOutFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/emailTrashFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/settingsInvNumber.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/windowmarkModule.jpg   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/AddEvent.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/AddToDo.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/Recurring.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/actionGenPurchaseOrder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/actionGenerateInvoice.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/actionGeneratePDF.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/actionGenerateQuote.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/actionGenerateSalesOrder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/actionPrintNow.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/blueLagoonHomeMark.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/emailDelete.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/emailInFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/emailOutFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/emailTrashFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/settingsInvNumber.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/windowmarkModule.jpg   (with props)
    vtigercrm/branches/5.1_jens/themes/images/btnSignIn.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/btnSignInNEW.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/bullets.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/honestCRM.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/honestCRMTop.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/signin.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/topBg.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/images/vtigerName.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/AddEvent.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/AddToDo.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/Recurring.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/actionGenPurchaseOrder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/actionGenerateInvoice.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/actionGeneratePDF.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/actionGenerateQuote.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/actionGenerateSalesOrder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/actionPrintNow.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/emailDelete.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/emailInFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/emailOutFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/emailTrashFolder.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/settingsInvNumber.gif   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/windowmarkModule.jpg   (with props)
    vtigercrm/branches/5.1_jens/themes/woodspice/images/woodspiceHomeMark.gif   (with props)
    vtigercrm/branches/5.1_jens/user_privileges/CustomInvoiceNo.php   (with props)
Removed:
    vtigercrm/branches/5.1_jens/include/clock/Clock.php
    vtigercrm/branches/5.1_jens/include/js/prototype.js
    vtigercrm/branches/5.1_jens/modules/Accounts/Account.js
    vtigercrm/branches/5.1_jens/modules/Accounts/Account.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Activity.js
    vtigercrm/branches/5.1_jens/modules/Campaigns/Campaign.js
    vtigercrm/branches/5.1_jens/modules/Campaigns/Campaign.php
    vtigercrm/branches/5.1_jens/modules/Contacts/Contact.js
    vtigercrm/branches/5.1_jens/modules/Contacts/Contact.php
    vtigercrm/branches/5.1_jens/modules/Emails/Email.js
    vtigercrm/branches/5.1_jens/modules/Emails/Email.php
    vtigercrm/branches/5.1_jens/modules/Leads/Lead.js
    vtigercrm/branches/5.1_jens/modules/Leads/Lead.php
    vtigercrm/branches/5.1_jens/modules/Migration/502DBChanges.php
    vtigercrm/branches/5.1_jens/modules/Migration/ModifyDatabase/42P2_to_50.php
    vtigercrm/branches/5.1_jens/modules/Migration/ModifyDatabase/MigrationInfo.php
    vtigercrm/branches/5.1_jens/modules/Migration/ModifyDatabase/deleteCustomFields.php
    vtigercrm/branches/5.1_jens/modules/Migration/ModifyDatabase/rename_tables.php
    vtigercrm/branches/5.1_jens/modules/Notes/Note.js
    vtigercrm/branches/5.1_jens/modules/Potentials/Opportunity.js
    vtigercrm/branches/5.1_jens/modules/PriceBooks/PriceBook.js
    vtigercrm/branches/5.1_jens/modules/PriceBooks/PriceBook.php
    vtigercrm/branches/5.1_jens/modules/Products/Product.js
    vtigercrm/branches/5.1_jens/modules/Products/Product.php
    vtigercrm/branches/5.1_jens/modules/Quotes/Quote.js
    vtigercrm/branches/5.1_jens/modules/Quotes/Quote.php
    vtigercrm/branches/5.1_jens/modules/Reports/Report.js
    vtigercrm/branches/5.1_jens/modules/Settings/AddMailAccount.php
    vtigercrm/branches/5.1_jens/modules/Settings/SaveMailAccount.php
    vtigercrm/branches/5.1_jens/modules/Users/AuditTrail.php
    vtigercrm/branches/5.1_jens/modules/Users/AuditTrailList.php
    vtigercrm/branches/5.1_jens/modules/Users/CreateSharingRule.php
    vtigercrm/branches/5.1_jens/modules/Users/DefModuleView.php
    vtigercrm/branches/5.1_jens/modules/Users/DefaultFieldPermissions.php
    vtigercrm/branches/5.1_jens/modules/Users/EditDefOrgFieldLevelAccess.php
    vtigercrm/branches/5.1_jens/modules/Users/EditInventoryNotification.php
    vtigercrm/branches/5.1_jens/modules/Users/EditNotification.php
    vtigercrm/branches/5.1_jens/modules/Users/GroupDetailView.php
    vtigercrm/branches/5.1_jens/modules/Users/ListLoginHistory.php
    vtigercrm/branches/5.1_jens/modules/Users/ListProfiles.php
    vtigercrm/branches/5.1_jens/modules/Users/OrgSharingDetailView.php
    vtigercrm/branches/5.1_jens/modules/Users/OrganizationTermsandConditions.php
    vtigercrm/branches/5.1_jens/modules/Users/RoleDeleteStep1.php
    vtigercrm/branches/5.1_jens/modules/Users/RoleDetailView.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveAuditTrail.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveInventoryNotification.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveNotification.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveRole.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveSharingRule.php
    vtigercrm/branches/5.1_jens/modules/Users/ShowAuditTrail.php
    vtigercrm/branches/5.1_jens/modules/Users/UpdateDefaultFieldLevelAccess.php
    vtigercrm/branches/5.1_jens/modules/Users/User.php
    vtigercrm/branches/5.1_jens/modules/Users/add2db.php
    vtigercrm/branches/5.1_jens/modules/Users/createemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Users/createnewgroup.php
    vtigercrm/branches/5.1_jens/modules/Users/createrole.php
    vtigercrm/branches/5.1_jens/modules/Users/deleteemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Users/detailviewemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Users/editemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Users/listemailtemplates.php
    vtigercrm/branches/5.1_jens/modules/Users/listgroups.php
    vtigercrm/branches/5.1_jens/modules/Users/listinventorynotifications.php
    vtigercrm/branches/5.1_jens/modules/Users/listnotificationschedulers.php
    vtigercrm/branches/5.1_jens/modules/Users/listroles.php
    vtigercrm/branches/5.1_jens/modules/Users/listwordtemplates.php
    vtigercrm/branches/5.1_jens/modules/Users/profilePrivileges.php
    vtigercrm/branches/5.1_jens/modules/Users/saveemailtemplate.php
    vtigercrm/branches/5.1_jens/modules/Users/savetermsandconditions.php
    vtigercrm/branches/5.1_jens/modules/Users/upload.php
    vtigercrm/branches/5.1_jens/modules/Vendors/Vendor.js
    vtigercrm/branches/5.1_jens/modules/Vendors/Vendor.php
    vtigercrm/branches/5.1_jens/modules/Webmails/Webmail.php
    vtigercrm/branches/5.1_jens/modules/Webmails/webmails.js
    vtigercrm/branches/5.1_jens/test/user/ela.jpg
    vtigercrm/branches/5.1_jens/test/user/richie.jpg
Modified:
    vtigercrm/branches/5.1_jens/Image/Canvas/SVG.php
    vtigercrm/branches/5.1_jens/Popup.php
    vtigercrm/branches/5.1_jens/Release_Notes.html
    vtigercrm/branches/5.1_jens/SendReminder.php
    vtigercrm/branches/5.1_jens/Smarty/templates/ActivityDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ActivityEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ActivityListView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/AddMailAccount.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/AddProductToPriceBooks.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/AddProductsToPriceBook.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/AuditTrailList.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List1.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ComposeEmail.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CreateEmailTemplate.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CreateProfile.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CreateView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CreateWordTemplate.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyListView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldList.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldMapping.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/CustomView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DefModuleView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DeleteRole.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewEmailTemplate.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewFields.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewHidden.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewUI.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/DisplayFields.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/EditProfile.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/EditViewHidden.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/EmailContents.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetails.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Emails.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/FieldAccess.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/GlobalListView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/GroupDetailview.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/GroupEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Header.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/HomePage.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep1.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep2.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryActions.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryCreateView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetails.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetailsEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListEmailTemplates.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListGroup.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListLeadCustomFieldMapping.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListRoles.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListViewEntries.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ListWordTemplates.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/MigrationStep1.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Popup.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/PopupContents.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/PrintReport.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ProfileDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreate.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreateHidden.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListContents.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListNew.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/RelatedLists.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ReportColumns.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ReportRun.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Reports.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ReportsCustomize.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep0.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep1.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/RoleDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/RoleEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Rss.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/SelectEmail.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/SetMenu.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/Announcements.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServer.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServerContents.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailConfig.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailNotification.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryNotify.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryTerms.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ModuleOwners.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/PickList.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ProxyServer.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Settings/TaxConfig.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/ShowAuditTrail.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/SysInformation.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/UserDetailView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/UserEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/UserGroups.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/UserProfileList.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/Webmails.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/pendingActivities.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/salesEditView.tpl
    vtigercrm/branches/5.1_jens/Smarty/templates/upcomingActivities.tpl
    vtigercrm/branches/5.1_jens/Smarty_setup.php
    vtigercrm/branches/5.1_jens/config.template.php
    vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.bat
    vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.php
    vtigercrm/branches/5.1_jens/cron/jobstartwindows.bat
    vtigercrm/branches/5.1_jens/data/CRMEntity.php
    vtigercrm/branches/5.1_jens/data/Tracker.php
    vtigercrm/branches/5.1_jens/include/Ajax/TagCloud.php
    vtigercrm/branches/5.1_jens/include/CustomFieldUtil.php
    vtigercrm/branches/5.1_jens/include/RelatedListView.php
    vtigercrm/branches/5.1_jens/include/fpdf/fpdf.php
    vtigercrm/branches/5.1_jens/include/fpdf/templates/body.php
    vtigercrm/branches/5.1_jens/include/freetag/freetag.class.php
    vtigercrm/branches/5.1_jens/include/js/Inventory.js
    vtigercrm/branches/5.1_jens/include/js/ListView.js
    vtigercrm/branches/5.1_jens/include/js/Mail.js
    vtigercrm/branches/5.1_jens/include/js/Merge.js
    vtigercrm/branches/5.1_jens/include/js/QuickCreate.js
    vtigercrm/branches/5.1_jens/include/js/customview.js
    vtigercrm/branches/5.1_jens/include/js/dtlviewajax.js
    vtigercrm/branches/5.1_jens/include/js/general.js
    vtigercrm/branches/5.1_jens/include/js/popup.js
    vtigercrm/branches/5.1_jens/include/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/include/magpierss/rss_fetch.inc
    vtigercrm/branches/5.1_jens/include/nusoap/nusoap.php
    vtigercrm/branches/5.1_jens/include/php_writeexcel/class.writeexcel_worksheet.inc.php
    vtigercrm/branches/5.1_jens/include/style.css
    vtigercrm/branches/5.1_jens/include/utils/CommonUtils.php
    vtigercrm/branches/5.1_jens/include/utils/DeleteUtils.php
    vtigercrm/branches/5.1_jens/include/utils/DetailViewUtils.php
    vtigercrm/branches/5.1_jens/include/utils/EditViewUtils.php
    vtigercrm/branches/5.1_jens/include/utils/ExportUtils.php
    vtigercrm/branches/5.1_jens/include/utils/GraphUtils.php
    vtigercrm/branches/5.1_jens/include/utils/InventoryUtils.php
    vtigercrm/branches/5.1_jens/include/utils/ListViewUtils.php
    vtigercrm/branches/5.1_jens/include/utils/RecurringType.php
    vtigercrm/branches/5.1_jens/include/utils/SearchUtils.php
    vtigercrm/branches/5.1_jens/include/utils/UserInfoUtil.php
    vtigercrm/branches/5.1_jens/include/utils/export.php
    vtigercrm/branches/5.1_jens/include/utils/utils.php
    vtigercrm/branches/5.1_jens/index.php
    vtigercrm/branches/5.1_jens/install/0welcome.php
    vtigercrm/branches/5.1_jens/install/1checkSystem.php
    vtigercrm/branches/5.1_jens/install/2setConfig.php
    vtigercrm/branches/5.1_jens/install/3confirmConfig.php
    vtigercrm/branches/5.1_jens/install/4createConfigFile.php
    vtigercrm/branches/5.1_jens/install/5createTables.inc.php
    vtigercrm/branches/5.1_jens/install/5createTables.php
    vtigercrm/branches/5.1_jens/install/populateSeedData.php
    vtigercrm/branches/5.1_jens/jscalendar/lang/calendar-pl.js
    vtigercrm/branches/5.1_jens/log4php/appenders/LoggerAppenderRollingFile.php
    vtigercrm/branches/5.1_jens/modules/Accounts/Accounts.php
    vtigercrm/branches/5.1_jens/modules/Accounts/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Accounts/EditView.php
    vtigercrm/branches/5.1_jens/modules/Accounts/ListView.php
    vtigercrm/branches/5.1_jens/modules/Accounts/ListViewTop.php
    vtigercrm/branches/5.1_jens/modules/Accounts/Merge.php
    vtigercrm/branches/5.1_jens/modules/Accounts/Save.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Activity.php
    vtigercrm/branches/5.1_jens/modules/Calendar/ActivityAjax.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Appointment.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Calendar.php
    vtigercrm/branches/5.1_jens/modules/Calendar/CalendarCommon.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Date.php
    vtigercrm/branches/5.1_jens/modules/Calendar/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Calendar/EditView.php
    vtigercrm/branches/5.1_jens/modules/Calendar/ListView.php
    vtigercrm/branches/5.1_jens/modules/Calendar/OpenListView.php
    vtigercrm/branches/5.1_jens/modules/Calendar/Save.php
    vtigercrm/branches/5.1_jens/modules/Calendar/TodoSave.php
    vtigercrm/branches/5.1_jens/modules/Calendar/addEventUI.php
    vtigercrm/branches/5.1_jens/modules/Calendar/calendarLayout.php
    vtigercrm/branches/5.1_jens/modules/Calendar/calendar_share.php
    vtigercrm/branches/5.1_jens/modules/Calendar/header.php
    vtigercrm/branches/5.1_jens/modules/Calendar/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Calendar/script.js
    vtigercrm/branches/5.1_jens/modules/Calendar/updateCalendarSharing.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/CallRelatedList.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/Campaigns.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/EditView.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/ListView.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/LoadList.php
    vtigercrm/branches/5.1_jens/modules/Campaigns/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Contacts/CallRelatedList.php
    vtigercrm/branches/5.1_jens/modules/Contacts/Contacts.php
    vtigercrm/branches/5.1_jens/modules/Contacts/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Contacts/DetailViewAjax.php
    vtigercrm/branches/5.1_jens/modules/Contacts/EditView.php
    vtigercrm/branches/5.1_jens/modules/Contacts/ListView.php
    vtigercrm/branches/5.1_jens/modules/Contacts/Merge.php
    vtigercrm/branches/5.1_jens/modules/Contacts/Save.php
    vtigercrm/branches/5.1_jens/modules/Contacts/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Contacts/updateRelations.php
    vtigercrm/branches/5.1_jens/modules/Contacts/vtchat.php
    vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.js
    vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.php
    vtigercrm/branches/5.1_jens/modules/CustomView/EditView.php
    vtigercrm/branches/5.1_jens/modules/CustomView/ListViewTop.php
    vtigercrm/branches/5.1_jens/modules/CustomView/PopulateCustomView.php
    vtigercrm/branches/5.1_jens/modules/CustomView/Save.php
    vtigercrm/branches/5.1_jens/modules/CustomView/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome_matrix.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/Entity_charts.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/HomepageDB.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/accumulated_bargraph.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/display_charts.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/horizontal_bargraph.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/index.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/line_graph.php
    vtigercrm/branches/5.1_jens/modules/Dashboard/pie_graph.php
    vtigercrm/branches/5.1_jens/modules/Emails/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Emails/EditView.php
    vtigercrm/branches/5.1_jens/modules/Emails/Emails.php
    vtigercrm/branches/5.1_jens/modules/Emails/Save.php
    vtigercrm/branches/5.1_jens/modules/Emails/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Emails/mail.php
    vtigercrm/branches/5.1_jens/modules/Emails/mailSelect.php
    vtigercrm/branches/5.1_jens/modules/Emails/mailbox.php
    vtigercrm/branches/5.1_jens/modules/Emails/mailsend.php
    vtigercrm/branches/5.1_jens/modules/Emails/sendmail.php
    vtigercrm/branches/5.1_jens/modules/Faq/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Faq/EditView.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailView.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailViewAjax.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/EditView.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.js
    vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/ListTickets.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/ListView.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/Merge.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/Save.php
    vtigercrm/branches/5.1_jens/modules/HelpDesk/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Home/UnifiedSearch.php
    vtigercrm/branches/5.1_jens/modules/Home/index.php
    vtigercrm/branches/5.1_jens/modules/Import/ImportAjax.php
    vtigercrm/branches/5.1_jens/modules/Import/ImportSave.php
    vtigercrm/branches/5.1_jens/modules/Import/ImportStep2.php
    vtigercrm/branches/5.1_jens/modules/Import/ImportSteplast.php
    vtigercrm/branches/5.1_jens/modules/Import/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Invoice/CreatePDF.php
    vtigercrm/branches/5.1_jens/modules/Invoice/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Invoice/EditView.php
    vtigercrm/branches/5.1_jens/modules/Invoice/Invoice.php
    vtigercrm/branches/5.1_jens/modules/Invoice/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/Default/_default/header.php
    vtigercrm/branches/5.1_jens/modules/Leads/CallRelatedList.php
    vtigercrm/branches/5.1_jens/modules/Leads/ConvertLead.html
    vtigercrm/branches/5.1_jens/modules/Leads/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Leads/EditView.php
    vtigercrm/branches/5.1_jens/modules/Leads/LeadConvertToEntities.php
    vtigercrm/branches/5.1_jens/modules/Leads/Leads.php
    vtigercrm/branches/5.1_jens/modules/Leads/ListView.php
    vtigercrm/branches/5.1_jens/modules/Leads/ListViewTop.php
    vtigercrm/branches/5.1_jens/modules/Leads/Merge.php
    vtigercrm/branches/5.1_jens/modules/Leads/updateRelations.php
    vtigercrm/branches/5.1_jens/modules/Migration/Migration.php
    vtigercrm/branches/5.1_jens/modules/Migration/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Notes/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Notes/EditView.php
    vtigercrm/branches/5.1_jens/modules/Notes/Notes.php
    vtigercrm/branches/5.1_jens/modules/Notes/Save.php
    vtigercrm/branches/5.1_jens/modules/Portal/Portal.js
    vtigercrm/branches/5.1_jens/modules/Portal/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Potentials/CallRelatedList.php
    vtigercrm/branches/5.1_jens/modules/Potentials/Charts.php
    vtigercrm/branches/5.1_jens/modules/Potentials/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Potentials/DetailViewAjax.php
    vtigercrm/branches/5.1_jens/modules/Potentials/EditView.php
    vtigercrm/branches/5.1_jens/modules/Potentials/ListView.php
    vtigercrm/branches/5.1_jens/modules/Potentials/ListViewTop.php
    vtigercrm/branches/5.1_jens/modules/Potentials/Opportunity.php
    vtigercrm/branches/5.1_jens/modules/Potentials/Potentials.php
    vtigercrm/branches/5.1_jens/modules/Potentials/Save.php
    vtigercrm/branches/5.1_jens/modules/Potentials/updateRelations.php
    vtigercrm/branches/5.1_jens/modules/PriceBooks/DetailView.php
    vtigercrm/branches/5.1_jens/modules/PriceBooks/EditView.php
    vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.html
    vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.php
    vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.html
    vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.php
    vtigercrm/branches/5.1_jens/modules/Products/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Products/EditView.php
    vtigercrm/branches/5.1_jens/modules/Products/Products.php
    vtigercrm/branches/5.1_jens/modules/Products/Save.php
    vtigercrm/branches/5.1_jens/modules/Products/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Products/updateRelations.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/CreatePDF.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/DetailView.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/EditView.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/PurchaseOrder.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/Save.php
    vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/Default/_default/header.php
    vtigercrm/branches/5.1_jens/modules/Quotes/CreatePDF.php
    vtigercrm/branches/5.1_jens/modules/Quotes/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Quotes/EditView.php
    vtigercrm/branches/5.1_jens/modules/Quotes/ListTopQuotes.php
    vtigercrm/branches/5.1_jens/modules/Quotes/ListView.php
    vtigercrm/branches/5.1_jens/modules/Quotes/Quotes.php
    vtigercrm/branches/5.1_jens/modules/Quotes/Save.php
    vtigercrm/branches/5.1_jens/modules/Quotes/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/Default/_default/header.php
    vtigercrm/branches/5.1_jens/modules/Reports/AdvancedFilter.php
    vtigercrm/branches/5.1_jens/modules/Reports/CreatePDF.php
    vtigercrm/branches/5.1_jens/modules/Reports/PopulateReports.php
    vtigercrm/branches/5.1_jens/modules/Reports/PrintReport.php
    vtigercrm/branches/5.1_jens/modules/Reports/ReportColumns.php
    vtigercrm/branches/5.1_jens/modules/Reports/ReportRun.php
    vtigercrm/branches/5.1_jens/modules/Reports/Reports.php
    vtigercrm/branches/5.1_jens/modules/Reports/Save.php
    vtigercrm/branches/5.1_jens/modules/Reports/SaveReportFolder.php
    vtigercrm/branches/5.1_jens/modules/Reports/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Rss/Popup.php
    vtigercrm/branches/5.1_jens/modules/Rss/Rss.js
    vtigercrm/branches/5.1_jens/modules/Rss/Rss.php
    vtigercrm/branches/5.1_jens/modules/Rss/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/CreateSOPDF.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/DetailView.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/EditView.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/SalesOrder.php
    vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/Default/_default/header.php
    vtigercrm/branches/5.1_jens/modules/Settings/AddCustomFieldToDB.php
    vtigercrm/branches/5.1_jens/modules/Settings/CreateCustomField.php
    vtigercrm/branches/5.1_jens/modules/Settings/DeleteCustomField.php
    vtigercrm/branches/5.1_jens/modules/Settings/EmailConfig.php
    vtigercrm/branches/5.1_jens/modules/Settings/ListMailAccount.php
    vtigercrm/branches/5.1_jens/modules/Settings/ProxyServerConfig.php
    vtigercrm/branches/5.1_jens/modules/Settings/Save.php
    vtigercrm/branches/5.1_jens/modules/Settings/SettingsAjax.php
    vtigercrm/branches/5.1_jens/modules/Settings/UpdateComboValues.php
    vtigercrm/branches/5.1_jens/modules/Settings/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/System/includes/system_header.php
    vtigercrm/branches/5.1_jens/modules/System/systemconfig.php
    vtigercrm/branches/5.1_jens/modules/Users/Authenticate.php
    vtigercrm/branches/5.1_jens/modules/Users/ChangePassword.php
    vtigercrm/branches/5.1_jens/modules/Users/CreateUserPrivilegeFile.php
    vtigercrm/branches/5.1_jens/modules/Users/DefaultDataPopulator.php
    vtigercrm/branches/5.1_jens/modules/Users/DeleteGroup.php
    vtigercrm/branches/5.1_jens/modules/Users/DeleteProfile.php
    vtigercrm/branches/5.1_jens/modules/Users/DeleteRole.php
    vtigercrm/branches/5.1_jens/modules/Users/DeleteSharingRule.php
    vtigercrm/branches/5.1_jens/modules/Users/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Users/EditView.php
    vtigercrm/branches/5.1_jens/modules/Users/Forms.php
    vtigercrm/branches/5.1_jens/modules/Users/GroupDeleteStep1.php
    vtigercrm/branches/5.1_jens/modules/Users/Login.php
    vtigercrm/branches/5.1_jens/modules/Users/RecalculateSharingRules.php
    vtigercrm/branches/5.1_jens/modules/Users/RoleDragDrop.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveGroup.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveOrgSharing.php
    vtigercrm/branches/5.1_jens/modules/Users/SaveProfile.php
    vtigercrm/branches/5.1_jens/modules/Users/UpdateProfileChanges.php
    vtigercrm/branches/5.1_jens/modules/Users/Users.php
    vtigercrm/branches/5.1_jens/modules/Users/UsersAjax.php
    vtigercrm/branches/5.1_jens/modules/Users/about_us.php
    vtigercrm/branches/5.1_jens/modules/Users/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/Users/lookupemailtemplates.php
    vtigercrm/branches/5.1_jens/modules/Users/massdelete.php
    vtigercrm/branches/5.1_jens/modules/Users/notify_detail.php
    vtigercrm/branches/5.1_jens/modules/Users/updateLeadDBStatus.php
    vtigercrm/branches/5.1_jens/modules/Vendors/Delete.php
    vtigercrm/branches/5.1_jens/modules/Vendors/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Vendors/EditView.php
    vtigercrm/branches/5.1_jens/modules/Vendors/Vendors.php
    vtigercrm/branches/5.1_jens/modules/Vendors/updateRelations.php
    vtigercrm/branches/5.1_jens/modules/Webmails/CallRelatedList.php
    vtigercrm/branches/5.1_jens/modules/Webmails/DetailView.php
    vtigercrm/branches/5.1_jens/modules/Webmails/ListView.php
    vtigercrm/branches/5.1_jens/modules/Webmails/MailBox.php
    vtigercrm/branches/5.1_jens/modules/Webmails/MailParse.php
    vtigercrm/branches/5.1_jens/modules/Webmails/Save.php
    vtigercrm/branches/5.1_jens/modules/Webmails/WebmailsAjax.php
    vtigercrm/branches/5.1_jens/modules/Webmails/body.php
    vtigercrm/branches/5.1_jens/modules/Webmails/dlAttachments.php
    vtigercrm/branches/5.1_jens/modules/Webmails/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/uploads/add2db.php
    vtigercrm/branches/5.1_jens/modules/uploads/language/en_us.lang.php
    vtigercrm/branches/5.1_jens/modules/uploads/upload.php
    vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.bat
    vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.sh
    vtigercrm/branches/5.1_jens/pkg/bin/stopvTiger.bat
    vtigercrm/branches/5.1_jens/schema/DatabaseSchema.xml
    vtigercrm/branches/5.1_jens/soap/customerportal.php
    vtigercrm/branches/5.1_jens/soap/firefoxtoolbar.php
    vtigercrm/branches/5.1_jens/soap/thunderbirdplugin.php
    vtigercrm/branches/5.1_jens/soap/vtigerolservice.php
    vtigercrm/branches/5.1_jens/soap/wordplugin.php
    vtigercrm/branches/5.1_jens/tabdata.php
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/aboutUS.jpg
    vtigercrm/branches/5.1_jens/themes/alphagrey/images/cal12x12Shared.gif
    vtigercrm/branches/5.1_jens/themes/alphagrey/style.css
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/aboutUS.jpg
    vtigercrm/branches/5.1_jens/themes/bluelagoon/images/cal12x12Shared.gif
    vtigercrm/branches/5.1_jens/themes/bluelagoon/style.css
    vtigercrm/branches/5.1_jens/themes/woodspice/images/aboutUS.jpg
    vtigercrm/branches/5.1_jens/themes/woodspice/images/cal12x12Shared.gif
    vtigercrm/branches/5.1_jens/themes/woodspice/style.css
    vtigercrm/branches/5.1_jens/user_privileges/default_module_view.php
    vtigercrm/branches/5.1_jens/vtigerversion.php

Modified: vtigercrm/branches/5.1_jens/Image/Canvas/SVG.php
==============================================================================
--- vtigercrm/branches/5.1_jens/Image/Canvas/SVG.php (original)
+++ vtigercrm/branches/5.1_jens/Image/Canvas/SVG.php Mon Apr 16 12:27:44 2007
@@ -28,6 +28,7 @@
 /**
  * Include file Image/Canvas.php
  */
+global $app_strings; 
 require_once 'Image/Canvas.php';
 
 /**
@@ -817,7 +818,7 @@
     function show($param = false)
     {
         parent::show($param);
-        $output = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n" .
+        $output = '<?xml version="1.0" encoding='.$app_strings['LBL_CHARSET'].'?>' . "\n" .
             '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
             ' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
             '<svg width="' . $this->_width . '" height="' . $this->_height .
@@ -844,7 +845,7 @@
     function save($param = false)
     {
         parent::save($param);
-        $output = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n" .
+        $output = '<?xml version="1.0" encoding='.$app_strings['LBL_CHARSET'].'?>' . "\n" .
             '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"' . "\n\t" .
             ' "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">' . "\n" .
             '<svg width="' . $this->_width . '" height="' . $this->_height .
@@ -915,4 +916,4 @@
       
 }
 
-?>
+?>

Modified: vtigercrm/branches/5.1_jens/Popup.php
==============================================================================
--- vtigercrm/branches/5.1_jens/Popup.php (original)
+++ vtigercrm/branches/5.1_jens/Popup.php Mon Apr 16 12:27:44 2007
@@ -20,7 +20,6 @@
 require_once('include/database/PearDatabase.php');
 require_once('include/ComboUtil.php');
 require_once('include/utils/utils.php');
-
 global $app_strings;
 global $currentModule;
 global $theme;
@@ -31,6 +30,7 @@
 $popuptype = '';
 $filter = '';
 $popuptype = $_REQUEST["popuptype"];
+$dependency_type = '';
 switch($currentModule)
 {
 	case 'Contacts':
@@ -47,40 +47,6 @@
 		if (isset($_REQUEST['select'])) $smarty->assign("SELECT",'enable');
 		$alphabetical = AlphabeticalSearch($currentModule,'Popup','lastname','true','basic',$popuptype,"","","");
 
-		//set up a filter if we got a parent
-		if(isset($_REQUEST['Parent']) && $_REQUEST['Parent'] !='') {
-		    $sql = "SELECT tablename,entityidfield FROM vtiger_entityname
-				JOIN vtiger_crmentity ON
-				    vtiger_entityname.modulename = vtiger_crmentity.setype
-				WHERE crmid=".$_REQUEST['Parent'];
-		    $result = $adb->query($sql);
-		    $tablename = $adb->query_result($result,0,"tablename");
-		    if( $tablename == "vtiger_quotes" ||
-			$tablename == "vtiger_salesorder" ||
-			$tablename == "vtiger_invoice") {
-			$fieldname = "accountid";
-		    /*
-		    } elseif( $tablename == "vtiger_purchaseorder") {
-			$fieldname = "vendorid";
-		    */
-		    } else {
-			$fieldname = "";
-		    }
-
-		    //get the fieldvalue to filter on. We cannot just set 
-		    //up a filter addon, because the listquery is to hard
-		    //to change ...
-		    if( $fieldname != "") {
-			$tableindex = $adb->query_result($result,0,"entityidfield");
-			$sql = "SELECT ".$fieldname." FROM ".$tablename."
-				  WHERE ".$tableindex."=".$_REQUEST['Parent'];
-			$result = $adb->query($sql);
-			$filter = $adb->query_result($result,0,$fieldname);
-
-			if( $filter != '') 
-			    $filter = "vtiger_contactdetails.accountid=".$filter;
-		    }
-		}
 		break;
 	case 'Campaigns':
 		require_once("modules/$currentModule/Campaigns.php");
@@ -168,6 +134,10 @@
 		}
 		if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] !='')
 			$smarty->assign("RETURN_MODULE",$_REQUEST['return_module']);
+		if (isset($_REQUEST['select'])) $smarty->assign("SELECT",'enable');
+		if (isset($_REQUEST['dependency_type']) && $_REQUEST['dependency_type'] != '') {
+		    $dependency_type = $_REQUEST['dependency_type'];
+		}
 		$alphabetical = AlphabeticalSearch($currentModule,'Popup','productname','true','basic',$popuptype,"","","");
 		break;
 	case 'Vendors':
@@ -240,6 +210,7 @@
 		break;
 }
 $smarty->assign("RETURN_ACTION",$_REQUEST['return_action']);
+$smarty->assign("DEPENDENCY_TYPE",$dependency_type);
 
 
 $theme_path="themes/".$theme."/";
@@ -263,12 +234,19 @@
 		{		
 			$smarty->assign("RECORDID",$_REQUEST['recordid']);
 			$url_string .='&recordid='.$_REQUEST['recordid'];
-		}
-        $where_relquery = getRelCheckquery($currentModule,$_REQUEST['return_module'],$_REQUEST['recordid']);
+			$where_relquery = getRelCheckquery($currentModule,$_REQUEST['return_module'],$_REQUEST['recordid'],$dependency_type);
+		}
+	if($where_relquery == '')
+	{
+		if(isset($_REQUEST['relmod_id']))
+			$where_relquery = getPopupCheckquery($currentModule,$_REQUEST['parent_module'],$_REQUEST['relmod_id']);
+		else
+			$where_relquery = getPopupCheckquery($currentModule,$_REQUEST['task_parent_module'],$_REQUEST['task_relmod_id']);
+	}
+	
         $query = getListQuery($currentModule,$where_relquery);
 }
 			
-
 if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true')
 {
 	list($where, $ustring) = split("#@@#",getWhereCondition($currentModule));
@@ -283,7 +261,6 @@
 {
         $query .= ' and '.$where;
 }
-
 if (isset($_REQUEST['order_by'])) $order_by = $_REQUEST['order_by'];
 if(isset($_REQUEST['sorder']) && $_REQUEST['sorder'] != '')	$sorder = $_REQUEST['sorder'];
 
@@ -294,7 +271,6 @@
 $list_result = $adb->query($query);
 //Retreiving the no of rows
 $noofrows = $adb->num_rows($list_result);
-
 //Retreiving the start value from request
 if(isset($_REQUEST['start']) && $_REQUEST['start'] != '')
 {
@@ -353,8 +329,6 @@
 	$url_string .='&select=enable';
 if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != '')
 	$url_string .='&return_module='.$_REQUEST['return_module'];
-if(isset($_REQUEST['Parent']) && $_REQUEST['Parent'] != '')
-	$url_string .='&Parent='.$_REQUEST['Parent'];
 $listview_header_search=getSearchListHeaderValues($focus,"$currentModule",$url_string,$sorder,$order_by);
 $smarty->assign("SEARCHLISTHEADER", $listview_header_search);
 

Modified: vtigercrm/branches/5.1_jens/Release_Notes.html
==============================================================================
--- vtigercrm/branches/5.1_jens/Release_Notes.html (original)
+++ vtigercrm/branches/5.1_jens/Release_Notes.html Mon Apr 16 12:27:44 2007
@@ -1,5 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html lang="en"><head><title>vtiger CRM 5.0.2 : Release Notes</title>
+<html lang="en"><head><title>vtiger CRM 5 : Release Notes</title>
   
   <style>
 p {  font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
@@ -28,6 +28,145 @@
 <body class="background">
 <p><img src="vtiger.jpg" width="112" height="48"></p>
 <p>&nbsp;</p>
+<h1>vtiger CRM 5.0.3: Release Notes</h1>
+<p><b>Date: January 24, 2007</b></p>
+<p>Hi All,</p>
+<p>Welcome to <b>vtiger CRM. </b>We are happy to annouce the release of vtiger CRM 5.0.3. In this release, we have focussed on the following bug fixes and issues:</p>
+<p>&nbsp;</p>
+<p><b><a name="TOC4" id="TOC3"></a>Table of Contents</b></p>
+<ol>
+  <li><a href="#Summary5">Summary</a></li>
+  <li><a href="#bugfix5">Bug Fixes</a></li>
+  <li><a href="#ki">Known Issues </a></li>
+  <li><a href="#patch">How to update the patch</a></li>
+</ol>
+<h3><a name="summary5"></a>1. Summary</h3>
+<table border="1" cellpadding="5" cellspacing="0" width="73%">
+  <tbody> 
+  <tr bgcolor="#ccccff"> 
+    <td width="5%"><b><font color="#990000">S. No</font></b></td>
+    <td width="40%"><b><font color="#990000">Item</font></b></td>
+    <td width="55%"><b><font color="#990000">Status</font></b></td>
+  </tr>
+  <tr> 
+    <td width="5%">1 </td>
+    <td width="40%">Features</td>
+    <td width="55%">&nbsp; </td>
+  </tr>
+  <tr> 
+    <td width="5%">2</td>
+    <td width="40%">Product Size</td>
+    <td width="55%"><b>Platform Independent - 6.2 MB<br>
+		    Windows (EXE) - 27 MB<br>
+      Linux (BIN) - 43 MB</b></td>
+  </tr>
+  <tr> 
+    <td width="5%">3</td>
+    <td width="40%">Database Migration</td>
+    <td width="55%"><span class="style2">Available for migrating data from 4.2.3 
+      , 4.2.4, or 5.0.1 RC to v5.0.2, 5.0.2 to 5.0.3-rc2</span></td>
+  </tr>
+  <tr> 
+    <td>4</td>
+    <td>Product Download </td>
+    <td><a href="http://www.vtiger.com/index.php?option=com_content&task=view&id=30&Itemid=57" target="_blank">Click 
+      Here</a></td>
+  </tr>
+  <tr> 
+    <td width="5%">5</td>
+    <td width="40%">vtiger CRM - PHP Documentation</td>
+    <td width="55%"> URL: <a href="http://api.vtiger.com/index.php" target="_blank">Click 
+      Here</a></td>
+  </tr>
+  <tr> 
+    <td width="5%">6</td>
+    <td width="40%">Product Documentation</td>
+    <td width="55%"> 
+      <p>Available at the <a href="http://wiki.vtiger.com/index.php" target="_blank">Wiki</a></p>
+    </td>
+  </tr>
+  </tbody> 
+</table>
+<h3><a name="feature"></a>2. Bug Fixes</h3>
+<p>We have fixed nearly 150 issues for the current release.For more information, 
+  please refer our <strong><a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=closed&milestone=5.0.3&order=priority" target="_blank">vtiger 
+  CRM Bug Tracker.</a></strong></p>
+<p><strong><b>The top ten issues fixed are listed below:</b></strong></p>
+<p>1) The issues with Ajax Edit in IE has been fixed.<br>
+  2) The issue with functioning of Tag Cloud in IE has been fixed.<br>
+  3) Shared public activity will be shown in user view<br>
+  4) In the detail view of Invoice and Orders,the issue wherein Products that 
+  are assigned disappears while using ajax edit has been fixed.<br>
+  5) Status column for events in Reports showing &quot;-&quot; has been set right.<br>
+  6) The issue in Change Owner Pop Up, where Group name was missing, has been 
+  fixed in calendar listview<br>
+  7) In 5.0.3, it is possible to view the details of other users by an non-admin 
+  user.<br>
+  8 ) i18N support for custom fields during custom view creation has been dealt 
+  with. <br>
+  9) Relevant contacts will be shown for particular Account / Potential, in the 
+  5.0.3 .<br>
+  10) Quote created from an Account,will be filtered only for specific Account, 
+  and will not henceforth displays all the Potentials for all Companies.<br>
+</p>
+<h3><a name="ki">3</a>. Known Issues</h3>
+<p>We have about 247 issues to be fixed. You can refer our<a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=new&status=assigned&status=reopened&milestone=5.0.3&order=priority"><b>vtiger CRM Bug Tracker </b></a>for the details of these issues.<strong> </strong></p>
+<h3><a name="patch"></a>4.How to update the patch</b> (For users in version 5.0.2 and below)</h3>
+<p> <b><i>Step 1: Kindly refer to the Migration wizard tool in our product under settings tab. </i></b><br>
+<b><i>Step 2: Remove the Following files and directores after applying the patch:</i></b><br>
+<i>Files under modules/Users directory</i><br>
+Announcement.php<br> 
+createrole.php <br>
+listroles.php <br>
+profilePrivileges.php <br>
+RoleDeleteStep1.php <br>
+RoleDetailView.php <br>
+SaveRole.php <br>
+ListProfiles.php <br>
+listinventorynotifications.php <br> 
+SaveInventoryNotification.php <br>
+EditInventoryNotification.php <br>
+listnotificationschedulers.php <br>
+SaveNotification.php <br>
+EditNotification.php <br>
+CreateSharingRule.php <br>
+listwordtemplates.php <br>
+upload.php <br>
+deletewordtemplate.php <br>
+createemailtemplate.php <br>
+deleteemailtemplate.php <br>
+detailviewemailtemplate.php <br>
+editemailtemplate.php <br>
+listemailtemplates.php <br>
+saveemailtemplate.php <br>
+listgroups.php <br>
+createnewgroup.php <br>
+GroupDetailView.php <br>
+ListLoginHistory.php <br>
+UpdateDefaultFieldLevelAccess.php <br>
+DefaultFieldPermissions.php <br>
+EditDefOrgFieldLevelAccess.php  <br>
+OrgSharingDetailView.php <br>
+SaveSharingRule.php <br>
+DefModuleView.php <br>
+AuditTrailList.php <br>
+ShowAuditTrail.php <br>
+AuditTrail.php <br>
+SaveAuditTrail.php <br>
+savetermsandconditions.php <br>
+OrganizationTermsandConditions.php<br>
+createrole.php <br>
+listroles.php <br>
+profilePrivileges.php <br>
+RoleDeleteStep1.php <br>
+RoleDetailView.php <br>
+SaveRole.php <br>
+add2db.php<br>
+downloadfile.php<br>
+ListProfiles.php<br><br>
+
+<b><i>Step 3: Remove the directory install/</i></b>
+</p><center>---------------------------------------------------------------</center></p>
 <h1>vtiger CRM 5.0.2: Release Notes</h1>
 <p><b>Date: October 31, 2006</b></p>
 <p>Hi All,</p>
@@ -66,7 +205,8 @@
   <tr> 
     <td width="5%">3</td>
     <td width="40%">Database Migration</td>
-    <td width="55%"><span class="style2">Available for migrating data from 4.2Patch2/4.2.3/4.2.4/5.0.0 to 5.0.2</span></td>
+    <td width="55%"><span class="style2">Available for migrating data from 4.2Patch2/4.2.3/4.2.4/5.0.0 
+      to 5.0.2</span></td>
   </tr>
   <tr> 
     <td>4</td>
@@ -89,12 +229,13 @@
   </tr>
   </tbody> 
 </table>
-<h3><a name="feature"></a>2. Enhancements</h3>
+<h3><a name="feature"></a>2. Minor Enhancements</h3>
 <ul>
-	<li>Viewing  quantity in stock in the product list view</li>
+  <li>Viewing quantity in stock in the product list view </li>
   <li>Display of Event date in the Activity history</li>
   <li>Facility to add tags within the Tag cloud box.</li>
-  <li>Today's and All views are enabled in the Home page under Upcoming and Pending Activities sections<br>
+  <li>Today's and All views are enabled in the Home page under Upcoming and Pending 
+    activities sections.<br>
   </li>
 </ul>
 <p>&nbsp;</p>
@@ -102,36 +243,32 @@
 <ul>
   <li>Editing a calender entry resets the start and end time (Ticket 2271 )</li>
   <li>Error in custom list view when a custom field related to that view is deleted 
-    has been handled (Ticket 2432)</li>
-  <li>Display of currency rate in campaign page (Ticket 2333 )</li>
-  <li>Formating issues in HTML editor.(Ticket 2290 )</li>
+    has been handled(Ticket 2432)</li>
+  <li>Display of currency rate in campaign page((Ticket 2333 )</li>
+  <li>Formating issues in HTML editor.((Ticket 2290 )</li>
   <li>Using the $contacts-salutationtype$ from Contacts in an email template, 
     the email client does not send the email-this issue has been fixed. (Ticket 
     2273)</li>
-  <li>PHP Version check during installation (Ticket 2329 )</li>
-  <li>Issue in removing contacts from Events and To dos (Ticket 2048 )</li>
+  <li>PHP Version check during installation ((Ticket 2329 )</li>
+  <li>Issue in removing contacts from Events and To dos ((Ticket 2048 )</li>
   <li>Product stock reduced twice - SO and Invoice -quantity (Ticket 1497 )</li>
 </ul>
-<p> For more information, please refer our <strong><a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=closed&group=owner&milestone=5.0.2&order=priority" target="_blank">vtiger CRM Bug Tracker.</a></strong></p>
+<p> For more information, please refer our <strong><a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=closed&group=owner&milestone=5.0.2&order=priority" target="_blank">vtiger 
+  CRM Bug Tracker.</a></strong></p>
 <h3><a name="ki"></a>4. Known Issues</h3>
-<p>We have about 125 issues to be fixed. You can refer our <a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=new&status=assigned&status=reopened&milestone=5.0.3&milestone=5.1.0&type=defect&order=priority"><b>vtiger CRM Bug Tracker</b></a> for the details of these issues.<strong> </strong></p>
-<p>
-<b><a name="patch"></a>5.How to update the patch</b>
+<p>We have about 125 issues to be fixed. You can refer our <a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=new&status=assigned&status=reopened&milestone=5.0.3&milestone=5.1.0&type=defect&order=priority"><b>vtiger 
+  CRM Bug Tracker</b></a> for the details of these issues.<strong> </strong></p>
+<p> <b><a name="patch"></a>5.How to update the patch</b> 
 <p></p>
-<p>To upgrade from the version 5.0.0 or 5.0.1 to the latest version 5.0.2
-<ol>
-	<li> Login as admin user
-	<li> Click on the Settings tab 
-	<li> Go to Migration Wizard. 
-	<li> Use the link 'Click here to apply the 5.0.2 Database changes from 5.0.0/5.0.1'
-</ol>
+<p>To upgrade from the version 5.0. or 5.0.1 to the latest version 5.0.2, please 
+  click on the settings tab in the vtiger CRM client and use the migration wizard. 
 </p>
+<p>You can click on the database changes link to upgrade the patch.</p>
 <p>&nbsp;</p>
-<hr />
-
-<p>&nbsp;</p>
-<h1>vtiger CRM 5.0.1: Release Notes</h1>
-<p><b>Date: Octoer 10, 2006</b></p>
+<p>&nbsp; </p>
+<p>&nbsp; </p>
+<h3>vtiger CRM 5.0.1: Release Notes</h3>
+<p><b>Date: October 9, 2006</b></p>
 <p>Hi All,</p>
 <p>We are happy to bring out yet another release of vtiger CRM, with much more 
   capabilities, interesting code contributions and whole lot of Bug fixes..</p>
@@ -167,7 +304,7 @@
     <td width="5%">3</td>
     <td width="40%">Database Migration</td>
     <td width="55%"><span class="style2">Available for migrating data from 4.2.3 
-		    , 4.2.4, or 5.0 RC to v5.0.1. No database changes from 5.0.0 to 5.0.1</span></td>
+      , 4.2.4, or 5.0 RC to v5.0.1</span></td>
   </tr>
   <tr> 
     <td>4</td>
@@ -192,11 +329,11 @@
 </table>
 <h3><a name="feature"></a>2. Features</h3>
 <ul>
-  <li>UTF-8 Support</li>
+  <li>To Support UTF - 8 in vtiger CRM</li>
 </ul>
 <h3><a name="bugfix5"></a>3. Bug Fixes</h3>
-<p>We have fixed about 71 issues after v5.0 Release and intergrated code contributions 
-  from the community. Please refer our <strong><a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=closed&group=owner&milestone=5.0.1&order=priority" target="_blank">vtiger 
+<p>We have fixed about 68 issues after v5.0 Release and intergrated code contributions 
+  from the community. Please refer our <strong><a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=closed&group=owner&version=5.0.0&order=priority%20" target="_blank">vtiger 
   CRM Bug Tracker.</a></strong></p>
 <h3><a name="ki"></a>4. Known Issues</h3>
 <p>We have about 121 issues to be fixed. You can refer our<a href="http://vtiger.fosslabs.com/cgi-bin/trac.cgi/query?status=new&status=assigned&status=reopened&milestone=5.0.1&milestone=5.0.2&milestone=5.1.0&type=defect&order=priority"> 
@@ -485,6 +622,7 @@
     <td>3</td>
     <td>Security Management support for Emails module</td>
   </tr>
+
   <tr>
     <td>4</td>
     <td>Database table prefix support for a deploying vtiger CRM in other working databases</td>
@@ -2497,6 +2635,7 @@
   <li><a href="#Size">Product Size</a></li>
   <li><a href="#Bugs2">Bug Fixes</a></li>
   <li><a href="#DBMigration2">Database Migration</a></li>
+
   <li><a href="#KI2">Known Issues</a></li>
   <li><a href="#v451tov452">List of Files Changed from V 4.5
 Development 1 to V 4.5 Development 2</a></li>

Modified: vtigercrm/branches/5.1_jens/SendReminder.php
==============================================================================
--- vtigercrm/branches/5.1_jens/SendReminder.php (original)
+++ vtigercrm/branches/5.1_jens/SendReminder.php Mon Apr 16 12:27:44 2007
@@ -32,6 +32,9 @@
 global $log;
 $log =& LoggerManager::getLogger('SendReminder');
 $log->debug(" invoked SendReminder ");
+
+// retrieve the translated strings.
+$app_strings = return_application_language($current_language);
 
 //modified query for recurring events -Jag
  	$query="select vtiger_crmentity.crmid,vtiger_seactivityrel.crmid as setype,vtiger_activity.*,vtiger_activity_reminder.reminder_time,vtiger_activity_reminder.reminder_sent,vtiger_activity_reminder.recurringid,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_activity_reminder on vtiger_activity.activityid=vtiger_activity_reminder.activity_id left outer join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid where DATE_FORMAT(vtiger_activity.date_start,'%Y-%m-%d, %H:%i:%s') >= '".date('Y-m-d')."' and vtiger_crmentity.crmid != 0 and vtiger_activity.eventstatus = 'Planned' and vtiger_activity_reminder.reminder_sent = 0 group by vtiger_activity.activityid,vtiger_recurringevents.recurringid";
@@ -94,10 +97,10 @@
 			$sql = "select active,notificationsubject,notificationbody from vtiger_notificationscheduler where schedulednotificationid=7";
 			$result_main = $adb->query($sql);
 
-			$subject = "[Reminder:".$result_set['activitytype']." @ ".$result_set['date_start']." ".$result_set['time_start']."] ".$adb->query_result($result_main,0,'notificationsubject');
+			$subject = $app_strings['Reminder'].$result_set['activitytype']." @ ".$result_set['date_start']." ".$result_set['time_start']."] ".$adb->query_result($result_main,0,'notificationsubject');
 
 			//Set the mail body/contents here
-			$contents = nl2br($adb->query_result($result_main,0,'notificationbody')) ."\n\n Subject : ".$activity_sub."\n ". $parent_content ." Date & Time : ".$date_start." ".$time_start."\n\n Kindly visit the link for more details on the activity <a href='".$site_URL."/index.php?action=DetailView&module=Calendar&record=".$activity_id."&activity_mode=".$activitymode."'>Click here</a>";
+			$contents = nl2br($adb->query_result($result_main,0,'notificationbody')) ."\n\n ".$app_strings['Subject']." ".$activity_sub."\n ". $parent_content ." ".$app_strings['Date & Time']." ".$date_start." ".$time_start."\n\n ".$app_strings['Visit_Link']." <a href='".$site_URL."/index.php?action=DetailView&module=Calendar&record=".$activity_id."&activity_mode=".$activitymode."'>".$app_strings['Click here']."</a>";
 
 			if(count($to_addr) >=1)
 			{

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ActivityDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ActivityDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ActivityDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -1,486 +1,507 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-<script type="text/javascript" src="modules/{$MODULE}/Activity.js"></script>
-<script type="text/javascript" src="include/js/reflection.js"></script>
-<script src="include/scriptaculous/prototype.js" type="text/javascript"></script>
-<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
-<span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
-   <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
-</span>
-
-<script>
-function tagvalidate()
-{ldelim}
-	if(document.getElementById('txtbox_tagfields').value != '')
-		SaveTag('txtbox_tagfields','{$ID}','{$MODULE}');	
-	else
-	{ldelim}
-		alert("Please enter a tag");
-		return false;
-	{rdelim}
-{rdelim}
-function DeleteTag(id)
-{ldelim}
-	$("vtbusy_info").style.display="inline";
-	Effect.Fade('tag_'+id);
-	new Ajax.Request(
-		'index.php',
-                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-                        method: 'post',
-                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&tagid=" +id,
-                        onComplete: function(response) {ldelim}
-						getTagCloud();
-						$("vtbusy_info").style.display="none";
-                        {rdelim}
-                {rdelim}
-        );
-{rdelim}
-</script>
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<form action="index.php" method="post" name="DetailView" id="form">
-<tr><td>&nbsp;</td>
-	<td>
-                <table cellpadding="0" cellspacing="5" border="0">
-			{include file='DetailViewHidden.tpl'}
-		</table>	
-
-<!-- Contents -->
-<table  border="0" cellpadding="5" cellspacing="0" width="100%" >
-<tr>
-	<td class="lvtHeaderText" style="border-bottom:1px dotted #cccccc">
-	
-		<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
-			<tr><td>		
-				 <span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} -  {$SINGLE_MOD} {$APP.LBL_INFORMATION}</span>&nbsp;&nbsp;<span id="vtbusy_info" style="display:none;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span><span id="vtbusy_info" style="visibility:hidden;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span></td><td>&nbsp;
-			</td></tr>
-			 <tr height=20><td class=small>{$UPDATEINFO}</td></tr>
-		 </table>
-	</td>
-</tr>
-<tr><td>
-<table border="0" cellpadding="0" cellspacing="0" width="100%">
-	<tr>
-		<td valign=top align=left >
-                           <table border=0 cellspacing=0 cellpadding=3 width=100%>
-				<tr>
-					<td align=left>
-					<!-- content cache -->
-					
-					<table border=0 cellspacing=0 cellpadding=0 width=100%>
-			                  <tr>
-					     <td style="padding:3px">
-						     <!-- General details -->
-				                     <table border=0 cellspacing=0 cellpadding=0 width=100%>
-						     <tr nowrap>
-							<td  colspan=4 style="padding:5px">
-								{if $EDIT_DUPLICATE eq 'permitted'}
-                                                                <input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="&nbsp;{$APP.LBL_EDIT_BUTTON_LABEL}&nbsp;">&nbsp;
-								{/if}
-							</td>
-							<td width=50% align=right>
-							{if $EDIT_DUPLICATE eq 'permitted'}
-                                                                <input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
-                                                        {/if}
-							{if $DELETE eq 'permitted'}
-                                                                <input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; {if $VIEWTYPE eq 'calendar'} this.form.return_action.value='index'; {else} this.form.return_action.value='ListView'; {/if}  this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
-                                                         {/if}
-
-							</td>
-						     </tr>
-						     </table>
-						     {foreach key=header item=detail from=$BLOCKS}
-						     <table border=0 cellspacing=0 cellpadding=5 width=100% class="small">
-						     	<tr>{strip}
-						     		<td colspan=4 class="tableHeading">
-									<b>{$header}</b>
-								</td>{/strip}
-					             	</tr>
-						     </table>
-						     {/foreach}
-						     {if $ACTIVITYDATA.activitytype neq 'Task'}	
-							 <!-- display of fields starts -->
-						     <table border=0 cellspacing=0 cellpadding=5 width=100% >
-               						 <tr>
-								{if $LABEL.activitytype neq ''}
-								<td class="cellLabel" width="20%" align="right"><b>{$MOD.LBL_EVENTTYPE}</b></td>
-								<td class="cellInfo" width="30%"align="left">{$ACTIVITYDATA.activitytype}</td>
-								{/if}
-								{if $LABEL.visibility neq ''}
-								<td class="cellLabel" width="20%" align="right"><b>{$LABEL.visibility}</b></td>
-                                                                <td class="cellInfo" width="30%" align="left" >{$ACTIVITYDATA.visibility}</td>
-								{/if}
-							 </tr>
-							 <tr>
-                        					<td class="cellLabel" align="right"><b>{$MOD.LBL_EVENTNAME}</b></td>
-					                        <td class="cellInfo" colspan=3 align="left" >{$ACTIVITYDATA.subject}</td>
-             						 </tr>
-							 {if $LABEL.description neq ''}
-							 <tr>
-								<td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.description}</b></td>
-								<td class="cellInfo" valign="top" align="left" colspan="3" height="60px">{$ACTIVITYDATA.description}</td>
-							 </tr>
-							{/if}
-							 <tr>
-								{if $LABEL.eventstatus neq ''}
-								<td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.eventstatus}</b></td>
-								<td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.eventstatus}</td>
-								{/if}
-								{if $LABEL.assigned_user_id neq ''}
-								<td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.assigned_user_id}</b></td>
-								<td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.assigned_user_id}</td>
-								{/if}
-                                                         </tr>
-							 <tr>
-								{if $LABEL.taskpriority neq ''}
-                                                                <td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.taskpriority}</b></td>
-                                                                <td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.taskpriority}</td>
-								{/if}
-								{if $LABEL.sendnotification neq ''}
-                                                                <td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.sendnotification}</b></td>
-                                                                <td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.sendnotification}</td>
-								{/if}
-                                                         </tr>
-                                                         <tr>
-                                                                <td class="cellLabel" align="right" nowrap valign="top"align="right">{if $LABEL.createdtime neq ''}<b>{$LABEL.createdtime}</b>{/if}</td>
-                                                                <td class="cellInfo" align="left" nowrap valign="top">{if $LABEL.createdtime neq ''}{$ACTIVITYDATA.createdtime}{/if}</td>
-                                                                <td class="cellLabel" align="right" nowrap valign="top"align="right">{if $LABEL.modifiedtime neq ''}<b>{$LABEL.modifiedtime}</b>{/if}</td>
-                                                                <td class="cellInfo" align="left" nowrap valign="top">{if $LABEL.modifiedtime neq ''}{$ACTIVITYDATA.modifiedtime}{/if}</td>
-                                                         </tr>
-						     </table>
-						     <table border=0 cellspacing=1 cellpadding=0 width=100%>
-							<tr><td width=50% valign=top >
-								<table border=0 cellspacing=0 cellpadding=2 width=100%>
-                                                                        <tr><td class="mailSubHeader"><b>{$MOD.LBL_EVENTSTAT}</b></td></tr>
-                                                                        <tr><td class=small>{$ACTIVITYDATA.starthr}:{$ACTIVITYDATA.startmin}{$ACTIVITYDATA.startfmt}</td></tr>
-                                                                        <tr><td class=small>{$ACTIVITYDATA.date_start}</td></tr>
-                                                                </table></td>
-							<td width=50% valign=top >
-                                                                <table border=0 cellspacing=0 cellpadding=2 width=100%>
-                                                                        <tr><td  class="mailSubHeader"><b>{$MOD.LBL_EVENTEDAT}</b></td></tr>
-                                                                        <tr><td class=small>{$ACTIVITYDATA.endhr}:{$ACTIVITYDATA.endmin}{$ACTIVITYDATA.endfmt}</td></tr>
-                                                                        <tr><td class=small>{$ACTIVITYDATA.due_date}</td></tr>
-                                                                </table>
-                                                        </td></tr>
-                                                     </table>
-						     <br>
-					             <table border=0 cellspacing=0 cellpadding=0 width=100% align=center>
-                					 <tr>
-                        					<td>
-                         				        	<table border=0 cellspacing=0 cellpadding=3 width=100%>
-                             						<tr>
-                                        					<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
-					                                        <td id="cellTabInvite" class="dvtSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');dispLayer('addEventInviteUI');ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_INVITE}</a></td>
-										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-										<td id="cellTabAlarm" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','on');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');dispLayer('addEventAlarmUI');ghide('addEventInviteUI');ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_REMINDER}</a></td>
-										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-										<td id="cellTabRepeat" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','on');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');ghide('addEventInviteUI');dispLayer('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_REPEAT}</a></td>
-										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-										<td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','on');ghide('addEventAlarmUI');ghide('addEventInviteUI');dispLayer('addEventRelatedtoUI');ghide('addEventRepeatUI');">{$MOD.LBL_LIST_RELATED_TO}</a></td>
-										<td class="dvtTabCache" style="width:100%">&nbsp;</td>
-									</tr>
-									</table>
-								</td>
-							 </tr>
-							
-							 <tr>
-								<td width=100% valign=top align=left class="dvtContentSpace" style="padding:10px;height:120px">
-									<!-- Invite UI -->
-									<DIV id="addEventInviteUI" style="display:block;width:100%">
-									<table width="100%" cellpadding="5" cellspacing="0" border="0">
-										<tr>
-                                                                                        <td width="30%" valign="top" align=right><b>{$MOD.LBL_USERS}</b></td>
-                                                                                        <td width="70%" align=left valign="top" >
-												{foreach item=username key=userid from=$INVITEDUSERS}
-                                                                                        	        {$username.3}<br>
-                                                                                                {/foreach}
-											</td>
-                                                                                </tr>
-									</table>
-									</DIV>
-									<!-- Reminder UI -->
-					                                <DIV id="addEventAlarmUI" style="display:none;width:100%">
-									{if $LABEL.reminder_time != ''}
-									<table width="100%" cellpadding="5" cellspacing="0" border="0">
-                                                                                <tr>
-                                                                                        <td width="30%" align=right><b>{$MOD.LBL_SENDREMINDER}</b></td>
-                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.set_reminder}</td>
-                                                                                </tr>
-										{if $ACTIVITYDATA.set_reminder != 'No'}
-										<tr>
-                                                                                        <td width="30%" align=right><b>{$MOD.LBL_RMD_ON}</b></td>
-											<td width="70%" align=left>{$ACTIVITYDATA.reminder_str}</td>
-										</tr>
-										{/if}
-                                                                        </table>
-									{/if}
-									</DIV>
-									<!-- Repeat UI -->
-                                					<div id="addEventRepeatUI" style="display:none;width:100%">
-									{if $LABEL.recurringtype neq ''}
-									<table width="100%" cellpadding="5" cellspacing="0" border="0">
-										<tr>
-                                                                                        <td width="30%" align=right><b>{$MOD.LBL_ENABLE_REPEAT}</b></td>
-                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.recurringcheck}</td>
-                                                                                </tr>
-										{if $ACTIVITYDATA.recurringcheck != 'No'}
-										<tr>
-											<td width="30%" align=right>&nbsp;</td>
-											<td>{$MOD.LBL_REPEATEVENT}&nbsp;{$ACTIVITYDATA.repeat_frequency}&nbsp;{$MOD[$ACTIVITYDATA.recurringtype]}</td>
-										</tr>
-										<tr>
-                                                                                        <td width="30%" align=right>&nbsp;</td>
-                                                                                        <td>{$ACTIVITYDATA.repeat_str}</td>
-                                                                                </tr>
-										{/if}
-									</table>
-									{/if}
-									</div>
-									<!-- Relatedto UI -->
-									<div id="addEventRelatedtoUI" style="display:none;width:100%">
-									<table width="100%" cellpadding="5" cellspacing="0" border="0">
-										{if $LABEL.parent_id neq ''}
-										<tr>
-											<td width="30%" align=right valign="top"><b>{$LABEL.parent_id}</b></td>
-											<td width="70%" align=left valign="top">{$ACTIVITYDATA.parent_name}</td>
-										</tr>
-										{/if}
-										<tr>
-											<td width="30%" valign="top" align=right><b>{$MOD.LBL_CONTACT_NAME}</b></td>	
-											<td width="70%" valign="top" align=left>
-											{foreach item=contactname key=cntid from=$CONTACTS}
-	                                                                                {$contactname.0}&nbsp;{$contactname.1}<br>
-                                                                                        {/foreach}
-										</tr>
-									</table>
-									</div>
-								</td>
-                					 </tr>
-						     </table>
-						    {else}
-							<!-- detailed view of a ToDo -->
-					 	     <table border="0" cellpadding="5" cellspacing="0" width="100%">
-							<tr>
-								<td class="cellLabel" width="20%" align="right"><b>{$MOD.LBL_TODO}</b></td>
-								<td class="cellInfo" width="80%" align="left">{$ACTIVITYDATA.subject}</td>
-							</tr>
-							{if $LABEL.description neq ''}
-							<tr>
-								<td class="cellLabel" align="right" valign="top"><b>{$LABEL.description}</b></td>
-                                                                <td class="cellInfo" align="left" colspan="3" valign="top" height="60px">{$ACTIVITYDATA.description}</td>
-                					</tr>
-							{/if}
-							<tr>
-                        					<td colspan="2" align="center" style="padding:0px">
-                                				<table border="0" cellpadding="5" cellspacing="1" width="100%" >
-                                       					<tr>
-                                                				<td class="cellLabel" width=33% align="left">{if $LABEL.taskstatus neq ''}<b>{$LABEL.taskstatus}</b>{/if}</td>
-										<td class="cellLabel" width=33% align="left">{if $LABEL.taskpriority neq ''}<b>{$LABEL.taskpriority}</b>{/if}</td>
-										<td class="cellLabel" width=34% align="left">{if $LABEL.assigned_user_id neq ''}<b>{$LABEL.assigned_user_id}</b>{/if}</td>
-									</tr>
-									<tr>
-                                                				<td class="cellInfo" align="left" valign="top">{if $LABEL.taskstatus neq ''}{$ACTIVITYDATA.taskstatus}{/if}</td>
-										<td class="cellInfo" align="left" valign="top">{if $LABEL.taskpriority neq ''}{$ACTIVITYDATA.taskpriority}{/if}</td>
-										<td class="cellInfo" align="left" valign="top">{if $LABEL.taskpriority neq ''}{$ACTIVITYDATA.assigned_user_id}{/if}</td>
-									</tr>
-								</table>
-								</td>
-							</tr>
-						     </table>
-						     <table border="0" cellpadding="0" cellspacing="0" width="100%" align=center>
-	                                                <tr><td width=50% valign=top >
-								<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
-									<tr><td class="mailSubHeader" align=left ><b>{$MOD.LBL_TIMEDATE}</b></td></tr>
-									<tr><td class="small" >{$ACTIVITYDATA.starthr}:{$ACTIVITYDATA.startmin}{$ACTIVITYDATA.startfmt}</td></tr>
-									<tr><td class="cellInfo" style="padding-left:0px">{$ACTIVITYDATA.date_start}</td></tr>
-								</table>
-							</td>
-							<td width=50% valign="top">
-								<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
-									<tr><td class="mailSubHeader"><b>{$LABEL.due_date}</b></td></tr>
-									<tr><td class="small">{$ACTIVITYDATA.due_date}</td></tr>
-									<tr><td class="cellInfo">&nbsp;</td></tr>
-								</table>
-							</td>
-						     </table>
-						     <table border=0 cellspacing=0 cellpadding=5 width=100% >
-							<tr>
-								<td class="cellLabel" align=right nowrap width=20%>{if $LABEL.createdtime neq ''}<b>{$LABEL.createdtime}</b>{/if}</td>
-                                                                <td class="cellInfo" align=left nowrap width=30%>{if $LABEL.createdtime neq ''}{$ACTIVITYDATA.createdtime}{/if}</td>
-                                                                <td class="cellLabel" align=right nowrap width=20%>{if $LABEL.modifiedtime neq ''}<b>{$LABEL.modifiedtime}</b>{/if}</td>
-                                                                <td class="cellInfo" align=left  nowrap width=30%>{if $LABEL.modifiedtime neq ''}{$ACTIVITYDATA.modifiedtime}{/if}</td>
-                                                        </tr>
-                                                     </table>
-						     <br>
-						     <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
-							<tr>
-								<td>
-									<table border="0" cellpadding="3" cellspacing="0" width="100%">
-									<tr>
-										<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
-                                                                                <td id="cellTabInvite" class="dvtSelectedCell" align="center" nowrap="nowrap"><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabRelatedto','off');dispLayer('addTaskAlarmUI');ghide('addTaskRelatedtoUI');">{$MOD.LBL_NOTIFICATION}</td></a>
-										<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;
-                                                                                <td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabRelatedto','on');dispLayer('addTaskRelatedtoUI');ghide('addTaskAlarmUI');">{$MOD.LBL_RELATEDTO}</a></td>
-
-                                                                                <td class="dvtTabCache" style="width: 100%;">&nbsp;</td>
-									</tr>
-									</table>
-								</td>
-							</tr>
-							<tr>
-								<td width=100% valign=top align=left class="dvtContentSpace" style="padding:10px;height:120px">
-                                                                <!-- Notification UI -->
-                                                                        <DIV id="addTaskAlarmUI" style="display:block;width:100%">
-									{if $LABEL.sendnotification neq ''}
-                                                                        <table width="100%" cellpadding="5" cellspacing="0" border="0">
-                                                                                <tr>
-                                                                                        <td width="30%" align=right><b>{$MOD.LBL_SENDNOTIFICATION}</b></td>
-                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.sendnotification}</td>
-                                                                                </tr>
-                                                                        </table>
-									{/if}
-                                                                        </DIV>
-									<div id="addTaskRelatedtoUI" style="display:none;width:100%">
-									{if $LABEL.parent_id neq ''}
-                                                                        <table width="100%" cellpadding="5" cellspacing="0" border="0">
-                                                                                <tr>
-                                                                                        <td width="30%" align=right><b>{$LABEL.parent_id}</b></td>
-                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.parent_name}</td>
-                                                                                </tr>
-                                                                                <tr>
-                                                                                        <td align=right><b>{$MOD.LBL_CONTACT_NAME}</b></td>
-                                                                                        <td align=left>{$ACTIVITYDATA.contact_id}</td>
-                                                                                </tr>
-                                                                        </table>
-									{/if}
-                                                                        </div>
-								</td>
-							</tr>
-						     </table>
-						     {/if}
-
-                     	                      </td>
-					   </tr>
-                </tr>
-		<tr>
-			<td style="padding:10px">
-		           <table border=0 cellspacing=0 cellpadding=0 width=100%>
-				     {strip}<tr nowrap>
-							<td  colspan=4 style="padding:5px">
-								{if $EDIT_DUPLICATE eq 'permitted'}
-                                                                <input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="&nbsp;{$APP.LBL_EDIT_BUTTON_LABEL}&nbsp;">&nbsp;
-								{/if}
-							</td>
-							<td align=right>
-								{if $EDIT_DUPLICATE eq 'permitted'}
-                                                                <input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
-                                                                {/if}
-								{if $DELETE eq 'permitted'}
-                                                                <input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
-                                                                {/if}
-
-							</td>
-					</tr>{/strip}
-			   </table>
-			</td>
-		</tr>
-	</table>
-	</td>
-	<td width=22% valign=top style="border-left:2px dashed #cccccc;padding:13px">
-						<!-- right side relevant info -->
-
-		<!-- Tag cloud display -->
-		<table border=0 cellspacing=0 cellpadding=0 width=100% class="tagCloud">
-		<tr>
-			<td class="tagCloudTopBg"><img src="{$IMAGE_PATH}tagCloudName.gif" border=0></td>
-		</tr>
-		<tr>
-                      	<td><div id="tagdiv" style="display:visible;"><input class="textbox"  type="text" id="txtbox_tagfields" name="textbox_First Name" value="" style="width:100px;margin-left:5px;"></input>&nbsp;&nbsp;<input name="button_tagfileds" type="button" class="crmbutton small save" value="{$APP.LBL_TAG_IT}" onclick="return tagvalidate()"/></div></td>
-                </tr>
-		<tr>
-			<td class="tagCloudDisplay" valign=top> <span id="tagfields">{$ALL_TAG}</span></td>
-		</tr>
-		</table>
-		<!-- End Tag cloud display -->
-			<!-- Mail Merge-->
-				<br>
-				{if $MERGEBUTTON eq 'permitted'}
-  				<table border=0 cellspacing=0 cellpadding=0 width=100% class="rightMailMerge">
-      				<tr>
-      					   <td class="rightMailMergeHeader"><b>{$WORDTEMPLATEOPTIONS}</b></td>
-      				</tr>
-      				<tr style="height:25px">
-      						<td class="rightMailMergeContent">
-          						<select name="mergefile">{foreach key=templid item=tempflname from=$TOPTIONS}<option value="{$templid}">{$tempflname}</option>{/foreach}</select>
-          						<input class="crmbutton small create" value="{$APP.LBL_MERGE_BUTTON_LABEL}" onclick="this.form.action.value='Merge';" type="submit"></input>
-      					  </td>
-      				</tr>
-  				</table>
-				{/if}
-			</td>
-		</tr>
-		</table>
-		
-			
-			
-		
-		</div>
-		<!-- PUBLIC CONTENTS STOPS-->
-	</td>
-</tr>
-</table>
-
-{if $MODULE eq 'Products'}
-<script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script>
-<script language="JavaScript" type="text/javascript">Carousel();</script>
-{/if}
-
-<script>
-function getTagCloud()
-{ldelim}
-new Ajax.Request(
-        'index.php',
-        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-        method: 'post',
-        postBody: 'module={$MODULE}&action={$MODULE}Ajax&file=TagCloud&ajxaction=GETTAGCLOUD&recordid={$ID}',
-        onComplete: function(response) {ldelim}
-                                $("tagfields").innerHTML=response.responseText;
-                                $("txtbox_tagfields").value ='';
-                        {rdelim}
-        {rdelim}
-);
-{rdelim}
-getTagCloud();
-</script>
-<!-- added for validation -->
-<script language="javascript">
-  var fieldname = new Array({$VALIDATION_DATA_FIELDNAME});
-  var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL});
-  var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE});
-</script>
-</td>
-
-</tr></table></form>
-</td></tr></table>
-</td></tr></table>
-</td></tr></table>
-        </td></tr></table>
-        </td></tr></table>
-        </div>
-        </td>
-        <td valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-        </tr>
-        </table>
-
-
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+<script type="text/javascript" src="modules/{$MODULE}/Calendar.js"></script>
+<script type="text/javascript" src="include/js/reflection.js"></script>
+<script src="include/scriptaculous/prototype.js" type="text/javascript"></script>
+<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
+<span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
+   <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
+</span>
+
+<script>
+function tagvalidate()
+{ldelim}
+	if(document.getElementById('txtbox_tagfields').value != '')
+		SaveTag('txtbox_tagfields','{$ID}','{$MODULE}');	
+	else
+	{ldelim}
+		alert("{$APP.PLEASE_ENTER_TAG}");
+		return false;
+	{rdelim}
+{rdelim}
+function DeleteTag(id,recordid)
+{ldelim}
+        $("vtbusy_info").style.display="inline";
+        Effect.Fade('tag_'+id);
+        new Ajax.Request(
+                'index.php',
+                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                        method: 'post',
+                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&recordid="+recordid+"&tagid=" +id,
+                        onComplete: function(response) {ldelim}
+                                                getTagCloud();
+                                                $("vtbusy_info").style.display="none";
+                        {rdelim}
+                {rdelim}
+        );
+{rdelim}
+
+</script>
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<form action="index.php" method="post" name="DetailView" id="form">
+<tr><td>&nbsp;</td>
+	<td>
+                <table cellpadding="0" cellspacing="5" border="0">
+			{include file='DetailViewHidden.tpl'}
+		</table>	
+
+<!-- Contents -->
+<table  border="0" cellpadding="5" cellspacing="0" width="100%" >
+<tr>
+	<td class="lvtHeaderText" style="border-bottom:1px dotted #cccccc">
+	
+		<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
+			<tr><td>		
+				 <span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} -  {$SINGLE_MOD} {$APP.LBL_INFORMATION}</span>&nbsp;&nbsp;<span id="vtbusy_info" style="display:none;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span><span id="vtbusy_info" style="visibility:hidden;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span></td><td>&nbsp;
+			</td></tr>
+			 <tr height=20><td class=small>{$UPDATEINFO}</td></tr>
+		 </table>
+	</td>
+</tr>
+<tr><td>
+<table border="0" cellpadding="0" cellspacing="0" width="100%">
+	<tr>
+		<td valign=top align=left >
+                           <table border=0 cellspacing=0 cellpadding=3 width=100%>
+				<tr>
+					<td align=left>
+					<!-- content cache -->
+					
+					<table border=0 cellspacing=0 cellpadding=0 width=100%>
+			                  <tr>
+					     <td style="padding:3px">
+						     <!-- General details -->
+				                     <table border=0 cellspacing=0 cellpadding=0 width=100%>
+						     <tr nowrap>
+							<td  colspan=4 style="padding:5px">
+								{if $EDIT_DUPLICATE eq 'permitted'}
+                                                                <input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="&nbsp;{$APP.LBL_EDIT_BUTTON_LABEL}&nbsp;">&nbsp;
+								{/if}
+							</td>
+							<td width=50% align=right>
+							{if $EDIT_DUPLICATE eq 'permitted'}
+                                                                <input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
+                                                        {/if}
+							{if $DELETE eq 'permitted'}
+                                                                <input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; {if $VIEWTYPE eq 'calendar'} this.form.return_action.value='index'; {else} this.form.return_action.value='ListView'; {/if}  this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
+                                                         {/if}
+
+							</td>
+						     </tr>
+						     </table>
+						     {foreach key=header item=detail from=$BLOCKS}
+						     <table border=0 cellspacing=0 cellpadding=5 width=100% class="small">
+						     	<tr>{strip}
+						     		<td colspan=4 class="tableHeading">
+									<b>{$header}</b>
+								</td>{/strip}
+					             	</tr>
+						     </table>
+						     {/foreach}
+						     {if $ACTIVITYDATA.activitytype neq 'Task'}	
+							 <!-- display of fields starts -->
+						     <table border=0 cellspacing=0 cellpadding=5 width=100% >
+               						 <tr>
+								{if $LABEL.activitytype neq ''}
+								{assign var=type value=$ACTIVITYDATA.activitytype}
+								<td class="cellLabel" width="20%" align="right"><b>{$MOD.LBL_EVENTTYPE}</b></td>
+								<td class="cellInfo" width="30%"align="left">{$MOD.$type}</td>
+								{/if}
+								{if $LABEL.visibility neq ''}
+								{assign var=vblty value=$ACTIVITYDATA.visibility}
+								<td class="cellLabel" width="20%" align="right"><b>{$LABEL.visibility}</b></td>
+                                                                <td class="cellInfo" width="30%" align="left" >{$MOD.$vblty}</td>
+								{/if}
+							 </tr>
+							 <tr>
+                        					<td class="cellLabel" align="right"><b>{$MOD.LBL_EVENTNAME}</b></td>
+					                        <td class="cellInfo" colspan=3 align="left" >{$ACTIVITYDATA.subject}</td>
+             						 </tr>
+							 {if $LABEL.description neq ''}
+							 <tr>
+								<td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.description}</b></td>
+								<td class="cellInfo" valign="top" align="left" colspan="3" height="60px">{$ACTIVITYDATA.description}&nbsp;</td>
+							 </tr>
+							{/if}
+							{if $LABEL.location neq ''}
+							<tr>
+								<td class="cellLabel" align="right" valign="top"><b>{$LABEL.location}</b></td>
+								<td class="cellInfo" colspan=3 align="left" >{$ACTIVITYDATA.location}&nbsp;</td>
+							</tr>
+							{/if}	
+							 <tr>
+								{if $LABEL.eventstatus neq ''}
+								<td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.eventstatus}</b></td>
+								<td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.eventstatus}</td>
+								{/if}
+								{if $LABEL.assigned_user_id neq ''}
+								<td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.assigned_user_id}</b></td>
+								<td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.assigned_user_id}</td>
+								{/if}
+                                                         </tr>
+							{if $LABEL.taskpriority neq '' || $LABEL.sendnotification neq ''}
+							 <tr>
+								{if $LABEL.taskpriority neq ''}
+                                                                <td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.taskpriority}</b></td>
+                                                                <td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.taskpriority}</td>
+								{/if}
+								{if $LABEL.sendnotification neq ''}
+                                                                <td class="cellLabel" align="right" nowrap valign="top"><b>{$LABEL.sendnotification}</b></td>
+                                                                <td class="cellInfo" align="left" nowrap valign="top">{$ACTIVITYDATA.sendnotification}</td>
+								{/if}
+                                                         </tr>
+							{/if}
+							{if $LABEL.createdtime neq '' || $LABEL.modifiedtime neq ''}
+                                                         <tr>
+                                                                <td class="cellLabel" align="right" nowrap valign="top"align="right">{if $LABEL.createdtime neq ''}<b>{$LABEL.createdtime}</b>{/if}</td>
+                                                                <td class="cellInfo" align="left" nowrap valign="top">{if $LABEL.createdtime neq ''}{$ACTIVITYDATA.createdtime}{/if}</td>
+                                                                <td class="cellLabel" align="right" nowrap valign="top"align="right">{if $LABEL.modifiedtime neq ''}<b>{$LABEL.modifiedtime}</b>{/if}</td>
+                                                                <td class="cellInfo" align="left" nowrap valign="top">{if $LABEL.modifiedtime neq ''}{$ACTIVITYDATA.modifiedtime}{/if}</td>
+                                                         </tr>
+							{/if}
+						     </table>
+						     <table border=0 cellspacing=1 cellpadding=0 width=100%>
+							<tr><td width=50% valign=top >
+								<table border=0 cellspacing=0 cellpadding=2 width=100%>
+                                                                        <tr><td class="mailSubHeader"><b>{$MOD.LBL_EVENTSTAT}</b></td></tr>
+                                                                        <tr><td class=small>{$ACTIVITYDATA.starthr}:{$ACTIVITYDATA.startmin}{$ACTIVITYDATA.startfmt}</td></tr>
+                                                                        <tr><td class=small>{$ACTIVITYDATA.date_start}</td></tr>
+                                                                </table></td>
+							<td width=50% valign=top >
+                                                                <table border=0 cellspacing=0 cellpadding=2 width=100%>
+                                                                        <tr><td  class="mailSubHeader"><b>{$MOD.LBL_EVENTEDAT}</b></td></tr>
+                                                                        <tr><td class=small>{$ACTIVITYDATA.endhr}:{$ACTIVITYDATA.endmin}{$ACTIVITYDATA.endfmt}</td></tr>
+                                                                        <tr><td class=small>{$ACTIVITYDATA.due_date}</td></tr>
+                                                                </table>
+                                                        </td></tr>
+                                                     </table>
+						     <br>
+					             <table border=0 cellspacing=0 cellpadding=0 width=100% align=center>
+                					 <tr>
+                        					<td>
+                         				        	<table border=0 cellspacing=0 cellpadding=3 width=100%>
+                             						<tr>
+                                        					<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
+					                                        <td id="cellTabInvite" class="dvtSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');dispLayer('addEventInviteUI');ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_INVITE}</a></td>
+										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+										<td id="cellTabAlarm" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','on');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');dispLayer('addEventAlarmUI');ghide('addEventInviteUI');ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_REMINDER}</a></td>
+										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+										<td id="cellTabRepeat" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','on');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');ghide('addEventInviteUI');dispLayer('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_REPEAT}</a></td>
+										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+										<td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','on');ghide('addEventAlarmUI');ghide('addEventInviteUI');dispLayer('addEventRelatedtoUI');ghide('addEventRepeatUI');">{$MOD.LBL_LIST_RELATED_TO}</a></td>
+										<td class="dvtTabCache" style="width:100%">&nbsp;</td>
+									</tr>
+									</table>
+								</td>
+							 </tr>
+							
+							 <tr>
+								<td width=100% valign=top align=left class="dvtContentSpace" style="padding:10px;height:120px">
+									<!-- Invite UI -->
+									<DIV id="addEventInviteUI" style="display:block;width:100%">
+									<table width="100%" cellpadding="5" cellspacing="0" border="0">
+										<tr>
+                                                                                        <td width="30%" valign="top" align=right><b>{$MOD.LBL_USERS}</b></td>
+                                                                                        <td width="70%" align=left valign="top" >
+												{foreach item=username key=userid from=$INVITEDUSERS}
+                                                                                        	        {$username}<br>
+                                                                                                {/foreach}
+											</td>
+                                                                                </tr>
+									</table>
+									</DIV>
+									<!-- Reminder UI -->
+					                                <DIV id="addEventAlarmUI" style="display:none;width:100%">
+									{if $LABEL.reminder_time != ''}
+									<table width="100%" cellpadding="5" cellspacing="0" border="0">
+                                                                                <tr>
+                                                                                        <td width="30%" align=right><b>{$MOD.LBL_SENDREMINDER}</b></td>
+                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.set_reminder}</td>
+                                                                                </tr>
+										{if $ACTIVITYDATA.set_reminder != 'No'}
+										<tr>
+                                                                                        <td width="30%" align=right><b>{$MOD.LBL_RMD_ON}</b></td>
+											<td width="70%" align=left>{$ACTIVITYDATA.reminder_str}</td>
+										</tr>
+										{/if}
+                                                                        </table>
+									{/if}
+									</DIV>
+									<!-- Repeat UI -->
+                                					<div id="addEventRepeatUI" style="display:none;width:100%">
+									{if $LABEL.recurringtype neq ''}
+									<table width="100%" cellpadding="5" cellspacing="0" border="0">
+										<tr>
+                                                                                        <td width="30%" align=right><b>{$MOD.LBL_ENABLE_REPEAT}</b></td>
+                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.recurringcheck}</td>
+                                                                                </tr>
+										{if $ACTIVITYDATA.recurringcheck != 'No'}
+										<tr>
+											<td width="30%" align=right>&nbsp;</td>
+											<td>{$MOD.LBL_REPEATEVENT}&nbsp;{$ACTIVITYDATA.repeat_frequency}&nbsp;{$MOD[$ACTIVITYDATA.recurringtype]}</td>
+										</tr>
+										<tr>
+                                                                                        <td width="30%" align=right>&nbsp;</td>
+                                                                                        <td>{$ACTIVITYDATA.repeat_str}</td>
+                                                                                </tr>
+										{/if}
+									</table>
+									{/if}
+									</div>
+									<!-- Relatedto UI -->
+									<div id="addEventRelatedtoUI" style="display:none;width:100%">
+									<table width="100%" cellpadding="5" cellspacing="0" border="0">
+										{if $LABEL.parent_id neq ''}
+										<tr>
+											<td width="30%" align=right valign="top"><b>{$LABEL.parent_id}</b></td>
+											<td width="70%" align=left valign="top">{$ACTIVITYDATA.parent_name}</td>
+										</tr>
+										{/if}
+										<tr>
+											<td width="30%" valign="top" align=right><b>{$MOD.LBL_CONTACT_NAME}</b></td>	
+											<td width="70%" valign="top" align=left>
+											{foreach item=contactname key=cntid from=$CONTACTS}
+	                                                                                {$contactname.0}&nbsp;{$contactname.1}<br>
+                                                                                        {/foreach}
+										</tr>
+									</table>
+									</div>
+								</td>
+                					 </tr>
+						     </table>
+						    {else}
+							<!-- detailed view of a ToDo -->
+					 	     <table border="0" cellpadding="5" cellspacing="0" width="100%">
+							<tr>
+								<td class="cellLabel" width="20%" align="right"><b>{$MOD.LBL_TODO}</b></td>
+								<td class="cellInfo" width="80%" align="left">{$ACTIVITYDATA.subject}</td>
+							</tr>
+							{if $LABEL.description neq ''}
+							<tr>
+								<td class="cellLabel" align="right" valign="top"><b>{$LABEL.description}</b></td>
+                                                                <td class="cellInfo" align="left" colspan="3" valign="top" height="60px">{$ACTIVITYDATA.description}&nbsp;</td>
+                					</tr>
+							{/if}
+							<tr>
+                        					<td colspan="2" align="center" style="padding:0px">
+                                				<table border="0" cellpadding="5" cellspacing="1" width="100%" >
+                                       					<tr>
+										{if $LABEL.taskstatus neq ''}
+                                                					<td class="cellLabel" width=33% align="left"><b>{$LABEL.taskstatus}</b></td>
+										{/if}
+										{if $LABEL.taskpriority neq ''}
+											<td class="cellLabel" width=33% align="left"><b>{$LABEL.taskpriority}</b></td>
+										{/if}
+										<td class="cellLabel" width=34% align="left"><b>{$LABEL.assigned_user_id}</b></td>
+									</tr>
+									<tr>
+										{if $LABEL.taskstatus neq ''}
+                                                					<td class="cellInfo" align="left" valign="top">{$ACTIVITYDATA.taskstatus}</td>
+										{/if}
+										{if $LABEL.taskpriority neq ''}		
+											<td class="cellInfo" align="left" valign="top">{$ACTIVITYDATA.taskpriority}</td>
+										{/if}
+										<td class="cellInfo" align="left" valign="top">{$ACTIVITYDATA.assigned_user_id}</td>
+									</tr>
+								</table>
+								</td>
+							</tr>
+						     </table>
+						     <table border="0" cellpadding="0" cellspacing="0" width="100%" align=center>
+	                                                <tr><td width=50% valign=top >
+								<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+									<tr><td class="mailSubHeader" align=left ><b>{$MOD.LBL_TIMEDATE}</b></td></tr>
+									<tr><td class="small" >{$ACTIVITYDATA.starthr}:{$ACTIVITYDATA.startmin}{$ACTIVITYDATA.startfmt}</td></tr>
+									<tr><td class="cellInfo" style="padding-left:0px">{$ACTIVITYDATA.date_start}</td></tr>
+								</table>
+							</td>
+							<td width=50% valign="top">
+								<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+									<tr><td class="mailSubHeader"><b>{$LABEL.due_date}</b></td></tr>
+									<tr><td class="small">{$ACTIVITYDATA.due_date}</td></tr>
+									<tr><td class="cellInfo">&nbsp;</td></tr>
+								</table>
+							</td>
+						     </table>	
+						     <table border=0 cellspacing=0 cellpadding=5 width=100% >
+							<tr>
+								<td class="cellLabel" align=right nowrap width=20%>{if $LABEL.createdtime neq ''}<b>{$LABEL.createdtime}</b>{/if}</td>
+                                                                <td class="cellInfo" align=left nowrap width=30%>{if $LABEL.createdtime neq ''}{$ACTIVITYDATA.createdtime}{/if}</td>
+                                                                <td class="cellLabel" align=right nowrap width=20%>{if $LABEL.modifiedtime neq ''}<b>{$LABEL.modifiedtime}</b>{/if}</td>
+                                                                <td class="cellInfo" align=left  nowrap width=30%>{if $LABEL.modifiedtime neq ''}{$ACTIVITYDATA.modifiedtime}{/if}</td>
+                                                        </tr>
+                                                     </table>
+						     <br>
+						     <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
+							<tr>
+								<td>
+									<table border="0" cellpadding="3" cellspacing="0" width="100%">
+									<tr>
+										<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
+                                                                                <td id="cellTabInvite" class="dvtSelectedCell" align="center" nowrap="nowrap"><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabRelatedto','off');dispLayer('addTaskAlarmUI');ghide('addTaskRelatedtoUI');">{$MOD.LBL_NOTIFICATION}</td></a>
+										<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;
+                                                                                <td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabRelatedto','on');dispLayer('addTaskRelatedtoUI');ghide('addTaskAlarmUI');">{$MOD.LBL_RELATEDTO}</a></td>
+
+                                                                                <td class="dvtTabCache" style="width: 100%;">&nbsp;</td>
+									</tr>
+									</table>
+								</td>
+							</tr>
+							<tr>
+								<td width=100% valign=top align=left class="dvtContentSpace" style="padding:10px;height:120px">
+                                                                <!-- Notification UI -->
+                                                                        <DIV id="addTaskAlarmUI" style="display:block;width:100%">
+									{if $LABEL.sendnotification neq ''}
+                                                                        <table width="100%" cellpadding="5" cellspacing="0" border="0">
+                                                                                <tr>
+                                                                                        <td width="30%" align=right><b>{$MOD.LBL_SENDNOTIFICATION}</b></td>
+                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.sendnotification}</td>
+                                                                                </tr>
+                                                                        </table>
+									{/if}
+                                                                        </DIV>
+									<div id="addTaskRelatedtoUI" style="display:none;width:100%">
+									{if $LABEL.parent_id neq ''}
+                                                                        <table width="100%" cellpadding="5" cellspacing="0" border="0">
+                                                                                <tr>
+                                                                                        <td width="30%" align=right><b>{$LABEL.parent_id}</b></td>
+                                                                                        <td width="70%" align=left>{$ACTIVITYDATA.parent_name}</td>
+                                                                                </tr>
+                                                                                <tr>
+                                                                                        <td align=right><b>{$MOD.LBL_CONTACT_NAME}</b></td>
+											<td align=left><a href="{$ACTIVITYDATA.contact_idlink}">{$ACTIVITYDATA.contact_id}</a></td>
+                                                                                </tr>
+                                                                        </table>
+									{/if}
+                                                                        </div>
+								</td>
+							</tr>
+						     </table>
+						     {/if}
+
+                     	                      </td>
+					   </tr>
+                </tr>
+		<tr>
+			<td style="padding:10px">
+		           <table border=0 cellspacing=0 cellpadding=0 width=100%>
+				     {strip}<tr nowrap>
+							<td  colspan=4 style="padding:5px">
+								{if $EDIT_DUPLICATE eq 'permitted'}
+                                                                <input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="&nbsp;{$APP.LBL_EDIT_BUTTON_LABEL}&nbsp;">&nbsp;
+								{/if}
+							</td>
+							<td align=right>
+								{if $EDIT_DUPLICATE eq 'permitted'}
+                                                                <input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
+                                                                {/if}
+								{if $DELETE eq 'permitted'}
+                                                                <input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
+                                                                {/if}
+
+							</td>
+					</tr>{/strip}
+			   </table>
+			</td>
+		</tr>
+	</table>
+	</td>
+	<td width=22% valign=top style="border-left:2px dashed #cccccc;padding:13px">
+						<!-- right side relevant info -->
+
+		<!-- Tag cloud display -->
+		<table border=0 cellspacing=0 cellpadding=0 width=100% class="tagCloud">
+		<tr>
+			<td class="tagCloudTopBg"><img src="{$IMAGE_PATH}tagCloudName.gif" border=0></td>
+		</tr>
+		<tr>
+                      	<td><div id="tagdiv" style="display:visible;"><input class="textbox"  type="text" id="txtbox_tagfields" name="textbox_First Name" value="" style="width:100px;margin-left:5px;"></input>&nbsp;&nbsp;<input name="button_tagfileds" type="button" class="crmbutton small save" value="{$APP.LBL_TAG_IT}" onclick="return tagvalidate()"/></div></td>
+                </tr>
+		<tr>
+			<td class="tagCloudDisplay" valign=top> <span id="tagfields">{$ALL_TAG}</span></td>
+		</tr>
+		</table>
+		<!-- End Tag cloud display -->
+			<!-- Mail Merge-->
+				<br>
+				{if $MERGEBUTTON eq 'permitted'}
+  				<table border=0 cellspacing=0 cellpadding=0 width=100% class="rightMailMerge">
+      				<tr>
+      					   <td class="rightMailMergeHeader"><b>{$WORDTEMPLATEOPTIONS}</b></td>
+      				</tr>
+      				<tr style="height:25px">
+      						<td class="rightMailMergeContent">
+          						<select name="mergefile">{foreach key=templid item=tempflname from=$TOPTIONS}<option value="{$templid}">{$tempflname}</option>{/foreach}</select>
+          						<input class="crmbutton small create" value="{$APP.LBL_MERGE_BUTTON_LABEL}" onclick="this.form.action.value='Merge';" type="submit"></input>
+      					  </td>
+      				</tr>
+  				</table>
+				{/if}
+			</td>
+		</tr>
+		</table>
+		
+			
+			
+		
+		</div>
+		<!-- PUBLIC CONTENTS STOPS-->
+	</td>
+</tr>
+</table>
+
+{if $MODULE eq 'Products'}
+<script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script>
+<script language="JavaScript" type="text/javascript">Carousel();</script>
+{/if}
+
+<script>
+function getTagCloud()
+{ldelim}
+new Ajax.Request(
+        'index.php',
+        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+        method: 'post',
+        postBody: 'module={$MODULE}&action={$MODULE}Ajax&file=TagCloud&ajxaction=GETTAGCLOUD&recordid={$ID}',
+        onComplete: function(response) {ldelim}
+                                $("tagfields").innerHTML=response.responseText;
+                                $("txtbox_tagfields").value ='';
+                        {rdelim}
+        {rdelim}
+);
+{rdelim}
+getTagCloud();
+</script>
+<!-- added for validation -->
+<script language="javascript">
+  var fieldname = new Array({$VALIDATION_DATA_FIELDNAME});
+  var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL});
+  var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE});
+</script>
+</td>
+
+</tr></table></form>
+</td></tr></table>
+</td></tr></table>
+</td></tr></table>
+        </td></tr></table>
+        </td></tr></table>
+        </div>
+        </td>
+        <td valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+        </tr>
+        </table>
+
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ActivityEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ActivityEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ActivityEditView.tpl Mon Apr 16 12:27:44 2007
@@ -1,868 +1,918 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-
-{*<!-- module header -->*}
-
-<link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
-<script type="text/javascript" src="jscalendar/calendar.js"></script>
-<script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
-<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/Activity.js"></script>
-<script type="text/javascript">
-</script>
-
-{*<!-- Contents -->*}
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-<form name="EditView" method="POST" action="index.php">
-<input type="hidden" name="time_start" id="time_start">
-<tr>
-        <td>
-                <table cellpadding="0" cellspacing="5" border="0">
-			{include file='EditViewHidden.tpl'}
-                </table>
-<table  border="0" cellpadding="5" cellspacing="0" width="100%" >
-<tr>
-        <td class="lvtHeaderText" style="border-bottom:1px dotted #cccccc">
-
-                <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
-                        <tr><td>
-		
-				{if $OP_MODE eq 'edit_view'}   
-					<span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} - {$APP.LBL_EDITING} {$SINGLE_MOD} {$APP.LBL_INFORMATION}</span> <br>
-					<span class="small">{$UPDATEINFO}	 </span> 
-				{/if}
-				{if $OP_MODE eq 'create_view'}
-					<span class="lvtHeaderText">{$APP.LBL_CREATING} {$SINGLE_MOD}</span> <br>
-				{/if}
-			</td></tr>
-		</table>
-        </td>
-</tr>
-
-<tr><td>
-<table border="0" cellpadding="5" cellspacing="0" width="100%">
-        <tr>
-                <td valign=top align=left >
-                           <table border=0 cellspacing=0 cellpadding=0 width=100%>
-                                <tr>
-					<td align=left>
-					<!-- content cache -->
-
-					<table border=0 cellspacing=0 cellpadding=0 width=100%>
-					  <tr>
-					     <td style="padding:10px">
-						     <!-- General details -->
-						     <table border=0 cellspacing=0 cellpadding=0 width=100% >
-						     <tr>
-							<td  colspan=4 style="padding:5px">
-								<div align="center">
-								<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" {if $ACTIVITY_MODE neq 'Task'} onclick="this.form.action.value='Save';  displaydeleted();return maincheck_form();"{else} onclick="this.form.action.value='Save';  displaydeleted(); maintask_check_form();return formValidate();" {/if} type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-								<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
-								</div>
-							</td>
-						     </tr>
-						     </table>
-						     <!-- included to handle the edit fields based on ui types -->
-						     {foreach key=header item=data from=$BLOCKS}
-						     <table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
-						     <tr>
-							<td colspan=4 class="tableHeading">
-								<b>{$header}</b>
-							</td>
-						     </tr>
-						     </table>
-						     {/foreach}
-						     {if $ACTIVITY_MODE neq 'Task'}
-							<input type="hidden" name="time_end" id="time_end">
-							<input type=hidden name="inviteesid" id="inviteesid" value="">
-							<input type="hidden" name="duration_hours" value="0">
-							<input type="hidden" name="duration_minutes" value="0">
-						     <table border=0 cellspacing=0 cellpadding=5 width=100% >
-							{if $LABEL.activitytype neq ''}
-							<tr>
-								<td class="cellLabel" nowrap  width=20% align="right"><b>{$MOD.LBL_EVENTTYPE}</b></td>
-								<td class="cellInfo" width=80% align="left">
-									<table>
-										<tr>
-										{foreach key=tyeparrkey item=typearr from=$ACTIVITYDATA.activitytype}
-                                                                                {foreach key=sel_value item=value from=$typearr}
-                                                                                {if $value eq 'selected' && $sel_value eq 'Meeting'}
-                                                                                        {assign var='meetcheck' value='checked'}
-                                                                                        {assign var='callcheck' value=''}
-                                                                                {else}
-                                                                                        {assign var='meetcheck' value=''}
-                                                                                        {assign var='callcheck' value='checked'}
-                                                                                {/if}
-                                                                                {/foreach}
-                                                                                {/foreach}
-											<td><input type="radio" name='activitytype' value='Call' style='vertical-align: middle;' {$callcheck}></td><td>{$APP.Call}</td><td style="width:10px">
-											<td><input type="radio" name='activitytype' value='Meeting' style='vertical-align: middle;' {$meetcheck}></td><td>{$APP.Meeting}</td><td style="width:20px">
-										</tr>
-									</table>
-								</td>
-							</tr>
-							{/if}
-							<tr>
-								<td class="cellLabel" nowrap align="right"><b>{$MOD.LBL_EVENTNAME}</b></td>
-								<td class="cellInfo" align="left"><input name="subject" type="text" class="textbox" value="{$ACTIVITYDATA.subject}" style="width:50%">&nbsp;&nbsp;&nbsp;
-								{if $LABEL.visibility neq ''}
-								{foreach key=key_one item=arr from=$ACTIVITYDATA.visibility}
-                                                                        {foreach key=sel_value item=value from=$arr}
-                                                                        {if $value eq 'selected' && $sel_value eq 'Public'}
-                                                                                {assign var="visiblecheck" value="checked"}
-                                                                        {else}
-                                                                                {assign var="visiblecheck" value=""}
-                                                                        {/if}
-                                                                        {/foreach}
-                                                                        {/foreach}
-                                                                        <input name="visibility" value="Public" type="checkbox" {$visiblecheck}>{$MOD.LBL_PUBLIC}
-								{/if}
-								</td>
-							</tr>
-							{if $LABEL.description neq ''}
-							<tr>
-                        					<td class="cellLabel" valign="top" nowrap align="right"><b>{$LABEL.description}</b></td>
-								<td class="cellInfo" align="left"><textarea style="width:100%; height : 60px;" name="description">{$ACTIVITYDATA.description}</textarea></td>
-                					</tr>
-							{/if}
-							<tr>
-								<td colspan=2 width=80% align="center">
-								<table border=0 cellspacing=0 cellpadding=3 width=80%>
-									<tr>
-										<td >{if $LABEL.eventstatus neq ''}<b>{$LABEL.eventstatus}</b>{/if}</td>
-                                                                                <td >{if $LABEL.assigned_user_id != ''}<b>
-											{$LABEL.assigned_user_id}</b>
-											{/if}</td>
-									</tr>
-									<tr>
-										<td valign=top>
-										{if $LABEL.eventstatus neq ''}
-                                                                                <select name="eventstatus" id="eventstatus" class=small>
-                                                                                        {foreach item=arr from=$ACTIVITYDATA.eventstatus}
-                                                                                        {foreach key=sel_value item=value from=$arr}
-                                                                                        <option value="{$sel_value}" {$value}>
-                                                                                                {if $MOD.$sel_value neq ''}
-                                                                                                {$MOD.$sel_value}
-                                                                                                {else}
-                                                                                                        {$sel_value}
-                                                                                                {/if}
-                                                                                        </option>
-                                                                                        {/foreach}
-                                                                                        {/foreach}
-                                                                                </select>
-										{/if}
-                                                                        	</td>
-										<td valign=top rowspan=2>
-											{if $ACTIVITYDATA.assigned_user_id != ''}
-											{assign var=check value=1}
-                                        						{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
-                                                					{foreach key=sel_value item=value from=$arr}
-                                                        					{if $value ne ''}
-                                                                					{assign var=check value=$check*0}
-                                                        					{else}
-                                                                					{assign var=check value=$check*1}
-                                                        					{/if}
-                                                					{/foreach}
-                                        						{/foreach}
-
-                                        						{if $check eq 0}
-                                                						{assign var=select_user value='checked'}
-                                                						{assign var=style_user value='display:block'}
-                                                						{assign var=style_group value='display:none'}
-                                        						{else}
-                                                						{assign var=select_group value='checked'}
-                                                						{assign var=style_user value='display:none'}
-                                                						{assign var=style_group value='display:block'}
-                                        						{/if}
-                                        						<input type="radio" name="assigntype" {$select_user} value="U" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_USER}
-                                        						{if $secondvalue.assigned_user_id neq ''}
-                                                					<input type="radio" name="assigntype" {$select_group} value="T" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_GROUP}
-                                        						{/if}
-											<span id="assign_user" style="{$style_user}">
-                                     				           			<select name="assigned_user_id">
-                                                        					{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
-                                                                				{foreach key=sel_value item=value from=$arr}
-                                                                        				<option value="{$key_one}" {$value}>{$sel_value}</option>
-                                                                				{/foreach}
-                                                        					{/foreach}
-                                                			   			</select>
-                                        			       			</span>
-
-                                        						{if $secondvalue.assigned_user_id neq ''}
-                                                					<span id="assign_team" style="{$style_group}">
-                                                        					<select name="assigned_group_name" >';
-                                                                				{foreach key=key_one item=arr from=$secondvalue.assigned_user_id}
-                                                                        			{foreach key=sel_value item=value from=$arr}
-                                                                                			<option value="{$sel_value}" {$value}>{$sel_value}</option>
-                                                                        			{/foreach}
-                                                                				{/foreach}
-                                                        					</select>
-                                                					</span>
-                                        						{/if}
-											{else}
-											<input name="assigned_user_id" value="{$CURRENTUSERID}" type="hidden">
-											{/if}
-											<br>{if $LABEL.sendnotification neq ''}<input type="checkbox" name="sendnotification" >&nbsp;{$LABEL.sendnotification}{/if}
-										</td>
-									</tr>
-									{if $LABEL.taskpriority neq ''}
-									<tr>
-										<td valign=top><b>{$LABEL.taskpriority}</b>
-										<br>
-										<select name="taskpriority" id="taskpriority">
-                                                                                        {foreach item=arr from=$ACTIVITYDATA.taskpriority}
-                                                                                        {foreach key=sel_value item=value from=$arr}
-                                                                                        <option value="{$sel_value}" {$value}>
-                                                                                                {if $MOD.$sel_value neq ''}
-                                                                                                {$MOD.$sel_value}
-                                                                                                {else}
-                                                                                                        {$sel_value}
-                                                                                                {/if}
-                                                                                        </option>
-                                                                                        {/foreach}
-                                                                                        {/foreach}
-                                                                                </select>
-										</td> 
-										
-									</tr>
-									{/if}
-								</table>
-							</td></tr>
-						     </table>
-						     <hr noshade size=1>
-						     <table border=0 cellspacing=0 cellpadding=5 width=90% align=center bgcolor="#FFFFFF">
-							<tr>
-								<td >
-									<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
-									<tr><td width=50% valign=top style="border-right:1px solid #dddddd">
-										<table border=0 cellspacing=0 cellpadding=2 width=90% align=center>
-											<tr><td colspan=3 ><b>{$MOD.LBL_EVENTSTAT}</b></td></tr>
-											<tr><td colspan=3>{$STARTHOUR}</td></tr>
-											<tr><td>
-												{foreach key=date_value item=time_value from=$ACTIVITYDATA.date_start}
-                                                                                                        {assign var=date_val value="$date_value"}
-                                                                                                        {assign var=time_val value="$time_value"}
-	                                                                                        {/foreach}
-                                                                                                <input type="text" name="date_start" id="jscal_field_date_start" class="textbox" style="width:90px" value="{$date_val}"></td><td width=100%><img border=0 src="{$IMAGE_PATH}btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_date_start">
-													{foreach key=date_fmt item=date_str from=$secondvalue.date_start}
-													{assign var=date_vl value="$date_fmt"}
-													{/foreach}
-													<script type="text/javascript">
-														Calendar.setup ({ldelim}
-														inputField : "jscal_field_date_start", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
-														{rdelim})
-													</script>
-											</td></tr>
-										</table></td>
-										<td width=50% valign=top >
-											<table border=0 cellspacing=0 cellpadding=2 width=90% align=center>
-												<tr><td colspan=3><b>{$MOD.LBL_EVENTEDAT}</b></td></tr>
-												<tr><td colspan=3>{$ENDHOUR}
-												</td></tr>
-												<tr><td>
-													{foreach key=date_value item=time_value from=$ACTIVITYDATA.due_date}
-													{assign var=date_val value="$date_value"}
-													{assign var=time_val value="$time_value"}
-													{/foreach}
-													<input type="text" name="due_date" id="jscal_field_due_date" class="textbox" style="width:90px" value="{$date_val}"></td><td width=100%><img border=0 src="{$IMAGE_PATH}btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_due_date">
-													{foreach key=date_fmt item=date_str from=$secondvalue.due_date}
-													{assign var=date_vl value="$date_fmt"}
-                                                                                                        {/foreach}
-													<script type="text/javascript">
-														Calendar.setup ({ldelim}
-														inputField : "jscal_field_due_date", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_due_date", singleClick : true, step : 1
-														{rdelim})
-													</script>
-												</td></tr>
-											</table>
-										</td>
-									</tr>
-								</table></td>
-							</tr>
-						     </table>
-						     <br>
-						     <table border=0 cellspacing=0 cellpadding=0 width=100% align=center>
-							<tr><td>
-								<table border=0 cellspacing=0 cellpadding=3 width=100%>
-									<tr>
-										<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
-										<td id="cellTabInvite" class="dvtSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');gshow('addEventInviteUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_INVITE}</a></td>
-										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-										<td id="cellTabAlarm" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','on');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');gshow('addEventAlarmUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventInviteUI');ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_REMINDER}</a></td>
-										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-										<td id="cellTabRepeat" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','on');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');ghide('addEventInviteUI');gshow('addEventRepeatUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventRelatedtoUI');">{$MOD.LBL_REPEAT}</a></td>
-										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-										<td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','on');ghide('addEventAlarmUI');ghide('addEventInviteUI');gshow('addEventRelatedtoUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventRepeatUI');">{$MOD.LBL_RELATEDTO}</a></td>
-										<td class="dvtTabCache" style="width:100%">&nbsp;</td>
-									</tr>
-								</table>
-							</td></tr>
-							<tr>
-								<td width=100% valign=top align=left class="dvtContentSpace" style="padding:10px;height:120px">
-								<!-- Invite UI -->
-									<DIV id="addEventInviteUI" style="display:block;width:100%">
-									<table border=0 cellspacing=0 cellpadding=2 width=100%>
-										<tr>
-											<td valign=top> 
-												<table border=0 cellspacing=0 cellpadding=2 width=100%>
-													<tr><td colspan=3>
-														<ul style="padding-left:20px">
-														<li>{$MOD.LBL_INVITE_INST1}
-														<li>{$MOD.LBL_INVITE_INST2}
-														</ul>
-													</td></tr>
-													<tr>
-														<td><b>{$MOD.LBL_AVL_USERS}</b></td>
-														<td>&nbsp;</td>
-														<td><b>{$MOD.LBL_SEL_USERS}</b></td>
-													</tr>
-													<tr>
-														<td width=40% align=center valign=top>
-														<select name="availableusers" id="availableusers" class=small size=5 multiple style="height:70px;width:100%">
-														{foreach item=username key=userid from=$USERSLIST}
-														{if $userid != ''}
-														<option value="{$userid}">{$username}</option>
-														{/if}
-														{/foreach}
-														</select>
-														</td>
-														<td width=20% align=center valign=top>
-														<input type=button value="{$MOD.LBL_ADD_BUTTON} >>" class="crm button small save" style="width:100%" onClick="addColumn()"><br>
-														<input type=button value="<< {$MOD.LBL_RMV_BUTTON} " class="crm button small cancel" style="width:100%" onClick="delColumn()">
-														</td>
-														<td width=40% align=center valign=top>
-														<select name="selectedusers" id="selectedusers" class=small size=5 multiple style="height:70px;width:100%">
-														{foreach item=username key=userid from=$INVITEDUSERS}
-														{if $userid != ''}
-														<option value="{$userid}">{$username}</option>
-                                                                                                                {/if}
-                                                                                                                {/foreach}
-														</select>
-														<div align=left> {$MOD.LBL_SELUSR_INFO}
-														</div>
-														</td>
-													</tr>
-												</table>
-											</td>
-										</tr>
-									</table>
-									</DIV>
-									<!-- Reminder UI -->	
-									<DIV id="addEventAlarmUI" style="display:none;width:100%">
-									{if $LABEL.reminder_time neq ''}
-										<table>
-											{assign var=secondval value=$secondvalue.reminder_time}
-											{assign var=check value=$secondval[0]}
-											{assign var=yes_val value=$secondval[1]}
-											{assign var=no_val value=$secondval[2]}
-											
-											<tr><td>{$LABEL.reminder_time}</td><td>
-											<input type="radio" name="set_reminder" value="Yes" {$check} onClick="showBlock('reminderOptions')">&nbsp;{$yes_val}&nbsp;
-											<input type="radio" name="set_reminder" value="No" onClick="fnhide('reminderOptions')">&nbsp;{$no_val}&nbsp;
-											</td></tr>
-										</table>
-									{if $check eq 'CHECKED'}
-										{assign var=reminstyle value='style="display:block;width:100%"'}
-									{else}
-										{assign var=reminstyle value='style="display:none;width:100%"'}
-									{/if}
-									<DIV id="reminderOptions" {$reminstyle}>
-										<table border=0 cellspacing=0 cellpadding=2  width=100%>
-											<tr>
-												<td nowrap align=right width=20% valign=top><b>{$MOD.LBL_RMD_ON} : </b></td>
-												<td width=80%>
-													<table border=0>
-													<tr>
-														<td colspan=2>
-														{foreach item=val_arr from=$ACTIVITYDATA.reminder_time}
-														{assign var=start value="$val_arr[0]"}
-														{assign var=end value="$val_arr[1]"}
-														{assign var=sendname value="$val_arr[2]"}
-														{assign var=disp_text value="$val_arr[3]"}
-														{assign var=sel_val value="$val_arr[4]"}
-														<select name="{$sendname}">
-														{section name=reminder start=$start max=$end loop=$end step=1 }
-														{if $smarty.section.reminder.index eq $sel_val}
-														{assign var=sel_value value="SELECTED"}
-														{else}
-														{assign var=sel_value value=""}
-														{/if}
-														<OPTION VALUE="{$smarty.section.reminder.index}" "{$sel_value}">{$smarty.section.reminder.index}</OPTION>
-														{/section}
-														</select>
-														&nbsp;{$disp_text}
-														{/foreach}
-														</td>
-													</tr>
-													</table>
-												</td>
-											</tr>
-											<tr>
-												<td nowrap align=right>
-													{$MOD.LBL_SDRMD}
-												</td>
-												<td >
-													<input type=text name="toemail" readonly="readonly" class=textbox style="width:90%" value="{$USEREMAILID}">
-												</td>
-											</tr>
-										</table>
-									{/if}
-									</DIV>
-									</DIV>
-									<!-- Repeat UI -->
-									<div id="addEventRepeatUI" style="display:none;width:100%">
-									{if $LABEL.recurringtype neq ''}
-									<table border=0 cellspacing=0 cellpadding=2  width=100%>
-										<tr>
-											<td nowrap align=right width=20% valign=top>
-												<strong>{$MOD.LBL_REPEAT}</strong>
-											</td>
-											<td nowrap width=80% valign=top>
-												<table border=0 cellspacing=0 cellpadding=0>
-												<tr>
-							
-													<td width=20>
-													{if $ACTIVITYDATA.recurringcheck eq 'Yes'}
-														{assign var=rptstyle value='style="display:block"'}
-														{if $ACTIVITYDATA.eventrecurringtype eq 'Daily'}
-															{assign var=rptmonthstyle value='style="display:none"'}
-															{assign var=rptweekstyle value='style="display:none"'}
-														{elseif $ACTIVITYDATA.eventrecurringtype eq 'Weekly'}
-															{assign var=rptmonthstyle value='style="display:none"'}
-															{assign var=rptweekstyle value='style="display:block"'}
-														{elseif $ACTIVITYDATA.eventrecurringtype eq 'Monthly'}
-															{assign var=rptmonthstyle value='style="display:block"'}
-															{assign var=rptweekstyle value='style="display:none"'}
-														{elseif $ACTIVITYDATA.eventrecurringtype eq 'Yearly'}
-															{assign var=rptmonthstyle value='style="display:none"'}
-															{assign var=rptweekstyle value='style="display:none"'}
-														{/if}
-													<input type="checkbox" name="recurringcheck" onClick="showhide('repeatOptions')" checked>
-													{else}
-														{assign var=rptstyle value='style="display:none"'}
-														{assign var=rptmonthstyle value='style="display:none"'}
-														{assign var=rptweekstyle value='style="display:none"'}
-													<input type="checkbox" name="recurringcheck" onClick="showhide('repeatOptions')">
-													{/if}
-													</td>
-													<td colspan=2>{$MOD.LBL_ENABLE_REPEAT}<td>
-												</tr>
-												<tr>
-													<td colspan=2>
-													<div id="repeatOptions" {$rptstyle}>
-													<table border=0 cellspacing=0 cellpadding=2>
-													<tr>
-													<td>Repeat once in every</td>
-													<td><input type="text" name="repeat_frequency" class="textbox" style="width:20px" value="{$ACTIVITYDATA.repeat_frequency}" ></td>
-													<td><select name="recurringtype">
-													<option value="Daily" onClick="ghide('repeatWeekUI'); ghide('repeatMonthUI');" {if $ACTIVITYDATA.eventrecurringtype eq 'Daily'} selected {/if}>{$MOD.LBL_DAYS}</option>
-													<option value="Weekly" onClick="gshow('repeatWeekUI'); ghide('repeatMonthUI');" {if $ACTIVITYDATA.eventrecurringtype eq 'Weekly'} selected {/if}>{$MOD.LBL_WEEKS}</option>
-												<option value="Monthly" onClick="ghide('repeatWeekUI'); gshow('repeatMonthUI');" {if $ACTIVITYDATA.eventrecurringtype eq 'Monthly'} selected {/if}>{$MOD.LBL_MONTHS}</option>
-													<option value="Yearly" onClick="ghide('repeatWeekUI'); ghide('repeatMonthUI');"; {if $ACTIVITYDATA.eventrecurringtype eq 'Yearly'} selected {/if}>{$MOD.LBL_YEAR}</option>
-													</select>
-													</td>
-												</tr>
-												</table>
-												<div id="repeatWeekUI" {$rptweekstyle}>
-												<table border=0 cellspacing=0 cellpadding=2>
-												<tr>
-													<td><input name="sun_flag" value="sunday" {$ACTIVITYDATA.week0} type="checkbox"></td><td>Sun</td>
-													<td><input name="mon_flag" value="monday" {$ACTIVITYDATA.week1} type="checkbox"></td><td>Mon</td>
-													<td><input name="tue_flag" value="tuesday" {$ACTIVITYDATA.week2} type="checkbox"></td><td>Tue</td>
-													<td><input name="wed_flag" value="wednesday" {$ACTIVITYDATA.week3} type="checkbox"></td><td>Wed</td>
-													<td><input name="thu_flag" value="thursday" {$ACTIVITYDATA.week4} type="checkbox"></td><td>Thu</td>
-													<td><input name="fri_flag" value="friday" {$ACTIVITYDATA.week5} type="checkbox"></td><td>Fri</td>
-													<td><input name="sat_flag" value="saturday" {$ACTIVITYDATA.week6} type="checkbox"></td><td>Sat</td>
-												</tr>
-												</table>
-												</div>
-	
-												<div id="repeatMonthUI" {$rptmonthstyle}>
-												<table border=0 cellspacing=0 cellpadding=2>
-												<tr>
-													<td>
-														<table border=0 cellspacing=0 cellpadding=2>
-														<tr>
-														<td><input type="radio" checked name="repeatMonth" {if $ACTIVITYDATA.repeatMonth eq 'date'} checked {/if} value="date"></td><td>on</td><td><input type="text" class=textbox style="width:20px" value="{$ACTIVITYDATA.repeatMonth_date}" name="repeatMonth_date" ></td><td>day of the month</td>
-														</tr>
-														</table>
-													</td>
-												</tr>
-												<tr>
-													<td>
-														<table border=0 cellspacing=0 cellpadding=2>
-														<tr><td>
-														<input type="radio" name="repeatMonth" {if $ACTIVITYDATA.repeatMonth eq 'day'} checked {/if} value="day"></td>
-														<td>on</td>
-														<td>
-														<select name="repeatMonth_daytype">
-															<option value="first" {if $ACTIVITYDATA.repeatMonth_daytype eq 'first'} selected {/if}>First</option>
-															<option value="last" {if $ACTIVITYDATA.repeatMonth_daytype eq 'last'} selected {/if}>Last</option>
-														</select>
-														</td>
-														<td>
-														<select name="repeatMonth_day">
-															<option value=1 {if $ACTIVITYDATA.repeatMonth_day eq 1} selected {/if}>{$MOD.LBL_DAY1}</option>
-															<option value=2 {if $ACTIVITYDATA.repeatMonth_day eq 2} selected {/if}>{$MOD.LBL_DAY2}</option>
-															<option value=3 {if $ACTIVITYDATA.repeatMonth_day eq 3} selected {/if}>{$MOD.LBL_DAY3}</option>
-															<option value=4 {if $ACTIVITYDATA.repeatMonth_day eq 4} selected {/if}>{$MOD.LBL_DAY4}</option>
-															<option value=5 {if $ACTIVITYDATA.repeatMonth_day eq 5} selected {/if}>{$MOD.LBL_DAY5}</option>
-															<option value=6 {if $ACTIVITYDATA.repeatMonth_day eq 6} selected {/if}>{$MOD.LBL_DAY6}</option>
-														</select>
-														</td>
-														</tr>
-														</table>
-													</td>
-												</tr>
-												</table>
-												</div>
-								
-											</div>
-										</td>
-										</tr>
-									</table>
-								</td>
-							</tr>
-						</table>
-						{/if}
-						</div>
-						<div id="addEventRelatedtoUI" style="display:none;width:100%">
-						<table width="100%" cellpadding="5" cellspacing="0" border="0">
-							{if $LABEL.parent_id neq ''}	
-							<tr>
-								<td><b>{$MOD.LBL_RELATEDTO}</b></td>
-								<td>
-									<input name="parent_id" type="hidden" value="{$secondvalue.parent_id}">
-									<select name="parent_type" class="small" id="parent_type" onChange="document.EditView.parent_name.value='';document.EditView.parent_id.value=''">
-									{section name=combo loop=$LABEL.parent_id}
-										<option value="{$fldlabel_combo.parent_id[combo]}" {$fldlabel_sel.parent_id[combo]}>{$LABEL.parent_id[combo]}</option>
-									{/section}
-                                             				</select>
-								</td>
-								<td>
-									<div id="eventrelatedto" align="left">
-										<input name="parent_name" readonly type="text" class="calTxt small" value="{$ACTIVITYDATA.parent_id}">
-										<input type="button" name="selectparent" class="crmButton small edit" value="Select" onclick="return window.open('index.php?module='+document.EditView.parent_type.value+'&action=Popup','test','width=640,height=602,resizable=0,scrollbars=0,top=150,left=200');">
-									</div>
-								</td>
-							</tr>
-							{/if}
-							<tr>
-								<td><b>{$APP.Contacts}</b></td>
-								<td colspan="2">
-									<input name="contactidlist" id="contactidlist" value="{$CONTACTSID}" type="hidden">
-									<textarea rows="5" name="contactlist" readonly="readonly" class="calTxt">
-									{$CONTACTSNAME}
-									</textarea>&nbsp;
-									<input type="button" onclick="return window.open('index.php?module=Contacts&action=Popup&return_module=Calendar&popuptype=detailview&select=enable&form=EditView&form_submit=false','test','width=640,height=602,resizable=0,scrollbars=0');" class="crmButton small edit" name="selectcnt" value="Select Contacts">
-								</td>
-							</tr>
-						</table>
-					</div>
-			</td>
-		</tr>
-		</table>
-		<!-- Alarm, Repeat, Invite stops-->
-		{else}
-		<table border="0" cellpadding="5" cellspacing="0" width="100%">
-			<tr>
-                        	<td class="cellLabel" width="20%" align="right"><b>{$MOD.LBL_TODO}</b></td>
-                        	<td class="cellInfo" width="80%" align="left"><input name="subject" value="{$ACTIVITYDATA.subject}" class="textbox" style="width: 70%;" type="text"></td>
-           		</tr>
-			
-			<tr>
-				{if $LABEL.description != ''}
-				<td class="cellLabel" align="right"><b>{$LABEL.description}</b></td>
-				<td class="cellInfo" align="left"><textarea style="width: 90%; height: 60px;" name="description">{$ACTIVITYDATA.description}</textarea>
-				{/if}
-				
-			</tr>
-			<tr>
-		    		<td colspan="2" align="center" width="100%" style="padding:0px">
-					<table border="0" cellpadding="5" cellspacing="1" width="100%">
-            					<tr>
-							{if $LABEL.taskstatus != ''}
-							<td class="cellLabel" width=33% align="left"><b>{$LABEL.taskstatus}</b></td>
-							{/if}
-							{if $LABEL.taskpriority != ''}
-              						<td class="cellLabel" width=33% align="left"><b>{$LABEL.taskpriority}</b></td>
-							{/if}
-              						{if $LABEL.assigned_user_id != ''}
-							<td class="cellLabel" width=34% align="left"><b>{$LABEL.assigned_user_id}</b></td>
-							{/if}
-						</tr>
-						<tr>
-							{if $LABEL.taskstatus != ''}
-							<td align="left" valign="top">
-								<select name="taskstatus" id="taskstatus" class=small>
-                                        			{foreach item=arr from=$ACTIVITYDATA.taskstatus}
-                                        			{foreach key=sel_value item=value from=$arr}
-                                                			<option value="{$sel_value}" {$value}>
-                                                        		{if $MOD.$sel_value neq ''}
-                                                                		{$MOD.$sel_value}
-                                                        		{else}
-                                                                		{$sel_value}
-                                                        		{/if}
-                                                			</option>
-                                        			{/foreach}
-                                        			{/foreach}
-                                				</select>
-							</td>
-							{/if}
-							{if $LABEL.taskpriority != ''}
-							<td align="left" valign="top">
-								<select name="taskpriority" id="taskpriority" class=small>
-        			                                {foreach item=arr from=$ACTIVITYDATA.taskpriority}
-                                			        {foreach key=sel_value item=value from=$arr}
-			                                                <option value="{$sel_value}" {$value}>
-                        		                                {if $MOD.$sel_value neq ''}
-                                        		                        {$MOD.$sel_value}
-                                                       			{else}
-                                                                		{$sel_value}
-                                                        		{/if}
-                                                			</option>
-                                        			{/foreach}
-                                        			{/foreach}
-                                				</select>
-							</td>
-							{/if}
-							{if $LABEL.assigned_user_id != ''}
-							<td align="left" valign="top">
-								{assign var=check value=1}
-                                        			{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
-			                                        {foreach key=sel_value item=value from=$arr}
-                        		                              	{if $value ne ''}
-                                        		                      	{assign var=check value=$check*0}
-                                                        		{else}
-                                                                		{assign var=check value=$check*1}
-                                                        		{/if}
-                                                		{/foreach}
-                                        			{/foreach}
-								{if $check eq 0}
-                                             				{assign var=select_user value='checked'}
-                                                			{assign var=style_user value='display:block'}
-                                                			{assign var=style_group value='display:none'}
-                                        			{else}
-                                                			{assign var=select_group value='checked'}
-                                                			{assign var=style_user value='display:none'}
-                                                			{assign var=style_group value='display:block'}
-                                        			{/if}
-				                                <input type="radio" name="assigntype" {$select_user} value="U" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_USER}
-				                                {if $secondvalue.assigned_user_id neq ''}
-                                			        <input type="radio" name="assigntype" {$select_group} value="T" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_GROUP}
-                                        			{/if}
-                                        			<span id="assign_user" style="{$style_user}">
-                                                		<select name="assigned_user_id" class=small>
-                                                        	{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
-				                                {foreach key=sel_value item=value from=$arr}
-                                		                	<option value="{$key_one}" {$value}>{$sel_value}</option>
-								{/foreach}
-                                                        	{/foreach}
-                                                		</select>
-								</span>
-								{if $secondvalue.assigned_user_id neq ''}
-                                                		<span id="assign_team" style="{$style_group}">
-                                                        		<select name="assigned_group_name" class=small>';
-                                                                		{foreach key=key_one item=arr from=$secondvalue.assigned_user_id}
-                                                                       		{foreach key=sel_value item=value from=$arr}
-                                                                               		<option value="{$sel_value}" {$value}>{$sel_value}</option>
-                                                                       		{/foreach}
-                                                                		{/foreach}
-                                                        		</select>
-				                                </span>
-                                				{/if}	
-							</td>
-							{else}
-								<input name="assigned_user_id" value="{$CURRENTUSERID}" type="hidden">
-							{/if}
-						</tr>
-					</table>
-				</td>
-			</tr>
-			</table>
-			<table border="0" cellpadding="0" cellspacing="1" width="100%" align=center>
-			<tr><td width=50% valign=top>
-				<table border=0 cellspacing=0 cellpadding=2 width=100% align=center >
-					<tr><td colspan=3  class="mailSubHeader"><b>{$MOD.LBL_TODODATETIME}</b></td></tr>
-					<tr><td colspan=3>{$STARTHOUR}</td></tr>
-					<tr><td>
-							{foreach key=date_value item=time_value from=$ACTIVITYDATA.date_start}
-	                                        		{assign var=date_val value="$date_value"}
-								{assign var=time_val value="$time_value"}
-                                        		{/foreach}
-							<input name="date_start" id="date_start" class="textbox" style="width: 90px;" value="{$date_val}" type="text"></td><td width=100%><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_date_start" align="middle" border="0">
-							{foreach key=date_fmt item=date_str from=$secondvalue.date_start}
-								{assign var=date_vl value="$date_fmt"}
-							{/foreach}				
-							<script type="text/javascript">
-								Calendar.setup ({ldelim}
-	        	                                	inputField : "date_start", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
-							{rdelim})
-							</script>
-						</td></tr>
-					</table></td>
-					<td width=50% valign="top">
-                                                <table border="0" cellpadding="2" cellspacing="0" width="100%" align=center>
-							<tr><td class="mailSubHeader" colspan=3><b>{$LABEL.due_date}</b></td></tr>
-							<tr><td>
-								{foreach key=date_value item=time_value from=$ACTIVITYDATA.due_date}
-									{assign var=date_val value="$date_value"}
-									{assign var=time_val value="$time_value"}
-								{/foreach}
-								<input name="due_date" id="due_date" class="textbox" style="width: 90px;" value="{$date_val}" type="text"></td><td width=100%><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_due_date" border="0">
-								{foreach key=date_fmt item=date_str from=$secondvalue.due_date}
-                                                			{assign var=date_vl value="$date_fmt"}
-                                        			{/foreach}
-				      				<script type="text/javascript">
-								Calendar.setup ({ldelim}
-	                                        			inputField : "due_date", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_due_date", singleClick : true, step : 1
-					   			{rdelim})
-								</script>
-        						</td></tr>
-						</table></td>
-					</tr>
-				</table>
-				<br><br>
-		<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%" bgcolor="#FFFFFF">
-			<tr>
-				<td>
-					<table border="0" cellpadding="3" cellspacing="0" width="100%">
-						<tr>
-							<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
-							<td id="cellTabInvite" class="dvtSelectedCell" align="center" nowrap="nowrap"><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabRelatedto','off');Taskshow('addTaskAlarmUI','todo',document.EditView.date_start.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value);ghide('addTaskRelatedtoUI');">{$MOD.LBL_NOTIFICATION}</a></td>
-							<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
-                                                        <td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabRelatedto','on');Taskshow('addTaskRelatedtoUI','todo',document.EditView.date_start.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value);ghide('addTaskAlarmUI');">{$MOD.LBL_RELATEDTO}</a></td>
-                                                        <td class="dvtTabCache" style="width:100%">&nbsp;</td>
-						</tr>
-
-					</table>
-				</td>
-			</tr>
-			<tr>
-				<td class="dvtContentSpace" style="padding: 10px; height: 120px;" align="left" valign="top" width="100%">
-			<!-- Reminder UI -->
-			<div id="addTaskAlarmUI" style="display: block; width: 100%;">
-			{if $LABEL.sendnotification != ''}
-                	<table>
-				<tr><td>{$LABEL.sendnotification}</td>
-					{if $ACTIVITYDATA.sendnotification eq 1}
-                                        <td>
-                                                <input name="sendnotification" type="checkbox" checked>
-                                        </td>
-                                	{else}
-                                        <td>
-                                                <input name="sendnotification" type="checkbox">
-                                        </td>
-                                	{/if}
-				</tr>
-			</table>
-			{/if}
-			</div>
-			<div id="addTaskRelatedtoUI" style="display:none;width:100%">
-           		     <table width="100%" cellpadding="5" cellspacing="0" border="0">
-			     {if $LABEL.parent_id neq ''}
-                	     <tr>
-                        	     <td><b>{$MOD.LBL_RELATEDTO}</b></td>
-                                     <td>
-					<input name="parent_id" type="hidden" value="{$secondvalue.parent_id}">
-                                             <select name="parent_type" class="small" id="parent_type" onChange="document.EditView.parent_name.value='';document.EditView.parent_id.value=''">
-							{section name=combo loop=$LABEL.parent_id}
-								<option value="{$fldlabel_combo.parent_id[combo]}" {$fldlabel_sel.parent_id[combo]}>{$LABEL.parent_id[combo]}</option>
-							{/section}
-					     </select>
-                                     </td>
-                                     <td>
-                              	        <div id="taskrelatedto" align="left">
-						<input name="parent_name" readonly type="text" class="calTxt small" value="{$ACTIVITYDATA.parent_id}">
-						<input type="button" name="selectparent" class="crmButton small edit" value="Select" onclick="return window.open('index.php?module='+document.EditView.parent_type.value+'&action=Popup','test','width=640,height=602,resizable=0,scrollbars=0,top=150,left=200');">
-					 </div>
-                                     </td>
-			     </tr>
-			     {/if}
-			     {if $LABEL.contact_id neq ''}	
-			     <tr>
-                                     <td><b>{$LABEL.contact_id}</b></td>
-				     <td colspan="2">
-						<input name="contact_name" readonly type="text" class="calTxt" value="{$ACTIVITYDATA.contact_id}"><input name="contact_id" type="hidden" value="{$secondvalue.contact_id}">&nbsp;
-						<input type="button" onclick="return window.open('index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView','test','width=640,height=602,resizable=0,scrollbars=0');" class="crmButton small edit" name="selectcnt" value="Select Contact">
-				     </td>
-                             </tr>
-			     {/if}
-		</table>
-              	</div>
-                </td></tr></table>
-
-		{/if}
-			</td></tr>
-			<tr>
-				<td  colspan=4 style="padding:5px">
-					<div align="center">
-                        	        	<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" {if $ACTIVITY_MODE neq 'Task'} onclick="this.form.action.value='Save';  displaydeleted();return maincheck_form();"{else} onclick="this.form.action.value='Save';  displaydeleted(); maintask_check_form();return formValidate();" {/if} type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-						<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
-					</div>
-				</td>
-			</tr></table>
-		</td></tr></table>
-		</td></tr></table>
-		</td></tr></table>
-		</td></tr></table>
-		</td></tr></table>
-</td></tr>
-</form></table>
-</td></tr></table>
-</td></tr></table>
-</td></tr></table>
-        </td></tr></table>
-        </td></tr></table>
-        </div>
-        </td>
-        <td valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-        </tr>
-        </table>
-<script>
-{if $ACTIVITY_MODE eq 'Task'}
-	var fieldname = new Array('subject','date_start','time_start','taskstatus');
-	var fieldlabel = new Array('Subject','Date','Time','Status');
-	var fielddatatype = new Array('V~M','D~M~time_start','T~O','V~O');
-{else}
-	var fieldname = new Array('subject','date_start','due_date','taskpriority','sendnotification','parent_id','contact_id','reminder_time','recurringtype');
-	var fieldlabel = new Array('Subject','Start Date','Due Date','Priority','Send Notification','Related To','Contact Name','Send Reminder','Recurrence');
-	var fielddatatype = new Array('V~M','D~M','D~M~OTH~GE~date_start~Start Date','V~O','C~O','I~O','I~O','I~O','O~O');
-{/if}
-</script>
-<script>	
-	var ProductImages=new Array();
-	var count=0;
-
-	function delRowEmt(imagename)
-	{ldelim}
-		ProductImages[count++]=imagename;
-	{rdelim}
-
-	function displaydeleted()
-	{ldelim}
-		var imagelists='';
-		for(var x = 0; x < ProductImages.length; x++)
-		{ldelim}
-			imagelists+=ProductImages[x]+'###';
-		{rdelim}
-
-		if(imagelists != '')
-			document.EditView.imagelist.value=imagelists
-	{rdelim}
-
-</script>
-<script language="JavaScript" type="text/JavaScript">
-	setObjects();
-</script>
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+
+{*<!-- module header -->*}
+
+<link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
+<script type="text/javascript" src="jscalendar/calendar.js"></script>
+<script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
+<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/Calendar.js"></script>
+<script type="text/javascript">
+var gVTModule = '{$smarty.request.module}';
+</script>
+
+{*<!-- Contents -->*}
+<form name="EditView" method="POST" action="index.php">
+<input type="hidden" name="time_start" id="time_start">
+<input type="hidden" name="view" value="{$view}">
+<input type="hidden" name="hour" value="{$hour}">
+<input type="hidden" name="day" value="{$day}">
+<input type="hidden" name="month" value="{$month}">
+<input type="hidden" name="year" value="{$year}">
+<input type="hidden" name="viewOption" value="{$viewOption}">
+<input type="hidden" name="subtab" value="{$subtab}">
+<input type="hidden" name="maintab" value="{$maintab}">
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+<tr>
+        <td>
+                <table cellpadding="0" cellspacing="5" border="0">
+			{include file='EditViewHidden.tpl'}
+                </table>
+<table  border="0" cellpadding="5" cellspacing="0" width="100%" >
+<tr>
+        <td class="lvtHeaderText" style="border-bottom:1px dotted #cccccc">
+
+                <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
+                        <tr><td>
+		
+				{if $OP_MODE eq 'edit_view'}   
+					<span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} - {$APP.LBL_EDITING} {$SINGLE_MOD} {$APP.LBL_INFORMATION}</span> <br>
+					<span class="small">{$UPDATEINFO}	 </span> 
+				{/if}
+				{if $OP_MODE eq 'create_view'}
+					{if $DUPLICATE neq 'true'}
+					<span class="lvtHeaderText">{$APP.LBL_CREATING} {$SINGLE_MOD}</span> <br>
+					{else}
+					<span class="lvtHeaderText">{$APP.LBL_DUPLICATING} "{$NAME}"</span> <br>
+					{/if}
+				{/if}
+			</td></tr>
+		</table>
+        </td>
+</tr>
+
+<tr><td>
+<table border="0" cellpadding="5" cellspacing="0" width="100%">
+        <tr>
+                <td valign=top align=left >
+                           <table border=0 cellspacing=0 cellpadding=0 width=100%>
+                                <tr>
+					<td align=left>
+					<!-- content cache -->
+
+					<table border=0 cellspacing=0 cellpadding=0 width=100%>
+					  <tr>
+					     <td style="padding:10px">
+						     <!-- General details -->
+						     <table border=0 cellspacing=0 cellpadding=0 width=100% >
+						     <tr>
+							<td  colspan=4 style="padding:5px">
+								<div align="center">
+								<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" {if $ACTIVITY_MODE neq 'Task'} onclick="this.form.action.value='Save';  displaydeleted();return maincheck_form();"{else} onclick="this.form.action.value='Save';  displaydeleted(); maintask_check_form();return formValidate();" {/if} type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+								<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+								</div>
+							</td>
+						     </tr>
+						     </table>
+						     <!-- included to handle the edit fields based on ui types -->
+						     {foreach key=header item=data from=$BLOCKS}
+						     <table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
+						     <tr>
+							<td colspan=4 class="tableHeading">
+								<b>{$header}</b>
+							</td>
+						     </tr>
+						     </table>
+						     {/foreach}
+						     {if $ACTIVITY_MODE neq 'Task'}
+							<input type="hidden" name="time_end" id="time_end">
+							<input type="hidden" name="followup_time_start" id="followup_time_start">
+                                                        <input type="hidden" name="followup_time_end" id="followup_time_end">
+							<input type=hidden name="inviteesid" id="inviteesid" value="">
+							<input type="hidden" name="duration_hours" value="0">
+							<input type="hidden" name="duration_minutes" value="0">
+							<input type="hidden" name="dateformat" value="{$DATEFORMAT}">
+						     <table border=0 cellspacing=0 cellpadding=5 width=100% >
+							{if $LABEL.activitytype neq ''}
+							<tr>
+								<td class="cellLabel" nowrap  width=20% align="right"><b>{$MOD.LBL_EVENTTYPE}</b></td>
+								<td class="cellInfo" width=80% align="left">
+									<table>
+										<tr>
+										{foreach key=tyeparrkey item=typearr from=$ACTIVITYDATA.activitytype}
+                                                                                {foreach key=sel_value item=value from=$typearr}
+                                                                                {if $value eq 'selected' && $sel_value eq 'Call'}
+                                                                                        {assign var='meetcheck' value=''}
+                                                                                        {assign var='callcheck' value='checked'}
+                                                                                {elseif $value eq 'selected' && $sel_value eq 'Meeting'}
+                                                                                        {assign var='meetcheck' value='checked'}
+                                                                                        {assign var='callcheck' value=''}
+                                                                                {else}
+											{assign var='meetcheck' value=''}
+                                                                                        {assign var='callcheck' value='checked'}
+                                                                                {/if}
+                                                                                {/foreach}
+                                                                                {/foreach}
+											<td><input type="radio" name='activitytype' value='Call' style='vertical-align: middle;' {$callcheck} onClick="calDuedatetime('call');" ></td><td>{$APP.Call}</td>
+											<td><input type="radio" name='activitytype' value='Meeting' style='vertical-align: middle;' {$meetcheck} onClick="calDuedatetime('meeting');" ></td><td>{$APP.Meeting}</td>
+										</tr>
+									</table>
+								</td>
+							</tr>
+							{/if}
+							<tr>
+								<td class="cellLabel" nowrap align="right"><b><font color="red">*</font>{$MOD.LBL_EVENTNAME}</b></td>
+								<td class="cellInfo" align="left"><input name="subject" type="text" class="textbox" value="{$ACTIVITYDATA.subject}" style="width:50%">&nbsp;&nbsp;&nbsp;
+								{if $LABEL.visibility neq ''}
+								{foreach key=key_one item=arr from=$ACTIVITYDATA.visibility}
+                                                                        {foreach key=sel_value item=value from=$arr}
+                                                                        {if $value eq 'selected' && $sel_value eq 'Public'}
+                                                                                {assign var="visiblecheck" value="checked"}
+                                                                        {else}
+                                                                                {assign var="visiblecheck" value=""}
+                                                                        {/if}
+                                                                        {/foreach}
+                                                                        {/foreach}
+                                                                        <input name="visibility" value="Public" type="checkbox" {$visiblecheck}>{$MOD.LBL_PUBLIC}
+								{/if}
+								</td>
+							</tr>
+							{if $LABEL.description neq ''}
+							<tr>
+                        					<td class="cellLabel" valign="top" nowrap align="right"><b>{$LABEL.description}</b></td>
+								<td class="cellInfo" align="left"><textarea style="width:100%; height : 60px;" name="description">{$ACTIVITYDATA.description}</textarea></td>
+                					</tr>
+							{/if}
+							{if $LABEL.location neq ''}
+							<tr>
+			                                        <td class="cellLabel" align="right" valign="top"><b>{$MOD.LBL_APP_LOCATION}</b></td>
+								<td class="cellInfo" align="left"><input name="location" type="text" class="textbox" value="{$ACTIVITYDATA.location}" style="width:50%">
+							</tr>
+							{/if}
+
+							<tr>
+								<td colspan=2 width=80% align="center">
+								<table border=0 cellspacing=0 cellpadding=3 width=80%>
+									<tr>
+										<td >{if $LABEL.eventstatus neq ''}<b>{$LABEL.eventstatus}</b>{/if}</td>
+                                                                                <td >{if $LABEL.assigned_user_id != ''}<b>
+											{$LABEL.assigned_user_id}</b>
+											{/if}</td>
+									</tr>
+									<tr>
+										<td valign=top>
+										{if $LABEL.eventstatus neq ''}
+                                                                                <select name="eventstatus" id="eventstatus" class=small onChange = "getSelectedStatus();" >
+                                                                                        {foreach item=arr from=$ACTIVITYDATA.eventstatus}
+                                                                                        {foreach key=sel_value item=value from=$arr}
+                                                                                        <option value="{$sel_value}" {$value}>
+                                                                                                {if $MOD.$sel_value neq ''}
+                                                                                                {$MOD.$sel_value}
+                                                                                                {else}
+                                                                                                        {$sel_value}
+                                                                                                {/if}
+                                                                                        </option>
+                                                                                        {/foreach}
+                                                                                        {/foreach}
+                                                                                </select>
+										{/if}
+                                                                        	</td>
+										<td valign=top rowspan=2>
+											{if $ACTIVITYDATA.assigned_user_id != ''}
+											{assign var=check value=1}
+                                        						{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
+                                                					{foreach key=sel_value item=value from=$arr}
+                                                        					{if $value ne ''}
+                                                                					{assign var=check value=$check*0}
+                                                        					{else}
+                                                                					{assign var=check value=$check*1}
+                                                        					{/if}
+                                                					{/foreach}
+                                        						{/foreach}
+
+                                        						{if $check eq 0}
+                                                						{assign var=select_user value='checked'}
+                                                						{assign var=style_user value='display:block'}
+                                                						{assign var=style_group value='display:none'}
+                                        						{else}
+                                                						{assign var=select_group value='checked'}
+                                                						{assign var=style_user value='display:none'}
+                                                						{assign var=style_group value='display:block'}
+                                        						{/if}
+                                        						<input type="radio" name="assigntype" {$select_user} value="U" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_USER}
+                                        						{if $secondvalue.assigned_user_id neq ''}
+                                                					<input type="radio" name="assigntype" {$select_group} value="T" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_GROUP}
+                                        						{/if}
+											<span id="assign_user" style="{$style_user}">
+                                     				           			<select name="assigned_user_id">
+                                                        					{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
+                                                                				{foreach key=sel_value item=value from=$arr}
+                                                                        				<option value="{$key_one}" {$value}>{$sel_value}</option>
+                                                                				{/foreach}
+                                                        					{/foreach}
+                                                			   			</select>
+                                        			       			</span>
+
+                                        						{if $secondvalue.assigned_user_id neq ''}
+                                                					<span id="assign_team" style="{$style_group}">
+                                                        					<select name="assigned_group_name" >';
+                                                                				{foreach key=key_one item=arr from=$secondvalue.assigned_user_id}
+                                                                        			{foreach key=sel_value item=value from=$arr}
+                                                                                			<option value="{$sel_value}" {$value}>{$sel_value}</option>
+                                                                        			{/foreach}
+                                                                				{/foreach}
+                                                        					</select>
+                                                					</span>
+                                        						{/if}
+											{else}
+											<input name="assigned_user_id" value="{$CURRENTUSERID}" type="hidden">
+											{/if}
+											<br>{if $LABEL.sendnotification neq ''}
+												{if $ACTIVITYDATA.sendnotification eq 1}
+
+												<input type="checkbox" name="sendnotification" checked>&nbsp;{$LABEL.sendnotification}
+												{else}
+												<input type="checkbox" name="sendnotification" >&nbsp;{$LABEL.sendnotification}
+												{/if}
+											{/if}
+										</td>
+									</tr>
+									{if $LABEL.taskpriority neq ''}
+									<tr>
+										<td valign=top><b>{$LABEL.taskpriority}</b>
+										<br>
+										<select name="taskpriority" id="taskpriority">
+                                                                                        {foreach item=arr from=$ACTIVITYDATA.taskpriority}
+                                                                                        {foreach key=sel_value item=value from=$arr}
+                                                                                        <option value="{$sel_value}" {$value}>
+                                                                                                {if $MOD.$sel_value neq ''}
+                                                                                                {$MOD.$sel_value}
+                                                                                                {else}
+                                                                                                        {$sel_value}
+                                                                                                {/if}
+                                                                                        </option>
+                                                                                        {/foreach}
+                                                                                        {/foreach}
+                                                                                </select>
+										</td> 
+										
+									</tr>
+									{/if}
+								</table>
+							</td></tr>
+						     </table>
+						     <hr noshade size=1>
+						     <table border=0 id="date_table" cellspacing=0 cellpadding=5 width=100% align=center bgcolor="#FFFFFF">
+							<tr>
+								<td >
+									<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+									<tr><td width=50% id="date_table_firsttd" valign=top style="border-right:1px solid #dddddd">
+										<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+											<tr><td colspan=3 ><b>{$MOD.LBL_EVENTSTAT}</b></td></tr>
+											<tr><td colspan=3>{$STARTHOUR}</td></tr>
+											<tr><td>
+												{foreach key=date_value item=time_value from=$ACTIVITYDATA.date_start}
+                                                                                                        {assign var=date_val value="$date_value"}
+                                                                                                        {assign var=time_val value="$time_value"}
+	                                                                                        {/foreach}
+                                                                                                <input type="text" name="date_start" id="jscal_field_date_start" class="textbox" style="width:90px" onChange="dochange('jscal_field_date_start','jscal_field_due_date');" value="{$date_val}"></td><td width=100%><img border=0 src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$MOD.LBL_SET_DATE}" title="{$MOD.LBL_SET_DATE}" id="jscal_trigger_date_start">
+													{foreach key=date_fmt item=date_str from=$secondvalue.date_start}
+													{assign var=date_vl value="$date_fmt"}
+													{/foreach}
+													<script type="text/javascript">
+														Calendar.setup ({ldelim}
+														inputField : "jscal_field_date_start", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
+														{rdelim})
+													</script>
+											</td></tr>
+										</table></td>
+										<td width=50% valign=top id="date_table_secondtd">
+											<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+												<tr><td colspan=3><b>{$MOD.LBL_EVENTEDAT}</b></td></tr>
+												<tr><td colspan=3>{$ENDHOUR}
+												</td></tr>
+												<tr><td>
+													{foreach key=date_value item=time_value from=$ACTIVITYDATA.due_date}
+													{assign var=date_val value="$date_value"}
+													{assign var=time_val value="$time_value"}
+													{/foreach}
+													<input type="text" name="due_date" id="jscal_field_due_date" class="textbox" style="width:90px" value="{$date_val}"></td><td width=100%><img border=0 src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$MOD.LBL_SET_DATE}" title="{$MOD.LBL_SET_DATE}" id="jscal_trigger_due_date">
+													{foreach key=date_fmt item=date_str from=$secondvalue.due_date}
+													{assign var=date_vl value="$date_fmt"}
+                                                                                                        {/foreach}
+													<script type="text/javascript">
+														Calendar.setup ({ldelim}
+														inputField : "jscal_field_due_date", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_due_date", singleClick : true, step : 1
+														{rdelim})
+													</script>
+												</td></tr>
+											</table>
+										</td>
+										<td width=33% valign=top style="display:none;border-left:1px solid #dddddd" id="date_table_thirdtd">
+                                                                                        <table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+                                                                                                <tr><td colspan=3><b><input type="checkbox" name="followup"><b>{$MOD.LBL_HOLDFOLLOWUP}</b></td></tr>
+                                                                                                <tr><td colspan=3>{$FOLLOWUP}</td></tr>
+                                                                                                <tr><td>
+                                                                                                        {foreach key=date_value item=time_value from=$ACTIVITYDATA.due_date}
+                                                                                                        {assign var=date_val value="$date_value"}
+                                                                                                        {assign var=time_val value="$time_value"}
+                                                                                                        {/foreach}
+                                                                                                        <input type="text" name="followup_date" id="jscal_field_followup_date" class="textbox" style="width:90px" value="{$date_val}"></td><td width=100%><img border=0 src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$MOD.LBL_SET_DATE}" title="{$MOD.LBL_SET_DATE}" id="jscal_trigger_followup_date">
+                                                                                                        {foreach key=date_fmt item=date_str from=$secondvalue.due_date}
+                                                                                                        {assign var=date_vl
+ value="$date_fmt"}
+                                                                                                        {/foreach}
+													<script type="text/javascript">
+                                                                                                        Calendar.setup ({ldelim}
+                                                                                                                inputField : "jscal_field_followup_date", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_followup_date", singleClick : true, step : 1
+                                                                                                                {rdelim})
+                                                                                                        </script>
+                                                                                                </td></tr>
+                                                                                        </table>
+                                                                                </td>
+									</tr>
+								</table></td>
+							</tr>
+						     </table>
+						     <br>
+						     <table border=0 cellspacing=0 cellpadding=0 width=100% align=center>
+							<tr><td>
+								<table border=0 cellspacing=0 cellpadding=3 width=100%>
+									<tr>
+										<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
+										<td id="cellTabInvite" class="dvtSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');gshow('addEventInviteUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_INVITE}</a></td>
+										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+										<td id="cellTabAlarm" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','on');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','off');gshow('addEventAlarmUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventInviteUI');ghide('addEventRepeatUI');ghide('addEventRelatedtoUI');">{$MOD.LBL_REMINDER}</a></td>
+										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+										<td id="cellTabRepeat" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','on');switchClass('cellTabRelatedto','off');ghide('addEventAlarmUI');ghide('addEventInviteUI');gshow('addEventRepeatUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventRelatedtoUI');">{$MOD.LBL_REPEAT}</a></td>
+										<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+										<td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabAlarm','off');switchClass('cellTabRepeat','off');switchClass('cellTabRelatedto','on');ghide('addEventAlarmUI');ghide('addEventInviteUI');gshow('addEventRelatedtoUI','',document.EditView.date_start.value,document.EditView.due_date.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value,document.EditView.endhr.value,document.EditView.endmin.value,document.EditView.endfmt.value);ghide('addEventRepeatUI');">{$MOD.LBL_RELATEDTO}</a></td>
+										<td class="dvtTabCache" style="width:100%">&nbsp;</td>
+									</tr>
+								</table>
+							</td></tr>
+							<tr>
+								<td width=100% valign=top align=left class="dvtContentSpace" style="padding:10px;height:120px">
+								<!-- Invite UI -->
+									<DIV id="addEventInviteUI" style="display:block;width:100%">
+									<table border=0 cellspacing=0 cellpadding=2 width=100%>
+										<tr>
+											<td valign=top> 
+												<table border=0 cellspacing=0 cellpadding=2 width=100%>
+													<tr><td colspan=3>
+														<ul style="padding-left:20px">
+														<li>{$MOD.LBL_INVITE_INST1}
+														<li>{$MOD.LBL_INVITE_INST2}
+														</ul>
+													</td></tr>
+													<tr>
+														<td><b>{$MOD.LBL_AVL_USERS}</b></td>
+														<td>&nbsp;</td>
+														<td><b>{$MOD.LBL_SEL_USERS}</b></td>
+													</tr>
+													<tr>
+														<td width=40% align=center valign=top>
+														<select name="availableusers" id="availableusers" class=small size=5 multiple style="height:70px;width:100%">
+														{foreach item=username key=userid from=$USERSLIST}
+														{if $userid != ''}
+														<option value="{$userid}">{$username}</option>
+														{/if}
+														{/foreach}
+														</select>
+														</td>
+														<td width=20% align=center valign=top>
+														<input type=button value="{$MOD.LBL_ADD_BUTTON} >>" class="crm button small save" style="width:100%"  onClick="incUser('availableusers','selectedusers')"><br>
+														<input type=button value="<< {$MOD.LBL_RMV_BUTTON} " class="crm button small cancel" style="width:100%" onClick="rmvUser('selectedusers')">
+														</td>
+														<td width=40% align=center valign=top>
+														<select name="selectedusers" id="selectedusers" class=small size=5 multiple style="height:70px;width:100%">
+														{foreach item=username key=userid from=$INVITEDUSERS}
+														{if $userid != ''}
+														<option value="{$userid}">{$username}</option>
+                                                                                                                {/if}
+                                                                                                                {/foreach}
+														</select>
+														<div align=left> {$MOD.LBL_SELUSR_INFO}
+														</div>
+														</td>
+													</tr>
+												</table>
+											</td>
+										</tr>
+									</table>
+									</DIV>
+									<!-- Reminder UI -->	
+									<DIV id="addEventAlarmUI" style="display:none;width:100%">
+									{if $LABEL.reminder_time neq ''}
+										<table>
+											{assign var=secondval value=$secondvalue.reminder_time}
+											{assign var=check value=$secondval[0]}
+											{assign var=yes_val value=$secondval[1]}
+											{assign var=no_val value=$secondval[2]}
+											
+											<tr><td>{$LABEL.reminder_time}</td><td>
+											<input type="radio" name="set_reminder" value="Yes" {$check} onClick="showBlock('reminderOptions')">&nbsp;{$yes_val}&nbsp;
+											<input type="radio" name="set_reminder" value="No" onClick="fnhide('reminderOptions')">&nbsp;{$no_val}&nbsp;
+											</td></tr>
+										</table>
+									{if $check eq 'CHECKED'}
+										{assign var=reminstyle value='style="display:block;width:100%"'}
+									{else}
+										{assign var=reminstyle value='style="display:none;width:100%"'}
+									{/if}
+									<DIV id="reminderOptions" {$reminstyle}>
+										<table border=0 cellspacing=0 cellpadding=2  width=100%>
+											<tr>
+												<td nowrap align=right width=20% valign=top><b>{$MOD.LBL_RMD_ON} : </b></td>
+												<td width=80%>
+													<table border=0>
+													<tr>
+														<td colspan=2>
+														{foreach item=val_arr from=$ACTIVITYDATA.reminder_time}
+														{assign var=start value="$val_arr[0]"}
+														{assign var=end value="$val_arr[1]"}
+														{assign var=sendname value="$val_arr[2]"}
+														{assign var=disp_text value="$val_arr[3]"}
+														{assign var=sel_val value="$val_arr[4]"}
+														<select name="{$sendname}">
+														{section name=reminder start=$start max=$end loop=$end step=1 }
+														{if $smarty.section.reminder.index eq $sel_val}
+														{assign var=sel_value value="SELECTED"}
+														{else}
+														{assign var=sel_value value=""}
+														{/if}
+														<OPTION VALUE="{$smarty.section.reminder.index}" "{$sel_value}">{$smarty.section.reminder.index}</OPTION>
+														{/section}
+														</select>
+														&nbsp;{$disp_text}
+														{/foreach}
+														</td>
+													</tr>
+													</table>
+												</td>
+											</tr>
+											<tr>
+												<td nowrap align=right>
+													{$MOD.LBL_SDRMD}
+												</td>
+												<td >
+													<input type=text name="toemail" readonly="readonly" class=textbox style="width:90%" value="{$USEREMAILID}">
+												</td>
+											</tr>
+										</table>
+									{/if}
+									</DIV>
+									</DIV>
+									<!-- Repeat UI -->
+									<div id="addEventRepeatUI" style="display:none;width:100%">
+									{if $LABEL.recurringtype neq ''}
+									<table border=0 cellspacing=0 cellpadding=2  width=100%>
+										<tr>
+											<td nowrap align=right width=20% valign=top>
+												<strong>{$MOD.LBL_REPEAT}</strong>
+											</td>
+											<td nowrap width=80% valign=top>
+												<table border=0 cellspacing=0 cellpadding=0>
+												<tr>
+							
+													<td width=20>
+													{if $ACTIVITYDATA.recurringcheck eq 'Yes'}
+														{assign var=rptstyle value='style="display:block"'}
+														{if $ACTIVITYDATA.eventrecurringtype eq 'Daily'}
+															{assign var=rptmonthstyle value='style="display:none"'}
+															{assign var=rptweekstyle value='style="display:none"'}
+														{elseif $ACTIVITYDATA.eventrecurringtype eq 'Weekly'}
+															{assign var=rptmonthstyle value='style="display:none"'}
+															{assign var=rptweekstyle value='style="display:block"'}
+														{elseif $ACTIVITYDATA.eventrecurringtype eq 'Monthly'}
+															{assign var=rptmonthstyle value='style="display:block"'}
+															{assign var=rptweekstyle value='style="display:none"'}
+														{elseif $ACTIVITYDATA.eventrecurringtype eq 'Yearly'}
+															{assign var=rptmonthstyle value='style="display:none"'}
+															{assign var=rptweekstyle value='style="display:none"'}
+														{/if}
+													<input type="checkbox" name="recurringcheck" onClick="showhide('repeatOptions')" checked>
+													{else}
+														{assign var=rptstyle value='style="display:none"'}
+														{assign var=rptmonthstyle value='style="display:none"'}
+														{assign var=rptweekstyle value='style="display:none"'}
+													<input type="checkbox" name="recurringcheck" onClick="showhide('repeatOptions')">
+													{/if}
+													</td>
+													<td colspan=2>{$MOD.LBL_ENABLE_REPEAT}<td>
+												</tr>
+												<tr>
+													<td colspan=2>
+													<div id="repeatOptions" {$rptstyle}>
+													<table border=0 cellspacing=0 cellpadding=2>
+													<tr>
+													<td>{$MOD.LBL_REPEAT_ONCE}</td>
+													<td><input type="text" name="repeat_frequency" class="textbox" style="width:20px" value="{$ACTIVITYDATA.repeat_frequency}" ></td>
+													<td><select name="recurringtype">
+													<option value="Daily" onClick="ghide('repeatWeekUI'); ghide('repeatMonthUI');" {if $ACTIVITYDATA.eventrecurringtype eq 'Daily'} selected {/if}>{$MOD.LBL_DAYS}</option>
+													<option value="Weekly" onClick="gshow('repeatWeekUI'); ghide('repeatMonthUI');" {if $ACTIVITYDATA.eventrecurringtype eq 'Weekly'} selected {/if}>{$MOD.LBL_WEEKS}</option>
+												<option value="Monthly" onClick="ghide('repeatWeekUI'); gshow('repeatMonthUI');" {if $ACTIVITYDATA.eventrecurringtype eq 'Monthly'} selected {/if}>{$MOD.LBL_MONTHS}</option>
+													<option value="Yearly" onClick="ghide('repeatWeekUI'); ghide('repeatMonthUI');"; {if $ACTIVITYDATA.eventrecurringtype eq 'Yearly'} selected {/if}>{$MOD.LBL_YEAR}</option>
+													</select>
+													</td>
+												</tr>
+												</table>
+												<div id="repeatWeekUI" {$rptweekstyle}>
+												<table border=0 cellspacing=0 cellpadding=2>
+												<tr>
+													<td><input name="sun_flag" value="sunday" {$ACTIVITYDATA.week0} type="checkbox"></td><td>{$MOD.LBL_SM_SUN}</td>
+													<td><input name="mon_flag" value="monday" {$ACTIVITYDATA.week1} type="checkbox"></td><td>{$MOD.LBL_SM_MON}</td>
+													<td><input name="tue_flag" value="tuesday" {$ACTIVITYDATA.week2} type="checkbox"></td><td>{$MOD.LBL_SM_TUE}</td>
+													<td><input name="wed_flag" value="wednesday" {$ACTIVITYDATA.week3} type="checkbox"></td><td>{$MOD.LBL_SM_WED}</td>
+													<td><input name="thu_flag" value="thursday" {$ACTIVITYDATA.week4} type="checkbox"></td><td>{$MOD.LBL_SM_THU}</td>
+													<td><input name="fri_flag" value="friday" {$ACTIVITYDATA.week5} type="checkbox"></td><td>{$MOD.LBL_SM_FRI}</td>
+													<td><input name="sat_flag" value="saturday" {$ACTIVITYDATA.week6} type="checkbox"></td><td>{$MOD.LBL_SM_SAT}</td>
+												</tr>
+												</table>
+												</div>
+	
+												<div id="repeatMonthUI" {$rptmonthstyle}>
+												<table border=0 cellspacing=0 cellpadding=2>
+												<tr>
+													<td>
+														<table border=0 cellspacing=0 cellpadding=2>
+														<tr>
+														<td><input type="radio" checked name="repeatMonth" {if $ACTIVITYDATA.repeatMonth eq 'date'} checked {/if} value="date"></td><td>on</td><td><input type="text" class=textbox style="width:20px" value="{$ACTIVITYDATA.repeatMonth_date}" name="repeatMonth_date" ></td><td>day of the month</td>
+														</tr>
+														</table>
+													</td>
+												</tr>
+												<tr>
+													<td>
+														<table border=0 cellspacing=0 cellpadding=2>
+														<tr><td>
+														<input type="radio" name="repeatMonth" {if $ACTIVITYDATA.repeatMonth eq 'day'} checked {/if} value="day"></td>
+														<td>on</td>
+														<td>
+														<select name="repeatMonth_daytype">
+															<option value="first" {if $ACTIVITYDATA.repeatMonth_daytype eq 'first'} selected {/if}>First</option>
+															<option value="last" {if $ACTIVITYDATA.repeatMonth_daytype eq 'last'} selected {/if}>Last</option>
+														</select>
+														</td>
+														<td>
+														<select name="repeatMonth_day">
+															<option value=1 {if $ACTIVITYDATA.repeatMonth_day eq 1} selected {/if}>{$MOD.LBL_DAY1}</option>
+															<option value=2 {if $ACTIVITYDATA.repeatMonth_day eq 2} selected {/if}>{$MOD.LBL_DAY2}</option>
+															<option value=3 {if $ACTIVITYDATA.repeatMonth_day eq 3} selected {/if}>{$MOD.LBL_DAY3}</option>
+															<option value=4 {if $ACTIVITYDATA.repeatMonth_day eq 4} selected {/if}>{$MOD.LBL_DAY4}</option>
+															<option value=5 {if $ACTIVITYDATA.repeatMonth_day eq 5} selected {/if}>{$MOD.LBL_DAY5}</option>
+															<option value=6 {if $ACTIVITYDATA.repeatMonth_day eq 6} selected {/if}>{$MOD.LBL_DAY6}</option>
+														</select>
+														</td>
+														</tr>
+														</table>
+													</td>
+												</tr>
+												</table>
+												</div>
+								
+											</div>
+										</td>
+										</tr>
+									</table>
+								</td>
+							</tr>
+						</table>
+						{/if}
+						</div>
+						<div id="addEventRelatedtoUI" style="display:none;width:100%">
+						<table width="100%" cellpadding="5" cellspacing="0" border="0">
+							{if $LABEL.parent_id neq ''}	
+							<tr>
+								<td><b>{$MOD.LBL_RELATEDTO}</b></td>
+								<td>
+									<input name="parent_id" type="hidden" value="{$secondvalue.parent_id}">
+									<select name="parent_type" class="small" id="parent_type" onChange="document.EditView.parent_name.value='';document.EditView.parent_id.value=''">
+									{section name=combo loop=$LABEL.parent_id}
+										<option value="{$fldlabel_combo.parent_id[combo]}" {$fldlabel_sel.parent_id[combo]}>{$LABEL.parent_id[combo]}</option>
+									{/section}
+                                             				</select>
+								</td>
+								<td>
+									<div id="eventrelatedto" align="left">
+										<input name="parent_name" readonly type="text" class="calTxt small" value="{$ACTIVITYDATA.parent_id}">
+										<input type="button" name="selectparent" class="crmButton small edit" value="Select" onclick="return window.open('index.php?module='+document.EditView.parent_type.value+'&action=Popup','test','width=640,height=602,resizable=0,scrollbars=0,top=150,left=200');">
+									</div>
+								</td>
+							</tr>
+							{/if}
+							<tr>
+								<td><b>{$APP.Contacts}</b></td>
+								<td colspan="2">
+									<input name="contactidlist" id="contactidlist" value="{$CONTACTSID}" type="hidden">
+									<textarea rows="5" name="contactlist" readonly="readonly" class="calTxt" id='parentid'>{$CONTACTSNAME}</textarea>&nbsp;
+									<input type="button" onclick="selectContact('true','general',document.EditView);" class="crmButton small edit" name="selectcnt" value="Select Contacts">
+								</td>
+							</tr>
+						</table>
+					</div>
+			</td>
+		</tr>
+		</table>
+		<!-- Alarm, Repeat, Invite stops-->
+		{else}
+		<table border="0" cellpadding="5" cellspacing="0" width="100%">
+			<tr>
+                        	<td class="cellLabel" width="20%" align="right"><b><font color="red">*</font>{$MOD.LBL_TODO}</b></td>
+                        	<td class="cellInfo" width="80%" align="left"><input name="subject" value="{$ACTIVITYDATA.subject}" class="textbox" style="width: 70%;" type="text"></td>
+           		</tr>
+			
+			<tr>
+				{if $LABEL.description != ''}
+				<td class="cellLabel" align="right"><b>{$LABEL.description}</b></td>
+				<td class="cellInfo" align="left"><textarea style="width: 90%; height: 60px;" name="description">{$ACTIVITYDATA.description}</textarea>
+				{/if}
+				
+			</tr>
+			<tr>
+		    		<td colspan="2" align="center" width="100%" style="padding:0px">
+					<table border="0" cellpadding="5" cellspacing="1" width="100%">
+            					<tr>
+							{if $LABEL.taskstatus != ''}
+							<td class="cellLabel" width=33% align="left"><b>{$LABEL.taskstatus}</b></td>
+							{/if}
+							{if $LABEL.taskpriority != ''}
+              						<td class="cellLabel" width=33% align="left"><b>{$LABEL.taskpriority}</b></td>
+							{/if}
+              						{if $LABEL.assigned_user_id != ''}
+							<td class="cellLabel" width=34% align="left"><b>{$LABEL.assigned_user_id}</b></td>
+							{/if}
+						</tr>
+						<tr>
+							{if $LABEL.taskstatus != ''}
+							<td align="left" valign="top">
+								<select name="taskstatus" id="taskstatus" class=small>
+                                        			{foreach item=arr from=$ACTIVITYDATA.taskstatus}
+                                        			{foreach key=sel_value item=value from=$arr}
+                                                			<option value="{$sel_value}" {$value}>
+                                                        		{if $MOD.$sel_value neq ''}
+                                                                		{$MOD.$sel_value}
+                                                        		{else}
+                                                                		{$sel_value}
+                                                        		{/if}
+                                                			</option>
+                                        			{/foreach}
+                                        			{/foreach}
+                                				</select>
+							</td>
+							{/if}
+							{if $LABEL.taskpriority != ''}
+							<td align="left" valign="top">
+								<select name="taskpriority" id="taskpriority" class=small>
+        			                                {foreach item=arr from=$ACTIVITYDATA.taskpriority}
+                                			        {foreach key=sel_value item=value from=$arr}
+			                                                <option value="{$sel_value}" {$value}>
+                        		                                {if $MOD.$sel_value neq ''}
+                                        		                        {$MOD.$sel_value}
+                                                       			{else}
+                                                                		{$sel_value}
+                                                        		{/if}
+                                                			</option>
+                                        			{/foreach}
+                                        			{/foreach}
+                                				</select>
+							</td>
+							{/if}
+							{if $LABEL.assigned_user_id != ''}
+							<td align="left" valign="top">
+								{assign var=check value=1}
+                                        			{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
+			                                        {foreach key=sel_value item=value from=$arr}
+                        		                              	{if $value ne ''}
+                                        		                      	{assign var=check value=$check*0}
+                                                        		{else}
+                                                                		{assign var=check value=$check*1}
+                                                        		{/if}
+                                                		{/foreach}
+                                        			{/foreach}
+								{if $check eq 0}
+                                             				{assign var=select_user value='checked'}
+                                                			{assign var=style_user value='display:block'}
+                                                			{assign var=style_group value='display:none'}
+                                        			{else}
+                                                			{assign var=select_group value='checked'}
+                                                			{assign var=style_user value='display:none'}
+                                                			{assign var=style_group value='display:block'}
+                                        			{/if}
+				                                <input type="radio" name="assigntype" {$select_user} value="U" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_USER}
+				                                {if $secondvalue.assigned_user_id neq ''}
+                                			        <input type="radio" name="assigntype" {$select_group} value="T" onclick="toggleAssignType(this.value)">&nbsp;{$APP.LBL_GROUP}
+                                        			{/if}
+                                        			<span id="assign_user" style="{$style_user}">
+                                                		<select name="assigned_user_id" class=small>
+                                                        	{foreach key=key_one item=arr from=$ACTIVITYDATA.assigned_user_id}
+				                                {foreach key=sel_value item=value from=$arr}
+                                		                	<option value="{$key_one}" {$value}>{$sel_value}</option>
+								{/foreach}
+                                                        	{/foreach}
+                                                		</select>
+								</span>
+								{if $secondvalue.assigned_user_id neq ''}
+                                                		<span id="assign_team" style="{$style_group}">
+                                                        		<select name="assigned_group_name" class=small>';
+                                                                		{foreach key=key_one item=arr from=$secondvalue.assigned_user_id}
+                                                                       		{foreach key=sel_value item=value from=$arr}
+                                                                               		<option value="{$sel_value}" {$value}>{$sel_value}</option>
+                                                                       		{/foreach}
+                                                                		{/foreach}
+                                                        		</select>
+				                                </span>
+                                				{/if}	
+							</td>
+							{else}
+								<input name="assigned_user_id" value="{$CURRENTUSERID}" type="hidden">
+							{/if}
+						</tr>
+					</table>
+				</td>
+			</tr>
+			</table>
+			<table border="0" cellpadding="0" cellspacing="1" width="100%" align=center>
+			<tr><td width=50% valign=top>
+				<table border=0 cellspacing=0 cellpadding=2 width=100% align=center >
+					<tr><td colspan=3  class="mailSubHeader"><b>{$MOD.LBL_TODODATETIME}</b></td></tr>
+					<tr><td colspan=3>{$STARTHOUR}</td></tr>
+					<tr><td>
+							{foreach key=date_value item=time_value from=$ACTIVITYDATA.date_start}
+	                                        		{assign var=date_val value="$date_value"}
+								{assign var=time_val value="$time_value"}
+                                        		{/foreach}
+							<input name="date_start" id="date_start" class="textbox" style="width: 90px;" onChange="dochange('date_start','due_date');" value="{$date_val}" type="text"></td><td width=100%><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$MOD.LBL_SET_DATE}" title="{$MOD.LBL_SET_DATE}" id="jscal_trigger_date_start" align="middle" border="0">
+							{foreach key=date_fmt item=date_str from=$secondvalue.date_start}
+								{assign var=date_vl value="$date_fmt"}
+							{/foreach}				
+							<script type="text/javascript">
+								Calendar.setup ({ldelim}
+	        	                                	inputField : "date_start", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
+							{rdelim})
+							</script>
+						</td></tr>
+					</table></td>
+					<td width=50% valign="top">
+                                                <table border="0" cellpadding="2" cellspacing="0" width="100%" align=center>
+							<tr><td class="mailSubHeader" colspan=3><b>{$LABEL.due_date}</b></td></tr>
+							<tr><td>
+								{foreach key=date_value item=time_value from=$ACTIVITYDATA.due_date}
+									{assign var=date_val value="$date_value"}
+									{assign var=time_val value="$time_value"}
+								{/foreach}
+								<input name="due_date" id="due_date" class="textbox" style="width: 90px;" value="{$date_val}" type="text"></td><td width=100%><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$MOD.LBL_SET_DATE}" title="{$MOD.LBL_SET_DATE}" id="jscal_trigger_due_date" border="0">
+								{foreach key=date_fmt item=date_str from=$secondvalue.due_date}
+                                                			{assign var=date_vl value="$date_fmt"}
+                                        			{/foreach}
+				      				<script type="text/javascript">
+								Calendar.setup ({ldelim}
+	                                        			inputField : "due_date", ifFormat : "{$date_vl}", showsTime : false, button : "jscal_trigger_due_date", singleClick : true, step : 1
+					   			{rdelim})
+								</script>
+        						</td></tr>
+						</table></td>
+					</tr>
+				</table>
+				<br><br>
+		<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%" bgcolor="#FFFFFF">
+			<tr>
+				<td>
+					<table border="0" cellpadding="3" cellspacing="0" width="100%">
+						<tr>
+							<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
+							<td id="cellTabInvite" class="dvtSelectedCell" align="center" nowrap="nowrap"><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','on');switchClass('cellTabRelatedto','off');Taskshow('addTaskAlarmUI','todo',document.EditView.date_start.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value);ghide('addTaskRelatedtoUI');">{$MOD.LBL_NOTIFICATION}</a></td>
+							<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
+                                                        <td id="cellTabRelatedto" class="dvtUnSelectedCell" align=center nowrap><a href="javascript:doNothing()" onClick="switchClass('cellTabInvite','off');switchClass('cellTabRelatedto','on');Taskshow('addTaskRelatedtoUI','todo',document.EditView.date_start.value,document.EditView.starthr.value,document.EditView.startmin.value,document.EditView.startfmt.value);ghide('addTaskAlarmUI');">{$MOD.LBL_RELATEDTO}</a></td>
+                                                        <td class="dvtTabCache" style="width:100%">&nbsp;</td>
+						</tr>
+
+					</table>
+				</td>
+			</tr>
+			<tr>
+				<td class="dvtContentSpace" style="padding: 10px; height: 120px;" align="left" valign="top" width="100%">
+			<!-- Reminder UI -->
+			<div id="addTaskAlarmUI" style="display: block; width: 100%;">
+			{if $LABEL.sendnotification != ''}
+                	<table>
+				<tr><td>{$LABEL.sendnotification}</td>
+					{if $ACTIVITYDATA.sendnotification eq 1}
+                                        <td>
+                                                <input name="sendnotification" type="checkbox" checked>
+                                        </td>
+                                	{else}
+                                        <td>
+                                                <input name="sendnotification" type="checkbox">
+                                        </td>
+                                	{/if}
+				</tr>
+			</table>
+			{/if}
+			</div>
+			<div id="addTaskRelatedtoUI" style="display:none;width:100%">
+           		     <table width="100%" cellpadding="5" cellspacing="0" border="0">
+			     {if $LABEL.parent_id neq ''}
+                	     <tr>
+                        	     <td><b>{$MOD.LBL_RELATEDTO}</b></td>
+                                     <td>
+					<input name="parent_id" type="hidden" value="{$secondvalue.parent_id}">
+                                             <select name="parent_type" class="small" id="parent_type" onChange="document.EditView.parent_name.value='';document.EditView.parent_id.value=''">
+							{section name=combo loop=$LABEL.parent_id}
+								<option value="{$fldlabel_combo.parent_id[combo]}" {$fldlabel_sel.parent_id[combo]}>{$LABEL.parent_id[combo]}</option>
+							{/section}
+					     </select>
+                                     </td>
+                                     <td>
+                              	        <div id="taskrelatedto" align="left">
+						<input name="parent_name" readonly type="text" class="calTxt small" value="{$ACTIVITYDATA.parent_id}">
+						<input type="button" name="selectparent" class="crmButton small edit" value="Select" onclick="return window.open('index.php?module='+document.EditView.parent_type.value+'&action=Popup','test','width=640,height=602,resizable=0,scrollbars=0,top=150,left=200');">
+					 </div>
+                                     </td>
+			     </tr>
+			     {/if}
+			     {if $LABEL.contact_id neq ''}	
+			     <tr>
+                                     <td><b>{$LABEL.contact_id}</b></td>
+				     <td colspan="2">
+						<input name="contact_name" id = "contact_name" readonly type="text" class="calTxt" value="{$ACTIVITYDATA.contact_id}"><input name="contact_id"  type="hidden" value="{$secondvalue.contact_id}">&nbsp;
+						<input type="button" onclick="selectContact('false','task',document.EditView);" class="crmButton small edit" name="selectcnt" value="Select Contact">
+				     </td>
+                             </tr>
+			     {/if}
+		</table>
+              	</div>
+                </td></tr></table>
+
+		{/if}
+			</td></tr>
+			<tr>
+				<td  colspan=4 style="padding:5px">
+					<div align="center">
+                        	        	<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" {if $ACTIVITY_MODE neq 'Task'} onclick="this.form.action.value='Save';  displaydeleted();return maincheck_form();"{else} onclick="this.form.action.value='Save';  displaydeleted(); maintask_check_form();return formValidate();" {/if} type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+						<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+					</div>
+				</td>
+			</tr></table>
+		</td></tr></table>
+		</td></tr></table>
+		</td></tr></table>
+		</td></tr></table>
+		</td></tr></table>
+</td></tr>
+</form></table>
+</td></tr></table>
+</td></tr></table>
+</td></tr></table>
+        </td></tr></table>
+        </td></tr></table>
+        </div>
+        </td>
+        <td valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+        </tr>
+        </table>
+<script>
+{if $ACTIVITY_MODE eq 'Task'}
+	var fieldname = new Array('subject','date_start','time_start','due_date','taskstatus');
+        var fieldlabel = new Array('{$MOD.LBL_LIST_SUBJECT}','{$MOD.LBL_START_DATE}','{$MOD.LBL_TIME}','{$MOD.LBL_DUE_DATE}','{$MOD.LBL_STATUS}');
+        var fielddatatype = new Array('V~M','D~M~time_start','T~O','D~M~OTH~GE~date_start~Start Date & Time','V~O');
+{else}
+	var fieldname = new Array('subject','date_start','due_date','taskpriority','sendnotification','parent_id','contact_id','reminder_time','recurringtype');
+        var fieldlabel = new Array('{$MOD.LBL_LIST_SUBJECT}','{$MOD.LBL_START_DATE}','{$MOD.LBL_DUE_DATE}','{$MOD.Priority}','{$MOD.LBL_SENDNOTIFICATION}','{$MOD.LBL_RELATEDTO}','{$MOD.LBL_CONTACT_NAME}','{$MOD.LBL_SENDREMINDER}','{$MOD.Recurrence}');
+        var fielddatatype = new Array('V~M','D~M','D~M~OTH~GE~date_start~Start Date','V~O','C~O','I~O','I~O','I~O','O~O');
+{/if}
+</script>
+<script>	
+	var ProductImages=new Array();
+	var count=0;
+
+	function delRowEmt(imagename)
+	{ldelim}
+		ProductImages[count++]=imagename;
+	{rdelim}
+
+	function displaydeleted()
+	{ldelim}
+		var imagelists='';
+		for(var x = 0; x < ProductImages.length; x++)
+		{ldelim}
+			imagelists+=ProductImages[x]+'###';
+		{rdelim}
+
+		if(imagelists != '')
+			document.EditView.imagelist.value=imagelists
+	{rdelim}
+
+</script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ActivityListView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ActivityListView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ActivityListView.tpl Mon Apr 16 12:27:44 2007
@@ -16,7 +16,7 @@
 <script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
 <script language="JavaScript" type="text/javascript" src="include/js/ListView.js"></script>
 <script language="JavaScript" type="text/javascript" src="include/js/search.js"></script>
-<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 <script language="javascript">
 function checkgroup()
 {ldelim}
@@ -41,7 +41,6 @@
         	getObj(data_td_id).className = 'searchAlph';
     	{rdelim}
    	gPopupAlphaSearchUrl = '';
-
 	search_fld_val= document.basicSearch.search_field[document.basicSearch.search_field.selectedIndex].value;
         search_txt_val=document.basicSearch.search_text.value;
         var urlstring = '';
@@ -79,6 +78,7 @@
                                 $("ListViewContents").innerHTML= result[2];
                                 if(result[1] != '')
                                         alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
 			{rdelim}
 	       {rdelim}
         );
@@ -105,6 +105,7 @@
 				$("ListViewContents").innerHTML= result[2];
 				if(result[1] != '')
 			                alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
 			{rdelim}
 		{rdelim}
 	);
@@ -117,7 +118,7 @@
                                         <table border=0 cellspacing=0 cellpadding=0 width=100%>
                                         <tr>
                                                 <td align=center>
-                                                <img src="images/searching.gif" alt="Searching... please wait"  title="Searching... please wait">
+                                                <img src="{$IMAGE_PATH}searching.gif" alt="{$APP.LBL_SEARCHING}"  title="{$APP.LBL_SEARCHING}">
                                                 </td>
                                         </tr>
                                         </table>
@@ -139,18 +140,22 @@
 	<td class="showPanelBg" valign="top" width=100% style="padding:10px;">
 	 <!-- SIMPLE SEARCH -->
 <div id="searchAcc" style="z-index:1;display:none;position:relative;">
+<form name="basicSearch" method="post" action="index.php" onSubmit="return callSearch('Basic');">
 <table width="80%" cellpadding="5" cellspacing="0"  class="searchUIBasic small" align="center" border=0>
 	<tr>
 		<td class="searchUIName small" nowrap align="left">
-		<span class="moduleName">Search</span><br><span class="small"><a href="#" onClick="fnhide('searchAcc');show('advSearch');document.basicSearch.searchtype.value='advance';">{$APP.LBL_GO_TO} {$APP.LNK_ADVANCED_SEARCH}</a></span>
+		<span class="moduleName">{$APP.LBL_SEARCH}</span><br><span class="small"><a href="#" onClick="fnhide('searchAcc');show('advSearch');document.basicSearch.searchtype.value='advance';">{$APP.LBL_GO_TO} {$APP.LNK_ADVANCED_SEARCH}</a></span>
 		<!-- <img src="{$IMAGE_PATH}basicSearchLens.gif" align="absmiddle" alt="{$APP.LNK_BASIC_SEARCH}" title="{$APP.LNK_BASIC_SEARCH}" border=0>&nbsp;&nbsp;-->
 		</td>
 		<td class="small" nowrap align=right><b>{$APP.LBL_SEARCH_FOR}</b></td>
 		<td class="small"><input type="text"  class="txtBox" style="width:120px" name="search_text"></td>
-		<td class="small" nowrap><b>{$APP.LBL_IN}</b>&nbsp;
-			<select name ="search_field" class="txtBox" style="width:150px">
-			 {html_options  options=$SEARCHLISTHEADER }
-			</select>
+		<td class="small" nowrap><b>{$APP.LBL_IN}</b>&nbsp;</td>
+		<td class="small" nowrap>
+			<div id="basicsearchcolumns_real">
+                        <select name="search_field" id="bas_searchfield" class="txtBox" style="width:150px">
+                         {html_options  options=$SEARCHLISTHEADER }
+                        </select>
+                        </div>
                         <input type="hidden" name="searchtype" value="BasicSearch">
                         <input type="hidden" name="module" value="{$MODULE}">
                         <input type="hidden" name="parenttab" value="{$CATEGORY}">
@@ -165,7 +170,7 @@
 		<td class="small" valign="top" onMouseOver="this.style.cursor='pointer';" onclick="moveMe('searchAcc');searchshowhide('searchAcc','advSearch')">[x]</td>
 	</tr>
 	<tr>
-		<td colspan="6" align="center" class="small">
+		<td colspan="7" align="center" class="small">
 			<table border=0 cellspacing=0 cellpadding=0 width=100%>
 				<tr>
                                                 {$ALPHABETICAL}
@@ -174,12 +179,14 @@
 		</td>
 	</tr>
 </table>
+</form>
 </div>
 <!-- ADVANCED SEARCH -->
 <div id="advSearch" style="display:none;">
+<form name="advSearch" method="post" action="index.php" onSubmit="totalnoofrows();return callSearch('Advanced');">
 		<table  cellspacing=0 cellpadding=5 width=80% class="searchUIAdv1 small" align="center" border=0>
 			<tr>
-					<td class="searchUIName small" nowrap align="left"><span class="moduleName">Search</span><br><span class="small"><a href="#" onClick="show('searchAcc');fnhide('advSearch')">{$APP.LBL_GO_TO} {$APP.LNK_BASIC_SEARCH}</a></span></td>
+					<td class="searchUIName small" nowrap align="left"><span class="moduleName">{$APP.LBL_SEARCH}</span><br><span class="small"><a href="#" onClick="show('searchAcc');fnhide('advSearch')">{$APP.LBL_GO_TO} {$APP.LNK_BASIC_SEARCH}</a></span></td>
 					<td nowrap class="small"><b><input name="matchtype" type="radio" value="all">&nbsp;{$APP.LBL_ADV_SEARCH_MSG_ALL}</b></td>
 					<td nowrap width=60% class="small" ><b><input name="matchtype" type="radio" value="any" checked>&nbsp;{$APP.LBL_ADV_SEARCH_MSG_ANY}</b></td>
 					<td class="small" valign="top" onMouseOver="this.style.cursor='pointer';" onclick="moveMe('searchAcc');searchshowhide('searchAcc','advSearch')">[x]</td>
@@ -223,8 +230,8 @@
 			</td>
 		</tr>
 	</table>
+</form>
 </div>		
-</form>
 {*<!-- Searching UI -->*}
 
 
@@ -315,7 +322,7 @@
        		       </tr>
 			 </table>
                          <div  class="calDIV" style="overflow:auto;">
-			 <table border=0 cellspacing=1 cellpadding=3 width=100% class="calListTable" class="small">
+			 <table border=0 cellspacing=1 cellpadding=3 width=100% class="lvt small" class="small">
 			      <tr>
              			 <td class="lvtCol"><input type="checkbox"  name="selectall" onClick=toggleSelect(this.checked,"selected_id")></td>
 				 {foreach name="listviewforeach" item=header from=$LISTHEADER}
@@ -340,7 +347,7 @@
 							<table border="0" cellpadding="5" cellspacing="0" width="98%">
 							<tr>
 								<td rowspan="2" width="25%"><img src="{$IMAGE_PATH}empty.jpg" height="60" width="61"></td>
-								<td style="border-bottom: 1px solid rgb(204, 204, 204);" nowrap="nowrap" width="75%"><span class="genHeaderSmall">{$APP.LBL_NO} {$APP.$MODULE_CREATE}s {$APP.LBL_FOUND} !</span></td>
+								<td style="border-bottom: 1px solid rgb(204, 204, 204);" nowrap="nowrap" width="75%"><span class="genHeaderSmall">{$APP.LBL_NO} {$APP.ACTIVITIES} {$APP.LBL_FOUND} !</span></td>
 							</tr>
 							<tr>
 							<td class="small" align="left" nowrap="nowrap">{$APP.LBL_YOU_CAN_CREATE} {$APP.$vowel_conf} {$APP.$MODULE_CREATE} {$APP.LBL_NOW}. {$APP.LBL_CLICK_THE_LINK}:<br>
@@ -358,7 +365,7 @@
 							<table border="0" cellpadding="5" cellspacing="0" width="98%">
 							<tr>
 								<td rowspan="2" width="25%"><img src="{$IMAGE_PATH}empty.jpg" height="60" width="61"></td>
-								<td style="border-bottom: 1px solid rgb(204, 204, 204);" nowrap="nowrap" width="75%"><span class="genHeaderSmall">{$APP.LBL_NO} {$APP.$MODULE_CREATE}s {$APP.LBL_FOUND} !</span></td>
+								<td style="border-bottom: 1px solid rgb(204, 204, 204);" nowrap="nowrap" width="75%"><span class="genHeaderSmall">{$APP.LBL_NO} {$APP.ACTIVITIES} {$APP.LBL_FOUND} !</span></td>
 							</tr>
 							<tr>
 								<td class="small" align="left" nowrap="nowrap">{$APP.LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE} {$APP.$vowel_conf} {$APP.$MODULE_CREATE}<br>
@@ -442,10 +449,10 @@
 	        <input type = "radio" name = "user_lead_owner"  onclick=checkgroup();  checked>{$APP.LBL_USER}&nbsp;
 					<input type = "radio" name = "user_lead_owner" onclick=checkgroup(); >{$APP.LBL_GROUP}<br>
 					<select name="lead_owner" id="lead_owner" class="detailedViewTextBox">
-					{$CHANGE_OWNER}
+						{$CHANGE_OWNER}
 					</select>
 					<select name="lead_group_owner" id="lead_group_owner" class="detailedViewTextBox" style="display:none;">
-					{$CHANGE_GROUP_OWNER}
+						{$CHANGE_GROUP_OWNER}
 					</select>
 					</form>
 	</td>
@@ -508,6 +515,7 @@
                                 $("ListViewContents").innerHTML= result[2];
                                 if(result[1] != '')
                                         alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
                         }
                 }
         );

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/AddMailAccount.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/AddMailAccount.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/AddMailAccount.tpl Mon Apr 16 12:27:44 2007
@@ -21,7 +21,7 @@
                         <hr noshade="noshade" size="1"><br>
 
   		<form action="index.php" method="post" name="EditView" id="form">
-			<input type="hidden" name="module" value="Settings">
+			<input type="hidden" name="module" value="Users">
 		  	<input type="hidden" name="action">
   			<input type="hidden" name="server_type" value="email">
 			<input type="hidden" name="record" value="{$ID}">

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/AddProductToPriceBooks.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/AddProductToPriceBooks.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/AddProductToPriceBooks.tpl Mon Apr 16 12:27:44 2007
@@ -1,164 +1,164 @@
-<!--*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
--->
-{literal}
-<script language="javascript">
-function addtopricebook()
-{
-	x = document.addToPB.selected_id.length;
-	prod_array = new Array(x);
-	idstring = "";
-	if ( x == undefined)
-	{
-		if (document.addToPB.selected_id.checked)
-		{
-			yy = document.addToPB.selected_id.value+"_listprice";
-			document.addToPB.idlist.value=document.addToPB.selected_id.value;
-			var elem = document.addToPB.elements;
-			var ele_len =elem.length;
-			var i=0,j=0;
-	
-			for(i=0; i<ele_len; i++)
-			{	
-				if(elem[i].name == yy)
-				{
-					if (elem[i].value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) 
-					{
-						alert("List Price cannot be empty");
-			               		return false;	
-					}	
-					else if(isNaN(elem[i].value))
-                                        {
-                                                alert("Invalid List Price");
-                                                return false;
-                                        }
-
-				}
-			}	
-			
-		}
-		else 
-		{
-			alert("Please select at least one entity");
-			return false;
-		}
-	}
-	else
-	{
-		xx = 0;
-		for(i = 0; i < x ; i++)
-		{
-			if(document.addToPB.selected_id[i].checked)
-			{
-				idstring = document.addToPB.selected_id[i].value +";"+idstring;
-				 prod_array[xx] = document.addToPB.selected_id[i].value;
-				
-				xx++;	
-			}
-		}
-		if (xx != 0)
-		{
-			document.addToPB.idlist.value=idstring;
-			var elem = document.addToPB.elements;
-                        var ele_len =elem.length;
-                        var i=0,j=0;
-
-                        for(i=0; i<ele_len; i++)
-                        {
-                                for(j=0; j < xx; j++)
-                                {
-                                        var xy= prod_array[j]+"_listprice";
-                                        if(elem[i].name == xy)
-                                        {
-						if (elem[i].value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) 
-						{
-							alert("List Price cannot be empty");
-			                		return false;	
-						}
-						else if(isNaN(elem[i].value))
-                	                        {
-        	                                        alert("Invalid List Price");
-                                                	return false;
-                                        	}
-	
-                                        }
-                                }
-                        }
-
-		}
-		else
-		{
-			alert("Please select at least one entity");
-			return false;
-		}
-	}
-{/literal}
-document.addToPB.action="index.php?module=Products&action=addPbProductRelToDB&return_module=Products&return_action=DetailView&return_id={$RETURN_ID}"
-{rdelim}
-
-
-function updateAllListPrice(unitprice)
-{ldelim}
-        var fieldname_array = new Array({$FIELD_NAME_ARRAY});
-        var unitprice,fieldname;
-	var id;
-	var fieldinfo;
-	var checkid;
-
-        for(j=0; j<fieldname_array.length; j++)
-        {ldelim}
-		fieldinfo = fieldname_array[j].split("_");
-		id = fieldinfo[0];
-		checkid = "check_"+id;
-
-                fieldname=fieldname_array[j];
-                updateListPrice(unitprice,fieldname,document.getElementById(checkid));
-        {rdelim}
-{rdelim}
-
-</script>
-<script language="javascript" src="modules/Products/Product.js"></script>
-<table width="95%" border="0" cellpadding="0" cellspacing="0">
-<tr><td colspan="3">&nbsp;</td></tr>
-<tr>
-		<td>&nbsp;</td>
-		<td class="showPanelBg">
-{$PRICEBOOKLISTHEADER}
-<table border="0" cellpadding="0" cellspacing="0"  width="100%">
-  <tr height="20"> 
-    <td  class="listFormHeaderLinks">
-	 <table border="0" cellpadding="0" cellspacing="0" width="100%">
-		<tr>
-			<td>&nbsp;{$RECORD_COUNTS}</td>
-			   {$NAVIGATION}
-		</tr>
-	 </table>
-    </td>
-   </tr>
-   <tr>
-   			<td>
-					<table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="3" cellspacing="1" width="90%" align="center">
-							 {$LISTHEADER}
-							 {$LISTENTITY}
-					</table>
-			</td>
-   </tr>   
-   <tr><td>&nbsp;</td></tr>
-   </form>
-</table>
-
-</form>
-</table>
-</td>
-<td>&nbsp;</td>
-</tr>
-</table>
-
-
+<!--*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+-->
+{literal}
+<script language="javascript">
+function addtopricebook()
+{
+	x = document.addToPB.selected_id.length;
+	prod_array = new Array(x);
+	idstring = "";
+	if ( x == undefined)
+	{
+		if (document.addToPB.selected_id.checked)
+		{
+			yy = document.addToPB.selected_id.value+"_listprice";
+			document.addToPB.idlist.value=document.addToPB.selected_id.value;
+			var elem = document.addToPB.elements;
+			var ele_len =elem.length;
+			var i=0,j=0;
+	
+			for(i=0; i<ele_len; i++)
+			{	
+				if(elem[i].name == yy)
+				{
+					if (elem[i].value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) 
+					{
+						alert(alert_arr.LISTPRICE_CANNOT_BE_EMPTY);
+			               		return false;	
+					}	
+					else if(isNaN(elem[i].value))
+                                        {
+                                                alert(alert_arr.INVALID_LIST_PRICE);
+                                                return false;
+                                        }
+
+				}
+			}	
+			
+		}
+		else 
+		{
+			alert(alert_arr.SELECT);
+			return false;
+		}
+	}
+	else
+	{
+		xx = 0;
+		for(i = 0; i < x ; i++)
+		{
+			if(document.addToPB.selected_id[i].checked)
+			{
+				idstring = document.addToPB.selected_id[i].value +";"+idstring;
+				 prod_array[xx] = document.addToPB.selected_id[i].value;
+				
+				xx++;	
+			}
+		}
+		if (xx != 0)
+		{
+			document.addToPB.idlist.value=idstring;
+			var elem = document.addToPB.elements;
+                        var ele_len =elem.length;
+                        var i=0,j=0;
+
+                        for(i=0; i<ele_len; i++)
+                        {
+                                for(j=0; j < xx; j++)
+                                {
+                                        var xy= prod_array[j]+"_listprice";
+                                        if(elem[i].name == xy)
+                                        {
+						if (elem[i].value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) 
+						{
+							alert(alert_arr.LISTPRICE_CANNOT_BE_EMPTY);
+			                		return false;	
+						}
+						else if(isNaN(elem[i].value))
+                	                        {
+        	                                        alert(alert_arr.INVALID_LIST_PRICE);
+                                                	return false;
+                                        	}
+	
+                                        }
+                                }
+                        }
+
+		}
+		else
+		{
+			alert(alert_arr.SELECT);
+			return false;
+		}
+	}
+{/literal}
+document.addToPB.action="index.php?module=Products&action=addPbProductRelToDB&return_module=Products&return_action=DetailView&return_id={$RETURN_ID}"
+{rdelim}
+
+
+function updateAllListPrice(unitprice)
+{ldelim}
+        var fieldname_array = new Array({$FIELD_NAME_ARRAY});
+        var unitprice,fieldname;
+	var id;
+	var fieldinfo;
+	var checkid;
+
+        for(j=0; j<fieldname_array.length; j++)
+        {ldelim}
+		fieldinfo = fieldname_array[j].split("_");
+		id = fieldinfo[0];
+		checkid = "check_"+id;
+
+                fieldname=fieldname_array[j];
+                updateListPrice(unitprice,fieldname,document.getElementById(checkid));
+        {rdelim}
+{rdelim}
+
+</script>
+<script language="javascript" src="modules/Products/Products.js"></script>
+<table width="95%" border="0" cellpadding="0" cellspacing="0">
+<tr><td colspan="3">&nbsp;</td></tr>
+<tr>
+		<td>&nbsp;</td>
+		<td class="showPanelBg">
+{$PRICEBOOKLISTHEADER}
+<table border="0" cellpadding="0" cellspacing="0"  width="100%">
+  <tr height="20"> 
+    <td  class="listFormHeaderLinks">
+	 <table border="0" cellpadding="0" cellspacing="0" width="100%">
+		<tr>
+			<td>&nbsp;{$RECORD_COUNTS}</td>
+			   {$NAVIGATION}
+		</tr>
+	 </table>
+    </td>
+   </tr>
+   <tr>
+   			<td>
+					<table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="3" cellspacing="1" width="90%" align="center">
+							 {$LISTHEADER}
+							 {$LISTENTITY}
+					</table>
+			</td>
+   </tr>   
+   <tr><td>&nbsp;</td></tr>
+   </form>
+</table>
+
+</form>
+</table>
+</td>
+<td>&nbsp;</td>
+</tr>
+</table>
+
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/AddProductsToPriceBook.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/AddProductsToPriceBook.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/AddProductsToPriceBook.tpl Mon Apr 16 12:27:44 2007
@@ -1,65 +1,65 @@
-<!--*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
--->
-<script language="javascript">
-
-function updateAllListPrice()
-{ldelim}
-        var unitprice_array = new Array({$UNIT_PRICE_ARRAY});
-        var fieldname_array = new Array({$FIELD_NAME_ARRAY});
-
-	var n=unitprice_array.length;	
-	var unitprice,fieldname;
-	var id;
-	var fieldinfo;
-	var checkid;
-
-	for(j=0; j<unitprice_array.length; j++)
-	{ldelim}
-		fieldinfo = fieldname_array[j].split("_");
-		id = fieldinfo[0];
-		checkid = "check_"+id;
-
-		unitprice=unitprice_array[j];
-		fieldname=fieldname_array[j];	
-		updateListPrice(unitprice,fieldname,document.getElementById(checkid));
-	{rdelim}
-{rdelim}
-
-</script>
-<script language="javascript" src="modules/PriceBooks/PriceBook.js"></script>
-<BR>
-<BR>
-{$PRODUCTLISTHEADER}
-<table border="0" cellpadding="0" cellspacing="0" class="FormBorder" width="100%">
-  <tr height="20"> 
-    <td >
-	 <table border="0" cellpadding="0" cellspacing="0" width="100%">
-		<tr>
-			<td>&nbsp;{$RECORD_COUNTS}</td>
-			   {$NAVIGATION}
-		</tr>
-	 </table>
-    </td>
-   </tr>
-   <tr><td >
-   <table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="3" cellspacing="1" width="90%" align="center">
-   {$LISTHEADER}
-   {$LISTENTITY}
-   </table>
-   </td></tr>
-   <tr><td>&nbsp;</td></tr>
-   </form>
-</table>
-
-</form>
-</table>
-
-
+<!--*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+-->
+<script language="javascript">
+
+function updateAllListPrice()
+{ldelim}
+        var unitprice_array = new Array({$UNIT_PRICE_ARRAY});
+        var fieldname_array = new Array({$FIELD_NAME_ARRAY});
+
+	var n=unitprice_array.length;	
+	var unitprice,fieldname;
+	var id;
+	var fieldinfo;
+	var checkid;
+
+	for(j=0; j<unitprice_array.length; j++)
+	{ldelim}
+		fieldinfo = fieldname_array[j].split("_");
+		id = fieldinfo[0];
+		checkid = "check_"+id;
+
+		unitprice=unitprice_array[j];
+		fieldname=fieldname_array[j];	
+		updateListPrice(unitprice,fieldname,document.getElementById(checkid));
+	{rdelim}
+{rdelim}
+
+</script>
+<script language="javascript" src="modules/PriceBooks/PriceBooks.js"></script>
+<BR>
+<BR>
+{$PRODUCTLISTHEADER}
+<table border="0" cellpadding="0" cellspacing="0" class="FormBorder" width="100%">
+  <tr height="20"> 
+    <td >
+	 <table border="0" cellpadding="0" cellspacing="0" width="100%">
+		<tr>
+			<td>&nbsp;{$RECORD_COUNTS}</td>
+			   {$NAVIGATION}
+		</tr>
+	 </table>
+    </td>
+   </tr>
+   <tr><td >
+   <table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="3" cellspacing="1" width="90%" align="center">
+   {$LISTHEADER}
+   {$LISTENTITY}
+   </table>
+   </td></tr>
+   <tr><td>&nbsp;</td></tr>
+   </form>
+</table>
+
+</form>
+</table>
+
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/AuditTrailList.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/AuditTrailList.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/AuditTrailList.tpl Mon Apr 16 12:27:44 2007
@@ -18,10 +18,10 @@
         <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
         <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
 <form action="index.php" method="post" name="AuditTrail" id="form">
-<input type='hidden' name='module' value='Users'>
+<input type='hidden' name='module' value='Settings'>
 <input type='hidden' name='action' value='AuditTrail'>
 <input type='hidden' name='return_action' value='ListView'>
-<input type='hidden' name='return_module' value='Users'>
+<input type='hidden' name='return_module' value='Settings'>
 <input type='hidden' name='parenttab' value='Settings'>
 
         <br>
@@ -82,11 +82,11 @@
 	    </td>
                         </tr>
                         </table>	
-				<table border=0 cellspacing=0 cellpadding=5 width=100% >
+				<!--table border=0 cellspacing=0 cellpadding=5 width=100% >
 				<tr>
 					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
 				</tr>
-				</table>
+				</table-->
 	
 				</td>
 				</tr>
@@ -135,7 +135,7 @@
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
                         method: 'post',
-                        postBody: 'module=Users&action=UsersAjax&file=SaveAuditTrail&ajax=true&audit_trail='+status,
+                        postBody: 'module=Settings&action=SettingsAjax&file=SaveAuditTrail&ajax=true&audit_trail='+status,
                         onComplete: function(response) {
                                 $("status").style.display="none";
                         }
@@ -149,7 +149,7 @@
 {
 	
 	var userid = $('user_list').options[$('user_list').selectedIndex].value;
-	window.open("index.php?module=Users&action=UsersAjax&file=ShowAuditTrail&userid="+userid,"","width=645,height=750,resizable=0,scrollbars=1,left=100");
+	window.open("index.php?module=Settings&action=SettingsAjax&file=ShowAuditTrail&userid="+userid,"","width=645,height=750,resizable=0,scrollbars=1,left=100");
 	
 
 }

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List.tpl Mon Apr 16 12:27:44 2007
@@ -1,140 +1,148 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-<!-- Activity createlink layer start  -->
-{if $MODULE eq 'Calendar'}
-<div id="reportLay" style="width: 125px; right: 159px; top: 260px; display: none; z-index:50" onmouseout="fninvsh('reportLay')" onmouseover="fnvshNrm('reportLay')">
-        <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
-                <tr>
-                        <td>
-                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Events&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_EVENT}</a>
-                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Task&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_TASK}</a>
-                        </td>
-                </tr>
-        </table>
-
-</div>
-{/if}
-<!-- Activity createlink layer end  -->
-
-
-<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
-<tr><td style="height:2px"></td></tr>
-<tr>
-	<td style="padding-left:10px;padding-right:50px" class="moduleName" nowrap>{$APP.$CATEGORY} > <a class="hdrLink" href="index.php?action=ListView&module={$MODULE}&parenttab={$CATEGORY}">{$APP.$MODULE}</a></td>
-	<td width=100% nowrap>
-	
-		<table border="0" cellspacing="0" cellpadding="0" >
-		<tr>
-		<td class="sep1" style="width:1px;"></td>
-		<td class=small >
-			<!-- Add and Search -->
-			<table border=0 cellspacing=0 cellpadding=0>
-			<tr>
-			<td>
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-					{if $CHECK.EditView eq 'yes' && $MODULE neq 'Emails' && $MODULE neq 'Webmails'}
-			        		{if $MODULE eq 'Calendar'}
-		                      	        	<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Add-Faded.gif" border=0></td>
-                	   			 {else}
-	                        		       	<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=EditView&return_action=DetailView&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.$SINGLE_MOD}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.$SINGLE_MOD}..." border=0></a></td>
-			                       	{/if}
-					{else}
-						<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Add-Faded.gif" border=0></td>	
-					{/if}
-									
-					{if $CHECK.index eq 'yes' && $MODULE neq 'Emails' && $MODULE neq 'Webmails'}
-						 <td style="padding-right:10px"><a href="javascript:;" onClick="moveMe('searchAcc');searchshowhide('searchAcc','advSearch')" ><img src="{$IMAGE_PATH}btnL3Search.gif" alt="{$APP.LBL_SEARCH_ALT}{$APP.$MODULE}..." title="{$APP.LBL_SEARCH_TITLE}{$APP.$MODULE}..." border=0></a></a></td>
-					{else}
-						<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Search-Faded.gif" border=0></td>
-					{/if}
-					
-				</tr>
-				</table>
-			</td>
-			</tr>
-			</table>
-		</td>
-		<td style="width:20px;">&nbsp;</td>
-		<td class="small">
-			<!-- Calendar Clock Calculator and Chat -->
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-					{if $CATEGORY eq 'Settings' || $CATEGORY eq 'Tools' || $CATEGORY eq 'Analytics'}
-						{if $CHECK.Calendar eq 'yes'}
-						<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab=My Home Page");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td>
-						{else}
-						<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td>
-						{/if}
-					{else}
-						{if $CHECK.Calendar eq 'yes'}
-						<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab={$CATEGORY}");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td>
-						{else}
-						<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td>
-						{/if}
-					{/if}
-					<td style="padding-right:0px"><a href="javascript:;"><img src="{$IMAGE_PATH}btnL3Clock.gif" alt="{$APP.LBL_CLOCK_ALT}" title="{$APP.LBL_CLOCK_TITLE}" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td>
-					<td style="padding-right:0px"><a href="#"><img src="{$IMAGE_PATH}btnL3Calc.gif" alt="{$APP.LBL_CALCULATOR_ALT}" title="{$APP.LBL_CALCULATOR_TITLE}" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td>
-					<td style="padding-right:10px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="{$IMAGE_PATH}tbarChat.gif" alt="{$APP.LBL_CHAT_ALT}" title="{$APP.LBL_CHAT_TITLE}" border=0></a>
-                    </td>	
-					<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Tracker.gif" alt="{$APP.LBL_LAST_VIEWED}" title="{$APP.LBL_LAST_VIEWED}" border=0 onClick="fnvshobj(this,'tracker');">
-                    			</td>	
-				</tr>
-				</table>
-		</td>
-		<td style="width:20px;">&nbsp;</td>
-		<td class="small">
-			<!-- Import / Export -->
-			<table border=0 cellspacing=0 cellpadding=5>
-			<tr>
-			{if $MODULE eq 'Contacts' || $MODULE eq 'Leads' || $MODULE eq 'Accounts' || $MODULE eq 'Potentials' || $MODULE eq 'Products' }
-		   		{if $CHECK.Import eq 'yes'}	
-					<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=Import&step=1&return_module={$MODULE}&return_action=index&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}tbarImport.gif" alt="{$APP.LBL_IMPORT} {$APP.$MODULE}" title="{$APP.LBL_IMPORT} {$APP.$MODULE}" border="0"></a></td>	
-				{else}	
-					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>	
-				{/if}	
-				{if $CHECK.Export eq 'yes'}	
-	    			<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
-				{else}	
-					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
-                {/if}
-			{elseif $MODULE eq 'Notes' || $MODULE eq 'Emails'}	
-				
-				{if $CHECK.Export eq 'yes'}
-					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
-					<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
-				{else}	 
-					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
-					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
-				{/if}
-			{else}
-				<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
-                <td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
-			{/if}
-			</tr>
-			</table>	
-		<td style="width:20px;">&nbsp;</td>
-		<td class="small">
-			<!-- All Menu -->
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-				<td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh('allMenu');" onClick="fnvshobj(this,'allMenu')"><img src="{$IMAGE_PATH}btnL3AllMenu.gif" alt="{$APP.LBL_ALL_MENU_ALT}" title="{$APP.LBL_ALL_MENU_TITLE}" border="0"></a></td>
-				</tr>
-				</table>
-		</td>			
-		</tr>
-		</table>
-	</td>
-</tr>
-<tr><td style="height:2px"></td></tr>
-</TABLE>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<!-- Activity createlink layer start  -->
+{if $MODULE eq 'Calendar'}
+<div id="reportLay" style="width: 125px; right: 159px; top: 260px; display: none; z-index:50" onmouseout="fninvsh('reportLay')" onmouseover="fnvshNrm('reportLay')">
+        <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
+                <tr>
+                        <td>
+                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Events&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_EVENT}</a>
+                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Task&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_TASK}</a>
+                        </td>
+                </tr>
+        </table>
+
+</div>
+{/if}
+<!-- Activity createlink layer end  -->
+
+
+<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
+<tr><td style="height:2px"></td></tr>
+<tr>
+	<td style="padding-left:10px;padding-right:50px" class="moduleName" nowrap>{$APP.$CATEGORY} > <a class="hdrLink" href="index.php?action=ListView&module={$MODULE}&parenttab={$CATEGORY}">{$APP.$MODULE}</a></td>
+	<td width=100% nowrap>
+	
+		<table border="0" cellspacing="0" cellpadding="0" >
+		<tr>
+		<td class="sep1" style="width:1px;"></td>
+		<td class=small >
+			<!-- Add and Search -->
+			<table border=0 cellspacing=0 cellpadding=0>
+			<tr>
+			<td>
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+					{if $CHECK.EditView eq 'yes' && $MODULE neq 'Emails' && $MODULE neq 'Webmails'}
+			        		{if $MODULE eq 'Calendar'}
+		                      	        	<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Add-Faded.gif" border=0></td>
+                	   			 {else}
+	                        		       	<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=EditView&return_action=DetailView&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.$SINGLE_MOD}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.$SINGLE_MOD}..." border=0></a></td>
+			                       	{/if}
+					{else}
+						<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Add-Faded.gif" border=0></td>	
+					{/if}
+									
+					{if $CHECK.index eq 'yes' && $MODULE neq 'Emails' && $MODULE neq 'Webmails'}
+						 <td style="padding-right:10px"><a href="javascript:;" onClick="moveMe('searchAcc');searchshowhide('searchAcc','advSearch')" ><img src="{$IMAGE_PATH}btnL3Search.gif" alt="{$APP.LBL_SEARCH_ALT}{$APP.$MODULE}..." title="{$APP.LBL_SEARCH_TITLE}{$APP.$MODULE}..." border=0></a></a></td>
+					{else}
+						<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Search-Faded.gif" border=0></td>
+					{/if}
+					
+				</tr>
+				</table>
+			</td>
+			</tr>
+			</table>
+		</td>
+		<td style="width:20px;">&nbsp;</td>
+		<td class="small">
+			<!-- Calendar Clock Calculator and Chat -->
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+						{if $CALENDAR_DISPLAY eq 'true'} 
+ 		                                                {if $CATEGORY eq 'Settings' || $CATEGORY eq 'Tools' || $CATEGORY eq 'Analytics'} 
+ 		                                                        {if $CHECK.Calendar eq 'yes'} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab=My Home Page");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td> 
+ 		                                                        {else} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td> 
+ 		                                                        {/if} 
+						{else}
+						{if $CHECK.Calendar eq 'yes'} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab={$CATEGORY}");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td> 
+ 		                                                        {else} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td> 
+ 		                                                        {/if} 
+						{/if}
+					{/if}
+					{if $WORLD_CLOCK_DISPLAY eq 'true'} 
+ 		                                                <td style="padding-right:0px"><a href="javascript:;"><img src="{$IMAGE_PATH}btnL3Clock.gif" alt="{$APP.LBL_CLOCK_ALT}" title="{$APP.LBL_CLOCK_TITLE}" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td> 
+ 		                                        {/if} 
+ 		                                        {if $CALCULATOR_DISPLAY eq 'true'} 
+ 		                                                <td style="padding-right:0px"><a href="#"><img src="{$IMAGE_PATH}btnL3Calc.gif" alt="{$APP.LBL_CALCULATOR_ALT}" title="{$APP.LBL_CALCULATOR_TITLE}" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td> 
+ 		                                        {/if} 
+ 		                                        {if $CHAT_DISPLAY eq 'true'} 
+ 		                                                <td style="padding-right:10px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="{$IMAGE_PATH}tbarChat.gif" alt="{$APP.LBL_CHAT_ALT}" title="{$APP.LBL_CHAT_TITLE}" border=0></a> 
+ 		                                        {/if} 
+                    </td>	
+					<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Tracker.gif" alt="{$APP.LBL_LAST_VIEWED}" title="{$APP.LBL_LAST_VIEWED}" border=0 onClick="fnvshobj(this,'tracker');">
+                    			</td>	
+				</tr>
+				</table>
+		</td>
+		<td style="width:20px;">&nbsp;</td>
+		<td class="small">
+			<!-- Import / Export -->
+			<table border=0 cellspacing=0 cellpadding=5>
+			<tr>
+			{if $MODULE eq 'Contacts' || $MODULE eq 'Leads' || $MODULE eq 'Accounts' || $MODULE eq 'Potentials' || $MODULE eq 'Products' }
+		   		{if $CHECK.Import eq 'yes'}	
+					<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=Import&step=1&return_module={$MODULE}&return_action=index&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}tbarImport.gif" alt="{$APP.LBL_IMPORT} {$APP.$MODULE}" title="{$APP.LBL_IMPORT} {$APP.$MODULE}" border="0"></a></td>	
+				{else}	
+					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>	
+				{/if}	
+				{if $CHECK.Export eq 'yes'}	
+	    			<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
+				{else}	
+					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
+                {/if}
+			{elseif $MODULE eq 'Notes' || $MODULE eq 'Emails'}	
+				
+				{if $CHECK.Export eq 'yes'}
+					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
+					<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
+				{else}	 
+					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
+					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
+				{/if}
+			{else}
+				<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
+                <td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
+			{/if}
+			</tr>
+			</table>	
+		<td style="width:20px;">&nbsp;</td>
+		<td class="small">
+			<!-- All Menu -->
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+				<td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh('allMenu');" onClick="fnvshobj(this,'allMenu')"><img src="{$IMAGE_PATH}btnL3AllMenu.gif" alt="{$APP.LBL_ALL_MENU_ALT}" title="{$APP.LBL_ALL_MENU_TITLE}" border="0"></a></td>
+				</tr>
+				</table>
+		</td>			
+		</tr>
+		</table>
+	</td>
+</tr>
+<tr><td style="height:2px"></td></tr>
+</TABLE>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List1.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List1.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Buttons_List1.tpl Mon Apr 16 12:27:44 2007
@@ -1,142 +1,150 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-<!-- Activity createlink layer start  -->
-{if $MODULE eq 'Calendar'}
-<div id="reportLay" style="width: 125px; right: 159px; top: 260px; display: none; z-index:50" onmouseout="fninvsh('reportLay')" onmouseover="fnvshNrm('reportLay')">
-        <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
-                <tr>
-                        <td>
-                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Events&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_EVENT}</a>
-                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Task&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_TASK}</a>
-                        </td>
-                </tr>
-        </table>
-
-</div>
-{/if}
-<!-- Activity createlink layer end  -->
-
-
-<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
-<tr><td style="height:2px"></td></tr>
-<tr>
-	{if $CATEGORY eq 'Settings' || $CATEGORY eq 'Organization' }
-<!-- No List View in Settings and Organizations - Action is index -->
-		<td style="padding-left:10px;padding-right:50px" class="moduleName" nowrap><a class="hdrLink" href="index.php?action=index&module={$MODULE}&parenttab={$CATEGORY}">{$APP.$MODULE}</a></td>
-	{else}
-		<td style="padding-left:10px;padding-right:50px" class="moduleName" nowrap>{$APP.$CATEGORY} > <a class="hdrLink" href="index.php?action=ListView&module={$MODULE}&parenttab={$CATEGORY}">{$APP.$MODULE}</a></td>
-	{/if}
-	<td width=100% nowrap>
-	
-		<table border="0" cellspacing="0" cellpadding="0" >
-		<tr>
-		<td class="sep1" style="width:1px;"></td>
-		<td class=small >
-			<!-- Add and Search -->
-			<table border=0 cellspacing=0 cellpadding=0>
-			<tr>
-			<td>
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-					{if $CHECK.EditView eq 'yes'}
-			        		{if $MODULE eq 'Calendar'}
-		                      	        	<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" id="showSubMenu"  onMouseOver="fnvshobj(this,'reportLay');" onMouseOut="fninvsh('reportLay');"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." border=0></a></td>
-			        		{elseif $MODULE eq 'OrgUnit'}
-	                        		       	<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=EditView&return_action=DetailView&parenttab={$CATEGORY}&parentid={$PARENTORG}"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$MODULE}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$MODULE}..." border=0></a></td>
-                	   			{else}
-	                        		       	<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=EditView&return_action=DetailView&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." border=0></a></td>
-			                       	{/if}
-					{else}
-						<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Add-Faded.gif" border=0></td>	
-					{/if}
-									
-						<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Search-Faded.gif" border=0></td>
-					
-				</tr>
-				</table>
-			</td>
-			</tr>
-			</table>
-		</td>
-		<td style="width:20px;">&nbsp;</td>
-		<td class="small">
-			<!-- Calendar Clock Calculator and Chat -->
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-					{if $CATEGORY eq 'Settings' || $CATEGORY eq 'Tools' || $CATEGORY eq 'Analytics'}
-						{if $CHECK.Calendar eq 'yes'}
-						<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab=My Home Page");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td>
-						{else}
-                                                <td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td>
-                                                {/if}
-					{else}
-						{if $CHECK.Calendar eq 'yes'}
-						<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab={$CATEGORY}");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td>
-						{else}
-                                                <td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td>
-                                                {/if}
-					{/if}
-					<td style="padding-right:0px"><a href="javascript:;"><img src="{$IMAGE_PATH}btnL3Clock.gif" alt="{$APP.LBL_CLOCK_ALT}" title="{$APP.LBL_CLOCK_TITLE}" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td>
-					<td style="padding-right:0px"><a href="#"><img src="{$IMAGE_PATH}btnL3Calc.gif" alt="{$APP.LBL_CALCULATOR_ALT}" title="{$APP.LBL_CALCULATOR_TITLE}" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td>
-					<td style="padding-right:0px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="{$IMAGE_PATH}tbarChat.gif" alt="{$APP.LBL_CHAT_ALT}" title="{$APP.LBL_CHAT_TITLE}" border=0></a>
-                    </td>	
-					<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Tracker.gif" alt="{$APP.LBL_LAST_VIEWED}" title="{$APP.LBL_LAST_VIEWED}" border=0 onClick="fnvshobj(this,'tracker');">
-                    			</td>	
-				</tr>
-				</table>
-		</td>
-		<td style="width:20px;">&nbsp;</td>
-		<td class="small">
-			<!-- Import / Export -->
-			<table border=0 cellspacing=0 cellpadding=5>
-			<tr>
-			{if $MODULE eq 'Contacts' || $MODULE eq 'Leads' || $MODULE eq 'Accounts' || $MODULE eq 'Potentials' || $MODULE eq 'Products' }
-		   		{if $CHECK.Import eq 'yes'}	
-					<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=Import&step=1&return_module={$MODULE}&return_action=index&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}tbarImport.gif" alt="{$APP.LBL_IMPORT} {$APP.$MODULE}" title="{$APP.LBL_IMPORT} {$APP.$MODULE}" border="0"></a></td>	
-				{else}	
-					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>	
-				{/if}	
-				{if $CHECK.Export eq 'yes'}	
-	    			<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
-				{else}	
-					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
-                {/if}
-			{elseif $MODULE eq 'Notes' || $MODULE eq 'Emails'}	
-				
-				{if $CHECK.Export eq 'yes'}
-					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
-					<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
-				{else}	 
-					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
-					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
-				{/if}
-			{else}
-				<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
-                <td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
-			{/if}
-			</tr>
-			</table>	
-		<td style="width:20px;">&nbsp;</td>
-		<td class="small">
-			<!-- All Menu -->
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-				<td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh('allMenu');" onClick="fnvshobj(this,'allMenu')"><img src="{$IMAGE_PATH}btnL3AllMenu.gif" alt="{$APP.LBL_ALL_MENU_ALT}" title="{$APP.LBL_ALL_MENU_TITLE}" border="0"></a></td>
-				</tr>
-				</table>
-		</td>			
-		</tr>
-		</table>
-	</td>
-</tr>
-</TABLE>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<!-- Activity createlink layer start  -->
+{if $MODULE eq 'Calendar'}
+<div id="reportLay" style="width: 125px; right: 159px; top: 260px; display: none; z-index:50" onmouseout="fninvsh('reportLay')" onmouseover="fnvshNrm('reportLay')">
+        <table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="100%">
+                <tr>
+                        <td>
+                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Events&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_EVENT}</a>
+                                <a href="index.php?module={$MODULE}&action=EditView&return_module={$MODULE}&activity_mode=Task&return_action=DetailView&parenttab={$CATEGORY}" class="calMnu">{$NEW_TASK}</a>
+                        </td>
+                </tr>
+        </table>
+
+</div>
+{/if}
+<!-- Activity createlink layer end  -->
+
+
+<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
+<tr><td style="height:2px"></td></tr>
+<tr>
+	{if $CATEGORY eq 'Settings' || $CATEGORY eq 'Organization' }
+<!-- No List View in Settings and Organizations - Action is index -->
+		<td style="padding-left:10px;padding-right:50px" class="moduleName" nowrap><a class="hdrLink" href="index.php?action=index&module={$MODULE}&parenttab={$CATEGORY}">{$APP.$MODULE}</a></td>
+	{else}
+		<td style="padding-left:10px;padding-right:50px" class="moduleName" nowrap>{$APP.$CATEGORY} > <a class="hdrLink" href="index.php?action=ListView&module={$MODULE}&parenttab={$CATEGORY}">{$APP.$MODULE}</a></td>
+	{/if}
+	<td width=100% nowrap>
+	
+		<table border="0" cellspacing="0" cellpadding="0" >
+		<tr>
+		<td class="sep1" style="width:1px;"></td>
+		<td class=small >
+			<!-- Add and Search -->
+			<table border=0 cellspacing=0 cellpadding=0>
+			<tr>
+			<td>
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+					{if $CHECK.EditView eq 'yes'}
+			        		{if $MODULE eq 'Calendar'}
+		                      	        	<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" id="showSubMenu"  onMouseOver="fnvshobj(this,'reportLay');" onMouseOut="fninvsh('reportLay');"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." border=0></a></td>
+			        		{elseif $MODULE eq 'OrgUnit'}
+	                        		       	<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=EditView&return_action=DetailView&parenttab={$CATEGORY}&parentid={$PARENTORG}"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$MODULE}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$MODULE}..." border=0></a></td>
+                	   			{else}
+	                        		       	<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=EditView&return_action=DetailView&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}btnL3Add.gif" alt="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." title="{$APP.LBL_CREATE_BUTTON_LABEL} {$SINGLE_MOD}..." border=0></a></td>
+			                       	{/if}
+					{else}
+						<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Add-Faded.gif" border=0></td>	
+					{/if}
+									
+						<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Search-Faded.gif" border=0></td>
+					
+				</tr>
+				</table>
+			</td>
+			</tr>
+			</table>
+		</td>
+		<td style="width:20px;">&nbsp;</td>
+		<td class="small">
+			<!-- Calendar Clock Calculator and Chat -->
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+					{if $CALENDAR_DISPLAY eq 'true'} 
+ 		                                                {if $CATEGORY eq 'Settings' || $CATEGORY eq 'Tools' || $CATEGORY eq 'Analytics'} 
+ 		                                                        {if $CHECK.Calendar eq 'yes'} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab=My Home Page");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td> 
+						{else}
+                                                <td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td>
+                                                {/if}
+					{else}
+						{if $CHECK.Calendar eq 'yes'} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab={$CATEGORY}");'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td> 
+ 		                                                        {else} 
+ 		                                                                <td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif"></td> 
+								{/if}
+ 		                               {/if} 
+					{/if}
+					<!--{if $WORLD_CLOCK_DISPLAY eq 'true'}--> 
+ 		                                                <td style="padding-right:0px"><a href="javascript:;"><img src="{$IMAGE_PATH}btnL3Clock.gif" alt="{$APP.LBL_CLOCK_ALT}" title="{$APP.LBL_CLOCK_TITLE}" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td> 
+ 		                                        <!--{/if}--> 
+ 		                                        {if $CALCULATOR_DISPLAY eq 'true'} 
+ 		                                                <td style="padding-right:0px"><a href="#"><img src="{$IMAGE_PATH}btnL3Calc.gif" alt="{$APP.LBL_CALCULATOR_ALT}" title="{$APP.LBL_CALCULATOR_TITLE}" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td> 
+ 		                                        {/if} 
+ 		                                        {if $CHAT_DISPLAY eq 'true'} 
+ 		                                                <td style="padding-right:0px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="{$IMAGE_PATH}tbarChat.gif" alt="{$APP.LBL_CHAT_ALT}" title="{$APP.LBL_CHAT_TITLE}" border=0></a> 
+ 		                                        {/if} 
+				</td>
+					<td style="padding-right:10px"><img src="{$IMAGE_PATH}btnL3Tracker.gif" alt="{$APP.LBL_LAST_VIEWED}" title="{$APP.LBL_LAST_VIEWED}" border=0 onClick="fnvshobj(this,'tracker');">
+                    			</td>	
+				</tr>
+				</table>
+		</td>
+		<td style="width:20px;">&nbsp;</td>
+		<td class="small">
+			<!-- Import / Export -->
+			<table border=0 cellspacing=0 cellpadding=5>
+			<tr>
+			{if $MODULE eq 'Contacts' || $MODULE eq 'Leads' || $MODULE eq 'Accounts' || $MODULE eq 'Potentials' || $MODULE eq 'Products' }
+		   		{if $CHECK.Import eq 'yes'}	
+					<td style="padding-right:0px;padding-left:10px;"><a href="index.php?module={$MODULE}&action=Import&step=1&return_module={$MODULE}&return_action=index&parenttab={$CATEGORY}"><img src="{$IMAGE_PATH}tbarImport.gif" alt="{$APP.LBL_IMPORT} {$APP.$MODULE}" title="{$APP.LBL_IMPORT} {$APP.$MODULE}" border="0"></a></td>	
+				{else}	
+					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>	
+				{/if}	
+				{if $CHECK.Export eq 'yes'}	
+	    			<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
+				{else}	
+					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
+                {/if}
+			{elseif $MODULE eq 'Notes' || $MODULE eq 'Emails'}	
+				
+				{if $CHECK.Export eq 'yes'}
+					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
+					<td style="padding-right:10px"><a href="index.php?module={$MODULE}&action=Export&all=1"><img src="{$IMAGE_PATH}tbarExport.gif" alt="{$APP.LBL_EXPORT} {$APP.$MODULE}" title="{$APP.LBL_EXPORT} {$APP.$MODULE}" border="0"></a></td>
+				{else}	 
+					<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
+					<td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
+				{/if}
+			{else}
+				<td style="padding-right:0px;padding-left:10px;"><img src="{$IMAGE_PATH}tbarImport-Faded.gif" border="0"></td>
+                <td style="padding-right:10px"><img src="{$IMAGE_PATH}tbarExport-Faded.gif" border="0"></td>
+			{/if}
+			</tr>
+			</table>	
+		<td style="width:20px;">&nbsp;</td>
+		<td class="small">
+			<!-- All Menu -->
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+				<td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh('allMenu');" onClick="fnvshobj(this,'allMenu')"><img src="{$IMAGE_PATH}btnL3AllMenu.gif" alt="{$APP.LBL_ALL_MENU_ALT}" title="{$APP.LBL_ALL_MENU_TITLE}" border="0"></a></td>
+				</tr>
+				</table>
+		</td>			
+		</tr>
+		</table>
+	</td>
+</tr>
+</TABLE>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ComposeEmail.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ComposeEmail.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ComposeEmail.tpl Mon Apr 16 12:27:44 2007
@@ -15,12 +15,14 @@
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>Compose Mail</title>
+<meta http-equiv="Content-Type" content="text/html; charset={$APP.LBL_CHARSET}">
+<title>{$MOD.TITLE_COMPOSE_MAIL}</title>
 <link REL="SHORTCUT ICON" HREF="include/images/vtigercrm_icon.ico">	
 <style type="text/css">@import url("themes/{$THEME}/style.css");</style>
 <script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
 <script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+<script src="include/js/general.js" type="text/javascript"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/{php} echo $_SESSION['authenticated_user_language'];{/php}.lang.js?{php} echo $_SESSION['vtiger_version'];{/php}"></script>
 <script type="text/javascript" src="include/fckeditor/fckeditor.js"></script>
 </head>
 <body marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
@@ -60,7 +62,7 @@
 	<td class="cellText" style="padding: 5px;">
  		<input name="{$elements.2.0}" type="hidden" value="{$IDLISTS}">
 		<input type="hidden" name="saved_toid" value="{$TO_MAIL}">
-		<textarea id="parent_name" readonly cols="70">{$TO_MAIL}</textarea>
+		<input id="parent_name" readonly class="txtBox" type="text" value="{$TO_MAIL}" style="width:99%">&nbsp;
 	</td>
 	<td class="cellText" style="padding: 5px;" align="left" nowrap>
 		<select name="parent_type">
@@ -70,22 +72,22 @@
 		</select>
 		&nbsp;
 		<span  class="mailClientCSSButton">
-		<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=set_return_emails","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;
-		</span><span class="mailClientCSSButton" ><input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.hidden_toid.value='';this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+		<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=set_return_emails","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;
+		</span><span class="mailClientCSSButton" ><input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.hidden_toid.value='';this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 		</span>
 	</td>
    </tr>
    <tr>
 	<td class="mailSubHeader" style="padding: 5px;" align="right">{$MOD.LBL_CC}</td>
 	<td class="cellText" style="padding: 5px;">
-		<input name="ccmail" class="txtBox" type="text" value="{$CC_MAIL}" style="width:99%">&nbsp;
+		<input name="ccmail" id ="cc_name" class="txtBox" type="text" value="{$CC_MAIL}" style="width:99%">&nbsp;
 	</td>	
 	<td valign="top" class="cellLabel" rowspan="4"><div id="attach_cont" class="addEventInnerBox" style="overflow:auto;height:110px;width:100%;position:relative;left:0px;top:0px;"></div>
    </tr>
    <tr>
 	<td class="mailSubHeader" style="padding: 5px;" align="right">{$MOD.LBL_BCC}</td>
 	<td class="cellText" style="padding: 5px;">
-		<input name="bccmail" class="txtBox" type="text" value="{$BCC_MAIL}" style="width:99%">&nbsp;
+		<input name="bccmail" id="bcc_name" class="txtBox" type="text" value="{$BCC_MAIL}" style="width:99%">&nbsp;
 	</td>
    </tr>
 	{elseif $elements.2.0 eq 'subject'}
@@ -125,7 +127,7 @@
    <tr>
 	<td colspan="3" align="center" valign="top" height="320">
         {if $WEBMAIL eq 'true'}
-                <textarea style="display: none;" class="detailedViewTextBox" name="description" cols="90" rows="8">{$DESCRIPTION}</textarea>
+                <textarea style="display: none;" class="detailedViewTextBox" id="description" name="description" cols="90" rows="8">{$DESCRIPTION}</textarea>
         {else}
                 <textarea style="display: none;" class="detailedViewTextBox" id="description" name="description" cols="90" rows="16">{$elements.3.0}</textarea>        {/if}
 	</td>
@@ -146,14 +148,51 @@
 </table>
 </form>
 </body>
+<script>
+var cc_err_msg = '{$MOD.LBL_CC_EMAIL_ERROR}';
+var no_rcpts_err_msg = '{$MOD.LBL_NO_RCPTS_EMAIL_ERROR}';
+var bcc_err_msg = '{$MOD.LBL_BCC_EMAIL_ERROR}';
+var conf_mail_srvr_err_msg = '{$MOD.LBL_CONF_MAILSERVER_ERROR}';
 {literal}
-<script>
 function email_validate(oform,mode)
 {
 	if(oform.parent_name.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0)
 	{
-		alert('No recipients were specified');
+		//alert('No recipients were specified');
+				alert(no_rcpts_err_msg);
 		return false;
+	}
+	if(document.EditView.ccmail.value.length >= 1)
+	{
+		var str = document.EditView.ccmail.value;
+		arr = new Array();
+		arr = str.split(",");
+		for(var i=0; i<=arr.length-1; i++)
+		{
+			if(arr[i] != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(arr[i]))
+			{
+				//alert("Your CC Email Id for "+ arr[i] +" is not correct");
+				alert(cc_err_msg);
+				return false;
+			}
+		}
+	}
+	
+	if(document.EditView.bccmail.value.length >= 1)
+	{
+		var str = document.EditView.bccmail.value;
+		arr = new Array();
+		arr = str.split(",");
+		for(var i=0; i<=arr.length-1; i++)
+		{
+			if(arr[i] != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(arr[i]))
+			{
+				//alert("Your BCC Email Id for "+ arr[i] +" is not correct");
+				alert(bcc_err_msg);
+
+				return false;	
+			}
+		}	
 	}
 	if(oform.subject.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0)
 	{
@@ -190,7 +229,8 @@
 				oform.submit();
 			}else
 			{
-				alert('Please Configure Your Mail Server');
+				//alert('Please Configure Your Mail Server');
+				alert(conf_mail_srvr_err_msg);
 				return false;
 			}
                	    }
@@ -213,6 +253,7 @@
     );
 
 }
+{/literal}
 </script>
 <script type="text/javascript" defer="1">
 var oFCKeditor = null;
@@ -220,5 +261,4 @@
 oFCKeditor.BasePath   = "include/fckeditor/" ;
 oFCKeditor.ReplaceTextarea();
 </script>
-{/literal}
 </html>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CreateEmailTemplate.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CreateEmailTemplate.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CreateEmailTemplate.tpl Mon Apr 16 12:27:44 2007
@@ -1,324 +1,323 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
-
-<script language="JavaScript" type="text/javascript">
-    var allOptions = null;
-
-    function setAllOptions(inputOptions) 
-    {ldelim}
-        allOptions = inputOptions;
-    {rdelim}
-
-    function modifyMergeFieldSelect(cause, effect) 
-    {ldelim}
-        var selected = cause.options[cause.selectedIndex].value;  id="mergeFieldValue"
-        var s = allOptions[cause.selectedIndex];
-            
-        effect.length = s;
-        for (var i = 0; i < s; i++) 
-	{ldelim}
-            effect.options[i] = s[i];
-        {rdelim}
-        document.getElementById('mergeFieldValue').value = '';
-    {rdelim}
-{literal}
-    function init() 
-    {
-        var blankOption = new Option('--None--', '--None--');
-        var allOpts = new Object(0);
-        var options = null;
-            
-	    options = new Object(19);
-            options[0] = blankOption;
-            
-                
-                options[1] = new Option('Account: Account Name', '$accounts-accountname$'); 
-                options[2] = new Option('Account: Account Type', '$accounts-account_type$'); 
-                options[3] = new Option('Account: Industry', '$accounts-industry$'); 
-                options[4] = new Option('Account: Annual Revenue', '$accounts-annualrevenue$'); 
-                options[5] = new Option('Account: Phone', '$accounts-phone$'); 
-                options[6] = new Option('Account: Email', '$accounts-email1$'); 
-                options[7] = new Option('Account: Rating', '$accounts-rating$'); 
-                options[8] = new Option('Account: Website', '$accounts-website$'); 
-                options[9] = new Option('Account: Fax', '$accounts-fax$'); 
-            
-	        allOpts[1] = options;
-        
-            options = new Object(11);
-            options[0] = blankOption;
-                
-                options[1] = new Option('Contact: First Name', '$contacts-firstname$'); 
-                options[2] = new Option('Contact: Last Name', '$contacts-lastname$'); 
-                options[3] = new Option('Contact: Salutation', '$contacts-salutation$'); 
-                options[4] = new Option('Contact: Title', '$contacts-title$'); 
-                options[5] = new Option('Contact: Email', '$contacts-email$'); 
-                options[6] = new Option('Contact: Department', '$contacts-department$'); 
-                options[7] = new Option('Contact: Other Email','$contacts-otheremail$'); 
-                options[8] = new Option('Contact: Phone', '$contacts-phone$'); 
-                options[9] = new Option('Contact: Mobile', '$contacts-mobile$'); 
-                options[10] = new Option('Contact: Currency', '$contacts-currency$'); 
-                            
-            allOpts[2] = options;
-        
-            
-            options = new Object(19);
-            options[0] = blankOption;
-            
-                
-                options[1] = new Option('Lead: First Name', '$leads-firstname$'); 
-                options[2] = new Option('Lead: Last Name', '$leads-lastname$'); 
-                options[3] = new Option('Lead: Lead Source', '$leads-leadsource$'); 
-                options[4] = new Option('Lead: Status', '$leads-leadstatus$'); 
-                options[5] = new Option('Lead: Rating', '$leads-rating$'); 
-                options[6] = new Option('Lead: Industry', '$leads-industry$'); 
-                options[7] = new Option('Lead: Yahoo ID', '$leads-yahooid$'); 
-                options[8] = new Option('Lead: Email', '$leads-email$'); 
-                options[9] = new Option('Lead: Annual Revenue', '$leads-annualrevenue$'); 
-                options[10] = new Option('Lead: Title', '$leads-designation$'); 
-                options[11] = new Option('Lead: Salutation', '$leads-salutation$'); 
-            
-	        allOpts[3] = options;
-
-	        options = new Object(19);
-                options[0] = blankOption;
-            
-                options[1] = new Option('User: First Name', '$users-first_name$'); 
-                options[2] = new Option('User: Last Name', '$users-last_name$'); 
-		options[3] = new Option('User: Title', '$users-title$'); 
-		options[4] = new Option('User: Department', '$users-department$'); 
-		options[5] = new Option('User: HomePhone', '$users-phone_home$'); 
-		options[6] = new Option('User: Mobile', '$users-phone_mobile$'); 
-		options[7] = new Option('User: Signature', '$users-signature$'); 
-		options[8] = new Option('User: Email', '$users-email$'); 
-		options[9] = new Option('User: Street', '$users-address_street$'); 
-		options[10] = new Option('User: City', '$users-address_city$'); 
-		options[11] = new Option('User: State', '$users-address_state$'); 
-		options[11] = new Option('User: Country', '$users-address_country$'); 
-		options[11] = new Option('User: PostalCode', '$users-address_postalcode$'); 
-            
-            	allOpts[4] = options;
-	    
-        setAllOptions(allOpts);
-    }
-	
-	function cancelForm(frm)
-	{
-		frm.action.value='detailviewemailtemplate';
-		frm.parenttab.value='Settings';
-		frm.submit();
-	}
-{/literal}
-</script>
-
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-<br>
-	<div align=center>
-	
-			{include file='SetMenu.tpl'}
-				<!-- DISPLAY -->
-				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-				<form action="index.php" method="post" name="templatecreate" onsubmit="return check4null(templatecreate);">  
-				<input type="hidden" name="action">
-				<input type="hidden" name="mode" value="{$EMODE}">
-				<input type="hidden" name="module" value="Users">
-				<input type="hidden" name="templateid" value="{$TEMPLATEID}">
-				<input type="hidden" name="parenttab" value="PARENTTAB}">
-				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ViewTemplate.gif" alt="Users" width="45" height="60" border=0 title="Users"></td>
-				{if $EMODE eq 'edit'}
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings">{$UMOD.LBL_EMAIL_TEMPLATES}</a> &gt; {$MOD.LBL_EDIT} &quot;{$TEMPLATENAME}&quot; </b></td>
-				{else}
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings">{$UMOD.LBL_EMAIL_TEMPLATES}</a> &gt; {$MOD.LBL_CREATE_EMAIL_TEMPLATES} </b></td>
-				{/if}
-					
-				</tr>
-				<tr>
-					<td valign=top class="small">{$UMOD.LBL_EMAIL_TEMPLATE_DESC}</td>
-				</tr>
-				</table>
-				
-				<br>
-				<table border=0 cellspacing=0 cellpadding=10 width=100% >
-				<tr>
-				<td>
-				
-					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-					<tr>
-						{if $EMODE eq 'edit'}
-						<td class="big"><strong>{$UMOD.LBL_PROPERTIES} &quot;{$TEMPLATENAME}&quot; </strong></td>
-						{else}
-						<td class="big"><strong>{$MOD.LBL_CREATE_EMAIL_TEMPLATES}</strong></td>
-						{/if}
-						<td class="small" align=right>
-							<input type="submit" value="{$APP.LBL_SAVE_BUTTON_LABEL}" class="crmButton small save" onclick="this.form.action.value='saveemailtemplate'; this.form.parenttab.value='Settings'" >&nbsp;&nbsp;
-			{if $EMODE eq 'edit'}
-				<input type="submit" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" onclick="cancelForm(this.form)" />
-			{else}
-				<input type="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" onclick="window.history.back()" >
-			{/if}
-						</td>
-					</tr>
-					</table>
-					
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr>
-						<td width=20% class="small cellLabel"><font color="red">*</font><strong>{$UMOD.LBL_NAME}</strong></td>
-						<td width=80% class="small cellText"><input name="templatename" type="text" value="{$TEMPLATENAME}" class="detailedViewTextBox" tabindex="1">&nbsp;</td>
-					  </tr>
-					<tr>
-						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_DESCRIPTION}</strong></td>
-						<td class="cellText small" valign=top><span class="small cellText">
-						  <input name="description" type="text" value="{$DESCRIPTION}" class="detailedViewTextBox" tabindex="2">
-						</span></td>
-					  </tr>
-					<tr>
-						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_FOLDER}</strong></td>
-						<td class="cellText small" valign=top>
-						{if $EMODE eq 'edit'}
-						<select name="foldername" class="small" tabindex="" style="width:100%" tabindex="3">
-                                                    {foreach item=arr from=$FOLDERNAME}
-                                                     <option value="{$FOLDERNAME}" {$arr}>{$FOLDERNAME}</option>
-                                                        {if $FOLDERNAME == 'Public'}
-                                                          <option value="Personal">{$UMOD.LBL_PERSONAL}</option>
-                                                        {else}
-                                                          <option value="Public">{$UMOD.LBL_PUBLIC}</option>
-                                                         {/if}
-                                                   {/foreach}
-                                                 </select>
-						{else}
-						<select name="foldername" class="small" tabindex="" value="{$FOLDERNAME}" style="width:100%" tabindex="3">
-                                                    <option value="Personal">{$UMOD.LBL_PERSONAL}</option>
-                                                    <option value="Public" selected>{$UMOD.LBL_PUBLIC}</option>
-        	                                </select>
-						{/if}
-					
-						</td>
-					  </tr>
-					
-					
-					<tr>
-					  <td colspan="2" valign=top class="cellText small"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="thickBorder">
-                        <tr>
-                          <td valign=top><table width="100%"  border="0" cellspacing="0" cellpadding="5" >
-                              <tr>
-                                <td colspan="3" valign="top" class="small" style="background-color:#cccccc"><strong>{$UMOD.LBL_EMAIL_TEMPLATE}</strong></td>
-                                </tr>
-                              <tr>
-                                <td width="15%" valign="top" class="cellLabel small"><font color='red'>*</font>{$UMOD.LBL_SUBJECT}</td>
-                                <td width="85%" colspan="2" class="cellText small"><span class="small cellText">
-                                  <input name="subject" type="text" value="{$SUBJECT}" class="detailedViewTextBox" tabindex="4">
-                                </span></td>
-                              </tr>
-                              <tr>
-                                <td valign="top" width=10% class="cellLabel small">{$UMOD.LBL_MESSAGE}</td>
-                                 <td valign="top" width=60% class="cellText small"><p><textarea name="body" style="width:90%;height:200px" class=small tabindex="5">{$BODY}</textarea></p>
-                                    </td>
-                                <td valign="top" width=30% class="cellText small" style="border-left:2px dotted #cccccc;"><table width="100%"  border="0" cellspacing="0" cellpadding="5" >
-                                  <tr>
-                                    <td class="small"><strong>{$UMOD.LBL_MERGE_FIELDS}<br>
-                                    </strong>{$UMOD.LBL_USE_MERGE_FIELDS_TO_EMAIL_CONTENT}</td>
-                                  </tr>
-                                  <tr>
-                                    <td class="small" nowrap><strong>{$UMOD.LBL_STEP} 1. {$UMOD.LBL_SELECT_FIELD_TYPE}</strong></td>
-                                  </tr>
-				<tr><td><select class="detailedViewTextBox" id="entityType" ONCHANGE="modifyMergeFieldSelect(this, document.getElementById('mergeFieldSelect'));" tabindex="6">
-					<OPTION VALUE="0" selected>{$APP.LBL_NONE}                            
-					<OPTION VALUE="1">{$UMOD.LBL_ACCOUNT_FIELDS}                            
-                        	        <OPTION VALUE="2">{$UMOD.LBL_CONTACT_FIELDS}
-                      			<OPTION VALUE="3" >{$UMOD.LBL_LEAD_FIELDS}
-               				<OPTION VALUE="4" >{$UMOD.LBL_USER_FIELDS}
-					</select></td></tr>
-                                  <tr>
-                                    <td class="small"><strong>{$UMOD.LBL_STEP} 2. {$UMOD.LBL_SELECT_FIELD} </strong></td>
-                                  </tr>
-					<tr><td><select class="detailedViewTextBox" id="mergeFieldSelect" onchange="document.getElementById('mergeFieldValue').value=this.options[this.selectedIndex].value;" tabindex="7"><option value="0" selected>{$APP.LBL_NONE}</select></td></tr>
-                                  <tr>
-                                    <td class="small"><strong>{$UMOD.LBL_STEP} 3. {$UMOD.LBL_COPY_PASTE} </strong></td>
-                                  </tr>
-					<tr><td><input type="text"  id="mergeFieldValue" name="variable" value="variable" class="detailedViewTextBoxOn" tabindex="8"/></td></tr>
-                                </table></td>
-                              </tr>
-                          </table></td>
-                          
-                        </tr>
-                      </table></td>
-					  </tr>
-					</table>
-					<br>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr>
-					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
-					</tr>
-					</table>
-				</td>
-				</tr>
-				</table>
-			
-			
-			
-			</td>
-			</tr>
-			</table>
-		</td>
-	</tr>
-	</form>
-	</table>
-		
-	</div>
-
-</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody>
-</table>
-<script>
-
-function check4null(form)
-{ldelim}
-
-        var isError = false;
-        var errorMessage = "";
-        // Here we decide whether to submit the form.
-        if (trim(form.templatename.value) =='') {ldelim}
-                isError = true;
-                errorMessage += "\n template name";
-                form.templatename.focus();
-        {rdelim}
-        if (trim(form.foldername.value) =='') {ldelim}
-                isError = true;
-                errorMessage += "\n folder name";
-                form.foldername.focus();
-        {rdelim}
-        if (trim(form.subject.value) =='') {ldelim}
-                isError = true;
-                errorMessage += "\n subject";
-                form.subject.focus();
-        {rdelim}
-
-        // Here we decide whether to submit the form.
-        if (isError == true) {ldelim}
-                alert("Missing required fields: " + errorMessage);
-                return false;
-        {rdelim}
- return true;
-
-{rdelim}
-
-init();
-
-</script>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
+
+<script language="JavaScript" type="text/javascript">
+    var allOptions = null;
+
+    function setAllOptions(inputOptions) 
+    {ldelim}
+        allOptions = inputOptions;
+    {rdelim}
+
+    function modifyMergeFieldSelect(cause, effect) 
+    {ldelim}
+        var selected = cause.options[cause.selectedIndex].value;  id="mergeFieldValue"
+        var s = allOptions[cause.selectedIndex];
+        effect.length = s;
+        for (var i = 0; i < s; i++) 
+	{ldelim}
+            effect.options[i] = s[i];
+        {rdelim}
+        document.getElementById('mergeFieldValue').value = '';
+    {rdelim}
+{literal}
+    function init() 
+    {
+        var blankOption = new Option('--None--', '--None--');
+        var allOpts = new Object(0);
+        var options = null;
+            
+	    options = new Object(10);
+            options[0] = blankOption;
+            
+                
+                options[1] = new Option('Account: Account Name', '$accounts-accountname$'); 
+                options[2] = new Option('Account: Account Type', '$accounts-account_type$'); 
+                options[3] = new Option('Account: Industry', '$accounts-industry$'); 
+                options[4] = new Option('Account: Annual Revenue', '$accounts-annualrevenue$'); 
+                options[5] = new Option('Account: Phone', '$accounts-phone$'); 
+                options[6] = new Option('Account: Email', '$accounts-email1$'); 
+                options[7] = new Option('Account: Rating', '$accounts-rating$'); 
+                options[8] = new Option('Account: Website', '$accounts-website$'); 
+                options[9] = new Option('Account: Fax', '$accounts-fax$'); 
+            
+	        allOpts[1] = options;
+        
+            options = new Object(11);
+            options[0] = blankOption;
+                
+                options[1] = new Option('Contact: First Name', '$contacts-firstname$'); 
+                options[2] = new Option('Contact: Last Name', '$contacts-lastname$'); 
+                options[3] = new Option('Contact: Salutation', '$contacts-salutation$'); 
+                options[4] = new Option('Contact: Title', '$contacts-title$'); 
+                options[5] = new Option('Contact: Email', '$contacts-email$'); 
+                options[6] = new Option('Contact: Department', '$contacts-department$'); 
+                options[7] = new Option('Contact: Other Email','$contacts-otheremail$'); 
+                options[8] = new Option('Contact: Phone', '$contacts-phone$'); 
+                options[9] = new Option('Contact: Mobile', '$contacts-mobile$'); 
+                //options[10] = new Option('Contact: Currency', '$contacts-currency$'); 
+                            
+            allOpts[2] = options;
+        
+            
+            options = new Object(12);
+            options[0] = blankOption;
+            
+                
+                options[1] = new Option('Lead: First Name', '$leads-firstname$'); 
+                options[2] = new Option('Lead: Last Name', '$leads-lastname$'); 
+                options[3] = new Option('Lead: Lead Source', '$leads-leadsource$'); 
+                options[4] = new Option('Lead: Status', '$leads-leadstatus$'); 
+                options[5] = new Option('Lead: Rating', '$leads-rating$'); 
+                options[6] = new Option('Lead: Industry', '$leads-industry$'); 
+                options[7] = new Option('Lead: Yahoo ID', '$leads-yahooid$'); 
+                options[8] = new Option('Lead: Email', '$leads-email$'); 
+                options[9] = new Option('Lead: Annual Revenue', '$leads-annualrevenue$'); 
+                options[10] = new Option('Lead: Title', '$leads-designation$'); 
+                options[11] = new Option('Lead: Salutation', '$leads-salutation$'); 
+            
+	        allOpts[3] = options;
+
+	        options = new Object(14);
+                options[0] = blankOption;
+            
+                options[1] = new Option('User: First Name', '$users-first_name$'); 
+                options[2] = new Option('User: Last Name', '$users-last_name$'); 
+		options[3] = new Option('User: Title', '$users-title$'); 
+		options[4] = new Option('User: Department', '$users-department$'); 
+		options[5] = new Option('User: HomePhone', '$users-phone_home$'); 
+		options[6] = new Option('User: Mobile', '$users-phone_mobile$'); 
+		options[7] = new Option('User: Signature', '$users-signature$'); 
+		options[8] = new Option('User: Email', '$users-email$'); 
+		options[9] = new Option('User: Street', '$users-address_street$'); 
+		options[10] = new Option('User: City', '$users-address_city$'); 
+		options[11] = new Option('User: State', '$users-address_state$'); 
+		options[12] = new Option('User: Country', '$users-address_country$'); 
+		options[13] = new Option('User: PostalCode', '$users-address_postalcode$'); 
+            
+            	allOpts[4] = options;
+	    
+        setAllOptions(allOpts);
+    }
+	
+	function cancelForm(frm)
+	{
+		frm.action.value='detailviewemailtemplate';
+		frm.parenttab.value='Settings';
+		frm.submit();
+	}
+{/literal}
+</script>
+
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+<br>
+	<div align=center>
+	
+			{include file='SetMenu.tpl'}
+				<!-- DISPLAY -->
+				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
+				<form action="index.php" method="post" name="templatecreate" onsubmit="return check4null(templatecreate);">  
+				<input type="hidden" name="action">
+				<input type="hidden" name="mode" value="{$EMODE}">
+				<input type="hidden" name="module" value="Settings">
+				<input type="hidden" name="templateid" value="{$TEMPLATEID}">
+				<input type="hidden" name="parenttab" value="PARENTTAB}">
+				<tr>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ViewTemplate.gif" alt="{$MOD.LBL_MODULE_NAME}" width="45" height="60" border=0 title="{$MOD.LBL_MODULE_NAME}"></td>
+				{if $EMODE eq 'edit'}
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings">{$UMOD.LBL_EMAIL_TEMPLATES}</a> &gt; {$MOD.LBL_EDIT} &quot;{$TEMPLATENAME}&quot; </b></td>
+				{else}
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings">{$UMOD.LBL_EMAIL_TEMPLATES}</a> &gt; {$MOD.LBL_CREATE_EMAIL_TEMPLATES} </b></td>
+				{/if}
+					
+				</tr>
+				<tr>
+					<td valign=top class="small">{$UMOD.LBL_EMAIL_TEMPLATE_DESC}</td>
+				</tr>
+				</table>
+				
+				<br>
+				<table border=0 cellspacing=0 cellpadding=10 width=100% >
+				<tr>
+				<td>
+				
+					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+					<tr>
+						{if $EMODE eq 'edit'}
+						<td class="big"><strong>{$UMOD.LBL_PROPERTIES} &quot;{$TEMPLATENAME}&quot; </strong></td>
+						{else}
+						<td class="big"><strong>{$MOD.LBL_CREATE_EMAIL_TEMPLATES}</strong></td>
+						{/if}
+						<td class="small" align=right>
+							<input type="submit" value="{$APP.LBL_SAVE_BUTTON_LABEL}" class="crmButton small save" onclick="this.form.action.value='saveemailtemplate'; this.form.parenttab.value='Settings'" >&nbsp;&nbsp;
+			{if $EMODE eq 'edit'}
+				<input type="submit" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" onclick="cancelForm(this.form)" />
+			{else}
+				<input type="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" onclick="window.history.back()" >
+			{/if}
+						</td>
+					</tr>
+					</table>
+					
+					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr>
+						<td width=20% class="small cellLabel"><font color="red">*</font><strong>{$UMOD.LBL_NAME}</strong></td>
+						<td width=80% class="small cellText"><input name="templatename" type="text" value="{$TEMPLATENAME}" class="detailedViewTextBox" tabindex="1">&nbsp;</td>
+					  </tr>
+					<tr>
+						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_DESCRIPTION}</strong></td>
+						<td class="cellText small" valign=top><span class="small cellText">
+						  <input name="description" type="text" value="{$DESCRIPTION}" class="detailedViewTextBox" tabindex="2">
+						</span></td>
+					  </tr>
+					<tr>
+						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_FOLDER}</strong></td>
+						<td class="cellText small" valign=top>
+						{if $EMODE eq 'edit'}
+						<select name="foldername" class="small" tabindex="" style="width:100%" tabindex="3">
+                                                    {foreach item=arr from=$FOLDERNAME}
+                                                     <option value="{$FOLDERNAME}" {$arr}>{$FOLDERNAME}</option>
+                                                        {if $FOLDERNAME == 'Public'}
+                                                          <option value="Personal">{$UMOD.LBL_PERSONAL}</option>
+                                                        {else}
+                                                          <option value="Public">{$UMOD.LBL_PUBLIC}</option>
+                                                         {/if}
+                                                   {/foreach}
+                                                 </select>
+						{else}
+						<select name="foldername" class="small" tabindex="" value="{$FOLDERNAME}" style="width:100%" tabindex="3">
+                                                    <option value="Personal">{$UMOD.LBL_PERSONAL}</option>
+                                                    <option value="Public" selected>{$UMOD.LBL_PUBLIC}</option>
+        	                                </select>
+						{/if}
+					
+						</td>
+					  </tr>
+					
+					
+					<tr>
+					  <td colspan="2" valign=top class="cellText small"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="thickBorder">
+                        <tr>
+                          <td valign=top><table width="100%"  border="0" cellspacing="0" cellpadding="5" >
+                              <tr>
+                                <td colspan="3" valign="top" class="small" style="background-color:#cccccc"><strong>{$UMOD.LBL_EMAIL_TEMPLATE}</strong></td>
+                                </tr>
+                              <tr>
+                                <td width="15%" valign="top" class="cellLabel small"><font color='red'>*</font>{$UMOD.LBL_SUBJECT}</td>
+                                <td width="85%" colspan="2" class="cellText small"><span class="small cellText">
+                                  <input name="subject" type="text" value="{$SUBJECT}" class="detailedViewTextBox" tabindex="4">
+                                </span></td>
+                              </tr>
+                              <tr>
+                                <td valign="top" width=10% class="cellLabel small">{$UMOD.LBL_MESSAGE}</td>
+                                 <td valign="top" width=60% class="cellText small"><p><textarea name="body" style="width:90%;height:200px" class=small tabindex="5">{$BODY}</textarea></p>
+                                    </td>
+                                <td valign="top" width=30% class="cellText small" style="border-left:2px dotted #cccccc;"><table width="100%"  border="0" cellspacing="0" cellpadding="5" >
+                                  <tr>
+                                    <td class="small"><strong>{$UMOD.LBL_MERGE_FIELDS}<br>
+                                    </strong>{$UMOD.LBL_USE_MERGE_FIELDS_TO_EMAIL_CONTENT}</td>
+                                  </tr>
+                                  <tr>
+                                    <td class="small" nowrap><strong>{$UMOD.LBL_STEP} 1. {$UMOD.LBL_SELECT_FIELD_TYPE}</strong></td>
+                                  </tr>
+				<tr><td><select class="detailedViewTextBox" id="entityType" ONCHANGE="modifyMergeFieldSelect(this, document.getElementById('mergeFieldSelect'));" tabindex="6">
+					<OPTION VALUE="0" selected>{$APP.LBL_NONE}                            
+					<OPTION VALUE="1">{$UMOD.LBL_ACCOUNT_FIELDS}                            
+                        	        <OPTION VALUE="2">{$UMOD.LBL_CONTACT_FIELDS}
+                      			<OPTION VALUE="3" >{$UMOD.LBL_LEAD_FIELDS}
+               				<OPTION VALUE="4" >{$UMOD.LBL_USER_FIELDS}
+					</select></td></tr>
+                                  <tr>
+                                    <td class="small"><strong>{$UMOD.LBL_STEP} 2. {$UMOD.LBL_SELECT_FIELD} </strong></td>
+                                  </tr>
+					<tr><td><select class="detailedViewTextBox" id="mergeFieldSelect" onchange="document.getElementById('mergeFieldValue').value=this.options[this.selectedIndex].value;" tabindex="7"><option value="0" selected>{$APP.LBL_NONE}</select></td></tr>
+                                  <tr>
+                                    <td class="small"><strong>{$UMOD.LBL_STEP} 3. {$UMOD.LBL_COPY_PASTE} </strong></td>
+                                  </tr>
+					<tr><td><input type="text"  id="mergeFieldValue" name="variable" value="variable" class="detailedViewTextBoxOn" tabindex="8"/></td></tr>
+                                </table></td>
+                              </tr>
+                          </table></td>
+                          
+                        </tr>
+                      </table></td>
+					  </tr>
+					</table>
+					<br>
+					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr>
+					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
+					</tr>
+					</table>
+				</td>
+				</tr>
+				</table>
+			
+			
+			
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+	</form>
+	</table>
+		
+	</div>
+
+</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody>
+</table>
+<script>
+
+function check4null(form)
+{ldelim}
+
+        var isError = false;
+        var errorMessage = "";
+        // Here we decide whether to submit the form.
+        if (trim(form.templatename.value) =='') {ldelim}
+                isError = true;
+                errorMessage += "\n template name";
+                form.templatename.focus();
+        {rdelim}
+        if (trim(form.foldername.value) =='') {ldelim}
+                isError = true;
+                errorMessage += "\n folder name";
+                form.foldername.focus();
+        {rdelim}
+        if (trim(form.subject.value) =='') {ldelim}
+                isError = true;
+                errorMessage += "\n subject";
+                form.subject.focus();
+        {rdelim}
+
+        // Here we decide whether to submit the form.
+        if (isError == true) {ldelim}
+                alert("{$APP.MISSING_FIELDS}" + errorMessage);
+                return false;
+        {rdelim}
+ return true;
+
+{rdelim}
+
+init();
+
+</script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CreateProfile.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CreateProfile.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CreateProfile.tpl Mon Apr 16 12:27:44 2007
@@ -20,8 +20,8 @@
 	<br>
 	<div align=center>
 				{include file='SetMenu.tpl'}
-				<form action="index.php" method="post" name="profileform" id="form">
-                                <input type="hidden" name="module" value="Users">
+				<form action="index.php" method="post" name="profileform" id="form" onSubmit="return rolevalidate();">
+                                <input type="hidden" name="module" value="Settings">
                                 <input type="hidden" name="mode" value="{$MODE}">
                                 <input type="hidden" name="action" value="profilePrivileges">
                                 <input type="hidden" name="parenttab" value="Settings">
@@ -32,7 +32,7 @@
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<tr>
 					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-profile.gif" alt="{$MOD.LBL_PROFILES}" width="48" height="48" border=0 title="{$MOD.LBL_PROFILES}"></td>
-					<td class=heading2 valign=bottom><b> <a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=ListProfiles&parenttab=Settings">{$CMOD.LBL_PROFILE_PRIVILEGES}</a></b></td>
+					<td class=heading2 valign=bottom><b> <a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings">{$CMOD.LBL_PROFILE_PRIVILEGES}</a></b></td>
 				</tr>
 				<tr>
 					<td valign=top class="small">{$MOD.LBL_PROFILE_DESCRIPTION}</td>
@@ -125,7 +125,7 @@
 					<tr><td colspan="2" style="border-bottom:1px dashed #CCCCCC;" height="75">&nbsp;</td></tr>
 					<tr>
 						<td colspan="2" align="right">
-						<input type="button" value=" {$APP.LNK_LIST_NEXT} &rsaquo; " name="Next" class="crmButton small" onClick="rolevalidate();"/>&nbsp;&nbsp;
+						<input type="button" value=" {$APP.LNK_LIST_NEXT} &rsaquo; " name="Next" class="crmButton small" onClick="return rolevalidate();"/>&nbsp;&nbsp;
 						<input type="button" value=" {$APP.LBL_CANCEL_BUTTON_LABEL} " title="{$APP.LBL_CANCEL_BUTTON_TITLE}" name="Cancel" onClick="window.history.back();" class="crmButton small cancel"/>
 						</td>
 					</tr>
@@ -144,7 +144,7 @@
 
 					<p>&nbsp;</p>
 					<table border="0" cellpadding="5" cellspacing="0" width="100%">
-					<tbody><tr><td class="small" align="right" nowrap="nowrap"><a href="#top">Scroll to Top</a></td></tr>
+					<tbody><tr><td class="small" align="right" nowrap="nowrap"><a href="#top">{$APP.LBL_SCROLL}</a></td></tr>
 					</tbody></table>
 				
 				
@@ -173,6 +173,7 @@
 </tbody>
 </table>
 <script>
+var profile_err_msg='{$MOD.LBL_ENTER_PROFILE}';
 function rolevalidate()
 {ldelim}
     var profilename = document.getElementById('pobox').value;
@@ -181,9 +182,11 @@
 	dup_validation(profilename);
     else
     {ldelim}
-        alert('Enter The Profile name');
+        alert(profile_err_msg);
         document.getElementById('pobox').focus();
+	return false
     {rdelim}
+    return false
 {rdelim}
 
 

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CreateView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CreateView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CreateView.tpl Mon Apr 16 12:27:44 2007
@@ -18,9 +18,10 @@
 <script type="text/javascript" src="jscalendar/calendar.js"></script>
 <script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
 <script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 
 <script type="text/javascript">
+var gVTModule = '{$smarty.request.module}';
 function sensex_info()
 {ldelim}
         var Ticker = $('tickersymbol').value;
@@ -61,7 +62,11 @@
 			{$UPDATEINFO}	 
 		 {/if}
 		 {if $OP_MODE eq 'create_view'}
+			{if $DUPLICATE neq 'true'}
 			<span class="lvtHeaderText">{$APP.LBL_CREATING} {$APP.LBL_NEW} {$APP[$SINGLE_MOD]}</span> <br>
+			{else}
+			<span class="lvtHeaderText">{$APP.LBL_DUPLICATING} "{$NAME}" </span> <br>
+			{/if}
 		 {/if}
 
 		 <hr noshade size=1>
@@ -77,7 +82,7 @@
 				   <tr>
 					<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
 
-					{if $MODULE eq 'Leads' || $MODULE eq 'Accounts' || $MODULE eq 'Contacts' || $MODULE eq 'Products'}	
+					{if $ADVBLOCKS neq ''}	
 						<td width=75 style="width:15%" align="center" nowrap class="dvtSelectedCell" id="bi" onclick="fnLoadValues('bi','mi','basicTab','moreTab','normal','{$MODULE}')"><b>{$APP.LBL_BASIC} {$APP.LBL_INFORMATION}</b></td>
                     				<td class="dvtUnSelectedCell" style="width: 100px;" align="center" nowrap id="mi" onclick="fnLoadValues('mi','bi','moreTab','basicTab','normal','{$MODULE}')"><b>{$APP.LBL_MORE} {$APP.LBL_INFORMATION} </b></td>
                    				<td class="dvtTabCache" style="width:65%" nowrap>&nbsp;</td>
@@ -111,7 +116,11 @@
 								   <tr>
 									<td  colspan=4 style="padding:5px">
 									   <div align="center">
-										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{if $MODULE eq 'Accounts'}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  if(formValidate())AjaxDuplicateValidate('Accounts','accountname',this.form);" type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{else}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{/if}
                                                                  		<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 									   </div>
 									</td>
@@ -162,7 +171,11 @@
                                                                 			<input title="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_KEY}" class="crmbutton small create" onclick="window.open('index.php?module=Users&action=lookupemailtemplates&entityid={$ENTITY_ID}&entity={$ENTITY_TYPE}','emailtemplate','top=100,left=200,height=400,width=300,menubar=no,addressbar=no,status=yes')" type="button" name="button" value="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL}">
                                                                 			<input title="{$MOD.LBL_SEND}" accessKey="{$MOD.LBL_SEND}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.send_mail.value='true'; return formValidate()" type="submit" name="button" value="  {$MOD.LBL_SEND}  " >
                                                                 		{/if}
+										{if $MODULE eq 'Accounts'}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  if(formValidate())AjaxDuplicateValidate('Accounts','accountname',this.form);" type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{else}
                                                                 		<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{/if}
                                                                 		<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 									   </div>
 									</td>
@@ -196,7 +209,11 @@
 								   <tr>
 									<td  colspan=4 style="padding:5px">
 									   <div align="center">
+										{if $MODULE eq 'Accounts'}
+								<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  if(formValidate())AjaxDuplicateValidate('Accounts','accountname',this.form);" type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{else}
 										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{/if}
                                                                  		<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 									   </div>
 									</td>
@@ -222,8 +239,11 @@
                                                                 			<input title="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_KEY}" class="crmbutton small create" onclick="window.open('index.php?module=Users&action=lookupemailtemplates&entityid={$ENTITY_ID}&entity={$ENTITY_TYPE}','emailtemplate','top=100,left=200,height=400,width=300,menubar=no,addressbar=no,status=yes')" type="button" name="button" value="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL}">
                                                                 			<input title="{$MOD.LBL_SEND}" accessKey="{$MOD.LBL_SEND}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.send_mail.value='true'; return formValidate()" type="submit" name="button" value="  {$MOD.LBL_SEND}  " >
                                                                 		{/if}
-
-										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+							{if $MODULE eq 'Accounts'}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  if(formValidate())AjaxDuplicateValidate('Accounts','accountname',this.form);" type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{else}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{/if}
 										<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 									   </div>
 									</td>
@@ -280,6 +300,3 @@
 
 
 </script>
-
-
-

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CreateWordTemplate.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CreateWordTemplate.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CreateWordTemplate.tpl Mon Apr 16 12:27:44 2007
@@ -1,100 +1,100 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-<br>
-	<div align=center>
-	
-			{include file='SetMenu.tpl'}
-
-				<!-- DISPLAY -->
-				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-				<form action="index.php?module=Users&action=add2db" method="post" enctype="multipart/form-data">
-				<input type="hidden" name="return_module" value="Settings">
-				<input type="hidden" name="parenttab" value="{$PARENTTAB}">
-				<input type="hidden" name="MAX_FILE_SIZE" value="{$MAX_FILE_SIZE}">
-				<input type="hidden" name="action">
-				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}mailmarge.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listwordtemplates&parenttab=Settings">{$UMOD.LBL_WORD_TEMPLATES}</a> > {$UMOD.LBL_NEW_TEMPLATE} </b></td>
-				</tr>
-				<tr>
-					<td valign=top class="small">{$MOD.LBL_MAIL_MERGE_DESC}</td>
-				</tr>
-				</table>
-				
-				<br>
-				<table border=0 cellspacing=0 cellpadding=10 width=100% >
-				<tr>
-				<td>
-				
-					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-					<tr>
-						<td class="big"><strong>{$UMOD.LBL_NEW_TEMPLATE}</strong><br>{$ERRORFLAG}</br></td>
-						<td class="small" align=right>
-							<input title="{$APP.LBL_SAVE_BUTTON_LABEL}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" type="submit" tabindex="4" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" onclick="this.form.action.value='add2db'; this.form.parenttab.value='Settings'" class="crmButton small save" />&nbsp;
-							&nbsp;<input title="{$APP.LBL_CANCEL_BUTTON_LABEL}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" tabindex="5"  onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" />
-						</td>
-					</tr>
-					</table>
-					
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr valign="top">
-					  <td nowrap class="cellLabel small"><font color="red">*</font><strong>{$UMOD.LBL_NEW} {$UMOD.LBL_TEMPLATE_FILE}</strong></td>
-					  <td class="cellText small"><strong>
-					    <input type="file" name="binFile" class="small">
-					  </strong></td>
-					  </tr>
-					<tr>
-						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_DESCRIPTION}</strong></td>
-						<td class="cellText small" valign=top><textarea name="txtDescription" class=small style="width:90%;height:50px" value={$textDesc}></textarea></td>
-					  </tr>
-					<tr>
-						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_MODULENAMES}</strong></td>
-						<td class="cellText small" valign=top>
-						<select name="target_module" size=1 class="small" tabindex="3">
-							<option value="Leads">{$APP.COMBO_LEADS}</option>	
-							<option value="Accounts">{$APP.COMBO_ACCOUNTS}</option>	
-							<option value="Contacts">{$APP.COMBO_CONTACTS}</option>	
-							<option value="HelpDesk">{$APP.COMBO_HELPDESK}</option>	
-			                      </select>
-						</td>
-					  </tr>
-					</table>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr>
-					  <td class="small" nowrap align=right><a href="#top">[Scroll to Top]</a></td>
-					</tr>
-					</table>
-				</td>
-				</tr>
-				</table>
-			
-			
-			
-			</td>
-			</tr>
-			</table>
-		</td>
-	</tr>
-	</form>
-	</table>
-</div>		
-	</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody>
-</table>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+<br>
+	<div align=center>
+	
+			{include file='SetMenu.tpl'}
+
+				<!-- DISPLAY -->
+				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
+				<form action="index.php?module=Settings&action=savewordtemplate" method="post" enctype="multipart/form-data">
+				<input type="hidden" name="return_module" value="Settings">
+				<input type="hidden" name="parenttab" value="{$PARENTTAB}">
+				<input type="hidden" name="MAX_FILE_SIZE" value="{$MAX_FILE_SIZE}">
+				<input type="hidden" name="action">
+				<tr>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}mailmarge.gif" alt="{$MOD.LBL_MODULE_NAME}" width="48" height="48" border=0 title="{$MOD.LBL_MODULE_NAME}"></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listwordtemplates&parenttab=Settings">{$UMOD.LBL_WORD_TEMPLATES}</a> > {$UMOD.LBL_NEW_TEMPLATE} </b></td>
+				</tr>
+				<tr>
+					<td valign=top class="small">{$MOD.LBL_MAIL_MERGE_DESC}</td>
+				</tr>
+				</table>
+				
+				<br>
+				<table border=0 cellspacing=0 cellpadding=10 width=100% >
+				<tr>
+				<td>
+				
+					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+					<tr>
+						<td class="big"><strong>{$UMOD.LBL_NEW_TEMPLATE}</strong><br>{$ERRORFLAG}</br></td>
+						<td class="small" align=right>
+							<input title="{$APP.LBL_SAVE_BUTTON_LABEL}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" type="submit" tabindex="4" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" onclick="this.form.action.value='savewordtemplate'; this.form.parenttab.value='Settings'" class="crmButton small save" />&nbsp;
+							&nbsp;<input title="{$APP.LBL_CANCEL_BUTTON_LABEL}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" tabindex="5"  onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" class="crmButton small cancel" />
+						</td>
+					</tr>
+					</table>
+					
+					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr valign="top">
+					  <td nowrap class="cellLabel small"><font color="red">*</font><strong>{$UMOD.LBL_NEW} {$UMOD.LBL_TEMPLATE_FILE}</strong></td>
+					  <td class="cellText small"><strong>
+					    <input type="file" name="binFile" class="small">
+					  </strong></td>
+					  </tr>
+					<tr>
+						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_DESCRIPTION}</strong></td>
+						<td class="cellText small" valign=top><textarea name="txtDescription" class=small style="width:90%;height:50px">{$smarty.request.description}</textarea></td>
+					  </tr>
+					<tr>
+						<td valign=top class="small cellLabel"><strong>{$UMOD.LBL_MODULENAMES}</strong></td>
+						<td class="cellText small" valign=top>
+						<select name="target_module" size=1 class="small" tabindex="3">
+						<option value="Leads" {$LEADS_SELECTED}>{$APP.COMBO_LEADS}</option>
+						<option value="Accounts" {$ACCOUNTS_SELECTED}>{$APP.COMBO_ACCOUNTS}</option>
+						<option value="Contacts" {$CONTACTS_SELECTED}>{$APP.COMBO_CONTACTS}</option>
+						<option value="HelpDesk" {$HELPDESK_SELECTED}>{$APP.COMBO_HELPDESK}</option>
+			                      </select>
+						</td>
+					  </tr>
+					</table>
+					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr>
+					  <td class="small" nowrap align=right><a href="#top">{$APP.LBL_SCROLL}</a></td>
+					</tr>
+					</table>
+				</td>
+				</tr>
+				</table>
+			
+			
+			
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+	</form>
+	</table>
+</div>		
+	</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody>
+</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -27,7 +27,7 @@
 			<input type="hidden" name="action" value="index">
 			<input type="hidden" name="record" value="{$ID}">
 			<tr>
-				<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}currency.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+				<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}currency.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 				<td class="heading2" valign="bottom" ><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a> > {$MOD.LBL_VIEWING} &quot;{$CURRENCY_NAME}&quot; </b></td>
 			</tr>
 			<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyEditView.tpl Mon Apr 16 12:27:44 2007
@@ -27,7 +27,7 @@
 			<input type="hidden" name="action" value="index">
 			<input type="hidden" name="record" value="{$ID}">
 			<tr>
-				<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}currency.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+				<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}currency.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 				<td class="heading2" valign="bottom" ><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a> > 
 				{if $ID neq ''}
 					{$MOD.LBL_EDIT} &quot;{$CURRENCY_NAME}&quot; 
@@ -131,8 +131,10 @@
 						if(isNaN(getObj("conversion_rate").value) || eval(getObj("conversion_rate")
 .value) == 0)
                                                 {
-                                                        alert("Enter valid Conversion Rate")
+							{/literal}
+                                                        alert("{$APP.ENTER_VALID_CONVERSION_RATE}")
                                                         return false
+                                                        {literal}
                                                 }
                                                 return true;
 

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyListView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyListView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CurrencyListView.tpl Mon Apr 16 12:27:44 2007
@@ -28,7 +28,7 @@
 			<input type="hidden" name="action" value="CurrencyEditView">
 			<input type="hidden" name="parenttab" value="{$PARENTTAB}">
 			<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}currency.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}currency.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 				<td class="heading2" valign="bottom" ><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_CURRENCY_SETTINGS} </b></td>
 			</tr>
 			<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldList.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldList.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldList.tpl Mon Apr 16 12:27:44 2007
@@ -29,7 +29,9 @@
 {literal}
 function deleteCustomField(id, fld_module, colName, uitype)
 {
-        if(confirm("Are you sure?"))
+	{/literal}
+        if(confirm("{$APP.ARE_YOU_SURE}"))
+        {literal}
         {
                 document.form.action="index.php?module=Settings&action=DeleteCustomField&fld_module="+fld_module+"&fld_id="+id+"&colName="+colName+"&uitype="+uitype
                 document.form.submit()
@@ -88,7 +90,7 @@
 			
 				<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
 				<tbody><tr>
-					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}custom.gif" alt="Users" title="Users" border="0" height="48" width="48"></td>
+					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}custom.gif" alt="{$MOD.LBL_USERS}" title="{$MOD.LBL_USERS}" border="0" height="48" width="48"></td>
 					<td class="heading2" valign="bottom"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> &gt; {$MOD.LBL_CUSTOM_FIELD_SETTINGS}</b></td>
 				</tr>
 

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldMapping.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldMapping.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CustomFieldMapping.tpl Mon Apr 16 12:27:44 2007
@@ -21,7 +21,7 @@
 			<!-- DISPLAY -->
 				<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
 				<tr>
-					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}custom.gif" alt="Users" title="Users" border="0" height="48" width="48"></td>
+					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}custom.gif" alt="{$MOD.LBL_USERS}" title="{$MOD.LBL_USERS}" border="0" height="48" width="48"></td>
 					<td class="heading2" valign="bottom"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> &gt; {$MOD.LBL_CUSTOM_FIELD_SETTINGS}</b></td>
 				</tr>
 

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/CustomView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/CustomView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/CustomView.tpl Mon Apr 16 12:27:44 2007
@@ -92,7 +92,7 @@
         {rdelim}
         if(mandatorycheck == false)
         {ldelim}
-                alert("Must have one Required field to be selected\n"+showvalues);
+                alert("{$APP.MUSTHAVE_ONE_REQUIREDFIELD}"+showvalues);
         {rdelim}
         
         return false;
@@ -146,7 +146,18 @@
 			{foreach item=filteroption key=label from=$CHOOSECOLUMN1}
 				<optgroup label="{$label}" class=\"select\" style=\"border:none\">
 					{foreach item=text from=$filteroption}
-		   		         <option {$text.selected} value={$text.value}>{$text.text}</option>
+					 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                     {/foreach}
 			{/foreach}
           	        {$CHOOSECOLUMN1}
@@ -156,7 +167,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN2}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                              	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN2}
@@ -166,7 +188,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN3}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                    	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN3}
@@ -176,7 +209,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN4}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                    	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN4}
@@ -189,7 +233,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN5}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                    	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN5}
@@ -199,7 +254,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN6}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                   	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN6}
@@ -209,7 +275,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN7}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                    	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN7}
@@ -219,7 +296,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN8}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                    	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN8}
@@ -231,7 +319,18 @@
                         {foreach item=filteroption key=label from=$CHOOSECOLUMN9}
                                 <optgroup label="{$label}" class=\"select\" style=\"border:none\">
                                 {foreach item=text from=$filteroption}
-                                     <option {$text.selected} value={$text.value}>{$text.text}</option>
+                                    	 {assign var=option_values value=$text.text}
+		   		         <option {$text.selected} value={$text.value}>
+			{if $MOD.$option_values neq ''}
+				{$MOD.$option_values}
+
+			{elseif $APP.$option_values neq ''}
+				{$APP.$option_values}
+
+			{else}
+				{$option_values}
+			{/if}
+</option>
                                 {/foreach}
                         {/foreach}
                         {$CHOOSECOLUMN9}
@@ -469,6 +568,8 @@
   </td></tr>
   <tr><td colspan="4">&nbsp;</td></tr>
 </table>
+</table>
+</table>
 {$STDFILTER_JAVASCRIPT}
 {$JAVASCRIPT}
 <!-- to show the mandatory fields while creating new customview -->
@@ -507,9 +608,11 @@
 					selected_cv_icolumnvalue = $(cvselect_array[iloop]).options[$(cvselect_array[iloop]).selectedIndex].value;	
 					if(selected_cv_columnvalue == selected_cv_icolumnvalue)
 					{
-						alert('Columns cannot be duplicated');
-						$(cvselect_array[iloop]).selectedIndex = 0;
-						return false;
+						{/literal}
+                                                alert('{$APP.COLUMNS_CANNOT_BE_DUPLICATED}');
+                                                $(cvselect_array[iloop]).selectedIndex = 0;
+                                                return false;
+                                                {literal}
 					}
 
 				}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DefModuleView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DefModuleView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DefModuleView.tpl Mon Apr 16 12:27:44 2007
@@ -72,11 +72,11 @@
 	    </td>
                         </tr>
                         </table>	
-				<table border=0 cellspacing=0 cellpadding=5 width=100% >
+				<!--table border=0 cellspacing=0 cellpadding=5 width=100% >
 				<tr>
 					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
 				</tr>
-				</table>
+				</table-->
 	
 				</td>
 				</tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DeleteRole.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DeleteRole.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DeleteRole.tpl Mon Apr 16 12:27:44 2007
@@ -83,8 +83,10 @@
 {
 	if(document.getElementById('role_name').value == '')
 	{
-		alert('Specfiy the Role to Transfer Existing Roles Users');
-		return false;
+		{/literal}
+                alert('{$APP.SPECIFY_ROLE_INFO}');
+                return false;
+                {literal}
 	}
 	return true;
 }

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DetailView.tpl Mon Apr 16 12:27:44 2007
@@ -11,7 +11,7 @@
  ********************************************************************************/
 
 -->*}
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 <script type="text/javascript" src="include/js/reflection.js"></script>
 <script src="include/scriptaculous/prototype.js" type="text/javascript"></script>
 <script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
@@ -27,7 +27,7 @@
 <div id="convertleaddiv" style="display:block;position:absolute;left:225px;top:150px;"></div>
 <script>
 {literal}
-
+var gVTModule = '{$smarty.request.module}';
 function callConvertLeadDiv(id)
 {
         new Ajax.Request(
@@ -46,15 +46,15 @@
 
 function tagvalidate()
 {ldelim}
-	if(document.getElementById('txtbox_tagfields').value != '')
+	if(trim(document.getElementById('txtbox_tagfields').value) != '')
 		SaveTag('txtbox_tagfields','{$ID}','{$MODULE}');	
 	else
 	{ldelim}
-		alert("Please enter a tag");
+		alert("{$APP.PLEASE_ENTER_TAG}");
 		return false;
 	{rdelim}
 {rdelim}
-function DeleteTag(id)
+function DeleteTag(id,recordid)
 {ldelim}
 	$("vtbusy_info").style.display="inline";
 	Effect.Fade('tag_'+id);
@@ -62,7 +62,7 @@
 		'index.php',
                 {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
                         method: 'post',
-                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&tagid=" +id,
+                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&recordid="+recordid+"&tagid=" +id,
                         onComplete: function(response) {ldelim}
 						getTagCloud();
 						$("vtbusy_info").style.display="none";
@@ -128,7 +128,7 @@
 				<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
 				<tr>
 					<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
-					{if $MODULE eq 'Notes' || $MODULE eq 'Faq' || $MODULE eq 'Webmails' || ($MODULE eq 'Calendar' && $ACTIVITY_MODE eq 'Task')}
+					{if $IS_REL_LIST eq 'false'}
 					<td class="dvtSelectedCell" align=center nowrap>{$APP[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</td>
 					<td class="dvtTabCache" style="width:100%">&nbsp;</td>
 					{else}
@@ -174,9 +174,11 @@
 								<input title="Reply to Sender" class="crmbutton small create" onclick="window.location='index.php?module={$MODULE}&action=EditView&mailid={$ID}&reply=single&return_action=DetailView&return_module=Webmails&return_id={$ID}';return false;" type="submit" name="replytosender" value="Reply to Sender">&nbsp;
 								<input title="Reply to All" class="crmbutton small create" onclick="window.location='index.php?module={$MODULE}&action=EditView&mailid={$ID}&reply=all&return_action=DetailView&return_module=Webmails&return_id={$ID}';return false;" type="submit" name="replytosender" value="Reply to All">&nbsp;
 						{/if}
-						{if $MODULE eq 'Leads' || $MODULE eq 'Contacts'}
-								{if $SENDMAILBUTTON eq 'permitted'}
-								<input title="{$APP.LBL_SENDMAIL_BUTTON_TITLE}" accessKey="{$APP.LBL_SENDMAIL_BUTTON_KEY}" class="crmbutton small edit" onclick="fnvshobj(this,'sendmail_cont');sendmail('{$MODULE}',{$ID});" type="button" name="SendMail" value="{$APP.LBL_SENDMAIL_BUTTON_LABEL}">&nbsp;
+						{if $MODULE eq 'Leads' || $MODULE eq 'Contacts' || $MODULE eq 'Accounts'}
+							{if $SENDMAILBUTTON eq 'permitted'}
+								<input type="hidden" name="pri_email" value="{$EMAIL1}"/>
+								<input type="hidden" name="sec_email" value="{$EMAIL2}"/>
+								<input title="{$APP.LBL_SENDMAIL_BUTTON_TITLE}" accessKey="{$APP.LBL_SENDMAIL_BUTTON_KEY}" class="crmbutton small edit" onclick="if(checkEmailid('{$MODULE}',document.DetailView.pri_email.value,document.DetailView.sec_email.value)){ldelim}fnvshobj(this,'sendmail_cont');sendmail('{$MODULE}',{$ID}){rdelim}else{ldelim}return false{rdelim}" type="button" name="SendMail" value="{$APP.LBL_SENDMAIL_BUTTON_LABEL}">&nbsp;
 								{/if}
 						{/if}
 						{if $MODULE eq 'Quotes' || $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Invoice'}
@@ -211,7 +213,7 @@
 								<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
 								{/if}
 								{if $DELETE eq 'permitted'}
-								<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
+								<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; {if $MODULE eq 'Accounts'} return confirm('{$APP.NTC_ACCOUNT_DELETE_CONFIRMATION}')" {else} return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" {/if} type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
 								{/if}
 
 						</td>
@@ -297,7 +299,8 @@
 						     </table>
                      	                      </td>
 					   </tr>
-		<tr>                                                                                                               <td style="padding:10px">
+		       <tr>
+		       <td style="padding:10px">
 			{/foreach}
 			 {if $MODULE eq "Organization"}
 			     <tr>
@@ -306,14 +309,14 @@
 				</td>
 			     </tr>
 			 {/if}
-                    {*-- End of Blocks--*} 
+			{*-- End of Blocks--*} 
 			</td>
                 </tr>
 		<!-- Inventory - Product Details informations -->
 		   <tr>
 			{$ASSOCIATED_PRODUCTS}
 		   </tr>
-			{if $SinglePane_View eq 'false'}
+			{if $SinglePane_View eq 'false' || $MODULE eq 'Notes' }
 			                  <tr>
 					     <td style="padding:10px">
 		           <table border=0 cellspacing=0 cellpadding=0 width=100%>
@@ -331,10 +334,10 @@
 								<input title="Reply to Sender" class="crmbutton small create" onclick="window.location='index.php?module={$MODULE}&action=EditView&mailid={$ID}&reply=single&return_action=DetailView&return_module=Webmails&return_id={$ID}';return false;" type="submit" name="replytosender" value="Reply to Sender">&nbsp;
 								<input title="Reply to All" class="crmbutton small create" onclick="window.location='index.php?module={$MODULE}&action=EditView&mailid={$ID}&reply=all&return_action=DetailView&return_module=Webmails&return_id={$ID}';return false;" type="submit" name="replytosender" value="Reply to All">&nbsp;
 						{/if}
-						{if $MODULE eq 'Leads' || $MODULE eq 'Contacts'}
-								{if $SENDMAILBUTTON eq 'permitted'}
-								<input title="{$APP.LBL_SENDMAIL_BUTTON_TITLE}" accessKey="{$APP.LBL_SENDMAIL_BUTTON_KEY}" class="crmbutton small edit" onclick="fnvshobj(this,'sendmail_cont');sendmail('{$MODULE}',{$ID});" type="button" name="SendMail" value="{$APP.LBL_SENDMAIL_BUTTON_LABEL}">&nbsp;
-								{/if}
+						{if $MODULE eq 'Leads' || $MODULE eq 'Contacts' || $MODULE eq 'Accounts'}
+							{if $SENDMAILBUTTON eq 'permitted'}
+								<input title="{$APP.LBL_SENDMAIL_BUTTON_TITLE}" accessKey="{$APP.LBL_SENDMAIL_BUTTON_KEY}" class="crmbutton small edit" onclick="if(checkEmailid('{$MODULE}',document.DetailView.pri_email.value,document.DetailView.sec_email.value)){ldelim}fnvshobj(this,'sendmail_cont');sendmail('{$MODULE}',{$ID}){rdelim}else{ldelim}return false{rdelim}" type="button" name="SendMail" value="{$APP.LBL_SENDMAIL_BUTTON_LABEL}">&nbsp;
+							{/if}
 						{/if}
 						{if $MODULE eq 'Quotes' || $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Invoice'}
 								{if $CREATEPDF eq 'permitted'}
@@ -368,7 +371,7 @@
 								<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
 								{/if}
 								{if $DELETE eq 'permitted'}
-								<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
+								<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; {if $MODULE eq 'Accounts'} return confirm('{$APP.NTC_ACCOUNT_DELETE_CONFIRMATION}')" {else} return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" {/if} type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
 								{/if}
 
 						</td>
@@ -383,13 +386,34 @@
 </td></tr>
 {/if}
 </form>
-			{if $SinglePane_View eq 'true'}
+			{if $SinglePane_View eq 'true' && $IS_REL_LIST eq 'true'}
 				{include file= 'RelatedListNew.tpl'}
 			{/if}
 		</table>
 		</td>
 		<td width=22% valign=top style="border-left:2px dashed #cccccc;padding:13px">
 						<!-- right side relevant info -->
+		<!-- Action links for Event & Todo START-by Minnie -->
+                {if $MODULE eq 'Contacts' || $MODULE eq 'Accounts' || $MODULE eq 'Leads'}
+                        <table width="100%" border="0" cellpadding="5" cellspacing="0">
+                                <tr><td>&nbsp;</td></tr>
+                                <tr><td align="left" class="genHeaderSmall">{$APP.LBL_ACTIONS}</td></tr>
+                                <tr><td align="left" style="padding-left:10px;">
+		        <a href="index.php?module=Calendar&action=EditView&return_module={$MODULE}&return_action=DetailView&activity_mode=Events&return_id={$ID}&parent_id={$ID}&parenttab={$CATEGORY}" class="webMnu"><img src="{$IMAGE_PATH}AddEvent.gif" hspace="5" align="absmiddle"  border="0"/></a>
+                                        <a href="index.php?module=Calendar&action=EditView&return_module={$MODULE}&return_action=DetailView&activity_mode=Events&return_id={$ID}&parent_id={$ID}&parenttab={$CATEGORY}" class="webMnu">{$APP.LBL_ADD_NEW} {$APP.Event}</a>
+                                </td></tr>
+                                <tr><td align="left" style="padding-left:10px;">
+				{if $MODULE eq 'Contacts'}
+					{assign var=subst value="contact_id"}
+				{else}
+					{assign var=subst value="parent_id"}
+				{/if}
+			        <a href="index.php?module=Calendar&action=EditView&return_module={$MODULE}&return_action=DetailView&activity_mode=Task&return_id={$ID}&{$subst}={$ID}&parenttab={$CATEGORY}" class="webMnu"><img src="{$IMAGE_PATH}AddToDo.gif" hspace="5" align="absmiddle" border="0"/></a>
+                                        <a href="index.php?module=Calendar&action=EditView&return_module={$MODULE}&return_action=DetailView&activity_mode=Task&return_id={$ID}&{$subst}={$ID}&parenttab={$CATEGORY}" class="webMnu">{$APP.LBL_ADD_NEW} {$APP.Todo}</a></td></tr>
+                        </table>
+                <br>
+                {/if}
+                <!-- Action links for Event & Todo END-by Minnie -->
 
 		<!-- Tag cloud display -->
 		<table border=0 cellspacing=0 cellpadding=0 width=100% class="tagCloud">
@@ -417,10 +441,14 @@
       					   <td class="rightMailMergeHeader"><b>{$WORDTEMPLATEOPTIONS}</b></td>
       				</tr>
       				<tr style="height:25px">
-      						<td class="rightMailMergeContent">
-          						<select name="mergefile">{foreach key=templid item=tempflname from=$TOPTIONS}<option value="{$templid}">{$tempflname}</option>{/foreach}</select>
-          						<input class="crmbutton small create" value="{$APP.LBL_MERGE_BUTTON_LABEL}" onclick="this.form.action.value='Merge';" type="submit"></input>
-      					  </td>
+					<td class="rightMailMergeContent">
+						{if $TEMPLATECOUNT neq 0}
+						<select name="mergefile">{foreach key=templid item=tempflname from=$TOPTIONS}<option value="{$templid}">{$tempflname}</option>{/foreach}</select>
+                                                   <input class="crmbutton small create" value="{$APP.LBL_MERGE_BUTTON_LABEL}" onclick="this.form.action.value='Merge';" type="submit"></input> 
+						{else}
+						<a href=index.php?module=Settings&action=upload&tempModule={$MODULE}>{$APP.LBL_CREATE_MERGE_TEMPLATE}</a>
+						{/if}
+					</td>
       				</tr>
   				</table>
 				</form>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewEmailTemplate.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewEmailTemplate.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewEmailTemplate.tpl Mon Apr 16 12:27:44 2007
@@ -24,14 +24,14 @@
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 		    		<form method="post" action="index.php" name="etemplatedetailview">  
 				<input type="hidden" name="action" value="editemailtemplate">
-				<input type="hidden" name="module" value="Users">
+				<input type="hidden" name="module" value="Settings">
 				<input type="hidden" name="templatename" value="{$TEMPLATENAME}">
 				<input type="hidden" name="templateid" value="{$TEMPLATEID}">
 				<input type="hidden" name="foldername" value="{$FOLDERNAME}">
 				<input type="hidden" name="parenttab" value="{$PARENTTAB}">
 				<tr>
 					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ViewTemplate.gif" width="45" height="60" border=0 ></td>
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings">{$UMOD.LBL_EMAIL_TEMPLATES}</a> &gt; {$MOD.LBL_VIEWING} &quot;{$TEMPLATENAME}&quot; </b></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings">{$UMOD.LBL_EMAIL_TEMPLATES}</a> &gt; {$MOD.LBL_VIEWING} &quot;{$TEMPLATENAME}&quot; </b></td>
 				</tr>
 				<tr>
 					<td valign=top class="small">{$UMOD.LBL_EMAIL_TEMPLATE_DESC}</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewFields.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewFields.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewFields.tpl Mon Apr 16 12:27:44 2007
@@ -1,49 +1,49 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-
-<!-- This file is used to display the fields based on the ui type in detailview -->
-		{if $keyid eq '1' || $keyid eq 2 ||$keyid eq 8 || $keyid eq '11' || $keyid eq '7' || $keyid eq '9' || $keyid eq '55' || $keyid eq '71' || $keyid eq '72'} <!--TextBox-->
-                                         		<td width=25% class="dvtCellInfo" align="left">&nbsp;
-                                         		      {if $keyid eq '55'}<!--SalutationSymbol-->
-                                         		            {$keysalut}
-                                         		      {*elseif $keyid eq '71' || $keyid eq '72'}  <!--CurrencySymbol-->
-                                         		            {$keycursymb*}
-                                                        	{/if}
-                                                       {$keyval}
-                                                  </td>
-                                             {elseif $keyid eq '13'} <!--Email-->
-                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;<a href="mailto:{$keyval}" target="_blank">{$keyval}</a>
-                                                  </td>
-                                             {elseif $keyid eq '14'} <!-- Organization picklist-->
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+
+<!-- This file is used to display the fields based on the ui type in detailview -->
+		{if $keyid eq '1' || $keyid eq 2 ||$keyid eq 8 || $keyid eq '11' || $keyid eq '7' || $keyid eq '9' || $keyid eq '55' || $keyid eq '71' || $keyid eq '72'} <!--TextBox-->
+                                         		<td width=25% class="dvtCellInfo" align="left">&nbsp;
+                                         		      {if $keyid eq '55'}<!--SalutationSymbol-->
+                                         		            {$keysalut}
+                                         		      {*elseif $keyid eq '71' || $keyid eq '72'}  <!--CurrencySymbol-->
+                                         		            {$keycursymb*}
+                                                        	{/if}
+                                                       {$keyval}
+                                                  </td>
+                                             {elseif $keyid eq '13'} <!--Email-->
+                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;<a href="mailto:{$keyval}" target="_blank">{$keyval}</a>
+                                                  </td>
+                                             {elseif $keyid eq '14'} <!-- Organization picklist-->
                                                   <td width=25% class="dvtCellInfo" align="left">&nbsp;{$keyval}
-						  </td>
-                                             {elseif $keyid eq '15' || $keyid eq '16' || $keyid eq '111'} <!--ComboBox-->
-               							<td width=25% class="dvtCellInfo" align="left">&nbsp;{$keyval}
-               							</td>
-                                             {elseif $keyid eq '17'} <!--WebSite-->
-                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;<a href="http://{$keyval}" target="_blank">{$keyval}</a>
-                                                  </td>
-                                             {elseif $keyid eq '19' || $keyid eq '20'} <!--TextArea/Description-->
-                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;{$keyval}                   
-                                                  </td>
-                                             {elseif $keyid eq '21' || $keyid eq '24' || $keyid eq '22'} <!--TextArea/Street-->
-                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;{$keyval}
-                                                  </td>
-                                             {elseif $keyid eq '12'} <!-- Orgunit picklist-->
-					          <td width=25% class="dvtCellInfo" align="left">&nbsp;{$ASSIGN_ORGUNIT_LIST.$keyval.name}
-						  </td>
-					     {elseif $keyid eq '3' || $keyid eq '4' || $keyid eq '32' || $keyid eq '31'} <!--TextBox with Inheritance/Extension-->
+						  </td>
+                                             {elseif $keyid eq '15' || $keyid eq '16' || $keyid eq '111'} <!--ComboBox-->
+               							<td width=25% class="dvtCellInfo" align="left">&nbsp;{$keyval}
+               							</td>
+                                             {elseif $keyid eq '17'} <!--WebSite-->
+                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;<a href="http://{$keyval}" target="_blank">{$keyval}</a>
+                                                  </td>
+                                             {elseif $keyid eq '19' || $keyid eq '20'} <!--TextArea/Description-->
+                                                  <td width=100% class="dvtCellInfo" align="left">&nbsp;{$keyval}                   
+                                                  </td>
+                                             {elseif $keyid eq '21' || $keyid eq '24' || $keyid eq '22'} <!--TextArea/Street-->
+                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;{$keyval}
+                                                  </td>
+                                             {elseif $keyid eq '12'} <!-- Orgunit picklist-->
+					          <td width=25% class="dvtCellInfo" align="left">&nbsp;{$ASSIGN_ORGUNIT_LIST.$keyval.name}
+						  </td>
+					     {elseif $keyid eq '3' || $keyid eq '4' || $keyid eq '32' || $keyid eq '31'} <!--TextBox with Inheritance/Extension-->
 					     <td width=25% class="dvtCellInfo" align="left">&nbsp;
 						 {if $keyinherit == 1}
 						     {if $keyid eq '32' || $keyid eq '31'}
@@ -54,62 +54,62 @@
 						 {else}
 						     {$keyval}
 						 {/if}
-					     </td>
-                                             {elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51' || $keyid eq '57' || $keyid eq '59' || $keyid eq '75' || $keyid eq '81' || $keyid eq '76' || $keyid eq '78' || $keyid eq '80'} <!--AccountPopup-->
-                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;<a href="{$keyseclink}">{$keyval}</a>
-                                                  </td>
-                                             {elseif $keyid eq 82} <!--Email Body-->
-                                                  <td colspan="3" width=100% class="dvtCellInfo" align="left">&nbsp;{$keyval}
-                                                  </td>
-					{elseif $keyid eq '53'} <!--Assigned To-->
-                    <td width=25% class="dvtCellInfo" align="left">&nbsp;
-                    {if $keyseclink eq ''}
-                        {$keyval}
-                    {else}
-                        <a href="{$keyseclink}">{$keyval}</a>         
-                    {/if}
-					&nbsp;
-                    
-                    </td>
-		    {elseif $keyid eq '56'} <!--CheckBox--> 
-                      <td width=25% class="dvtCellInfo" align="left">{$keyval}&nbsp;
-                        </td>     
-		{elseif $keyid eq 83}<!-- Handle the Tax in Inventory -->
-							<td align="right" class="dvtCellLabel">
-							{$APP.LBL_VAT} {$APP.COVERED_PERCENTAGE}
-							
-							</td>
-							<td class="dvtCellInfo" align="left">&nbsp;
-							{$VAT_TAX}
-							</td>
-							<td colspan="2" class="dvtCellInfo">&nbsp;</td>
-						   </tr>
-		   				   <tr>
-							<td align="right" class="dvtCellLabel">
-							{$APP.LBL_SALES} {$APP.LBL_TAX} {$APP.COVERED_PERCENTAGE}
-							</td> 
-							<td class="dvtCellInfo" align="left">&nbsp;
-								{$SALES_TAX}
-							</td>	
-							<td colspan="2" class="dvtCellInfo">&nbsp;</td>
-						   </tr>
-				   		   <tr>
-							<td align="right" class="dvtCellLabel">
-								{$APP.LBL_SERVICE} {$APP.LBL_TAX} {$APP.COVERED_PERCENTAGE}
-							</td>
-							<td class="dvtCellInfo" align="left" >&nbsp;
-								{$SERVICE_TAX}
-							</td>
-	
-
-				{elseif $keyid eq 69}<!-- for Image Reflection -->
-                                                  	<td align="left" width=25%">&nbsp;{$keyval}</td>
+					     </td>
+                                             {elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51' || $keyid eq '57' || $keyid eq '59' || $keyid eq '75' || $keyid eq '81' || $keyid eq '76' || $keyid eq '78' || $keyid eq '80'} <!--AccountPopup-->
+                                                  <td width=25% class="dvtCellInfo" align="left">&nbsp;<a href="{$keyseclink}">{$keyval}</a>
+                                                  </td>
+                                             {elseif $keyid eq 82} <!--Email Body-->
+                                                  <td colspan="3" width=100% class="dvtCellInfo" align="left">&nbsp;{$keyval}
+                                                  </td>
+					{elseif $keyid eq '53'} <!--Assigned To-->
+                    <td width=25% class="dvtCellInfo" align="left">&nbsp;
+                    {if $keyseclink eq ''}
+                        {$keyval}
+                    {else}
+                        <a href="{$keyseclink}">{$keyval}</a>         
+                    {/if}
+					&nbsp;
+                    
+                    </td>
+		    {elseif $keyid eq '56'} <!--CheckBox--> 
+                      <td width=25% class="dvtCellInfo" align="left">{$keyval}&nbsp;
+                        </td>     
+		{elseif $keyid eq 83}<!-- Handle the Tax in Inventory -->
+							<td align="right" class="dvtCellLabel">
+							{$APP.LBL_VAT} {$APP.COVERED_PERCENTAGE}
+							
+							</td>
+							<td class="dvtCellInfo" align="left">&nbsp;
+							{$VAT_TAX}
+							</td>
+							<td colspan="2" class="dvtCellInfo">&nbsp;</td>
+						   </tr>
+		   				   <tr>
+							<td align="right" class="dvtCellLabel">
+							{$APP.LBL_SALES} {$APP.LBL_TAX} {$APP.COVERED_PERCENTAGE}
+							</td> 
+							<td class="dvtCellInfo" align="left">&nbsp;
+								{$SALES_TAX}
+							</td>	
+							<td colspan="2" class="dvtCellInfo">&nbsp;</td>
+						   </tr>
+				   		   <tr>
+							<td align="right" class="dvtCellLabel">
+								{$APP.LBL_SERVICE} {$APP.LBL_TAX} {$APP.COVERED_PERCENTAGE}
+							</td>
+							<td class="dvtCellInfo" align="left" >&nbsp;
+								{$SERVICE_TAX}
+							</td>
+	
+
+				{elseif $keyid eq 69}<!-- for Image Reflection -->
+                                                  	<td align="left" width=25%">&nbsp;{$keyval}</td>
 				{elseif $keyid eq 107}<!-- Company Logo -->
 				    <td class="dvtCellInfo" align="left" width="25%">
 					{if $keyval ne ""}
 					    <img src="test/logo/{$keyval}" width="96" height="48" alt="{$keyval}" title="{$keyval}" border="0">
 					{/if}
 				    </td>
-				{else}									
-                                                  	<td class="dvtCellInfo" align="left" width=25%">&nbsp;{$keyval}</td>
-				{/if}
+				{else}									
+                                                  	<td class="dvtCellInfo" align="left" width=25%">&nbsp;{$keyval}</td>
+				{/if}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewHidden.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewHidden.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewHidden.tpl Mon Apr 16 12:27:44 2007
@@ -203,6 +203,14 @@
 	{if $MODULE eq 'OrgUnit'}
 		<input type="hidden" name="organizationname" value="{$PARENTORG}">
 	{/if}
+{else}
+	<input type="hidden" name="module" value="{$MODULE}">
+        <input type="hidden" name="record" value="{$ID}">
+        <input type="hidden" name="isDuplicate" value=false>
+        <input type="hidden" name="action">
+        <input type="hidden" name="return_module">
+        <input type="hidden" name="return_action">
+        <input type="hidden" name="return_id">
 {/if}
 
 

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewUI.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewUI.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DetailViewUI.tpl Mon Apr 16 12:27:44 2007
@@ -14,7 +14,11 @@
 
 <!-- This file is used to display the fields based on the ui type in detailview -->
 		{if $keyid eq '1' || $keyid eq 2 || $keyid eq '11' || $keyid eq '7' || $keyid eq '9' || $keyid eq '55' || $keyid eq '71' || $keyid eq '72' || $keyid eq '103'} <!--TextBox-->
-                                         		<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">
+				{if $label eq 'Invoice No'}
+                                                        <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}">
+                                {else}
+                                         		<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">
+                                 {/if}
                                          		      {if $keyid eq '55'}<!--SalutationSymbol-->
                                          		            {$keysalut}
                                          		      {*elseif $keyid eq '71' || $keyid eq '72'}  <!--CurrencySymbol-->
@@ -22,24 +26,24 @@
                                                         {/if}
                                                        &nbsp;&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
                                               		<div id="editarea_{$label}" style="display:none;">
-                                              		  <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval}"></input>
-                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                              		  <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval|escape}"></input>
+                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>
                                              {elseif $keyid eq '8'} <!--Non editable text field-->
 						 <td width=25% class="dvtCellInfo" align="left">&nbsp;&nbsp;{$keyval}</td>
                                              {elseif $keyid eq '13' || $keyid eq '104'} <!--Email-->
-                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="mailto:{$keyval}" target="_blank">{$keyval}</a></span>
-                                              		<div id="editarea_{$label}" style="display:none;">
-                                              		  <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval}"></input>
-                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="mailto:{$keyval}" target="_blank">{$keyval}</a></span>
+                                              		<div id="editarea_{$label}" style="display:none;">
+                                              		  <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval|escape}"></input>
+                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>
 						<!-- uitype 111 added for noneditable existing picklist values - ahmed -->
                                              {elseif $keyid eq '15' || $keyid eq '16' || $keyid eq '111'} <!--ComboBox-->
-               							<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
+               							<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{if $APP.$keyval!=''}{$APP.$keyval}{elseif $MOD.$keyval!=''}{$MOD.$keyval}{else}{$keyval}{/if}</span>
                                               		<div id="editarea_{$label}" style="display:none;">
                     							   <select id="txtbox_{$label}" name="{$keyfldname}">
                     								{foreach item=arr from=$keyoptions}
@@ -49,8 +53,8 @@
                     									{/foreach}
                     								{/foreach}
                     							   </select>
-                    							   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                    							   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                     							</div>
                							</td>
                                              {elseif $keyid eq '12'} <!-- OrgUnit picklist-->
@@ -158,7 +162,7 @@
 						<!--code given by Neil start Ref:http://forums.vtiger.com/viewtopic.php?p=31096#31096-->
 						{assign var="MULTISELECT_COMBO_BOX_ITEM_SEPARATOR_STRING" value=", "}  {* Separates Multi-Select Combo Box items *}
 						{assign var="DETAILVIEW_WORDWRAP_WIDTH" value="70"} {* No. of chars for word wrapping long lines of Multi-Select Combo Box items *}
-                                          <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">
+                                          <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">
 						{$keyval|replace:$MULTISELECT_COMBO_BOX_ITEM_SEPARATOR_STRING:"\x1"|replace:" ":"\x0"|replace:"\x1":$MULTISELECT_COMBO_BOX_ITEM_SEPARATOR_STRING|wordwrap:$DETAILVIEW_WORDWRAP_WIDTH:"<br>&nbsp;"|replace:"\x0":"&nbsp;"}
 						</span>
 						<!--code given by Neil End-->
@@ -170,13 +174,13 @@
 					                                     {/foreach}
 				                                    {/foreach}
 			                                   </select>
-			                                   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+			                                   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                     							</div>
                							</td>
 						{elseif $keyid eq '115'} <!--ComboBox Status edit only for admin Users-->
 								{if $keyadmin eq 1}
-               							<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
+               							<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
                                               		<div id="editarea_{$label}" style="display:none;">
                     							   <select id="txtbox_{$label}" name="{$keyfldname}">
                     								{foreach item=arr from=$keyoptions}
@@ -185,8 +189,8 @@
                     									{/foreach}
                     								{/foreach}
                     							   </select>
-                    							   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                    							   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                     							</div>
 								{else}
                							<td width=25% class="dvtCellInfo" align="left">{$keyval}
@@ -195,7 +199,7 @@
                							</td>
 						{elseif $keyid eq '116'} <!--ComboBox currency id edit only for admin Users-->
 								{if $keyadmin eq 1}
-               							<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
+               							<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
 								<div id="editarea_{$label}" style="display:none;">
                     							   <select id="txtbox_{$label}" name="{$keyfldname}">
 									{foreach item=arr key=uivalueid from=$keyoptions}
@@ -204,8 +208,8 @@
 									{/foreach}
 									{/foreach}
                     							   </select>
-                    							   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                    							   <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		   <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                     							</div>
 								{else}
                							<td width=25% class="dvtCellInfo" align="left">{$keyval}
@@ -214,19 +218,19 @@
                                         		
                							</td>
                                              {elseif $keyid eq '17'} <!--WebSite-->
-                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="http://{$keyval}" target="_blank">{$keyval}</a></span>
-                                              		<div id="editarea_{$label}" style="display:none;">
-                                              		  <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval}"></input>
-                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="http://{$keyval}" target="_blank">{$keyval}</a></span>
+                                              		<div id="editarea_{$label}" style="display:none;">
+                                              		  <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval|escape}"></input>
+                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>
 					     {elseif $keyid eq '85'}<!--Skype-->
-                                                <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<img src="{$IMAGE_PATH}skype.gif" alt="Skype" title="Skype" LANGUAGE=javascript align="absmiddle"></img><span id="dtlview_{$label}"><a href="skype:{$keyval}?call">{$keyval}</a></span>
+                                                <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<img src="{$IMAGE_PATH}skype.gif" alt="{$APP.LBL_SKYPE}" title="{$APP.LBL_SKYPE}" LANGUAGE=javascript align="absmiddle"></img><span id="dtlview_{$label}"><a href="skype:{$keyval}?call">{$keyval}</a></span>
                                                         <div id="editarea_{$label}" style="display:none;">
-                                                          <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval}"></input>
-                                                          <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                                          <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                          <input class="detailedViewTextBox" onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" type="text" id="txtbox_{$label}" name="{$keyfldname}" maxlength='100' value="{$keyval|escape}"></input>
+                                                          <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                                          <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>	
                                              {elseif $keyid eq '18'} <!--WebSite with Inheritance-->
@@ -271,40 +275,45 @@
 						{/if}
 							<!--{assign var="DESCRIPTION_SEPARATOR_STRING" value=" "}  {* Separates Description *}-->
 							<!--{assign var="DESCRIPTION_WORDWRAP_WIDTH" value="70"} {* No. of chars for word wrapping long lines of Description *}-->
-                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">
-							{$keyval}<!--|replace:$DESCRIPTION_SEPARATOR_STRING:"\x1"|replace:" ":"\x0"|replace:"\x1":$DESCRIPTION_SEPARATOR_STRING|wordwrap:$DESCRIPTION_WORDWRAP_WIDTH:"<br>&nbsp;"|replace:"\x0":"&nbsp;"}-->
-							</span>
-                                              		<div id="editarea_{$label}" style="display:none;">
-                                              		  <textarea id="txtbox_{$label}" name="{$keyfldname}"  class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" cols="90" rows="8">{$keyval}</textarea>                                            		  
-                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
-                                                       </div>
-                                                  </td>
+							{if $MODULE eq 'Notes'}
+                                                        <td width="100%" colspan="3" class="dvtCellInfo" align="left">{$keyval|replace:"\n":"<br>&nbsp;&nbsp;"}&nbsp;
+                                                        </td>
+                                                  	{else}
+                                                        <td width="100%" colspan="3" class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">
+                                                                {$keyval|replace:"\n":"<br>&nbsp;&nbsp;"}<!--|replace:$DESCRIPTION_SEPARATOR_STRING:"\x1"|replace:" ":"\x0"|replace:"\x1":$DESCRIPTION_SEPARATOR_STRING|wordwrap:$DESCRIPTION_WORDWRAP_WIDTH:"<br>&nbsp;"|replace:"\x0":"&nbsp;"}-->
+                                                                </span>
+                                                                <div id="editarea_{$label}" style="display:none;">
+                                                                <textarea id="txtbox_{$label}" name="{$keyfldname}"  class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" cols="90" rows="8">{$keyval|replace:"<br>":"\n"}</textarea>
+                                                                <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                                                <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                                </div>
+                                                        </td>
+                                                   {/if}
                                              {elseif $keyid eq '21' || $keyid eq '24' || $keyid eq '22'} <!--TextArea/Street-->
-                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
-                                              		<div id="editarea_{$label}" style="display:none;">
-                                              		  <textarea id="txtbox_{$label}" name="{$keyfldname}"  class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" rows=2>{$keyval}</textarea>                                            		  
-                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
+                                              		<div id="editarea_{$label}" style="display:none;">
+                                              		  <textarea id="txtbox_{$label}" name="{$keyfldname}"  class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" rows=2>{$keyval|regex_replace:"/<br\s*\/>/":""}</textarea>                                            		  
+                                              		  <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>
                                              {elseif $keyid eq '50' || $keyid eq '73' || $keyid eq '51'} <!--AccountPopup-->
                                                   <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}">&nbsp;<a href="{$keyseclink}">{$keyval}</a>
                                                   </td>
                                              {elseif $keyid eq '57'} <!--ContactPopup-->
-                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="{$keyseclink}">{$keyval}</a></span>
+                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="{$keyseclink}">{$keyval}</a></span>
                                               		<div id="editarea_{$label}" style="display:none;">                                              		  
-                                                         <input id="popuptxt_{$label}" name="contact_name" readonly type="text" style="border:1px solid #bababa;" value="{$keyval}"><input id="txtbox_{$label}" name="{$keyfldname}" type="hidden" value="{$keysecid}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&action=Popup&Parent={$ID}&html=Popup_picker&popuptype=specific&form=EditView","test","width=600,height=602,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.contact_id.value=''; this.form.contact_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
-                                                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                         <input id="popuptxt_{$label}" name="contact_name" readonly type="text" style="border:1px solid #bababa;" value="{$keyval|escape}"><input id="txtbox_{$label}" name="{$keyfldname}" type="hidden" value="{$keysecid}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=600,height=602,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.contact_id.value=''; this.form.contact_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+                                                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>                                                  
                                              {elseif $keyid eq '59'} <!--ProductPopup-->
-                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="{$keyseclink}">{$keyval}</a></span>
+                                                  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}"><a href="{$keyseclink}">{$keyval}</a></span>
                                               		<div id="editarea_{$label}" style="display:none;">                                              		  
-                                                         <input id="popuptxt_{$label}" name="product_name" readonly type="text" value="{$keyval}"><input id="txtbox_{$label}" name="{$keyfldname}" type="hidden" value="{$keysecid}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=specific","test","width=600,height=602,resizable=1,scrollbars=1,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.product_id.value=''; this.form.product_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
-                                                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
-                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                         <input id="popuptxt_{$label}" name="product_name" readonly type="text" value="{$keyval|escape}"><input id="txtbox_{$label}" name="{$keyfldname}" type="hidden" value="{$keysecid}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=specific","test","width=600,height=602,resizable=1,scrollbars=1,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.product_id.value=''; this.form.product_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+                                                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                              		  <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                                                        </div>
                                                   </td>
                                              {elseif $keyid eq '75' || $keyid eq '81'} <!--VendorPopup-->
@@ -322,8 +331,23 @@
                                              {elseif $keyid eq 80} <!--SalesOrderPopup-->
                                                   <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}">&nbsp;<a href="{$keyseclink}">{$keyval}</a>
                                                   </td>
+					     {elseif $keyid eq '52' || $keyid eq '77'} 
+                                                                <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}</span>
+                                                        <div id="editarea_{$label}" style="display:none;">
+                                                                           <select id="txtbox_{$label}" name="{$keyfldname}">
+                                                                                {foreach item=arr key=uid from=$keyoptions}
+                                                                                        {foreach key=sel_value item=value from=$arr}
+                                                                                                <option value="{$uid}" {$value}>{if $APP.$sel_value}{$APP.$sel_value}{else}{$sel_value}{/if}</option>
+
+                                                                                        {/foreach}
+                                                                                {/foreach}
+                                                                           </select>
+                                                                           <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');fnhide('crmspanid');"/> {$APP.LBL_OR}
+                                                           <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                                                                        </div>
+                                                                </td>	
 					     {elseif $keyid eq '53'} <!--Assigned To-->
-                    				  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">
+                    				  <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">
                     				{if $keyoptions.0 eq 'User' && $keyadmin eq 1}
 			                        	<a href="{$keyseclink.0}">{$keyval}</a>         
 			                        {elseif $keyoptions.0 eq 'Group' && $keyadmin eq 1}
@@ -358,7 +382,7 @@
 					{else}
 						<span id="assign_team" style="display: none;">
 					{/if}
-                   	<select id="txtbox_G{$label}" onchange="setSelectValue('{$label}')" name="{$keyfldname}">
+                   	<select id="txtbox_G{$label}" onchange="setSelectValue('{$label}')" name="assigned_group_name" class="groupname">
                     {foreach item=arr key=id from=$keyoptions.2}
                     	{foreach key=sel_value item=value from=$arr}
                        		 <option value="{$id}" {$value}>{$sel_value}</option>
@@ -368,35 +392,35 @@
 					</span>
 
                     <br>
-                    <input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');"/> {$APP.LBL_OR}
-                    <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                    <input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');"/> {$APP.LBL_OR}
+                    <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                     </div>
                     </td>
 						{elseif $keyid eq '99'}<!-- Password Field-->
 						<td width=25% class="dvtCellInfo" align="left">{$CHANGE_PW_BUTTON}</td>	
 					    {elseif $keyid eq '56'} <!--CheckBox--> 
-                      <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onMouseOver="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}&nbsp;</span>
+                      <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onMouseOver="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}&nbsp;</span>
                     	<div id="editarea_{$label}" style="display:none;">
                         {if $keyval eq 'yes'}                                              		  
                             <input id="txtbox_{$label}" name="{$keyfldname}" type="checkbox" style="border:1px solid #bababa;" checked value="1">
                         {else}
                           <input id="txtbox_{$label}" type="checkbox" name="{$keyfldname}" style="border:1px solid #bababa;" value="0">
                        	{/if}
-                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');"/> {$APP.LBL_OR}
-                          <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');"/> {$APP.LBL_OR}
+                          <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                         </div>
                         </td>    
 			{elseif $keyid eq '156'} <!--CheckBox for is admin-->
 			{if $smarty.request.record neq $CURRENT_USERID && $keyadmin eq 1} 
-                      <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onMouseOver="hndMouseOver({$keyid},'{$label}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{$keyval}&nbsp;</span>
+                      <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onMouseOver="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">&nbsp;<span id="dtlview_{$label}">{if $APP.$keyval!=''}{$APP.$keyval}{elseif $MOD.$keyval!=''}{$MOD.$keyval}{else}{$keyval}{/if}&nbsp;</span>
                     	<div id="editarea_{$label}" style="display:none;">
                         {if $keyval eq 'on'}                                              		  
                             <input id="txtbox_{$label}" name="{$keyfldname}" type="checkbox" style="border:1px solid #bababa;" checked value="1">
                         {else}
                           <input id="txtbox_{$label}" type="checkbox" name="{$keyfldname}" style="border:1px solid #bababa;" value="0">
                        	{/if}
-                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');"/> {$APP.LBL_OR}
-                          <a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
+                         <br><input name="button_{$label}" type="button" class="crmbutton small save" value="{$APP.LBL_SAVE_LABEL}" onclick="dtlViewAjaxSave('{$label|escape:'quotes'}','{$MODULE}',{$keyid},'{$keytblname}','{$keyfldname}','{$ID}');"/> {$APP.LBL_OR}
+                          <a href="javascript:;" onclick="hndCancel('dtlview_{$label|escape:'quotes'}','editarea_{$label|escape:'quotes'}','{$label|escape:'quotes'}')" class="link">{$APP.LBL_CANCEL_BUTTON_LABEL}</a>
                         </div>
 			{else}
 				 <td width=25% class="dvtCellInfo" align="left">{$keyval}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/DisplayFields.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/DisplayFields.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/DisplayFields.tpl Mon Apr 16 12:27:44 2007
@@ -35,7 +35,7 @@
 				<font color="red">*</font>{$fldlabel}
 			</td>
 			<td width=30% align=left class="dvtCellInfo">
-				<input type="text" name="{$fldname}" tabindex="{$vt_tab}" value="{$fldvalue}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
+				<input type="text" name="{$fldname}" tabindex="{$vt_tab}" value="{$fldvalue|escape}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
 			</td>
 		{elseif $uitype eq 8}
 			<td width=20% class="dvtCellLabel" align=right>{$fldlabel}</td>
@@ -46,12 +46,17 @@
 
 			{if $fldname eq 'tickersymbol' && $MODULE eq 'Accounts'}
 				<td width=30% align=left class="dvtCellInfo">
-					<input type="text" name="{$fldname}" tabindex="{$vt_tab}" id ="{$fldname}" value="{$fldvalue}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn';" onBlur="this.className='detailedViewTextBox';{if $fldname eq 'tickersymbol' && $MODULE eq 'Accounts'}sensex_info(){/if}">
+					<input type="text" name="{$fldname}" tabindex="{$vt_tab}" id ="{$fldname}" value="{$fldvalue|escape}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn';" onBlur="this.className='detailedViewTextBox';{if $fldname eq 'tickersymbol' && $MODULE eq 'Accounts'}sensex_info(){/if}">
 					<span id="vtbusy_info" style="display:none;">
 						<img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span>
 				</td>
+			{elseif $fldname eq 'invoice_no' && $MODULE eq 'Invoice'}
+
+                                <td width=30% align=left class="dvtCellInfo"><input readonly type="text" tabindex="{$vt_tab}" name="{$fldname}" id ="{$fldname}" {if $MODE eq 'edit'} value="{$fldvalue|escape}" {else} value="{$inv_no}" {/if} class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
+		
+
 			{else}
-				<td width=30% align=left class="dvtCellInfo"><input type="text" tabindex="{$vt_tab}" name="{$fldname}" id ="{$fldname}" value="{$fldvalue}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
+				<td width=30% align=left class="dvtCellInfo"><input type="text" tabindex="{$vt_tab}" name="{$fldname}" id ="{$fldname}" value="{$fldvalue|escape}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
 			{/if}
 		{elseif $uitype eq '14'} <!-- Organization picklist-->
 			<td width=20% class="dvtCellLabel" align=right>{$fldlabel}</td>
@@ -80,7 +85,10 @@
 				{$fldlabel}
 			</td>
 			<td colspan=3>
-				<textarea class="detailedViewTextBox" tabindex="{$vt_tab}" onFocus="this.className='detailedViewTextBoxOn'" name="{$fldname}"  onBlur="this.className='detailedViewTextBox'" cols="90" rows="8">{$fldvalue}</textarea>
+				<textarea class="detailedViewTextBox" tabindex="{$vt_tab}" onFocus="this.className='detailedViewTextBoxOn'" name="{$fldname}"  onBlur="this.className='detailedViewTextBox'" cols="90" rows="8">{$fldvalue|escape}</textarea>
+				{if $fldlabel eq $MOD.Solution}
+				<input type = "hidden" name="helpdesk_solution" value = '{$fldvalue}'>
+				{/if}
 			</td>
 		{elseif $uitype eq 21 || $uitype eq 24}
 			<td width=20% class="dvtCellLabel" align=right>
@@ -90,7 +98,7 @@
 				{$fldlabel}
 			</td>
 			<td width=30% align=left class="dvtCellInfo">
-				<textarea value="{$fldvalue}" name="{$fldname}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" rows=2>{$fldvalue}</textarea>
+				<textarea value="{$fldvalue|escape}" name="{$fldname}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" rows=2>{$fldvalue|escape}</textarea>
 			</td>
 		{elseif $uitype eq 15 || $uitype eq 16 || $uitype eq 111} <!-- uitype 111 added for noneditable existing picklist values - ahmed -->
 			<td width="20%" class="dvtCellLabel" align=right>
@@ -104,8 +112,8 @@
 				{foreach item=arr from=$fldvalue}
 					{foreach key=sel_value item=value from=$arr}
 						<option value="{$sel_value}" {$value}>
-                                                {if $APP.$sel_value neq ''}
-                                                {$APP.$sel_value}
+                                                {if $MOD.$sel_value neq ''}
+                                                {$MOD.$sel_value}
                                                 {else}
                                                         {$sel_value}
                                                 {/if}
@@ -182,10 +190,11 @@
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
 			   <select MULTIPLE name="{$fldname}[]" size="4" style="width:160px;" tabindex="{$vt_tab}" class="small">
-				                    									{foreach key=sel_value item=value from=$arr}
-                    										<option value="{$sel_value}" {$value}>{if $APP.$sel_value}{$APP.$sel_value}{else}{$sel_value}{/if}</option>
-                    									
-                    									{/foreach}
+				{foreach item=arr from=$fldvalue}
+					{foreach key=sel_value item=value from=$arr}
+						<option value="{$sel_value}" {$value}>{if $APP.$sel_value}{$APP.$sel_value}{else}{$sel_value}{/if}</option>
+					{/foreach}
+				{/foreach}
 			   </select>
 			</td>
 
@@ -235,7 +244,7 @@
 						<select name="assigned_group_name" class="small">';
 							{foreach key=key_one item=arr from=$secondvalue}
 								{foreach key=sel_value item=value from=$arr}
-									<option value="{$sel_value}" {$value}>{$sel_value}</option>
+									<option value="{$sel_value}" {$value}>{$sel_value|truncate:20:'...'}</option>
 								{/foreach}
 							{/foreach}
 						</select>
@@ -272,7 +281,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input readonly name="account_name" style="border:1px solid #bababa;" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype={$popuptype}&form=TasksEditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.account_id.value=''; this.form.account_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input readonly name="account_name" style="border:1px solid #bababa;" type="text" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype={$popuptype}&form=TasksEditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.account_id.value=''; this.form.account_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 50}
@@ -280,24 +289,24 @@
 				<font color="red">*</font>{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input readonly name="account_name" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific&form=TasksEditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input readonly name="account_name" type="text" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific&form=TasksEditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 		{elseif $uitype eq 73}
 			<td width="20%" class="dvtCellLabel" align=right>
 				<font color="red">*</font>{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input readonly name="account_name" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific_account_address&form=TasksEditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
-			</td>
-
-		{elseif $uitype eq 74}
-			<td width="20%" class="dvtCellLabel" align=right>
-				{$fldlabel}
-			</td>
-			<td width="30%" align=left class="dvtCellInfo">
-				<input name="orgunit" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Organization&action=Popup&html=Popup_picker&popuptype=specific_orgunit&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.orgunit.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
-			</td>
-
+				<input readonly name="account_name" id = "single_accountid" type="text" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific_account_address&form=TasksEditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
+			</td>
+
+ 		{elseif $uitype eq 74}
+ 			<td width="20%" class="dvtCellLabel" align=right>
+ 				{$fldlabel}
+ 			</td>
+ 			<td width="30%" align=left class="dvtCellInfo">
+ 				<input name="orgunit" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Organization&action=Popup&html=Popup_picker&popuptype=specific_orgunit&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.orgunit.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+ 			</td>
+ 
 		{elseif $uitype eq 75 || $uitype eq 81}
 			<td width="20%" class="dvtCellLabel" align=right>
 				{if $uitype eq 81}
@@ -308,9 +317,9 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="vendor_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Vendors&action=Popup&html=Popup_picker&popuptype={$pop_type}&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="vendor_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Vendors&action=Popup&html=Popup_picker&popuptype={$pop_type}&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>
 				{if $uitype eq 75}
-					&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.vendor_id.value='';this.form.vendor_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+					&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.vendor_id.value='';this.form.vendor_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 				{/if}
 			</td>
 		{elseif $uitype eq 57}
@@ -318,7 +327,8 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="contact_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&action=Popup&Parent={$ID}&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.contact_id.value=''; this.form.contact_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+			
+				<input name="contact_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='selectContact("false","general",document.EditView)' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.contact_id.value=''; this.form.contact_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 		
 		{elseif $uitype eq 58}
@@ -326,7 +336,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="campaignname" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Campaigns&action=Popup&html=Popup_picker&popuptype=specific_campaign&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.campaignid.value=''; this.form.campaignname.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="campaignname" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Campaigns&action=Popup&html=Popup_picker&popuptype=specific_campaign&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.campaignid.value=''; this.form.campaignname.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 80}
@@ -334,7 +344,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="salesorder_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.salesorder_id.value=''; this.form.salesorder_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="salesorder_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='selectSalesOrder();' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.salesorder_id.value=''; this.form.salesorder_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 78}
@@ -342,7 +352,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="quote_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$QUOTE_ID}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.quote_id.value=''; this.form.quote_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="quote_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='selectQuote()' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" tabindex="{$vt_tab}" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.quote_id.value=''; this.form.quote_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 76}
@@ -350,7 +360,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="potential_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.potential_id.value=''; this.form.potential_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="potential_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='selectPotential()' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.potential_id.value=''; this.form.potential_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 17}
@@ -358,8 +368,8 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				&nbsp;&nbsp;http://&nbsp;
-				<input type="text" tabindex="{$vt_tab}" name="{$fldname}" style="border:1px solid #bababa;" size="27" onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" value="{$fldvalue}">
+				&nbsp;&nbsp;http://
+			<input style="width:74%;" class = 'detailedViewTextBoxOn' type="text" tabindex="{$vt_tab}" name="{$fldname}" style="border:1px solid #bababa;" size="27" onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'"  value="{$fldvalue|escape}">
 			</td>
 
 		{elseif $uitype eq 85}
@@ -367,7 +377,7 @@
                                 {$fldlabel}
                         </td>
                         <td width="30%" align=left class="dvtCellInfo">
-                                <img src="{$IMAGE_PATH}skype.gif" alt="Skype" title="Skype" LANGUAGE=javascript align="absmiddle"></img><input type="text" tabindex="{$vt_tab}" name="{$fldname}" style="border:1px solid #bababa;" size="27" onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" value="{$fldvalue}">
+                                <img src="{$IMAGE_PATH}skype.gif" alt="Skype" title="Skype" LANGUAGE=javascript align="absmiddle"></img><input type="text" tabindex="{$vt_tab}" name="{$fldname}" style="border:1px solid #bababa;" size="27" onFocus="this.className='detailedViewTextBoxOn'"onBlur="this.className='detailedViewTextBox'" value="{$fldvalue|escape}">
                         </td>
 
 		{elseif $uitype eq 18}
@@ -408,7 +418,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="{$fldname}" tabindex="{$vt_tab}" type="text" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"  value="{$fldvalue}">
+				<input name="{$fldname}" tabindex="{$vt_tab}" type="text" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"  value="{$fldvalue|escape}">
 			</td>
 
 		{elseif $uitype eq 56}
@@ -446,7 +456,7 @@
 					{assign var=time_val value="$time_value"}
 				{/foreach}
 
-				<input name="{$fldname}" tabindex="{$vt_tab}" id="jscal_field_{$fldname}" type="text" style="border:1px solid #bababa;" size="11" maxlength="10" value="{$date_val}">
+				<input name="{$fldname}" tabindex="{$vt_tab}" id="jscal_field_{$fldname}" type="text" style="border:1px solid #bababa;" size="11" maxlength="10" value="{$date_val|escape}">
 				<img src="{$IMAGE_PATH}calendar.gif" id="jscal_trigger_{$fldname}">
 
 				{if $uitype eq 6}
@@ -478,7 +488,7 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-				<input name="{$fldname}" type="text" size="2" value="{$fldvalue}" tabindex="{$vt_tab}" >&nbsp;
+				<input name="{$fldname}" type="text" size="2" value="{$fldvalue|escape}" tabindex="{$vt_tab}" >&nbsp;
 				<select name="duration_minutes" tabindex="{$vt_tab}" class="small">
 					{foreach key=labelval item=selectval from=$secondvalue}
 						<option value="{$labelval}" {$selectval}>{$labelval}</option>
@@ -495,8 +505,8 @@
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
 				<input name="{$fldname}" type="hidden" value="{$secondvalue}">
-				<input name="parent_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}">
-				&nbsp;<img src="{$IMAGE_PATH}select.gif" tabindex="{$vt_tab}" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="parent_name" readonly id = "parentid" type="text" style="border:1px solid #bababa;" value="{$fldvalue|escape}">
+				&nbsp;<img src="{$IMAGE_PATH}select.gif" tabindex="{$vt_tab}" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 357}
@@ -509,7 +519,7 @@
 						<option value="{$labelval}" {$selectval}>{$labelval}</option>
 					{/foreach}
 				</select>
-				&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 		   <tr style="height:25px">
 			<td width="20%" class="dvtCellLabel" align=right>CC:&nbsp;</td>	
@@ -528,7 +538,7 @@
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
 				<input name="{$fldname}" type="hidden" value="{$secondvalue}">
-				<input name="product_name" readonly type="text" value="{$fldvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=specific","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.product_id.value=''; this.form.product_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="product_name" readonly type="text" value="{$fldvalue|escape}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=specific","test","width=640,height=602,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.product_id.value=''; this.form.product_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 
 		{elseif $uitype eq 55} 
@@ -541,7 +551,7 @@
 						{/foreach}
 					{/foreach}
 				</select>
-				<input type="text" name="{$fldname}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" value= "{$secondvalue}">
+			<input type="text" name="{$fldname}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'" style="width:58%;" value= "{$secondvalue|escape}" >
 			</td>
 
 		{elseif $uitype eq 22}
@@ -559,7 +569,7 @@
 			<td colspan="3" width="30%" align=left class="dvtCellInfo">
 				{if $MODULE eq 'Products'}
 					<input name="del_file_list" type="hidden" value="">
-					<div id="files_list" style="border: 1px solid grey; width: 500px; padding: 5px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-size: x-small">Files Maximum 6
+					<div id="files_list" style="border: 1px solid grey; width: 500px; padding: 5px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-size: x-small">{$APP.Files_Maximum_6}
 						<input id="my_file_element" type="file" name="file_1" tabindex="{$vt_tab}" >
 						{assign var=image_count value=0}
 						{if $maindata[3].0.name neq ''}
@@ -627,10 +637,10 @@
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
 			{if $thirdvalue eq 1}
-				<input name="role_name" id="role_name" readonly class="txtBox" tabindex="{$vt_tab}" value="{$secondvalue}" type="text">&nbsp;
-				<a href="javascript:openPopup();"><img src="{$IMAGE_PATH}select.gif" align="absmiddle" border="0"></a>
-			{else}	
-				<input name="role_name" id="role_name" tabindex="{$vt_tab}" class="txtBox" readonly value="{$secondvalue}" type="text">&nbsp;
+				<input name="role_name" id="role_name" readonly class="txtBox" tabindex="{$vt_tab}" value="{$secondvalue|escape}" type="text">&nbsp;
+  				<a href="javascript:openPopup();"><img src="{$IMAGE_PATH}select.gif" align="absmiddle" border="0"></a>
+  			{else}	
+				<input name="role_name" id="role_name" tabindex="{$vt_tab}" class="txtBox" readonly value="{$secondvalue|escape}" type="text">&nbsp;
 			{/if}	
 			<input name="{$fldname}" id="user_role" value="{$fldvalue}" type="hidden">
 			</td>
@@ -639,13 +649,13 @@
 			 <font color="red">*</font>
 			 {$fldlabel}
 			 </td>
-    	     <td width=30% align=left class="dvtCellInfo"><input type="text" name="{$fldname}" id ="{$fldname}" value="{$fldvalue}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
+    	     <td width=30% align=left class="dvtCellInfo"><input type="text" name="{$fldname}" id ="{$fldname}" value="{$fldvalue|escape}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
 			{elseif $uitype eq 115}<!-- for Status field Disabled for nonadmin -->
 			<td width="20%" class="dvtCellLabel" align=right>
 				{$fldlabel}
 			</td>
 			<td width="30%" align=left class="dvtCellInfo">
-			   {if $secondvalue eq 1}
+			   {if $secondvalue eq 1 && $CURRENT_USERID != $smarty.request.record}
 			   	<select name="{$fldname}" tabindex="{$vt_tab}" class="small">
 			   {else}
 			   	<select disabled name="{$fldname}" class="small">
@@ -653,16 +663,26 @@
 				{foreach item=arr from=$fldvalue}
 					{foreach key=sel_value item=value from=$arr}
 						<option value="{$sel_value}" {$value}>{$sel_value}</option>
+						<!-- code added to pass Status field value, if Disabled for nonadmin -->
+						{if $value eq 'selected' && $secondvalue neq 1}
+							{assign var="user_stat" value="$sel_value"}
+						{/if}
+						<!--code ends -->
 					{/foreach}
 				{/foreach}
 			   </select>
+			<!-- code added to pass Status field value, if Disabled for nonadmin -->
+			{if $user_stat neq ''}
+				<input name="{$fldname}" type="hidden" value="{$user_stat}">
+			{/if}
+			<!--code ends -->
 			</td>
 			{elseif $uitype eq 105}
 			    <td width="20%" class="dvtCellLabel" align=right>
 				{$fldlabel}
 			    </td>
 			    <td width="30%" align=left class="dvtCellInfo">
-					<input name="{$fldname}"  type="file" value="{$maindata[3].0.name}" tabindex="{$vt_tab}" />
+					<input name="{$fldname}"  type="file" value="{$maindata[3].0.name}" tabindex="{$vt_tab}" /><br>{$APP.LBL_IMG_FORMATS}
 					<input type="hidden" name="id" value=""/>
 					{$maindata[3].0.name}
 			    </td>
@@ -684,14 +704,14 @@
 				{$fldlabel}
 			</td>
 			<td width="30%" colspan="3" align=left class="dvtCellInfo">
-				<input type="text" name="{$fldname}" value="{$fldvalue}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
+				<input type="text" name="{$fldname}" value="{$fldvalue|escape}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
 			</td>	
 			{elseif $uitype eq 101}<!-- for reportsto field USERS POPUP -->
 				<td width="20%" class="dvtCellLabel" align=right>
 			       {$fldlabel}
 	            </td>
 				<td width="30%" align=left class="dvtCellInfo">
-				<input readonly name='reports_to_name' class="small" type="text" value='{$fldvalue}' tabindex="{$vt_tab}" ><input name='reports_to_id' type="hidden" value='{$secondvalue}'>&nbsp;<input title="Change [Alt+C]" accessKey="C" type="button" class="small" value='{$UMOD.LBL_CHANGE}' name=btn1 LANGUAGE=javascript onclick='return window.open("index.php?module=Users&action=Popup&form=UsersEditView&form_submit=false","test","width=640,height=522,resizable=0,scrollbars=0");'>
+				<input readonly name='reports_to_name' class="small" type="text" value='{$fldvalue|escape}' tabindex="{$vt_tab}" ><input name='reports_to_id' type="hidden" value='{$secondvalue}'>&nbsp;<input title="Change [Alt+C]" accessKey="C" type="button" class="small" value='{$UMOD.LBL_CHANGE}' name=btn1 LANGUAGE=javascript onclick='return window.open("index.php?module=Users&action=Popup&form=UsersEditView&form_submit=false","test","width=640,height=522,resizable=0,scrollbars=0");'>
 	            </td>
 			{elseif $uitype eq 116}<!-- for currency in users details-->	
 			<td width="20%" class="dvtCellLabel" align=right>
@@ -707,9 +727,19 @@
 				{foreach item=arr key=uivalueid from=$fldvalue}
 					{foreach key=sel_value item=value from=$arr}
 						<option value="{$uivalueid}" {$value}>{$sel_value}</option>
+						<!-- code added to pass Currency field value, if Disabled for nonadmin -->
+						{if $value eq 'selected' && $secondvalue neq 1}
+							{assign var="curr_stat" value="$uivalueid"}
+						{/if}
+						<!--code ends -->
 					{/foreach}
 				{/foreach}
 			   </select>
+			<!-- code added to pass Currency field value, if Disabled for nonadmin -->
+			{if $curr_stat neq ''}
+				<input name="{$fldname}" type="hidden" value="{$curr_stat}">
+			{/if}
+			<!--code ends -->
 			</td>
 			{elseif $uitype eq 106}
 			<td width=20% class="dvtCellLabel" align=right>
@@ -717,9 +747,9 @@
 			</td>
 			<td width=30% align=left class="dvtCellInfo">
 				{if $MODE eq 'edit'}
-				<input type="text" readonly name="{$fldname}" value="{$fldvalue}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
-				{else}
-				<input type="text" name="{$fldname}" value="{$fldvalue}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
+				<input type="text" readonly name="{$fldname}" value="{$fldvalue|escape}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
+				{else}
+				<input type="text" name="{$fldname}" value="{$fldvalue|escape}" tabindex="{$vt_tab}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'">
 				{/if}
 			</td>
 			{elseif $uitype eq 99}
@@ -800,7 +830,7 @@
 	{ldelim}
 			temp= /^\d+\.\d+$/.test(document.getElementById(txtObj).value);
 			if(temp == false)
-				alert("Please enter Valid TAX value");
+				alert("{$APP.ENTER_VALID_TAX}");
 	{rdelim}	
 
 function delimage(id)
@@ -815,12 +845,12 @@
 					if(response.responseText.indexOf("SUCESS")>-1)
 						$("replaceimage").innerHTML='{$APP.LBL_IMAGE_DELETED}';
 					else
-						alert("Error while Deleting")
+						alert("{$APP.ERROR_WHILE_EDITING}")
 				    {rdelim}
 		{rdelim}
 	);
 
 {rdelim}
 
-
 </script>
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/EditProfile.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/EditProfile.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/EditProfile.tpl Mon Apr 16 12:27:44 2007
@@ -45,7 +45,7 @@
 				<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
 				<tbody><tr>
 					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}ico-profile.gif" alt="{$MOD.LBL_PROFILES}" title="{$MOD.LBL_PROFILES}" border="0" height="48" width="48"></td>
-					<td class="heading2" valign="bottom"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=ListProfiles&parenttab=Settings">{$CMOD.LBL_PROFILE_PRIVILEGES}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$PROFILE_NAME}&quot;</b></td>
+					<td class="heading2" valign="bottom"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings">{$CMOD.LBL_PROFILE_PRIVILEGES}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$PROFILE_NAME}&quot;</b></td>
 				</tr>
 				<tr>
 					<td class="small" valign="top">{$CMOD.LBL_PROFILE_MESG} &quot;{$PROFILE_NAME}&quot; </td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/EditViewHidden.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/EditViewHidden.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/EditViewHidden.tpl Mon Apr 16 12:27:44 2007
@@ -58,11 +58,8 @@
         <form name="EditView" method="POST" action="index.php">
         <input type="hidden" name="campaignid" value="{$campaignid}">
 
-{elseif $MODULE eq 'Accounts' || $MODULE eq 'Faq' || $MODULE eq 'PriceBooks' || $MODULE eq 'Vendors' || $MODULE eq 'OrgUnit'}
+{elseif $MODULE eq 'Accounts' || $MODULE eq 'Faq' || $MODULE eq 'PriceBooks' || $MODULE eq 'Vendors'}
 	<form name="EditView" method="POST" action="index.php">
-
-{elseif $MODULE eq 'Organization'}
-	<form name="EditView" method="POST" ENCTYPE="multipart/form-data" action="index.php">
 
 {elseif $MODULE eq 'Notes'}
 	<form name="EditView" method="POST" ENCTYPE="multipart/form-data" action="index.php">
@@ -79,6 +76,9 @@
 	<form name="EditView" method="POST" ENCTYPE="multipart/form-data" action="index.php">
 	<input type="hidden" name="activity_mode" value="{$ACTIVITY_MODE}">
 	<INPUT TYPE="HIDDEN" NAME="MAX_FILE_SIZE" VALUE="800000">
+{else}
+	{$ERROR_MESSAGE}
+	<form name="EditView" method="POST" action="index.php">
 {/if}
 
 <input type="hidden" name="module" value="{$MODULE}">

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/EmailContents.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/EmailContents.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/EmailContents.tpl Mon Apr 16 12:27:44 2007
@@ -17,16 +17,20 @@
             <th width="15%">{$LISTHEADER.1}</th>
             <th width="15%">{$LISTHEADER.2}</th>
         </tr>
-		{foreach key=id item=row from=$LISTENTITY}
-	    <tr id="row_{$id}">
-			<td>
-			<span><input type="checkbox" name="selected_id" value= '{$id}' onClick=toggleSelectAll(this.name,"selectall")>
-</span></td>
-			<td onClick="getEmailContents('{$id}'),setSubject('{$row.0}');" style="cursor:pointer;"><b>{$row.0}</b></td>
-			<td onClick="getEmailContents('{$id}'),setSubject('{$row.0}');" style="cursor:pointer;">{$row.1}</td>
-			<td onClick="getEmailContents('{$id}'),setSubject('{$row.0}');" style="cursor:pointer;">{$row.2}</td>
-        </tr>
-		{/foreach}
+		{if $LISTENTITY != NULL}
+			{foreach key=id item=row from=$LISTENTITY}
+			    <tr id="row_{$id}">
+				<td>
+				<span><input type="checkbox" name="selected_id" value= '{$id}' onClick=toggleSelectAll(this.name,"selectall")>
+				</span></td>
+				<td onClick="getEmailContents('{$id}');" style="cursor:pointer;"><b>{$row.0}</b></td>
+				<td onClick="getEmailContents('{$id}');" style="cursor:pointer;">{$row.1}</td>
+				<td onClick="getEmailContents('{$id}');" style="cursor:pointer;">{$row.2}</td>
+			        </tr>
+			{/foreach}
+		{else}
+			<tr><td align="center"><b>{$MOD.LBL_NO_RECORDS}</b></td></tr>
+		{/if}
     </table>
 </div>
 <SCRIPT>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -13,23 +13,23 @@
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>vtigerCRM Mail</title>
+<meta http-equiv="Content-Type" content="text/html; charset={$APP.LBL_CHARSET}">
+<title>{$MOD.TITLE_VTIGERCRM_MAIL}</title>
 <link REL="SHORTCUT ICON" HREF="include/images/vtigercrm_icon.ico">	
 <style type="text/css">@import url("themes/{$THEME}/style.css");</style>
 <script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-<script language="javascript" type="text/javascript" src="include/js/prototype.js"></script>
+<script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
 <body marginheight="0" marginwidth="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
 <table class="small" border="0" cellpadding="0" cellspacing="0" width="100%">
 <tbody>
    <tr>
 	<td colspan="3">
-		<table width="100%" border="0" cellpadding="0" cellspacing="0">
-		   <tr>
-			<td background="{$IMAGE_PATH}mailHdr.jpg" style="background-repeat:repeat-x;" width="100%">&nbsp;</td>
-			<td width="86"><img src="{$IMAGE_PATH}mailTitle.jpg"></td>
-		   </tr>
-		</table>	
+		<table border=0 cellspacing=0 cellpadding=0 width=100% class="mailClientWriteEmailHeader">
+		<tr>
+		<td >{$MOD.LBL_DETAILVIEW_EMAIL}</td>
+		</tr>
+		</table>
+
 	</td>
    </tr> 
    {foreach item=row from=$BLOCKS}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetails.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetails.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/EmailDetails.tpl Mon Apr 16 12:27:44 2007
@@ -1,84 +1,86 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<table width="100%" border="0" cellpadding="0" cellspacing="0" valign="top">
-<tr>
-    <td class="hdrNameBg">
-  		<table width="100%"  border="0" cellspacing="5" cellpadding="0">
-		<tr>
-		{if $BLOCKS neq ''}
-			<td align="left">
-			  	<input type="button" name="forward" value=" {$MOD.LBL_FORWARD_BUTTON} " class="crmbutton small edit" onClick=OpenCompose('{$ID}','forward')>&nbsp;
-				{if $EMAIL_FLAG neq 'WEBMAIL'}
-			  	<input type="button" name="Send" value=" {$MOD.LBL_SEND} " class="crmbutton small save" onClick=OpenCompose('{$ID}','edit')>&nbsp;
-				{else}
-			  	<input type="button" name="Send" value=" {$MOD.LBL_REPLY_BUTTON} " class="crmbutton small edit" onClick=OpenCompose('{$ID}','edit')>&nbsp;
-				{/if}
-				{foreach item=row from=$BLOCKS}	
-				{foreach item=elements key=title from=$row}	
-					{if $elements.fldname eq 'filename' && $elements.value != ''}
-						<input type="button" name="download" value=" {$MOD.LBL_DOWNLOAD_ATTCH_BUTTON} " class="crmbutton small save" onclick="fnvshobj(this,'reportLay')"/>
-					{/if}
-				{/foreach}
-				{/foreach}
-			</td>
-						<td width="25%" align="right"><input type="button" name="Button" value=" {$APP.LBL_DELETE_BUTTON} "  class="crmbutton small delete" onClick="DeleteEmail('{$ID}')"/></td>
-						{else}
-						<td colspan="2">&nbsp;</td>
-						{/if}
-		</tr>
-		</table>
-	</td>
-</tr>
-<tr>
-	<td height="250" bgcolor="#FFFFFF" valign="top" style="padding-top:10px;">
-	{foreach item=row from=$BLOCKS}	
-	{foreach item=elements from=$row}	
-		{if $elements.fldname eq 'subject'}
-		<table width="100%" border="0" cellpadding="0" cellspacing="0">
-	{if $EMAIL_FLAG neq 'WEBMAIL'}
-	<tr><td width="20%" align="right" valign="top"><b>{$MOD.LBL_TO}</b></td><td width="2%" align="left">&nbsp;</td><td align="left">{$TO_MAIL}&nbsp;</td></tr>
-	<tr><td align="right" valign="top">{$MOD.LBL_CC}</td><td align="left">&nbsp;</td><td align="left">{$CC_MAIL}&nbsp;</td></tr>
-	<tr><td align="right" valign="top">{$MOD.LBL_BCC}</td><td align="left">&nbsp;</td><td align="left">{$BCC_MAIL}&nbsp;</td></tr>
-	{else}
-	<tr><td width="20%" align="right" valign="top"><b>{$MOD.LBL_FROM}</b></td><td width="2%" align="left">&nbsp;</td><td align="left">{$TO_MAIL}&nbsp;</td></tr>
-	{/if}
-	<tr><td align="right"><b>{$MOD.LBL_SUBJECT}</b></td><td align="left">&nbsp;</td><td align="left">{$elements.value}&nbsp;</td></tr>
-			<tr><td align="right" style="border-bottom:1px solid #666666;" colspan="3">&nbsp;</td></tr>
-		</table>
-		{elseif $elements.fldname eq 'description'}
-		<div>
-			{$elements.value}
-		</div>
-		{/if}
-	{/foreach}
-	{/foreach}
-	</td>
-</tr>
-</table>
-{foreach item=row from=$BLOCKS}	
-	{foreach item=elements key=title from=$row}	
-	{if $elements.fldname eq 'filename'}
-	<div id="reportLay" style="width:130px;" onmouseout="fninvsh('reportLay')" onmouseover="fnvshNrm('reportLay')">
-		<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
-		{foreach item=attachments from=$elements.options}
-		<tr>
-			<td style="border-bottom: 1px solid rgb(204, 204, 204); padding: 5px;">
-				{$attachments}
-			</td>
-		</tr>
-		{/foreach}
-		</table>
-	</div>
-	{/if}
-	{/foreach}
-{/foreach}
-
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<table width="100%" border="0" cellpadding="0" cellspacing="0" valign="top">
+<tr>
+    <td class="hdrNameBg">
+  		<table width="100%"  border="0" cellspacing="5" cellpadding="0">
+		<tr>
+		{if $BLOCKS neq ''}
+			<td align="left">
+			  	<input type="button" name="forward" value=" {$MOD.LBL_FORWARD_BUTTON} " class="crmbutton small edit" onClick=OpenCompose('{$ID}','forward')>&nbsp;
+				{if $EMAIL_FLAG neq 'WEBMAIL'}
+			  	<input type="button" name="Send" value=" {$MOD.LBL_SEND} " class="crmbutton small save" onClick=OpenCompose('{$ID}','edit')>&nbsp;	
+	<input type="button" name="Reply" value=" {$MOD.LBL_REPLY_BUTTON} " class="crmbutton small edit" onClick=ReplyCompose('{$ID}','reply')>&nbsp;
+				{else}
+			  	<input type="button" name="Send" value=" {$MOD.LBL_REPLY_BUTTON} " class="crmbutton small edit" onClick=OpenCompose('{$ID}','edit')>&nbsp;
+				{/if}
+				{foreach item=row from=$BLOCKS}	
+				{foreach item=elements key=title from=$row}	
+					{if $elements.fldname eq 'filename' && $elements.value != ''}
+						<input type="button" name="download" value=" {$MOD.LBL_DOWNLOAD_ATTCH_BUTTON} " class="crmbutton small save" onclick="fnvshobj(this,'reportLay')"/>
+					{/if}
+				{/foreach}
+				{/foreach}
+			</td>
+						<td width="25%" align="right"><input type="button" name="Button" value=" {$APP.LBL_DELETE_BUTTON} "  class="crmbutton small delete" onClick="DeleteEmail('{$ID}')"/></td>
+						{else}
+						<td colspan="2">&nbsp;</td>
+						{/if}
+		</tr>
+		</table>
+	</td>
+</tr>
+<tr>
+	<td height="250" bgcolor="#FFFFFF" valign="top" style="padding-top:10px;">
+	{foreach item=row from=$BLOCKS}	
+	{foreach item=elements from=$row}	
+		{if $elements.fldname eq 'subject'}
+		<table width="100%" border="0" cellpadding="0" cellspacing="0">
+	{if $EMAIL_FLAG neq 'WEBMAIL'}
+	<tr><td width="20%" align="right" valign="top"><b>{$MOD.LBL_FROM}</b></td><td width="2%" align="left">&nbsp;</td><td align="left">{$FROM_MAIL}&nbsp;</td></tr>
+	<tr><td width="20%" align="right" valign="top"><b>{$MOD.LBL_TO}</b></td><td width="2%" align="left">&nbsp;</td><td align="left">{$TO_MAIL}&nbsp;</td></tr>
+	<tr><td align="right" valign="top">{$MOD.LBL_CC}</td><td align="left">&nbsp;</td><td align="left">{$CC_MAIL}&nbsp;</td></tr>
+	<tr><td align="right" valign="top">{$MOD.LBL_BCC}</td><td align="left">&nbsp;</td><td align="left">{$BCC_MAIL}&nbsp;</td></tr>
+	{else}
+	<tr><td width="20%" align="right" valign="top"><b>{$MOD.LBL_FROM}</b></td><td width="2%" align="left">&nbsp;</td><td align="left">{$TO_MAIL}&nbsp;</td></tr>
+	{/if}
+	<tr><td align="right"><b>{$MOD.LBL_SUBJECT}</b></td><td align="left">&nbsp;</td><td align="left">{$elements.value}&nbsp;</td></tr>
+			<tr><td align="right" style="border-bottom:1px solid #666666;" colspan="3">&nbsp;</td></tr>
+		</table>
+		{elseif $elements.fldname eq 'description'}
+		<div>
+			{$elements.value}
+		</div>
+		{/if}
+	{/foreach}
+	{/foreach}
+	</td>
+</tr>
+</table>
+{foreach item=row from=$BLOCKS}	
+	{foreach item=elements key=title from=$row}	
+	{if $elements.fldname eq 'filename'}
+	<div id="reportLay" style="width:130px;" onmouseout="fninvsh('reportLay')" onmouseover="fnvshNrm('reportLay')">
+		<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
+		{foreach item=attachments from=$elements.options}
+		<tr>
+			<td style="border-bottom: 1px solid rgb(204, 204, 204); padding: 5px;">
+				{$attachments}
+			</td>
+		</tr>
+		{/foreach}
+		</table>
+	</div>
+	{/if}
+	{/foreach}
+{/foreach}
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Emails.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Emails.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Emails.tpl Mon Apr 16 12:27:44 2007
@@ -16,7 +16,7 @@
 	gselectedrowid = 0;
 	$("status").style.display="inline";
 	gFolderid = folderid;
-	getObj('search_text').value = '';
+//	getObj('search_text').value = '';
 	switch(folderid)
 	{ldelim}
 		case 1:
@@ -45,10 +45,12 @@
                 postBody: 'module=Emails&ajax=true&action=EmailsAjax&file=ListView&folderid='+folderid,
                 onComplete: function(response) {ldelim}
                                         $("status").style.display="none";
-                                        if(gFolderid != folderid)
+                                        if(gFolderid == folderid)
                                         {ldelim}
                                                 gselectedrowid = 0;
                                                 $("email_con").innerHTML=response.responseText;
+						$('EmailDetails').innerHTML = '<table valign="top" border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td class="forwardBg"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td colspan="2">&nbsp;</td></tr></tbody></table></td></tr><tr><td style="padding-top:10px;" bgcolor="#ffffff" height="300" valign="top"></td></tr></tbody></table>';
+						$("subjectsetter").innerHTML='';
                                                 execJS($('email_con'));
                                         {rdelim}
                                         else
@@ -65,8 +67,8 @@
 {rdelim}
 </script>
 		{include file='Buttons_List.tpl'}
-<script language="JavaScript" type="text/javascript" src="modules/Emails/Email.js"></script>
-<div id="mailconfchk" class="small" style="position:absolute;display:none;left:350px;top:160px;height:27px;white-space:nowrap;z-index:10000007px;"><font color='red'><b>{$MOD.LBL_CONFIGURE_MAIL_SETTINGS}.<br> {$APP.LBL_PLEASE_CLICK} <a href="index.php?module=Settings&action=AddMailAccount&record={$USERID}">{$APP.LBL_HERE}</a> {$APP.LBL_TO_CONFIGURE}</b></font></div>
+<script language="JavaScript" type="text/javascript" src="modules/Emails/Emails.js"></script>
+<div id="mailconfchk" class="small" style="position:absolute;display:none;left:350px;top:160px;height:27px;white-space:nowrap;z-index:10000007px;"><font color='red'><b>{$MOD.LBL_CONFIGURE_MAIL_SETTINGS}.<br> {$APP.LBL_PLEASE_CLICK} <a href="index.php?module=Users&action=AddMailAccount&record={$USERID}">{$APP.LBL_HERE}</a> {$APP.LBL_TO_CONFIGURE}</b></font></div>
 <!-- Shadow starts here -->
 <table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">
 	<tr>
@@ -96,7 +98,7 @@
 												</td>
 												<td nowrap style="padding-left:20px;padding-right:20px" class=small>
 												<img src="{$IMAGE_PATH}webmail_settings.gif" align="absmiddle" />
-							&nbsp;<a href="index.php?module=Settings&action=AddMailAccount&record={$USERID}" >{$MOD.LBL_SETTINGS}</a>
+							&nbsp;<a href="index.php?module=Users&action=AddMailAccount&record={$USERID}" >{$MOD.LBL_SETTINGS}</a>
 												</td>
 											</tr>
 											</table>
@@ -104,7 +106,7 @@
 										<td align=right>
 											<table >
 											<tr>
-												<td class="componentName" align=right>vtiger Email Client <!-- <img src="{$IMAGE_PATH}titleMailClient.gif" align="right"/> --></td>
+												<td class="componentName" align=right>{$MOD.LBL_VTIGER_EMAIL_CLIENT}<!-- <img src="{$IMAGE_PATH}titleMailClient.gif" align="right"/> --></td>
 											</tr>
 											</table>
 									</td>
@@ -115,9 +117,8 @@
 							</tr>
 							<!-- Columns -->
 							<tr>
-							<td width="25%" class="big mailSubHeader" ><b>{$MOD.LBL_EMAIL_FOLDERS}</b></td>
-							<td width="2%">&nbsp;</td>
-							<td width="73%" class="big mailSubHeader" align="left"><span id="mail_fldrname"><b>{$MOD.LBL_ALLMAILS}</b></span></td>
+							<td width="18%" class="big mailSubHeader" ><b>{$MOD.LBL_EMAIL_FOLDERS}</b></td>
+							<td width="82%" class="big mailSubHeader" align="left"><span id="mail_fldrname"><b>{$MOD.LBL_ALLMAILS}</b></span></td>
 							</tr>
 							
 							<tr>
@@ -126,50 +127,52 @@
 								<!-- Inbox -->
 								<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<b class="txtGreen">{$MOD.LBL_INBOX}</b>
 								<ul style="list-style-type:none;margin-left:10px;margin-top:5px;padding:2px">
-									<li><img src="{$IMAGE_PATH}webmail_downarrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailInFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 										<a href="javascript:;" onClick="ShowFolders(6)" class="webMnu">{$MOD.LBL_QUAL_CONTACT}</a>&nbsp;<b></b>
 									</li>
-									<li><img src="{$IMAGE_PATH}webmail_downarrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailInFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 									<a href="javascript:;" onClick="gotoWebmail();" class="webMnu">{$MOD.LBL_MY_MAILS}</a>&nbsp;<b></b>
 									</li>
 								</ul>
 								<!-- Sent mail -->
 								<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<b class="txtGreen">{$MOD.LBL_SENT_MAILS}</b>
 								<ul style="list-style-type:none;margin-left:10px;margin-top:5px;padding:2px">
-									<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 									<a href="javascript:;" onClick="ShowFolders(1)" class="webMnu">{$MOD.LBL_ALLMAILS}</a>&nbsp;<b></b>
-									<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 									<a href="javascript:;" onClick="ShowFolders(2)" class="webMnu">{$MOD.LBL_TO_CONTACTS}</a>&nbsp;<b></b>
 									</li>
-									<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 									<a href="javascript:;" onClick="ShowFolders(3)" class="webMnu">{$MOD.LBL_TO_ACCOUNTS}</a>&nbsp;<b></b>
 									</li>
-									<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 									<a href="javascript:;" onClick="ShowFolders(4)" class="webMnu">{$MOD.LBL_TO_LEADS}</a>&nbsp;
 									</li>
-									<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
+									<li><img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
 									<a href="javascript:;" onClick="ShowFolders(5)" class="webMnu">{$MOD.LBL_TO_USERS}</a>&nbsp;
 									</li>
 								</ul>
 								</td>
-								<td>&nbsp;</td>
 								<!-- All mails pane -->
 								<td class="hdrNameBg">
 									<!-- Command Buttons and Search Email -->
 									<table width="100%"  border="0" cellspacing="0" cellpadding="2">
 									<input name="idlist" type="hidden">
 										<tr>
-											<td width="25%" align="left"><input type="button" name="Button2" value=" {$APP.LBL_DELETE_BUTTON}"  class="crmbutton small delete" onClick="return massDelete();"/> &nbsp;</td>
-											<td width="50%" align="right" class="small">
-												<font color="#000000">{$APP.LBL_SEARCH}</font>&nbsp;<input type="text" name="search_text" id="search_text" class="importBox" onkeyUp="Searchfn();">&nbsp;
+											<td width="30%" align="left"><input type="button" name="Button2" value=" {$APP.LBL_DELETE_BUTTON}"  class="crmbutton small delete" onClick="return massDelete();"/> &nbsp;</td>
+											<td width="40%" align="right" class="small">
+												<font color="#000000">{$APP.LBL_SEARCH}</font>&nbsp;<input type="text" name="search_text" id="search_text" class="importBox" >&nbsp;
 											</td>
-											<td width="25%" align=left class="small">
+											<td width="20%" align=left class="small">
 												<select name="search_field" id="search_field" onChange="Searchfn();" class="importBox">
 												<option value='subject'>{$MOD.LBL_IN_SUBJECT}</option>
 												<option value='user_name'>{$MOD.LBL_IN_SENDER}</option>
 												<option value='join'>{$MOD.LBL_IN_SUBJECT_OR_SENDER}</option>
 												</select>&nbsp;
 											</td>
+											<td width="10%">
+					<input name="find" value=" Find " class="crmbutton small create" onclick="Searchfn();" type="button">
+				</td>
 										</tr>
 									</table>
 									
@@ -177,7 +180,6 @@
 							</tr>
 							<!-- Mail Subject Headers list -->
 							<tr>
-								<td>&nbsp;</td>
 								<td align="left">
 									<div id="email_con">
 									{include file="EmailContents.tpl"}
@@ -186,17 +188,6 @@
 							</tr>
 							
 							<tr>
-								<td>&nbsp;</td>
-								<td height="5"></td>
-							</tr>
-							
-							<tr>
-								<td>&nbsp;</td>
-								<td class="mailSubHeader" id="subjectsetter" align=left><b>&nbsp;</b></td>
-							</tr>
-							
-							<tr>
-								<td>&nbsp;</td>	
 								<td valign="top">
 									<div id="EmailDetails" > 
 									{include file="EmailDetails.tpl"}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/FieldAccess.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/FieldAccess.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/FieldAccess.tpl Mon Apr 16 12:27:44 2007
@@ -23,7 +23,7 @@
 		<!-- DISPLAY -->
 		<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 		<form action="index.php" method="post" name="new" id="form">
-		<input type="hidden" name="module" value="Users">
+		<input type="hidden" name="module" value="Settings">
 		<input type="hidden" name="parenttab" value="Settings">
 		<input type="hidden" name="fld_module" id="fld_module" value="{$DEF_MODULE}">
 		{if $MODE neq 'view'}
@@ -32,7 +32,7 @@
 			<input type="hidden" name="action" value="EditDefOrgFieldLevelAccess">
 		{/if}	
 		<tr>
-			<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}orgshar.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+			<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}orgshar.gif" alt="{$MOD.LBL_MODULE_NAME}" width="48" height="48" border=0 title="{$MOD.LBL_MODULE_NAME}"></td>
 			<td colspan=2 class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_FIELDS_ACCESS} </b></td>
 			<td rowspan=2 class="small" align=right>&nbsp;</td>
 		</tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/GlobalListView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/GlobalListView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/GlobalListView.tpl Mon Apr 16 12:27:44 2007
@@ -20,7 +20,7 @@
 <script language="JavaScript" type="text/javascript" src="include/js/thumbnail.js"></script>
 <div id="dynloadarea" style=float:left;position:absolute;left:350px;top:150px;></div>
 {/if}
-<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 
 {if $SEARCH_MODULE eq 'All'}
 <script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/GroupDetailview.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/GroupDetailview.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/GroupDetailview.tpl Mon Apr 16 12:27:44 2007
@@ -23,14 +23,14 @@
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<form action="index.php" method="post" name="new" id="form">
-				<input type="hidden" name="module" value="Users">
+				<input type="hidden" name="module" value="Settings">
 				<input type="hidden" name="action" value="createnewgroup">
 				<input type="hidden" name="groupId" value="{$GROUPID}">
 				<input type="hidden" name="mode" value="edit">
 				<input type="hidden" name="parenttab" value="Settings">
 				<tr>
 					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-groups.gif" width="48" height="48" border=0 ></td>
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listgroups&parenttab=Settings">{$CMOD.LBL_GROUPS}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$GROUPINFO.0.groupname}&quot; </b></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listgroups&parenttab=Settings">{$CMOD.LBL_GROUPS}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$GROUPINFO.0.groupname}&quot; </b></td>
 				</tr>
 				<tr>
 					<td valign=top class="small">{$CMOD.LBL_VIEWING} {$CMOD.LBL_PROPERTIES} &quot;{$GROUPINFO.0.groupname}`&quot; {$CMOD.LBL_GROUP_NAME} </td>
@@ -92,7 +92,15 @@
                             <td width="16"><div align="center"></div></td>
                             <td>
 					{foreach item=element from=$details}
+						{if $element.memberaction == "GroupDetailView"}
+						<a href="index.php?module=Settings&action={$element.memberaction}&{$element.actionparameter}={$element.memberid}">{$element.membername}</a><br />
+						{/if}
+						{if $element.memberaction == "RoleDetailView"}	
+						<a href="index.php?module=Settings&action={$element.memberaction}&{$element.actionparameter}={$element.memberid}">{$element.membername}</a><br />
+						{/if}
+						{if $element.memberaction == "DetailView"}	
 						<a href="index.php?module=Users&action={$element.memberaction}&{$element.actionparameter}={$element.memberid}">{$element.membername}</a><br />
+						{/if}
 					{/foreach}
 			    </td>  	 
                           </tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/GroupEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/GroupEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/GroupEditView.tpl Mon Apr 16 12:27:44 2007
@@ -21,6 +21,9 @@
 		var reminstr = '&mode='+mode+'&groupName='+groupname+'&groupid='+groupid;
 	else
 		var reminstr = '&groupName='+groupname;
+	var status = usernameValid(groupname);
+	if(status)
+	{ldelim}
 	new Ajax.Request(
 		'index.php',
 		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
@@ -33,9 +36,11 @@
 					alert(response.responseText);
 			{rdelim}
 		{rdelim}
-	);
-{rdelim}
-
+		);
+	{rdelim}
+	else
+		alert(alert_arr.NO_SPECIAL+" in Group Name ")
+{rdelim}
 var constructedOptionValue;
 var constructedOptionName;
 
@@ -136,7 +141,7 @@
 
 	if(trim(document.newGroupForm.groupName.value) == "")
 	{ldelim}	
-		alert('Group Name cannot be none');
+		alert('{$APP.GROUPNAME_CANNNOT_BE_NONE}');
 		return false;		
 	{rdelim}
 
@@ -144,7 +149,7 @@
 	if(document.newGroupForm.selectedColumnsString.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0)
 	{ldelim}
 
-		alert('Group should have at least one member. Select a member to the group');
+		alert('{$APP.GROUP_SHOULDHAVE_ONEMEMBER_INFO}');
 		return false;
 	{rdelim}
 	dup_validation();	
@@ -170,11 +175,11 @@
 				<input type="hidden" name="groupId" value="{$GROUPID}">
 				<input type="hidden" name="returnaction" value="{$RETURN_ACTION}">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-groups.gif" alt="Groups" width="48" height="48" border=0 title="Roles"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-groups.gif" alt="{$CMOD.LBL_GROUPS}" title="{$CMOD.LBL_GROUPS}" width="48" height="48" border=0 ></td>
 					{if $MODE eq 'edit'}
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listgroups&parenttab=Settings">{$CMOD.LBL_GROUPS}</a> &gt; {$MOD.LBL_EDIT} &quot;{$GROUPNAME}&quot; </b></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listgroups&parenttab=Settings">{$CMOD.LBL_GROUPS}</a> &gt; {$MOD.LBL_EDIT} &quot;{$GROUPNAME}&quot; </b></td>
 					{else}	
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listgroups&parenttab=Settings">{$CMOD.LBL_GROUPS}</a> &gt; {$CMOD.LBL_CREATE_NEW_GROUP}</b></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listgroups&parenttab=Settings">{$CMOD.LBL_GROUPS}</a> &gt; {$CMOD.LBL_CREATE_NEW_GROUP}</b></td>
 					{/if}
 				</tr>
 				<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Header.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Header.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Header.tpl Mon Apr 16 12:27:44 2007
@@ -13,7 +13,7 @@
 <html>
 <head>
 	<title>{$CURRENT_USER} - {$APP.$CATEGORY} - {$APP.$MODULE_NAME} - {$APP.LBL_BROWSER_TITLE}</title>
-	<link rel="stylesheet" type="text/css" href="style.css">
+	<link rel="stylesheet" type="text/css" href="themes/{$THEME}/style.css">
 	<link REL="SHORTCUT ICON" HREF="include/images/vtigercrm_icon.ico">	
 	<style type="text/css">@import url("themes/{$THEME}/style.css");</style>
 </head>
@@ -22,6 +22,7 @@
 	<!-- header -->
 	<!-- header-vtiger crm name & RSS -->
 	<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
+	<script language="JavaScript" type="text/javascript" src="include/js/{php} echo $_SESSION['authenticated_user_language'];{/php}.lang.js?{php} echo $_SESSION['vtiger_version'];{/php}"></script>
 	<script language="JavaScript" type="text/javascript" src="include/js/QuickCreate.js"></script>
 	<script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
 	<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
@@ -32,7 +33,7 @@
         <script type="text/javascript" src="jscalendar/calendar.js"></script>
         <script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
         <script type="text/javascript" src="jscalendar/lang/calendar-{$APP.LBL_JSCALENDAR_LANG}.js"></script>
-
+	
 	<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class="hdrNameBg">
 	<tr>
 		<td valign=top><img src="{$IMAGEPATH}/vtiger-crm.gif" alt="vtiger CRM" title="vtiger CRM" border=0></td>
@@ -58,7 +59,7 @@
 			<table border=0 cellspacing=0 cellpadding=0>
 			 <tr>
 			 <td style="padding-left:10px;padding-right:10px" class=small nowrap> <a href="index.php?module=Users&action=DetailView&record={$CURRENT_USER_ID}&modechk=prefview">{$APP.LBL_MY_PREFERENCES}</a></td>
-			 <td style="padding-left:10px;padding-right:10px" class=small nowrap><a href="http://www.vtiger.com/index.php?option=com_content&task=view&id=34&Itemid=60" target="_blank">{$APP.LNK_HELP}</a></td>
+			 <td style="padding-left:10px;padding-right:10px" class=small nowrap><a href="http://wiki.vtiger.com/index.php/Main_Page" target="_blank">{$APP.LNK_HELP}</a></td>
 			 <td style="padding-left:10px;padding-right:10px" class=small nowrap><a href="javascript:;" onClick="openwin();">{$APP.LNK_WEARE}</a></td>
 			 <td style="padding-left:10px;padding-right:10px" class=small nowrap> <a href="index.php?module=Users&action=Logout">{$APP.LBL_LOGOUT}</a> ({$CURRENT_USER})</td>
 			 </tr>
@@ -93,14 +94,14 @@
                                 <select class=small id="qccombo" style="width:120px"  onclick="QCreate(this);">
 					<option value="none">{$APP.LBL_QUICK_CREATE}...</option>
                         {foreach  item=detail from=$QCMODULE}
-                                        <option value="{$detail.1}">{$APP[$detail.0]}</option>
+                                        <option value="{$detail.1}">{$APP.NEW}&nbsp;{$APP[$detail.0]}</option>
                         {/foreach}
                                 </select>
                         {else}
                                 <select class=small id="qccombo" style="width:120px"  onchange="QCreate(this);">
 					<option value="none">{$APP.LBL_QUICK_CREATE}...</option>
                         {foreach  item=detail from=$QCMODULE}
-                                        <option value="{$detail.1}">{$APP[$detail.0]}</option>
+                                        <option value="{$detail.1}">{$APP.NEW}&nbsp;{$APP[$detail.0]}</option>
                         {/foreach}
                                 </select>
 
@@ -121,7 +122,7 @@
 				<input type="text" name="query_string" value="{$QUERY_STRING}" class="searchBox" onFocus="this.value=''" >
 			</td>
 			<td style="background-color:#cccccc">
-				<input type="submit" class="searchBtn" value="{$APP.LBL_FIND_BUTTON}" alt="Find" title="Find">
+				<input type="submit" class="searchBtn" value="{$APP.LBL_FIND_BUTTON}" alt="{$APP.LBL_FIND}" title="{$APP.LBL_FIND}">
 			</td>
 			</form>
 		   </tr>
@@ -160,6 +161,7 @@
 <div id="qcform" style="position:absolute;width:500px;top:60px;left:450px;z-index:5000;"></div>
 
 <script>
+var gVTModule = '{$smarty.request.module}';
 function set_org(orgoptions)
 {ldelim}
 	var neworg = orgoptions.options[orgoptions.options.selectedIndex].value;
@@ -177,7 +179,6 @@
                   	{rdelim}
 		{rdelim}
 	);
-
 {rdelim}
 
 function fetch_clock()
@@ -437,7 +438,7 @@
 {/literal}
 
 {* Quick Access Functionality *}
-<div id="allMenu" onmouseout="fninvsh('allMenu');" onMouseOver="fnvshNrm('allMenu');" style="width:550px">
+<div id="allMenu" onmouseout="fninvsh('allMenu');" onMouseOver="fnvshNrm('allMenu');" style="width:550px;z-index: 10000001;">
 	<table border=0 cellpadding="5" cellspacing="0" class="allMnuTable" >
 	<tr>
 		<td valign="top">
@@ -497,7 +498,8 @@
 		<td class="trackerList small"> <a href="index.php?module={$trackelements.module_name}&action=DetailView&record={$trackelements.crmid}">{$trackelements.item_summary}</a> </td><td class="trackerList small">&nbsp;</td></tr>
 	{/foreach}
 	</table>
-</div>	
+</div>
+	
 <script>
 	var THandle = document.getElementById("Track_Handle");
 	var TRoot   = document.getElementById("tracker");

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/HomePage.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/HomePage.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/HomePage.tpl Mon Apr 16 12:27:44 2007
@@ -71,14 +71,22 @@
 					<td class="small">
 							<table border=0 cellspacing=0 cellpadding=5>
 								<tr>
-									{if $CHECK.Calendar eq 'yes'}
-									<td style="padding-right:5px;padding-left:5px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal();'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td>
-									{else}
-									<td style="padding-right:5px;padding-left:5px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif" border=0></td>
+									{if $CALENDAR_DISPLAY eq 'true'} 
+ 		                                                                              {if $CHECK.Calendar eq 'yes'} 
+ 		                                                                                        <td style="padding-right:5px;padding-left:5px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal();'><img src="{$IMAGE_PATH}btnL3Calendar.gif" alt="{$APP.LBL_CALENDAR_ALT}" title="{$APP.LBL_CALENDAR_TITLE}" border=0></a></a></td> 
+ 		                                                                              {else} 
+ 		                                                                                        <td style="padding-right:5px;padding-left:5px;"><img src="{$IMAGE_PATH}btnL3Calendar-Faded.gif" border=0></td> 
+ 		                                                                              {/if} 
 									{/if}
-									<td style="padding-right:5px"><a href="javascript:;"><img src="{$IMAGE_PATH}btnL3Clock.gif" alt="{$APP.LBL_CLOCK_ALT}" title="{$APP.LBL_CLOCK_TITLE}" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td>
-									<td style="padding-right:5px"><a href="#"><img src="{$IMAGE_PATH}btnL3Calc.gif" alt="{$APP.LBL_CALCULATOR_ALT}" title="{$APP.LBL_CALCULATOR_TITLE}" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td>
-									<td style="padding-right:5px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="{$IMAGE_PATH}tbarChat.gif" alt="{$APP.LBL_CHAT_ALT}" title="{$APP.LBL_CHAT_TITLE}" border=0></a></td>	
+									 {if $WORLD_CLOCK_DISPLAY eq 'true'} 
+ 		                                                                                <td style="padding-right:5px"><a href="javascript:;"><img src="{$IMAGE_PATH}btnL3Clock.gif" alt="{$APP.LBL_CLOCK_ALT}" title="{$APP.LBL_CLOCK_TITLE}" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td> 
+ 		                                                         {/if} 
+ 		                                                                        {if $CALCULATOR_DISPLAY eq 'true'} 
+ 		                                                                                <td style="padding-right:5px"><a href="#"><img src="{$IMAGE_PATH}btnL3Calc.gif" alt="{$APP.LBL_CALCULATOR_ALT}" title="{$APP.LBL_CALCULATOR_TITLE}" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td> 
+ 		                                                                        {/if} 
+ 		                                                                        {if $CHAT_DISPLAY eq 'true'} 
+ 		                                                                                <td style="padding-right:5px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="{$IMAGE_PATH}tbarChat.gif" alt="{$APP.LBL_CHAT_ALT}" title="{$APP.LBL_CHAT_TITLE}" border=0></a></td>     
+ 		                                                                        {/if} 
 									<td style="padding-right:5px"><img src="{$IMAGE_PATH}btnL3Tracker.gif" alt="{$APP.LBL_LAST_VIEWED}" title="{$APP.LBL_LAST_VIEWED}" border=0 onClick="fnvshobj(this,'tracker');"></td>
 								</tr>
 							</table>
@@ -124,14 +132,18 @@
 									<td align="left" class="homePageMatrixHdr" ><b>{$tabledetail.Title.1}</b></td>
 									<td align="right" class="homePageMatrixHdr" ><img src="{$IMAGE_PATH}uparrow.gif" align="absmiddle" /></td>
 								</tr>
-								<tr align="left">
+								<tr align="left" class="winmarkModulesdef">
 									<td valign=top  colspan=2>
-											<div style="overflow-y:auto;overflow-x:hidden;height:250px;width:99%"> 
+											<div style="overflow-y:auto;overflow-x:hidden;height:200px;width:99%"> 
 											<table border=0 cellspacing=0 cellpadding=5 width=100%>
 												{foreach item=elements from=$tabledetail.Entries}
 													<tr>
 														{if $tabledetail.Title.2 neq 'home_mytopinv' && $tabledetail.Title.2 neq 'home_mytopso' && $tabledetail.Title.2 neq 'home_mytopquote' && $tabledetail.Title.2 neq 'home_metrics' &&  $tabledetail.Title.2 neq 'home_mytoppo' &&  $tabledetail.Title.2 neq 'home_myfaq'  }
-															<td colspan="2"><img src="{$IMAGE_PATH}bookMark.gif" align="absmiddle" /> {$elements.0}</td>
+															<td colspan="2"><img src="{$IMAGE_PATH}bookMark.gif" align="absmiddle" />{$elements.0} 
+															 	{if $modulename eq 'Leads'}
+																 - {$elements.1}	
+																{/if}
+															</td>
 														{elseif $tabledetail.Title.2 eq 'home_metrics'}
 															<td><img src="{$IMAGE_PATH}bookMark.gif" align="absmiddle" /> {$elements.0}</td>
 															<td align="absmiddle" /> {$elements.1}</td>
@@ -141,31 +153,29 @@
 													</tr>
 												{/foreach}
 											</table>	
-											</div>
-											<table border=0 cellspacing=0 cellpadding=5 width=100%>
-													<tr>
-														<td colspan="2" align="right" valign="bottom">
-															{if $modulename neq 'CustomView' && $modulename neq 'GroupAllocation'}
-																<a href="index.php?module={$modulename}&action=index">{$APP.LBL_MORE}..</a>
-															{else}
-																&nbsp;	
-															{/if}
-														</td>
-													</tr>
-											</table>										
+											</div>									
+									</td>
+								</tr>
+								<tr>
+									<td colspan="2" align="right" valign="bottom">
+									{if $modulename neq 'CustomView' && $modulename neq 'GroupAllocation'}
+									 <a href="index.php?module={$modulename}&action=index&search_field=assigned_user_id&searchtype=BasicSearch&search_text={$CURRENTUSER}&query=true">{$APP.LBL_MORE}..</a>
+									{else}
+										&nbsp;	
+									{/if}
 									</td>
 								</tr>
 							</table>
 								</div>
 							{/if}	
 							{else}
-								<div class="MatrixLayer" style="float:left;width:61%;" id="homepagedb">
+								<div class="MatrixLayer" style="float:left;width:93%;" id="homepagedb">
 									<table width="100%" border="0" cellpadding="8" cellspacing="0" class="small">
 										<tr style="cursor:move;">
 											<td align="left" class="homePageMatrixHdr"><b>{$APP.LBL_HOMEPAGE_DASHBOARD}</b></td>
 											<td align="right" class="homePageMatrixHdr"><img src="{$IMAGE_PATH}uparrow.gif" align="absmiddle" /></td>
 										</tr>
-										<tr>	
+										<tr align="left" class="winmarkModulesdef">	
 											<td colspan="2">
 											<div style="overflow:hidden;height:255px;width:99%"> 
 												<table border=0 cellspacing=0 cellpadding=5 width=100%>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep1.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep1.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep1.tpl Mon Apr 16 12:27:44 2007
@@ -11,8 +11,30 @@
 -->*}
 
 
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<script type="text/javascript" language="Javascript">
+function validateFile(form) 
+	{ldelim}
 
+	if(!emptyCheck("userfile","File Location","any"))
+		{ldelim}
+                
+			form.userfile.focus();
+		        return false;
+		{rdelim}
+
+
+    	if(! upload_filter("userfile", "csv") )
+		{ldelim}
+        
+                	form.userfile.focus();
+	                return false;
+	
+		{rdelim}
+	
+		return true;
+	{rdelim}
+</script>
 <!-- header - level 2 tabs -->
 {include file='Buttons_List1.tpl'}	
 
@@ -40,7 +62,7 @@
 				<br />
 				<table align="center" cellpadding="5" cellspacing="0" width="80%" class="mailClient importLeadUI small" border="0">
 				   <tr>
-					<td colspan="2" height="50" valign="middle" align="left" class="mailClientBg  genHeaderSmall">{$MOD.LBL_MODULE_NAME} {$MODULE}</td>
+					<td colspan="2" height="50" valign="middle" align="left" class="mailClientBg  genHeaderSmall">{$MOD.LBL_MODULE_NAME} {$APP.$MODULE}</td>
 				   </tr>
 				   <tr >
 					<td colspan="2" align="left" valign="top" style="padding-left:40px;">
@@ -86,7 +108,10 @@
 				   <tr ><td colspan="2" height="50">&nbsp;</td></tr>
 				    <tr >
 						<td colspan="2" align="right" style="padding-right:40px;" class="reportCreateBottom">
-							<input title="{$MOD.LBL_NEXT}" accessKey="" class="crmButton small save" type="submit" name="button" value="  {$MOD.LBL_NEXT} &rsaquo; "  onclick="this.form.action.value='Import';this.form.step.value='2'; return verify_data(this.form);">
+							<input title="{$MOD.LBL_NEXT}" accessKey="" class="crmButton small save" type="submit" name="button" value="  {$MOD.LBL_NEXT} &rsaquo; "  onclick="this.form.action.value='Import';this.form.step.value='2'; return validateFile(this.form);">
+						&nbsp;
+ <input title="{$APP.LBL_CANCEL_BUTTON_LABEL}" accessKey="" class="crmButton small cancel" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" onclick="window.history.back()">
+
 						</td>
 				   </tr>				</form>
 				 </table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep2.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep2.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ImportStep2.tpl Mon Apr 16 12:27:44 2007
@@ -1,188 +1,223 @@
-{*<!--
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
--->*}
-
-
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-<script type="text/javascript" src="include/js/general.js"></script>
-<script>
-
-function getImportSavedMap(impoptions)
-{ldelim}
-	var mapping = impoptions.options[impoptions.options.selectedIndex].value;
-
-	//added to show the delete link
-	if(mapping != -1)
-		document.getElementById("delete_mapping").style.visibility = "visible";
-	else
-		document.getElementById("delete_mapping").style.visibility = "hidden";
-
-	new Ajax.Request(
-		'index.php',
-		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-			method: 'post',
-			postBody: 'module=Import&mapping='+mapping+'&action=ImportAjax',
-			onComplete: function(response) {ldelim}
-					$("importmapform").innerHTML = response.responseText;
-				{rdelim}
-			{rdelim}
-		);
-{rdelim}
-function deleteMapping()
-{ldelim}
-	var options_collection = document.getElementById("saved_source").options;
-	var mapid = options_collection[options_collection.selectedIndex].value;
-
-	new Ajax.Request(
-		'index.php',
-		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-			method: 'post',
-			postBody: 'module=Import&mapping='+mapid+'&action=ImportAjax&delete_map='+mapid,
-			onComplete: function(response) {ldelim}
-					$("importmapform").innerHTML = response.responseText;
-				{rdelim}
-			{rdelim}
-		);
-
-	//we have emptied the map name from the select list
-	document.getElementById("saved_source").options[options_collection.selectedIndex] = null;
-	document.getElementById("delete_mapping").style.visibility = "hidden";
-	alert("This map has been deleted. You cannot use this map again");
-{rdelim}
-
-</script>
-<!-- header - level 2 tabs -->
-{include file='Buttons_List1.tpl'}	
-
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%" class="small">
-<tbody>
-   <tr>
-	<td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif" /></td>
-	<td class="showPanelBg" valign="top" width="100%">
-		<table  cellpadding="0" cellspacing="0" width="100%" class="small">
-		   <tr>
-			<td width="75%" valign=top>
-				<form enctype="multipart/form-data" name="Import" method="POST" action="index.php">
-				<input type="hidden" name="module" value="{$MODULE}">
-				<input type="hidden" name="action" value="Import">
-				<input type="hidden" name="step" value="3">
-				<input type="hidden" name="has_header" value="{$HAS_HEADER}">
-				<input type="hidden" name="source" value="{$SOURCE}">
-				<input type="hidden" name="delimiter" value="{$DELIMITER}">
-				<input type="hidden" name="tmp_file" value="{$TMP_FILE}">
-				<input type="hidden" name="return_module" value="{$RETURN_MODULE}">
-				<input type="hidden" name="return_id" value="{$RETURN_ID}">
-				<input type="hidden" name="return_action" value="{$RETURN_ACTION}">
-				<input type="hidden" name="parenttab" value="{$CATEGORY}">
-
-				<!-- IMPORT LEADS STARTS HERE  -->
-				<br />
-				<table align="center" cellpadding="5" cellspacing="0" width="95%" class="mailClient importLeadUI small">
-				   <tr>
-					<td class="mailClientBg genHeaderSmall" height="50" valign="middle" align="left" >{$MOD.LBL_MODULE_NAME} {$MODULE}</td>
-				   </tr>
-				   <tr>
-					<td>&nbsp;</td>
-				   </tr>
-				   <tr>
-					<td align="left"  style="padding-left:40px;">
-						<span class="genHeaderGray">{$MOD.LBL_STEP_2_3} </span>&nbsp; 
-						<span class="genHeaderSmall">{$MODULE} {$MOD.LBL_LIST_MAPPING} </span>
-					</td>
-				   </tr>
-				   <tr>
-					<td align="left" style="padding-left:40px;"> 
-					   {$MOD.LBL_STEP_2_MSG} {$MODULE} {$MOD.LBL_STEP_2_MSG1} 
-					   {$MOD.LBL_STEP_2_TXT} {$MODULE}. 
-					</td>
-				   </tr>
-				   <tr>
-					<td>&nbsp;</td>
-				   </tr>
-				   <tr>
-					<td align="left" style="padding-left:40px;" >
-						<input type="checkbox" name="use_saved_mapping" id="saved_map_checkbox" onclick="ActivateCheckBox()" />&nbsp;&nbsp;
-						{$MOD.LBL_USE_SAVED_MAPPING}&nbsp;&nbsp;&nbsp;{$SAVED_MAP_LISTS}
-					</td>
-				   </tr>
-				   <tr>
-					<td  align="left"style="padding-left:40px;padding-right:40px;">
-						<table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="5" cellspacing="1" width="100%" >
-						   <tr bgcolor="white">
-							<td width="25%" class="lvtCol" align="center"><b>{$MOD.LBL_MAPPING}</b></td>
-							{if $HASHEADER eq 1}
-							<td width="25%" bgcolor="#E1E1E1"  ><b>{$MOD.LBL_HEADERS}</b></td>
-							<td width="25%" ><b>{$MOD.LBL_ROW} 1</b></td>
-							<td width="25%" ><b>{$MOD.LBL_ROW} 2</b></td>
-							{else}
-							<td width="25%" ><b>{$MOD.LBL_ROW} 1</b></td>
-							<td width="25%" ><b>{$MOD.LBL_ROW} 2</b></td>
-							<td width="25%" ><b>{$MOD.LBL_ROW} 3</b></td>
-							{/if}
-						   </tr>
-						</table>
-						{assign var="Firstrow" value=$FIRSTROW}
-						{assign var="Secondrow" value=$SECONDROW}
-						{assign var="Thirdrow" value=$THIRDROW}				
-						<table border="0" cellpadding="0" cellspacing="0" width="100%">
-						   <tr>
-							<td width="25%" valign="top">
-								<div id="importmapform">
-									{include file="ImportMap.tpl"}
-								</div>
-							</td>	
-							<td valign="top">
-								<table border="0" cellpadding="0" cellspacing="1" width="100%" valign="top"  class="small">
-								   {foreach name=iter item=row1 from=$Firstrow}
-									{assign var="counter" value=$smarty.foreach.iter.iteration}
-									{math assign="num" equation="x - y" x=$counter y=1}	
-								   <tr bgcolor="white" >
-									{if $HASHEADER eq 1}
-										<td bgcolor="#E1E1E1" width="33%" height="30">&nbsp;{$row1}</td>
-										<td width="34%">&nbsp;{$Secondrow[$num]}</td>
-										<td>&nbsp;{$Thirdrow[$num]}</td>
-									{else}
-										<td width="31%" height="30">&nbsp;{$row1}</td>
-										<td width="30%">&nbsp;{$Secondrow[$num]}</td>
-										<td>&nbsp;{$Thirdrow[$num]}</td>
-									{/if}	
-								   </tr>
-								   {/foreach}
-								</table>
-							</td>
-						   </tr>
-						</table>	
-					</td>
-				   </tr>
-				   <tr>
-					<td align="left" style="padding-left:40px;" >
-						<input type="checkbox" name="save_map" id="save_map" onclick="set_readonly(this.form)" />&nbsp;&nbsp;
-						{$MOD.LBL_SAVE_AS_CUSTOM} &nbsp;&nbsp;&nbsp;
-						<input type="text" readonly name="save_map_as" id="save_map_as" value="" class="importBox" >
-					</td>
-				   </tr>
-				   <tr >
-					<td align="right" style="padding-right:40px;" class="reportCreateBottom" >
-						<input type="submit" name="button"  value=" &nbsp;&lsaquo; {$MOD.LBL_BACK} &nbsp; " class="crmbutton small cancel" onclick="this.form.action.value='Import';this.form.step.value='1'; return true;" />
-						&nbsp;&nbsp;
-						<input type="submit" name="button"  value=" &nbsp; {$MOD.LBL_IMPORT_NOW} &rsaquo; &nbsp; " class="crmbutton small save" onclick="this.form.action.value='Import';this.form.step.value='3'; return validate_import_map();" />
-					</td>
-				   </tr>
-				  </table>
-				</form>
-				<!-- IMPORT LEADS ENDS HERE -->	
-			</td>
-		   </tr>
-		</table>
-	</td>
-   </tr>
-</table>
-
+{*<!--
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+-->*}
+
+
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<script type="text/javascript" src="include/js/general.js"></script>
+<script>
+
+function getImportSavedMap(impoptions)
+{ldelim}
+	var mapping = impoptions.options[impoptions.options.selectedIndex].value;
+
+	//added to show the delete link
+	if(mapping != -1)
+		document.getElementById("delete_mapping").style.visibility = "visible";
+	else
+		document.getElementById("delete_mapping").style.visibility = "hidden";
+
+	new Ajax.Request(
+		'index.php',
+		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+			method: 'post',
+			postBody: 'module=Import&mapping='+mapping+'&action=ImportAjax',
+			onComplete: function(response) {ldelim}
+					$("importmapform").innerHTML = response.responseText;
+				{rdelim}
+			{rdelim}
+		);
+{rdelim}
+function deleteMapping()
+{ldelim}
+	var options_collection = document.getElementById("saved_source").options;
+	var mapid = options_collection[options_collection.selectedIndex].value;
+
+	new Ajax.Request(
+		'index.php',
+		{ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+			method: 'post',
+			postBody: 'module=Import&mapping='+mapid+'&action=ImportAjax&delete_map='+mapid,
+			onComplete: function(response) {ldelim}
+					$("importmapform").innerHTML = response.responseText;
+				{rdelim}
+			{rdelim}
+		);
+
+	//we have emptied the map name from the select list
+	document.getElementById("saved_source").options[options_collection.selectedIndex] = null;
+	document.getElementById("delete_mapping").style.visibility = "hidden";
+	alert("{$APP.MAP_DELETED_INFO}");
+{rdelim}
+{literal}
+function check_submit()
+{
+	if(validate_import_map())
+	{	
+		if(document.getElementById("save_map").checked)
+	        {
+	                var name=document.getElementById("save_map_as").value
+	                $("status").style.display="block";
+	                new Ajax.Request(
+	                'index.php',
+	                {queue: {position: 'end', scope: 'command'},
+	                method: 'post',
+                        postBody: 'module=Import&name='+name+'&ajax_action=check_dup_map_name&action=ImportAjax',
+                        onComplete: function(response) {
+
+			if(response.responseText == 'true')
+        	                document.Import.submit();
+{/literal}              else
+				if(confirm("{$APP.MAP_NAME_EXISTS}"))
+{literal}					document.Import.submit();
+	                	$("status").style.display="none";
+
+                			                }
+                        }
+			                );
+
+
+		}
+		else
+			document.Import.submit();
+	}
+}
+
+
+{/literal}
+</script>
+<!-- header - level 2 tabs -->
+{include file='Buttons_List1.tpl'}	
+
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%" class="small">
+<tbody>
+   <tr>
+	<td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif" /></td>
+	<td class="showPanelBg" valign="top" width="100%">
+		<table  cellpadding="0" cellspacing="0" width="100%" class="small">
+		   <tr>
+			<td width="75%" valign=top>
+				<form enctype="multipart/form-data" name="Import" method="POST" action="index.php">
+				<input type="hidden" name="module" value="{$MODULE}">
+				<input type="hidden" name="action" value="Import">
+				<input type="hidden" name="step" value="3">
+				<input type="hidden" name="has_header" value="{$HAS_HEADER}">
+				<input type="hidden" name="source" value="{$SOURCE}">
+				<input type="hidden" name="delimiter" value="{$DELIMITER}">
+				<input type="hidden" name="tmp_file" value="{$TMP_FILE}">
+				<input type="hidden" name="return_module" value="{$RETURN_MODULE}">
+				<input type="hidden" name="return_id" value="{$RETURN_ID}">
+				<input type="hidden" name="return_action" value="{$RETURN_ACTION}">
+				<input type="hidden" name="parenttab" value="{$CATEGORY}">
+
+				<!-- IMPORT LEADS STARTS HERE  -->
+				<br />
+				<table align="center" cellpadding="5" cellspacing="0" width="95%" class="mailClient importLeadUI small">
+				   <tr>
+					<td class="mailClientBg genHeaderSmall" height="50" valign="middle" align="left" >{$MOD.LBL_MODULE_NAME} {$APP.$MODULE}</td>
+				   </tr>
+				   <tr>
+					<td>&nbsp;</td>
+				   </tr>
+				   <tr>
+					<td align="left"  style="padding-left:40px;">
+						<span class="genHeaderGray">{$MOD.LBL_STEP_2_3} </span>&nbsp; 
+						<span class="genHeaderSmall">{$APP.$MODULE} {$MOD.LBL_LIST_MAPPING} </span>
+					</td>
+				   </tr>
+				   <tr>
+					<td align="left" style="padding-left:40px;"> 
+					   {$MOD.LBL_STEP_2_MSG} {$APP.$MODULE} {$MOD.LBL_STEP_2_MSG1} 
+					   {$MOD.LBL_STEP_2_TXT} {$APP.$MODULE}. 
+					</td>
+				   </tr>
+				   <tr>
+					<td>&nbsp;</td>
+				   </tr>
+				   <tr>
+					<td align="left" style="padding-left:40px;" >
+						<input type="checkbox" name="use_saved_mapping" id="saved_map_checkbox" onclick="ActivateCheckBox()" />&nbsp;&nbsp;
+						{$MOD.LBL_USE_SAVED_MAPPING}&nbsp;&nbsp;&nbsp;{$SAVED_MAP_LISTS}
+					</td>
+				   </tr>
+				   <tr>
+					<td  align="left"style="padding-left:40px;padding-right:40px;">
+						<table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="5" cellspacing="1" width="100%" >
+						   <tr bgcolor="white">
+							<td width="25%" class="lvtCol" align="center"><b>{$MOD.LBL_MAPPING}</b></td>
+							{if $HASHEADER eq 1}
+							<td width="25%" bgcolor="#E1E1E1"  ><b>{$MOD.LBL_HEADERS}</b></td>
+							<td width="25%" ><b>{$MOD.LBL_ROW} 1</b></td>
+							<td width="25%" ><b>{$MOD.LBL_ROW} 2</b></td>
+							{else}
+							<td width="25%" ><b>{$MOD.LBL_ROW} 1</b></td>
+							<td width="25%" ><b>{$MOD.LBL_ROW} 2</b></td>
+							<td width="25%" ><b>{$MOD.LBL_ROW} 3</b></td>
+							{/if}
+						   </tr>
+						</table>
+						{assign var="Firstrow" value=$FIRSTROW}
+						{assign var="Secondrow" value=$SECONDROW}
+						{assign var="Thirdrow" value=$THIRDROW}				
+						<table border="0" cellpadding="0" cellspacing="0" width="100%">
+						   <tr>
+							<td width="25%" valign="top">
+								<div id="importmapform">
+									{include file="ImportMap.tpl"}
+								</div>
+							</td>	
+							<td valign="top">
+								<table border="0" cellpadding="0" cellspacing="1" width="100%" valign="top"  class="small">
+								   {foreach name=iter item=row1 from=$Firstrow}
+									{assign var="counter" value=$smarty.foreach.iter.iteration}
+									{math assign="num" equation="x - y" x=$counter y=1}	
+								   <tr bgcolor="white" >
+									{if $HASHEADER eq 1}
+										<td bgcolor="#E1E1E1" width="33%" height="30">&nbsp;{$row1}</td>
+										<td width="34%">&nbsp;{$Secondrow[$num]}</td>
+										<td>&nbsp;{$Thirdrow[$num]}</td>
+									{else}
+										<td width="31%" height="30">&nbsp;{$row1}</td>
+										<td width="30%">&nbsp;{$Secondrow[$num]}</td>
+										<td>&nbsp;{$Thirdrow[$num]}</td>
+									{/if}	
+								   </tr>
+								   {/foreach}
+								</table>
+							</td>
+						   </tr>
+						</table>	
+					</td>
+				   </tr>
+				   <tr>
+					<td align="left" style="padding-left:40px;" >
+						<input type="checkbox" name="save_map" id="save_map" onclick="set_readonly(this.form)" />&nbsp;&nbsp;
+						{$MOD.LBL_SAVE_AS_CUSTOM} &nbsp;&nbsp;&nbsp;
+						<input type="text" readonly name="save_map_as" id="save_map_as" value="" class="importBox" >
+					</td>
+				   </tr>
+				   <tr >
+					<td align="right" style="padding-right:40px;" class="reportCreateBottom" >
+						<input type="submit" name="button"  value=" &nbsp;&lsaquo; {$MOD.LBL_BACK} &nbsp; " class="crmbutton small cancel" onclick="this.form.action.value='Import';this.form.step.value='1'; return true;" />
+						&nbsp;&nbsp;
+						<input type="button" name="button"  value=" &nbsp; {$MOD.LBL_IMPORT_NOW} &rsaquo; &nbsp; " class="crmbutton small save" onclick="this.form.action.value='Import';this.form.step.value='3'; check_submit();" />
+					</td>
+				   </tr>
+				  </table>
+				</form>
+				<!-- IMPORT LEADS ENDS HERE -->	
+			</td>
+		   </tr>
+		</table>
+	</td>
+   </tr>
+</table>
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryActions.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryActions.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryActions.tpl Mon Apr 16 12:27:44 2007
@@ -34,27 +34,28 @@
 	<!-- Module based actions starts -->
 	{if $MODULE eq 'Products'}
 	   <!-- Product Actions starts -->
-	   <tr>
-		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+
+	   <tr>
+		<td align="left" style="padding-left:5px;">
+	<a href="javascript: document.DetailView.module.value='Quotes'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateQuote.gif" hspace="2" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='Quotes'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.Quote}</a> 
 		</td>
 	   </tr>
 	   <tr>
-		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+		<td align="left" style="padding-left:5px;">
+			<a href="javascript: document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateInvoice.gif" hspace="2" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.Invoice}</a> 
 		</td>
 	   </tr>
 	   <tr>
-		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+		<td align="left" style="padding-left:5px;">
+<a href="javascript: document.DetailView.module.value='SalesOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateSalesOrder.gif" hspace="2" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='SalesOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.SalesOrder}</a> 
 		</td>
 	   </tr>
 	   <tr>
-		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+		<td align="left" style="padding-left:5px;">
+			<a href="javascript: document.DetailView.module.value='PurchaseOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenPurchaseOrder.gif" hspace="2" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='PurchaseOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Products'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.product_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.PurchaseOrder}</a> 
 		</td>
 	   </tr>
@@ -90,7 +91,7 @@
 	   <!-- Vendors Actions starts -->
 	   <tr>
 		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+<a href="javascript: document.DetailView.module.value='PurchaseOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Vendors'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.vendor_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu">	<img src="{$IMAGE_PATH}actionGenPurchaseOrder.gif" hspace="5" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='PurchaseOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='Vendors'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.parent_id.value='{$ID}'; document.DetailView.vendor_id.value='{$ID}'; document.DetailView.record.value=''; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.PurchaseOrder}</a> 
 		</td>
 	   </tr>
@@ -120,7 +121,7 @@
 	   <!-- SO Actions starts -->
 	   <tr>
 		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+			<a href="javascript: document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='SalesOrder'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.record.value='{$ID}'; document.DetailView.convertmode.value='sotoinvoice'; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateInvoice.gif" hspace="5" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='SalesOrder'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.record.value='{$ID}'; document.DetailView.convertmode.value='sotoinvoice'; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.Invoice}</a> 
 		</td>
 	   </tr>
@@ -144,13 +145,14 @@
 	   <!-- Quotes Actions starts -->
 	   <tr>
 		<td align="left" style="padding-left:10px;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/> 
-			<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.convertmode.value='{$CONVERTMODE}'; document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="webMnu">{$APP.LBL_GENERATE} {$APP.Invoice}</a> 
-		</td>
-	   </tr>
+<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.convertmode.value='{$CONVERTMODE}'; document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateInvoice.gif" hspace="5" align="absmiddle" border="0"/></a> 
+		<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.convertmode.value='{$CONVERTMODE}'; document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="webMnu">{$APP.LBL_GENERATE} {$APP.Invoice}</a> 
+		</td>
+	   </tr>
+
 	   <tr>
 		<td align="left" style="padding-left:10px;border-bottom:1px dotted #CCCCCC;">
-			<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+			<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.convertmode.value='quotetoso'; document.DetailView.module.value='SalesOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateSalesOrder.gif" hspace="5" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.convertmode.value='quotetoso'; document.DetailView.module.value='SalesOrder'; document.DetailView.action.value='EditView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="webMnu">{$APP.LBL_GENERATE} {$APP.SalesOrder}</a> 
 		</td>
 	   </tr>
@@ -198,7 +200,8 @@
 
    <tr>
 	<td align="left" style="padding-left:10px;">
-		<img src="{$IMAGE_PATH}pointer.gif" hspace="5" align="absmiddle"/>
+		<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.module.value='{$MODULE}'; document.DetailView.action.value='{$export_pdf_action}'; document.DetailView.record.value='{$ID}'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="
+webMnu"><img src="{$IMAGE_PATH}actionGeneratePDF.gif" hspace="5" align="absmiddle" border="0"/></a>
 		<a href="javascript: document.DetailView.return_module.value='{$MODULE}'; document.DetailView.return_action.value='DetailView'; document.DetailView.module.value='{$MODULE}'; document.DetailView.action.value='{$export_pdf_action}'; document.DetailView.record.value='{$ID}'; document.DetailView.return_id.value='{$ID}'; document.DetailView.submit();" class="webMnu">{$APP.LBL_EXPORT_TO_PDF}</a> 
 	</td>
    </tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryCreateView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryCreateView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryCreateView.tpl Mon Apr 16 12:27:44 2007
@@ -1,205 +1,216 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-
-{*<!-- module header -->*}
-
-<link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
-<script type="text/javascript" src="jscalendar/calendar.js"></script>
-<script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
-<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-<script type="text/javascript" src="include/js/Inventory.js"></script>
-
-<script type="text/javascript">
-
-function sensex_info()
-{ldelim}
-        var Ticker = $('tickersymbol').value;
-        if(Ticker!='')
-        {ldelim}
-		$("vtbusy_info").style.display="inline";
-		new Ajax.Request(
-          	      'index.php',
-                      {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-                      		method: 'post',
-                        	postBody: 'module={$MODULE}&action=Tickerdetail&tickersymbol='+Ticker,
-	                        onComplete: function(response) {ldelim}
-					$('autocom').innerHTML = response.responseText;
-				        $('autocom').style.display="block";
-        	                        $("vtbusy_info").style.display="none";
-                	        {rdelim}
-                	{rdelim}
-        	);
-        {rdelim}
-{rdelim}
-
-</script>
-
-{include file='Buttons_List1.tpl'}
-
-{*<!-- Contents -->*}
-<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
-   <tr>
-	<td valign=top>
-		<img src="{$IMAGE_PATH}showPanelTopLeft.gif">
-	</td>
-
-	<td class="showPanelBg" valign=top width=100%>
-	     {*<!-- PUBLIC CONTENTS STARTS-->*}
-		{include file='EditViewHidden.tpl'}
-	     <div class="small" style="padding:20px">
-		
-		 {if $OP_MODE eq 'edit_view'}   
-			 <span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} -  {$APP.LBL_EDITING} {$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</span> <br>
-			{$UPDATEINFO}	 
-		 {/if}
-		 {if $OP_MODE eq 'create_view'}
-			<span class="lvtHeaderText">{$APP.LBL_CREATING} {$APP.LBL_NEW} {$MOD[$SINGLE_MOD]}</span> <br>
-		 {/if}
-
-		 <hr noshade size=1>
-		 <br> 
-		
-		
-
-		{*<!-- Account details tabs -->*}
-		<table border=0 cellspacing=0 cellpadding=0 width=95% align=center>
-		   <tr>
-			<td>
-				<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
-				   <tr>
-					<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
-
-					{if $BLOCKS_COUNT eq 2}	
-						<td width=75 style="width:15%" align="center" nowrap class="dvtSelectedCell" id="bi" onclick="fnLoadValues('bi','mi','basicTab','moreTab','inventory','{$MODULE}')"><b>{$APP.LBL_BASIC} {$APP.LBL_INFORMATION}</b></td>
-                    				<td class="dvtUnSelectedCell" style="width: 100px;" align="center" nowrap id="mi" onclick="fnLoadValues('mi','bi','moreTab','basicTab','inventory','{$MODULE}')"><b>{$APP.LBL_MORE} {$APP.LBL_INFORMATION} </b></td>
-                   				<td class="dvtTabCache" style="width:65%" nowrap>&nbsp;</td>
-					{else}
-						<td class="dvtSelectedCell" align=center nowrap>{$APP.LBL_BASIC} {$APP.LBL_INFORMATION}</td>
-	                                        <td class="dvtTabCache" style="width:65%">&nbsp;</td>
-					{/if}
-				   <tr>
-				</table>
-			</td>
-		   </tr>
-		   <tr>
-			<td valign=top align=left >
-
-			    {foreach item=blockInfo key=divName from=$BLOCKS}
-			    <!-- Basic and More Information Tab Opened -->
-			    <div id="{$divName}">
-
-				<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
-				   <tr>
-					<!--this td is to display the entity details -->
-					<td align=left>
-					<!-- content cache -->
-
-						<table border=0 cellspacing=0 cellpadding=0 width=100%>
-						   <tr>
-							<td id ="autocom"></td>
-						   </tr>
-						   <tr>
-							<td style="padding:10px">
-							<!-- General details -->
-								<table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
-								   <tr>
-									<td  colspan=4 style="padding:5px">
-									   <div align="center">
-										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-                                                                 		<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
-									   </div>
-									</td>
-								   </tr>
-
-								   {foreach key=header item=data from=$blockInfo}
-								   <tr>
-									{if $header== $MOD.LBL_ADDRESS_INFORMATION && ($MODULE == 'Accounts' || $MODULE == 'Contacts' || $MODULE == 'Quotes' || $MODULE == 'PurchaseOrder' || $MODULE == 'SalesOrder'|| $MODULE == 'Invoice')}
-                                                                        <td colspan=2 class="detailedViewHeader">
-                                                                        <b>{$header}</b></td>
-                                                                        <td class="detailedViewHeader">
-                                                                        <input name="cpy" onclick="return copyAddressLeft(EditView)" type="radio"><b>{$APP.LBL_RCPY_ADDRESS}</b></td>
-                                                                        <td class="detailedViewHeader">
-                                                                        <input name="cpy" onclick="return copyAddressRight(EditView)" type="radio"><b>{$APP.LBL_LCPY_ADDRESS}</b></td>
-                                                                        {else}
-						         		<td colspan=4 class="detailedViewHeader">
-                                                	        		<b>{$header}</b>
-									{/if}
-									</td>
-								   </tr>
-
-								   <!-- Here we should include the uitype handlings-->
-								   {include file="DisplayFields.tpl"}
-
-								   <tr style="height:25px"><td>&nbsp;</td></tr>
-								   {/foreach}
-
-								   <!-- This if is added to restrict display in more tab-->
-								   {if $divName eq 'basicTab'}
-								   {if $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Invoice'}
-								   	<!-- Added to display the product details -->
-									<!-- This if is added when we want to populate product details from the related entity  for ex. populate product details in new SO page when select Quote -->
-									{if $AVAILABLE_PRODUCTS eq true}
-										{include file="Inventory/ProductDetailsEditView.tpl"}
-									{else}
-										{include file="Inventory/ProductDetails.tpl"}
-									{/if}
-
-								   {/if}
-								   {/if}
-
-								   <tr>
-									<td  colspan=4 style="padding:5px">
-									   <div align="center">
-										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-										<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
-									   </div>
-									</td>
-								   </tr>
-								</table>
-								<!-- General details - end -->
-							</td>
-						   </tr>
-						</table>
-					</td>
-				   </tr>
-				</table>
-							
-			    </div>
-			    {/foreach}
-			</td>
-		   </tr>
-		</table>
-	 </div>
-	</td>
-	<td align=right valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</table>
-</form>
-
-<!-- This div is added to get the left and top values to show the tax details-->
-<div id="tax_container" style="display:none; position:absolute; z-index:1px;"></div>
-
-<script>
-
-
-
-        var fieldname = new Array({$VALIDATION_DATA_FIELDNAME})
-
-        var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL})
-
-        var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE})
-
-
-</script>
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+
+{*<!-- module header -->*}
+
+<link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
+<script type="text/javascript" src="jscalendar/calendar.js"></script>
+<script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
+<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<script type="text/javascript" src="include/js/Inventory.js"></script>
+
+<script type="text/javascript">
+
+function sensex_info()
+{ldelim}
+        var Ticker = $('tickersymbol').value;
+        if(Ticker!='')
+        {ldelim}
+		$("vtbusy_info").style.display="inline";
+		new Ajax.Request(
+          	      'index.php',
+                      {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                      		method: 'post',
+                        	postBody: 'module={$MODULE}&action=Tickerdetail&tickersymbol='+Ticker,
+	                        onComplete: function(response) {ldelim}
+					$('autocom').innerHTML = response.responseText;
+				        $('autocom').style.display="block";
+        	                        $("vtbusy_info").style.display="none";
+                	        {rdelim}
+                	{rdelim}
+        	);
+        {rdelim}
+{rdelim}
+
+</script>
+
+{include file='Buttons_List1.tpl'}
+
+{*<!-- Contents -->*}
+<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
+   <tr>
+	<td valign=top>
+		<img src="{$IMAGE_PATH}showPanelTopLeft.gif">
+	</td>
+
+	<td class="showPanelBg" valign=top width=100%>
+	     {*<!-- PUBLIC CONTENTS STARTS-->*}
+		{include file='EditViewHidden.tpl'}
+	     <div class="small" style="padding:20px">
+		
+		 {if $OP_MODE eq 'edit_view'}   
+			 <span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} -  {$APP.LBL_EDITING} {$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</span> <br>
+			{$UPDATEINFO}	 
+		 {/if}
+		 {if $OP_MODE eq 'create_view'}
+			{if $DUPLICATE neq 'true'}
+			<span class="lvtHeaderText">{$APP.LBL_CREATING} {$APP.LBL_NEW} {$MOD[$SINGLE_MOD]}</span> <br>
+			{else}
+			<span class="lvtHeaderText">{$APP.LBL_DUPLICATING} "{$NAME}" </span> <br>
+			{/if}
+		 {/if}
+
+		 <hr noshade size=1>
+		 <br> 
+		
+		
+
+		{*<!-- Account details tabs -->*}
+		<table border=0 cellspacing=0 cellpadding=0 width=95% align=center>
+		   <tr>
+			<td>
+				<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
+				   <tr>
+					<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
+
+					{if $BLOCKS_COUNT eq 2}	
+						<td width=75 style="width:15%" align="center" nowrap class="dvtSelectedCell" id="bi" onclick="fnLoadValues('bi','mi','basicTab','moreTab','inventory','{$MODULE}')"><b>{$APP.LBL_BASIC} {$APP.LBL_INFORMATION}</b></td>
+                    				<td class="dvtUnSelectedCell" style="width: 100px;" align="center" nowrap id="mi" onclick="fnLoadValues('mi','bi','moreTab','basicTab','inventory','{$MODULE}')"><b>{$APP.LBL_MORE} {$APP.LBL_INFORMATION} </b></td>
+                   				<td class="dvtTabCache" style="width:65%" nowrap>&nbsp;</td>
+					{else}
+						<td class="dvtSelectedCell" align=center nowrap>{$APP.LBL_BASIC} {$APP.LBL_INFORMATION}</td>
+	                                        <td class="dvtTabCache" style="width:65%">&nbsp;</td>
+					{/if}
+				   <tr>
+				</table>
+			</td>
+		   </tr>
+		   <tr>
+			<td valign=top align=left >
+
+			    {foreach item=blockInfo key=divName from=$BLOCKS}
+			    <!-- Basic and More Information Tab Opened -->
+			    <div id="{$divName}">
+
+				<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
+				   <tr>
+					<!--this td is to display the entity details -->
+					<td align=left>
+					<!-- content cache -->
+
+						<table border=0 cellspacing=0 cellpadding=0 width=100%>
+						   <tr>
+							<td id ="autocom"></td>
+						   </tr>
+						   <tr>
+							<td style="padding:10px">
+							<!-- General details -->
+								<table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
+								   <tr>
+									<td  colspan=4 style="padding:5px">
+									   <div align="center">
+										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+                                                                 		<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+									   </div>
+									</td>
+								   </tr>
+
+								   {foreach key=header item=data from=$blockInfo}
+								   <tr>
+									{if $header== $MOD.LBL_ADDRESS_INFORMATION && ($MODULE == 'Accounts' || $MODULE == 'Contacts' || $MODULE == 'Quotes' || $MODULE == 'PurchaseOrder' || $MODULE == 'SalesOrder'|| $MODULE == 'Invoice')}
+                                                                        <td colspan=2 class="detailedViewHeader">
+                                                                        <b>{$header}</b></td>
+                                                                        <td class="detailedViewHeader">
+                                                                        <input name="cpy" onclick="return copyAddressLeft(EditView)" type="radio"><b>{$APP.LBL_RCPY_ADDRESS}</b></td>
+                                                                        <td class="detailedViewHeader">
+                                                                        <input name="cpy" onclick="return copyAddressRight(EditView)" type="radio"><b>{$APP.LBL_LCPY_ADDRESS}</b></td>
+                                                                        {else}
+						         		<td colspan=4 class="detailedViewHeader">
+                                                	        		<b>{$header}</b>
+									{/if}
+									</td>
+								   </tr>
+
+								   <!-- Here we should include the uitype handlings-->
+								   {include file="DisplayFields.tpl"}
+
+								   <tr style="height:25px"><td>&nbsp;</td></tr>
+								   {/foreach}
+
+								   <!-- This if is added to restrict display in more tab-->
+								   {if $divName eq 'basicTab'}
+								   {if $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Invoice'}
+								   	<!-- Added to display the product details -->
+									<!-- This if is added when we want to populate product details from the related entity  for ex. populate product details in new SO page when select Quote -->
+									{if $AVAILABLE_PRODUCTS eq true}
+										{include file="Inventory/ProductDetailsEditView.tpl"}
+									{else}
+										{include file="Inventory/ProductDetails.tpl"}
+									{/if}
+
+								   {/if}
+								   {/if}
+
+								   <tr>
+									<td  colspan=4 style="padding:5px">
+									   <div align="center">
+										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+									   </div>
+									</td>
+								   </tr>
+								</table>
+								<!-- General details - end -->
+							</td>
+						   </tr>
+						</table>
+					</td>
+				   </tr>
+				</table>
+							
+			    </div>
+			    {/foreach}
+			</td>
+		   </tr>
+		</table>
+	 </div>
+	</td>
+	<td align=right valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</table>
+</form>
+
+<!-- This div is added to get the left and top values to show the tax details-->
+<div id="tax_container" style="display:none; position:absolute; z-index:1px;"></div>
+
+<script>
+
+
+
+        var fieldname = new Array({$VALIDATION_DATA_FIELDNAME})
+
+        var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL})
+
+        var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE})
+
+	var product_labelarr = {ldelim}CLEAR_COMMENT:'{$APP.LBL_CLEAR_COMMENT}',
+                                DISCOUNT:'{$APP.LBL_DISCOUNT}',
+                                TOTAL_AFTER_DISCOUNT:'{$APP.LBL_TOTAL_AFTER_DISCOUNT}',
+                                TAX:'{$APP.LBL_TAX}',
+                                ZERO_DISCOUNT:'{$APP.LBL_ZERO_DISCOUNT}',
+                                PERCENT_OF_PRICE:'{$APP.LBL_OF_PRICE}',
+                                DIRECT_PRICE_REDUCTION:'{$APP.LBL_DIRECT_PRICE_REDUCTION}'{rdelim};
+
+</script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -1,339 +1,340 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
-<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
-<div id="convertleaddiv" style="display:block;position:absolute;left:225px;top:150px;"></div>
-<span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
-   <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
-</span>
-<script>
-function tagvalidate()
-{ldelim}
-	if(document.getElementById('txtbox_tagfields').value != '')
-		SaveTag('txtbox_tagfields','{$ID}','{$MODULE}');	
-	else
-	{ldelim}
-		alert("Please enter a tag");
-		return false;
-	{rdelim}
-{rdelim}
-function DeleteTag(id)
-{ldelim}
-	$("vtbusy_info").style.display="inline";
-	Effect.Fade('tag_'+id);
-	new Ajax.Request(
-		'index.php',
-                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-                        method: 'post',
-                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&tagid=" +id,
-                        onComplete: function(response) {ldelim}
-						getTagCloud();
-						$("vtbusy_info").style.display="none";
-                        {rdelim}
-                {rdelim}
-        );
-{rdelim}
-
-</script>
-
-<table width="100%" cellpadding="2" cellspacing="0" border="0">
-   <tr>
-	<td>
-		{include file='Buttons_List1.tpl'}
-
-		<!-- Contents -->
-		<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
-		   <tr>
-			<td valign=top><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-			<td class="showPanelBg" valign=top width=100%>
-			<!-- PUBLIC CONTENTS STARTS-->
-			   <div class="small" style="padding:20px" >
-		
-				<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
-				   <tr>
-					<td>
-						<span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} -  {$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</span>&nbsp;&nbsp;<span id="vtbusy_info" style="display:none;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span><span id="vtbusy_info" style="visibility:hidden;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span>
-					</td>
-					<td>&nbsp;</td>
-				   </tr>
-				   <tr height=20>
-					<td>{$UPDATEINFO}</td>
-				   </tr>
-				</table>
-
-				<hr noshade size=1>
-		
-				<!-- Entity and More information tabs -->
-				<table border=0 cellspacing=0 cellpadding=0 width=95% align=center>
-				   <tr>
-					<td>
-						<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
-						   <tr>
-							<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
-							<td class="dvtSelectedCell" align=center nowrap>{$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</td>	
-							<td class="dvtTabCache" style="width:10px">&nbsp;</td>
-							{if $SinglePane_View eq 'false'}
-								<td class="dvtUnSelectedCell" align=center nowrap><a href="index.php?action=CallRelatedList&module={$MODULE}&record={$ID}&parenttab={$CATEGORY}">{$APP.LBL_MORE} {$APP.LBL_INFORMATION}</a></td>
-							{/if}
-							<td class="dvtTabCache" style="width:100%">&nbsp;</td>
-						   </tr>
-						</table>
-					</td>
-				   </tr>
-				   <tr>
-					<td valign=top align=left >
-						<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
-						   <tr>
-
-							<td align=left style="padding:10px;">
-							<!-- content cache -->
-								<!-- Entity informations display - starts -->	
-								<table border=0 cellspacing=0 cellpadding=0 width=100%>
-			                			   <tr>
-									<td style="padding:10px;border-right:1px dashed #CCCCCC;" width="80%">
-
-
-
-<!-- The following table is used to display the buttons -->
-   <form action="index.php" method="post" name="DetailView" id="form">
-					{include file='DetailViewHidden.tpl'}
-<table border=0 cellspacing=0 cellpadding=0 width=100%>
-   {strip}
-   <tr>
-	<td  colspan=4 style="padding:5px">
-		<table border=0 cellspacing=0 cellpadding=0 width=100%>
-                   <tr>
-                        <td>
-				{if $EDIT_DUPLICATE eq 'permitted'}
-				<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="{$APP.LBL_EDIT_BUTTON_LABEL}">&nbsp;
-				{/if}
-			</td>
-			<td align=right>
-				{if $EDIT_DUPLICATE eq 'permitted'}
-				<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
-				{/if}
-				{if $DELETE eq 'permitted'}
-				<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
-				{/if}
-			</td>
-                   </tr>
-                </table>
-		<!-- Commented the buttons in DetailView because these buttons have been given as links
-		{if $MODULE eq 'Quotes' || $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Invoice'}
-			{if $CREATEPDF eq 'permitted'}
-				<input title="Export To PDF" accessKey="Alt+e" class="small" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}'; this.form.module.value='{$MODULE}'; {if $MODULE eq 'SalesOrder'} this.form.action.value='CreateSOPDF'" {else} this.form.action.value='CreatePDF'" {/if} type="submit" name="Export To PDF" value="{$APP.LBL_EXPORT_TO_PDF}">&nbsp;
-			{/if}
-		{/if}
-		{if $MODULE eq 'Quotes'}
-			{if $CONVERTSALESORDER eq 'permitted'}
-				<input title="{$APP.LBL_CONVERTSO_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTSO_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='SalesOrder'; this.form.return_action.value='DetailView'; this.form.convertmode.value='quotetoso';this.form.module.value='SalesOrder'; this.form.action.value='EditView'" type="submit" name="Convert To SalesOrder" value="{$APP.LBL_CONVERTSO_BUTTON_LABEL}">&nbsp;
-			{/if}
-		{/if}
-		{if $MODULE eq 'Potentials' || $MODULE eq 'Quotes' || $MODULE eq 'SalesOrder'}
-			{if $CONVERTINVOICE eq 'permitted'}
-				<input title="{$APP.LBL_CONVERTINVOICE_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTINVOICE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.convertmode.value='{$CONVERTMODE}';this.form.module.value='Invoice'; this.form.action.value='EditView'" type="submit" name="Convert To Invoice" value="{$APP.LBL_CONVERTINVOICE_BUTTON_LABEL}">&nbsp;
-			{/if}
-		{/if}
-		-->
-	</td>
-   </tr>
-   {/strip}
-</table>
-<!-- Button displayed - finished-->
-
-<!-- Entity information(blocks) display - start -->
-{foreach key=header item=detail from=$BLOCKS}
-	<table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
-	   <tr>
-		<td>&nbsp;</td>
-		<td>&nbsp;</td>
-		<td>&nbsp;</td>
-		<td align=right>
-		</td>
-	   </tr>
-	   <tr>
-		{strip}
-		<td colspan=4 class="dvInnerHeader" >
-			<b>
-			       	{$header}
-			</b>
-		</td>
-		{/strip}
-	   </tr>
-
-	   {foreach item=detail from=$detail}
-	   <tr style="height:25px">
-		{foreach key=label item=data from=$detail}
-			{assign var=keyid value=$data.ui}
-			{assign var=keyval value=$data.value}
-			{assign var=keytblname value=$data.tablename}
-			{assign var=keyfldname value=$data.fldname}
-			{assign var=keyoptions value=$data.options}
-			{assign var=keysecid value=$data.secid}
-			{assign var=keyseclink value=$data.link}
-			{assign var=keycursymb value=$data.cursymb}
-			{assign var=keysalut value=$data.salut}
-			{assign var=keycntimage value=$data.cntimage}
-			   {assign var=keyadmin value=$data.isadmin}
-							   
-
-				{if $label ne ''}
-					{if $keycntimage ne ''}
-						<td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$keycntimage}</td>
-					{elseif $label neq 'Tax Class'}<!-- Avoid to display the label Tax Class -->
-						{if $keyid eq '71' || $keyid eq '72'}  <!--CurrencySymbol-->
-							<td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$label} ({$keycursymb})</td>
-						{else}
-							<td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$label}</td>
-						{/if}
-					{/if}  
-					{if $EDIT_PERMISSION eq 'yes'}
-						{include file="DetailViewUI.tpl"}
-					{else}
-						{include file="DetailViewFields.tpl"}
-					{/if}
-				{else} 
-					<td class="dvtCellLabel" align=right>&nbsp;</td>
-					<td class="dvtCellInfo" align=left >&nbsp;</td>
-				{/if}
-		{/foreach}
-	   </tr>	
-	   {/foreach}	
-	</table>
-{/foreach}
-{*-- End of Blocks--*} 
-<!-- Entity information(blocks) display - ends -->
-
-									<br>
-
-										<!-- Product Details informations -->
-										{$ASSOCIATED_PRODUCTS}
-
-									</td>
-<!-- The following table is used to display the buttons -->
-								<table border=0 cellspacing=0 cellpadding=0 width=100%>
-			                			   <tr>
-									<td style="padding:10px;border-right:1px dashed #CCCCCC;" width="80%">
-			{if $SinglePane_View eq 'false'}
-<table border=0 cellspacing=0 cellpadding=0 width=100%>
-   {strip}
-   <tr>
-	<td  colspan=4 style="padding:5px">
-		<table border=0 cellspacing=0 cellpadding=0 width=100%>
-                   <tr>
-                        <td>
-				{if $EDIT_DUPLICATE eq 'permitted'}
-				<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="{$APP.LBL_EDIT_BUTTON_LABEL}">&nbsp;
-				{/if}
-			</td>
-			<td align=right>
-				{if $EDIT_DUPLICATE eq 'permitted'}
-				<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
-				{/if}
-				{if $DELETE eq 'permitted'}
-				<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
-				{/if}
-			</td>
-                   </tr>
-                </table>
-
-		<!-- Commented the buttons in DetailView because these buttons have been given as links
-		{if $MODULE eq 'Quotes' || $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Invoice'}
-			{if $CREATEPDF eq 'permitted'}
-				<input title="Export To PDF" accessKey="Alt+e" class="small" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}'; this.form.module.value='{$MODULE}'; {if $MODULE eq 'SalesOrder'} this.form.action.value='CreateSOPDF'" {else} this.form.action.value='CreatePDF'" {/if} type="submit" name="Export To PDF" value="{$APP.LBL_EXPORT_TO_PDF}">&nbsp;
-			{/if}
-		{/if}
-		{if $MODULE eq 'Quotes'}
-			{if $CONVERTSALESORDER eq 'permitted'}
-				<input title="{$APP.LBL_CONVERTSO_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTSO_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='SalesOrder'; this.form.return_action.value='DetailView'; this.form.convertmode.value='quotetoso';this.form.module.value='SalesOrder'; this.form.action.value='EditView'" type="submit" name="Convert To SalesOrder" value="{$APP.LBL_CONVERTSO_BUTTON_LABEL}">&nbsp;
-			{/if}
-		{/if}
-		{if $MODULE eq 'Potentials' || $MODULE eq 'Quotes' || $MODULE eq 'SalesOrder'}
-			{if $CONVERTINVOICE eq 'permitted'}
-				<input title="{$APP.LBL_CONVERTINVOICE_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTINVOICE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.convertmode.value='{$CONVERTMODE}';this.form.module.value='Invoice'; this.form.action.value='EditView'" type="submit" name="Convert To Invoice" value="{$APP.LBL_CONVERTINVOICE_BUTTON_LABEL}">&nbsp;
-			{/if}
-		{/if}
-		-->
-	</td>
-   </tr>
-   {/strip}
-</table>
-{/if}
-</form>
-		<table border=0 cellspacing=0 cellpadding=0 width=100%>
-		  <tr>
-			<td style="border-right:1px dashed #CCCCCC;" width="100%">
-			{if $SinglePane_View eq 'true'}
-				{include file= 'RelatedListNew.tpl'}
-			{/if}
-		</td></tr></table>
-</td></tr></table>
-<!-- Button displayed - finished-->
-									<!-- Inventory Actions - ends -->	
-									<td width=22% valign=top style="padding:10px;">
-										<!-- right side InventoryActions -->
-										{include file="Inventory/InventoryActions.tpl"}
-
-										<br>
-										<!-- To display the Tag Clouds -->
-										<div>
-										      {include file="TagCloudDisplay.tpl"}
-										</div>
-									</td>
-								   </tr>
-								</table>
-							</td>
-						   </tr>
-						</table>
-					<!-- PUBLIC CONTENTS STOPS-->
-					</td>
-					<td align=right valign=top>
-						<img src="{$IMAGE_PATH}showPanelTopRight.gif">
-					</td>
-				   </tr>
-				</table>
-			   </div>
-			</td>
-		   </tr>
-		</table>
-		<!-- Contents - end -->
-
-<script>
-function getTagCloud()
-{ldelim}
-new Ajax.Request(
-        'index.php',
-        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-        method: 'post',
-        postBody: 'module={$MODULE}&action={$MODULE}Ajax&file=TagCloud&ajxaction=GETTAGCLOUD&recordid={$ID}',
-        onComplete: function(response) {ldelim}
-                                $("tagfields").innerHTML=response.responseText;
-                                $("txtbox_tagfields").value ='';
-                        {rdelim}
-        {rdelim}
-);
-{rdelim}
-getTagCloud();
-</script>
-
-	</td>
-   </tr>
-</table>
-<script language="javascript">
-  var fieldname = new Array({$VALIDATION_DATA_FIELDNAME});
-  var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL});
-  var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE});
-</script>
-
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
+<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+<div id="convertleaddiv" style="display:block;position:absolute;left:225px;top:150px;"></div>
+<span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
+   <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
+</span>
+<script>
+function tagvalidate()
+{ldelim}
+	if(document.getElementById('txtbox_tagfields').value != '')
+		SaveTag('txtbox_tagfields','{$ID}','{$MODULE}');	
+	else
+	{ldelim}
+		alert("{$APP.PLEASE_ENTER_TAG}");
+		return false;
+	{rdelim}
+{rdelim}
+function DeleteTag(id,recordid)
+{ldelim}
+	$("vtbusy_info").style.display="inline";
+	Effect.Fade('tag_'+id);
+	new Ajax.Request(
+		'index.php',
+                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                        method: 'post',
+                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&recordid="+recordid+"&tagid=" +id,
+                        onComplete: function(response) {ldelim}
+						getTagCloud();
+						$("vtbusy_info").style.display="none";
+                        {rdelim}
+                {rdelim}
+        );
+{rdelim}
+
+</script>
+
+<table width="100%" cellpadding="2" cellspacing="0" border="0">
+   <tr>
+	<td>
+		{include file='Buttons_List1.tpl'}
+
+		<!-- Contents -->
+		<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
+		   <tr>
+			<td valign=top><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+			<td class="showPanelBg" valign=top width=100%>
+			<!-- PUBLIC CONTENTS STARTS-->
+			   <div class="small" style="padding:20px" >
+		
+				<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
+				   <tr>
+					<td>
+						<span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} -  {$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</span>&nbsp;&nbsp;<span id="vtbusy_info" style="display:none;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span><span id="vtbusy_info" style="visibility:hidden;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span>
+					</td>
+					<td>&nbsp;</td>
+				   </tr>
+				   <tr height=20>
+					<td>{$UPDATEINFO}</td>
+				   </tr>
+				</table>
+
+				<hr noshade size=1>
+		
+				<!-- Entity and More information tabs -->
+				<table border=0 cellspacing=0 cellpadding=0 width=95% align=center>
+				   <tr>
+					<td>
+						<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
+						   <tr>
+							<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
+							<td class="dvtSelectedCell" align=center nowrap>{$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</td>	
+							<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+							{if $MODULE eq 'Products'}
+								<td class="dvtUnSelectedCell" align=center nowrap><a href="index.php?action=CallDependencyList&module={$MODULE}&record={$ID}&parenttab={$CATEGORY}">{$APP.LBL_DEPLIST} {$APP.LBL_INFORMATION}</a></td>
+								<td class="dvtTabCache" style="width:10px">&nbsp;</td>
+							{/if}
+							{if $SinglePane_View eq 'false'}
+								<td class="dvtUnSelectedCell" align=center nowrap><a href="index.php?action=CallRelatedList&module={$MODULE}&record={$ID}&parenttab={$CATEGORY}">{$APP.LBL_MORE} {$APP.LBL_INFORMATION}</a></td>
+							{/if}
+							<td class="dvtTabCache" style="width:100%">&nbsp;</td>
+						   </tr>
+						</table>
+					</td>
+				   </tr>
+				   <tr>
+					<td valign=top align=left >
+						<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
+						   <tr>
+
+							<td align=left style="padding:10px;">
+							<!-- content cache -->
+								<!-- Entity informations display - starts -->	
+								<table border=0 cellspacing=0 cellpadding=0 width=100%>
+			                			   <tr>
+									<td style="padding:10px;border-right:1px dashed #CCCCCC;" width="80%">
+
+
+
+<!-- The following table is used to display the buttons -->
+   <form action="index.php" method="post" name="DetailView" id="form">
+					{include file='DetailViewHidden.tpl'}
+<table border=0 cellspacing=0 cellpadding=0 width=100%>
+   {strip}
+   <tr>
+	<td  colspan=4 style="padding:5px">
+		<table border=0 cellspacing=0 cellpadding=0 width=100%>
+                   <tr>
+                        <td>
+				{if $EDIT_DUPLICATE eq 'permitted'}
+				<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="{$APP.LBL_EDIT_BUTTON_LABEL}">&nbsp;
+				{/if}
+			</td>
+			<td align=right>
+				{if $EDIT_DUPLICATE eq 'permitted'}
+				<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
+				{/if}
+				{if $DELETE eq 'permitted'}
+				<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; {if $MODULE eq 'Vendors'} return confirm('{$APP.NTC_VENDOR_DELETE_CONFIRMATION}')" {else} return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" {/if} type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
+				{/if}
+			</td>
+                   </tr>
+                </table>
+		<!-- Commented the buttons in DetailView because these buttons have been given as links
+		{if $MODULE eq 'Quotes' || $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Invoice'}
+			{if $CREATEPDF eq 'permitted'}
+				<input title="Export To PDF" accessKey="Alt+e" class="small" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}'; this.form.module.value='{$MODULE}'; {if $MODULE eq 'SalesOrder'} this.form.action.value='CreateSOPDF'" {else} this.form.action.value='CreatePDF'" {/if} type="submit" name="Export To PDF" value="{$APP.LBL_EXPORT_TO_PDF}">&nbsp;
+			{/if}
+		{/if}
+		{if $MODULE eq 'Quotes'}
+			{if $CONVERTSALESORDER eq 'permitted'}
+				<input title="{$APP.LBL_CONVERTSO_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTSO_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='SalesOrder'; this.form.return_action.value='DetailView'; this.form.convertmode.value='quotetoso';this.form.module.value='SalesOrder'; this.form.action.value='EditView'" type="submit" name="Convert To SalesOrder" value="{$APP.LBL_CONVERTSO_BUTTON_LABEL}">&nbsp;
+			{/if}
+		{/if}
+		{if $MODULE eq 'Potentials' || $MODULE eq 'Quotes' || $MODULE eq 'SalesOrder'}
+			{if $CONVERTINVOICE eq 'permitted'}
+				<input title="{$APP.LBL_CONVERTINVOICE_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTINVOICE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.convertmode.value='{$CONVERTMODE}';this.form.module.value='Invoice'; this.form.action.value='EditView'" type="submit" name="Convert To Invoice" value="{$APP.LBL_CONVERTINVOICE_BUTTON_LABEL}">&nbsp;
+			{/if}
+		{/if}
+		-->
+	</td>
+   </tr>
+   {/strip}
+</table>
+<!-- Button displayed - finished-->
+
+<!-- Entity information(blocks) display - start -->
+{foreach key=header item=detail from=$BLOCKS}
+	<table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
+	   <tr>
+		<td>&nbsp;</td>
+		<td>&nbsp;</td>
+		<td>&nbsp;</td>
+		<td align=right>
+		</td>
+	   </tr>
+	   <tr>
+		{strip}
+		<td colspan=4 class="dvInnerHeader" >
+			<b>
+			       	{$header}
+			</b>
+		</td>
+		{/strip}
+	   </tr>
+
+	   {foreach item=detail from=$detail}
+	   <tr style="height:25px">
+		{foreach key=label item=data from=$detail}
+			{assign var=keyid value=$data.ui}
+			{assign var=keyval value=$data.value}
+			{assign var=keytblname value=$data.tablename}
+			{assign var=keyfldname value=$data.fldname}
+			{assign var=keyoptions value=$data.options}
+			{assign var=keysecid value=$data.secid}
+			{assign var=keyseclink value=$data.link}
+			{assign var=keycursymb value=$data.cursymb}
+			{assign var=keysalut value=$data.salut}
+			{assign var=keycntimage value=$data.cntimage}
+			   {assign var=keyadmin value=$data.isadmin}
+							   
+
+				{if $label ne ''}
+					{if $keycntimage ne ''}
+						<td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$keycntimage}</td>
+					{elseif $label neq 'Tax Class'}<!-- Avoid to display the label Tax Class -->
+						{if $keyid eq '71' || $keyid eq '72'}  <!--CurrencySymbol-->
+							<td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$label} ({$keycursymb})</td>
+						{else}
+							<td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$label}</td>
+						{/if}
+					{/if}  
+					{if $EDIT_PERMISSION eq 'yes'}
+						{include file="DetailViewUI.tpl"}
+					{else}
+						{include file="DetailViewFields.tpl"}
+					{/if}
+				{/if}
+		{/foreach}
+	   </tr>	
+	   {/foreach}	
+	</table>
+{/foreach}
+{*-- End of Blocks--*} 
+<!-- Entity information(blocks) display - ends -->
+
+									<br>
+
+										<!-- Product Details informations -->
+										{$ASSOCIATED_PRODUCTS}
+
+									</td>
+<!-- The following table is used to display the buttons -->
+								<table border=0 cellspacing=0 cellpadding=0 width=100%>
+			                			   <tr>
+									<td style="padding:10px;border-right:1px dashed #CCCCCC;" width="80%">
+			{if $SinglePane_View eq 'false'}
+<table border=0 cellspacing=0 cellpadding=0 width=100%>
+   {strip}
+   <tr>
+	<td  colspan=4 style="padding:5px">
+		<table border=0 cellspacing=0 cellpadding=0 width=100%>
+                   <tr>
+                        <td>
+				{if $EDIT_DUPLICATE eq 'permitted'}
+				<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmbutton small edit" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.module.value='{$MODULE}';this.form.action.value='EditView'" type="submit" name="Edit" value="{$APP.LBL_EDIT_BUTTON_LABEL}">&nbsp;
+				{/if}
+			</td>
+			<td align=right>
+				{if $EDIT_DUPLICATE eq 'permitted'}
+				<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value='true';this.form.module.value='{$MODULE}'; this.form.action.value='EditView'" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}">&nbsp;
+				{/if}
+				{if $DELETE eq 'permitted'}
+				<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="crmbutton small delete" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='index'; this.form.action.value='Delete'; {if $MODULE eq 'Vendors'} return confirm('{$APP.NTC_VENDOR_DELETE_CONFIRMATION}')" {else} return confirm('{$APP.NTC_DELETE_CONFIRMATION}')" {/if} type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">&nbsp;
+				{/if}
+			</td>
+                   </tr>
+                </table>
+
+		<!-- Commented the buttons in DetailView because these buttons have been given as links
+		{if $MODULE eq 'Quotes' || $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Invoice'}
+			{if $CREATEPDF eq 'permitted'}
+				<input title="Export To PDF" accessKey="Alt+e" class="small" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}'; this.form.module.value='{$MODULE}'; {if $MODULE eq 'SalesOrder'} this.form.action.value='CreateSOPDF'" {else} this.form.action.value='CreatePDF'" {/if} type="submit" name="Export To PDF" value="{$APP.LBL_EXPORT_TO_PDF}">&nbsp;
+			{/if}
+		{/if}
+		{if $MODULE eq 'Quotes'}
+			{if $CONVERTSALESORDER eq 'permitted'}
+				<input title="{$APP.LBL_CONVERTSO_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTSO_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='SalesOrder'; this.form.return_action.value='DetailView'; this.form.convertmode.value='quotetoso';this.form.module.value='SalesOrder'; this.form.action.value='EditView'" type="submit" name="Convert To SalesOrder" value="{$APP.LBL_CONVERTSO_BUTTON_LABEL}">&nbsp;
+			{/if}
+		{/if}
+		{if $MODULE eq 'Potentials' || $MODULE eq 'Quotes' || $MODULE eq 'SalesOrder'}
+			{if $CONVERTINVOICE eq 'permitted'}
+				<input title="{$APP.LBL_CONVERTINVOICE_BUTTON_TITLE}" accessKey="{$APP.LBL_CONVERTINVOICE_BUTTON_KEY}" class="crmbutton small create" onclick="this.form.return_module.value='{$MODULE}'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$ID}';this.form.convertmode.value='{$CONVERTMODE}';this.form.module.value='Invoice'; this.form.action.value='EditView'" type="submit" name="Convert To Invoice" value="{$APP.LBL_CONVERTINVOICE_BUTTON_LABEL}">&nbsp;
+			{/if}
+		{/if}
+		-->
+	</td>
+   </tr>
+   {/strip}
+</table>
+{/if}
+</form>
+		<table border=0 cellspacing=0 cellpadding=0 width=100%>
+		  <tr>
+			<td style="border-right:1px dashed #CCCCCC;" width="100%">
+			{if $SinglePane_View eq 'true'}
+				{include file= 'RelatedListNew.tpl'}
+			{/if}
+		</td></tr></table>
+</td></tr></table>
+<!-- Button displayed - finished-->
+									<!-- Inventory Actions - ends -->	
+									<td width=22% valign=top style="padding:10px;">
+										<!-- right side InventoryActions -->
+										{include file="Inventory/InventoryActions.tpl"}
+
+										<br>
+										<!-- To display the Tag Clouds -->
+										<div>
+										      {include file="TagCloudDisplay.tpl"}
+										</div>
+									</td>
+								   </tr>
+								</table>
+							</td>
+						   </tr>
+						</table>
+					<!-- PUBLIC CONTENTS STOPS-->
+					</td>
+					<td align=right valign=top>
+						<img src="{$IMAGE_PATH}showPanelTopRight.gif">
+					</td>
+				   </tr>
+				</table>
+			   </div>
+			</td>
+		   </tr>
+		</table>
+		<!-- Contents - end -->
+
+<script>
+function getTagCloud()
+{ldelim}
+new Ajax.Request(
+        'index.php',
+        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+        method: 'post',
+        postBody: 'module={$MODULE}&action={$MODULE}Ajax&file=TagCloud&ajxaction=GETTAGCLOUD&recordid={$ID}',
+        onComplete: function(response) {ldelim}
+                                $("tagfields").innerHTML=response.responseText;
+                                $("txtbox_tagfields").value ='';
+                        {rdelim}
+        {rdelim}
+);
+{rdelim}
+getTagCloud();
+</script>
+
+	</td>
+   </tr>
+</table>
+<script language="javascript">
+  var fieldname = new Array({$VALIDATION_DATA_FIELDNAME});
+  var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL});
+  var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE});
+</script>
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/InventoryEditView.tpl Mon Apr 16 12:27:44 2007
@@ -1,197 +1,201 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-
-{*<!-- module header -->*}
-
-<link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
-<script type="text/javascript" src="jscalendar/calendar.js"></script>
-<script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
-<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-<script type="text/javascript" src="include/js/Inventory.js"></script>
-<script type="text/javascript">
-
-function sensex_info()
-{ldelim}
-        var Ticker = $('tickersymbol').value;
-        if(Ticker!='')
-        {ldelim}
-                $("vtbusy_info").style.display="inline";
-                new Ajax.Request(
-                      'index.php',
-                      {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-                                method: 'post',
-                                postBody: 'module={$MODULE}&action=Tickerdetail&tickersymbol='+Ticker,
-                                onComplete: function(response) {ldelim}
-                                        $('autocom').innerHTML = response.responseText;
-                                        $('autocom').style.display="block";
-                                        $("vtbusy_info").style.display="none";
-                                {rdelim}
-                        {rdelim}
-                );
-        {rdelim}
-{rdelim}
-
-</script>
-
-		{include file='Buttons_List1.tpl'}	
-
-{*<!-- Contents -->*}
-<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
-   <tr>
-	<td valign=top><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-
-	<td class="showPanelBg" valign=top width=100%>
-		{*<!-- PUBLIC CONTENTS STARTS-->*}
-		<div class="small" style="padding:20px">
-		
-			{if $OP_MODE eq 'edit_view'}   
-				<span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} - {$APP.LBL_EDITING} {$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</span> <br>
-				{$UPDATEINFO}	 
-			{/if}
-			{if $OP_MODE eq 'create_view'}
-				<span class="lvtHeaderText">{$APP.LBL_CREATING} {$MOD[$SINGLE_MOD]}</span> <br>
-			{/if}
-
-			<hr noshade size=1>
-			<br> 
-		
-			{include file='EditViewHidden.tpl'}
-
-			{*<!-- Account details tabs -->*}
-			<table border=0 cellspacing=0 cellpadding=0 width=95% align=center>
-			   <tr>
-				<td>
-					<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
-					   <tr>
-						<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
-                                        	<td class="dvtSelectedCell" align=center nowrap>{$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</td>
-	                                        <td class="dvtTabCache" style="width:10px">&nbsp;</td>
-                	                        <td class="dvtTabCache" style="width:100%">&nbsp;</td>
-					   </tr>
-					</table>
-				</td>
-			   </tr>
-			   <tr>
-				<td valign=top align=left >
-					<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
-					   <tr>
-
-						<td align=left style="padding:10px;border-right:1px dashed #CCCCCC;" width=80%>
-							{*<!-- content cache -->*}
-					
-							<table border=0 cellspacing=0 cellpadding=0 width=100%>
-							   <tr>
-								<td id ="autocom"></td>
-							   </tr>
-							   <tr>
-								<td style="padding:10px">
-								<!-- General details -->
-									<table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
-									   <tr>
-										<td  colspan=4 style="padding:5px">
-										   <div align="center">
-											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted(); return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-											<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
-										   </div>
-										</td>
-									   </tr>
-
-									   <!-- included to handle the edit fields based on ui types -->
-									   {foreach key=header item=data from=$BLOCKS}
-									      <tr>
-										{if $header== $MOD.LBL_ADDRESS_INFORMATION && ($MODULE == 'Accounts' || $MODULE == 'Contacts' || $MODULE == 'Quotes' || $MODULE == 'PurchaseOrder' || $MODULE == 'SalesOrder'|| $MODULE == 'Invoice')}
-                                                                        	<td colspan=2 class="detailedViewHeader">
-	                                                                        <b>{$header}</b></td>
-        	                                                                <td class="detailedViewHeader">
-                	                                                        <input name="cpy" onclick="return copyAddressLeft(EditView)" type="radio"><b>{$APP.LBL_RCPY_ADDRESS}</b></td>
-                        	                                                <td class="detailedViewHeader">
-                                	                                        <input name="cpy" onclick="return copyAddressRight(EditView)" type="radio"><b>{$APP.LBL_LCPY_ADDRESS}</b></td>
-                                        	                                {else}
-										<td colspan=4 class="detailedViewHeader">
-											<b>{$header}</b>
-										{/if}
-										</td>
-									      </tr>
-
-										<!-- Handle the ui types display -->
-										{include file="DisplayFields.tpl"}
-
-									      <tr style="height:25px"><td>&nbsp;</td></tr>
-
-									   {/foreach}
-
-
-									   <!-- Added to display the Product Details in Inventory-->
-									   {if $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Invoice'}
-									   <tr>
-										<td colspan=4>
-											{include file="Inventory/ProductDetailsEditView.tpl"}
-										</td>
-									   </tr>
-									   {/if}
-
-									   <tr>
-										<td  colspan=4 style="padding:5px">
-											<div align="center">
-												<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  displaydeleted();return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-												<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
-											</div>
-										</td>
-									   </tr>
-									</table>
-								</td>
-							   </tr>
-							</table>
-						</td>
-						<!-- Inventory Actions - ends -->
-						<td width=20% valign=top style="padding:10px;">
-							<!-- right side InventoryActions -->
-							{include file="Inventory/InventoryActions.tpl"}
-						</td>
-					   </tr>
-					</table>
-				</td>
-			   </tr>
-			</table>
-		</div>
-	</td>
-   </tr>
-</table>
-</form>
-
-<!-- This div is added to get the left and top values to show the tax details-->
-<div id="tax_container" style="display:none; position:absolute; z-index:1px;"></div>
-
-<script>	
-        var fieldname = new Array({$VALIDATION_DATA_FIELDNAME})
-
-        var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL})
-
-        var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE})
-
-	var ProductImages=new Array();
-	var count=0;
-	function delRowEmt(imagename)
-	{ldelim}
-		ProductImages[count++]=imagename;
-		multi_selector.current_element.disabled = false;
-		multi_selector.count--;
-	{rdelim}
-	function displaydeleted()
-	{ldelim}
-		if(ProductImages.length > 0)
-			document.EditView.del_file_list.value=ProductImages.join('###');
-	{rdelim}
-</script>
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+
+{*<!-- module header -->*}
+
+<link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
+<script type="text/javascript" src="jscalendar/calendar.js"></script>
+<script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
+<script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
+<script type="text/javascript" src="include/js/Inventory.js"></script>
+<script type="text/javascript">
+
+function sensex_info()
+{ldelim}
+        var Ticker = $('tickersymbol').value;
+        if(Ticker!='')
+        {ldelim}
+                $("vtbusy_info").style.display="inline";
+                new Ajax.Request(
+                      'index.php',
+                      {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                                method: 'post',
+                                postBody: 'module={$MODULE}&action=Tickerdetail&tickersymbol='+Ticker,
+                                onComplete: function(response) {ldelim}
+                                        $('autocom').innerHTML = response.responseText;
+                                        $('autocom').style.display="block";
+                                        $("vtbusy_info").style.display="none";
+                                {rdelim}
+                        {rdelim}
+                );
+        {rdelim}
+{rdelim}
+
+</script>
+
+		{include file='Buttons_List1.tpl'}	
+
+{*<!-- Contents -->*}
+<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
+   <tr>
+	<td valign=top><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+
+	<td class="showPanelBg" valign=top width=100%>
+		{*<!-- PUBLIC CONTENTS STARTS-->*}
+		<div class="small" style="padding:20px">
+		
+			{if $OP_MODE eq 'edit_view'}   
+				<span class="lvtHeaderText"><font color="purple">[ {$ID} ] </font>{$NAME} - {$APP.LBL_EDITING} {$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</span> <br>
+				{$UPDATEINFO}	 
+			{/if}
+			{if $OP_MODE eq 'create_view'}
+				<span class="lvtHeaderText">{$APP.LBL_CREATING} {$MOD[$SINGLE_MOD]}</span> <br>
+			{/if}
+
+			<hr noshade size=1>
+			<br> 
+		
+			{include file='EditViewHidden.tpl'}
+
+			{*<!-- Account details tabs -->*}
+			<table border=0 cellspacing=0 cellpadding=0 width=95% align=center>
+			   <tr>
+				<td>
+					<table border=0 cellspacing=0 cellpadding=3 width=100% class="small">
+					   <tr>
+						<td class="dvtTabCache" style="width:10px" nowrap>&nbsp;</td>
+                                        	<td class="dvtSelectedCell" align=center nowrap>{$MOD[$SINGLE_MOD]} {$APP.LBL_INFORMATION}</td>
+	                                        <td class="dvtTabCache" style="width:10px">&nbsp;</td>
+                	                        <td class="dvtTabCache" style="width:100%">&nbsp;</td>
+					   </tr>
+					</table>
+				</td>
+			   </tr>
+			   <tr>
+				<td valign=top align=left >
+					<table border=0 cellspacing=0 cellpadding=3 width=100% class="dvtContentSpace">
+					   <tr>
+
+						<td align=left style="padding:10px;border-right:1px #CCCCCC;" width=80%>
+							{*<!-- content cache -->*}
+					
+							<table border=0 cellspacing=0 cellpadding=0 width=100%>
+							   <tr>
+								<td id ="autocom"></td>
+							   </tr>
+							   <tr>
+								<td style="padding:10px">
+								<!-- General details -->
+									<table border=0 cellspacing=0 cellpadding=0 width=100% class="small">
+									   <tr>
+										<td  colspan=4 style="padding:5px">
+										   <div align="center">
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted(); return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+											<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+										   </div>
+										</td>
+									   </tr>
+
+									   <!-- included to handle the edit fields based on ui types -->
+									   {foreach key=header item=data from=$BLOCKS}
+									      <tr>
+										{if $header== $MOD.LBL_ADDRESS_INFORMATION && ($MODULE == 'Accounts' || $MODULE == 'Contacts' || $MODULE == 'Quotes' || $MODULE == 'PurchaseOrder' || $MODULE == 'SalesOrder'|| $MODULE == 'Invoice')}
+                                                                        	<td colspan=2 class="detailedViewHeader">
+	                                                                        <b>{$header}</b></td>
+        	                                                                <td class="detailedViewHeader">
+                	                                                        <input name="cpy" onclick="return copyAddressLeft(EditView)" type="radio"><b>{$APP.LBL_RCPY_ADDRESS}</b></td>
+                        	                                                <td class="detailedViewHeader">
+                                	                                        <input name="cpy" onclick="return copyAddressRight(EditView)" type="radio"><b>{$APP.LBL_LCPY_ADDRESS}</b></td>
+                                        	                                {else}
+										<td colspan=4 class="detailedViewHeader">
+											<b>{$header}</b>
+										{/if}
+										</td>
+									      </tr>
+
+										<!-- Handle the ui types display -->
+										{include file="DisplayFields.tpl"}
+
+									      <tr style="height:25px"><td>&nbsp;</td></tr>
+
+									   {/foreach}
+
+
+									   <!-- Added to display the Product Details in Inventory-->
+									   {if $MODULE eq 'PurchaseOrder' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Invoice'}
+									   <tr>
+										<td colspan=4>
+											{include file="Inventory/ProductDetailsEditView.tpl"}
+										</td>
+									   </tr>
+									   {/if}
+
+									   <tr>
+										<td  colspan=4 style="padding:5px">
+											<div align="center">
+												<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  displaydeleted();return validateInventory('{$MODULE}')" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+												<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+											</div>
+										</td>
+									   </tr>
+									</table>
+								</td>
+							   </tr>
+							</table>
+						</td>
+						<!-- Inventory Actions - ends -->
+					   </tr>
+					</table>
+				</td>
+			   </tr>
+			</table>
+		</div>
+	</td>
+   </tr>
+</table>
+</form>
+
+<!-- This div is added to get the left and top values to show the tax details-->
+<div id="tax_container" style="display:none; position:absolute; z-index:1px;"></div>
+
+<script>	
+        var fieldname = new Array({$VALIDATION_DATA_FIELDNAME})
+
+        var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL})
+
+        var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE})
+
+	var product_labelarr = {ldelim}CLEAR_COMMENT:'{$APP.LBL_CLEAR_COMMENT}',
+				DISCOUNT:'{$APP.LBL_DISCOUNT}',
+				TOTAL_AFTER_DISCOUNT:'{$APP.LBL_TOTAL_AFTER_DISCOUNT}',
+				TAX:'{$APP.LBL_TAX}',
+				ZERO_DISCOUNT:'{$APP.LBL_ZERO_DISCOUNT}',
+				PERCENT_OF_PRICE:'{$APP.LBL_OF_PRICE}',
+				DIRECT_PRICE_REDUCTION:'{$APP.LBL_DIRECT_PRICE_REDUCTION}'{rdelim};
+
+	var ProductImages=new Array();
+	var count=0;
+	function delRowEmt(imagename)
+	{ldelim}
+		ProductImages[count++]=imagename;
+		multi_selector.current_element.disabled = false;
+		multi_selector.count--;
+	{rdelim}
+	function displaydeleted()
+	{ldelim}
+		if(ProductImages.length > 0)
+			document.EditView.del_file_list.value=ProductImages.join('###');
+	{rdelim}
+</script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetails.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetails.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetails.tpl Mon Apr 16 12:27:44 2007
@@ -28,7 +28,7 @@
 		var curr_productid = document.getElementById("hdnProductId"+curr_row).value;
 		if(curr_productid == '')
 		{ldelim}
-			alert("Please select a Product");
+			alert("{$APP.PLEASE_SELECT_PRODUCT}");
 			return false;
 		{rdelim}
 	{rdelim}
@@ -36,24 +36,24 @@
 	//Set the Header value for Discount
 	if(mode == 'discount')
 	{ldelim}
-		document.getElementById("discount_div_title"+curr_row).innerHTML = '<b>Set Discount for : '+document.getElementById("productTotal"+curr_row).innerHTML+'</b>';
+		document.getElementById("discount_div_title"+curr_row).innerHTML = '<b>{$APP.LABEL_SET_DISCOUNT_FOR_COLON} '+document.getElementById("productTotal"+curr_row).innerHTML+'</b>';
 	{rdelim}
 	else if(mode == 'tax')
 	{ldelim}
-		document.getElementById("tax_div_title"+curr_row).innerHTML = "<b>Set Tax for "+document.getElementById("totalAfterDiscount"+curr_row).innerHTML+'</b>';
+		document.getElementById("tax_div_title"+curr_row).innerHTML = "<b>{$APP.LABEL_SET_TAX_FOR} "+document.getElementById("totalAfterDiscount"+curr_row).innerHTML+'</b>';
 	{rdelim}
 	else if(mode == 'discount_final')
 	{ldelim}
-		document.getElementById("discount_div_title_final").innerHTML = '<b>Set Discount for : '+document.getElementById("netTotal").innerHTML+'</b>';
+		document.getElementById("discount_div_title_final").innerHTML = '<b>{$APP.LABEL_SET_DISCOUNT_FOR} '+document.getElementById("netTotal").innerHTML+'</b>';
 	{rdelim}
 	else if(mode == 'sh_tax_div_title')
 	{ldelim}
-		document.getElementById("sh_tax_div_title").innerHTML = '<b>Set S&H Tax for : '+document.getElementById("shipping_handling_charge").value+'</b>';
+		document.getElementById("sh_tax_div_title").innerHTML = '<b>{$APP.LABEL_SET_SH_TAX_FOR_COLON} '+document.getElementById("shipping_handling_charge").value+'</b>';
 	{rdelim}
 	else if(mode == 'group_tax_div_title')
 	{ldelim}
 		var net_total_after_discount = eval(document.getElementById("netTotal").innerHTML)-eval(document.getElementById("discountTotal_final").innerHTML);
-		document.getElementById("group_tax_div_title").innerHTML = '<b>Set Group Tax for : '+net_total_after_discount+'</b>';
+		document.getElementById("group_tax_div_title").innerHTML = '<b>{$APP.LABEL_SET_GROUP_TAX_FOR_COLON} '+net_total_after_discount+'</b>';
 	{rdelim}
 
 	fnvshobj(currObj,'tax_container');
@@ -170,7 +170,7 @@
 
 	<!-- column 4 - Quantity - starts -->
 	<td class="crmTableRow small lineOnTop">
-		<input id="qty1" name="qty1" type="text" class="small " style="width:50px" onfocus="this.className='detailedViewTextBoxOn'" onBlur="FindDuplicate(); settotalnoofrows(); calcTotal(); loadTaxes_Ajax(1);" value=""/>
+		<input id="qty1" name="qty1" type="text" class="small " style="width:50px" onfocus="this.className='detailedViewTextBoxOn'" onBlur="settotalnoofrows(); calcTotal(); loadTaxes_Ajax(1);" onChange="setDiscount(this,'1')" value=""/>
 	</td>
 	<!-- column 4 - Quantity - ends -->
 
@@ -180,7 +180,7 @@
 		<table width="100%" cellpadding="0" cellspacing="0">
 		   <tr>
 			<td align="right">
-				<input id="listPrice1" name="listPrice1" value="{$UNIT_PRICE}" type="text" class="small " style="width:70px" onBlur="calcTotal(); callTaxCalc(1);"/>&nbsp;<img src="{$IMAGE_PATH}pricebook.gif" onclick="priceBookPickList(this,1)">
+				<input id="listPrice1" name="listPrice1" value="{$UNIT_PRICE}" type="text" class="small " style="width:70px" onBlur="calcTotal(); callTaxCalc(1);" onChange="setDiscount(this,'1')"/>&nbsp;<img src="{$IMAGE_PATH}pricebook.gif" onclick="priceBookPickList(this,1)">
 			</td>
 		   </tr>
 		   <tr>
@@ -199,7 +199,7 @@
 					   </tr>
 					   <tr>
 						<td align="left"><input type="radio" name="discount1" onclick="setDiscount(this,1); callTaxCalc(1);">&nbsp; % {$APP.LBL_OF_PRICE}</td>
-						<td align="right"><input type="text" class="small" size="2" id="discount_percentage1" name="discount_percentage1" value="0" style="visibility:hidden" onBlur="setDiscount(this,1); callTaxCalc(1);">&nbsp;%</td>
+						<td align="right"><input type="text" class="small" size="5" id="discount_percentage1" name="discount_percentage1" value="0" style="visibility:hidden" onBlur="setDiscount(this,1); callTaxCalc(1);">&nbsp;%</td>
 					   </tr>
 					   <tr>
 						<td align="left" nowrap><input type="radio" name="discount1" onclick="setDiscount(this,1); callTaxCalc(1);">&nbsp;{$APP.LBL_DIRECT_PRICE_REDUCTION}</td>
@@ -299,7 +299,7 @@
 			   </tr>
 			   <tr>
 				<td align="left"><input type="radio" name="discount_final" onclick="setDiscount(this,'_final'); calcGroupTax();">&nbsp; % {$APP.LBL_OF_PRICE}</td>
-				<td align="right"><input type="text" class="small" size="2" id="discount_percentage_final" name="discount_percentage_final" value="0" style="visibility:hidden" onBlur="setDiscount(this,'_final'); calcGroupTax();">&nbsp;%</td>
+				<td align="right"><input type="text" class="small" size="5" id="discount_percentage_final" name="discount_percentage_final" value="0" style="visibility:hidden" onBlur="setDiscount(this,'_final'); calcGroupTax();">&nbsp;%</td>
 			   </tr>
 			   <tr>
 				<td align="left" nowrap><input type="radio" name="discount_final" onclick="setDiscount(this,'_final'); calcGroupTax();">&nbsp;{$APP.LBL_DIRECT_PRICE_REDUCTION}</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetailsEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetailsEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Inventory/ProductDetailsEditView.tpl Mon Apr 16 12:27:44 2007
@@ -29,7 +29,7 @@
 		var curr_productid = document.getElementById("hdnProductId"+curr_row).value;
 		if(curr_productid == '')
 		{ldelim}
-			alert("Please select a Product");
+			alert("{$APP.PLEASE_SELECT_PRODUCT}");
 			return false;
 		{rdelim}
 	{rdelim}
@@ -37,24 +37,24 @@
 	//Set the Header value for Discount
 	if(mode == 'discount')
 	{ldelim}
-		document.getElementById("discount_div_title"+curr_row).innerHTML = '<b>Set Discount for : '+document.getElementById("productTotal"+curr_row).innerHTML+'</b>';
+		document.getElementById("discount_div_title"+curr_row).innerHTML = '<b>{$APP.LABEL_SET_DISCOUNT_FOR_X_COLON} '+document.getElementById("productTotal"+curr_row).innerHTML+'</b>';
 	{rdelim}
 	else if(mode == 'tax')
 	{ldelim}
-		document.getElementById("tax_div_title"+curr_row).innerHTML = "<b>Set Tax for "+document.getElementById("totalAfterDiscount"+curr_row).innerHTML+'</b>';
+		document.getElementById("tax_div_title"+curr_row).innerHTML = "<b>{$APP.LABEL_SET_TAX_FOR} "+document.getElementById("totalAfterDiscount"+curr_row).innerHTML+'</b>';
 	{rdelim}
 	else if(mode == 'discount_final')
 	{ldelim}
-		document.getElementById("discount_div_title_final").innerHTML = '<b>Set Discount for : '+document.getElementById("netTotal").innerHTML+'</b>';
+		document.getElementById("discount_div_title_final").innerHTML = '<b>{$APP.LABEL_SET_DISCOUNT_FOR_COLON} '+document.getElementById("netTotal").innerHTML+'</b>';
 	{rdelim}
 	else if(mode == 'sh_tax_div_title')
 	{ldelim}
-		document.getElementById("sh_tax_div_title").innerHTML = '<b>Set S&H Tax for : '+document.getElementById("shipping_handling_charge").value+'</b>';
+		document.getElementById("sh_tax_div_title").innerHTML = '<b>{$APP.LABEL_SET_SH_TAX_FOR_COLON} '+document.getElementById("shipping_handling_charge").value+'</b>';
 	{rdelim}
 	else if(mode == 'group_tax_div_title')
 	{ldelim}
 		var net_total_after_discount = eval(document.getElementById("netTotal").innerHTML)-eval(document.getElementById("discountTotal_final").innerHTML);
-		document.getElementById("group_tax_div_title").innerHTML = '<b>Set Group Tax for : '+net_total_after_discount+'</b>';
+		document.getElementById("group_tax_div_title").innerHTML = '<b>{$APP.LABEL_SET_GROUP_TAX_FOR_COLON} '+net_total_after_discount+'</b>';
 	{rdelim}
 
 	fnvshobj(currObj,'tax_container');
@@ -132,6 +132,7 @@
 	{assign var="hdnProductId" value="hdnProductId"|cat:$row_no}
 	{assign var="productName" value="productName"|cat:$row_no}
 	{assign var="comment" value="comment"|cat:$row_no}
+	{assign var="productDescription" value="productDescription"|cat:$row_no}
 	{assign var="qtyInStock" value="qtyInStock"|cat:$row_no}
 	{assign var="qty" value="qty"|cat:$row_no}
 	{assign var="listPrice" value="listPrice"|cat:$row_no}
@@ -169,6 +170,7 @@
 			<td class="small" valign="top">
 				<input type="text" id="{$productName}" name="{$productName}" value="{$data.$productName}" class="small" readonly />
 				<input type="hidden" id="{$hdnProductId}" name="{$hdnProductId}" value="{$data.$hdnProductId}">
+				<input type="hidden" id="{$productDescription}" name="{$productDescription}" value="{$data.$productDescription}">
 				<img src="{$IMAGE_PATH}search.gif" style="cursor: pointer;" align="absmiddle" onclick="productPickList(this,'{$MODULE}','{$row_no}')" />
 			</td>
 		   </tr>
@@ -192,7 +194,7 @@
 
 	<!-- column 4 - Quantity - starts -->
 	<td class="crmTableRow small lineOnTop" valign="top">
-		<input id="{$qty}" name="{$qty}" type="text" class="small " style="width:50px" onfocus="this.className='detailedViewTextBoxOn'" onBlur="FindDuplicate(); settotalnoofrows(); calcTotal(); loadTaxes_Ajax('{$row_no}');" value="{$data.$qty}"/>
+		<input id="{$qty}" name="{$qty}" type="text" class="small " style="width:50px" onfocus="this.className='detailedViewTextBoxOn'" onBlur="settotalnoofrows(); calcTotal(); loadTaxes_Ajax('{$row_no}');" onChange="setDiscount(this,'{$row_no}')" value="{$data.$qty}"/>
 	</td>
 	<!-- column 4 - Quantity - ends -->
 
@@ -201,7 +203,7 @@
 		<table width="100%" cellpadding="0" cellspacing="0">
 		   <tr>
 			<td align="right">
-				<input id="{$listPrice}" name="{$listPrice}" value="{$data.$listPrice}" type="text" class="small " style="width:70px" onBlur="calcTotal(); callTaxCalc('{$row_no}');"/>&nbsp;<img src="{$IMAGE_PATH}pricebook.gif" onclick="priceBookPickList(this,'{$row_no}')">
+				<input id="{$listPrice}" name="{$listPrice}" value="{$data.$listPrice}" type="text" class="small " style="width:70px" onBlur="calcTotal(); callTaxCalc('{$row_no}');" onChange="setDiscount(this,'{$row_no}')"/>&nbsp;<img src="{$IMAGE_PATH}pricebook.gif" onclick="priceBookPickList(this,'{$row_no}')">
 			</td>
 		   </tr>
 		   <tr>
@@ -220,7 +222,7 @@
 					   </tr>
 					   <tr>
 						<td align="left"><input type="radio" name="discount{$row_no}" onclick="setDiscount(this,'{$row_no}'); callTaxCalc('{$row_no}');" {$data.$checked_discount_percent}>&nbsp; % {$APP.LBL_OF_PRICE}</td>
-						<td align="right"><input type="text" class="small" size="2" id="discount_percentage{$row_no}" name="discount_percentage{$row_no}" value="{$data.$discount_percent}" {$data.$style_discount_percent} onBlur="setDiscount(this,'{$row_no}'); callTaxCalc('{$row_no}');">&nbsp;%</td>
+						<td align="right"><input type="text" class="small" size="5" id="discount_percentage{$row_no}" name="discount_percentage{$row_no}" value="{$data.$discount_percent}" {$data.$style_discount_percent} onBlur="setDiscount(this,'{$row_no}'); callTaxCalc('{$row_no}');">&nbsp;%</td>
 					   </tr>
 					   <tr>
 						<td align="left" nowrap><input type="radio" name="discount{$row_no}" onclick="setDiscount(this,'{$row_no}'); callTaxCalc('{$row_no}');" {$data.$checked_discount_amount}>&nbsp;{$APP.LBL_DIRECT_PRICE_REDUCTION}</td>
@@ -350,7 +352,7 @@
 			   </tr>
 			   <tr>
 				<td align="left"><input type="radio" name="discount_final" onclick="setDiscount(this,'_final'); calcGroupTax();" {$FINAL.checked_discount_percentage_final}>&nbsp; % {$APP.LBL_OF_PRICE}</td>
-				<td align="right"><input type="text" class="small" size="2" id="discount_percentage_final" name="discount_percentage_final" value="{$FINAL.discount_percentage_final}" {$FINAL.style_discount_percentage_final} onBlur="setDiscount(this,'_final'); calcGroupTax();">&nbsp;%</td>
+				<td align="right"><input type="text" class="small" size="5" id="discount_percentage_final" name="discount_percentage_final" value="{$FINAL.discount_percentage_final}" {$FINAL.style_discount_percentage_final} onBlur="setDiscount(this,'_final'); calcGroupTax();">&nbsp;%</td>
 			   </tr>
 			   <tr>
 				<td align="left" nowrap><input type="radio" name="discount_final" onclick="setDiscount(this,'_final'); calcGroupTax();" {$FINAL.checked_discount_amount_final}>&nbsp;{$APP.LBL_DIRECT_PRICE_REDUCTION}</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListEmailTemplates.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListEmailTemplates.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListEmailTemplates.tpl Mon Apr 16 12:27:44 2007
@@ -1,192 +1,191 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<script>
-function ifselected()
-{ldelim}
-  
-      
-      var sel =document.massdelete.selected_id.length;
-      var returnval=false;
-      
-     for(i=0; i < sel; i++)
-     {ldelim}
-     
-      if(document.massdelete.selected_id[i].checked == true)
-        {ldelim}
-            returnval=true;
-            break;
-        {rdelim}
-        
-      {rdelim}
-      
-      
-          if(returnval==true)
-           {ldelim}
-               document.getElementById("myProfile").style.display="none";
-           {rdelim}
-          else
-           {ldelim}
-              document.getElementById("myProfile").style.display="block";
-          {rdelim}
-    	
-{rdelim}
-
-
-function massDelete()
-{ldelim}
-        
-        x = document.massdelete.selected_id.length;
-        idstring = "";
-
-        if ( x == undefined)
-        {ldelim}
-
-                if (document.massdelete.selected_id.checked)
-               {ldelim}
-                        document.massdelete.idlist.value=document.massdelete.selected_id.value+';';
-                          
-                        
-			xx=1;
-                {rdelim}
-                else
-                {ldelim}
-                         document.massdelete.profile.style.display="none";
-                        alert("Please select at least one entity");
-                        
-                        return false;
-                {rdelim}
-        {rdelim}
-        else
-        {ldelim}
-                xx = 0;
-                for(i = 0; i < x ; i++)
-                {ldelim}
-                        if(document.massdelete.selected_id[i].checked)
-                        {ldelim}
-                                idstring = document.massdelete.selected_id[i].value +";"+idstring
-                        xx++
-                        {rdelim}
-                {rdelim}
-                if (xx != 0)
-                {ldelim}
-                        document.massdelete.idlist.value=idstring;
-                {rdelim}
-               else
-                {ldelim}
-                        alert("Please select at least one entity");
-                        return false;
-                {rdelim}
-       {rdelim}
-		if(confirm("Are you sure you want to delete the selected "+xx+" records ?"))
-		{ldelim}
-	        document.massdelete.action="index.php?module=Users&action=deleteemailtemplate&return_module=Users&return_action=listemailtemplates";
-		{rdelim}
-		else
-		{ldelim}
-			return false;
-		{rdelim}
-
-{rdelim}
-</script>
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-<br>
-	<div align=center>
-	
-			{include file='SetMenu.tpl'}
-
-				<!-- DISPLAY -->
-				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-				<form  name="massdelete" method="POST">
-	    			<input name="idlist" type="hidden">
-    				<input name="module" type="hidden" value="Users">
-    				<input name="action" type="hidden" value="deleteemailtemplate">
-				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ViewTemplate.gif" width="45" height="60" border=0></td>
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$UMOD.LBL_EMAIL_TEMPLATES} </b></td>
-				</tr>
-				<tr>
-					<td valign=top class="small">{$UMOD.LBL_EMAIL_TEMPLATE_DESC}</td>
-				</tr>
-				</table>
-				
-				<br>
-				<table border=0 cellspacing=0 cellpadding=10 width=100% >
-				<tr>
-				<td>
-				
-					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-					<tr>
-						<td class="big"><strong>{$UMOD.LBL_EMAIL_TEMPLATES}</strong></td>
-						<td class="small" align=right>&nbsp;
-						</td>
-					</tr>
-					</table>
-					
-					<table border=0 cellspacing=0 cellpadding=5 width=100% class="listTableTopButtons">
-					<tr>
-						<td class=small><input type="submit" value="{$UMOD.LBL_DELETE}" onclick="return massDelete();" class="crmButton delete small"></td>
-						<td class=small align=right id="new_template"><div id = "myProfile"><input class="crmButton create small" type="submit" value="{$UMOD.LBL_NEW_TEMPLATE}" name="profile"  class="classBtn" onclick="this.form.action.value='createemailtemplate';this.form.parenttab.value='Settings';"></div></td>
-					</tr>
-					</table>
-					<table border="0" cellspacing="0" cellpadding="5" width="100%" class="listTable">
-					<tr>
-						<td width="2%" class="colHeader small">#</td>
-						<td width="3%" class="colHeader small">{$UMOD.LBL_LIST_SELECT}</td>
-						<td width="25%" class="colHeader small">{$UMOD.LBL_EMAIL_TEMPLATE}</td>
-						<td width="50%" class="colHeader small">{$UMOD.LBL_DESCRIPTION}</td>
-					        <td width="20%" class="colHeader small">{$UMOD.LBL_TEMPLATE_TOOLS}</td>
-					</tr>
-					{foreach name=emailtemplate item=template from=$TEMPLATES}
-					<tr>
-						<td class="listTableRow small" valign=top>{$smarty.foreach.emailtemplate.iteration}</td>
-						<td class="listTableRow small" valign=top><input type="checkbox" name="selected_id" value="{$template.templateid}" onClick="ifselected(); " class=small></td>
-						<td class="listTableRow small" valign=top>
-							<a href="index.php?module=Users&action=detailviewemailtemplate&parenttab=Settings&templateid={$template.templateid}" ><b>{$template.templatename}</b></a>
-						</td>
-						<td class="listTableRow small" valign=top>{$template.description}&nbsp;</td>
-					        <td class="listTableRow small" valign=top>
-							<a href="index.php?module=Users&action=detailviewemailtemplate&parenttab=Settings&templateid={$template.templateid}">{$UMOD.LNK_SAMPLE_EMAIL}</a>
-						</td>
-					</tr>
-					{/foreach}	
-					</table>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr>
-					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
-					</tr>
-					</table>
-				</td>
-				</tr>
-				</table>
-			
-			
-			
-			</td>
-			</tr>
-			</table>
-		</td>
-	</tr>
-	</form>
-	</table>
-		
-	</div>
-</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody>
-</table>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<script>
+function ifselected()
+{ldelim}
+  
+      
+      var sel =document.massdelete.selected_id.length;
+      var returnval=false;
+      
+     for(i=0; i < sel; i++)
+     {ldelim}
+     
+      if(document.massdelete.selected_id[i].checked == true)
+        {ldelim}
+            returnval=true;
+            break;
+        {rdelim}
+        
+      {rdelim}
+      
+      
+          if(returnval==true)
+           {ldelim}
+               document.getElementById("myProfile").style.display="none";
+           {rdelim}
+          else
+           {ldelim}
+              document.getElementById("myProfile").style.display="block";
+          {rdelim}
+    	
+{rdelim}
+
+
+function massDelete()
+{ldelim}
+        
+        x = document.massdelete.selected_id.length;
+        idstring = "";
+
+        if ( x == undefined)
+        {ldelim}
+
+                if (document.massdelete.selected_id.checked)
+               {ldelim}
+                        document.massdelete.idlist.value=document.massdelete.selected_id.value+';';
+                          
+                        
+			xx=1;
+                {rdelim}
+                else
+                {ldelim}
+                         document.massdelete.profile.style.display="none";
+                        alert("{$APP.SELECT_ATLEAST_ONE}");
+                        return false;
+                {rdelim}
+        {rdelim}
+        else
+        {ldelim}
+                xx = 0;
+                for(i = 0; i < x ; i++)
+                {ldelim}
+                        if(document.massdelete.selected_id[i].checked)
+                        {ldelim}
+                                idstring = document.massdelete.selected_id[i].value +";"+idstring
+                        xx++
+                        {rdelim}
+                {rdelim}
+                if (xx != 0)
+                {ldelim}
+                        document.massdelete.idlist.value=idstring;
+                {rdelim}
+               else
+                {ldelim}
+                        alert("{$APP.SELECT_ATLEAST_ONE}");
+                        return false;
+                {rdelim}
+       {rdelim}
+		if(confirm("{$APP.DELETE_CONFIRMATION}"+xx+"{$APP.RECORDS}"))
+		{ldelim}
+	        document.massdelete.action="index.php?module=Settings&action=deleteemailtemplate&return_module=Settings&return_action=listemailtemplates";
+		{rdelim}
+		else
+		{ldelim}
+			return false;
+		{rdelim}
+
+{rdelim}
+</script>
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+<br>
+	<div align=center>
+	
+			{include file='SetMenu.tpl'}
+
+				<!-- DISPLAY -->
+				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
+				<form  name="massdelete" method="POST">
+	    			<input name="idlist" type="hidden">
+    				<input name="module" type="hidden" value="Settings">
+    				<input name="action" type="hidden" value="deleteemailtemplate">
+				<tr>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ViewTemplate.gif" border=0></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$UMOD.LBL_EMAIL_TEMPLATES} </b></td>
+				</tr>
+				<tr>
+					<td valign=top class="small">{$UMOD.LBL_EMAIL_TEMPLATE_DESC}</td>
+				</tr>
+				</table>
+				
+				<br>
+				<table border=0 cellspacing=0 cellpadding=10 width=100% >
+				<tr>
+				<td>
+				
+					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+					<tr>
+						<td class="big"><strong>{$UMOD.LBL_EMAIL_TEMPLATES}</strong></td>
+						<td class="small" align=right>&nbsp;
+						</td>
+					</tr>
+					</table>
+					
+					<table border=0 cellspacing=0 cellpadding=5 width=100% class="listTableTopButtons">
+					<tr>
+						<td class=small><input type="submit" value="{$UMOD.LBL_DELETE}" onclick="return massDelete();" class="crmButton delete small"></td>
+						<td class=small align=right id="new_template"><div id = "myProfile"><input class="crmButton create small" type="submit" value="{$UMOD.LBL_NEW_TEMPLATE}" name="profile"  class="classBtn" onclick="this.form.action.value='createemailtemplate';this.form.parenttab.value='Settings';"></div></td>
+					</tr>
+					</table>
+					<table border="0" cellspacing="0" cellpadding="5" width="100%" class="listTable">
+					<tr>
+						<td width="5%" class="colHeader small">#</td>
+						<td width="5%" class="colHeader small">{$UMOD.LBL_LIST_SELECT}</td>
+						<td width="30%" class="colHeader small">{$UMOD.LBL_EMAIL_TEMPLATE}</td>
+						<td width="60%" class="colHeader small">{$UMOD.LBL_DESCRIPTION}</td>
+					        <!--<td width="20%" class="colHeader small">{$UMOD.LBL_TEMPLATE_TOOLS}</td>-->
+					</tr>
+					{foreach name=emailtemplate item=template from=$TEMPLATES}
+					<tr>
+						<td class="listTableRow small" valign=top>{$smarty.foreach.emailtemplate.iteration}</td>
+						<td class="listTableRow small" valign=top><input type="checkbox" name="selected_id" value="{$template.templateid}" onClick="ifselected(); " class=small></td>
+						<td class="listTableRow small" valign=top>
+							<a href="index.php?module=Settings&action=detailviewemailtemplate&parenttab=Settings&templateid={$template.templateid}" ><b>{$template.templatename}</b></a>
+						</td>
+						<td class="listTableRow small" valign=top>{$template.description}&nbsp;</td>
+					        <!--<td class="listTableRow small" valign=top>
+							<a href="index.php?module=Settings&action=detailviewemailtemplate&parenttab=Settings&templateid={$template.templateid}">{$UMOD.LNK_SAMPLE_EMAIL}</a>
+						</td>-->
+					</tr>
+					{/foreach}	
+					</table>
+					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr>
+					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
+					</tr>
+					</table>
+				</td>
+				</tr>
+				</table>
+			
+			
+			
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+	</form>
+	</table>
+		
+	</div>
+</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody>
+</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListGroup.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListGroup.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListGroup.tpl Mon Apr 16 12:27:44 2007
@@ -23,7 +23,7 @@
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<form action="index.php" method="post" name="new" id="form">
-				<input type="hidden" name="module" value="Users">
+				<input type="hidden" name="module" value="Settings">
 				<input type="hidden" name="action" value="createnewgroup">
 				<input type="hidden" name="mode" value="create">
 				<input type="hidden" name="parenttab" value="Settings">
@@ -67,11 +67,11 @@
 					  <tr>
 						<td class="listTableRow small" valign=top>{$smarty.foreach.grouplist.iteration}</td>
 						<td class="listTableRow small" valign=top nowrap>
-							  	<a href="index.php?module=Users&action=createnewgroup&returnaction=listgroups&parenttab=Settings&mode=edit&groupId={$groupvalues.groupid}"><img src="{$IMAGE_PATH}editfield.gif" alt="{$APP.LNK_EDIT}" title="{$APP.LNK_EDIT}" border="0" align="absmiddle"></a>&nbsp;|	
+							  	<a href="index.php?module=Settings&action=createnewgroup&returnaction=listgroups&parenttab=Settings&mode=edit&groupId={$groupvalues.groupid}"><img src="{$IMAGE_PATH}editfield.gif" alt="{$APP.LNK_EDIT}" title="{$APP.LNK_EDIT}" border="0" align="absmiddle"></a>&nbsp;|	
 								<a href="#" onClick="deletegroup(this,'{$groupvalues.groupid}')";><img src="{$IMAGE_PATH}delete.gif" alt="{$LNK_DELETE}" title="{$APP.LNK_DELETE}" border="0" align="absmiddle"></a>
 						</td>
 						<td class="listTableRow small" valign=top><strong>
-                              				<a href="index.php?module=Users&action=GroupDetailView&parenttab=Settings&groupId={$groupvalues.groupid}">{$groupvalues.groupname}</a></strong>
+                              				<a href="index.php?module=Settings&action=GroupDetailView&parenttab=Settings&groupId={$groupvalues.groupid}">{$groupvalues.groupname}</a></strong>
 						</td>
 						<td class="listTableRow small" valign=top>{$groupvalues.description}</td>
 					  </tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListLeadCustomFieldMapping.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListLeadCustomFieldMapping.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListLeadCustomFieldMapping.tpl Mon Apr 16 12:27:44 2007
@@ -83,7 +83,7 @@
 <script>
 	function confirmdelete(url)
 	{ldelim}
-        	if(confirm("Are you sure?"))
+        	if(confirm("{$APP.ARE_YOU_SURE}"))
         	{ldelim}
                 	document.location.href=url;
 	       {rdelim}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListRoles.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListRoles.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListRoles.tpl Mon Apr 16 12:27:44 2007
@@ -97,7 +97,7 @@
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-roles.gif" alt="Roles" width="48" height="48" border=0 title="Roles"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-roles.gif" alt="{$MOD.LBL_ROLES}" width="48" height="48" border=0 title="{$MOD.LBL_ROLES}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_ROLES}</b></td>
 				</tr>
 				<tr>
@@ -201,7 +201,7 @@
 			{ldelim}
 //				alert("Please Select the Node");
 				parentId = parentId.replace(/user_/gi,'');
-				window.location.href="index.php?module=Users&action=RoleDetailView&parenttab=Settings&roleid="+parentId;
+				window.location.href="index.php?module=Settings&action=RoleDetailView&parenttab=Settings&roleid="+parentId;
 			{rdelim}
 			else
 			{ldelim}
@@ -213,7 +213,7 @@
 					        method: 'post',
 					        postBody: 'module=Users&action=UsersAjax&file=RoleDragDrop&ajax=true&parentId='+parentId+'&childId='+childId,
 						onComplete: function(response) {ldelim}
-							if(response.responseText != 'You cannot move a Parent Node under a Child Node')
+							if(response.responseText != alert_arr.ROLE_DRAG_ERR_MSG)
 							{ldelim}
 						                $('RoleTreeFull').innerHTML=response.responseText;
 						                hideAll = false;

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListView.tpl Mon Apr 16 12:27:44 2007
@@ -19,11 +19,11 @@
 {if $MODULE eq 'Contacts'}
 <div id="dynloadarea" style="z-index:100000001;float:left;position:absolute;left:350px;top:150px;"></div>
 {/if}
-<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 <script language="javascript">
 function checkgroup()
 {ldelim}
-  if(document.change_ownerform_name.user_lead_owner[1].checked)
+  if($("group_checkbox").checked)
   {ldelim}
   document.change_ownerform_name.lead_group_owner.style.display = "block";
   document.change_ownerform_name.lead_owner.style.display = "none";
@@ -79,7 +79,8 @@
                                 result = response.responseText.split('&#&#&#');
                                 $("ListViewContents").innerHTML= result[2];
                                 if(result[1] != '')
-                                        alert(result[1]);
+                                       alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
 			{rdelim}
 	       {rdelim}
         );
@@ -106,6 +107,7 @@
 				$("ListViewContents").innerHTML= result[2];
 				if(result[1] != '')
 			                alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
 			{rdelim}
 		{rdelim}
 	);
@@ -134,7 +136,7 @@
                                         <table border=0 cellspacing=0 cellpadding=0 width=100%>
                                         <tr>
                                                 <td align=center>
-                                                <img src="images/searching.gif" alt="Searching... please wait"  title="Searching... please wait">
+                                                <img src="{$IMAGE_PATH}searching.gif" alt="{$APP.LBL_SEARCHING}"  title="{$APP.LBL_SEARCHING}">
                                                 </td>
                                         </tr>
                                         </table>
@@ -277,13 +279,15 @@
 					<td width="50%"><b>{$APP.LBL_TRANSFER_OWNERSHIP}</b></td>
 					<td width="2%"><b>:</b></td>
 					<td width="48%">
-					<input type = "radio" name = "user_lead_owner"  onclick=checkgroup(); checked>{$APP.LBL_USER}&nbsp;
-					<input type = "radio" name = "user_lead_owner" onclick=checkgroup(); >{$APP.LBL_GROUP}<br>
-					<select name="lead_owner" id="lead_owner" class="detailedViewTextBox">
+					<input type = "radio" id="user_checkbox"  name="user_lead_owner" {if $CHANGE_GROUP_OWNER neq ''} onclick=checkgroup(); {/if} checked>{$APP.LBL_USER}&nbsp;
+					{if $CHANGE_GROUP_OWNER neq ''}
+					<input type = "radio" id="group_checkbox" name="user_lead_owner" onclick=checkgroup(); >{$APP.LBL_GROUP}<br>
+					<select name="lead_group_owner" id="lead_group_owner" class="select" style="display:none;">  
+					{$CHANGE_GROUP_OWNER}
+					</select>
+					{/if}				
+					<select name="lead_owner" id="lead_owner" class="select">
 					{$CHANGE_OWNER}
-					</select>
-					<select name="lead_group_owner" id="lead_group_owner" class="detailedViewTextBox" style="display:none;">
-					{$CHANGE_GROUP_OWNER}
 					</select>
 					</td>
 				</tr>
@@ -361,7 +365,7 @@
 	}
 	else if(statusname == 'owner')
 	{
-	   if(document.change_ownerform_name.user_lead_owner[0].checked)
+	   if($("user_checkbox").checked)
 	   {
 		    fninvsh('changeowner');
 		    var url='&user_id='+document.getElementById('lead_owner').options[document.getElementById('lead_owner').options.selectedIndex].value;
@@ -389,6 +393,7 @@
                                 $("ListViewContents").innerHTML= result[2];
                                 if(result[1] != '')
                                         alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
                         }
                 }
         );

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListViewEntries.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListViewEntries.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListViewEntries.tpl Mon Apr 16 12:27:44 2007
@@ -54,7 +54,8 @@
 					</table>
                 </td>
 				<td width=100% align="right">
-					<!-- Filters -->
+				   <!-- Filters -->
+				   {if $HIDE_CUSTOM_LINKS neq '1'}
 					<table border=0 cellspacing=0 cellpadding=0 class="small">
 					<tr>
 						<td>{$APP.LBL_VIEW}</td>
@@ -71,10 +72,13 @@
 							<span class="small">|</span>
                             <a href="index.php?module={$MODULE}&action=CustomView&record={$VIEWID}&parenttab={$CATEGORY}">{$APP.LNK_CV_EDIT}</a>
                             <span class="small">|</span>
-							<a href="index.php?module=CustomView&action=Delete&dmodule={$MODULE}&record={$VIEWID}&parenttab={$CATEGORY}">{$APP.LNK_CV_DELETE}</a></td>
+							<a href="javascript:confirmdelete('index.php?module=CustomView&action=Delete&dmodule={$MODULE}&record={$VIEWID}&parenttab={$CATEGORY}')">{$APP.LNK_CV_DELETE}</a></td>
 						    {/if}
 					</tr>
-					</table>
+					</table> 
+				   <!-- Filters  END-->
+				   {/if}
+
 				</td>	
        		    </tr>
 			</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ListWordTemplates.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ListWordTemplates.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ListWordTemplates.tpl Mon Apr 16 12:27:44 2007
@@ -28,7 +28,7 @@
                 {rdelim}
                 else
                 {ldelim}
-                        alert("Please select at least one entity");
+                        alert("{$APP.SELECT_ATLEAST_ONE}");
                         return false;
                 {rdelim}
         {rdelim}
@@ -49,11 +49,11 @@
                 {rdelim}
                else
                 {ldelim}
-                        alert("Please select at least one entity");
+                        alert("{$APP.SELECT_ATLEAST_ONE}");
                         return false;
                 {rdelim}
        {rdelim}
-		if(confirm("Are you sure you want to delete the selected "+xx+" records ?"))
+		if(confirm("{$APP.DELETE_CONFIRMATION}"+xx+"{$APP.RECORDS}"))
 		{ldelim}
 	        	document.massdelete.action.value= "deletewordtemplate";
 		{rdelim}
@@ -78,11 +78,11 @@
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 	               		<form  name="massdelete" method="POST">
 	    			<input name="idlist" type="hidden">
-    				<input name="module" type="hidden" value="Users">
+    				<input name="module" type="hidden" value="Settings">
     				<input name="parenttab" type="hidden" value="Settings">
     				<input name="action" type="hidden">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}mailmarge.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}mailmarge.gif" alt="{$MOD.LBL_MODULE_NAME}" width="48" height="48" border=0 title="{$MOD.LBL_MODULE_NAME}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$UMOD.LBL_WORD_TEMPLATES} </b></td>
 				</tr>
 				<tr>
@@ -126,7 +126,7 @@
 						<td class="listTableRow small" valign=top><b>{$template.filename}</b></a></td>
 						<td class="listTableRow small" valign=top>{$template.description}&nbsp;</td>
 				        <td class="listTableRow small" valign=top>{$template.module}</td>
-				        <td class="listTableRow small" valign=top><a href="index.php?module=Users&action=downloadfile&record={$template.templateid}">{$UMOD.LBL_DOWNLOAD}</a></td>
+				        <td class="listTableRow small" valign=top><a href="index.php?module=Settings&action=mailmergedownloadfile&record={$template.templateid}">{$UMOD.LBL_DOWNLOAD}</a></td>
 			          </tr>
 					{/foreach}
 					</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/MigrationStep1.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/MigrationStep1.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/MigrationStep1.tpl Mon Apr 16 12:27:44 2007
@@ -1,389 +1,383 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-
-
-<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-
-<form name="Migration" method="POST" action="index.php" enctype="multipart/form-data">
-<input type="hidden" name="module" value="Migration">
-<input type="hidden" name="action" value="MigrationCheck">
-<input type="hidden" name="migration_option" value="">
-<input type="hidden" name="parenttab" value="Settings">
-<input type="hidden" id="getmysqlpath" name="getmysqlpath" value="{$GET_MYSQL_PATH}">
-
-<table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%" class="small">
-   <tr>
-	<td class="showPanelBg" valign="top" width="95%"  style="padding-left:20px; "><br />
-		<span class="lvtHeaderText"> {$MOD.LBL_SETTINGS} &gt; {$MOD.LBL_UPGRADE_VTIGER}</span>
-		<span class="lvtHeaderText" align="right">
-			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-			{if $502_PATCH eq 'apply'}
-				<a style="color:red;" href="index.php?module=Migration&action=502DBChanges&parenttab=Settings">Click here to apply the 5.0.2 Database changes from 5.0.0/5.0.1</a>
-			{/if}
-		</span>
-		<hr noshade="noshade" size="1" />
-	</td>
-	<td width="5%" class="showPanelBg">&nbsp;</td>
-   </tr>
-   <tr>
-	<td width="98%" style="padding-left:20px;" valign="top">
-		<!-- module Select Table -->
-		<table width="95%"  border="0" cellspacing="0" cellpadding="0" align="center" class="mailClient">
-		   <tr>
-			<td class="mailClientBg" width="7"></td>
-			<td class="mailClientBg" style="padding-left:10px;padding-top:10px;vertical-align:top;">
-				<table width="100%"  border="0" cellpadding="5" cellspacing="0" class="small">
-				   <tr>
-					<td width="10%"><img src="{$IMAGE_PATH}migrate.gif" align="absmiddle"/></td>
-					<td width="90%">
-						<span class="genHeaderBig">{$MOD.LBL_UPGRADE_VTIGER}</span><br />
-						({$MOD.LBL_UPGRADE_FROM_VTIGER_423})
-					</td>
-				   </tr>
-					   <tr>
-					<td colspan="2" class="hdrNameBg">
-						<span class="genHeaderGray">{$MOD.LBL_STEP} 1 : </span>
-				  		<span class="genHeaderSmall">{$MOD.LBL_SELECT_SOURCE}</span><br />
-						{$MOD.LBL_STEP1_DESC}<br /><br />
-					</td>
-				   </tr>
-				   <tr bgcolor="#FFFFFF">
-					<td align="right" valign="top">
-						<input type="radio" name="radio" id="db_details" value="db_details" onclick="fnChangeMigrate()" "{$DB_DETAILS_CHECKED}" />
-					</td>
-					<td>
-						<b>{$MOD.LBL_RADIO_BUTTON1_TEXT}</b><br /><br />
-						<b>{$MOD.LBL_NOTE_TITLE}</b> {$MOD.LBL_RADIO_BUTTON1_DESC}
-					</td>
-				   </tr>
-				   <tr><td colspan="2" bgcolor="#FFFFFF" height="10"></td></tr>
-				   <tr bgcolor="#FFFFFF">
-					<td align="right" valign="top">
-						<input type="radio" name="radio" id="dump_details" value="dump_details" onclick="fnChangeMigrate()" "{$DUMP_DETAILS_CHECKED}"/>
-					</td>
-					<td>
-						<b>{$MOD.LBL_RADIO_BUTTON2_TEXT}</b><br /><br />
-						<b>{$MOD.LBL_NOTE_TITLE}</b> {$MOD.LBL_RADIO_BUTTON2_DESC}
-					</td>
-				   </tr>
-				   <tr><td colspan="2" bgcolor="#FFFFFF" height="10"></td></tr>
-				   <tr bgcolor="#FFFFFF">
-					<td align="right" valign="top">
-						<input type="radio" name="radio" id="alter_db_details" value="alter_db_details" onclick="fnChangeMigrate()" "{$ALTER_DB_DETAILS_CHECKED}"/>
-					</td>
-					<td>
-						<b>{$MOD.LBL_RADIO_BUTTON3_TEXT}</b><br /><br /><b>{$MOD.LBL_NOTE_TITLE}</b> {$MOD.LBL_RADIO_BUTTON3_DESC}
-					</td>
-				   </tr>
-				   <tr><td colspan="2" bgcolor="#FFFFFF" height="10"></td></tr>
-
-				   <tr><td colspan="2" height="10"></td></tr>
-				   <tr>
-					<td colspan="2" class="hdrNameBg">
-
-
-						<!-- OPTION 1 -->
-						<div id="mnuTab" style="display:{$SHOW_DB_DETAILS}">
-							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
-							   <tr >
-								<td colspan="2">
-									<span class="genHeaderGray">{$MOD.LBL_STEP} 2 : </span>
-									<span class="genHeaderSmall">{$MOD.LBL_HOST_DB_ACCESS_DETAILS}</span><br /><br />
-								</td>
-							   </tr>
-							   <tr>
-								<td width="30%" align="right">{$MOD.LBL_SOURCE_HOST_NAME}</td>
-								<td width="70%"><input type="text" name="old_host_name" class="importBox" value="{$OLD_HOST_NAME}" /></td>
-							   </tr>
-							   <tr>
-								<td align="right">{$MOD.LBL_SOURCE_MYSQL_PORT_NO}</td>
-								<td><input type="text" name="old_port_no" class="importBox" value="{$OLD_PORT_NO}" /></td>
-							   </tr>
-							   <tr>
-								<td align="right">{$MOD.LBL_SOURCE_MYSQL_USER_NAME}</td>
-								<td><input type="text" name="old_mysql_username" class="importBox" value="{$OLD_MYSQL_USERNAME}" /></td>
-							   </tr>
-							   <tr>
-								<td align="right">{$MOD.LBL_SOURCE_MYSQL_PASSWORD}</td>
-								<td><input type="text" name="old_mysql_password" class="importBox" value="{$OLD_MYSQL_PASSWORD}" /></td>
-							   </tr>
-							   <tr>
-								<td align="right">{$MOD.LBL_SOURCE_DB_NAME}</td>
-								<td><input type="text" name="old_dbname" class="importBox" value="{$OLD_DBNAME}" /></td>
-							   </tr>
-							</table>
-						</div>
-
-						<!-- OPTION 2 -->
-						<div id="mnuTab1" style="display:{$SHOW_DUMP_DETAILS}">
-							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
-							   <tr >
-								<td colspan="2">
-									<span class="genHeaderGray">{$MOD.LBL_STEP} 2 : </span>
-									<span class="genHeaderSmall">{$MOD.LBL_LOCATE_DB_DUMP_FILE}</span><br /><br />
-								</td>
-							   </tr>
-							   <tr>
-								<td width="10%">&nbsp;</td>
-								<td width="90%">
-									{$MOD.LBL_DUMP_FILE_LOCATION}
-									<input type="file" name="old_dump_filename" class="txtBox" />
-								</td>
-							   </tr>
-							   <tr><td colspan="2" height="10"></td></tr>
-							   <tr bgcolor="#FFFFFF">
-								<td align="right" valign="top"><b>{$MOD.LBL_NOTE_TITLE}</b></td>
-								<td>{$MOD.LBL_NOTES_DUMP_PROCESS}</td>
-							   </tr>
-							</table>
-						</div>
-
-
-						<!-- OPTION 3 -->
-						<div id="mnuTab2" style="display:{$SHOW_ALTER_DB_DETAILS}">
-							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
-							   <tr>
-								<td colspan="3">
-									<span class="genHeaderGray">{$MOD.LBL_STEP} 2 : </span>
-									<span class="genHeaderSmall">{$MOD.LBL_HOST_DB_ACCESS_DETAILS}</span><br /><br />
-								</td>
-							   </tr>
-							   <tr>
-								<td width="5%">&nbsp;</td>
-								<td width="20%" align="right">{$MOD.LBL_MYSQL_HOST_NAME_IP}</td>
-								<td width="75%"><input type="text" name="alter_old_host_name" class="importBox" value="{$ALTER_OLD_HOST_NAME}" /></td>
-							   </tr>
-							   <tr>
-								<td>&nbsp;</td>
-								<td align="right">{$MOD.LBL_MYSQL_PORT}</td>
-								<td><input type="text" name="alter_old_port_no" class="importBox" value="{$ALTER_OLD_PORT_NO}" /></td>
-							   </tr>
-							   <tr>
-								<td>&nbsp;</td>
-								<td align="right">{$MOD.LBL_MYSQL_USER_NAME}</td>
-								<td><input type="text" name="alter_old_mysql_username" class="importBox" value="{$ALTER_OLD_MYSQL_USERNAME}" /></td>
-							   </tr>
-							   <tr>
-								<td>&nbsp;</td>
-								<td align="right">{$MOD.LBL_MYSQL_PASSWORD}</td>
-								<td><input type="text" name="alter_old_mysql_password" class="importBox" value="{$ALTER_OLD_MYSQL_PASSWORD}" /></td>
-							   </tr>
-							   <tr>
-								<td>&nbsp;</td>
-								<td align="right">{$MOD.LBL_DB_NAME}</td>
-								<td><input type="text" name="alter_old_dbname" class="importBox" value="{$ALTER_OLD_DBNAME}" /></td>
-							   </tr>
-							   <tr><td colspan="3" height="10"></td></tr>
-							   <tr bgcolor="#FFFFFF">
-								<td align="right" valign="top"><b>{$MOD.LBL_NOTE_TITLE}</b></td>
-								<td width="90%" colspan="2">
-
-									{$MOD.LBL_RADIO_BUTTON3_PROCESS}
-								</td>
-							   </tr>
-
-							</table>
-						</div>
-
-
-					</td>
-				   </tr>
-
-				   <!-- this if condition is added to display the text box to get the mysql server path -->
-				   {if $GET_MYSQL_PATH eq 1}
-				   <tr><td colspan="2" height="10"></td></tr>
-				   <tr>
-					<td colspan="2" class="hdrNameBg">
-						<!-- OPTION 3 -->
-						<div id="mnuTab3" style="width:100%; display:{$SHOW_MYSQL_PATH}">
-							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
-							   <tr>
-								<td colspan="2" >
-									<span class="genHeaderGray">{$MOD.LBL_STEP} 3 : </span>
-									<span class="genHeaderSmall">{$MOD.LBL_ENTER_MYSQL_SERVER_PATH}</span><br>{$MOD.LBL_SERVER_PATH_DESC}<br /><br />
-								</td>
-							   </tr>
-							   <tr>
-								<td align="right" width="30%">{$MOD.LBL_MYSQL_SERVER_PATH}</td>
-								<td width="70%">
-									<input type="text" name="server_mysql_path" class="txtBox" value="{$SERVER_MYSQL_PATH}" />
-								</td>
-							   </tr>
-							</table>
-						</div>
-
-
-					</td>
-				   </tr>
-				   {/if}
-				   <tr>
-					<td colspan="2" style="padding:10px;" align="center">
-						<input type="submit" name="migrate" value="  {$MOD.LBL_MIGRATE_BUTTON}  "  class="crmbutton small save" onclick="return validate_migration(Migration);"/>
-						&nbsp;<input type="submit" name="cancel" value=" &nbsp;{$MOD.LBL_CANCEL_BUTTON}&nbsp; "  class="crmbutton small cancel" onclick="this.form.module.value='Settings';this.form.action.value='index';"/>
- 					</td>
-				   </tr>
-				</table>
-			</td>
-			<td class="mailClientBg" width="8"></td>
-		   </tr>
-		  </table>
-		<br />
-	</td>
-	<td>&nbsp;</td>
-   </tr>
-</table>
-<!-- END -->
-</form>
-
-<script language="javascript" type="text/javascript">
-	//function to show and hide the db_details or dump_details details based on the radio option selected
-	function fnChangeMigrate()
-	{ldelim}
-		var opt_one = document.getElementById('db_details').checked;
-		var opt_two = document.getElementById('dump_details').checked;
-		var opt_three = document.getElementById('alter_db_details').checked;
-		if(opt_one)
-		{ldelim}
-			document.getElementById('mnuTab').style.display = 'block';
-			document.getElementById('mnuTab1').style.display = 'none';
-			document.getElementById('mnuTab2').style.display = 'none';
-		{rdelim}
-		else if(opt_two)
-		{ldelim}
-			document.getElementById('mnuTab').style.display = 'none';
-			document.getElementById('mnuTab1').style.display = 'block';
-			document.getElementById('mnuTab2').style.display = 'none';
-		{rdelim}
-		else
-		{ldelim}
-			document.getElementById('mnuTab').style.display = 'none';
-			document.getElementById('mnuTab1').style.display = 'none';
-			document.getElementById('mnuTab2').style.display = 'block';
-		{rdelim}
-
-		//show/hide MySQL server path
-		if(document.getElementById('getmysqlpath').value == 1 && document.getElementById('mnuTab2').style.display == 'none')
-		{ldelim}
-			//show MySQL server path
-			document.getElementById('mnuTab3').style.display = 'block';
-		{rdelim}
-		else
-		{ldelim}
-			//hide MySQL server path
-			document.getElementById('mnuTab3').style.display = 'none';
-		{rdelim}
-	{rdelim}
-
-	//function to validate the input values based on the radio option selected
-	function validate_migration(formname)
-	{ldelim}
-
-		var error = false;
-		var mig_option = '';
-
-		if(document.getElementById("db_details").checked == true)
-		{ldelim}
-			formname.migration_option.value = 'db_details';
-			//check whether the user entered the valid Source MySQL database details when db details selected
-			if(trim(formname.old_host_name.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Source Host Name";
-				error = true;
-			{rdelim}
-			else if(trim(formname.old_port_no.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Source MySql Port Number";
-				error = true;
-			{rdelim}
-			else if(trim(formname.old_mysql_username.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Source MySql User Name";
-				error = true;
-			{rdelim}
-			else if(trim(formname.old_dbname.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Source Database Name";
-				error = true;
-			{rdelim}
-		{rdelim}
-		else if(document.getElementById("dump_details").checked == true)
-		{ldelim}
-			formname.migration_option.value = 'dump_details';
-			//check whether the user entered the MySQL File when dump file details selected
-			if(trim(formname.old_dump_filename.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Valid MySQL Dump File";
-				error = true;
-			{rdelim}
-		{rdelim}
-		else if(document.getElementById("alter_db_details").checked == true)
-		{ldelim}
-			formname.migration_option.value = 'alter_db_details';
-			//check whether the user entered the valid Source MySQL database details when db details selected
-			if(trim(formname.alter_old_host_name.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Host Name";
-				error = true;
-			{rdelim}
-			else if(trim(formname.alter_old_port_no.value) == '')
-			{ldelim}
-				error_msg = "Please enter the MySql Port Number";
-				error = true;
-			{rdelim}
-			else if(trim(formname.alter_old_mysql_username.value) == '')
-			{ldelim}
-				error_msg = "Please enter the MySql User Name";
-				error = true;
-			{rdelim}
-			else if(trim(formname.alter_old_dbname.value) == '')
-			{ldelim}
-				error_msg = "Please enter the Database Name";
-				error = true;
-			{rdelim}
-		{rdelim}
-		else
-		{ldelim}
-			formname.migration_option.value = '';
-			error_msg = "Please select any one option";
-			error = true;
-		{rdelim}
-
-		//this is added to check whether the getmysql path is true and the user has entered the path or not
-		if(error != true)
-		{ldelim}
-			if(document.getElementById("getmysqlpath").value == 1 && trim(formname.server_mysql_path.value) == '' && document.getElementById("alter_db_details").checked != true)
-			{ldelim}
-				//alert(document.getElementById("getmysqlpath").value+" Enter the mysql path");
-				error_msg = "Please enter the Correct MySQL Path";
-				error = true;
-			{rdelim}
-			else
-			{ldelim}
-				//alert(document.getElementById("getmysqlpath").value+" MySQL path found");
-				error = false;
-			{rdelim}
-		{rdelim}
-
-		//if there is any error then alert the user and return false;
-		if(error == true)
-		{ldelim}
-			alert(error_msg);
-			return false;
-		{rdelim}
-		else
-		{ldelim}
-			return true;
-		{rdelim}
-	{rdelim}
-</script>
-
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+
+
+<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
+
+<form name="Migration" method="POST" action="index.php" enctype="multipart/form-data">
+<input type="hidden" name="module" value="Migration">
+<input type="hidden" name="action" value="MigrationCheck">
+<input type="hidden" name="migration_option" value="">
+<input type="hidden" name="parenttab" value="Settings">
+<input type="hidden" id="getmysqlpath" name="getmysqlpath" value="{$GET_MYSQL_PATH}">
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%" class="small">
+   <tr>
+	<td class="showPanelBg" valign="top" width="95%"  style="padding-left:20px; "><br />
+		<span class="lvtHeaderText"> {$MOD.LBL_SETTINGS} &gt; {$MOD.LBL_UPGRADE_VTIGER}</span>
+		<hr noshade="noshade" size="1" />
+	</td>
+	<td width="5%" class="showPanelBg">&nbsp;</td>
+   </tr>
+   <tr>
+	<td width="98%" style="padding-left:20px;" valign="top">
+		<!-- module Select Table -->
+		<table width="95%"  border="0" cellspacing="0" cellpadding="0" align="center" class="mailClient">
+		   <tr>
+			<td class="mailClientBg" width="7"></td>
+			<td class="mailClientBg" style="padding-left:10px;padding-top:10px;vertical-align:top;">
+				<table width="100%"  border="0" cellpadding="5" cellspacing="0" class="small">
+				   <tr>
+					<td width="10%"><img src="{$IMAGE_PATH}migrate.gif" align="absmiddle"/></td>
+					<td width="90%">
+						<span class="genHeaderBig">{$MOD.LBL_UPGRADE_VTIGER}</span><br />
+						({$MOD.LBL_UPGRADE_FROM_VTIGER_423})
+					</td>
+				   </tr>
+					   <tr>
+					<td colspan="2" class="hdrNameBg">
+						<span class="genHeaderGray">{$MOD.LBL_STEP} 1 : </span>
+				  		<span class="genHeaderSmall">{$MOD.LBL_SELECT_SOURCE}</span><br />
+						{$MOD.LBL_STEP1_DESC}<br /><br />
+					</td>
+				   </tr>
+				   <tr bgcolor="#FFFFFF">
+					<td align="right" valign="top">
+						<input type="radio" name="radio" id="db_details" value="db_details" onclick="fnChangeMigrate()" "{$DB_DETAILS_CHECKED}" />
+					</td>
+					<td>
+						<b>{$MOD.LBL_RADIO_BUTTON1_TEXT}</b><br /><br />
+						<b>{$MOD.LBL_NOTE_TITLE}</b> {$MOD.LBL_RADIO_BUTTON1_DESC}
+					</td>
+				   </tr>
+				   <tr><td colspan="2" bgcolor="#FFFFFF" height="10"></td></tr>
+				   <tr bgcolor="#FFFFFF">
+					<td align="right" valign="top">
+						<input type="radio" name="radio" id="dump_details" value="dump_details" onclick="fnChangeMigrate()" "{$DUMP_DETAILS_CHECKED}"/>
+					</td>
+					<td>
+						<b>{$MOD.LBL_RADIO_BUTTON2_TEXT}</b><br /><br />
+						<b>{$MOD.LBL_NOTE_TITLE}</b> {$MOD.LBL_RADIO_BUTTON2_DESC}
+					</td>
+				   </tr>
+				   <tr><td colspan="2" bgcolor="#FFFFFF" height="10"></td></tr>
+				   <tr bgcolor="#FFFFFF">
+					<td align="right" valign="top">
+						<input type="radio" name="radio" id="alter_db_details" value="alter_db_details" onclick="fnChangeMigrate()" "{$ALTER_DB_DETAILS_CHECKED}"/>
+					</td>
+					<td>
+						<b>{$MOD.LBL_RADIO_BUTTON3_TEXT}</b><br /><br /><b>{$MOD.LBL_NOTE_TITLE}</b> {$MOD.LBL_RADIO_BUTTON3_DESC}
+					</td>
+				   </tr>
+				   <tr><td colspan="2" bgcolor="#FFFFFF" height="10"></td></tr>
+
+				   <tr><td colspan="2" height="10"></td></tr>
+				   <tr>
+					<td colspan="2" class="hdrNameBg">
+
+
+						<!-- OPTION 1 -->
+						<div id="mnuTab" style="display:{$SHOW_DB_DETAILS}">
+							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
+							   <tr >
+								<td colspan="2">
+									<span class="genHeaderGray">{$MOD.LBL_STEP} 2 : </span>
+									<span class="genHeaderSmall">{$MOD.LBL_HOST_DB_ACCESS_DETAILS}</span><br /><br />
+								</td>
+							   </tr>
+							   <tr>
+								<td width="30%" align="right">{$MOD.LBL_SOURCE_HOST_NAME}</td>
+								<td width="70%"><input type="text" name="old_host_name" class="importBox" value="{$OLD_HOST_NAME}" /></td>
+							   </tr>
+							   <tr>
+								<td align="right">{$MOD.LBL_SOURCE_MYSQL_PORT_NO}</td>
+								<td><input type="text" name="old_port_no" class="importBox" value="{$OLD_PORT_NO}" /></td>
+							   </tr>
+							   <tr>
+								<td align="right">{$MOD.LBL_SOURCE_MYSQL_USER_NAME}</td>
+								<td><input type="text" name="old_mysql_username" class="importBox" value="{$OLD_MYSQL_USERNAME}" /></td>
+							   </tr>
+							   <tr>
+								<td align="right">{$MOD.LBL_SOURCE_MYSQL_PASSWORD}</td>
+								<td><input type="text" name="old_mysql_password" class="importBox" value="{$OLD_MYSQL_PASSWORD}" /></td>
+							   </tr>
+							   <tr>
+								<td align="right">{$MOD.LBL_SOURCE_DB_NAME}</td>
+								<td><input type="text" name="old_dbname" class="importBox" value="{$OLD_DBNAME}" /></td>
+							   </tr>
+							</table>
+						</div>
+
+						<!-- OPTION 2 -->
+						<div id="mnuTab1" style="display:{$SHOW_DUMP_DETAILS}">
+							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
+							   <tr >
+								<td colspan="2">
+									<span class="genHeaderGray">{$MOD.LBL_STEP} 2 : </span>
+									<span class="genHeaderSmall">{$MOD.LBL_LOCATE_DB_DUMP_FILE}</span><br /><br />
+								</td>
+							   </tr>
+							   <tr>
+								<td width="10%">&nbsp;</td>
+								<td width="90%">
+									{$MOD.LBL_DUMP_FILE_LOCATION}
+									<input type="file" name="old_dump_filename" class="txtBox" />
+								</td>
+							   </tr>
+							   <tr><td colspan="2" height="10"></td></tr>
+							   <tr bgcolor="#FFFFFF">
+								<td align="right" valign="top"><b>{$MOD.LBL_NOTE_TITLE}</b></td>
+								<td>{$MOD.LBL_NOTES_DUMP_PROCESS}</td>
+							   </tr>
+							</table>
+						</div>
+
+
+						<!-- OPTION 3 -->
+						<div id="mnuTab2" style="display:{$SHOW_ALTER_DB_DETAILS}">
+							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
+							   <tr>
+								<td colspan="3">
+									<span class="genHeaderGray">{$MOD.LBL_STEP} 2 : </span>
+									<span class="genHeaderSmall">{$MOD.LBL_HOST_DB_ACCESS_DETAILS}</span><br /><br />
+								</td>
+							   </tr>
+							   <tr>
+								<td width="5%">&nbsp;</td>
+								<td width="20%" align="right">{$MOD.LBL_MYSQL_HOST_NAME_IP}</td>
+								<td width="75%"><input type="text" name="alter_old_host_name" class="importBox" value="{$ALTER_OLD_HOST_NAME}" /></td>
+							   </tr>
+							   <tr>
+								<td>&nbsp;</td>
+								<td align="right">{$MOD.LBL_MYSQL_PORT}</td>
+								<td><input type="text" name="alter_old_port_no" class="importBox" value="{$ALTER_OLD_PORT_NO}" /></td>
+							   </tr>
+							   <tr>
+								<td>&nbsp;</td>
+								<td align="right">{$MOD.LBL_MYSQL_USER_NAME}</td>
+								<td><input type="text" name="alter_old_mysql_username" class="importBox" value="{$ALTER_OLD_MYSQL_USERNAME}" /></td>
+							   </tr>
+							   <tr>
+								<td>&nbsp;</td>
+								<td align="right">{$MOD.LBL_MYSQL_PASSWORD}</td>
+								<td><input type="text" name="alter_old_mysql_password" class="importBox" value="{$ALTER_OLD_MYSQL_PASSWORD}" /></td>
+							   </tr>
+							   <tr>
+								<td>&nbsp;</td>
+								<td align="right">{$MOD.LBL_DB_NAME}</td>
+								<td><input type="text" name="alter_old_dbname" class="importBox" value="{$ALTER_OLD_DBNAME}" /></td>
+							   </tr>
+							   <tr><td colspan="3" height="10"></td></tr>
+							   <tr bgcolor="#FFFFFF">
+								<td align="right" valign="top"><b>{$MOD.LBL_NOTE_TITLE}</b></td>
+								<td width="90%" colspan="2">
+
+									{$MOD.LBL_RADIO_BUTTON3_PROCESS}
+								</td>
+							   </tr>
+
+							</table>
+						</div>
+
+
+					</td>
+				   </tr>
+
+				   <!-- this if condition is added to display the text box to get the mysql server path -->
+				   {if $GET_MYSQL_PATH eq 1}
+				   <tr><td colspan="2" height="10"></td></tr>
+				   <tr>
+					<td colspan="2" class="hdrNameBg">
+						<!-- OPTION 3 -->
+						<div id="mnuTab3" style="width:100%; display:{$SHOW_MYSQL_PATH}">
+							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
+							   <tr>
+								<td colspan="2" >
+									<span class="genHeaderGray">{$MOD.LBL_STEP} 3 : </span>
+									<span class="genHeaderSmall">{$MOD.LBL_ENTER_MYSQL_SERVER_PATH}</span><br>{$MOD.LBL_SERVER_PATH_DESC}<br /><br />
+								</td>
+							   </tr>
+							   <tr>
+								<td align="right" width="30%">{$MOD.LBL_MYSQL_SERVER_PATH}</td>
+								<td width="70%">
+									<input type="text" name="server_mysql_path" class="txtBox" value="{$SERVER_MYSQL_PATH}" />
+								</td>
+							   </tr>
+							</table>
+						</div>
+
+
+					</td>
+				   </tr>
+				   {/if}
+				   <tr>
+					<td colspan="2" style="padding:10px;" align="center">
+						<input type="submit" name="migrate" value="  {$MOD.LBL_MIGRATE_BUTTON}  "  class="crmbutton small save" onclick="return validate_migration(Migration);"/>
+						&nbsp;<input type="submit" name="cancel" value=" &nbsp;{$MOD.LBL_CANCEL_BUTTON}&nbsp; "  class="crmbutton small cancel" onclick="this.form.module.value='Settings';this.form.action.value='index';"/>
+ 					</td>
+				   </tr>
+				</table>
+			</td>
+			<td class="mailClientBg" width="8"></td>
+		   </tr>
+		  </table>
+		<br />
+	</td>
+	<td>&nbsp;</td>
+   </tr>
+</table>
+<!-- END -->
+</form>
+
+<script language="javascript" type="text/javascript">
+	//function to show and hide the db_details or dump_details details based on the radio option selected
+	function fnChangeMigrate()
+	{ldelim}
+		var opt_one = document.getElementById('db_details').checked;
+		var opt_two = document.getElementById('dump_details').checked;
+		var opt_three = document.getElementById('alter_db_details').checked;
+		if(opt_one)
+		{ldelim}
+			document.getElementById('mnuTab').style.display = 'block';
+			document.getElementById('mnuTab1').style.display = 'none';
+			document.getElementById('mnuTab2').style.display = 'none';
+		{rdelim}
+		else if(opt_two)
+		{ldelim}
+			document.getElementById('mnuTab').style.display = 'none';
+			document.getElementById('mnuTab1').style.display = 'block';
+			document.getElementById('mnuTab2').style.display = 'none';
+		{rdelim}
+		else
+		{ldelim}
+			document.getElementById('mnuTab').style.display = 'none';
+			document.getElementById('mnuTab1').style.display = 'none';
+			document.getElementById('mnuTab2').style.display = 'block';
+		{rdelim}
+
+		//show/hide MySQL server path
+		if(document.getElementById('getmysqlpath').value == 1 && document.getElementById('mnuTab2').style.display == 'none')
+		{ldelim}
+			//show MySQL server path
+			document.getElementById('mnuTab3').style.display = 'block';
+		{rdelim}
+		else
+		{ldelim}
+			//hide MySQL server path
+			document.getElementById('mnuTab3').style.display = 'none';
+		{rdelim}
+	{rdelim}
+
+	//function to validate the input values based on the radio option selected
+	function validate_migration(formname)
+	{ldelim}
+
+		var error = false;
+		var mig_option = '';
+
+		if(document.getElementById("db_details").checked == true)
+		{ldelim}
+			formname.migration_option.value = 'db_details';
+			//check whether the user entered the valid Source MySQL database details when db details selected
+			if(trim(formname.old_host_name.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_SOURCE_HOST}";
+				error = true;
+			{rdelim}
+			else if(trim(formname.old_port_no.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_SOURCE_MYSQL_PORT}";
+				error = true;
+			{rdelim}
+			else if(trim(formname.old_mysql_username.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_SOURCE_MYSQL_USER}";
+				error = true;
+			{rdelim}
+			else if(trim(formname.old_dbname.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_SOURCE_DATABASE}";
+				error = true;
+			{rdelim}
+		{rdelim}
+		else if(document.getElementById("dump_details").checked == true)
+		{ldelim}
+			formname.migration_option.value = 'dump_details';
+			//check whether the user entered the MySQL File when dump file details selected
+			if(trim(formname.old_dump_filename.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_SOURCE_MYSQL_DUMP}";
+				error = true;
+			{rdelim}
+		{rdelim}
+		else if(document.getElementById("alter_db_details").checked == true)
+		{ldelim}
+			formname.migration_option.value = 'alter_db_details';
+			//check whether the user entered the valid Source MySQL database details when db details selected
+			if(trim(formname.alter_old_host_name.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_HOST}";
+				error = true;
+			{rdelim}
+			else if(trim(formname.alter_old_port_no.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_MYSQL_PORT}";
+				error = true;
+			{rdelim}
+			else if(trim(formname.alter_old_mysql_username.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_MYSQL_USER}";
+				error = true;
+			{rdelim}
+			else if(trim(formname.alter_old_dbname.value) == '')
+			{ldelim}
+				error_msg = "{$MOD.ENTER_DATABASE}";
+				error = true;
+			{rdelim}
+		{rdelim}
+		else
+		{ldelim}
+			formname.migration_option.value = '';
+			error_msg = "{$MOD.SELECT_ANYONE_OPTION}";
+			error = true;
+		{rdelim}
+
+		//this is added to check whether the getmysql path is true and the user has entered the path or not
+		if(error != true)
+		{ldelim}
+			if(document.getElementById("getmysqlpath").value == 1 && trim(formname.server_mysql_path.value) == '' && document.getElementById("alter_db_details").checked != true)
+			{ldelim}
+				//alert(document.getElementById("getmysqlpath").value+" Enter the mysql path");
+				error_msg = "{$MOD.ENTER_CORRECT_MYSQL_PATH}";
+				error = true;
+			{rdelim}
+			else
+			{ldelim}
+				//alert(document.getElementById("getmysqlpath").value+" MySQL path found");
+				error = false;
+			{rdelim}
+		{rdelim}
+
+		//if there is any error then alert the user and return false;
+		if(error == true)
+		{ldelim}
+			alert(error_msg);
+			return false;
+		{rdelim}
+		else
+		{ldelim}
+			return true;
+		{rdelim}
+	{rdelim}
+</script>
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -45,7 +45,7 @@
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}shareaccess.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}shareaccess.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_SHARING_ACCESS} </b></td>
 					<td rowspan=2 class="small" align=right>&nbsp;</td>
 				</tr>
@@ -194,22 +194,22 @@
 <div id="tempdiv" style="display:block;position:absolute;width:400px;"></div>
 
 <!-- For Disabling Window -->
-<div id="confId"  class='veil_new' style="display:none;">
-<table class="options" border="0" cellpadding="18" cellspacing="0">
+<div id="confId"  class='veil_new small' style="display:none;">
+<table class="options small" border="0" cellpadding="18" cellspacing="0">
 <tr>
-	<td class="big" align="center">
-		<h2>{$CMOD.LBL_RECALC_MSG}</h2>
+	<td align="center" nowrap style="color:#FFFFFF;font-size:15px;">
+		<b>{$CMOD.LBL_RECALC_MSG}</b>
 	</td>
 	<br>
 	<tr>
-		<td align="center"><input type="button" value="{$CMOD.LBL_YES}" onclick="return disableStyle('confId');">&nbsp;&nbsp;<input type="button" value="&nbsp;{$CMOD.LBL_NO}&nbsp;" onclick="$('freeze').style.display='none';$('confId').style.display='none'; "></td>
+		<td align="center"><input type="button" value="{$CMOD.LBL_YES}" onclick="return disableStyle('confId');">&nbsp;&nbsp;<input type="button" value="&nbsp;{$CMOD.LBL_NO}&nbsp;" onclick="showSelect();$('confId').style.display='none';document.body.removeChild($('freeze'));"></td>
 	</tr>
 </tr>
 </table>
 </div>
 
-<div id="divId" class="veil_new" style="display:none;top:0px;left:0px;">
-<table class="optioncontainer" border="0" cellpadding="18" cellspacing="0">
+<div id="divId" class="veil_new" style="position:absolute;width:100%;display:none;top:0px;left:0px;">
+<table border="5" cellpadding="0" cellspacing="0" align="center" style="vertical-align:middle;width:100%;height:100%;">
 <tbody><tr>
 		<td class="big" align="center">
 		    <img src="{$IMAGE_PATH}plsWaitAnimated.gif">
@@ -228,7 +228,7 @@
                 'index.php',
                 {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
                         method: 'post',
-                        postBody: 'module=Users&action=UsersAjax&orgajax=true&mode='+mode+'&sharing_module='+modulename+'&shareid='+id,
+                        postBody: 'module=Settings&action=SettingsAjax&orgajax=true&mode='+mode+'&sharing_module='+modulename+'&shareid='+id,
                         onComplete: function(response) {ldelim}
                                 $("status").style.display="none";
                                 $("tempdiv").innerHTML=response.responseText;
@@ -280,7 +280,7 @@
 
 		function confirmdelete(url)
 		{ldelim}
-			if(confirm("Are you sure?"))
+			if(confirm("{$APP.ARE_YOU_SURE}"))
 			{ldelim}
 				document.location.href=url;
 			{rdelim}
@@ -291,14 +291,24 @@
 			$('orgSharingform').action.value = 'RecalculateSharingRules';
 			$('orgSharingform').submit();
  			$(id).style.display = 'none';
-			$('divId').style.display = 'block';
+
+			if(browser_ie && (gBrowserAgent.indexOf("msie 7.")!=-1))//for IE 7
+                        {ldelim}
+                                document.body.removeChild($('freeze'));
+                        {rdelim}else if(browser_ie)
+                        {ldelim}
+                             var oDivfreeze = $('divId');
+                             oDivfreeze.style.height = document.documentElement['clientHeight'] + 'px';
+
+                        {rdelim}
+                        $('divId').style.display = 'block';
 	{rdelim}
 
 	function freezeBackground()
 	{ldelim}
 	    var oFreezeLayer = document.createElement("DIV");
 	    oFreezeLayer.id = "freeze";
-	    oFreezeLayer.className = "veil";
+	    oFreezeLayer.className = "small veil";
 
 	     if (browser_ie) oFreezeLayer.style.height = (document.body.offsetHeight + (document.body.scrollHeight - document.body.offsetHeight)) + "px";
 	     else if (browser_nn4 || browser_nn6) oFreezeLayer.style.height = document.body.offsetHeight + "px";
@@ -306,6 +316,7 @@
 	    oFreezeLayer.style.width = "100%";
 	    document.body.appendChild(oFreezeLayer);
 	    document.getElementById('confId').style.display = 'block';
+	    hideSelect();
 	{rdelim}
 
 </script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/OrgSharingEditView.tpl Mon Apr 16 12:27:44 2007
@@ -26,7 +26,7 @@
 				<input type="hidden" name="action" value="SaveOrgSharing">
 				<input type="hidden" name="parenttab" value="Settings">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}shareaccess.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}shareaccess.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_EDIT} {$MOD.LBL_SHARING_ACCESS} </b></td>
 					<td rowspan=2 class="small" align=right>&nbsp;</td>
 				</tr>
@@ -87,7 +87,7 @@
 {ldelim}
 	if (share_value == "3")
 	{ldelim}
-		alert("Potentials, HelpDesk, Quotes, SalesOrder & Invoice Access must be set to Private when the Account Access is set to Private");
+		alert("{$APP.ACCOUNT_ACCESS_INFO}");
 		document.getElementById('2_perm_combo').options[3].selected=true
 		document.getElementById('13_perm_combo').options[3].selected=true
 		document.getElementById('20_perm_combo').options[3].selected=true

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Popup.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Popup.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Popup.tpl Mon Apr 16 12:27:44 2007
@@ -14,15 +14,17 @@
 
 <link rel="stylesheet" type="text/css" href="{$THEME_PATH}style.css">
 <script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/{php} echo $_SESSION['authenticated_user_language'];{/php}.lang.js?{php} echo $_SESSION['vtiger_version'];{/php}"></script>
+<script language="JavaScript" type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 <script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
 <script type="text/javascript">
 function add_data_to_relatedlist(entity_id,recordid,mod) {ldelim}
-        opener.document.location.href="index.php?module={$RETURN_MODULE}&action=updateRelations&destination_module="+mod+"&entityid="+entity_id+"&parid="+recordid+"&return_action={$RETURN_ACTION}";
+        opener.document.location.href="index.php?module={$RETURN_MODULE}&action=updateRelations&destination_module="+mod+"&entityid="+entity_id+"&parid="+recordid+"&return_module={$RETURN_MODULE}&return_action={$RETURN_ACTION}&dependency_type={$DEPENDENCY_TYPE}";
 {rdelim}
 
 </script>
-<body class="small" marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 bottommargin=0 rigthmargin=0>
+
+<body class="small" marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 bottommargin=0 rightmargin=0>
 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="mailClient mailClientBg">
 	<tr>
 		<td>
@@ -49,6 +51,7 @@
 								<input type="hidden" name="action" value="Popup">
 											<input type="hidden" name="query" value="true">
 								<input type="hidden" name="select_enable" id="select_enable" value="{$SELECT}">
+								<input type="hidden" name="dependency_type" id="dependency_type" value="{$DEPENDENCY_TYPE}">
 								<input type="hidden" name="curr_row" id="curr_row" value="{$CURR_ROW}">
 								<input type="hidden" name="fldname_pb" value="{$FIELDNAME}">
 								<input type="hidden" name="productid_pb" value="{$PRODUCTID}">

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/PopupContents.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/PopupContents.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/PopupContents.tpl Mon Apr 16 12:27:44 2007
@@ -14,9 +14,9 @@
 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="small">
 	<tr>
 	{if $SELECT eq 'enable'}
-		<td style="padding-left:10px;" align="left"><input class="crmbutton small save" type="button" value="{$APP.LBL_ADD_ITEM} {$APP[$MODULE]}" onclick="if(SelectAll('{$MODULE}','{$RETURN_MODULE}')) window.close();"/></td>
+	    <td style="padding-left:10px;" align="left"><input class="crmbutton small save" type="button" value="{$APP.LBL_ADD_ITEM} {$APP[$MODULE]}" onclick="if(SelectAll('{$MODULE}','{$RETURN_MODULE}')) window.close();"/></td>
 	{else}		
-		<td>&nbsp;</td>	
+	    <td>&nbsp;</td>	
 	{/if}
 	<td style="padding-right:10px;" align="right">{$RECORD_COUNTS}</td></tr>
    	<tr>
@@ -29,13 +29,19 @@
 		<input name="entityid" type="hidden" value="">
 		<input name="popuptype" id="popup_type" type="hidden" value="{$POPUPTYPE}">
 		<input name="idlist" type="hidden" value="">
+		<input type="hidden" name="dependency_type" id="dependency_type" value="{$DEPENDENCY_TYPE}">
 		<div style="overflow:auto;height:348px;">
 		<table style="background-color: rgb(204, 204, 204);" class="small" border="0" cellpadding="5" cellspacing="1" width="100%">
 		<tbody>
 		<tr>
-			{if $SELECT eq 'enable'}
-				<td class="lvtCol" width="3%"><input type="checkbox" name="select_all" value="" onClick=toggleSelect(this.checked,"selected_id")></td>
-            {/if}
+		    {if $SELECT eq 'enable'}
+			<td class="lvtCol" width="3%"><input type="checkbox" name="select_all" value="" onClick=toggleSelect(this.checked,"selected_id")></td>
+			{if $DEPENDENCY_TYPE eq '10' || $DEPENDENCY_TYPE eq '40'}
+			    <td class="lvtCol" style="padding-left:10px;" align="left">Qty</td>
+			{elseif $DEPENDENCY_TYPE eq '20'}
+			    <td class="lvtCol" style="padding-left:10px;" align="left">Grp</td>
+			{/if}
+		    {/if}
 		    {foreach item=header from=$LISTHEADER}
 		        <td class="lvtCol">{$header}</td>
 		    {/foreach}
@@ -44,6 +50,11 @@
 	        <tr bgcolor=white onMouseOver="this.className='lvtColDataHover'" onMouseOut="this.className='lvtColData'"  >
 		   {if $SELECT eq 'enable'}
 			<td><input type="checkbox" name="selected_id" value="{$entity_id}" onClick=toggleSelectAll(this.name,"select_all")></td>
+		   {if $DEPENDENCY_TYPE eq '10' || $DEPENDENCY_TYPE eq '40' || $DEPENDENCY_TYPE eq '20'}
+		        <td><input type="text" name="quantity_{$entity_id}" class="txtBox" size=3></td>
+		   {else}
+			<input type="hidden" name="quantity_{$entity_id}" value=1>
+		   {/if}
 		   {/if}
                    {foreach item=data from=$entity}
 		        <td>{$data}</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/PrintReport.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/PrintReport.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/PrintReport.tpl Mon Apr 16 12:27:44 2007
@@ -16,9 +16,9 @@
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset={$APP.LBL_CHARSET}">
 <link rel="stylesheet" media="print" href="print.css" type="text/css">
-<title>vtiger -  Print Report</title>
+<title>vtiger -  {$MOD.LBL_PRINT_REPORT}</title>
 <style>
 {literal}
 body{
@@ -58,7 +58,7 @@
 	<table width="80%" border="0" cellpadding="5" cellspacing="0" align="center">
 	<tr>
 		<td align="left" valign="top" style="border:0px solid #000000;">
-		<h2>{$REPORT_NAME}</h2>
+		<h2>{$MOD.$REPORT_NAME}</h2>
 		<font  color="#666666"><div id="report_info"></div></font>
 		</td>
 		<td align="right" style="border:0px solid #000000;" valign="top"><h3 style="color:#CCCCCC">{$COUNT} {$APP.LBL_RECORDS}</h3></td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ProfileDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ProfileDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ProfileDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -1,398 +1,402 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-{literal}
-<style>
-.showTable{
-	display:inline-table;
-}
-.hideTable{
-	display:none;
-}
-</style>
-{/literal}
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/general.js"></script>
-<script language="JAVASCRIPT" type="text/javascript">
-{literal}
-function UpdateProfile()
-{
-	var prof_name = $('profile_name').value;
-	var prof_desc = $('description').value;
-	if(prof_name == '')
-	{
-		
-		$('profile_name').focus();
-		alert("Profile Name Cannot be empty");
-	}
-	else
-	{
-		
-{/literal}
-		
-		var urlstring ="module=Users&action=UsersAjax&file=RenameProfile&profileid="+{$PROFILEID}+"&profilename="+prof_name+"&description="+prof_desc;
-{literal}
-	new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody:urlstring,
-			onComplete: function(response)
-			{
-				$('renameProfile').style.display="none";
-				window.location.reload();
-				alert("Profile Details are updated");
-			}
-                }
-		);
-	}
-		
-	
-}
-</script>
-{/literal}
-
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-        <br>
-	<div align=center>
-			{include file='SetMenu.tpl'}
-			
-				<form  method="post" name="new" id="form">
-			        <input type="hidden" name="module" value="Users">
-			        <input type="hidden" name="action" value="profilePrivileges">
-			        <input type="hidden" name="parenttab" value="Settings">
-			        <input type="hidden" name="return_action" value="profilePrivileges">
-			        <input type="hidden" name="mode" value="edit">
-			        <input type="hidden" name="profileid" value="{$PROFILEID}">
-				
-				<!-- DISPLAY -->
-				<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
-				<tbody><tr>
-					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}ico-profile.gif" alt="{$MOD.LBL_PROFILES}" title="{$MOD.LBL_PROFILES}" border="0" height="48" width="48"></td>
-					<td class="heading2" valign="bottom"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=ListProfiles&parenttab=Settings">{$CMOD.LBL_PROFILE_PRIVILEGES}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$PROFILE_NAME}&quot;</b></td>
-				</tr>
-				<tr>
-					<td class="small" valign="top">{$CMOD.LBL_PROFILE_MESG} &quot;{$PROFILE_NAME}&quot; </td>
-				</tr>
-				</tbody></table>
-				
-				
-				<table border="0" cellpadding="10" cellspacing="0" width="100%">
-				<tbody><tr>
-				<td valign="top">
-					<table border="0" cellpadding="0" cellspacing="0" width="100%">
-                      <tbody><tr>
-                        <td><table border="0" cellpadding="0" cellspacing="0" width="100%">
-                            <tbody><tr class="small">
-                              <td><img src="{$IMAGE_PATH}prvPrfTopLeft.gif"></td>
-                              <td class="prvPrfTopBg" width="100%"></td>
-                              <td><img src="{$IMAGE_PATH}prvPrfTopRight.gif"></td>
-                            </tr>
-                          </tbody></table>
-                            <table class="prvPrfOutline" border="0" cellpadding="0" cellspacing="0" width="100%">
-                              <tbody><tr>
-                                <td><!-- tabs -->
-                                    
-                                    <!-- Headers -->
-                                    <table border="0" cellpadding="5" cellspacing="0" width="100%">
-                                      <tbody><tr>
-                                        <td><table class="small" border="0" cellpadding="5" cellspacing="0" width="100%">
-                                            <tbody><tr>
-                                              <td><!-- Module name heading -->
-                                                  <table class="small" border="0" cellpadding="2" cellspacing="0">
-                                                    <tbody><tr>
-                                                      <td valign="top"><img src="{$IMAGE_PATH}prvPrfHdrArrow.gif"> </td>
-                                                      <td class="prvPrfBigText"><b> {$CMOD.LBL_DEFINE_PRIV_FOR} &lt;{$PROFILE_NAME}&gt; </b><br>
-                                                      <font class="small">{$CMOD.LBL_USE_OPTION_TO_SET_PRIV}</font> </td>
-                                                      <td class="small" style="padding-left: 10px;" align="right"></td>
-
-                                                    </tr>
-                                                </tbody></table></td>
-                                              <td align="right" valign="bottom">&nbsp;<input type="button" value="{$APP.LBL_RENAMEPROFILE_BUTTON_LABEL}" class="crmButton small edit" name="rename_profile"  onClick = "fnvshobj(this,'renameProfile');">&nbsp;<input type="submit" value="{$APP.LBL_EDIT_BUTTON_LABEL}" class="crmButton small edit" name="edit" >
-                              		     </td>
-					    	
-                                            </tr></tbody></table>
-					    <!-- RenameProfile Div start -->	 
-					    <div id="renameProfile" style="left: 49px; top: 152px; display: none; visibility: visible;position:absolute;" class="layerPopup">
-						<table class="layerHeadingULine" border="0" cellpadding="3" cellspacing="0" width="100%">
-						<tr style="cursor:move;">
-						<td class="layerPopupHeading" id = "renameUI" align="left" width="60%">{$APP.LBL_RENAME_PROFILE}</td>
-						<td align="right" width="40%"><a href="javascript:fninvsh('renameProfile');"><img src="themes/bluelagoon/images/close.gif" align="middle" border="0"></a></td>
-						</tr>
-						</table>
-					    <table align="center" border="0" cellpadding="5" cellspacing="0" width="95%">
-
-						<tr>
-						<td class="small">
-							<table celspacing="0" align="center" bgcolor="white" border="0" cellpadding="5" width="100%">
-								<tr>
-								<td align="right" width="25%" style="padding-right:10px;" nowrap><b>{$APP.LBL_PROFILE_NAME} :</b></td>
-								<td align="left" width="75%" style="padding-right:10px;"><input id = "profile_name" name="profile_name" class="txtBox" value="{$Profile_Name}" type="text"></td>
-								</tr>
-								<tr>
-                                                                <td align="right" width="25%" style="padding-right:10px;" nowrap><b>{$APP.LBL_DESCRIPTION} :</b></td>
-                                                                <td align="left" width="75%" style="padding-right:10px;"><textarea name="description" id = "description" class="txtBox">{$Profile_Description} </textarea></td>
-                                                                </tr>
-							</table>
-						</td>
-						</tr>
-					    </table>
-					    <table class="layerPopupTransport" border="0" cellpadding="5" cellspacing="0" width="100%">
-					    <tr>
-						<td align = "center">
-							<input name="save" value="Update" class="crmbutton small save" onclick="UpdateProfile();" type="button">&nbsp;&nbsp;
-							<input name="cancel" value="Cancel" class="crmbutton small save" onclick="fninvsh('renameProfile');" type="button">&nbsp;&nbsp;
-						</td>
-					    </tr>		
-					    </table>		
-					    </div>		
-				             <!- RenameProfile Div end -->		
-
-                                         
-                                            <!-- privilege lists -->
-                                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
-                                              <tbody><tr>
-                                                <td style="height: 10px;" align="center"><img src="{$IMAGE_PATH}prvPrfLine.gif" style="width: 100%; height: 1px;"></td>
-                                              </tr>
-                                            </tbody></table>
-                                            <table border="0" cellpadding="10" cellspacing="0" width="100%">
-                                              <tbody><tr>
-                                                <td>
-						<table border="0" cellpadding="5" cellspacing="0" width="100%">
-  						<tbody>
-							<tr>
-    							<td class="cellLabel big"> {$CMOD.LBL_SUPER_USER_PRIV} </td>
-						       </tr>
-						</tbody>
-						</table>
-						<table class="small" align="center" border="0" cellpadding="5" cellspacing="0" width="90%">
-                                                <tbody><tr>
-                                                    <td class="prvPrfTexture" style="width: 20px;">&nbsp;</td>
-                                                    <td valign="top" width="97%"><table class="small" border="0" cellpadding="2" cellspacing="0" width="100%">
-                                                      <tbody>
-				                         <tr id="gva">
-                                                          <td valign="top">{$GLOBAL_PRIV.0}</td>
-                                                          <td ><b>{$CMOD.LBL_VIEW_ALL}</b> </td>
-                                                        </tr>
-                                                        <tr >
-                                                          <td valign="top"></td>
-                                                          <td width="100%" >{$CMOD.LBL_ALLOW} "{$PROFILE_NAME}" {$CMOD.LBL_MESG_VIEW}</td>
-                                                        </tr>
-                                                        <tr>
-                                                          <td>&nbsp;</td>
-                                                        </tr>
-							<tr>
-							<td valign="top">{$GLOBAL_PRIV.1}</td>
-							<td ><b>{$CMOD.LBL_EDIT_ALL}</b> </td>
-							</tr>
-                                                        <tr>
-                                                          <td valign="top"></td>
-                                                          <td > {$CMOD.LBL_ALLOW} "{$PROFILE_NAME}" {$CMOD.LBL_MESG_EDIT}</td>
-                                                        </tr>
-
-                                                      </tbody></table>
-						</td>
-                                                  </tr>
-                                                </tbody></table>
-<br>
-
-			<table border="0" cellpadding="5" cellspacing="0" width="100%">
-			  <tbody><tr>
-			    <td class="cellLabel big"> {$CMOD.LBL_SET_PRIV_FOR_EACH_MODULE} </td>
-			  </tr>
-			</tbody></table>
-			<table class="small" align="center" border="0" cellpadding="5" cellspacing="0" width="90%">
-			  <tbody><tr>
-			    <td class="prvPrfTexture" style="width: 20px;">&nbsp;</td>
-			    <td valign="top" width="97%">
-				<table class="small listTable" border="0" cellpadding="5" cellspacing="0" width="100%">
-			        <tbody>
-				<tr id="gva">
-			          <td colspan="2" rowspan="2" class="small colHeader"><strong> {$CMOD.LBL_TAB_MESG_OPTION} </strong><strong></strong></td>
-			          <td colspan="3" class="small colHeader"><div align="center"><strong> {$CMOD.LBL_EDIT_PERMISSIONS} </strong></div></td>
-			          <td rowspan="2" class="small colHeader" nowrap="nowrap"> {$CMOD.LBL_FIELDS_AND_TOOLS_SETTINGS} </td>
-			        </tr>
-			        <tr id="gva">
-			          <td class="small colHeader"><div align="center"><strong>{$CMOD.LBL_CREATE_EDIT}
-			          </strong></div></td>
-			          <td class="small colHeader"> <div align="center"><strong>{$CMOD.LBL_VIEW} </strong></div></td>
-			          <td class="small colHeader"> <div align="center"><strong>{$CMOD.LBL_DELETE}</strong></div></td>
-			        </tr>
-					
-				<!-- module loops-->
-			        {foreach key=tabid item=elements from=$TAB_PRIV}	
-			        <tr>
-                                        {assign var=modulename value=$TAB_PRIV[$tabid][0]}
-			          <td class="small cellLabel" width="3%"><div align="right">
-					{$TAB_PRIV[$tabid][1]}
-			          </div></td>
-			          <td class="small cellLabel" width="40%"><p>{$APP[$modulename]}</p></td>
-			          <td class="small cellText" width="15%">&nbsp;<div align="center">
-					{$STANDARD_PRIV[$tabid][1]}
-			          </div></td>
-			          <td class="small cellText" width="15%">&nbsp;<div align="center">
-					{$STANDARD_PRIV[$tabid][3]}
-			          </div></td>
-			          <td class="small cellText" width="15%">&nbsp;<div align="center">
-					{$STANDARD_PRIV[$tabid][2]}
-        			  </div></td>
-			          <td class="small cellText" width="22%">&nbsp;<div align="center">
-				{if $FIELD_PRIVILEGES[$tabid] neq NULL || $modulename eq 'Emails'}
-				<img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onclick="fnToggleVIew('{$modulename}_view')" border="0" height="16" width="40">
-				{/if}
-				</div></td>
-				  </tr>
-		                  <tr class="hideTable" id="{$modulename}_view" className="hideTable">
-				          <td colspan="6" class="small settingsSelectedUI">
-						<table class="small" border="0" cellpadding="2" cellspacing="0" width="100%">
-			        	    	<tbody>
-						{if $FIELD_PRIVILEGES[$tabid] neq ''}
-						<tr>
-							{if $modulename eq 'Calendar'}
-				                	<td class="small colHeader" colspan="6" valign="top">{$CMOD.LBL_FIELDS_SELECT_DESELECT} ({$APP.Tasks})</td>
-							{else}
-				                	<td class="small colHeader" colspan="6" valign="top">{$CMOD.LBL_FIELDS_SELECT_DESELECT}</td>
-							{/if}
-					        </tr>
-						{/if}
-						{foreach item=row_values from=$FIELD_PRIVILEGES[$tabid]}
-				            	<tr>
-						      {foreach item=element from=$row_values}
-					              <td valign="top">{$element.1}</td>
-					              <td>{$element.0}</td>
-						      {/foreach}
-				                </tr>
-						{/foreach}
-						{if $modulename eq 'Calendar'}
-						<tr>
-				                	<td class="small colHeader" colspan="6" valign="top">{$CMOD.LBL_FIELDS_SELECT_DESELECT}  ({$APP.Events})</td>
-					        </tr>
-						{foreach item=row_values from=$FIELD_PRIVILEGES[16]}
-				            	<tr>
-						      {foreach item=element from=$row_values}
-					              <td valign="top">{$element.1}</td>
-					              <td>{$element.0}</td>
-						      {/foreach}
-				                </tr>
-						{/foreach}
-						{/if}
-						{if $UTILITIES_PRIV[$tabid] neq ''}
-					        <tr>
-					              <td colspan="6" class="small colHeader" valign="top">{$CMOD.LBL_TOOLS_TO_BE_SHOWN} </td>
-						</tr>
-						{/if}
-						{foreach item=util_value from=$UTILITIES_PRIV[$tabid]}
-						<tr>
-							{foreach item=util_elements from=$util_value}
-					              		<td valign="top">{$util_elements.1}</td>
-						                <td>{$APP[$util_elements.0]}</td>
-							{/foreach}
-				               	</tr>
-						{/foreach}
-					        </tbody>
-						</table>
-					</td>
-			          </tr>
-				  {/foreach}	
-			    	  </tbody>
-				  </table>
-			  </td>
-			  </tr>
-                          </tbody>
-			</table>
-		</td>
-                </tr>
-		<table border="0" cellpadding="2" cellspacing="0">
-			<tr>
-				<td align="left"><font color="red" size=5>*</font>{$CMOD.LBL_MANDATORY_MSG}</td>
-			</tr>
-			<tr>
-				<td align="left"><font color="blue" size=5>*</font>{$CMOD.LBL_DISABLE_FIELD_MSG}</td>
-			</tr>
-		</table>
-		<tr>
-		<td style="border-top: 2px dotted rgb(204, 204, 204);" align="right">
-		<!-- wizard buttons -->
-		<table border="0" cellpadding="2" cellspacing="0">
-		<tbody>
-			<tr>
-				<td><input type="submit" value="{$APP.LBL_EDIT_BUTTON_LABEL}" class="crmButton small edit" name="edit"></td>
-				<td>&nbsp;</td>
-			</tr>
-			
-		</tbody>
-		</table>
-		</td>
-		</tr>
-          </tbody>
-	  </table>
-	</td>
-        </tr>
-        </tbody>
-	</table>
-      </td>
-      </tr>
-      </tbody></table>
-      <table class="small" border="0" cellpadding="0" cellspacing="0" width="100%">
-           <tbody><tr>
-                <td><img src="{$IMAGE_PATH}prvPrfBottomLeft.gif"></td>
-                <td class="prvPrfBottomBg" width="100%"></td>
-                <td><img src="{$IMAGE_PATH}prvPrfBottomRight.gif"></td>
-                </tr>
-            </tbody>
-      </table></td>
-      </tr>
-      </tbody></table>
-	<p>&nbsp;</p>
-	<table border="0" cellpadding="5" cellspacing="0" width="100%">
-	<tbody><tr><td class="small" align="right" nowrap="nowrap"><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
-	</tbody></table>
-					
-	</td>
-	</tr>
-	</tbody></table>
-	</form>	
-	<!-- End of Display -->
-	</td>
-	</tr>
-	</table>
-	</td>
-	</tr>
-	</table>
-	</div>
-
-	</td>
-	<td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-	</tr>
-</tbody>
-</table>
-<script language="javascript" type="text/javascript">
-{literal}
-function fnToggleVIew(obj){
-	var tagStyle = document.getElementById(obj).className;
-	if(tagStyle == 'hideTable')
-		document.getElementById(obj).className = 'showTable';
-	else
-		document.getElementById(obj).className = 'hideTable';
-}
-{/literal}
-{literal}
-        //for move RenameProfile
-        var theEventHandle = document.getElementById("renameUI");
-        var theEventRoot   = document.getElementById("renameProfile");
-        Drag.init(theEventHandle, theEventRoot);
-{/literal}
-</script>
-
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+{literal}
+<style>
+.showTable{
+	display:inline-table;
+}
+.hideTable{
+	display:none;
+}
+</style>
+{/literal}
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/general.js"></script>
+<script language="JAVASCRIPT" type="text/javascript">
+{literal}
+function UpdateProfile()
+{
+	var prof_name = $('profile_name').value;
+	var prof_desc = $('description').value;
+	if(prof_name == '')
+	{
+		
+		$('profile_name').focus();
+		{/literal}
+                alert("{$APP.PROFILENAME_CANNOT_BE_EMPTY}");
+                {literal}
+	}
+	else
+	{
+		
+{/literal}
+		
+		var urlstring ="module=Users&action=UsersAjax&file=RenameProfile&profileid="+{$PROFILEID}+"&profilename="+prof_name+"&description="+prof_desc;
+{literal}
+	new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody:urlstring,
+			onComplete: function(response)
+			{
+				$('renameProfile').style.display="none";
+				window.location.reload();
+				{/literal}
+                                alert("{$APP.PROFILE_DETAILS_UPDATED}");
+                                {literal}
+			}
+                }
+		);
+	}
+		
+	
+}
+</script>
+{/literal}
+
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+        <br>
+	<div align=center>
+			{include file='SetMenu.tpl'}
+			
+				<form  method="post" name="new" id="form">
+			        <input type="hidden" name="module" value="Settings">
+			        <input type="hidden" name="action" value="profilePrivileges">
+			        <input type="hidden" name="parenttab" value="Settings">
+			        <input type="hidden" name="return_action" value="profilePrivileges">
+			        <input type="hidden" name="mode" value="edit">
+			        <input type="hidden" name="profileid" value="{$PROFILEID}">
+				
+				<!-- DISPLAY -->
+				<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
+				<tbody><tr>
+					<td rowspan="2" valign="top" width="50"><img src="{$IMAGE_PATH}ico-profile.gif" alt="{$MOD.LBL_PROFILES}" title="{$MOD.LBL_PROFILES}" border="0" height="48" width="48"></td>
+					<td class="heading2" valign="bottom"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings">{$CMOD.LBL_PROFILE_PRIVILEGES}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$PROFILE_NAME}&quot;</b></td>
+				</tr>
+				<tr>
+					<td class="small" valign="top">{$CMOD.LBL_PROFILE_MESG} &quot;{$PROFILE_NAME}&quot; </td>
+				</tr>
+				</tbody></table>
+				
+				
+				<table border="0" cellpadding="10" cellspacing="0" width="100%">
+				<tbody><tr>
+				<td valign="top">
+					<table border="0" cellpadding="0" cellspacing="0" width="100%">
+                      <tbody><tr>
+                        <td><table border="0" cellpadding="0" cellspacing="0" width="100%">
+                            <tbody><tr class="small">
+                              <td><img src="{$IMAGE_PATH}prvPrfTopLeft.gif"></td>
+                              <td class="prvPrfTopBg" width="100%"></td>
+                              <td><img src="{$IMAGE_PATH}prvPrfTopRight.gif"></td>
+                            </tr>
+                          </tbody></table>
+                            <table class="prvPrfOutline" border="0" cellpadding="0" cellspacing="0" width="100%">
+                              <tbody><tr>
+                                <td><!-- tabs -->
+                                    
+                                    <!-- Headers -->
+                                    <table border="0" cellpadding="5" cellspacing="0" width="100%">
+                                      <tbody><tr>
+                                        <td><table class="small" border="0" cellpadding="5" cellspacing="0" width="100%">
+                                            <tbody><tr>
+                                              <td><!-- Module name heading -->
+                                                  <table class="small" border="0" cellpadding="2" cellspacing="0">
+                                                    <tbody><tr>
+                                                      <td valign="top"><img src="{$IMAGE_PATH}prvPrfHdrArrow.gif"> </td>
+                                                      <td class="prvPrfBigText"><b> {$CMOD.LBL_DEFINE_PRIV_FOR} &lt;{$PROFILE_NAME}&gt; </b><br>
+                                                      <font class="small">{$CMOD.LBL_USE_OPTION_TO_SET_PRIV}</font> </td>
+                                                      <td class="small" style="padding-left: 10px;" align="right"></td>
+
+                                                    </tr>
+                                                </tbody></table></td>
+                                              <td align="right" valign="bottom">&nbsp;<input type="button" value="{$APP.LBL_RENAMEPROFILE_BUTTON_LABEL}" class="crmButton small edit" name="rename_profile"  onClick = "show('renameProfile');">&nbsp;<input type="submit" value="{$APP.LBL_EDIT_BUTTON_LABEL}" class="crmButton small edit" name="edit" >
+                              		     </td>
+					    	
+                                            </tr></tbody></table>
+					    <!-- RenameProfile Div start -->	 
+					    <div class="layerPopup"  style="left:350px;width:500px;top:300px;display:none;" id="renameProfile">
+						<table class="layerHeadingULine" border="0" cellpadding="3" cellspacing="0" width="100%">
+						<tr style="cursor:move;">
+						<td class="layerPopupHeading" id = "renameUI" align="left" width="60%">{$APP.LBL_RENAME_PROFILE}</td>
+						<td align="right" width="40%"><a href="javascript:hide('renameProfile');"><img src="themes/bluelagoon/images/close.gif" align="middle" border="0"></a></td>
+						</tr>
+						</table>
+					    <table align="center" border="0" cellpadding="5" cellspacing="0" width="95%">
+
+						<tr>
+						<td class="small">
+							<table celspacing="0" align="center" bgcolor="white" border="0" cellpadding="5" width="100%">
+								<tr>
+								<td align="right" width="25%" style="padding-right:10px;" nowrap><b>{$APP.LBL_PROFILE_NAME} :</b></td>
+								<td align="left" width="75%" style="padding-right:10px;"><input id = "profile_name" name="profile_name" class="txtBox" value="{$PROFILE_NAME}" type="text"></td>
+								</tr>
+								<tr>
+                                                                <td align="right" width="25%" style="padding-right:10px;" nowrap><b>{$APP.LBL_DESCRIPTION} :</b></td>
+                                                                <td align="left" width="75%" style="padding-right:10px;"><textarea name="description" id = "description" class="txtBox">{$PROFILE_DESCRIPTION} </textarea></td>
+                                                                </tr>
+							</table>
+						</td>
+						</tr>
+					    </table>
+					    <table class="layerPopupTransport" border="0" cellpadding="5" cellspacing="0" width="100%">
+					    <tr>
+						<td align = "center">
+							<input name="save" value="Update" class="crmbutton small save" onclick="UpdateProfile();" type="button">&nbsp;&nbsp;
+							<input name="cancel" value="Cancel" class="crmbutton small save" onclick="hide('renameProfile');" type="button">&nbsp;&nbsp;
+						</td>
+					    </tr>		
+					    </table>		
+					    </div>		
+				             <!- RenameProfile Div end -->		
+
+                                         
+                                            <!-- privilege lists -->
+                                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
+                                              <tbody><tr>
+                                                <td style="height: 10px;" align="center"><img src="{$IMAGE_PATH}prvPrfLine.gif" style="width: 100%; height: 1px;"></td>
+                                              </tr>
+                                            </tbody></table>
+                                            <table border="0" cellpadding="10" cellspacing="0" width="100%">
+                                              <tbody><tr>
+                                                <td>
+						<table border="0" cellpadding="5" cellspacing="0" width="100%">
+  						<tbody>
+							<tr>
+    							<td class="cellLabel big"> {$CMOD.LBL_SUPER_USER_PRIV} </td>
+						       </tr>
+						</tbody>
+						</table>
+						<table class="small" align="center" border="0" cellpadding="5" cellspacing="0" width="90%">
+                                                <tbody><tr>
+                                                    <td class="prvPrfTexture" style="width: 20px;">&nbsp;</td>
+                                                    <td valign="top" width="97%"><table class="small" border="0" cellpadding="2" cellspacing="0" width="100%">
+                                                      <tbody>
+				                         <tr id="gva">
+                                                          <td valign="top">{$GLOBAL_PRIV.0}</td>
+                                                          <td ><b>{$CMOD.LBL_VIEW_ALL}</b> </td>
+                                                        </tr>
+                                                        <tr >
+                                                          <td valign="top"></td>
+                                                          <td width="100%" >{$CMOD.LBL_ALLOW} "{$PROFILE_NAME}" {$CMOD.LBL_MESG_VIEW}</td>
+                                                        </tr>
+                                                        <tr>
+                                                          <td>&nbsp;</td>
+                                                        </tr>
+							<tr>
+							<td valign="top">{$GLOBAL_PRIV.1}</td>
+							<td ><b>{$CMOD.LBL_EDIT_ALL}</b> </td>
+							</tr>
+                                                        <tr>
+                                                          <td valign="top"></td>
+                                                          <td > {$CMOD.LBL_ALLOW} "{$PROFILE_NAME}" {$CMOD.LBL_MESG_EDIT}</td>
+                                                        </tr>
+
+                                                      </tbody></table>
+						</td>
+                                                  </tr>
+                                                </tbody></table>
+<br>
+
+			<table border="0" cellpadding="5" cellspacing="0" width="100%">
+			  <tbody><tr>
+			    <td class="cellLabel big"> {$CMOD.LBL_SET_PRIV_FOR_EACH_MODULE} </td>
+			  </tr>
+			</tbody></table>
+			<table class="small" align="center" border="0" cellpadding="5" cellspacing="0" width="90%">
+			  <tbody><tr>
+			    <td class="prvPrfTexture" style="width: 20px;">&nbsp;</td>
+			    <td valign="top" width="97%">
+				<table class="small listTable" border="0" cellpadding="5" cellspacing="0" width="100%">
+			        <tbody>
+				<tr id="gva">
+			          <td colspan="2" rowspan="2" class="small colHeader"><strong> {$CMOD.LBL_TAB_MESG_OPTION} </strong><strong></strong></td>
+			          <td colspan="3" class="small colHeader"><div align="center"><strong> {$CMOD.LBL_EDIT_PERMISSIONS} </strong></div></td>
+			          <td rowspan="2" class="small colHeader" nowrap="nowrap"> {$CMOD.LBL_FIELDS_AND_TOOLS_SETTINGS} </td>
+			        </tr>
+			        <tr id="gva">
+			          <td class="small colHeader"><div align="center"><strong>{$CMOD.LBL_CREATE_EDIT}
+			          </strong></div></td>
+			          <td class="small colHeader"> <div align="center"><strong>{$CMOD.LBL_VIEW} </strong></div></td>
+			          <td class="small colHeader"> <div align="center"><strong>{$CMOD.LBL_DELETE}</strong></div></td>
+			        </tr>
+					
+				<!-- module loops-->
+			        {foreach key=tabid item=elements from=$TAB_PRIV}	
+			        <tr>
+                                        {assign var=modulename value=$TAB_PRIV[$tabid][0]}
+			          <td class="small cellLabel" width="3%"><div align="right">
+					{$TAB_PRIV[$tabid][1]}
+			          </div></td>
+			          <td class="small cellLabel" width="40%"><p>{$APP[$modulename]}</p></td>
+			          <td class="small cellText" width="15%">&nbsp;<div align="center">
+					{$STANDARD_PRIV[$tabid][1]}
+			          </div></td>
+			          <td class="small cellText" width="15%">&nbsp;<div align="center">
+					{$STANDARD_PRIV[$tabid][3]}
+			          </div></td>
+			          <td class="small cellText" width="15%">&nbsp;<div align="center">
+					{$STANDARD_PRIV[$tabid][2]}
+        			  </div></td>
+			          <td class="small cellText" width="22%">&nbsp;<div align="center">
+				{if $FIELD_PRIVILEGES[$tabid] neq NULL || $modulename eq 'Emails'}
+				<img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onclick="fnToggleVIew('{$modulename}_view')" border="0" height="16" width="40">
+				{/if}
+				</div></td>
+				  </tr>
+		                  <tr class="hideTable" id="{$modulename}_view" className="hideTable">
+				          <td colspan="6" class="small settingsSelectedUI">
+						<table class="small" border="0" cellpadding="2" cellspacing="0" width="100%">
+			        	    	<tbody>
+						{if $FIELD_PRIVILEGES[$tabid] neq ''}
+						<tr>
+							{if $modulename eq 'Calendar'}
+				                	<td class="small colHeader" colspan="6" valign="top">{$CMOD.LBL_FIELDS_SELECT_DESELECT} ({$APP.Tasks})</td>
+							{else}
+				                	<td class="small colHeader" colspan="6" valign="top">{$CMOD.LBL_FIELDS_SELECT_DESELECT}</td>
+							{/if}
+					        </tr>
+						{/if}
+						{foreach item=row_values from=$FIELD_PRIVILEGES[$tabid]}
+				            	<tr>
+						      {foreach item=element from=$row_values}
+					              <td valign="top">{$element.1}</td>
+					              <td>{$element.0}</td>
+						      {/foreach}
+				                </tr>
+						{/foreach}
+						{if $modulename eq 'Calendar'}
+						<tr>
+				                	<td class="small colHeader" colspan="6" valign="top">{$CMOD.LBL_FIELDS_SELECT_DESELECT}  ({$APP.Events})</td>
+					        </tr>
+						{foreach item=row_values from=$FIELD_PRIVILEGES[16]}
+				            	<tr>
+						      {foreach item=element from=$row_values}
+					              <td valign="top">{$element.1}</td>
+					              <td>{$element.0}</td>
+						      {/foreach}
+				                </tr>
+						{/foreach}
+						{/if}
+						{if $UTILITIES_PRIV[$tabid] neq ''}
+					        <tr>
+					              <td colspan="6" class="small colHeader" valign="top">{$CMOD.LBL_TOOLS_TO_BE_SHOWN} </td>
+						</tr>
+						{/if}
+						{foreach item=util_value from=$UTILITIES_PRIV[$tabid]}
+						<tr>
+							{foreach item=util_elements from=$util_value}
+					              		<td valign="top">{$util_elements.1}</td>
+						                <td>{$APP[$util_elements.0]}</td>
+							{/foreach}
+				               	</tr>
+						{/foreach}
+					        </tbody>
+						</table>
+					</td>
+			          </tr>
+				  {/foreach}	
+			    	  </tbody>
+				  </table>
+			  </td>
+			  </tr>
+                          </tbody>
+			</table>
+		</td>
+                </tr>
+		<table border="0" cellpadding="2" cellspacing="0">
+			<tr>
+				<td align="left"><font color="red" size=5>*</font>{$CMOD.LBL_MANDATORY_MSG}</td>
+			</tr>
+			<tr>
+				<td align="left"><font color="blue" size=5>*</font>{$CMOD.LBL_DISABLE_FIELD_MSG}</td>
+			</tr>
+		</table>
+		<tr>
+		<td style="border-top: 2px dotted rgb(204, 204, 204);" align="right">
+		<!-- wizard buttons -->
+		<table border="0" cellpadding="2" cellspacing="0">
+		<tbody>
+			<tr>
+				<td><input type="submit" value="{$APP.LBL_EDIT_BUTTON_LABEL}" class="crmButton small edit" name="edit"></td>
+				<td>&nbsp;</td>
+			</tr>
+			
+		</tbody>
+		</table>
+		</td>
+		</tr>
+          </tbody>
+	  </table>
+	</td>
+        </tr>
+        </tbody>
+	</table>
+      </td>
+      </tr>
+      </tbody></table>
+      <table class="small" border="0" cellpadding="0" cellspacing="0" width="100%">
+           <tbody><tr>
+                <td><img src="{$IMAGE_PATH}prvPrfBottomLeft.gif"></td>
+                <td class="prvPrfBottomBg" width="100%"></td>
+                <td><img src="{$IMAGE_PATH}prvPrfBottomRight.gif"></td>
+                </tr>
+            </tbody>
+      </table></td>
+      </tr>
+      </tbody></table>
+	<p>&nbsp;</p>
+	<table border="0" cellpadding="5" cellspacing="0" width="100%">
+	<tbody><tr><td class="small" align="right" nowrap="nowrap"><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
+	</tbody></table>
+					
+	</td>
+	</tr>
+	</tbody></table>
+	</form>	
+	<!-- End of Display -->
+	</td>
+	</tr>
+	</table>
+	</td>
+	</tr>
+	</table>
+	</div>
+
+	</td>
+	<td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+	</tr>
+</tbody>
+</table>
+<script language="javascript" type="text/javascript">
+{literal}
+function fnToggleVIew(obj){
+	var tagStyle = document.getElementById(obj).className;
+	if(tagStyle == 'hideTable')
+		document.getElementById(obj).className = 'showTable';
+	else
+		document.getElementById(obj).className = 'hideTable';
+}
+{/literal}
+{literal}
+        //for move RenameProfile
+        var Handle = document.getElementById("renameUI");
+        var Root   = document.getElementById("renameProfile");
+        Drag.init(Handle,Root);
+{/literal}
+</script>
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreate.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreate.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreate.tpl Mon Apr 16 12:27:44 2007
@@ -17,7 +17,7 @@
 	<table border=0 cellspacing=0 cellpadding=0 width="100%" class=small>
 	<tr>
 		<td width-90% class="mailSubHeader" background="{$IMAGE_PATH}qcBg.gif"><b >{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.$QCMODULE}</b></td>
-		<td nowrap class="mailSubHeader moduleName" align=right><i>Quick Create</i></td></tr>
+		<td nowrap class="mailSubHeader moduleName" align=right><i>{$APP.LBL_QUICK_CREATE}</i></td></tr>
 	</table>
 
 	<table border=0 cellspacing=0 cellpadding=0 width="100%" class="small">
@@ -66,10 +66,19 @@
 					{$fldlabel}
 				</td>
 				<td width="30%" align=left class="cellText">
-					<select name="{$fldname}">
+					{if $QCMODULE eq 'Event'}
+                                                {assign var=typejsfn value="onChange='calQCduedatetime();'"}
+                                        {else}
+                                                {assign var=typejsfn value=""}
+                                        {/if}
+					<select name="{$fldname}" {$typejsfn}>
 					{foreach item=arr from=$fldvalue}
 						{foreach key=sel_value item=value from=$arr}
+							{if $MOD.$sel_value neq ''}
 							<option value="{$sel_value}" {$value}>{$MOD.$sel_value}</option>
+							{else}
+							<option value="{$sel_value}" {$value}>{$sel_value}</option>
+							{/if}
 						{/foreach}
 					{/foreach}
 					</select>
@@ -150,14 +159,14 @@
 									{assign var='popuptype' value = 'specific_contact_account_address'}
 								{/if}
 							<td width="20%" class="cellLabel" align=right>{$fldlabel}</td>
-							<td width="30%" align=left class="cellText"><input readonly size="9" name="account_name" style="border:1px solid #bababa;" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific&form=EditView&form_submit=false&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.account_id.value=''; this.form.account_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+							<td width="30%" align=left class="cellText"><input readonly size="9" name="account_name" style="border:1px solid #bababa;" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific&form=EditView&form_submit=false&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.account_id.value=''; this.form.account_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 	
 							{elseif $uitype eq 50}
 							<td width="20%" class="cellLabel" align=right><font color="red">*</font>{$fldlabel}</td>
-							<td width="30%" align=left class="cellText"><input readonly name="account_name" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific&form=TasksEditView&form_submit=false&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+							<td width="30%" align=left class="cellText"><input readonly name="account_name" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific&form=TasksEditView&form_submit=false&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 							{elseif $uitype eq 73}
                                                         <td width="20%" class="cellLabel" align=right><font color="red">*</font>{$fldlabel}</td>
-							<td width="30%" align=left class="cellText"><input readonly name="account_name" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific_account_address&form=TasksEditView&form_submit=false&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+							<td width="30%" align=left class="cellText"><input readonly name="account_name" type="text" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&action=Popup&popuptype=specific_account_address&form=TasksEditView&form_submit=false&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 							
 							{elseif $uitype eq 75 || $uitype eq 81}
                                                           <td width="20%" class="cellLabel" align=right>
@@ -168,25 +177,25 @@
                                                                 {/if}
                                                                 {$fldlabel}
                                                           </td>
-                                                          <td width="30%" align=left class="cellText"><input name="vendor_name" readonly size="8" type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Vendors&action=Popup&html=Popup_picker&popuptype={$pop_type}&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>
+                                                          <td width="30%" align=left class="cellText"><input name="vendor_name" readonly size="8" type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Vendors&action=Popup&html=Popup_picker&popuptype={$pop_type}&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>
 							  {if $uitype eq 75}
-                                                           &nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.vendor_id.value='';this.form.vendor_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+                                                           &nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.vendor_id.value='';this.form.vendor_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 							  {/if}
 							{elseif $uitype eq 57}
 							<td width="20%" class="cellLabel" align=right>{$fldlabel}</td>
-							<td width="30%" align=left class="cellText"><input size="8" name="contact_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.contact_id.value=''; this.form.contact_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+							<td width="30%" align=left class="cellText"><input size="8" name="contact_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.contact_id.value=''; this.form.contact_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 
 							{elseif $uitype eq 80}
 							<td width="20%" class="cellLabel" align=right>{$fldlabel}</td>
-							<td width="30%" align=left class="cellText"><input size="8" name="salesorder_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.salesorder_id.value=''; this.form.salesorder_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+							<td width="30%" align=left class="cellText"><input size="8" name="salesorder_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.salesorder_id.value=''; this.form.salesorder_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 							
 							 {elseif $uitype eq 78}
 							 <td width="20%" class="cellLabel" align=right>{$fldlabel}</td>
-							 <td width="30%" align=left class="cellText"><input size="8" name="quote_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$ID}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.quote_id.value=''; this.form.quote_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+							 <td width="30%" align=left class="cellText"><input size="8" name="quote_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$ID}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.quote_id.value=''; this.form.quote_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 
 							{elseif $uitype eq 76}
                                                         <td width="20%" class="cellLabel" align=right>{$fldlabel}</td>
-                                                        <td width="30%" align=left class="cellText"><input size="8" name="potential_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.potential_id.value=''; this.form.potential_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+                                                        <td width="30%" align=left class="cellText"><input size="8" name="potential_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}"><input name="{$fldname}" type="hidden" value="{$secondvalue}">&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.potential_id.value=''; this.form.potential_name.value='';return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 
 							{elseif $uitype eq 17}
 							<td width="20%" class="cellLabel" align=right>{$fldlabel}</td>
@@ -228,10 +237,22 @@
 								{assign var=date_val value="$date_value"}
 								{assign var=time_val value="$time_value"}
 							   {/foreach}
-							<input name="{$fldname}" id="jscal_field_{$fldname}" type="text" style="border:1px solid #bababa;" size="11" maxlength="10" value="{$date_val}">
+							   {foreach key=date_fmt item=date_str from=$secondvalue}
+                                                                {assign var=dateFormat value="$date_fmt"}
+                                                                {assign var=dateStr value="$date_str"}
+                                                           {/foreach}
+                                                        {if $uitype eq 6 && $QCMODULE eq 'Event'}
+                                                                {assign var=datejsfn value="onChange='dochange(\"jscal_field_date_start\",\"jscal_field_due_date\");'"}
+                                                                {assign var=timejsfn value="onChange='calQCduedatetime();'"}
+                                                                <input name="dateFormat" type="hidden" value="{$dateFormat}">
+                                                        {else}
+                                                                {assign var=datejsfn value=""}
+                                                                {assign var=timejsfn value=""}
+                                                        {/if}	
+							<input name="{$fldname}" id="jscal_field_{$fldname}" type="text" style="border:1px solid #bababa;" size="11" maxlength="10" value="{$date_val}" {$datejsfn}>
 							<img src="{$IMAGE_PATH}calendar.gif" id="jscal_trigger_{$fldname}">
 							{if $uitype eq 6}
-							   <input name="time_start" style="border:1px solid #bababa;" size="5" maxlength="5" type="text" value="{$time_val}">
+							   <input name="time_start" style="border:1px solid #bababa;" size="5" maxlength="5" type="text" value="{$time_val}" {$timejsfn} >
 							{/if}
 							{if $uitype eq 23 && $QCMODULE eq 'Event'}
                                                            <input name="time_end" style="border:1px solid #bababa;" size="5" maxlength="5" type="text" value="{$time_val}">
@@ -239,10 +260,6 @@
                                                                 getCalendarPopup('jscal_trigger_{$fldname}','jscal_field_{$fldname}','{$dateFormat}');
                                                              </script>
                                                         {/if}
-							{foreach key=date_format item=date_str from=$secondvalue}
-                                                                {assign var=dateFormat value="$date_format"}
-							        {assign var=dateStr value="$date_str"}
-							{/foreach}
 							{if $uitype eq 5 || $uitype eq 23}
 							   <br><font size=1><em old="(yyyy-mm-dd)">({$dateStr})</em></font>
 							   {else}
@@ -275,7 +292,7 @@
 							  </td>
 							<td width="30%" align=left class="cellText">
 							<input name="{$fldname}" type="hidden" value="{$secondvalue}"><input size="8" name="parent_name" readonly type="text" style="border:1px solid #bababa;" value="{$fldvalue}">
-						&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+						&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 							
 							{elseif $uitype eq 357}
 								<td width="20%" class="cellLabel" align=right>To:&nbsp;</td>
@@ -287,7 +304,7 @@
 		                                                                <option value="{$labelval}" {$selectval}>{$labelval}</option>
                 	                                                {/foreach}
                                                                 </select>
-								&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
+								&nbsp;<img src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&html=Popup_picker&form=HelpDeskEditView&fromlink=qcreate","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.parent_id.value=''; this.form.parent_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'></td>
 								<tr style="height:25px">
 								<td width="20%" class="cellLabel" align=right>CC:&nbsp;</td>	
 								<td width="30%" align=left class="cellText">
@@ -302,7 +319,7 @@
                                                            {$fldlabel}</td>
 	<td width="30%" align=left class="cellText">
 				<input name="{$fldname}" type="hidden" value="{$secondvalue}">
-				<input name="product_name" readonly type="text" value="{$fldvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="Select" title="Select" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=specific&fromlink=qcreate","test","width=640,height=565,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.product_id.value=''; this.form.product_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
+				<input name="product_name" readonly type="text" value="{$fldvalue}">&nbsp;<img tabindex="{$vt_tab}" src="{$IMAGE_PATH}select.gif" alt="{$APP.LBL_SELECT}" title="{$APP.LBL_SELECT}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype=specific&fromlink=qcreate","test","width=640,height=565,resizable=0,scrollbars=0,top=150,left=200");' align="absmiddle" style='cursor:hand;cursor:pointer'>&nbsp;<input type="image" src="{$IMAGE_PATH}clear_field.gif" alt="{$APP.LBL_CLEAR}" title="{$APP.LBL_CLEAR}" LANGUAGE=javascript onClick="this.form.product_id.value=''; this.form.product_name.value=''; return false;" align="absmiddle" style='cursor:hand;cursor:pointer'>
 			</td>
 		
 							{elseif $uitype eq 55} 
@@ -322,7 +339,7 @@
 						<td colspan="3" width="30%" align=left class="cellText">
 						{if $MODULE eq 'Products'}
 							<input name="imagelist" type="hidden" value="">
-						    <div id="files_list" style="border: 1px solid grey; width: 500px; padding: 5px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-size: x-small">Files Maximum 6
+						    <div id="files_list" style="border: 1px solid grey; width: 500px; padding: 5px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; font-size: x-small">{$APP.Files_Maximum_6}
 						    <input id="my_file_element" type="file" name="file_1" >
                             </div>
                             <script>
@@ -376,7 +393,14 @@
 		<!-- save cancel buttons -->
 		<table border=0 cellspacing=0 cellpadding=5 width=100% class=qcTransport>
 		<tr>
-			<td width=50% align=right><input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" ></td>
+
+										{if $MODULE eq 'Accounts'}
+									<td width=50% align=right><input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="AjaxDuplicateValidate('Accounts','accountname',this.form);" type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" ></td>
+										{else}
+											<td width=50% align=right><input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}" style="width:70px" ></td>
+										{/if}
+
+
 			<td width=50% align=left>
 				<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="hide('qcform'); $('qccombo').options.selectedIndex=0;" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 			</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreateHidden.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreateHidden.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/QuickCreateHidden.tpl Mon Apr 16 12:27:44 2007
@@ -17,71 +17,12 @@
 	<form name="QcEditView" onSubmit="return getFormValidate('qcform');" method="POST" action="index.php">
 {/if}
 
-{if $MODULE eq 'Accounts'}
+{if $MODULE eq 'Calendar'}
+	<input type="hidden" name="activity_mode" value="{$ACTIVITY_MODE}">
+{elseif $MODULE eq 'Events'}
+        <input type="hidden" name="activity_mode" value="{$ACTIVITY_MODE}">
+{/if}
+	<input type="hidden" name="record" value="">
+	<input type="hidden" name="action" value="Save">
 	<input type="hidden" name="module" value="{$MODULE}">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="email1" value="">
-	<input type="hidden" name="email2" value="">
 	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Leads'}
-	<input type="hidden" name="module" value="{$MODULE}">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="email2" value="">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Contacts'}
-	<input type="hidden" name="module" value="{$MODULE}">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="email2" value="">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Calendar'}
-	<input type="hidden" name="module" value="Calendar">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="activity_mode" value="{$ACTIVITY_MODE}">
-	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Events'}
-        <input type="hidden" name="module" value="Calendar">
-        <input type="hidden" name="record" value="">
-        <input type="hidden" name="activity_mode" value="{$ACTIVITY_MODE}">
-        <input type="hidden" name="assigned_user_id" value="{$USERID}">
-        <input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'HelpDesk'}
-	<input type="hidden" name="module" value="{$MODULE}">
-        <input type="hidden" name="return_module" value="HelpDesk">
-	<input type="hidden" name="record" value="">
-        <input type="hidden" name="parent_type" value="{$APP.record_type_default_key}">
-        <input type="hidden" name="assigned_user_id" value="{$USERID}">
-        <input type="hidden" name="action" value="Save">
-        <input type="hidden" name="return_action" value="DetailView">
-{elseif $MODULE eq 'Notes'}
-	<input type="hidden" name="module" value="{$MODULE}">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="parent_type" value="{$APP.record_type_default_key}">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Potentials'}
-	<input type="hidden" name="module" value="Potentials">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Campaigns'}
-        <input type="hidden" name="module" value="{$MODULE}">
-        <input type="hidden" name="record" value="">
-        <input type="hidden" name="assigned_user_id" value="{$USERID}">
-        <input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'PriceBooks'}
-	<input type="hidden" name="module" value="PriceBooks">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="action" value="Save">
-{elseif $MODULE eq 'Vendors'}
-	<input type="hidden" name="module" value="Vendors">
-	<input type="hidden" name="record" value="">
-	<input type="hidden" name="assigned_user_id" value="{$USERID}">
-	<input type="hidden" name="action" value="Save">
-
-{/if}
-
-

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListContents.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListContents.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListContents.tpl Mon Apr 16 12:27:44 2007
@@ -1,147 +1,188 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-
-{if $SinglePane_View eq 'true'}
-	{assign var = return_modname value='DetailView'}
-{else}
-	{assign var = return_modname value='CallRelatedList'}
-{/if}
-
-{foreach key=header item=detail from=$RELATEDLISTS}
-
-<table border=0 cellspacing=0 cellpadding=0 width=100% class="small" style="border-bottom:1px solid #999999;padding:5px;">
-        <tr>
-                <td  valign=bottom><b>{$APP.$header}</b></td>
-                {if $detail ne ''}
-                <td align=center>{$detail.navigation.0}</td>
-                {$detail.navigation.1}
-                {/if}
-                <td align=right>
-			{if $header eq 'Potentials'}
-                                <input title="{$APP.LBL_ADD_NEW} {$APP.Potential}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Potentials'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Potential}">
-                </td>
-                        {elseif $header eq 'PriceBooks'}
-                                {if $MODULE eq 'Products'}
-                                <input title="{$APP.LBL_ADD_TO} {$APP.PriceBook}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_ADD_TO} {$APP.PriceBook}" LANGUAGE=javascript onclick="this.form.action.value='AddProductToPriceBooks';this.form.module.value='Products'"  type="submit" name="button">
-                                {/if}
-                        {elseif $header eq 'Products'}
-                                {if $MODULE eq 'PriceBooks'}
-	                                <input title="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" LANGUAGE=javascript onclick="this.form.action.value='AddProductsToPriceBook';this.form.module.value='Products';this.form.return_module.value='Products';this.form.return_action.value='PriceBookDetailView'"  type="submit" name="button"></td>
-				{elseif $MODULE eq 'Potentials'}
-					<input title="Change" accessKey="" class="crmbutton small save" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">&nbsp;
-					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small save" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
-
-				{elseif $MODULE eq 'Vendors'}
-					<input title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessyKey="F" class="crmbutton small create" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module=Products&action=Popup&return_action={$return_modname}&popuptype=detailview&form=DetailView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button" name="button" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}">
-					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'; this.form.parent_id.value='';" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
-                                {else}
-					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
-				{/if}
-			{elseif $header eq 'Leads'}
-				{if $MODULE eq 'Campaigns'}
-				{$LEADCVCOMBO} <span id="lead_list_button"><input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button"></span>
-				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Lead}" LANGUAGE=javascript onclick='return window.open("index.php?module=Leads&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
-				{/if}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Lead}" accessyKey="F" class="crmbutton small edit" onclick="this.form.action.value='EditView';this.form.module.value='Leads'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Lead}"></td>
-			{elseif $header eq 'Contacts' }
-				{if $MODULE eq 'Calendar' || $MODULE eq 'Potentials' || $MODULE eq 'Vendors'}
-				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
-				{elseif $MODULE eq 'Emails'}
-				<input title="{$APP.LBL_BULK_MAILS}" accessykey="F" class="crmbutton small create" onclick="this.form.action.value='sendmail';this.form.return_action.value='DetailView';this.form.module.value='Emails';this.form.return_module.value='Emails';" name="button" value="{$APP.LBL_BULK_MAILS}" type="submit">&nbsp;
-				<input title="Change" accessKey="" class="crmbutton small create" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module=Emails&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
-				{elseif $MODULE eq 'Campaigns'}
-				{$CONTCVCOMBO}  <span id="contact_list_button"><input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button"></span>
-				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
-				{else}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
-				{/if}
-			{elseif $header eq 'Activities'}
-				{if $MODULE eq 'PurchaseOrder' || $MODULE eq 'Invoice' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Campaigns'}
-				<input type="hidden" name="activity_mode">
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Todo}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Calendar'; this.form.return_module.value='{$MODULE}'; this.form.activity_mode.value='Task'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Todo}"></td>
-				{else}
-				<input type="hidden" name="activity_mode">
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Todo}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Calendar'; this.form.return_module.value='{$MODULE}'; this.form.activity_mode.value='Task'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Todo}">&nbsp;
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Event}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Calendar'; this.form.return_module.value='{$MODULE}'; this.form.activity_mode.value='Events'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Event}"></td>
-				{/if}
-			{elseif $header eq 'HelpDesk'}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Ticket}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='HelpDesk'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Ticket}"></td>
-			{elseif $header eq 'Campaigns'}
-                                <input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Campaign}" LANGUAGE=javascript onclick='return window.open("index.php?module=Campaigns&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
-			{elseif $header eq 'Attachments'}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Note}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Notes'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Note}">&nbsp;
-				<input type="hidden" name="fileid">
-				<input title="{$APP.LBL_ADD_NEW} {$APP.LBL_ATTACHMENT}" accessyKey="F" class="crmbutton small create" onclick="window.open('index.php?module=uploads&action=uploadsAjax&file=upload&return_action={$return_modname}&return_module={$MODULE}&return_id={$ID}','Attachments','width=500,height=300');" type="button" name="button" value="{$APP.LBL_ADD_NEW} {$APP.LBL_ATTACHMENT}"></td>
-			{elseif $header eq 'Quotes'}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Quote}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Quotes'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Quote}"></td>
-			{elseif $header eq 'Invoice'}
-				{if $MODULE eq 'SalesOrder'}
-				<input type="hidden">
-				{else}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.Invoice}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Invoice'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Invoice}"></td>
-				{/if}
-			{elseif $header eq 'Sales Order'}
-				{if $MODULE eq 'Quotes'}
-				<input type="hidden">
-				{else}
-				<input title="{$APP.LBL_ADD_NEW} {$APP.SalesOrder}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='SalesOrder'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.SalesOrder}"></td>
-				{/if}
-			{elseif $header eq 'Purchase Order'}
-                                <input title="{$APP.LBL_ADD_NEW} {$APP.PurchaseOrder}" accessyKey="O" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.module.value='PurchaseOrder'; this.form.return_module.value='{$MODULE}'; this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.PurchaseOrder}"></td>
-                        {elseif $header eq 'Emails'}
-                                <input type="hidden" name="email_directing_module">
-                                <input type="hidden" name="record">
-                                <input title="{$APP.LBL_ADD_NEW} {$APP.Email}" accessyKey="F" class="crmbutton small create" onclick="fnvshobj(this,'sendmail_cont');sendmail('{$MODULE}',{$ID});" type="button" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Email}"></td>
-			{elseif $header eq 'Users'}
-                                {if $MODULE eq 'Calendar'}
-				<input title="Change" accessKey="" tabindex="2" type="button" class="crmbutton small edit" value="{$APP.LBL_SELECT_USER_BUTTON_LABEL}" name="button" LANGUAGE=javascript onclick='return window.open("index.php?module=Users&return_module=Calendar&return_action={$return_modname}&activity_mode=Events&action=Popup&popuptype=detailview&form=EditView&form_submit=true&select=enable&return_id={$ID}&recordid={$ID}","test","width=640,height=525,resizable=0,scrollbars=0")';>
-                                {elseif $MODULE eq 'Emails'}
-                                <input title="{$APP.LBL_BULK_MAILS}" accessykey="F" class="crmbutton small create" onclick="this.form.action.value='sendmail';this.form.return_action.value='DetailView';this.form.module.value='Emails';this.form.return_module.value='Emails';" name="button" value="{$APP.LBL_BULK_MAILS}" type="submit">&nbsp;
-                                <input title="Change" accesskey="" tabindex="2" class="crmbutton small edit" value="{$APP.LBL_SELECT_USER_BUTTON_LABEL}" name="Button" language="javascript" onclick='return window.open("index.php?module=Users&return_module=Emails&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=true&return_id={$ID}&recordid={$ID}","test","width=640,height=520,resizable=0,scrollbars=0");' type="button">&nbsp;</td>
-                                {/if}
-                        {elseif $header eq 'Activity History'}
-                                &nbsp;</td>
-                        {/if}
-        </tr>
-</table>
-{if $detail ne ''}
-	{foreach key=header item=detail from=$detail}
-		{if $header eq 'header'}
-			<table border=0 cellspacing=1 cellpadding=3 width=100% style="background-color:#eaeaea;" class="small">
-				<tr style="height:25px" bgcolor=white>
-				{foreach key=header item=headerfields from=$detail}
-					<td class="lvtCol">{$headerfields}</td>
-				{/foreach}
-                                </tr>
-		{elseif $header eq 'entries'}
-			{foreach key=header item=detail from=$detail}
-				<tr bgcolor=white>
-				{foreach key=header item=listfields from=$detail}
-	                                 <td>{$listfields}</td>
-				{/foreach}
-				</tr>
-			{/foreach}
-			</table>
-		{/if}
-	{/foreach}
-{else}
-	<table style="background-color:#eaeaea;color:eeeeee" border="0" cellpadding="3" cellspacing="1" width="100%" class="small">
-		<tr style="height: 25px;" bgcolor="white">
-			<td><i>{$APP.LBL_NONE_INCLUDED}</i></td>
-		</tr>
-	</table>
-{/if}
-<br><br>
-{/foreach}
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+
+{if $SinglePane_View eq 'true'}
+    {assign var = return_modname value='DetailView'}
+    {assign var = mylist value=$RELATEDLISTS}
+{else}
+    {if $RELATEDLISTS eq ''}
+	{assign var = return_modname value='CallDependencydList'}
+	{assign var = mylist value=$DEPENDENDLISTS}
+    {else}
+  	{assign var = return_modname value='CallRelatedList'}
+	{assign var = mylist value=$RELATEDLISTS}
+    {/if}
+{/if}
+{if $BASE_ACCOUNT neq ''}
+        {assign var="search_string" value="&search_field=accountid&query=true&searchtype=BasicSearch&search_text=$BASE_ACCOUNT&check_rel=potential_rel"}
+{/if}
+{foreach key=header item=detail from=$mylist}
+
+<table border=0 cellspacing=0 cellpadding=0 width=100% class="small" style="border-bottom:1px solid #999999;padding:5px;">
+        <tr>
+                <td  valign=bottom><b>{$APP.$header}</b></td>
+                {if $detail ne ''}
+                <td align=center>{$detail.navigation.0}</td>
+                {$detail.navigation.1}
+                {/if}
+                <td align=right>
+			{if $header eq 'Potentials'}
+				{if $MODULE eq 'Products'}
+					<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Potential}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Potential}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Potential}" LANGUAGE=javascript onclick='return window.open("index.php?module=Potentials&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">	
+				{elseif $MODULE eq 'Contacts'}
+                                        <input title="{$APP.LBL_ADD_NEW} {$APP.Potential}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Potentials';this.form.return_action.value='updateRelations'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Potential}">
+				{else}
+	                                <input title="{$APP.LBL_ADD_NEW} {$APP.Potential}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Potentials'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Potential}">
+				{/if}
+                </td>
+                        {elseif $header eq 'PriceBooks'}
+                                {if $MODULE eq 'Products'}
+                                <input title="{$APP.LBL_ADD_TO} {$APP.PriceBook}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_ADD_TO} {$APP.PriceBook}" LANGUAGE=javascript onclick="this.form.action.value='AddProductToPriceBooks';this.form.module.value='Products'"  type="submit" name="button">
+                                {/if}
+                        {elseif $header eq 'Products'}
+                                {if $MODULE eq 'PriceBooks'}
+	                                <input alt="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" title="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_PRODUCT_BUTTON_LABEL}" LANGUAGE=javascript onclick="this.form.action.value='AddProductsToPriceBook';this.form.module.value='Products';this.form.return_module.value='Products';this.form.return_action.value='PriceBookDetailView'"  type="submit" name="button"></td>
+				{elseif $MODULE eq 'Leads'}
+					<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{elseif $MODULE eq 'Accounts'}
+					<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{elseif $MODULE eq 'Contacts'}
+					<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{elseif $MODULE eq 'Potentials'}
+					<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessKey="" class="crmbutton small save" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">&nbsp;
+					<!-- input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small save" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td -->
+
+				{elseif $MODULE eq 'Vendors'}
+					<input title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" accessyKey="F" class="crmbutton small create" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module=Vendors&action=Popup&return_action={$return_modname}&popuptype=detailview&select=enable&form=DetailView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button" name="button" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}">
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'; this.form.parent_id.value='';" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
+                                {else}
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Product}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Products';this.form.return_module.value='{$MODULE}';this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Product}"></td>
+				{/if}
+			{elseif $header eq 'Leads'}
+				{if $MODULE eq 'Campaigns'}
+				{$LEADCVCOMBO}<input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button" onclick="loadCvList('Leads','{$ID}')">
+				<input alt="{$APP.LBL_SELECT_LEAD_BUTTON_LABEL}" title="{$APP.LBL_SELECT_LEAD_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Lead}" LANGUAGE=javascript onclick='return window.open("index.php?module=Leads&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{/if}
+				{if $MODULE eq 'Products'}
+					<input alt="{$APP.LBL_SELECT_LEAD_BUTTON_LABEL}" title="{$APP.LBL_SELECT_LEAD_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Lead}" LANGUAGE=javascript onclick='return window.open("index.php?module=Leads&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{else}
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Lead}" accessyKey="F" class="crmbutton small edit" onclick="this.form.action.value='EditView';this.form.module.value='Leads'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Lead}"></td>
+				{/if}
+			{elseif $header eq 'Accounts'}
+				{if $MODULE eq 'Products'}
+					<input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Account}" LANGUAGE=javascript onclick='return window.open("index.php?module=Accounts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{/if}
+			{elseif $header eq 'Contacts' }
+				{if $MODULE eq 'Calendar' || $MODULE eq 'Potentials' || $MODULE eq 'Vendors'}
+					<input alt="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" title="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}{$search_string}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
+				{elseif $MODULE eq 'Emails'}
+					<input title="{$APP.LBL_BULK_MAILS}" accessykey="F" class="crmbutton small create" onclick="this.form.action.value='sendmail';this.form.return_action.value='DetailView';this.form.module.value='Emails';this.form.return_module.value='Emails';" name="button" value="{$APP.LBL_BULK_MAILS}" type="submit">&nbsp;
+					<input alt="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" title="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" accessKey="" class="crmbutton small create" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module=Emails&action=Popup&popuptype=detailview&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
+				{elseif $MODULE eq 'Campaigns'}
+					{$CONTCVCOMBO}<input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button" onclick="loadCvList('Contacts','{$ID}')">
+					<input alt="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" title="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
+				{elseif $MODULE eq 'Products'}
+					<input alt="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" title="{$APP.LBL_SELECT_CONTACT_BUTTON_LABEL}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Contact}" LANGUAGE=javascript onclick='return window.open("index.php?module=Contacts&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+				{else}
+					<input title="{$APP.LBL_ADD_NEW} {$APP.Contact}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Contacts'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Contact}"></td>
+				{/if}
+			{elseif $header eq 'Activities'}
+				{if $MODULE eq 'PurchaseOrder' || $MODULE eq 'Invoice' || $MODULE eq 'SalesOrder' || $MODULE eq 'Quotes' || $MODULE eq 'Campaigns'}
+				<input type="hidden" name="activity_mode">
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Todo}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Calendar'; this.form.return_module.value='{$MODULE}'; this.form.activity_mode.value='Task'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Todo}"></td>
+				{else}
+				<input type="hidden" name="activity_mode">
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Todo}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Calendar'; this.form.return_module.value='{$MODULE}'; this.form.activity_mode.value='Task'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Todo}">&nbsp;
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Event}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Calendar'; this.form.return_module.value='{$MODULE}'; this.form.activity_mode.value='Events'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Event}"></td>
+				{/if}
+			{elseif $header eq 'HelpDesk'}
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Ticket}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='HelpDesk'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Ticket}"></td>
+			{elseif $header eq 'Campaigns'}
+                                <input alt="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Campaign}" title="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Campaign}" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Campaign}" LANGUAGE=javascript onclick='return window.open("index.php?module=Campaigns&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button"></td>
+			{elseif $header eq 'Attachments'}
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Note}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.return_action.value='{$return_modname}'; this.form.module.value='Notes'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Note}">&nbsp;
+				<input type="hidden" name="fileid">
+				<input title="{$APP.LBL_ADD_NEW} {$APP.LBL_ATTACHMENT}" accessyKey="F" class="crmbutton small create" onclick="window.open('index.php?module=uploads&action=uploadsAjax&file=upload&return_action={$return_modname}&return_module={$MODULE}&return_id={$ID}','Attachments','width=500,height=370');" type="button" name="button" value="{$APP.LBL_ADD_NEW} {$APP.LBL_ATTACHMENT}"></td>
+			{elseif $header eq 'Quotes'}
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Quote}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Quotes'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Quote}"></td>
+			{elseif $header eq 'Invoice'}
+				{if $MODULE eq 'SalesOrder'}
+				<input type="hidden">
+				{else}
+				<input title="{$APP.LBL_ADD_NEW} {$APP.Invoice}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='Invoice'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Invoice}"></td>
+				{/if}
+			{elseif $header eq 'Sales Order'}
+				{if $MODULE eq 'Quotes'}
+				<input type="hidden">
+				{else}
+				<input title="{$APP.LBL_ADD_NEW} {$APP.SalesOrder}" accessyKey="F" class="crmbutton small create" onclick="this.form.action.value='EditView';this.form.module.value='SalesOrder'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.SalesOrder}"></td>
+				{/if}
+			{elseif $header eq 'Purchase Order'}
+                                <input title="{$APP.LBL_ADD_NEW} {$APP.PurchaseOrder}" accessyKey="O" class="crmbutton small create" onclick="this.form.action.value='EditView'; this.form.module.value='PurchaseOrder'; this.form.return_module.value='{$MODULE}'; this.form.return_action.value='{$return_modname}'" type="submit" name="button" value="{$APP.LBL_ADD_NEW} {$APP.PurchaseOrder}"></td>
+                        {elseif $header eq 'Emails'}
+                                <input type="hidden" name="email_directing_module">
+                                <input type="hidden" name="record">
+                                <input title="{$APP.LBL_ADD_NEW} {$APP.Email}" accessyKey="F" class="crmbutton small create" onclick="fnvshobj(this,'sendmail_cont');sendmail('{$MODULE}',{$ID});" type="button" name="button" value="{$APP.LBL_ADD_NEW} {$APP.Email}"></td>
+			{elseif $header eq 'Users'}
+                                {if $MODULE eq 'Calendar'}
+				<input title="Change" accessKey="" tabindex="2" type="button" class="crmbutton small edit" value="{$APP.LBL_SELECT_USER_BUTTON_LABEL}" name="button" LANGUAGE=javascript onclick='return window.open("index.php?module=Users&return_module=Calendar&return_action={$return_modname}&activity_mode=Events&action=Popup&popuptype=detailview&form=EditView&form_submit=true&select=enable&return_id={$ID}&recordid={$ID}","test","width=640,height=525,resizable=0,scrollbars=0")';>
+                                {elseif $MODULE eq 'Emails'}
+                                <input title="{$APP.LBL_BULK_MAILS}" accessykey="F" class="crmbutton small create" onclick="this.form.action.value='sendmail';this.form.return_action.value='DetailView';this.form.module.value='Emails';this.form.return_module.value='Emails';" name="button" value="{$APP.LBL_BULK_MAILS}" type="submit">&nbsp;
+                                <input title="Change" accesskey="" tabindex="2" class="crmbutton small edit" value="{$APP.LBL_SELECT_USER_BUTTON_LABEL}" name="Button" language="javascript" onclick='return window.open("index.php?module=Users&return_module=Emails&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=true&return_id={$ID}&recordid={$ID}","test","width=640,height=520,resizable=0,scrollbars=0");' type="button">&nbsp;</td>
+                                {/if}
+                        {elseif $header eq 'Activity History'}
+                                &nbsp;</td>
+                        {elseif $header eq 'Piecelist'}
+				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}&dependency_type=10","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+                        {elseif $header eq 'Incompatibles'}
+				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}&dependency_type=21","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+                        {elseif $header eq 'Options'}
+				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}&dependency_type=30","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+                        {elseif $header eq 'Dependencies'}
+				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}&dependency_type=20","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+                        {elseif $header eq 'Purchaselist'}
+				<input title="Change" accessKey="" class="crmbutton small edit" value="{$APP.LBL_SELECT_BUTTON_LABEL} {$APP.Product}" LANGUAGE=javascript onclick='return window.open("index.php?module=Products&return_module={$MODULE}&action=Popup&popuptype=detailview&select=enable&form=EditView&form_submit=false&recordid={$ID}&dependency_type=40","test","width=640,height=602,resizable=0,scrollbars=0");' type="button"  name="button">
+                        {/if}
+        </tr>
+</table>
+{if $detail ne ''}
+	{foreach key=header item=detail from=$detail}
+		{if $header eq 'header'}
+			<table border=0 cellspacing=1 cellpadding=3 width=100% style="background-color:#eaeaea;" class="small">
+				<tr style="height:25px" bgcolor=white>
+				{foreach key=header item=headerfields from=$detail}
+					<td class="lvtCol">{$headerfields}</td>
+				{/foreach}
+                                </tr>
+		{elseif $header eq 'entries'}
+			{foreach key=header item=detail from=$detail}
+				<tr bgcolor=white>
+				{foreach key=header item=listfields from=$detail}
+	                                 <td>{$listfields}</td>
+				{/foreach}
+				</tr>
+			{/foreach}
+			</table>
+		{/if}
+	{/foreach}
+{else}
+	<table style="background-color:#eaeaea;color:eeeeee" border="0" cellpadding="3" cellspacing="1" width="100%" class="small">
+		<tr style="height: 25px;" bgcolor="white">
+			<td><i>{$APP.LBL_NONE_INCLUDED}</i></td>
+		</tr>
+	</table>
+{/if}
+<br><br>
+{/foreach}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListNew.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListNew.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/RelatedListNew.tpl Mon Apr 16 12:27:44 2007
@@ -11,8 +11,8 @@
  ********************************************************************************/
 
 -->*}
-<script language="JavaScript" type="text/javascript" src="modules/PriceBooks/PriceBook.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/PriceBooks/PriceBooks.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 {literal}
 <script>
 function editProductListPrice(id,pbid,price)
@@ -40,7 +40,7 @@
                         'index.php',
                         {queue: {position: 'end', scope: 'command'},
                                 method: 'post',
-                                postBody: 'module=Products&action=ProductsAjax&file=UpdateListPrice&ajax=true&return_action=DetailView&return_module=PriceBooks&record='+id+'&pricebook_id='+pbid+'&product_id='+proid+'&list_price='+listprice,
+                                postBody: 'module=Products&action=ProductsAjax&file=UpdateListPrice&ajax=true&return_action=CallRelatedList&return_module=PriceBooks&record='+id+'&pricebook_id='+pbid+'&product_id='+proid+'&list_price='+listprice,
                                 onComplete: function(response) {
                                         $("status").style.display="none";
                                         $("RLContents").innerHTML= response.responseText;
@@ -51,11 +51,22 @@
 {/literal}
 
 function loadCvList(type,id) {ldelim}
+        $("status").style.display="inline";
 	if(type === 'Leads')
 	{ldelim}
 		if($("lead_cv_list").value != 'None')
 		{ldelim}
-			$("lead_list_button").innerHTML = '<input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button" onclick="window.location.href=\'index.php?action=LoadList&module=Campaigns&return_action=DetailView&return_id='+id+'&list_type='+type+'&cvid='+$("lead_cv_list").value+'\'">';
+			new Ajax.Request(
+                        'index.php',
+                        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                                method: 'post',
+                                postBody: 'module=Campaigns&action=CampaignsAjax&file=LoadList&ajax=true&return_action=DetailView&return_id='+id+'&list_type='+type+'&cvid='+$("lead_cv_list").value,
+                                onComplete: function(response) {ldelim}
+                                        $("status").style.display="none";
+                                        $("RLContents").innerHTML= response.responseText;
+                                {rdelim}
+                        {rdelim}
+                );
 		{rdelim}
 	{rdelim}
 
@@ -63,7 +74,17 @@
 	{ldelim}
 		if($("cont_cv_list").value != 'None')
 		{ldelim}
-		$("contact_list_button").innerHTML = '<input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button" onclick="window.location.href=\'index.php?action=LoadList&module=Campaigns&return_action=DetailView&return_id='+id+'&list_type='+type+'&cvid='+$("cont_cv_list").value+'\'">';
+			new Ajax.Request(
+                        'index.php',
+                        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                                method: 'post',
+                                postBody: 'module=Campaigns&action=CampaignsAjax&file=LoadList&ajax=true&return_action=DetailView&return_id='+id+'&list_type='+type+'&cvid='+$("cont_cv_list").value,
+                                onComplete: function(response) {ldelim}
+                                        $("status").style.display="none";
+                                        $("RLContents").innerHTML= response.responseText;
+                                {rdelim}
+                        {rdelim}
+                );
 		{rdelim}
 	{rdelim}
 {rdelim}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/RelatedLists.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/RelatedLists.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/RelatedLists.tpl Mon Apr 16 12:27:44 2007
@@ -11,8 +11,8 @@
  ********************************************************************************/
 
 -->*}
-<script language="JavaScript" type="text/javascript" src="modules/PriceBooks/PriceBook.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/PriceBooks/PriceBooks.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 {literal}
 <script>
 function editProductListPrice(id,pbid,price)
@@ -51,21 +51,41 @@
 {/literal}
 
 function loadCvList(type,id) {ldelim}
-	if(type === 'Leads')
-	{ldelim}
-		if($("lead_cv_list").value != 'None')
-		{ldelim}
-			$("lead_list_button").innerHTML = '<input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button" onclick="window.location.href=\'index.php?action=LoadList&module=Campaigns&return_id='+id+'&list_type='+type+'&cvid='+$("lead_cv_list").value+'\'">';
+	$("status").style.display="inline";
+        if(type === 'Leads')
+        {ldelim}
+                if($("lead_cv_list").value != 'None')
+                {ldelim}
+                        new Ajax.Request(
+                        'index.php',
+                        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                                method: 'post',
+                                postBody: 'module=Campaigns&action=CampaignsAjax&file=LoadList&ajax=true&return_action=DetailView&return_id='+id+'&list_type='+type+'&cvid='+$("lead_cv_list").value,
+                                onComplete: function(response) {ldelim}
+                                        $("status").style.display="none";
+                                        $("RLContents").innerHTML= response.responseText;
+                                {rdelim}
+                        {rdelim}
+                );
+                {rdelim}
+        {rdelim}
+        if(type === 'Contacts')
+        {ldelim}
+        if($("cont_cv_list").value != 'None')
+                {ldelim}
+                        new Ajax.Request(
+                        'index.php',
+                        {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                                method: 'post',
+                                postBody: 'module=Campaigns&action=CampaignsAjax&file=LoadList&ajax=true&return_action=DetailView&return_id='+id+'&list_type='+type+'&cvid='+$("cont_cv_list").value,
+                                onComplete: function(response) {ldelim}
+                                        $("status").style.display="none";
+                                        $("RLContents").innerHTML= response.responseText;
+                                {rdelim}
+                        {rdelim}
+                );
 		{rdelim}
-	{rdelim}
-
-	if(type === 'Contacts')
-	{ldelim}
-		if($("cont_cv_list").value !='None')
-		{ldelim}
-			$("contact_list_button").innerHTML = '<input title="{$MOD.LBL_LOAD_LIST}" accessKey="" class="crmbutton small edit" value="{$MOD.LBL_LOAD_LIST}" type="button"  name="button" onclick="window.location.href=\'index.php?action=LoadList&module=Campaigns&return_id='+id+'&list_type='+type+'&cvid='+$("cont_cv_list").value+'\'">';
-		{rdelim}
-	{rdelim}
+        {rdelim}
 {rdelim}
 </script>
 	{include file='Buttons_List1.tpl'}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ReportColumns.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ReportColumns.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ReportColumns.tpl Mon Apr 16 12:27:44 2007
@@ -35,7 +35,7 @@
 	</td>
 	<input type="hidden" name="selectedColumnsString"/>
 	<td style="padding-left: 5px;" align="left" width="40%">
-	<select id="selectedColumns" size="16" name="selectedColumns" multiple class="txtBox">
+	<select id="selectedColumns" size="16" name="selectedColumns" onClick="selectedColumnClick(this);" multiple class="txtBox">
 	{$BLOCK2}
 	</select>
 	</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ReportRun.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ReportRun.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ReportRun.tpl Mon Apr 16 12:27:44 2007
@@ -12,7 +12,7 @@
 
 -->*}
 <br>
-<script language="JavaScript" type="text/javascript" src="modules/Reports/Report.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/Reports/Reports.js"></script>
 <link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css">
 <script type="text/javascript" src="jscalendar/calendar.js"></script>
 <script type="text/javascript" src="jscalendar/lang/calendar-en.js"></script>
@@ -64,13 +64,13 @@
 			{if $report_in_fld_id neq $REPORTID}
 				<option value={$report_in_fld_id}>{$MOD.$report_in_fld_name}</option>
 			{else}	
-				<option value={$report_in_fld_id} "selected">{$MOD.$report_in_fld_name}</option>
+				<option value={$report_in_fld_id} selected>{$MOD.$report_in_fld_name}</option>
 			{/if}
 		{else}
 			{if $report_in_fld_id neq $REPORTID}
 				<option value={$report_in_fld_id}>{$report_in_fld_name}</option>
 			{else}	
-				<option value={$report_in_fld_id} "selected">{$report_in_fld_name}</option>
+				<option value={$report_in_fld_id} selected>{$report_in_fld_name}</option>
 			{/if}
 		{/if}
 		{/foreach}
@@ -205,7 +205,9 @@
 		var reportinfr = 'Reporting  "'+stdDateFilterFieldvalue+'"   (  till  '+enddatevalue+')';
 	}else if(startdatevalue == '' && enddatevalue =='')
 	{
-		var reportinfr = 'No filter Selected';
+		{/literal}
+                var reportinfr = "{$MOD.NO_FILTER_SELECTED}";
+                {literal}
 	}else if(startdatevalue != '' && enddatevalue !='')
 	{
 	var reportinfr = 'Reporting  "'+stdDateFilterFieldvalue+'"  of  "'+stdDateFiltervalue+'"  ( '+startdatevalue+'  to  '+enddatevalue+' )';

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Reports.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Reports.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Reports.tpl Mon Apr 16 12:27:44 2007
@@ -13,7 +13,7 @@
 -->*}
 
 {*<!-- module header -->*}
-<script language="JavaScript" type="text/javascript" src="modules/Reports/Report.js"></script>
+<script language="JavaScript" type="text/javascript" src="modules/Reports/Reports.js"></script>
 
 <!-- Toolbar -->
 <TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
@@ -28,13 +28,13 @@
 	<td>
 		<table border=0 cellspacing=0 cellpadding=0>
 			<tr>
-				<td style="padding-right:5px"><a href="javascript:;" onclick="gcurrepfolderid=0;fnvshobj(this,'reportLay');"><img src="{$IMAGE_PATH}reportsCreate.gif" alt="Create {$MODULE}..." title="Create {$MODULE}..." border=0></a></td>
+				<td style="padding-right:5px"><a href="javascript:;" onclick="gcurrepfolderid=0;fnvshobj(this,'reportLay');"><img src="{$IMAGE_PATH}reportsCreate.gif" alt="{$MOD.LBL_CREATE_REPORT}..." title="{$MOD.LBL_CREATE_REPORT}..." border=0></a></td>
                         <td>&nbsp;</td>
-            <td style="padding-right:5px"><a href="javascript:;" onclick="createrepFolder(this,'orgLay');"><img src="{$IMAGE_PATH}reportsFolderCreate.gif" alt="Create New Folder..." title="Create New Folder..." border=0></a></td>
+            <td style="padding-right:5px"><a href="javascript:;" onclick="createrepFolder(this,'orgLay');"><img src="{$IMAGE_PATH}reportsFolderCreate.gif" alt="{$MOD.Create_New_Folder}..." title="{$MOD.Create_New_Folder}..." border=0></a></td>
                         <td>&nbsp;</td>
-            <td style="padding-right:5px"><a href="javascript:;" onclick="fnvshobj(this,'folderLay');"><img src="{$IMAGE_PATH}reportsMove.gif" alt="Move Reports..." title="Move Reports..." border=0></a></td>
+            <td style="padding-right:5px"><a href="javascript:;" onclick="fnvshobj(this,'folderLay');"><img src="{$IMAGE_PATH}reportsMove.gif" alt="{$MOD.Move_Reports}..." title="{$MOD.Move_Reports}..." border=0></a></td>
                         <td>&nbsp;</td>
-            <td style="padding-right:5px"><a href="javascript:;" onClick="massDeleteReport();"><img src="{$IMAGE_PATH}reportsDelete.gif" alt="Delete Report..." title="Delete Report..." border=0></a></td>
+            <td style="padding-right:5px"><a href="javascript:;" onClick="massDeleteReport();"><img src="{$IMAGE_PATH}reportsDelete.gif" alt="{$MOD.LBL_DELETE_FOLDER}..." title="{$MOD.Delete_Report}..." border=0></a></td>
 			</tr>
 		</table>
 	</td>
@@ -82,15 +82,15 @@
 			<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
 			<tr>
 				<td align="right" nowrap class="cellLabel small"><b>{$MOD.LBL_REP_FOLDER_NAME} </b></td>
-				<td align="left" class="cellText small">
+				<td align="left">
 				<input id="folder_id" name="folderId" type="hidden" value=''>
 				<input id="fldrsave_mode" name="folderId" type="hidden" value='save'>
-				<input id="folder_name" name="folderName" class="txtBox" type="text">
+				<input id="folder_name" name="folderName"  type="text" width="100%" solid="#666666" font-family="Arial, Helvetica,sans-serif" font-size="11px">
 				</td>
 			</tr>
 			<tr>
 				<td class="cellLabel small" align="right" nowrap><b>{$MOD.LBL_REP_FOLDER_DESC} </b></td>
-				<td class="cellText small" align="left"><input id="folder_desc" name="folderDesc" class="txtBox" type="text"></td>
+				<td class="cellText small" align="left"><input id="folder_desc" name="folderDesc"  type="text" width="100%" solid="#666666" font-family="Arial, Helvetica,sans-serif" font-size="11px"></td>
 			</tr>
 			</table>
 		</td>
@@ -135,7 +135,9 @@
 {
 	var title = 'folder'+id;
 	var fldr_name = getObj(title).innerHTML;
-	if(confirm("Are you sure you want to delete the folder  '"+fldr_name +"' ?"))
+	{/literal}
+        if(confirm("{$APP.DELETE_FOLDER_CONFIRMATION}"+fldr_name +"' ?"))
+        {literal}
 	{
 		new Ajax.Request(
 			'index.php',
@@ -159,42 +161,74 @@
 {
 	if(getObj('folder_name').value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0)
 	{
-		alert('The Folder name cannot be empty');
-		return false;
+		{/literal}
+                alert('{$APP.FOLDERNAME_CANNOT_BE_EMPTY}');
+                return false;
+                {literal}
 	}
 	else
 	{
-		fninvsh('orgLay');
-		var foldername = getObj('folder_name').value;
-		var folderdesc = getObj('folder_desc').value;
-		getObj('folder_name').value = '';
-		getObj('folder_desc').value = '';
-		foldername = foldername.replace(/&/gi,'*amp*')
-			folderdesc = folderdesc.replace(/&/gi,'*amp*')
-			var mode = getObj('fldrsave_mode').value;
-		if(mode == 'save')
-		{
-			url ='&savemode=Save&foldername='+foldername+'&folderdesc='+folderdesc;
-		}
-		else
-		{
-			var folderid = getObj('folder_id').value;
-			url ='&savemode=Edit&foldername='+foldername+'&folderdesc='+folderdesc+'&record='+folderid;
-		}
-		getObj('fldrsave_mode').value = 'save';
 		new Ajax.Request(
                         'index.php',
                         {queue: {position: 'end', scope: 'command'},
                                 method: 'post',
-                                postBody: 'action=ReportsAjax&mode=ajax&file=SaveReportFolder&module=Reports'+url,
+                                postBody: 'action=ReportsAjax&mode=ajax&file=CheckReport&module=Reports&check=folderCheck&folderName='+getObj('folder_name').value,
                                 onComplete: function(response) {
-                                        var item = response.responseText;
-                                        getObj('customizedrep').innerHTML = item;
-                                }
-                        }
-                );
-	}
-}
+					if((response.responseText==1) && (mode == 'Edit'))
+					{
+						{/literal}
+                                                alert("{$APP.FOLDER_NAME_ALREADY_EXISTS}");
+                                                return false;
+                                                {literal}
+					}
+					else if((response.responseText !=0) && (mode == 'Edit'))
+					{
+						{/literal};
+                                                alert("{$APP.FOLDER_NAME_ALREADY_EXISTS}");
+                                                return false;
+                                                {literal}
+					}
+					else
+					{
+						fninvsh('orgLay');
+						var foldername = getObj('folder_name').value;
+						var folderdesc = getObj('folder_desc').value;
+						getObj('folder_name').value = '';
+						getObj('folder_desc').value = '';
+						foldername = foldername.replace(/&/gi,'*amp*')
+						folderdesc = folderdesc.replace(/&/gi,'*amp*')
+						var mode = getObj('fldrsave_mode').value;
+						if(mode == 'save')
+						{
+							url ='&savemode=Save&foldername='+foldername+'&folderdesc='+folderdesc;
+						}
+						else
+						{
+							var folderid = getObj('folder_id').value;
+							url ='&savemode=Edit&foldername='+foldername+'&folderdesc='+folderdesc+'&record='+folderid;
+						}
+						getObj('fldrsave_mode').value = 'save';
+						new Ajax.Request(
+				                        'index.php',
+				                        {queue: {position: 'end', scope: 'command'},
+			                                method: 'post',
+			                                postBody: 'action=ReportsAjax&mode=ajax&file=SaveReportFolder&module=Reports'+url,
+			                                onComplete: function(response) {
+			                                        var item = response.responseText;
+                        			                getObj('customizedrep').innerHTML = item;
+			                                }
+						}
+			                      
+				                );
+					}
+				}
+			}
+			);
+		
+	}
+}
+
+
 function EditFolder(id,name,desc)
 {
 {/literal}
@@ -241,8 +275,9 @@
 		}
 	}
 	if(idstring != '')
-	{
-		if(confirm("Are you sure you want to delete the selected "+count+" reports ?"))
+	{	{/literal}
+                if(confirm("{$APP.DELETE_CONFIRMATION}"+count+"{$APP.RECORDS}"))
+                {literal}
        		{
 			new Ajax.Request(
                         'index.php',
@@ -262,13 +297,17 @@
 			
 	}else
 	{
-		alert('Please select at least one Report');
-		return false;
+		{/literal}
+                alert('{$APP.SELECT_ATLEAST_ONE_REPORT}');
+                return false;
+                {literal}
 	}
 }
 function DeleteReport(id)
 {
-	if(confirm("Are you sure you want to delete this report ?"))
+	{/literal}
+        if(confirm("{$APP.DELETE_REPORT_CONFIRMATION}"))
+        {literal}
 	{
 		new Ajax.Request(
                         'index.php',
@@ -323,7 +362,9 @@
 	}
 	if(idstring != '')
 	{
-		if(confirm("Are you sure you want to move this report to "+foldername+" folder ?"))
+		{/literal}
+                if(confirm("{$APP.MOVE_REPORT_CONFIRMATION}"+foldername+"{$APP.FOLDER}"))
+                {literal}
         	{
 			new Ajax.Request(
                         'index.php',
@@ -342,8 +383,10 @@
 			
 	}else
 	{
-		alert('Please select at least one Report');
-		return false;
+		{/literal}
+                alert('{$APP.SELECT_ATLEAST_ONE_REPORT}');
+                return false;
+                {literal}
 	}
 }
 </script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ReportsCustomize.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ReportsCustomize.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ReportsCustomize.tpl Mon Apr 16 12:27:44 2007
@@ -23,7 +23,7 @@
 				<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
 		<td  width="5%" align="right"><input name="newReportInThisModule" value="{$MOD.LBL_CREATE_REPORT}..." class="crmButton small create" onclick="gcurrepfolderid={$reportfolder.id};fnvshobj(this,'reportLay')" type="button"></td>
 		<td  width="75%" align="right">
-			<input type="button" name="Edit" value=" {$MOD.LBL_RENAME_FOLDER} " class="crmbutton small edit" onClick="EditFolder('{$reportfolder.id}','{$reportfolder.name}','{$reportfolder.description}'),fnvshobj(this,'orgLay');">&nbsp;
+			<input type="button" name="Edit" value=" {$MOD.LBL_RENAME_FOLDER} " class="crmbutton small edit" onClick="EditFolder('{$reportfolder.id}','{$reportfolder.name|addslashes}','{$reportfolder.description|addslashes}'),fnvshobj(this,'orgLay');">&nbsp;
 		</td>
 		<td align="right">
 			<input type="button" name="delete" value=" {$MOD.LBL_DELETE_FOLDER} " class="crmbutton small delete" onClick="DeleteFolder('{$reportfolder.id}');">

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep0.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep0.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep0.tpl Mon Apr 16 12:27:44 2007
@@ -11,11 +11,13 @@
 -->*}
 <html>
 <head>
-	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-	<title>vtiger CRM - Create Report</title>
+	<meta http-equiv="Content-Type" content="text/html; charset={$APP.LBL_CHARSET}">
+	<title>{$MOD.TITLE_VTIGERCRM_CREATE_REPORT}</title>
 	<link href="{$THEME_PATH}style.css" rel="stylesheet" type="text/css">
 	<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-	<script language="JavaScript" type="text/javascript" src="modules/Reports/Report.js"></script>
+	<script language="JavaScript" type="text/javascript" src="include/js/{php} echo $_SESSION['authenticated_user_language'];{/php}.lang.js?{php} echo $_SESSION['vtiger_version'];{/php}"></script>
+	<script language="javascript" type="text/javascript" src="include/scriptaculous/prototype.js"></script>
+	<script language="JavaScript" type="text/javascript" src="modules/Reports/Reports.js"></script>
 </head>
 <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
 <table width="100%"  border="0" cellspacing="0" cellpadding="0" class="mailClient mailClientBg">

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep1.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep1.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ReportsStep1.tpl Mon Apr 16 12:27:44 2007
@@ -11,11 +11,12 @@
 -->*}
 <html>
 <head>
-	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-	<title>vtiger CRM - Create Report</title>
+	<meta http-equiv="Content-Type" content="text/html; charset={$APP.LBL_CHARSET}">
+	<title>{$MOD.TITLE_VTIGERCRM_CREATE_REPORT}</title>
 	<link href="{$THEME_PATH}style.css" rel="stylesheet" type="text/css">
 	<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-	<script language="JavaScript" type="text/javascript" src="modules/Reports/Report.js"></script>
+	<script language="JavaScript" type="text/javascript" src="include/js/{php} echo $_SESSION['authenticated_user_language'];{/php}.lang.js?{php} echo $_SESSION['vtiger_version'];{/php}"></script>
+	<script language="JavaScript" type="text/javascript" src="modules/Reports/Reports.js"></script>
 </head>
 <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
 <!-- Master Table -->

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/RoleDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/RoleDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/RoleDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -1,125 +1,125 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-        <br>
-
-	<div align=center>
-			{include file='SetMenu.tpl'}
-				<!-- DISPLAY -->
-				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-				<form id="form" name="roleView" action="index.php" method="post">
-				<input type="hidden" name="module" value="Users">
-				<input type="hidden" name="action" value="createrole">
-				<input type="hidden" name="parenttab" value="Settings">
-				<input type="hidden" name="returnaction" value="RoleDetailView">
-				<input type="hidden" name="roleid" value="{$ROLEID}">
-				<input type="hidden" name="mode" value="edit">
-				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-roles.gif" width="48" height="48" border=0 ></td>
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listroles&parenttab=Settings">{$CMOD.LBL_ROLES}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$ROLE_NAME}&quot; </b></td>
-				</tr>
-				<tr>
-					<td valign=top class="small">{$CMOD.LBL_VIEWING} {$CMOD.LBL_PROPERTIES} &quot;{$ROLE_NAME}&quot; {$MOD.LBL_LIST_CONTACT_ROLE} </td>
-				</tr>
-				</table>
-				
-				<br>
-				<table border=0 cellspacing=0 cellpadding=10 width=100% >
-				<tr>
-				<td valign=top>
-					
-					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-					<tr>
-						<td class="big"><strong>{$CMOD.LBL_PROPERTIES} &quot;{$ROLE_NAME}&quot; </strong></td>
-						<td><div align="right">
-					 	    <input value="   {$APP.LBL_EDIT_BUTTON_LABEL}   " title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmButton small edit" type="submit" name="Edit" >
-						</div></td>
-					  </tr>
-					</table>
-					<table width="100%"  border="0" cellspacing="0" cellpadding="5">
-                      <tr class="small">
-                        <td width="15%" class="small cellLabel"><strong>{$CMOD.LBL_ROLE_NAME}</strong></td>
-                        <td width="85%" class="cellText" >{$ROLE_NAME}</td>
-                      </tr>
-                      <tr class="small">
-                        <td class="small cellLabel"><strong>{$CMOD.LBL_REPORTS_TO}</strong></td>
-                        <td class="cellText">{$PARENTNAME}</td>
-                      </tr>
-                      <tr class="small">
-                        <td valign=top class="cellLabel"><strong>{$CMOD.LBL_MEMBER}</strong></td>
-                        <td class="cellText">
-						<table width="70%"  border="0" cellspacing="0" cellpadding="5">
-                          <tr class="small">
-                            		<td colspan="2" class="cellBottomDotLine">
-						<div align="left"><strong>{$CMOD.LBL_ASSOCIATED_PROFILES}</strong></div>
-					</td>
-                            </tr>
-			{foreach item=elements from=$ROLEINFO.profileinfo}
-                          <tr class="small">
-
-                            <td width="16"><div align="center"></div></td>
-                            <td>
-										<a href="index.php?module=Users&action=profilePrivileges&parenttab=Settings&profileid={$elements.0}&mode=view">{$elements.1}</a><br>
-			    </td>  	 
-                          </tr>
-			{/foreach}
-   <tr class="small">
-                            		<td colspan="2" class="cellBottomDotLine">
-						<div align="left"><strong>{$CMOD.LBL_ASSOCIATED_USERS}</strong></div>
-					</td>
-                            </tr>
-				{if $ROLEINFO.userinfo.0 neq ''}
-			{foreach item=elements from=$ROLEINFO.userinfo}
-                          <tr class="small">
-
-                            <td width="16"><div align="center"></div></td>
-                            <td>
-				<a href="index.php?module=Users&action=DetailView&parenttab=Settings&record={$elements.0}">{$elements.1}</a><br>
-			    </td>  	 
-                          </tr>
-			{/foreach}	
-			{/if}
-                        </table></td>
-                      </tr>
-                    </table>
-					<br>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr><td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
-					</table>
-					
-					
-				</td>
-				</tr>
-				</table>
-			
-			
-			
-			</td>
-			</tr>
-			</table>
-		</td>
-	</tr>
-	</form>
-	</table>
-		
-	</div>
-</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody>
-</table>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+        <br>
+
+	<div align=center>
+			{include file='SetMenu.tpl'}
+				<!-- DISPLAY -->
+				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
+				<form id="form" name="roleView" action="index.php" method="post">
+				<input type="hidden" name="module" value="Settings">
+				<input type="hidden" name="action" value="createrole">
+				<input type="hidden" name="parenttab" value="Settings">
+				<input type="hidden" name="returnaction" value="RoleDetailView">
+				<input type="hidden" name="roleid" value="{$ROLEID}">
+				<input type="hidden" name="mode" value="edit">
+				<tr>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-roles.gif" width="48" height="48" border=0 ></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listroles&parenttab=Settings">{$CMOD.LBL_ROLES}</a> &gt; {$CMOD.LBL_VIEWING} &quot;{$ROLE_NAME}&quot; </b></td>
+				</tr>
+				<tr>
+					<td valign=top class="small">{$CMOD.LBL_VIEWING} {$CMOD.LBL_PROPERTIES} &quot;{$ROLE_NAME}&quot; {$MOD.LBL_LIST_CONTACT_ROLE} </td>
+				</tr>
+				</table>
+				
+				<br>
+				<table border=0 cellspacing=0 cellpadding=10 width=100% >
+				<tr>
+				<td valign=top>
+					
+					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+					<tr>
+						<td class="big"><strong>{$CMOD.LBL_PROPERTIES} &quot;{$ROLE_NAME}&quot; </strong></td>
+						<td><div align="right">
+					 	    <input value="   {$APP.LBL_EDIT_BUTTON_LABEL}   " title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="crmButton small edit" type="submit" name="Edit" >
+						</div></td>
+					  </tr>
+					</table>
+					<table width="100%"  border="0" cellspacing="0" cellpadding="5">
+                      <tr class="small">
+                        <td width="15%" class="small cellLabel"><strong>{$CMOD.LBL_ROLE_NAME}</strong></td>
+                        <td width="85%" class="cellText" >{$ROLE_NAME}</td>
+                      </tr>
+                      <tr class="small">
+                        <td class="small cellLabel"><strong>{$CMOD.LBL_REPORTS_TO}</strong></td>
+                        <td class="cellText">{$PARENTNAME}</td>
+                      </tr>
+                      <tr class="small">
+                        <td valign=top class="cellLabel"><strong>{$CMOD.LBL_MEMBER}</strong></td>
+                        <td class="cellText">
+						<table width="70%"  border="0" cellspacing="0" cellpadding="5">
+                          <tr class="small">
+                            		<td colspan="2" class="cellBottomDotLine">
+						<div align="left"><strong>{$CMOD.LBL_ASSOCIATED_PROFILES}</strong></div>
+					</td>
+                            </tr>
+			{foreach item=elements from=$ROLEINFO.profileinfo}
+                          <tr class="small">
+
+                            <td width="16"><div align="center"></div></td>
+                            <td>
+										<a href="index.php?module=Settings&action=profilePrivileges&parenttab=Settings&profileid={$elements.0}&mode=view">{$elements.1}</a><br>
+			    </td>  	 
+                          </tr>
+			{/foreach}
+   <tr class="small">
+                            		<td colspan="2" class="cellBottomDotLine">
+						<div align="left"><strong>{$CMOD.LBL_ASSOCIATED_USERS}</strong></div>
+					</td>
+                            </tr>
+				{if $ROLEINFO.userinfo.0 neq ''}
+			{foreach item=elements from=$ROLEINFO.userinfo}
+                          <tr class="small">
+
+                            <td width="16"><div align="center"></div></td>
+                            <td>
+				<a href="index.php?module=Users&action=DetailView&parenttab=Settings&record={$elements.0}">{$elements.1}</a><br>
+			    </td>  	 
+                          </tr>
+			{/foreach}	
+			{/if}
+                        </table></td>
+                      </tr>
+                    </table>
+					<br>
+					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr><td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
+					</table>
+					
+					
+				</td>
+				</tr>
+				</table>
+			
+			
+			
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+	</form>
+	</table>
+		
+	</div>
+</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody>
+</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/RoleEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/RoleEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/RoleEditView.tpl Mon Apr 16 12:27:44 2007
@@ -24,7 +24,7 @@
                 'index.php',
                 {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
                                 method: 'post',
-                                postBody: 'module=Users&action=UsersAjax&file=SaveRole&ajax=true&dup_check=true'+urlstring,
+                                postBody: 'module=Settings&action=SettingsAjax&file=SaveRole&ajax=true&dup_check=true'+urlstring,
                                 onComplete: function(response) {ldelim}
 					if(response.responseText == 'SUCESS')
 						document.newRoleForm.submit();
@@ -38,16 +38,16 @@
 function validate()
 {ldelim}
 	formSelectColumnString();
-	if( !emptyCheck( "roleName", "Role Name" ) )
+	if( !emptyCheck("roleName", "Role Name", "text" ) )
 		return false;
 
 	if(document.newRoleForm.selectedColumnsString.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0)
 	{ldelim}
 
-		alert('Role should have atlease one profile');
+		alert('{$APP.ROLE_SHOULDHAVE_INFO}');
 		return false;
 	{rdelim}
-	dup_validation();
+	dup_validation();return false
 {rdelim}
 </script>
 <br>
@@ -61,8 +61,8 @@
 			{include file='SetMenu.tpl'}
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-				<form name="newRoleForm" action="index.php" method="post">
-				<input type="hidden" name="module" value="Users">
+				<form name="newRoleForm" action="index.php" method="post" onSubmit="return validate()">
+				<input type="hidden" name="module" value="Settings">
 				<input type="hidden" name="action" value="SaveRole">
 				<input type="hidden" name="parenttab" value="Settings">
 				<input type="hidden" name="returnaction" value="{$RETURN_ACTION}">
@@ -70,11 +70,11 @@
 				<input type="hidden" name="mode" value="{$MODE}">
 				<input type="hidden" name="parent" value="{$PARENT}">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-roles.gif" alt="Roles" width="48" height="48" border=0 title="Roles"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ico-roles.gif" alt="{$CMOD.LBL_ROLES}" width="48" height="48" border=0 title="{$CMOD.LBL_ROLES}"></td>
 					{if $MODE eq 'edit'}
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listroles&parenttab=Settings">{$CMOD.LBL_ROLES}</a> &gt; {$MOD.LBL_EDIT} &quot;{$ROLENAME}&quot; </b></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listroles&parenttab=Settings">{$CMOD.LBL_ROLES}</a> &gt; {$MOD.LBL_EDIT} &quot;{$ROLENAME}&quot; </b></td>
 					{else}	
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Users&action=listroles&parenttab=Settings">{$CMOD.LBL_ROLES}</a> &gt; {$CMOD.LBL_CREATE_NEW_ROLE}</b></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > <a href="index.php?module=Settings&action=listroles&parenttab=Settings">{$CMOD.LBL_ROLES}</a> &gt; {$CMOD.LBL_CREATE_NEW_ROLE}</b></td>
 					{/if}
 				</tr>
 				<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Rss.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Rss.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Rss.tpl Mon Apr 16 12:27:44 2007
@@ -34,8 +34,10 @@
 function DeleteRssFeeds(id)
 {
    if(id != '')	
-   {		
-  	if(confirm('Are you sure to delete the rss feed?'))
+   {
+	{/literal}
+        if(confirm('{$APP.DELETE_RSSFEED_CONFIRMATION}'))
+        {literal}
 	{	
 		show('status');	
 		var feed = 'feed_'+id;
@@ -103,7 +105,7 @@
 						<table width="100%"  border="0" cellspacing="0" cellpadding="0">
 						<tr>
 							<td width=95% align=left><img src='{$IMAGE_PATH}rssroot.gif' align='absmiddle'/><a href="javascript:;" onClick="fnvshobj(this,'PopupLay');$('rssurl').focus();" title='{$APP.LBL_ADD_RSS_FEEDS}'>{$MOD.LBL_ADD_RSS_FEED}</a></td>
-							<td  class="componentName" nowrap>vtiger RSS Reader</td>
+							<td  class="componentName" nowrap>{$MOD.LBL_VTIGER_RSS_READER}</td>
 						</tr>
 						<tr>
 							<td colspan="2">
@@ -112,7 +114,7 @@
 									<td width=30% valign=top>
 									<!-- Feed Folders -->
 										<table border=0 cellspacing=0 cellpadding=0 width=100%>
-										<tr><td class="small mailSubHeader" height="25"><b>Feed Sources</b></td></tr>
+										<tr><td class="small mailSubHeader" height="25"><b>{$MOD.LBL_FEED_SOURCES}</b></td></tr>
 										<tr><td class="hdrNameBg" bgcolor="#fff" height=155><div id="rssfolders" style="height:100%;overflow:auto;">{$RSSFEEDS}</div></td></tr>
 										</table>
 									</td>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/SelectEmail.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/SelectEmail.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/SelectEmail.tpl Mon Apr 16 12:27:44 2007
@@ -11,59 +11,68 @@
 -->*}
 <!-- BEGIN: main -->
 <div id="roleLay" style="z-index:12;display:block;width:400px;" class="layerPopup">
-<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
-<tr>
-	<td width="90%" align="left" class="genHeaderSmall">{$MOD.SELECT_EMAIL}
-	{if $ONE_RECORD neq 'true'}
-	({$MOD.LBL_MULTIPLE} {$APP[$FROM_MODULE]})
-	{/if}
-	&nbsp;
-	</td>
-	<td width="10%" align="right"><a href="javascript:fninvsh('roleLay');"><img title="{$APP.LBL_CLOSE}" alt="{$APP.LBL_CLOSE}" src="{$IMAGE_PATH}close.gif" border="0"  align="absmiddle" /></a></td>
-</tr>
-</table>
-<table border=0 cellspacing=0 cellpadding=5 width=95% align=center> 
-<tr>
-	<td class="small">
-	<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
-	<tr>
-		<td align="left">
-		{if $ONE_RECORD eq 'true'}
-			<b>{$ENTITY_NAME}</b> {$MOD.LBL_MAILSELECT_INFO}.<br><br>
-		{else}
-			{$MOD.LBL_MAILSELECT_INFO1} {$APP[$FROM_MODULE]}.{$MOD.LBL_MAILSELECT_INFO2}<br><br>
-		{/if}
-			<div style="height:120px;overflow-y:auto;averflow-x:hidden;" align="center">
-			<table border="0" cellpadding="5" cellspacing="0" width="90%">
-			{foreach name=emailids key=fieldid item=elements from=$MAILINFO}
-			<tr>
-				{if $smarty.foreach.emailids.iteration eq 1}	
-					<td align="center"><input checked type="checkbox" value="{$fieldid}" name="email"/></td>
-				{else}
-					<td align="center"><input type="checkbox" value="{$fieldid}" name="email"/></td>
+	<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
+		<tr>
+			<td width="90%" align="left" class="genHeaderSmall">{$MOD.SELECT_EMAIL}
+				{if $ONE_RECORD neq 'true'}
+				({$MOD.LBL_MULTIPLE} {$APP[$FROM_MODULE]})
 				{/if}
-				{if $ONE_RECORD eq 'true'}	
-					<td align="left"><b>{$elements.0} </b><br>{$MAILDATA[$smarty.foreach.emailids.iteration]}</td>
-				{else}
-					<td align="left"><b>{$elements.0} </b></td>
-				{/if}
-			</tr>
-			{/foreach}
+				&nbsp;
+			</td>
+			<td width="10%" align="right">
+				<a href="javascript:fninvsh('roleLay');"><img title="{$APP.LBL_CLOSE}" alt="{$APP.LBL_CLOSE}" src="{$IMAGE_PATH}close.gif" border="0"  align="absmiddle" /></a>
+			</td>
+		</tr>
+	</table>
+{if $PERMIT eq '0'}
+	<table border=0 cellspacing=0 cellpadding=5 width=95% align=center> 
+		<tr><td class="small">
+			<table border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
+				<tr>
+					<td align="left">
+					{if $ONE_RECORD eq 'true'}
+						<b>{$ENTITY_NAME}</b> {$MOD.LBL_MAILSELECT_INFO}.<br><br>
+					{else}
+						{$MOD.LBL_MAILSELECT_INFO1} {$APP[$FROM_MODULE]}.{$MOD.LBL_MAILSELECT_INFO2}<br><br>
+					{/if}
+						<div style="height:120px;overflow-y:auto;overflow-x:hidden;" align="center">
+							<table border="0" cellpadding="5" cellspacing="0" width="90%">
+								{foreach name=emailids key=fieldid item=elements from=$MAILINFO}
+								<tr>
+									{if $smarty.foreach.emailids.iteration eq 1}	
+									<td align="center"><input type="checkbox" value="{$fieldid}" name="semail" /></td>
+									{else}
+									<td align="center"><input type="checkbox" value="{$fieldid}" name="semail"  /></td>
+									{/if}
+									{if $ONE_RECORD eq 'true'}	
+									<td align="left"><b>{$elements.0} </b><br>{$MAILDATA[$smarty.foreach.emailids.iteration]}</td>
+									{else}
+									<td align="left"><b>{$elements.0}</b></td>
+									{/if}
+								</tr>
+								{/foreach}
+							</table>
+						</div>
+					</td>	
+				</tr>
 			</table>
-			</div>
-		</td>	
-	</tr>
+		</td></tr>
 	</table>
-	</td>
-</tr>
-</table>
-<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
-<tr>
-	<td align=center class="small">
-		<input type="button" name="{$APP.LBL_SELECT_BUTTON_LABEL}" value=" {$APP.LBL_SELECT_BUTTON_LABEL} " class="crmbutton small create" onClick="validate_sendmail('{$IDLIST}','{$FROM_MODULE}');"/>&nbsp;&nbsp;
-		<input type="button" name="{$APP.LBL_CANCEL_BUTTON_LABEL}" value=" {$APP.LBL_CANCEL_BUTTON_LABEL} " class="crmbutton small cancel" onclick="fninvsh('roleLay');" />
-	</td>
-</tr>
-</table>
-</div> 
-
+	<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
+		<tr><td align=center class="small">
+			<input type="button" name="{$APP.LBL_SELECT_BUTTON_LABEL}" value=" {$APP.LBL_SELECT_BUTTON_LABEL} " class="crmbutton small create" onClick="validate_sendmail('{$IDLIST}','{$FROM_MODULE}');"/>&nbsp;&nbsp;
+			<input type="button" name="{$APP.LBL_CANCEL_BUTTON_LABEL}" value=" {$APP.LBL_CANCEL_BUTTON_LABEL} " class="crmbutton small cancel" onclick="fninvsh('roleLay');" />
+		</td></tr>
+	</table>
+{else}
+	<table border=0 cellspacing=0 cellpadding=5 width=95% align=center>
+                <tr><td class="small">
+			<table border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
+                                <tr><td align="center">
+					<b>{$MOD.LBL_MAILSELECT_INFO3}</b>
+				</td></tr>
+			</table>
+		</td></tr>
+	</table>
+{/if}
+</div>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/SetMenu.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/SetMenu.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/SetMenu.tpl Mon Apr 16 12:27:44 2007
@@ -1,192 +1,202 @@
-{*<!--
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
--->*}
-<table border=0 cellspacing=0 cellpadding=20 width=90% class="settingsUI">
-<tr>
-<td valign=top>
-	<table border=0 cellspacing=0 cellpadding=0 width=100%>
-	<tr>
-	<td valign=top>
-		<!--Left Side Navigation Table-->
-		<table border=0 cellspacing=0 cellpadding=0 width=100%>
-		<tr>
-			<td class="settingsTabHeader" nowrap>{$MOD.LBL_USER_MANAGEMENT}</td>
-		</tr>
-
-		{if $smarty.request.action eq 'index' ||  $smarty.request.action eq 'DetailView' || $smarty.request.action eq 'EditView' || $smarty.request.action eq 'ListView' }
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'listroles' ||  $smarty.request.action eq 'RoleDetailView' ||  $smarty.request.action eq 'saverole' ||  $smarty.request.action eq 'createrole' || $smarty.request.action eq 'RoleDeleteStep1'} 		
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=listroles&parenttab=Settings">{$MOD.LBL_ROLES}</a></td></tr>
-		{else}	
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=listroles&parenttab=Settings">{$MOD.LBL_ROLES}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'ListProfiles' || $smarty.request.action eq 'profilePrivileges' ||  $smarty.request.action eq 'CreateProfile' ||  $smarty.request.action eq 'SaveProfile' || $smarty.request.action eq 'UpdateProfileChanges' }
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=ListProfiles&parenttab=Settings">{$MOD.LBL_PROFILES}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=ListProfiles&parenttab=Settings">{$MOD.LBL_PROFILES}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'listgroups' || $smarty.request.action eq 'GroupDetailView' || $smarty.request.action eq 'createnewgroup' || $smarty.request.action eq 'SaveGroup'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=listgroups&parenttab=Settings">{$MOD.USERGROUPLIST}</a></td></tr>   	
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=listgroups&parenttab=Settings">{$MOD.USERGROUPLIST}</a></td></tr>
-		{/if}
-
-		{if  $smarty.request.action eq 'OrgSharingEditView' || $smarty.request.action eq 'OrgSharingDetailView' || $smarty.request.action eq 'SaveOrgSharing'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=OrgSharingDetailView&parenttab=Settings">{$MOD.LBL_SHARING_ACCESS}</a></td></tr>  	
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=OrgSharingDetailView&parenttab=Settings">{$MOD.LBL_SHARING_ACCESS}</a></td></tr>
-		{/if}
-			
-		{if $smarty.request.action eq 'DefaultFieldPermissions' || $smarty.request.action eq 'UpdateDefaultFieldLevelAccess' || $smarty.request.action eq 'EditDefOrgFieldLevelAccess' }
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=DefaultFieldPermissions&parenttab=Settings">{$MOD.LBL_FIELDS_ACCESS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=DefaultFieldPermissions&parenttab=Settings">{$MOD.LBL_FIELDS_ACCESS}</a></td></tr>
-		{/if}
-			
-		{if $smarty.request.action eq 'AuditTrailList'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=AuditTrailList&parenttab=Settings">{$MOD.LBL_AUDIT_TRAIL}</a></td></tr>
-        {else}
-        <tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=AuditTrailList&parenttab=Settings">{$MOD.LBL_AUDIT_TRAIL}</a></td></tr>
-        {/if}
-
-		{if $smarty.request.action eq 'ListLoginHistory'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=ListLoginHistory&parenttab=Settings">{$MOD.LBL_LOGIN_HISTORY_DETAILS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=ListLoginHistory&parenttab=Settings">{$MOD.LBL_LOGIN_HISTORY_DETAILS}</a></td></tr>
-		{/if}
-
-		
-		<tr><td class="settingsTabHeader" nowrap>{$MOD.LBL_STUDIO}</td></tr>
-		{if  $smarty.request.action eq 'CustomFieldList' || $smarty.request.action eq 'LeadCustomFieldMapping'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings">{$MOD.LBL_CUSTOM_FIELDS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings">{$MOD.LBL_CUSTOM_FIELDS}</a></td></tr>
-		{/if}
-				
-		{if  $smarty.request.action eq 'PickList' ||  $smarty.request.action eq 'SettingsAjax'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=PickList&parenttab=Settings">{$MOD.LBL_PICKLIST_EDITOR}</a></td></tr>						     {else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=PickList&parenttab=Settings">{$MOD.LBL_PICKLIST_EDITOR}</a></td></tr>
-		{/if}
-	
-		<tr><td class="settingsTabHeader" nowrap>{$MOD.LBL_COMMUNICATION_TEMPLATES}</td></tr>
-
-		{if $smarty.request.action eq 'listemailtemplates' || $smarty.request.action eq 'detailviewemailtemplate' || $smarty.request.action eq 'editemailtemplate' || $smarty.request.action eq 'saveemailtemplate' || $smarty.request.action eq 'deleteemailtemplate' || $smarty.request.action eq 'createemailtemplate'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings">{$MOD.EMAILTEMPLATES}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings">{$MOD.EMAILTEMPLATES}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'listwordtemplates' || $smarty.request.action eq 'add2db' || $smarty.request.action eq 'deletewordtemplate' || $smarty.request.action eq 'upload'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=listwordtemplates&parenttab=Settings">{$MOD.WORDINTEGRATION}</a></td></tr>
-		{else}	
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=listwordtemplates&parenttab=Settings">{$MOD.WORDINTEGRATION}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'listnotificationschedulers' || $smarty.request.action eq 'UsersAjax'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=listnotificationschedulers&parenttab=Settings">{$MOD.NOTIFICATIONSCHEDULERS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=listnotificationschedulers&parenttab=Settings">{$MOD.NOTIFICATIONSCHEDULERS}</a></td></tr>
-		{/if}
-				
-		{if $smarty.request.action eq 'listinventorynotifications' || $smarty.request.action eq 'UsersAjax'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=listinventorynotifications&parenttab=Settings">{$MOD.INVENTORYNOTIFICATION}</a></td></tr>
-		{else}	
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=listinventorynotifications&parenttab=Settings">{$MOD.INVENTORYNOTIFICATION}</a></td></tr>
-		{/if} 	
-
-		
-
-		<tr><td class="settingsTabHeader" nowrap>{$MOD.LBL_OTHER_SETTINGS}</td></tr>
-		{if $smarty.request.action eq 'OrganizationConfig' || $smarty.request.action eq 'EditCompanyDetails' || $smarty.request.action eq 'add2db'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Organization&action=ListView&parenttab=Settings">{$MOD.LBL_COMPANY_DETAILS}</a></td></tr>
-		{else}	
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Organization&action=ListView&parenttab=Settings">{$MOD.LBL_COMPANY_DETAILS}</a></td></tr>
-		{/if}
-		
-		{if  $smarty.request.action eq 'EmailConfig' ||  $smarty.request.action eq 'Save' }
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings">{$MOD.LBL_MAIL_SERVER_SETTINGS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings">{$MOD.LBL_MAIL_SERVER_SETTINGS}</a></td></tr>
-		{/if}
-		
-		{if $smarty.request.action eq 'BackupServerConfig' || $smarty.request.action eq 'Save'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings">{$MOD.LBL_BACKUP_SERVER_SETTINGS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings">{$MOD.LBL_BACKUP_SERVER_SETTINGS}</a></td></tr>
-		{/if}
-		
-		{if $smarty.request.action eq 'ListModuleOwners' || $smarty.request.action eq 'SettingsAjax'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings">{$MOD.LBL_MODULE_OWNERS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings">{$MOD.LBL_MODULE_OWNERS}</a></td></tr>
-		{/if}
-		
-		{if $smarty.request.action eq 'CurrencyListView' ||  $smarty.request.action eq 'CurrencyEditView' ||  $smarty.request.action eq 'SaveCurrencyInfo'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a></td></tr>
-		{/if}
-		
-		{if $smarty.request.action eq 'TaxConfig'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings">{$MOD.LBL_TAX_SETTINGS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings">{$MOD.LBL_TAX_SETTINGS}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'listsysconfig'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=System&action=listsysconfig&parenttab=Settings">{$MOD.LBL_SYSTEM_INFO}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=System&action=listsysconfig&parenttab=Settings">{$MOD.LBL_SYSTEM_INFO}</a></td></tr>
-		{/if}
-
-		{if $smarty.request.action eq 'ProxyServerConfig'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings">{$MOD.LBL_PROXY_SETTINGS}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings">{$MOD.LBL_PROXY_SETTINGS}</a></td></tr>
-		{/if}
-
-		{if  $smarty.request.action eq 'Announcements' ||  $smarty.request.action eq 'UsersAjax' }
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=Announcements&parenttab=Settings">{$MOD.LBL_ANNOUNCEMENT}</a></td></tr>		
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=Announcements&parenttab=Settings">{$MOD.LBL_ANNOUNCEMENT}</a></td></tr>
-		{/if}
-		
-		{if $smarty.request.action eq 'DefModuleView'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=DefModuleView&parenttab=Settings">{$MOD.LBL_DEFAULT_MODULE_VIEW}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=DefModuleView&parenttab=Settings">{$MOD.LBL_DEFAULT_MODULE_VIEW}</a></td></tr>
-		{/if}
-	
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Migration&action=MigrationStep1&parenttab=Settings">{$MOD.LBL_MIGRATION}</a></td></tr>
-
-		{if $smarty.request.action eq 'OrganizationTermsandConditions' || $smarty.request.action eq 'savetermsandconditions'}
-		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Users&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td></tr>
-		{else}
-		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Users&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td></tr>
-		{/if}
-
-		</table>
-		<!-- Left side navigation table ends -->
-		
-	</td>
-	<td width=90% class="small settingsSelectedUI" valign=top align=left>
-
-
-
-
+{*<!--
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+-->*}
+<table border=0 cellspacing=0 cellpadding=20 width=90% class="settingsUI">
+<tr>
+<td valign=top>
+	<table border=0 cellspacing=0 cellpadding=0 width=100%>
+	<tr>
+	<td valign=top>
+		<!--Left Side Navigation Table-->
+		<table border=0 cellspacing=0 cellpadding=0 width=100%>
+		<tr>
+			<td class="settingsTabHeader" nowrap>{$MOD.LBL_USER_MANAGEMENT}</td>
+		</tr>
+
+		{if $smarty.request.action eq 'index' ||  $smarty.request.action eq 'DetailView' || $smarty.request.action eq 'EditView' || $smarty.request.action eq 'ListView' }
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'listroles' ||  $smarty.request.action eq 'RoleDetailView' ||  $smarty.request.action eq 'saverole' ||  $smarty.request.action eq 'createrole' || $smarty.request.action eq 'RoleDeleteStep1'} 		
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=listroles&parenttab=Settings">{$MOD.LBL_ROLES}</a></td></tr>
+		{else}	
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=listroles&parenttab=Settings">{$MOD.LBL_ROLES}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'ListProfiles' || $smarty.request.action eq 'profilePrivileges' ||  $smarty.request.action eq 'CreateProfile' ||  $smarty.request.action eq 'SaveProfile' || $smarty.request.action eq 'UpdateProfileChanges' }
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings">{$MOD.LBL_PROFILES}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings">{$MOD.LBL_PROFILES}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'listgroups' || $smarty.request.action eq 'GroupDetailView' || $smarty.request.action eq 'createnewgroup' || $smarty.request.action eq 'SaveGroup'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=listgroups&parenttab=Settings">{$MOD.USERGROUPLIST}</a></td></tr>   	
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=listgroups&parenttab=Settings">{$MOD.USERGROUPLIST}</a></td></tr>
+		{/if}
+
+		{if  $smarty.request.action eq 'OrgSharingEditView' || $smarty.request.action eq 'OrgSharingDetailView' || $smarty.request.action eq 'SaveOrgSharing'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=OrgSharingDetailView&parenttab=Settings">{$MOD.LBL_SHARING_ACCESS}</a></td></tr>  	
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=OrgSharingDetailView&parenttab=Settings">{$MOD.LBL_SHARING_ACCESS}</a></td></tr>
+		{/if}
+			
+		{if $smarty.request.action eq 'DefaultFieldPermissions' || $smarty.request.action eq 'UpdateDefaultFieldLevelAccess' || $smarty.request.action eq 'EditDefOrgFieldLevelAccess' }
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=DefaultFieldPermissions&parenttab=Settings">{$MOD.LBL_FIELDS_ACCESS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=DefaultFieldPermissions&parenttab=Settings">{$MOD.LBL_FIELDS_ACCESS}</a></td></tr>
+		{/if}
+			
+		{if $smarty.request.action eq 'AuditTrailList'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=AuditTrailList&parenttab=Settings">{$MOD.LBL_AUDIT_TRAIL}</a></td></tr>
+        {else}
+        <tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=AuditTrailList&parenttab=Settings">{$MOD.LBL_AUDIT_TRAIL}</a></td></tr>
+        {/if}
+
+		{if $smarty.request.action eq 'ListLoginHistory'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=ListLoginHistory&parenttab=Settings">{$MOD.LBL_LOGIN_HISTORY_DETAILS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=ListLoginHistory&parenttab=Settings">{$MOD.LBL_LOGIN_HISTORY_DETAILS}</a></td></tr>
+		{/if}
+
+		
+		<tr><td class="settingsTabHeader" nowrap>{$MOD.LBL_STUDIO}</td></tr>
+		{if  $smarty.request.action eq 'CustomFieldList' || $smarty.request.action eq 'LeadCustomFieldMapping'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings">{$MOD.LBL_CUSTOM_FIELDS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings">{$MOD.LBL_CUSTOM_FIELDS}</a></td></tr>
+		{/if}
+				
+		{if  $smarty.request.action eq 'PickList' ||  $smarty.request.action eq 'SettingsAjax'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=PickList&parenttab=Settings">{$MOD.LBL_PICKLIST_EDITOR}</a></td></tr>						     {else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=PickList&parenttab=Settings">{$MOD.LBL_PICKLIST_EDITOR}</a></td></tr>
+		{/if}
+	
+		<tr><td class="settingsTabHeader" nowrap>{$MOD.LBL_COMMUNICATION_TEMPLATES}</td></tr>
+
+		{if $smarty.request.action eq 'listemailtemplates' || $smarty.request.action eq 'detailviewemailtemplate' || $smarty.request.action eq 'editemailtemplate' || $smarty.request.action eq 'saveemailtemplate' || $smarty.request.action eq 'deleteemailtemplate' || $smarty.request.action eq 'createemailtemplate'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings">{$MOD.EMAILTEMPLATES}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings">{$MOD.EMAILTEMPLATES}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'listwordtemplates' || $smarty.request.action eq 'savewordtemplate' || $smarty.request.action eq 'deletewordtemplate' || $smarty.request.action eq 'upload'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=listwordtemplates&parenttab=Settings">{$MOD.WORDINTEGRATION}</a></td></tr>
+		{else}	
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=listwordtemplates&parenttab=Settings">{$MOD.WORDINTEGRATION}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'listnotificationschedulers' || $smarty.request.action eq 'SettingsAjax'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=listnotificationschedulers&parenttab=Settings">{$MOD.NOTIFICATIONSCHEDULERS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=listnotificationschedulers&parenttab=Settings">{$MOD.NOTIFICATIONSCHEDULERS}</a></td></tr>
+		{/if}
+				
+		{if $smarty.request.action eq 'listinventorynotifications' || $smarty.request.action eq 'SettingsAjax'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=listinventorynotifications&parenttab=Settings">{$MOD.INVENTORYNOTIFICATION}</a></td></tr>
+		{else}	
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=listinventorynotifications&parenttab=Settings">{$MOD.INVENTORYNOTIFICATION}</a></td></tr>
+		{/if} 	
+
+		
+
+		<tr><td class="settingsTabHeader" nowrap>{$MOD.LBL_OTHER_SETTINGS}</td></tr>
+		{if $smarty.request.action eq 'OrganizationConfig' || $smarty.request.action eq 'EditCompanyDetails' || $smarty.request.action eq 'add2db'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Organization&action=ListView&parenttab=Settings">{$MOD.LBL_COMPANY_DETAILS}</a></td></tr>
+		{else}	
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Organization&action=ListView&parenttab=Settings">{$MOD.LBL_COMPANY_DETAILS}</a></td></tr>
+		{/if}
+		
+		{if  $smarty.request.action eq 'EmailConfig' ||  $smarty.request.action eq 'Save' }
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings">{$MOD.LBL_MAIL_SERVER_SETTINGS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings">{$MOD.LBL_MAIL_SERVER_SETTINGS}</a></td></tr>
+		{/if}
+		
+		{if $smarty.request.action eq 'BackupServerConfig' || $smarty.request.action eq 'Save'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings">{$MOD.LBL_BACKUP_SERVER_SETTINGS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings">{$MOD.LBL_BACKUP_SERVER_SETTINGS}</a></td></tr>
+		{/if}
+		
+		{if $smarty.request.action eq 'ListModuleOwners' || $smarty.request.action eq 'SettingsAjax'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings">{$MOD.LBL_MODULE_OWNERS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings">{$MOD.LBL_MODULE_OWNERS}</a></td></tr>
+		{/if}
+		
+		{if $smarty.request.action eq 'CurrencyListView' ||  $smarty.request.action eq 'CurrencyEditView' ||  $smarty.request.action eq 'SaveCurrencyInfo'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a></td></tr>
+		{/if}
+		
+		{if $smarty.request.action eq 'TaxConfig'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings">{$MOD.LBL_TAX_SETTINGS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings">{$MOD.LBL_TAX_SETTINGS}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'listsysconfig'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=System&action=listsysconfig&parenttab=Settings">{$MOD.LBL_SYSTEM_INFO}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=System&action=listsysconfig&parenttab=Settings">{$MOD.LBL_SYSTEM_INFO}</a></td></tr>
+		{/if}
+
+		{if $smarty.request.action eq 'ProxyServerConfig'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings">{$MOD.LBL_PROXY_SETTINGS}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings">{$MOD.LBL_PROXY_SETTINGS}</a></td></tr>
+		{/if}
+
+		{if  $smarty.request.action eq 'Announcements' ||  $smarty.request.action eq 'SettingsAjax' }
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=Announcements&parenttab=Settings">{$MOD.LBL_ANNOUNCEMENT}</a></td></tr>		
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=Announcements&parenttab=Settings">{$MOD.LBL_ANNOUNCEMENT}</a></td></tr>
+		{/if}
+		
+		{if $smarty.request.action eq 'DefModuleView'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=DefModuleView&parenttab=Settings">{$MOD.LBL_DEFAULT_MODULE_VIEW}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=DefModuleView&parenttab=Settings">{$MOD.LBL_DEFAULT_MODULE_VIEW}</a></td></tr>
+		{/if}
+	
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Migration&action=index&parenttab=Settings">{$MOD.LBL_MIGRATION}</a></td></tr>
+
+		{if $smarty.request.action eq 'OrganizationTermsandConditions' || $smarty.request.action eq 'savetermsandconditions'}
+		<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td></tr>
+		{else}
+		<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td></tr>
+		{/if}
+
+<!-- Added For Custom Invoice Number #start -->
+
+		{if $smarty.request.action eq 'CustomInvoiceNo'}
+			<tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}</a></td></tr>
+		{else}
+			<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}</a></td></tr>
+		{/if}
+
+<!-- Added For Custom Invoice Number #end -->
+
+		</table>
+		<!-- Left side navigation table ends -->
+		
+	</td>
+	<td width=90% class="small settingsSelectedUI" valign=top align=left>
+
+
+
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings.tpl Mon Apr 16 12:27:44 2007
@@ -1,507 +1,527 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-
-	{include file="Buttons_List1.tpl"}
-
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-	<td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-	<br>
-	<div align=center>
-	<table border=0 cellspacing=0 cellpadding=20 width=90% class="settingsUI">
-	<tr>
-		<td>
-			<!--All Icons table -->
-			<table border=0 cellspacing=0 cellpadding=0 width=100%>
-			<tr>
-
-				<td class="settingsTabHeader">
-				<!-- Users & Access Management -->
-					{$MOD.LBL_USER_MANAGEMENT}	
-				</td>
-			</tr>
-			<tr>
-				<td class="settingsIconDisplay small">
-				<!-- Icons for Users & Access Management -->
-				
-				<table border=0 cellspacing=0 cellpadding=10 width=100%>
-
-				<tr>
-					<td width=25% valign=top>
-					<!-- icon 1-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Administration&action=index&parenttab=Settings"><img src="{$IMAGE_PATH}ico-users.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a></td>
-						</tr>
-
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_USER_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 2-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=listroles&parenttab=Settings"><img src="{$IMAGE_PATH}ico-roles.gif" alt="{$MOD.LBL_ROLES}" width="48" height="48" border=0 title="{$MOD.LBL_ROLES}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=listroles&parenttab=Settings">{$MOD.LBL_ROLES}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_ROLE_DESCRIPTION}</td>
-						</tr>
-						</table>
-
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 3-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=ListProfiles&parenttab=Settings"><img src="{$IMAGE_PATH}ico-profile.gif" alt="{$MOD.LBL_PROFILES}" width="48" height="48" border=0 title="{$MOD.LBL_PROFILES}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=ListProfiles&parenttab=Settings">{$MOD.LBL_PROFILES}</a></td>
-						</tr>
-
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_PROFILE_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 4-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=listgroups&parenttab=Settings"><img src="{$IMAGE_PATH}ico-groups.gif" alt="{$MOD.USERGROUPLIST}" width="48" height="48" border=0 title="{$MOD.USERGROUPLIST}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=listgroups&parenttab=Settings">{$MOD.USERGROUPLIST}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_GROUP_DESCRIPTION}</td>
-						</tr>
-						</table>
-
-					</td>
-				</tr>
-				<!-- Row 2 -->
-				<tr>
-					<td width=25% valign=top>
-					<!-- icon 5-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=OrgSharingDetailView&parenttab=Settings"><img src="{$IMAGE_PATH}shareaccess.gif" alt="{$MOD.LBL_SHARING_ACCESS}" width="48" height="48" border=0 title="{$MOD.LBL_SHARING_ACCESS}"></a></td>
-
-							<td class=big valign=top><a href="index.php?module=Users&action=OrgSharingDetailView&parenttab=Settings">{$MOD.LBL_SHARING_ACCESS}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_SHARING_ACCESS_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-
-					<!-- icon 6 -->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=DefaultFieldPermissions&parenttab=Settings"><img src="{$IMAGE_PATH}orgshar.gif" alt="Fields to be shown" width="48" height="48" border=0 title="Fields to be shown"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=DefaultFieldPermissions&parenttab=Settings">{$MOD.LBL_FIELDS_ACCESS}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_SHARING_FIELDS_DESCRIPTION}</td>
-
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 7-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=AuditTrailList&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}audit.gif" alt="{$MOD.LBL_AUDIT_TRAIL}" title="{$MOD.LBL_AUDIT_TRAIL}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=AuditTrailList&parenttab=Settings">{$MOD.LBL_AUDIT_TRAIL}</a></td>
-						</tr>
-
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_AUDIT_DESCRIPTION}</td>
-						</tr>
-						</table>
-
-						
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 8-->	
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=ListLoginHistory&parenttab=Settings"><img src="{$IMAGE_PATH}set-IcoLoginHistory.gif" alt="{$MOD.LBL_LOGIN_HISTORY_DETAILS}" width="48" height="48" border=0 title="{$MOD.LBL_LOGIN_HISTORY_DETAILS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=ListLoginHistory&parenttab=Settings">{$MOD.LBL_LOGIN_HISTORY_DETAILS}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_LOGIN_HISTORY_DESCRIPTION}</td>
-						</tr>
-
-						</table>
-					</td>
-					<!-- Row 3 -->
-					<tr>
-					
-				</tr>
-				</table>
-
-
-				</td>
-			</tr>
-
-
-			<tr>
-				<td class="settingsTabHeader">
-
-				<!-- Studio  -->
-					{$MOD.LBL_STUDIO}	
-				</td>
-			</tr>
-			<tr>
-				<td class="settingsIconDisplay small">
-				<!-- Icons for Users & Access Management -->
-				
-				<table border=0 cellspacing=0 cellpadding=10 width=100%>
-				<tr>
-
-					<td width=25% valign=top>
-					<!-- icon 9-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}custom.gif" alt="{$MOD.LBL_CUSTOM_FIELDS}" title="{$MOD.LBL_CUSTOM_FIELDS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings">{$MOD.LBL_CUSTOM_FIELDS}</a></td>
-						</tr>
-						<tr>
-
-							<td class="small" valign=top>{$MOD.LBL_CUSTOM_FIELDS_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 10-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=PickList&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}picklist.gif" alt="{$MOD.LBL_PICKLIST_EDITOR}" title="{$MOD.LBL_PICKLIST_EDITOR}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=PickList&parenttab=Settings">{$MOD.LBL_PICKLIST_EDITOR}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_PICKLIST_DESCRIPTION}</td>	
-						</tr>
-						</table>
-					</td>
-
-					<td width=25% valign=top>
-					<!-- empty-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top>&nbsp;</td>
-							<td class=big valign=top>&nbsp;</td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>&nbsp;</td>
-
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- empty-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top>&nbsp;</td>
-							<td class=big valign=top>&nbsp;</td>
-
-						</tr>
-						<tr>
-							<td class="small" valign=top>&nbsp;</td>
-						</tr>
-						</table>
-					</td>
-				</tr>
-				</table>
-				
-				
-				</td>
-
-			</tr>
-			
-			
-			
-			<tr>
-				<td class="settingsTabHeader">
-				<!-- Communication Templates -->
-					{$MOD.LBL_COMMUNICATION_TEMPLATES}
-				</td>
-			</tr>
-			<tr>
-				<td class="settingsIconDisplay small">
-
-				<!-- Icons for Communication Templates -->
-				
-				<table border=0 cellspacing=0 cellpadding=10 width=100%>
-				<tr>
-					<td width=25% valign=top>
-					<!-- icon 11-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}ViewTemplate.gif" alt="{$MOD.EMAILTEMPLATES}" title="{$MOD.EMAILTEMPLATES}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=listemailtemplates&parenttab=Settings">{$MOD.EMAILTEMPLATES}</a></td>
-
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_EMAIL_TEMPLATE_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 12-->
-
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=listwordtemplates&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}mailmarge.gif" alt="{$MOD.LBL_MAIL_MERGE}" title="{$MOD.LBL_MAIL_MERGE}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=listwordtemplates&parenttab=Settings">{$MOD.WORDINTEGRATION}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_MAIL_MERGE_DESCRIPTION}</td>
-						</tr>
-
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 13-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=listnotificationschedulers&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}notification.gif" alt="{$MOD.NOTIFICATIONSCHEDULERS}" title="{$MOD.NOTIFICATIONSCHEDULERS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=listnotificationschedulers&parenttab=Settings">{$MOD.NOTIFICATIONSCHEDULERS}</a></td>
-
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_NOTIF_SCHED_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 14-->
-
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=listinventorynotifications&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}inventory.gif" alt="{$MOD.INVENTORYNOTIFICATION}" title="{$MOD.INVENTORYNOTIFICATION}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=listinventorynotifications&parenttab=Settings">{$MOD.INVENTORYNOTIFICATION}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_INV_NOTIF_DESCRIPTION}</td>
-						</tr>
-
-						</table>
-					</td>
-				</tr>
-				</table>
-				
-				
-				</td>
-			</tr>
-			<tr>
-				<td class="settingsTabHeader">
-				<!-- Other settings -->
-					{$MOD.LBL_OTHER_SETTINGS}
-				</td>
-
-			</tr>
-			<tr>
-				<td class="settingsIconDisplay small">
-				<!-- Icons for Other Settings-->
-				
-				<table border=0 cellspacing=0 cellpadding=10 width=100%>
-				<tr>
-					<td width=25% valign=top>
-					<!-- icon 16-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Organization&action=ListView&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}company.gif" alt="{$MOD.LBL_COMPANY_DETAILS}" title="{$MOD.LBL_COMPANY_DETAILS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Organization&action=ListView&parenttab=Settings">{$MOD.LBL_COMPANY_DETAILS}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_COMPANY_DESCRIPTION}</td>
-						</tr>
-						</table>
-
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 17-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}ogmailserver.gif" alt="{$MOD.LBL_MAIL_SERVER_SETTINGS}" title="{$MOD.LBL_MAIL_SERVER_SETTINGS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings">{$MOD.LBL_MAIL_SERVER_SETTINGS}</a></td>
-						</tr>
-
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_MAIL_SERVER_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 18-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}backupserver.gif" alt="{$MOD.LBL_BACKUP_SERVER_SETTINGS}" title="{$MOD.LBL_BACKUP_SERVER_SETTINGS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings">{$MOD.LBL_BACKUP_SERVER_SETTINGS}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_BACKUP_SERVER_DESCRIPTION}</td>
-						</tr>
-						</table>
-
-					</td>
-					<td width=25% valign=top>
-					<!-- icon 7-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings"><img src="{$IMAGE_PATH}assign.gif" alt="{$MOD.LBL_ASSIGN_MODULE_OWNERS}" width="48" height="48" border=0 title="{$MOD.LBL_ASSIGN_MODULE_OWNERS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings">{$MOD.LBL_MODULE_OWNERS}</a></td>
-
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_MODULE_OWNERS_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-				</tr>
-				<!-- Row 2 -->
-				<tr>
-
-					<td width=25% valign=top>
-					<!-- icon 19-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}currency.gif" alt="{$MOD.LBL_CURRENCY_SETTINGS}" title="{$MOD.LBL_CURRENCY_SETTINGS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a></td>
-						</tr>
-
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_CURRENCY_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-
-					<td width=25% valign=top>
-					<!-- icon 20-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}taxConfiguration.gif" alt="{$MOD.LBL_TAX_SETTINGS}" title="{$MOD.LBL_TAX_SETTINGS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings">{$MOD.LBL_TAX_SETTINGS}</a></td>
-						</tr>
-						<tr>
-
-							<td class="small" valign=top>{$MOD.LBL_TAX_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-					<!-- empty -->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=System&action=listsysconfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}system.gif" alt="{$MOD.LBL_SYSTEM_INFO}" title="{$MOD.LBL_SYSTEM_INFO}"></a></td>
-							<td class=big valign=top><a href="index.php?module=System&action=listsysconfig&parenttab=Settings">{$MOD.LBL_SYSTEM_INFO}</a></td>
-
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_SYSTEM_DESCRIPTION}</td>
-						</tr>
-						</table>
-					</td>
-					<td width=25% valign=top>
-
-					<!-- empty-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}proxy.gif" alt="{$MOD.LBL_PROXY_SETTINGS}" title="{$MOD.LBL_PROXY_SETTINGS}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings">{$MOD.LBL_PROXY_SETTINGS}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_PROXY_DESCRIPTION}</td>
-						</tr>
-
-						</table>
-					</td>
-				</tr>
-				<tr>
-
-					<td width=25% valign=top>
-					<!-- empty-->
-						<table border=0 cellspacing=0 cellpadding=5 width=100%>
-						<tr>
-							<td rowspan=2 valign=top><a href="index.php?module=Users&action=Announcements&parenttab=Settings"><img src="{$IMAGE_PATH}announ.gif" alt="{$MOD.LBL_ANNOUNCEMENT}" width="48" height="48" border=0 title="{$MOD.LBL_ANNOUNCEMENT}"></a></td>
-							<td class=big valign=top><a href="index.php?module=Users&action=Announcements&parenttab=Settings">{$MOD.LBL_ANNOUNCEMENT}</a></td>
-						</tr>
-						<tr>
-							<td class="small" valign=top>{$MOD.LBL_ANNOUNCEMENT_DESCRIPTION}</td>
-						</tr>
-
-						</table>
-					</td>
-<td width=25% valign=top>
-					<!-- icon 9-->	
-					<table border=0 cellspacing=0 cellpadding=5 width=100%>
-					<tr>
-						<td rowspan=2 valign=top><a href="index.php?module=Users&action=DefModuleView&parenttab=Settings"><img src="{$IMAGE_PATH}set-IcoTwoTabConfig.gif" alt="{$MOD.LBL_DEFAULT_MODULE_VIEW}" width="48" height="48" border=0 title="{$MOD.LBL_DEFAULT_MODULE_VIEW}"></a></td>
-						<td class=big valign=top><a href="index.php?module=Users&action=DefModuleView&parenttab=Settings">{$MOD.LBL_DEFAULT_MODULE_VIEW}</a></td>
-					</tr>
-					<tr>
-						<td class="small" valign=top>{$MOD.LBL_DEFAULT_MODULE_VIEW_DESC}</td>
-					</tr>
-
-					</table>
-					</td>
-				  <td valign=top><table border=0 cellspacing=0 cellpadding=5 width=100%>
-                    <tr>
-                      <td rowspan=2 valign=top><a href="index.php?module=Migration&action=MigrationStep1&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}migrate.gif" alt="{$MOD.LBL_MIGRATION}" title="{$MOD.LBL_MIGRATION}"></a></td>
-                      <td class=big valign=top><a href="index.php?module=Migration&action=MigrationStep1&parenttab=Settings">{$MOD.LBL_MIGRATION}</a></td>
-                    </tr>
-                    <tr>
-                      <td class="small" valign=top>{$MOD.LBL_MIGRATION_INFO}</td>
-                    </tr>
-                  </table></td>
-		<td width=25% valign=top>
-			<!-- icon 15-->
-			<table border=0 cellspacing=0 cellpadding=5 width=100%>
-			<tr>
-
-			<td rowspan=2 valign=top><a href="index.php?module=Users&action=OrganizationTermsandConditions&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}terms.gif" alt="{$MOD.INVENTORYTERMSANDCONDITIONS}" title="{$MOD.INVENTORYTERMSANDCONDITIONS}"></a></td>
-			<td class=big valign=top><a href="index.php?module=Users&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td>
-			</tr>
-			<tr>
-			<td class="small" valign=top>{$MOD.LBL_INV_TANDC_DESCRIPTION}</td>
-			</tr>
-			</table>
-
-		</td>
-
-		</tr>
-
-		</table>
-		
-		</td>
-	</tr>
-	</table>
-	</td></tr></table>	
-	</div>
-
-	</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody></table>
-
-
-
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+
+	{include file="Buttons_List1.tpl"}
+
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+	<td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+	<br>
+	<div align=center>
+	<table border=0 cellspacing=0 cellpadding=20 width=90% class="settingsUI">
+	<tr>
+		<td>
+			<!--All Icons table -->
+			<table border=0 cellspacing=0 cellpadding=0 width=100%>
+			<tr>
+
+				<td class="settingsTabHeader">
+				<!-- Users & Access Management -->
+					{$MOD.LBL_USER_MANAGEMENT}	
+				</td>
+			</tr>
+			<tr>
+				<td class="settingsIconDisplay small">
+				<!-- Icons for Users & Access Management -->
+				
+				<table border=0 cellspacing=0 cellpadding=10 width=100%>
+
+				<tr>
+					<td width=25% valign=top>
+					<!-- icon 1-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Administration&action=index&parenttab=Settings"><img src="{$IMAGE_PATH}ico-users.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a></td>
+						</tr>
+
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_USER_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 2-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=listroles&parenttab=Settings"><img src="{$IMAGE_PATH}ico-roles.gif" alt="{$MOD.LBL_ROLES}" width="48" height="48" border=0 title="{$MOD.LBL_ROLES}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=listroles&parenttab=Settings">{$MOD.LBL_ROLES}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_ROLE_DESCRIPTION}</td>
+						</tr>
+						</table>
+
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 3-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings"><img src="{$IMAGE_PATH}ico-profile.gif" alt="{$MOD.LBL_PROFILES}" width="48" height="48" border=0 title="{$MOD.LBL_PROFILES}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=ListProfiles&parenttab=Settings">{$MOD.LBL_PROFILES}</a></td>
+						</tr>
+
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_PROFILE_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 4-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=listgroups&parenttab=Settings"><img src="{$IMAGE_PATH}ico-groups.gif" alt="{$MOD.USERGROUPLIST}" width="48" height="48" border=0 title="{$MOD.USERGROUPLIST}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=listgroups&parenttab=Settings">{$MOD.USERGROUPLIST}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_GROUP_DESCRIPTION}</td>
+						</tr>
+						</table>
+
+					</td>
+				</tr>
+				<!-- Row 2 -->
+				<tr>
+					<td width=25% valign=top>
+					<!-- icon 5-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=OrgSharingDetailView&parenttab=Settings"><img src="{$IMAGE_PATH}shareaccess.gif" alt="{$MOD.LBL_SHARING_ACCESS}" width="48" height="48" border=0 title="{$MOD.LBL_SHARING_ACCESS}"></a></td>
+
+							<td class=big valign=top><a href="index.php?module=Settings&action=OrgSharingDetailView&parenttab=Settings">{$MOD.LBL_SHARING_ACCESS}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_SHARING_ACCESS_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+
+					<!-- icon 6 -->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=DefaultFieldPermissions&parenttab=Settings"><img src="{$IMAGE_PATH}orgshar.gif" alt="{$MOD.LBL_FIELDS_TO_BE_SHOWN}" width="48" height="48" border=0 title="{$MOD.LBL_FIELDS_TO_BE_SHOWN}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=DefaultFieldPermissions&parenttab=Settings">{$MOD.LBL_FIELDS_ACCESS}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_SHARING_FIELDS_DESCRIPTION}</td>
+
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 7-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=AuditTrailList&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}audit.gif" alt="{$MOD.LBL_AUDIT_TRAIL}" title="{$MOD.LBL_AUDIT_TRAIL}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=AuditTrailList&parenttab=Settings">{$MOD.LBL_AUDIT_TRAIL}</a></td>
+						</tr>
+
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_AUDIT_DESCRIPTION}</td>
+						</tr>
+						</table>
+
+						
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 8-->	
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=ListLoginHistory&parenttab=Settings"><img src="{$IMAGE_PATH}set-IcoLoginHistory.gif" alt="{$MOD.LBL_LOGIN_HISTORY_DETAILS}" width="48" height="48" border=0 title="{$MOD.LBL_LOGIN_HISTORY_DETAILS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=ListLoginHistory&parenttab=Settings">{$MOD.LBL_LOGIN_HISTORY_DETAILS}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_LOGIN_HISTORY_DESCRIPTION}</td>
+						</tr>
+
+						</table>
+					</td>
+					<!-- Row 3 -->
+					<tr>
+					
+				</tr>
+				</table>
+
+
+				</td>
+			</tr>
+
+
+			<tr>
+				<td class="settingsTabHeader">
+
+				<!-- Studio  -->
+					{$MOD.LBL_STUDIO}	
+				</td>
+			</tr>
+			<tr>
+				<td class="settingsIconDisplay small">
+				<!-- Icons for Users & Access Management -->
+				
+				<table border=0 cellspacing=0 cellpadding=10 width=100%>
+				<tr>
+
+					<td width=25% valign=top>
+					<!-- icon 9-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}custom.gif" alt="{$MOD.LBL_CUSTOM_FIELDS}" title="{$MOD.LBL_CUSTOM_FIELDS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=CustomFieldList&parenttab=Settings">{$MOD.LBL_CUSTOM_FIELDS}</a></td>
+						</tr>
+						<tr>
+
+							<td class="small" valign=top>{$MOD.LBL_CUSTOM_FIELDS_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 10-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=PickList&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}picklist.gif" alt="{$MOD.LBL_PICKLIST_EDITOR}" title="{$MOD.LBL_PICKLIST_EDITOR}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=PickList&parenttab=Settings">{$MOD.LBL_PICKLIST_EDITOR}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_PICKLIST_DESCRIPTION}</td>	
+						</tr>
+						</table>
+					</td>
+
+					<td width=25% valign=top>
+					<!-- empty-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top>&nbsp;</td>
+							<td class=big valign=top>&nbsp;</td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>&nbsp;</td>
+
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- empty-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top>&nbsp;</td>
+							<td class=big valign=top>&nbsp;</td>
+
+						</tr>
+						<tr>
+							<td class="small" valign=top>&nbsp;</td>
+						</tr>
+						</table>
+					</td>
+				</tr>
+				</table>
+				
+				
+				</td>
+
+			</tr>
+			
+			
+			
+			<tr>
+				<td class="settingsTabHeader">
+				<!-- Communication Templates -->
+					{$MOD.LBL_COMMUNICATION_TEMPLATES}
+				</td>
+			</tr>
+			<tr>
+				<td class="settingsIconDisplay small">
+
+				<!-- Icons for Communication Templates -->
+				
+				<table border=0 cellspacing=0 cellpadding=10 width=100%>
+				<tr>
+					<td width=25% valign=top>
+					<!-- icon 11-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}ViewTemplate.gif" alt="{$MOD.EMAILTEMPLATES}" title="{$MOD.EMAILTEMPLATES}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=listemailtemplates&parenttab=Settings">{$MOD.EMAILTEMPLATES}</a></td>
+
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_EMAIL_TEMPLATE_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 12-->
+
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=listwordtemplates&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}mailmarge.gif" alt="{$MOD.LBL_MAIL_MERGE}" title="{$MOD.LBL_MAIL_MERGE}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=listwordtemplates&parenttab=Settings">{$MOD.WORDINTEGRATION}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_MAIL_MERGE_DESCRIPTION}</td>
+						</tr>
+
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 13-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=listnotificationschedulers&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}notification.gif" alt="{$MOD.NOTIFICATIONSCHEDULERS}" title="{$MOD.NOTIFICATIONSCHEDULERS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=listnotificationschedulers&parenttab=Settings">{$MOD.NOTIFICATIONSCHEDULERS}</a></td>
+
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_NOTIF_SCHED_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 14-->
+
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=listinventorynotifications&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}inventory.gif" alt="{$MOD.INVENTORYNOTIFICATION}" title="{$MOD.INVENTORYNOTIFICATION}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=listinventorynotifications&parenttab=Settings">{$MOD.INVENTORYNOTIFICATION}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_INV_NOTIF_DESCRIPTION}</td>
+						</tr>
+
+						</table>
+					</td>
+				</tr>
+				</table>
+				
+				
+				</td>
+			</tr>
+			<tr>
+				<td class="settingsTabHeader">
+				<!-- Other settings -->
+					{$MOD.LBL_OTHER_SETTINGS}
+				</td>
+
+			</tr>
+			<tr>
+				<td class="settingsIconDisplay small">
+				<!-- Icons for Other Settings-->
+				
+				<table border=0 cellspacing=0 cellpadding=10 width=100%>
+				<tr>
+					<td width=25% valign=top>
+					<!-- icon 16-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Organization&action=ListView&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}company.gif" alt="{$MOD.LBL_COMPANY_DETAILS}" title="{$MOD.LBL_COMPANY_DETAILS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Organization&action=ListView&parenttab=Settings">{$MOD.LBL_COMPANY_DETAILS}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_COMPANY_DESCRIPTION}</td>
+						</tr>
+						</table>
+
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 17-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}ogmailserver.gif" alt="{$MOD.LBL_MAIL_SERVER_SETTINGS}" title="{$MOD.LBL_MAIL_SERVER_SETTINGS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=EmailConfig&parenttab=Settings">{$MOD.LBL_MAIL_SERVER_SETTINGS}</a></td>
+						</tr>
+
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_MAIL_SERVER_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 18-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}backupserver.gif" alt="{$MOD.LBL_BACKUP_SERVER_SETTINGS}" title="{$MOD.LBL_BACKUP_SERVER_SETTINGS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=BackupServerConfig&parenttab=Settings">{$MOD.LBL_BACKUP_SERVER_SETTINGS}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_BACKUP_SERVER_DESCRIPTION}</td>
+						</tr>
+						</table>
+
+					</td>
+					<td width=25% valign=top>
+					<!-- icon 7-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings"><img src="{$IMAGE_PATH}assign.gif" alt="{$MOD.LBL_ASSIGN_MODULE_OWNERS}" width="48" height="48" border=0 title="{$MOD.LBL_ASSIGN_MODULE_OWNERS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=ListModuleOwners&parenttab=Settings">{$MOD.LBL_MODULE_OWNERS}</a></td>
+
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_MODULE_OWNERS_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+				</tr>
+				<!-- Row 2 -->
+				<tr>
+
+					<td width=25% valign=top>
+					<!-- icon 19-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}currency.gif" alt="{$MOD.LBL_CURRENCY_SETTINGS}" title="{$MOD.LBL_CURRENCY_SETTINGS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=CurrencyListView&parenttab=Settings">{$MOD.LBL_CURRENCY_SETTINGS}</a></td>
+						</tr>
+
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_CURRENCY_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+
+					<td width=25% valign=top>
+					<!-- icon 20-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}taxConfiguration.gif" alt="{$MOD.LBL_TAX_SETTINGS}" title="{$MOD.LBL_TAX_SETTINGS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings">{$MOD.LBL_TAX_SETTINGS}</a></td>
+						</tr>
+						<tr>
+
+							<td class="small" valign=top>{$MOD.LBL_TAX_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+					<!-- empty -->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=System&action=listsysconfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}system.gif" alt="{$MOD.LBL_SYSTEM_INFO}" title="{$MOD.LBL_SYSTEM_INFO}"></a></td>
+							<td class=big valign=top><a href="index.php?module=System&action=listsysconfig&parenttab=Settings">{$MOD.LBL_SYSTEM_INFO}</a></td>
+
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_SYSTEM_DESCRIPTION}</td>
+						</tr>
+						</table>
+					</td>
+					<td width=25% valign=top>
+
+					<!-- empty-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}proxy.gif" alt="{$MOD.LBL_PROXY_SETTINGS}" title="{$MOD.LBL_PROXY_SETTINGS}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=ProxyServerConfig&parenttab=Settings">{$MOD.LBL_PROXY_SETTINGS}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_PROXY_DESCRIPTION}</td>
+						</tr>
+
+						</table>
+					</td>
+				</tr>
+				<tr>
+
+					<td width=25% valign=top>
+					<!-- empty-->
+						<table border=0 cellspacing=0 cellpadding=5 width=100%>
+						<tr>
+							<td rowspan=2 valign=top><a href="index.php?module=Settings&action=Announcements&parenttab=Settings"><img src="{$IMAGE_PATH}announ.gif" alt="{$MOD.LBL_ANNOUNCEMENT}" width="48" height="48" border=0 title="{$MOD.LBL_ANNOUNCEMENT}"></a></td>
+							<td class=big valign=top><a href="index.php?module=Settings&action=Announcements&parenttab=Settings">{$MOD.LBL_ANNOUNCEMENT}</a></td>
+						</tr>
+						<tr>
+							<td class="small" valign=top>{$MOD.LBL_ANNOUNCEMENT_DESCRIPTION}</td>
+						</tr>
+
+						</table>
+					</td>
+<td width=25% valign=top>
+					<!-- icon 9-->	
+					<table border=0 cellspacing=0 cellpadding=5 width=100%>
+					<tr>
+						<td rowspan=2 valign=top><a href="index.php?module=Settings&action=DefModuleView&parenttab=Settings"><img src="{$IMAGE_PATH}set-IcoTwoTabConfig.gif" alt="{$MOD.LBL_DEFAULT_MODULE_VIEW}" width="48" height="48" border=0 title="{$MOD.LBL_DEFAULT_MODULE_VIEW}"></a></td>
+						<td class=big valign=top><a href="index.php?module=Settings&action=DefModuleView&parenttab=Settings">{$MOD.LBL_DEFAULT_MODULE_VIEW}</a></td>
+					</tr>
+					<tr>
+						<td class="small" valign=top>{$MOD.LBL_DEFAULT_MODULE_VIEW_DESC}</td>
+					</tr>
+
+					</table>
+					</td>
+				  <td valign=top><table border=0 cellspacing=0 cellpadding=5 width=100%>
+                    <tr>
+                      <td rowspan=2 valign=top><a href="index.php?module=Migration&action=index&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}migrate.gif" alt="{$MOD.LBL_MIGRATION}" title="{$MOD.LBL_MIGRATION}"></a></td>
+                      <td class=big valign=top><a href="index.php?module=Migration&action=index&parenttab=Settings">{$MOD.LBL_MIGRATION}</a></td>
+                    </tr>
+                    <tr>
+                      <td class="small" valign=top>{$MOD.LBL_MIGRATION_INFO}</td>
+                    </tr>
+                  </table></td>
+		<td width=25% valign=top>
+			<!-- icon 15-->
+			<table border=0 cellspacing=0 cellpadding=5 width=100%>
+			<tr>
+
+			<td rowspan=2 valign=top><a href="index.php?module=Settings&action=OrganizationTermsandConditions&parenttab=Settings"><img border=0 src="{$IMAGE_PATH}terms.gif" alt="{$MOD.INVENTORYTERMSANDCONDITIONS}" title="{$MOD.INVENTORYTERMSANDCONDITIONS}"></a></td>
+			<td class=big valign=top><a href="index.php?module=Settings&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td>
+			</tr>
+			<tr>
+			<td class="small" valign=top>{$MOD.LBL_INV_TANDC_DESCRIPTION}</td>
+			</tr>
+			</table>
+
+		</td>
+
+		</tr>
+
+		<!-- Added for Custom Invoice Number #start -->
+		<!-- icon for Invoice Number Configuration -->
+		<tr>
+			<td width=25% valign=top>
+			<!-- empty-->
+
+			<table border=0 cellspacing=0 cellpadding=5 width=100%>
+			<tr>
+				<td rowspan=2 valign=top><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings"><img src="{$IMAGE_PATH}settingsInvNumber.gif" alt="{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}" width="48" height="48" border=0 title="{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}"></a></td>
+				<td class=big valign=top><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}</a></td>
+			</tr>
+			<tr>
+				<td class="small" valign=top>{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER_DESCRIPTION}</td>
+			</tr>
+
+			</table>
+			</td>
+		</tr>
+		<!-- Added for Custom Invoice Number #end -->
+
+		</table>
+		
+		</td>
+	</tr>
+	</table>
+	</td></tr></table>	
+	</div>
+
+	</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody></table>
+
+
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/Announcements.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/Announcements.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/Announcements.tpl Mon Apr 16 12:27:44 2007
@@ -18,11 +18,15 @@
 {
 	$("an_busy").style.display="inline";
 	var announcement=$("announcement").value;
+
+	//Replace & with ##$## and do vice versa in modules/Settings/SettingsAjax.php. if we pass as it is, request of announcement will be skipped after &
+	announcement = announcement.replace(/&/g,"##$##");//replace('&','##$##');
+
 	new Ajax.Request(
 	'index.php',
         {queue: {position: 'end', scope: 'command'},
        		method: 'post',
-	        postBody: 'module=Users&action=UsersAjax&announcement='+announcement+'&announce_save=yes',
+	        postBody: 'module=Settings&action=SettingsAjax&announcement='+announcement+'&announce_save=yes',
 	        onComplete: function(response) {
 					$("announcement").innerHTML=response.responseText;
 					$("an_busy").style.display="none";
@@ -73,9 +77,9 @@
 						<td class="listTableRow small" valign=top><textarea class=small width=90% height=100px id="announcement" name="announcement">{$ANNOUNCE}</textarea></td>
 					  </tr>
 					</table>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<!--table border=0 cellspacing=0 cellpadding=5 width=100% >
 					<tr><td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
-					</table>
+					</table-->
 				</td>
 				</tr>
 				</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServer.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServer.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServer.tpl Mon Apr 16 12:27:44 2007
@@ -28,7 +28,7 @@
 				<input type="hidden" name="server_type" value="backup">
 				<input type="hidden" name="parenttab" value="Settings">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}backupserver.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}backupserver.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_BACKUP_SERVER_SETTINGS} </b></td>
 				</tr>
 				<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServerContents.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServerContents.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/BackupServerContents.tpl Mon Apr 16 12:27:44 2007
@@ -59,8 +59,8 @@
 			</td>
 			  </tr>
 			</table>
-			<table border=0 cellspacing=0 cellpadding=5 width=100% >
+			<!--table border=0 cellspacing=0 cellpadding=5 width=100% >
 			<tr>
 				  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
 			</tr>
-			</table>
+			</table-->

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailConfig.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailConfig.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailConfig.tpl Mon Apr 16 12:27:44 2007
@@ -36,7 +36,7 @@
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ogmailserver.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}ogmailserver.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_MAIL_SERVER_SETTINGS} </b></td>
 				</tr>
 				<tr>
@@ -132,11 +132,11 @@
 						</td>
 					  </tr>
 					</table>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<!--table border=0 cellspacing=0 cellpadding=5 width=100% >
 					<tr>
 					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
 					</tr>
-					</table>
+					</table-->
 				</td>
 				</tr>
 				</table>
@@ -164,8 +164,10 @@
 {
 	if(form.server.value =='')
 	{
-		alert("Server Name cannot be empty")
-			return false;
+		{/literal}
+                alert("{$APP.SERVERNAME_CANNOT_BE_EMPTY}")
+                        return false;
+                {literal}
 	}
 	return true;
 }

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailNotification.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailNotification.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/EmailNotification.tpl Mon Apr 16 12:27:44 2007
@@ -47,7 +47,7 @@
 			<!-- DISPLAY -->
 			<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 			<tr>
-				<td width="50" rowspan="2" valign="top"><img src="{$IMAGE_PATH}notification.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+				<td width="50" rowspan="2" valign="top"><img src="{$IMAGE_PATH}notification.gif" alt="{$MOD.LBL_MODULE_NAME}" width="48" height="48" border=0 title="{$MOD.LBL_MODULE_NAME}"></td>
 				<td colspan="2" class="heading2" valign=bottom align="left"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.NOTIFICATIONSCHEDULERS} </b></td>
 				<td rowspan=2 class="small" align=right>&nbsp;</td>
 			</tr>
@@ -110,7 +110,7 @@
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
                         method: 'post',
-                        postBody: 'action=UsersAjax&module=Users&file=SaveNotification&active='+active+'&notifysubject='+subject+'&notifybody='+body+'&record='+id,
+                        postBody: 'action=SettingsAjax&module=Settings&file=SaveNotification&active='+active+'&notifysubject='+subject+'&notifybody='+body+'&record='+id,
                         onComplete: function(response) {
                                 $("status").style.display="none";
 				$("notifycontents").innerHTML=response.responseText;
@@ -126,7 +126,7 @@
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
                         method: 'post',
-                        postBody:'action=UsersAjax&module=Users&file=EditNotification&record='+id,
+                        postBody:'action=SettingsAjax&module=Settings&file=EditNotification&record='+id,
                         onComplete: function(response) {
                                 $("status").style.display="none";
                                 $("editdiv").innerHTML=response.responseText;

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryNotify.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryNotify.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryNotify.tpl Mon Apr 16 12:27:44 2007
@@ -47,7 +47,7 @@
 			<!-- DISPLAY -->
 			<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 			<tr>
-				<td width="50" rowspan="2" valign="top"><img src="{$IMAGE_PATH}inventory.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+				<td width="50" rowspan="2" valign="top"><img src="{$IMAGE_PATH}inventory.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 				<td colspan="2" class="heading2" valign=bottom align="left"><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.INVENTORYNOTIFICATION} </b></td>
 				<td rowspan=2 class="small" align=right>&nbsp;</td>
 			</tr>
@@ -104,7 +104,7 @@
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
                         method: 'post',
-                        postBody: 'action=UsersAjax&module=Users&file=SaveInventoryNotification&notifysubject='+subject+'&notifybody='+body+'&record='+id,
+                        postBody: 'action=SettingsAjax&module=Settings&file=SaveInventoryNotification&notifysubject='+subject+'&notifybody='+body+'&record='+id,
                         onComplete: function(response) {
                                 $("status").style.display="none";
                         }
@@ -119,7 +119,7 @@
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
                         method: 'post',
-                        postBody: 'action=UsersAjax&module=Users&file=EditInventoryNotification&record='+id,
+                        postBody: 'action=SettingsAjax&module=Settings&file=EditInventoryNotification&record='+id,
                         onComplete: function(response) {
                                 $("status").style.display="none";
 				$("editdiv").innerHTML=response.responseText;

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryTerms.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryTerms.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/InventoryTerms.tpl Mon Apr 16 12:27:44 2007
@@ -18,7 +18,7 @@
         <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
 <br>
 <form action="index.php" method="post" name="tandc">
-<input type="hidden" name="module" value="Users">
+<input type="hidden" name="module" value="Settings">
 <input type="hidden" name="action">
 <input type="hidden" name="inv_terms_mode">
 <input type="hidden" name="parenttab" value="Settings">

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ModuleOwners.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ModuleOwners.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ModuleOwners.tpl Mon Apr 16 12:27:44 2007
@@ -24,7 +24,7 @@
 			<!-- DISPLAY -->
 			<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 			<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}assign.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}assign.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 				<td class="heading2" valign="bottom" ><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_MODULE_OWNERS} </b></td>
 			</tr>
 			<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/PickList.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/PickList.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/PickList.tpl Mon Apr 16 12:27:44 2007
@@ -1,259 +1,267 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
-<script src="include/scriptaculous/prototype.js" type="text/javascript"></script>
-<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
-<script>
-{literal}
-function splitvalues() {
-	var picklistobj=getobj("listarea")
-	var picklistcontent=picklistobj.value
-	var picklistary=new array()
-	var i=0;
-	
-	//splitting up of values
-	if (picklistcontent.indexof("\n")!=-1) {
-		while(picklistcontent.indexof("\n")!=-1) {
-			if (picklistcontent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
-				picklistary[i]=picklistcontent.substr(0,picklistcontent.indexof("\n")).replace(/^\s+/g, '').replace(/\s+$/g, '')
-				picklistcontent=picklistcontent.substr(picklistcontent.indexof("\n")+1,picklistcontent.length)
-				i++
-			} else break;
-		}
-	} else if (picklistcontent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
-		picklistary[0]=picklistcontent.replace(/^\s+/g, '').replace(/\s+$/g, '')
-	}
-	
-	return picklistary;
-}
-function setdefaultlist() {
-	var picklistary=new array()
-	picklistary=splitvalues()
-	
-	getobj("defaultlist").innerhtml=""
-	
-	for (i=0;i<picklistary.length;i++) {
-		var objoption=document.createelement("option")
-		if (browser_ie) {
-			objoption.innertext=picklistary[i]
-			objoption.value=picklistary[i]
-		} else if (browser_nn4 || browser_nn6) {
-			objoption.text=picklistary[i]
-			objoption.setattribute("value",picklistary[i])
-		}
-	
-		getobj("defaultlist").appendchild(objoption)
-	}
-}
-function validate() {
-	if (emptycheck("listarea","picklist values"))	{
-		var picklistary=new array()
-		picklistary=splitvalues()
-		//empty check validation
-		for (i=0;i<picklistary.length;i++) {
-			if (picklistary[i]=="") {
-				alert("picklist value cannot be empty")
-				picklistobj.focus()
-				return false
-			}
-		}
-
-		//duplicate values' validation
-		for (i=0;i<picklistary.length;i++) {
-			for (j=i+1;j<picklistary.length;j++) {
-				if (picklistary[i]==picklistary[j]) {
-					alert("duplicate values found")
-					picklistobj.focus()
-					return false
-				}
-			}
-		}
-
-		return true;
-	}
-}
-
-{/literal}
-</script>
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-<br>
-	<div align=center>
-	
-			{include file='SetMenu.tpl'}
-				<!-- DISPLAY -->
-				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}picklist.gif" width="48" height="48" border=0 ></td>
-					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_PICKLIST_EDITOR}</b></td>
-				</tr>
-				<tr>
-					<td valign=top class="small">{$MOD.LBL_PICKLIST_DESCRIPTION}</td>
-				</tr>
-				</table>
-				
-				
-				<table border=0 cellspacing=0 cellpadding=10 width=100% >
-				<tr>
-				<td valign=top>
-				
-					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-					<tr>
-						<td class="big"><strong>1. {$MOD.LBL_SELECT_MODULE}</strong></td>
-						<td class="small" align=right>&nbsp;</td>
-					</tr>
-					</table>
-					<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
-						<tr class="small">
-                        	<td width="35%" class="small cellLabel"><strong>{$MOD.LBL_SELECT_CRM_MODULE}</strong></td>
-	                        <td width="65%" class="cellText" >
-					<select name="pickmodule" class="detailedViewTextBox" onChange="changeModule(this);">
-					{foreach key=tabid item=module from=$MODULE_LISTS}
-						<option value="{$module}">{$APP.$module}</option>
-					{/foreach}
-					</select>
-				</td>
-                      </tr>
-					</table>
-					<br>
-				<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-				<tr>
-				    <td class="big" rowspan="2">
-					<div id="picklist_datas">	
-						{include file='Settings/PickListContents.tpl'}
-					</div>
-				    </td>	
-				</td>
-				</tr>
-			    	</table>
-				<table border=0 cellspacing=0 cellpadding=5 width=100% >
-					<tr><td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
-				</table>
-				
-				</td>
-				</tr>
-				</table>
-			
-			
-			
-			</td>
-			</tr>
-			</table>
-		</td>
-	</tr>
-	</table>
-		
-	</div>
-
-</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody>
-</table>
-<div id="editdiv" style="display:block;position:absolute;width:510px;"></div>
-{literal}
-<script>
-function SavePickList(fieldname,module,uitype)
-{
-	$("status").style.display = "inline";
-	Effect.Puff($('editdiv'),{duration:2});
-	var body = escape($("picklist_values").value);
-
-	new Ajax.Request(
-        	'index.php?action=SettingsAjax&module=Settings&directmode=ajax&file=UpdateComboValues&table_name='+fieldname+'&fld_module='+module+'&listarea='+body+'&uitype='+uitype,
-	        {queue: {position: 'end', scope: 'command'},
-        		method: 'get',
-		        postBody: null,
-		        /* postBody: 'action=SettingsAjax&module=Settings&directmode=ajax&file=UpdateComboValues&table_name='+fieldname+'&fld_module='+module+'&listarea='+body, */
-		        onComplete: function(response) {
-					$("status").style.display="none";
-        				$("picklist_datas").innerHTML=response.responseText;
-	                        }
-        	}
-	);
-}
-function changeModule(pickmodule)
-{
-	$("status").style.display="inline";
-	var module=pickmodule.options[pickmodule.options.selectedIndex].value;
-	new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: 'action=SettingsAjax&module=Settings&directmode=ajax&file=PickList&fld_module='+module,
-                        onComplete: function(response) {
-                                        $("status").style.display="none";
-                                        $("picklist_datas").innerHTML=response.responseText;
-                                }
-                }
-        );
-}
-function fetchEditPickList(module,fieldname,uitype)
-{
-	$("status").style.display="inline";
-	new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: 'action=SettingsAjax&module=Settings&mode=edit&file=EditComboField&fld_module='+module+'&fieldname='+fieldname+'&uitype='+uitype,
-			onComplete: function(response) {
-                                        $("status").style.display="none";
-                                        $("editdiv").innerHTML=response.responseText;
-					Effect.Grow('editdiv');
-                	}
-                }
-        );
-}
-
-function picklist_validate(mode,fieldname,module,uitype)
-{
-	
-	//alert(trim($("picklist_values").value));
-	
-	var pick_arr=new Array();
-	pick_arr=trim($("picklist_values").value).split('\n');	
-	var len=pick_arr.length;
-	for(i=0;i<len;i++)
-	{
-		var valone;
-		curr_iter = i;
-		valone=pick_arr[curr_iter];
-		for(j=curr_iter+1;j<len;j++)
-		{
-			var valnext;
-			valnext=pick_arr[j];
-			if(trim(valone) == trim(valnext))
-			{
-				alert("Duplicate entries found for the value '"+valone+"'");
-				return false;
-			}
-		}
-		i = curr_iter		
-
-	}
-	if(mode == 'edit')
-	{
-		if(trim($("picklist_values").value) == '')
-		{
-			alert("Picklist value cannot be empty");
-			$("picklist_values").focus();	
-			return false;
-		}
-	}
-	SavePickList(fieldname,module,uitype)	
-}
-</script>
-{/literal}
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
+<script src="include/scriptaculous/prototype.js" type="text/javascript"></script>
+<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+<script>
+{literal}
+function splitvalues() {
+	var picklistobj=getobj("listarea")
+	var picklistcontent=picklistobj.value
+	var picklistary=new array()
+	var i=0;
+	
+	//splitting up of values
+	if (picklistcontent.indexof("\n")!=-1) {
+		while(picklistcontent.indexof("\n")!=-1) {
+			if (picklistcontent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
+				picklistary[i]=picklistcontent.substr(0,picklistcontent.indexof("\n")).replace(/^\s+/g, '').replace(/\s+$/g, '')
+				picklistcontent=picklistcontent.substr(picklistcontent.indexof("\n")+1,picklistcontent.length)
+				i++
+			} else break;
+		}
+	} else if (picklistcontent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
+		picklistary[0]=picklistcontent.replace(/^\s+/g, '').replace(/\s+$/g, '')
+	}
+	
+	return picklistary;
+}
+function setdefaultlist() {
+	var picklistary=new array()
+	picklistary=splitvalues()
+	
+	getobj("defaultlist").innerhtml=""
+	
+	for (i=0;i<picklistary.length;i++) {
+		var objoption=document.createelement("option")
+		if (browser_ie) {
+			objoption.innertext=picklistary[i]
+			objoption.value=picklistary[i]
+		} else if (browser_nn4 || browser_nn6) {
+			objoption.text=picklistary[i]
+			objoption.setattribute("value",picklistary[i])
+		}
+	
+		getobj("defaultlist").appendchild(objoption)
+	}
+}
+function validate() {
+	if (emptycheck("listarea","picklist values"))	{
+		var picklistary=new array()
+		picklistary=splitvalues()
+		//empty check validation
+		for (i=0;i<picklistary.length;i++) {
+			if (picklistary[i]=="") {
+				{/literal}
+                                alert("{$APP.PICKLIST_CANNOT_BE_EMPTY}")
+				picklistobj.focus()
+				return false
+				{literal}
+			}
+		}
+
+		//duplicate values' validation
+		for (i=0;i<picklistary.length;i++) {
+			for (j=i+1;j<picklistary.length;j++) {
+				if (picklistary[i]==picklistary[j]) {
+					{/literal}
+                                        alert("{$APP.DUPLICATE_VALUES_FOUND}")
+					picklistobj.focus()
+					return false
+					{literal}
+				}
+			}
+		}
+
+		return true;
+	}
+}
+
+{/literal}
+</script>
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+<br>
+	<div align=center>
+	
+			{include file='SetMenu.tpl'}
+				<!-- DISPLAY -->
+				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
+				<tr>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}picklist.gif" width="48" height="48" border=0 ></td>
+					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_PICKLIST_EDITOR}</b></td>
+				</tr>
+				<tr>
+					<td valign=top class="small">{$MOD.LBL_PICKLIST_DESCRIPTION}</td>
+				</tr>
+				</table>
+				
+				
+				<table border=0 cellspacing=0 cellpadding=10 width=100% >
+				<tr>
+				<td valign=top>
+				
+					<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+					<tr>
+						<td class="big"><strong>1. {$MOD.LBL_SELECT_MODULE}</strong></td>
+						<td class="small" align=right>&nbsp;</td>
+					</tr>
+					</table>
+					<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small">
+						<tr class="small">
+                        	<td width="35%" class="small cellLabel"><strong>{$MOD.LBL_SELECT_CRM_MODULE}</strong></td>
+	                        <td width="65%" class="cellText" >
+					<select name="pickmodule" class="detailedViewTextBox" onChange="changeModule(this);">
+					{foreach key=tabid item=module from=$MODULE_LISTS}
+						<option value="{$module}">{$APP.$module}</option>
+					{/foreach}
+					</select>
+				</td>
+                      </tr>
+					</table>
+					<br>
+				<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+				<tr>
+				    <td class="big" rowspan="2">
+					<div id="picklist_datas">	
+						{include file='Settings/PickListContents.tpl'}
+					</div>
+				    </td>	
+				</td>
+				</tr>
+			    	</table>
+				<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<tr><td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td></tr>
+				</table>
+				
+				</td>
+				</tr>
+				</table>
+			
+			
+			
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+	</table>
+		
+	</div>
+
+</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody>
+</table>
+<div id="editdiv" style="display:block;position:absolute;width:510px;"></div>
+{literal}
+<script>
+function SavePickList(fieldname,module,uitype)
+{
+	$("status").style.display = "inline";
+	Effect.Puff($('editdiv'),{duration:2});
+	var body = escape($("picklist_values").value);
+
+	new Ajax.Request(
+        	'index.php?action=SettingsAjax&module=Settings&directmode=ajax&file=UpdateComboValues&table_name='+fieldname+'&fld_module='+module+'&listarea='+body+'&uitype='+uitype,
+	        {queue: {position: 'end', scope: 'command'},
+        		method: 'get',
+		        postBody: null,
+		        /* postBody: 'action=SettingsAjax&module=Settings&directmode=ajax&file=UpdateComboValues&table_name='+fieldname+'&fld_module='+module+'&listarea='+body, */
+		        onComplete: function(response) {
+					$("status").style.display="none";
+        				$("picklist_datas").innerHTML=response.responseText;
+	                        }
+        	}
+	);
+}
+function changeModule(pickmodule)
+{
+	$("status").style.display="inline";
+	var module=pickmodule.options[pickmodule.options.selectedIndex].value;
+	new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: 'action=SettingsAjax&module=Settings&directmode=ajax&file=PickList&fld_module='+module,
+                        onComplete: function(response) {
+                                        $("status").style.display="none";
+                                        $("picklist_datas").innerHTML=response.responseText;
+                                }
+                }
+        );
+}
+function fetchEditPickList(module,fieldname,uitype)
+{
+	$("status").style.display="inline";
+	new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: 'action=SettingsAjax&module=Settings&mode=edit&file=EditComboField&fld_module='+module+'&fieldname='+fieldname+'&uitype='+uitype,
+			onComplete: function(response) {
+                                        $("status").style.display="none";
+                                        $("editdiv").innerHTML=response.responseText;
+					Effect.Grow('editdiv');
+                	}
+                }
+        );
+}
+
+function picklist_validate(mode,fieldname,module,uitype)
+{
+	
+	//alert(trim($("picklist_values").value));
+	
+	var pick_arr=new Array();
+	pick_arr=trim($("picklist_values").value).split('\n');	
+	var len=pick_arr.length;
+	for(i=0;i<len;i++)
+	{
+		var valone;
+		curr_iter = i;
+		valone=pick_arr[curr_iter];
+		for(j=curr_iter+1;j<len;j++)
+		{
+			var valnext;
+			valnext=pick_arr[j];
+			if(trim(valone) == trim(valnext))
+			{
+				{/literal}
+                                alert("{$APP.DUPLICATE_ENTRIES_FOUND}"+valone+"'");
+                                return false;
+                                {literal}
+			}
+		}
+		i = curr_iter		
+
+	}
+	if(mode == 'edit')
+	{
+		if(trim($("picklist_values").value) == '')
+		{
+			{/literal}
+                        alert("{$APP.PICKLIST_CANNOT_BE_EMPTY}");
+                        $("picklist_values").focus();
+                        return false;
+                        {literal}
+		}
+	}
+	SavePickList(fieldname,module,uitype)	
+}
+</script>
+{/literal}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ProxyServer.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ProxyServer.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/ProxyServer.tpl Mon Apr 16 12:27:44 2007
@@ -27,7 +27,7 @@
 				<input type="hidden" name="proxy_server_mode">
 				<input type="hidden" name="parenttab" value="Settings">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}proxy.gif" alt="proxy" width="48" height="48" border=0 title="proxy"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}proxy.gif" alt="{$MOD.LBL_PROXY}" width="48" height="48" border=0 title="{$MOD.LBL_PROXY}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_PROXY_SERVER_SETTINGS} </b></td>
 				</tr>
 				<tr>
@@ -63,20 +63,20 @@
                         <tr>
                             <td width="20%" nowrap class="small cellLabel"><font color="red">*</font><strong>{$MOD.LBL_SERVER_ADDRESS} </strong></td>
                             <td width="80%" class="small cellText">
-				<input type="text" class="detailedViewTextBox small" value="{$PROXYSERVER}" name="server"></strong>
+				<input type="text" class="detailedViewTextBox small" value="{$PROXYSERVER}{$smarty.request.server}" name="server"></strong>
 			    </td>
                           </tr>
 			  <tr>
                             <td width="20%" nowrap class="small cellLabel"><font color="red">*</font><strong>{$MOD.LBL_PROXY_PORT} </strong></td>
                             <td width="80%" class="small cellText">
-                                <input type="text" class="detailedViewTextBox small" value="{$PROXYPORT}" name="port"></strong>
+                                <input type="text" class="detailedViewTextBox small" value="{$PROXYPORT}{$smarty.request.port}" name="port"></strong>
                             </td>
                           </tr>
                           <tr valign="top">
 
                             <td nowrap class="small cellLabel"><font color="red">*</font><strong>{$MOD.LBL_USERNAME}</strong></td>
                             <td class="small cellText">
-				<input type="text" class="detailedViewTextBox small" value="{$PROXYUSER}" name="server_username">
+				<input type="text" class="detailedViewTextBox small" value="{$PROXYUSER}{$smarty.request.server_username}" name="server_username">
 			    </td>
                           </tr>
                           <tr>
@@ -116,11 +116,11 @@
 						</td>
 					  </tr>
 					</table>
-					<table border=0 cellspacing=0 cellpadding=5 width=100% >
+					<!--table border=0 cellspacing=0 cellpadding=5 width=100% >
 					<tr>
 					  <td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
 					</tr>
-					</table>
+					</table-->
 				</td>
 				</tr>
 				</table>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Settings/TaxConfig.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Settings/TaxConfig.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Settings/TaxConfig.tpl Mon Apr 16 12:27:44 2007
@@ -1,262 +1,268 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/Inventory.js"></script>
-
-{literal}
-<style>
-	
-	.tax_delete{
-		text-decoration:none;
-	}
-	
-	.tax_delete td{
-			
-	}
-	
-</style>
-{/literal}
-<br>
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody>
-   <tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-	<br>
-	<div align=center>
-
-			{include file='SetMenu.tpl'}
-				<!-- DISPLAY -->
-{if $EDIT_MODE eq 'true'}
-	{assign var=formname value='EditTax'}
-	{assign var=shformname value='SHEditTax'}
-{else}
-	{assign var=formname value='ListTax'}
-	{assign var=shformname value='SHListTax'}
-{/if}
-
-
-<!-- This table is used to display the Tax Configuration values-->
-<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
-   <tr>
-	<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}taxConfiguration.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
-	<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > 
-		{if $EDIT_MODE eq 'true'}
-			<strong>{$MOD.LBL_EDIT} {$MOD.LBL_TAX_SETTINGS} </strong>
-		{else}
-			<strong>{$MOD.LBL_TAX_SETTINGS} </strong>
-		{/if}
-		</b>
-	</td>
-   </tr>
-   <tr>
-	<td valign=top class="small">{$MOD.LBL_TAX_DESC}</td>
-   </tr>
-</table>
-
-<br>
-<table border=0 cellspacing=0 cellpadding=10 width=100%>
-   <tr>
-	<td style="border-right:1px dotted #CCCCCC;" valign="top">
-		<!-- if EDIT_MODE is true then Textbox will be displayed else the value will be displayed-->
-		<form name="{$formname}" method="POST" action="index.php">
-		<input type="hidden" name="module" value="Settings">
-		<input type="hidden" name="action" value="">
-		<input type="hidden" name="parenttab" value="Settings">
-		<input type="hidden" name="save_tax" value="">
-		<input type="hidden" name="edit_tax" value="">
-		<input type="hidden" name="add_tax_type" value="">
-
-		<!-- Table to display the Product Tax Add and Edit Buttons - Starts -->
-		<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-		   <tr>
-			<td class="big" colspan="3"><strong>{$MOD.LBL_PRODUCT_TAX_SETTINGS} </strong></td>
-		   </tr>
-		   <tr>
-			<td>&nbsp;</td>
-			<td id="td_add_tax" class="small" colspan="2" align="right" nowrap>
-				{if $EDIT_MODE neq 'true'}
-					<input title="Add Tax" accessKey="Add Tax" onclick="fnAddTaxConfigRow('');" type="button" name="button" value="{$MOD.LBL_ADD_TAX_BUTTON}" class="crmButton small edit">
-				{/if}
-			</td>
-			<td class="small" align=right nowrap>
-			{if $EDIT_MODE eq 'true'}	
-				<input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}"  onclick="this.form.action.value='TaxConfig'; this.form.save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('tax_count');" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL}  ">&nbsp;
-				<input class="crmButton small cancel" title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form.save_tax.value='false'; this.form.parenttab.value='Settings';" type="submit" name="button22" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  ">
-			{elseif $TAX_COUNT > 0}
-				<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.edit_tax.value='true'; this.form.parenttab.value='Settings';" type="submit" name="button" value="  {$APP.LBL_EDIT_BUTTON_LABEL}  " class="crmButton small edit">
-			{/if}
-			</td>
-		   </tr>
-		</table>
-		<!-- Table to display the Product Tax Add and Edit Buttons - Ends -->
-
-		<!-- Table to display the List of Product Tax values - Starts -->
-		<table id="add_tax" border=0 cellspacing=0 cellpadding=5 width=100% class="listRow">
-		   {if $TAX_COUNT eq 0}
-			<tr><td>No taxes available. Please Add Tax.</td></tr>
-		   {else}
-			{foreach item=tax key=count from=$TAX_VALUES}
-
-				<!-- To set the color coding for the taxes which are active and inactive-->
-				{if $tax.deleted eq 0}
-				   <tr><!-- set color to taxes which are active now-->
-				{else}
-				   <tr><!-- set color to taxes which are disabled now-->
-				{/if}
-				
-				<!--assinging tax label name for javascript validation-->
-				{assign var=tax_label value="taxlabel_"|cat:$tax.taxname} 
-        
-				<td width=35% class="cellLabel small" >
-					{if $EDIT_MODE eq 'true'}
-						<input name="{$tax.taxlabel}" id={$tax_label} type="text" value="{$tax.taxlabel}" class="detailedViewTextBox small">
-					{else}
-						{$tax.taxlabel}
-					{/if}
-				</td>
-				<td width=55% class="cellText small">
-					{if $EDIT_MODE eq 'true'}
-						<input name="{$tax.taxname}" id="{$tax.taxname}" type="text" value="{$tax.percentage}" class="detailedViewTextBox small">&nbsp;%
-					{else}
-						{$tax.percentage}&nbsp;%
-					{/if}
-				</td>
-				<td width=10% class="cellText small">
-						{if $tax.deleted eq 0}
-							<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&disable=true&taxname={$tax.taxname}"><img src="{$IMAGE_PATH}enabled.gif" border="0" align="absmiddle" alt="Enable me" title="Disable me"></a>
-						{else}
-							<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&enable=true&taxname={$tax.taxname}"><img src="{$IMAGE_PATH}disabled.gif" border="0" align="absmiddle" alt="Enable me" title="Enable me"></a>
-						{/if}
-				</td>
-			   </tr>
-			{/foreach}
-			{if $EDIT_MODE eq 'true'}
-				<input type="hidden" id="tax_count" value="{$count}">
-			{/if}
-		   {/if}
-		</table>
-		<!-- Table to display the List of Product Tax values - Ends -->
-		</form>
-	</td>
-
-	<!-- Shipping Tax Config Table Starts Here -->
-	<td width="50%" valign="top">
-		<form name="{$shformname}" method="POST" action="index.php">
-		<input type="hidden" name="module" value="Settings">
-		<input type="hidden" name="action" value="">
-		<input type="hidden" name="parenttab" value="Settings">
-		<input type="hidden" name="sh_save_tax" value="">
-		<input type="hidden" name="sh_edit_tax" value="">
-		<input type="hidden" name="sh_add_tax_type" value="">
-
-		<!-- Table to display the S&H Tax Add and Edit Buttons - Starts -->
-		<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
-		   <tr>
-        		<td class="big" colspan="3"><strong>{$MOD.LBL_SHIPPING_HANDLING_TAX_SETTINGS}</strong></td>
-		   </tr>
-		   <tr>
-			<td>&nbsp;</td>
-        		<td id="td_sh_add_tax" class="small" colspan="2" align="right" nowrap>
-				{if $SH_EDIT_MODE neq 'true'}
-					<input title="Add Tax" accessKey="Add Tax" onclick="fnAddTaxConfigRow('sh');" type="button" name="button" value="  Add Tax  " class="crmButton small edit">
-				{/if}
-			</td>
-			<td class="small" align=right nowrap>
-				{if $SH_EDIT_MODE eq 'true'}
-					<input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}"  onclick="this.form.action.value='TaxConfig'; this.form.sh_save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('sh_tax_count');" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL}  ">
-					&nbsp;
-					<input class="crmButton small cancel" title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form.sh_save_tax.value='false'; this.form.parenttab.value='Settings';" type="submit" name="button22" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  ">
-				{elseif $SH_TAX_COUNT > 0}
-					<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.sh_edit_tax.value='true'; this.form.parenttab.value='Settings';" type="submit" name="button" value="  {$APP.LBL_EDIT_BUTTON_LABEL}  " class="crmButton small edit">
-				{/if}
-			</td>
-		   </tr>
-		</table>
-		<!-- Table to display the S&H Tax Add and Edit Buttons - Ends -->
-
-		<!-- Table to display the List of S&H Tax Values - Starts -->
-		<table id="sh_add_tax" border=0 cellspacing=0 cellpadding=5 width=100% class="listRow">
-		   {if $SH_TAX_COUNT eq 0}
-			<tr><td>No taxes available. Please Add Tax.</td></tr>
-		   {else}
-		   	{foreach item=tax key=count from=$SH_TAX_VALUES}
-
-			<!-- To set the color coding for the taxes which are active and inactive-->
-			{if $tax.deleted eq 0}
-			   <tr><!-- set color to taxes which are active now-->
-			{else}
-			   <tr><!-- set color to taxes which are disabled now-->
-			{/if}
-
-			{assign var=tax_label value="taxlabel_"|cat:$tax.taxname} 
-			<td width=35% class="cellLabel small">
-			 	{if $SH_EDIT_MODE eq 'true'}
-			 	
-					<input name="{$tax.taxlabel}" id="{$tax_label}" type="text" value="{$tax.taxlabel}" class="detailedViewTextBox small">
-			 	{else} 
-					{$tax.taxlabel}
-				{/if}
-			</td>
-			<td width=55% class="cellText small">
-				{if $SH_EDIT_MODE eq 'true'}
-					<input name="{$tax.taxname}" id="{$tax.taxname}" type="text" value="{$tax.percentage}" class="detailedViewTextBox small">
-					&nbsp;% 
-				{else} 
-					{$tax.percentage}&nbsp;% 
-				{/if}
-			</td>
-			<td width=10% class="cellText small"> 
-				{if $tax.deleted eq 0}
-						<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&sh_disable=true&sh_taxname={$tax.taxname}"><img src="{$IMAGE_PATH}enabled.gif" border="0" align="absmiddle" alt="Enable me" title="Disable me"></a>
-					{else}
-						<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&sh_enable=true&sh_taxname={$tax.taxname}"><img src="{$IMAGE_PATH}disabled.gif" border="0" align="absmiddle" alt="Enable me" title="Enable me"></a>
-					{/if}
-			</td>
-		   </tr>
-		   {/foreach}
-		   {if $SH_EDIT_MODE eq 'true'}
-			<input type="hidden" id="sh_tax_count" value="{$count}">
-		   {/if}
-		{/if}
-		</table>
-		<!-- Table to display the List of S&H Tax Values - Ends -->
-	        </form>
-	</td>
-	<!-- Shipping Tax Ends Here -->
-   </tr>
-</table>
-
-<table border=0 cellspacing=0 cellpadding=5 width=100% >
-		   <tr>
-			<td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
-		   </tr>
-</table>
-
-
-			
-			
-			</td>
-			</tr>
-			</table>
-		</td>
-	</tr>
-	</table>
-	</div>
-
-</td>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
-   </tr>
-</tbody>
-</table>
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/Inventory.js"></script>
+
+{literal}
+<style>
+	
+	.tax_delete{
+		text-decoration:none;
+	}
+	
+	.tax_delete td{
+			
+	}
+	
+</style>
+{/literal}
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody>
+   <tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+	<br>
+	<div align=center>
+
+			{include file='SetMenu.tpl'}
+				<!-- DISPLAY -->
+{if $EDIT_MODE eq 'true'}
+	{assign var=formname value='EditTax'}
+	{assign var=shformname value='SHEditTax'}
+{else}
+	{assign var=formname value='ListTax'}
+	{assign var=shformname value='SHListTax'}
+{/if}
+
+
+<!-- This table is used to display the Tax Configuration values-->
+<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
+   <tr>
+	<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}taxConfiguration.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
+	<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > 
+		{if $EDIT_MODE eq 'true'}
+			<strong>{$MOD.LBL_EDIT} {$MOD.LBL_TAX_SETTINGS} </strong>
+		{else}
+			<strong>{$MOD.LBL_TAX_SETTINGS} </strong>
+		{/if}
+		</b>
+	</td>
+   </tr>
+   <tr>
+	<td valign=top class="small">{$MOD.LBL_TAX_DESC}</td>
+   </tr>
+</table>
+
+<br>
+<table border=0 cellspacing=0 cellpadding=10 width=100%>
+   <tr>
+	<td style="border-right:1px dotted #CCCCCC;" valign="top">
+		<!-- if EDIT_MODE is true then Textbox will be displayed else the value will be displayed-->
+		<form name="{$formname}" method="POST" action="index.php">
+		<input type="hidden" name="module" value="Settings">
+		<input type="hidden" name="action" value="">
+		<input type="hidden" name="parenttab" value="Settings">
+		<input type="hidden" name="save_tax" value="">
+		<input type="hidden" name="edit_tax" value="">
+		<input type="hidden" name="add_tax_type" value="">
+
+		<!-- Table to display the Product Tax Add and Edit Buttons - Starts -->
+		<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+		   <tr>
+			<td class="big" colspan="3"><strong>{$MOD.LBL_PRODUCT_TAX_SETTINGS} </strong></td>
+		   </tr>
+		   <tr>
+			<td>&nbsp;</td>
+			<td id="td_add_tax" class="small" colspan="2" align="right" nowrap>
+				{if $EDIT_MODE neq 'true'}
+					<input title="{$MOD.LBL_ADD_TAX_BUTTON}" accessKey="{$MOD.LBL_ADD_TAX_BUTTON}" onclick="fnAddTaxConfigRow('');" type="button" name="button" value="{$MOD.LBL_ADD_TAX_BUTTON}" class="crmButton small edit">
+				{/if}
+			</td>
+			<td class="small" align=right nowrap>
+			{if $EDIT_MODE eq 'true'}	
+				<input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}"  onclick="this.form.action.value='TaxConfig'; this.form.save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('tax_count');" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL}  ">&nbsp;
+				<input class="crmButton small cancel" title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form.save_tax.value='false'; this.form.parenttab.value='Settings';" type="submit" name="button22" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  ">
+			{elseif $TAX_COUNT > 0}
+				<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.edit_tax.value='true'; this.form.parenttab.value='Settings';" type="submit" name="button" value="  {$APP.LBL_EDIT_BUTTON_LABEL}  " class="crmButton small edit">
+			{/if}
+			</td>
+		   </tr>
+		</table>
+		<!-- Table to display the Product Tax Add and Edit Buttons - Ends -->
+
+		<!-- Table to display the List of Product Tax values - Starts -->
+		<table id="add_tax" border=0 cellspacing=0 cellpadding=5 width=100% class="listRow">
+		   {if $TAX_COUNT eq 0}
+			<tr><td>{$MOD.LBL_NO_TAXES_AVAILABLE}. {$MOD.LBL_PLEASE} {$MOD.LBL_ADD_TAX_BUTTON}.</td></tr>
+		   {else}
+			{foreach item=tax key=count from=$TAX_VALUES}
+
+				<!-- To set the color coding for the taxes which are active and inactive-->
+				{if $tax.deleted eq 0}
+				   <tr><!-- set color to taxes which are active now-->
+				{else}
+				   <tr><!-- set color to taxes which are disabled now-->
+				{/if}
+				
+				<!--assinging tax label name for javascript validation-->
+				{assign var=tax_label value="taxlabel_"|cat:$tax.taxname} 
+        
+				<td width=35% class="cellLabel small" >
+					{if $EDIT_MODE eq 'true'}
+						<input name="{$tax.taxlabel}" id={$tax_label} type="text" value="{$tax.taxlabel}" class="detailedViewTextBox small">
+					{else}
+						{$tax.taxlabel}
+					{/if}
+				</td>
+				<td width=55% class="cellText small">
+					{if $EDIT_MODE eq 'true'}
+						<input name="{$tax.taxname}" id="{$tax.taxname}" type="text" value="{$tax.percentage}" class="detailedViewTextBox small">&nbsp;%
+					{else}
+						{$tax.percentage}&nbsp;%
+					{/if}
+				</td>
+				<td width=10% class="cellText small">
+						{if $tax.deleted eq 0}
+							<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&disable=true&taxname={$tax.taxname}"><img src="{$IMAGE_PATH}enabled.gif" border="0" align="absmiddle" alt="{$MOD.LBL_ENABLE}" title="{$MOD.LBL_ENABLE}"></a>
+						{else}
+							<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&enable=true&taxname={$tax.taxname}"><img src="{$IMAGE_PATH}disabled.gif" border="0" align="absmiddle" alt="{$MOD.LBL_ENABLE}" title="{$MOD.LBL_DISABLE}"></a>
+						{/if}
+				</td>
+			   </tr>
+			{/foreach}
+			{if $EDIT_MODE eq 'true'}
+				<input type="hidden" id="tax_count" value="{$count}">
+			{/if}
+		   {/if}
+		</table>
+		<!-- Table to display the List of Product Tax values - Ends -->
+		</form>
+	</td>
+
+	<!-- Shipping Tax Config Table Starts Here -->
+	<td width="50%" valign="top">
+		<form name="{$shformname}" method="POST" action="index.php">
+		<input type="hidden" name="module" value="Settings">
+		<input type="hidden" name="action" value="">
+		<input type="hidden" name="parenttab" value="Settings">
+		<input type="hidden" name="sh_save_tax" value="">
+		<input type="hidden" name="sh_edit_tax" value="">
+		<input type="hidden" name="sh_add_tax_type" value="">
+
+		<!-- Table to display the S&H Tax Add and Edit Buttons - Starts -->
+		<table border=0 cellspacing=0 cellpadding=5 width=100% class="tableHeading">
+		   <tr>
+        		<td class="big" colspan="3"><strong>{$MOD.LBL_SHIPPING_HANDLING_TAX_SETTINGS}</strong></td>
+		   </tr>
+		   <tr>
+			<td>&nbsp;</td>
+        		<td id="td_sh_add_tax" class="small" colspan="2" align="right" nowrap>
+				{if $SH_EDIT_MODE neq 'true'}
+					<input title="{$MOD.LBL_ADD_TAX_BUTTON}" accessKey="{$MOD.LBL_ADD_TAX_BUTTON}" onclick="fnAddTaxConfigRow('sh');" type="button" name="button" value="  {$MOD.LBL_ADD_TAX_BUTTON}  " class="crmButton small edit">
+				{/if}
+			</td>
+			<td class="small" align=right nowrap>
+				{if $SH_EDIT_MODE eq 'true'}
+					<input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}"  onclick="this.form.action.value='TaxConfig'; this.form.sh_save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('sh_tax_count');" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL}  ">
+					&nbsp;
+					<input class="crmButton small cancel" title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form.sh_save_tax.value='false'; this.form.parenttab.value='Settings';" type="submit" name="button22" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  ">
+				{elseif $SH_TAX_COUNT > 0}
+					<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.sh_edit_tax.value='true'; this.form.parenttab.value='Settings';" type="submit" name="button" value="  {$APP.LBL_EDIT_BUTTON_LABEL}  " class="crmButton small edit">
+				{/if}
+			</td>
+		   </tr>
+		</table>
+		<!-- Table to display the S&H Tax Add and Edit Buttons - Ends -->
+
+		<!-- Table to display the List of S&H Tax Values - Starts -->
+		<table id="sh_add_tax" border=0 cellspacing=0 cellpadding=5 width=100% class="listRow">
+		   {if $SH_TAX_COUNT eq 0}
+			<tr><td>{$MOD.LBL_NO_TAXES_AVAILABLE}. {$MOD.LBL_PLEASE} {$MOD.LBL_ADD_TAX_BUTTON}.</td></tr>
+		   {else}
+		   	{foreach item=tax key=count from=$SH_TAX_VALUES}
+
+			<!-- To set the color coding for the taxes which are active and inactive-->
+			{if $tax.deleted eq 0}
+			   <tr><!-- set color to taxes which are active now-->
+			{else}
+			   <tr><!-- set color to taxes which are disabled now-->
+			{/if}
+
+			{assign var=tax_label value="taxlabel_"|cat:$tax.taxname} 
+			<td width=35% class="cellLabel small">
+			 	{if $SH_EDIT_MODE eq 'true'}
+			 	
+					<input name="{$tax.taxlabel}" id="{$tax_label}" type="text" value="{$tax.taxlabel}" class="detailedViewTextBox small">
+			 	{else} 
+					{$tax.taxlabel}
+				{/if}
+			</td>
+			<td width=55% class="cellText small">
+				{if $SH_EDIT_MODE eq 'true'}
+					<input name="{$tax.taxname}" id="{$tax.taxname}" type="text" value="{$tax.percentage}" class="detailedViewTextBox small">
+					&nbsp;% 
+				{else} 
+					{$tax.percentage}&nbsp;% 
+				{/if}
+			</td>
+			<td width=10% class="cellText small"> 
+				{if $tax.deleted eq 0}
+						<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&sh_disable=true&sh_taxname={$tax.taxname}"><img src="{$IMAGE_PATH}enabled.gif" border="0" align="absmiddle" alt="{$MOD.LBL_ENABLE}" title="{$MOD.LBL_ENABLE}"></a>
+					{else}
+						<a href="index.php?module=Settings&action=TaxConfig&parenttab=Settings&sh_enable=true&sh_taxname={$tax.taxname}"><img src="{$IMAGE_PATH}disabled.gif" border="0" align="absmiddle" alt="{$MOD.LBL_DISABLE}" title="{$MOD.LBL_DISABLE}"></a>
+					{/if}
+			</td>
+		   </tr>
+		   {/foreach}
+		   {if $SH_EDIT_MODE eq 'true'}
+			<input type="hidden" id="sh_tax_count" value="{$count}">
+		   {/if}
+		{/if}
+		</table>
+		<!-- Table to display the List of S&H Tax Values - Ends -->
+	        </form>
+	</td>
+	<!-- Shipping Tax Ends Here -->
+   </tr>
+</table>
+
+<table border=0 cellspacing=0 cellpadding=5 width=100% >
+		   <tr>
+			<td class="small" nowrap align=right><a href="#top">{$MOD.LBL_SCROLL}</a></td>
+		   </tr>
+</table>
+
+
+			
+			
+			</td>
+			</tr>
+			</table>
+		</td>
+	</tr>
+	</table>
+	</div>
+
+</td>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
+</tbody>
+</table>
+<script>
+	var tax_labelarr = {ldelim}SAVE_BUTTON:'{$APP.LBL_SAVE_BUTTON_LABEL}',
+                                CANCEL_BUTTON:'{$APP.LBL_CANCEL_BUTTON_LABEL}',
+                                TAX_NAME:'{$APP.LBL_TAX_NAME}',
+                                TAX_VALUE:'{$APP.LBL_TAX_VALUE}'{rdelim};
+</script>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/ShowAuditTrail.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/ShowAuditTrail.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/ShowAuditTrail.tpl Mon Apr 16 12:27:44 2007
@@ -14,7 +14,7 @@
 <body class="small" marginwidth=0 marginheight=0 leftmargin=0 topmargin=0 bottommargin=0 rigthmargin=0>
 
 <form action="index.php" method="post" id="form">
-<input type='hidden' name='module' value='Users'>
+<input type='hidden' name='module' value='Settings'>
 <input type='hidden' id='userid' name='userid' value='{$USERID}'>
 
 <table  width="100%" border="0" cellspacing="0" cellpadding="0" class="mailClient mailClientBg">
@@ -50,7 +50,7 @@
                 'index.php',
                 {queue: {position: 'end', scope: 'command'},
                         method: 'post',
-                        postBody: 'module=Users&action=UsersAjax&file=ShowAuditTrail&ajax=true&'+url+'&userid='+userid,
+                        postBody: 'module=Settings&action=SettingsAjax&file=ShowAuditTrail&ajax=true&'+url+'&userid='+userid,
                         onComplete: function(response) {
                                 $("AuditTrailContents").innerHTML= response.responseText;
                         }

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/SysInformation.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/SysInformation.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/SysInformation.tpl Mon Apr 16 12:27:44 2007
@@ -21,7 +21,7 @@
 				<!-- DISPLAY -->
 				<table border=0 cellspacing=0 cellpadding=5 width=100% class="settingsSelUITopLine">
 				<tr>
-					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}system.gif" alt="Users" width="48" height="48" border=0 title="Users"></td>
+					<td width=50 rowspan=2 valign=top><img src="{$IMAGE_PATH}system.gif" alt="{$MOD.LBL_USERS}" width="48" height="48" border=0 title="{$MOD.LBL_USERS}"></td>
 					<td class=heading2 valign=bottom><b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS}</a> > {$MOD.LBL_SYSTEM_INFO} </b></td>
 				</tr>
 				<tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/UserDetailView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/UserDetailView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/UserDetailView.tpl Mon Apr 16 12:27:44 2007
@@ -1,359 +1,360 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/ColorPicker2.js"></script>
-<script language="javascript" type="text/javascript" src="include/js/general.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
-<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-<span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
-   <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
-</span>
-
-<br>
-<!-- Shadow table -->
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tr>
-    <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-    <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-    <br>
-    <div align=center>
-		{if $CATEGORY eq 'Settings'}
-			{include file='SetMenu.tpl'}
-		{/if}
-				<table width="100%"  border="0" cellspacing="0" cellpadding="0">
-				<tr>
-					<td class="padTab" align="left">
-						<form name="DetailView" method="POST" action="index.php" ENCTYPE="multipart/form-data" id="form" style="margin:0px">
-							<input type="hidden" name="module" value="Users" style="margin:0px">
-							<input type="hidden" name="record" id="userid" value="{$ID}" style="margin:0px">
-							<input type="hidden" name="isDuplicate" value=false style="margin:0px">
-							<input type="hidden" name="action" style="margin:0px">
-							<input type="hidden" name="changepassword" style="margin:0px">
-							{if $CATEGORY neq 'Settings'}
-								<input type="hidden" name="modechk" value="prefview" style="margin:0px">
-							{/if}
-							<input type="hidden" name="old_password" style="margin:0px">
-							<input type="hidden" name="new_password" style="margin:0px">
-							<input type="hidden" name="return_module" value="Users" style="margin:0px">
-							<input type="hidden" name="return_action" value="ListView"  style="margin:0px">
-							<input type="hidden" name="return_id" style="margin:0px">
-							<input type="hidden" name="forumDisplay" style="margin:0px">
-							{if $CATEGORY eq 'Settings'}
-							<input type="hidden" name="parenttab" value="{$PARENTTAB}" style="margin:0px">
-							{/if}	
-							<table width="100%" border="0" cellpadding="0" cellspacing="0" >
-							<tr>
-								<td colspan=2>
-									<!-- Heading and Icons -->
-									<table width="100%" cellpadding="5" cellspacing="0" border="0" class="settingsSelUITopLine">
-									<tr>
-										<td width=50 rowspan="2"><img src="{$IMAGE_PATH}ico-users.gif" align="absmiddle"></td>	
-										<td>
-											{if $CATEGORY eq 'Settings'}
-											<span class="heading2">
-											<b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS} </a> &gt; <a href="index.php?module=Administration&action=index&parenttab=Settings"> {$MOD.LBL_USERS} </a>&gt;"{$USERNAME}" </b></span>
-											{else}
-											<span class="heading2">	
-											<b>{$APP.LBL_MY_PREFERENCES}</b>
-											</span>
-											{/if}
-											<span id="vtbusy_info" style="display:none;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span>					
-										</td>
-										
-									</tr>
-									<tr>
-										<td>{$UMOD.LBL_USERDETAIL_INFO} "{$USERNAME}"</td>
-									</tr>
-									</table>
-								</td>
-							</tr>
-							<tr><td colspan="2">&nbsp;</td></tr>
-							<tr>
-								<td colspan="2" nowrap align="right">
-									{if $IS_ADMIN eq 'true'}
-									<input type="button" onclick="showAuditTrail();" value="{$MOD.LBL_VIEW_AUDIT_TRAIL}" class="crmButton small save"></input>
-									{/if}
-									{if $CATEGORY eq 'Settings'}
-														{$DUPLICATE_BUTTON}
-												{/if}
-									{$EDIT_BUTTON}
-									{if $CATEGORY eq 'Settings' && $ID neq 1 && $ID neq 2 & $ID neq $CURRENT_USERID}
-									<input type="button" onclick="deleteUser({$ID});" class="crmButton small cancel" value="{$UMOD.LBL_DELETE}"></input>
-									{/if}
-								</td>
-							</tr>
-							<tr>
-								<td colspan="2" align=left>
-								<!-- User detail blocks -->
-								<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
-								<tr>
-								<td align="left" valign="top">
-									{foreach key=header name=blockforeach item=detail from=$BLOCKS}
-									<br>
-									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
-									<tr>
-										{strip}
-										 <td class="big">	
-										<strong>{$smarty.foreach.blockforeach.iteration}. {$header}</strong>
-										 </td>
-										 <td class="small" align="right">&nbsp;</td>	
-										{/strip}
-									</tr>
-									</table>
-									
-									<table border="0" cellpadding="5" cellspacing="0" width="100%">
-									{foreach item=detail from=$detail}
-									<tr >
-										{foreach key=label item=data from=$detail}
-										   {assign var=keyid value=$data.ui}
-										   {assign var=keyval value=$data.value}
-										   {assign var=keytblname value=$data.tablename}
-										   {assign var=keyfldname value=$data.fldname}
-										   {assign var=keyoptions value=$data.options}
-										   {assign var=keysecid value=$data.secid}
-										   {assign var=keyseclink value=$data.link}
-										   {assign var=keycursymb value=$data.cursymb}
-										   {assign var=keysalut value=$data.salut}
-										   {assign var=keycntimage value=$data.cntimage}
-										   {assign var=keyadmin value=$data.isadmin}
-										   
-										   {if $label ne ''}
-										   <td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$label}</td>
-											{include file="DetailViewUI.tpl"}
-										   {else}
-										   <td class="dvtCellLabel" align=right>&nbsp;</td>
-										   <td class="dvtCellInfo" align=left >&nbsp;</td>
-										   {/if}	
-										{/foreach}
-									</tr>
-									{/foreach}
-									</table>
-									{/foreach}
-									
-									{include file="UserDetailOrg.tpl"}
-									
-									<br>
-									<!-- Home page components -->
-									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
-									<tr>
-										 <td class="big">	
-										<strong>6. {$UMOD.LBL_HOME_PAGE_COMP}</strong>
-										 </td>
-										 <td class="small" align="right"><img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onClick="ShowHidefn('home_comp');"></td>	
-									</tr>
-									</table>
-									
-									<div style="float: none; display: none;" id="home_comp">	
-									<table border="0" cellpadding="5" cellspacing="0" width="100%">
-									{foreach item=homeitems key=values from=$HOMEORDER}
-										<tr><td class="dvtCellLabel" align="right" width="30%">{$UMOD.$values}</td>
-											{if $homeitems neq ''}
-												<td class="dvtCellInfo" align="center" width="5%">
-												<img src="{$IMAGE_PATH}prvPrfSelectedTick.gif" alt="{$UMOD.LBL_SHOWN}" height="12" width="12"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_SHOWN}</td> 		
-												{else}	
-												<td class="dvtCellInfo" align="center" width="5%">
-												<img src="{$IMAGE_PATH}no.gif" alt="{$UMOD.LBL_HIDDEN}" height="12" width="12"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_HIDDEN}</td> 		
-											{/if}	
-										</tr>			
-									{/foreach}
-									</table>	
-									</div>
-								
-									<br>
-									<!-- My Groups -->
-									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
-									<tr>
-										<td class="big">	
-										<strong>7. {$UMOD.LBL_MY_GROUPS}</strong>
-										 </td>
-										 <td class="small" align="right">
-										{if $GROUP_COUNT > 0}
-										<img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onClick="fetchGroups_js({$ID});">
-										{else}
-											&nbsp;
-										{/if}
-										</td>	
-									</tr>
-									</table>
-									
-									<table border="0" cellpadding="5" cellspacing="0" width="100%">
-									<tr><td align="left"><div id="user_group_cont" style="display:none;"></div></td></tr>	
-									</table>	
-									<br>
-									<!-- Login History -->
-									{if $IS_ADMIN eq 'true'}
-									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
-										<tr>
-										 <td class="big">	
-										<strong>8. {$UMOD.LBL_LOGIN_HISTORY}</strong>
-										 </td>
-										 <td class="small" align="right"><img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onClick="fetchlogin_js({$ID});"></td>	
-										</tr>
-									</table>
-
-									<table border="0" cellpadding="5" cellspacing="0" width="100%">
-									<tr><td align="left"><div id="login_history_cont" style="display:none;"></div></td></tr>	
-									</table>	
-									<br>	
-									{/if}	
-								</td>
-								</tr>
-								</table>
-								<!-- User detail blocks ends -->
-								
-								</td>
-							</tr>
-							<tr>
-								<td colspan=2 class="small"><div align="right"><a href="#top">{$MOD.LBL_SCROLL}</a></div></td>
-							</tr>
-							</table>
-							
-						</form>
-			
-					</td>
-				</tr>
-				</table>
-
-		
-	</div>
-	</td>
-	
-</tr>
-</table>
-			
-			</td>
-			</tr>
-			</table>
-			
-			</td>
-			<td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>			
-			</tr>
-			</table>
-			
-
-
-
-<br>
-{$JAVASCRIPT}
-<div id="tempdiv" style="display:block;position:absolute;left:350px;top:200px;"></div>
-<!-- added for validation -->
-<script language="javascript">
-  var fieldname = new Array({$VALIDATION_DATA_FIELDNAME});
-  var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL});
-  var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE});
-function ShowHidefn(divid)
-{ldelim}
-	if($(divid).style.display != 'none')
-		Effect.Fade(divid);
-	else
-		Effect.Appear(divid);
-{rdelim}
-{literal}
-function fetchlogin_js(id)
-{
-	if($('login_history_cont').style.display != 'none')
-		Effect.Fade('login_history_cont');
-	else
-		fetchLoginHistory(id);
-
-}
-function fetchLoginHistory(id)
-{
-        $("status").style.display="inline";
-        new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: 'module=Users&action=UsersAjax&file=ShowHistory&ajax=true&record='+id,
-                        onComplete: function(response) {
-                                $("status").style.display="none";
-                                $("login_history_cont").innerHTML= response.responseText;
-				Effect.Appear('login_history_cont');
-                        }
-                }
-        );
-
-}
-function fetchGroups_js(id)
-{
-	if($('user_group_cont').style.display != 'none')
-		Effect.Fade('user_group_cont');
-	else
-		fetchUserGroups(id);
-}
-function fetchUserGroups(id)
-{
-        $("status").style.display="inline";
-        new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: 'module=Users&action=UsersAjax&file=UserGroups&ajax=true&record='+id,
-                        onComplete: function(response) {
-                                $("status").style.display="none";
-                                $("user_group_cont").innerHTML= response.responseText;
-				Effect.Appear('user_group_cont');
-                        }
-                }
-        );
-
-}
-
-function showAuditTrail()
-{
-	var userid =  document.getElementById('userid').value;
-	window.open("index.php?module=Users&action=UsersAjax&file=ShowAuditTrail&userid="+userid,"","width=650,height=800,resizable=0,scrollbars=1,left=100");
-}
-
-function deleteUser(userid)
-{
-        $("status").style.display="inline";
-        new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: 'action=UsersAjax&file=UserDeleteStep1&return_action=ListView&return_module=Users&module=Users&parenttab=Settings&record='+userid,
-                        onComplete: function(response) {
-                                $("status").style.display="none";
-                                $("tempdiv").innerHTML= response.responseText;
-                        }
-                }
-        );
-}
-function transferUser(del_userid)
-{
-        $("status").style.display="inline";
-        $("DeleteLay").style.display="none";
-        var trans_userid=$('transfer_user_id').options[$('transfer_user_id').options.selectedIndex].value;
-	window.document.location.href = 'index.php?module=Users&action=DeleteUser&ajax_delete=false&delete_user_id='+del_userid+'&transfer_user_id='+trans_userid;
-}
-{/literal}
-</script>
-<script>
-function getListViewEntries_js(module,url)
-{ldelim}
-	$("status").style.display="inline";
-        new Ajax.Request(
-        	'index.php',
-                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-                	method: 'post',
-                        postBody:"module="+module+"&action="+module+"Ajax&file=ShowHistory&record={$ID}&ajax=true&"+url,
-			onComplete: function(response) {ldelim}
-                        	$("status").style.display="none";
-                                $("login_history_cont").innerHTML= response.responseText;
-                  	{rdelim}
-                {rdelim}
-        );
-{rdelim}
-</script>
-
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/ColorPicker2.js"></script>
+<script language="javascript" type="text/javascript" src="include/js/general.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
+<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+<span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
+   <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
+</span>
+
+<br>
+<!-- Shadow table -->
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tr>
+    <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+    <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+    <br>
+    <div align=center>
+		{if $CATEGORY eq 'Settings'}
+			{include file='SetMenu.tpl'}
+		{/if}
+				<table width="100%"  border="0" cellspacing="0" cellpadding="0">
+				<tr>
+					<td class="padTab" align="left">
+						<form name="DetailView" method="POST" action="index.php" ENCTYPE="multipart/form-data" id="form" style="margin:0px">
+							<input type="hidden" name="module" value="Users" style="margin:0px">
+							<input type="hidden" name="record" id="userid" value="{$ID}" style="margin:0px">
+							<input type="hidden" name="isDuplicate" value=false style="margin:0px">
+							<input type="hidden" name="action" style="margin:0px">
+							<input type="hidden" name="changepassword" style="margin:0px">
+							{if $CATEGORY neq 'Settings'}
+								<input type="hidden" name="modechk" value="prefview" style="margin:0px">
+							{/if}
+							<input type="hidden" name="old_password" style="margin:0px">
+							<input type="hidden" name="new_password" style="margin:0px">
+							<input type="hidden" name="return_module" value="Users" style="margin:0px">
+							<input type="hidden" name="return_action" value="ListView"  style="margin:0px">
+							<input type="hidden" name="return_id" style="margin:0px">
+							<input type="hidden" name="forumDisplay" style="margin:0px">
+							{if $CATEGORY eq 'Settings'}
+							<input type="hidden" name="parenttab" value="{$PARENTTAB}" style="margin:0px">
+							{/if}	
+							<table width="100%" border="0" cellpadding="0" cellspacing="0" >
+							<tr>
+								<td colspan=2>
+									<!-- Heading and Icons -->
+									<table width="100%" cellpadding="5" cellspacing="0" border="0" class="settingsSelUITopLine">
+									<tr>
+										<td width=50 rowspan="2"><img src="{$IMAGE_PATH}ico-users.gif" align="absmiddle"></td>	
+										<td>
+											{if $CATEGORY eq 'Settings'}
+											<span class="heading2">
+											<b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS} </a> &gt; <a href="index.php?module=Administration&action=index&parenttab=Settings"> {$MOD.LBL_USERS} </a>&gt;"{$USERNAME}" </b></span>
+											{else}
+											<span class="heading2">	
+											<b>{$APP.LBL_MY_PREFERENCES}</b>
+											</span>
+											{/if}
+											<span id="vtbusy_info" style="display:none;" valign="bottom"><img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span>					
+										</td>
+										
+									</tr>
+									<tr>
+										<td>{$UMOD.LBL_USERDETAIL_INFO} "{$USERNAME}"</td>
+									</tr>
+									</table>
+								</td>
+							</tr>
+							<tr><td colspan="2">&nbsp;</td></tr>
+							<tr>
+								<td colspan="2" nowrap align="right">
+									{if $IS_ADMIN eq 'true'}
+									<input type="button" onclick="showAuditTrail();" value="{$MOD.LBL_VIEW_AUDIT_TRAIL}" class="crmButton small save"></input>
+									{/if}
+									{if $CATEGORY eq 'Settings'}
+														{$DUPLICATE_BUTTON}
+												{/if}
+									{$EDIT_BUTTON}
+									{if $CATEGORY eq 'Settings' && $ID neq 1 && $ID neq 2 & $ID neq $CURRENT_USERID}
+									<input type="button" onclick="deleteUser({$ID});" class="crmButton small cancel" value="{$UMOD.LBL_DELETE}"></input>
+									{/if}
+								</td>
+							</tr>
+							<tr>
+								<td colspan="2" align=left>
+								<!-- User detail blocks -->
+								<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
+								<tr>
+								<td align="left" valign="top">
+									{foreach key=header name=blockforeach item=detail from=$BLOCKS}
+									<br>
+									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
+									<tr>
+										{strip}
+										 <td class="big">	
+										<strong>{$smarty.foreach.blockforeach.iteration}. {$header}</strong>
+										 </td>
+										 <td class="small" align="right">&nbsp;</td>	
+										{/strip}
+									</tr>
+									</table>
+									
+									<table border="0" cellpadding="5" cellspacing="0" width="100%">
+									{foreach item=detail from=$detail}
+									<tr >
+										{foreach key=label item=data from=$detail}
+										   {assign var=keyid value=$data.ui}
+										   {assign var=keyval value=$data.value}
+										   {assign var=keytblname value=$data.tablename}
+										   {assign var=keyfldname value=$data.fldname}
+										   {assign var=keyoptions value=$data.options}
+										   {assign var=keysecid value=$data.secid}
+										   {assign var=keyseclink value=$data.link}
+										   {assign var=keycursymb value=$data.cursymb}
+										   {assign var=keysalut value=$data.salut}
+										   {assign var=keycntimage value=$data.cntimage}
+										   {assign var=keyadmin value=$data.isadmin}
+										   
+										   {if $label ne ''}
+										   <td class="dvtCellLabel" align=right width=25%><input type="hidden" id="hdtxt_IsAdmin" value={$keyadmin}></input>{$label}</td>
+											{include file="DetailViewUI.tpl"}
+										   {else}
+										   <td class="dvtCellLabel" align=right>&nbsp;</td>
+										   <td class="dvtCellInfo" align=left >&nbsp;</td>
+										   {/if}	
+										{/foreach}
+									</tr>
+									{/foreach}
+									</table>
+									{/foreach}
+									
+									{include file="UserDetailOrg.tpl"}
+									
+									<br>
+									<!-- Home page components -->
+									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
+									<tr>
+										 <td class="big">	
+										<strong>6. {$UMOD.LBL_HOME_PAGE_COMP}</strong>
+										 </td>
+										 <td class="small" align="right"><img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onClick="ShowHidefn('home_comp');"></td>	
+									</tr>
+									</table>
+									
+									<div style="float: none; display: none;" id="home_comp">	
+									<table border="0" cellpadding="5" cellspacing="0" width="100%">
+									{foreach item=homeitems key=values from=$HOMEORDER}
+										<tr><td class="dvtCellLabel" align="right" width="30%">{$UMOD.$values}</td>
+											{if $homeitems neq ''}
+												<td class="dvtCellInfo" align="center" width="5%">
+												<img src="{$IMAGE_PATH}prvPrfSelectedTick.gif" alt="{$UMOD.LBL_SHOWN}" title="{$UMOD.LBL_SHOWN}" height="12" width="12"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_SHOWN}</td> 		
+												{else}	
+												<td class="dvtCellInfo" align="center" width="5%">
+												<img src="{$IMAGE_PATH}no.gif" alt="{$UMOD.LBL_HIDDEN}" title="{$UMOD.LBL_HIDDEN}" height="12" width="12"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_HIDDEN}</td> 		
+											{/if}	
+										</tr>			
+									{/foreach}
+									</table>	
+									</div>
+								
+									<br>
+									<!-- My Groups -->
+									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
+									<tr>
+										<td class="big">	
+										<strong>7. {$UMOD.LBL_MY_GROUPS}</strong>
+										 </td>
+										 <td class="small" align="right">
+										{if $GROUP_COUNT > 0}
+										<img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onClick="fetchGroups_js({$ID});">
+										{else}
+											&nbsp;
+										{/if}
+										</td>	
+									</tr>
+									</table>
+									
+									<table border="0" cellpadding="5" cellspacing="0" width="100%">
+									<tr><td align="left"><div id="user_group_cont" style="display:none;"></div></td></tr>	
+									</table>	
+									<br>
+									<!-- Login History -->
+									{if $IS_ADMIN eq 'true'}
+									<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
+										<tr>
+										 <td class="big">	
+										<strong>8. {$UMOD.LBL_LOGIN_HISTORY}</strong>
+										 </td>
+										 <td class="small" align="right"><img src="{$IMAGE_PATH}showDown.gif" alt="{$APP.LBL_EXPAND_COLLAPSE}" title="{$APP.LBL_EXPAND_COLLAPSE}" onClick="fetchlogin_js({$ID});"></td>	
+										</tr>
+									</table>
+
+									<table border="0" cellpadding="5" cellspacing="0" width="100%">
+									<tr><td align="left"><div id="login_history_cont" style="display:none;"></div></td></tr>	
+									</table>	
+									<br>	
+									{/if}	
+								</td>
+								</tr>
+								</table>
+								<!-- User detail blocks ends -->
+								
+								</td>
+							</tr>
+							<tr>
+								<td colspan=2 class="small"><div align="right"><a href="#top">{$MOD.LBL_SCROLL}</a></div></td>
+							</tr>
+							</table>
+							
+						</form>
+			
+					</td>
+				</tr>
+				</table>
+
+		
+	</div>
+	</td>
+	
+</tr>
+</table>
+			
+			</td>
+			</tr>
+			</table>
+			
+			</td>
+			<td valign="top"><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>			
+			</tr>
+			</table>
+			
+
+
+
+<br>
+{$JAVASCRIPT}
+<div id="tempdiv" style="display:block;position:absolute;left:350px;top:200px;"></div>
+<!-- added for validation -->
+<script language="javascript">
+  var gVTModule = '{$smarty.request.module}';
+  var fieldname = new Array({$VALIDATION_DATA_FIELDNAME});
+  var fieldlabel = new Array({$VALIDATION_DATA_FIELDLABEL});
+  var fielddatatype = new Array({$VALIDATION_DATA_FIELDDATATYPE});
+function ShowHidefn(divid)
+{ldelim}
+	if($(divid).style.display != 'none')
+		Effect.Fade(divid);
+	else
+		Effect.Appear(divid);
+{rdelim}
+{literal}
+function fetchlogin_js(id)
+{
+	if($('login_history_cont').style.display != 'none')
+		Effect.Fade('login_history_cont');
+	else
+		fetchLoginHistory(id);
+
+}
+function fetchLoginHistory(id)
+{
+        $("status").style.display="inline";
+        new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: 'module=Users&action=UsersAjax&file=ShowHistory&ajax=true&record='+id,
+                        onComplete: function(response) {
+                                $("status").style.display="none";
+                                $("login_history_cont").innerHTML= response.responseText;
+				Effect.Appear('login_history_cont');
+                        }
+                }
+        );
+
+}
+function fetchGroups_js(id)
+{
+	if($('user_group_cont').style.display != 'none')
+		Effect.Fade('user_group_cont');
+	else
+		fetchUserGroups(id);
+}
+function fetchUserGroups(id)
+{
+        $("status").style.display="inline";
+        new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: 'module=Users&action=UsersAjax&file=UserGroups&ajax=true&record='+id,
+                        onComplete: function(response) {
+                                $("status").style.display="none";
+                                $("user_group_cont").innerHTML= response.responseText;
+				Effect.Appear('user_group_cont');
+                        }
+                }
+        );
+
+}
+
+function showAuditTrail()
+{
+	var userid =  document.getElementById('userid').value;
+	window.open("index.php?module=Settings&action=SettingsAjax&file=ShowAuditTrail&userid="+userid,"","width=650,height=800,resizable=0,scrollbars=1,left=100");
+}
+
+function deleteUser(userid)
+{
+        $("status").style.display="inline";
+        new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: 'action=UsersAjax&file=UserDeleteStep1&return_action=ListView&return_module=Users&module=Users&parenttab=Settings&record='+userid,
+                        onComplete: function(response) {
+                                $("status").style.display="none";
+                                $("tempdiv").innerHTML= response.responseText;
+                        }
+                }
+        );
+}
+function transferUser(del_userid)
+{
+        $("status").style.display="inline";
+        $("DeleteLay").style.display="none";
+        var trans_userid=$('transfer_user_id').options[$('transfer_user_id').options.selectedIndex].value;
+	window.document.location.href = 'index.php?module=Users&action=DeleteUser&ajax_delete=false&delete_user_id='+del_userid+'&transfer_user_id='+trans_userid;
+}
+{/literal}
+</script>
+<script>
+function getListViewEntries_js(module,url)
+{ldelim}
+	$("status").style.display="inline";
+        new Ajax.Request(
+        	'index.php',
+                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                	method: 'post',
+                        postBody:"module="+module+"&action="+module+"Ajax&file=ShowHistory&record={$ID}&ajax=true&"+url,
+			onComplete: function(response) {ldelim}
+                        	$("status").style.display="none";
+                                $("login_history_cont").innerHTML= response.responseText;
+                  	{rdelim}
+                {rdelim}
+        );
+{rdelim}
+</script>
+

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/UserEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/UserEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/UserEditView.tpl Mon Apr 16 12:27:44 2007
@@ -1,206 +1,217 @@
-{*<!--
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
--->*}
-<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
-<script language="JavaScript" type="text/javascript" src="include/js/ColorPicker2.js"></script>
-<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
-
-<script language="JavaScript" type="text/javascript">
-
- 	var cp2 = new ColorPicker('window');
-	
-function pickColor(color)
-{ldelim}
-	ColorPicker_targetInput.value = color;
-        ColorPicker_targetInput.style.backgroundColor = color;
-{rdelim}	
-
-function openPopup(){ldelim}
-		window.open("index.php?module=Users&action=UsersAjax&file=RolePopup&parenttab=Settings","roles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable =no");
-	{rdelim}	
-</script>	
-
-<script language="javascript">
-function check_duplicate()
-{ldelim}
-	var user_name = window.document.EditView.user_name.value;
-	new Ajax.Request(
-                'index.php',
-                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
-                        method: 'post',
-                        postBody: 'module=Users&action=UsersAjax&file=Save&ajax=true&dup_check=true&userName='+user_name,
-                        onComplete: function(response) {ldelim}
-				if(response.responseText == 'SUCCESS')
-			                document.EditView.submit();
-       				else
-			                alert(response.responseText);
-                        {rdelim}
-                {rdelim}
-        );
-
-{rdelim}
-
-</script>
-
-
-<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
-<tbody><tr>
-        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
-        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
-        <br>
-
-	<div align=center>
-	{if $PARENTTAB eq 'Settings'}
-		{include file='SetMenu.tpl'}
-	{/if}
-
-		<form name="EditView" method="POST" action="index.php" ENCTYPE="multipart/form-data">
-		<input type="hidden" name="module" value="Users">
-		<input type="hidden" name="record" value="{$ID}">
-		<input type="hidden" name="mode" value="{$MODE}">
-		<input type='hidden' name='parenttab' value='{$PARENTTAB}'>
-		<input type="hidden" name="activity_mode" value="{$ACTIVITYMODE}">
-		<input type="hidden" name="action">
-		<input type="hidden" name="return_module" value="{$RETURN_MODULE}">
-		<input type="hidden" name="return_id" value="{$RETURN_ID}">
-		<input type="hidden" name="return_action" value="{$RETURN_ACTION}">			
-		<input type="hidden" name="tz" value="Europe/Berlin">			
-		<input type="hidden" name="holidays" value="de,en_uk,fr,it,us,">			
-		<input type="hidden" name="workdays" value="0,1,2,3,4,5,6,">			
-		<input type="hidden" name="namedays" value="">			
-		<input type="hidden" name="weekstart" value="1">
-
-	<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="settingsSelUITopLine">
-	<tr><td align="left">
-		<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
-		<tr>
-			<td rowspan="2"><img src="{$IMAGE_PATH}ico-users.gif" align="absmiddle"></td>
-			<td>	
-				<span class="lvtHeaderText">
-				{if $PARENTTAB neq ''}	
-				<b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS} </a> &gt; <a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a> &gt; 
-					{if $MODE eq 'edit'}
-						{$UMOD.LBL_EDITING} "{$USERNAME}" 
-					{else}
-						{$UMOD.LBL_CREATE_NEW_USER}
-					{/if}
-					</b></span>
-				{else}
-                                <span class="lvtHeaderText">
-                                <b>{$APP.LBL_MY_PREFERENCES}</b>
-                                </span>
-                                {/if}
-			</td>
-			<td rowspan="2" nowrap>&nbsp;
-			</td>
-	 	</tr>
-		<tr>
-			{if $MODE eq 'edit'}
-				<td><b class="small">{$UMOD.LBL_EDIT_VIEW} "{$USERNAME}"</b>
-			{else}
-				<td><b class="small">{$UMOD.LBL_CREATE_NEW_USER}</b>
-			{/if}
-			</td>
-                </tr>
-		</table>
-	</td>
-	</tr>
-	<tr><td>&nbsp;</td></tr>
-	<tr>
-		<td nowrap align="right">
-				<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accesskey="{$APP.LBL_SAVE_BUTTON_KEY}" class="small crmbutton save"  name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  "  onclick="this.form.action.value='Save'; return verify_data(EditView)" style="width: 70px;" type="button" />
-				<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="small crmbutton cancel" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " onclick="window.history.back()" style="width: 70px;" type="button" />
-						
-		</td>
-	</tr>
-	<tr><td class="padTab" align="left">
-				<table width="100%" border="0" cellpadding="0" cellspacing="0">
-
-		<tr><td colspan="2">
-			<table align="center" border="0" cellpadding="0" cellspacing="0" width="99%">
-			<tr>
-			    <td align="left" valign="top">
-			             <table border="0" cellpadding="0" cellspacing="0" width="100%">
-					<tr><td align="left">
-						{foreach key=header name=blockforeach item=data from=$BLOCKS}
-						<br>
-		                                <table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
-                		                <tr>
-                                		    {strip}
-		                                     <td class="big">
-                		                        <strong>{$smarty.foreach.blockforeach.iteration}. {$header}</strong>
-                                		     </td>
-		                                     <td class="small" align="right">&nbsp;</td>
-		                                  {/strip}
-                		              	</tr>
-                                		</table>
-		                                <table border="0" cellpadding="5" cellspacing="0" width="100%">
-						<!-- Handle the ui types display -->
-							{include file="DisplayFields.tpl"}
-						</table>
-					   	{/foreach}
-				
-				{include file="UserEditOrg.tpl"}
-				
-				<br>
-			    	<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
-			    	<tr>
-				     <td class="big">	
-					<strong>6. {$UMOD.LBL_HOME_PAGE_COMP}</strong>
-				     </td>
-				     <td class="small" align="right">&nbsp;</td>	
-			        </tr>
-			    	</table>
-			    	<table border="0" cellpadding="5" cellspacing="0" width="100%">
-				{foreach item=homeitems key=values from=$HOMEORDER}
-					<tr><td class="dvtCellLabel" align="right" width="30%">{$UMOD.$values}</td>
-					    {if $homeitems neq ''}
-					    	<td class="dvtCellInfo" align="center" width="5%">
-					   	<input name="{$values}" value="{$values}" checked type="radio"></td><td class="dvtCellInfo" align="left" width="20%">{$UMOD.LBL_SHOW}</td> 		
-					    	<td class="dvtCellInfo" align="center" width="5%">
-					   	<input name="{$values}" value="" type="radio"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_HIDE}</td> 		
-					    {else}	
-					    	<td class="dvtCellInfo" align="center" width="5%">
-					   	<input name="{$values}" value="{$values}" type="radio"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_SHOW}</td> 		
-					    	<td class="dvtCellInfo" align="center" width="5%">
-					   	<input name="{$values}" value="" checked type="radio"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_HIDE}</td> 		
-					    {/if}	
-					</tr>			
-				{/foreach}
-			    	</table>	
-				<br>
-				<tr><td colspan=4>&nbsp;</td></tr>
-							
-					        <tr>
-					       		<td colspan=4 align="right">
-							<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accesskey="{$APP.LBL_SAVE_BUTTON_KEY}" class="small crmbutton save"  name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  "  onclick="this.form.action.value='Save'; return verify_data(EditView)" style="width: 70px;" type="button" />
-							<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="small crmbutton cancel" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " onclick="window.history.back()" style="width: 70px;" type="button" />
-							</td>
-						</tr>
-					    </table>
-					 </td></tr>
-					</table>
-			  	   </td></tr>
-				   </table>
-				 <br>
-				  </td></tr>
-				<tr><td class="small"><div align="right"><a href="#top">{$MOD.LBL_SCROLL}</a></div></td></tr>
-				</table>
-			</td>
-			</tr>
-			</table>
-			</form>	
-</td>
-</tr>
-</table>
-</td></tr></table>
-<br>
-{$JAVASCRIPT}
+{*<!--
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+-->*}
+<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
+<script language="JavaScript" type="text/javascript" src="include/js/ColorPicker2.js"></script>
+<script language="JAVASCRIPT" type="text/javascript" src="include/js/smoothscroll.js"></script>
+
+<script language="JavaScript" type="text/javascript">
+
+ 	var cp2 = new ColorPicker('window');
+	
+function pickColor(color)
+{ldelim}
+	ColorPicker_targetInput.value = color;
+        ColorPicker_targetInput.style.backgroundColor = color;
+{rdelim}	
+
+function openPopup(){ldelim}
+		window.open("index.php?module=Users&action=UsersAjax&file=RolePopup&parenttab=Settings","roles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable =no");
+	{rdelim}	
+</script>	
+
+<script language="javascript">
+function check_duplicate()
+{ldelim}
+	var user_name = window.document.EditView.user_name.value;
+	var status = usernameValid(user_name);
+        if(status)
+	{ldelim}
+	new Ajax.Request(
+                'index.php',
+                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                        method: 'post',
+                        postBody: 'module=Users&action=UsersAjax&file=Save&ajax=true&dup_check=true&userName='+user_name,
+                        onComplete: function(response) {ldelim}
+				if(response.responseText == 'SUCCESS')
+			                document.EditView.submit();
+       				else
+			                alert(response.responseText);
+                        {rdelim}
+                {rdelim}
+        );
+	{rdelim}
+	else
+            alert(alert_arr.NO_SPECIAL+" in User Name ")
+{rdelim}
+
+</script>
+
+<br>
+<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
+<tbody><tr>
+        <td valign="top"><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+        <td class="showPanelBg" style="padding: 10px;" valign="top" width="100%">
+        <br>
+
+	<div align=center>
+	{if $PARENTTAB eq 'Settings'}
+		{include file='SetMenu.tpl'}
+	{/if}
+
+		<form name="EditView" method="POST" action="index.php" ENCTYPE="multipart/form-data">
+		<input type="hidden" name="module" value="Users">
+		<input type="hidden" name="record" value="{$ID}">
+		<input type="hidden" name="mode" value="{$MODE}">
+		<input type='hidden' name='parenttab' value='{$PARENTTAB}'>
+		<input type="hidden" name="activity_mode" value="{$ACTIVITYMODE}">
+		<input type="hidden" name="action">
+		<input type="hidden" name="return_module" value="{$RETURN_MODULE}">
+		<input type="hidden" name="return_id" value="{$RETURN_ID}">
+		<input type="hidden" name="return_action" value="{$RETURN_ACTION}">			
+		<input type="hidden" name="tz" value="Europe/Berlin">			
+		<input type="hidden" name="holidays" value="de,en_uk,fr,it,us,">			
+		<input type="hidden" name="workdays" value="0,1,2,3,4,5,6,">			
+		<input type="hidden" name="namedays" value="">			
+		<input type="hidden" name="weekstart" value="1">
+
+	<table width="100%"  border="0" cellspacing="0" cellpadding="0" class="settingsSelUITopLine">
+	<tr><td align="left">
+		<table class="settingsSelUITopLine" border="0" cellpadding="5" cellspacing="0" width="100%">
+		<tr>
+			<td rowspan="2"><img src="{$IMAGE_PATH}ico-users.gif" align="absmiddle"></td>
+			<td>	
+				<span class="lvtHeaderText">
+				{if $PARENTTAB neq ''}	
+				<b><a href="index.php?module=Settings&action=index&parenttab=Settings">{$MOD.LBL_SETTINGS} </a> &gt; <a href="index.php?module=Administration&action=index&parenttab=Settings">{$MOD.LBL_USERS}</a> &gt; 
+					{if $MODE eq 'edit'}
+						{$UMOD.LBL_EDITING} "{$USERNAME}" 
+					{else}
+						{if $DUPLICATE neq 'true'}
+						{$UMOD.LBL_CREATE_NEW_USER}
+						{else}
+						{$APP.LBL_DUPLICATING} "{$USERNAME}"
+						{/if}
+					{/if}
+					</b></span>
+				{else}
+                                <span class="lvtHeaderText">
+                                <b>{$APP.LBL_MY_PREFERENCES}</b>
+                                </span>
+                                {/if}
+			</td>
+			<td rowspan="2" nowrap>&nbsp;
+			</td>
+	 	</tr>
+		<tr>
+			{if $MODE eq 'edit'}
+				<td><b class="small">{$UMOD.LBL_EDIT_VIEW} "{$USERNAME}"</b>
+			{else}
+				{if $DUPLICATE neq 'true'}
+				<td><b class="small">{$UMOD.LBL_CREATE_NEW_USER}</b>
+				{/if}
+			{/if}
+			</td>
+                </tr>
+		</table>
+	</td>
+	</tr>
+	<tr><td>&nbsp;</td></tr>
+	<tr>
+		<td nowrap align="right">
+				<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accesskey="{$APP.LBL_SAVE_BUTTON_KEY}" class="small crmbutton save"  name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  "  onclick="this.form.action.value='Save'; return verify_data(EditView)" style="width: 70px;" type="button" />
+				<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="small crmbutton cancel" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " onclick="window.history.back()" style="width: 70px;" type="button" />
+						
+		</td>
+	</tr>
+	<tr><td class="padTab" align="left">
+				<table width="100%" border="0" cellpadding="0" cellspacing="0">
+
+		<tr><td colspan="2">
+			<table align="center" border="0" cellpadding="0" cellspacing="0" width="99%">
+			<tr>
+			    <td align="left" valign="top">
+			             <table border="0" cellpadding="0" cellspacing="0" width="100%">
+					<tr><td align="left">
+						{foreach key=header name=blockforeach item=data from=$BLOCKS}
+						<br>
+		                                <table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
+                		                <tr>
+                                		    {strip}
+		                                     <td class="big">
+                		                        <strong>{$smarty.foreach.blockforeach.iteration}. {$header}</strong>
+                                		     </td>
+		                                     <td class="small" align="right">&nbsp;</td>
+		                                  {/strip}
+                		              	</tr>
+                                		</table>
+		                                <table border="0" cellpadding="5" cellspacing="0" width="100%">
+						<!-- Handle the ui types display -->
+							{include file="DisplayFields.tpl"}
+						</table>
+					   	{/foreach}
+				
+				{include file="UserEditOrg.tpl"}
+				
+				<br>
+			    	<table class="tableHeading" border="0" cellpadding="5" cellspacing="0" width="100%">
+			    	<tr>
+				     <td class="big">	
+					<strong>6. {$UMOD.LBL_HOME_PAGE_COMP}</strong>
+				     </td>
+				     <td class="small" align="right">&nbsp;</td>	
+			        </tr>
+			    	</table>
+			    	<table border="0" cellpadding="5" cellspacing="0" width="100%">
+				{foreach item=homeitems key=values from=$HOMEORDER}
+					<tr><td class="dvtCellLabel" align="right" width="30%">{$UMOD.$values}</td>
+					    {if $homeitems neq ''}
+					    	<td class="dvtCellInfo" align="center" width="5%">
+					   	<input name="{$values}" value="{$values}" checked type="radio"></td><td class="dvtCellInfo" align="left" width="20%">{$UMOD.LBL_SHOW}</td> 		
+					    	<td class="dvtCellInfo" align="center" width="5%">
+					   	<input name="{$values}" value="" type="radio"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_HIDE}</td> 		
+					    {else}	
+					    	<td class="dvtCellInfo" align="center" width="5%">
+					   	<input name="{$values}" value="{$values}" type="radio"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_SHOW}</td> 		
+					    	<td class="dvtCellInfo" align="center" width="5%">
+					   	<input name="{$values}" value="" checked type="radio"></td><td class="dvtCellInfo" align="left">{$UMOD.LBL_HIDE}</td> 		
+					    {/if}	
+					</tr>			
+				{/foreach}
+			    	</table>	
+				<br>
+				<tr><td colspan=4>&nbsp;</td></tr>
+							
+					        <tr>
+					       		<td colspan=4 align="right">
+							<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accesskey="{$APP.LBL_SAVE_BUTTON_KEY}" class="small crmbutton save"  name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  "  onclick="this.form.action.value='Save'; return verify_data(EditView)" style="width: 70px;" type="button" />
+							<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accesskey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="small crmbutton cancel" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " onclick="window.history.back()" style="width: 70px;" type="button" />
+							</td>
+						</tr>
+					    </table>
+					 </td></tr>
+					</table>
+			  	   </td></tr>
+				   </table>
+				 <br>
+				  </td></tr>
+				<tr><td class="small"><div align="right"><a href="#top">{$MOD.LBL_SCROLL}</a></div></td></tr>
+				</table>
+			</td>
+			</tr>
+			</table>
+			</form>	
+</td>
+</tr>
+</table>
+</td></tr></table>
+<br>
+{$JAVASCRIPT}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/UserGroups.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/UserGroups.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/UserGroups.tpl Mon Apr 16 12:27:44 2007
@@ -19,7 +19,7 @@
 <tr>
 <td class="listTableRow small" valign="top" width="5%">{$smarty.foreach.groupiter.iteration}</td>
 {if $IS_ADMIN}
-<td class="listTableRow small" valign="top"><a href="index.php?module=Users&action=GroupDetailView&parenttab=Settings&groupId={$id}">{$groupname.1}</a></td>
+<td class="listTableRow small" valign="top"><a href="index.php?module=Settings&action=GroupDetailView&parenttab=Settings&groupId={$id}">{$groupname.1}</a></td>
 {else}
 <td class="listTableRow small" valign="top">{$groupname.1}</td>
 {/if}

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/UserProfileList.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/UserProfileList.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/UserProfileList.tpl Mon Apr 16 12:27:44 2007
@@ -69,7 +69,7 @@
 					<tr>
 						<td class="listTableRow small" valign=top>{$smarty.foreach.profilelist.iteration}</td>
 						<td class="listTableRow small" valign=top nowrap>
-							<a href="index.php?module=Users&action=profilePrivileges&return_action=ListProfiles&parenttab=Settings&mode=edit&profileid={$listvalues.profileid}"><img src="{$IMAGE_PATH}editfield.gif" alt="Edit" title="Edit" border="0" align="absmiddle"></a>
+							<a href="index.php?module=Settings&action=profilePrivileges&return_action=ListProfiles&parenttab=Settings&mode=edit&profileid={$listvalues.profileid}"><img src="{$IMAGE_PATH}editfield.gif" alt="{$APP.LBL_EDIT}" title="{$APP.LBL_EDIT}" border="0" align="absmiddle"></a>
 	                                                {if $listvalues.del_permission eq 'yes'}
         	                                                &nbsp;|&nbsp;
                 	                                <a href="#"><img src="{$IMAGE_PATH}delete.gif" border="0" height="15" width="15" onclick="DeleteProfile(this,'{$listvalues.profileid}')" align="absmiddle"></a>
@@ -77,7 +77,7 @@
                                                 	{/if}
 
 						</td>
-						<td class="listTableRow small" valign=top><a href="index.php?module=Users&action=profilePrivileges&mode=view&parenttab=Settings&profileid={$listvalues.profileid}"><b>{$listvalues.profilename}</b></a></td>
+						<td class="listTableRow small" valign=top><a href="index.php?module=Settings&action=profilePrivileges&mode=view&parenttab=Settings&profileid={$listvalues.profileid}"><b>{$listvalues.profilename}</b></a></td>
 						<td class="listTableRow small" valign=top>{$listvalues.description}</td>
 					  </tr>
 					{/foreach}		

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/Webmails.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/Webmails.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/Webmails.tpl Mon Apr 16 12:27:44 2007
@@ -12,178 +12,209 @@
 <!--  USER  SETTINGS PAGE STARTS HERE -->
                 {include file='Buttons_List1.tpl'} 
 <table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%">
-	<tr>
-		 <td class="showPanelBg" valign="top" width="95%"  style="padding-left:20px; ">&nbsp;
-		</td>
-		<td width="5%" class="showPanelBg">&nbsp;</td>
-	</tr>
-	<tr>
-		<td width="95%" style="padding-left:20px;" valign="top">
-			<!-- module Select Table -->
+   <tr>
+	<td valign=top align=right><img src="{$IMAGE_PATH}showPanelTopLeft.gif"></td>
+	<td class="showPanelBg" valign="top" width="95%"  style="padding-left:20px; ">
+	<br>
+	<!-- module Select Table -->
+		<table class="mailClient" width="100%"  border="0" cellspacing="0" cellpadding="0">
+		   <tr>
+			<td class="mailClientBg" width="7">&nbsp;</td>
+			<td class="mailClientBg">
+
+				<table width="100%"  border="0" cellspacing="0" cellpadding="0">
+                		   <tr>
+					<td colspan="3" style="padding:10px;vertical-align:middle;height:2px;">
+						<table width="100%" cellpadding="0" cellspacing="0" border="0">
+						   <tr>
+							<td width="10%">
+								<img src="{$IMAGE_PATH}check_mail.gif" align="absmiddle" />
+								&nbsp;<a href="javascript:;" class="webMnu" onclick="check_for_new_mail('{$MAILBOX}');" >{$MOD.LBL_CHK_MAIL}</a>
+							</td>
+							<td width="10%">
+								<img src="{$IMAGE_PATH}compose.gif" align="absmiddle" />
+								&nbsp;<a href="javascript:;" onclick="OpenCompose('','create');" class="webMnu">{$MOD.LBL_COMPOSE}</a>
+							</td>
+							<td width="20%" nowrap>
+								<img src="{$IMAGE_PATH}webmail_settings.gif" align="absmiddle" />
+								&nbsp;<a href="index.php?module=Users&action=AddMailAccount&record={$USERID}&return_module=Webmails&return_action=index" class="webMnu">{$MOD.LBL_SETTINGS}</a>
+							</td>
+							<td width="30%">
+								<img src="{$IMAGE_PATH}webmail_settings.gif" align="absmiddle" />
+								&nbsp;<a href="javascript:;" onclick="runEmailCommand('expunge','0');" class="webMnu">{$MOD.LBL_EXPUNGE_MAILBOX}</a>
+							</td>
+							<td>&nbsp;</td>
+						   </tr>
+						</table>
+					</td>
+				   </tr>
+				   <tr>
+					<td width="20%" class="big mailSubHeader"><b>{$MOD.LBL_EMAIL_FOLDERS}</b></td>
+					<td width="80%" class="big mailSubHeader"><span style="float:left">{$ACCOUNT} &gt; {$MAILBOX}</span> <span style="float:right">{$NAVIGATION}</span></td>
+				   </tr>
+				   <tr>
+					<td rowspan="6" valign="top" class="hdrNameBg">
+						<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<span style="cursor:pointer;"><b class="txtGreen">{$MOD.LBL_MY_MAILS}</b>&nbsp;&nbsp;<span id="folderOpts" style="position:absolute;display:none">{$MOD.ADD_FOLDER}</span></span>
+
+						<ul style="list-style-type:none;">
+
+							{foreach item=row from=$BOXLIST}
+								{foreach item=row_values from=$row}
+									{$row_values}
+								{/foreach}
+							{/foreach}
+						</ul><br />
+
+						<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<b class="txtGreen">{$MOD.LBL_SENT_MAILS}</b>
+						<ul style="list-style-type:none;">
+							<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a href="index.php?module=Emails&action=ListView&parenttab=My Home Page&folderid=1&parenttab=My Home Page" class="webMnu">{$MOD.LBL_ALLMAILS}</a>&nbsp;<b></b>
+							</li>
+							<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a href="index.php?module=Emails&action=ListView&folderid=2&parenttab=My Home Page" class="webMnu">{$MOD.LBL_TO_CONTACTS}</a>&nbsp;<b></b>
+							</li>
+							<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a href="index.php?module=Emails&action=ListView&folderid=3&parenttab=My Home Page" class="webMnu">{$MOD.LBL_TO_ACCOUNTS}</a>&nbsp;
+							</li>	
+							<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a href="index.php?module=Emails&action=ListView&folderid=4&parenttab=My Home Page" class="webMnu">{$MOD.LBL_TO_LEADS}</a>&nbsp;
+							</li>
+							<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a href="index.php?module=Emails&action=ListView&folderid=5&parenttab=My Home Page" class="webMnu">{$MOD.LBL_TO_USERS}</a>&nbsp;
+							</li>
+	<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}emailOutFolder.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a
+						href="index.php?module=Emails&action=ListView&folderid=7&parenttab=My
+						Home Page"
+						class="webMnu">{$MOD.LBL_TO_GROUPS}</a>&nbsp; </li>
+						</ul><br />
+						<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<b class="txtGreen">{$MOD.LBL_TRASH}</b>
+						<ul style="list-style-type:none;">
+							<li class="lvtColData" onmouseover="this.className='lvtColDataHover'" onmouseout="this.className='lvtColData'">
+								<img src="{$IMAGE_PATH}webmail_trash.gif" align="absmiddle" />&nbsp;&nbsp;
+								<a href="#" class="webMnu">{$MOD.LBL_JUNK_MAILS}</a>&nbsp;<b></b>
+							</li>
+						</ul>
+
+					</td>
+					<td class="hdrNameBg" style="height:30px;">
+
+			<!-- Table to display Delete, Move To and Search buttons and options - Starts -->
 			<table width="100%"  border="0" cellspacing="0" cellpadding="0">
-			  <tr>
-				<td width="7" height="6" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;"><img src="{$IMAGE_PATH}top_left.jpg" align="top"  /></td>
-				<td bgcolor="#EBEBEB" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;height:6px;"></td>
-				<td width="8" height="6" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;"><img src="{$IMAGE_PATH}top_right.jpg" width="8" height="6" align="top" /></td>
-			  </tr>
-			  <tr>
-				<td bgcolor="#EBEBEB" width="7"></td>
-				<td bgcolor="#ECECEC" style="padding-left:10px;height:20px;vertical-align:middle;"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
-                  <tr>
-                    <td colspan="3" style="padding:10px;vertical-align:middle;">
-							<table width="100%" cellpadding="0" cellspacing="0" border="0">
-									<tr>
-											<td width="10%">
-												<img src="{$IMAGE_PATH}check_mail.gif" align="absmiddle" />
-												&nbsp;<a href="javascript:;" class="webMnu" onclick="check_for_new_mail('{$MAILBOX}');" >{$MOD.LBL_CHK_MAIL}</a>
-											</td>
-											<td width="10%">
-												<img src="{$IMAGE_PATH}compose.gif" align="absmiddle" />
-												&nbsp;<a href="javascript:;" onclick="OpenCompose('','create');" class="webMnu">{$MOD.LBL_COMPOSE}</a>
-											</td>
-											<td width="10%">
-												<img src="{$IMAGE_PATH}webmail_settings.gif" align="absmiddle" />
-												&nbsp;<a href="index.php?module=Settings&action=AddMailAccount&record={$USERID}" class="webMnu">{$MOD.LBL_SETTINGS}</a>
-											</td>
-											<td width="12%">
-												<img src="{$IMAGE_PATH}webmail_settings.gif" align="absmiddle" />
-												&nbsp;<a href="javascript:;"  onclick="show_hidden();" class="webMnu">{$MOD.LBL_SHOW_HIDDEN}</a>
-											</td>
-											<td width="18%">
-												<img src="{$IMAGE_PATH}webmail_settings.gif" align="absmiddle" />
-												&nbsp;<a href="javascript:;" onclick="runEmailCommand('expunge','0');" class="webMnu">{$MOD.LBL_EXPUNGE_MAILBOX}</a>
-											</td>
-					<td><img src="{$IMAGE_PATH}webmail_header.gif" align="right"/></td>
-									</tr>
-							</table>
-					</td>
-                  </tr>
-                  <tr>
-                    <td width="22%" bgcolor="#949494" style="overflow:auto"><span class="subHdr"><b>{$MOD.LBL_EMAIL_FOLDERS}</b></span> </td>
-                    <td width="2%">&nbsp;</td>
-					 <td width="60%" class="subHdr"><span style="float:left"><strong>{$ACCOUNT} &gt; {$MAILBOX} </strong></span> <span style="float:right">{$NAVIGATION}</span></td>
-                  </tr>
-                  <tr>
-                    <td rowspan="6" valign="top" bgcolor="#FFFFFF" style="padding:10px; ">
-							<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<span onmouseover="show_addfolder();" onmouseout="show_addfolder();" style="cursor:pointer;"><b class="txtGreen">{$MOD.LBL_MY_MAILS}</b>&nbsp;&nbsp;<span id="folderOpts" style="position:absolute;display:none">Add Folder[X]</span></span>
-
-							<ul style="list-style-type:none;">
-
-                                                  {foreach item=row from=$BOXLIST}
-                                                        {foreach item=row_values from=$row}
-                                				{$row_values}
-                                                        {/foreach}
-                                                  {/foreach}
-							</ul><br />
-
-							<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<b class="txtGreen">{$MOD.LBL_SENT_MAILS}</b>
-							<ul style="list-style-type:none;">
-								<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
-										<a href="index.php?module=Emails&action=ListView" class="webMnu">{$MOD.LBL_TO_LEADS}</a>&nbsp;<b></b>
-								</li>
-								<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
-										<a href="index.php?module=Emails&action=ListView" class="webMnu">{$MOD.LBL_TO_ACCOUNTS}</a>&nbsp;<b></b>
-								</li>
-								<li><img src="{$IMAGE_PATH}webmail_uparrow.gif" align="absmiddle" />&nbsp;&nbsp;
-										<a href="index.php?module=Emails&action=ListView" class="webMnu">{$MOD.LBL_TO_CONTACTS}</a>&nbsp;
-								</li>
-							</ul><br />
-							<img src="{$IMAGE_PATH}webmail_root.gif" align="absmiddle" />&nbsp;<b class="txtGreen">{$MOD.LBL_TRASH}</b>
-							<ul style="list-style-type:none;">
-								<li><img src="{$IMAGE_PATH}webmail_trash.gif" align="absmiddle" />&nbsp;&nbsp;
-										<a href="#" class="webMnu">{$MOD.LBL_JUNK_MAILS}</a>&nbsp;<b></b>
-								</li>
-							</ul>
-
-					</td>
-                    <td>&nbsp;</td>
-                    <td class="delBg"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
-                      <tr>
-                        <td width="45%">
-			<input type="button" name="mass_del" value=" {$MOD.LBL_DELETE} "  class="crmbutton small delete" onclick="mass_delete();"/>
-			<input type="button" name="Button2" value=" {$MOD.LBL_MOVE_TO} "  class="crmbutton small edit" onclick="move_messages();"/> {$FOLDER_SELECT}
-                        </td>
-			{if $DEGRADED_SERVICE eq 'false'}
-                        <td width="75%" align="right">
-							<font color="#000000">{$APP.LBL_SEARCH}</font>&nbsp;<input type="text" name="srch" class="importBox" id="search_input"/>&nbsp;
-							<select name="optionSel" class="importBox" id="search_type"><option selected value="SUBJECT">in Subject</option><option value="BODY">in Body</option><option value="TO">in To:</option><option value="CC">in CC:</option><option value="BCC">in BCC:</option><option value="FROM">in From:</option></select>&nbsp;
-							<input type="button" name="find" value=" {$APP.LBL_FIND_BUTTON} " class="crmbutton small create" onclick="search_emails();" />
-			</td>
-			{/if}
-                      </tr>
-                    </table></td>
-                  </tr>
-                  <tr>
-                    <td>&nbsp;</td>
-                    <td style="padding:1px;" align="left">
-						<div id="rssScroll">
-						<table class="rssTable" cellspacing="0" cellpadding="0" border="0" width="100%" id="message_table">
-	                      <tr>
-    	                    <th><input type="checkbox" name="checkbox" value="checkbox"  onclick="select_all();"/></th>
-							{foreach item=element from=$LISTHEADER}
-								{$element}
-							{/foreach}
-                    	  </tr>
-						  {foreach item=row from=$LISTENTITY}
-						  	{foreach item=row_values from=$row}
-                	        				{$row_values}
-							{/foreach}
-						  {/foreach}
-                    </table>
-					</div>
+                	   <tr>
+                        	<td width="45%">
+					<input type="button" name="mass_del" value=" {$MOD.LBL_DELETE} "  class="crmbutton small delete" onclick="mass_delete();"/>
+					{$FOLDER_SELECT}
+                        	</td>
+				{if $DEGRADED_SERVICE eq 'false'}
+                        	<td width="50%" align="right" nowrap>
+					<font color="#000000">{$APP.LBL_SEARCH}</font>&nbsp;
+					<input type="text" name="srch" class="importBox" id="search_input"  value="{$SEARCH_VALUE}"/>&nbsp;
+					{$SEARCH_HTML}&nbsp;
 				</td>
-             </tr>
-			 <tr>
-			 	<td></td>
-				<td height="5"></td>
-			 </tr>
-			 <tr>
-			   <td>&nbsp;</td>
-			   </tr>
-			 <tr style="visibility:hidden" class="previewWindow">
-			   <td>&nbsp;</td>
-			   <td class="forwardBg">
+				<td width="5%">
+					<input type="button" name="find" value=" {$APP.LBL_FIND_BUTTON} " class="crmbutton small create" onclick="search_emails();" />
+				</td>
+				{/if}
+                	   </tr>
+                	</table>
+			<!-- Table to display Delete, Move To and Search buttons and options - Ends -->
+
+					</td>
+				   </tr>
+				   <tr>
+					<!-- td style="padding:1px;" align="left" -->
+					<td  align="left" valign="top" style="height:150px;">
+						<div id="rssScroll" style="height:220px;">
+
+				<!-- Table to display the mails list -	Starts -->
+				<form name="massdelete" method="post">
+				<table class="rssTable" cellspacing="0" cellpadding="0" border="0" width="100%" id="message_table">
+				   <tr>
+				<th><input type="checkbox" name="select_all" value="checkbox"  onclick="toggleSelect(this.checked,'selected_id');"/></th>
+					{foreach item=element from=$LISTHEADER}
+						{$element}
+					{/foreach}
+				   </tr>
+					{foreach item=row from=$LISTENTITY}
+						{foreach item=row_values from=$row}
+                	        			{$row_values}
+						{/foreach}
+					{/foreach}
+				</table>
+				</form>
+				<!-- Table to display the mails list - Ends -->
+
+						</div>
+					</td>
+				   </tr>
+				   <!-- tr>
+					<td colspan="2">&nbsp;</td>
+				   </tr -->
+				   <tr style="visibility:hidden" class="previewWindow">
+					<td class="forwardBg">
+
+					<!-- Table to display the Qualify, Reply, Forward, etc buttons - Starts -->
 			   		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
-					  <tr>
-						<td width="75%">
-						  <span id="qualify_button"><input type="button" name="Qualify2" value=" {$MOD.LBL_QUALIFY_BUTTON} " class="crmbutton small create" /></span>&nbsp;
-						  <span id="reply_button"><input type="button" name="reply" value=" {$MOD.LBL_REPLY_TO_SENDER} " class="crmbutton small edit" /></span>&nbsp;
-						  <span id="reply_button_all"><input type="button" name="reply" value=" {$MOD.LBL_REPLY_ALL} " class="crmbutton small edit" /></span>&nbsp;
-						  <span id="forward_button"><input type="button" name="forward" value=" {$MOD.LBL_FORWARD_BUTTON} " class="crmbutton small edit" /></span>&nbsp;
-						  <span id="download_attach_button"><input type="button" name="download" value=" {$MOD.LBL_DOWNLOAD_ATTCH_BUTTON} " class="crmbutton small save" /></span>
+					   <tr>
+						<td width="75%" nowrap>
+							<span id="qualify_button"><input type="button" name="Qualify2" value=" {$MOD.LBL_QUALIFY_BUTTON} " class="crmbutton small create" /></span>&nbsp;
+							<span id="reply_button"><input type="button" name="reply" value=" {$MOD.LBL_REPLY_TO_SENDER} " class="crmbutton small edit" /></span>&nbsp;
+							<span id="reply_button_all"><input type="button" name="reply" value=" {$MOD.LBL_REPLY_ALL} " class="crmbutton small edit" /></span>&nbsp;
+							<span id="forward_button"><input type="button" name="forward" value=" {$MOD.LBL_FORWARD_BUTTON} " class="crmbutton small edit" /></span>&nbsp;
+							<span id="download_attach_button"><input type="button" name="download" value=" {$MOD.LBL_DOWNLOAD_ATTCH_BUTTON} " class="crmbutton small save" /></span>
 						</td>
 						<td width="25%" align="right"><span id="delete_button"><input type="button" name="Button" value=" {$APP.LBL_DELETE_BUTTON} "  class="crmbutton small delete" /></span></td>
-					  </tr>
+					   </tr>
 					</table>
-				</td>
-			   </tr>
-			 <tr style="visibility:hidden" class="previewWindow">
-			   <td>&nbsp;</td>
-			   <td height="300" bgcolor="#FFFFFF" valign="top" style="padding-top:10px;">
+					<!-- Table to display the Qualify, Reply, Forward, etc buttons - Ends -->
+
+					</td>
+				   </tr>
+				   <tr style="visibility:hidden" class="previewWindow">
+					<td height="300" bgcolor="#FFFFFF" valign="top" style="padding-top:10px;">
+
+					<!-- Table to display the Header details (From, To, Subject and date) - Starts -->
 			   		<table width="100%" border="0" cellpadding="0" cellspacing="0">
 						<tr><td width="20%" align="right"><b>{$MOD.LBL_FROM}</b></td><td id="from_addy">&nbsp;</td></tr>
 						<tr><td width="20%" align="right"><b>{$MOD.LBL_TO}</b></td><td id="to_addy">&nbsp;</td></tr>
+<tr><td width="20%" align="right"><b>{$MOD.LBL_CC}</b></td><td id="webmail_cc">&nbsp;</td></tr>
+
 						<tr><td align="right"><b>{$MOD.LBL_SUBJECT}</b></td><td id="webmail_subject"></td></tr>
-						<tr><td align="right"><b>{$MOD.LBL_DATE}</b></td><td id="webmail_date"></td>
-							<td id="full_view"><a href="javascript:;">Full Window View</a></td></tr>
+		<tr><td	align="right"><b>{$MOD.LBL_DATE}</b></td><td id="webmail_date"></td>
+	<tr><td align="right"><b>{$MOD.LBL_ATTACHMENT}</b></td><td id="webmail_attachment"></td>
+							<td id="full_view"><a href="javascript:;"> Full Email View</a></td></tr>
 						<tr><td align="right" style="border-bottom:1px solid #666666;" colspan="3">&nbsp;</td></tr>
 					</table>
-			   <span id="body_area" style="width:95%">&nbsp;</span></td>
-			   </tr>
-                </table>
-				</td>
-				<td bgcolor="#EBEBEB" width="8"></td>
-			  </tr>
-			  <tr>
-				<td width="7" height="8" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;"><img src="{$IMAGE_PATH}bottom_left.jpg" align="bottom"  /></td>
-				<td bgcolor="#ECECEC" height="8" style="font-size:1px;" ></td>
-				<td width="8" height="8" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;"><img src="{$IMAGE_PATH}bottom_right.jpg" align="bottom" /></td>
-			  </tr>
-		  </table><br />
-		</td>
-		<td>&nbsp;</td>
-	</tr>
+					<!-- Table to display the Header details (From, To, Subject and date) - Ends -->
+
+					   <span id="body_area" style="width:95%">
+						<iframe id="email_description" width="100%" height="210" frameBorder="0"></iframe>
+					   </span>
+					</td>
+				   </tr>
+				</table>
+			</td>
+			<td bgcolor="#EBEBEB" width="8"></td>
+		   </tr>
+		   <tr>
+			<td width="7" height="8" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;"><img src="{$IMAGE_PATH}bottom_left.jpg" align="bottom"  /></td>
+			<td bgcolor="#ECECEC" height="8" style="font-size:1px;" ></td>
+			<td width="8" height="8" style="font-size:1px;font-family:Arial, Helvetica, sans-serif;"><img src="{$IMAGE_PATH}bottom_right.jpg" align="bottom" /></td>
+		   </tr>
+		</table>
+		<br />
+	</td>
+	<td valign=top><img src="{$IMAGE_PATH}showPanelTopRight.gif"></td>
+   </tr>
 </table>
+
 <script>
 function OpenCompose(id,mode)
 {ldelim}
@@ -213,5 +244,21 @@
                 {rdelim}
         openPopUp('xComposeEmail',this,url,'createemailWin',830,662,'menubar=no,toolbar=no,location=no,status=no,resizable=yes,scrollbars=yes');
 {rdelim}
+var gselected_mail = '';
+{if $smarty.request.mailbox.value neq ''}
+	var gCurrentFolder = '{$smarty.request.mailbox}';
+{else}	
+	var gCurrentFolder = 'INBOX';
+{/if}
+{literal}
+function makeSelected(rowId)
+{
+	if(gselected_mail != '')
+		$(gselected_mail).className = '';
+		
+	$(rowId).className = 'mailSelected_select';
+	gselected_mail = rowId;
+}
+{/literal}
 </script>
 <!-- END -->

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/pendingActivities.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/pendingActivities.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/pendingActivities.tpl Mon Apr 16 12:27:44 2007
@@ -9,19 +9,36 @@
   *
  ********************************************************************************/
 -->*}
-{if $ACTIVITIES.1.noofactivities > 0}
-{assign var=label value=$ACTIVITIES.1.Title.0}
+{if $ACTIVITIES.2.noofactivities > 0 || $ACTIVITIES.3.noofactivities > 0}
+<script>
+{literal}
+function changePendingView(view)
+{
+        if(view == "today")
+        {
+
+                document.getElementById('todaypending').style.display="block";
+                document.getElementById('allpending').style.display="none";
+        }
+        else
+        {
+                document.getElementById('todaypending').style.display="none";
+                document.getElementById('allpending').style.display="block";
+
+        }
+}
+{/literal}
+</script>
+
+<div id="todaypending" style="display:block;">
+{assign var=label value=$ACTIVITIES.2.Title.0}
 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="small">
         <tr>
 		<td><img src="{$IMAGE_PATH}pending_left.gif"></td>
                 <td width="100%" background="{$IMAGE_PATH}pendingEvents.gif" valign="bottom" style="background-repeat:repeat-x;">
-                        <b class="fontBold">{$APP.$label}&nbsp;{$APP.LBL_PENDING_EVENTS}&nbsp;({$ACTIVITIES.1.noofactivities})</b><br />
+                        <b class="fontBold">{$APP.$label}&nbsp;{$APP.LBL_PENDING_EVENTS}&nbsp;({$ACTIVITIES.2.noofactivities})</b><br />
                         <b>{$APP.LBL_SHOW}</b>
-                        {if $ACTIVITIES.1.Title.0 eq 'today'}
-	                        {$APP.LBL_TODAY}&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onClick="getHomeActivities(1,'all');">{$APP.LBL_ALL}</a>
-                        {else}
-                                <a href="#" onClick="getHomeActivities(1,'today');">{$APP.LBL_TODAY}</a>&nbsp;&nbsp;|&nbsp;&nbsp;{$APP.LBL_ALL}
-                        {/if}
+	                        {$APP.LBL_TODAY}&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onClick="changePendingView('all');">{$APP.LBL_ALL}</a>
 		</td>
 
                 <td><img src="{$IMAGE_PATH}pending_right.gif"></td>
@@ -31,9 +48,49 @@
 			<div id="pendingActivitiesEntry" style="overflow-y:auto;overflow-x:hidden;height:150px;width:100%">
                 	<table width="100%" border="0" cellpadding="5" cellspacing="0">
                         	<tr>
-                                <td style="border-bottom:1px dotted #dddddd;" colspan=3 align="right" valign=top>&nbsp;</td>
+                                <td style="border-bottom:1px dotted #dddddd;" colspan=4 align="right" valign=top>&nbsp;</td>
                                 </tr>
-                                {foreach item=entries name=entryloop from=$ACTIVITIES.1.Entries}
+				{if $ACTIVITIES.2.noofactivities != 0}
+                                {foreach item=entries name=entryloop from=$ACTIVITIES.2.Entries}
+                                <tr>
+					<td  style="border-bottom:1px dotted #dddddd;"  align="right" width="20">{math equation="x+1" x=$smarty.foreach.entryloop.index}</td>
+                                        <td  style="border-bottom:1px dotted #dddddd;"  align="right" width="20">{$entries.IMAGE}</td>
+                                        <td  style="border-bottom:1px dotted #dddddd;" align="left" valign="middle" colspan="2" width="85%"><b class="style_Gray">{$entries.0}</b>{*<br />{$entries.ACCOUNT_NAME*}</td>
+                                </tr>
+                                {/foreach}
+				{else}
+				<tr>
+					<td  style="border-bottom:1px dotted #dddddd;" align="left" valign="middle" colspan="2" width="85%"><b>{$APP.LBL_NONE_SCHEDULED}</b></td>
+				</tr>
+				{/if}
+                        </table>
+			</div>
+                </td>
+	</tr>
+</table>
+<br>
+</div>
+<div id = "allpending" style="display:none">
+{assign var=label value=$ACTIVITIES.3.Title.0}
+<table width="100%" border="0" cellpadding="0" cellspacing="0" class="small">
+        <tr>
+		<td><img src="{$IMAGE_PATH}pending_left.gif"></td>
+                <td width="100%" background="{$IMAGE_PATH}pendingEvents.gif" valign="bottom" style="background-repeat:repeat-x;">
+                        <b class="fontBold">{$APP.$label}&nbsp;{$APP.LBL_PENDING_EVENTS}&nbsp;({$ACTIVITIES.3.noofactivities})</b><br />
+                        <b>{$APP.LBL_SHOW}</b>
+                                <a href="#" onClick="changePendingView('today')">{$APP.LBL_TODAY}</a>&nbsp;&nbsp;|&nbsp;&nbsp;{$APP.LBL_ALL}
+		</td>
+
+                <td><img src="{$IMAGE_PATH}pending_right.gif"></td>
+        </tr>
+        <tr>
+                <td colspan="3" bgcolor="#FEF7C1" style="border-left:2px solid #A6A4A5;border-right:2px solid #A6A4A5;border-bottom:2px solid #A6A4A5;">
+			<div id="pendingActivitiesEntry" style="overflow-y:auto;overflow-x:hidden;height:150px;width:100%">
+                	<table width="100%" border="0" cellpadding="5" cellspacing="0">
+                        	<tr>
+                                <td style="border-bottom:1px dotted #dddddd;" colspan=4 align="right" valign=top>&nbsp;</td>
+                                </tr>
+                                {foreach item=entries name=entryloop from=$ACTIVITIES.3.Entries}
                                 <tr>
 					<td  style="border-bottom:1px dotted #dddddd;"  align="right" width="20">{math equation="x+1" x=$smarty.foreach.entryloop.index}</td>
                                         <td  style="border-bottom:1px dotted #dddddd;"  align="right" width="20">{$entries.IMAGE}</td>
@@ -46,5 +103,7 @@
 	</tr>
 </table>
 <br>
+</div>
+
 {/if}
 

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/salesEditView.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/salesEditView.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/salesEditView.tpl Mon Apr 16 12:27:44 2007
@@ -18,8 +18,9 @@
 <script type="text/javascript" src="jscalendar/calendar.js"></script>
 <script type="text/javascript" src="jscalendar/lang/calendar-{$CALENDAR_LANG}.js"></script>
 <script type="text/javascript" src="jscalendar/calendar-setup.js"></script>
-<script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
+<script type="text/javascript" src="modules/{$MODULE}/{$MODULE}.js"></script>
 <script type="text/javascript">
+var gVTModule = '{$smarty.request.module}';
 function sensex_info()
 {ldelim}
         var Ticker = $('tickersymbol').value;
@@ -40,6 +41,14 @@
                 );
         {rdelim}
 {rdelim}
+function AddressSync(Addform,id)
+{ldelim}
+        if(formValidate() == true)
+        {ldelim}  
+	      checkAddress(Addform,id);
+        {rdelim}
+{rdelim}
+
 </script>
 
 		{include file='Buttons_List1.tpl'}	
@@ -101,8 +110,10 @@
 											<div align="center">
 												{if $MODULE eq 'Webmails'}
 													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.module.value='Webmails';this.form.send_mail.value='true';this.form.record.value='{$ID}'" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+											{elseif $MODULE eq 'Accounts'}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted();  AddressSync(this.form,{$ID});"  type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
 												{else}
-													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted(); return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmButton small save" onclick="this.form.action.value='Save'; displaydeleted(); return formValidate() " type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
 												{/if}
 													<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 											</div>
@@ -180,16 +191,19 @@
 									   <tr>
 										<td  colspan=4 style="padding:5px">
 											<div align="center">
-												{if $MODULE eq 'Emails'}
-													<input title="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_KEY}" class="crmbutton small create" onclick="window.open('index.php?module=Users&action=lookupemailtemplates&entityid={$ENTITY_ID}&entity={$ENTITY_TYPE}','emailtemplate','top=100,left=200,height=400,width=300,menubar=no,addressbar=no,status=yes')" type="button" name="button" value="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL}">
-													<input title="{$MOD.LBL_SEND}" accessKey="{$MOD.LBL_SEND}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.send_mail.value='true'; return formValidate()" type="submit" name="button" value="  {$MOD.LBL_SEND}  " >
-												{/if}
-												{if $MODULE eq 'Webmails'}
-													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.module.value='Webmails';this.form.send_mail.value='true';this.form.record.value='{$ID}'" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-												{else}
-                                				                                	<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  displaydeleted();return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-												{/if}
-                                                                					<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+										{if $MODULE eq 'Emails'}
+										<input title="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_KEY}" class="crmbutton small create" onclick="window.open('index.php?module=Users&action=lookupemailtemplates&entityid={$ENTITY_ID}&entity={$ENTITY_TYPE}','emailtemplate','top=100,left=200,height=400,width=300,menubar=no,addressbar=no,status=yes')" type="button" name="button" value="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL}">
+										<input title="{$MOD.LBL_SEND}" accessKey="{$MOD.LBL_SEND}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.send_mail.value='true'; return formValidate()" type="submit" name="button" value="  {$MOD.LBL_SEND}  " >
+										{/if}
+										{if $MODULE eq 'Webmails'}
+										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.module.value='Webmails';this.form.send_mail.value='true';this.form.record.value='{$ID}'" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{elseif $MODULE eq 'Accounts'}
+                                		                     <input type='hidden'  name='address_change' value='no'>
+                                                                             <input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted();  AddressSync(this.form,{$ID}) " type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >		
+										{else}
+              				                                	<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  displaydeleted();return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{/if}
+                                               					<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 											</div>
 										</td>
 									   </tr>

Modified: vtigercrm/branches/5.1_jens/Smarty/templates/upcomingActivities.tpl
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty/templates/upcomingActivities.tpl (original)
+++ vtigercrm/branches/5.1_jens/Smarty/templates/upcomingActivities.tpl Mon Apr 16 12:27:44 2007
@@ -9,7 +9,28 @@
   *
  ********************************************************************************/
 -->*}
-{if $ACTIVITIES.0.noofactivities > 0}
+{if $ACTIVITIES.0.noofactivities > 0 || $ACTIVITIES.1.noofactivities > 0}
+<script>
+{literal}
+function changeUpcomingView(view)
+{
+        if(view == "today")
+        {
+
+                document.getElementById('todayUpcoming').style.display="block";
+                document.getElementById('allUpcoming').style.display="none";
+        }
+        else
+        {
+                document.getElementById('todayUpcoming').style.display="none";
+                document.getElementById('allUpcoming').style.display="block";
+
+        }
+}
+{/literal}
+</script>
+
+<div id='todayUpcoming'>
 	{assign var=label value=$ACTIVITIES.0.Title.0}
 	<table width="100%" border="0" cellpadding="0" cellspacing="0">
         	<tr>
@@ -21,11 +42,7 @@
                         <td colspan="3" bgcolor="#FFFFCF" style="border-left:2px solid #A6A4A5;border-right:2px solid #A6A4A5;padding-left:10px;">
                 	        <b class="fontBold">{$APP.$label}&nbsp;{$APP.LBL_UPCOMING_EVENTS}&nbsp;({$ACTIVITIES.0.noofactivities})</b><br />
                                 <b>{$APP.LBL_SHOW}</b>
-				{if $ACTIVITIES.0.Title.0 eq 'today'}
-					{$APP.LBL_TODAY}&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onClick="getHomeActivities(0,'all')">{$APP.LBL_ALL}</a>
-				{else}
-					<a href="#" onClick="getHomeActivities(0,'today')">{$APP.LBL_TODAY}</a>&nbsp;&nbsp;|&nbsp;&nbsp;{$APP.LBL_ALL}
-			        {/if}
+					{$APP.LBL_TODAY}&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onClick="changeUpcomingView('all')">{$APP.LBL_ALL}</a>
 			</td>
 		</tr>
 		<tr>
@@ -33,9 +50,51 @@
 			<div id="upcomingActivitiesEntry" style="overflow-y:auto;overflow-x:hidden;height:150px;width:100%">
 				<table width="100%" border="0" cellpadding="5" cellspacing="0">
 					<tr bgcolor="#FFFFCF">
-	                                        <td style="border-bottom:1px dotted #dddddd;" colspan=3 align="right" valign=top>&nbsp;</td>
+	                                        <td style="border-bottom:1px dotted #dddddd;" colspan=4 align="right" valign=top>&nbsp;</td>
                                         </tr>
+					{if $ACTIVITIES.0.noofactivities != 0}
                                         {foreach item=entries name=entryloop from=$ACTIVITIES.0.Entries}
+                                        <tr bgcolor="#FFFFCF">
+						<td style="border-bottom:1px dotted #dddddd;" align="right" width="20" valign=top>{math equation="x+1" x=$smarty.foreach.entryloop.index}</td>
+						<td style="border-bottom:1px dotted #dddddd;" align="right" width="20" valign=top>{$entries.IMAGE}</td>
+                                                <td style="border-bottom:1px dotted #dddddd;" align="left" valign="middle" colspan="2" width="85%"><b>{$entries.0}</b>{*<br />{$entries.ACCOUNT_NAME*}</td>
+                                        </tr>
+                                        {/foreach}
+					{else}
+					<tr>
+					<td style="border-bottom:1px dotted #dddddd;" align="left" valign="middle" colspan="2" width="85%"><b>{$APP.LBL_NONE_SCHEDULED}</b></td>
+					</tr>
+					{/if}
+				</table>
+				</div>
+			</td>
+		</tr>
+	</table>
+	<br>
+</div>
+<div id = "allUpcoming" style = "display:none">
+	{assign var=label value=$ACTIVITIES.1.Title.0}
+	<table width="100%" border="0" cellpadding="0" cellspacing="0">
+        	<tr>
+                	<td><img src="{$IMAGE_PATH}upcoming_left.gif" align="top"  /></td>
+                	<td width="100%" background="{$IMAGE_PATH}upcomingEvents.gif" style="background-repeat:repeat-x; "></td>
+			<td><img src="{$IMAGE_PATH}upcoming_right.gif" align="top"  /></td>
+		</tr>
+		<tr>
+                        <td colspan="3" bgcolor="#FFFFCF" style="border-left:2px solid #A6A4A5;border-right:2px solid #A6A4A5;padding-left:10px;">
+                	        <b class="fontBold">{$APP.$label}&nbsp;{$APP.LBL_UPCOMING_EVENTS}&nbsp;({$ACTIVITIES.1.noofactivities})</b><br />
+                                <b>{$APP.LBL_SHOW}</b>
+					<a href="#" onClick="changeUpcomingView('today')">{$APP.LBL_TODAY}</a>&nbsp;&nbsp;|&nbsp;&nbsp;{$APP.LBL_ALL}
+			</td>
+		</tr>
+		<tr>
+			<td colspan="3" bgcolor="#FFFFCF" style="border-left:2px solid #A6A4A5;border-right:2px solid #A6A4A5;border-bottom:2px solid #A6A4A5;">
+			<div id="upcomingActivitiesEntry" style="overflow-y:auto;overflow-x:hidden;height:150px;width:100%">
+				<table width="100%" border="0" cellpadding="5" cellspacing="0">
+					<tr bgcolor="#FFFFCF">
+	                                        <td style="border-bottom:1px dotted #dddddd;" colspan=4 align="right" valign=top>&nbsp;</td>
+                                        </tr>
+                                        {foreach item=entries name=entryloop from=$ACTIVITIES.1.Entries}
                                         <tr bgcolor="#FFFFCF">
 						<td style="border-bottom:1px dotted #dddddd;" align="right" width="20" valign=top>{math equation="x+1" x=$smarty.foreach.entryloop.index}</td>
 						<td style="border-bottom:1px dotted #dddddd;" align="right" width="20" valign=top>{$entries.IMAGE}</td>
@@ -48,5 +107,7 @@
 		</tr>
 	</table>
 	<br>
+</div>
+
 {/if}
 

Modified: vtigercrm/branches/5.1_jens/Smarty_setup.php
==============================================================================
--- vtigercrm/branches/5.1_jens/Smarty_setup.php (original)
+++ vtigercrm/branches/5.1_jens/Smarty_setup.php Mon Apr 16 12:27:44 2007
@@ -16,6 +16,8 @@
 	*/
 	function vtigerCRM_Smarty()
 	{
+		global $CALENDAR_DISPLAY, $WORLD_CLOCK_DISPLAY, $CALCULATOR_DISPLAY, $CHAT_DISPLAY;
+
 		$this->Smarty();
 		$this->template_dir = 'Smarty/templates';
 		$this->compile_dir = 'Smarty/templates_c';
@@ -24,6 +26,10 @@
 
 		//$this->caching = true;
 	        //$this->assign('app_name', 'Login');
+		$this->assign('CALENDAR_DISPLAY', $CALENDAR_DISPLAY); 
+ 		$this->assign('WORLD_CLOCK_DISPLAY', $WORLD_CLOCK_DISPLAY); 
+ 		$this->assign('CALCULATOR_DISPLAY', $CALCULATOR_DISPLAY); 
+ 		$this->assign('CHAT_DISPLAY', $CHAT_DISPLAY);
 	}
 }
 

Modified: vtigercrm/branches/5.1_jens/config.template.php
==============================================================================
--- vtigercrm/branches/5.1_jens/config.template.php (original)
+++ vtigercrm/branches/5.1_jens/config.template.php Mon Apr 16 12:27:44 2007
@@ -16,15 +16,15 @@
 include('vtigerversion.php');
 
 // more than 8MB memory needed for graphics
-// memory limit default value = 16M
-ini_set('memory_limit','16M');
+// memory limit default value = 64M
+ini_set('memory_limit','64M');
 
-// show or hide world clock, calculator and FCKEditor
-// world_clock_display default value = true
-// calculator_display default value = true
-// fckeditor_display default value = true
+// show or hide calendar, world clock, calculator, chat and FCKEditor 
+// Do NOT remove the quotes if you set these to false! 
+$CALENDAR_DISPLAY = 'true';
 $WORLD_CLOCK_DISPLAY = 'true';
 $CALCULATOR_DISPLAY = 'true';
+$CHAT_DISPLAY = 'true'; 
 $FCKEDITOR_DISPLAY = 'true';
 
 // url for customer portal (Example: http://vtiger.com/portal)

Modified: vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.bat
==============================================================================
--- vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.bat (original)
+++ vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.bat Mon Apr 16 12:27:44 2007
@@ -1,2 +1,11 @@
+REM  **************************************************************************************
+REM  * The contents of this file are subject to the vtiger CRM Public License Version 1.0 *
+REM  * ("License"); You may not use this file except in compliance with the License       *
+REM  * The Original Code is:  vtiger CRM Open Source                                      *
+REM  * The Initial Developer of the Original Code is vtiger.                              *
+REM  * Portions created by vtiger are Copyright (C) vtiger.                               *
+REM  * All Rights Reserved.                                                               *
+REM  *                                                                                    *
+REM  **************************************************************************************  
 @echo off
 ..\..\..\..\php\php.exe intimateTaskStatus.php

Modified: vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.php
==============================================================================
--- vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.php (original)
+++ vtigercrm/branches/5.1_jens/cron/intimateTaskStatus.php Mon Apr 16 12:27:44 2007
@@ -1,5 +1,5 @@
 <?php
-ini_set("include_path", "../:.");
+ini_set("include_path", "../");
 
 require('send_mail.php');
 require_once('config.php');
@@ -38,7 +38,7 @@
   $status=$myrow[0];
   if($status != 'Completed')
   {
-	 sendmail($emailaddress,$emailaddress,"Task Not completed","Dear Admin,<br><br> Please note that there are certain tasks in the system which have not been completed even after 24hours of their existence<br> Thank You<br>HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,"");	
+	 sendmail($emailaddress,$emailaddress,$app_strings['Task_Not_completed'],$app_strings['Dear_Admin_tasks_not_been_completed'],$mailserver,$mailuname,$mailpwd,"");	
   }
 }
 }
@@ -58,7 +58,7 @@
   if($stage == 'Closed Won' &&  $amount > 10000)
   {
     
-    sendmail($emailaddress,$emailaddress,"Big Deal Closed Successfully!","Dear Team,<br>Congratulations!Time to Party! <br>We closed a deal worth more than 10000!!!!<br> Time to hit the dance floor!<br>",$mailserver,$mailuname,$mailpwd,"");	
+    sendmail($emailaddress,$emailaddress,$app_srings['Big_Deal_Closed_Successfully'],$app_strings['Dear_Team_Time_to_Party'],$mailserver,$mailuname,$mailpwd,"");	
   }
 }
 
@@ -79,7 +79,7 @@
   $ticketid = $myrow[1];
   if($status != "Completed" || $status != "Closed")
   {
-    sendmail($emailaddress,$emailaddress,"Pending Ticket notification","Dear Admin,<br> This is to bring to your kind attention that ticket number ".$ticketid ." is yet to be closed<br> Thank You,<br> HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,"");	
+    sendmail($emailaddress,$emailaddress,$app_strings['Pending_Ticket_notification'],$app_strings['Kind_Attention'].$ticketid .$app_strings['Thank_You_HelpDesk'],$mailserver,$mailuname,$mailpwd,"");	
   }
 }
 
@@ -99,7 +99,7 @@
 {
   $status=$myrow[0];
   $ticketid = $myrow[1];
-  sendmail($emailaddress,$emailaddress,"Too many pending tickets","Dear Admin,<br> This is to bring to your notice that there are too many tickets pending. Kindly take the necessary action required for addressing the same<br><br> Thanks and Regards,<br> HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,"");	
+  sendmail($emailaddress,$emailaddress,$app_strings['Too_many_pending_tickets'],$app_strings['Dear_Admin_too_ many_tickets_pending'],$mailserver,$mailuname,$mailpwd,"");	
 }
 
 }
@@ -115,7 +115,7 @@
 while ($myrow = $adb->fetch_array($result))
 {
   $productname=$myrow[0];
-  sendmail($emailaddress,$emailaddress,"Support starting","Hello! Support Starts for ".$productname ."\n Congratulations! Your support starts from today",$mailserver,$mailuname,$mailpwd,"");	
+  sendmail($emailaddress,$emailaddress,$app_strings['Support_starting'],$app_strings['Hello_Support'].$productname ."\n ".$app_strings['Congratulations'],$mailserver,$mailuname,$mailpwd,"");	
 }
 
 }
@@ -132,7 +132,7 @@
 while ($myrow = $adb->fetch_array($result))
 {
   $productname=$myrow[0];
-  sendmail($emailaddress,$emailaddress,"Support Ending","Dear Admin,<br> This is to inform you that the support for ".$productname ."\n ends shortly. Kindly renew your support please<br>Regards,<br>HelpDesk Team<br>",$mailserver,$mailuname,$mailpwd,"");	
+  sendmail($emailaddress,$emailaddress,$app_strings['Support_Ending'],$app_strings['Dear_Admin'].$productname ."\n ".$app_strings['kindly_renew'],$mailserver,$mailuname,$mailpwd,"");	
 }
 
 }

Modified: vtigercrm/branches/5.1_jens/cron/jobstartwindows.bat
==============================================================================
--- vtigercrm/branches/5.1_jens/cron/jobstartwindows.bat (original)
+++ vtigercrm/branches/5.1_jens/cron/jobstartwindows.bat Mon Apr 16 12:27:44 2007
@@ -1,5 +1,14 @@
+REM  **************************************************************************************
+REM  * The contents of this file are subject to the vtiger CRM Public License Version 1.0 *
+REM  * ("License"); You may not use this file except in compliance with the License       *
+REM  * The Original Code is:  vtiger CRM Open Source                                      *
+REM  * The Initial Developer of the Original Code is vtiger.                              *
+REM  * Portions created by vtiger are Copyright (C) vtiger.                               *
+REM  * All Rights Reserved.                                                               *
+REM  *                                                                                    *
+REM  **************************************************************************************  
 @echo off
 set SCH_INSTALL=%1
 FOR %%X in (%SCH_INSTALL%) DO SET SCH_INSTALL=%%~sX
 schtasks /create /tn "vtigerCRM Notification Scheduler" /tr %SCH_INSTALL%\apache\htdocs\vtigerCRM\cron\intimateTaskStatus.bat /sc daily /st 11:00:00 /RU SYSTEM
-schtasks /create /tn "vtigerCRM Email Reminder" /tr %SCH_INSTALL%\apache\htdocs\vtigerCRM\modules\Activities\SendReminder.bat /sc minute /mo 1 /RU SYSTEM
+schtasks /create /tn "vtigerCRM Email Reminder" /tr %SCH_INSTALL%\apache\htdocs\vtigerCRM\modules\Calendar\SendReminder.bat /sc minute /mo 1 /RU SYSTEM

Modified: vtigercrm/branches/5.1_jens/data/CRMEntity.php
==============================================================================
--- vtigercrm/branches/5.1_jens/data/CRMEntity.php (original)
+++ vtigercrm/branches/5.1_jens/data/CRMEntity.php Mon Apr 16 12:27:44 2007
@@ -1,494 +1,518 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/vtigercrm/data/CRMEntity.php,v 1.16 2005/04/29 04:21:31 mickie Exp $
- * Description:  Defines the base class for all data entities used throughout the 
- * application.  The base class including its methods and variables is designed to 
- * be overloaded with module-specific methods and variables particular to the 
- * module's base entity class. 
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('data/Tracker.php');
-require_once('include/utils/utils.php');
-require_once('include/utils/UserInfoUtil.php');
-
-class CRMEntity
-{
-  /**
-   * This method implements a generic insert and update logic for any SugarBean
-   * This method only works for subclasses that implement the same variable names.
-   * This method uses the presence of an id vtiger_field that is not null to signify and update.
-   * The id vtiger_field should not be set otherwise.
-   * todo - Add support for vtiger_field type validation and encoding of parameters.
-   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
-   * All Rights Reserved.
-   * Contributor(s): ______________________________________..
-   */
-
-	
-  function saveentity($module)
-  {
-	global $current_user, $adb;//$adb added by raju for mass mailing
-	$insertion_mode = $this->mode;
-
-	$this->db->println("TRANS saveentity starts $module");
-	$this->db->startTransaction();
-	
-
-	foreach($this->tab_name as $table_name)
-	{
-			
-		if($table_name == "vtiger_crmentity")
-		{
-			$this->insertIntoCrmEntity($module);
-		}
-		elseif($table_name == 'vtiger_entity2org')
-		{
-			$this->insertIntoEntity2Org($this->id,$module);
-		}
-		else
-		{
-			$this->insertIntoEntityTable($table_name, $module);			
-		}
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/vtigercrm/data/CRMEntity.php,v 1.16 2005/04/29 04:21:31 mickie Exp $
+ * Description:  Defines the base class for all data entities used throughout the 
+ * application.  The base class including its methods and variables is designed to 
+ * be overloaded with module-specific methods and variables particular to the 
+ * module's base entity class. 
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('data/Tracker.php');
+require_once('include/utils/utils.php');
+require_once('include/utils/UserInfoUtil.php');
+
+class CRMEntity
+{
+  /**
+   * This method implements a generic insert and update logic for any SugarBean
+   * This method only works for subclasses that implement the same variable names.
+   * This method uses the presence of an id vtiger_field that is not null to signify and update.
+   * The id vtiger_field should not be set otherwise.
+   * todo - Add support for vtiger_field type validation and encoding of parameters.
+   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+   * All Rights Reserved.
+   * Contributor(s): ______________________________________..
+   */
+
+  var $ownedby;
+   
+	
+  function saveentity($module)
+  {
+	global $current_user, $adb;//$adb added by raju for mass mailing
+	$insertion_mode = $this->mode;
+
+	$this->db->println("TRANS saveentity starts $module");
+	$this->db->startTransaction();
+	
+
+	foreach($this->tab_name as $table_name)
+	{
+			
+		if($table_name == "vtiger_crmentity")
+		{
+			$this->insertIntoCrmEntity($module);
+		}
+		elseif($table_name == 'vtiger_entity2org')
+		{
+			$this->insertIntoEntity2Org($this->id,$module);
+		}
+		else
+		{
+			$this->insertIntoEntityTable($table_name, $module);			
+		}
+	}
+
+	//Inserting into the group Table
+	if($this->ownedby == 0)
+	{
+		$this->insertIntoGroupTable($module);
+	}	
+	
+	//Calling the Module specific save code
+	$this->save_module($module);
+
+	$assigntype=$_REQUEST['assigntype'];
+	if($module != "Calendar")
+          $this->whomToSendMail($module,$this ->mode,$assigntype);
+	
+	$this->db->completeTransaction();
+        $this->db->println("TRANS saveentity ends");
+  }
+
+
+	
+	function insertIntoAttachment1($id,$module,$filedata,$filename,$filesize,$filetype,$user_id)
+	{
+		$date_var = date('YmdHis');
+		global $current_user;
+		global $adb;
+		//global $root_directory;
+		global $log;
+
+		$ownerid = $user_id;
+		
+		if($filesize != 0)
+		{
+			$data = base64_encode(fread(fopen($filedata, "r"), $filesize));
+		}
+		
+		$current_id = $adb->getUniqueID("vtiger_crmentity");
+
+		if($module=='Emails') 
+		{ 
+			$log->info("module is ".$module);
+			$idname='emailid';      $tablename='emails';    $descname='description';
+		}
+		else     
+		{ 
+			$idname='notesid';      $tablename='notes';     $descname='notecontent';
+		}
+
+		$sql="update ".$tablename." set filename='".$filename."' where ".$idname."=".$id;
+		$adb->query($sql);
+
+		$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','"."',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")";
+		$adb->query($sql1);
+
+		$sql2="insert into vtiger_attachments(attachmentsid, name, description, type) values(".$current_id.",'".$filename."','"."','".$filetype."')";
+		$result=$adb->query($sql2);
+
+		//TODO -- instead of put contents in db now we should store the file in harddisk
+
+		$sql3='insert into vtiger_seattachmentsrel values('.$id.','.$current_id.')';
+		$adb->query($sql3);
+	}
+	
+
+
+	/**
+	 *      This function is used to upload the attachment in the server and save that attachment information in db.
+	 *      @param int $id  - entity id to which the file to be uploaded
+	 *      @param string $module  - the current module name
+	 *      @param array $file_details  - array which contains the file information(name, type, size, tmp_name and error)
+	 *      return void
+	*/
+	function uploadAndSaveFile($id,$module,$file_details)
+	{
+		global $log;
+		$log->debug("Entering into uploadAndSaveFile($id,$module,$file_details) method.");
+
+		global $adb, $current_user;
+		global $upload_badext;
+
+		$date_var = date('YmdHis');
+
+		//to get the owner id
+		$ownerid = $this->column_fields['assigned_user_id'];
+		if(!isset($ownerid) || $ownerid=='')
+			$ownerid = $current_user->id;
+
+	
+		// Arbitrary File Upload Vulnerability fix - Philip
+		$binFile = $file_details['name'];
+		$ext_pos = strrpos($binFile, ".");
+
+		$ext = substr($binFile, $ext_pos + 1);
+
+		if (in_array($ext, $upload_badext))
+		{
+			$binFile .= ".txt";
+		}
+		// Vulnerability fix ends
+
+		$current_id = $adb->getUniqueID("vtiger_crmentity");
+
+		$filename = basename($binFile);
+		$filetype= $file_details['type'];
+		$filesize = $file_details['size'];
+		$filetmp_name = $file_details['tmp_name'];
+
+		//get the file path inwhich folder we want to upload the file
+		$upload_file_path = decideFilePath();
+
+		//upload the file in server
+		$upload_status = move_uploaded_file($filetmp_name,$upload_file_path.$current_id."_".$binFile);
+
+		$save_file = 'true';
+		//only images are allowed for these modules
+		if($module == 'Contacts' || $module == 'Products')
+		{
+			$save_file = validateImageFile(&$file_details);
+		}
+
+		if($save_file == 'true' && $upload_status == 'true')
+		{
+			//This is only to update the attached filename in the vtiger_notes vtiger_table for the Notes module
+			if($module=='Notes')
+			{
+				$sql="update vtiger_notes set filename='".$filename."' where notesid = ".$id;
+				$adb->query($sql);
+			}
+
+			$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','".$this->column_fields['description']."',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")";
+			$adb->query($sql1);
+
+			$sql2="insert into vtiger_attachments(attachmentsid, name, description, type, path) values(".$current_id.",'".$filename."','".$this->column_fields['description']."','".$filetype."','".$upload_file_path."')";
+			$result=$adb->query($sql2);
+
+			if($_REQUEST['mode'] == 'edit')
+			{
+				if($id != '' && $_REQUEST['fileid'] != '')
+				{
+					$delquery = 'delete from vtiger_seattachmentsrel where crmid = '.$id.' and attachmentsid = '.$_REQUEST['fileid'];
+					$adb->query($delquery);
+				}
+			}
+			if($module == 'Notes')
+			{
+				$query = "delete from vtiger_seattachmentsrel where crmid = ".$id;
+				$adb->query($query);
+			}
+			$sql3='insert into vtiger_seattachmentsrel values('.$id.','.$current_id.')';
+			$adb->query($sql3);
+
+			return true;
+		}
+		else
+		{
+			$log->debug("Skip the save attachment process.");
+			return false;
+		}
+	}
+
+	/** Function to insert values in the vtiger_crmentity for the specified module
+  	  * @param $module -- module:: Type varchar
+ 	 */	
+
+  function insertIntoCrmEntity($module)
+  {
+	global $adb;
+	global $current_user;
+	global $log;
+                
+	$date_var = date('YmdHis');
+	if($_REQUEST['assigntype'] == 'T')
+	{
+		$ownerid= 0;
+	}
+	else
+	{
+		$ownerid = $this->column_fields['assigned_user_id'];
+	}
+        
+	$sql="select ownedby from vtiger_tab where name='".$module."'";
+	$res=$adb->query($sql);
+	$this->ownedby = $adb->query_result($res,0,'ownedby');
+	
+	if($this->ownedby == 1)
+	{
+		$log->info("module is =".$module);
+		$ownerid = $current_user->id;
+	}	
+	
+	
+	if($module == 'Events')
+	{
+		$module = 'Calendar';
+	}
+	if($this->mode == 'edit')
+	{
+		$description_val = from_html($adb->formatString("vtiger_crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
+
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		$tabid = getTabid($module);
+		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
+		{
+			$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
+		}
+		else
+		{
+			$profileList = getCurrentUserProfileList();
+			$perm_qry = "SELECT columnname FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid = vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid = vtiger_field.fieldid WHERE vtiger_field.tabid = ".$tabid." AND vtiger_profile2field.visible = 0 AND vtiger_profile2field.profileid IN ".$profileList." AND vtiger_def_org_field.visible = 0 and vtiger_field.tablename='vtiger_crmentity' and vtiger_field.displaytype in (1,3);";
+			$perm_result = $adb->query($perm_qry);
+			$perm_rows = $adb->num_rows($perm_result);
+			for($i=0; $i<$perm_rows; $i++)
+			{
+				$columname[]=$adb->query_result($perm_result,$i,"columnname");
+			}
+			if(is_array($columname) && in_array("description",$columname))
+			{
+				$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
+			}
+			else
+			{
+				$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
+			}
+		}
+		$adb->query($sql);
+		$sql1 ="delete from vtiger_ownernotify where crmid=".$this->id;
+		$adb->query($sql1);
+		if($ownerid != $current_user->id)
+		{
+			$sql1 = "insert into vtiger_ownernotify values(".$this->id.",".$ownerid.",null)";
+			$adb->query($sql1);
+		}
+		
+		
+
+		
+
+		
+	}
+	else
+	{
+		//if this is the create mode and the group allocation is chosen, then do the following
+		$current_id = $adb->getUniqueID("vtiger_crmentity");
+		$_REQUEST['currentid']=$current_id;
+
+		$description_val = from_html($adb->formatString("vtiger_crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
+		$sql = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('".$current_id."','".$current_user->id."','".$ownerid."','".$module."',".$description_val.",".$adb->formatDate($date_var).",".$adb->formatDate($date_var).")";
+		$adb->query($sql);
+		$this->id = $current_id;
+
+		//set the organization relation for this entity
+		//default value: The current selected organization
+		$orglist = array();
+		if( isset($_SESSION['authenticated_user_current_organization']) && $_SESSION['authenticated_user_current_organization'] != '') {
+		    $orglist[0] = $_SESSION['authenticated_user_current_organization'];
+		} else {
+		    global $current_organization;
+		    $orglist[0] = $current_organization;
+		}
+
+		//if we still have not got some organization
+		if( count( $orglist) < 0) {
+		    $log->info("crmid ".$this->id." is not explizitely related to any organization");
+		    $sql = "select organizationname from vtiger_organizationdetails where deleted=0";
+		    $result = $adb->query($sql);
+		    $orglist[0]=$adb->query_result($result,$i,"organizationname");
+		}
+		if( count( $orglist) < 0) {
+		    $log->fatal("crmid ".$this->id." is not related to any organization");
+		}
+
+		//set up the relations in the database
+		foreach($orglist as $org) {
+		    $sql = "insert into vtiger_entity2org (crmid,organizationname,primarytag) values (".$this->id.",'".$org."',1)";
+		    $adb->query($sql);
+		}
+	    }
+	}
+
+	/** Function to insert values in the vtiger_entity2org relation
+	 *  @param $crmid -- CRM id
+	 *  @param $module -- module object
+	 */
+	function insertIntoEntity2Org($crmid,$module)
+	{
+	    global $current_organization;
+	    global $log;
+
+	    $log->debug( "Entering insertIntoEntity2Org for crmid=".$crmid." module=".$module);
+
+	    // parameters
+	    if( isset( $crmid) && $crmid != '' &&
+		isset( $this->column_fields["otherorgs"]) && $this->column_fields["otherorgs"] != '') {
+
+		// the organization list is the current users organization plus
+		// the other organizations stored in the modules parameters
+		if( is_array( $this->column_fields["otherorgs"])) {
+		    // As array when enetered in EditView
+		    $orglist = array();
+		    foreach( array_keys( $this->column_fields["otherorgs"]) as $key)
+			$orglist[] = $this->column_fields["otherorgs"][$key];
+		} else {
+		    // As string when entered in DetailView
+		    $orglist = explode( ' |##| ', $this->column_fields["otherorgs"]);
+		}
+		$orglist[] = $current_organization;
+
+		// get the current list of assignments
+		$sql = "SELECT organizationname,primarytag FROM vtiger_entity2org WHERE crmid='".$crmid."'";
+		$result = $this->db->query($sql);
+		$delete = array();
+		$noofrows = $this->db->num_rows($result);
+
+		for( $i=0; $i<$noofrows; $i++) {
+		    $organizationname = $this->db->query_result($result,$i,"organizationname");
+		    // If this organization is part of the $orglist array we'll
+		    // just keept it.
+		    for( $j=0; $j<count($orglist); $j++) {
+			if( $orglist[$j] == $organizationname) {
+			    array_splice( $orglist, $j, 1);
+			    continue 2;
+			}
+		    }
+
+		    // So the relation defined in the database is to be removed
+		    // Do not remove primary organizations
+		    $primary = $this->db->query_result($result,$i,"primarytag");
+		    if( $primary == 0)
+			$delete[] = $organizationname;
+		}
+
+		// Now we have two arrays $delete and $orglist defining the 
+		// required database modification
+		$delstr = "";
+		foreach( $delete as $org) {
+		    if( $delstr == "") 
+			$delstr = "'".$org."'";
+		    else
+			$delstr .= ",'".$org."'";
+		}
+		if( $delstr != '') {
+		    $sql = "DELETE from vtiger_entity2org WHERE crmid='".$crmid."'
+			       AND organizationname IN (".$delstr.")";
+		    $result = $this->db->query($sql);
+		}
+
+		foreach( $orglist as $org) {
+		    $sql = "INSERT INTO vtiger_entity2org (crmid,organizationname,primarytag)
+			       VALUES ('".$crmid."','".$org."',0)";
+		    $result = $this->db->query($sql);
+		}
+	    }
+
+	    $log->debug( "Exit from insertIntoEntity2Org for crmid=".$crmid." module=".$module);
 	}
-
-	//Calling the Module specific save code
-	$this->save_module($module);
-	
-	$this->db->completeTransaction();
-        $this->db->println("TRANS saveentity ends");
-  }
-
-
-	
-	function insertIntoAttachment1($id,$module,$filedata,$filename,$filesize,$filetype,$user_id)
-	{
-		$date_var = date('YmdHis');
-		global $current_user;
-		global $adb;
-		//global $root_directory;
-		global $log;
-
-		$ownerid = $user_id;
-		
-		if($filesize != 0)
-		{
-			$data = base64_encode(fread(fopen($filedata, "r"), $filesize));
-		}
-		
-		$current_id = $adb->getUniqueID("vtiger_crmentity");
-
-		if($module=='Emails') 
-		{ 
-			$log->info("module is ".$module);
-			$idname='emailid';      $tablename='emails';    $descname='description';
-		}
-		else     
-		{ 
-			$idname='notesid';      $tablename='notes';     $descname='notecontent';
-		}
-
-		$sql="update ".$tablename." set filename='".$filename."' where ".$idname."=".$id;
-		$adb->query($sql);
-
-		$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','"."',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")";
-		$adb->query($sql1);
-
-		$sql2="insert into vtiger_attachments(attachmentsid, name, description, type) values(".$current_id.",'".$filename."','"."','".$filetype."')";
-		$result=$adb->query($sql2);
-
-		//TODO -- instead of put contents in db now we should store the file in harddisk
-
-		$sql3='insert into vtiger_seattachmentsrel values('.$id.','.$current_id.')';
-		$adb->query($sql3);
-	}
-	
-
-
-	/**
-	 *      This function is used to upload the attachment in the server and save that attachment information in db.
-	 *      @param int $id  - entity id to which the file to be uploaded
-	 *      @param string $module  - the current module name
-	 *      @param array $file_details  - array which contains the file information(name, type, size, tmp_name and error)
-	 *      return void
-	*/
-	function uploadAndSaveFile($id,$module,$file_details)
-	{
-		global $log;
-		$log->debug("Entering into uploadAndSaveFile($id,$module,$file_details) method.");
-
-		global $adb, $current_user;
-		global $upload_badext;
-
-		$date_var = date('YmdHis');
-
-		//to get the owner id
-		$ownerid = $this->column_fields['assigned_user_id'];
-		if(!isset($ownerid) || $ownerid=='')
-			$ownerid = $current_user->id;
-
-	
-		// Arbitrary File Upload Vulnerability fix - Philip
-		$binFile = $file_details['name'];
-		$ext_pos = strrpos($binFile, ".");
-
-		$ext = substr($binFile, $ext_pos + 1);
-
-		if (in_array($ext, $upload_badext))
-		{
-			$binFile .= ".txt";
-		}
-		// Vulnerability fix ends
-
-		$current_id = $adb->getUniqueID("vtiger_crmentity");
-
-		$filename = basename($binFile);
-		$filetype= $file_details['type'];
-		$filesize = $file_details['size'];
-		$filetmp_name = $file_details['tmp_name'];
-
-		//get the file path inwhich folder we want to upload the file
-		$upload_file_path = decideFilePath();
-
-		//upload the file in server
-		$upload_status = move_uploaded_file($filetmp_name,$upload_file_path.$current_id."_".$binFile);
-
-		$save_file = 'true';
-		//only images are allowed for these modules
-		if($module == 'Contacts' || $module == 'Products')
-		{
-			$save_file = validateImageFile(&$file_details);
-		}
-
-		if($save_file == 'true' && $upload_status == 'true')
-		{
-			//This is only to update the attached filename in the vtiger_notes vtiger_table for the Notes module
-			if($module=='Notes')
-			{
-				$sql="update vtiger_notes set filename='".$filename."' where notesid = ".$id;
-				$adb->query($sql);
-			}
-
-			$sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(".$current_id.",".$current_user->id.",".$ownerid.",'".$module." Attachment','".$this->column_fields['description']."',".$adb->formatString("vtiger_crmentity","createdtime",$date_var).",".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var).")";
-			$adb->query($sql1);
-
-			$sql2="insert into vtiger_attachments(attachmentsid, name, description, type, path) values(".$current_id.",'".$filename."','".$this->column_fields['description']."','".$filetype."','".$upload_file_path."')";
-			$result=$adb->query($sql2);
-
-			if($_REQUEST['mode'] == 'edit')
-			{
-				if($id != '' && $_REQUEST['fileid'] != '')
-				{
-					$delquery = 'delete from vtiger_seattachmentsrel where crmid = '.$id.' and attachmentsid = '.$_REQUEST['fileid'];
-					$adb->query($delquery);
-				}
-			}
-			if($module == 'Notes')
-			{
-				$query = "delete from vtiger_seattachmentsrel where crmid = ".$id;
-				$adb->query($query);
-			}
-			$sql3='insert into vtiger_seattachmentsrel values('.$id.','.$current_id.')';
-			$adb->query($sql3);
-
-			return true;
-		}
-		else
-		{
-			$log->debug("Skip the save attachment process.");
-			return false;
-		}
-	}
-
-	/** Function to insert values in the vtiger_crmentity for the specified module
-  	  * @param $module -- module:: Type varchar
- 	 */	
-
-  function insertIntoCrmEntity($module)
-  {
-	global $adb;
-	global $current_user;
-	global $log;
-                
-	$date_var = date('YmdHis');
-	if($_REQUEST['assigntype'] == 'T')
-	{
-		$ownerid= 0;
-	}
-	else
-	{
-		$ownerid = $this->column_fields['assigned_user_id'];
-	}
-                
-	if($module == 'Products' || $module == 'Notes' || $module =='Faq' || $module == 'Vendors' || $module == 'PriceBooks')
-	{
-		$log->info("module is =".$module);
-		$ownerid = $current_user->id;
-	}
-	if($module == 'Events')
-	{
-		$module = 'Calendar';
-	}
-	if($this->mode == 'edit')
-	{
-		$description_val = from_html($adb->formatString("vtiger_crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
-
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		$tabid = getTabid($module);
-		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
-		{
-			$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
-		}
-		else
-		{
-			$profileList = getCurrentUserProfileList();
-			$perm_qry = "SELECT columnname FROM vtiger_field INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid = vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid = vtiger_field.fieldid WHERE vtiger_field.tabid = ".$tabid." AND vtiger_profile2field.visible = 0 AND vtiger_profile2field.profileid IN ".$profileList." AND vtiger_def_org_field.visible = 0 and vtiger_field.tablename='vtiger_crmentity' and vtiger_field.displaytype in (1,3);";
-			$perm_result = $adb->query($perm_qry);
-			$perm_rows = $adb->num_rows($perm_result);
-			for($i=0; $i<$perm_rows; $i++)
-			{
-				$columname[]=$adb->query_result($perm_result,$i,"columnname");
-			}
-			if(is_array($columname) && in_array("description",$columname))
-			{
-				$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.",description=".$description_val.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
-			}
-			else
-			{
-				$sql = "update vtiger_crmentity set smownerid=".$ownerid.",modifiedby=".$current_user->id.", modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid=".$this->id;
-			}
-		}
-		$adb->query($sql);
-		$sql1 ="delete from vtiger_ownernotify where crmid=".$this->id;
-		$adb->query($sql1);
-		if($ownerid != $current_user->id)
-		{
-			$sql1 = "insert into vtiger_ownernotify values(".$this->id.",".$ownerid.",null)";
-			$adb->query($sql1);
-		}
-	}
-	else
-	{
-		//if this is the create mode and the group allocation is chosen, then do the following
-		$current_id = $adb->getUniqueID("vtiger_crmentity");
-		$_REQUEST['currentid']=$current_id;
-
-		$description_val = from_html($adb->formatString("vtiger_crmentity","description",$this->column_fields['description']),($insertion_mode == 'edit')?true:false);
-		$sql = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('".$current_id."','".$current_user->id."','".$ownerid."','".$module."',".$description_val.",".$adb->formatDate($date_var).",".$adb->formatDate($date_var).")";
-		$adb->query($sql);
-		$this->id = $current_id;
-
-		//set the organization relation for this entity
-		//default value: The current selected organization
-		$orglist = array();
-		if( isset($_SESSION['authenticated_user_current_organization']) && $_SESSION['authenticated_user_current_organization'] != '') {
-		    $orglist[0] = $_SESSION['authenticated_user_current_organization'];
-		} else {
-		    global $current_organization;
-		    $orglist[0] = $current_organization;
-		}
-
-		//if we still have not got some organization
-		if( count( $orglist) < 0) {
-		    $log->info("crmid ".$this->id." is not explizitely related to any organization");
-		    $sql = "select organizationname from vtiger_organizationdetails where deleted=0";
-		    $result = $adb->query($sql);
-		    $orglist[0]=$adb->query_result($result,$i,"organizationname");
-		}
-		if( count( $orglist) < 0) {
-		    $log->fatal("crmid ".$this->id." is not related to any organization");
-		}
-
-		//set up the relations in the database
-		foreach($orglist as $org) {
-		    $sql = "insert into vtiger_entity2org (crmid,organizationname,primarytag) values (".$this->id.",'".$org."',1)";
-		    $adb->query($sql);
-		}
-	}
-
-    }
-
-	/** Function to insert values in the vtiger_entity2org relation
-	 *  @param $crmid -- CRM id
-	 *  @param $module -- module object
-	 */
-	function insertIntoEntity2Org($crmid,$module)
-	{
-	    global $current_organization;
-	    global $log;
-
-	    $log->debug( "Entering insertIntoEntity2Org for crmid=".$crmid." module=".$module);
-
-	    // parameters
-	    if( isset( $crmid) && $crmid != '' &&
-		isset( $this->column_fields["otherorgs"]) && $this->column_fields["otherorgs"] != '') {
-
-		// the organization list is the current users organization plus
-		// the other organizations stored in the modules parameters
-		if( is_array( $this->column_fields["otherorgs"])) {
-		    // As array when enetered in EditView
-		    $orglist = array();
-		    foreach( array_keys( $this->column_fields["otherorgs"]) as $key)
-			$orglist[] = $this->column_fields["otherorgs"][$key];
-		} else {
-		    // As string when entered in DetailView
-		    $orglist = explode( ' |##| ', $this->column_fields["otherorgs"]);
-		}
-		$orglist[] = $current_organization;
-
-		// get the current list of assignments
-		$sql = "SELECT organizationname,primarytag FROM vtiger_entity2org WHERE crmid='".$crmid."'";
-		$result = $this->db->query($sql);
-		$delete = array();
-		$noofrows = $this->db->num_rows($result);
-
-		for( $i=0; $i<$noofrows; $i++) {
-		    $organizationname = $this->db->query_result($result,$i,"organizationname");
-		    // If this organization is part of the $orglist array we'll
-		    // just keept it.
-		    for( $j=0; $j<count($orglist); $j++) {
-			if( $orglist[$j] == $organizationname) {
-			    array_splice( $orglist, $j, 1);
-			    continue 2;
-			}
-		    }
-
-		    // So the relation defined in the database is to be removed
-		    // Do not remove primary organizations
-		    $primary = $this->db->query_result($result,$i,"primarytag");
-		    if( $primary == 0)
-			$delete[] = $organizationname;
-		}
-
-		// Now we have two arrays $delete and $orglist defining the 
-		// required database modification
-		$delstr = "";
-		foreach( $delete as $org) {
-		    if( $delstr == "") 
-			$delstr = "'".$org."'";
-		    else
-			$delstr .= ",'".$org."'";
-		}
-		if( $delstr != '') {
-		    $sql = "DELETE from vtiger_entity2org WHERE crmid='".$crmid."'
-			       AND organizationname IN (".$delstr.")";
-		    $result = $this->db->query($sql);
-		}
-
-		foreach( $orglist as $org) {
-		    $sql = "INSERT INTO vtiger_entity2org (crmid,organizationname,primarytag)
-			       VALUES ('".$crmid."','".$org."',0)";
-		    $result = $this->db->query($sql);
-		}
-	    }
-
-	    $log->debug( "Exit from insertIntoEntity2Org for crmid=".$crmid." module=".$module);
-	}
-
-
-	/** Function to insert values in the specifed table for the specified module
-  	  * @param $table_name -- table name:: Type varchar
-  	  * @param $module -- module:: Type varchar
- 	 */
-  function insertIntoEntityTable($table_name, $module)
-  {
-	  global $log;
-  	  global $current_user;	  
-	   $log->info("function insertIntoEntityTable ".$module.' vtiger_table name ' .$table_name);
-	  global $adb;
-	  $insertion_mode = $this->mode;
-
-	  //Checkin whether an entry is already is present in the vtiger_table to update
-	  if($insertion_mode == 'edit')
-	  {
-		  $check_query = "select * from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
-		  $check_result=$adb->query($check_query);
-
-		  $num_rows = $adb->num_rows($check_result);
-
-		  if($num_rows <= 0)
-		  {
-			  $insertion_mode = '';
-		  }	 
-	  }
-
-	  if($insertion_mode == 'edit')
-	  {
-		  $update = '';
-		  $tabid= getTabid($module);	
-		  require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		  if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
-		  {
-
-			  $sql = "select * from vtiger_field where tabid=".$tabid." and tablename='".$table_name."' and displaytype in (1,3)"; 
-		  }
-		  else
-		  {
-			  $profileList = getCurrentUserProfileList();
-			  $sql = "SELECT *
-			  FROM vtiger_field
-			  INNER JOIN vtiger_profile2field
-			  ON vtiger_profile2field.fieldid = vtiger_field.fieldid
-			  INNER JOIN vtiger_def_org_field
-			  ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
-			  WHERE vtiger_field.tabid = ".$tabid."
-			  AND vtiger_profile2field.visible = 0 
-			  AND vtiger_profile2field.profileid IN ".$profileList."
-			  AND vtiger_def_org_field.visible = 0 and vtiger_field.tablename='".$table_name."' and vtiger_field.displaytype in (1,3)";
-		  }	   
-
-	  }
-	  else
-	  {
-		  $column = $this->tab_name_index[$table_name];
-		  if($column == 'id' && $table_name == 'vtiger_users')
-		  {
-		 	$currentuser_id = $adb->getUniqueID("vtiger_users");
-			$this->id = $currentuser_id;
+
+	/** Function to insert values in the specifed table for the specified module
+  	  * @param $table_name -- table name:: Type varchar
+  	  * @param $module -- module:: Type varchar
+ 	 */
+  function insertIntoEntityTable($table_name, $module)
+  {
+	  global $log;
+  	  global $current_user;	  
+	   $log->info("function insertIntoEntityTable ".$module.' vtiger_table name ' .$table_name);
+	  global $adb;
+	  $insertion_mode = $this->mode;
+
+	  //Checkin whether an entry is already is present in the vtiger_table to update
+	  if($insertion_mode == 'edit')
+	  {
+		  $check_query = "select * from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
+		  $check_result=$adb->query($check_query);
+
+		  $num_rows = $adb->num_rows($check_result);
+
+		  if($num_rows <= 0)
+		  {
+			  $insertion_mode = '';
+		  }	 
+	  }
+
+	  if($insertion_mode == 'edit')
+	  {
+		  $update = '';
+		  $tabid= getTabid($module);
+	  	  if($tabid == 9)
+	          	$tabid ="9,16";	  
+		  require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		  if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
+		  {
+
+			  $sql = "select * from vtiger_field where tabid in (".$tabid.") and tablename='".$table_name."' and displaytype in (1,3)"; 
+		  }
+		  else
+		  {
+			  $profileList = getCurrentUserProfileList();
+			  $sql = "SELECT *
+			  FROM vtiger_field
+			  INNER JOIN vtiger_profile2field
+			  ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+			  INNER JOIN vtiger_def_org_field
+			  ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+			  WHERE vtiger_field.tabid in (".$tabid.")
+			  AND vtiger_profile2field.visible = 0 
+			  AND vtiger_profile2field.profileid IN ".$profileList."
+			  AND vtiger_def_org_field.visible = 0 and vtiger_field.tablename='".$table_name."' and vtiger_field.displaytype in (1,3)";
+		  }	   
+
+	  }
+	  else
+	  {
+		  $column = $this->tab_name_index[$table_name];
+		  if($column == 'id' && $table_name == 'vtiger_users')
+		  {
+		 	$currentuser_id = $adb->getUniqueID("vtiger_users");
+			$this->id = $currentuser_id;
 		  } elseif( $column == 'orgunitid' && $table_name == 'vtiger_orgunit') {
 			$this->id = $adb->getUniqueID("vtiger_orgunit");
-		  }
-		  $value = $this->id;
-	  	  $tabid= getTabid($module);	
-		  $sql = "select * from vtiger_field where tabid=".$tabid." and tablename='".$table_name."' and displaytype in (1,3,4)"; 
-	  }
+		  }
+		  $value = $this->id;
+	  	  $tabid= getTabid($module);	
+		  $sql = "select * from vtiger_field where tabid=".$tabid." and tablename='".$table_name."' and displaytype in (1,3,4)"; 
+	  }
+
+	  $result = $adb->query($sql);
+	  $noofrows = $adb->num_rows($result);
+	  for($i=0; $i<$noofrows; $i++)
+	  {
+		  $fieldname=$adb->query_result($result,$i,"fieldname");
+		  $columname=$adb->query_result($result,$i,"columnname");
+		  $uitype=$adb->query_result($result,$i,"uitype");
 
-	  $result = $adb->query($sql);
-	  $noofrows = $adb->num_rows($result);
-	  for($i=0; $i<$noofrows; $i++)
-	  {
-		  $fieldname=$adb->query_result($result,$i,"fieldname");
-		  $columname=$adb->query_result($result,$i,"columnname");
-		  $uitype=$adb->query_result($result,$i,"uitype");
-
-		  if(isset($this->column_fields[$fieldname]))
-		  {
-			  if($uitype == 56)
-			  {
-				  if($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1)
-				  {
-					  $fldvalue = 1;
-				  }
-				  else
-				  {
-					  $fldvalue = 0;
-				  }
-
-			  }
+		  if(isset($this->column_fields[$fieldname]))
+		  {
+			  if($uitype == 56)
+			  {
+				  if($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1)
+				  {
+					  $fldvalue = 1;
+				  }
+				  else
+				  {
+					  $fldvalue = 0;
+				  }
+
+			  }
 			  // Added for inheritance and extensions fields
 			  elseif( $uitype == '3' || $uitype == '4' || $uitype == '18' ||
 			      $uitype == '31' || $uitype == '32') {
@@ -497,675 +521,593 @@
 				  $this->column_fields[$fieldname."@##@"] == 1) 
 				  $fldvalue = "@##@".$fldvalue;
 			  }
-			  elseif($uitype == 33)
-			  {
-  				if(is_array($this->column_fields[$fieldname]))
-  				{
-  				  $field_list = implode(' |##| ',$this->column_fields[$fieldname]);
-  				}else
-  				{
-  				  $field_list = $this->column_fields[$fieldname];
-          		}
-  				$fldvalue = $field_list;
-			  }
-			  elseif($uitype == 5 || $uitype == 6 || $uitype ==23)
-			  {
+			  elseif($uitype == 33)
+			  {
+  				if(is_array($this->column_fields[$fieldname]))
+  				{
+  				  $field_list = implode(' |##| ',$this->column_fields[$fieldname]);
+  				}else
+  				{
+  				  $field_list = $this->column_fields[$fieldname];
+          		}
+  				$fldvalue = $field_list;
+			  }
+			  elseif($uitype == 5 || $uitype == 6 || $uitype ==23)
+			  {
 				  if($_REQUEST['action'] == 'Import' ||
-				     ereg("^".$module."Ajax",$_REQUEST['action']))
-				  {
-					  $fldvalue = $this->column_fields[$fieldname];
-				  }
-				  else
-				  {
-					  $fldvalue = getDBInsertDateValue($this->column_fields[$fieldname]);
-				  }
-			  }
-			  elseif($uitype == 7)
-			  {
-				  //strip out the spaces and commas in numbers if given ie., in amounts there may be ,
-				  $fldvalue = str_replace(",","",$this->column_fields[$fieldname]);//trim($this->column_fields[$fieldname],",");
-
-			  }
-			  else
-			  {
-				  $fldvalue = $this->column_fields[$fieldname]; 
-				  $fldvalue = stripslashes($fldvalue);
-			  }
-			  $fldvalue = from_html($adb->formatString($table_name,$columname,$fldvalue),($insertion_mode == 'edit')?true:false);
-		  }
-		  else
-		  {
-			  $fldvalue = '';
-		  }
-		  if($fldvalue=='') $fldvalue ="NULL";
-		  if($insertion_mode == 'edit')
-		  {
-			  if($table_name == 'vtiger_notes' && $columname == 'filename' && $_FILES['filename']['name'] == '')
-			  {
-				  $fldvalue = $this->getOldFileName($this->id);
-			  }
-			  if($table_name != 'vtiger_ticketcomments')
-			  {
-				  if($i == 0)
-				  {
-					  $update = $columname."=".$fldvalue."";
-				  }
-				  else
-				  {
-					  $update .= ', '.$columname."=".$fldvalue."";
-				  }
-			  }
-		  }
-		  else
-		  {
-			  $column .= ", ".$columname;
-			  $value .= ", ".$fldvalue."";
-		  }
-
-	  }
-
-
-
-
-
-	  if($insertion_mode == 'edit')
-	  {
-		  if($_REQUEST['module'] == 'Potentials')
-		  {
-			  $dbquery = 'select sales_stage from vtiger_potential where potentialid = '.$this->id;
-			  $sales_stage = $adb->query_result($adb->query($dbquery),0,'sales_stage');
-			  if($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '')
-			  {
-				  $date_var = date('YmdHis');
-				  $closingdate = getDBInsertDateValue($this->column_fields['closingdate']);
-				  $sql = "insert into vtiger_potstagehistory values('',".$this->id.",'".$this->column_fields['amount']."','".$sales_stage."','".$this->column_fields['probability']."',0,".$adb->formatString("vtiger_potstagehistory","closedate",$closingdate).",".$adb->formatString("vtiger_potstagehistory","lastmodified",$date_var).")";
-				  $adb->query($sql);
-			  }
-		  }
-		  elseif($_REQUEST['module'] == 'PurchaseOrder' || $_REQUEST['module'] == 'SalesOrder' || $_REQUEST['module'] == 'Quotes' || $_REQUEST['module'] == 'Invoice')
-		  {
-			  //added to update the history for PO, SO, Quotes and Invoice
-			  $history_field_array = Array(
-				  			"PurchaseOrder"=>"postatus",
-							"SalesOrder"=>"sostatus",
-							"Quotes"=>"quotestage",
-							"Invoice"=>"invoicestatus"
-						      );
-
-			  $inventory_module = $_REQUEST['module'];
-
-			  if($_REQUEST['ajxaction'] == 'DETAILVIEW')//if we use ajax edit
-			  {
-				  if($inventory_module == "PurchaseOrder")
-					  $relatedname = getVendorName($this->column_fields['vendor_id']);
-				  else
-				  	$relatedname = getAccountName($this->column_fields['account_id']);
-
-				  $total = $this->column_fields['hdnGrandTotal'];
-			  }
-			  else//using edit button and save
-			  {
-			  	if($inventory_module == "PurchaseOrder")
-			  		$relatedname = $_REQUEST["vendor_name"];
-			  	else
-			  		$relatedname = $_REQUEST["account_name"];
-
-				$total = $_REQUEST['total'];
-			  }
-
-			  $oldvalue = getSingleFieldValue($this->table_name,$history_field_array[$inventory_module],$this->module_id,$this->id);
-			  if($oldvalue != $this->column_fields["$history_field_array[$inventory_module]"])
-			  {
-				  addInventoryHistory($inventory_module, $this->id,$relatedname,$total,$this->column_fields["$history_field_array[$inventory_module]"]);
-			  }
-		  }
-
-		  //Check done by Don. If update is empty the the query fails
-		  if(trim($update) != '')
-        	  {
-		  	$sql1 = "update ".$table_name." set ".$update." where ".$this->tab_name_index[$table_name]."=".$this->id;
-
-		  	$adb->query($sql1); 
-		  }
-		  //to disable the update of groupentity relation in ajax edit for the fields except assigned_user_id field
-		  if($_REQUEST['ajxaction'] != 'DETAILVIEW' || ($_REQUEST['ajxaction'] == 'DETAILVIEW' && $_REQUEST['fldName'] == 'assigned_user_id'))
-		  {	  
-			  if($_REQUEST['assigntype'] == 'T')
-			  {
-				  $groupname = $_REQUEST['assigned_group_name'];
-				  //echo 'about to update lead group relation';
-				  if($module == 'Leads' && $table_name == 'vtiger_leaddetails')
-				  {
-					  updateLeadGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'Accounts' && $table_name == 'vtiger_account')
-				  {
-					  updateAccountGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'Contacts' && $table_name == 'vtiger_contactdetails')
-				  {
-					  updateContactGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'Potentials' && $table_name == 'vtiger_potential')
-				  {
-					  updatePotentialGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'Quotes' && $table_name == 'vtiger_quotes')
-				  {
-					  updateQuoteGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'SalesOrder' && $table_name == 'vtiger_salesorder')
-				  {
-					  updateSoGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'Invoice' && $table_name == 'vtiger_invoice')
-				  {
-					  updateInvoiceGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'PurchaseOrder' && $table_name == 'vtiger_purchaseorder')
-				  {
-					  updatePoGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'HelpDesk' && $table_name == 'vtiger_troubletickets')
-				  {
-					  updateTicketGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module == 'Campaigns' && $table_name == 'vtiger_campaign')
-				  {
-					  updateCampaignGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module =='Calendar' || $module =='Events' || $module == 'Emails')
-				  {
-					  if($table_name == 'vtiger_activity')
-					  {
-						  updateActivityGroupRelation($this->id,$groupname);
-					  }
-				  }
-
-
-			  }
-			  else
-			  {
-				  //echo 'about to update lead group relation again!';
-				  if($module == 'Leads' && $table_name == 'vtiger_leaddetails')
-				  {
-					  updateLeadGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'Accounts' && $table_name == 'vtiger_account')
-				  {
-					  updateAccountGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'Contacts' && $table_name == 'vtiger_contactdetails')
-				  {
-					  updateContactGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'Potentials' && $table_name == 'vtiger_potential')
-				  {
-					  updatePotentialGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'Quotes' && $table_name == 'vtiger_quotes')
-				  {
-					  updateQuoteGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'SalesOrder' && $table_name == 'vtiger_salesorder')
-				  {
-					  updateSoGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'Invoice' && $table_name == 'vtiger_invoice')
-				  {
-					  updateInvoiceGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'PurchaseOrder' && $table_name == 'vtiger_purchaseorder')
-				  {
-					  updatePoGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'HelpDesk' && $table_name == 'vtiger_troubletickets')
-				  {
-					  updateTicketGroupRelation($this->id,'');
-				  }
-				  elseif($module == 'Campaigns' && $table_name == 'vtiger_campaign')
-				  {
-					  updateCampaignGroupRelation($this->id,$groupname);
-				  }
-				  elseif($module =='Calendar' || $module =='Events' || $module == 'Emails')
-				  {
-					  if($table_name == 'vtiger_activity')
-					  {
-						  updateActivityGroupRelation($this->id,$groupname);
-					  }
-				  }
-
-
-			  }
-		  }
-
-	  }
-	  else
-	  {	
-		  $sql1 = "insert into ".$table_name." (".$column.") values(".$value.")";
-		  $adb->query($sql1); 
-		  $groupname = $_REQUEST['assigned_group_name'];
-		  if($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_leaddetails')
-		  {
-			  insert2LeadGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_account')
-		  {
-			  insert2AccountGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_contactdetails')
-		  {
-			  insert2ContactGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_potential')
-		  {
-			  insert2PotentialGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_quotes')
-		  {
-			  insert2QuoteGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_salesorder')
-		  {
-			  insert2SoGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_invoice')
-		  {
-			  insert2InvoiceGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_purchaseorder')
-		  {
-			  insert2PoGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_activity') 
-		  {
-			  insert2ActivityGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_troubletickets') 
-		  {
-			  insert2TicketGroupRelation($this->id,$groupname);
-		  }
-		  elseif($_REQUEST['assigntype'] == 'T' && $table_name == 'vtiger_campaign')
-		  {
-			  insert2CampaignGroupRelation($this->id,$groupname);
-		  }
-
-	  }
-
-  }
-	/** Function to delete a record in the specifed table 
-  	  * @param $table_name -- table name:: Type varchar
-	  * The function will delete a record .The id is obtained from the class variable $this->id and the columnname got from $this->tab_name_index[$table_name]
- 	 */
-function deleteRelation($table_name)
-{
-         global $adb;
-         $check_query = "select * from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
-         $check_result=$adb->query($check_query);
-         $num_rows = $adb->num_rows($check_result);
-
-         if($num_rows == 1)
-         {
-                $del_query = "DELETE from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
-                $adb->query($del_query);
-         }
-
-}
-	/** Function to attachment filename of the given entity 
-  	  * @param $notesid -- crmid:: Type Integer
-	  * The function will get the attachmentsid for the given entityid from vtiger_seattachmentsrel table and get the attachmentsname from vtiger_attachments table 
-	  * returns the 'filename'
- 	 */
-function getOldFileName($notesid)
-{
-	   global $log;
-$log->info("in getOldFileName  ".$notesid);
-	global $adb;
-	$query1 = "select * from vtiger_seattachmentsrel where crmid=".$notesid;
-	$result = $adb->query($query1);
-	$noofrows = $adb->num_rows($result);
-	if($noofrows != 0)
-		$attachmentid = $adb->query_result($result,0,'attachmentsid');
-	if($attachmentid != '')
-	{
-		$query2 = "select * from vtiger_attachments where attachmentsid=".$attachmentid;
-		$filename = $adb->query_result($adb->query($query2),0,'name');
+				     ereg("^".$module."Ajax",$_REQUEST['action']))
+				  {
+					  $fldvalue = $this->column_fields[$fieldname];
+				  }
+				  else
+				  {
+					  //Added to avoid function call getDBInsertDateValue in ajax save
+					  $fldvalue = (($_REQUEST['ajxaction'] == 'DETAILVIEW')?$this->column_fields[$fieldname]:getDBInsertDateValue($this->column_fields[$fieldname]));
+				  }
+			  }
+			  elseif($uitype == 7)
+			  {
+				  //strip out the spaces and commas in numbers if given ie., in amounts there may be ,
+				  $fldvalue = str_replace(",","",$this->column_fields[$fieldname]);//trim($this->column_fields[$fieldname],",");
+
+			  }
+			  else
+			  {
+				  $fldvalue = $this->column_fields[$fieldname]; 
+				  $fldvalue = stripslashes($fldvalue);
+			  }
+			  $fldvalue = from_html($adb->formatString($table_name,$columname,$fldvalue),($insertion_mode == 'edit')?true:false);
+		  }
+		  else
+		  {
+			  $fldvalue = '';
+		  }
+		  if( is_string($fldvalue) && $fldvalue == '')
+		      $fldvalue ="NULL";
+		  if($insertion_mode == 'edit')
+		  {
+			  if($table_name == 'vtiger_notes' && $columname == 'filename' && $_FILES['filename']['name'] == '')
+			  {
+				  $fldvalue = $this->getOldFileName($this->id);
+			  }
+			  if($table_name != 'vtiger_ticketcomments')
+			  {
+				  if($i == 0)
+				  {
+					  $update = $columname."=".$fldvalue."";
+				  }
+				  else
+				  {
+					  $update .= ', '.$columname."=".$fldvalue."";
+				  }
+			  }
+		  }
+		  else
+		  {
+			  $column .= ", ".$columname;
+			  $value .= ", ".$fldvalue."";
+		  }
+
+	  }
+
+
+
+
+
+	  if($insertion_mode == 'edit')
+	  {
+		  if($_REQUEST['module'] == 'Potentials')
+		  {
+			  $dbquery = 'select sales_stage from vtiger_potential where potentialid = '.$this->id;
+			  $sales_stage = $adb->query_result($adb->query($dbquery),0,'sales_stage');
+			  if($sales_stage != $_REQUEST['sales_stage'] && $_REQUEST['sales_stage'] != '')
+			  {
+				  $date_var = date('YmdHis');
+				  $closingdate = getDBInsertDateValue($this->column_fields['closingdate']);
+				  $sql = "insert into vtiger_potstagehistory values('',".$this->id.",'".$this->column_fields['amount']."','".$sales_stage."','".$this->column_fields['probability']."',0,".$adb->formatString("vtiger_potstagehistory","closedate",$closingdate).",".$adb->formatString("vtiger_potstagehistory","lastmodified",$date_var).")";
+				  $adb->query($sql);
+			  }
+		  }
+		  elseif($_REQUEST['module'] == 'PurchaseOrder' || $_REQUEST['module'] == 'SalesOrder' || $_REQUEST['module'] == 'Quotes' || $_REQUEST['module'] == 'Invoice')
+		  {
+			  //added to update the history for PO, SO, Quotes and Invoice
+			  $history_field_array = Array(
+				  			"PurchaseOrder"=>"postatus",
+							"SalesOrder"=>"sostatus",
+							"Quotes"=>"quotestage",
+							"Invoice"=>"invoicestatus"
+						      );
+
+			  $inventory_module = $_REQUEST['module'];
+
+			  if($_REQUEST['ajxaction'] == 'DETAILVIEW')//if we use ajax edit
+			  {
+				  if($inventory_module == "PurchaseOrder")
+					  $relatedname = getVendorName($this->column_fields['vendor_id']);
+				  else
+				  	$relatedname = getAccountName($this->column_fields['account_id']);
+
+				  $total = $this->column_fields['hdnGrandTotal'];
+			  }
+			  else//using edit button and save
+			  {
+			  	if($inventory_module == "PurchaseOrder")
+			  		$relatedname = $_REQUEST["vendor_name"];
+			  	else
+			  		$relatedname = $_REQUEST["account_name"];
+
+				$total = $_REQUEST['total'];
+			  }
+
+			  $oldvalue = getSingleFieldValue($this->table_name,$history_field_array[$inventory_module],$this->module_id,$this->id);
+			  if($oldvalue != $this->column_fields["$history_field_array[$inventory_module]"])
+			  {
+				  addInventoryHistory($inventory_module, $this->id,$relatedname,$total,$this->column_fields["$history_field_array[$inventory_module]"]);
+			  }
+		  }
+
+		  //Check done by Don. If update is empty the the query fails
+		  if(trim($update) != '')
+        	  {
+		  	$sql1 = "update ".$table_name." set ".$update." where ".$this->tab_name_index[$table_name]."=".$this->id;
+
+		  	$adb->query($sql1); 
+		  }
+		  
+
+	  }
+	  else
+	  {
+		  $sql1 = "insert into ".$table_name." (".$column.") values(".$value.")";
+		  $adb->query($sql1); 
+		  
+
+	  }
+
+  }
+
+function whomToSendMail($module,$insertion_mode,$assigntype)
+{
+ global $adb;
+       if($insertion_mode!="edit")
+       {
+               if($assigntype=='U')
+               {
+                       if($module == 'Events' || $module == 'Calendar')
+                       {
+                               $moduleObj=new Activity();
+                       }else
+                       {
+                               $moduleObj=new $module();
+                       }
+                       sendNotificationToOwner($module,$moduleObj);
+               }
+               elseif($assigntype=='T')
+               {
+                       $groupname=$_REQUEST['assigned_group_name'];
+                       $resultqry=$adb->query("select groupid from vtiger_groups where groupname='".$groupname."'");
+                       $groupid=$adb->query_result($resultqry,0,"groupid");
+                       sendNotificationToGroups($groupid,$this->id,$module);
+               }
+       }
+}
+
+
+	/** Function to delete a record in the specifed table 
+  	  * @param $table_name -- table name:: Type varchar
+	  * The function will delete a record .The id is obtained from the class variable $this->id and the columnname got from $this->tab_name_index[$table_name]
+ 	 */
+function deleteRelation($table_name)
+{
+         global $adb;
+         $check_query = "select * from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
+         $check_result=$adb->query($check_query);
+         $num_rows = $adb->num_rows($check_result);
+
+         if($num_rows == 1)
+         {
+                $del_query = "DELETE from ".$table_name." where ".$this->tab_name_index[$table_name]."=".$this->id;
+                $adb->query($del_query);
+         }
+
+}
+	/** Function to attachment filename of the given entity 
+  	  * @param $notesid -- crmid:: Type Integer
+	  * The function will get the attachmentsid for the given entityid from vtiger_seattachmentsrel table and get the attachmentsname from vtiger_attachments table 
+	  * returns the 'filename'
+ 	 */
+function getOldFileName($notesid)
+{
+	   global $log;
+$log->info("in getOldFileName  ".$notesid);
+	global $adb;
+	$query1 = "select * from vtiger_seattachmentsrel where crmid=".$notesid;
+	$result = $adb->query($query1);
+	$noofrows = $adb->num_rows($result);
+	if($noofrows != 0)
+		$attachmentid = $adb->query_result($result,0,'attachmentsid');
+	if($attachmentid != '')
+	{
+		$query2 = "select * from vtiger_attachments where attachmentsid=".$attachmentid;
+		$filename = $adb->query_result($adb->query($query2),0,'name');
+	}
+	return "'".$filename."'";
+}
+	
+	
+	
+
+
+
+
+
+// Code included by Jaguar - Ends 
+
+	/** Function to retrive the information of the given recordid ,module 
+  	  * @param $record -- Id:: Type Integer
+  	  * @param $module -- module:: Type varchar
+	  * This function retrives the information from the database and sets the value in the class columnfields array
+ 	 */
+  function retrieve_entity_info($record, $module)
+  {
+    global $adb,$log,$app_strings;
+    $result = Array();
+    foreach($this->tab_name_index as $table_name=>$index)
+    {
+	if( $module == 'Organization') {
+	    $result[$table_name] = $adb->query("select * from ".$table_name." where ".$index."='".$record."'");
+	} elseif( $module == 'OrgUnit' ) {
+	    $result[$table_name] = $adb->query("select * from ".$table_name." where ".$index."=".$record);
+	} else {
+	    $result[$table_name] = $adb->query("select * from ".$table_name." where ".$index."=".$record);
+	    if($adb->query_result($result["vtiger_crmentity"],0,"deleted") == 1)
+	    die("<br><br><center>".$app_strings['LBL_RECORD_DELETE']." <a href='javascript:window.history.back()'>".$app_strings['LBL_GO_BACK'].".</a></center>");
 	}
-	return "'".$filename."'";
-}
-	
-	
-	
-
-
-
-
-
-// Code included by Jaguar - Ends 
-
-	/** Function to retrive the information of the given recordid ,module 
-  	  * @param $record -- Id:: Type Integer
-  	  * @param $module -- module:: Type varchar
-	  * This function retrives the information from the database and sets the value in the class columnfields array
- 	 */
-  function retrieve_entity_info($record, $module)
-  {
-    global $adb,$log,$app_strings;
-    $result = Array();
-    foreach($this->tab_name_index as $table_name=>$index)
-    {
-	if( $module == 'Organization') {
-	    $result[$table_name] = $adb->query("select * from ".$table_name." where ".$index."='".$record."'");
-	} elseif( $module == 'OrgUnit' ) {
-	    $result[$table_name] = $adb->query("select * from ".$table_name." where ".$index."=".$record);
-	} else {
-	    $result[$table_name] = $adb->query("select * from ".$table_name." where ".$index."=".$record);
-	    if($adb->query_result($result["vtiger_crmentity"],0,"deleted") == 1)
-	    die("<br><br><center>".$app_strings['LBL_RECORD_DELETE']." <a href='javascript:window.history.back()'>".$app_strings['LBL_GO_BACK'].".</a></center>");
-	}
-    }
-    $tabid = getTabid($module);
-    $sql1 =  "select * from vtiger_field where tabid=".$tabid;
-    $result1 = $adb->query($sql1);
-    $noofrows = $adb->num_rows($result1);
-    for($i=0; $i<$noofrows; $i++)
-    {
-      $fieldcolname = $adb->query_result($result1,$i,"columnname");
-      $tablename = $adb->query_result($result1,$i,"tablename");
-      $fieldname = $adb->query_result($result1,$i,"fieldname");
-      $uitype = $adb->query_result($result1,$i,"uitype");
-
-      // vtiger_entity2org results in a list value
-      if( $tablename == 'vtiger_entity2org') {
-	  $fld_value = array();
-	  $nooforgs = $adb->num_rows( $result[$tablename]);
-	  for($o=0; $o<$nooforgs; $o++) {
-	      $fld_value[$adb->query_result($result[$tablename],$o,'organizationname')] = 
-		  $adb->query_result($result[$tablename],$o,'primarytag');
-	  }
-      } else {
-	  $fld_value = $adb->query_result($result[$tablename],0,$fieldcolname);
-      }
-
-      // Added for inheritance and extensions fields
-      if( $uitype == '3' || $uitype == '4' || $uitype == '18' ||
-	  $uitype == '31' || $uitype == '32') {
-	  if( substr( $fld_value, 0, 4) == "@##@") {
-	      $this->column_fields[$fieldname."@##@"] = 1;
-	      $fld_value = substr( $fld_value, 4, strlen( $fld_value)-4);
-	  } else {
-	      $this->column_fields[$fieldname."@##@"] = 0;
-	  }
-      }
-      $this->column_fields[$fieldname] = $fld_value;
-				
-    }
-	if($module == 'Users')
-	{
-		for($i=0; $i<$noofrows; $i++)
-		{
-			$fieldcolname = $adb->query_result($result1,$i,"columnname");
-			$tablename = $adb->query_result($result1,$i,"tablename");
-			$fieldname = $adb->query_result($result1,$i,"fieldname");
-			$fld_value = $adb->query_result($result[$tablename],0,$fieldcolname);
-			$this->$fieldname = $fld_value;
-
-		}
-	}
-		
-    $this->column_fields["record_id"] = $record;
-    $this->column_fields["record_module"] = $module;
-  }
-
-	/** Function to saves the values in all the tables mentioned in the class variable $tab_name for the specified module
-  	  * @param $module -- module:: Type varchar
- 	 */
-	function save($module_name) 
-	{
-		global $log;
-	        $log->debug("module name is ".$module_name);
-		//GS Save entity being called with the modulename as parameter
-		$this->saveentity($module_name);
-	}
-  
-	function process_list_query($query, $row_offset, $limit= -1, $max_per_page = -1)
-	{
-		global $list_max_entries_per_page;
-		$this->log->debug("process_list_query: ".$query);
-		if(!empty($limit) && $limit != -1){
-			$result =& $this->db->limitQuery($query, $row_offset + 0, $limit,true,"Error retrieving $this->object_name list: ");
-		}else{
-			$result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
-		}
-
-		$list = Array();
-		if($max_per_page == -1){
-			$max_per_page 	= $list_max_entries_per_page;
-		}
-		$rows_found =  $this->db->getRowCount($result);
-
-		$this->log->debug("Found $rows_found ".$this->object_name."s");
-                
-		$previous_offset = $row_offset - $max_per_page;
-		$next_offset = $row_offset + $max_per_page;
-
-		if($rows_found != 0)
-		{
-
-			// We have some data.
-
-			for($index = $row_offset , $row = $this->db->fetchByAssoc($result, $index); $row && ($index < $row_offset + $max_per_page || $max_per_page == -99) ;$index++, $row = $this->db->fetchByAssoc($result, $index)){
-
-				
-				foreach($this->list_fields as $entry)
-				{
-
-					foreach($entry as $key=>$field) // this will be cycled only once
-					{						
-						if (isset($row[$field])) {
-							$this->column_fields[$this->list_fields_names[$key]] = $row[$field];
-						
-						
-							$this->log->debug("$this->object_name({$row['id']}): ".$field." = ".$this->$field);
-						}
-						else 
-						{
-							$this->column_fields[$this->list_fields_names[$key]] = "";
-						}
-					}
-				}
-
-
-				//$this->db->println("here is the bug");
-				
-
-				$list[] = clone($this);//added by Richie to support PHP5
-			}
-		}
-
-		$response = Array();
-		$response['list'] = $list;
-		$response['row_count'] = $rows_found;
-		$response['next_offset'] = $next_offset;
-		$response['previous_offset'] = $previous_offset;
-
-		return $response;
-	}
-
-	function process_full_list_query($query)
-	{
-		$this->log->debug("CRMEntity:process_full_list_query");
-		$result =& $this->db->query($query, false);
-		$this->log->debug("CRMEntity:process_full_list_query: result is ".$result);
-
-
-		if($this->db->getRowCount($result) > 0){
-		
-		//	$this->db->println("process_full mid=".$this->module_id." mname=".$this->module_name);
-			// We have some data.
-			while ($row = $this->db->fetchByAssoc($result)) {				
-				$rowid=$row[$this->module_id];
-
-				if(isset($rowid))
-			       		$this->retrieve_entity_info($rowid,$this->module_name);
-				else
-					$this->db->println("rowid not set unable to retrieve");
-				 
-				 
-				
-		//clone function added to resolvoe PHP5 compatibility issue in Dashboards
-		//If we do not use clone, while using PHP5, the memory address remains fixed but the
-	//data gets overridden hence all the rows that come in bear the same value. This in turn
-//provides a wrong display of the Dashboard graphs. The data is erroneously shown for a specific month alone
-//Added by Richie
-				$list[] = clone($this);//added by Richie to support PHP5
-			}
-		}
-
-		if (isset($list)) return $list;
-		else return null;
-	}
-	
-	/** This function should be overridden in each module.  It marks an item as deleted.
-	* If it is not overridden, then marking this type of item is not allowed
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	*/
-	function mark_deleted($id)
-	{
-		$query = "UPDATE vtiger_crmentity set deleted=1 where crmid='$id'";
-		$this->db->query($query, true,"Error marking record deleted: ");
-
-
-	}
-
-
-	function retrieve_by_string_fields($fields_array, $encode=true) 
-	{ 
-		$where_clause = $this->get_where($fields_array);
-		
-		$query = "SELECT * FROM $this->table_name $where_clause";
-		$this->log->debug("Retrieve $this->object_name: ".$query);
-		$result =& $this->db->requireSingleResult($query, true, "Retrieving record $where_clause:");
-		if( empty($result)) 
-		{ 
-		 	return null; 
-		} 
-
-		 $row = $this->db->fetchByAssoc($result,-1, $encode);
-
-		foreach($this->column_fields as $field) 
-		{ 
-			if(isset($row[$field])) 
-			{ 
-				$this->$field = $row[$field];
-			}
-		} 
-		return $this;
-	}
-
-	// this method is called during an import before inserting a bean
-	// define an associative array called $special_fields
-	// the keys are user defined, and don't directly map to the bean's vtiger_fields
-	// the value is the method name within that bean that will do extra
-	// processing for that vtiger_field. example: 'full_name'=>'get_names_from_full_name'
-
-	function process_special_fields() 
-	{ 
-		foreach ($this->special_functions as $func_name) 
-		{ 
-			if ( method_exists($this,$func_name) ) 
-			{ 
-				$this->$func_name(); 
-			} 
-		} 
-	}
-
-	/**
-         * Function to check if the custom vtiger_field vtiger_table exists
-         * return true or false
-         */
-        function checkIfCustomTableExists($tablename)
-        {
-                $query = "select * from ".$tablename;
-                $result = $this->db->query($query);
-                $testrow = $this->db->num_fields($result);
-                if($testrow > 1)
-                {
-                        $exists=true;
-                }
-                else
-                {
-                        $exists=false;
-                }
-                return $exists;
-        }
-
-	/**
-	 * function to construct the query to fetch the custom vtiger_fields
-	 * return the query to fetch the custom vtiger_fields
-         */
-        function constructCustomQueryAddendum($tablename,$module)
-        {
-                global $adb;
-		$tabid=getTabid($module);		
-                $sql1 = "select columnname,fieldlabel from vtiger_field where generatedtype=2 and tabid=".$tabid;
-                $result = $adb->query($sql1);
-                $numRows = $adb->num_rows($result);
-                $sql3 = "select ";
-                for($i=0; $i < $numRows;$i++)
-                {
-                        $columnName = $adb->query_result($result,$i,"columnname");
-                        $fieldlable = $adb->query_result($result,$i,"fieldlabel");
-                        //construct query as below
-                        if($i == 0)
-                        {
-                                $sql3 .= $tablename.".".$columnName. " '" .$fieldlable."'";
-                        }
-                        else
-                        {
-                                $sql3 .= ", ".$tablename.".".$columnName. " '" .$fieldlable."'";
-                        }
-
-                }
-                if($numRows>0)
-                {
-                        $sql3=$sql3.',';
-                }
-                return $sql3;
-
-        }
-
-
-	/**
-	 * This function returns a full (ie non-paged) list of the current object type.  
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_full_list($order_by = "", $where = "") {
-		$this->log->debug("get_full_list:  order_by = '$order_by' and where = '$where'");
-		$query = $this->create_list_query($order_by, $where);
-		return $this->process_full_list_query($query);
-	}
-
-	/**
-	 * Track the viewing of a detail record.  This leverages get_summary_text() which is object specific
-	 * params $user_id - The user that is viewing the record.
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function track_view($user_id, $current_module,$id='')
-	{
-		$this->log->debug("About to call vtiger_tracker (user_id, module_name, item_id)($user_id, $current_module, $this->id)");
-
-		$tracker = new Tracker();
-		$tracker->track_view($user_id, $current_module, $id, '');
-	}
-
-	
-
-}
-?>
+    }
+    $tabid = getTabid($module);
+    $sql1 =  "select * from vtiger_field where tabid=".$tabid;
+    $result1 = $adb->query($sql1);
+    $noofrows = $adb->num_rows($result1);
+    for($i=0; $i<$noofrows; $i++)
+    {
+      $fieldcolname = $adb->query_result($result1,$i,"columnname");
+      $tablename = $adb->query_result($result1,$i,"tablename");
+      $fieldname = $adb->query_result($result1,$i,"fieldname");
+
+      $uitype = $adb->query_result($result1,$i,"uitype");
+
+      // vtiger_entity2org results in a list value
+      if( $tablename == 'vtiger_entity2org') {
+	  $fld_value = array();
+	  $nooforgs = $adb->num_rows( $result[$tablename]);
+	  for($o=0; $o<$nooforgs; $o++) {
+	      $fld_value[$adb->query_result($result[$tablename],$o,'organizationname')] = 
+		  $adb->query_result($result[$tablename],$o,'primarytag');
+	  }
+      } elseif( $tablename != 'vtiger_products2products_rel') {
+	  $fld_value = $adb->query_result($result[$tablename],0,$fieldcolname);
+      }
+
+      // Added for inheritance and extensions fields
+      if( $uitype == '3' || $uitype == '4' || $uitype == '18' ||
+	  $uitype == '31' || $uitype == '32') {
+	  if( substr( $fld_value, 0, 4) == "@##@") {
+	      $this->column_fields[$fieldname."@##@"] = 1;
+	      $fld_value = substr( $fld_value, 4, strlen( $fld_value)-4);
+	  } else {
+	      $this->column_fields[$fieldname."@##@"] = 0;
+	  }
+      }
+      $this->column_fields[$fieldname] = $fld_value;
+
+    }
+	if($module == 'Users')
+	{
+		for($i=0; $i<$noofrows; $i++)
+		{
+			$fieldcolname = $adb->query_result($result1,$i,"columnname");
+			$tablename = $adb->query_result($result1,$i,"tablename");
+			$fieldname = $adb->query_result($result1,$i,"fieldname");
+			$fld_value = $adb->query_result($result[$tablename],0,$fieldcolname);
+			$this->$fieldname = $fld_value;
+
+		}
+	}
+		
+    $this->column_fields["record_id"] = $record;
+    $this->column_fields["record_module"] = $module;
+  }
+
+	/** Function to saves the values in all the tables mentioned in the class variable $tab_name for the specified module
+  	  * @param $module -- module:: Type varchar
+ 	 */
+	function save($module_name) 
+	{
+		global $log;
+	        $log->debug("module name is ".$module_name);
+		//GS Save entity being called with the modulename as parameter
+		$this->saveentity($module_name);
+	}
+  
+	function process_list_query($query, $row_offset, $limit= -1, $max_per_page = -1)
+	{
+		global $list_max_entries_per_page;
+		$this->log->debug("process_list_query: ".$query);
+		if(!empty($limit) && $limit != -1){
+			$result =& $this->db->limitQuery($query, $row_offset + 0, $limit,true,"Error retrieving $this->object_name list: ");
+		}else{
+			$result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
+		}
+
+		$list = Array();
+		if($max_per_page == -1){
+			$max_per_page 	= $list_max_entries_per_page;
+		}
+		$rows_found =  $this->db->getRowCount($result);
+
+		$this->log->debug("Found $rows_found ".$this->object_name."s");
+                
+		$previous_offset = $row_offset - $max_per_page;
+		$next_offset = $row_offset + $max_per_page;
+
+		if($rows_found != 0)
+		{
+
+			// We have some data.
+
+			for($index = $row_offset , $row = $this->db->fetchByAssoc($result, $index); $row && ($index < $row_offset + $max_per_page || $max_per_page == -99) ;$index++, $row = $this->db->fetchByAssoc($result, $index)){
+
+				
+				foreach($this->list_fields as $entry)
+				{
+
+					foreach($entry as $key=>$field) // this will be cycled only once
+					{						
+						if (isset($row[$field])) {
+							$this->column_fields[$this->list_fields_names[$key]] = $row[$field];
+						
+						
+							$this->log->debug("$this->object_name({$row['id']}): ".$field." = ".$this->$field);
+						}
+						else 
+						{
+							$this->column_fields[$this->list_fields_names[$key]] = "";
+						}
+					}
+				}
+
+
+				//$this->db->println("here is the bug");
+				
+
+				$list[] = clone($this);//added by Richie to support PHP5
+			}
+		}
+
+		$response = Array();
+		$response['list'] = $list;
+		$response['row_count'] = $rows_found;
+		$response['next_offset'] = $next_offset;
+		$response['previous_offset'] = $previous_offset;
+
+		return $response;
+	}
+
+	function process_full_list_query($query)
+	{
+		$this->log->debug("CRMEntity:process_full_list_query");
+		$result =& $this->db->query($query, false);
+		$this->log->debug("CRMEntity:process_full_list_query: result is ".$result);
+
+
+		if($this->db->getRowCount($result) > 0){
+		
+		//	$this->db->println("process_full mid=".$this->module_id." mname=".$this->module_name);
+			// We have some data.
+			while ($row = $this->db->fetchByAssoc($result)) {				
+				$rowid=$row[$this->module_id];
+
+				if(isset($rowid))
+			       		$this->retrieve_entity_info($rowid,$this->module_name);
+				else
+					$this->db->println("rowid not set unable to retrieve");
+				 
+				 
+				
+		//clone function added to resolvoe PHP5 compatibility issue in Dashboards
+		//If we do not use clone, while using PHP5, the memory address remains fixed but the
+	//data gets overridden hence all the rows that come in bear the same value. This in turn
+//provides a wrong display of the Dashboard graphs. The data is erroneously shown for a specific month alone
+//Added by Richie
+				$list[] = clone($this);//added by Richie to support PHP5
+			}
+		}
+
+		if (isset($list)) return $list;
+		else return null;
+	}
+	
+	/** This function should be overridden in each module.  It marks an item as deleted.
+	* If it is not overridden, then marking this type of item is not allowed
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	*/
+	function mark_deleted($id)
+	{
+		$query = "UPDATE vtiger_crmentity set deleted=1 where crmid='$id'";
+		$this->db->query($query, true,"Error marking record deleted: ");
+
+
+	}
+
+
+	function retrieve_by_string_fields($fields_array, $encode=true) 
+	{ 
+		$where_clause = $this->get_where($fields_array);
+		
+		$query = "SELECT * FROM $this->table_name $where_clause";
+		$this->log->debug("Retrieve $this->object_name: ".$query);
+		$result =& $this->db->requireSingleResult($query, true, "Retrieving record $where_clause:");
+		if( empty($result)) 
+		{ 
+		 	return null; 
+		} 
+
+		 $row = $this->db->fetchByAssoc($result,-1, $encode);
+
+		foreach($this->column_fields as $field) 
+		{ 
+			if(isset($row[$field])) 
+			{ 
+				$this->$field = $row[$field];
+			}
+		} 
+		return $this;
+	}
+
+	// this method is called during an import before inserting a bean
+	// define an associative array called $special_fields
+	// the keys are user defined, and don't directly map to the bean's vtiger_fields
+	// the value is the method name within that bean that will do extra
+	// processing for that vtiger_field. example: 'full_name'=>'get_names_from_full_name'
+
+	function process_special_fields() 
+	{ 
+		foreach ($this->special_functions as $func_name) 
+		{ 
+			if ( method_exists($this,$func_name) ) 
+			{ 
+				$this->$func_name(); 
+			} 
+		} 
+	}
+
+	/**
+         * Function to check if the custom vtiger_field vtiger_table exists
+         * return true or false
+         */
+        function checkIfCustomTableExists($tablename)
+        {
+                $query = "select * from ".$tablename;
+                $result = $this->db->query($query);
+                $testrow = $this->db->num_fields($result);
+                if($testrow > 1)
+                {
+                        $exists=true;
+                }
+                else
+                {
+                        $exists=false;
+                }
+                return $exists;
+        }
+
+	/**
+	 * function to construct the query to fetch the custom vtiger_fields
+	 * return the query to fetch the custom vtiger_fields
+         */
+        function constructCustomQueryAddendum($tablename,$module)
+        {
+                global $adb;
+		$tabid=getTabid($module);		
+                $sql1 = "select columnname,fieldlabel from vtiger_field where generatedtype=2 and tabid=".$tabid;
+                $result = $adb->query($sql1);
+                $numRows = $adb->num_rows($result);
+                $sql3 = "select ";
+                for($i=0; $i < $numRows;$i++)
+                {
+                        $columnName = $adb->query_result($result,$i,"columnname");
+                        $fieldlabel = $adb->query_result($result,$i,"fieldlabel");
+                        //construct query as below
+                        if($i == 0)
+                        {
+                                $sql3 .= $tablename.".".$columnName. " '" .$fieldlabel."'";
+                        }
+                        else
+                        {
+                                $sql3 .= ", ".$tablename.".".$columnName. " '" .$fieldlabel."'";
+                        }
+
+                }
+                if($numRows>0)
+                {
+                        $sql3=$sql3.',';
+                }
+                return $sql3;
+
+        }
+
+
+	/**
+	 * This function returns a full (ie non-paged) list of the current object type.  
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_full_list($order_by = "", $where = "") {
+		$this->log->debug("get_full_list:  order_by = '$order_by' and where = '$where'");
+		$query = $this->create_list_query($order_by, $where);
+		return $this->process_full_list_query($query);
+	}
+
+	/**
+	 * Track the viewing of a detail record.  This leverages get_summary_text() which is object specific
+	 * params $user_id - The user that is viewing the record.
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function track_view($user_id, $current_module,$id='')
+	{
+		$this->log->debug("About to call vtiger_tracker (user_id, module_name, item_id)($user_id, $current_module, $this->id)");
+
+		$tracker = new Tracker();
+		$tracker->track_view($user_id, $current_module, $id, '');
+	}
+
+	function insertIntoGroupTable($module)
+	{
+		global $log;
+
+		if($module == 'Events')
+		{
+			$module = 'Calendar';
+		}
+		if($this->mode=='edit')
+		{
+						
+		  	//to disable the update of groupentity relation in ajax edit for the fields except assigned_user_id field
+			if($_REQUEST['ajxaction'] != 'DETAILVIEW' || ($_REQUEST['ajxaction'] == 'DETAILVIEW' && $_REQUEST['fldName'] == 'assigned_user_id'))
+		  	{	  
+			  	if($_REQUEST['assigntype'] == 'T')
+			  	{
+					$groupname = $_REQUEST['assigned_group_name'];
+
+					updateModuleGroupRelation($module,$this->id,$groupname);
+
+			  	}
+				else
+				{
+					updateModuleGroupRelation($module,$this->id,'');
+
+				}
+
+		  	}
+      		}
+		else
+		{
+			$groupname = $_REQUEST['assigned_group_name'];
+		 	if($_REQUEST['assigntype'] == 'T')
+		  	{
+			  	insertIntoGroupRelation($module,$this->id,$groupname);
+		  	}
+		  
+		}			
+
+	}	
+
+	
+
+}
+?>

Modified: vtigercrm/branches/5.1_jens/data/Tracker.php
==============================================================================
--- vtigercrm/branches/5.1_jens/data/Tracker.php (original)
+++ vtigercrm/branches/5.1_jens/data/Tracker.php Mon Apr 16 12:27:44 2007
@@ -69,8 +69,6 @@
       $log->info("in  track view method ".$current_module);
         // Add a new item to the user's list
 
-        $esc_item_id = addslashes($item_id);
-        
 //No genius required. Just add an if case and change the query so that it puts the tracker entry whenever you touch on the DetailView of the required entity
          //get the first name and last name from the respective modules
 	 if($current_module != '')
@@ -94,11 +92,17 @@
 		 }
 		 $result = $adb->query($query1);
 		 $item_summary = $adb->query_result($result,0,'entityname');
-		 if(strlen($item_summary) > 30)
-	     {
-		    $item_summary=substr($item_summary,0,30).'...';
-	     }
 	 }
+
+	 ### Check database item sizes
+	 #
+	 if(strlen($item_summary) > 251) {
+	     $item_summary=substr($item_summary,0,251).'...';
+	 }
+	 if(strlen($item_id) > 32) {
+	     $item_id=substr($item_id,0,32).'...';
+	 }
+         $esc_item_id = addslashes($item_id);
 	 
 	 #if condition added to skip vtiger_faq in last viewed history
           $query = "INSERT into $this->table_name (user_id, module_name, item_id, item_summary) values ('$user_id', '$current_module', '$esc_item_id', ".$this->db->formatString($this->table_name,'item_summary',$item_summary).")";

Modified: vtigercrm/branches/5.1_jens/include/Ajax/TagCloud.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/Ajax/TagCloud.php (original)
+++ vtigercrm/branches/5.1_jens/include/Ajax/TagCloud.php Mon Apr 16 12:27:44 2007
@@ -46,10 +46,10 @@
 	{
 		$tagid = $_REQUEST['tagid']; 
 		global $adb;
-		$query="delete from vtiger_freetagged_objects where tag_id=".$tagid;
+		$query="delete from vtiger_freetagged_objects where tag_id=".$tagid." and object_id=".$crmid;
 		$result=$adb->query($query);
-		$query="delete from vtiger_freetags where id=".$tagid;
-		$result=$adb->query($query);
+		/*$query="delete from vtiger_freetags where id=".$tagid;
+		$result=$adb->query($query);*/
 		echo 'SUCESS';
 	}else
 	{

Modified: vtigercrm/branches/5.1_jens/include/CustomFieldUtil.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/CustomFieldUtil.php (original)
+++ vtigercrm/branches/5.1_jens/include/CustomFieldUtil.php Mon Apr 16 12:27:44 2007
@@ -19,6 +19,8 @@
  */
 function getCustomFieldTypeName($uitype)
 {
+	
+	global $mod_strings,$app_strings;
 	global $log;
 	$log->debug("Entering getCustomFieldTypeName(".$uitype.") method ...");
 	global $log;
@@ -27,55 +29,55 @@
 	
 	if($uitype == 1)
 	{
-		$fldname = 'Text';
+		$fldname = $mod_strings['Text'];
 	}
 	elseif($uitype == 7)
 	{
-		$fldname = 'Number';
+		$fldname = $mod_strings['Number'];
 	}
 	elseif($uitype == 9)
 	{
-		$fldname = 'Percent';
+		$fldname = $mod_strings['Percent'];
 	}
 	elseif($uitype == 5)
 	{
-		$fldname = 'Date';
+		$fldname = $mod_strings['Date'];
 	}
 	elseif($uitype == 13)
 	{
-		$fldname = 'Email';
+		$fldname = $mod_strings['Email'];
 	}
 	elseif($uitype == 11)
 	{
-		$fldname = 'Phone';
+		$fldname = $mod_strings['Phone'];
 	}
 	elseif($uitype == 15)
 	{
-		$fldname = 'PickList';
+		$fldname = $mod_strings['PickList'];
 	}
 	elseif($uitype == 17)
 	{
-		$fldname = 'Url';
+		$fldname = $mod_strings['LBL_URL'];
 	}
 	elseif($uitype == 56)
 	{
-		$fldname = 'Checkbox';
+		$fldname = $mod_strings['LBL_CHECK_BOX'];
 	}
 	elseif($uitype == 71)
 	{
-		$fldname = 'Currency';
+		$fldname = $mod_strings['Currency'];
 	}
 	elseif($uitype == 21)
 	{
-		$fldname = 'Text Area';
+		$fldname = $mod_strings['LBL_TEXT_AREA'];
 	}
 	elseif($uitype == 33)
 	{
-		$fldname = 'Multi-Select Combo Box';
+		$fldname = $mod_strings['LBL_MULTISELECT_COMBO'];
 	}
 	elseif($uitype == 85)
 	{
-		$fldname = 'Skype';
+		$fldname = $mod_strings['Skype'];
 	}
 $log->debug("Exiting getCustomFieldTypeName method ...");
 	return $fldname;
@@ -200,7 +202,7 @@
 	{
 		$fieldtype = '6';
 	}
-	elseif($label == 'PickList')
+	elseif($label == 'Pick List')
 	{
 		$fieldtype = '7';
 	}

Modified: vtigercrm/branches/5.1_jens/include/RelatedListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/RelatedListView.php (original)
+++ vtigercrm/branches/5.1_jens/include/RelatedListView.php Mon Apr 16 12:27:44 2007
@@ -24,11 +24,12 @@
   * @param $id -- id:: Type string
   * @param $edit_val -- edit value:: Type string
   * @param $del_val -- delete value:: Type string
+  * @param $rel_type -- relation type:: Type integer
   * @returns $related_entries -- related entires:: Type string array
   *
   */
 
-function GetRelatedList($module,$relatedmodule,$focus,$query,$button,$returnset,$id='',$edit_val='',$del_val='')
+function GetRelatedList($module,$relatedmodule,$focus,$query,$button,$returnset,$id='',$edit_val='',$del_val='',$rel_type='')
 {
 	$log = LoggerManager::getLogger('account_list');
 	$log->debug("Entering GetRelatedList(".$module.",".$relatedmodule.",".$focus.",".$query.",".$button.",".$returnset.",".$edit_val.",".$del_val.") method ...");
@@ -135,8 +136,13 @@
 		$order_by = $focus->default_order_by;
 		$sorder = $focus->default_sort_order;
 	}
-		
-	$query .= ' ORDER BY '.$order_by.' '.$sorder;
+		//Added by Don for AssignedTo ordering issue in Related Lists
+	$query_order_by = $order_by;
+	if($order_by == 'smownerid')
+	{
+		$query_order_by = "case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end ";
+	}	
+	$query .= ' ORDER BY '.$query_order_by.' '.$sorder;
 	$url_qry .="&order_by=".$order_by;
 	//Added for PHP version less than 5
 	if (!function_exists("stripos"))
@@ -187,35 +193,43 @@
 	else
 	{
 		$id = $_REQUEST['record'];
-		$listview_header = getListViewHeader($focus,$relatedmodule,'',$sorder,$order_by,$id,'',$module);//"Accounts");
 		if ($noofrows > 15)
 		{
 			$smarty->assign('SCROLLSTART','<div style="overflow:auto;height:315px;width:100%;">');
 			$smarty->assign('SCROLLSTOP','</div>');
 		}
+		if($module == 'Products' && $relatedmodule == 'Products') {
+		    $listview_entries = getDepListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'EditView','Delete','',$rel_type);
+		    $listview_header = getDepListViewHeader($focus,$relatedmodule,'',$sorder,$order_by,$id,'',$module,$rel_type);
+		}
+		else
+		{
+		    $listview_header = getListViewHeader($focus,$relatedmodule,'',$sorder,$order_by,$id,'',$module);
+		    if($module == 'PriceBook' && $relatedmodule == 'Products')
+		    {
+			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,$edit_val,$del_val);
+		    }
+		    if($module == 'Products' && $relatedmodule == 'PriceBook')
+		    {
+			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'EditListPrice','DeletePriceBookProductRel');
+		    }
+		    elseif($relatedmodule == 'SalesOrder')
+		    {
+			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'SalesOrderEditView','DeleteSalesOrder');
+		    }else
+		    {
+			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset);
+		    }
+		}
+
 		$smarty->assign("LISTHEADER", $listview_header);
-															
-		if($module == 'PriceBook' && $relatedmodule == 'Products')
-		{
-			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,$edit_val,$del_val);
-		}
-		if($module == 'Products' && $relatedmodule == 'PriceBook')
-		{
-			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'EditListPrice','DeletePriceBookProductRel');
-		}
-		elseif($relatedmodule == 'SalesOrder')
-		{
-			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset,'SalesOrderEditView','DeleteSalesOrder');
-		}else
-		{
-			$listview_entries = getListViewEntries($focus,$relatedmodule,$list_result,$navigation_array,'relatedlist',$returnset);
-		}
 
 		$navigationOutput = Array();
 		$navigationOutput[] = $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
 		$module_rel = $module.'&relmodule='.$relatedmodule.'&record='.$id;
 		$navigationOutput[] = getRelatedTableHeaderNavigation($navigation_array, $url_qry,$module_rel);
 		$related_entries = array('header'=>$listview_header,'entries'=>$listview_entries,'navigation'=>$navigationOutput);
+
 		$log->debug("Exiting GetRelatedList method ...");
 		return $related_entries;
 	}
@@ -238,13 +252,12 @@
 	$list = '<script>
 		function confirmdelete(url)
 		{
-			if(confirm("Are you sure?"))
+			if(confirm("'.$app_strings['ARE_YOU_SURE'].'"))
 			{
 				document.location.href=url;
 			}
 		}
 	</script>';
-	echo $list;
 
 	$theme_path="themes/".$theme."/";
 	$image_path=$theme_path."images/";
@@ -383,8 +396,8 @@
 		$header[] = $app_strings['LBL_TYPE'];
 		$header[] = $app_strings['LBL_SUBJECT'];
 		$header[] = $app_strings['LBL_RELATED_TO'];
-		$header[] = $app_strings['LBL_START_DATE'];
-		$header[] = $app_strings['LBL_END_DATE'];
+		$header[] = $app_strings['LBL_START_DATE']." & ".$app_strings['LBL_TIME'];
+		$header[] = $app_strings['LBL_END_DATE']." & ".$app_strings['LBL_TIME'];
 		//$header[] = $app_strings['LBL_DESCRIPTION'];
 		$header[] = $app_strings['LBL_ACTION'];
 		$header[] = $app_strings['LBL_ASSIGNED_TO'];
@@ -413,10 +426,10 @@
 	
 			$parentname = getRelatedTo('Calendar',$result,$i-1);
 			$entries[] = $parentname;
-
-			$entries[] = $row['date_start'];
-			$entries[] = $row['due_date'];
-
+		
+			$entries[] = $row['date_start']."   ".$row['time_start'];
+			$entries[] = $row['due_date']."   ".$row['time_end'];
+			
 			//$entries[] = nl2br($row['description']);
 
 			if(isPermitted("Calendar",1,$row["activityid"]) == 'yes')
@@ -445,7 +458,7 @@
 			$i++;
 			$entries_list[] = $entries;
 		}
-
+	
 		$return_data = array('header'=>$header,'entries'=>$entries_list);
 		$log->debug("Exiting getHistory method ...");
 		return $return_data; 
@@ -487,7 +500,9 @@
 	$header[]=$mod_strings['LBL_PRODUCT_CODE'];
 	$header[]=$mod_strings['LBL_PRODUCT_UNIT_PRICE'];
 	$header[]=$mod_strings['LBL_PB_LIST_PRICE'];
-	$header[]=$mod_strings['LBL_ACTION'];
+	if(isPermitted("PriceBooks","EditView","") == 'yes' || isPermitted("PriceBooks","Delete","") == 'yes')
+		$header[]=$mod_strings['LBL_ACTION'];
+	
 
 	for($i=0; $i<$num_rows; $i++)
 	{
@@ -502,8 +517,17 @@
 		$entries[] = $adb->query_result($list_result,$i,"productcode");
 		$entries[] = $unit_price;
 		$entries[] = $listprice;
-		$entries[] = '<img style="cursor:pointer;" src="'.$image_path.'editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\''.$entity_id.'\',\''.$pricebook_id.'\',\''.$listprice.'\')" alt="'.$app_strings["LBL_EDIT_BUTTON"].'" title="'.$app_strings["LBL_EDIT_BUTTON"].'"/><!--a href="index.php?module=Products&action=EditListPrice&record='.$entity_id.'&pricebook_id='.$pricebook_id.'&listprice='.$listprice.'">edit</a-->&nbsp;|&nbsp;<img src="'.$image_path.'delete.gif" onclick="if(confirm(\'Are you sure?\')) deletePriceBookProductRel('.$entity_id.','.$pricebook_id.');" alt="'.$app_strings["LBL_DELETE"].'" title="'.$app_strings["LBL_DELETE"].'" style="cursor:pointer;" border="0">';
-
+		$action = "";
+		if(isPermitted("PriceBooks","EditView","") == 'yes')
+			$action .= '<img style="cursor:pointer;" src="'.$image_path.'editfield.gif" border="0" onClick="fnvshobj(this,\'editlistprice\'),editProductListPrice(\''.$entity_id.'\',\''.$pricebook_id.'\',\''.$listprice.'\')" alt="'.$app_strings["LBL_EDIT_BUTTON"].'" title="'.$app_strings["LBL_EDIT_BUTTON"].'"/>';
+		if(isPermitted("PriceBooks","Delete","") == 'yes')
+		{		
+			if($action != "")
+				$action .= '&nbsp;|&nbsp;';
+			$action .= '<img src="'.$image_path.'delete.gif" onclick="if(confirm(\''.$app_strings['ARE_YOU_SURE'].'\')) deletePriceBookProductRel('.$entity_id.','.$pricebook_id.');" alt="'.$app_strings["LBL_DELETE"].'" title="'.$app_strings["LBL_DELETE"].'" style="cursor:pointer;" border="0">';	
+		}
+		if($action != "")		
+			$entries[] = $action;
 		$entries_list[] = $entries;
 	}
 	if($num_rows>0)

Modified: vtigercrm/branches/5.1_jens/include/fpdf/fpdf.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/fpdf/fpdf.php (original)
+++ vtigercrm/branches/5.1_jens/include/fpdf/fpdf.php Mon Apr 16 12:27:44 2007
@@ -122,7 +122,9 @@
 	if(is_string($format))
 	{
 		$format=strtolower($format);
-		if($format=='a3')
+		if($format=='a1')
+			$format=array(2500,3000);
+		elseif($format=='a3')
 			$format=array(841.89,1190.55);
 		elseif($format=='a4')
 			$format=array(595.28,841.89);

Modified: vtigercrm/branches/5.1_jens/include/fpdf/templates/body.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/fpdf/templates/body.php (original)
+++ vtigercrm/branches/5.1_jens/include/fpdf/templates/body.php Mon Apr 16 12:27:44 2007
@@ -1,15 +1,15 @@
 <?php
 // watermark based on status
 // this is the postion of the watermark before the rotate
-$waterMarkPositions=array("50","180");
+$waterMarkPositions=array("30","180");
 // this is the rotate amount (todo)
 $waterMarkRotate=array("45","50","180");
 $pdf->watermark( $status, $waterMarkPositions, $waterMarkRotate );
 
-$bottom="130";
-$top="80";
+include("include/fpdf/pdfconfig.php");
+
 // blow a bubble around the table
-$Bubble=array("10",$top,"170","$bottom");
+$Bubble=array("10",$body_top,"170","$bottom");
 $pdf->tableWrapper($Bubble);
 
 /* ************ Begin Table Setup ********************** */
@@ -18,8 +18,12 @@
 // total of columns needs to be 190 in order to fit the table
 // correctly
 $prodTable=array("10","60");
-
-if($focus->column_fields["hdnTaxType"] == "individual") {
+//added for value field allignment
+//contains the x angle starting point of the value field
+$space=array("4"=>"191","5"=>"189","6"=>"187","7"=>"186","8"=>"184","9"=>"182","10"=>"180","11"=>"179","12"=>"177","13"=>"175");
+//if taxtype is individual
+if($focus->column_fields["hdnTaxType"] == "individual")
+{
 	$colsAlign["Product Name"] = "L";
 	$colsAlign["Description"] = "L";
 	$colsAlign["Qty"] = "R";
@@ -27,24 +31,25 @@
 	$colsAlign["Discount"] = "R";
 	$colsAlign["Tax"] = "R";
 	$colsAlign["Total"] = "R";
-
-	$cols["Product Name"] = "25";
-	$cols["Description"] = "70";
+	$cols["Product Code"] = "30";
+	$cols["Product Name"] = "65";
 	$cols["Qty"] = "10";
 	$cols["Price"] = "25";
 	$cols["Discount"] = "15";
 	$cols["Tax"] = "20";
 	$cols["Total"] = "25";
-} else {
+}
+else
+{
+	//if taxtype is group
 	$colsAlign["Product Name"] = "L";
 	$colsAlign["Description"] = "L";
 	$colsAlign["Qty"] = "R";
 	$colsAlign["Price"] = "R";
 	$colsAlign["Discount"] = "R";
 	$colsAlign["Total"] = "R";
-
-	$cols["Product Name"] = "25";
-	$cols["Description"] = "70";
+	$cols["Product Code"] = "30";
+	$cols["Product Name"] = "65";
 	$cols["Qty"] = "15";
 	$cols["Price"] = "30";
 	$cols["Discount"] = "20";
@@ -61,10 +66,12 @@
 
 /* ************* Begin Product Population *************** */
 $ppad=3;
-$y    = $top+10;
-for($i=0;$i<count($product_name);$i++) {
-        $size = $pdf->addProductLine( $y, $line[$i] );
-        $y   += $size+$ppad;
+$y    = $body_top+10;
+
+for($i=0;$i<count($line);$i++)
+{
+	$size = $pdf->addProductLine( $y, $line[$i] );
+	$y   += $size+$ppad;
 }
 
 /* ******************* End product population ********* */
@@ -73,85 +80,158 @@
 /* ************* Begin Totals ************************** */
 $t=$bottom+56;
 $pad=6;
-for($i=0;$i<count($total);$i++) {
-        $size = $pdf->addProductLine( $t, $total[$i], $total[$i] );
-        $t   += $pad;
-}
-
-
-if($focus->column_fields["hdnTaxType"] != "individual") {
+for($i=0;$i<count($total);$i++)
+{
+	$size = $pdf->addProductLine( $t, $total[$i], $total[$i] );
+	$t   += $pad;
+}
+
+//Set the x and y positions to place the NetTotal, Discount, S&H charge
+//if taxtype is not individual ie., group tax
+if($focus->column_fields["hdnTaxType"] != "individual")
+{
 	$lineData=array("105",$bottom+37,"94");
 	$pdf->drawLine($lineData);
-	$data= $app_strings['LBL_NET_TOTAL'].":                                                                   ".$price_subtotal."";
-	$pdf->SetXY( 105 , 168 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
+	$data= $app_strings['LBL_NET_TOTAL'].":";//                                                                  ".$price_subtotal."";
+	$pdf->SetXY( 105 , ($nettotal_y+(0*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+
+//Added for value field alignment
+        $pdf->SetXY( $space[strlen($price_subtotal)] , ($nettotal_y+(0*$next_y)) );
+        $pdf->SetFont( "Helvetica", "", 10);
+        $pdf->MultiCell(110, 4, $price_subtotal);
+
 
 	$lineData=array("105",$bottom+43,"94");
 	$pdf->drawLine($lineData);
-	$data= $app_strings['LBL_DISCOUNT'].":                                                                      ".$price_discount."";
-	$pdf->SetXY( 105 , 174 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
+
+	//For alignment
+	if($final_price_discount_percent != '')
+		$data= $app_strings['LBL_DISCOUNT'].":   $final_price_discount_percent";//                                                ".$price_discount."";
+	else
+		$data= $app_strings['LBL_DISCOUNT'].":";//                                                                  ".$price_discount."";
+	$pdf->SetXY( 105 , ($nettotal_y+(1*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+
+//Added for value field alignment
+        $pdf->SetXY( $space[strlen($price_discount)] , ($nettotal_y+(1*$next_y)) );
+        $pdf->SetFont( "Helvetica", "", 10);
+        $pdf->MultiCell(110, 4, $price_discount);
 
 	$lineData=array("105",$bottom+49,"94");
 	$pdf->drawLine($lineData);
-	$data= $app_strings['LBL_TAX'].":  ($group_total_tax_percent %)                                                               ".$price_salestax."";
-	$pdf->SetXY( 105 , 180 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
+	$data= $app_strings['LBL_TAX'].":  ($group_total_tax_percent %)";//                                                                  ".$price_salestax."";
+	$pdf->SetXY( 105 , ($nettotal_y+(2*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+
+	//Added for value field alignment
+	$pdf->SetXY( $space[strlen($price_salestax)] , ($nettotal_y+(2*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $price_salestax);
 
 	$lineData=array("105",$bottom+55,"94");
 	$pdf->drawLine($lineData);
-	$data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].":                                     ".$price_shipping;
-	$pdf->SetXY( 105 , 186 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
-
-} else {
+	$data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].":";//                                  ".$price_shipping;
+	$pdf->SetXY( 105 , ($nettotal_y+(3*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+
+//Added for value field alignment
+        $pdf->SetXY( $space[strlen($price_shipping)] , ($nettotal_y+(3*$next_y)) );
+        $pdf->SetFont( "Helvetica", "", 10);
+        $pdf->MultiCell(110, 4, $price_shipping);
+}
+else
+{
+	//if taxtype is individual
 	$lineData=array("105",$bottom+43,"94");
 	$pdf->drawLine($lineData);
-	$data= $app_strings['LBL_NET_TOTAL'].":                                                                   ".$price_subtotal."";
-	$pdf->SetXY( 105 , 174 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
+	$data= $app_strings['LBL_NET_TOTAL'].":";//                                              ".$price_subtotal."";
+	$pdf->SetXY( 105 , ($nettotal_y+(1*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+
+// added for value field allignment
+
+	$pdf->SetXY( $space[strlen($price_subtotal)] , ($nettotal_y+(1*$next_y)) );
+        $pdf->SetFont( "Helvetica", "", 10);
+        $pdf->MultiCell(110, 4,$price_subtotal);
+
 
 	$lineData=array("105",$bottom+49,"94");
 	$pdf->drawLine($lineData);
-	$data= $app_strings['LBL_DISCOUNT'].":                                                                      ".$price_discount."";
-	$pdf->SetXY( 105 , 180 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
+
+	//For alignment
+	if($final_price_discount_percent != '')
+		$data= $app_strings['LBL_DISCOUNT'].":   $final_price_discount_percent                                                 ".$price_discount."";
+	else
+		$data= $app_strings['LBL_DISCOUNT'].":";//                                                                   ".$price_discount."";
+
+	$pdf->SetXY( 105 , ($nettotal_y+(2*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+//Added for value field alignment
+        $pdf->SetXY( $space[strlen($price_discount)] , ($nettotal_y+(2*$next_y)) );
+        $pdf->SetFont( "Helvetica", "", 10);
+        $pdf->MultiCell(110, 4, $price_discount);
+
 
 	$lineData=array("105",$bottom+55,"94");
 	$pdf->drawLine($lineData);
-	$data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].":                                   ".$price_shipping;
-	$pdf->SetXY( 105 , 186 );
-	$pdf->SetFont( "Helvetica", "", 10);
-	$pdf->MultiCell(110, 4, $data);
-}
-
+	$data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].":";//                                  ".$price_shipping;
+	$pdf->SetXY( 105 , ($nettotal_y+(3*$next_y)) );
+	$pdf->SetFont( "Helvetica", "", 10);
+	$pdf->MultiCell(110, 4, $data);
+
+//Added for value field alignment
+
+        $pdf->SetXY( $space[strlen($price_shipping)] , ($nettotal_y+(3*$next_y)) );
+        $pdf->SetFont( "Helvetica", "", 10);
+        $pdf->MultiCell(110, 4, $price_shipping);
+
+}
+
+//Set the x and y positions to place the S&H Tax, Adjustment and Grand Total
 $lineData=array("105",$bottom+61,"94");
 $pdf->drawLine($lineData);
-$data = $app_strings['LBL_TAX_FOR_SHIPPING_AND_HANDLING'].":  ($sh_tax_percent %)                      ".$price_shipping_tax;
-$pdf->SetXY( 105 , 192 );
+$data = $app_strings['LBL_TAX_FOR_SHIPPING_AND_HANDLING'].":  ($sh_tax_percent %)";//               ".$price_shipping_tax;
+$pdf->SetXY( 105 , ($nettotal_y+(4*$next_y)) );
 $pdf->SetFont( "Helvetica", "", 10);
 $pdf->MultiCell(110, 4, $data);
+
+//Added for value field alignment
+$pdf->SetXY( $space[strlen($price_shipping_tax)] , ($nettotal_y+(4*$next_y)) );
+$pdf->SetFont( "Helvetica", "", 10);
+$pdf->MultiCell(110, 4, $price_shipping_tax);
 
 $lineData=array("105",$bottom+67,"94");
 $pdf->drawLine($lineData);
-$data = $app_strings['LBL_ADJUSTMENT'].":                                                                    ".$price_adjustment;
-$pdf->SetXY( 105 , 198 );
+$data = $app_strings['LBL_ADJUSTMENT'].":";//                                                                   ".$price_adjustment;
+$pdf->SetXY( 105 , ($nettotal_y+(5*$next_y)) );
 $pdf->SetFont( "Helvetica", "", 10);
 $pdf->MultiCell(110, 4, $data);
+
+//Added for value field alignment
+$pdf->SetXY( $space[strlen($price_adjustment)] , ($nettotal_y+(5*$next_y)) );
+$pdf->SetFont( "Helvetica", "", 10);
+$pdf->MultiCell(110, 4, $price_adjustment);
+
 
 $lineData=array("105",$bottom+73,"94");
 $pdf->drawLine($lineData);
-$data = $app_strings['LBL_GRAND_TOTAL'].":(in $currency_symbol)                                                  ".$price_total;
-$pdf->SetXY( 105 , 204 );
+$data = $app_strings['LBL_GRAND_TOTAL'].":(in $currency_symbol)";//                                                    ".$price_total;
+$pdf->SetXY( 105 , ($nettotal_y+(6*$next_y)) );
 $pdf->SetFont( "Helvetica", "", 10);
 $pdf->MultiCell(110, 4, $data);
 
+//Added for value field alignment
+$pdf->SetXY( $space[strlen($price_total)] , ($nettotal_y+(6*$next_y)) );
+$pdf->SetFont( "Helvetica", "", 10);
+$pdf->MultiCell(110, 4, $price_total);
+
 /* ************** End Totals *********************** */
 
 

Modified: vtigercrm/branches/5.1_jens/include/freetag/freetag.class.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/freetag/freetag.class.php (original)
+++ vtigercrm/branches/5.1_jens/include/freetag/freetag.class.php Mon Apr 16 12:27:44 2007
@@ -923,9 +923,9 @@
 		{	
 			foreach($tag_list[0] as $tag => $qty) {
 				$size = $min_font_size + ($qty - $min_qty) * 3;
-				$cloud_span[] = '<span id="tag_'.$tag_list[1][$tag].'" class="' . $span_class . '" onMouseOver=$("tagspan_'.$tag_list[1][$tag].'").style.display="inline"; onMouseOut=$("tagspan_'.$tag_list[1][$tag].'").style.display="none";><a class="tagit" href="index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&query_string='. $tag . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a><span class="'. $span_class .'" id="tagspan_'.$tag_list[1][$tag].'" style="display:none;cursor:pointer;" onClick="DeleteTag('.$tag_list[1][$tag].');"><img src="'.$image_path.'del_tag.gif"></span></span>';
-
-			}
+				$cloud_span[] = '<span id="tag_'.$tag_list[1][$tag].'" class="' . $span_class . '" onMouseOver=$("tagspan_'.$tag_list[1][$tag].'").style.display="inline"; onMouseOut=$("tagspan_'.$tag_list[1][$tag].'").style.display="none";><a class="tagit" href="index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&query_string='. $tag . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a><span class="'. $span_class .'" id="tagspan_'.$tag_list[1][$tag].'" style="display:none;cursor:pointer;" onClick="DeleteTag('.$tag_list[1][$tag].','.$obj_id.');"><img src="'.$image_path.'del_tag.gif"></span></span>';
+
+		}
 		}else
 		{
 			foreach($tag_list[0] as $tag => $qty) {

Modified: vtigercrm/branches/5.1_jens/include/js/Inventory.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/Inventory.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/Inventory.js Mon Apr 16 12:27:44 2007
@@ -59,8 +59,13 @@
 	popuptype = 'inventory_prod';
 	if(module == 'PurchaseOrder')
 		popuptype = 'inventory_prod_po';
-
-	window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId,"productWin","width=640,height=565,resizable=0,scrollbars=0,status=1,top=150,left=200");
+	var record_id = ''
+        if(document.getElementsByName("account_id").length != 0)
+                record_id= document.EditView.account_id.value;
+        if(record_id != '')
+                window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId+"&relmod_id="+record_id+"&parent_module=Accounts","productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
+        else
+		window.open("index.php?module=Products&action=Popup&html=Popup_picker&form=HelpDeskEditView&popuptype="+popuptype+"&curr_row="+rowId,"productWin","width=640,height=600,resizable=0,scrollbars=0,status=1,top=150,left=200");
 }
 
 function priceBookPickList(currObj, row_no) {
@@ -225,7 +230,7 @@
 
 	if(max_row_count == 0)
 	{
-		alert('No product is selected. Select at least one Product');
+		alert(alert_arr.NO_PRODUCT_SELECTED);
 		return false;
 	}
 
@@ -256,7 +261,7 @@
 		temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("discount_percentage_final").value);
 		if(!temp)
 		{
-			alert("Enter valid Final Discount Percentage");
+			alert(alert_arr.VALID_FINAL_PERCENT);
 			return false;
 		}
 	}
@@ -265,7 +270,7 @@
 		temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("discount_amount_final").value);
 		if(!temp)
 		{
-			alert("Enter valid Final Discount Amount");
+			alert(alert_arr.VALID_FINAL_AMOUNT);
 			return false;
 		}
 	}
@@ -274,7 +279,7 @@
 	temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("shipping_handling_charge").value);
 	if(!temp)
 	{
-		alert("Enter a valid Shipping & Handling charge");
+		alert(alert_arr.VALID_SHIPPING_CHARGE);
 		return false;
 	}
 
@@ -282,17 +287,51 @@
 	temp = /^-?(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("adjustment").value)
 	if(!temp)
 	{
-		alert("Enter a valid Adjustment");
+		alert(alert_arr.VALID_ADJUSTMENT);
 		return false;
 	}
-
-	return true    
+	
+	//Group - Tax Validation  - not allow negative values
+	//We need to validate group tax only if taxtype is group.
+	var taxtype=document.getElementById("taxtype").value;
+	if(taxtype=="group")
+	{
+		var tax_count=document.getElementById("group_tax_count").value;
+		for(var i=1;i<=tax_count;i++)
+		{
+
+			temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("group_tax_percentage"+i).value);
+			if(!temp)
+			{
+				alert(alert_arr.VALID_TAX_PERCENT);
+				return false;
+			}
+		}
+	}
+	
+	//Taxes for Shippring and Handling  validation - not allow negative values
+		var shtax_count=document.getElementById("sh_tax_count").value;
+		for(var i=1;i<=shtax_count;i++)
+		{
+
+			temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("sh_tax_percentage"+i).value);
+			if(!temp)
+			{
+				alert(alert_arr.VALID_SH_TAX);
+				return false;
+			}
+		}
+
+
+	return true;    
 }
 
 function FindDuplicate()
 {
 	var max_row_count = document.getElementById('proTab').rows.length;
         max_row_count = eval(max_row_count)-2;//As the table has two header rows, we will reduce two from row length
+
+	var duplicate = false, iposition = '', positions = '', duplicate_products = '';
 
 	var product_id = new Array(max_row_count-1);
 	var product_name = new Array(max_row_count-1);
@@ -300,6 +339,7 @@
 	product_name[1] = getObj("productName"+1).value;
 	for (var i=1;i<=max_row_count;i++)
 	{
+		iposition = ""+i;
 		for(var j=i+1;j<=max_row_count;j++)
 		{
 			if(i == 1)
@@ -308,10 +348,20 @@
 			}
 			if(product_id[i] == product_id[j] && product_id[i] != '')
 			{
-				alert("You have selected < "+getObj("productName"+j).value+" > more than once in line items  "+i+" & "+j+".\n It is advisable to select the product just once but change the Qty. Thank You");
-				//return false;
+				if(!duplicate) positions = iposition;
+				duplicate = true;
+				if(positions.search(j) == -1) positions = positions+" & "+j;
+
+				if(duplicate_products.search(getObj("productName"+j).value) == -1)
+					duplicate_products = duplicate_products+getObj("productName"+j).value+" \n";
 			}
 		}
+	}
+	if(duplicate)
+	{
+		//alert("You have selected < "+duplicate_products+" > more than once in line items  "+positions+".\n It is advisable to select the product just once but change the Qty. Thank You");
+		if(!confirm(alert_arr.SELECTED_MORE_THAN_ONCE+"\n"+duplicate_products+"\n "+alert_arr.WANT_TO_CONTINUE))
+			return false;
 	}
         return true;
 }
@@ -328,7 +378,7 @@
 {
 	temp= /^\d+(\.\d\d*)*$/.test(document.getElementById(txtObj).value);
 	if(temp == false)
-		alert("Please enter Valid TAX value");
+		alert(alert_arr.ENTER_VALID_TAX);
 }
 
 function loadTaxes_Ajax(curr_row)
@@ -378,22 +428,22 @@
 	colone.className = "cellLabel small";
 	coltwo.className = "cellText small";
 
-	colone.innerHTML="<input type='text' id='"+label_name+"' name='"+label_name+"' value='Tax Name' class='txtBox' onclick=\"this.form."+label_name+".value=''\";/>";
-	coltwo.innerHTML="<input type='text' id='"+label_val+"' name='"+label_val+"' value='Tax Value' class='txtBox' onclick=\"this.form."+label_val+".value=''\";/>";
-
-	document.getElementById(td_id).innerHTML="<input type='submit' name='Save' value='Save' class='crmButton small save' onclick=\"this.form.action.value='TaxConfig'; this.form."+add_tax_flag+".value='true'; this.form.parenttab.value='Settings'; return validateNewTaxType('"+label_name+"','"+label_val+"');\">&nbsp;<input type='submit' name='Cancel' value='Cancel' class='crmButton small cancel' onclick=\"this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form."+add_tax_flag+".value='false'; this.form.parenttab.value='Settings';\">";
+	colone.innerHTML="<input type='text' id='"+label_name+"' name='"+label_name+"' value='"+tax_labelarr.TAX_NAME+"' class='txtBox' onclick=\"this.form."+label_name+".value=''\";/>";
+	coltwo.innerHTML="<input type='text' id='"+label_val+"' name='"+label_val+"' value='"+tax_labelarr.TAX_VALUE+"' class='txtBox' onclick=\"this.form."+label_val+".value=''\";/>";
+
+	document.getElementById(td_id).innerHTML="<input type='submit' name='Save' value=' "+tax_labelarr.SAVE_BUTTON+" ' class='crmButton small save' onclick=\"this.form.action.value='TaxConfig'; this.form."+add_tax_flag+".value='true'; this.form.parenttab.value='Settings'; return validateNewTaxType('"+label_name+"','"+label_val+"');\">&nbsp;<input type='submit' name='Cancel' value=' "+tax_labelarr.CANCEL_BUTTON+" ' class='crmButton small cancel' onclick=\"this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form."+add_tax_flag+".value='false'; this.form.parenttab.value='Settings';\">";
 }
 
 function validateNewTaxType(fieldname, fieldvalue)
 {
 	if(trim(document.getElementById(fieldname).value)== '')
 	{
-		alert("Enter valid Tax Name");
+		alert(alert_arr.VALID_TAX_NAME);
 		return false;
 	}
 	if(trim(document.getElementById(fieldvalue).value)== '')
 	{
-		alert("Enter Correct Tax Value");
+		alert(alert_arr.CORRECT_TAX_VALUE);
 		return false;
 	}
 	else
@@ -401,7 +451,7 @@
 		var temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById(fieldvalue).value);
 		if(!temp)
 		{
-			alert("Please enter positive value");
+			alert(alert_arr.ENTER_POSITIVE_VALUE);
 			return false;
 		}
 	}
@@ -432,7 +482,7 @@
 
 		if(document.getElementById(taxLabelPrefix+i).value.length == 0)
 		{
-			alert("The tax label name should not be empty");
+			alert(alert_arr.LABEL_SHOULDNOT_EMPTY);
 			return false
 		} 
 
@@ -440,7 +490,7 @@
 		var temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(taxval);
 		if(!temp)
 		{
-			alert("'"+taxval+"' is not a valid entry. Please enter correct value");
+			alert("'"+taxval+"' "+alert_arr.NOT_VALID_ENTRY);
 			return false;
 		}
 	}
@@ -476,14 +526,13 @@
 		var colsix = row.insertCell(5);
 		var colseven = row.insertCell(6);
 	}
-	
 	//Delete link
 	colone.className = "crmTableRow small";
 	colone.innerHTML='<img src="'+image_path+'delete.gif" border="0" onclick="deleteRow(\''+module+'\','+count+')"><input id="deleted'+count+'" name="deleted'+count+'" type="hidden" value="0">';
 
 	//Product Name with Popup image to select product
 	coltwo.className = "crmTableRow small"
-	coltwo.innerHTML= '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td class="small"><input id="productName'+count+'" name="productName'+count+'" class="small" style="width: 70%;" value="" readonly="readonly" type="text"><input id="hdnProductId'+count+'" name="hdnProductId'+count+'" value="" type="hidden"><img src="'+image_path+'search.gif" style="cursor: pointer;" onclick="productPickList(this,\''+module+'\','+count+')" align="absmiddle"></td></tr><tr><td class="small" id="setComment'+count+'"><textarea id="comment1" name="comment'+count+'" class=small style="width:70%;height:40px"></textarea><br>[<a href="javascript:;" onclick="getObj(\'comment'+count+'\').value=\'\'";>Clear Comment</a>]</td></tr></tbody></table>';	
+	coltwo.innerHTML= '<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td class="small"><input id="productName'+count+'" name="productName'+count+'" class="small" style="width: 70%;" value="" readonly="readonly" type="text"><input id="hdnProductId'+count+'" name="hdnProductId'+count+'" value="" type="hidden"><img src="'+image_path+'search.gif" style="cursor: pointer;" onclick="productPickList(this,\''+module+'\','+count+')" align="absmiddle"></td></tr><tr><td class="small" id="setComment'+count+'"><textarea id="comment'+count+'" name="comment'+count+'" class=small style="width:70%;height:40px"></textarea><br>[<a href="javascript:;" onclick="getObj(\'comment'+count+'\').value=\'\'";>'+product_labelarr.CLEAR_COMMENT+'</a>]</td></tr></tbody></table>';	
 	
 	//Quantity In Stock - only for SO, Quotes and Invoice
 	if(module != "PurchaseOrder"){
@@ -491,13 +540,13 @@
 	colthree.innerHTML='<span id="qtyInStock'+count+'">&nbsp;</span>';
 	}
 	
-	//Quantiry
+	//Quantity
 	colfour.className = "crmTableRow small"
-	colfour.innerHTML='<input id="qty'+count+'" name="qty'+count+'" type="text" class="small " style="width:50px" onfocus="this.className=\'detailedViewTextBoxOn\'" onBlur="FindDuplicate(); settotalnoofrows(); calcTotal(); loadTaxes_Ajax('+count+');" value=""/>';
+	colfour.innerHTML='<input id="qty'+count+'" name="qty'+count+'" type="text" class="small " style="width:50px" onfocus="this.className=\'detailedViewTextBoxOn\'" onBlur="settotalnoofrows(); calcTotal(); loadTaxes_Ajax('+count+');" onChange="setDiscount(this,'+count+')" value=""/>';
 	
 	//List Price with Discount, Total after Discount and Tax labels
 	colfive.className = "crmTableRow small"
-	colfive.innerHTML='<table width="100%" cellpadding="0" cellspacing="0"><tr><td align="right"><input id="listPrice'+count+'" name="listPrice'+count+'" value="0.00" type="text" class="small " style="width:70px" onBlur="calcTotal(); callTaxCalc('+count+');"/>&nbsp;<img src="'+image_path+'pricebook.gif" onclick="priceBookPickList(this,'+count+')"></td></tr><tr><td align="right" style="padding:5px;" nowrap>		(-)&nbsp;<b><a href="javascript:doNothing();" onClick="displayCoords(event,\'discount_div'+count+'\',\'discount\','+count+')" >Discount</a> : </b><div class=\"discountUI\" id=\"discount_div'+count+'"><input type="hidden" id="discount_type'+count+'" name="discount_type'+count+'" value=""><table width="100%" border="0" cellpadding="5" cellspacing="0" class="small"><tr><td id="discount_div_title'+count+'" nowrap align="left" ></td><td align="right"><img src="'+image_path+'close.gif" border="0" onClick="fnHidePopDiv(\'discount_div'+count+'\')" style="cursor:pointer;"></td></tr><tr><td align="left" class="lineOnTop"><input type="radio" name="discount'+count+'" checked onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp; Zero Discount</td><td class="lineOnTop">&nbsp;</td></tr><tr><td align="left"><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp; % of Price </td><td align="right"><input type="text" class="small" size="2" id="discount_percentage'+count+'" name="discount_percentage'+count+'" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp;%</td></tr><tr><td align="left" nowrap><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp; Direct Price Redunction</td><td align="right"><input type="text" id="discount_amount'+count+'" name="discount_amount'+count+'" size="5" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');"></td></tr></table></div></td></tr><tr> <td align="right" style="padding:5px;" nowrap><b>Total After Discount :</b></td></tr><tr id="individual_tax_row'+count+'" class="TaxShow"><td align="right" style="padding:5px;" nowrap>(+)&nbsp;<b><a href="javascript:doNothing();" onClick="displayCoords(event,\'tax_div'+count+'\',\'tax\','+count+')" >Tax </a> : </b><div class="discountUI" id="tax_div'+count+'"></div></td></tr></table> ';
+	colfive.innerHTML='<table width="100%" cellpadding="0" cellspacing="0"><tr><td align="right"><input id="listPrice'+count+'" name="listPrice'+count+'" value="0.00" type="text" class="small " style="width:70px" onBlur="calcTotal(); callTaxCalc('+count+');" onChange="setDiscount(this,'+count+')"/>&nbsp;<img src="'+image_path+'pricebook.gif" onclick="priceBookPickList(this,'+count+')"></td></tr><tr><td align="right" style="padding:5px;" nowrap>		(-)&nbsp;<b><a href="javascript:doNothing();" onClick="displayCoords(this,\'discount_div'+count+'\',\'discount\','+count+')" >'+product_labelarr.DISCOUNT+'</a> : </b><div class=\"discountUI\" id=\"discount_div'+count+'"><input type="hidden" id="discount_type'+count+'" name="discount_type'+count+'" value=""><table width="100%" border="0" cellpadding="5" cellspacing="0" class="small"><tr><td id="discount_div_title'+count+'" nowrap align="left" ></td><td align="right"><img src="'+image_path+'close.gif" border="0" onClick="fnHidePopDiv(\'discount_div'+count+'\')" style="cursor:pointer;"></td></tr><tr><td align="left" class="lineOnTop"><input type="radio" name="discount'+count+'" checked onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp; '+product_labelarr.ZERO_DISCOUNT+'</td><td class="lineOnTop">&nbsp;</td></tr><tr><td align="left"><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp; % '+product_labelarr.PERCENT_OF_PRICE+' </td><td align="right"><input type="text" class="small" size="2" id="discount_percentage'+count+'" name="discount_percentage'+count+'" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp;%</td></tr><tr><td align="left" nowrap><input type="radio" name="discount'+count+'" onclick="setDiscount(this,'+count+'); callTaxCalc('+count+');">&nbsp; '+product_labelarr.DIRECT_PRICE_REDUCTION+'</td><td align="right"><input type="text" id="discount_amount'+count+'" name="discount_amount'+count+'" size="5" value="0" style="visibility:hidden" onBlur="setDiscount(this,'+count+'); callTaxCalc('+count+');"></td></tr></table></div></td></tr><tr> <td align="right" style="padding:5px;" nowrap><b>'+product_labelarr.TOTAL_AFTER_DISCOUNT+' :</b></td></tr><tr id="individual_tax_row'+count+'" class="TaxShow"><td align="right" style="padding:5px;" nowrap>(+)&nbsp;<b><a href="javascript:doNothing();" onClick="displayCoords(this,\'tax_div'+count+'\',\'tax\','+count+')" >'+product_labelarr.TAX+' </a> : </b><div class="discountUI" id="tax_div'+count+'"></div></td></tr></table> ';
 
 	//Total and Discount, Total after Discount and Tax details
 	colsix.className = "crmTableRow small"
@@ -588,14 +637,16 @@
 			discount_amount = eval(document.getElementById("productTotal"+curr_row).innerHTML)*eval(document.getElementById("discount_percentage"+curr_row).value)/eval(100);
 		}
 
-		document.getElementById("discountTotal"+curr_row).innerHTML = discount_amount;
+		//Rounded the decimal part of discount amount to two digits
+		document.getElementById("discountTotal"+curr_row).innerHTML = roundValue(discount_amount.toString());
 	}
 	if(discount_checks[2].checked == true)
 	{
 		document.getElementById("discount_type"+curr_row).value = 'amount';
 		document.getElementById("discount_percentage"+curr_row).style.visibility = 'hidden';
 		document.getElementById("discount_amount"+curr_row).style.visibility = 'visible';
-		document.getElementById("discountTotal"+curr_row).innerHTML = document.getElementById("discount_amount"+curr_row).value;
+		//Rounded the decimal part of discount amount to two digits
+		document.getElementById("discountTotal"+curr_row).innerHTML = roundValue(document.getElementById("discount_amount"+curr_row).value.toString());
 	}
 
 	calcTotal();
@@ -605,13 +656,15 @@
 function callTaxCalc(curr_row)
 {
 	//when we change discount or list price, we have to calculate the taxes again before calculate the total
-	tax_count = eval(document.getElementById('tax_table'+curr_row).rows.length-1);//subtract the title tr length
-
-	for(var i=0, j=i+1;i<tax_count;i++,j++)
-	{
-		var tax_hidden_name = "hidden_tax"+j+"_percentage"+curr_row;
-		var tax_name = document.getElementById(tax_hidden_name).value;
-		calcCurrentTax(tax_name,curr_row,i);
+	if(getObj('tax_table'+curr_row))
+	{
+		tax_count = eval(document.getElementById('tax_table'+curr_row).rows.length-1);//subtract the title tr length
+		for(var i=0, j=i+1;i<tax_count;i++,j++)
+		{
+			var tax_hidden_name = "hidden_tax"+j+"_percentage"+curr_row;
+			var tax_name = document.getElementById(tax_hidden_name).value;
+			calcCurrentTax(tax_name,curr_row,i);
+		}
 	}
 }
 
@@ -625,7 +678,10 @@
 	var new_amount_lbl = document.getElementsByName("popup_tax_row"+curr_row);
 
 	//calculate the new tax amount
-	new_tax_amount = eval(product_total)*eval(new_tax_percent)/eval(100);
+	var new_tax_amount = eval(product_total)*eval(new_tax_percent)/eval(100);
+
+	//Rounded the decimal part of tax amount to two digits
+	new_tax_amount = roundValue(new_tax_amount.toString());
 
 	//assign the new tax amount in the corresponding text box
 	new_amount_lbl[tax_row].value = new_tax_amount;
@@ -635,7 +691,7 @@
 	{
 		tax_total = tax_total + eval(new_amount_lbl[i].value);
 	}
-	document.getElementById("taxTotal"+curr_row).innerHTML = tax_total;
+	document.getElementById("taxTotal"+curr_row).innerHTML = roundValue(tax_total);
 
 	calcTotal();
 }
@@ -653,7 +709,7 @@
 		group_tax_total = eval(group_tax_total) + eval(tax_amount);
 	}
 
-	document.getElementById("tax_final").innerHTML = group_tax_total;
+	document.getElementById("tax_final").innerHTML = roundValue(group_tax_total);
 
 	calcTotal();
 }
@@ -667,11 +723,13 @@
 	for(var i=1;i<=sh_tax_count;i++)
 	{
 		tax_amount = eval(sh_charge)*eval(document.getElementById("sh_tax_percentage"+i).value)/eval(100);
-		document.getElementById("sh_tax_amount"+i).value = tax_amount;
+		//Rounded the decimal part of S&H Tax amount to two digits
+		document.getElementById("sh_tax_amount"+i).value = roundValue(tax_amount.toString());
 		sh_tax_total = eval(sh_tax_total) + eval(tax_amount);
 	}
 
-	document.getElementById("shipping_handling_tax").innerHTML = sh_tax_total;
+	//Rounded the decimal part of Total S&H Tax amount to two digits
+	document.getElementById("shipping_handling_tax").innerHTML = roundValue(sh_tax_total.toString());
 
 	calcTotal();
 }
@@ -695,7 +753,7 @@
 			temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("discount_percentage"+i).value);
 			if(!temp)
 			{
-				alert("Enter a valid Discount percentage");
+				alert(alert_arr.VALID_DISCOUNT_PERCENT);
 				return false;
 			}
 		}
@@ -704,7 +762,7 @@
 			temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(document.getElementById("discount_amount"+i).value);
 			if(!temp)
 			{
-				alert("Enter a valid Discount Amount");
+				alert(alert_arr.VALID_DISCOUNT_AMOUNT);
 				return false;
 			}
 		}

Modified: vtigercrm/branches/5.1_jens/include/js/ListView.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/ListView.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/ListView.js Mon Apr 16 12:27:44 2007
@@ -1,151 +1,161 @@
-/*********************************************************************************
-
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
- ********************************************************************************/
-function change(obj,divid)
-{
-	var select_options  =  document.getElementsByName('selected_id');
-	var x = select_options.length;
-	var viewid =getviewId();		
-	idstring = "";
-
-	xx = 0;
-	for(i = 0; i < x ; i++)
-	{
-		if(select_options[i].checked)
-		{
-			idstring = select_options[i].value +";"+idstring
-				xx++
+/*********************************************************************************
+
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ ********************************************************************************/
+function change(obj,divid)
+{
+	var select_options  =  document.getElementsByName('selected_id');
+	var x = select_options.length;
+	var viewid =getviewId();		
+	idstring = "";
+
+	xx = 0;
+	for(i = 0; i < x ; i++)
+	{
+		if(select_options[i].checked)
+		{
+			idstring = select_options[i].value +";"+idstring
+				xx++
+		}
+	}
+	if (xx != 0)
+	{
+		document.getElementById('idlist').value=idstring;
+	}
+	else
+	{
+		alert(alert_arr.SELECT);
+		return false;
+	}
+	fnvshobj(obj,divid);
+}
+function getviewId()
+{
+	if(typeof(document.getElementById("viewname")) != 'undefined')
+	{
+		var oViewname = document.getElementById("viewname");
+		if( oViewname.selectedIndex >= 0) {
+		    var viewid = oViewname.options[oViewname.selectedIndex].value;
+		} else {
+		    var viewid ='';		
 		}
-	}
-	if (xx != 0)
-	{
-		document.getElementById('idlist').value=idstring;
-	}
-	else
-	{
-		alert("Please select at least one entity");
-		return false;
-	}
-	fnvshobj(obj,divid);
-}
-function getviewId()
-{
-	if(typeof(document.getElementById("viewname")) != 'undefined')
-	{
-		var oViewname = document.getElementById("viewname");
-		if( oViewname.selectedIndex >= 0) {
-		    var viewid = oViewname.options[oViewname.selectedIndex].value;
-		} else {
-		    var viewid ='';		
-		}
-	}
-	else
-	{
-		var viewid ='';		
-	}
-	return viewid;	
-}
-function massDelete(module)
-{
-		var select_options  =  document.getElementsByName('selected_id');
-		var x = select_options.length;
-		var viewid =getviewId();		
-		idstring = "";
-
-        xx = 0;
-        for(i = 0; i < x ; i++)
-        {
-        	if(select_options[i].checked)
-            {
-            	idstring = select_options[i].value +";"+idstring
-                xx++
-            }
-        }
-        if (xx != 0)
-        {
-            document.getElementById('idlist').value=idstring;
-        }
-        else
-        {
-            alert("Please select at least one entity");
-            return false;
-        }
-		if(confirm("Are you sure you want to delete the selected "+xx+" records ?"))
-		{
-			
-			$("status").style.display="inline";
-			new Ajax.Request(
-          	  	      'index.php',
-			      	{queue: {position: 'end', scope: 'command'},
-		                        method: 'post',
-                		        postBody:"module=Users&action=massdelete&return_module="+module+"&viewname="+viewid+"&idlist="+idstring,
-		                        onComplete: function(response) {
-        	        	                $("status").style.display="none";
-                	        	        result = response.responseText.split('&#&#&#');
-                        	        	$("ListViewContents").innerHTML= result[2];
-	                        	        if(result[1] != '')
-                                        		alert(result[1]);
-		                        }
-              			 }
-       			);
-		}
-		else
-		{
-			return false;
-		}
-
-}
-
-function showDefaultCustomView(selectView,module)
-{
-	$("status").style.display="inline";
-	var viewName = selectView.options[selectView.options.selectedIndex].value;
-	new Ajax.Request(
-               	'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                       	method: 'post',
-                        postBody:"module="+module+"&action="+module+"Ajax&file=ListView&ajax=true&start=1&viewname="+viewName,
-                        onComplete: function(response) {
-                        $("status").style.display="none";
-                        result = response.responseText.split('&#&#&#');
-                        $("ListViewContents").innerHTML= result[2];
-                        if(result[1] != '')
-                               	alert(result[1]);
-			$('basicsearchcolumns_real').innerHTML = $('basicsearchcolumns').innerHTML
-			$('basicsearchcolumns').innerHTML = '';
-			document.basicSearch.search_text.value = '';
-                        }
-                }
-	);
-}
-
-
-function getListViewEntries_js(module,url)
-{
-	$("status").style.display="inline";
-	if($('search_url').value!='')
-                urlstring = $('search_url').value;
-	else
-		urlstring = '';
-        new Ajax.Request(
-        	'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                	method: 'post',
-                        postBody:"module="+module+"&action="+module+"Ajax&file=ListView&ajax=true&"+url+urlstring,
-			onComplete: function(response) {
-                        	$("status").style.display="none";
-                                result = response.responseText.split('&#&#&#');
-                                $("ListViewContents").innerHTML= result[2];
-                                if(result[1] != '')
-                                        alert(result[1]);
-                  	}
-                }
-        );
-}
-
+	}
+	else
+	{
+		var viewid ='';		
+	}
+	return viewid;	
+}
+function massDelete(module)
+{
+		var select_options  =  document.getElementsByName('selected_id');
+		var x = select_options.length;
+		var viewid =getviewId();		
+		idstring = "";
+
+        xx = 0;
+        for(i = 0; i < x ; i++)
+        {
+        	if(select_options[i].checked)
+            {
+            	idstring = select_options[i].value +";"+idstring
+                xx++
+            }
+        }
+        if (xx != 0)
+        {
+            document.getElementById('idlist').value=idstring;
+        }
+        else
+        {
+            alert(alert_arr.SELECT);
+            return false;
+        }
+		var alert_str = alert_arr.DELETE + xx +alert_arr.RECORDS;
+
+		if(module=="Accounts")
+			alert_str = alert_arr.DELETE_ACCOUNT +xx+alert_arr.RECORDS;
+		else if(module=="Vendors")
+			alert_str = alert_arr.DELETE_VENDOR+xx+alert_arr.RECORDS;
+
+		if(confirm(alert_str))
+		{
+			
+			$("status").style.display="inline";
+			new Ajax.Request(
+          	  	      'index.php',
+			      	{queue: {position: 'end', scope: 'command'},
+		                        method: 'post',
+                		        postBody:"module=Users&action=massdelete&return_module="+module+"&viewname="+viewid+"&idlist="+idstring,
+		                        onComplete: function(response) {
+        	        	                $("status").style.display="none";
+                	        	        result = response.responseText.split('&#&#&#');
+                        	        	$("ListViewContents").innerHTML= result[2];
+	                        	        if(result[1] != '')
+                                        		alert(result[1]);
+
+						$('basicsearchcolumns').innerHTML = '';
+		                        }
+              			 }
+       			);
+		}
+		else
+		{
+			return false;
+		}
+
+}
+
+function showDefaultCustomView(selectView,module)
+{
+	$("status").style.display="inline";
+	var viewName = selectView.options[selectView.options.selectedIndex].value;
+	new Ajax.Request(
+               	'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                       	method: 'post',
+                        postBody:"module="+module+"&action="+module+"Ajax&file=ListView&ajax=true&start=1&viewname="+viewName,
+                        onComplete: function(response) {
+                        $("status").style.display="none";
+                        result = response.responseText.split('&#&#&#');
+                        $("ListViewContents").innerHTML= result[2];
+                        if(result[1] != '')
+                               	alert(result[1]);
+			$('basicsearchcolumns_real').innerHTML = $('basicsearchcolumns').innerHTML
+			$('basicsearchcolumns').innerHTML = '';
+			document.basicSearch.search_text.value = '';
+                        }
+                }
+	);
+}
+
+
+function getListViewEntries_js(module,url)
+{
+	$("status").style.display="inline";
+	if($('search_url').value!='')
+                urlstring = $('search_url').value;
+	else
+		urlstring = '';
+        new Ajax.Request(
+        	'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                	method: 'post',
+                        postBody:"module="+module+"&action="+module+"Ajax&file=ListView&ajax=true&"+url+urlstring,
+			onComplete: function(response) {
+                        	$("status").style.display="none";
+                                result = response.responseText.split('&#&#&#');
+                                $("ListViewContents").innerHTML= result[2];
+                                if(result[1] != '')
+                                        alert(result[1]);
+				$('basicsearchcolumns').innerHTML = '';
+                  	}
+                }
+        );
+}
+

Modified: vtigercrm/branches/5.1_jens/include/js/Mail.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/Mail.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/Mail.js Mon Apr 16 12:27:44 2007
@@ -31,7 +31,7 @@
 	}
 	else
 	{
-		alert("Please select at least one entity");
+		alert(alert_arr.SELECT);
 		return false;
 	}
 	allids = document.getElementById('idlist').value;	
@@ -63,7 +63,7 @@
 	}
 	else
 	{
-		alert("Please select at least one entity");
+		alert(alert_arr.SELECT);
 		return false;
 	}
 	document.massdelete.action="index.php?module=CustomView&action=SendMailAction&return_module="+module+"&return_action=index&viewname="+viewid;
@@ -79,7 +79,7 @@
 		window.close();
 	}else
 	{
-		alert('The Record '+parentname+' does\'t have email id' );
+		alert('"'+parentname+alert_arr.DOESNOT_HAVE_AN_MAILID);
 		return false;
 	}
 }	
@@ -111,7 +111,7 @@
 	}
 	else
 	{
-		alert('Please Select a mailid');
+		alert(alert_arr.SELECT_MAILID);
 	}
 }
 function sendmail(module,idstrings)

Modified: vtigercrm/branches/5.1_jens/include/js/Merge.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/Merge.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/Merge.js Mon Apr 16 12:27:44 2007
@@ -25,7 +25,7 @@
                 else
                 {
                 			
-                        alert("Please select at least one entity");
+                        alert(alert_arr.SELECT);
                         return false;
                 }
         }
@@ -47,7 +47,7 @@
                else
                 {
                 			
-                        alert("Please select at least one entity");
+                        alert(alert_arr.SELECT);
                         return false;
                 }
         }
@@ -59,7 +59,7 @@
 	
 	if(getObj('mergefile').value == '')
 	{
-	         alert("Please select a template to merge");
+	         alert(alert_arr.SELECT_TEMPLATE_TO_MERGE);
            	 return false;   
         }
         document.massdelete.action="index.php?module="+module+"&action=Merge&return_module="+module+"&return_action=index";

Modified: vtigercrm/branches/5.1_jens/include/js/QuickCreate.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/QuickCreate.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/QuickCreate.js Mon Apr 16 12:27:44 2007
@@ -16,7 +16,7 @@
 	if (fldType=="text") {
 		if (currObj.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) {
 
-       			alert(fldLabel+" cannot be empty")
+       			alert(fldLabel+alert_arr.CANNOT_BE_EMPTY)
 
 			currObj.focus()
 
@@ -30,7 +30,7 @@
 	} else {
 		if (currObj.value == "" ) {
 
-	                alert(fldLabel+" cannot be none")
+	                alert(fldLabel+alert_arr.CANNOT_BE_NONE)
 
         	        return false
 
@@ -73,7 +73,7 @@
 	}
 	
 	if (!re.test(currObj.value)) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		currObj.focus()
 		return false
 	}
@@ -91,19 +91,19 @@
 	yyyy=dateelements[2]
 	
 	if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		window.document.QcEditView[fldName].focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>29)) {//checking of no. of days in february month
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		window.document.QcEditView[fldName].focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		window.document.QcEditView[fldName].focus()
 		return false
 	}
@@ -114,7 +114,7 @@
 		case 6 : 
 		case 9 : 
 		case 11 :	if (dd>30) {
-						alert("Please enter a valid "+fldLabel)
+						alert(alert_arr.ENTER_VALID+fldLabel)
 						window.document.QcEditView[fldName].focus()
 						return false
 					}	
@@ -173,13 +173,13 @@
 	var val=window.document.QcEditView[fldName].value.replace(/^\s+/g, '').replace(/\s+$/g, '')
 	if (isNaN(val) || (val.indexOf(".")!=-1 && fldName != 'potential_amount')) 
 	{
-		alert("Invalid "+fldLabel)
+		alert(alert_arr.INVALID+fldLabel)
 		window.document.QcEditView[fldName].focus()
 		return false
 	} 
         else if( val < -2147483648 || val > 2147483647)
         {
-                alert(fldLabel +" is out of range");
+                alert(fldLabel +alert_arr.OUT_OF_RANGE);
                 return false;
         }
 
@@ -196,32 +196,32 @@
 	var ret=true
 	switch (type) {
 		case "L"  : if (val>=constval) {
-						alert(fldLabel+" should be less than "+constval)
+						alert(fldLabel+alert_arr.SHOULDBE_LESS+constval)
 						ret=false
 					}
 					break;
 		case "LE" :	if (val>constval) {
-					alert(fldLabel+" should be less than or equal to "+constval)
+					alert(fldLabel+alert_arr.SHOULDBE_LESS_EQUAL+constval)
 			        ret=false
 					}
 					break;
 		case "E"  :	if (val!=constval) {
-                                        alert(fldLabel+" should be equal to "+constval)
+                                        alert(fldLabel+alert_arr.SHOULDBE_EQUAL+constval)
                                         ret=false
                                 }
                                 break;
 		case "NE" : if (val==constval) {
-						 alert(fldLabel+" should not be equal to "+constval)
+						 alert(fldLabel+alert_arr.SHOULDNOTBE_EQUAL+constval)
 							ret=false
 					}
 					break;
 		case "G"  :	if (val<=constval) {
-							alert(fldLabel+" should be greater than "+constval)
+							alert(fldLabel+alert_arr.SHOULDBE_GREATER+constval)
 							ret=false
 					}
 					break;
 		case "GE" : if (val<constval) {
-							alert(fldLabel+" should be greater than or equal to "+constval)
+							alert(fldLabel+alert_arr.SHOULDBE_GREATER_EQUAL+constval)
 							ret=false
 					}
 					break;
@@ -243,19 +243,19 @@
 	yyyy=dateelements[2];
 	
 	if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		window.document.QcEditView[dateFldName].focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>29)) {//checking of no. of days in february month
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		window.document.QcEditView[dateFldName].focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		window.document.QcEditView[dateFldName].focus()
 		return false
 	}
@@ -266,7 +266,7 @@
 		case 6 : 
 		case 9 : 
 		case 11 :	if (dd>30) {
-						alert("Please enter a valid "+fldLabel)
+						alert(alert_arr.ENTER_VALID+fldLabel)
 						window.document.QcEditView[dateFldName].focus()
 						return false
 					}	
@@ -281,7 +281,7 @@
 	var currObj=window.document.QcEditView[timeFldName]
 	
 	if (hourval>23 || minval>59) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		currObj.focus()
 		return false
 	}

Modified: vtigercrm/branches/5.1_jens/include/js/customview.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/customview.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/customview.js Mon Apr 16 12:27:44 2007
@@ -1,392 +1,392 @@
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
- ********************************************************************************/
-
-function splitValues() {
-        var picklistObj=getObj("fldPickList")
-        var pickListContent=picklistObj.value
-        var pickListAry=new Array()
-        var i=0;
-
-        //Splitting up of Values
-        if (pickListContent.indexOf("\n")!=-1) {
-                while(pickListContent.length>0) {
-                        if(pickListContent.indexOf("\n")!=-1) {
-                                if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
-                                        pickListAry[i]=pickListContent.substr(0,pickListContent.indexOf("\n")).replace(/^\s+/g, '').replace(/\s+$/g, '')
-                                        pickListContent=pickListContent.substr(pickListContent.indexOf("\n")+1,pickListContent.length)
-                                        i++
-                                } else break;
-                        } else {
-                                pickListAry[i]=pickListContent.substr(0,pickListContent.length)
-                                break;
-                        }
-                }
-        } else if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
-                pickListAry[0]=pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '')
-        }
-
-        return pickListAry;
-}
-
-
-function validate() {
-	var nummaxlength = 255;
-        var fieldtype = document.getElementById('selectedfieldtype').value;
-	var mode = document.getElementById('cfedit_mode').value;
-        if(fieldtype == "" && mode != 'edit')
-	{
-		alert("Field Type is not selected");
-		return false;
-	}
-	lengthLayer=getObj("lengthdetails")
-        decimalLayer=getObj("decimaldetails")
-        pickListLayer=getObj("picklist")
-        var str = getObj("fldLabel").value;
-        if (!emptyCheck("fldLabel","Label"))
-                return false
-
-        var re1=/^[a-z\d\_ ]+$/i
-        if (!re1.test(str))
-        {
-                alert("Special characters are not allowed in Label field")
-                return false;
-        }
-
-        if (lengthLayer.style.visibility=="visible") {
-                if (!emptyCheck("fldLength","Length"))
-                        return false
-
-                if (!intValidate("fldLength","Length"))
-                        return false
-
-                if (!numConstComp("fldLength","Length","GT",0))
-                        return false
-
-        }
-
-        if (decimalLayer.style.visibility=="visible") {
-                if (getObj("fldDecimal").value.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0)
-                        if (!intValidate("fldDecimal","Decimal"))
-                                return false
-                if (!numConstComp("fldDecimal","Decimal","GE",0))
-                        return false
-
-                if (!numConstComp("fldDecimal","Decimal","LE",30))
-                        return false
-        }
-	var decimallength = document.addtodb.fldDecimal.value;
-        if(fieldtype == 'Percent' || fieldtype == 'Currency' || fieldtype == 'Number')
-        {
-                if(decimallength == '')
-                        decimallength = 0;
-                nummaxlength = 65 - (eval(decimallength) + 1);
-        }
-        if (!numConstComp("fldLength","Length","LE",nummaxlength))
-                return false
-var picklistObj=getObj("fldPickList")
-        if (pickListLayer.style.visibility=="visible") {
-                if (emptyCheck("fldPickList","Picklist values"))        {
-                        var pickListAry=new Array()
-                        pickListAry=splitValues()
-
-                        //Empty Check validation
-                        for (i=0;i<pickListAry.length;i++) {
-                                if (pickListAry[i]=="") {
-                                        alert("Picklist value cannot be empty")
-                                        picklistObj.focus()
-                                        return false
-                                }
-                        }
-
-                        //Duplicate Values' Validation
-                        for (i=0;i<pickListAry.length;i++) {
-                                for (j=i+1;j<pickListAry.length;j++) {
-                                        if (pickListAry[i]==pickListAry[j]) {
-                                                alert("Duplicate Values found")
-                                                picklistObj.focus()
-                                                return false
-                                        }
-                                }
-                        }
-
-                        return true
-                } else return false
-        }
-}
-var fieldValueArr=new Array('Text','Number','Percent','Currency','Date','Email','Phone','Picklist','URL','Checkbox','TextArea','MultiSelectCombo','Skype');
-var fieldTypeArr=new Array('text','number','percent','currency','date','email','phone','picklist','url','checkbox','textarea','multiselectcombo','skype');
-var currFieldIdx=0,totFieldType;
-var focusFieldType;
-
-function init() {
-        lengthLayer=getObj("lengthdetails")
-        decimalLayer=getObj("decimaldetails")
-        pickListLayer=getObj("picklist")
-        totFieldType=fieldTypeArr.length-1
-}
-
-
-function setVisible() {
-        if (focusFieldType==true) {
-                var selFieldType=fieldLayer.getObj("field"+currFieldIdx)
-                var height=findPosY(selFieldType)+selFieldType.offsetHeight
-
-                if (currFieldIdx==0) {
-                        fieldLayer.document.body.scrollTop=0
-                } else if (height>220) {
-                        fieldLayer.document.body.scrollTop+=height-220
-                } else {
-                        fieldLayer.document.body.scrollTop-=220-height
-                }
-
-                if (window.navigator.appName.toUpperCase()=="OPERA") {
-                                var newDiv=fieldLayer.document.createElement("DIV")
-                                newDiv.style.zIndex="-1"
-                                newDiv.style.position="absolute"
-                                newDiv.style.top=findPosY(selFieldType)+"px"
-                                newDiv.style.left="25px"
-
-                                var newObj=fieldLayer.document.createElement("INPUT")
-                                newObj.type="text"
-
-                                fieldLayer.document.body.appendChild(newDiv)
-                                newDiv.appendChild(newObj)
-                                newObj.focus()
-
-                                fieldLayer.document.body.removeChild(newDiv)
-                }
-        }
-}
-
-function selFieldType(id,scrollLayer,bool) {
-        currFieldIdx=id
-        var type=fieldTypeArr[id]
-	var lengthLayer=getObj("lengthdetails");
-	var decimalLayer=getObj("decimaldetails");
-	var pickListLayer=getObj("picklist");
-        if (type=='text') {
-                lengthLayer.style.visibility="visible"
-                decimalLayer.style.visibility="hidden"
-                pickListLayer.style.visibility="hidden"
-        } else if (type=='date' || type=='email' || type=='phone' || type=='url' || type=='checkbox' || type=='textarea' || type=='skype') {
-                getObj("lengthdetails").style.visibility="hidden"
-                decimalLayer.style.visibility="hidden"
-                pickListLayer.style.visibility="hidden"
-        } else if (type=='number' || type=='percent' || type=='currency') {
-                lengthLayer.style.visibility="visible"
-                decimalLayer.style.visibility="visible"
-                pickListLayer.style.visibility="hidden"
-        } else if (type=='picklist' || type=='multiselectcombo') {
-                lengthLayer.style.visibility="hidden"
-                decimalLayer.style.visibility="hidden"
-                pickListLayer.style.visibility="visible"
-        }
-
-
-        parent.getObj("fieldType").value = fieldValueArr[id];
-}
-
-function srchFieldType(ev) {
-        if (browser_ie) {
-                var keyCode=window.fieldLayer.event.keyCode
-                var currElement=window.fieldLayer.event.srcElement
-                if (currElement.id.indexOf("field")>=0) var doSearch=true
-                else var doSearch=false
-                window.fieldLayer.event.cancelBubble=true
-        } else if (browser_nn4 || browser_nn6) {
-                var keyCode=ev.which
-                var currElement=ev.target
-                if (currElement.type) doSearch=false
-                else doSearch=true
-        }
-
-        if (doSearch==true) {
-                switch (keyCode) {
-                        case 9  : //Reset Field Type
-                                                resetFieldTypeHilite();break;
-                        case 33 : //Page Up
-                        case 36 : //Home
-                                                selFieldType(0);break;
-                        case 34 : //Page Down
-                        case 35 : //End
-                                                selFieldType(totFieldType);break;
-                        case 38 : //Up
-                                                if (currFieldIdx!=0)
-                                                        selFieldType(currFieldIdx-1);
-                                                else
-                                                        selFieldType(totFieldType,"yes");
-                                                break;
-                        case 40 : //Down
-                                                if (currFieldIdx!=totFieldType)
-                                                        selFieldType(currFieldIdx+1);
-                                                else
-                                                        selFieldType(0,"yes");
-default : //Character Search
-                                                if (keyCode>=65 && keyCode<=90) {
-                                                        var srchChar=String.fromCharCode(keyCode)
-                                                        if (currFieldIdx==totFieldType) var startIdx=0
-                                                        else var startIdx=currFieldIdx+1
-
-                                                        var loop=1
-                                                        for (i=startIdx;i<=totFieldType;) {
-                                                                currFieldStr=fieldLayer.getObj("field"+i).innerHTML
-                                                                currFieldStr=currFieldStr.replace(/^\s+/g, '').replace(/\s+$/g, '').substr(0,1)
-                                                                if (currFieldStr==srchChar) {
-                                                                        selFieldType(i,"yes")
-                                                                        i++
-                                                                } else if (i==totFieldType && loop<=2) {
-                                                                        i=0
-                                                                        loop++
-                                                                } else i++
-                                                        }
-                                           }
-                }
-        }
-}
-function resetFieldTypeHilite() {
-        fieldLayer.getObj("field"+currFieldIdx).className="fieldType sel"
-}
-function validateCustomFieldAccounts()
-        {
-                var obj=document.getElementsByTagName("SELECT");
-                var i,j=0,k=0,l=0;
-                var n=obj.length;
-                account = new Array;
-                contact =  new Array;
-                potential = new Array;
-                for( i = 0; i < n; i++)
-                {
-                        if(obj[i].name.indexOf("_account")>0)
-                        {
-                                account[j]=obj[i].value;
-                                j++;
-                        }
-                        if(obj[i].name.indexOf("_contact")>0)
-                        {
-                                contact[k]=obj[i].value;
-                                k++;
-                        }
-                        if(obj[i].name.indexOf("_potential")>0)
-                        {
-                                potential[l]=obj[i].value;
-                                l++;
-                        }
-                }
-                for( i = 0; i < account.length; i++)
-                {
-                        for(j=i+1; j<account.length; j++)
-                        {
-                                if( account[i] == account[j] && account[i]!="None" && account[j] !="None")
-                                {
-                                        alert("Duplicate mapping for accounts!!");
-                                        return false;
-                                }
-                        }
-                }
-for( i = 0; i < contact.length; i++)
-                {
-                        for(k=i+1; k< contact.length; k++)
-                        {
-                                if( contact[i] == contact[k] && contact[i]!="None" && contact[k]!="None")
-                                {
-                                        alert("Duplicate mapping for Contacts!!");
-                                        return false;
-                                }
-                        }
-                }
-                for( i = 0; i < potential.length; i++)
-                {
-                        for(l=i+1; l<potential.length; l++)
-                        {
-                                if( potential[i] == potential[l] && potential[i]!="None" && potential[l]!="None")
-                                {
-                                        alert("Duplicate mapping for Potential!!");
-                                        return false;
-                                }
-                        }
-
-                }
-        }
-
-
-function gotourl(url)
-{
-                document.location.href=url;
-}
-
-function validateTypeforCFMapping(leadtype,leadtypeofdata,field_name,cf_form)
-{
-	var combo_val = cf_form.options[cf_form.selectedIndex].value;
-	if(combo_val != 'None')
-	{
-		var type = document.getElementById(combo_val+"_type").value;
-		var typeofdata = document.getElementById(combo_val+"_typeofdata").value;
-		if(leadtype == type)
-		{
-			if(leadtypeofdata == typeofdata)
-			{
-				return true;
-			}
-			else
-			{
-				var lead_tod = leadtypeofdata.split("~");
-				var tod = typeofdata.split("~");
-				switch (lead_tod[0]) {
-                	                case "V"  :
-						if(lead_tod[3] <= tod[3])
-							return true;
-						else
-						{
-							alert(alertmessage[3]);
-							document.getElementById(field_name).value = 'None';
-							return false;
-						}
-						break;
-					case "N"  :
-						if(lead_tod[2].indexOf(",")>0)
-						{
-							var lead_dec = lead_tod[2].split(",");
-							var dec = tod[2].split(",");
-						
-						}
-						else
-						{
-							var lead_dec = lead_tod[2].split("~");
-                	                                var dec = tod[2].split("~");
-						}
-						if(lead_dec[0] <= dec[0])
-						{
-							if(lead_dec[1] <= dec[1])
-								return true;
-							else
-							{
-								alert(alertmessage[4]);
-								document.getElementById(field_name).value = 'None';
-								return false;
-							}
-						}
-						else
-						{
-							alert(alertmessage[3]);
-							document.getElementById(field_name).value = 'None';
-							return false;
-						}
-						break;
-				}	
-			}
-		}
-		else
-		{
-			alert(alertmessage[0]+" "+leadtype+" "+alertmessage[1]+" "+type+" "+alertmessage[2]);
-			document.getElementById(field_name).value = 'None';
-			return false;
-		}
-	}
-}
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+ ********************************************************************************/
+
+function splitValues() {
+        var picklistObj=getObj("fldPickList")
+        var pickListContent=picklistObj.value
+        var pickListAry=new Array()
+        var i=0;
+
+        //Splitting up of Values
+        if (pickListContent.indexOf("\n")!=-1) {
+                while(pickListContent.length>0) {
+                        if(pickListContent.indexOf("\n")!=-1) {
+                                if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
+                                        pickListAry[i]=pickListContent.substr(0,pickListContent.indexOf("\n")).replace(/^\s+/g, '').replace(/\s+$/g, '')
+                                        pickListContent=pickListContent.substr(pickListContent.indexOf("\n")+1,pickListContent.length)
+                                        i++
+                                } else break;
+                        } else {
+                                pickListAry[i]=pickListContent.substr(0,pickListContent.length)
+                                break;
+                        }
+                }
+        } else if (pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0) {
+                pickListAry[0]=pickListContent.replace(/^\s+/g, '').replace(/\s+$/g, '')
+        }
+
+        return pickListAry;
+}
+
+
+function validate() {
+	var nummaxlength = 255;
+        var fieldtype = document.getElementById('selectedfieldtype').value;
+	var mode = document.getElementById('cfedit_mode').value;
+        if(fieldtype == "" && mode != 'edit')
+	{
+		alert(alert_arr.FIELD_TYPE_NOT_SELECTED);
+		return false;
+	}
+	lengthLayer=getObj("lengthdetails")
+        decimalLayer=getObj("decimaldetails")
+        pickListLayer=getObj("picklist")
+        var str = getObj("fldLabel").value;
+        if (!emptyCheck("fldLabel","Label","text"))
+                return false
+
+        var re1=/^[a-z\d\_ ]+$/i
+        if (!re1.test(str))
+        {
+                alert(alert_arr.SPECIAL_CHARACTERS_NOT_ALLOWED)
+                return false;
+        }
+
+        if (lengthLayer.style.visibility=="visible") {
+                if (!emptyCheck("fldLength","Length"))
+                        return false
+
+                if (!intValidate("fldLength","Length"))
+                        return false
+
+                if (!numConstComp("fldLength","Length","GT",0))
+                        return false
+
+        }
+
+        if (decimalLayer.style.visibility=="visible") {
+                if (getObj("fldDecimal").value.replace(/^\s+/g, '').replace(/\s+$/g, '').length>0)
+                        if (!intValidate("fldDecimal","Decimal"))
+                                return false
+                if (!numConstComp("fldDecimal","Decimal","GE",0))
+                        return false
+
+                if (!numConstComp("fldDecimal","Decimal","LE",30))
+                        return false
+        }
+	var decimallength = document.addtodb.fldDecimal.value;
+        if(fieldtype == 'Percent' || fieldtype == 'Currency' || fieldtype == 'Number')
+        {
+                if(decimallength == '')
+                        decimallength = 0;
+                nummaxlength = 65 - (eval(decimallength) + 1);
+        }
+        if (!numConstComp("fldLength","Length","LE",nummaxlength))
+                return false
+var picklistObj=getObj("fldPickList")
+        if (pickListLayer.style.visibility=="visible") {
+                if (emptyCheck("fldPickList","Picklist values"))        {
+                        var pickListAry=new Array()
+                        pickListAry=splitValues()
+
+                        //Empty Check validation
+                        for (i=0;i<pickListAry.length;i++) {
+                                if (pickListAry[i]=="") {
+                                        alert(alert_arr.PICKLIST_CANNOT_BE_EMPTY)
+                                        picklistObj.focus()
+                                        return false
+                                }
+                        }
+
+                        //Duplicate Values' Validation
+                        for (i=0;i<pickListAry.length;i++) {
+                                for (j=i+1;j<pickListAry.length;j++) {
+                                        if (pickListAry[i]==pickListAry[j]) {
+                                                alert(alert_arr.DUPLICATE_VALUES_FOUND)
+                                                picklistObj.focus()
+                                                return false
+                                        }
+                                }
+                        }
+
+                        return true
+                } else return false
+        }
+}
+var fieldValueArr=new Array('Text','Number','Percent','Currency','Date','Email','Phone','Picklist','URL','Checkbox','TextArea','MultiSelectCombo','Skype');
+var fieldTypeArr=new Array('text','number','percent','currency','date','email','phone','picklist','url','checkbox','textarea','multiselectcombo','skype');
+var currFieldIdx=0,totFieldType;
+var focusFieldType;
+
+function init() {
+        lengthLayer=getObj("lengthdetails")
+        decimalLayer=getObj("decimaldetails")
+        pickListLayer=getObj("picklist")
+        totFieldType=fieldTypeArr.length-1
+}
+
+
+function setVisible() {
+        if (focusFieldType==true) {
+                var selFieldType=fieldLayer.getObj("field"+currFieldIdx)
+                var height=findPosY(selFieldType)+selFieldType.offsetHeight
+
+                if (currFieldIdx==0) {
+                        fieldLayer.document.body.scrollTop=0
+                } else if (height>220) {
+                        fieldLayer.document.body.scrollTop+=height-220
+                } else {
+                        fieldLayer.document.body.scrollTop-=220-height
+                }
+
+                if (window.navigator.appName.toUpperCase()=="OPERA") {
+                                var newDiv=fieldLayer.document.createElement("DIV")
+                                newDiv.style.zIndex="-1"
+                                newDiv.style.position="absolute"
+                                newDiv.style.top=findPosY(selFieldType)+"px"
+                                newDiv.style.left="25px"
+
+                                var newObj=fieldLayer.document.createElement("INPUT")
+                                newObj.type="text"
+
+                                fieldLayer.document.body.appendChild(newDiv)
+                                newDiv.appendChild(newObj)
+                                newObj.focus()
+
+                                fieldLayer.document.body.removeChild(newDiv)
+                }
+        }
+}
+
+function selFieldType(id,scrollLayer,bool) {
+        currFieldIdx=id
+        var type=fieldTypeArr[id]
+	var lengthLayer=getObj("lengthdetails");
+	var decimalLayer=getObj("decimaldetails");
+	var pickListLayer=getObj("picklist");
+        if (type=='text') {
+                lengthLayer.style.visibility="visible"
+                decimalLayer.style.visibility="hidden"
+                pickListLayer.style.visibility="hidden"
+        } else if (type=='date' || type=='email' || type=='phone' || type=='url' || type=='checkbox' || type=='textarea' || type=='skype') {
+                getObj("lengthdetails").style.visibility="hidden"
+                decimalLayer.style.visibility="hidden"
+                pickListLayer.style.visibility="hidden"
+        } else if (type=='number' || type=='percent' || type=='currency') {
+                lengthLayer.style.visibility="visible"
+                decimalLayer.style.visibility="visible"
+                pickListLayer.style.visibility="hidden"
+        } else if (type=='picklist' || type=='multiselectcombo') {
+                lengthLayer.style.visibility="hidden"
+                decimalLayer.style.visibility="hidden"
+                pickListLayer.style.visibility="visible"
+        }
+
+
+        parent.getObj("fieldType").value = fieldValueArr[id];
+}
+
+function srchFieldType(ev) {
+        if (browser_ie) {
+                var keyCode=window.fieldLayer.event.keyCode
+                var currElement=window.fieldLayer.event.srcElement
+                if (currElement.id.indexOf("field")>=0) var doSearch=true
+                else var doSearch=false
+                window.fieldLayer.event.cancelBubble=true
+        } else if (browser_nn4 || browser_nn6) {
+                var keyCode=ev.which
+                var currElement=ev.target
+                if (currElement.type) doSearch=false
+                else doSearch=true
+        }
+
+        if (doSearch==true) {
+                switch (keyCode) {
+                        case 9  : //Reset Field Type
+                                                resetFieldTypeHilite();break;
+                        case 33 : //Page Up
+                        case 36 : //Home
+                                                selFieldType(0);break;
+                        case 34 : //Page Down
+                        case 35 : //End
+                                                selFieldType(totFieldType);break;
+                        case 38 : //Up
+                                                if (currFieldIdx!=0)
+                                                        selFieldType(currFieldIdx-1);
+                                                else
+                                                        selFieldType(totFieldType,"yes");
+                                                break;
+                        case 40 : //Down
+                                                if (currFieldIdx!=totFieldType)
+                                                        selFieldType(currFieldIdx+1);
+                                                else
+                                                        selFieldType(0,"yes");
+default : //Character Search
+                                                if (keyCode>=65 && keyCode<=90) {
+                                                        var srchChar=String.fromCharCode(keyCode)
+                                                        if (currFieldIdx==totFieldType) var startIdx=0
+                                                        else var startIdx=currFieldIdx+1
+
+                                                        var loop=1
+                                                        for (i=startIdx;i<=totFieldType;) {
+                                                                currFieldStr=fieldLayer.getObj("field"+i).innerHTML
+                                                                currFieldStr=currFieldStr.replace(/^\s+/g, '').replace(/\s+$/g, '').substr(0,1)
+                                                                if (currFieldStr==srchChar) {
+                                                                        selFieldType(i,"yes")
+                                                                        i++
+                                                                } else if (i==totFieldType && loop<=2) {
+                                                                        i=0
+                                                                        loop++
+                                                                } else i++
+                                                        }
+                                           }
+                }
+        }
+}
+function resetFieldTypeHilite() {
+        fieldLayer.getObj("field"+currFieldIdx).className="fieldType sel"
+}
+function validateCustomFieldAccounts()
+        {
+                var obj=document.getElementsByTagName("SELECT");
+                var i,j=0,k=0,l=0;
+                var n=obj.length;
+                account = new Array;
+                contact =  new Array;
+                potential = new Array;
+                for( i = 0; i < n; i++)
+                {
+                        if(obj[i].name.indexOf("_account")>0)
+                        {
+                                account[j]=obj[i].value;
+                                j++;
+                        }
+                        if(obj[i].name.indexOf("_contact")>0)
+                        {
+                                contact[k]=obj[i].value;
+                                k++;
+                        }
+                        if(obj[i].name.indexOf("_potential")>0)
+                        {
+                                potential[l]=obj[i].value;
+                                l++;
+                        }
+                }
+                for( i = 0; i < account.length; i++)
+                {
+                        for(j=i+1; j<account.length; j++)
+                        {
+                                if( account[i] == account[j] && account[i]!="None" && account[j] !="None")
+                                {
+                                        alert(alert_arr.DUPLICATE_MAPPING_ACCOUNTS);
+                                        return false;
+                                }
+                        }
+                }
+for( i = 0; i < contact.length; i++)
+                {
+                        for(k=i+1; k< contact.length; k++)
+                        {
+                                if( contact[i] == contact[k] && contact[i]!="None" && contact[k]!="None")
+                                {
+                                        alert(alert_arr.DUPLICATE_MAPPING_CONTACTS);
+                                        return false;
+                                }
+                        }
+                }
+                for( i = 0; i < potential.length; i++)
+                {
+                        for(l=i+1; l<potential.length; l++)
+                        {
+                                if( potential[i] == potential[l] && potential[i]!="None" && potential[l]!="None")
+                                {
+                                        alert(alert_arr.DUPLICATE_MAPPING_POTENTIAL);
+                                        return false;
+                                }
+                        }
+
+                }
+        }
+
+
+function gotourl(url)
+{
+                document.location.href=url;
+}
+
+function validateTypeforCFMapping(leadtype,leadtypeofdata,field_name,cf_form)
+{
+	var combo_val = cf_form.options[cf_form.selectedIndex].value;
+	if(combo_val != 'None')
+	{
+		var type = document.getElementById(combo_val+"_type").value;
+		var typeofdata = document.getElementById(combo_val+"_typeofdata").value;
+		if(leadtype == type)
+		{
+			if(leadtypeofdata == typeofdata)
+			{
+				return true;
+			}
+			else
+			{
+				var lead_tod = leadtypeofdata.split("~");
+				var tod = typeofdata.split("~");
+				switch (lead_tod[0]) {
+                	                case "V"  :
+						if(lead_tod[3] <= tod[3])
+							return true;
+						else
+						{
+							alert(alertmessage[3]);
+							document.getElementById(field_name).value = 'None';
+							return false;
+						}
+						break;
+					case "N"  :
+						if(lead_tod[2].indexOf(",")>0)
+						{
+							var lead_dec = lead_tod[2].split(",");
+							var dec = tod[2].split(",");
+						
+						}
+						else
+						{
+							var lead_dec = lead_tod[2].split("~");
+                	                                var dec = tod[2].split("~");
+						}
+						if(lead_dec[0] <= dec[0])
+						{
+							if(lead_dec[1] <= dec[1])
+								return true;
+							else
+							{
+								alert(alertmessage[4]);
+								document.getElementById(field_name).value = 'None';
+								return false;
+							}
+						}
+						else
+						{
+							alert(alertmessage[3]);
+							document.getElementById(field_name).value = 'None';
+							return false;
+						}
+						break;
+				}	
+			}
+		}
+		else
+		{
+			alert(alertmessage[0]+" "+leadtype+" "+alertmessage[1]+" "+type+" "+alertmessage[2]);
+			document.getElementById(field_name).value = 'None';
+			return false;
+		}
+	}
+}

Modified: vtigercrm/branches/5.1_jens/include/js/dtlviewajax.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/dtlviewajax.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/dtlviewajax.js Mon Apr 16 12:27:44 2007
@@ -1,420 +1,478 @@
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-var globaldtlviewspanid = "";
-var globaleditareaspanid = ""; 
-var globaltxtboxid = "";
-var itsonview=false;
-// to retain the old value if we cancel the ajax edit
-var globaltempvalue = '';
-var globaluitype = '';
-function showHide(showId, hideId)
-{
-	show(showId);
-	fnhide(hideId);
-}
-
-function hndCancel(valuespanid,textareapanid,fieldlabel)
-{
-
-  showHide(valuespanid,textareapanid);
-  if(globaluitype == '56')
-  {	  
-	  if(globaltempvalue == 1)
-	  	getObj(globaltxtboxid).checked = true; 
-	  else		
-	  	getObj(globaltxtboxid).checked = false; 
-  }
-  else if(globaluitype != '53')	  
-	  getObj(globaltxtboxid).value = globaltempvalue; 
-  globaltempvalue = '';
-  itsonview=false;
-  return false;
-}
-
-function hndMouseOver(uitype,fieldLabel)
-{
-      var mouseArea="";
-      mouseArea="mouseArea_"+ fieldLabel;
-      if(itsonview)
-      {
-            return;
-      }
-      
-      show("crmspanid");
-	  globaluitype = uitype;
-      globaldtlviewspanid= "dtlview_"+ fieldLabel;//valuespanid;
-      globaleditareaspanid="editarea_"+ fieldLabel;//textareapanid;
-	  globalfieldlabel = fieldLabel;
-	  if(globaluitype == 53)
-	  {
-		  if(typeof(document.DetailView.assigntype[0]) != 'undefined')
-		  {
-			  var assign_type_U = document.DetailView.assigntype[0].checked;
-			  var assign_type_G = document.DetailView.assigntype[1].checked;
-			  if(assign_type_U == true)
-				  globaltxtboxid= 'txtbox_U'+fieldLabel;
-			  else if(assign_type_G == true)
-				  globaltxtboxid= 'txtbox_G'+fieldLabel;
-		  }else
-		  {
-			  globaltxtboxid= 'txtbox_U'+fieldLabel;
-		  }
-	  }else
-	  {
-      	  globaltxtboxid="txtbox_"+ fieldLabel;//textboxpanid;
-	  }
-      divObj = getObj('crmspanid'); 
-      crmy = findPosY(getObj(mouseArea));
-      crmx = findPosX(getObj(mouseArea));
-      if(document.all)
-      {
-          divObj.onclick=handleEdit;
-      }
-      else
-      {
-          divObj.setAttribute('onclick','handleEdit();');
-      }
-      divObj.style.left=(crmx+getObj(mouseArea).offsetWidth -divObj.offsetWidth)+"px";
-      divObj.style.top=crmy+"px";
-}
-
-function handleEdit()
-{
-     show(globaleditareaspanid) ;
-     fnhide(globaldtlviewspanid);
-	 if(globaluitype != 53)
-	 {
-		globaltempvalue = getObj(globaltxtboxid).value;
-		if(getObj(globaltxtboxid).type != 'hidden')
-	     	 	getObj(globaltxtboxid).focus();
-	 }
-     fnhide('crmspanid');
-     itsonview=true;
-     return false;
-}
-
-function trim(str)
-{
-	return(str.replace(/\s+$/,''));
-}
-
-var genUiType = "";
-var genFldValue = "";
-
-function dtlViewAjaxSave(fieldLabel,module,uitype,tableName,fieldName,crmId)
-{
-	var dtlView = "dtlview_"+ fieldLabel;
-	var editArea = "editarea_"+ fieldLabel;
-	var groupurl = "";
-	
-	if(globaluitype == 53)
-	{
-		if(typeof(document.DetailView.assigntype[0]) != 'undefined')
-		{
-			var assign_type_U = document.DetailView.assigntype[0].checked;
-			var assign_type_G = document.DetailView.assigntype[1].checked;
-		}else
-		{
-			var assign_type_U = document.DetailView.assigntype.checked;
-		}
-		if(assign_type_U == true)
-		{
-			var txtBox= 'txtbox_U'+fieldLabel;
-		}
-		else if(assign_type_G == true)
-		{
-			var txtBox= 'txtbox_G'+fieldLabel;
-			var group_name = $(txtBox).options[$(txtBox).selectedIndex].text; 
-			var groupurl = "&assigned_group_name="+group_name+"&assigntype=T"
-		}
-
-	}else if(globaluitype == 14 || globaluitype == 33 || globaluitype == 34)
-	{
-	  var txtBox= "txtbox_"+ fieldLabel;
-	  var oMulSelect = $(txtBox);
-	  var r = new Array();
-	  for (iter=0;iter < oMulSelect.options.length ; iter++)
-	  {
-      if (oMulSelect.options[iter].selected)
-        r[r.length] = oMulSelect.options[iter].value;
-      }
-	}else
-	{
-		var txtBox= "txtbox_"+ fieldLabel;
-	}
-	
-	var popupTxt= "popuptxt_"+ fieldLabel;      
-	var hdTxt = "hdtxt_"+ fieldLabel;
-
-	if(formValidate() == false)
-	{
-		return false;
-	}
-
-
-	$("vtbusy_info").style.display="inline";
-	var isAdmin = document.getElementById("hdtxt_IsAdmin").value; 
-
-
-	//overriden the tagValue based on UI Type for checkbox 
-	if(uitype == '56')
-	{
-		if(document.getElementById(txtBox).checked == true)
-		{
-			tagValue = "1";
-		}else
-		{
-			tagValue = "0";
-		}
-	}else	if(uitype == '156')
-	{
-		if(document.getElementById(txtBox).checked == true)
-		{
-			tagValue = "on";
-		}else
-		{
-			tagValue = "off";
-		}
-	}else if(uitype == 14 || uitype == '33' || uitype == '34')
-	{
-		tagValue = r.join(" |##| ");
-  	}else
-	{
-		tagValue = trim(document.getElementById(txtBox).value);
-	}
-
-	if(uitype == '3' || uitype == '4' || uitype == '18' || uitype == '31' || uitype == '32') {
-	    if(document.getElementById(txtBox+"_inh").checked) {
-		tagValue = "@##@" + tagValue;
-	    }
-	}
-
-	var data = "file=DetailViewAjax&module=" + module + "&action=" + module + "Ajax&record=" + crmId+"&recordid=" + crmId ;
-	data = data + "&fldName=" + fieldName + "&fieldValue=" + escape(tagValue) + "&ajxaction=DETAILVIEW"+groupurl;
-	data = data + "&tableName=" + tableName;
-	new Ajax.Request(
-		'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: data,
-                        onComplete: function(response) {
-                  				if(response.responseText.indexOf(":#:FAILURE")>-1)
-                  				{
-                  					alert("Error while Editing");
-                  				}
-                  				else if(response.responseText.indexOf(":#:SUCCESS")>-1)
-                       		{
-                  					$("vtbusy_info").style.display="none";
-                       		}
-                        }
-                }
-            );
-	if(uitype == '13' || uitype == '104')
-	{
-		getObj(dtlView).innerHTML = "<a href=\"mailto:"+ tagValue+"\" target=\"_blank\">"+tagValue+"&nbsp;</a>";
-	}else if(uitype == '17')
-	{
-		getObj(dtlView).innerHTML = "<a href=\"http://"+ tagValue+"\" target=\"_blank\">"+tagValue+"&nbsp;</a>";
-	}else if(uitype == '34' || (uitype == '115' && fieldName == 'primary_org'))
-	{
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+var globaldtlviewspanid = "";
+var globaleditareaspanid = ""; 
+var globaltxtboxid = "";
+var itsonview=false;
+// to retain the old value if we cancel the ajax edit
+var globaltempvalue = '';
+var globaluitype = '';
+function showHide(showId, hideId)
+{
+	show(showId);
+	fnhide(hideId);
+}
+
+function hndCancel(valuespanid,textareapanid,fieldlabel)
+{
+
+  showHide(valuespanid,textareapanid);
+  if(globaluitype == '56')
+  {	  
+	  if(globaltempvalue == 1)
+	  	getObj(globaltxtboxid).checked = true; 
+	  else		
+	  	getObj(globaltxtboxid).checked = false; 
+  }
+  else if(globaluitype != '53')	  
+	  getObj(globaltxtboxid).value = globaltempvalue; 
+  globaltempvalue = '';
+  itsonview=false;
+  return false;
+}
+
+function hndMouseOver(uitype,fieldLabel)
+{
+      var mouseArea="";
+      mouseArea="mouseArea_"+ fieldLabel;
+      if(itsonview)
+      {
+            return;
+      }
+      
+      show("crmspanid");
+	  globaluitype = uitype;
+      globaldtlviewspanid= "dtlview_"+ fieldLabel;//valuespanid;
+      globaleditareaspanid="editarea_"+ fieldLabel;//textareapanid;
+	  globalfieldlabel = fieldLabel;
+	  if(globaluitype == 53)
+	  {
+		  if(typeof(document.DetailView.assigntype[0]) != 'undefined')
+		  {
+			  var assign_type_U = document.DetailView.assigntype[0].checked;
+			  var assign_type_G = document.DetailView.assigntype[1].checked;
+			  if(assign_type_U == true)
+				  globaltxtboxid= 'txtbox_U'+fieldLabel;
+			  else if(assign_type_G == true)
+				  globaltxtboxid= 'txtbox_G'+fieldLabel;
+		  }else
+		  {
+			  globaltxtboxid= 'txtbox_U'+fieldLabel;
+		  }
+	  }else
+	  {
+      	  globaltxtboxid="txtbox_"+ fieldLabel;//textboxpanid;
+	  }
+      divObj = getObj('crmspanid'); 
+      crmy = findPosY(getObj(mouseArea));
+      crmx = findPosX(getObj(mouseArea));
+      if(document.all)
+      {
+          divObj.onclick=handleEdit;
+      }
+      else
+      {
+          divObj.setAttribute('onclick','handleEdit();');
+      }
+      divObj.style.left=(crmx+getObj(mouseArea).offsetWidth -divObj.offsetWidth)+"px";
+      divObj.style.top=crmy+"px";
+}
+
+function handleEdit()
+{
+     show(globaleditareaspanid) ;
+     fnhide(globaldtlviewspanid);
+	 if(globaluitype != 53)
+	 {
+		globaltempvalue = getObj(globaltxtboxid).value;
+		if(getObj(globaltxtboxid).type != 'hidden')
+	     	 	getObj(globaltxtboxid).focus();
+	 }
+     fnhide('crmspanid');
+     itsonview=true;
+     return false;
+}
+
+function trim(str)
+{
+	return(str.replace(/\s+$/,''));
+}
+
+var genUiType = "";
+var genFldValue = "";
+
+function dtlViewAjaxSave(fieldLabel,module,uitype,tableName,fieldName,crmId)
+{
+	var dtlView = "dtlview_"+ fieldLabel;
+	var editArea = "editarea_"+ fieldLabel;
+	var groupurl = "";
+	
+	if(globaluitype == 53)
+	{
+		if(typeof(document.DetailView.assigntype[0]) != 'undefined')
+		{
+			var assign_type_U = document.DetailView.assigntype[0].checked;
+			var assign_type_G = document.DetailView.assigntype[1].checked;
+		}else
+		{
+			var assign_type_U = document.DetailView.assigntype.checked;
+		}
+		if(assign_type_U == true)
+		{
+			var txtBox= 'txtbox_U'+fieldLabel;
+		}
+		else if(assign_type_G == true)
+		{
+			var txtBox= 'txtbox_G'+fieldLabel;
+			var group_name = $(txtBox).options[$(txtBox).selectedIndex].text; 
+			var groupurl = "&assigned_group_name="+group_name+"&assigntype=T"
+		}
+
+	}else if(globaluitype == 14 || globaluitype == 33 || globaluitype == 34)
+	{
+	  var txtBox= "txtbox_"+ fieldLabel;
+	  var oMulSelect = $(txtBox);
+	  var r = new Array();
+	  for (iter=0;iter < oMulSelect.options.length ; iter++)
+	  {
+      if (oMulSelect.options[iter].selected)
+        r[r.length] = oMulSelect.options[iter].value;
+      }
+	}else
+	{
+		var txtBox= "txtbox_"+ fieldLabel;
+	}
+	
+	var popupTxt= "popuptxt_"+ fieldLabel;      
+	var hdTxt = "hdtxt_"+ fieldLabel;
+
+	if(formValidate() == false)
+	{
+		return false;
+	}
+
+
+	$("vtbusy_info").style.display="inline";
+	var isAdmin = document.getElementById("hdtxt_IsAdmin").value; 
+
+
+	//overriden the tagValue based on UI Type for checkbox 
+	if(uitype == '56')
+	{
+		if(document.getElementById(txtBox).checked == true)
+		{
+			tagValue = "1";
+		}else
+		{
+			tagValue = "0";
+		}
+	}else	if(uitype == '156')
+	{
+		if(document.getElementById(txtBox).checked == true)
+		{
+			tagValue = "on";
+		}else
+		{
+			tagValue = "off";
+		}
+	}else if(uitype == 14 || uitype == '33' || uitype == '34')
+	{
+		tagValue = r.join(" |##| ");
+  	}else if(uitype == '24' || uitype == '21')
+        {
+                tagValue = document.getElementById(txtBox).value.replace(/<br\s*\/>/g, " ");
+
+  	}else
+	{
+		tagValue = trim(document.getElementById(txtBox).value);
+		if(module == "Contacts")
+                {
+                        var port_obj = getObj('portal').checked;
+                        if(fieldName == "email" && tagValue == '' && port_obj == true)
+                        {
+                                alert(alert_arr.PORTAL_PROVIDE_EMAILID);
+                                return false;
+                        }
+                }
+	}
+
+	if(uitype == '3' || uitype == '4' || uitype == '18' || uitype == '31' || uitype == '32') {
+	    if(document.getElementById(txtBox+"_inh").checked) {
+		tagValue = "@##@" + tagValue;
+	    }
+	}
+
+	var data = "file=DetailViewAjax&module=" + module + "&action=" + module + "Ajax&record=" + crmId+"&recordid=" + crmId ;
+	data = data + "&fldName=" + fieldName + "&fieldValue=" + escapeAll(tagValue) + "&ajxaction=DETAILVIEW"+groupurl;
+	data = data + "&tableName=" + tableName;
+	new Ajax.Request(
+		'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: data,
+                        onComplete: function(response) {
+                  				if(response.responseText.indexOf(":#:FAILURE")>-1)
+                  				{
+                  					alert(alert_arr.ERROR_WHILE_EDITING);
+                  				}
+                  				else if(response.responseText.indexOf(":#:SUCCESS")>-1)
+                       		{
+                  					$("vtbusy_info").style.display="none";
+                       		}
+                        }
+                }
+            );
+	if(uitype == '13' || uitype == '104')
+	{
+		getObj(dtlView).innerHTML = "<a href=\"mailto:"+ tagValue+"\" target=\"_blank\">"+tagValue+"&nbsp;</a>";
+		if(fieldName == "email" || fieldName == "email1"){
+			var priEmail = getObj("pri_email");
+			if(priEmail)
+				priEmail.value = tagValue;
+		}else{
+			var secEmail = getObj("sec_email");
+			if(secEmail)
+                	        secEmail.value = tagValue;
+		}
+	}else if(uitype == '17')
+	{
+		getObj(dtlView).innerHTML = "<a href=\"http://"+ tagValue+"\" target=\"_blank\">"+tagValue+"&nbsp;</a>";
+	}else if(uitype == '34' || (uitype == '115' && fieldName == 'primary_org'))
+	{
 	    var data = "file=UpdateUserOrg&module=" + module + "&action=" + module + "Ajax&recordid=" + crmId;
-	    new Ajax.Request(
-		'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: data,
-                        onComplete: function(response) {
+	    new Ajax.Request(
+		'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: data,
+                        onComplete: function(response) {
 			    $("dvtUserOrg").innerHTML = response.responseText;
-                        }
-                }
-            );
-	}else if(uitype == '85')
-        {
-                getObj(dtlView).innerHTML = "<a href=\"skype://"+ tagValue+"?call\">"+tagValue+"&nbsp;</a>";
-        }else if(uitype == '53')
-	{
-		var hdObj = getObj(hdTxt);
-		if(typeof(document.DetailView.assigntype[0]) != 'undefined')
-        {
-			var assign_type_U = document.DetailView.assigntype[0].checked;
-			var assign_type_G = document.DetailView.assigntype[1].checked;
-		}else
-		{
-			var assign_type_U = document.DetailView.assigntype.checked;
-		}
-		if(isAdmin == "0")
-		{
-			getObj(dtlView).innerHTML = hdObj.value;
-		}else if(isAdmin == "1" && assign_type_U == true)
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";
-		}else if(isAdmin == "1" && assign_type_G == true)
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=GroupDetailView&groupId="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";
-		}
-	}else if(uitype == '56')
-	{
-		if(tagValue == '1')
-		{
-			getObj(dtlView).innerHTML = "yes";
-		}else
-		{
-			getObj(dtlView).innerHTML = "";
-		}
-
-	}else if(uitype == 116)
-	{
-			getObj(dtlView).innerHTML = document.getElementById(txtBox).options[document.getElementById(txtBox).selectedIndex].text; 
-	}
-	else if(getObj(popupTxt))
-	{
-		var popObj = getObj(popupTxt);
-		if(uitype == '50' || uitype == '73' || uitype == '51')
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Accounts&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-		}
-		else if(uitype == '57')
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Contacts&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-		}
-		else if(uitype == '59')
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Products&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-		}
-		else if(uitype == '75' || uitype == '81' )
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Vendors&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-
-		}
-		else if(uitype == '76')
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Potentials&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-		}
-		else if(uitype == '78')
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Quotes&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-		}
-		else if(uitype == '80')
-		{
-			getObj(dtlView).innerHTML = "<a href=\"index.php?module=SalesOrder&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
-		}
-		else if(uitype == '53')
-		{
-			var hdObj = getObj(hdTxt);
-			if(isAdmin == "0")
-			{
-				getObj(dtlView).innerHTML = hdObj.value;
-			}else if(isAdmin == "1")
-			{
-				getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";;
-			}
-		}
-		else if(uitype == '56')
-		{
-			if(tagValue == '1')
-			{
-				getObj(dtlView).innerHTML = "yes";
-			}else
-			{
-				getObj(dtlView).innerHTML = "";
-			}
-
-		}
-		else
-		{
-			getObj(dtlView).innerHTML = popObj.value;
-		}
-	}else if(uitype == '33' || uitype == '34')
-  	{
-		/* Wordwrap a long list of multi-select combo box items at the
-                 * item separator string */
-                const DETAILVIEW_WORDWRAP_WIDTH = "70"; // must match value in DetailViewUI.tpl.
-
-                var lineLength = 0;
-                for(var i=0; i < r.length; i++) {
-                        lineLength += r[i].length + 2; // + 2 for item separator string
-                        if(lineLength > DETAILVIEW_WORDWRAP_WIDTH && i > 0) {
-                                lineLength = r[i].length + 2; // reset.
-                            r[i] = '<br/>&nbsp;' + r[i]; // prepend newline.
-                        }
-                        // Prevent a browser splitting multiword items:
-                        r[i] = r[i].replace(/ /g, '&nbsp;');
-                }
-                /* Join items with item separator string (which must match string in DetailViewUI.tpl,
-                 * EditViewUtils.php and CRMEntity.php)!!
-                 */
-       		getObj(dtlView).innerHTML = r.join(", ");
+                        }
+                }
+            );
+	}else if(uitype == '85')
+        {
+                getObj(dtlView).innerHTML = "<a href=\"skype://"+ tagValue+"?call\">"+tagValue+"&nbsp;</a>";
+        }else if(uitype == '53')
+	{
+		var hdObj = getObj(hdTxt);
+		if(typeof(document.DetailView.assigntype[0]) != 'undefined')
+        {
+			var assign_type_U = document.DetailView.assigntype[0].checked;
+			var assign_type_G = document.DetailView.assigntype[1].checked;
+		}else
+		{
+			var assign_type_U = document.DetailView.assigntype.checked;
+		}
+		if(isAdmin == "0")
+		{
+			getObj(dtlView).innerHTML = hdObj.value;
+		}else if(isAdmin == "1" && assign_type_U == true)
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";
+		}else if(isAdmin == "1" && assign_type_G == true)
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Settings&action=GroupDetailView&groupId="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";
+		}
+	}
+	else if(uitype == '52' || uitype == '77')
+	{
+		if(isAdmin == "1")
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+document.getElementById(txtBox).options[document.getElementById(txtBox).selectedIndex].text+"&nbsp;</a>";
+		else
+			getObj(dtlView).innerHTML = document.getElementById(txtBox).options[document.getElementById(txtBox).selectedIndex].text;
+	}
+	else if(uitype == '56')
+	{
+		if(tagValue == '1')
+		{
+			if(module == "Contacts")
+                        {
+                                var obj = getObj("email");
+                                if((fieldName == "portal") && (obj.value == ''))
+                                {
+                                        alert(alert_arr.PORTAL_PROVIDE_EMAILID);
+                                        return false;
+
+                                }
+                                else
+                                        getObj(dtlView).innerHTML = alert_arr.YES;
+
+                        }
+                        else
+                                getObj(dtlView).innerHTML = alert_arr.YES;
+		}else
+		{
+			getObj(dtlView).innerHTML = alert_arr.NO;
+		}
+
+	}else if(uitype == 116)
+	{
+			getObj(dtlView).innerHTML = document.getElementById(txtBox).options[document.getElementById(txtBox).selectedIndex].text; 
+	}
+	else if(getObj(popupTxt))
+	{
+		var popObj = getObj(popupTxt);
+		if(uitype == '50' || uitype == '73' || uitype == '51')
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Accounts&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+		}
+		else if(uitype == '57')
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Contacts&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+		}
+		else if(uitype == '59')
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Products&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+		}
+		else if(uitype == '75' || uitype == '81' )
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Vendors&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+
+		}
+		else if(uitype == '76')
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Potentials&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+		}
+		else if(uitype == '78')
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=Quotes&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+		}
+		else if(uitype == '80')
+		{
+			getObj(dtlView).innerHTML = "<a href=\"index.php?module=SalesOrder&action=DetailView&record="+tagValue+"\">"+popObj.value+"&nbsp;</a>";
+		}
+		else if(uitype == '53')
+		{
+			var hdObj = getObj(hdTxt);
+			if(isAdmin == "0")
+			{
+				getObj(dtlView).innerHTML = hdObj.value;
+			}else if(isAdmin == "1")
+			{
+				getObj(dtlView).innerHTML = "<a href=\"index.php?module=Users&action=DetailView&record="+tagValue+"\">"+hdObj.value+"&nbsp;</a>";;
+			}
+		}
+		else if(uitype == '56')
+		{
+			if(tagValue == '1')
+			{
+				getObj(dtlView).innerHTML = alert_arr.YES;
+			}else
+			{
+				getObj(dtlView).innerHTML = "";
+			}
+
+		}
+		else
+		{
+			getObj(dtlView).innerHTML = popObj.value;
+		}
+	}else if(uitype == '33' || uitype == '34')
+  	{
+		/* Wordwrap a long list of multi-select combo box items at the
+                 * item separator string */
+                var DETAILVIEW_WORDWRAP_WIDTH = "70"; // must match value in DetailViewUI.tpl.
+
+                var lineLength = 0;
+                for(var i=0; i < r.length; i++) {
+                        lineLength += r[i].length + 2; // + 2 for item separator string
+                        if(lineLength > DETAILVIEW_WORDWRAP_WIDTH && i > 0) {
+                                lineLength = r[i].length + 2; // reset.
+                            r[i] = '<br/>&nbsp;' + r[i]; // prepend newline.
+                        }
+                        // Prevent a browser splitting multiword items:
+                        r[i] = r[i].replace(/ /g, '&nbsp;');
+                }
+                /* Join items with item separator string (which must match string in DetailViewUI.tpl,
+                 * EditViewUtils.php and CRMEntity.php)!!
+                 */
+       		getObj(dtlView).innerHTML = r.join(", ");
 	}else if(uitype == '3' || uitype == '4' || uitype == '14' || uitype == '18' || uitype == '31' || uitype == '32') 
 	{
-	    var data = "file=DetailView&module=" + module + "&action=" + module + "Ajax&record=" + crmId+"&recordid=" + crmId ;
-	    new Ajax.Request(
-		'index.php',
-                {queue: {position: 'end', scope: 'command'},
-		    method: 'post',
-		    postBody: data,
-		    onComplete: function(response) {
+	    var data = "file=DetailView&module=" + module + "&action=" + module + "Ajax&record=" + crmId+"&recordid=" + crmId ;
+	    new Ajax.Request(
+		'index.php',
+                {queue: {position: 'end', scope: 'command'},
+		    method: 'post',
+		    postBody: data,
+		    onComplete: function(response) {
 			result = response.responseText.split('<!-- @#@#@#@# '+fieldLabel+' @#@#@#@# -->');
 			$("mouseArea_"+fieldLabel).innerHTML= result[1];
-		    }
-                }
-            );
-	}else
-	{
-		getObj(dtlView).innerHTML = tagValue;
-	}
-	showHide(dtlView,editArea);  //show,hide
-	itsonview=false;
-}
-
-function SaveTag(txtBox,crmId,module)
-{
-	var tagValue = document.getElementById(txtBox).value;
-	document.getElementById(txtBox).value ='';
-	$("vtbusy_info").style.display="inline";
-	new Ajax.Request(
-		'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody: "file=TagCloud&module=" + module + "&action=" + module + "Ajax&recordid=" + crmId + "&ajxaction=SAVETAG&tagfields=" +tagValue,
-                        onComplete: function(response) {
-				        getObj('tagfields').innerHTML = response.responseText;
-					$("vtbusy_info").style.display="none";
-                        }
-                }
-        );
-    
-}
-function setSelectValue(fieldLabel)
-{
-	if(globaluitype == 53)
-	{
-		if(typeof(document.DetailView.assigntype[0]) != 'undefined')
-		{
-			var assign_type_U = document.DetailView.assigntype[0].checked;
-			var assign_type_G = document.DetailView.assigntype[1].checked;
-			if(assign_type_U == true)
-				var selCombo= 'txtbox_U'+fieldLabel;
-			else if(assign_type_G == true)	
-				var selCombo= 'txtbox_G'+fieldLabel;
-		}else
-		{
-			var selCombo= 'txtbox_U'+fieldLabel;
-		}
-	}else
-	{
-			var selCombo= 'txtbox_'+fieldLabel;
-	}
-	var hdTxtBox = 'hdtxt_'+fieldLabel;
-	var oHdTxtBox = document.getElementById(hdTxtBox);
-	var oSelCombo = document.getElementById(selCombo);
-
-	oHdTxtBox.value = oSelCombo.options[oSelCombo.selectedIndex].text;
-}
-
+		    }
+                }
+            );
+	}else if(uitype == '19'){
+		var desc = tagValue.replace(/(^|[\n ])([\w]+?:\/\/.*?[^ \"\n\r\t<]*)/g, "$1<a href=\"$2\" target=\"_blank\">$2</a>");
+		desc = desc.replace(/(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:\/[^ \"\t\n\r<]*)?)/g, "$1<a href=\"http://$2\" target=\"_blank\">$2</a>");
+		desc = desc.replace(/(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)/i, "$1<a href=\"mailto:$2@$3\">$2@$3</a>");
+		desc = desc.replace(/,\"|\.\"|\)\"|\)\.\"|\.\)\"/, "\"");
+		desc = desc.replace(/[\n\r]+/g, "<br>&nbsp;");
+		getObj(dtlView).innerHTML = desc;
+	}
+	else
+	{
+		getObj(dtlView).innerHTML = tagValue.replace(/[\n\r]+/g, "<br>&nbsp;");
+	}
+	showHide(dtlView,editArea);  //show,hide
+	itsonview=false;
+}
+
+// Replace the % sign with %25 to make sure the AJAX url is going wel. 
+function escapeAll(tagValue) 
+{ 
+ 	return escape(tagValue.replace(/%/g, '%25')); 
+}
+ 
+function SaveTag(tagfield,crmId,module)
+{
+	var tagValue = $(tagfield).value;
+	$("vtbusy_info").style.display="inline";
+	new Ajax.Request(
+		'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody: "file=TagCloud&module=" + module + "&action=" + module + "Ajax&recordid=" + crmId + "&ajxaction=SAVETAG&tagfields=" +escape(tagValue),
+                        onComplete: function(response) {
+				        getObj('tagfields').innerHTML = response.responseText;
+					$("vtbusy_info").style.display="none";
+					$(tagfield).value = '';
+                        }
+                }
+        );
+    
+}
+function setSelectValue(fieldLabel)
+{
+	if(globaluitype == 53)
+	{
+		if(typeof(document.DetailView.assigntype[0]) != 'undefined')
+		{
+			var assign_type_U = document.DetailView.assigntype[0].checked;
+			var assign_type_G = document.DetailView.assigntype[1].checked;
+			if(assign_type_U == true)
+				var selCombo= 'txtbox_U'+fieldLabel;
+			else if(assign_type_G == true)	
+				var selCombo= 'txtbox_G'+fieldLabel;
+		}else
+		{
+			var selCombo= 'txtbox_U'+fieldLabel;
+		}
+	}else
+	{
+			var selCombo= 'txtbox_'+fieldLabel;
+	}
+	var hdTxtBox = 'hdtxt_'+fieldLabel;
+	var oHdTxtBox = document.getElementById(hdTxtBox);
+	var oSelCombo = document.getElementById(selCombo);
+
+	oHdTxtBox.value = oSelCombo.options[oSelCombo.selectedIndex].text;
+}
+

Modified: vtigercrm/branches/5.1_jens/include/js/general.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/general.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/general.js Mon Apr 16 12:27:44 2007
@@ -10,6 +10,8 @@
 
 //Utility Functions
 
+var gValidationCall='';
+
 if (document.all)
 
 	var browser_ie=true
@@ -22,8 +24,25 @@
 
 	var browser_nn6=true
 
-
-
+var gBrowserAgent = navigator.userAgent.toLowerCase();
+
+function hideSelect()
+{
+        var oselect_array = document.getElementsByTagName('SELECT');
+        for(var i=0;i<oselect_array.length;i++)
+        {
+                oselect_array[i].style.display = 'none';
+        }
+}
+
+function showSelect()
+{
+        var oselect_array = document.getElementsByTagName('SELECT');
+        for(var i=0;i<oselect_array.length;i++)
+        {
+                oselect_array[i].style.display = 'block';
+        }
+}
 function getObj(n,d) {
 
   var p,i,x; 
@@ -192,7 +211,7 @@
 	if (fldType=="text") {
 		if (currObj.value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) {
 
-       			alert(fldLabel+" cannot be empty")
+       			alert(fldLabel+alert_arr.CANNOT_BE_EMPTY)
 
 			currObj.focus()
 
@@ -204,9 +223,9 @@
             	
 		return true
 	} else {
-		if (currObj.value == "" ) {
-
-	                alert(fldLabel+" cannot be none")
+		if (trim(currObj.value) == '') {
+
+	                alert(fldLabel+alert_arr.CANNOT_BE_NONE)
 
         	        return false
 
@@ -251,7 +270,7 @@
 	}
 	
 	if (!re.test(currObj.value)) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID + fldLabel)
 		currObj.focus()
 		return false
 	}
@@ -290,27 +309,27 @@
 	var ret=true
 	switch (type) {
 		case 'L'	:	if (date1>=date2) {//DATE1 VALUE LESS THAN DATE2
-							alert(fldLabel1+" should be less than "+fldLabel2)
+							alert(fldLabel1+ alert_arr.SHOULDBE_LESS +fldLabel2)
 							ret=false
 						}
 						break;
 		case 'LE'	:	if (date1>date2) {//DATE1 VALUE LESS THAN OR EQUAL TO DATE2
-							alert(fldLabel1+" should be less than or equal to "+fldLabel2)
+							alert(fldLabel1+alert_arr.SHOULDBE_LESS_EQUAL+fldLabel2)
 							ret=false
 						}
 						break;
 		case 'E'	:	if (date1!=date2) {//DATE1 VALUE EQUAL TO DATE
-							alert(fldLabel1+" should be equal to "+fldLabel2)
+							alert(fldLabel1+alert_arr.SHOULDBE_EQUAL+fldLabel2)
 							ret=false
 						}
 						break;
 		case 'G'	:	if (date1<=date2) {//DATE1 VALUE GREATER THAN DATE2
-							alert(fldLabel1+" should be greater than "+fldLabel2)
+							alert(fldLabel1+alert_arr.SHOULDBE_GREATER+fldLabel2)
 							ret=false
 						}
 						break;	
 		case 'GE'	:	if (date1<date2) {//DATE1 VALUE GREATER THAN OR EQUAL TO DATE2
-							alert(fldLabel1+" should be greater than or equal to "+fldLabel2)
+							alert(fldLabel1+alert_arr.SHOULDBE_GREATER_EQUAL+fldLabel2)
 							ret=false
 						}
 						break;
@@ -332,19 +351,19 @@
 	yyyy=dateelements[2]
 	
 	if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		getObj(dateFldName).focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>29)) {//checking of no. of days in february month
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		getObj(dateFldName).focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		getObj(dateFldName).focus()
 		return false
 	}
@@ -355,7 +374,7 @@
 		case 6 : 
 		case 9 : 
 		case 11 :	if (dd>30) {
-						alert("Please enter a valid "+fldLabel)
+						alert(alert_arr.ENTER_VALID+fldLabel)
 						getObj(dateFldName).focus()
 						return false
 					}	
@@ -370,7 +389,7 @@
 	var currObj=getObj(timeFldName)
 	
 	if (hourval>23 || minval>59) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		currObj.focus()
 		return false
 	}
@@ -451,19 +470,19 @@
 	yyyy=dateelements[2]
 	
 	if (dd<1 || dd>31 || mm<1 || mm>12 || yyyy<1 || yyyy<1000) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		getObj(fldName).focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>29)) {//checking of no. of days in february month
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		getObj(fldName).focus()
 		return false
 	}
 	
 	if ((mm==2) && (dd>28) && ((yyyy%4)!=0)) {//leap year checking
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		getObj(fldName).focus()
 		return false
 	}
@@ -474,7 +493,7 @@
 		case 6 : 
 		case 9 : 
 		case 11 :	if (dd>30) {
-						alert("Please enter a valid "+fldLabel)
+						alert(alert_arr.ENTER_VALID+fldLabel)
 						getObj(fldName).focus()
 						return false
 					}	
@@ -539,7 +558,7 @@
 	var currObj=getObj(fldName)
 	
 	if (hourval>23 || minval>59) {
-		alert("Please enter a valid "+fldLabel)
+		alert(alert_arr.ENTER_VALID+fldLabel)
 		currObj.focus()
 		return false
 	}
@@ -612,19 +631,36 @@
                    invalid=true
        }
               if (invalid==true) {
-           alert("Invalid "+fldLabel)
+           alert(alert_arr.INVALID+fldLabel)
            getObj(fldName).focus()
            return false
        } else return true
    } else {
-	
+	   // changes made -- to fix the ticket#3272
 	   var splitval=val.split(".")
-
-                if(splitval[0]>2147483647)
-                {
-                        alert( fldLabel + " exceeds the maximum limit ");
+	   var arr_len = splitval.length;
+           var len = 0;
+	   if(fldName == "probability" || fldName == "commissionrate")
+           {
+                   if(arr_len > 1)
+                           len = splitval[1].length;
+                   if(isNaN(val))
+                   {
+                        alert(alert_arr.INVALID+fldLabel)
+                        getObj(fldName).focus()
+                        return false
+                   }
+                   else if(splitval[0] > 100 || len > 3)
+                   {
+                        alert( fldLabel + alert_arr.EXCEEDS_MAX);
                         return false;
-                }
+                   }
+           }
+	   else if(splitval[0]>18446744073709551615)
+           {
+                   alert( fldLabel + alert_arr.EXCEEDS_MAX);
+                   return false;
+           }
 
 
        if (neg==true)
@@ -632,8 +668,24 @@
        else
            var re=/^\d+(\.\d\d*)*$/
    }
+
+	//for precision check. ie.number must contains only one "."	
+	var dotcount=0;
+	for (var i = 0; i < val.length; i++)
+	{   
+	  	if (val.charAt(i) == ".")
+			 dotcount++;
+	}	
+
+	if(dotcount>1)
+	{
+       		alert(alert_arr.INVALID+fldLabel)
+		getObj(fldName).focus()
+		return false;
+	}
+
       if (!re.test(val)) {
-       alert("Invalid "+fldLabel)
+       alert(alert_arr.INVALID+fldLabel)
        getObj(fldName).focus()
        return false
    } else return true
@@ -644,16 +696,20 @@
 	var val=getObj(fldName).value.replace(/^\s+/g, '').replace(/\s+$/g, '')
 	if (isNaN(val) || (val.indexOf(".")!=-1 && fldName != 'potential_amount')) 
 	{
-		alert("Invalid "+fldLabel)
+		alert(alert_arr.INVALID+fldLabel)
 		getObj(fldName).focus()
 		return false
 	} 
-        else if( val < -2147483648 || val > 2147483647)
+        else if((fldName != 'employees') && (val < -2147483648 || val > 2147483647))
         {
-                alert(fldLabel +" is out of range");
+                alert(fldLabel +alert_arr.OUT_OF_RANGE);
                 return false;
         }
-
+	else if((fldName == 'employees') && (val < 0 || val > 2147483647))
+        {
+                alert(fldLabel +alert_arr.OUT_OF_RANGE);
+                return false;
+        }
 	else
 	{
 		return true
@@ -667,32 +723,32 @@
 	var ret=true
 	switch (type) {
 		case "L"  : if (val>=constval) {
-						alert(fldLabel+" should be less than "+constval)
+						alert(fldLabel+alert_arr.SHOULDBE_LESS+constval)
 						ret=false
 					}
 					break;
 		case "LE" :	if (val>constval) {
-					alert(fldLabel+" should be less than or equal to "+constval)
+					alert(fldLabel+alert_arr.SHOULDBE_LESS_EQUAL+constval)
 			        ret=false
 					}
 					break;
 		case "E"  :	if (val!=constval) {
-                                        alert(fldLabel+" should be equal to "+constval)
+                                        alert(fldLabel+alert_arr.SHOULDBE_EQUAL+constval)
                                         ret=false
                                 }
                                 break;
 		case "NE" : if (val==constval) {
-						 alert(fldLabel+" should not be equal to "+constval)
+						 alert(fldLabel+alert_arr.SHOULDNOTBE_EQUAL+constval)
 							ret=false
 					}
 					break;
 		case "G"  :	if (val<=constval) {
-							alert(fldLabel+" should be greater than "+constval)
+							alert(fldLabel+alert_arr.SHOULDBE_GREATER+constval)
 							ret=false
 					}
 					break;
 		case "GE" : if (val<constval) {
-							alert(fldLabel+" should be greater than or equal to "+constval)
+							alert(fldLabel+alert_arr.SHOULDBE_GREATER_EQUAL+constval)
 							ret=false
 					}
 					break;
@@ -705,6 +761,17 @@
 }
 
 function formValidate() {
+;
+//Validation for Portal User
+
+if(gVTModule == 'Contacts' && gValidationCall != 'tabchange')
+{
+	if(getObj('portal').checked && trim(getObj('email').value) == '')   {
+		alert(alert_arr.PORTAL_PROVIDE_EMAILID);
+		return false;
+	}
+}
+
 	for (var i=0; i<fieldname.length; i++) {
 		if(getObj(fieldname[i]) != null)
 		{
@@ -722,7 +789,7 @@
 					if (getObj(fieldname[i]) != null && getObj(fieldname[i]).value.replace(/^\s+/g, '').replace(/\s+$/g, '').length!=0)
 					{	 
 						if (type[1]=="M")
-							if (!emptyCheck(type[2],fieldlabel[i],getObj(type[2]).type))
+							if (!emptyCheck(fieldname[2],fieldlabel[i],getObj(type[2]).type))
 								return false
 
 									if(typeof(type[3])=="undefined") var currdatechk="OTH"
@@ -1104,13 +1171,13 @@
 * @param divId :: div tag ID
 */
 function show(divId)
-
-{
-
-    var id = document.getElementById(divId);
-
-    id.style.display = 'inline';
-
+{
+	if(getObj(divId))
+	{
+		var id = document.getElementById(divId);
+
+		id.style.display = 'inline';
+	}
 }
 
 /*
@@ -1148,6 +1215,8 @@
 	
    var oform = document.forms['EditView'];
    oform.action.value='Save';	
+   //global variable to check the validation calling function to avoid validating when tab change
+   gValidationCall = 'tabchange'; 	
    if((moduletype == 'inventory' && validateInventory(module)) ||(moduletype == 'normal') && formValidate())	
    if(formValidate())
    {	
@@ -1170,6 +1239,7 @@
 
 	   tagName2.style.display='none';
    }
+   gValidationCall = ''; 	
 }
 
 function fnCopy(source,design){
@@ -1374,6 +1444,10 @@
     var topSide = findPosY(obj);
     var maxW = tagName.style.width;
     var widthM = maxW.substring(0,maxW.length-2);
+    if(Lay == 'editdiv') {
+        leftSide = leftSide - 225;
+        topSide = topSide - 125;
+    }
     var getVal = eval(leftSide) + eval(widthM);
     if(getVal  > document.body.clientWidth ){
         leftSide = eval(leftSide) - eval(widthM);
@@ -1514,11 +1588,11 @@
       window.onload = fnc;
   }
 }
-function InternalMailer(record_id,type) {
+function InternalMailer(record_id,field_id,type) {
         var url;
         switch(type) {
                 case 'record_id':
-                        url = 'index.php?module=Emails&action=EmailsAjax&internal_mailer=true&type='+type+'&record=&rec_id='+record_id+'&file=EditView';
+                        url = 'index.php?module=Emails&action=EmailsAjax&internal_mailer=true&type='+type+'&record=&field_id='+field_id+'&rec_id='+record_id+'&file=EditView';//query string field_id added for listview-compose email issue
                 break;
                 case 'email_addy':
                         url = 'index.php?module=Emails&action=EmailsAjax&internal_mailer=true&type='+type+'&record=&email_addy='+record_id+'&file=EditView';
@@ -1533,7 +1607,12 @@
 function fnHide_Event(obj){
         document.getElementById(obj).style.visibility = 'hidden';
 }
-
+function ReplyCompose(id,mode)
+{
+			url = 'index.php?module=Emails&action=EmailsAjax&file=EditView&record='+id+'&reply=true';
+	
+	openPopUp('xComposeEmail',this,url,'createemailWin',820,689,'menubar=no,toolbar=no,location=no,status=no,resizable=no,scrollbars=yes');	
+}
 function OpenCompose(id,mode) 
 {
 	switch(mode)
@@ -1559,10 +1638,12 @@
 	var y=0;
 	if(parmod != 'Calendar')
         {
-                var module = window.opener.document.getElementById('return_module').value
-                var entity_id = window.opener.document.getElementById('parent_id').value
+                var module = window.opener.document.getElementById('return_module').value;
+                var entity_id = window.opener.document.getElementById('parent_id').value;
+                var dependency_type = getObj('dependency_type').value;
         }
         idstring = "";
+        qtystring = "";
 	namestr = "";
 
         if ( x == undefined)
@@ -1571,13 +1652,14 @@
                 if (document.selectall.selected_id.checked)
                 {
 			idstring = document.selectall.selected_id.value;
+			qtystring = idstring+":"+getObj('quantity_'+idstring).value;
 			if(parmod == 'Calendar')
                                 namestr = document.getElementById('calendarCont'+idstring).innerHTML;
                         y=1;
                 }
                 else
 		{
-                        alert("Please select at least one entity");
+                        alert(alert_arr.SELECT);
                         return false;
                 }
         }
@@ -1589,6 +1671,7 @@
                         if(document.selectall.selected_id[i].checked)
                         {
                                 idstring = document.selectall.selected_id[i].value +";"+idstring;
+                                qtystring = document.selectall.selected_id[i].value+":"+getObj('quantity_'+document.selectall.selected_id[i].value).value+";"+qtystring;
 				if(parmod == 'Calendar')
                                 {
                                         idval = document.selectall.selected_id[i].value;
@@ -1604,10 +1687,10 @@
         }
         else
         {
-                alert("Please select at least one entity");
+                alert(alert_arr.SELECT);
                 return false;
         }
-        if(confirm("Are you sure you want to add the selected "+y+" records ?"))
+        if(confirm(alert_arr.ADD_CONFIRMATION+y+alert_arr.RECORDS))
         {
 		if(parmod == 'Calendar')
                 {
@@ -1616,7 +1699,7 @@
                 }
                 else
                 {
-			opener.document.location.href="index.php?module="+module+"&parentid="+entity_id+"&action=updateRelations&destination_module="+mod+"&idlist="+idstring;
+			opener.document.location.href="index.php?module="+module+"&parentid="+entity_id+"&action=updateRelations&destination_module="+mod+"&idlist="+idstring+"&qtylist="+qtystring+"&dependency_type="+dependency_type;
 		}
                 self.close();
         }
@@ -1718,3 +1801,282 @@
         });
 }
 
+//Added to check duplicate account creation
+
+function AjaxDuplicateValidate(module,fieldname,oform)
+{
+      var fieldvalue = getObj(fieldname).value;
+	if(fieldvalue == '')
+	{
+		alert(alert_arr.ACCOUNTNAME_CANNOT_EMPTY);
+		return false;	
+	}
+      var url = "module="+module+"&action="+module+"Ajax&file=Save&"+fieldname+"="+fieldvalue+"&dup_check=true"
+      new Ajax.Request(
+                            'index.php',
+                              {queue: {position: 'end', scope: 'command'},
+                                      method: 'post',
+                                      postBody:url,
+                                      onComplete: function(response) {
+                                              var str = response.responseText
+                                              if(str.indexOf('SUCCESS') > -1)
+                                              {
+                                                      oform.submit();
+                                              }else
+                                              {
+                                                      alert(str);
+                                              }
+                                      }
+                              }
+                              );
+}
+
+/**to get SelectContacts Popup
+check->to check select options enable or disable
+*type->to differentiate from task
+*frmName->form name*/
+
+function selectContact(check,type,frmName)
+{
+        if($("single_accountid"))
+        {
+		var potential_id = '';
+		if($("potential_id"))
+			potential_id = frmName.potential_id.value;
+		account_id = frmName.account_id.value;
+		if(potential_id != '')
+		{
+			record_id = potential_id;
+			module_string = "&parent_module=Potentials";
+		}	
+		else
+		{
+			record_id = account_id;
+			module_string = "&parent_module=Accounts";
+		}
+		if(record_id != '')
+	                window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView"+module_string+"&relmod_id="+record_id,"test","width=640,height=602,resizable=0,scrollbars=0");
+		else
+			 window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");	
+        }
+        else if(($("parentid")) && type != 'task')
+        {
+		if(getObj("parent_type")){
+                	rel_parent_module = frmName.parent_type.value;
+			record_id = frmName.parent_id.value;
+        	        module = rel_parent_module.split("&");	
+			if(record_id != '' && module[0] == "Leads")
+			{
+				alert(alert_arr.CANT_SELECT_CONTACTS);
+			}
+			else
+			{
+				if(check == 'true')
+					search_string = "&return_module=Calendar&select=enable&popuptype=detailview&form_submit=false";
+				else
+					search_string="&popuptype=specific";
+				if(record_id != '')
+					window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&form=EditView"+search_string+"&relmod_id="+record_id+"&parent_module="+module[0],"test","width=640,height=602,resizable=0,scrollbars=0");
+				else
+					window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&form=EditView"+search_string,"test","width=640,height=602,resizable=0,scrollbars=0");
+			}
+		}else{
+			window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&return_module=Calendar&select=enable&popuptype=detailview&form=EditView&form_submit=false","test","width=640,height=602,resizable=0,scrollbars=0");
+		}
+        }
+	else if(($("contact_name")) && type == 'task')
+	{
+		var formName = frmName.name;
+		if(formName == 'EditView')
+		{
+			task_parent_module = frmName.parent_type.value;
+			task_recordid = frmName.parent_id.value;
+			task_module = task_parent_module.split("&");
+			popuptype="&popuptype=specific";
+		}
+		else
+		{
+			task_parent_module = frmName.task_parent_type.value;
+			task_recordid = frmName.task_parent_id.value;
+			task_module = task_parent_module.split("&");
+			popuptype="&popuptype=toDospecific";
+		}
+		if(task_recordid != '' && task_module[0] == "Leads" )
+		{
+			alert(alert_arr.CANT_SELECT_CONTACTS);
+		}
+		else
+		{
+			if(task_recordid != '')
+				window.open("index.php?module=Contacts&action=Popup&html=Popup_picker"+popuptype+"&form=EditView&task_relmod_id="+task_recordid+"&task_parent_module="+task_module[0],"test","width=640,height=602,resizable=0,scrollbars=0");
+			else	
+				window.open("index.php?module=Contacts&action=Popup&html=Popup_picker"+popuptype+"&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");
+		}
+
+	}
+        else
+        {
+                window.open("index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");
+        }
+}
+//to get Select Potential Popup
+function selectPotential()
+{
+	var record_id= document.EditView.account_id.value;
+	if(record_id != '')
+		window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView&relmod_id="+record_id+"&parent_module=Accounts","test","width=640,height=602,resizable=0,scrollbars=0");
+	else
+		window.open("index.php?module=Potentials&action=Popup&html=Popup_picker&popuptype=specific_potential_account_address&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");
+}
+//to select Quote Popup
+function selectQuote()
+{
+	var record_id= document.EditView.account_id.value;
+        if(record_id != '')
+		window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&relmod_id="+record_id+"&parent_module=Accounts","test","width=640,height=602,resizable=0,scrollbars=0");
+
+	else
+		window.open("index.php?module=Quotes&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");
+}
+//to get select SalesOrder Popup
+function selectSalesOrder()
+{
+	var record_id= document.EditView.account_id.value;
+        if(record_id != '')
+		window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView&relmod_id="+record_id+"&parent_module=Accounts","test","width=640,height=602,resizable=0,scrollbars=0");
+	else
+		window.open("index.php?module=SalesOrder&action=Popup&html=Popup_picker&popuptype=specific&form=EditView","test","width=640,height=602,resizable=0,scrollbars=0");
+}
+
+function checkEmailid(parent_module,emailid,yahooid)
+ {
+       var check = true;
+       if(emailid == '' && yahooid == '')
+       {
+               alert(alert_arr.LBL_THIS+parent_module+alert_arr.DOESNOT_HAVE_MAILIDS);
+               check=false;
+       }
+       return check;
+ }
+
+function calQCduedatetime()
+{
+        var datefmt = document.QcEditView.dateFormat.value;
+        var type = document.QcEditView.activitytype.value;
+        var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        var dateelements1=splitDateVal(dateval1);
+        dd1=parseInt(dateelements1[0],10);
+        mm1=dateelements1[1];
+        yyyy1=dateelements1[2];
+        var date1=new Date();
+        date1.setYear(yyyy1);
+        date1.setMonth(mm1-1,dd1+1);
+        var yy = date1.getFullYear();
+        var mm = date1.getMonth() + 1;
+        var dd = date1.getDate();
+        var date = document.QcEditView.date_start.value;
+        var starttime = document.QcEditView.time_start.value;
+        if (!timeValidate('time_start',' Start Date & Time','OTH'))
+                return false;
+        var timearr = starttime.split(":");
+        var hour = parseInt(timearr[0],10);
+        var min = parseInt(timearr[1],10);
+        dd = _2digit(dd);
+        mm = _2digit(mm);
+        var tempdate = yy+'-'+mm+'-'+dd;
+        if(datefmt == '%d-%m-%Y')
+                var tempdate = dd+'-'+mm+'-'+yy;
+        else if(datefmt == '%m-%d-%Y')
+                var tempdate = mm+'-'+dd+'-'+yy;
+        if(type == 'Meeting')
+        {
+                hour = hour + 1;
+                if(hour == 24)
+                {
+                        hour = 0;
+                        date =  tempdate;
+                }
+                hour = _2digit(hour);
+		min = _2digit(min);
+                document.QcEditView.due_date.value = date;
+                document.QcEditView.time_end.value = hour+':'+min;
+        }
+        if(type == 'Call')
+        {
+                if(min >= 55)
+                {
+                        min = min%55;
+                        hour = hour + 1;
+                }else min = min + 5;
+                if(hour == 24)
+                {
+                        hour = 0;
+                        date =  tempdate;
+                }
+                hour = _2digit(hour);
+		min = _2digit(min);
+                document.QcEditView.due_date.value = date;
+                document.QcEditView.time_end.value = hour+':'+min;
+        }
+
+}
+
+function _2digit( no ){
+        if(no < 10) return "0" + no;
+        else return "" + no;
+}
+
+function confirmdelete(url)
+{
+if(confirm(alert_arr.ARE_YOU_SURE))
+       {
+            document.location.href=url;
+       }
+}
+
+function usernameCharValid(c) {
+  return ( ((c >= 'a') && (c <= 'z')) ||
+           ((c >= 'A') && (c <= 'Z')) ||
+           ((c >= '0') && (c <= '9')) ||
+           (c == '.') );
+}
+
+function usernameValid(s) {
+  for (var i = 0; i < s.length; i++) {
+    if (!usernameCharValid(s.charAt(i))){
+      return false;}
+  }
+  return true;
+}
+
+/** Check Upload file is in specified format(extension).
+  * @param fldname -- name of the file field
+  * @param fldLabel -- Lable of the file field
+  * @param filter -- List of file extensions to allow. each extension must be seperated with a | sybmol.
+  * Example: upload_filter("imagename","Image", "jpg|gif|bmp|png") 
+  * @returns true -- if the extension is IN  specified extension.
+  * @returns false -- if the extension is NOT IN specified extension.
+  *
+  * NOTE: If this field is mandatory,  please call emptyCheck() function before calling this function.
+ */
+
+function upload_filter(fldName, filter)
+{
+	var currObj=getObj(fldName)
+	if(currObj.value !="")
+	{
+		var file=currObj.value;
+		var type=file.split(".");
+		var valid_extn=filter.split("|");	
+	
+		if(valid_extn.indexOf(type[type.length-1]) == -1)
+		{
+			alert(alert_arr.PLS_SELECT_VALID_FILE+valid_extn)
+			currObj.focus();
+		 	return false;
+		}
+	}	
+	return true
+	
+}
+

Modified: vtigercrm/branches/5.1_jens/include/js/popup.js
==============================================================================
--- vtigercrm/branches/5.1_jens/include/js/popup.js (original)
+++ vtigercrm/branches/5.1_jens/include/js/popup.js Mon Apr 16 12:27:44 2007
@@ -13,3 +13,8 @@
       mywindow = window.open("copyright.html","mywindow", "height=115, width=575");
       mywindow.moveTo(210,620);
 }
+
+function newpopup(str){
+                window.open (str,"mywinw","menubar=1,resizable=1,scrollbars=yes");
+//              window.parent.close();
+}

Modified: vtigercrm/branches/5.1_jens/include/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/include/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -1,1258 +1,959 @@
 <?php
-
 /*********************************************************************************
-
  * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
-
  * ("License"); You may not use this file except in compliance with the
-
  * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
-
  * Software distributed under the License is distributed on an  "AS IS"  basis,
-
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
-
  * the specific language governing rights and limitations under the License.
-
  * The Original Code is:  SugarCRM Open Source
-
  * The Initial Developer of the Original Code is SugarCRM, Inc.
-
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
-
  * All Rights Reserved.
-
  * Contributor(s): ______________________________________.
-
  ********************************************************************************/
-
 /*********************************************************************************
-
  * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/include/language/en_us.lang.php,v 1.68 2005/04/26 06:50:39 rank Exp $
-
  * Description:  Defines the English language pack for the base application.
-
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
-
  * All Rights Reserved.
-
  * Contributor(s): ______________________________________..
-
  ********************************************************************************/
-
-
-
-$app_strings = Array(
-
-'LBL_CHARSET'=>'ISO-8859-1',
-
-'LBL_BROWSER_TITLE'=>'vtiger CRM 5 - Commercial Open Source CRM',
-
-'LBL_MY_ACCOUNT'=>'My Account',
-
-'LBL_MY_PREFERENCES'=>'My Preferences',
-
-'LBL_ADMIN'=>'Admin',
-
-'LBL_LOGOUT'=>'Sign out',
-
-'LBL_SEARCH'=>'Search',
-
-'LBL_LAST_VIEWED'=>'Last Viewed',
-
+$app_strings = array (
+'LBL_CHARSET' => 'ISO-8859-1',
+'LBL_BROWSER_TITLE' => 'vtiger CRM 5 - Commercial Open Source CRM',
+'LBL_MY_ACCOUNT' => 'My Account',
+'LBL_MY_PREFERENCES' => 'My Preferences',
+'LBL_ADMIN' => 'Admin',
+'LBL_LOGOUT' => 'Sign Out',
+'LBL_SEARCH' => 'Search',
+'LBL_LAST_VIEWED' => 'Last Viewed',
 'LBL_TODAY'=>'Today',
-
 'LBL_ALL'=>'All',
-
 'LBL_SHOW'=>'Show :',
-
 'today'=>"Today's",
-
 'all'=>'All',
-
 'LBL_UPCOMING_EVENTS'=>'Upcoming Activities',
-
 'LBL_PENDING_EVENTS'=>'Pending Activities',
-
-'NTC_WELCOME_MESSAGE'=>"Welcome to vtiger CRM!",
-
-'NTC_DESCRIPTION'=>"Use a valid username and password to login to the vtiger CRM.",
-
-'NTC_WELCOME'=>'Welcome',
-
-'NTC_NO_ITEMS_DISPLAY'=>'none',
-
-'LBL_OR'=>'or',
-
-'LBL_ALT_HOT_KEY'=>'Alt+',
-//added for 4.2
-'LBL_SAVE_LABEL'=>'Save',
-
-'LBL_SEND_MAIL_BUTTON'=>'Send Mail',
-
-
-'LBL_SAVE_BUTTON_TITLE'=>'Save [Alt+S]',
-
-'LBL_EDIT_BUTTON_TITLE'=>'Edit [Alt+E]',
-
-'LBL_CONVERTSO_BUTTON_TITLE'=>'Create SalesOrder',
-'LBL_CONVERTINVOICE_BUTTON_TITLE'=>'Create Invoice',
-
-'LBL_EDIT_BUTTON'=>'Edit',
-
-'LBL_DUPLICATE_BUTTON_TITLE'=>'Duplicate [Alt+U]',
-
-'LBL_DUPLICATE_BUTTON'=>'Duplicate',
-
-'LBL_TABCUSTOMISE_BUTTON_TITLE'=>'Customise [Alt+C]',
-
-'LBL_FORUM_HIDE_BUTTON_TITLE'=>'Hide Forum [Alt+I]',
-
-'LBL_FORUM_HIDE_BUTTON_KEY'=>'H',
-
-'LBL_FORUM_SHOW_BUTTON_TITLE'=>'Show Forum [Alt+W]',
-
-'LBL_FORUM_SHOW_BUTTON_KEY'=>'W',
-
-'LBL_TABCUSTOMISE_BUTTON'=>'Customise',
-
-'LBL_DELETE_BUTTON_TITLE'=>'Delete [Alt+D]',
-
-'LBL_DELETE_BUTTON'=>'Delete',
-
-'LBL_FIND_BUTTON'=>'Find',
-
-'LBL_CONVERT_BUTTON_TITLE'=>'Convert [Alt+C]',
-
-'LBL_CONVERT_BUTTON_KEY'=>'C',
-
-'LBL_CONVERT_BUTTON_LABEL'=>'Convert Lead',
-
-'LBL_TABCUSTOMISE_BUTTON_KEY'=>'C',
-
-'LBL_TABCUSTOMISE_BUTTON_LABEL'=>'Customize Tab',
-
-'LBL_ROLES_BUTTON_LABEL'=>'Show Roles',
-
-'LBL_LISTROLES_BUTTON_LABEL'=>'List Roles',
-
-'LBL_FORUM_HIDE_BUTTON_LABEL'=>'Hide Forums',
-
-'LBL_FORUM_SHOW_BUTTON_LABEL'=>'Show Forums',
-
-'LBL_NEW_BUTTON_TITLE'=>'New [Alt+N]',
-
-'LBL_CHANGE_BUTTON_TITLE'=>'Change [Alt+G]',
-
-'LBL_CANCEL_BUTTON_TITLE'=>'Cancel [Alt+X]',
-
-'LBL_SEARCH_BUTTON_TITLE'=>'Search [Alt+Q]',
-
-'LBL_CLEAR_BUTTON_TITLE'=>'Clear [Alt+C]',
-
-'LBL_SELECT_BUTTON_TITLE'=>'Select [Alt+T]',
-
-'LBL_CREATE_BUTTON_LABEL' =>'Create',
-
-'LBL_GENERATE'=>'Generate',
-
-'LBL_SAVE_BUTTON_KEY'=>'S',
-
-'LBL_EDIT_BUTTON_KEY'=>'E',
-'LBL_CONVERTSO_BUTTON_KEY'=>'S',
-'LBL_CONVERTINVOICE_BUTTON_KEY'=>'I',
-
-'LBL_DUPLICATE_BUTTON_KEY'=>'U',
-
-'LBL_DELETE_BUTTON_KEY'=>'D',
-
-'LBL_NEW_BUTTON_KEY'=>'N',
-
-'LBL_CHANGE_BUTTON_KEY'=>'G',
-
-'LBL_CANCEL_BUTTON_KEY'=>'X',
-
-'LBL_SEARCH_BUTTON_KEY'=>'Q',
-
-'LBL_CLEAR_BUTTON_KEY'=>'C',
-
-'LBL_SELECT_BUTTON_KEY'=>'T',
-
-'LBL_SAVE_BUTTON_LABEL'=>'Save',
-
-'LBL_EDIT_BUTTON_LABEL'=>'Edit',
-'LBL_CONVERTSO_BUTTON_LABEL'=>'Create SalesOrder',
-'LBL_CONVERTINVOICE_BUTTON_LABEL'=>'Create Invoice',
-
-'LBL_DUPLICATE_BUTTON_LABEL'=>'Duplicate',
-
-'LBL_DELETE_BUTTON_LABEL'=>'Delete',
-
-'LBL_NEW_BUTTON_LABEL'=>'New',
-
-'LBL_CHANGE_BUTTON_LABEL'=>'Change',
-
-'LBL_CANCEL_BUTTON_LABEL'=>'Cancel',
-
-'LBL_SEARCH_BUTTON_LABEL'=>'Search',
-
-'LBL_CLEAR_BUTTON_LABEL'=>'Clear',
-
-'LBL_SELECT_BUTTON_LABEL'=>'Select',
-
-'LBL_SELECT_CONTACT_BUTTON_TITLE'=>'Select Contact [Alt+T]',
-
-'LBL_SELECT_CONTACT_BUTTON_KEY'=>'T',
-
-'LBL_SELECT_CONTACT_BUTTON_LABEL'=>'Select Contact',
-
-'LBL_SELECT_CAMPAIGN_BUTTON_LABEL'=>'Select Campaign',
-
-'LBL_SELECT_USER_BUTTON_TITLE'=>'Select User [Alt+U]',
-
-'LBL_SELECT_USER_BUTTON_KEY'=>'U',
-
-'LBL_SELECT_USER_BUTTON_LABEL'=>'Select User',
-
-'LBL_SETTINGS'=>'Settings',
-
-'LBL_LIST_USERIP'=>'User IP',
-
-'LBL_LIST_SIGNIN'=>'Sign in Time',
-
-'LBL_LIST_SIGNOUT'=>'Sign out Time',
-
-'LBL_LIST_STATUS'=>'Status',
-
-
-
-'LBL_LIST_NAME'=>'Name',
-
-'LBL_LIST_USER_NAME'=>'User Name',
-
-'LBL_LIST_EMAIL'=>'Email',
-
-'LBL_LIST_PHONE'=>'Phone',
-
-'LBL_LIST_CONTACT_NAME'=>'Contact Name',
-
-'LBL_LIST_ACCOUNT_NAME'=>'Account Name',
-
-'LBL_USER_LIST'=>'User List',
-
-'LBL_CONTACT_LIST'=>'Contact List',
-
-'LBL_LNK_SETTINGS'=> 'Settings',
-
-'LNK_IMPORT_LEADS'=>'Import Leads',
-
-'LBL_LOCATE_MAP'=>'Locate Map',
-
-'LBL_ADDRESS'=>'Address',
-
-'LBL_ADD_TAG'=>'Add Tag',
-
-'LBL_TAG_IT'=>'Tag it',
-
-'LBL_CLOSE'=>'Close',
-
-'LNK_ADVANCED_SEARCH'=>'Advanced Search',
-
-'LNK_BASIC_SEARCH'=>'Basic Search',
-
-'LNK_EDIT'=>'edit',
-
-'LNK_REMOVE'=>'rem',
-
-'LNK_DELETE'=>'del',
-
-'LNK_LIST_START'=>'Start',
-
-'LNK_LIST_NEXT'=>'Next',
-
-'LNK_LIST_PREVIOUS'=>'Previous',
-
-'LNK_LIST_END'=>'End',
-
-'LBL_LIST_OF'=>'of',
-
-'LNK_PRINT'=>'Print',
-
-'LNK_HELP'=>'Help',
-
-'LNK_VTDOCS'=>'vtiger Docs',
-
-'LNK_ABOUT'=>'About',
-
-'LNK_OUTLOOK'=>'./include/images/outlook_download.gif',
-
-'LNK_NEW_HDESK'=>'New Ticket',
-
-'LNK_NEW_PRODUCT'=>'New Product',
-
-'LNK_NEW_CONTACT'=>'New Contact',
-
-'LNK_NEW_CAMPAIGN'=>'New Campaign',
-
-'LNK_NEW_LEAD'=>'New Lead',
-
-'LNK_NEW_ACCOUNT'=>'New Account',
-
-'LNK_NEW_OPPORTUNITY'=>'New Potential',
-
-'LNK_NEW_NOTE'=>'New Note',
-
-'LNK_NEW_EMAIL'=>'New Email',
-
-'LNK_NEW_TASK'=>'New Task',
-
-'LNK_NEW_EVENT'=>'New Event',
-'LNK_NEW_QUOTE'=>'New Quote',
-'LNK_NEW_PO'=>'New Purchase Order',
-'LNK_NEW_SO'=>'New Sales Order',
-'LNK_NEW_INVOICE'=>'New Invoice',
-'LNK_NEW_VENDOR'=>'New Vendor',
-'LNK_NEW_PRICEBOOK'=>'New PriceBook',
-
-
-'NTC_REQUIRED'=>'Indicates required field',
-
-'LBL_REQUIRED_SYMBOL'=>'*',
-
-'LBL_CURRENCY_SYMBOL'=>'$',
-
-'LBL_THOUSANDS_SYMBOL'=>'K',
-
-'NTC_DATE_FORMAT'=>'(yyyy-mm-dd)',
-
-'NTC_TIME_FORMAT'=>'(24:00)',
-
-'NTC_DATE_TIME_FORMAT'=>'(yyyy-mm-dd 24:00)',
-
-'NTC_DELETE_CONFIRMATION'=>'Are you sure you want to delete this record?',
-
-'ERR_DELETE_RECORD'=>'A record number must be specified to delete the contact.',
-
-'ERR_CREATING_TABLE'=>'Error creating table: ',
-
-'ERR_CREATING_FIELDS'=>'Error filling in additional detail fields: ',
-
-'ERR_MISSING_REQUIRED_FIELDS'=>'Missing required fields:',
-
-'ERR_INVALID_EMAIL_ADDRESS'=>'not a valid email address.',
-
-'ERR_INVALID_DATE_FORMAT'=>'The date format must be: yyyy-mm-dd',
-
-'ERR_INVALID_MONTH'=>'Please enter a valid month.',
-
-'ERR_INVALID_DAY'=>'Please enter a valid day.',
-
-'ERR_INVALID_YEAR'=>'Please enter a valid 4 digit year.',
-
-'ERR_INVALID_DATE'=>'Please enter a valid date.',
-
-'ERR_INVALID_HOUR'=>'Please enter a valid hour.',
-
-'ERR_INVALID_TIME'=>'Please enter a valid time.',
-
-'NTC_CLICK_BACK'=>'Please click the browser back button and fix the error.',
-
-'LBL_LIST_ASSIGNED_USER'=>'Assigned To',
-
-'LBL_ASSIGNED_TO'=>'Assigned To:',
-
-'LBL_DATE_MODIFIED'=>'Last Modified:',
-
-'LBL_DATE_ENTERED'=>'Created:',
-
-'LBL_CURRENT_USER_FILTER'=>'Only my items:',
-
-'NTC_LOGIN_MESSAGE'=>"Login",
-
-'LBL_NONE'=>'--None--',
-
-'LBL_BACK'=>'Back',
-
-'LBL_IMPORT'=>'Import',
-
-'LBL_EXPORT'=>'Export',
-
-'LBL_EXPORT_ALL'=>'Export All',
-
-'LBL_QUICK_CREATE'=>'Quick Create',
-
-'Export'=>'Export',
-'Import'=>'Import',
-'Merge'=>'Merge',
-'ConvertLead'=>'ConvertLead',
-
-
-'LBL_SHOW_RESULTS'=>'Show Results in',
-'LBL_TOTAL_RECORDS_FOUND'=>'Total Records found :',
-'LBL_SEARCH_RESULTS_FOR'=>' -- Search results for ',
-'LBL_TAG_SEARCH'=>' -- Tag search for ',
-'LBL_NO_DATA'=>'No Data Found',
-
-
-//3.2 release
-
-'NTC_MERGE_CONFIRMATION'=>'Are you sure you want to merge this record?',
-
-'LBL_MERGE_BUTTON_TITLE'=>'Merge',
-
-'LBL_MERGE_BUTTON_KEY'=> 'Merge',
-
-'LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE'=>'Select Email Template',
-
-'LBL_SELECTEMAILTEMPLATE_BUTTON_KEY'=>'Select Email Template',
-
-'LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL'=>'Select Email Template',
-
-'LBL_MERGE_BUTTON_LABEL'=>'Merge',
-
-'LBL_SENDMAIL_BUTTON_TITLE'=>'SendMail',
-
-'LBL_SENDMAIL_BUTTON_KEY'=> 'SendMail',
-
-'LBL_SENDMAIL_BUTTON_LABEL'=>'Send Mail',
-
-
-
-//Added fields for upload file as attachment -- 4 Beta
-
-'LBL_UPD_DESC'=>'Description',
-
-'LBL_FILENAME'=>'File Name',
-
-'LBL_FILE'=>'File',
-
-'LBL_TYPE'=>'File Type',
-
-'LBL_DOWNLOAD'=>'Download Now',
-
-'LBL_OPERATION'=>'Operation',
-
-'LBL_GROUP_ALLOCATION_TITLE'=>'My Group Allocation ',
-
-'LBL_ENTITY_NAME'=>'Entity Name',
-
-'LBL_GROUP_NAME'=>'Group',
-
-'LBL_ENTITY_TYPE'=>'Type',
-
-
-
-//Added fields for Ticket Attachment in RelatedTicketListUtil
-
-'LBL_NEW_TICKET'=>'New Ticket',
-
-'LBL_TITLE'=>'Title',
-
-'LBL_PRIORITY'=>'Priority',
-
-'LBL_STATUS'=>'Status',
-
-
-
-//Added fields for Change Owner and Change Status in all modules -- after 4 Beta
-
-'LBL_CHANGE_OWNER'=>'Change Owner',
-
-'LBL_CHANGE_STATUS'=>'Change Status',
-
-'LBL_MASS_DELETE'=>'Delete',
-//added by raju
-
-'LBL_ADD_ITEM'=>'Add',
-
-'LBL_ADD_NEW'=>'Add',
-
-'LBL_DEDUCT'=>'Deduct',
-//Added for version 5
-
-'LBL_CALENDAR_TITLE'=>'Open Calendar...',
-'LBL_CALENDAR_ALT'=>'Open Calendar...',
-
-'LBL_CALCULATOR_TITLE'=>'Open Calculator...',
-'LBL_CALCULATOR_ALT'=>'Open Calculator...',
-
-'LBL_CLOCK_TITLE'=>'Show World Clock...',
-'LBL_CLOCK_ALT'=>'Show World Clock...',
-
-'LBL_ALL_MENU_TITLE'=>'Open All Menu...',
-'LBL_ALL_MENU_ALT'=>'Open All Menu...',
-
-'LBL_CHAT_TITLE'=>'Chat...',
-'LBL_CHAT_ALT'=>'Chat...',
-
-'LBL_SEARCH_TITLE'=>'Search in ',
-'LBL_SEARCH_ALT'=>'Search in ',
-
-'LBL_SEARCH_STRING'=>'Search...',
-
-'LBL_SEARCH_FOR'=>'Search for',
-'LBL_SEARCH_NOW_BUTTON'=>'Search Now',
-'LBL_GO_TO'=>'Go to',
-'LBL_FEWER_BUTTON'=>'Fewer',
-'LBL_IN'=>'In',
-
-'LBL_ADV_SEARCH_MSG_ANY'=>'Match Any of the Following',
-'LBL_ADV_SEARCH_MSG_ALL'=>'Match All of the Following',
-
-'COMBO_ALL'=>'All',
-
-// Added fields for Related Field Display Informations in Detail View of All Modules
-
-'LBL_OPEN_ACTIVITIES'=>'Open Activities',
-
-'LBL_HISTORY'=>'History',
-
-'LBL_ACTIVITY_HISTORY'=>'Activity History',
-
-'LBL_ATTACHMENTS'=>'Attachments',
-
-'LBL_ATTACHMENT'=>'Attachment',
-
-'LBL_TYPE'=>'Type',
-
-'LBL_ASSIGNED_TO'=>'Assigned To',
-
-'LBL_TIME'=>'Time',
-
-'LBL_ACTION'=>'Action',
-
-'LBL_SUBJECT'=>'Subject',
-
-'LBL_RELATED_TO'=>'Related To',
-
-//added by raju for emails
-
-'LBL_MULTIPLE'=>'Multiple',
-
-'LBL_DUE_DATE'=>'Due Date',
-
-'LBL_LAST_MODIFIED'=>'Last Modified',
-
-'LBL_CREATED'=>'Created', // Armando Lüscher 26.09.2005 -> §visibleDescription -> Desc: Added
-
-'LBL_DESCRIPTION'=>'Description',
-
-
-
-'LBL_NEW_TASK'=>'New Task',
-
-'LBL_NEW_EVENT'=>'New Event',
-
-'LBL_ATTACHMENT_AND_NOTES'=>'Attachments & Notes',
-
-'LBL_POTENTIAL_NAME'=>'Potential Name',
-
-'LBL_CONTACT_NAME'=>'Contact Name',
-
-'LBL_DEPARTMENT'=>'Department',
-
-'LBL_ROLE'=>'Role',
-
-'LBL_EMAIL'=>'Email',
-
-'LBL_PHONE'=>'Phone',
-
-'LBL_PRODUCT'=>'Product',
-
-'LBL_AMOUNT'=>'Amount',
-
-'LBL_CLOSE_DATE'=>'Close Date',
-
-'LBL_NEW_ATTACHMENT'=>'New Attachment',
-
-'LBL_NEW_NOTE'=>'New Note',
-
-
-
-'LBL_PRODUCT_TITLE'=>'Products',
-
-'LBL_NEW_PRODUCT'=>'New Product',
-
-'LBL_PRODUCT_NAME'=>'Product Name',
-
-'LBL_QUANTITY'=>'Quantity',
-
-'LBL_SALES_PRICE'=>'Sale Price',
-
-'LBL_PURCHASE_DATE'=>'Purchase Date',
-
-'LBL_TICKET_ID'=>'Ticket Id',
-
-'LBL_NEW_TICKET'=>'New Ticket',
-
-'LBL_TICKETS'=>'Tickets',
-
-
-
-'LBL_POTENTIAL_TITLE'=>'Potentials',
-
-'LBL_NEW_POTENTIAL'=>'New Potential',
-
-'LBL_LEAD_NAME'=>'Lead Name',
-
-'LBL_ACCOUNT_NAME'=>'Account Name',
-
-'LBL_ACCOUNT_TYPE'=>'Account Type',
-
-'LBL_USER_TITLE'=>'Users',
-
-'LBL_CONTACT_TITLE'=>'Contacts',
-
-
-
-// 4 GA
-
+'NTC_WELCOME_MESSAGE' => 'Welcome to vtiger CRM!',
+'NTC_DESCRIPTION' => 'Use a valid username and password to login to the vtiger CRM.',
+'NTC_WELCOME' => 'Welcome',
+'NTC_NO_ITEMS_DISPLAY' => 'none',
+'LBL_OR' => 'or',
+'LBL_ALT_HOT_KEY' => 'Alt+',
+'LBL_SAVE_LABEL' => 'Save',
+'LBL_SEND_MAIL_BUTTON' => 'Send Mail',
+'LBL_SAVE_BUTTON_TITLE' => 'Save [Alt+S]',
+'LBL_EDIT_BUTTON_TITLE' => 'Edit [Alt+E]',
+'LBL_CONVERTSO_BUTTON_TITLE' => 'Create SalesOrder',
+'LBL_CONVERTINVOICE_BUTTON_TITLE' => 'Create Invoice',
+'LBL_EDIT_BUTTON' => 'Edit',
+'LBL_DUPLICATE_BUTTON_TITLE' => 'Duplicate [Alt+U]',
+'LBL_DUPLICATE_BUTTON' => 'Duplicate',
+'LBL_TABCUSTOMISE_BUTTON_TITLE' => 'Customise [Alt+C]',
+'LBL_FORUM_HIDE_BUTTON_TITLE' => 'Hide Forum [Alt+I]',
+'LBL_FORUM_HIDE_BUTTON_KEY' => 'H',
+'LBL_FORUM_SHOW_BUTTON_TITLE' => 'Show Forum [Alt+W]',
+'LBL_FORUM_SHOW_BUTTON_KEY' => 'W',
+'LBL_TABCUSTOMISE_BUTTON' => 'Customise',
+'LBL_DELETE_BUTTON_TITLE' => 'Delete [Alt+D]',
+'LBL_DELETE_BUTTON' => 'Delete',
+'LBL_FIND_BUTTON' => 'Find',
+'LBL_CONVERT_BUTTON_TITLE' => 'Convert [Alt+C]',
+'LBL_CONVERT_BUTTON_KEY' => 'C',
+'LBL_CONVERT_BUTTON_LABEL' => 'Convert Lead',
+'LBL_TABCUSTOMISE_BUTTON_KEY' => 'C',
+'LBL_TABCUSTOMISE_BUTTON_LABEL' => 'Customize Tab',
+'LBL_ROLES_BUTTON_LABEL' => 'Show Roles',
+'LBL_LISTROLES_BUTTON_LABEL' => 'List Roles',
+'LBL_FORUM_HIDE_BUTTON_LABEL' => 'Hide Forums',
+'LBL_FORUM_SHOW_BUTTON_LABEL' => 'Show Forums',
+'LBL_NEW_BUTTON_TITLE' => 'New [Alt+N]',
+'LBL_CHANGE_BUTTON_TITLE' => 'Change [Alt+G]',
+'LBL_CANCEL_BUTTON_TITLE' => 'Cancel [Alt+X]',
+'LBL_SEARCH_BUTTON_TITLE' => 'Search [Alt+Q]',
+'LBL_CLEAR_BUTTON_TITLE' => 'Clear [Alt+C]',
+'LBL_SELECT_BUTTON_TITLE' => 'Select [Alt+T]',
+'LBL_CREATE_BUTTON_LABEL' => 'Create',
+'LBL_GENERATE' => 'Generate',
+'LBL_SAVE_BUTTON_KEY' => 'S',
+'LBL_EDIT_BUTTON_KEY' => 'E',
+'LBL_CONVERTSO_BUTTON_KEY' => 'S',
+'LBL_CONVERTINVOICE_BUTTON_KEY' => 'I',
+'LBL_DUPLICATE_BUTTON_KEY' => 'U',
+'LBL_DELETE_BUTTON_KEY' => 'D',
+'LBL_NEW_BUTTON_KEY' => 'N',
+'LBL_CHANGE_BUTTON_KEY' => 'G',
+'LBL_CANCEL_BUTTON_KEY' => 'X',
+'LBL_SEARCH_BUTTON_KEY' => 'Q',
+'LBL_CLEAR_BUTTON_KEY' => 'C',
+'LBL_SELECT_BUTTON_KEY' => 'T',
+'LBL_SAVE_BUTTON_LABEL' => 'Save',
+'LBL_EDIT_BUTTON_LABEL' => 'Edit',
+'LBL_CONVERTSO_BUTTON_LABEL' => 'Create SalesOrder',
+'LBL_CONVERTINVOICE_BUTTON_LABEL' => 'Create Invoice',
+'LBL_DUPLICATE_BUTTON_LABEL' => 'Duplicate',
+'LBL_DELETE_BUTTON_LABEL' => 'Delete',
+'LBL_NEW_BUTTON_LABEL' => 'New',
+'LBL_CHANGE_BUTTON_LABEL' => 'Change',
+'LBL_CANCEL_BUTTON_LABEL' => 'Cancel',
+'LBL_SEARCH_BUTTON_LABEL' => 'Search',
+'LBL_CLEAR_BUTTON_LABEL' => 'Clear',
+'LBL_SELECT_BUTTON_LABEL' => 'Select',
+'LBL_SELECT_CONTACT_BUTTON_TITLE' => 'Select Contact [Alt+T]',
+'LBL_SELECT_CONTACT_BUTTON_KEY' => 'T',
+'LBL_SELECT_CONTACT_BUTTON_LABEL' => 'Select Contact',
+'LBL_SELECT_CAMPAIGN_BUTTON_LABEL' => 'Select Campaign',
+'LBL_SELECT_USER_BUTTON_TITLE' => 'Select User [Alt+U]',
+'LBL_SELECT_USER_BUTTON_KEY' => 'U',
+'LBL_SELECT_USER_BUTTON_LABEL' => 'Select User',
+'LBL_SETTINGS' => 'Settings',
+'LBL_LIST_USERIP' => 'User IP',
+'LBL_LIST_SIGNIN' => 'Sign in Time',
+'LBL_LIST_SIGNOUT' => 'Sign out Time',
+'LBL_LIST_STATUS' => 'Status',
+'LBL_LIST_NAME' => 'Name',
+'LBL_LIST_USER_NAME' => 'User Name',
+'LBL_LIST_EMAIL' => 'Email',
+'LBL_LIST_PHONE' => 'Phone',
+'LBL_LIST_CONTACT_NAME' => 'Contact Name',
+'LBL_LIST_ACCOUNT_NAME' => 'Account Name',
+'LBL_USER_LIST' => 'User List',
+'LBL_CONTACT_LIST' => 'Contact List',
+'LBL_LNK_SETTINGS' => 'Settings',
+'LNK_IMPORT_LEADS' => 'Import Leads',
+'LBL_LOCATE_MAP' => 'Locate Map',
+'LBL_ADDRESS' => 'Address',
+'LBL_ADD_TAG' => 'Add Tag',
+'LBL_TAG_IT' => 'Tag it',
+'LBL_CLOSE' => 'Close',
+'LNK_ADVANCED_SEARCH' => 'Advanced Search',
+'LNK_BASIC_SEARCH' => 'Basic Search',
+'LNK_EDIT' => 'edit',
+'LNK_REMOVE' => 'rem',
+'LNK_DELETE' => 'del',
+'LNK_LIST_START' => 'Start',
+'LNK_LIST_NEXT' => 'Next',
+'LNK_LIST_PREVIOUS' => 'Previous',
+'LNK_LIST_END' => 'End',
+'LBL_LIST_OF' => 'of',
+'LNK_PRINT' => 'Print',
+'LNK_HELP' => 'Help',
+'LNK_VTDOCS' => 'vtiger Docs',
+'LNK_ABOUT' => 'About',
+'LNK_OUTLOOK' => './include/images/outlook_download.gif',
+'SINGLE_Accounts' => 'Account',
+'SINGLE_Contacts' => 'Contact',
+'SINGLE_Campaigns' => 'Campaign',
+'SINGLE_HelpDesk' => 'Ticket',
+'SINGLE_Leads' => 'Lead',
+'SINGLE_Events' => 'Event',
+'SINGLE_Calendar' => 'Task',
+'SINGLE_Dashboard' => 'Dashboard',
+'SINGLE_Emails' => 'Email',
+'SINGLE_Faq' => 'Faq',
+'SINGLE_Home' => 'Home',
+'SINGLE_Invoice' => 'Invoice',
+'SINGLE_Potentials' => 'Potential',
+'SINGLE_Notes' => 'Note',
+'SINGLE_Products' => 'Product',
+'SINGLE_Vendors' => 'Vendor',
+'SINGLE_PriceBooks' => 'PriceBook',
+'SINGLE_Quotes' => 'Quote',
+'SINGLE_PurchaseOrder' => 'PurchaseOrder',
+'SINGLE_SalesOrder' => 'SalesOrder',
+'SINGLE_Rss' => 'Rss',
+'SINGLE_Reports' => 'Report',
+'SINGLE_Portal' => 'Portal',
+'SINGLE_Webmails' => 'Webmail',
+'SINGLE_Users' => 'User',
+'NEW' => 'New',
+'NTC_REQUIRED' => 'Indicates required field',
+'LBL_REQUIRED_SYMBOL' => '*',
+'LBL_CURRENCY_SYMBOL' => '$',
+'LBL_THOUSANDS_SYMBOL' => 'K',
+'NTC_DATE_FORMAT' => '(yyyy-mm-dd)',
+'NTC_TIME_FORMAT' => '(24:00)',
+'NTC_DATE_TIME_FORMAT' => '(yyyy-mm-dd 24:00)',
+'NTC_DELETE_CONFIRMATION' => 'Are you sure you want to delete this record?',
+'NTC_ACCOUNT_DELETE_CONFIRMATION' => 'Deleting this account will remove its related Potentials,Quotes,Sales Orders & Invoice. Are you sure you want to delete this account?',
+'NTC_VENDOR_DELETE_CONFIRMATION' => 'Deleting this vendor will remove its related Purchase Orders. Are you sure you want to delete this vendor?',
+'ERR_DELETE_RECORD' => 'A record number must be specified to delete the contact.',
+'ERR_CREATING_TABLE' => 'Error creating table: ',
+'ERR_CREATING_FIELDS' => 'Error filling in additional detail fields: ',
+'ERR_MISSING_REQUIRED_FIELDS' => 'Missing required fields:',
+'ERR_INVALID_EMAIL_ADDRESS' => 'not a valid email address.',
+'ERR_INVALID_DATE_FORMAT' => 'The date format must be: yyyy-mm-dd',
+'ERR_INVALID_MONTH' => 'Please enter a valid month.',
+'ERR_INVALID_DAY' => 'Please enter a valid day.',
+'ERR_INVALID_YEAR' => 'Please enter a valid 4 digit year.',
+'ERR_INVALID_DATE' => 'Please enter a valid date.',
+'ERR_INVALID_HOUR' => 'Please enter a valid hour.',
+'ERR_INVALID_TIME' => 'Please enter a valid time.',
+'NTC_CLICK_BACK' => 'Please click the browser back button and fix the error.',
+'LBL_LIST_ASSIGNED_USER' => 'Assigned To',
+'LBL_ASSIGNED_TO' => 'Assigned To',
+'LBL_DATE_MODIFIED' => 'Last Modified:',
+'LBL_DATE_ENTERED' => 'Created:',
+'LBL_CURRENT_USER_FILTER' => 'Only my items:',
+'NTC_LOGIN_MESSAGE' => 'Login',
+'LBL_NONE' => '--None--',
+'LBL_BACK' => 'Back',
+'LBL_IMPORT' => 'Import',
+'LBL_EXPORT' => 'Export',
+'LBL_EXPORT_ALL' => 'Export All',
+'LBL_QUICK_CREATE' => 'Quick Create',
+'Export' => 'Export',
+'Import' => 'Import',
+'Merge' => 'Merge',
+'ConvertLead' => 'ConvertLead',
+'LBL_SHOW_RESULTS' => 'Show Results in',
+'LBL_TOTAL_RECORDS_FOUND' => 'Total Records found :',
+'LBL_SEARCH_RESULTS_FOR' => ' -- Search results for ',
+'LBL_TAG_SEARCH' => ' -- Tag search for ',
+'LBL_NO_DATA' => 'No Data Found',
+'NTC_MERGE_CONFIRMATION' => 'Are you sure you want to merge this record?',
+'LBL_MERGE_BUTTON_TITLE' => 'Merge',
+'LBL_MERGE_BUTTON_KEY' => 'Merge',
+'LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE' => 'Select Email Template',
+'LBL_SELECTEMAILTEMPLATE_BUTTON_KEY' => 'Select Email Template',
+'LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL' => 'Select Email Template',
+'LBL_MERGE_BUTTON_LABEL' => 'Merge',
+'LBL_SENDMAIL_BUTTON_TITLE' => 'SendMail',
+'LBL_SENDMAIL_BUTTON_KEY' => 'SendMail',
+'LBL_SENDMAIL_BUTTON_LABEL' => 'Send Mail',
+'LBL_UPD_DESC' => 'Description',
+'LBL_FILENAME' => 'File Name',
+'LBL_FILE' => 'File',
+'LBL_TYPE' => 'Type',
+'LBL_DOWNLOAD' => 'Download Now',
+'LBL_OPERATION' => 'Operation',
+'LBL_GROUP_ALLOCATION_TITLE' => 'My Group Allocation ',
+'LBL_ENTITY_NAME' => 'Entity Name',
+'LBL_GROUP_NAME' => 'Group',
+'LBL_ENTITY_TYPE' => 'Type',
+'LBL_NEW_TICKET' => 'New Ticket',
+'LBL_TITLE' => 'Title',
+'LBL_PRIORITY' => 'Priority',
+'LBL_STATUS' => 'Status',
+'LBL_CHANGE_OWNER' => 'Change Owner',
+'LBL_CHANGE_STATUS' => 'Change Status',
+'LBL_MASS_DELETE' => 'Delete',
+'LBL_ADD_ITEM' => 'Add',
+'LBL_ADD_NEW' => 'Add',
+'LBL_DEDUCT' => 'Deduct',
+'LBL_CALENDAR_TITLE' => 'Open Calendar...',
+'LBL_CALENDAR_ALT' => 'Open Calendar...',
+'LBL_CALCULATOR_TITLE' => 'Open Calculator...',
+'LBL_CALCULATOR_ALT' => 'Open Calculator...',
+'LBL_CLOCK_TITLE' => 'Show World Clock...',
+'LBL_CLOCK_ALT' => 'Show World Clock...',
+'LBL_ALL_MENU_TITLE' => 'Open All Menu...',
+'LBL_ALL_MENU_ALT' => 'Open All Menu...',
+'LBL_CHAT_TITLE' => 'Chat...',
+'LBL_CHAT_ALT' => 'Chat...',
+'LBL_SEARCH_TITLE' => 'Search in ',
+'LBL_SEARCH_ALT' => 'Search in ',
+'LBL_SEARCH_STRING' => 'Search...',
+'LBL_SEARCH_FOR' => 'Search for',
+'LBL_SEARCH_NOW_BUTTON' => 'Search Now',
+'LBL_GO_TO' => 'Go to',
+'LBL_FEWER_BUTTON' => 'Fewer',
+'LBL_IN' => 'In',
+'LBL_ADV_SEARCH_MSG_ANY' => 'Match Any of the Following',
+'LBL_ADV_SEARCH_MSG_ALL' => 'Match All of the Following',
+'COMBO_ALL' => 'All',
+'LBL_OPEN_ACTIVITIES' => 'Open Activities',
+'LBL_HISTORY' => 'History',
+'LBL_ACTIVITY_HISTORY' => 'Activity History',
+'LBL_ATTACHMENTS' => 'Attachments',
+'LBL_ATTACHMENT' => 'Attachment',
+'LBL_TIME' => 'Time',
+'LBL_ACTION' => 'Action',
+'LBL_SUBJECT' => 'Subject',
+'LBL_RELATED_TO' => 'Related To',
+'LBL_MULTIPLE' => 'Multiple',
+'LBL_DUE_DATE' => 'Due Date',
+'LBL_LAST_MODIFIED' => 'Last Modified',
+'LBL_CREATED' => 'Created',
+'LBL_DESCRIPTION' => 'Description',
+'LBL_NEW_TASK' => 'New Task',
+'LBL_NEW_EVENT' => 'New Event',
+'LBL_ATTACHMENT_AND_NOTES' => 'Attachments & Notes',
+'LBL_POTENTIAL_NAME' => 'Potential Name',
+'LBL_CONTACT_NAME' => 'Contact Name',
+'LBL_DEPARTMENT' => 'Department',
+'LBL_ROLE' => 'Role',
+'LBL_EMAIL' => 'Email',
+'LBL_PHONE' => 'Phone',
+'LBL_PRODUCT' => 'Product',
+'LBL_AMOUNT' => 'Amount',
+'LBL_CLOSE_DATE' => 'Close Date',
+'LBL_NEW_ATTACHMENT' => 'New Attachment',
+'LBL_NEW_NOTE' => 'New Note',
+'LBL_PRODUCT_TITLE' => 'Products',
+'LBL_NEW_PRODUCT' => 'New Product',
+'LBL_PRODUCT_NAME' => 'Product Name',
+'LBL_QUANTITY' => 'Quantity',
+'LBL_SALES_PRICE' => 'Sale Price',
+'LBL_PURCHASE_DATE' => 'Purchase Date',
+'LBL_TICKET_ID' => 'Ticket Id',
+'LBL_TICKETS' => 'Tickets',
+'LBL_POTENTIAL_TITLE' => 'Potentials',
+'LBL_NEW_POTENTIAL' => 'New Potential',
+'LBL_LEAD_NAME' => 'Lead Name',
+'LBL_ACCOUNT_NAME' => 'Account Name',
+'LBL_ACCOUNT_TYPE' => 'Account Type',
+'LBL_USER_TITLE' => 'Users',
+'LBL_CONTACT_TITLE' => 'Contacts',
 'LBL_SHOWING' => 'Showing',
-
-//
-
-
-
-//Added fields after RC1 - Release
-
-'LBL_SELECT_PRODUCT_BUTTON_LABEL'=>'Select Product',
-
-'LBL_VIEW'=>'Filters :',
-// Mike Crowe Mod --------------------------------------------------------Added for group sort
-'LBL_GROUP_VIEW'=>'Group',
-
-
-'LBL_SALES_STAGE'=>'Sales Stage',
-
-'LBL_PROBABILITY'=>'Probability',
-
-'LBL_BULK_MAILS'=>'Bulk Mails',
-
-
-
-'LBL_WORLD_CLOCK'=>'World Clock',
-
-'LBL_CALCULATOR'=>'Calculator',
-
-'LBL_CLOSE_WON' =>'Closed Won',			# 'Closed Won'
-'LBL_CLOSE_LOST'=>'Closed Lost',					# 'Closed Lost'
-
-'LBL_USER'=>'User',
-
-'LBL_TEAM'=>'Team',
-
-'LBL_GROUP'=>'Group',
-
-'LBL_NONE_NO_LINE'=>'none',
-
-'LBL_SELECT_GROUP'=>'Select a group',
-
-'LBL_HOUR_AND_MINUTE'=>'(hours/minutes)',
-
-'YEAR_MONTH_DATE'=>'24:00',
-
-
-
-'COMBO_LEADS'=>'Leads',
-
-'COMBO_ACCOUNTS'=>'Accounts',
-
-'COMBO_CONTACTS'=>'Contacts',
-
-'COMBO_POTENTIALS'=>'Potentials',
-
-'COMBO_PRODUCTS'=>'Products',
-
-'COMBO_HELPDESK'=>'Trouble Tickets',
-
-'COMBO_USERS'=>'Users',
-
-'COMBO_CAMPAIGNS'=>'Campaigns',
-
-
-'LBL_SELECT'=>'Select',
-
-'LBL_EDIT'=>'Edit',
-
-'LBL_DELETE'=>'Delete',
-
-
-
-//List Fields
-
-'Name'=>'Name',
-
-'Company'=>'Company',
-
-'Phone'=>'Phone',
-
-'Website'=>'Website',
-
-'Email'=>'Email',
-
-'Assigned To'=>'Assigned To',
-
-'Account Name'=>'Account Name',
-
-'City'=>'City',
-
-'Title'=>'Title',
-
-'Potential'=>'Potential',
-
-'Sales Stage'=>'Sales Stage',
-
-'Amount'=>'Amount',
-
-'Expected Close'=>'Expected Close',
-
-'Subject'=>'Subject',
-
-'Contact Name'=>'Contact Name',
-
-'Related to'=>'Related To',
-
-'File'=>'File',
-
-'Last Modified'=>'Last Modified',
-
-'Close'=>'Close',
-
-'Type'=>'Type',
-
-'Start Date/Due Date'=>'Start Date/Due Date',
-
-'Date Sent'=>'Date Sent',
-
-'Ticket ID'=>'Ticket ID',
-
-'Status'=>'Status',
-
-'Priority'=>'Priority',
-
-'Product Name'=>'Product Name',
-
-'Product Code'=>'Part Number',
-
-'Commission Rate'=>'Commission Rate',
-
-'Qty/Unit'=>'Qty/Unit',
-
-'Unit Price'=>'Unit Price',
-
-'Question'=>'Question',
-
-'Category'=>'Category',
-
-'Price Book Name'=>'Price Book Name',
-'LBL_EVENT_ENDDATE'=>'End Date & Time',
-
-//Added after 4 GA
-'LBL_CUSTOM_INFORMATION'=>'Custom Information',
-
-//Added fields to display the related lists titles and None Scheduled 
-'LBL_NONE_SCHEDULED'=>'None Scheduled',
-
-'Leads'=>'Leads',
-'Accounts'=>'Accounts',
-'Accounts & Contacts'=>'Accounts & Contacts',
-'Contacts'=>'Contacts',
-'Potentials'=>'Potentials',
-'Products'=>'Products',
-'Emails'=>'Emails',
-'HelpDesk'=>'Trouble Tickets',
-'Activities'=>'Activities',
-'Events'=>'Events',
-'Tasks'=>'Tasks',
-'Todo'=>'To Do',
-'Call'=>'Call',
-'Meeting'=>'Meeting',
-'Quotes'=>'Quotes',
-'PriceBook'=>'Price Books',
-'PurchaseOrder'=>'Purchase Order',
-'SalesOrder'=>'Sales Order',
-'Invoice'=>'Invoices',
-'Calendar'=>'Calendar',
-'Home'=>'Home',
-'Campaigns'=>'Campaigns',
+'LBL_SELECT_PRODUCT_BUTTON_LABEL' => 'Select Product',
+'LBL_VIEW' => 'Filters :',
+'LBL_GROUP_VIEW' => 'Group',
+'LBL_SALES_STAGE' => 'Sales Stage',
+'LBL_PROBABILITY' => 'Probability',
+'LBL_BULK_MAILS' => 'Bulk Mails',
+'LBL_WORLD_CLOCK' => 'World Clock',
+'LBL_CALCULATOR' => 'Calculator',
+'LBL_CLOSE_WON' => 'Closed Won',
+'LBL_CLOSE_LOST' => 'Closed Lost',
+'LBL_USER' => 'User',
+'LBL_TEAM' => 'Team',
+'LBL_GROUP' => 'Group',
+'LBL_NONE_NO_LINE' => 'none',
+'LBL_SELECT_GROUP' => 'Select a group',
+'LBL_HOUR_AND_MINUTE' => '(hours/minutes)',
+'YEAR_MONTH_DATE' => '24:00',
+'COMBO_LEADS' => 'Leads',
+'COMBO_ACCOUNTS' => 'Accounts',
+'COMBO_CONTACTS' => 'Contacts',
+'COMBO_POTENTIALS' => 'Potentials',
+'COMBO_PRODUCTS' => 'Products',
+'COMBO_HELPDESK' => 'Trouble Tickets',
+'COMBO_USERS' => 'Users',
+'COMBO_CAMPAIGNS' => 'Campaigns',
+'LBL_SELECT' => 'Select',
+'LBL_EDIT' => 'Edit',
+'LBL_DELETE' => 'Delete',
+'Name' => 'Name',
+'Company' => 'Company',
+'Phone' => 'Phone',
+'Website' => 'Website',
+'Email' => 'Email',
+'Assigned To' => 'Assigned To',
+'Account Name' => 'Account Name',
+'City' => 'City',
+'Title' => 'Title',
+'Potential' => 'Potential',
+'Sales Stage' => 'Sales Stage',
+'Amount' => 'Amount',
+'Expected Close' => 'Expected Close',
+'Subject' => 'Subject',
+'Contact Name' => 'Contact Name',
+'Related to' => 'Related To',
+'File' => 'File',
+'Last Modified' => 'Last Modified',
+'Close' => 'Close',
+'Type' => 'Type',
+'Start Date/Due Date' => 'Start Date/Due Date',
+'Date Sent' => 'Date Sent',
+'Ticket ID' => 'Ticket ID',
+'Status' => 'Status',
+'Priority' => 'Priority',
+'Product Name' => 'Product Name',
+'Product Code' => 'Part Number',
+'Commission Rate' => 'Commission Rate',
+'Quantity In Stock' => 'Quantity In Stock',
+'Qty/Unit' => 'Qty/Unit',
+'Unit Price' => 'Unit Price',
+'Question' => 'Question',
+'Category' => 'Category',
+'Price Book Name' => 'Price Book Name',
+'LBL_EVENT_ENDDATE' => 'End Date & Time',
+'LBL_CUSTOM_INFORMATION' => 'Custom Information',
+'LBL_NONE_SCHEDULED' => 'None Scheduled',
+'Leads' => 'Leads',
+'Accounts' => 'Accounts',
+'Accounts & Contacts' => 'Accounts & Contacts',
+'Contacts' => 'Contacts',
+'Potentials' => 'Potentials',
+'Products' => 'Products',
+'Emails' => 'Emails',
+'HelpDesk' => 'Trouble Tickets',
+'Activities' => 'Activities',
+'Events' => 'Events',
+'Tasks' => 'Tasks',
+'Todo' => 'To Do',
+'Call' => 'Call',
+'Meeting' => 'Meeting',
+'Quotes' => 'Quotes',
+'PriceBook' => 'PriceBook',
+'PurchaseOrder' => 'Purchase Orders',
+'SalesOrder' => 'Sales Orders',
+'Invoice' => 'Invoices',
+'Calendar' => 'Calendar',
+'Home' => 'Home',
+'Campaigns' => 'Campaigns',
 'Organization'=>'Organization',
 'Organization Name'=>'Organization Name',
 'OrgUnit'=>'Org Unit',
-'PriceBooks'=>'Price Books',
-'Notes'=>'Notes',
-'Faq'=>'FAQ',
-'Dashboards'=>'Dashboard',
-'Reports'=>'Reports',
-'Vendors'=>'Vendors',
-'Rss'=>'RSS',
-'Portal'=>'My Sites',
-'Webmails'=>'Webmails',
-'Attachments'=>'Attachments',
-'Activity History'=>'Activity History',
-'Ticket History'=>'Ticket History',
-'Purchase Order'=>'Purchase Order',
-'Sales Stage History'=>'Sales Stage History',
-'Users'=>'Users',
-'Admin'=>'Admin',
-'PurchaseOrder Status History'=>'PurchaseOrder Status History',
-'SalesOrder Status History'=>'SalesOrder Status History',
-'Quote Stage History'=>'Quote Stage History',
-'Invoice Status History'=>'Invoice Status History',
-'LBL_TROUBLE_TICKET'=>'Trouble Ticket',
-
-//Added language for Parent Tab
-
-'My Home Page'=>'My Home Page',
-'Marketing'=>'Marketing',
-'Sales'=>'Sales',
-'Support'=>'Support',
-'Analytics'=>'Analytics',
-'Inventory'=>'Inventory',
-'Tools'=>'Tools',
-'Settings'=>'Settings',
-
-'LBL_INFORMATION'=>'Information',
-'LBL_MORE'=>'More',
-'LBL_BASIC'=>'Basic',
-'LBL_CREATING'=>'Creating',
-'LBL_EDITING'=>'Editing',
-'LBL_NEW'=>'New',
-
-//Added for Detail/Edit/Related List of all modules
-
-'Lead'=>'Lead',
-'Account'=>'Account',
-'Contact'=>'Contact',
-'Potential'=>'Potential',
-'Opportunity'=>'Potential',
-'Product'=>'Product',
-'Email'=>'Email',
-'Activity'=>'Activity',
-'Event'=>'Event',
-'Task'=>'Task',
-'Quote'=>'Quote',
-'PriceBook'=>'PriceBook',
-'PurchaseOrder'=>'Purchase Order',
-'Ticket'=>'Ticket',
-'SalesOrder'=>'Sales Orders',
-'Campaign'=>'Campaign',
-'Note'=>'Note',
-'Dashboard'=>'Dashboards',
-'Report'=>'Report',
-'Vendor'=>'Vendor',
-'Webmail'=>'Webmail',
-
-'LBL_NONE_INCLUDED'=>'None Included',
-'LBL_ADD_TO'=>'Add to',
-
-'LBL_SELECT_TEMPLATE_TO_MAIL_MERGE'=>'Select template to Mail Merge:',
-'LBL_TITLE_OR_DESCRIPTION'=>'Title / Description',
-
-//Added for RSS Module
-'LBL_RSS_FEEDS'=>'RSS Feeds',
-'LBL_ADD_RSS_FEEDS'=>'Add New RSS Feed',
-
-//Added fields after 4.2 alpha
-'COMBO_ACCOUNTS'=>'Accounts',
-'LNK_NEW_FAQ'=>'New FAQ',
-'Vendor Name'=>'Vendor Name',
-'LNK_WEARE'=>'About us',
-'LBL_ABOUTUS_TITLE'=>'vtiger CRM - About Us',
-'LBL_DISCUSS'=>'Discuss with other users',
-'Quote Stage'=>'Quote Stage',
-'Potential Name'=>'Potential Name',
-'Total'=>'Total Amount',
-'First Name'=>'First Name',
-'Last Name'=>'Last Name',
-'User Name'=>'User Name',
-  /* For purchase order related list in vendor */
-'LBL_PORDER_BUTTON_TITLE'=>'New Purchase Order [Alt+O]',
-'LBL_PORDER_BUTTON'=>'New Purchase Order',
-'LBL_PORDER_BUTTON_KEY'=>'O',
-'Tracking Number'=>'Tracking Number',
-'Order Id'=>'Order Id',
-'Quote Name'=>'Quote Name',
-'Invoice Id'=>'Invoice Id',
-'Quote Id'=>'Quote Id',
-'Sales Order'=>'Sales Order',
- // Added Quote in activity parent type selection / Related list
-'COMBO_QUOTES'=>'Quotes',
-'End Date'=>'End Date',
-'Start Date'=>'Start Date',
-'Related to'=>'Related To',
-'Recurring Type'=> 'Recurring Type',
-'SalesOrders'=> 'Sales Order',
-'PurchaseOrder'=> 'Purchase Orders',
-'LBL_QUOTE_NAME'=>'Quote Name',
- //Added Orders in activity parent type selection / Related list
-'LBL_NEW_QUOTE_BUTTON_TITLE'=>'New Quote [Alt+Q]',
-'LBL_NEW_QUOTE_BUTTON_KEY'=>'Q',
-'LBL_NEW_QUOTE_BUTTON'=>'New Quote',
-'COMBO_PORDER'=>'Purchase Order',
-'COMBO_SORDER'=>'Sales Order',
-'LBL_PORDER_NAME'=>'Purchase Order',
-'LBL_SORDER_NAME'=>'Sales Order',
- // Added Invoice in activity parent type selection / Related list
-'COMBO_INVOICES'=>'Invoice',
-'LBL_INVOICE_NAME'=>'Invoice',
-'LBL_HELPDESK_NAME'=>'Trouble Ticket',
-'LBL_CAMPAIGN_NAME'=>'Campaign Name',
-
-'LBL_NEW_INVOICE_BUTTON_TITLE'=>'New Invoice [Alt+I]',
-'LBL_NEW_INVOICE_BUTTON_KEY'=>'I',
-'LBL_NEW_INVOICE_BUTTON'=>'New Invoice',
-'LBL_NEW_SORDER_BUTTON_TITLE'=>'New Sales Order [Alt+E]',
-'LBL_NEW_SORDER_BUTTON_KEY'=>'E',
-'LBL_NEW_SORDER_BUTTON'=>'New Sales Order',
-
-'LBL_PRODUCT_DETAILS'=>'Product Details',
-'LBL_PRODUCT'=>'Product',
-'LBL_QTY_IN_STOCK'=>'Qty In Stock',
-'LBL_QTY'=>'Qty',
-'LBL_UNIT_PRICE'=>'Unit Price',
-'LBL_LIST_PRICE'=>'List Price',
-'LBL_TOTAL'=>'Total',
-'LBL_ADD_PRODUCT'=>'Add Product',
-'LBL_SUB_TOTAL'=>'Sub Total',
-'LBL_TAX'=>'Tax',
-'LBL_ADJUSTMENT'=>'Adjustment',
-'LBL_GRAND_TOTAL'=>'Grand Total',
-'LBL_QUOTE_ID'=>'Quote Id',
-'LBL_SALES_ORDER_ID'=>'Sales Order Id',
-'LBL_PURCHASE_ORDER_ID'=>'Purchase Order Id',
-'LBL_EXPORT_TO_PDF'=>'Export To PDF',
-
-//Added for 4.2 Patch I
-'LBL_HOME_KEY_METRICS'=>'Key Metrics',
-'LBL_HOME_METRICS'=>'Metrics',
-'LBL_HOME_COUNT'=>'Count',
-
-//Added for 4.2 patch 2
-'LBL_JSCALENDAR_LANG'=>'en',
-'LNK_CV_EDIT'=>'Edit',
-'LNK_CV_DELETE'=>'Delete',
-'LNK_CV_CREATEVIEW'=>'New',
-//Added for 5.0
-'LBL_UPD_FIELD_ORD'=>'Update Field Order',
-'LBL_SEND_CUSTOM_MAIL_BUTTON'=>'Send Custom Mail',
-'LBL_UPDATED_TODAY'=>'Updated today',
-'LBL_UPDATED'=>'Updated',
-'LBL_DAY_AGO'=>'day ago',
-'LBL_DAYS_AGO'=>'days ago',
-
-//Added to convert Month string in update info - ahmed
-
-'Jan'=>'Jan',
-'Feb'=>'Feb',
-'Mar'=>'Mar',
-'Apr'=>'Apr',
-'May'=>'May',
-'Jun'=>'Jun',
-'Jul'=>'Jul',
-'Aug'=>'Aug',
-'Sep'=>'Sep',
-'Oct'=>'Oct',
-'Nov'=>'Nov',
-'Dec'=>'Dec',
-
-//Added after 5.0 Alpha5
-'Campaign Name'=>'Campaign Name',
-'Campaign Type'=>'Campaign Type',
-'Campaign Status'=>'Campaign Status',
-'Expected Revenue'=>'Expected Revenue',
-'Expected Close Date'=>'Expected Close Date',
-'LBL_ACTIONS'=>'Actions',
-'LBL_SEND'=>'Send',
-'LBL_VAT'=>'VAT',
-'LBL_SALES'=>'Sales',
-'LBL_SERVICE'=>'Service',
-'LBL_TAX_DETAILS'=>'Tax Details',
-'LBL_TAX_CALCULATION'=>'Tax Calculation',
-'COVERED_PERCENTAGE'=>'(%)',
-
-'LBL_TAG_CLOUD'=>'Tag Cloud',
-'LBL_FOR'=>'for',
-'LBL_PO_STATUS'=>'PurchaseOrder Status',
-'LBL_SO_STATUS'=>'SalesOrder Status',
-'LBL_INVOICE_STATUS'=>'Invoice Status',
-'LBL_NOTE'=>'Note',
-'LBL_MODULE'=>'Module',
-'Active'=>'Active',
-'Inactive'=>'Inactive',
-'Today'=>'Today',
-'Last 2 Days'=>'Last 2 Days',
-'Last Week'=>'Last Week',
-'This Week'=>'This Week',
-'This Month'=>'This Month',
-'This Year'=>'This Year',
-'LBL_PLEASE_CLICK'=>'Please Click',
-'LBL_TO_CONFIGURE'=>'to Configure',
-'LBL_HERE'=>'here',
-'LBL_RECORDS'=>'Records',
-'LBL_SCROLL'=>'[Scroll to Top]',
-'LBL_EXPAND_COLLAPSE'=>'Expand/Collapse',
-'LBL_RCPY_ADDRESS'=>'Copy Shipping address',
-'LBL_LCPY_ADDRESS'=>'Copy Billing address',
-'LBL_RECORD_ID'=>'Record ID',
-'LBL_ACTION_DATE'=>'Action Date',
-'LBL_HOMEPAGE_DASHBOARD'=>'HomePage Dashboard',
-'LBL_NO'=>'No',
-'LBL_FOUND'=>'Found',
-'LBL_YOU_CAN_CREATE'=>'You can Create',
-'LBL_NOW'=>'now',
-'LBL_CLICK_THE_LINK'=>'Click the link below',
-'LBL_CREATE'=>'Create',
-'LBL_A'=>'a',
-'LBL_AN'=>'an',
-'LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE'=>'You are not allowed to create',
-'LBL_TRANSFER_OWNERSHIP'=>'Transfer Ownership to',
-'LBL_SELECT_STATUS'=>'Select New Status',
-'LBL_UPDATE_OWNER'=>'Update Owner',
-'LBL_UPDATE_STATUS'=>'Update Status',
-
-//added for tax calculations - after 5beta2
-'LBL_NET_PRICE'=>'Net Price',
-'LBL_TOOLS'=>'Tools',
-'LBL_DISCOUNT'=>'Discount',
-'LBL_TOTAL_AFTER_DISCOUNT'=>'Total After Discount',
-'LBL_NET_TOTAL'=>'Net Total',
-'LBL_SHIPPING_AND_HANDLING_CHARGES'=>'Shipping & Handling Charges',
-'LBL_TAX_FOR_SHIPPING_AND_HANDLING'=>'Taxes For Shipping and Handling',
-'LBL_FINISH'=>'Finish',
-'LBL_IMAGE_DELETED'=>'Image Deleted',
-'LBL_TAX_MODE'=>'Tax Mode',
-'LBL_CLEAR_COMMENT'=>'Clear Comment',
-'LBL_ZERO_DISCOUNT'=>'Zero Discount',
-'LBL_OF_PRICE'=>'of Price',
-'LBL_DIRECT_PRICE_REDUCTION'=>'Direct Price Reduction',
-'LBL_INDIVIDUAL'=>'Individual',
-
-//Added the address strings for Contacts Module
-'LBL_CPY_MAILING_ADDRESS'=>'Copy Mailing Address',
-'LBL_CPY_OTHER_ADDRESS'=>'Copy Other Address',
-
-'LBL_PERMISSION'=>'You are not permitted to execute this Operation',
-'VTIGER'=>'vtiger',
-
-//Added for Inventory Tax details
-'LBL_DIRECT_AMOUNT_DISCOUNT'=>'Direct Amount Discount',
-'LBL_NO_DISCOUNT_FOR_THIS_PRODUCT'=>'No Discount for this Product',
-'LBL_TOTAL_TAX_AMOUNT'=>'Total Tax Amount',
-'LBL_FINAL_DISCOUNT_AMOUNT'=>'Final Discount Amount',
-'LBL_SHIPPING_AND_HANDLING_CHARGE'=>'Shipping & Handling Charge',
-'LBL_GO_BACK'=>'Go Back',
-
-//Record deleted message
-'LBL_RECORD_DELETE'=>'The record you are trying to view has been deleted.',
-'Part Number'=>'Part Number',
-
-//Added after 5.0.1
-'Salutation'=>'Salutation ',
-'Rating'=>'Rating',
-'industry'=>'Industry',
-'Severity'=>'Severity',
-'Product Category'=>'Product Category',
-'GL Account'=>'GL Account',
-'Usage Unit'=>'Usage Unit',
-'Carrier'=>'Carrier',
-'Expected Response'=>'Expected Response',
-'LBL_ADDRESS_INF'=>'Address Information',
-
-'yes'=>'yes',
+'PriceBooks' => 'Price Books',
+'Notes' => 'Notes',
+'Faq' => 'FAQ',
+'Dashboards' => 'Dashboard',
+'Reports' => 'Reports',
+'Vendors' => 'Vendors',
+'Rss' => 'RSS',
+'Portal' => 'My Sites',
+'Webmails' => 'Webmails',
+'Attachments' => 'Attachments',
+'Activity History' => 'Activity History',
+'Ticket History' => 'Ticket History',
+'Purchase Order' => 'Purchase Order',
+'Sales Stage History' => 'Sales Stage History',
+'Users' => 'Users',
+'Admin' => 'Admin',
+'PurchaseOrder Status History' => 'PurchaseOrder Status History',
+'SalesOrder Status History' => 'SalesOrder Status History',
+'Quote Stage History' => 'Quote Stage History',
+'Invoice Status History' => 'Invoice Status History',
+'Piecelist'=>'Group Product consists of',
+'Incompatibles'=>'Product cannot be selled together with',
+'Options'=>'Related products',
+'Dependencies'=>'Required products',
+'Purchaselist'=>'Product purchase list',
+'LBL_TROUBLE_TICKET' => 'Trouble Ticket',
+'My Home Page' => 'My Home Page',
+'Marketing' => 'Marketing',
+'Sales' => 'Sales',
+'Support' => 'Support',
+'Analytics' => 'Analytics',
+'Inventory' => 'Inventory',
+'Tools' => 'Tools',
+'Settings' => 'Settings',
+'LBL_INFORMATION' => 'Information',
+'LBL_MORE' => 'More',
+'LBL_DEPLIST'=>'Piecelist and Dependencies',
+'LBL_BASIC' => 'Basic',
+'LBL_CREATING' => 'Creating',
+'LBL_DUPLICATING' => 'Duplicating',
+'LBL_EDITING' => 'Editing',
+'LBL_NEW' => 'New',
+'Lead' => 'Lead',
+'Account' => 'Account',
+'Contact' => 'Contact',
+'Opportunity' => 'Potential',
+'Product' => 'Product',
+'Activity' => 'Activity',
+'Event' => 'Event',
+'Task' => 'Task',
+'Quote' => 'Quote',
+'Ticket' => 'Ticket',
+'Campaign' => 'Campaign',
+'Note' => 'Note',
+'Dashboard' => 'Dashboards',
+'Report' => 'Report',
+'Vendor' => 'Vendor',
+'Webmail' => 'Webmail',
+'LBL_NONE_INCLUDED' => 'None Included',
+'LBL_ADD_TO' => 'Add to',
+'LBL_SELECT_TEMPLATE_TO_MAIL_MERGE' => 'Select template to Mail Merge:',
+'LBL_TITLE_OR_DESCRIPTION' => 'Title / Description',
+'LBL_RSS_FEEDS' => 'RSS Feeds',
+'LBL_ADD_RSS_FEEDS' => 'Add New RSS Feed',
+'LNK_NEW_FAQ' => 'New FAQ',
+'Vendor Name' => 'Vendor Name',
+'LNK_WEARE' => 'About Us',
+'LBL_ABOUTUS_TITLE' => 'vtiger CRM - About Us',
+'LBL_DISCUSS' => 'Discuss with other users',
+'Quote Stage' => 'Quote Stage',
+'Potential Name' => 'Potential Name',
+'Total' => 'Total Amount',
+'First Name' => 'First Name',
+'Last Name' => 'Last Name',
+'User Name' => 'User Name',
+'LBL_PORDER_BUTTON_TITLE' => 'New Purchase Order [Alt+O]',
+'LBL_PORDER_BUTTON' => 'New Purchase Order',
+'LBL_PORDER_BUTTON_KEY' => 'O',
+'Tracking Number' => 'Tracking Number',
+'Order Id' => 'Order Id',
+'Quote Name' => 'Quote Name',
+'Invoice Id' => 'Invoice Id',
+'Quote Id' => 'Quote Id',
+'Sales Order' => 'Sales Order',
+'COMBO_QUOTES' => 'Quotes',
+'End Date' => 'End Date',
+'End Date & Time' => 'End Date & Time',
+'Start Date' => 'Start Date',
+'Start Date & Time' => 'Start Date & Time',
+'Recurring Type' => 'Recurring Type',
+'SalesOrders' => 'Sales Order',
+'LBL_QUOTE_NAME' => 'Quote Name',
+'LBL_NEW_QUOTE_BUTTON_TITLE' => 'New Quote [Alt+Q]',
+'LBL_NEW_QUOTE_BUTTON_KEY' => 'Q',
+'LBL_NEW_QUOTE_BUTTON' => 'New Quote',
+'COMBO_PORDER' => 'Purchase Order',
+'COMBO_SORDER' => 'Sales Order',
+'LBL_PORDER_NAME' => 'Purchase Order',
+'LBL_SORDER_NAME' => 'Sales Order',
+'COMBO_INVOICES' => 'Invoice',
+'LBL_INVOICE_NAME' => 'Invoice',
+'LBL_HELPDESK_NAME' => 'Trouble Ticket',
+'LBL_CAMPAIGN_NAME' => 'Campaign Name',
+'LBL_NEW_INVOICE_BUTTON_TITLE' => 'New Invoice [Alt+I]',
+'LBL_NEW_INVOICE_BUTTON_KEY' => 'I',
+'LBL_NEW_INVOICE_BUTTON' => 'New Invoice',
+'LBL_NEW_SORDER_BUTTON_TITLE' => 'New Sales Order [Alt+E]',
+'LBL_NEW_SORDER_BUTTON_KEY' => 'E',
+'LBL_NEW_SORDER_BUTTON' => 'New Sales Order',
+'LBL_PRODUCT_DETAILS' => 'Product Details',
+'LBL_QTY_IN_STOCK' => 'Qty In Stock',
+'LBL_QTY' => 'Qty',
+'LBL_GRP'=>'Grp',
+'LBL_UNIT_PRICE' => 'Unit Price',
+'LBL_LIST_PRICE' => 'List Price',
+'LBL_TOTAL' => 'Total',
+'LBL_ADD_PRODUCT' => 'Add Product',
+'LBL_SUB_TOTAL' => 'Sub Total',
+'LBL_TAX' => 'Tax',
+'LBL_ADJUSTMENT' => 'Adjustment',
+'LBL_GRAND_TOTAL' => 'Grand Total',
+'LBL_QUOTE_ID' => 'Quote Id',
+'LBL_SALES_ORDER_ID' => 'Sales Order Id',
+'LBL_PURCHASE_ORDER_ID' => 'Purchase Order Id',
+'LBL_EXPORT_TO_PDF' => 'Export To PDF',
+'LBL_HOME_KEY_METRICS' => 'Key Metrics',
+'LBL_HOME_METRICS' => 'Metrics',
+'LBL_HOME_COUNT' => 'Count',
+'LBL_JSCALENDAR_LANG' => 'en',
+'LNK_CV_EDIT' => 'Edit',
+'LNK_CV_DELETE' => 'Delete',
+'LNK_CV_CREATEVIEW' => 'New',
+'LBL_UPD_FIELD_ORD' => 'Update Field Order',
+'LBL_SEND_CUSTOM_MAIL_BUTTON' => 'Send Custom Mail',
+'LBL_UPDATED_TODAY' => 'Updated today',
+'LBL_UPDATED' => 'Updated',
+'LBL_DAY_AGO' => 'day ago',
+'LBL_DAYS_AGO' => 'days ago',
+'Jan' => 'Jan',
+'Feb' => 'Feb',
+'Mar' => 'Mar',
+'Apr' => 'Apr',
+'May' => 'May',
+'Jun' => 'Jun',
+'Jul' => 'Jul',
+'Aug' => 'Aug',
+'Sep' => 'Sep',
+'Oct' => 'Oct',
+'Nov' => 'Nov',
+'Dec' => 'Dec',
+'Campaign Name' => 'Campaign Name',
+'Campaign Type' => 'Campaign Type',
+'Campaign Status' => 'Campaign Status',
+'Expected Revenue' => 'Expected Revenue',
+'Expected Close Date' => 'Expected Close Date',
+'LBL_ACTIONS' => 'Actions',
+'LBL_SEND' => 'Send',
+'LBL_VAT' => 'VAT',
+'LBL_SALES' => 'Sales',
+'LBL_SERVICE' => 'Service',
+'LBL_TAX_DETAILS' => 'Tax Details',
+'LBL_TAX_CALCULATION' => 'Tax Calculation',
+'LBL_TAX_NAME' => 'Tax Name',
+'LBL_TAX_VALUE' => 'Tax Value',
+'COVERED_PERCENTAGE' => '(%)',
+'LBL_TAG_CLOUD' => 'Tag Cloud',
+'LBL_FOR' => 'for',
+'LBL_PO_STATUS' => 'PurchaseOrder Status',
+'LBL_SO_STATUS' => 'SalesOrder Status',
+'LBL_INVOICE_STATUS' => 'Invoice Status',
+'LBL_NOTE' => 'Note',
+'LBL_MODULE' => 'Module',
+'Active' => 'Active',
+'Inactive' => 'Inactive',
+'Today' => 'Today',
+'Last 2 Days' => 'Last 2 Days',
+'Last Week' => 'Last Week',
+'This Week' => 'This Week',
+'This Month' => 'This Month',
+'This Year' => 'This Year',
+'LBL_PLEASE_CLICK' => 'Please Click',
+'LBL_TO_CONFIGURE' => 'to Configure',
+'LBL_HERE' => 'here',
+'LBL_RECORDS' => 'Records',
+'LBL_SCROLL' => '[Scroll to Top]',
+'LBL_EXPAND_COLLAPSE' => 'Expand/Collapse',
+'LBL_RCPY_ADDRESS' => 'Copy Shipping address',
+'LBL_LCPY_ADDRESS' => 'Copy Billing address',
+'LBL_RECORD_ID' => 'Record ID',
+'LBL_ACTION_DATE' => 'Action Date',
+'LBL_HOMEPAGE_DASHBOARD' => 'HomePage Dashboard',
+'LBL_NO' => 'No',
+'LBL_FOUND' => 'Found',
+'LBL_YOU_CAN_CREATE' => 'You can Create',
+'LBL_NOW' => 'now',
+'LBL_CLICK_THE_LINK' => 'Click the link below',
+'LBL_CREATE' => 'Create',
+'LBL_A' => 'a',
+'LBL_AN' => 'an',
+'LBL_YOU_ARE_NOT_ALLOWED_TO_CREATE' => 'You are not allowed to create',
+'LBL_TRANSFER_OWNERSHIP' => 'Transfer Ownership to',
+'LBL_SELECT_STATUS' => 'Select New Status',
+'LBL_UPDATE_OWNER' => 'Update Owner',
+'LBL_UPDATE_STATUS' => 'Update Status',
+'LBL_NET_PRICE' => 'Net Price',
+'LBL_TOOLS' => 'Tools',
+'LBL_DISCOUNT' => 'Discount',
+'LBL_TOTAL_AFTER_DISCOUNT' => 'Total After Discount',
+'LBL_NET_TOTAL' => 'Net Total',
+'LBL_SHIPPING_AND_HANDLING_CHARGES' => 'Shipping & Handling Charges',
+'LBL_TAX_FOR_SHIPPING_AND_HANDLING' => 'Taxes For Shipping and Handling',
+'LBL_FINISH' => 'Finish',
+'LBL_IMAGE_DELETED' => 'Image Deleted',
+'LBL_TAX_MODE' => 'Tax Mode',
+'LBL_CLEAR_COMMENT' => 'Clear Comment',
+'LBL_ZERO_DISCOUNT' => 'Zero Discount',
+'LBL_OF_PRICE' => 'of Price',
+'LBL_DIRECT_PRICE_REDUCTION' => 'Direct Price Reduction',
+'LBL_INDIVIDUAL' => 'individual',
+'LBL_CPY_MAILING_ADDRESS' => 'Copy Mailing Address',
+'LBL_CPY_OTHER_ADDRESS' => 'Copy Other Address',
+'LBL_PERMISSION' => 'You are not permitted to execute this Operation',
+'VTIGER' => 'vtiger',
+'LBL_DIRECT_AMOUNT_DISCOUNT' => 'Direct Amount Discount',
+'LBL_NO_DISCOUNT_FOR_THIS_PRODUCT' => 'No Discount for this Product',
+'LBL_TOTAL_TAX_AMOUNT' => 'Total Tax Amount',
+'LBL_FINAL_DISCOUNT_AMOUNT' => 'Final Discount Amount',
+'LBL_SHIPPING_AND_HANDLING_CHARGE' => 'Shipping & Handling Charge',
+'LBL_GO_BACK' => 'Go Back',
+'LBL_RECORD_DELETE' => 'The record you are trying to view has been deleted.',
+'Part Number' => 'Part Number',
+'Salutation' => 'Salutation ',
+'Rating' => 'Rating',
+'industry' => 'Industry',
+'Severity' => 'Severity',
+'Product Category' => 'Product Category',
+'GL Account' => 'GL Account',
+'Usage Unit' => 'Usage Unit',
+'Carrier' => 'Carrier',
+'Expected Response' => 'Expected Response',
+'LBL_ADDRESS_INF' => 'Address Information',
+'yes' => 'yes',
+'no' => 'no',
 'LBL_RENAMEPROFILE_BUTTON_LABEL'=>'Rename',
 'LBL_RENAME_PROFILE'=>'Rename Profile',
 'LBL_PROFILE_NAME'=>'Profile Name',
 'LBL_START_DATE'=>'Start Date',
+'LBL_START_DATE_TIME'=>'Start Date & Time',
 'LBL_END_DATE'=>'End Date',
-
+'LBL_END_DATE_TIME'=>'End Date & Time',
+'LBL_CREATE_MERGE_TEMPLATE'=>'Create Mail Merge templates ',
+'LBL_IMG_FORMATS'=>'(Only jpg, gif, bmp and png images)',
+
+//Added for Taxmode in detail view of Product Details.
+'group'=>'Group',
+'individual'=>'individual',
+
+//Added for values of picklist in Advanced Search filter
+'contains'=>'contains',
+'does not contains'=>'does not contains',
+'is'=>'is',
+'is not'=>'is not',
+'begins with'=>'begins with',
+'ends with'=>'ends with',
+'greater than'=>'greater than',
+'less than'=>'less than',
+'greater or equal'=>'greater or equal',
+'less or equal'=>'less or equal',
+
+//For Product Details
+'LABEL_SET_DISCOUNT_FOR_COLON'=>'Set Discount for :',
+'LABEL_SET_TAX_FOR'=>'Set Tax for',
+'LABEL_SET_DISCOUNT_FOR'=>'Set Discount for',
+'LABEL_SET_GROUP_TAX_FOR_COLON'=>'Set Group Tax for :',
+'LABEL_SET_DISCOUNT_FOR_X_COLON'=>'Set Discount for x :',
+'LABEL_SET_TAX_FOR_X'=>'Set Tax for x',
+'LABEL_SET_SH_TAX_FOR_COLON'=>'Set S&H Tax for :',
+
+'NO_DATA_AVAILABLE_WITH_SPECIFIED_PERIOD'=>'No data available with the specified time period',
+
+//Added for 5.0.3
+'Files_Maximum_6'=>'Files Maximum 6',
+'To'=>'To:',
+
+'Date & Time' => 'Date & Time',
+'Reminder' => '[Reminder:',
+'Visit_Link' => 'Kindly visit the link for more details on the activity',
+'Click here' => 'Click here',
+'Subject' => 'Subject',
+'Support_starting' => 'Support starting',
+'Congratulations' => 'Congratulations! Your support starts from today',
+'Hello_Support' => 'Hello! Support Starts for',
+'Suppport_Ending' => 'Support Ending',
+'kindly_renew' => 'ends shortly. Kindly renew your support please<br>Regards,<br>HelpDesk Team<br>',
+'Dear_Admin' => 'Dear Admin,<br> This is to bring to your notice that there are too many tickets pending. Kindly take the necessary action required for addressing the same<br><br> Thanks and Regards,<br> HelpDesk Team<br>',
+'Pending_Tickets' => 'Too many pending tickets',
+'Pending_Ticket_notification' => 'Pending Ticket notification',
+'Kind_Attention' => 'Dear Admin,<br> This is to bring to your kind attention that ticket number ',
+'Thank_You_HelpDesk' => ' is yet to be closed<br> Thank You,<br> HelpDesk Team<br>',
+'Big_Deal_Closed_Successfully' => 'Big Deal Closed Successfully',
+'Dear_Team_Time_to_Party' => 'Dear Team,<br>Congratulations!Time to Party! <br>We closed a deal worth more than 10000!!!!<br> Time to hit the dance floor!<br>',
+'Task_Not_completed' => 'Task Not completed',
+'Dear_Admin_tasks_not_been_completed' => 'Dear Admin,<br><br> Please note that there are certain tasks in the system which have not been completed even after 24hours of their existence<br> Thank You<br>HelpDesk Team<br>',
+'Too_many_pending_tickets' => 'Too many pending tickets',
+'Dear_Admin_too_ many_tickets_pending' => 'Dear Admin,<br> This is to bring to your notice that there are too many tickets pending. Kindly take the necessary action required for addressing the same<br><br> Thanks and Regards,<br> HelpDesk Team<br>',
+
+//Added for java script alerts
+'DELETE_CONFIRMATION' => 'Are you sure you want to delete the selected ',
+'SELECT_ATLEAST_ONE' => 'Please select at least one entity',
+'DELETING_ACCOUNT' => 'Deleting this account(s) will remove its related Potentials,Quotes,Sales Orders & Invoice. Are you sure you want to delete the selected ',
+'DELETING_VENDOR' => 'Deleting this vendor(s) will remove its related Purchase Orders. Are you sure you want to delete the selected ',
+'PLEASE_SELECT_MAILID' => 'Please Select a mailid',
+'OVERWRITE_EXISTING_ACCOUNT1' => 'Overwrite the existing address with this selected account(',
+'OVERWRITE_EXISTING_ACCOUNT2' => ') address details?',
+'MISSING_FIELDS' => 'Missing required fields:',
+'NOT_ALLOWED_TO_EDIT' => 'you are not allowed to edit this field',
+'COLUMNS_CANNOT_BE_EMPTY' => 'Selected Columns cannot be empty',
+'CANNOT_BE_EMPTY' => ' cannot be empty',
+'CANNOT_BE_NONE' => ' cannot be none',
+'SERVERNAME_CANNOT_BE_EMPTY' => 'Server Name cannot be empty',
+'ENTER_VALID' => 'Please enter a valid ',
+'SHOULDBE_LESS' => ' should be less than ',
+'SHOULDBE_LESS_EQUAL' => ' should be less than or equal to ',
+'SHOULDBE_EQUAL' => ' should be equal to ',
+'SHOULDBE_GREATER' => ' should be greater than ',
+'SHOULDBE_GREATER_EQUAL' => ' should be greater than or equal to ',
+'INVALID' => 'Invalid ',
+'EXCEEDS_MAX' => ' exceeds the maximum limit ',
+'OUT_OF_RANGE' => ' is out of range',
+'SHOULDNOTBE_EQUAL' => ' should not be equal to ',
+'PORTAL_PROVIDE_EMAILID' => 'Portal user should provide email Id for portal login',
+'ADD_CONFIRMATION' => 'Are you sure you want to add the selected ',
+'ACCOUNTNAME_CANNOT_EMPTY' => 'AccountName Cannot be Empty',
+'CANT_SELECT_CONTACTS' => "You can\'t select related contacts from Lead",
+'LBL_THIS' => 'This ',
+'DOESNOT_HAVE_MAILIDS' => " doesn\'t have any mail ids",
+'DOESNOT_HAVE_AN_MAILID' => '" '."doesn\'t have an Email Id",
+'ARE_YOU_SURE' => 'Are you sure?',
+'MISSING_REPORT_NAME' => 'Missing Report Name',
+'REPORT_NAME_EXISTS' => 'Report name already exists, try again...',
+'WANT_TO_CHANGE_CONTACT_ADDR' => 'Do you want to change the addresses of the Contacts related to this Account?',
+'SURE_TO_DELETE' => 'Are you sure you want to delete ?',
+'RECORDS' => ' records ?',
+'NO_PRODUCT_SELECTED' => 'No product is selected. Select at least one Product',
+'VALID_FINAL_PERCENT' => 'Enter valid Final Discount Percentage',
+'VALID_FINAL_AMOUNT' => 'Enter valid Final Discount Amount',
+'VALID_SHIPPING_CHARGE' => 'Enter a valid Shipping & Handling charge',
+'VALID_ADJUSTMENT' => 'Enter a valid Adjustment',
+'SELECTED_MORE_THAN_ONCE' => 'You have selected  the following product(s) more than once.',
+'WANT_TO_CONTINUE' => 'Do you want to Continue?',
+'ENTER_VALID_TAX' => 'Please enter Valid TAX value',
+'VALID_TAX_NAME' => 'Enter valid Tax Name',
+'CORRECT_TAX_VALUE' => 'Enter Correct Tax Value',
+'ENTER_POSITIVE_VALUE' => 'Please enter positive value',
+'LABEL_SHOULDNOT_EMPTY' => 'The tax label name should not be empty',
+'NOT_VALID_ENTRY' => 'is not a valid entry. Please enter correct value',
+'VALID_DISCOUNT_PERCENT' => 'Enter a valid Discount percentage',
+'VALID_DISCOUNT_AMOUNT' => 'Enter a valid Discount Amount',
+'SELECT_TEMPLATE_TO_MERGE' => 'Please select a template to merge',
+'MISSING_REQUIRED_FIELDS' => 'Missing required fields: ',
+'READONLY' => "it\'s readonly",
+'SELECT_ATLEAST_ONE_USER' => 'Please select at least one user',
+'DISABLE_SHARING_CONFIRMATION' => 'Are you sure you want to disable sharing for selected ',
+'USERS' => ' user(s) ?',
+'ENDTIME_GREATER_THAN_STARTTIME' => 'End Time should be greater than Start Time ',
+'FOLLOWUPTIME_GREATER_THAN_STARTTIME' => 'Followup Time should be greater than End Time ',
+'MISSING_EVENT_NAME' => 'Missing Event Name',
+'EVENT_TYPE_NOT_SELECTED' => 'Event Type is not selected',
+'OPPORTUNITYNAME_CANNOT_BE_EMPTY' => 'Opportunity Name field cannot be empty',
+'CLOSEDATE_CANNOT_BE_EMPTY' => 'Close Date field cannot be empty',
+'SITEURL_CANNOT_BE_EMPTY' => 'Site Url cannot be empty',
+'SITENAME_CANNOT_BE_EMPTY' => 'Site Name cannot be empty',
+'LISTPRICE_CANNOT_BE_EMPTY' => 'List Price cannot be empty',
+'INVALID_LIST_PRICE' => 'Invalid List Price',
+'PROBLEM_ACCESSSING_URL' => 'Problem accessing url: ',
+'CODE' => ' Code: ',
+'WISH_TO_QUALIFY_MAIL_AS_CONTACT' => 'Are you sure you wish to Qualify this Mail as Contact?',
+'SELECT_ATLEAST_ONEMSG_TO_DEL' => 'Please select at least one message to delete',
+'ERROR' => 'Error',
+'FIELD_TYPE_NOT_SELECTED' => 'Field Type is not selected',
+'SPECIAL_CHARACTERS_NOT_ALLOWED' => 'Special characters are not allowed in Label field',
+'PICKLIST_CANNOT_BE_EMPTY' => 'Picklist value cannot be empty',
+'DUPLICATE_VALUES_FOUND' => 'Duplicate Values found',
+'DUPLICATE_MAPPING_ACCOUNTS' => 'Duplicate mapping for accounts!!',
+'DUPLICATE_MAPPING_CONTACTS' => 'Duplicate mapping for Contacts!!',
+'DUPLICATE_MAPPING_POTENTIAL' => 'Duplicate mapping for Potential!!',
+'ERROR_WHILE_EDITING' => 'Error while Editing',
+'PLEASE_ENTER_TAG' => 'Please enter a tag',
+'PLEASE_SELECT_PRODUCT' => 'Please select a Product',
+'DUPLICATE_ENTRIES_FOUND' => "Duplicate entries found for the value \'",
+'ROLE_SHOULDHAVE_INFO' => 'Role should have at least one profile',
+'ENTER_VALID_CONVERSION_RATE' => 'Enter valid Conversion Rate',
+'GROUPNAME_CANNNOT_BE_NONE' => 'Group Name cannot be none',
+'GROUP_SHOULDHAVE_ONEMEMBER_INFO' => 'Group should have at least one member. Select a member to the group',
+'MAP_DELETED_INFO' => 'This map has been deleted. You cannot use this map again',
+'MUSTHAVE_ONE_REQUIREDFIELD' => 'Must have one Required field to be selected\n',
+'COLUMNS_CANNOT_BE_DUPLICATED' => 'Columns cannot be duplicated',
+'SPECIFY_ROLE_INFO' => 'Specfiy the Role to Transfer Existing Roles Users',
+'FOLDERNAME_CANNOT_BE_EMPTY' => 'The Folder name cannot be empty',
+'FOLDER_NAME_ALREADY_EXISTS' => 'Folder name already exists, try again...',
+'SELECT_ATLEAST_ONE_REPORT' => 'Please select at least one Report',
+'DELETE_FOLDER_CONFIRMATION' => "Are you sure you want to delete the folder  \'",
+'DELETE_REPORT_CONFIRMATION' => 'Are you sure you want to delete this report ?',
+'MOVE_REPORT_CONFIRMATION' => 'Are you sure you want to move this report to ',
+'FOLDER' => ' folder ?',
+'ACCOUNT_ACCESS_INFO' => 'Potentials, HelpDesk, Quotes, SalesOrder & Invoice Access must be set to Private when the Account Access is set to Private',
+'PROFILENAME_CANNOT_BE_EMPTY' => 'Profile Name Cannot be empty',
+'PROFILE_DETAILS_UPDATED' => 'Profile Details are updated',
+'CURRENCY_CHANGE_INFO' => 'Currency Changes has been made Successfully',
+'CURRENCY_CONVERSION_INFO' => 'Are you using Dollar $ as Currency? \n Click OK to remain as $, Cancel to change the currency conversion rate.',
+'THE_EMAILID' => "The email id \'",
+'EMAIL_FIELD_INVALID' => "\' in the email field is invalid",
+'SELECT_VALID_IMAGE' => 'Please Select a Valid Image',
+'EMAIL_FILED_IS' => "\' in the email field is ",
+'OTHER_EMAIL_FILED_IS' => "\' in other email field is ",
+'YAHOO_EMAIL_FILED_IS' => "\' in yahoo email field is ",
+'INVALID_ADD_IN_EMAILFIELD' => '\" not a valid email address in Email field',
+'INVALID_ADD_IN_OTHER_EMAILFIELD' => '\" not a valid email address in Other Email field',
+'ENTER_VALID_4DIGIT_YEAR' => 'Please enter a valid 4 digit year between ',
+'AND' => '  and ',
+'DATABASE_CHANGE_CONFIRMATION' => 'Are you sure to apply the Database Changes from ',
+'TO' => ' to ',
+'DELETE_RSSFEED_CONFIRMATION' => 'Are you sure to delete the rss feed?',
+'NOT_PERMITTED_TO_EXPORT' => 'you are not permitted to export!',
+
+//Added for 5.0.3
+'MSG_DEAR'=>'Dear',
+'MSG_REGARDING'=>'Regarding',
+'MSG_UPDATION'=>'updation -',
+'MSG_THE'=>'The',
+'MSG_HAS_BEEN_UPDATED'=>'has been updated',
+'MSG_ASSIGNMENT'=>'assignment -',
+'MSG_HAS_BEEN_ASSIGNED_TO_YOU'=>'has been assigned to you',
+'MSG_DETAILS_ARE'=>'details are',
+'MSG_ID'=>'Id :',
+'MSG_THANK_YOU'=>'Thank You',
+'MSG_HAS_BEEN_CREATED_FOR'=>'has been created for',
+'MSG_THANKS'=>'Thanks,',
+'MSG_VTIGERTEAM'=>' vTiger Team',
+'MSG_IS_NOT_UPLOADED'=>'is not uploaded. Allowed file types - jpeg, png, jpg, pjpeg, x-png or gif',
+'MSG_IMAGE_ERROR'=>'Image not found',
+
+'Information'=>'Information',
+'Address'=>'Address',
+'Custom Information'=>'Custom Information',
+'Portal Information'=>'- Portal Information',
+'Description'=>'Description',
+'Expectations'=>'Expectations',
+'Pricing Information'=>'Pricing Information',
+'Stock Information'=>'Stock Information',
+'Solution'=>'Solution',
+'Terms and Conditions'=>'Terms and Conditions',
+'LBL_SEARCHING'=>'Searching... please wait',
+'LBL_SKYPE'=>'Skype',
+'LBL_FIND'=>'Find',
+'LBL_CLEAR'=>'Clear',
+// Added for display the label of Invoice no
+'invoice no'=>'invoice no',
+//Added for title to the button Select Lead
+'LBL_SELECT_LEAD_BUTTON_LABEL' => 'Select Lead',
+//Added for the link Read License in footer
+'LNK_READ_LICENSE'=>'Read License',
+'ACTIVITIES' => 'Activities',
+'MAP_NAME_EXISTS'=>'This map name already exists. \n Do you want to overwrite it?',
 );
 
-
-
-//the left value is the key stored in the db and the right value is the display value
-
-//to translate, only modify the right value in each key/value pair
-
-$app_list_strings = Array(
-
-//e.g. auf Deutsch 'Contacts'=>'Contakten',
-
-'moduleList' => Array('Home'=>'Home'
-
-				, 'Dashboard'=>'Dashboard'
-
-				, 'Leads'=>'Leads'
-
-				, 'Contacts'=>'Contacts'
-
-				, 'Accounts'=>'Accounts'
-
-				, 'Potentials'=>'Potentials'
-
-				, 'Campaigns'=>'Campaigns'
-
-				, 'Notes'=>'Notes'
-
-				, 'Emails'=>'Emails'
-
-				, 'Activities'=>'Activities'
-
-				, 'Products'=>'Products'
-
-				, 'HelpDesk'=>'Trouble Tickets'
-
-				, 'Faq'=>'FAQ'
-
-				, 'Calendar'=>'Calendar'
-
-				, 'Quotes'=>'Quotes'
-		
-				, 'PurchaseOrder'=>'PurchaseOrder'
-
-				, 'Invoice'=>'Invoice'
-
-				, 'Rss'=>'RSS'
-				
-				, 'Reports'=>'Reports'
-				
-				, 'Vendors'=>'Vendors'
-				
-				, 'PriceBooks'=>'PriceBooks'
-
-				, 'SalesOrder'=>'SalesOrder'
-
-				, 'Portal'=>'My Sites'
-				
-				),
-
-
-
-//Note:  do not translate opportunity_relationship_type_default_key
-
-//       it is the key for the default opportunity_relationship_type_dom value
-
-'opportunity_relationship_type_default_key' => 'Primary Decision Maker',
-
-'opportunity_relationship_type_dom' => Array(''=>''
-
-		, 'Primary Decision Maker'=>'Primary Decision Maker'
-
-		, 'Business Decision Maker'=>'Business Decision Maker'
-
-		, 'Business Evaluator'=>'Business Evaluator'
-
-		, 'Technical Decision Maker'=>'Technical Decision Maker'
-
-		, 'Technical Evaluator'=>'Technical Evaluator'
-
-		, 'Executive Sponsor'=>'Executive Sponsor'
-
-		, 'Influencer'=>'Influencer'
-
-		, 'Other'=>'Other'
-
-		),
-
-
-
-//Note:  do not translate case_relationship_type_default_key
-
-//       it is the key for the default case_relationship_type_dom value
-
-'case_relationship_type_default_key' => 'Primary Contact',
-
-'case_relationship_type_dom' => Array(''=>''
-
-		, 'Primary Contact'=>'Primary Contact'
-
-		, 'Alternate Contact'=>'Alternate Contact'
-
-		),
-
-
-
-'task_priority_dom' => Array('High'=>'High'
-
-		, 'Medium'=>'Medium'
-
-		, 'Low'=>'Low'
-
-		),
-
-
-
-'task_status_dom' => Array('Planned'=>'Planned'
-
-		, 'Completed'=>'Completed'
-
-		, 'Deferred'=>'Deferred'
-
-		),
-
-
-
-'meeting_status_dom' => Array('Planned'=>'Planned'
-
-		, 'Held'=>'Held'
-
-		, 'Not Held'=>'Not Held'
-
-		),
-
-
-
-'call_status_dom' => Array('Planned'=>'Planned'
-
-		, 'Held'=>'Held'
-
-		, 'Not Held'=>'Not Held'
-
-		),
-
-
-
-//Note:  do not translate case_status_default_key
-
-//       it is the key for the default case_status_dom value
-
-'case_status_default_key' => 'New',
-
-'case_status_dom' => Array('New'=>'New'
-
-		, 'Assigned'=>'Assigned'
-
-		, 'Closed'=>'Closed'
-
-		, 'Pending Input'=>'Pending Input'
-
-		, 'Rejected'=>'Rejected'
-
-		),
-
-
-
-'user_status_dom' => Array('Active'=>'Active'
-
-		, 'Inactive'=>'Inactive'
-
-		),
-
-
-
-//Note:  do not translate record_type_default_key
-
-//       it is the key for the default record_type_module value
-
-'record_type_default_key' => 'Accounts',
-
-'record_type_display' => array('Accounts' => 'Account',
-
-		'Leads' => 'Lead',
-
-		'Opportunities' => 'Opportunity'),
-
-);
-
-
-
-?>
+$app_list_strings = array (
+  'moduleList' => 
+  array (
+    'Home' => 'Home',
+    'Dashboard' => 'Dashboard',
+    'Leads' => 'Leads',
+    'Contacts' => 'Contacts',
+    'Accounts' => 'Accounts',
+    'Potentials' => 'Potentials',
+    'Campaigns' => 'Campaigns',
+    'Notes' => 'Notes',
+    'Emails' => 'Emails',
+    'Activities' => 'Activities',
+    'Products' => 'Products',
+    'HelpDesk' => 'Trouble Tickets',
+    'Faq' => 'FAQ',
+    'Calendar' => 'Calendar',
+    'Quotes' => 'Quotes',
+    'PurchaseOrder' => 'PurchaseOrder',
+    'Invoice' => 'Invoice',
+    'Rss' => 'RSS',
+    'Reports' => 'Reports',
+    'Vendors' => 'Vendors',
+    'PriceBooks' => 'PriceBooks',
+    'SalesOrder' => 'SalesOrder',
+    'Portal' => 'My Sites',
+  ),
+  'opportunity_relationship_type_default_key' => 'Primary Decision Maker',
+  'opportunity_relationship_type_dom' => 
+  array (
+    '' => '',
+    'Primary Decision Maker' => 'Primary Decision Maker',
+    'Business Decision Maker' => 'Business Decision Maker',
+    'Business Evaluator' => 'Business Evaluator',
+    'Technical Decision Maker' => 'Technical Decision Maker',
+    'Technical Evaluator' => 'Technical Evaluator',
+    'Executive Sponsor' => 'Executive Sponsor',
+    'Influencer' => 'Influencer',
+    'Other' => 'Other',
+  ),
+  'case_relationship_type_default_key' => 'Primary Contact',
+  'case_relationship_type_dom' => 
+  array (
+    '' => '',
+    'Primary Contact' => 'Primary Contact',
+    'Alternate Contact' => 'Alternate Contact',
+  ),
+  'task_priority_dom' => 
+  array (
+    'High' => 'High',
+    'Medium' => 'Medium',
+    'Low' => 'Low',
+  ),
+  'task_status_dom' => 
+  array (
+    'Planned' => 'Planned',
+    'Completed' => 'Completed',
+    'Deferred' => 'Deferred',
+  ),
+  'meeting_status_dom' => 
+  array (
+    'Planned' => 'Planned',
+    'Held' => 'Held',
+    'Not Held' => 'Not Held',
+  ),
+  'call_status_dom' => 
+  array (
+    'Planned' => 'Planned',
+    'Held' => 'Held',
+    'Not Held' => 'Not Held',
+  ),
+  'case_status_default_key' => 'New',
+  'case_status_dom' => 
+  array (
+    'New' => 'New',
+    'Assigned' => 'Assigned',
+    'Closed' => 'Closed',
+    'Pending Input' => 'Pending Input',
+    'Rejected' => 'Rejected',
+  ),
+  'user_status_dom' => 
+  array (
+    'Active' => 'Active',
+    'Inactive' => 'Inactive',
+  ),
+  'record_type_default_key' => 'Accounts',
+  'record_type_display' => 
+  array (
+    'Accounts' => 'Account',
+    'Leads' => 'Lead',
+    'Opportunities' => 'Opportunity',
+  ),
+
+); ?>

Modified: vtigercrm/branches/5.1_jens/include/magpierss/rss_fetch.inc
==============================================================================
--- vtigercrm/branches/5.1_jens/include/magpierss/rss_fetch.inc (original)
+++ vtigercrm/branches/5.1_jens/include/magpierss/rss_fetch.inc Mon Apr 16 12:27:44 2007
@@ -355,7 +355,7 @@
     }
 
     if ( !defined('MAGPIE_OUTPUT_ENCODING') ) {
-        define('MAGPIE_OUTPUT_ENCODING', 'ISO-8859-1');
+        define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
     }
     
     if ( !defined('MAGPIE_INPUT_ENCODING') ) {

Modified: vtigercrm/branches/5.1_jens/include/nusoap/nusoap.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/nusoap/nusoap.php (original)
+++ vtigercrm/branches/5.1_jens/include/nusoap/nusoap.php Mon Apr 16 12:27:44 2007
@@ -130,8 +130,8 @@
 	* @var      string
 	* @access   public
 	*/
-    	//var $soap_defencoding = 'ISO-8859-1';
-	var $soap_defencoding = 'UTF-8';
+    	var $soap_defencoding = 'ISO-8859-1';
+	//var $soap_defencoding = 'UTF-8';
 
 	/**
 	* namespaces in an array of prefix => uri

Modified: vtigercrm/branches/5.1_jens/include/php_writeexcel/class.writeexcel_worksheet.inc.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/php_writeexcel/class.writeexcel_worksheet.inc.php (original)
+++ vtigercrm/branches/5.1_jens/include/php_writeexcel/class.writeexcel_worksheet.inc.php Mon Apr 16 12:27:44 2007
@@ -110,7 +110,7 @@
 
         $rowmax                   = 65536; // 16384 in Excel 5
         $colmax                   = 256;
-        $strmax                   = 255;
+        $strmax                   = 20000;
 
         $this->_name              = $name;
         $this->_index             = $index;

Modified: vtigercrm/branches/5.1_jens/include/style.css
==============================================================================
--- vtigercrm/branches/5.1_jens/include/style.css (original)
+++ vtigercrm/branches/5.1_jens/include/style.css Mon Apr 16 12:27:44 2007
@@ -1,60 +1,55 @@
+#positioningdiv {
+	left:5%;
+	right:5%;
+	width:600px;
+	position:absolute;
+	border:1px solid violet;
+}
+
 .small {
 	
         font-family: Arial, Helvetica, sans-serif;
         font-size: 11px;
         color:#000000;
-	
-	}
+	line-height:18px;
+}
 
-    .loginTopBg {
-        background:url(images/loginTopBg.gif) repeat-x;
-    }
+input {
+	border:1px solid #999999;
+}
 
-    .loginTopShade {
-        background:url(images/loginTopShade.gif) repeat-x;
-    }
+select {
+	border:1px solid #999999;
+}
 
-    .loginBg{
-        background:#818181 url(images/loginBg.gif) repeat-x;
-    }
+input[src] {
+	border:0px solid #999999;
+}
 
-    .textbox {
-        border:1px solid #999999;
-        background-color:#ffffff;
-        font-family: Arial, Helvetica, sans-serif;
-        font-size: 11px;
-        width:120px;
-        padding:2px;
 
-    }
-    .loginBottomBg {
-        background:url(images/loginBottomBg.gif) repeat-x;
-    }
-    .loginSignin {
-        font-family: Arial, Helvetica, sans-serif;
-        font-size: 18px;
-        color: #818181;
-        font-weight:bold;
-    }
+.bg {
+	background-image:url(images/topBg.gif);
+	background-repeat:repeat-x;
+	background-position:bottom;
+}
 
-    .loginBillBoard {
-        font-family: Arial, Helvetica, sans-serif;
-        font-size: 11px;
-        color:#ffffff;
-    }
-
-a {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	text-decoration:none;
-color:#333366;
+#loginTable {
+	border-left:1px solid #C0C0FF;
+	border-right:1px solid #C0C0FF;
+	border-bottom:1px solid #C0C0FF;
 
 }
 
-a:hover {
-	  font-family: Arial, Helvetica, sans-serif;
-	  font-size: 11px;
-	  text-decoration:underline;
-color:#333333;
+.z1 {
+	border-left:2px solid #c0c0ff;
+	border-bottom:2px solid #c0c0ff;
+}
+.z2 {
+	border-right:2px solid #c0c0ff;
+	border-bottom:2px solid #c0c0ff;
+}
 
-  }
+.signinHdr {
+	border-bottom:2px dotted #c0c0ff;
+	padding:5px;
+}

Modified: vtigercrm/branches/5.1_jens/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/CommonUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/CommonUtils.php Mon Apr 16 12:27:44 2007
@@ -329,6 +329,63 @@
 	return $tabid;
 
 }
+/**
+ * Function to get the CustomViewName
+ * Takes the input as $cvid - customviewid
+ * returns the cvname string fromat
+ */
+
+function getCVname($cvid)
+{
+        global $log;
+        $log->debug("Entering getCVname method ...");
+
+        global $adb;
+        $sql = "select viewname from vtiger_customview where cvid=".$cvid;
+        $result = $adb->query($sql);
+        $cvname =  $adb->query_result($result,0,"viewname");
+
+        $log->debug("Exiting getCVname method ...");
+        return $cvname;
+
+}
+
+
+
+/**
+ * Function to get the ownedby value for the specified module 
+ * Takes the input as $module - module name
+ * returns the tabid, integer type
+ */
+
+function getTabOwnedBy($module)
+{
+	global $log;
+	$log->debug("Entering getTabid(".$module.") method ...");
+
+	$tabid=getTabid($module);
+	
+	if (file_exists('tabdata.php') && (filesize('tabdata.php') != 0)) 
+	{
+		include('tabdata.php');
+		$tab_ownedby= $tab_ownedby_array[$tabid];
+	}
+	else
+	{	
+
+        	$log->info("module  is ".$module);
+        	global $adb;
+		$sql = "select ownedby from vtiger_tab where name='".$module."'";
+		$result = $adb->query($sql);
+		$tab_ownedby=  $adb->query_result($result,0,"ownedby");
+	}
+	$log->debug("Exiting getTabid method ...");
+	return $tab_ownedby;
+
+}
+
+
+
 
 /**
  * Function to get the tabid 
@@ -430,11 +487,15 @@
 	$log->info("in getContactName ".$contact_id);
 
         global $adb;
-        $sql = "select * from vtiger_contactdetails where contactid=".$contact_id;
-        $result = $adb->query($sql);
-        $firstname = $adb->query_result($result,0,"firstname");
-        $lastname = $adb->query_result($result,0,"lastname");
-        $contact_name = $lastname.' '.$firstname;
+	$contact_name = '';
+	if($contact_id != '')
+	{
+        	$sql = "select * from vtiger_contactdetails where contactid=".$contact_id;
+        	$result = $adb->query($sql);
+        	$firstname = $adb->query_result($result,0,"firstname");
+        	$lastname = $adb->query_result($result,0,"lastname");
+        	$contact_name = $lastname.' '.$firstname;
+	}
 	$log->debug("Exiting getContactName method ...");
         return $contact_name;
 }
@@ -638,6 +699,14 @@
         {
                $sql = "select vtiger_activitygrouprelation.groupname,vtiger_groups.groupid from vtiger_activitygrouprelation inner join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_activitygrouprelation.activityid=".$id;
 	}
+	else
+        {
+		$modObj = new $module();
+			
+               $sql = "select ".$modObj->groupTable[0].".groupname,vtiger_groups.groupid from ".$modObj->groupTable[0]." inner join vtiger_groups on vtiger_groups.groupname=".$modObj->groupTable[0].".groupname where ".$modObj->groupTable[0].".".$modObj->groupTable[1]."=".$id;
+	}
+	
+	
 	$result = $adb->query($sql);
         $group_info[] = $adb->query_result($result,0,"groupname");
         $group_info[] = $adb->query_result($result,0,"groupid");
@@ -1038,7 +1107,7 @@
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
 	if($disp_view == "detail_view")
 	{
-		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users")
+		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails")
   		{
  			$sql = "SELECT vtiger_field.* FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN $blockid_list AND vtiger_field.displaytype IN (1,2,4) ORDER BY block,sequence";
   		}
@@ -1057,7 +1126,7 @@
 	{
 		if ($info_type != '')
 		{
-			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2]== 0 || $module == 'Users')
+			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2]== 0 || $module == 'Users' || $module == "Emails")
   			{
  				$sql = "SELECT vtiger_field.* FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list ." AND ".$display_type_check." AND info_type = '".$info_type."' ORDER BY block,sequence";
   			}
@@ -1072,7 +1141,7 @@
 		}
 		else
 		{
-		if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == 'Users')
+			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == 'Users' || $module == "Emails")
   			{
  				$sql = "SELECT vtiger_field.* FROM vtiger_field WHERE vtiger_field.tabid=".$tabid." AND vtiger_field.block IN ".$blockid_list." AND ".$display_type_check." ORDER BY block,sequence";
   			}
@@ -1090,26 +1159,29 @@
 	}
 	$index_count =1;
 	$max_index =0;
-	foreach($getBlockInfo as $label=>$contents)
-	{
+	if(count($getBlockInfo) > 0)
+	{
+		foreach($getBlockInfo as $label=>$contents)
+		{
 			$no_rows = count($contents);	
 			$index_count = $max_index+1;
-		foreach($contents as $block_row => $elements)
-		{
-			$max_index= $no_rows+$index_count;
-			
-			for($i=0;$i<count($elements);$i++)
-			{	
-				if(sizeof($getBlockInfo[$label][$block_row][$i])!=0)
-				{
-					if($i==0)
-					$getBlockInfo[$label][$block_row][$i][]=array($index_count);
-					else
-					$getBlockInfo[$label][$block_row][$i][]=array($max_index);
+			foreach($contents as $block_row => $elements)
+			{
+				$max_index= $no_rows+$index_count;
+
+				for($i=0;$i<count($elements);$i++)
+				{	
+					if(sizeof($getBlockInfo[$label][$block_row][$i])!=0)
+					{
+						if($i==0)
+						$getBlockInfo[$label][$block_row][$i][]=array($index_count);
+						else
+						$getBlockInfo[$label][$block_row][$i][]=array($max_index);
+					}
 				}
+				$index_count++;
+
 			}
-			$index_count++;
-			
 		}
 	}
 	$log->debug("Exiting getBlocks method ...");
@@ -1255,6 +1327,7 @@
 			if(in_array($tabid,$childArr))
 			{
 				$parent_tabname= $parent_tab_info_array[$parid];
+				break;
 			}
 		}
 		$log->debug("Exiting getParentTabFromModule method ...");
@@ -1661,13 +1734,17 @@
         $num_rows=$adb->num_rows($result);
         $result_array=Array();
 	$seq_array=Array();
+	$ownedby_array=Array();
+	
         for($i=0;$i<$num_rows;$i++)
         {
                 $tabid=$adb->query_result($result,$i,'tabid');
                 $tabname=$adb->query_result($result,$i,'name');
 		$presence=$adb->query_result($result,$i,'presence');
+		$ownedby=$adb->query_result($result,$i,'ownedby');
                 $result_array[$tabname]=$tabid;
 		$seq_array[$tabid]=$presence;
+		$ownedby_array[$tabid]=$ownedby;
 
         }
 
@@ -1717,6 +1794,8 @@
                 $newbuf .= "\n";
                 $newbuf .= "\$tab_seq_array=".constructArray($seq_array).";\n";
 		$newbuf .= "\n";
+		$newbuf .= "\$tab_ownedby_array=".constructArray($ownedby_array).";\n";
+		$newbuf .= "\n";
                 $newbuf .= "\$action_id_array=".constructSingleStringKeyAndValueArray($actionid_array).";\n";
 		$newbuf .= "\n";
                 $newbuf .= "\$action_name_array=".constructSingleStringValueArray($actionname_array).";\n";
@@ -1841,20 +1920,6 @@
          global $mod_strings;
 
 
-	$new_label=Array('Leads'=>'LNK_NEW_LEAD',
-			 'Accounts'=>'LNK_NEW_ACCOUNT',
-			 'Calendar'=>'LNK_NEW_TASK',
-			 'Campaigns'=>'LNK_NEW_CAMPAIGN',
-			 'Emails'=>'LNK_NEW_EMAIL',
-			 'Events'=>'LNK_NEW_EVENT',
-			 'HelpDesk'=>'LNK_NEW_HDESK',
-			 'Notes'=>'LNK_NEW_NOTE',
-			 'Potentials'=>'LNK_NEW_OPPORTUNITY',
-			 'PriceBooks'=>'LNK_NEW_PRICEBOOK',
-			 'Products'=>'LNK_NEW_PRODUCT',
-			 'Contacts'=>'LNK_NEW_CONTACT',
-			 'Vendors'=>'LNK_NEW_VENDOR'); 	
-
 $qc_query = "select distinct vtiger_tab.tablabel,vtiger_tab.name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where quickcreate=0 order by vtiger_tab.tablabel";
 $result = $adb->query($qc_query);
 $noofrows = $adb->num_rows($result);
@@ -1864,7 +1929,7 @@
          $tablabel = $adb->query_result($result,$i,'tablabel');
 
          $tabname = $adb->query_result($result,$i,'name');
-	 $tablabel = $new_label[$tabname];
+	 $tablabel = "SINGLE_$tabname";
 	 if(isPermitted($tabname,'EditView','') == 'yes')
 	 {
          	$return_qcmodule[] = $tablabel;
@@ -1958,7 +2023,7 @@
 **/
 function sendNotificationToOwner($module,$focus)
 {
-	global $log;
+	global $log,$app_strings;
 	$log->debug("Entering sendNotificationToOwner(".$module.",".$focus.") method ...");
 	require_once("modules/Emails/mail.php");
 	global $current_user;
@@ -2003,47 +2068,91 @@
 			      		     );
 	}	
 	
-	$description = 'Dear '.$ownername.',<br><br>';
-
-	if($focus->mode == 'edit')
-	{
-		$subject = 'Regarding '.$mod_name.' updation - '.$objectname;
-		$description .= 'The '.$mod_name.' has been updated.';
+	if($module == "Accounts" || $module == "Potentials" || $module == "Contacts")
+	{
+		$description = $app_strings['MSG_DEAR'].' '.$ownername.',<br><br>';
+
+		if($focus->mode == 'edit')
+		{
+			$subject = $app_strings['MSG_REGARDING'].' '.$mod_name.' '.$app_strings['MSG_UPDATION'].' '.$objectname;
+			$description .= $app_strings['MSG_THE'].' '.$mod_name.' '.$app_strings['MSG_HAS_BEEN_UPDATED'].'.';
+		}
+		else
+		{
+			$subject = $app_strings['MSG_REGARDING'].' '.$mod_name.' '.$app_strings['MSG_ASSIGNMENT'].' '.$objectname;
+		        $description .= $app_strings['MSG_THE'].' '.$mod_name.' '.$app_strings['MSG_HAS_BEEN_ASSIGNED_TO_YOU'].'.';
+		}
+		$description .= '<br>'.$app_strings['MSG_THE'].' '.$mod_name.' '.$app_strings['MSG_DETAILS_ARE'].':<br><br>';
+                $description .= $mod_name.' '.$app_strings['MSG_ID'].' '.'<b>'.$focus->id.'</b><br>';
+		foreach($object_column_fields as $fieldname => $fieldlabel)
+		{
+			//Get the translated string
+			$temp_label = isset($app_strings[$fieldlabel])?$app_strings[$fieldlabel]:(isset($mod_strings[$fieldlabel])?$mod_strings[$fieldlabel]:$fieldlabel);
+
+			$description .= $temp_label.' : <b>'.$focus->column_fields[$fieldname].'</b><br>';
+		}
+
+		$description .= '<br><br>'.$app_strings['MSG_THANK_YOU'].'<br>';
+		$status = send_mail($module,$ownermailid,$current_user->user_name,'',$subject,$description);
+
+		$log->debug("Exiting sendNotificationToOwner method ...");
+		return $status;
+	}
+}
+
+//Function to send notification to the users of a group
+function sendNotificationToGroups($groupid,$crmid,$module)
+{
+       global $adb,$app_strings;
+       $returnEntity=Array();
+       $returnEntity=getEntityName($module,Array($crmid));
+       $mycrmid=$groupid;
+       require_once('include/utils/GetGroupUsers.php');
+       $getGroupObj=new GetGroupUsers();
+       $getGroupObj->getAllUsersInGroup($mycrmid);
+       $userIds=$getGroupObj->group_users;
+        $groupqry="select email1,id,user_name from vtiger_users where id in(".implode(',',$userIds).")";
+       $groupqry_res=$adb->query($groupqry);
+       for($z=0;$z < $adb->num_rows($groupqry_res);$z++)
+       {
+               //handle the mail send to vtiger_users
+               $emailadd = $adb->query_result($groupqry_res,$z,'email1');
+               $curr_userid = $adb->query_result($groupqry_res,$z,'id');
+               $tosender=$adb->query_result($groupqry_res,$z,'user_name');
+               $pmodule = 'Users';
+	       $description = $app_strings['MSG_DEAR']." ".$tosender.",<br>".$returnEntity[$crmid]." ".$app_strings['MSG_HAS_BEEN_CREATED_FOR']." ".$module."<br><br>".$app_strings['MSG_THANKS'].",<br>".$app_strings['MSG_VTIGERTEAM'];
+               require_once('modules/Emails/mail.php');
+               $mail_status = send_mail('Emails',$emailadd,$current_user->user_name,'','Record created-vTiger Team',$description,'','','all',$focus->id);
+               $all_to_emailids []= $emailadd;
+                $mail_status_str .= $emailadd."=".$mail_status."&&&";
+        }
+}
+
+
+function getUserslist()
+{
+	global $log,$current_user,$module,$adb,$assigned_user_id;
+	$log->debug("Entering getUserslist() method ...");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	
+	if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0))
+	{
+		$users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id,'private'), $current_user->id);
 	}
 	else
 	{
-		$subject = 'Regarding '.$mod_name.' assignment - '.$objectname;
-		$description .= 'The '.$mod_name.' has been assigned to you.';
-	}
-	$description .= '<br>The '.$mod_name.' details are:<br><br>';
-	$description .= $mod_name.' Id : '.$focus->id.'<br>';
-
-	foreach($object_column_fields as $fieldname => $fieldlabel)
-	{
-		//Get the translated string
-		$temp_label = isset($app_strings[$fieldlabel])?$app_strings[$fieldlabel]:(isset($mod_strings[$fieldlabel])?$mod_strings[$fieldlabel]:$fieldlabel);
-
-		$description .= $temp_label.' : <b>'.$focus->column_fields[$fieldname].'</b><br>';
-	}
-
-	$description .= '<br><br>Thank You <br>';
-	$status = send_mail($module,$ownermailid,$current_user->user_name,'',$subject,$description);
-
-	$log->debug("Exiting sendNotificationToOwner method ...");
-	return $status;
-}
-function getUserslist()
-{
-	global $log;
-	$log->debug("Entering getUserslist() method ...");
-	global $adb;
-	$result=$adb->query("select * from vtiger_users");
-	for($i=0;$i<$adb->num_rows($result);$i++)
-	{
-	       $useridlist[$i]=$adb->query_result($result,$i,'id');
-	       $usernamelist[$useridlist[$i]]=$adb->query_result($result,$i,'user_name');
-	}
-	$change_owner = get_select_options_with_id($usernamelist,'admin');
+		$users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id),$current_user->id);
+	}
+	foreach($users_combo as $userid=>$value)	
+	{
+
+		foreach($value as $username=>$selected)
+		{
+			$change_owner .= "<option value=$userid $selected>".$username."</option>";
+		}
+	}
+	
 	$log->debug("Exiting getUserslist method ...");
 	return $change_owner;
 }
@@ -2051,21 +2160,43 @@
 
 function getGroupslist()
 {
-	global $log;
+	global $log,$adb,$module,$current_user;
 	$log->debug("Entering getGroupslist() method ...");
-	global $adb;
-	$result=$adb->query("select * from vtiger_groups");
-	
-	for($i=0;$i<$adb->num_rows($result);$i++)
-	{
-	       $groupidlist[$i]=$adb->query_result($result,$i,'groupid');
-	       $groupnamelist[$groupidlist[$i]]=$adb->query_result($result,$i,'groupname');
-	       
-	}
-	$change_groups_owner = get_select_options_with_id($groupnamelist,'');
-	$log->debug("Exiting getGroupslist method ...");
-
-	return $change_groups_owner;
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0))
+	{
+		$result=get_current_user_access_groups($module);
+	}
+	else
+	{
+		$result = get_group_options();
+	}
+
+	$groupArray = $adb->fetch_array($result);
+	if(!empty($groupArray)){
+		do{
+			$groupname=$groupArray["groupname"];
+			$group_id=$groupArray["groupid"];
+			$selected = '';
+			if($groupname == $selected_groupname[0])
+			{
+				$selected = "selected";
+			}
+			if($groupname != '')
+				$group_option[$group_id] = array($groupname=>$selected);
+	          }while($groupArray = $adb->fetch_array($result));
+
+		foreach($group_option as $groupid=>$value)  
+		{ 
+			foreach($value as $groupname=>$selected) 
+			{
+				$change_groups_owner .= "<option value=$groupid $selected >".$groupname."</option>";  
+			}	 
+		}
+		$log->debug("Exiting getGroupslist method ...");
+		return $change_groups_owner;
+	}	
 }
 
 
@@ -2256,7 +2387,7 @@
 */
 function validateImageFile($file_details)
 {
-	global $adb, $log;
+	global $adb, $log,$app_strings;
 	$log->debug("Entering into validateImageFile($file_details) method.");
 	
 	$savefile = 'true';
@@ -2270,7 +2401,7 @@
 	else
 	{
 		$saveimage = 'false';
-		$_SESSION['image_type_error'] .= "<br> &nbsp;&nbsp;<b>$file_details[name]</b> is not uploaded. Allowed file types - jpeg, png, jpg, pjpeg, x-png or gif.";
+		$_SESSION['image_type_error'] .= "<br> &nbsp;&nbsp;<b>".$file_details[name]."</b>".$app_strings['MSG_IS_NOT_UPLOADED'];
 		$log->debug("Invalid Image type == $filetype");
 	}
 
@@ -2548,4 +2679,183 @@
 	}
 	
 }
+
+/**	Function used to get the translated string to the input string
+ *	@param string $str - input string which we want to translate
+ *	@return string $str - translated string, if the translated string is available then the translated string other wise original string will be returned
+ */
+function getTranslatedString($str)
+{
+	global $app_strings, $mod_strings, $log;
+	$str = ($app_strings[$str] != '')?$app_strings[$str]:(($mod_strings[$str] != '')?$mod_strings[$str]:$str);
+	$log->debug("function getTranslatedString($str) - translated to ($str)");
+	return $str;
+}
+
+/**	function used to get the list of importable fields
+ *	@param string $module - module name
+ *	@return array $fieldslist - array with list of fieldnames and the corresponding translated fieldlabels. The return array will be in the format of [fieldname]=>[fieldlabel] where as the fieldlabel will be translated
+ */
+function getImportFieldsList($module)
+{
+	global $adb, $log;
+	$log->debug("Entering into function getImportFieldsList($module)");
+	
+	$tabid = getTabid($module);
+
+	//Here we can add special cases for module basis, ie., if we want the fields of display type 3, we can add
+	$displaytype = " displaytype=1 ";
+
+	$fieldnames = "";
+	//For module basis we can add the list of fields for Import mapping
+	if($module == "Leads")
+	{
+		$fieldnames = " fieldname='salutationtype' ";
+	}
+
+	//Form the where condition based on tabid , displaytype and extra fields
+	$where = " WHERE tabid=$tabid and ( $displaytype ";
+	if($fieldnames != "")
+	{
+		$where .= " or $fieldnames ";
+	}
+	$where .= ")";
+
+	//Get the list of fields and form as array with [fieldname] => [fieldlabel]
+	$query = "SELECT fieldname, fieldlabel FROM vtiger_field $where";
+	$result = $adb->query($query);
+	for($i=0;$i<$adb->num_rows($result);$i++)
+	{
+		$fieldname = $adb->query_result($result,$i,'fieldname');
+		$fieldlabel = $adb->query_result($result,$i,'fieldlabel');
+		$fieldslist[$fieldname] = getTranslatedString($fieldlabel);
+	}
+
+	$log->debug("Exit from function getImportFieldsList($module)");
+
+	return $fieldslist;
+}
+/**     Function to get all the comments for a troubleticket
+  *     @param int $ticketid -- troubleticket id
+  *     return all the comments as a sequencial string which are related to this ticket
+**/
+function getTicketComments($ticketid)
+{
+        global $log;
+        $log->debug("Entering getTicketComments(".$ticketid.") method ...");
+        global $adb;
+
+        $commentlist = '';
+        $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
+        $result = $adb->query($sql);
+        for($i=0;$i<$adb->num_rows($result);$i++)
+        {
+                $comment = $adb->query_result($result,$i,'comments');
+                if($comment != '')
+                {
+                        $commentlist .= '<br><br>'.$comment;
+                }
+        }
+        if($commentlist != '')
+                $commentlist = '<br><br> The comments are : '.$commentlist;
+
+        $log->debug("Exiting getTicketComments method ...");
+        return $commentlist;
+}
+
+function getTicketDetails($id,$whole_date)
+{
+	 global $adb,$mod_strings;
+	 if($whole_date['mode'] == 'edit')
+	 {
+		$reply = $mod_strings["replied"];
+		$temp = "Re : ";
+	 }
+	 else	
+	 {
+		$reply = $mod_strings["created"];
+		$temp = " ";
+	 }
+	
+	 $desc = $mod_strings['Ticket ID'] .' : '.$id.'<br> Ticket Title : '. $temp .' '.$whole_date['sub'];
+	 $desc .= "<br><br>".$mod_strings['Hi']." ". $whole_date['parent_name'].",<br><br>".$mod_strings['LBL_PORTAL_BODY_MAILINFO']." ".$reply." ".$mod_strings['LBL_DETAIL']."<br>";
+	 $desc .= "<br>".$mod_strings['Status']." : ".$whole_date['status'];
+	 $desc .= "<br>".$mod_strings['Category']." : ".$whole_date['category'];
+	 $desc .= "<br>".$mod_strings['Severity']." : ".$whole_date['severity'];
+	 $desc .= "<br>".$mod_strings['Priority']." : ".$whole_date['priority'];
+	 $desc .= "<br><br>".$mod_strings['Description']." : <br>".$whole_date['description'];
+	 $desc .= "<br><br>".$mod_strings['Solution']." : <br>".$whole_date['solution'];
+	 $desc .= getTicketComments($id);
+
+	 $sql = "SELECT * FROM vtiger_ticketcf WHERE ticketid = \"".$id."\"";
+	 $result = $adb->query($sql);
+	 $cffields = $adb->getFieldsArray($result);
+	 foreach ($cffields as $cfOneField)
+	 {
+		 if ($cfOneField != 'ticketid')
+		 {
+			 $cfData = $adb->query_result($result,0,$cfOneField);
+			 $sql = "SELECT fieldlabel FROM vtiger_field WHERE columnname = \"$cfOneField\"";
+			 $cfLabel = $adb->query_result($adb->query($sql),0,'fieldlabel');
+			 $desc .= '<br><br>'.$cfLabel.' : <br>'.$cfData;
+		 }
+	 }
+	 // end of contribution
+	 $desc .= '<br><br><br>';
+	 $desc .= '<br>'.$mod_strings["LBL_REGARDS"].',<br>'.$mod_strings["LBL_TEAM"].'.<br>';
+	 return $desc;
+
+}
+
+function getPortalInfo_Ticket($id,$title,$contactname,$portal_url)
+{
+	global $mod_strings;
+	$bodydetails =$mod_strings['Dear']." ".$contactname.",<br><br>";
+        $bodydetails .= $mod_strings['reply'].' <b>'.$title.'</b>'.$mod_strings['customer_portal'];
+        $bodydetails .= $mod_strings["link"].'<br>';
+        $bodydetails .= $portal_url;
+        $bodydetails .= '<br><br>'.$mod_strings["Thanks"].'<br><br>'.$mod_strings["Support_team"];
+	return $bodydetails;
+}
+
+/**
+ * This function is used to get a random password.
+ * @return a random password with alpha numeric chanreters of length 8
+ */
+function makeRandomPassword()
+{
+	global $log;
+	$log->debug("Entering makeRandomPassword() method ...");
+	$salt = "abcdefghijklmnopqrstuvwxyz0123456789";
+	srand((double)microtime()*1000000);
+	$i = 0;
+	while ($i <= 7)
+	{
+		$num = rand() % 33;
+		$tmp = substr($salt, $num, 1);
+		$pass = $pass . $tmp;
+		$i++;
+	}
+	$log->debug("Exiting makeRandomPassword method ...");
+	return $pass;
+}
+
+//added to get mail info for portal user
+function getmail_contents_portalUser($request_array,$password)
+{
+	global $mod_strings;
+	$subject = $mod_strings['Customer Portal Login Details'];
+	$contents = $mod_strings['Dear']." ".$request_array['first_name']." ".$request_array['last_name'].",<br><br>";
+	$contents .= $mod_strings['Your Customer Portal Login details are given below:'];
+	$contents .= "<br><br>".$mod_strings['User Id :']." ".$request_array['email'];
+	$contents .= "<br>".$mod_strings['Password :']." ".$password;
+	$contents .= "<br><br>".$request_array['portal_url'];
+
+	$contents .= "<br><br><b>".$mod_strings['Note :']." </b>".$mod_strings['We suggest you to change your password after logging in first time'];
+	$contents .= "<br><br>".$mod_strings['Support Team'];
+	return $contents;
+
+}
+
+
 ?>

Modified: vtigercrm/branches/5.1_jens/include/utils/DeleteUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/DeleteUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/DeleteUtils.php Mon Apr 16 12:27:44 2007
@@ -27,20 +27,29 @@
 
 	switch($module):
 	case Leads:
-		if($return_module == "Campaigns") {
+		if($return_module == "Campaigns")
+		{
 			$sql = 'delete from vtiger_campaignleadrel where leadid='.$record.' and campaignid='.$return_id;
 			$adb->query($sql);
-		} else {
+		}
+		elseif($return_module == 'Products')//Delete Lead from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
+			$adb->query($sql);
+		}
+		else
+		{
 			$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 			$adb->query($sql);
 		}
 	break;
 	case Accounts:
-		if($return_id!='')
-		{
-			$sql ='delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
-			$adb->query($sql);
-		}
+		if($return_module == 'Products')//Delete Account from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
+			$adb->query($sql);
+		}
+		delAccRelRecords($record);
 	break;
 	case Campaigns:
 		if($return_module == "Leads") {
@@ -54,18 +63,33 @@
 	case Contacts:
 		if($return_module == 'Accounts')
 		{
-			$sql = 'update vtiger_contactdetails set accountid = "" where contactid = '.$record;
-			$adb->query($sql);
-		}
-		if($return_module == 'Potentials' && $record != '' && $return_id != '')
+			$sql = 'update vtiger_contactdetails set accountid = null where contactid = '.$record;
+			$adb->query($sql);
+		}
+		elseif($return_module == 'Potentials' && $record != '' && $return_id != '')
 		{
 			$sql = 'delete from vtiger_contpotentialrel where contactid='.$record.' and potentialid='.$return_id;
 			$adb->query($sql);
 		}
-		if($return_module == "Campaigns") {
+		elseif($return_module == "Campaigns") {
 			$sql = 'delete from vtiger_campaigncontrel where contactid='.$record.' and campaignid='.$return_id;
 			$adb->query($sql);
 		}
+		elseif($return_module == 'Products')//Delete Contact from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
+			$adb->query($sql);
+		}
+		elseif($return_module == 'Vendors')
+		{
+			$sql = "delete from vtiger_vendorcontactrel where vendorid=$return_id and contactid=$record";
+			$adb->query($sql);
+		}
+		else
+		{
+			$sql = "delete from vtiger_cntactivityrel where contactid=".$record;
+			$adb->query($sql);
+		}	
 		if($record != '' && $return_id != '')
 		{
 			$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
@@ -73,31 +97,36 @@
 			$sql_recentviewed ='delete from vtiger_tracker where user_id = '.$current_user->id.' and item_id = '.$record;
 			$adb->query($sql_recentviewed);
 		}
-		if($return_module == 'Products')
-		{
-			$sql = 'delete from vtiger_vendorcontactrel where contactid='.$record.' and vendorid='.$return_id;
-			$adb->query($sql);
-		}
-		if($return_module == 'Vendors')
-		{
-			$sql = "delete from vtiger_vendorcontactrel where vendorid=$return_id and contactid=$record";
-			$adb->query($sql);
-		}
-		if($return_module == 'Calendar')
-		{
-			$sql = "delete from vtiger_cntactivityrel where activityid=$return_id and contactid=$record";
-			$adb->query($sql);
-		}
 	break;
 	case Potentials:
-		if($return_module == 'Accounts' || $return_module == 'Campaigns')
+		if($return_module == 'Accounts')
 		{
 			//we can call $focus->mark_deleted($record)
 			$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$record;
 			$adb->query($sql);
-		}
-		$sql ='delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
-		$adb->query($sql);
+			$sql ='delete from vtiger_seactivityrel where crmid = '.$record;
+			$adb->query($sql);
+		}
+		elseif($return_module == 'Campaigns')
+		{
+			$sql = 'update vtiger_potential set campaignid = null where potentialid = '.$record;
+		        $adb->query($sql);	
+		}
+		elseif($return_module == 'Products')//Delete Potential from Product relatedlist
+		{
+			$sql = "delete from vtiger_seproductsrel where crmid=$record and productid=$return_id";
+			$adb->query($sql);
+		}
+		elseif($return_module == 'Contacts')
+		{
+			$sql = "delete from vtiger_contpotentialrel where potentialid=$record and contactid=$return_id";
+			$adb->query($sql);
+		}
+		else
+		{
+			$sql ='delete from vtiger_seactivityrel where crmid = '.$record;
+			$adb->query($sql);
+		}	
 	break;
 	case Calendar:
 		if($return_module == 'Contacts')
@@ -129,7 +158,7 @@
 	case HelpDesk:
 		if($return_module == 'Contacts' || $return_module == 'Accounts')
 		{
-			$sql = "update vtiger_troubletickets set parent_id='' where ticketid=".$record;
+			$sql = "update vtiger_troubletickets set parent_id=null where ticketid=".$record;
 			$adb->query($sql);
 			$se_sql= 'delete from vtiger_seticketsrel where ticketid='.$record;
 			$adb->query($se_sql);
@@ -137,7 +166,7 @@
 		}
 		if($return_module == 'Products')
 		{
-			$sql = "update vtiger_troubletickets set product_id='' where ticketid=".$record;
+			$sql = "update vtiger_troubletickets set product_id=null where ticketid=".$record;
 			$adb->query($sql);
 		}
 	break;
@@ -156,19 +185,13 @@
 			if($return_module == 'Calendar')
 				$sql = 'delete from vtiger_seactivityrel where crmid = '.$record.' and activityid = '.$return_id;
 
-			if($return_module == 'Potentials' || $return_module == 'Accounts' || $return_module == 'Leads')
+			if($return_module == 'Leads' || $return_module == 'Accounts' || $return_module == 'Contacts' || $return_module == 'Potentials')
 				$sql = 'delete from vtiger_seproductsrel where crmid = '.$return_id.' and productid = '.$record;
-
-			$adb->query($sql);
-		}
-		if($return_module == "Contacts")
-		{
-			$sql = "UPDATE vtiger_products set contactid = '' where productid = ".$record;
 			$adb->query($sql);
 		}
 		if($return_module == "Vendors")
 		{
-			$sql = "update vtiger_products set vendor_id = '' where productid = $record";
+			$sql = "update vtiger_products set vendor_id = null where productid = $record";
 			$adb->query($sql);
 		}
 	break;
@@ -218,17 +241,17 @@
 		}
 		elseif($return_module == "Quotes")
 		{
-			$relation_query = "UPDATE vtiger_salesorder set quoteid='' where salesorderid=".$record;
+			$relation_query = "UPDATE vtiger_salesorder set quoteid=null where salesorderid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Potentials")
 		{
-			$relation_query = "UPDATE vtiger_salesorder set potentialid='' where salesorderid=".$record;
+			$relation_query = "UPDATE vtiger_salesorder set potentialid=null where salesorderid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Contacts")
 		{
-			$relation_query = "UPDATE vtiger_salesorder set contactid='' where salesorderid=".$record;
+			$relation_query = "UPDATE vtiger_salesorder set contactid=null where salesorderid=".$record;
 			$adb->query($relation_query);
 		}
 		//Following condition is commented because in Product Relatedlist we have SO which should not be deleted.
@@ -264,12 +287,12 @@
 		}
 		elseif($return_module == "Potentials")
 		{
-			$relation_query = "UPDATE vtiger_quotes set potentialid='' where quoteid=".$record;
+			$relation_query = "UPDATE vtiger_quotes set potentialid=null where quoteid=".$record;
 			$adb->query($relation_query);
 		}
 		elseif($return_module == "Contacts")
 		{
-			$relation_query = "UPDATE vtiger_quotes set contactid='' where quoteid=".$record;
+			$relation_query = "UPDATE vtiger_quotes set contactid=null where quoteid=".$record;
 			$adb->query($relation_query);
 		}
 		//Following condition is commented because in Product Relatedlist we have Quotes which should not be deleted.
@@ -305,7 +328,7 @@
 		}
 		elseif($return_module=="SalesOrder")
 		{
-			$relation_query = "UPDATE vtiger_invoice set salesorderid='' where invoiceid=".$record;
+			$relation_query = "UPDATE vtiger_invoice set salesorderid=null where invoiceid=".$record;
 			$adb->query($relation_query);
 		}
 		//Following condition is commented because in Product Relatedlist we have Invoice which should not be deleted.
@@ -372,4 +395,81 @@
 	}
 	$log->debug("Entering DeleteEntity method ...");
 }
+
+function delAccRelRecords($record){
+
+	global $adb;
+
+	//Deleting Account related Potentials.
+	$pot_q = "select vtiger_crmentity.crmid from vtiger_crmentity inner join vtiger_potential on vtiger_crmentity.crmid=vtiger_potential.potentialid inner join vtiger_account on vtiger_account.accountid=vtiger_potential.accountid where vtiger_crmentity.deleted=0 and vtiger_potential.accountid=".$record;
+	$pot_res = $adb->query($pot_q);
+	for($k=0;$k < $adb->num_rows($pot_res);$k++)
+	{
+		$pot_id = $adb->query_result($pot_res,$k,"crmid");
+		$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$pot_id;
+		$adb->query($sql);
+	}
+	//Deleting Account related Sales Orders.
+	/*$so_q = "select vtiger_crmentity.crmid from vtiger_crmentity inner join vtiger_salesorder on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid inner join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid where vtiger_crmentity.deleted=0 and vtiger_salesorder.accountid=".$record;
+	$so_res = $adb->query($so_q);
+	for($k=0;$k < $adb->num_rows($so_res);$k++)
+	{
+		$so_id = $adb->query_result($so_res,$k,"crmid");
+		$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$so_id;
+		$adb->query($sql);
+	}*/
+	//Deleting Account related Quotes.
+	$quo_q = "select vtiger_crmentity.crmid from vtiger_crmentity inner join vtiger_quotes on vtiger_crmentity.crmid=vtiger_quotes.quoteid inner join vtiger_account on vtiger_account.accountid=vtiger_quotes.accountid where  vtiger_crmentity.deleted=0 and vtiger_quotes.accountid=".$record;
+	$quo_res = $adb->query($quo_q);
+	for($k=0;$k < $adb->num_rows($quo_res);$k++)
+	{
+		$quo_id = $adb->query_result($quo_res,$k,"crmid");
+		$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$quo_id;
+		$adb->query($sql);
+	}
+	//Deleting Account related Invoices.
+	/*$inv_q = "select vtiger_crmentity.crmid from vtiger_crmentity inner join vtiger_invoice on vtiger_crmentity.crmid=vtiger_invoice.invoiceid inner join vtiger_account on vtiger_account.accountid=vtiger_invoice.accountid where  vtiger_crmentity.deleted=0 and vtiger_invoice.accountid=".$record;
+	$inv_res = $adb->query($inv_q);
+	for($k=0;$k < $adb->num_rows($inv_res);$k++)
+	{
+		$inv_id = $adb->query_result($inv_res,$k,"crmid");
+		$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$inv_id;
+		$adb->query($sql);
+	}*/
+	//Deleting Contact-Account Relation.
+	$con_q = "update vtiger_contactdetails set accountid = null where accountid = ".$record;
+	$con_res = $adb->query($con_q);
+	$adb->query($con_q);
+
+	//Deleting Trouble Tickets-Account Relation.
+	$tt_q = "update vtiger_troubletickets set parent_id = null where parent_id = ".$record;
+	$adb->query($tt_q);
+
+	//Deleting Activity-Account Relation
+        $sql="delete from vtiger_seactivityrel where crmid=".$record;
+        $adb->query($sql);
+}
+
+function delVendorRelRecords($record){
+	
+	global $adb;
+
+	//Deleting Vendor related PO.
+	$po_q = "select vtiger_crmentity.crmid from vtiger_crmentity inner join vtiger_purchaseorder on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid inner join vtiger_vendor on vtiger_vendor.vendorid=vtiger_purchaseorder.vendorid where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.vendorid=".$record;
+	$po_res = $adb->query($po_q);
+	for($k=0;$k < $adb->num_rows($po_res);$k++)
+	{
+		$po_id = $adb->query_result($po_res,$k,"crmid");
+		$sql = 'update vtiger_crmentity set deleted = 1 where crmid = '.$po_id;
+		$adb->query($sql);
+	}
+
+	//Deleting Product-Vendor Relation.
+	$pro_q = "update vtiger_products set vendor_id = null where vendor_id = ".$record;
+	$adb->query($pro_q);
+	//Deleting Contact-Vendor Relaton
+	$vc_sql = "delete from vtiger_vendorcontactrel where vendorid=".$record;
+	$adb->query($vc_sql);
+}
+
 ?>

Modified: vtigercrm/branches/5.1_jens/include/utils/DetailViewUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/DetailViewUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/DetailViewUtils.php Mon Apr 16 12:27:44 2007
@@ -50,6 +50,7 @@
 	$label_fld = Array();
 	$data_fld = Array();
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
 	if($generatedtype == 2)
 		$mod_strings[$fieldlabel] = $fieldlabel;
 
@@ -99,7 +100,7 @@
 	     $label_fld[] = $mod_strings[$fieldlabel];
 	     $label_fld[] = $col_fields[$fieldname];
 	     
-		$pick_query="select * from vtiger_".$fieldname;
+		$pick_query="select * from vtiger_".$fieldname." order by sortorderid";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 
@@ -159,7 +160,7 @@
 	}
 	elseif($uitype == 19)
 	{
-		$col_fields[$fieldname]= make_clickable(str_replace("&lt;br /&gt;","<br>",nl2br($col_fields[$fieldname])));
+		$col_fields[$fieldname]= make_clickable(str_replace("&lt;br /&gt;","<br>",$col_fields[$fieldname]));
 		$label_fld[] = $mod_strings[$fieldlabel];
 		$label_fld[] = $col_fields[$fieldname];
 	}
@@ -187,6 +188,7 @@
 		$label_fld[] = $mod_strings[$fieldlabel];
 		$user_id = $col_fields[$fieldname];
 		$user_name = getUserName($user_id);
+		$assigned_user_id = $current_user->id;
 		if(is_admin($current_user))
 		{
 			$label_fld[] ='<a href="index.php?module=Users&action=DetailView&record='.$user_id.'">'.$user_name.'</a>';
@@ -195,6 +197,16 @@
 		{
 			$label_fld[] =$user_name;
 		}
+		if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0))
+		{
+			$users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id,'private'), $assigned_user_id);
+		}
+		else
+		{
+			$users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id);
+		}
+		$label_fld ["options"] = $users_combo;
+
 	}
 	elseif($uitype == 53)
 	{
@@ -222,7 +234,7 @@
 			$label_fld["secid"][] = $user_id;
 			$label_fld["link"][] = "index.php?module=Users&action=DetailView&record=".$user_id;
 			$label_fld["secid"][] = $groupid;
-			$label_fld["link"][] = "index.php?module=Users&action=GroupDetailView&groupId=".$groupid;
+			$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid;
 		}
 		//Security Checks
 		if($fieldlabel == 'Assigned To' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0))
@@ -338,7 +350,7 @@
 		}
 		else
 		{
-			$display_val = '';
+			$display_val = $app_strings['no'];
 		}
 		$label_fld[] = $display_val;
 	}
@@ -470,7 +482,7 @@
 			$image_name = $adb->query_result($image_res,0,'name');
 			$imgpath = $image_path.$image_id."_".$image_name;
 			if($image_name != '')
-				$label_fld[] ='<img src="'.$imgpath.'" class="reflect" width="450" height="300" alt="">';
+				$label_fld[] ='<img src="'.$imgpath.'" alt="'.$app_strings['MSG_IMAGE_ERROR'].'">';
 			else
 				$label_fld[] = '';
 		}
@@ -545,6 +557,11 @@
 				$invoicename= $adb->query_result($result,0,"subject");
 
 				$label_fld[] ='<a href="index.php?module='.$parent_module.'&action=DetailView&record='.$value.'">'.$invoicename.'</a>';
+			}
+			elseif($parent_module == "HelpDesk")
+			{
+				$label_fld[] = $mod_strings[$fieldlabel];
+				$label_fld[] = '';
 			}
 		}
 		else
@@ -957,7 +974,7 @@
 	{
 	 	$label_fld[] =$mod_strings[$fieldlabel];
 		if(is_admin($current_user))
-			$label_fld[] = '<a href="index.php?module=Users&action=RoleDetailView&roleid='.$col_fields[$fieldname].'">'.getRoleName($col_fields[$fieldname]).'</a>';
+			$label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid='.$col_fields[$fieldname].'">'.getRoleName($col_fields[$fieldname]).'</a>';
 		else
 			$label_fld[] = getRoleName($col_fields[$fieldname]);
 	}elseif($uitype == 85) //Added for Skype by Minnie
@@ -1010,6 +1027,7 @@
 	global $log;
 	$log->debug("Entering getDetailAssociatedProducts(".$module.",".$focus.") method ...");
 	global $adb;
+	global $mod_strings;
 	global $theme;
 	global $log;
 	global $app_strings,$current_user;
@@ -1036,7 +1054,7 @@
 	   <tr valign="top">
 	   	<td colspan="'.$colspan.'" class="dvInnerHeader"><b>'.$app_strings['LBL_PRODUCT_DETAILS'].'</b></td>
 		<td class="dvInnerHeader" align="right"><b>'.$app_strings['LBL_TAX_MODE'].' : </b></td>
-		<td class="dvInnerHeader">'.$taxtype.'</td>
+		<td class="dvInnerHeader">'.$app_strings[$taxtype].'</td>
 	   </tr>
 	   <tr valign="top">
 		<td width=40% class="lvtCol"><font color="red">*</font>
@@ -1228,10 +1246,11 @@
 	{
 		$finalDiscount = $focus->column_fields['hdnDiscountAmount'];
 		$finalDiscount = getConvertedPriceFromDollar($finalDiscount);
-		$final_discount_info = $app_strings['LBL_FINAL_DISCOUNT_AMOUNT']." = $finalDiscount";
-	}
-	if($final_discount_info != '')
-		$final_discount_info = 'onclick="alert(\''.$final_discount_info.'\');"';
+	}
+
+	//Alert the Final Discount amount even it is zero
+	$final_discount_info = $app_strings['LBL_FINAL_DISCOUNT_AMOUNT']." = $finalDiscount";
+	$final_discount_info = 'onclick="alert(\''.$final_discount_info.'\');"';
 
 	$output .= '<tr>'; 
 	$output .= '<td align="right" class="crmTableRow small lineOnTop">(-)&nbsp;<b><a href="javascript:;" '.$final_discount_info.'>'.$app_strings['LBL_DISCOUNT'].'</a></b></td>';
@@ -1331,7 +1350,7 @@
 	
 	$cur_tab_id = getTabid($module);
 
-	$sql1 = "select * from vtiger_relatedlists where tabid=".$cur_tab_id;
+	$sql1 = "select * from vtiger_relatedlists where tabid=".$cur_tab_id." order by sequence";
 	$result = $adb->query($sql1);
 	$num_row = $adb->num_rows($result);
 	for($i=0; $i<$num_row; $i++)
@@ -1356,6 +1375,74 @@
 		}
 	}
 	$log->debug("Exiting getRelatedLists method ...");
+	return $focus_list;
+}
+
+/** This function returns whether related lists is present for this particular module or not
+* Param $module - module name
+* Param $activity_mode - mode of activity 
+* Return type true or false
+*/
+
+
+function isPresentRelatedLists($module,$activity_mode='')
+{
+	global $adb;
+	$retval='true';
+	$tab_id=getTabid($module);
+	$query= "select count(*) as count from vtiger_relatedlists where tabid=".$tab_id;
+	$result=$adb->query($query);
+	$count=$adb->query_result($result,0,'count');
+	if($count < 1 || ($module =='Calendar' && $activity_mode=='task'))
+	{
+		$retval='false';	
+	}	
+	return $retval;	
+			
+	
+}	
+
+/** This function returns the depended vtiger_tab details for a given entity or a module.
+* Param $module - module name
+* Param $focus - module object
+* Return type is an array
+*/
+		
+function getDependendLists($module,$focus)
+{
+	global $log;
+	$log->debug("Entering getDependendLists(".$module.",".$focus.") method ...");
+	global $adb;
+	global $current_user;
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	
+	$cur_tab_id = getTabid($module);
+
+	$sql1 = "select * from vtiger_dependendlists where tabid=".$cur_tab_id." order by sequence";
+	$result = $adb->query($sql1);
+	$num_row = $adb->num_rows($result);
+	for($i=0; $i<$num_row; $i++)
+	{
+		$rel_tab_id = $adb->query_result($result,$i,"related_tabid");
+		$function_name = $adb->query_result($result,$i,"name");
+		$label = $adb->query_result($result,$i,"label");
+		if($rel_tab_id != 0)
+		{
+
+			if($profileTabsPermission[$rel_tab_id] == 0)
+			{
+		        	if($profileActionPermission[$rel_tab_id][3] == 0)
+        			{
+		                	$focus_list[$label] = $focus->$function_name($focus->id);
+        			}
+			}
+		}
+		else
+		{
+			$focus_list[$label] = $focus->$function_name($focus->id);
+		}
+	}
+	$log->debug("Exiting getDependendLists method ...");
 	return $focus_list;
 }
 

Modified: vtigercrm/branches/5.1_jens/include/utils/EditViewUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/EditViewUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/EditViewUtils.php Mon Apr 16 12:27:44 2007
@@ -37,14 +37,13 @@
 
 function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module_name,$mode='')
 {
-	global $log;
+	global $log,$app_strings;
 	$log->debug("Entering getOutputHtml(".$uitype.",". $fieldname.",". $fieldlabel.",". $maxlength.",". $col_fields.",".$generatedtype.",".$module_name.") method ...");
 	global $adb,$log;
 	global $theme;
 	global $mod_strings;
 	global $app_strings;
 	global $current_user;
-	global $noof_group_rows;
 
 	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
@@ -68,18 +67,23 @@
 		if($value=='')
 		{
 			//modified to fix the issue in trac(http://vtiger.fosslabs.com/cgi-bin/trac.cgi/ticket/1469)
-			if($fieldname != 'birthday' && $generatedtype != 2)// && $fieldname != 'due_date')//due date is today's date by default
+			if($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) !=14)// && $fieldname != 'due_date')//due date is today's date by default
 				$disp_value=getNewDisplayDate();
 
 			//Added to display the Contact - Support End Date as one year future instead of today's date -- 30-11-2005
 			if($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts')
 			{
 				$addyear = strtotime("+1 year");
-				global $current_user;
 				$dat_fmt = (($current_user->date_format == '')?('dd-mm-yyyy'):($current_user->date_format));
 
 				$disp_value = (($dat_fmt == 'dd-mm-yyyy')?(date('d-m-Y',$addyear)):(($dat_fmt == 'mm-dd-yyyy')?(date('m-d-Y',$addyear)):(($dat_fmt == 'yyyy-mm-dd')?(date('Y-m-d', $addyear)):(''))));
 			}
+
+			if($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes')
+                        {
+                                $disp_value = '';
+                        }
+
 		}
 		else
 		{
@@ -106,7 +110,7 @@
 			}
 			else
 			{
-				$endtime = time() + (60 * 60);
+				$endtime = time() + (5 * 60);
 				$curr_time = date('H:i',$endtime);
 			}
 		}
@@ -128,7 +132,8 @@
 	elseif($uitype == 15 || $uitype == 16 || $uitype == 111) //uitype 111 added for non editable picklist - ahmed
 	{
 		$editview_label[]=$mod_strings[$fieldlabel];
-		$pick_query="select * from vtiger_".$fieldname;
+		//Query modified to fix the order of the picklist values ticket #3006
+		$pick_query="select * from vtiger_".$fieldname." order by sortorderid";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
 
@@ -152,7 +157,7 @@
 		}
 		$fieldvalue [] = $options;
 	}
-	elseif($uitype == 17 || $uitype == 18)
+	elseif($uitype == 17)
 	{
 		$editview_label[]=$mod_strings[$fieldlabel];
 		$fieldvalue [] = $value;
@@ -220,7 +225,6 @@
 	elseif($uitype == 52 || $uitype == 77)
 	{
 		$editview_label[]=$mod_strings[$fieldlabel];
-		global $current_user;
 		if($value != '')
 		{
 			$assigned_user_id = $value;	
@@ -251,6 +255,7 @@
 	}
 	elseif($uitype == 53)     
 	{  
+		global $noof_group_rows;
 		$editview_label[]=$mod_strings[$fieldlabel];
 		//Security Checks
 		if($fieldlabel == 'Assigned To' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0))
@@ -263,37 +268,15 @@
 		}
 		$nameArray = $adb->fetch_array($result);
 
-
-		global $current_user;
 		if($value != '' && $value != 0)
-		{
 			$assigned_user_id = $value;
-			$user_checked = "checked";
-			$team_checked = '';
-			$user_style='display:block';
-			$team_style='display:none';			
-		}
-		else
-		{
-			if($value=='0')
-			{
+		else{
+			if($value=='0'){
 				$record = $col_fields["record_id"];
 				$module = $col_fields["record_module"];
-
 				$selected_groupname = getGroupName($record, $module);
-				$user_checked = '';
-				$team_checked = 'checked';
-				$user_style='display:none';
-				$team_style='display:block';
-			}
-			else	
-			{				
+			}else
 				$assigned_user_id = $current_user->id;
-				$user_checked = "checked";
-				$team_checked = '';
-				$user_style='display:block';
-				$team_style='display:none';
-			}	
 		}
 		
 		if($fieldlabel == 'Assigned To' && $is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0))
@@ -305,32 +288,8 @@
 			$users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
 		}
 
-
-		$GROUP_SELECT_OPTION = '<td width=30%><input type="radio"
-			name="assigntype" value="U" '.$user_checked.'
-			onclick="toggleAssignType(this.value)">'.$app_strings['LBL_USER'];
-
 		if($noof_group_rows!=0)
 		{
-
-			$log->debug("Has a Group, get the Radio button");
-			$GROUP_SELECT_OPTION .= '<input
-				type="radio" name="assigntype" value="T"'.$team_checked.'
-				onclick="toggleAssignType(this.value)">'.$app_strings['LBL_GROUP'];
-		}
-
-		$GROUP_SELECT_OPTION .='<br><span
-			id="assign_user" style="'.$user_style.'"><select name="assigned_user_id">';
-
-		$GROUP_SELECT_OPTION .= $users_combo;
-
-		$GROUP_SELECT_OPTION .= '</select></span>';
-
-		if($noof_group_rows!=0)
-		{
-			$log->debug("Has a Group, getting the group names ");
-			$GROUP_SELECT_OPTION .='<span id="assign_team" style="'.$team_style.'"><select name="assigned_group_name">';
-			
 			do
 			{
 				$groupname=$nameArray["groupname"];
@@ -366,7 +325,7 @@
 	}
 	elseif($uitype == 54)
 	{
-		$options =Array();
+		$options = array();
 		$editview_label[]=$mod_strings[$fieldlabel];
 		$pick_query="select * from vtiger_groups";
 		$pickListResult = $adb->query($pick_query);
@@ -391,7 +350,7 @@
 	elseif($uitype == 55)
 	{
 		$editview_label[]=$mod_strings[$fieldlabel];
-		$options = Array();
+		$options = array();
 		$pick_query="select * from vtiger_salutationtype order by sortorderid";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
@@ -436,7 +395,7 @@
 		$editview_label[]=$mod_strings[$fieldlabel];
 		if($value=='')
 			$value=1;
-		$options = Array();
+		$options = array();
 		$pick_query="select * from vtiger_duration_minutes order by sortorderid";
 		$pickListResult = $adb->query($pick_query);
 		$noofpickrows = $adb->num_rows($pickListResult);
@@ -530,7 +489,6 @@
 	
 	elseif($uitype == 61)
 	{
-		global $current_user;
 		if($value != '')
 		{
 			$assigned_user_id = $value;
@@ -698,13 +656,15 @@
 	elseif($uitype == 66)
 	{
 		if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '')
+		{
 			$value = $_REQUEST['parent_id'];
+			$parent_module = getSalesEntityType($value);
+		}	
 		// Check for vtiger_activity type if task orders to be added in select option
 		$act_mode = $_REQUEST['activity_mode'];
 
-		if($value != '')
-		{
-			$parent_module = getSalesEntityType($value);
+		if($parent_module != "Contacts")
+		{
 			if($parent_module == "Leads")
 			{
 				$sql = "select * from vtiger_leaddetails where leadid=".$value;
@@ -731,14 +691,14 @@
 				$potential_selected = "selected";
 
 			}
-			elseif($parent_module == "Quotes")
-			{
-				$sql = "select * from  vtiger_quotes where quoteid=".$value;
+			elseif($parent_module == "HelpDesk")
+			{
+				$sql = "select title from vtiger_troubletickets where ticketid=".$value;
 				$result = $adb->query($sql);
-				$parent_name = $adb->query_result($result,0,"subject");
-				$quote_selected = "selected";
-
-			}
+				$parent_name = $adb->query_result($result,0,"title");
+				$ticket_selected = "selected";
+			}
+
 			elseif($act_mode == "Task")
 			{
 				if($parent_module == "PurchaseOrder")
@@ -769,92 +729,80 @@
 					$parent_name = $adb->query_result($result,0,"campaignname");
 					$campaign_selected = "selected";
 				}
-				if($parent_module == "HelpDesk")
+				if($parent_module == "Quotes")
 				{
-					$sql = "select title from vtiger_troubletickets where ticketid=".$value;
+					$sql = "select * from  vtiger_quotes where quoteid=".$value;
 					$result = $adb->query($sql);
-					$parent_name = $adb->query_result($result,0,"title");
-					$ticket_selected = "selected";
+					$parent_name = $adb->query_result($result,0,"subject");
+					$quote_selected = "selected";
 				}
 			}
-			elseif($act_mode == "Events")
-			{
-				if($parent_module == "HelpDesk")
-				{
-					$sql = "select title from vtiger_troubletickets where ticketid=".$value;
-					$result = $adb->query($sql);
-					$parent_name = $adb->query_result($result,0,"title");
-					$ticket_selected = "selected";
-				}
-			}
-
-		}
+			$fieldvalue[] =$parent_name;
+			$fieldvalue[] = $value;
+		}
+		$editview_label[0] = array(
+			$app_strings['COMBO_LEADS'],
+			$app_strings['COMBO_ACCOUNTS'],
+			$app_strings['COMBO_POTENTIALS'],
+		);
+		$editview_label[1] = array(
+			$lead_selected,
+			$account_selected,
+			$potential_selected
+		);
+		$editview_label[2] = array(
+			"Leads&action=Popup",
+			"Accounts&action=Popup",
+			"Potentials&action=Popup"
+		);
+
 		if($act_mode == "Task")
                 {
-                        $editview_label[] = array($app_strings['COMBO_LEADS'],
-                                $app_strings['COMBO_ACCOUNTS'],
-                                $app_strings['COMBO_POTENTIALS'],
+                        array_push($editview_label[0],
                                 $app_strings['COMBO_QUOTES'],
                                 $app_strings['COMBO_PORDER'],
                                 $app_strings['COMBO_SORDER'],
                                 $app_strings['COMBO_INVOICES'],
 				$app_strings['COMBO_CAMPAIGNS'],
 				$app_strings['COMBO_HELPDESK']
-                                        );
-			$editview_label[] = array($lead_selected,
-                                $account_selected,
-                                $potential_selected,
+                        );
+			array_push($editview_label[1],
                                 $quote_selected,
                                 $purchase_selected,
                                 $sales_selected,
                                 $invoice_selected,
 				$campaign_selected,
 				$ticket_selected
-                                        );
-                        $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup","Quotes&action=Popup","PurchaseOrder&action=Popup","SalesOrder&action=Popup","Invoice&action=Popup","Campaigns&action=Popup","HelpDesk&action=Popup");
+                        );
+                        array_push($editview_label[2],"Quotes&action=Popup","PurchaseOrder&action=Popup","SalesOrder&action=Popup","Invoice&action=Popup","Campaigns&action=Popup","HelpDesk&action=Popup");
                 }
 		elseif($act_mode == "Events")
 		{
-			$editview_label[] = array($app_strings['COMBO_LEADS'],
-				$app_strings['COMBO_ACCOUNTS'],
-				$app_strings['COMBO_POTENTIALS'],
-				$app_strings['COMBO_HELPDESK']
-			);
-			$editview_label[] = array($lead_selected,
-				$account_selected,
-				$potential_selected,
-				$ticket_selected
-			);
-			$editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup","HelpDesk&action=Popup");
-		}
-                else
-                {
-                        $editview_label[] = array($app_strings['COMBO_LEADS'],
-                                $app_strings['COMBO_ACCOUNTS'],
-                                $app_strings['COMBO_POTENTIALS'],
-                                );
-                        $editview_label[] = array($lead_selected,
-                                $account_selected,
-                                $potential_selected
-                                );
-                        $editview_label[] = array("Leads&action=Popup","Accounts&action=Popup","Potentials&action=Popup");
-
-                }
-		$fieldvalue[] =$parent_name;
-		$fieldvalue[] = $value;
+			array_push($editview_label[0],$app_strings['COMBO_HELPDESK']);
+			array_push($editview_label[1],$ticket_selected);
+			array_push($editview_label[2],"HelpDesk&action=Popup");
+		}
 	}
 	//added by rdhital/Raju for better email support
 	elseif($uitype == 357)
 	{
-		$contact_selected = 'selected';
-		$account_selected = '';
-		$lead_selected = '';
+		if($_REQUEST['pmodule'] == 'Contacts')
+		{
+			$contact_selected = 'selected';
+		}
+		elseif($_REQUEST['pmodule'] == 'Accounts')
+		{
+			$account_selected = 'selected';
+		}
+		elseif($_REQUEST['pmodule'] == 'Leads')
+		{
+			$lead_selected = 'selected';
+		}
 		if(isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '')
 		{
 			$parent_id = $_REQUEST['emailids'];
 			$parent_name='';
 			$pmodule=$_REQUEST['pmodule'];
-
 			$myids=explode("|",$parent_id);
 			for ($i=0;$i<(count($myids)-1);$i++)
 			{
@@ -972,7 +920,7 @@
 				}
 			}
 		}
-		$custfld .= '<td width="20%" class="dataLabel">To:&nbsp;</td>';
+		$custfld .= '<td width="20%" class="dataLabel">'.$app_strings['To'].'&nbsp;</td>';
 		$custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="'.$parent_id.'"><textarea readonly name="parent_name" cols="70" rows="2">'.$parent_name.'</textarea>&nbsp;<select name="parent_type" >';
 		$custfld .= '<OPTION value="Contacts" selected>'.$app_strings['COMBO_CONTACTS'].'</OPTION>';
 		$custfld .= '<OPTION value="Accounts" >'.$app_strings['COMBO_ACCOUNTS'].'</OPTION>';
@@ -1014,6 +962,12 @@
 				$account_selected = "selected";
 
 			}
+			else
+			{
+				$parent_name = "";
+				$value = "";
+			}
+				
 		}
 		$editview_label[] = array($app_strings['COMBO_CONTACTS'],
                                         $app_strings['COMBO_ACCOUNTS']
@@ -1240,11 +1194,6 @@
 			$fieldvalue[] = $value;
 	}
 
-	// For inheritance
-	if ( in_array($uitype,array(3,4,18,31,32)) ) {
-	    $fieldvalue[] = $col_fields[$fieldname."@##@"];
-	}
-
 	// Mike Crowe Mod --------------------------------------------------------force numerics right justified.
 	if ( !eregi("id=",$custfld) )
 		$custfld = preg_replace("/<input/iS","<input id='$fieldname' ",$custfld);
@@ -1257,7 +1206,6 @@
 	$final_arr[]=$editview_label;
 	$final_arr[]=$editview_fldname;
 	$final_arr[]=$fieldvalue;
-	$final_arr[]=$inherit;
 	$log->debug("Exiting getOutputHtml method ...");
 	return $final_arr;
 }
@@ -1404,27 +1352,97 @@
 	
 	if($module == 'Quotes')
 	{
-		$query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no";
+		$query="SELECT 
+					vtiger_products.productname,
+ 		                        vtiger_products.productcode, 
+					vtiger_products.unit_price, 
+ 		                        vtiger_products.qtyinstock, 
+ 		                        vtiger_inventoryproductrel.listprice, 
+ 		                        vtiger_inventoryproductrel.description AS product_description, 
+ 		                        vtiger_inventoryproductrel.* 
+ 	                                FROM vtiger_inventoryproductrel 
+ 		                        INNER JOIN vtiger_products 
+ 		                                ON vtiger_products.productid=vtiger_inventoryproductrel.productid 
+ 		                        WHERE id=".$focus->id." 
+ 		                        ORDER BY sequence_no"; 
 	}
 	elseif($module == 'PurchaseOrder')
 	{
-		$query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no";
+		$query="SELECT 
+ 		                        vtiger_products.productname, 
+ 		                        vtiger_products.productcode, 
+ 		                        vtiger_products.unit_price, 
+ 		                        vtiger_products.qtyinstock, 
+ 		                        vtiger_inventoryproductrel.listprice, 
+ 		                        vtiger_inventoryproductrel.description AS product_description, 
+ 		                        vtiger_inventoryproductrel.* 
+ 		                        FROM vtiger_inventoryproductrel 
+ 		                        INNER JOIN vtiger_products 
+ 		                                ON vtiger_products.productid=vtiger_inventoryproductrel.productid 
+ 		                        WHERE id=".$focus->id." 
+ 		                        ORDER BY sequence_no";
 	}
 	elseif($module == 'SalesOrder')
 	{
-		$query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no";
+		$query="SELECT 
+ 		                        vtiger_products.productname, 
+ 		                        vtiger_products.productcode, 
+ 		                        vtiger_products.unit_price, 
+ 		                        vtiger_products.qtyinstock, 
+ 		                        vtiger_inventoryproductrel.listprice, 
+ 		                        vtiger_inventoryproductrel.description AS product_description, 
+ 		                        vtiger_inventoryproductrel.* 
+ 		                        FROM vtiger_inventoryproductrel 
+ 		                        INNER JOIN vtiger_products 
+ 		                                ON vtiger_products.productid=vtiger_inventoryproductrel.productid 
+ 		                        WHERE id=".$focus->id." 
+ 		                        ORDER BY sequence_no";
 	}
 	elseif($module == 'Invoice')
 	{
-		$query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price, vtiger_products.qtyinstock, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$focus->id." ORDER BY sequence_no";
+		$query="SELECT 
+ 		                        vtiger_products.productname, 
+ 		                        vtiger_products.productcode, 
+ 		                        vtiger_products.unit_price, 
+ 		                        vtiger_products.qtyinstock, 
+ 		                        vtiger_inventoryproductrel.listprice, 
+ 		                        vtiger_inventoryproductrel.description AS product_description, 
+ 		                        vtiger_inventoryproductrel.* 
+ 		                        FROM vtiger_inventoryproductrel 
+ 		                        INNER JOIN vtiger_products 
+ 		                                ON vtiger_products.productid=vtiger_inventoryproductrel.productid 
+ 		                        WHERE id=".$focus->id." 
+ 		                        ORDER BY sequence_no";
 	}
 	elseif($module == 'Potentials')
 	{
-		$query="select vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_seproductsrel.* from vtiger_products inner join vtiger_seproductsrel on vtiger_seproductsrel.productid=vtiger_products.productid where crmid=".$seid;
+		$query="SELECT 
+ 		                        vtiger_products.productname, 
+ 		                        vtiger_products.productcode, 
+ 		                        vtiger_products.product_description, 
+ 		                        vtiger_products.unit_price, 
+ 		                        vtiger_products.qtyinstock, 
+ 		                        vtiger_seproductsrel.* 
+ 		                        FROM vtiger_products 
+ 		                        INNER JOIN vtiger_seproductsrel 
+ 		                                ON vtiger_seproductsrel.productid=vtiger_products.productid 
+ 		                        WHERE crmid=".$seid;
 	}
 	elseif($module == 'Products')
 	{
-		$query="select vtiger_products.productid, vtiger_products.productname, vtiger_products.product_description, vtiger_products.unit_price,vtiger_products.qtyinstock,vtiger_crmentity.* from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid where vtiger_crmentity.deleted=0 and productid=".$seid;
+		$query="SELECT 
+ 		                        vtiger_products.productid, 
+ 		                        vtiger_products.productcode, 
+ 		                        vtiger_products.productname, 
+ 		                        vtiger_products.product_description, 
+ 		                        vtiger_products.unit_price, 
+ 		                        vtiger_products.qtyinstock, 
+ 		                        vtiger_crmentity.* 
+ 		                        FROM vtiger_products  
+ 		                        INNER JOIN vtiger_crmentity 
+ 		                                ON vtiger_crmentity.crmid=vtiger_products.productid 
+ 		                        WHERE vtiger_crmentity.deleted=0 
+ 		                                AND productid=".$seid;
 	}
 
 	$result = $adb->query($query);
@@ -1432,6 +1450,7 @@
 	for($i=1;$i<=$num_rows;$i++)
 	{
 		$hdnProductId = $adb->query_result($result,$i-1,'productid');
+		$hdnProductcode = $adb->query_result($result,$i-1,'productcode');
 		$productname=$adb->query_result($result,$i-1,'productname');
 		$productdescription=$adb->query_result($result,$i-1,'product_description');
 		$comment=$adb->query_result($result,$i-1,'comment');
@@ -1455,8 +1474,9 @@
 		}
 
 		$product_Detail[$i]['hdnProductId'.$i] = $hdnProductId;
-		$product_Detail[$i]['productName'.$i]= $productname;
-		$product_Detail[$i]['productDescription'.$i]= $productdescription;
+		$product_Detail[$i]['productName'.$i]= from_html($productname);
+		$product_Detail[$i]['hdnProductcode'.$i] = $hdnProductcode;
+		$product_Detail[$i]['productDescription'.$i]= from_html($productdescription);
 		$product_Detail[$i]['comment'.$i]= $comment;
 
 		if($module != 'PurchaseOrder' && $focus->object_name != 'Order')
@@ -1474,6 +1494,11 @@
 		$discount_amount=$adb->query_result($result,$i-1,'discount_amount');
 		$discountTotal = '0.00';
 		//Based on the discount percent or amount we will show the discount details
+
+		//To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(for Each Product)
+		$product_Detail[$i]['discount_percent'.$i] = 0;
+		$product_Detail[$i]['discount_amount'.$i] = 0;
+
 		if($discount_percent != 'NULL' && $discount_percent != '')
 		{
 			$product_Detail[$i]['discount_type'.$i] = "percentage";
@@ -1502,6 +1527,23 @@
 		$product_Detail[$i]['discountTotal'.$i] = $discountTotal;
 		$product_Detail[$i]['totalAfterDiscount'.$i] = $totalAfterDiscount;
 
+		$taxTotal = '0.00';
+		$product_Detail[$i]['taxTotal'.$i] = $taxTotal;
+
+		//Calculate netprice
+		$netPrice = $totalAfterDiscount+$taxTotal;
+		//if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
+		if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice')
+		{
+			$taxtype = getInventoryTaxType($module,$focus->id);
+			if($taxtype == 'individual')
+			{
+				//Add the tax with product total and assign to netprice
+				$netPrice = $netPrice+$taxTotal;
+			}
+		}
+		$product_Detail[$i]['netPrice'.$i] = $netPrice;
+
 		//First we will get all associated taxes as array
 		$tax_details = getTaxDetailsForProduct($hdnProductId,'all');
 		//Now retrieve the tax values from the current query with the name
@@ -1513,7 +1555,12 @@
 
 			//condition to avoid this function call when create new PO/SO/Quotes/Invoice from Product module
 			if($focus->id != '')
-				$tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
+			{
+				if($taxtype == 'individual')//if individual then show the entered tax percentage
+					$tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
+				else//if group tax then we have to show the default value when change to individual tax
+					$tax_value = $tax_details[$tax_count]['percentage'];
+			}
 			else//if the above function not called then assign the default associated value of the product
 				$tax_value = $tax_details[$tax_count]['percentage'];
 
@@ -1522,22 +1569,6 @@
 			$product_Detail[$i]['taxes'][$tax_count]['percentage'] = $tax_value;
 		}
 
-		$taxTotal = '0.00';
-		$product_Detail[$i]['taxTotal'.$i] = $taxTotal;
-
-		//Calculate netprice
-		$netPrice = $totalAfterDiscount+$taxTotal;
-		//if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
-		if($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice')
-		{
-			$taxtype = getInventoryTaxType($module,$focus->id);
-			if($taxtype == 'individual')
-			{
-				//Add the tax with product total and assign to netprice
-				$netPrice = $netPrice+$taxTotal;
-			}
-		}
-		$product_Detail[$i]['netPrice'.$i] = $netPrice;
 	}
 
 	//set the taxtype
@@ -1553,6 +1584,10 @@
 
 	$discountPercent = ($focus->column_fields['hdnDiscountPercent'] != '')?$focus->column_fields['hdnDiscountPercent']:'0.00';
 	$discountAmount = ($focus->column_fields['hdnDiscountAmount'] != '')?$focus->column_fields['hdnDiscountAmount']:'0.00';
+
+//To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(For Final Discount)
+		$product_Detail[1]['final_details']['discount_percentage_final'] = 0;
+		$product_Detail[1]['final_details']['discount_amount_final'] = 0;
 
 	if($focus->column_fields['hdnDiscountPercent'] != '')
 	{
@@ -1578,29 +1613,36 @@
 	$product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount;
 
 	//To set the Final Tax values
-	if($taxtype == 'group')
-	{
-		$taxtotal = '0.00';
-		//First we should get all available taxes and then retrieve the corresponding tax values
-		$tax_details = getAllTaxes('available');
-		//if taxtype is group then the tax will be same for all products in vtiger_inventoryproductrel table
-		for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
-		{
-			$tax_name = $tax_details[$tax_count]['taxname'];
-			$tax_label = $tax_details[$tax_count]['taxlabel'];
+	//we will get all taxes. if individual then show the product related taxes only else show all taxes
+	//suppose user want to change individual to group or vice versa in edit time the we have to show all taxes. so that here we will store all the taxes and based on need we will show the corresponding taxes
+	
+	$taxtotal = '0.00';
+	//First we should get all available taxes and then retrieve the corresponding tax values
+	$tax_details = getAllTaxes('available');
+
+	for($tax_count=0;$tax_count<count($tax_details);$tax_count++)
+	{
+		$tax_name = $tax_details[$tax_count]['taxname'];
+		$tax_label = $tax_details[$tax_count]['taxlabel'];
+
+		//if taxtype is individual and want to change to group during edit time then we have to show the all available taxes and their default values 
+		//Also taxtype is group and want to change to individual during edit time then we have to provide the asspciated taxes and their default tax values for individual products
+		if($taxtype == 'group')
 			$tax_percent = $adb->query_result($result,0,$tax_name);
-			if($tax_percent == '' || $tax_percent == 'NULL')
-				$tax_percent = '0.00';
-			$taxamount = ($subTotal-$finalDiscount)*$tax_percent/100;
-			$taxtotal = $taxtotal + $taxamount;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
-			$product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
-		}
-		$product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal;
-	}
-
+		else
+			$tax_percent = $tax_details[$tax_count]['percentage'];//$adb->query_result($result,0,$tax_name);
+		
+		if($tax_percent == '' || $tax_percent == 'NULL')
+			$tax_percent = '0.00';
+		$taxamount = ($subTotal-$finalDiscount)*$tax_percent/100;
+		$taxtotal = $taxtotal + $taxamount;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
+		$product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
+	}
+	$product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal;
+	
 	//To set the Shipping & Handling charge
 	$shCharge = ($focus->column_fields['hdnS_H_Amount'] != '')?$focus->column_fields['hdnS_H_Amount']:'0.00';
 	$shCharge = getConvertedPriceFromDollar($shCharge);
@@ -1795,7 +1837,6 @@
 * Return type array 
 */
 
-
 function split_validationdataArray($validationData)
 {
 	global $log;
@@ -1818,11 +1859,11 @@
 		{
 			if($fieldLabel == '')
 			{
-				$fieldLabel = "'".$fldLabel ."'";
+				$fieldLabel = "'".addslashes($fldLabel)."'";
 			}
 			else
 			{
-				$fieldLabel .= ",'".$fldLabel ."'";
+				$fieldLabel .= ",'".addslashes($fldLabel)."'";
 			}
 			if($fldDataType == '')
 			{
@@ -1842,104 +1883,4 @@
 }
 
 
-/** This function returns the detailed list of organization units associated to 
-*   the selected organization
-* Param $organization - organization object 
-*/
-
-function getOrgUnits($organization,$orgunitid="")
-{
-    // The array we're about to build
-    $orgunittab = array();
-    $fields = "orgunitid,type,name,address,city,state,country,code,phone,fax,website";
-    $fields .= ",logoname,quote_template,so_template,po_template,invoice_template";
-    global $adb;
-
-    // Parameter check
-    if( !isset( $organization) || $organization == '' ||
-	!isset( $organization->id) || $organization->id == '')
-	return $orgunittab;
-
-    // Database query
-    if( $orgunitid != "0")
-	$query = "SELECT vtiger_orgunit.orgunitid AS orgunitid,";
-    else
-	$query = "SELECT 0 AS orgunitid,";
-
-    // logoname is only defined in the organization record.
-    $query .= "'@##@' AS logoname, vtiger_organizationdetails.logoname AS org_logoname";
-
-    foreach( split( ',', $fields) as $field) {
-	if( $field != "orgunitid" && $field != "logoname") {
-	    if( $orgunitid != "0")
-		$query .= ",vtiger_orgunit.".$field." AS ".$field;
-	    else
-		$query .= ",NULL AS ".$field;
-	    if( $field != "type" && $field != "name")
-		$query .= ",vtiger_organizationdetails.".$field." AS org_".$field;
-	}
-    }
-
-    if( $orgunitid != "0" ) {
-	// database joins
-	$query .= " FROM vtiger_orgunit 
-			LEFT JOIN vtiger_organizationdetails
-			    ON vtiger_orgunit.organizationname=vtiger_organizationdetails.organizationname ";
-
-	// single or list query?
-	if( $orgunitid == "")
-	    $query .= "WHERE vtiger_orgunit.organizationname='".$organization->id."' ";
-	else
-	    $query .= "WHERE vtiger_orgunit.orgunitid=".$orgunitid." ";
-
-	// do not return deleted orgunits
-	$query .= "AND vtiger_orgunit.deleted=0";
-    }
-
-    else {
-	$query .= " FROM vtiger_organizationdetails ";
-	$query .= " WHERE vtiger_organizationdetails.organizationname='".$organization->id."' ";
-    }
-
-    // Do not return deleted organizations
-    $query .= " AND vtiger_organizationdetails.deleted=0";
-
-    $result = $adb->query( $query);
-    $noofrows = $adb->num_rows($result);
-
-    // Get all rows from database
-    for($j = 0; $j < $noofrows; $j++) {
-	$orgunit = array();
-	foreach( split( ',', $fields) as $field) {
-	    if( $orgunitid != "0") {
-		$orgunit[$field] = $adb->query_result($result,$j,$field);
-
-		// Inherited and extended fields
-		if( substr( $orgunit[$field], 0, 4) == "@##@") {
-		    if( $field == "name") {
-			$orgunit[$field] = substr($orgunit[$field], 4, strlen( $orgunit[$field])-4);
-			if( $orgunitid != "") 
-			    $orgunit[$field] = $organization->id." ".$orgunit[$field];
-		    } else {
-			$orgunit[$field] = $adb->query_result($result,$j,"org_".$field);
-		    }
-		}
-	    }
-
-	    // no orgunit selected
-	    else {
-		if( $field == "name") 
-		    $orgunit[$field] = $organization->id;
-		elseif( $field == "orgunitid")
-		    $orgunit[$field] = 0;
-		else
-		    $orgunit[$field] = $adb->query_result($result,$j,"org_".$field);
-	    }
-	}
-	$id = $orgunit["orgunitid"];
-	$orgunittab[$id] = $orgunit;
-    }
-    // Return what we've found
-    return $orgunittab;
-}
 ?>

Modified: vtigercrm/branches/5.1_jens/include/utils/ExportUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/ExportUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/ExportUtils.php Mon Apr 16 12:27:44 2007
@@ -87,33 +87,33 @@
 	for($i=0; $i < $num_rows;$i++)
 	{
 		$columnName = $adb->query_result($result,$i,"columnname");
-		$fieldlable = $adb->query_result($result,$i,"fieldlabel");
+		$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
 		$tablename = $adb->query_result($result,$i,"tablename");
 
 		//HANDLE HERE - Mismatch fieldname-tablename in field table, in future we have to avoid these if elses
 		if($columnName == 'smownerid')//for all assigned to user name
 		{
-			$fields .= "vtiger_users.user_name as '".$fieldlable."', ";
+			$fields .= "vtiger_users.user_name as '".$fieldlabel."',";
 		}
 		elseif($tablename == 'vtiger_account' && $columnName == 'parentid')//Account - Member Of
 		{
-			 $fields .= "vtiger_account2.accountname as '".$fieldlable."', ";
+			 $fields .= "vtiger_account2.accountname as '".$fieldlabel."',";
 		}
 		elseif($tablename == 'vtiger_contactdetails' && $columnName == 'accountid')//Contact - Account Name
 		{
-			$fields .= "vtiger_account.accountname as '".$fieldlable."', ";
+			$fields .= "vtiger_account.accountname as '".$fieldlabel."',";
 		}
 		elseif($tablename == 'vtiger_contactdetails' && $columnName == 'reportsto')//Contact - Reports To
 		{
-			$fields .= " concat(vtiger_contactdetails2.lastname,' ',vtiger_contactdetails2.firstname) as 'Reports To Contact', ";
+			$fields .= " concat(vtiger_contactdetails2.lastname,' ',vtiger_contactdetails2.firstname) as 'Reports To Contact',";
 		}
 		elseif($tablename == 'vtiger_potential' && $columnName == 'accountid')//Potential - Account Name
 		{
-			$fields .= "vtiger_account.accountname as '".$fieldlable."',";
+			$fields .= "vtiger_account.accountname as '".$fieldlabel."',";
 		}
 		elseif($tablename == 'vtiger_potential' && $columnName == 'campaignid')//Potential - Campaign Source
 		{
-			$fields .= "vtiger_campaign.campaignname as '".$fieldlable."',";
+			$fields .= "vtiger_campaign.campaignname as '".$fieldlabel."',";
 		}
 		elseif($tablename == 'vtiger_seproductsrel' && $columnName == 'crmid')//Product - Related To
 		{
@@ -131,7 +131,7 @@
 		}
 		elseif($tablename == 'vtiger_products' && $columnName == 'vendor_id')//Product - Vendor Name
 		{
-			$fields .= "vtiger_vendor.vendorname as '".$fieldlable."',";
+			$fields .= "vtiger_vendor.vendorname as '".$fieldlabel."',";
 		}
 		elseif($tablename == 'vtiger_producttaxrel' && $columnName == 'taxclass')//avoid product - taxclass
 		{
@@ -155,11 +155,11 @@
 		}
 		elseif($tablename == 'vtiger_attachments' && $columnName == 'filename')//Emails filename
 		{
-			$fields .= $tablename.".name '".$fieldlable."',";
+			$fields .= $tablename.".name as '".$fieldlabel."',";
 		}
 		else
 		{
-			$fields .= $tablename.".".$columnName. " '" .$fieldlable."',";
+			$fields .= $tablename.".".$columnName. " as '" .$fieldlabel."',";
 		}
 	}
 	$fields = trim($fields,",");

Modified: vtigercrm/branches/5.1_jens/include/utils/GraphUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/GraphUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/GraphUtils.php Mon Apr 16 12:27:44 2007
@@ -101,7 +101,7 @@
 
 function get_tickspacing($max = 10)
 {
-	global $log;
+	global $log,$app_strings;
 	$log->debug("Entering get_tickspacing(".$max.") method ...");
 	$result = array(1,1);
 	
@@ -110,7 +110,7 @@
 	if($coef == 0)
 	{
 		$data=0;
-		echo "<h3> No data available with the specified time period</h3>";
+		echo "<h3>".$app_strings['NO_DATA_AVAILABLE_WITH_SPECIFIED_PERIOD']."</h3>";
 		$log->debug("Exiting get_tickspacing method ...");
 		return $data;
 	}

Modified: vtigercrm/branches/5.1_jens/include/utils/InventoryUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/InventoryUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/InventoryUtils.php Mon Apr 16 12:27:44 2007
@@ -496,17 +496,24 @@
 	$prod_seq=1;
 	for($i=1; $i<=$tot_no_prod; $i++)
 	{
+		//if the product is deleted then we should avoid saving the deleted products
+		if($_REQUEST["deleted".$i] == 1)
+			continue;
+
 	        $prod_id = $_REQUEST['hdnProductId'.$i];
+		if(isset($_REQUEST['productDescription'.$i]))
+			$description = $_REQUEST['productDescription'.$i];
+		else{
+			$desc_duery = "select vtiger_products.product_description from vtiger_products where vtiger_products.productid=".$prod_id;
+			$desc_res = $adb->query($desc_duery);
+			$description = $adb->query_result($desc_res,0,"product_description");
+		}	
 	        $qty = $_REQUEST['qty'.$i];
 	        $listprice = $_REQUEST['listPrice'.$i];
 		$listprice = getConvertedPrice($listprice);//convert the listPrice into $
 
 		$comment = addslashes($_REQUEST['comment'.$i]);
 
-		//if the product is deleted then we should avoid saving the deleted products
-		if($_REQUEST["deleted".$i] == 1)
-			continue;
-
 		//we have to update the Product stock for PurchaseOrder if $update_prod_stock is true
 		if($module == 'PurchaseOrder' && $update_prod_stock == 'true')
 		{
@@ -524,7 +531,7 @@
 			}
 		}
 
-		$query ="insert into vtiger_inventoryproductrel(id, productid, sequence_no, quantity, listprice, comment) values($focus->id, $prod_id , $prod_seq, $qty, $listprice, '$comment')";
+		$query ="insert into vtiger_inventoryproductrel(id, productid, sequence_no, quantity, listprice, comment, description) values($focus->id, $prod_id , $prod_seq, $qty, $listprice, '$comment','$description')";
 		$prod_seq++;
 		$adb->query($query);
 
@@ -709,4 +716,88 @@
 }
 
 
+/**	function used to set invoice string and increment invoice id 
+ *	@param string $mode - mode should be configure_invoiceno or increment_incoiceno
+ *	@param string $req_str - invoice string which is part of the invoice number, this may be alphanumeric characters
+ *	@param int $req_no - This should be a number which will written in file and will be used as a next invoice number
+ *	@return void. The invoice string and number are stored in the  file CustomInvoiceNo.php so that concatenated string 		with number will be used as a next invoice number
+ */
+
+function setInventoryInvoiceNumber($mode, $req_str='', $req_no='')
+{
+        global $root_directory;
+        $filename = $root_directory.'user_privileges/CustomInvoiceNo.php';
+        $readhandle = fopen($filename, "r+");
+        $buffer = '';
+        $new_buffer = '';
+
+	//when we configure the invoice number in Settings this will be used
+	if ($mode == "configure_invoiceno" && $req_str != '' && $req_no != '')
+	{
+
+ 	        while(!feof($readhandle))
+               	{
+                       	$buffer = fgets($readhandle, 5200);
+			list($starter, $tmp) = explode(" = ", $buffer);
+
+			if($starter == '$inv_str')
+			{
+				$new_buffer .= "\$inv_str = '".$req_str."';\n";
+			}
+			elseif($starter == '$inv_no')
+			{
+				$new_buffer .= "\$inv_no = '".$req_no."';\n";
+			}
+			else
+				$new_buffer .= $buffer;
+		}
+	}
+	else if ($mode == "increment_invoiceno")//when we save new invoice we will increment the invoice id and write
+	{
+		require_once('user_privileges/CustomInvoiceNo.php');
+		while(!feof($readhandle))
+		{
+			$buffer = fgets($readhandle, 5200);
+			list($starter, $tmp) = explode(" = ", $buffer);
+
+			if($starter == '$inv_no')
+			{
+				//if number is 001, 002 like this (starting with zero) then when we increment 1, zeros will be striped out and result comes as 1,2, etc. So we have added 0 previously for the needed length ie., two zeros for 001, 002, etc.,
+				//If the value is less than 0, then we assign 0 to it(to avoid error).
+				$strip=strlen($inv_no)-strlen($inv_no+1);
+				if($strip<0)$strip=0;
+
+				$temp = str_repeat("0",$strip);
+				$new_buffer .= "\$inv_no = '".$temp.($inv_no+1)."';\n";
+			}
+			else
+				$new_buffer .= $buffer;
+
+		}
+	}
+
+	//we have the contents in buffer. Going to write the contents in file
+	fclose($readhandle);
+	$handle = fopen($filename, "w");
+	fputs($handle, $new_buffer);
+	fclose($handle);
+}
+
+/**	Function used to check whether the provided invoicenumber is already available or not
+ *	@param int $invoiceno - invoice number, which we are going to check for duplicate
+ *	@return binary true or false. If invoice number is already available then return true else return false
+ */
+function CheckDuplicateInvoiceNumber($invoiceno)
+{
+	global $adb;
+	$result=$adb->query("select invoice_no  from vtiger_invoice where invoice_no = '".$invoiceno."'");
+	$num_rows = $adb->num_rows($result);
+
+	if($num_rows > 0)
+		return true;
+	else
+		return false;
+}
+
+
 ?>

Modified: vtigercrm/branches/5.1_jens/include/utils/ListViewUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/ListViewUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/ListViewUtils.php Mon Apr 16 12:27:44 2007
@@ -35,7 +35,88 @@
 *Param $oCv - Custom view object
 *Returns the listview header values in an array
 */
-function getListViewHeader($focus, $module,$sort_qry='',$sorder='',$order_by='',$relatedlist='',$oCv='',$relatedmodule='')
+function getListViewHeader($focus,$module,$sort_qry='',$sorder='',$order_by='',$relatedlist='',$oCv='',$relatedmodule='') {
+	
+	$list_fields=$focus->list_fields;
+	$list_fields_name=$focus->list_fields_name;
+	if($oCv) {
+	    if(isset($oCv->list_fields) && isset($oCv->list_fields_name)) {
+		$list_fields = $oCv->list_fields;
+		$list_fields_name = $oCv->list_fields_name;
+	    }
+	}
+	return getGenListViewHeader($focus,$module,$list_fields_name,$list_fields,$sort_qry,$sorder,$order_by,$relatedlist,$oCv,$relatedmodule);
+}
+
+/**This function is used to get the list view header values in a dep. list view
+*Param $focus - module object
+*Param $module - module name
+*Param $sort_qry - sort by value
+*Param $sorder - sorting order (asc/desc)
+*Param $order_by - order by
+*Param $relatedlist - flag to check whether the header is for listvie or related list
+*Param $oCv - Custom view object
+*Param $rel_type - Relation type
+*Returns the listview header values in an array
+*/
+function getDepListViewHeader($focus,$module,$sort_qry='',$sorder='',$order_by='',$relatedlist='',$oCv='',$relatedmodule='',$rel_type='') {
+	
+	### Get the field list from the module
+	#
+	$_list_fields=$focus->dependend_fields;
+	$_list_fields_name=$focus->dependend_fields_name;
+	if($oCv) {
+	    if(isset($oCv->dependend_fields) && isset($oCv->dependend_fields_name)) {
+		$_list_fields = $oCv->dependend_fields;
+		$_list_fields_name = $oCv->dependend_fields_name;
+	    }
+	}
+
+	### Prepend the filed list by relation specific fields
+	#
+	if( $rel_type == 10 || $rel_type == 40) {
+	    $list_fields = Array(
+		'LBL_QTY'=>Array('products2products_rel'=>'quantity'),
+	    );
+	    $list_fields_name = Array(
+		'LBL_QTY'=>'dependency_qty'
+	    );
+	} elseif( $rel_type == 20) {
+	    $list_fields = Array(
+		'LBL_GRP'=>Array('products2products_rel'=>'product_relgroup'),
+	    );
+	    $list_fields_name = Array(
+		'LBL_GRP'=>'dependency_grp'
+	    );
+	} else {
+	    $list_fields = Array();
+	    $list_fields_name = Array();
+	}
+	foreach($_list_fields as $key=>$value) {
+	    $list_fields[$key] = $value;
+	}
+	foreach($_list_fields_name as $key=>$value) {
+	    $list_fields_name[$key] = $value;
+	}
+
+	
+	return getGenListViewHeader($focus,$module,$list_fields_name,$list_fields,$sort_qry,$sorder,$order_by,$relatedlist,$oCv,$relatedmodule);
+}
+
+/**This function is used to get the generic list view header values in a
+*  list or dependency view
+*Param $focus - module object
+*Param $module - module name
+*Param $fieldnames - Array containing the field headers
+*Param $fields - Array containing the field references
+*Param $sort_qry - sort by value
+*Param $sorder - sorting order (asc/desc)
+*Param $order_by - order by
+*Param $relatedlist - flag to check whether the header is for listvie or related list
+*Param $oCv - Custom view object
+*Returns the listview header values in an array
+*/
+function getGenListViewHeader($focus,$module,$fieldnames,$fields,$sort_qry='',$sorder='',$order_by='',$relatedlist='',$oCv='',$relatedmodule='')
 {
 	global $log, $singlepane_view;
 	$log->debug("Entering getListViewHeader(".$focus.",". $module.",".$sort_qry.",".$sorder.",".$order_by.",".$relatedlist.",".$oCv.") method ...");
@@ -53,29 +134,13 @@
 	//Get the vtiger_tabid of the module
 	$tabid = getTabid($module);
 	global $current_user;
-	//added for vtiger_customview 27/5
-	if($oCv)
-	{
-		if(isset($oCv->list_fields))
-		{
-			$focus->list_fields = $oCv->list_fields;
-		}
-	}
-
 	//Added to reduce the no. of queries logging for non-admin user -- by Minnie-start
 	$field_list ='(';
 	$j=0;
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	foreach($focus->list_fields as $name=>$tableinfo)
-	{
-		$fieldname = $focus->list_fields_name[$name];
-		if($oCv)
-		{
-			if(isset($oCv->list_fields_name))
-			{
-				$fieldname = $oCv->list_fields_name[$name];
-			}
-		}
+	foreach($fields as $name=>$tableinfo)
+  	{
+		$fieldname = $fieldnames[$name];
 		if($j != 0)
 		{
 			$field_list .= ', ';
@@ -84,22 +149,30 @@
 		$j++;
 	}
 	$field_list .=')';
+	$field=Array();
 	if($is_admin==false)
 	{
-		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT vtiger_field.fieldname
-			FROM vtiger_field
-			INNER JOIN vtiger_profile2field
-				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
-			INNER JOIN vtiger_def_org_field
-				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
-			WHERE vtiger_field.tabid = ".$tabid."
-			AND vtiger_profile2field.visible = 0
-			AND vtiger_def_org_field.visible = 0
-			AND vtiger_profile2field.profileid IN ".$profileList."
-			AND vtiger_field.fieldname IN ".$field_list;
+		if($module == 'Emails')
+		{
+			$query  = "SELECT fieldname FROM vtiger_field WHERE tabid = $tabid";
+		}
+		else
+		{
+			$profileList = getCurrentUserProfileList();
+			$query  = "SELECT DISTINCT vtiger_field.fieldname
+				FROM vtiger_field
+				INNER JOIN vtiger_profile2field
+					ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+				INNER JOIN vtiger_def_org_field
+					ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+				WHERE vtiger_field.tabid = ".$tabid."
+				AND vtiger_profile2field.visible = 0
+				AND vtiger_def_org_field.visible = 0
+				AND vtiger_profile2field.profileid IN ".$profileList."
+				AND vtiger_field.fieldname IN ".$field_list;
+		}
+
 		$result = $adb->query($query);
-		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
 		{
 			$field[]=$adb->query_result($result,$k,"fieldname");
@@ -108,39 +181,26 @@
 	//end
 
 	//modified for vtiger_customview 27/5 - $app_strings change to $mod_strings
-	foreach($focus->list_fields as $name=>$tableinfo)
-	{
-		//added for vtiger_customview 27/5
-		if($oCv)
-		{
-			if(isset($oCv->list_fields_name))
-			{
-				$fieldname = $oCv->list_fields_name[$name];
-			}else
-			{
-				$fieldname = $focus->list_fields_name[$name];
-			}
-		}else
-		{
-			$fieldname = $focus->list_fields_name[$name];
-		}
-
-		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field))
+	foreach($fields as $name=>$tableinfo)
+  	{
+		$fieldname = $fieldnames[$name];
+
+		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field) || $fieldname == '')
 		{
 			if(isset($focus->sortby_fields) && $focus->sortby_fields !='')
 			{
 				//Added on 14-12-2005 to avoid if and else check for every list vtiger_field for arrow image and change order
 				$change_sorder = array('ASC'=>'DESC','DESC'=>'ASC');
 				$arrow_gif = array('ASC'=>'arrow_down.gif','DESC'=>'arrow_up.gif');
-
-				foreach($focus->list_fields[$name] as $tab=>$col)
+			
+				foreach($fields[$name] as $tab=>$col)
 				{
 					if(in_array($col,$focus->sortby_fields))
 					{
 						if($order_by == $col)
 						{
 							$temp_sorder = $change_sorder[$sorder];
-							$arrow = "<img src ='".$image_path.$arrow_gif[$sorder]."' border='0'>";
+							$arrow = "&nbsp;<img src ='".$image_path.$arrow_gif[$sorder]."' border='0'>";
 						}
 						else
 						{
@@ -162,23 +222,24 @@
 							{
 								$rate_symbol=getCurrencySymbolandCRate($user_info['currency_id']);
 								$curr_symbol = $rate_symbol['symbol'];
-								$lbl_name .=': (in '.$curr_symbol.')';
+								$lbl_name .=' (in '.$curr_symbol.')';
 							}
 							if($relatedlist !='' && $relatedlist != 'global')
 								if($singlepane_view == 'true')	
-									$name = "<a href='index.php?module=".$relatedmodule."&action=DetailView&relmodule=".$module."&order_by=".$col."&record=".$relatedlist."&sorder=".$temp_sorder."' class='listFormHeaderLinks'>".$lbl_name."&nbsp;".$arrow."</a>";
+									$name = "<a href='index.php?module=".$relatedmodule."&action=DetailView&relmodule=".$module."&order_by=".$col."&record=".$relatedlist."&sorder=".$temp_sorder."' class='listFormHeaderLinks'>".$lbl_name."".$arrow."</a>";
 								else
-									$name = "<a href='index.php?module=".$relatedmodule."&action=CallRelatedList&relmodule=".$module."&order_by=".$col."&record=".$relatedlist."&sorder=".$temp_sorder."' class='listFormHeaderLinks'>".$lbl_name."&nbsp;".$arrow."</a>";
+									$name = "<a href='index.php?module=".$relatedmodule."&action=CallRelatedList&relmodule=".$module."&order_by=".$col."&record=".$relatedlist."&sorder=".$temp_sorder."' class='listFormHeaderLinks'>".$lbl_name."".$arrow."</a>";
 							elseif($module == 'Users' && $name == 'User Name')
-								$name = "<a href='javascript:;' onClick='getListViewEntries_js(\"".$module."\",\"order_by=".$col."&sorder=".$temp_sorder."".$sort_qry."\");' class='listFormHeaderLinks'>".$mod_strings['LBL_LIST_USER_NAME_ROLE']."&nbsp;".$arrow."</a>";
+								$name = "<a href='javascript:;' onClick='getListViewEntries_js(\"".$module."\",\"order_by=".$col."&sorder=".$temp_sorder."".$sort_qry."\");' class='listFormHeaderLinks'>".$mod_strings['LBL_LIST_USER_NAME_ROLE']."".$arrow."</a>";
 							elseif($relatedlist == "global")
 							        $name = $lbl_name;
 							else
-								$name = "<a href='javascript:;' onClick='getListViewEntries_js(\"".$module."\",\"order_by=".$col."&start=".$_SESSION["lvs"][$module]["start"]."&sorder=".$temp_sorder."".$sort_qry."\");' class='listFormHeaderLinks'>".$lbl_name."&nbsp;".$arrow."</a>";
+								$name = "<a href='javascript:;' onClick='getListViewEntries_js(\"".$module."\",\"order_by=".$col."&start=".$_SESSION["lvs"][$module]["start"]."&sorder=".$temp_sorder."".$sort_qry."\");' class='listFormHeaderLinks'>".$lbl_name."".$arrow."</a>";
 							$arrow = '';
 					}
 					else
-					{       if($app_strings[$name])
+					{
+					       if($app_strings[$name])
 						{
 							$name = $app_strings[$name];
 						}
@@ -195,14 +256,15 @@
 		{
 			$rate_symbol=getCurrencySymbolandCRate($user_info['currency_id']);
 			$curr_symbol = $rate_symbol['symbol'];
-			$name .=': (in '.$curr_symbol.')';
+			$name .=' (in '.$curr_symbol.')';
 		}
 
 		//Added condition to hide the close column in Related Lists
-		if($name == $app_strings['Close'] && $relatedlist != '')
-		{
-			// $list_header[] = '';
-		}
+		if($name == $app_strings['Close'] && $relatedlist != '' && $relatedlist != 'global')
+                {
+                        // $list_header[] = '';
+               }
+
 		else
 		{
 			$list_header[]=$name;
@@ -211,7 +273,8 @@
      }
 
 	//Added for Action - edit and delete link header in listview
-	$list_header[] = $app_strings["LBL_ACTION"];
+	if(isPermitted($module,"EditView","") == 'yes' || isPermitted($module,"Delete","") == 'yes')
+		$list_header[] = $app_strings["LBL_ACTION"];
 
 	$log->debug("Exiting getListViewHeader method ...");
 	return $list_header;
@@ -252,22 +315,30 @@
 		$j++;
 	}
 	$field_list .=')';
-	if($is_admin==false)
-	{
-		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT vtiger_field.fieldname
-			FROM vtiger_field
-			INNER JOIN vtiger_profile2field
-				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
-			INNER JOIN vtiger_def_org_field
-				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
-			WHERE vtiger_field.tabid = ".$tabid."
-			AND vtiger_profile2field.visible=0
-			AND vtiger_def_org_field.visible=0
-			AND vtiger_profile2field.profileid IN ".$profileList."
-			AND vtiger_field.fieldname IN ".$field_list;
+	$field=Array();
+	if($is_admin==false && $module != 'Users')
+	{
+		if($module == 'Emails')
+		{
+			$query  = "SELECT fieldname FROM vtiger_field WHERE tabid = $tabid";
+		}
+		else
+		{
+			$profileList = getCurrentUserProfileList();
+			$query  = "SELECT DISTINCT vtiger_field.fieldname
+				FROM vtiger_field
+				INNER JOIN vtiger_profile2field
+					ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+				INNER JOIN vtiger_def_org_field
+					ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+				WHERE vtiger_field.tabid = ".$tabid."
+				AND vtiger_profile2field.visible=0
+				AND vtiger_def_org_field.visible=0
+				AND vtiger_profile2field.profileid IN ".$profileList."
+				AND vtiger_field.fieldname IN ".$field_list;
+		}
+
 		$result = $adb->query($query);
-		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
 		{
 			$field[]=$adb->query_result($result,$k,"fieldname");
@@ -283,7 +354,7 @@
 
 		global $current_user;
                 require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		if($is_admin==false)
+	/*	if($is_admin==false)
 		{
                 	$profileList = getCurrentUserProfileList();
                 	$query = "SELECT vtiger_profile2field.*
@@ -299,9 +370,9 @@
 				AND vtiger_field.fieldname = '".$fieldname."'";
 
                 	$result = $adb->query($query);
-                }
-
-                if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || $adb->num_rows($result) == 1)
+                }*/
+
+                if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field) || $module == 'Users')
                 {
 		
 			if(isset($focus->sortby_fields) && $focus->sortby_fields !='')
@@ -435,11 +506,95 @@
 *Returns an array type
 */
 
-//parameter added for vtiger_customview $oCv 27/5
-function getListViewEntries($focus, $module,$list_result,$navigation_array,$relatedlist='',$returnset='',$edit_action='EditView',$del_action='Delete',$oCv='')
+function getListViewEntries($focus,$module,$list_result,$navigation_array,$relatedlist='',$returnset='',$edit_action='EditView',$del_action='Delete',$oCv='') {
+
+	$list_fields=$focus->list_fields;
+	$list_fields_name=$focus->list_fields_name;
+	if($oCv) {
+	    if(isset($oCv->list_fields) && isset($oCv->list_fields_name)) {
+		$list_fields = $oCv->list_fields;
+		$list_fields_name = $oCv->list_fields_name;
+	    }
+	}
+
+	return getGenListViewEntries($focus,$module,$list_fields_name,$list_fields,$list_result,$navigation_array,$relatedlist,$returnset,$edit_action,$del_action,$oCv);
+}
+
+/**This function generates the List view entries in a dependency list view 
+*Param $focus - module object
+*Param $list_result - resultset of a listview query
+*Param $navigation_array - navigation values in an array
+*Param $relatedlist - check for related list flag
+*Param $returnset - list query parameters in url string
+*Param $edit_action - Edit action value
+*Param $del_action - delete action value
+*Param $oCv - vtiger_customview object
+*Param $rel_type - Relation type
+*Returns an array type
+*/
+
+function getDepListViewEntries($focus,$module,$list_result,$navigation_array,$relatedlist='',$returnset='',$edit_action='EditView',$del_action='Delete',$oCv='',$rel_type='') {
+
+	### Get the field list from the module
+	#
+	$_list_fields=$focus->dependend_fields;
+	$_list_fields_name=$focus->dependend_fields_name;
+	if($oCv) {
+	    if(isset($oCv->dependend_fields) && isset($oCv->dependend_fields_name)) {
+		$_list_fields = $oCv->dependend_fields;
+		$_list_fields_name = $oCv->dependend_fields_name;
+	    }
+	}
+
+	### Prepend the filed list by relation specific fields
+	#
+	if( $rel_type == 10 || $rel_type == 40) {
+	    $list_fields = Array(
+		'LBL_QTY'=>Array('products2products_rel'=>'quantity'),
+	    );
+	    $list_fields_name = Array(
+		'LBL_QTY'=>'dependency_qty'
+	    );
+	} elseif( $rel_type == 20) {
+	    $list_fields = Array(
+		'LBL_GRP'=>Array('products2products_rel'=>'product_relgroup'),
+	    );
+	    $list_fields_name = Array(
+		'LBL_GRP'=>'dependency_grp'
+	    );
+	} else {
+	    $list_fields = Array();
+	    $list_fields_name = Array();
+	}
+	foreach($_list_fields as $key=>$value) {
+	    $list_fields[$key] = $value;
+	}
+	foreach($_list_fields_name as $key=>$value) {
+	    $list_fields_name[$key] = $value;
+	}
+
+	return getGenListViewEntries($focus,$module,$list_fields_name,$list_fields,$list_result,$navigation_array,$relatedlist,$returnset,$edit_action,$del_action,$oCv);
+}
+
+/**This function generates the generic List view entries in a list or
+*  dependency view 
+*Param $focus - module object
+*Param $fieldnames - Array containing the field headers
+*Param $fields - Array containing the field references
+*Param $list_result - resultset of a listview query
+*Param $navigation_array - navigation values in an array
+*Param $relatedlist - check for related list flag
+*Param $returnset - list query parameters in url string
+*Param $edit_action - Edit action value
+*Param $del_action - delete action value
+*Param $oCv - vtiger_customview object
+*Returns an array type
+*/
+
+function getGenListViewEntries($focus,$module,$fieldnames,$fields,$list_result,$navigation_array,$relatedlist='',$returnset='',$edit_action='EditView',$del_action='Delete',$oCv='')
 {
 	global $log;
-	$log->debug("Entering getListViewEntries(".$focus.",". $module.",".$list_result.",".$navigation_array.",".$relatedlist.",".$returnset.",".$edit_action.",".$del_action.",".$oCv.") method ...");
+	$log->debug("Entering getGenListViewEntries(".$focus.",". $module.",".$list_result.",".$navigation_array.",".$relatedlist.",".$returnset.",".$edit_action.",".$del_action.",".$oCv.") method ...");
 	$tabname = getParentTab();
 	global $adb,$current_user;
 	global $app_strings;
@@ -452,28 +607,13 @@
 	//getting the vtiger_fieldtable entries from database
 	$tabid = getTabid($module);
 
-	//added for vtiger_customview 27/5
-	if($oCv)
-	{
-		if(isset($oCv->list_fields))
-		{
-			$focus->list_fields = $oCv->list_fields;
-		}
-	}
 	//Added to reduce the no. of queries logging for non-admin user -- by minnie-start
 	$field_list ='(';
 	$j=0;
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	foreach($focus->list_fields as $name=>$tableinfo)
-	{
-		$fieldname = $focus->list_fields_name[$name];
-		if($oCv)
-		{
-			if(isset($oCv->list_fields_name))
-			{
-				$fieldname = $oCv->list_fields_name[$name];
-			}
-		}
+	foreach($fields as $name=>$tableinfo)
+	{
+		$fieldname = $fieldnames[$name];
 		if($j != 0)
 		{
 			$field_list .= ', ';
@@ -482,22 +622,31 @@
 		$j++;
 	}
 	$field_list .=')';
-	if($is_admin==false)
-	{
-		$profileList = getCurrentUserProfileList();
-		$query  = "SELECT DISTINCT vtiger_field.fieldname
-			FROM vtiger_field
-			INNER JOIN vtiger_profile2field
-				ON vtiger_profile2field.fieldid = vtiger_field.fieldid
-			INNER JOIN vtiger_def_org_field
-				ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
-			WHERE vtiger_field.tabid = ".$tabid."
-			AND vtiger_profile2field.visible = 0
-			AND vtiger_def_org_field.visible = 0
-			AND vtiger_profile2field.profileid IN ".$profileList."
-			AND vtiger_field.fieldname IN ".$field_list;
+	
+	$field=Array();
+  	if($is_admin==false && $module != 'Users')
+	{
+		if($module == 'Emails')
+		{
+			$query  = "SELECT fieldname FROM vtiger_field WHERE tabid = $tabid";
+		}
+		else
+		{
+			$profileList = getCurrentUserProfileList();
+			$query  = "SELECT DISTINCT vtiger_field.fieldname
+				FROM vtiger_field
+				INNER JOIN vtiger_profile2field
+					ON vtiger_profile2field.fieldid = vtiger_field.fieldid
+				INNER JOIN vtiger_def_org_field
+					ON vtiger_def_org_field.fieldid = vtiger_field.fieldid
+				WHERE vtiger_field.tabid = ".$tabid."
+				AND vtiger_profile2field.visible = 0
+				AND vtiger_def_org_field.visible = 0
+				AND vtiger_profile2field.profileid IN ".$profileList."
+				AND vtiger_field.fieldname IN ".$field_list;
+		}
+		
 		$result = $adb->query($query);
-		$field=Array();
 		for($k=0;$k < $adb->num_rows($result);$k++)
 		{
 			$field[]=$adb->query_result($result,$k,"fieldname");
@@ -507,9 +656,12 @@
 	$ui_col_array=Array();
 
 	$query = "SELECT uitype, columnname, fieldname
-		FROM vtiger_field
-		WHERE tabid = ".$tabid."
-		AND fieldname IN".$field_list;
+		FROM vtiger_field";
+	if($module == "Calendar")
+	        $query .=" WHERE vtiger_field.tabid in (9,16)";
+	else
+	        $query .=" WHERE vtiger_field.tabid =".$tabid;
+	$query .=" AND fieldname IN".$field_list;
 	$result = $adb->query($query);
 	$num_rows=$adb->num_rows($result);
 	for($i=0;$i<$num_rows;$i++)
@@ -563,21 +715,13 @@
 		}
 		//end: Armando Lüscher 05.07.2005 -> §priority
 
-		foreach($focus->list_fields as $name=>$tableinfo)
-		{
-			$fieldname = $focus->list_fields_name[$name];
-
-			//added for vtiger_customview 27/5
-			if($oCv)
+		foreach($fields as $name=>$tableinfo)
+  		{
+			$fieldname = $fieldnames[$name];
+
+			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field) || $fieldname == '')
 			{
-				if(isset($oCv->list_fields_name))
-				{
-					$fieldname = $oCv->list_fields_name[$name];
-				}
-			}
-
-			if($is_admin==true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field))
-			{
+
 				if($fieldname == '')
 				{
 					$table_name = '';
@@ -595,8 +739,6 @@
 					if(($module == 'Calendar' || $module == 'Tasks' || $module == 'Meetings' || $module == 'Emails' || $module == 'HelpDesk' || $module == 'Invoice' || $module == 'Leads' || $module == 'Contacts') && (($name=='Related to') || ($name=='Contact Name') || ($name=='Close') || ($name == 'First Name')))
 					{
 						$status = $adb->query_result($list_result,$i-1,"status");
-						if($status == '')
-							$status = $adb->query_result($list_result,$i-1,"eventstatus");
 						if ($name=='Related to')
 							$value=getRelatedTo($module,$list_result,$i-1);
 						if($name=='Contact Name')
@@ -636,7 +778,7 @@
 							else
 							{
 								$activityid = $adb->query_result($list_result,$i-1,"activityid");
-								$activitytype = $adb->query_result($list_result,$i-1,"activitytype");
+								$activitytype = $adb->query_result($list_result,$i-1,"type");
 								if($activitytype=='Task')
 									$evt_status='&status=Completed';
 								else
@@ -644,7 +786,7 @@
 								if(isPermitted("Calendar",'EditView',$activityid) == 'yes')
 								{
 									// Fredy Klammsteiner, 4.8.2005: changes from 4.0.1 migrated to 4.2
-									$value = "<a href='index.php?return_module=Calendar&return_action=index&return_id=".$activityid."&return_viewname=".$oCv->setdefaultviewid."&action=Save&module=Calendar&record=".$activityid."&parenttab=".$tabname."&change_status=true".$evt_status."&start=".$navigation_array['current']."' style='".$P_FONT_COLOR."'>X</a>"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
+									$value = "<a href='index.php?return_module=Calendar&return_action=ListView&return_id=".$activityid."&return_viewname=".$oCv->setdefaultviewid."&action=Save&module=Calendar&record=".$activityid."&parenttab=".$tabname."&change_status=true".$evt_status."&start=".$navigation_array['current']."' style='".$P_FONT_COLOR."'>X</a>"; // Armando Lüscher 05.07.2005 -> §priority -> Desc: inserted style="$P_FONT_COLOR"
 								}
 								else
 								{
@@ -751,29 +893,36 @@
 		}
 
 		//Added for Actions ie., edit and delete links in listview 
-		$edit_link = getListViewEditLink($module,$entity_id,$relatedlist,$varreturnset,$list_result,$list_result_count);
-		$del_link = getListViewDeleteLink($module,$entity_id,$relatedlist,$varreturnset);
-
-		$links_info = "<a href=\"$edit_link\"> &nbsp;".$app_strings["LNK_EDIT"]." </a> ";
-		if($del_link != '')
-			$links_info .=	" | <a href='javascript:confirmdelete(\"$del_link\")'> ".$app_strings["LNK_DELETE"]." </a>";
-
-		$list_header[] = $links_info;
-
+		$links_info = "";
+		if(isPermitted($module,"EditView","") == 'yes'){
+			$edit_link = getListViewEditLink($module,$entity_id,$relatedlist,$varreturnset,$list_result,$list_result_count);
+			$links_info .= "<a href=\"$edit_link\">".$app_strings["LNK_EDIT"]."</a> ";
+		}
+		
+			
+		if(isPermitted($module,"Delete","") == 'yes'){
+			if($links_info != "")
+				$links_info .=  " | ";
+			$del_link = getListViewDeleteLink($module,$entity_id,$relatedlist,$varreturnset);
+			$links_info .=	"<a href='javascript:confirmdelete(\"$del_link\")'>".$app_strings["LNK_DELETE"]."</a>";
+		}	
+		if($links_info != "")
+			$list_header[] = $links_info;
+		/*commented to fix: attachments and notes cant be deleted in Invoice Related List. 
 		echo '<script>
 				function confirmdelete(url)
 		                {
-		                        if(confirm("Are you sure?"))
+		                        if(confirm("'.$app_strings['ARE_YOU_SURE'].'"))
 		                        {
 		                                document.location.href=url;
 		                        }
 		                }
 		        </script>';
-
+		*/
 		$list_block[$entity_id] = $list_header;
 
 	}
-	$log->debug("Exiting getListViewEntries method ...");
+	$log->debug("Exiting getGenListViewEntries method ...");
 	return $list_block;
 }
 
@@ -819,6 +968,7 @@
 		$j++;
 	}
 	$field_list .=')';
+	$field=Array();
 	if($is_admin==false)
 	{
 		$profileList = getCurrentUserProfileList();
@@ -834,7 +984,7 @@
 			AND vtiger_profile2field.profileid IN ".$profileList."
 			AND vtiger_field.fieldname IN ".$field_list;
 		$result = $adb->query($query);
-		$field=Array();
+		
 		for($k=0;$k < $adb->num_rows($result);$k++)
 		{
 			$field[]=$adb->query_result($result,$k,"fieldname");
@@ -881,7 +1031,9 @@
 			{
 				$fieldname = $focus->search_fields_name[$name];
 
-				if($is_admin==false)
+				/*
+
+				if($is_admin==false && $module != 'Users')
 				{
 					$profileList = getCurrentUserProfileList();
 					$query = "SELECT vtiger_profile2field.*
@@ -898,8 +1050,8 @@
 
 					$result = $adb->query($query);
 				}
-
-				if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || $adb->num_rows($result) == 1)
+				*/
+				if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field) || $module == 'Users')
 				{			
 					if($fieldname == '')
 					{
@@ -949,6 +1101,12 @@
 							$quotename = getQuoteName($quote_id);
 							$value = $quotename;
 						}
+						elseif($name == 'Account Name' && $module=='Contacts' )
+						{
+							$account_id = $adb->query_result($list_result,$i-1,"accountid");
+							$account_name = getAccountName($account_id);
+							$value = $account_name;
+						}
 						else
 						{
 							$list_result_count = $i-1;
@@ -985,11 +1143,14 @@
 
 function getValue($field_result, $list_result,$fieldname,$focus,$module,$entity_id,$list_result_count,$mode,$popuptype,$returnset='',$viewid='')
 {
-	global $log;
+	global $log,$app_strings,$current_language;
 	$log->debug("Entering getValue(".$field_result.",". $list_result.",".$fieldname.",".$focus.",".$module.",".$entity_id.",".$list_result_count.",".$mode.",".$popuptype.",".$returnset.",".$viewid.") method ...");
 	global $adb,$current_user;
+	
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
 	$tabname = getParentTab();
+	$tabid = getTabid($module);
+	$current_module_strings = return_module_language($current_language, $module);
 	$uicolarr=$field_result[$fieldname];
 	foreach($uicolarr as $key=>$value)
 	{
@@ -997,20 +1158,30 @@
 		$colname = $value;
         }
 	//added for getting event status in Custom view - Jaguar
-	if($module == 'Calendar' && $colname == "status")
+	if($module == 'Calendar' && ($colname == "status" || $colname == "eventstatus"))
 	{
 		$colname="activitystatus";
 	}
 	//Ends
-	$temp_val = $adb->query_result($list_result,$list_result_count,$colname);
-	if(strlen($temp_val) > 40)
+	$field_val = $adb->query_result($list_result,$list_result_count,$colname);
+	$temp_val = $field_val;
+        if(strlen($field_val) > 40)
         {
-                $temp_val = substr($temp_val,0,40).'...';
+                $temp_val = substr($field_val,0,40).'...';
         }
-	if($uitype == 52 || $uitype == 53 || $uitype == 77)
+
+	if($uitype == 53)
 	{
 		$value = $adb->query_result($list_result,$list_result_count,'user_name');
 	}
+	elseif($uitype == 52) 
+	{        
+		$value = getUserName($adb->query_result($list_result,$list_result_count,'handler')); 
+	}
+	elseif($uitype == 77) 
+	{        
+		$value = getUserName($adb->query_result($list_result,$list_result_count,'inventorymanager')); 
+	} 
 	elseif($uitype == 5 || $uitype == 6 || $uitype == 23 || $uitype == 70)
 	{
 		if($temp_val != '' && $temp_val != '0000-00-00')
@@ -1025,7 +1196,36 @@
 		{
 			$value = $temp_val;
 		}
+			
+	
+		//Added to get both start date & time
+		/*if(($tabid == 9 || $tabid == 16) && $uitype == 6 && $viewname != 'All')
+		{
+			$timestart = $adb->query_result($list_result,$list_result_count,'time_start');
+			$value = $value .'&nbsp;&nbsp;&nbsp;'.$timestart;	
+		}
+		else if($viewname != 'All' && isset($focus->list_fields['End Date & Time']))
+		{
+			$timeend = $adb->query_result($list_result,$list_result_count,'time_end');
+                        $value = $value .'&nbsp;&nbsp;&nbsp;'.$timeend;
+		}*/
 		
+		
+	}
+	elseif($uitype == 15 || $uitype == 111 ||  $uitype == 16)
+	{
+		if($current_module_strings[$temp_val] != '')
+		{
+			$value = $current_module_strings[$temp_val];
+		}
+		elseif($app_strings[$temp_val] != '')
+		{
+			$value = $app_strings[$temp_val];
+		}
+		else
+		{
+			$value = $temp_val;
+		}
 	}
 	elseif($uitype == 71 || $uitype == 72)
 	{
@@ -1043,24 +1243,30 @@
 	}
 	elseif($uitype == 17)
 	{
-		$value = '<a href="http://'.$temp_val.'" target="_blank">'.$temp_val.'</a>';
+		$value = '<a href="http://'.$field_val.'" target="_blank">'.$temp_val.'</a>';
 	}
 	elseif($uitype == 13 || $uitype == 104)
         {
 		if(useInternalMailer() == 1)
-                	$value = '<a href="javascript:InternalMailer('.$entity_id.',\'record_id\')">'.$temp_val.'</a>';
+		{
+			$querystr="SELECT fieldid FROM vtiger_field WHERE tabid=".getTabid($module)." and uitype=13;";
+			$queryres = $adb->query($querystr);
+			//Change this index 0 - to get the vtiger_fieldid based on email1 or email2
+			$fieldid = $adb->query_result($queryres,0,'fieldid');
+			$value = '<a href="javascript:InternalMailer('.$entity_id.','.$fieldid.',\'record_id\')">'.$temp_val.'</a>';
+		}
 		else
-                	$value = '<a href="mailto:'.$temp_val.'">'.$temp_val.'</a>';
+                	$value = '<a href="mailto:'.$field_val.'">'.$temp_val.'</a>';
         }
 	elseif($uitype == 56)
 	{
 		if($temp_val == 1)
 		{
-			$value = 'yes';
+			$value = $app_strings['yes'];
 		}
 		else
 		{
-			$value = 'no';
+			$value = $app_strings['no'];
 		}
 	}	
 	elseif($uitype == 57)
@@ -1304,7 +1510,15 @@
         }
 	elseif($uitype == 98)
 	{
-		$value = '<a href="index.php?action=RoleDetailView&module=Users&parenttab=Settings&roleid='.$temp_val.'">'.getRoleName($temp_val).'</a>';  
+		$value = '<a href="index.php?action=RoleDetailView&module=Settings&parenttab=Settings&roleid='.$temp_val.'">'.getRoleName($temp_val).'</a>';  
+	}
+	elseif($uitype == 33)
+	{
+		$value = ($temp_val != "") ? str_ireplace(' |##| ',', ',$temp_val) : "";
+	}
+	elseif($uitype == 85)
+	{
+		$value = ($temp_val != "") ? "<a href='skype:{$temp_val}?call'>{$temp_val}</a>" : "";
 	}
 	else
 	{
@@ -1313,7 +1527,7 @@
 		{
 			if($mode == "search")
 			{
-				if($popuptype == "specific")
+				if($popuptype == "specific" || $popuptype=="toDospecific")
 				{
 					// Added for get the first name of contact in Popup window
 					if($colname == "lastname" && $module == 'Contacts')
@@ -1329,7 +1543,10 @@
 					if($module == 'SalesOrder')
 						$value = '<a href="javascript:window.close();" onclick=\'set_return_specific("'.$entity_id.'", "'.br2nl($temp_val).'","'.$_REQUEST['form'].'");\'>'.$temp_val.'</a>';
 					else
-						$value = '<a href="javascript:window.close();" onclick=\'set_return_specific("'.$entity_id.'", "'.br2nl($temp_val).'");\'>'.$temp_val.'</a>';
+						if($popuptype=='toDospecific')
+							$value = '<a href="javascript:window.close();" onclick=\'set_return_toDospecific("'.$entity_id.'", "'.br2nl($temp_val).'");\'>'.$temp_val.'</a>';
+						else
+							$value = '<a href="javascript:window.close();" onclick=\'set_return_specific("'.$entity_id.'", "'.br2nl($temp_val).'");\'>'.$temp_val.'</a>';
 				}
 				elseif($popuptype == "detailview")
 				{
@@ -1372,7 +1589,7 @@
 					$qty_stock=$adb->query_result($list_result,$list_result_count,'qtyinstock');
 
 					$temp_val = popup_from_html($temp_val);
-					$value = '<a href="javascript:window.close();" onclick=\'set_return_inventory("'.$entity_id.'", "'.br2nl($temp_val).'", "'.$unitprice.'", "'.$qty_stock.'","'.$tax_str.'","'.$row_id.'");\'>'.$temp_val.'</a>';
+					$value = '<a href="javascript:window.close();" onclick=\'set_return_inventory("'.$entity_id.'", "'.nl2br($temp_val).'", "'.$unitprice.'", "'.$qty_stock.'","'.$tax_str.'","'.$row_id.'");\'>'.$temp_val.'</a>';
 				}
 				elseif($popuptype == "inventory_prod_po")
 				{
@@ -1519,20 +1736,21 @@
 				{
 					if($module == "Contacts")
 					{
-						$query="SELECT vtiger_contactdetails.imagename FROM vtiger_contactdetails WHERE contactid='".$entity_id."'";
-						$result = $adb->query($query);
+						$sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid inner join vtiger_contactdetails on vtiger_contactdetails.imagename=vtiger_attachments.name where vtiger_seattachmentsrel.crmid=".$entity_id;
+						$image_res = $adb->query($sql);
+						$image_id = $adb->query_result($image_res,0,'attachmentsid');
+						$image_path = $adb->query_result($image_res,0,'path');
+						$image_name = $adb->query_result($image_res,0,'name');
+						$imgpath = $image_path.$image_id."_".$image_name;
 						$contact_image = '';
-						$imagename=$adb->query_result($result,0,'imagename');
-						if($imagename != '')
-						{
-							$imgpath = "test/contact/".$imagename;
-							$contact_image='<img align="absmiddle" src="'.$imgpath.'" width="20" height="20" border="0" onMouseover=modifyimage("dynloadarea","'.$imgpath.'"); onMouseOut=fnhide("dynloadarea");>';
-						}
-						$value = '<a href="index.php?action=DetailView&module='.$module.'&record='.$entity_id.'&parenttab='.$tabname.'">'.$temp_val.'</a>'.$contact_image;
+						if($image_name != '')
+							$contact_image ='<img align="absmiddle" src="'.$imgpath.'" width="20" height="20" border="0" onMouseover="modifyimage(\'dynloadarea\',\''.$imgpath.'\');" onMouseOut="fnhide(\'dynloadarea\');" alt="'.$app_strings['MSG_IMAGE_ERROR'].'" title="'.$app_strings['Contact Image'].'">';
+						$value =$contact_image.'<a href="index.php?action=DetailView&module='.$module.'&record='.$entity_id.'&parenttab='.$tabname.'">'.$temp_val.'</a>';
+
 					}else
 					{
 						//Commented to give link even to the first name - Jaguar
-						$value = $contact_image.'<a href="index.php?action=DetailView&module='.$module.'&record='.$entity_id.'&parenttab='.$tabname.'">'.$temp_val.'</a>';
+						$value = '<a href="index.php?action=DetailView&module='.$module.'&record='.$entity_id.'&parenttab='.$tabname.'">'.$temp_val.'</a>';
 					}
 				}
 				elseif($module == "Calendar")
@@ -1589,7 +1807,10 @@
 	{
 		$value = '<span align="right">'.$value.'</div>';
 	}
-
+	if($value == '--None--')
+	{
+	        $value = '';
+	}
 	$log->debug("Exiting getValue method ...");
 	return $value; 
 }
@@ -1609,8 +1830,9 @@
 	require('user_privileges/user_privileges_'.$current_user->id.'.php');
 	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
 	$tab_id = getTabid($module);	
-	if($module == "HelpDesk")
-	{
+	switch($module)
+	{
+	Case "HelpDesk":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
 			vtiger_troubletickets.title, vtiger_troubletickets.status,
 			vtiger_troubletickets.priority, vtiger_troubletickets.parent_id,
@@ -1645,10 +1867,9 @@
 				$query .= $sec_parameter;
 
 		}
-
-	}
-	if($module == "Accounts")
-	{
+			break;
+
+	Case "Accounts":
 		//Query modified to sort by assigned to
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
 			vtiger_account.accountname, vtiger_account.email1,
@@ -1710,10 +1931,9 @@
 					WHERE userid=".$current_user->id."
 					AND tabid=".$tab_id.")))) ";
                 }
-
-	}
-	if ($module == "Potentials")
-	{
+			break;
+
+	Case "Potentials":
 		//Query modified to sort by assigned to
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
 			vtiger_account.accountname,
@@ -1746,10 +1966,9 @@
 			$query .= $sec_parameter;
 		}
 
-
-	}
-	if($module == "Leads")
-	{
+			break;
+
+	Case "Leads":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
 			vtiger_leaddetails.firstname, vtiger_leaddetails.lastname,
 			vtiger_leaddetails.company, vtiger_leadaddress.phone,
@@ -1780,31 +1999,19 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;
                 }				
-	}
-	if($module == "Products")
-	{
+			break;
+	Case "Products":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_products.*, vtiger_productcf.*
 			FROM vtiger_products
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_products.productid
-			INNER JOIN vtiger_entity2org
-				ON vtiger_crmentity.crmid = vtiger_entity2org.crmid
-				AND vtiger_entity2org.organizationname = '".$current_organization."'
-			LEFT JOIN vtiger_productcf
+			INNER JOIN vtiger_productcf
 				ON vtiger_products.productid = vtiger_productcf.productid
-			LEFT JOIN vtiger_seproductsrel
-				ON vtiger_seproductsrel.productid = vtiger_products.productid
-			WHERE vtiger_crmentity.deleted = 0
-			AND ((vtiger_seproductsrel.crmid IS NULL
-					AND (vtiger_products.contactid = 0
-						OR vtiger_products.contactid IS NULL))
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) ";
-	}
-        if($module == "Notes")
-        {
+			LEFT JOIN vtiger_vendor
+				ON vtiger_vendor.vendorid = vtiger_products.vendor_id	
+			WHERE vtiger_crmentity.deleted = 0 ".$where;
+			break;
+	Case "Notes":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.modifiedtime,
 			vtiger_notes.title, vtiger_notes.contact_id, vtiger_notes.filename,
 			vtiger_senotesrel.crmid AS relatedto,
@@ -1832,9 +2039,8 @@
 				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('PurchaseOrder').")
 				OR vtiger_senotesrel.crmid IN (".getReadEntityIds('SalesOrder').")
 				OR vtiger_notes.contact_id IN (".getReadEntityIds('Contacts').")) ";
-        }
-	if($module == "Contacts")
-        {
+			break;
+	Case "Contacts":
 		//Query modified to sort by assigned to
 		$query = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname,
 			vtiger_contactdetails.title, vtiger_contactdetails.accountid,
@@ -1867,9 +2073,8 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;
 		}
-        }
-	if($module == "Calendar")
-        {
+			break;
+	Case "Calendar":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.setype,
 			vtiger_activity.*,
 			vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,
@@ -1898,6 +2103,8 @@
 				ON vtiger_account.accountid = vtiger_contactdetails.accountid
 			LEFT OUTER JOIN vtiger_recurringevents
 				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+			LEFT OUTER JOIN vtiger_activity_reminder
+                        	ON vtiger_activity_reminder.activity_id = vtiger_activity.activityid
 			WHERE vtiger_crmentity.deleted = 0
 			AND (vtiger_activity.activitytype = 'Meeting'
 				OR vtiger_activity.activitytype = 'Call'
@@ -1910,9 +2117,8 @@
 		}
 		//$query .=" group by vtiger_activity.activityid ";
 		//included by Jaguar
-        }
-	if($module == "Emails")
-        {
+			break;
+	Case "Emails":
 		$query = "SELECT DISTINCT vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
 			vtiger_activity.activityid, vtiger_activity.subject,
 			vtiger_activity.date_start,
@@ -1948,10 +2154,8 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-	}
-
-	if($module == "Faq")
-	{
+			break;
+	Case "Faq":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime,
 			vtiger_faq.*
 			FROM vtiger_faq
@@ -1968,30 +2172,30 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-
-	}
-	
-	if($module == "Vendors")
-	{
+			break;
+
+	Case "Vendors":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_vendor.*
 			FROM vtiger_vendor
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_vendor.vendorid
+			INNER JOIN vtiger_vendorcf
+				ON vtiger_vendor.vendorid = vtiger_vendorcf.vendorid
 			INNER JOIN vtiger_entity2org
 				ON vtiger_crmentity.crmid = vtiger_entity2org.crmid
 				AND vtiger_entity2org.organizationname = '".$current_organization."'
 			WHERE vtiger_crmentity.deleted = 0";
-	}
-	if($module == "PriceBooks")
-	{
+			break;
+	Case "PriceBooks":
 		$query = "SELECT vtiger_crmentity.crmid, vtiger_pricebook.*
 			FROM vtiger_pricebook
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_pricebook.pricebookid
+			INNER JOIN vtiger_pricebookcf 
+				ON vtiger_pricebook.pricebookid = vtiger_pricebookcf.pricebookid
 			WHERE vtiger_crmentity.deleted = 0";
-	}
-	if($module == "Quotes")
-	{
+			break;
+	Case "Quotes":
 		//Query modified to sort by assigned to
 		$query = "SELECT vtiger_crmentity.*,
 			vtiger_quotes.*,
@@ -2015,21 +2219,24 @@
 				ON vtiger_account.accountid = vtiger_quotes.accountid
 			LEFT OUTER JOIN vtiger_potential
 				ON vtiger_potential.potentialid = vtiger_quotes.potentialid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_quotes.contactid
 			LEFT JOIN vtiger_quotegrouprelation
 				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
 			LEFT JOIN vtiger_groups
 				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
 			LEFT JOIN vtiger_users
 				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_users as vtiger_usersQuotes
+			        ON vtiger_usersQuotes.id = vtiger_quotes.inventorymanager
 			WHERE vtiger_crmentity.deleted = 0 ".$where;
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-	}
-	if($module == "PurchaseOrder")
-        {
+			break;
+	Case "PurchaseOrder":
 		//Query modified to sort by assigned to
                 $query = "SELECT vtiger_crmentity.*,
 			vtiger_purchaseorder.*,
@@ -2044,6 +2251,8 @@
 				AND vtiger_entity2org.organizationname = '".$current_organization."'
 			LEFT OUTER JOIN vtiger_vendor
 				ON vtiger_purchaseorder.vendorid = vtiger_vendor.vendorid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_purchaseorder.contactid = vtiger_contactdetails.contactid	
 			INNER JOIN vtiger_pobillads
 				ON vtiger_purchaseorder.purchaseorderid = vtiger_pobillads.pobilladdressid
 			INNER JOIN vtiger_poshipads
@@ -2062,9 +2271,8 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-        }
-        if($module == "SalesOrder")
-        {
+			break;
+	Case "SalesOrder":
 		//Query modified to sort by assigned to
                 $query = "SELECT vtiger_crmentity.*,
 			vtiger_salesorder.*,
@@ -2088,6 +2296,8 @@
 				ON vtiger_quotes.quoteid = vtiger_salesorder.quoteid
 			LEFT OUTER JOIN vtiger_account
 				ON vtiger_account.accountid = vtiger_salesorder.accountid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_salesorder.contactid = vtiger_contactdetails.contactid	
 			LEFT JOIN vtiger_sogrouprelation
 				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
 			LEFT JOIN vtiger_groups
@@ -2100,9 +2310,8 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-        }
-	if($module == "Invoice")
-	{
+			break;
+	Case "Invoice":
 		//Query modified to sort by assigned to
 		//query modified -Code contribute by Geoff(http://forums.vtiger.com/viewtopic.php?t=3376)
 		$query = "SELECT vtiger_crmentity.*,
@@ -2125,6 +2334,8 @@
 				ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid
 			LEFT OUTER JOIN vtiger_account
 			        ON vtiger_account.accountid = vtiger_invoice.accountid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_invoice.contactid
 			INNER JOIN vtiger_invoicecf
 				ON vtiger_invoice.invoiceid = vtiger_invoicecf.invoiceid
 			LEFT JOIN vtiger_invoicegrouprelation
@@ -2139,9 +2350,8 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-	}
-	if($module == "Campaigns")
-	{
+			break;
+	Case "Campaigns":
 		//Query modified to sort by assigned to
 		//query modified -Code contribute by Geoff(http://forums.vtiger.com/viewtopic.php?t=3376)
 		$query = "SELECT vtiger_crmentity.*,
@@ -2166,18 +2376,19 @@
 			$sec_parameter=getListViewSecurityParameter($module);
 			$query .= $sec_parameter;	
 		}
-	}
-	if($module == "Users")
-	{
+			break;
+	Case "Users":
 		$query = "select id,user_name,roleid,first_name,last_name,email1,phone_mobile,phone_work,is_admin,status from vtiger_users inner join vtiger_user2role on vtiger_user2role.userid=vtiger_users.id where deleted=0 ".$where ;
-	}
-	if($module == "Organization")
-	{
+			break;
+	Case "Organization":
 		$query = "SELECT organizationname,address,city,state,code FROM vtiger_organizationdetails where deleted=0 ".$where;
-	}
-	
-
-	$log->debug("Exiting getListQuery method ... ");
+			break;
+	default:
+		$focus = new $module();	
+		$query = $focus->getListQuery($module);
+	}
+
+	$log->debug("Exiting getListQuery method ...");
 	return $query;
 }
 
@@ -2287,16 +2498,17 @@
 			FROM vtiger_products
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_products.productid
+			INNER JOIN vtiger_entity2org
+				ON vtiger_crmentity.crmid = vtiger_entity2org.crmid
+				AND vtiger_entity2org.organizationname = '".$current_organization."'
 			LEFT JOIN vtiger_seproductsrel
 				ON vtiger_seproductsrel.productid = vtiger_products.productid
 			WHERE vtiger_crmentity.deleted = 0
-			AND ((vtiger_seproductsrel.crmid IS NULL
-					OR vtiger_products.contactid = 0
-					OR vtiger_products.contactid IS NULL)
+			AND (vtiger_seproductsrel.crmid IS NULL
 				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
 				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
 				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) ";
+				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Contacts').")) ".$where;
 	}
 
 	if($module == "PurchaseOrder")
@@ -2405,7 +2617,7 @@
 {
 	global $log;
 	$log->debug("Entering getRelatedToEntity(".$module.",".$list_result.",".$rset.") method ...");
-
+	
 	global $adb;
 	$seid = $adb->query_result($list_result,$rset,"relatedto");
 	$action = "DetailView";
@@ -2532,8 +2744,10 @@
         $evt_result = $adb->query($evt_query);
 		$numrows= $adb->num_rows($evt_result);
 		
-		$parent_module = $adb->query_result($evt_result,0,'setype');
+	$parent_module = $adb->query_result($evt_result,0,'setype');
         $parent_id = $adb->query_result($evt_result,0,'crmid');
+
+
 		
 		if ($numrows>1){
 		$parent_module ='Multiple';
@@ -2611,6 +2825,16 @@
 			$parent_name = substr($parent_name,0,25).'...';
 		}
 	}
+	if($parent_module == 'Campaigns')
+	{
+		$parent_query = "SELECT campaignname FROM vtiger_campaign WHERE campaignid=".$parent_id;
+		$parent_result = $adb->query($parent_query);
+		$parent_name = $adb->query_result($parent_result,0,"campaignname");
+		if(strlen($parent_name) > 25)
+		{
+			$parent_name = substr($parent_name,0,25).'...';
+		}
+	}
 
 	//added by rdhital for better emails - Raju
 	if ($parent_module == 'Multiple')
@@ -2624,6 +2848,7 @@
 	//code added by raju ends
 	$log->debug("Exiting getRelatedTo method ...");
         return $parent_value;
+	
 
 
 }
@@ -2684,7 +2909,213 @@
 	return;
 	else
 	return $output;
-} 
+}
+
+function getPopupCheckquery($current_module,$relmodule,$relmod_recordid)
+{
+	global $log,$adb;
+	$log->debug("Entering getPopupCheckquery(".$currentmodule.",".$relmodule.",".$relmod_recordid.") method ...");
+	if($current_module == "Contacts")	
+	{
+		if($relmodule == "Accounts")
+			$condition = "and vtiger_account.accountid= ".$relmod_recordid;
+
+		elseif($relmodule == "Potentials")
+		{
+			/*$query = "select accountid from vtiger_potential where potentialid=".$relmod_recordid;
+			$result = $adb->query($query);
+			$account_id = $adb->query_result($result,0,"accountid");
+			$condition = "and vtiger_contactdetails.accountid= ".$account_id;*/
+
+			$query = "select contactid from vtiger_contpotentialrel where potentialid=".$relmod_recordid;
+			$result = $adb->query($query);
+                        $contact_id = $adb->query_result($result,0,"contactid");
+			$condition = "and vtiger_contactdetails.contactid= ".$contact_id;
+		}
+		elseif($relmodule == "Quotes")
+		{
+
+			$query = "select contactid from vtiger_quotes where quoteid=".$relmod_recordid;
+			$result = $adb->query($query);
+			$contactid = $adb->query_result($result,0,"contactid");
+			if($contactid != '')
+				$condition = "and vtiger_contactdetails.contactid= ".$contactid;
+			else
+			{
+				$query = "select accountid from vtiger_quotes where quoteid=".$relmod_recordid;
+				$result = $adb->query($query);
+				$account_id = $adb->query_result($result,0,"accountid");
+				$condition = "and vtiger_contactdetails.accountid= ".$account_id;
+			}
+		}
+		elseif($relmodule == "PurchaseOrder")
+		{
+			$query = "select contactid from vtiger_purchaseorder where purchaseorderid=".$relmod_recordid;
+			$result = $adb->query($query);
+			$contact_id = $adb->query_result($result,0,"contactid");
+			$condition = "and vtiger_contactdetails.contactid= ".$contact_id;
+		}
+
+		elseif($relmodule == "SalesOrder")
+		{
+			$query = "select contactid from vtiger_salesorder where salesorderid=".$relmod_recordid;
+			$result = $adb->query($query);
+			$contact_id = $adb->query_result($result,0,"contactid");
+			$condition =  "and vtiger_contactdetails.contactid=".$contact_id;
+		}
+
+		elseif($relmodule == "Invoice")
+		{
+			$query = "select accountid from vtiger_invoice where invoiceid=".$relmod_recordid;
+			$result = $adb->query($query);
+			$account_id = $adb->query_result($result,0,"accountid");
+			$condition =  "and vtiger_contactdetails.accountid=".$account_id;
+
+		}
+
+		elseif($relmodule == "Campaigns")
+		{
+			$query = "select contactid from vtiger_campaigncontrel where campaignid =".$relmod_recordid;
+			$result = $adb->query($query);
+			$rows = $adb->num_rows($result);
+			if($rows != 0)
+			{
+				$j = 0;
+				$contactid_comma = "(";
+				for($k=0; $k < $rows; $k++)
+				{
+					$contactid = $adb->query_result($result,$k,'contactid');
+					$contactid_comma.=$contactid;
+					if($k < ($rows-1))
+						$contactid_comma.=', ';
+				}
+				$contactid_comma.= ")";
+			}
+			if($contactid_comma != '')
+				$condition = "and vtiger_contactdetails.contactid in ".$contactid_comma;
+		}
+
+		elseif($relmodule == "HelpDesk" || $relmodule == "Trouble Tickets")
+		{
+			$query = "select parent_id from vtiger_troubletickets where ticketid =".$relmod_recordid;	
+			$result = $adb->query($query);
+			$parent_id = $adb->query_result($result,0,"parent_id");
+			$crmquery = "select setype from vtiger_crmentity where crmid=".$parent_id;
+			$parentmodule_id = $adb->query($crmquery);
+			$parent_modname = $adb->query_result($parentmodule_id,0,"setype");
+			if($parent_modname == "Accounts")
+				$condition = "and vtiger_contactdetails.accountid= ".$parent_id;
+			if($parent_modname == "Contacts")
+				$condition = "and vtiger_contactdetails.contactid= ".$parent_id;
+
+		}
+	}
+	elseif($current_module == "Potentials")
+	{
+		if($relmodule == 'Accounts')
+		{
+			$pot_query = "select vtiger_crmentity.crmid,vtiger_account.accountid,vtiger_potential.potentialid from vtiger_potential inner join vtiger_account on vtiger_account.accountid=vtiger_potential.accountid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_potential.accountid=".$relmod_recordid;
+			$pot_result = $result = $adb->query($pot_query);
+			$rows = $adb->num_rows($pot_result);
+			$potids_comma = "";	
+			if($rows != 0)
+			{
+				$j = 0;
+				$potids_comma .= "(";
+				for($k=0; $k < $rows; $k++)
+				{
+					$potential_ids = $adb->query_result($pot_result,$k,'potentialid');
+					$potids_comma.=$potential_ids;
+					if($k < ($rows-1))
+						$potids_comma.=',';
+				}
+				$potids_comma.= ")";
+			}
+			if($potids_comma != '')
+				$condition ="and vtiger_potential.potentialid in ".$potids_comma;
+		}
+		
+	}
+	else if($current_module == "Products")
+	{
+		if($relmodule == 'Accounts')
+		{
+			$pro_query = "select productid from vtiger_seproductsrel where setype='Accounts' and crmid=".$relmod_recordid;
+			$pro_result = $result = $adb->query($pro_query);
+			$rows = $adb->num_rows($pro_result);
+			if($rows != 0)
+			{
+				$proids_comma = "(";
+				for($k=0; $k < $rows; $k++)
+				{
+					$product_ids = $adb->query_result($pro_result,$k,'productid');
+					$proids_comma .= $product_ids;
+					if($k < ($rows-1))
+						$proids_comma.=',';
+				}
+				$proids_comma.= ")";
+			}
+			if($proids_comma != '')
+				$condition ="and vtiger_products.productid in ".$proids_comma;
+		}
+	}
+	else if($current_module == 'Quotes')
+	{
+		if($relmodule == 'Accounts')
+		{
+			$quote_query = "select quoteid from vtiger_quotes where accountid=".$relmod_recordid;
+			$quote_result = $result = $adb->query($quote_query);
+			$rows = $adb->num_rows($quote_result);
+			if($rows != 0)
+			{
+				$j = 0;
+				$qtids_comma = "(";
+				for($k=0; $k < $rows; $k++)
+				{
+					$quote_ids = $adb->query_result($quote_result,$k,'quoteid');
+					$qtids_comma.=$quote_ids;
+					if($k < ($rows-1))
+						$qtids_comma.=',';
+				}
+				$qtids_comma.= ")";
+			}
+			if($qtids_comma != '')
+				$condition ="and vtiger_quotes.quoteid in ".$qtids_comma;
+		}
+
+	}
+	else if($current_module == 'SalesOrder')
+	{
+		if($relmodule == 'Accounts')
+		{
+			$SO_query = "select salesorderid from vtiger_salesorder where accountid=".$relmod_recordid;
+			$SO_result = $result = $adb->query($SO_query);
+			$rows = $adb->num_rows($SO_result);
+			if($rows != 0)
+			{
+				$SOids_comma = "(";
+				for($k=0; $k < $rows; $k++)
+				{
+					$SO_ids = $adb->query_result($SO_result,$k,'salesorderid');
+					$SOids_comma.=$SO_ids;
+					if($k < ($rows-1))
+						$SOids_comma.=',';
+				}
+				$SOids_comma.= ")";
+			}
+			if($SOids_comma != '')
+				$condition ="and vtiger_salesorder.salesorderid in ".$SOids_comma;
+		}
+
+	}
+	else
+		$condition = '';
+	$where = $condition;	
+	$log->debug("Exiting getPopupCheckquery method ...");
+	return $where;
+	
+	
+}
 
 /**This function return the entity ids that need to be excluded in popup listview for a given record
 Param $currentmodule - modulename of the entity to be selected
@@ -2693,10 +3124,10 @@
 Return type string.
 */
 
-function getRelCheckquery($currentmodule,$returnmodule,$recordid)
+function getRelCheckquery($currentmodule,$returnmodule,$recordid,$dependency_type)
 {
 	global $log;
-	$log->debug("Entering getRelCheckquery(".$currentmodule.",".$returnmodule.",".$recordid.") method ...");
+	$log->debug("Entering getRelCheckquery(".$currentmodule.",".$returnmodule.",".$recordid.",".$dependency_type.") method ...");
 	global $adb;
 	$skip_id = Array();
 	$where_relquery = "";
@@ -2756,6 +3187,21 @@
 		$condition = 'WHERE contactid = '.$recordid;;
 		$field = $selectfield = 'campaignid';
 		$table = 'vtiger_campaign';
+	}
+	elseif($currentmodule == "Products" && ($returnmodule == "Potentials" || $returnmodule == "Accounts" || $returnmodule == "Contacts" || $returnmodule == "Leads"))
+	{
+		$reltable = 'vtiger_seproductsrel';
+		$condition = 'WHERE crmid = '.$recordid.' and setype = "'.$returnmodule.'"';
+		$field = $selectfield ='productid';
+		$table = 'vtiger_products';
+	}
+	elseif($currentmodule=="Products" && $returnmodule == "Products" && $dependency_type != '')
+	{
+		$reltable = 'vtiger_products2products_rel';
+		$selectfield = 'related_productid';
+		$condition = 'WHERE productid = '.$recordid.' AND relation_type = '.$dependency_type;
+		$table = 'vtiger_products';
+		$field = 'productid';
 	}
 
 	if($reltable != null)
@@ -2951,7 +3397,11 @@
 		return '';
 	}
 
-	$del_link = "index.php?module=$module&action=Delete&record=$entity_id";
+	if($current_module == 'Products' && $module == 'Products') {
+	    $del_link = "index.php?module=$module&action=DeleteProductProductRel&record=$entity_id";
+	} else {
+	    $del_link = "index.php?module=$module&action=Delete&record=$entity_id";
+	}
 
 	//This is added for relatedlist listview
 	if($relatedlist == 'relatedlist')

Modified: vtigercrm/branches/5.1_jens/include/utils/RecurringType.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/RecurringType.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/RecurringType.php Mon Apr 16 12:27:44 2007
@@ -44,8 +44,8 @@
 		);
 		$this->recur_type = $repeat_arr['type'];
 		$this->recur_freq = $repeat_arr['repeat_frequency'];
-		$this->startdate = new DateTime($start_date,true);
-		$this->enddate = new DateTime($end_date,true);
+		$this->startdate = new vt_DateTime($start_date,true);
+		$this->enddate = new vt_DateTime($end_date,true);
 		if($repeat_arr['sun_flag'])
 		{
 			$this->dayofweek_to_rpt[] = 0;
@@ -79,6 +79,7 @@
 			$this->rptmonth_datevalue = $repeat_arr['repeatmonth_date'];
 		$this->rptmonth_daytype = $repeat_arr['repeatmonth_daytype'];
 		$this->recurringdates = $this->getRecurringDates();
+		//echo '<pre>';print_r($this->recurringdates);echo '</pre>';die;	
 	}
 
 	/**
@@ -89,13 +90,13 @@
 	function getRecurringDates()
 	{
 		$startdate = $this->startdate->get_formatted_date();
+		$recurringDates[] = $startdate;
 		$tempdate = $startdate;
 		$enddate = $this->enddate->get_formatted_date();
 		while($tempdate <= $enddate)
 		{
 			if($this->recur_type == 'Daily')
 			{
-				$recurringDates[] = $tempdate;
 				$st_date = explode("-",$tempdate);
 				if(isset($this->recur_freq))
 					$index = $st_date[2] + $this->recur_freq - 1;
@@ -103,6 +104,7 @@
 					$index = $st_date[2];
 				$tempdateObj = $this->startdate->getThismonthDaysbyIndex($index,'',$st_date[1],$st_date[0]);
 				$tempdate = $tempdateObj->get_formatted_date();
+				$recurringDates[] = $tempdate;
 			}
 			elseif($this->recur_type == 'Weekly')
 			{
@@ -112,58 +114,28 @@
 					'month' => $st_date[1],
 					'year'  => $st_date[0]
 				);
-				$tempdateObj = new DateTime($date_arr,true);
-				if(isset($this->dayofweek_to_rpt) && $this->dayofweek_to_rpt != null)
-				{
-					$weekstartObj = $tempdateObj->getThisweekDaysbyIndex(0);
-					if($weekstartObj->get_formatted_date() >= $this->startdate->get_formatted_date())
-					{
-						for($i=0;$i<count($this->dayofweek_to_rpt);$i++)
-						{
-							$repeatdateObj = $weekstartObj->getThisweekDaysbyIndex($this->dayofweek_to_rpt[$i]);
-							if($repeatdateObj->get_formatted_date() <= $enddate)
-								$recurringDates[] = $repeatdateObj->get_formatted_date();
-						}
-						if(isset($this->recur_freq))
-							$index = $this->recur_freq * 7;
-						else
-						        $index = 7;
-						$date_arr = Array(
-							'day'   => $st_date[2] + $index,
-							'month' => $st_date[1],
-							'year'  => $st_date[0]
-						);
-						$tempdateObj = new DateTime($date_arr,true);
-					}
-					else
-					{
-						if(isset($this->recur_freq))
-							$index = $this->recur_freq * 7;
-						else
-							$index = 7;
-						$date_arr = Array(
-							'day'   => $st_date[2] + $index,
-							'month' => $st_date[1],
-							'year'  => $st_date[0]
-						);
-						$tempdateObj = new DateTime($date_arr,true);
-						
-					}
-				}
+				$tempdateObj = new vt_DateTime($date_arr,true);
+				if(count($this->dayofweek_to_rpt) == 0)
+					$this->dayofweek_to_rpt[] = $this->startdate->dayofweek;
+				for($i=0;$i<count($this->dayofweek_to_rpt);$i++)
+				{
+
+					$repeatDay = $tempdateObj->getThisweekDaysbyIndex($this->dayofweek_to_rpt[$i]);
+					$repeatDate= $repeatDay->get_formatted_date();
+					if($repeatDate > $startdate && $repeatDate <= $enddate)
+						$recurringDates[] = $repeatDate;
+				}
+
+				if(isset($this->recur_freq))
+					$index = $this->recur_freq * 7;
 				else
-				{
-					$recurringDates[] = $tempdateObj->get_formatted_date();
-					if(isset($this->recur_freq))
-						$index = $this->recur_freq * 7;
-					else
-						$index = 7;
-					$date_arr = Array(
-						'day'   => $st_date[2] + $index,
-						'month' => $st_date[1],
-						'year'  => $st_date[0]
-					);
-					$tempdateObj = new DateTime($date_arr,true);
-				}
+					$index = 7;
+				$date_arr = Array(
+					'day'   => $st_date[2] + $index,
+					'month' => $st_date[1],
+					'year'  => $st_date[0]
+				);
+				$tempdateObj = new vt_DateTime($date_arr,true);
 				$tempdate = $tempdateObj->get_formatted_date();
 			}
 			elseif($this->recur_type == 'Monthly')
@@ -174,7 +146,7 @@
 					'month' => $st_date[1],
 					'year'  => $st_date[0]
 				);
-				$startdateObj = new DateTime($date_arr,true);
+				$startdateObj = new vt_DateTime($date_arr,true);
 				if($this->repeat_monthby == 'date')
 				{
 					if($this->rptmonth_datevalue <= $st_date[2])
@@ -206,7 +178,7 @@
 						        'month' => $st_date[1],
 						 	'year'  => $st_date[0]
 					        );
-						$tempdateObj = new DateTime($date_arr,true);
+						$tempdateObj = new vt_DateTime($date_arr,true);
 						$firstdayofmonthObj = $this->getFistdayofmonth($this->dayofweek_to_rpt[0],$tempdateObj); 
 						if($firstdayofmonthObj->get_formatted_date() <= $tempdate)
 						{
@@ -231,7 +203,7 @@
 							'month' => $startdateObj->month,
 							'year'  => $startdateObj->year
 						);
-						$tempdateObj = new DateTime($date_arr,true);
+						$tempdateObj = new vt_DateTime($date_arr,true);
 						$lastdayofmonthObj = $this->getLastdayofmonth($this->dayofweek_to_rpt[0],$tempdateObj);
 						if($lastdayofmonthObj->get_formatted_date() <= $tempdate)
 						{
@@ -257,14 +229,13 @@
 						'month' => $st_date[1]+1,
 						'year'  => $st_date[0]
 					);
-					$tempdateObj = new DateTime($date_arr,true);
+					$tempdateObj = new vt_DateTime($date_arr,true);
 				}
 				$tempdate = $tempdateObj->get_formatted_date();
 				$recurringDates[] = $tempdate;
 			}
 			elseif($this->recur_type == 'Yearly')
 			{
-				$recurringDates[] = $tempdate;
 				$st_date = explode("-",$tempdate);
 				if(isset($this->recur_freq))
 					$index = $st_date[0] + $this->recur_freq;
@@ -280,8 +251,9 @@
 					'month' => $st_date[1],
 					'year'  => $index
 				);
-				$tempdateObj = new DateTime($date_arr,true);
+				$tempdateObj = new vt_DateTime($date_arr,true);
 				$tempdate = $tempdateObj->get_formatted_date();
+				$recurringDates[] = $tempdate;
 			}
 			else
 			{
@@ -293,8 +265,8 @@
 
 	/** Function to get first day of the month(like first Monday or Friday and etc.)
 	 *  @param $dayofweek   -- day of the week to repeat the event :: Type string
-	 *  @param $dateObj     -- date object  :: Type DateTime Object
-	 *  return $dateObj -- the date object on which the event repeats :: Type DateTime Object
+	 *  @param $dateObj     -- date object  :: Type vt_DateTime Object
+	 *  return $dateObj -- the date object on which the event repeats :: Type vt_DateTime Object
 	 */
 	function getFistdayofmonth($dayofweek,& $dateObj)
 	{
@@ -319,8 +291,8 @@
 
 	/** Function to get last day of the month(like last Monday or Friday and etc.)
          *  @param $dayofweek   -- day of the week to repeat the event :: Type string
-	 *  @param $dateObj     -- date object  :: Type DateTime Object
-	 *  return $dateObj -- the date object on which the event repeats :: Type DateTime Object
+	 *  @param $dateObj     -- date object  :: Type vt_DateTime Object
+	 *  return $dateObj -- the date object on which the event repeats :: Type vt_DateTime Object
          */
 					    
 	function getLastdayofmonth($dayofweek,& $dateObj)

Modified: vtigercrm/branches/5.1_jens/include/utils/SearchUtils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/SearchUtils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/SearchUtils.php Mon Apr 16 12:27:44 2007
@@ -16,8 +16,8 @@
 require_once('include/ComboUtil.php'); //new
 require_once('include/utils/CommonUtils.php'); //new
 	
-$column_array=array('accountid','contact_id','product_id','campaignid');
-$table_col_array=array('vtiger_account.accountname','vtiger_contactdetails.firstname,vtiger_contactdetails.lastname','vtiger_products.productname','vtiger_campaign.campaignname');
+$column_array=array('accountid','contact_id','product_id','campaignid','quoteid','vendorid','potentialid','salesorderid','vendor_id','contactid');
+$table_col_array=array('vtiger_account.accountname','vtiger_contactdetails.firstname,vtiger_contactdetails.lastname','vtiger_products.productname','vtiger_campaign.campaignname','vtiger_quotes.subject','vtiger_vendor.vendorname','vtiger_potential.potentialname','vtiger_salesorder.subject','vtiger_vendor.vendorname','vtiger_contactdetails.firstname,vtiger_contactdetails.lastname');
 
 /**This function is used to get the list view header values in a list view during search
 *Param $focus - module object
@@ -126,65 +126,13 @@
 
                 if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0 || in_array($fieldname,$field))
 		{
-                        if(isset($focus->sortby_fields) && $focus->sortby_fields !='')
-                        {
-                                //Added on 14-12-2005 to avoid if and else check for every list vtiger_field for arrow image and change order
-
-                                foreach($focus->list_fields[$name] as $tab=>$col)
-                                {
-                                        if(in_array($col,$focus->sortby_fields))
-                                        {
-                                                if($relatedlist !='')
-                                                {
-                                                        if($app_strings[$name])
-                                                        {
-                                                                $name = $app_strings[$name];
-                                                        }
-                                                        else
-                                                        {
-                                                                $name = $mod_strings[$name];
-                                                        }
-                                                }
-                                                else
-                                                {
-                                                        if($app_strings[$name])
-                                                        {
-                                                                $lbl_name = $app_strings[$name];
-                                                        }
-                                                        else
-                                                        {
-								 $lbl_name = $mod_strings[$name];
-                                                        }
-                                                        $name = $lbl_name;
-                                                }
-                                        }
-                                        else
-                                        {       if($app_strings[$name])
-                                                {
-                                                        $name = $app_strings[$name];
-                                                }
-                                                elseif($mod_strings[$name])
-                                                {
-                                                        $name = $mod_strings[$name];
-                                                }
-                                        }
-                                }
-                        }
-                        //Added condition to hide the close column in Related Lists
-                        //if($name == 'Close' && $relatedlist != '')
-                        if($name == 'Close')
-                        {
-                                //$list_header .= '';
-                                // $list_header[] = '';
-			}
-                        else
-                        {
-				if($fieldname!='parent_id')
-				{
-					$fld_name=$fieldname;
-                                	$search_header[$fld_name]=$name;
-				}
-                        }
+			if($fieldname!='parent_id')
+			{
+				$fld_name=$fieldname;
+
+				//assign the translated string
+				$search_header[$fld_name] = getTranslatedString($name);
+			}
                 }
         }
 	$log->debug("Exiting getSearchListHeaderValues method ...");	
@@ -199,7 +147,7 @@
 
 function Search($module)
 {
-	global $log;
+	global $log,$default_charset;
         $log->debug("Entering Search(".$module.") method ...");
 	$url_string='';	
 	if(isset($_REQUEST['search_field']) && $_REQUEST['search_field'] !="")
@@ -208,7 +156,16 @@
         }
         if(isset($_REQUEST['search_text']) && $_REQUEST['search_text']!="")
         {
-                $search_string=addslashes(ltrim(rtrim($_REQUEST['search_text'])));
+		// search other characters like "|, ?, ?" by jagi
+
+		$search_string = $_REQUEST['search_text'];
+		
+		$stringConvert = iconv("UTF-8",$default_charset,$search_string);
+
+		$search_string=addslashes(ltrim(rtrim($stringConvert)));
+
+		// $search_string=addslashes(ltrim(rtrim($_REQUEST['search_text'])));
+
         }
         if(isset($_REQUEST['searchtype']) && $_REQUEST['searchtype']!="")
         {
@@ -331,12 +288,11 @@
          $log->debug("Entering BasicSearch(".$module.",".$search_field.",".$search_string.") method ...");
 	global $adb;
 	global $column_array,$table_col_array;
-
 	if($search_field =='crmid')
 	{
 		$column_name='crmid';
 		$table_name='vtiger_crmentity';
-		$where="$table_name.$column_name like '%".$search_string."%'";	
+		$where="$table_name.$column_name like '%".$search_string."%'";
 	}else
 	{	
 		//Check added for tickets by accounts/contacts in dashboard
@@ -361,6 +317,7 @@
 				if ($search_field_first	== 'contactid') $search_field_first = 'contact_id';
 				$column_name = $search_field_first;
 			}
+				
 			//Check ends
 			$table_name=$adb->query_result($result,0,'tablename');
 			if($table_name == "vtiger_crmentity" && $column_name == "smownerid")
@@ -370,6 +327,13 @@
 			elseif($table_name == "vtiger_activity" && $column_name == "status")
 			{
 				$where="$table_name.$column_name like '%".$search_string."%' or vtiger_activity.eventstatus like '%".$search_string."%'";
+			}
+			elseif($table_name == "vtiger_activity" && $column_name == "sendnotification")
+			{
+				if(stristr($search_string,'yes'))
+					$where="$table_name.$column_name = 1";
+				if(stristr($search_string,'no'))
+					$where="$table_name.$column_name = 0";
 			}
 			elseif($table_name == "vtiger_pricebook" && $column_name == "active")
 			{
@@ -451,7 +415,12 @@
 		$block = $adb->query_result($result,$i,"block");
 		$fieldtype = explode("~",$fieldtype);
 		$fieldtypeofdata = $fieldtype[0];
-		$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
+		$fieldlabel = $mod_strings[$adb->query_result($result,$i,"fieldlabel")];
+
+		// Added to display customfield label in search options
+		if($fieldlabel == "")
+			$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
+					
 		if($fieldlabel == "Related To")
 		{
 			$fieldlabel = "Related to";
@@ -464,6 +433,13 @@
 
 		}
 		$fieldlabel1 = str_replace(" ","_",$fieldlabel);
+		//Check added to search the lists by Inventory manager
+                if($fieldtablename == 'vtiger_quotes' && $fieldcolname == 'inventorymanager')
+                {
+                        $fieldtablename = 'vtiger_usersQuotes';
+                        $fieldcolname = 'user_name';
+                }
+
 		if($fieldlabel != 'Related to')
 		{
 			if ($i==0)
@@ -495,9 +471,9 @@
 
 function getcriteria_options()
 {
-	global $log;
+	global $log,$app_strings;
 	$log->debug("Entering getcriteria_options() method ...");
-	$CRIT_OPT = "<option value=\'cts\'>contains</option><option value=\'dcts\'>does not contains</option><option value=\'is\'>is</option><option value=\'isn\'>is not</option><option value=\'bwt\'>begins with</option><option value=\'ewt\'>ends with</option><option value=\'grt\'>greater than</option><option value=\'lst\'>less than</option><option value=\'grteq\'>greater or equal</option><option value=\'lsteq\'>lesser or equal</option>";
+	$CRIT_OPT = "<option value=\'cts\'>".$app_strings['contains']."</option><option value=\'dcts\'>".$app_strings['does not contains']."</option><option value=\'is\'>".$app_strings['is']."</option><option value=\'isn\'>".$app_strings['is not']."</option><option value=\'bwt\'>".$app_strings['begins with']."</option><option value=\'ewt\'>".$app_strings['ends with']."</option><option value=\'grt\'>".$app_strings['greater than']."</option><option value=\'lst\'>".$app_strings['less than']."</option><option value=\'grteq\'>".$app_strings['greater or equal']."</option><option value=\'lsteq\'>".$app_strings['less or equal']."</option>";
 	$log->debug("Exiting getcriteria_options method ...");
 	return $CRIT_OPT;
 }
@@ -581,7 +557,7 @@
 
 function getWhereCondition($currentModule)
 {
-	global $log;
+	global $log,$default_charset;
 	global $column_array,$table_col_array;
 
         $log->debug("Entering getWhereCondition(".$currentModule.") method ...");
@@ -608,6 +584,7 @@
 			$tab_col = str_replace('\'','',stripslashes($_REQUEST[$table_colname]));
 			$srch_cond = str_replace('\'','',stripslashes($_REQUEST[$search_condition]));
 			$srch_val = $_REQUEST[$search_value];
+			$srch_val = iconv("UTF-8",$default_charset,$srch_val);
 			list($tab_name,$column_name) = split("[.]",$tab_col);
 			$url_string .="&Fields".$i."=".$tab_col."&Condition".$i."=".$srch_cond."&Srch_value".$i."=".$srch_val;
 			if($tab_col == "vtiger_crmentity.smownerid")
@@ -632,7 +609,13 @@
 				if(stristr($srch_val,'no'))
 					$adv_string .= " ".getSearch_criteria($srch_cond,NULL,'vtiger_pricebook.active')." ".$matchtype;	
 			}
-
+			elseif($tab_col == "vtiger_activity.sendnotification")
+			{
+				if(stristr($srch_val,'yes'))
+					$adv_string .= " ".getSearch_criteria($srch_cond,"1",'vtiger_activity.sendnotification')." ".$matchtype;
+				if(stristr($srch_val,'no'))
+					$adv_string .= " ".getSearch_criteria($srch_cond,"0",'vtiger_activity.sendnotification')." ".$matchtype;
+			}
 			elseif(in_array($column_name,$column_array))
                         {
                                 $adv_string .= getValuesforColumns($column_name,$srch_val)." ".$matchtype;
@@ -673,7 +656,6 @@
 	if (isset($_REQUEST['sales_stage'])) $sales_stage = $_REQUEST['sales_stage'];
 	if (isset($_REQUEST['closingdate_start'])) $date_closed_start = $_REQUEST['closingdate_start'];
 	if (isset($_REQUEST['closingdate_end'])) $date_closed_end = $_REQUEST['closingdate_end'];
-	if (isset($_REQUEST['assigned_user_id'])) $assigned_user_id = $_REQUEST['assigned_user_id'];
 	
 
 	if(isset($date_closed_start) && $date_closed_start != "" && isset($date_closed_end) && $date_closed_end != "")
@@ -693,10 +675,6 @@
 		array_push($where_clauses, "vtiger_potential.leadsource = ".$adb->quote($lead_source));
 		$url_string .= "&leadsource=".$lead_source;
 	}
-	if(isset($assigned_user_id) && $assigned_user_id != "") {
-	        array_push($where_clauses, "vtiger_crmentity.smownerid = ".$assigned_user_id);
-	        $url_string .= "&assigned_user_id=".$assigned_user_id;
-		}
 	if(isset($date_closed) && $date_closed != "") {
 		array_push($where_clauses, $adb->getDBDateString("vtiger_potential.closingdate")." like ".$adb->quote($date_closed.'%')."");
 		$url_string .= "&date_closed=".$date_closed;

Modified: vtigercrm/branches/5.1_jens/include/utils/UserInfoUtil.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/UserInfoUtil.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/UserInfoUtil.php Mon Apr 16 12:27:44 2007
@@ -613,7 +613,7 @@
 	$sql = "insert into vtiger_groups(name,description) values('" .$groupName ."','". $groupDescription ."')";
 	$result = $adb->query($sql); 
 	$log->debug("Exiting createNewGroup method ...");
-	header("Location: index.php?module=Users&action=listgroups");
+	header("Location: index.php?module=Settings&action=listgroups");
 	
 }
 
@@ -879,6 +879,58 @@
 	return $replacedString;
 }
 
+
+/** Function to add module group relation 
+  * @param $module -- module name:: Type varchar
+  * @param $groupname -- Group Name:: Type varchar
+  *
+ */
+ function insertIntoGroupRelation($module,$moduleid,$groupname)
+ {
+	 global $log;
+	 $log->debug("Entering insertIntoGroupRelation(".$module.",".$moduleid.",".$groupname.") method ...");
+	 global $adb;
+
+	 //Get the module grouptable name and the
+	require_once("modules/$module/$module.php");
+	$modObj = new $module();	 
+	 
+	 $sql = "insert into ".$modObj->groupTable[0]." values (" .$moduleid .",'".$groupname."')";
+	 
+	 $adb->query($sql);
+	 $log->debug("Exiting insert2LeadGroupRelation method ...");
+
+ }
+
+/** Function to update lead group relation
+  * @param $module -- module name:: Type varchar	
+  * @param $leadid -- Lead Id:: Type integer
+  * @param $groupname -- Group Name:: Type varchar
+  *
+ */
+function updateModuleGroupRelation($module,$moduleid,$groupname)
+{
+	global $log;
+	$log->debug("Entering updateModuleGroupRelation(".$moduleid.",".$groupname.") method ...");
+ 	global $adb;
+	
+	//Get the module grouptable name and the
+	require_once("modules/$module/$module.php");
+	$modObj = new $module();
+
+ 	//Deleting the existing entry	 
+  	$sqldelete = "delete from ".$modObj->groupTable[0]." where " .$modObj->groupTable[1] ."=".$moduleid;
+  	$adb->query($sqldelete);
+	if($groupname != ""){	
+	  	$sql = "insert into ".$modObj->groupTable[0]." values (".$moduleid .",'" .$groupname ."')";  
+	  	$adb->query($sql);
+	}	
+  	$log->debug("Exiting updateLeadGroupRelation method ...");
+
+}
+ 
+
+
 /** Function to add lead group relation 
   * @param $leadid -- Lead Id:: Type integer
   * @param $groupname -- Group Name:: Type varchar
@@ -1359,7 +1411,7 @@
         $sql1 = "select  description from vtiger_profile where profileid=".$profileid;
         $result = $adb->query($sql1);
         $profileDescription = $adb->query_result($result,0,"description");
-        $log->debug("Exiting getProfileName method ...");
+        $log->debug("Exiting getProfileDescription method ...");
         return $profileDescription;
 }
 
@@ -1491,7 +1543,8 @@
 	//If modules is Notes,Products,Vendors,Faq,PriceBook then no sharing			
 	if($record_id != '')
 	{
-		if($module == 'Notes' || $module == 'Products' || $module == 'Faq' || $module == 'Vendors'  || $module == 'PriceBooks')
+		//if($module == 'Notes' || $module == 'Products' || $module == 'Faq' || $module == 'Vendors'  || $module == 'PriceBooks')
+		if(getTabOwnedBy($module) == 1)
 		{
 			$permission = "yes";
 			$log->debug("Exiting isPermitted method ...");
@@ -3738,17 +3791,17 @@
 	if($entityType == 'groups')
 	{
 		$groupNameArr = getGroupInfo($entityid); 
-		$display_out = "<a href='index.php?module=Users&action=GroupDetailView&returnaction=OrgSharingDetailView&groupId=".$entityid."'>Group::". $groupNameArr[0]." </a>";			
+		$display_out = "<a href='index.php?module=Settings&action=GroupDetailView&returnaction=OrgSharingDetailView&groupId=".$entityid."'>Group::". $groupNameArr[0]." </a>";			
 	}
 	elseif($entityType == 'roles')
 	{
 		$roleName=getRoleName($entityid);	
-		$display_out = "<a href='index.php?module=Users&action=RoleDetailView&returnaction=OrgSharingDetailView&roleid=".$entityid."'>Role::".$roleName. "</a>";			
+		$display_out = "<a href='index.php?module=Settings&action=RoleDetailView&returnaction=OrgSharingDetailView&roleid=".$entityid."'>Role::".$roleName. "</a>";			
 	}
 	elseif($entityType == 'rs')
 	{
 		$roleName=getRoleName($entityid);	
-		$display_out = "<a href='index.php?module=Users&action=RoleDetailView&returnaction=OrgSharingDetailView&roleid=".$entityid."'>RoleAndSubordinate::".$roleName. "</a>";			
+		$display_out = "<a href='index.php?module=Settings&action=RoleDetailView&returnaction=OrgSharingDetailView&roleid=".$entityid."'>RoleAndSubordinate::".$roleName. "</a>";			
 	}
 	$log->debug("Exiting getEntityDisplayLink method ...");
 	return $display_out;
@@ -4528,45 +4581,9 @@
 	}	
 	else
 	{
-
-		//Current User	
-		$sec_query = " and (vtiger_crmentity.smownerid=".$current_user->id;
-
-		//Subordinate User
-		$subUsersList=getSubordinateUsersList();
-		if($subUsersList != '')
-		{
-			$sec_query .= " or vtiger_crmentity.smownerid in".$subUsersList;
-		}
-
-		//Shared User
-		$sharedUsersList=getReadSharingUsersList($module);
-		if($sharedUsersList != '')
-		{
-			$sec_query .= " or vtiger_crmentity.smownerid in".$sharedUsersList;
-		}
-
-
-		//Current User Groups
-		if($module == 'Leads' or $module=='HelpDesk' or $module=='Calendar')
-		{
-			$userGroupsList=getCurrentUserGroupList();
-			if($userGroupsList != '')
-			{
-				$sec_query .= " or (vtiger_crmentity.smownerid in(0) and vtiger_groups.groupid in".$userGroupsList.")";
-			}
-
-			//Shared User Groups
-			$sharedGroupsList=getReadSharingGroupsList($module);
-			if($sharedGroupsList != '')
-			{
-				$sec_query .= " or (vtiger_crmentity.smownerid in(0) and vtiger_groups.groupid in".$sharedGroupsList.")";
-			}	
-
-
-		}
-
-		$sec_query .=") ";
+		$mobObj = new $module;
+		$sec_query = $modObj->getListViewSecurityParameter($module);
+		
 	}
 	$log->debug("Exiting getListViewSecurityParameter method ...");
 	return $sec_query;	
@@ -4667,8 +4684,20 @@
 function getFieldModuleAccessArray()
 {
 	global $log;
+	global $adb;
 	$log->debug("Entering getFieldModuleAccessArray() method ...");
 
+	$fldModArr=Array();
+	$query = 'select distinct(name) from vtiger_profile2field inner join vtiger_tab on vtiger_tab.tabid=vtiger_profile2field.tabid where vtiger_tab.tabid != 10';
+	$result = $adb->query($query);
+	$num_rows=$adb->num_rows($result);
+	for($i=0;$i<$num_rows;$i++)
+	{
+		$fldModArr[$adb->query_result($result,$i,'name')]=$adb->query_result($result,$i,'name');
+	}	
+		
+
+	/*
 	$fldModArr=Array('Leads'=>'LBL_LEAD_FIELD_ACCESS',
                 'Accounts'=>'LBL_ACCOUNT_FIELD_ACCESS',
                 'Contacts'=>'LBL_CONTACT_FIELD_ACCESS',
@@ -4687,6 +4716,7 @@
                 'Campaigns'=>'LBL_CAMPAIGN_FIELD_ACCESS',
 		'Faq'=>'LBL_FAQ_FIELD_ACCESS'
               );
+	 */     
 
 	$log->debug("Exiting getFieldModuleAccessArray method ...");
 	return $fldModArr;

Modified: vtigercrm/branches/5.1_jens/include/utils/export.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/export.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/export.php Mon Apr 16 12:27:44 2007
@@ -32,7 +32,7 @@
 require_once('modules/Products/Products.php');
 require_once('include/utils/UserInfoUtil.php');
 
-global $allow_exports;
+global $allow_exports,$app_strings;
 
 session_start();
 
@@ -60,7 +60,7 @@
 
 ?>
 	<script language=javascript>
-		alert("you are not permitted to export!");
+		alert("<?php echo $app_strings['NOT_PERMITTED_TO_EXPORT']?>");
 		window.location="index.php?module=<?php echo $_REQUEST['module'] ?>&action=index";
 	</script>
 <?php
@@ -113,7 +113,6 @@
 
 	$query = $focus->create_export_query($order_by,$where);
 
-
 	$result = $adb->query($query,true,"Error exporting $type: "."<BR>$query");
 
 	$fields_array = $adb->getFieldsArray($result);
@@ -131,10 +130,11 @@
 
 		foreach ($val as $key => $value)
 		{
-			if($key=="description")
+			if($key=="description" || $key=="note")
 			{
 				$value=br2nl_vt($value);
 			}
+			$value = preg_replace("/(<\/?)(\w+)([^>]*>)/i","",$value);
 			array_push($new_arr, preg_replace("/\"/","\"\"",$value));
 		}
 		$line = implode("\",\"",$new_arr);

Modified: vtigercrm/branches/5.1_jens/include/utils/utils.php
==============================================================================
--- vtigercrm/branches/5.1_jens/include/utils/utils.php (original)
+++ vtigercrm/branches/5.1_jens/include/utils/utils.php Mon Apr 16 12:27:44 2007
@@ -867,7 +867,7 @@
         global $toHtml;
         if($encode && is_string($string)){//$string = htmlentities($string, ENT_QUOTES);
 		if (is_array($toHtml))
-			$string = str_replace(array_keys($toHtml), array_values($toHtml), $string);
+			$string =strip_tags($string, '<span><br /><div><a><br><b><u><i><table><td><tr><style><p><command><h1><h2><h3><h4><h5><h6><li><ol><ul><th><tbody><font><center><big><hr><format> <strong><html><small>');
         }
 	$log->debug("Exiting to_html method ...");
         return $string;
@@ -1185,6 +1185,12 @@
 		{
 			$query1="select vtiger_groups.groupid from vtiger_campaigngrouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_campaigngrouprelation.groupname where campaignid=".$record;
 		}
+		else
+		{
+			require_once("modules/$module/$module.php");
+			$modObj = new $module();
+			$query1="select vtiger_groups.groupid from vtiger_".$module."grouprelation inner join vtiger_groups on vtiger_groups.groupname = vtiger_".$module."grouprelation.groupname where ".$modObj->groupTable[1]."=".$record;
+		}
 
 		$result1=$adb->query($query1);
 		$groupid=$adb->query_result($result1,0,'groupid');
@@ -1209,7 +1215,7 @@
 
 	global $adb;
 	$adb->database->SetFetchMode(ADODB_FETCH_ASSOC); 
-	$fld_result = $adb->query("select * from vtiger_field where generatedtype=1 and displaytype in (1,2) and tabid != 29");
+	$fld_result = $adb->query("select * from vtiger_field where generatedtype=1 and displaytype in (1,2,3) and tabid != 29");
         $num_rows = $adb->num_rows($fld_result);
         for($i=0; $i<$num_rows; $i++)
         {
@@ -1229,7 +1235,7 @@
 	$log->debug("Entering insert_def_org_field() method ...");
 	global $adb;
 	$adb->database->SetFetchMode(ADODB_FETCH_ASSOC); 
-	$fld_result = $adb->query("select * from vtiger_field where generatedtype=1 and displaytype in (1,2) and tabid != 29");
+	$fld_result = $adb->query("select * from vtiger_field where generatedtype=1 and displaytype in (1,2,3) and tabid != 29");
         $num_rows = $adb->num_rows($fld_result);
         for($i=0; $i<$num_rows; $i++)
         {

Modified: vtigercrm/branches/5.1_jens/index.php
==============================================================================
--- vtigercrm/branches/5.1_jens/index.php (original)
+++ vtigercrm/branches/5.1_jens/index.php Mon Apr 16 12:27:44 2007
@@ -22,6 +22,7 @@
 global $entityDel;
 global $display;
 global $category;
+
 require_once('include/utils/utils.php');
 
 
@@ -277,10 +278,13 @@
 		ereg("^HeadLines",$action) ||
 		ereg("^TodoSave",$action) ||
 		ereg("^RecalculateSharingRules",$action) ||
-		(ereg("^body",$action) &&
-			ereg("^Webmails",$module)) ||
-			(ereg("^DetailView",$action) &&
-			ereg("^Webmails",$module) ))
+		(ereg("^body",$action) && ereg("^Webmails",$module)) ||
+		(ereg("^dlAttachments",$action) && ereg("^Webmails",$module)) ||
+		(ereg("^DetailView",$action) &&	ereg("^Webmails",$module) ) ||
+		ereg("^savewordtemplate",$action) ||
+		ereg("^mailmergedownloadfile",$action) || ereg("^Webmails",$module) && ereg("^get_img",$action) || ereg("^download",$action) )
+	
+		
 	{
 		$skipHeaders=true;
 		//skip headers for all these invocations as they are mostly popups
@@ -295,10 +299,13 @@
 			ereg("^".$module."Ajax",$action) ||
 			ereg("^chat",$action) ||
 			ereg("^vtchat",$action) ||
-			ereg("^massdelete", $action))
+			ereg("^massdelete", $action) ||
+			ereg("^mailmergedownloadfile",$action) || 	ereg("^get_img",$action) ||
+			ereg("^download",$action) ||
+			ereg("^massdelete", $action ))
 			$skipFooters=true;
 		//skip footers for all these invocations as they are mostly popups
-		if(ereg("^downloadfile", $action) || ereg("^fieldtypes",$action))
+		if(ereg("^downloadfile", $action) || ereg("^fieldtypes",$action) || ereg("^mailmergedownloadfile",$action)|| ereg("^get_img",$action))
 		{
 			$viewAttachment = true;
 		}
@@ -495,6 +502,9 @@
 		case 'Calendar':
 			require_once("modules/$currentModule/Activity.php");
 			$focus = new Activity();
+			break;
+		case 'Webmails':
+			//No need to create a webmail object here
 			break;
 		default:
 			require_once("modules/$currentModule/$currentModule.php");
@@ -698,8 +708,8 @@
 		echo "<script language = 'JavaScript' type='text/javascript' src = 'include/js/popup.js'></script>";
 		echo '<style type="text/css">@import url("themes/'.$theme.'/style.css"); </style>';
 		echo "<br><br><br><table border=0 cellspacing=0 cellpadding=5 width=100% class=settingsSelectedUI >";
-		echo "<tr><td class=small align=left>vtiger CRM 5.0.2 | Visit <a href='http://www.vtiger.com'>www.vtiger.com</a> for more information </td>";
-		echo "<td class=small align=right> &copy; <a href='javascript:mypopup()'>Copyright Details</a></td></tr></table>";
+		echo "<tr><td class=small align=left><span style='color: rgb(153, 153, 153);'>vtiger CRM 5.0.3</span></td>";
+		echo "<td class=small align=right><span style='color: rgb(153, 153, 153);'>&copy; 2004-2007 <a href='http://www.vtiger.com'>vtiger.com</a> | <a href='javascript:mypopup()'>".$app_strings['LNK_READ_LICENSE']."</a></span></td></tr></table>";
 			
 	//	echo "<table align='center'><tr><td align='center'>";
 		// Under the Sugar Public License referenced above, you are required to leave in all copyright statements

Modified: vtigercrm/branches/5.1_jens/install/0welcome.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/0welcome.php (original)
+++ vtigercrm/branches/5.1_jens/install/0welcome.php Mon Apr 16 12:27:44 2007
@@ -1,164 +1,166 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is: SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/0welcome.php,v 1.10 2004/08/26 11:44:30 saraj Exp $
- * Description:  Executes a step in the installation process.
- ********************************************************************************/
-
-//get php configuration settings.  requires elaborate parsing of phpinfo() output
-ob_start();
-phpinfo(INFO_GENERAL);
-$string = ob_get_contents();
-ob_end_clean();
-
-$pieces = explode("<h2", $string);
-$settings = array();
-foreach($pieces as $val)
-{
-   preg_match("/<a name=\"module_([^<>]*)\">/", $val, $sub_key);
-   preg_match_all("/<tr[^>]*>
-									   <td[^>]*>(.*)<\/td>
-									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub);
-   preg_match_all("/<tr[^>]*>
-									   <td[^>]*>(.*)<\/td>
-									   <td[^>]*>(.*)<\/td>
-									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub_ext);
-   foreach($sub[0] as $key => $val) {
-		if (preg_match("/Configuration File \(php.ini\) Path /", $val)) {
-	   		$val = preg_replace("/Configuration File \(php.ini\) Path /", '', $val);
-			$phpini = strip_tags($val);
-	   	}
-   }
-
-}
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-	<title>vtiger CRM 5 - Configuration Wizard - Welcome</title>
-	<link href="include/install/install.css" rel="stylesheet" type="text/css">
-</head>
-
-<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
-
-	<br><br><br>
-	<!-- Table for cfgwiz starts -->
-
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
-		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
-
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
-	<tr>
-		<td class="small" bgcolor="#4572BE" align=center>
-			<!-- Master display -->
-			<table border=0 cellspacing=0 cellpadding=0 width=97%>
-			<tr>
-				<td width=20% valign=top>
-
-				<!-- Left side tabs -->
-					<table border=0 cellspacing=0 cellpadding=10 width=100%>
-					<tr><td class="small cwSelectedTab" align=right><div align="left"><b>Welcome</b></div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Installation Check</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Config File Creation</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Database Generation</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Finish</div></td></tr>
-					</table>
-					
-				</td>
-				<td width=80% valign=top class="cwContentDisplay" align=left>
-				<!-- Right side tabs -->
-					<table border=0 cellspacing=0 cellpadding=10 width=100%>
-					<tr><td class=small align=left><img src="include/install/images/welcome.gif" alt="Welcome to Configuration Wizard" title="Welcome to Configuration Wizard"><br>
-					  <hr noshade size=1></td></tr>
-
-					<tr>
-						<td align=left class="small" style="padding-left:20px">
-		<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This Configuration Wizard will create vtiger CRM 5.0.2 databases and tables and configuration files you need to start. The entire process should take about four minutes. Click the Start button when you are ready. 
-<br><br>
-<p><span style="color:#555555">- vtiger CRM 5.0.2 is tested on mySQL 4.1.X, mySQL 5.0.19, PHP 5.0.19 and Apache 2.0.40.</p> 
-<p align="center"><font color='red'><b>vtiger CRM 5.0.2 will not work on mysql 4.0.x versions</b></font></center><center><font color='blue'><b>vtiger crm can run on a system which has xampp/lampp/wampp already installed in it provided it meets the above mentioned requirements</b></font></center>
-<p>The installation wizard will guide you with the installation regardless of the setup you may have.</span>
-						
-					  </td>
-					</tr>
-					<tr>
-					<td><span style="color:#999999">Please take a moment to register your copy of vtiger CRM. Though this is optional, we encourage you to register. Only your name and email address are required for registration. We do not sell, rent, share or otherwise, distribute your information to third parties.<br></span>
-		
-					</td>
-					</tr>
-					<tr>
-						<td align=center>
-						<IFRAME src="http://www.vtiger.com/products/crm/registration.html" width="500" height=250 scrolling='no' frameborder="0">
-						  [Your user agent does not support frames or is currently configured
-						  not to display frames. However, you may visit
-						  <A href="http://www.vtiger.com/products/crm/registration.html">the related document.</A>] 
-						 </IFRAME>
-				 		 </td>
-					</tr>
-					<tr>
-						<td align="center">
-							Please read the <a href="Copyright.txt" target="_BLANK">license agreement</a> and click the "Start" button to continue. 
-						</td>
-					</tr>		
-					<tr>
-						<td align=center>
-						<form action="install.php" method="post" name="installform" id="form">
-				                <input type="hidden" name="file" value="1checkSystem.php" />	
-						<input type="image" src="include/install/images/start.jpg" alt="Start" border="0" title="Start" style="cursor:pointer;" onClick="window.document.installform.submit();">
-						</form><br>
-					    <br></td>
-					</tr>
-					
-					
-				</table>
-			</td>
-		</tr>
-	</table>
-	<!-- Master display stops -->
-	<br>
-	</td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-
-		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
-	</tr>
-	</table>
-    	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-
-      	<tr>
-        	<td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
-      	</tr>
-    	</table>
-</body>
-</html>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is: SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/0welcome.php,v 1.10 2004/08/26 11:44:30 saraj Exp $
+ * Description:  Executes a step in the installation process.
+ ********************************************************************************/
+
+//get php configuration settings.  requires elaborate parsing of phpinfo() output
+ob_start();
+phpinfo(INFO_GENERAL);
+$string = ob_get_contents();
+ob_end_clean();
+
+$pieces = explode("<h2", $string);
+$settings = array();
+foreach($pieces as $val)
+{
+   preg_match("/<a name=\"module_([^<>]*)\">/", $val, $sub_key);
+   preg_match_all("/<tr[^>]*>
+									   <td[^>]*>(.*)<\/td>
+									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub);
+   preg_match_all("/<tr[^>]*>
+									   <td[^>]*>(.*)<\/td>
+									   <td[^>]*>(.*)<\/td>
+									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub_ext);
+   foreach($sub[0] as $key => $val) {
+		if (preg_match("/Configuration File \(php.ini\) Path /", $val)) {
+	   		$val = preg_replace("/Configuration File \(php.ini\) Path /", '', $val);
+			$phpini = strip_tags($val);
+	   	}
+   }
+
+}
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+	<title>vtiger CRM 5 - Configuration Wizard - Welcome</title>
+	<link href="include/install/install.css" rel="stylesheet" type="text/css">
+</head>
+
+<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
+
+	<br><br><br>
+	<!-- Table for cfgwiz starts -->
+
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
+		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
+
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
+	<tr>
+		<td class="small" bgcolor="#4572BE" align=center>
+			<!-- Master display -->
+			<table border=0 cellspacing=0 cellpadding=0 width=97%>
+			<tr>
+				<td width=20% valign=top>
+
+				<!-- Left side tabs -->
+					<table border=0 cellspacing=0 cellpadding=10 width=100%>
+					<tr><td class="small cwSelectedTab" align=right><div align="left"><b>Welcome</b></div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Installation Check</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Config File Creation</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Database Generation</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Finish</div></td></tr>
+					</table>
+					
+				</td>
+				<td width=80% valign=top class="cwContentDisplay" align=left>
+				<!-- Right side tabs -->
+					<table border=0 cellspacing=0 cellpadding=10 width=100%>
+					<tr><td class=small align=left><img src="include/install/images/welcome.gif" alt="Welcome to Configuration Wizard" title="Welcome to Configuration Wizard"><br>
+					  <hr noshade size=1></td></tr>
+
+					<tr>
+						<td align=left class="small" style="padding-left:20px">
+		<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This Configuration Wizard will create the requisite data needed to get working with vtiger CRM. The entire process should take about four minutes. Click the Start button when you are ready. 
+<br><br>
+<p><span style="color:#555555">- vtiger CRM 5.0.3 is tested on mySQL 4.1.X, mySQL 5.0.19, PHP 5.0.19 and Apache 2.0.40.</p> 
+<p align="center"><font color='red'><b>vtiger CRM 5.0.3 will not work on mysql 4.0.x versions and PHP 5.2.x versions</b></font></center></p></font></center><center>
+ 
+<font color='blue'><b>vtiger CRM can run on a system which has xampp/lampp/wampp already installed in it provided it meets the above mentioned requirements</b></font></center>
+<p>The installation wizard will guide you with the installation regardless of the setup you may have.</span>
+						
+					  </td>
+					</tr>
+					<tr>
+					<td><span style="color:#999999">Please take a moment to register your copy of vtiger CRM. Though this is optional, we encourage you to register. Only your name and email address are required for registration. We do not sell, rent, share or otherwise, distribute your information to third parties.<br></span>
+		
+					</td>
+					</tr>
+					<tr>
+						<td align=center>
+						<IFRAME src="http://www.vtiger.com/products/crm/registration.html" width="500" height=250 scrolling='no' frameborder="0">
+						  [Your user agent does not support frames or is currently configured
+						  not to display frames. However, you may visit
+						  <A href="http://www.vtiger.com/products/crm/registration.html">the related document.</A>] 
+						 </IFRAME>
+				 		 </td>
+					</tr>
+					<tr>
+						<td align="center">
+							Please read the <a href="Copyright.txt" target="_BLANK">license agreement</a> and click the "Start" button to continue. 
+						</td>
+					</tr>		
+					<tr>
+						<td align=center>
+						<form action="install.php" method="post" name="installform" id="form">
+				                <input type="hidden" name="file" value="1checkSystem.php" />	
+						<input type="image" src="include/install/images/start.jpg" alt="Start" border="0" title="Start" style="cursor:pointer;" onClick="window.document.installform.submit();">
+						</form><br>
+					    <br></td>
+					</tr>
+					
+					
+				</table>
+			</td>
+		</tr>
+	</table>
+	<!-- Master display stops -->
+	<br>
+	</td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+
+		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
+	</tr>
+	</table>
+    	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+
+      	<tr>
+        	<td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
+      	</tr>
+    	</table>
+</body>
+</html>

Modified: vtigercrm/branches/5.1_jens/install/1checkSystem.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/1checkSystem.php (original)
+++ vtigercrm/branches/5.1_jens/install/1checkSystem.php Mon Apr 16 12:27:44 2007
@@ -1,374 +1,380 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is: SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/1checkSystem.php,v 1.16 2005/03/08 12:01:36 samk Exp $
- * Description:  Executes a step in the installation process.
- ********************************************************************************/
-
-//get php configuration settings.  requires elaborate parsing of phpinfo() output
-?>
-<html>
-<?php
-
-
-ob_start();
-eval("phpinfo();");
-$info = ob_get_contents();
-ob_end_clean();
-
- foreach(explode("\n", $info) as $line) {
-           if(strpos($line, "Client API version")!==false)
-               $mysql_version = trim(str_replace("Client API version", "", strip_tags($line)));
- }
-
-
-
-
-
-
-
-
-
-ob_start();
-phpinfo(INFO_GENERAL);
-$string = ob_get_contents();
-ob_end_clean();
-
-$pieces = explode("<h2", $string);
-$settings = array();
-foreach($pieces as $val)
-{
-   preg_match("/<a name=\"module_([^<>]*)\">/", $val, $sub_key);
-   preg_match_all("/<tr[^>]*>
-									   <td[^>]*>(.*)<\/td>
-									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub);
-   preg_match_all("/<tr[^>]*>
-									   <td[^>]*>(.*)<\/td>
-									   <td[^>]*>(.*)<\/td>
-									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub_ext);
-   foreach($sub[0] as $key => $val) {
-		if (preg_match("/Configuration File \(php.ini\) Path /", $val)) {
-	   		$val = preg_replace("/Configuration File \(php.ini\) Path /", '', $val);
-			$phpini = strip_tags($val);
-	   	}
-   }
-
-}
-
-$gd_info_alternate = 'function gd_info() {
-$array = Array(
-                       "GD Version" => "",
-                       "FreeType Support" => 0,
-                       "FreeType Support" => 0,
-                       "FreeType Linkage" => "",
-                       "T1Lib Support" => 0,
-                       "GIF Read Support" => 0,
-                       "GIF Create Support" => 0,
-                       "JPG Support" => 0,
-                       "PNG Support" => 0,
-                       "WBMP Support" => 0,
-                       "XBM Support" => 0
-                     );
-       $gif_support = 0;
-
-       ob_start();
-       eval("phpinfo();");
-       $info = ob_get_contents();
-       ob_end_clean();
-
-       foreach(explode("\n", $info) as $line) {
-           if(strpos($line, "GD Version")!==false)
-               $array["GD Version"] = trim(str_replace("GD Version", "", strip_tags($line)));
-           if(strpos($line, "FreeType Support")!==false)
-               $array["FreeType Support"] = trim(str_replace("FreeType Support", "", strip_tags($line)));
-           if(strpos($line, "FreeType Linkage")!==false)
-               $array["FreeType Linkage"] = trim(str_replace("FreeType Linkage", "", strip_tags($line)));
-           if(strpos($line, "T1Lib Support")!==false)
-               $array["T1Lib Support"] = trim(str_replace("T1Lib Support", "", strip_tags($line)));
-           if(strpos($line, "GIF Read Support")!==false)
-               $array["GIF Read Support"] = trim(str_replace("GIF Read Support", "", strip_tags($line)));
-           if(strpos($line, "GIF Create Support")!==false)
-               $array["GIF Create Support"] = trim(str_replace("GIF Create Support", "", strip_tags($line)));
-           if(strpos($line, "GIF Support")!==false)
-               $gif_support = trim(str_replace("GIF Support", "", strip_tags($line)));
-           if(strpos($line, "JPG Support")!==false)
-               $array["JPG Support"] = trim(str_replace("JPG Support", "", strip_tags($line)));
-           if(strpos($line, "PNG Support")!==false)
-               $array["PNG Support"] = trim(str_replace("PNG Support", "", strip_tags($line)));
-           if(strpos($line, "WBMP Support")!==false)
-               $array["WBMP Support"] = trim(str_replace("WBMP Support", "", strip_tags($line)));
-           if(strpos($line, "XBM Support")!==false)
-               $array["XBM Support"] = trim(str_replace("XBM Support", "", strip_tags($line)));
-       }
-
-       if($gif_support==="enabled") {
-           $array["GIF Read Support"]  = 1;
-           $array["GIF Create Support"] = 1;
-       }
-
-       if($array["FreeType Support"]==="enabled"){
-           $array["FreeType Support"] = 1;    }
-
-       if($array["T1Lib Support"]==="enabled")
-           $array["T1Lib Support"] = 1;
-
-       if($array["GIF Read Support"]==="enabled"){
-           $array["GIF Read Support"] = 1;    }
-
-       if($array["GIF Create Support"]==="enabled")
-           $array["GIF Create Support"] = 1;
-
-       if($array["JPG Support"]==="enabled")
-           $array["JPG Support"] = 1;
-
-       if($array["PNG Support"]==="enabled")
-           $array["PNG Support"] = 1;
-
-       if($array["WBMP Support"]==="enabled")
-           $array["WBMP Support"] = 1;
-
-       if($array["XBM Support"]==="enabled")
-           $array["XBM Support"] = 1;
-
-       return $array;
-
-}';
-
-?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-	<title>vtiger CRM 5 - Configuration Wizard - Installation Check</title>
-	<link href="include/install/install.css" rel="stylesheet" type="text/css">
-</head>
-
-<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
-
-	<br><br><br>
-	<!-- Table for cfgwiz starts -->
-
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
-		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
-
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
-	<tr>
-		<td class="small" bgcolor="#4572BE" align=center>
-			<!-- Master display -->
-			<table border=0 cellspacing=0 cellpadding=0 width=97%>
-			<tr>
-				<td width=20% valign=top>
-
-				<!-- Left side tabs -->
-					<table border=0 cellspacing=0 cellpadding=10 width=100%>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Welcome</div></td></tr>
-					<tr><td class="small cwSelectedTab" align=right><div align="left"><b>Installation Check</b></div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Config File Creation</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Database Generation</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Finish</div></td></tr>
-					</table>
-					
-				</td>
-				<td width=80% valign=top class="cwContentDisplay" align=left>
-				<!-- Right side tabs -->
-				    <table border=0 cellspacing=0 cellpadding=10 width=100%>
-				    <tr><td class=small align=left><img src="include/install/images/confWizInstallCheck.gif" alt="Pre Installation Check" title="Pre Installation Check"><br>
-					  <hr noshade size=1></td></tr>
-				    <tr>
-					<td align=left class="small" style="padding-left:20px">
-	    				<table cellpadding="10" cellspacing="1" width="90%" border="0" class="small" style="background-color:#cccccc">
-					<tr bgcolor="#efefef"><td colspan=2><span style="color:#003399"><strong>Core Components</strong></span></td></tr>
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>PHP version</strong><BR></td>
-						<td  valign=top bgcolor="white"><?php $php_version = phpversion(); echo (str_replace(".", "", $php_version) < "430") ? "<strong><font color=\"#FF0000\">Failed.</strong><br> Invalid version ($php_version) Installed</font>" : "<strong><font color=\"#00CC00\">Passed</strong><br>Version $php_version Installed</font>"; ?></td>
-    					</tr>
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>IMAP Support Availability</strong></td>
-				        	<td valign=top bgcolor=white><?php echo function_exists('imap_open')?"<strong><font color=\"#00CC00\">Passed</strong><br>IMAP library available</font>":"<strong><font color=\"#FF0000\">Failed</strong><br>Not Available</font>";?></td>
-					</tr>
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>GD graphics library</strong><br> version 2.0 or later</td>
-						<td valign=top bgcolor="white"><?php
-						if (!extension_loaded('gd')) {
-							echo "<strong><font size=-1 color=\"#FF0000\">GD Graphics Library not configured. </strong>.<br>Check out our <a href='http://sourceforge.net/docman/?group_id=107819'>online documentation</a> for tips on enabling this library. You can ignore this error and continue your vtiger CRM installation, however the chart images simply won't work.</font>";
-						}
-						else {
-							if (!function_exists('gd_info'))
-							{
-								eval($gd_info_alternate);
-							}
-							$gd_info = gd_info();
-
-							if (isset($gd_info['GD Version'])) {
-								$gd_version = $gd_info['GD Version'];
-								$gd_version=preg_replace('%[^0-9.]%', '', $gd_version);
-
-								if ($gd_version > "2.0") {
-									echo "<strong><font color=\"#00CC00\">Passed</strong><br>Version $gd_version Installed</font>";
-								}
-								else {
-									echo "<strong><font color=\"#00CC00\">Passed</strong><br>Version $gd_version Installed.</font>";
-								}
-							}
-							else {
-								echo "<strong><font size=-1 color=\"#FF0000\">GD Library available, but not properly configured in your PHP installation</strong>.<br>You can ignore this error and continue your vtiger CRM installation, however the chart images simply won't work.</font>";
-							}
-						}
-						?>
-						</td>
-					</tr>
-					<tr bgcolor="#efefef"><td colspan=2><strong><span style="color:#003399">Read/Write Access</span></strong></td></tr>
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>PHP Configuration</strong><br>(config.inc.php)</strong></td>
-						<td valign=top bgcolor="white" ><?php echo (is_writable('./config.inc.php') || is_writable('.'))?"<strong><font color=\"#00CC00\">Writeable</font>":"<strong><font color=\"#FF0000\">Failed</strong><br>Not Writeable</font>"; ?></td>
-					</tr>
-		 			<tr bgcolor="#fafafa">
-						<td valign=top ><strong>Cache Directory </strong> <br>(cache/)</td>
-            					<td valign=top bgcolor="white" ><?php echo (is_writable('./cache/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</font></strong>"; ?></td>
-        				</tr>
-		 			
-					<tr bgcolor="#fafafa">
-		    				<td valign=top ><strong>Uploads Directory</strong><br> (storage/)</td>
-            					<td valign=top bgcolor="white"><?php echo (is_writable('./storage/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the file vtiger_attachments feature. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
-        				</tr>
-					<tr bgcolor="#fafafa">
-		    				<td valign=top ><strong>Install Directory</strong><br> (install/)</td>
-            					<td valign=top bgcolor="white"><?php echo (is_writable('./install/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the last step of installation.</font>"; ?></td>
-        				</tr>
-					<tr bgcolor="#fafafa">
-		    				<td valign=top ><strong>Installation file</strong><br> (install.php)</td>
-            					<td valign=top bgcolor="white"><?php echo (is_writable('./install.php'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the last step of installation.</font>"; ?></td>
-					</tr>
-					<tr bgcolor="#fafafa">
-				                <td valign=top ><strong>Tabdata File Permission </strong><br> (tabdata.php) </td>
-				                <td valign=top bgcolor="white"><?php echo (is_writable('./tabdata.php'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You will not be able to work with the product</font>";?></td>
-				        </tr>
-
-					<tr bgcolor="#fafafa">
-				                <td valign=top ><strong>ParentTabdata File Permission </strong><br> (parent_tabdata.php) </td>
-				                <td valign=top bgcolor="white"><?php echo (is_writable('./parent_tabdata.php'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You will not be able to work with the product</font>";?></td>
-				        </tr>
-
-					<tr bgcolor="#fafafa">
-           					<td valign=top ><strong>User Privileges</strong><br> (user_privileges/)</td>
-           					<td valign=top bgcolor="white"><?php echo (is_writable('./user_privileges/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong><br> You will not be able to login </font>"; ?></td>
-        				</tr>
-
-					
-					<tr bgcolor="#fafafa">
-                				<td valign=top ><strong>Smarty Cache Directory </strong><br> (Smarty/cache)</td>
-                				<td valign=top bgcolor="white"><?php echo (is_writable('./Smarty/cache/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong>";?></td>
-					</tr>
-					<tr bgcolor="#fafafa">
-				                <td valign=top ><strong>Smarty Compile Directory </strong><br> (Smarty/templates_c)</td>
-				                <td valign=top bgcolor="white"><?php echo (is_writable('./Smarty/templates_c/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You will not be able to login </font>";?></td>
-					</tr>
-
-					<tr bgcolor="#fafafa">
-		    				<td valign=top ><strong>Email Templates Directory</strong><br> (modules/Emails/templates/)</td>
-						<td valign=top bgcolor="white"><?php echo (is_writable('./modules/Emails/templates/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong><br> You might experience problems with the email templates feature. Refer <a href= http://www.vtiger.com/forums/viewtopic.php?t=388&highlight=permission>Email templates issue </a> for more details  </font>"; ?></td>
-					</tr>
-				
-					<tr bgcolor="#fafafa">
-		    				<td valign=top ><strong>Mail Merge Template Directory </strong><br>(test/wordtemplatedownload/)</td>
-            					<td valign=top bgcolor="white"><?php echo (is_writable('./test/wordtemplatedownload/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong><br> You might experience issues with the word template feature. Visit <a href=\"http://www.vtiger.com/discussions/viewtopic.php?p=2200#2200\" target=\"_blank\">forums</a> for more details </font>"; ?></td>
-        				</tr>
-				
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>Product Image Directory</strong><br> (test/product/)</td>
-						<td valign=top bgcolor="white"><?php echo (is_writable('./test/product/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Products.Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
-					</tr>
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>User Image Directory</strong><br> (test/user/)</td>
-						<td valign=top bgcolor="white"><?php echo (is_writable('./test/user/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Users. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
-					</tr>
-					<tr bgcolor="#fafafa">
-						<td valign=top ><strong>Contact Image Directory</strong><br> (test/contact/)</td>
-						<td valign=top bgcolor="white"><?php echo (is_writable('./test/contact/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Contacts. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
-					</tr>	
-					<tr bgcolor="#fafafa">
-		    				<td valign=top ><strong>Logo Directory</strong><br> (test/logo/)</td>
-					        <td valign=top bgcolor="white"><?php echo (is_writable('./test/logo/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the company logo in the pdf generation. Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File vtiger_attachments issue</a> for more details </font>"; ?></td>
-					</tr>
-					
-
-       				</table>
-				<br><br>
-	   	   		<!-- Recommended Settings -->
-				<table cellpadding="10" cellspacing="1" width="90%" border="0" class="small" style="background-color:#cccccc">
-				<tr bgcolor="#efefef"><td colspan=2><span style="color:#003399"><strong>Recommended Settings: We strongly suggest that you check for the following values in your php.ini file </strong></span></td></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>Safe Mode Off</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>Display Errors On</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>File Uploads On</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>Register Globals Off</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>Max Execution Time 600</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>output_buffering= On</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>Change the memory limit = 32M</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>error_reporting = E_WARNING & ~E_NOTICE</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>allow_call_time_reference = On</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>log_errors = Off</strong></tr>
-				<tr bgcolor="#ffffff"> <td valign=top ><strong>short_open_tag= On</strong></tr>
-				<tr bgcolor="#ffffff">  <td valign=top ><a href="http://www.vtiger.com/products/crm/help/vtiger_CRM_Linux_Dependencies.pdf" target="_blank">Linux installation pre-requisites</a></tr>
-				</table>
-			</td>
-			</tr>
-			<tr>
-				<td align=center>
-					<form action="install.php" method="post" name="installform" id="form">
-			                <input type="hidden" name="file" value="2setConfig.php" />	
-					<input type="image" src="include/install/images/cwBtnNext.gif" alt="Next" border="0" title="Next" onClick="window.document.installform.submit();">
-					</form><br>
-				    <br></td>
-			</tr>
-		</table>
-	</td>
-		</tr>
-	</table>
-	<!-- Master display stops -->
-	<br>
-	</td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-
-		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
-	</tr>
-	</table>	
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-
-      	<tr>
-        	<td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
-      	</tr>
-    	</table>
-</body>
-</html>	
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is: SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/1checkSystem.php,v 1.16 2005/03/08 12:01:36 samk Exp $
+ * Description:  Executes a step in the installation process.
+ ********************************************************************************/
+
+//get php configuration settings.  requires elaborate parsing of phpinfo() output
+?>
+<html>
+<?php
+
+
+ob_start();
+eval("phpinfo();");
+$info = ob_get_contents();
+ob_end_clean();
+
+ foreach(explode("\n", $info) as $line) {
+           if(strpos($line, "Client API version")!==false)
+               $mysql_version = trim(str_replace("Client API version", "", strip_tags($line)));
+ }
+
+
+
+
+
+
+
+
+
+ob_start();
+phpinfo(INFO_GENERAL);
+$string = ob_get_contents();
+ob_end_clean();
+
+$pieces = explode("<h2", $string);
+$settings = array();
+foreach($pieces as $val)
+{
+   preg_match("/<a name=\"module_([^<>]*)\">/", $val, $sub_key);
+   preg_match_all("/<tr[^>]*>
+									   <td[^>]*>(.*)<\/td>
+									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub);
+   preg_match_all("/<tr[^>]*>
+									   <td[^>]*>(.*)<\/td>
+									   <td[^>]*>(.*)<\/td>
+									   <td[^>]*>(.*)<\/td>/Ux", $val, $sub_ext);
+   foreach($sub[0] as $key => $val) {
+		if (preg_match("/Configuration File \(php.ini\) Path /", $val)) {
+	   		$val = preg_replace("/Configuration File \(php.ini\) Path /", '', $val);
+			$phpini = strip_tags($val);
+	   	}
+   }
+
+}
+
+$gd_info_alternate = 'function gd_info() {
+$array = Array(
+                       "GD Version" => "",
+                       "FreeType Support" => 0,
+                       "FreeType Support" => 0,
+                       "FreeType Linkage" => "",
+                       "T1Lib Support" => 0,
+                       "GIF Read Support" => 0,
+                       "GIF Create Support" => 0,
+                       "JPG Support" => 0,
+                       "PNG Support" => 0,
+                       "WBMP Support" => 0,
+                       "XBM Support" => 0
+                     );
+       $gif_support = 0;
+
+       ob_start();
+       eval("phpinfo();");
+       $info = ob_get_contents();
+       ob_end_clean();
+
+       foreach(explode("\n", $info) as $line) {
+           if(strpos($line, "GD Version")!==false)
+               $array["GD Version"] = trim(str_replace("GD Version", "", strip_tags($line)));
+           if(strpos($line, "FreeType Support")!==false)
+               $array["FreeType Support"] = trim(str_replace("FreeType Support", "", strip_tags($line)));
+           if(strpos($line, "FreeType Linkage")!==false)
+               $array["FreeType Linkage"] = trim(str_replace("FreeType Linkage", "", strip_tags($line)));
+           if(strpos($line, "T1Lib Support")!==false)
+               $array["T1Lib Support"] = trim(str_replace("T1Lib Support", "", strip_tags($line)));
+           if(strpos($line, "GIF Read Support")!==false)
+               $array["GIF Read Support"] = trim(str_replace("GIF Read Support", "", strip_tags($line)));
+           if(strpos($line, "GIF Create Support")!==false)
+               $array["GIF Create Support"] = trim(str_replace("GIF Create Support", "", strip_tags($line)));
+           if(strpos($line, "GIF Support")!==false)
+               $gif_support = trim(str_replace("GIF Support", "", strip_tags($line)));
+           if(strpos($line, "JPG Support")!==false)
+               $array["JPG Support"] = trim(str_replace("JPG Support", "", strip_tags($line)));
+           if(strpos($line, "PNG Support")!==false)
+               $array["PNG Support"] = trim(str_replace("PNG Support", "", strip_tags($line)));
+           if(strpos($line, "WBMP Support")!==false)
+               $array["WBMP Support"] = trim(str_replace("WBMP Support", "", strip_tags($line)));
+           if(strpos($line, "XBM Support")!==false)
+               $array["XBM Support"] = trim(str_replace("XBM Support", "", strip_tags($line)));
+       }
+
+       if($gif_support==="enabled") {
+           $array["GIF Read Support"]  = 1;
+           $array["GIF Create Support"] = 1;
+       }
+
+       if($array["FreeType Support"]==="enabled"){
+           $array["FreeType Support"] = 1;    }
+
+       if($array["T1Lib Support"]==="enabled")
+           $array["T1Lib Support"] = 1;
+
+       if($array["GIF Read Support"]==="enabled"){
+           $array["GIF Read Support"] = 1;    }
+
+       if($array["GIF Create Support"]==="enabled")
+           $array["GIF Create Support"] = 1;
+
+       if($array["JPG Support"]==="enabled")
+           $array["JPG Support"] = 1;
+
+       if($array["PNG Support"]==="enabled")
+           $array["PNG Support"] = 1;
+
+       if($array["WBMP Support"]==="enabled")
+           $array["WBMP Support"] = 1;
+
+       if($array["XBM Support"]==="enabled")
+           $array["XBM Support"] = 1;
+
+       return $array;
+
+}';
+
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+	<title>vtiger CRM 5 - Configuration Wizard - Installation Check</title>
+	<link href="include/install/install.css" rel="stylesheet" type="text/css">
+</head>
+
+<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
+
+	<br><br><br>
+	<!-- Table for cfgwiz starts -->
+
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
+		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
+
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
+	<tr>
+		<td class="small" bgcolor="#4572BE" align=center>
+			<!-- Master display -->
+			<table border=0 cellspacing=0 cellpadding=0 width=97%>
+			<tr>
+				<td width=20% valign=top>
+
+				<!-- Left side tabs -->
+					<table border=0 cellspacing=0 cellpadding=10 width=100%>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Welcome</div></td></tr>
+					<tr><td class="small cwSelectedTab" align=right><div align="left"><b>Installation Check</b></div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Config File Creation</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Database Generation</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Finish</div></td></tr>
+					</table>
+					
+				</td>
+				<td width=80% valign=top class="cwContentDisplay" align=left>
+				<!-- Right side tabs -->
+				    <table border=0 cellspacing=0 cellpadding=10 width=100%>
+				    <tr><td class=small align=left><img src="include/install/images/confWizInstallCheck.gif" alt="Pre Installation Check" title="Pre Installation Check"><br>
+					  <hr noshade size=1></td></tr>
+				    <tr>
+					<td align=left class="small" style="padding-left:20px">
+	    				<table cellpadding="10" cellspacing="1" width="90%" border="0" class="small" style="background-color:#cccccc">
+					<tr bgcolor="#efefef"><td colspan=2><span style="color:#003399"><strong>Core Components</strong></span></td></tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>PHP version</strong><BR></td>
+						<td  valign=top bgcolor="white"><?php $php_version = phpversion(); echo (str_replace(".", "", $php_version) < "430") ? "<strong><font color=\"#FF0000\">Failed.</strong><br> Invalid version ($php_version) Installed</font>" : "<strong><font color=\"#00CC00\">Passed</strong><br>Version $php_version Installed</font>"; ?></td>
+    					</tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>IMAP Support Availability</strong></td>
+				        	<td valign=top bgcolor=white><?php echo function_exists('imap_open')?"<strong><font color=\"#00CC00\">Passed</strong><br>IMAP library available</font>":"<strong><font color=\"#FF0000\">Failed</strong><br>Not Available</font>";?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>GD graphics library</strong><br> version 2.0 or later</td>
+						<td valign=top bgcolor="white"><?php
+						if (!extension_loaded('gd')) {
+							echo "<strong><font size=-1 color=\"#FF0000\">GD Graphics Library not configured. </strong>.<br>Check out our <a target=\"_blank\" href='http://sourceforge.net/docman/?group_id=107819'>online documentation</a> for tips on enabling this library. You can ignore this error and continue your vtiger CRM installation, however the chart images simply won't work.</font>";
+						}
+						else {
+							if (!function_exists('gd_info'))
+							{
+								eval($gd_info_alternate);
+							}
+							$gd_info = gd_info();
+
+							if (isset($gd_info['GD Version'])) {
+								$gd_version = $gd_info['GD Version'];
+								$gd_version=preg_replace('%[^0-9.]%', '', $gd_version);
+
+								if ($gd_version > "2.0") {
+									echo "<strong><font color=\"#00CC00\">Passed</strong><br>Version $gd_version Installed</font>";
+								}
+								else {
+									echo "<strong><font color=\"#00CC00\">Passed</strong><br>Version $gd_version Installed.</font>";
+								}
+							}
+							else {
+								echo "<strong><font size=-1 color=\"#FF0000\">GD Library available, but not properly configured in your PHP installation</strong>.<br>You can ignore this error and continue your vtiger CRM installation, however the chart images simply won't work.</font>";
+							}
+						}
+						?>
+						</td>
+					</tr>
+					<tr bgcolor="#efefef"><td colspan=2><strong><span style="color:#003399">Read/Write Access</span></strong></td></tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>PHP Configuration</strong><br>(config.inc.php)</strong></td>
+						<td valign=top bgcolor="white" ><?php echo (is_writable('./config.inc.php') || is_writable('.'))?"<strong><font color=\"#00CC00\">Writeable</font>":"<strong><font color=\"#FF0000\">Failed</strong><br>Not Writeable</font>"; ?></td>
+					</tr>
+		 			<tr bgcolor="#fafafa">
+						<td valign=top ><strong>Cache Directory </strong> <br>(cache/)</td>
+            					<td valign=top bgcolor="white" ><?php echo (is_writable('./cache/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</font></strong>"; ?></td>
+        				</tr>
+		 			
+					<tr bgcolor="#fafafa">
+		    				<td valign=top ><strong>Uploads Directory</strong><br> (storage/)</td>
+            					<td valign=top bgcolor="white"><?php echo (is_writable('./storage/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the file attachments feature. Refer <a target=\"_blank\"  href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+        				</tr>
+					<tr bgcolor="#fafafa">
+		    				<td valign=top ><strong>Install Directory</strong><br> (install/)</td>
+            					<td valign=top bgcolor="white"><?php echo (is_writable('./install/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the last step of installation.</font>"; ?></td>
+        				</tr>
+					<tr bgcolor="#fafafa">
+		    				<td valign=top ><strong>Installation file</strong><br> (install.php)</td>
+            					<td valign=top bgcolor="white"><?php echo (is_writable('./install.php'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the last step of installation.</font>"; ?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+				                <td valign=top ><strong>Tabdata File Permission </strong><br> (tabdata.php) </td>
+				                <td valign=top bgcolor="white"><?php echo (is_writable('./tabdata.php'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You will not be able to work with the product</font>";?></td>
+				        </tr>
+
+					<tr bgcolor="#fafafa">
+				                <td valign=top ><strong>ParentTabdata File Permission </strong><br> (parent_tabdata.php) </td>
+				                <td valign=top bgcolor="white"><?php echo (is_writable('./parent_tabdata.php'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You will not be able to work with the product</font>";?></td>
+				        </tr>
+
+					<tr bgcolor="#fafafa">
+           					<td valign=top ><strong>User Privileges</strong><br> (user_privileges/)</td>
+           					<td valign=top bgcolor="white"><?php echo (is_writable('./user_privileges/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong><br> You will not be able to login </font>"; ?></td>
+        				</tr>
+
+					
+					<tr bgcolor="#fafafa">
+                				<td valign=top ><strong>Smarty Cache Directory </strong><br> (Smarty/cache)</td>
+                				<td valign=top bgcolor="white"><?php echo (is_writable('./Smarty/cache/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong>";?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+				                <td valign=top ><strong>Smarty Compile Directory </strong><br> (Smarty/templates_c)</td>
+				                <td valign=top bgcolor="white"><?php echo (is_writable('./Smarty/templates_c/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You will not be able to login </font>";?></td>
+					</tr>
+
+					<tr bgcolor="#fafafa">
+		    				<td valign=top ><strong>Email Templates Directory</strong><br> (modules/Emails/templates/)</td>
+						<td valign=top bgcolor="white"><?php echo (is_writable('./modules/Emails/templates/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong><br> You might experience problems with the email templates feature. Refer <a target=\"_blank\" href= http://www.vtiger.com/forums/viewtopic.php?t=388&highlight=permission>Email templates issue </a> for more details  </font>"; ?></td>
+					</tr>
+				
+					<tr bgcolor="#fafafa">
+		    				<td valign=top ><strong>Mail Merge Template Directory </strong><br>(test/wordtemplatedownload/)</td>
+            					<td valign=top bgcolor="white"><?php echo (is_writable('./test/wordtemplatedownload/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong><br> You might experience issues with the word template feature. Visit <a href=\"http://www.vtiger.com/discussions/viewtopic.php?p=2200#2200\" target=\"_blank\">forums</a> for more details </font>"; ?></td>
+        				</tr>
+				
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>Product Image Directory</strong><br> (test/product/)</td>
+						<td valign=top bgcolor="white"><?php echo (is_writable('./test/product/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Products.Refer <a href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission target=\"_blank\">File attachments issue</a> for more details </font>"; ?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>User Image Directory</strong><br> (test/user/)</td>
+						<td valign=top bgcolor="white"><?php echo (is_writable('./test/user/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Users. Refer <a target=\"_blank\"  href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>Contact Image Directory</strong><br> (test/contact/)</td>
+						<td valign=top bgcolor="white"><?php echo (is_writable('./test/contact/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems while attaching image for Contacts. Refer <a target=\"_blank\" href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+					</tr>	
+					<tr bgcolor="#fafafa">
+		    				<td valign=top ><strong>Logo Directory</strong><br> (test/logo/)</td>
+					        <td valign=top bgcolor="white"><?php echo (is_writable('./test/logo/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>You might experience problems with the company logo in the pdf generation. Refer <a target=\"_blank\" href=http://www.vtiger.com/forums/viewtopic.php?t=24&highlight=permission>File attachments issue</a> for more details </font>"; ?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>Logs Directory</strong><br> (logs/)</td>
+						<td valign=top bgcolor="white"><?php echo (is_writable('./logs/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>System will experience problems while writing to the logs. You are strongly urged to give write permissions to the logs folder please!!!"; ?></td>
+					</tr>
+					<tr bgcolor="#fafafa">
+						<td valign=top ><strong>WebMail attachments Directory</strong><br> (modules/Webmails/tmp/)</td>
+						<td valign=top bgcolor="white"><?php echo (is_writable('./modules/Webmails/tmp/'))?"<strong><font color=\"#00CC00\">Writeable</font></strong>":"<strong><font color=\"#FF0000\">Not Writeable</strong> <br>System will experience problems in saving attachments in received mail. You are strongly urged to give write permissions to ./modules/Webmails/tmp/ folder please!!!"; ?></td>
+					</tr>
+       				</table>
+				<br><br>
+	   	   		<!-- Recommended Settings -->
+				<table cellpadding="10" cellspacing="1" width="90%" border="0" class="small" style="background-color:#cccccc">
+				<tr bgcolor="#efefef"><td colspan=2><span style="color:#003399"><strong>Recommended Settings: We strongly suggest that you check for the following values in your php.ini file </strong></span></td></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>Safe Mode Off</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>Display Errors On</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>File Uploads On</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>Register Globals Off</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>Max Execution Time 600</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>output_buffering= On</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>Change the memory limit = 32M</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>error_reporting = E_ALL & ~E_NOTICE</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>allow_call_time_reference = On</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>log_errors = Off</strong></tr>
+				<tr bgcolor="#ffffff"> <td valign=top ><strong>short_open_tag= On</strong></tr>
+				<tr bgcolor="#ffffff">  <td valign=top ><a href="http://www.vtiger.com/products/crm/help/vtiger_CRM_Linux_Dependencies.pdf" target="_blank">Linux installation pre-requisites</a></tr>
+				</table>
+			</td>
+			</tr>
+			<tr>
+				<td align=center>
+					<form action="install.php" method="post" name="installform" id="form">
+			                <input type="hidden" name="file" value="2setConfig.php" />	
+					<input type="image" src="include/install/images/cwBtnNext.gif" alt="Next" border="0" title="Next" onClick="window.document.installform.submit();">
+					</form><br>
+				    <br></td>
+			</tr>
+		</table>
+	</td>
+		</tr>
+	</table>
+	<!-- Master display stops -->
+	<br>
+	</td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+
+		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
+	</tr>
+	</table>	
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+
+      	<tr>
+        	<td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
+      	</tr>
+    	</table>
+</body>
+</html>	

Modified: vtigercrm/branches/5.1_jens/install/2setConfig.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/2setConfig.php (original)
+++ vtigercrm/branches/5.1_jens/install/2setConfig.php Mon Apr 16 12:27:44 2007
@@ -27,7 +27,9 @@
 // TODO: introduce Apache port as parameters to use non-default value 80
 //$web_root = $_SERVER['SERVER_NAME']. ":" .$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF'];
 //$web_root = $hostname.$_SERVER['PHP_SELF'];
-$web_root = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
+//$web_root = $HTTP_SERVER_VARS["HTTP_HOST"] . $HTTP_SERVER_VARS["REQUEST_URI"];
+$web_root = ($_ENV["HOSTNAME"]=='')? $HTTP_SERVER_VARS["HTTP_HOST"]:$_ENV["HOSTNAME"];
+$web_root .= $HTTP_SERVER_VARS["REQUEST_URI"];
 $web_root = str_replace("/install.php", "", $web_root);
 $web_root = "http://".$web_root;
 
@@ -99,7 +101,7 @@
 	elseif (isset($dbconfig['db_name']) && $dbconfig['db_name']!='_DBC_NAME_')
 	$db_name = $dbconfig['db_name'];
 	else
-	$db_name = 'vtigercrm502';
+	$db_name = 'vtigercrm503';
 
 	!isset($_REQUEST['db_drop_tables']) ? $db_drop_tables = "0" : $db_drop_tables = $_REQUEST['db_drop_tables'];
 	if (isset($_REQUEST['host_name'])) $host_name = $_REQUEST['host_name'];
@@ -145,7 +147,7 @@
 	}
 	else {
 		!isset($_REQUEST['db_hostname']) ? $db_hostname = $hostname: $db_hostname = $_REQUEST['db_hostname'];
-		!isset($_REQUEST['db_name']) ? $db_name = "vtigercrm502" : $db_name = $_REQUEST['db_name'];
+		!isset($_REQUEST['db_name']) ? $db_name = "vtigercrm503" : $db_name = $_REQUEST['db_name'];
 		!isset($_REQUEST['db_drop_tables']) ? $db_drop_tables = "0" : $db_drop_tables = $_REQUEST['db_drop_tables'];
 		!isset($_REQUEST['host_name']) ? $host_name= $hostname : $host_name= $_REQUEST['host_name'];
 		!isset($_REQUEST['site_URL']) ? $site_URL = $web_root : $site_URL = $_REQUEST['site_URL'];
@@ -281,11 +283,11 @@
 
 	// Here we decide whether to submit the form.
 	if (isError == true) {
-		alert("Missing required fields: " + errorMessage);
+		alert("Missing required fields:" + errorMessage);
 		return false;
 	}
 	if (trim(form.admin_email.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.admin_email.value)) {
-		alert("The email id '"+form.admin_email.value+"' in the email field is invalid");
+		alert("The email id \'"+form.admin_email.value+"\' in the email field is invalid");
 		form.admin_email.focus();
 		exit();
 	}
@@ -463,7 +465,10 @@
 		<!-- Currency Configuration -->
             <table width="90%" cellpadding="5" border="0" class="small" cellspacing="1" style="background-color:#cccccc">
 			<tr>
-				<td colspan=2><strong>Currency Configuration</strong></td>
+				<td colspan=2><strong>Currency
+		Configuration</strong></td> <i>This will setup the
+		default currency which will be used for maintaining
+		transactions in vtiger.</i> 
             </tr>
 			<tr>
 				<td nowrap width=25% bgcolor="#F5F5F5" ><strong>Name</strong><sup><font color=red>*</font></sup></td>

Modified: vtigercrm/branches/5.1_jens/install/3confirmConfig.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/3confirmConfig.php (original)
+++ vtigercrm/branches/5.1_jens/install/3confirmConfig.php Mon Apr 16 12:27:44 2007
@@ -184,7 +184,7 @@
 						<b><?php echo $error_msg ?></b>
 						</div>
 						<?php if($error_msg_info) : ?>
-							<p><? echo $error_msg_info ?><p>
+							<p><?php echo $error_msg_info ?><p>
 						<?php endif ?>
 					<?php endif ?>
 					<table width="90%" cellpadding="5" border="0" class="small" style="background-color:#cccccc" cellspacing="1">

Modified: vtigercrm/branches/5.1_jens/install/4createConfigFile.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/4createConfigFile.php (original)
+++ vtigercrm/branches/5.1_jens/install/4createConfigFile.php Mon Apr 16 12:27:44 2007
@@ -1,505 +1,500 @@
-<?php
-
-/*********************************************************************************
-
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
-
- * ("License"); You may not use this file except in compliance with the
-
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
-
- * Software distributed under the License is distributed on an  "AS IS"  basis,
-
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
-
- * the specific language governing rights and limitations under the License.
-
- * The Original Code is:  SugarCRM Open Source
-
- * The Initial Developer of the Original Code is SugarCRM, Inc.
-
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
-
- * All Rights Reserved.
-
- * Contributor(s): ______________________________________.
-
- ********************************************************************************/
-
-/*********************************************************************************
-
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/4createConfigFile.php,v 1.26 2005/04/25 05:40:50 samk Exp $
-
- * Description:  Executes a step in the installation process.
-
- ********************************************************************************/
-
-
-
-include('vtigerversion.php');
-
-
-session_start();
-
-
-
-// vtiger CRM version number; do not edit!
-
-$vtiger_version = "5.0.2";
-$release_date = "31 October 2006";
-
-
-if (isset($_REQUEST['db_type'])) $db_type = $_REQUEST['db_type'];
-
-if (isset($_REQUEST['db_hostname']))
-{
-	if(strpos($_REQUEST['db_hostname'], ":"))
-	{
-		list($db_hostname,$db_port) = split(":",$_REQUEST['db_hostname']);
-	}	
-	else
-	{
-		$db_hostname = $_REQUEST['db_hostname'];
-		if($db_type == "pgsql")
-		     $db_port = '5432';
-		else
-		     $db_port = '3306';
-	}	
-}
-if (isset($_REQUEST['db_username']))$db_username = $_REQUEST['db_username'];
-
-if (isset($_REQUEST['db_password']))$db_password = $_REQUEST['db_password'];
-
-if (isset($_REQUEST['db_name']))$db_name = $_REQUEST['db_name'];
-
-if (isset($_REQUEST['db_drop_tables'])) $db_drop_tables = $_REQUEST['db_drop_tables'];
-
-if (isset($_REQUEST['db_create'])) $db_create = $_REQUEST['db_create'];
-
-if (isset($_REQUEST['db_populate'])) $db_populate = $_REQUEST['db_populate'];
-
-if (isset($_REQUEST['site_URL'])) $site_URL = $_REQUEST['site_URL'];
- 
-if (isset($_REQUEST['admin_email'])) $admin_email = $_REQUEST['admin_email'];
-
-if (isset($_REQUEST['admin_password'])) $admin_password = $_REQUEST['admin_password'];
-
-if (isset($_REQUEST['currency_name'])) $currency_name = $_REQUEST['currency_name'];
-
-if (isset($_REQUEST['currency_code'])) $currency_code = $_REQUEST['currency_code'];
-
-if (isset($_REQUEST['currency_symbol'])) $currency_symbol = $_REQUEST['currency_symbol'];
-
-if (isset($_REQUEST['mail_server'])) $mail_server = $_REQUEST['mail_server'];
-
-if (isset($_REQUEST['mail_server_username'])) $mail_server_username = $_REQUEST['mail_server_username'];
-
-if (isset($_REQUEST['mail_server_password'])) $mail_server_password = $_REQUEST['mail_server_password'];
-
-if (isset($_REQUEST['ftpserver'])) $ftpserver = $_REQUEST['ftpserver'];
-
-if (isset($_REQUEST['ftpuser'])) $ftpuser = $_REQUEST['ftpuser'];
-
-if (isset($_REQUEST['ftppassword'])) $ftppassword = $_REQUEST['ftppassword'];
-
-// update default port
-if ($db_port == '')
-{
-	if($db_type == 'mysql')
-	{
-		$db_port = "3306";
-	}
-	elseif($db_type = 'pgsql')
-	{
-		$db_port = "5432";
-	}
-	elseif($db_type = 'oci8')
-	{
-		$db_port = '1521';
-	}
-}
-
-$cache_dir = 'cache/';
-
-
-?>
-	
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-	<title>vtiger CRM 5 - Configuration Wizard - Config File Creation</title>
-	<link href="include/install/install.css" rel="stylesheet" type="text/css">
-</head>
-
-<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
-
-<br><br>
-	<!-- Table for cfgwiz starts -->
-
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
-		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
-
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
-	<tr>
-		<td class="small" bgcolor="#4572BE" align=center>
-			<!-- Master display -->
-			<table border=0 cellspacing=0 cellpadding=0 width=97%>
-			<tr>
-				<td width=20% valign=top>
-
-				<!-- Left side tabs -->
-					<table border=0 cellspacing=0 cellpadding=10 width=100%>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Welcome</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Installation Check</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
-					<tr><td class="small cwSelectedTab" id="configfile_tab" align=right><div align="left"><b>Config File Creation</b></div></td></tr>
-					<tr><td class="small cwUnSelectedTab" id="dbcreate_tab" align=right><div align="left">Database Generation</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Finish</div></td></tr>
-					</table>
-					
-				</td>
-				<td width=80% valign=top class="cwContentDisplay" align=left>
-				<table border=0 cellspacing=0 cellpadding=10 width=100%>
-				<tr><td class=small align=left><img id="title_img" src="include/install/images/confWizConfFile.gif" alt="Config File Creation" title="Config File Creation"><img id="title_img1" src="include/install/images/confWizDbGeneration.gif" style="display:none;" alt="Database Generation" title="Database Generation"><br>
-					  <hr noshade size=1></td></tr>
-				<tr>
-					<td align=left class="small" style="padding-left:20px">
-					<?php
-					if (isset($_REQUEST['root_directory']))
-						$root_directory = $_REQUEST['root_directory'];
-		
-					if (is_file('config.inc.php'))
-					    	$is_writable = is_writable('config.inc.php');
-					else
-	      					$is_writable = is_writable('.');
-
-	      				/* open template configuration file read only */
-	      				$templateFilename = 'config.template.php';
-	      				$templateHandle = fopen($templateFilename, "r");
-	      				if($templateHandle) {
-		      				/* open include configuration file write only */
-		      				$includeFilename = 'config.inc.php';
-					      	$includeHandle = fopen($includeFilename, "w");
-		      				if($includeHandle) {
-			      			   while (!feof($templateHandle)) {
-				      			$buffer = fgets($templateHandle);
-
-				     			/* replace _DBC_ variable */
-				      			$buffer = str_replace( "_DBC_SERVER_", $db_hostname, $buffer);
-				      			$buffer = str_replace( "_DBC_PORT_", $db_port, $buffer);
-				      			$buffer = str_replace( "_DBC_USER_", $db_username, $buffer);
-				      			$buffer = str_replace( "_DBC_PASS_", $db_password, $buffer);
-				      			$buffer = str_replace( "_DBC_NAME_", $db_name, $buffer);
-				      			$buffer = str_replace( "_DBC_TYPE_", $db_type, $buffer);
-
-				      			$buffer = str_replace( "_SITE_URL_", $site_URL, $buffer);
-
-				      			/* replace dir variable */
-				      			$buffer = str_replace( "_VT_ROOTDIR_", $root_directory, $buffer);
-				      			$buffer = str_replace( "_VT_CACHEDIR_", $cache_dir, $buffer);
-				      			$buffer = str_replace( "_VT_TMPDIR_", $cache_dir."images/", $buffer);
-				      			$buffer = str_replace( "_VT_UPLOADDIR_", $cache_dir."upload/", $buffer);
-				      			/* replace mail variable */
-				      			$buffer = str_replace( "_MAIL_SERVER_", $mail_server, $buffer);
-				      			$buffer = str_replace( "_MAIL_USERNAME_", $mail_server_username, $buffer);
-						      	$buffer = str_replace( "_MAIL_PASSWORD_", $mail_server_password, $buffer);
-						      	$buffer = str_replace( "_DB_STAT_", "true", $buffer);
-				
-						      	/* replace the application unique key variable */
-				      			$buffer = str_replace( "_MASTER_CURRENCY_", $currency_name, $buffer);
-
-						      	/* replace the application unique key variable */
-					      		$buffer = str_replace( "_VT_APP_UNIQKEY_", md5($root_directory), $buffer);
-	
-					      		fwrite($includeHandle, $buffer);
-					      		}
-
-				      		fclose($includeHandle);
-				      		}
-
-				      	fclose($templateHandle);
-				      	}
-  
-	if ($templateHandle && $includeHandle) {?>
-			<div id="config_info">
-			<p><strong class="big">Successfully created configuration file (config.inc.php) in :</strong><br><br>
-			<font color="green"><b><?php echo $root_directory; ?></b></font><br><br>
-			The installation will take at least 4 minutes. Grab a coffee,sit back and relax...<br>
-			</p>
-			</div>
-			<br>		
-	<?php } 
-	else {?>
-			<div id="config_info"><p><strong class="big"><font color="red">Cannot write configuration file (config.inc.php ) in : </font></strong><br><br>
-			<font color="green"><b><?php echo $root_directory; ?></b></font><br><br>
-			<P>You can continue this installation by manually creating the config.inc.php file and pasting the configuration information below inside.However, you <strong>must</strong> create the configuration file before you continue to the next step.<P><br><br>
-	<?php			
-	$config = "<?php \n";
- 	$config .= "/*********************************************************************************\n";
- 	$config .= " * The contents of this file are subject to the SugarCRM Public License Version 1.1.2\n";
- 	$config .= " * (\"License\"); You may not use this file except in compliance with the \n";
- 	$config .= " * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL\n";
- 	$config .= " * Software distributed under the License is distributed on an  \"AS IS\"  basis,\n";
- 	$config .= " * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for\n";
- 	$config .= " * the specific language governing rights and limitations under the License.\n";
- 	$config .= " * The Original Code is:  SugarCRM Open Source\n";
- 	$config .= " * The Initial Developer of the Original Code is SugarCRM, Inc.\n";
- 	$config .= " * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;\n";
- 	$config .= " * All Rights Reserved.\n";
- 	$config .= " * Contributor(s): ______________________________________.\n";
- 	$config .= "********************************************************************************/\n\n";
- 	$config .= "include('vtigerversion.php');\n\n";
- 	$config .= "// more than 8MB memory needed for graphics\n\n";
- 	$config .= "// memory limit default value = 16M\n\n";
- 	$config .= "ini_set('memory_limit','16M');\n\n";
- 	$config .= "// show or hide world clock, calculator and FCKEditor\n\n";
- 	$config .= "// world_clock_display default value = true\n";
- 	$config .= "// calculator_display default value = true\n";
- 	$config .= "// fckeditor_display default value = true\n\n";
- 	$config .= "\$WORLD_CLOCK_DISPLAY = 'true';\n";
- 	$config .= "\$CALCULATOR_DISPLAY = 'true';\n";
- 	$config .= "\$FCKEDITOR_DISPLAY = 'true';\n\n";
- 	
- 	$config .= "//This is the URL for customer portal. (Ex. http://vtiger.com/portal)\n";
- 	$config .= "\$PORTAL_URL = 'http://yourdomain.com/customerportal';\n\n";
- 	$config .= "//These two are the HelpDesk support email id and the support name. ";
- 	$config .= "(Ex. 'support at vtiger.com' and 'vtiger Support')\n";
- 	$config .= "\$HELPDESK_SUPPORT_EMAIL_ID = 'support at yourdomain.com';\n";
- 	$config .= "\$HELPDESK_SUPPORT_NAME = 'yourdomain Name';\n\n";
- 	
- 	$config .= "/* Database configuration\n";
- 	$config .= "      db_host_name:     MySQL Database Hostname\n";
- 	$config .= "      db_user_name:        MySQL Username\n";
- 	$config .= "      db_password:         MySQL Password\n";
- 	$config .= "      db_name:             MySQL Database Name\n*/\n";
- 	$config .= "\$dbconfig['db_server'] =     '".$db_hostname."';\n";
- 	$config .= "\$dbconfig['db_port'] =     '".$db_port."';\n";
- 	$config .= "\$dbconfig['db_username'] =     '".$db_username."';\n";
- 	$config .= "\$dbconfig['db_password'] =         '".$db_password."';\n";
- 	$config .= "\$dbconfig['db_name'] =             '".$db_name."';\n";
- 	$config .= "\$dbconfig['db_type'] = '".$db_type."';\n";
-	$config .= "\$dbconfig['db_status'] = 'true';\n";
-
-	$config .= "// TODO: test if port is empty\n";
-	$config .= "// TODO: set db_hostname dependending on db_type\n";
- 	$config .= "\$dbconfig['db_hostname'] = \$dbconfig['db_server'].\$dbconfig['db_port'];\n\n";
-
-	
-	$config .= "// log_sql default value = false\n";
-	$config .= "\$dbconfig['log_sql'] = false;\n\n";
-	
-	$config .= "// persistent default value = true\n";
-	$config .= "\$dbconfigoption['persistent'] = true;\n\n";
-
-	$config .= "// autofree default value = false\n";
-	$config .= "\$dbconfigoption['autofree'] = false;\n\n";
-	
-	$config .= "// debug default value = 0\n";
-	$config .= "\$dbconfigoption['debug'] = 0;\n\n";
-
-	$config .= "// seqname_format default value = '%s_seq'\n";
-	$config .= "\$dbconfigoption['seqname_format'] = '%s_seq';\n\n";
-
-	$config .= "// portability default value = 0\n";
-	$config .= "\$dbconfigoption['portability'] = 0;\n\n";
-
-	$config .= "// ssl default value = false\n";
-	$config .= "\$dbconfigoption['ssl'] = false;\n\n";
-
-	$config .= "\$host_name = \$dbconfig['db_hostname'];\n\n";
-	
-	$config .= "\$site_URL ='$site_URL';\n\n";
-
-	$config .= "// root directory path\n";
-	$config .= "\$root_directory = '$root_directory';\n\n";
-
-	$config .= "// cache direcory path\n";
-	$config .= "\$cache_dir = '$cache_dir';\n\n";
-
-	$config .= "// tmp_dir default value prepended by cache_dir = images/\n";
-	$config .= "\$tmp_dir = '$cache_dir"."images/';\n\n";
-
-	$config .= "// import_dir default value prepended by cache_dir = import/\n";
-	$config .= "\$tmp_dir = '$cache_dir"."import/';\n\n";
-
-	$config .= "// upload_dir default value prepended by cache_dir = upload/\n";
-	$config .= "\$tmp_dir = '$cache_dir"."upload/';\n\n";
-
-	$config .= "// mail server parameters\n";
-	$config .= "\$mail_server = '$mail_server';\n";
-	$config .= "\$mail_server_username = '$mail_server_username';\n";
-	$config .= "\$mail_server_password = '$mail_server_password';\n\n";
-	
-	$config .= "// maximum file size for uploaded files in bytes also used when uploading import files\n";
-	$config .= "// upload_maxsize default value = 3000000\n";
-	$config .= "\$upload_maxsize = 3000000;\n\n";
-
-	$config .= "// flag to allow export functionality\n";
-	$config .= "// 'all' to allow anyone to use exports \n";
-	$config .= "// 'admin' to only allow admins to export\n";
-	$config .= "// 'none' to block exports completely\n";
-	$config .= "// allow_exports default value = all\n";
-	$config .= "\$allow_exports = 'all';\n\n";
-
- 	$config .= "// Files with one of these extensions will have '.txt' appended to their filename on upload\n";
-	$config .= "// upload_badext default value = php, php3, php4, php5, pl, cgi, py, asp, cfm, js, vbs, html, htm\n";
- 	$config .= "\$upload_badext = array('php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', 'asp', 'cfm', 'js', 'vbs', 'html', 'htm');\n\n";
-
- 	$config .= "// This is the full path to the include directory including the trailing slash\n";
-	$config .= "// includeDirectory default value = $root_directory..'include/\n";
- 	$config .= "\$includeDirectory = \$root_directory.'include/';\n\n";
-	
-	$config .= "// list_max_entries_per_page default value = 20\n";
-	$config .= "\$list_max_entries_per_page = '20';\n\n";
-
- 	$config .= "// change this number to whatever you want. This is the number of pages that will appear in the pagination. by Raju \n";
- 	$config .= "\$limitpage_navigation = '9';\n\n";
-	
-	$config .= "// history_max_viewed default value = 5\n";
- 	$config .= "\$history_max_viewed = '5';\n\n";
- 	
- 	$config .= "// Map Sugar language codes to jscalendar language codes\n";
- 	$config .= "// Unimplemented until jscalendar language files are fixed\n";
- 	$config .= "// \$cal_codes = array('en_us'=>'en', 'ja'=>'jp', 'sp_ve'=>'sp', 'it_it'=>'it', 'tw_zh'=>'zh', 'pt_br'=>'pt', 'se'=>'sv', 'cn_zh'=>'zh', 'ge_ge'=>'de', 'ge_ch'=>'de', 'fr'=>'fr');\n\n";
-
-	$config .= "//set default module and action\n";
- 	$config .= "\$default_module = 'Home';\n";
- 	$config .= "\$default_action = 'index';\n\n";
-
- 	$config .= "//set default theme\n";
- 	$config .= "\$default_theme = 'bluelagoon';\n\n";
-
- 	$config .= "// If true, the time to compose each page is placed in the browser.\n";
- 	$config .= "\$calculate_response_time = true;\n";
-
- 	$config .= "// Default Username - The default text that is placed initially in the login form for user name.\n";
- 	$config .= "\$default_user_name = '';\n";
-	
- 	$config .= "// Default Password - The default text that is placed initially in the login form for password.\n";
- 	$config .= "\$default_password = '';\n";
-
- 	$config .= "// Create default user - If true, a user with the default username and password is created.\n";
- 	$config .= "\$create_default_user = false;\n";
- 	$config .= "\$default_user_is_admin = false;\n";
-
- 	$config .= "// disable persistent connections - If your MySQL/PHP configuration does not support persistent connections set this to true to avoid a large performance slowdown\n";
- 	$config .= "\$disable_persistent_connections = false;\n";
- 	$config .= "// Defined languages available.  The key must be the language file prefix.  E.g. 'en_us' is the prefix for every 'en_us.lang.php' file. \n";
- 	
- 	$language_value = "Array('en_us'=>'US English',)";
- 	if(isset($_SESSION['language_keys']) && isset($_SESSION['language_values']))
- 	{
- 	    $language_value = 'Array(';
- 	    $language_keys = explode(',', urldecode($_SESSION['language_keys']));
- 	    $language_values = explode(',', urldecode($_SESSION['language_values']));
- 	    $size = count($language_keys);
- 	    for($i = 0; $i < $size; $i+=1)
- 	    {
- 	        $language_value .= "'$language_keys[$i]'=>'$language_values[$i]',";
- 	    }
- 	    $language_value .= ')';
- 	}
- 	$config .= "\$languages = $language_value;\n";
-	$config .= "// Master currency name\n";
- 	$config .= "\$currency_name = '$currency_name';\n";
- 	$config .= "// Default charset if the language specific character set is not found.\n";
- 	$config .= "\$default_charset = 'ISO-8859-1';\n";
- 	$config .= "// Default language in case all or part of the user's language pack is not available.\n";
- 	$config .= "\$default_language = 'en_us';\n";
- 	$config .= "// Translation String Prefix - This will add the language pack name to every translation string in the display.\n";
- 	$config .= "\$translation_string_prefix = false;\n";
- 	
- 	$config .= "//Option to cache tabs permissions for speed.\n";
- 	$config .= "\$cache_tab_perms = true;\n\n";
- 	
- 	$config .= "//Option to hide empty home blocks if no entries.\n";
- 	$config .= "\$display_empty_home_blocks = false;\n\n";
-
- 	$config .= "// Generating Unique Application Key\n";
- 	$config .= "\$application_unique_key = '".md5($root_directory)."';\n\n";
- 	$config .= "?>";
-		
-			echo "<TEXTAREA class=\"dataInput\" rows=\"15\" cols=\"80\">".$config."</TEXTAREA><br><br>";
-			echo "<P>Did you remember to create the config.inc.php file ?</p>";
-	
-				  
-		}	?>
-				</div></td>
-				</tr>
-				<tr><td align="center"><img id="populating_info" src="include/install/images/loading.gif" style="visibility:hidden;"></td></tr>
-				<tr>
-				<td align=right style="height:60px;">
-				 <form action="install.php" method="post" name="form" id="form">
-				 <!--<form action="install.php" method="post" name="form" id="form"> -->
-				 <input type="hidden" name="file" value="5createTables.php">
-				 <input type="hidden" class="dataInput" name="db_hostname" value="<?php if (isset($db_hostname)) echo "$db_hostname"; ?>" />
-				 <input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
-				 <input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
-				 <input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
-				 <input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
-				 <input type="hidden" class="dataInput" name="db_create" value="<?php if (isset($db_create)) echo "$db_create"; ?>" />
-				 <input type="hidden" class="dataInput" name="db_populate" value="<?php if (isset($db_populate)) echo "$db_populate"; ?>" />
-				 <input type="hidden" class="dataInput" name="admin_email" value="<?php if (isset($admin_email)) echo "$admin_email"; ?>" />
-				 <input type="hidden" class="dataInput" name="admin_password" value="<?php if (isset($admin_password)) echo "$admin_password"; ?>" />
-				 <input type="hidden" class="dataInput" name="currency_name" value="<?php if (isset($currency_name)) echo "$currency_name"; ?>" />
-				 <input type="hidden" class="dataInput" name="currency_code" value="<?php if (isset($currency_code)) echo "$currency_code"; ?>" />
-				 <input type="hidden" class="dataInput" name="currency_symbol" value="<?php if (isset($currency_symbol)) echo "$currency_symbol"; ?>" />
-				 <input  type="image" name="next" value="Next" id="next_btn" src="include/install/images/cwBtnNext.gif" onClick="window.location=('install.php');createtablejs();" />
-				 </form>
-					
-				</td>
-			</tr>
-
-			</table>
-		</td>
-	</tr>
-	</table>
-	<!-- Master display stops -->
-	<br>
-	</td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-
-		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-
-      	<tr>
-        	<td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
-      	</tr>
-    	</table>	
-	<script>
-	function createtablejs()
-	{
-		document.getElementById('dbcreate_tab').innerHTML = '<div align="left"><b>Database Generation</b></div>';
-		document.getElementById('configfile_tab').className = 'small cwUnSelectedTab';
-		document.getElementById('configfile_tab').innerHTML = '<div align="left">Config File Creation</div>';
-		document.getElementById('dbcreate_tab').className = 'small cwSelectedTab';
-		oImg = document.getElementById('title_img').style.display = 'none';
-		oImg = document.getElementById('title_img1').style.display = 'block';
-		document.getElementById('populating_info').style.visibility='visible';
-		document.getElementById("next_btn").style.display = 'none';
-		window.document.title = 'vtiger CRM 5 - Configuration Wizard - Database Generation ...';
-	}
-	</script>
-</body>
-</html>
+<?php
+
+/*********************************************************************************
+
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+
+ * ("License"); You may not use this file except in compliance with the
+
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+
+ * the specific language governing rights and limitations under the License.
+
+ * The Original Code is:  SugarCRM Open Source
+
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+
+ * All Rights Reserved.
+
+ * Contributor(s): ______________________________________.
+
+ ********************************************************************************/
+
+/*********************************************************************************
+
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/4createConfigFile.php,v 1.26 2005/04/25 05:40:50 samk Exp $
+
+ * Description:  Executes a step in the installation process.
+
+ ********************************************************************************/
+
+
+
+include('vtigerversion.php');
+
+
+session_start();
+
+
+
+// vtiger CRM version number; do not edit!
+
+$vtiger_version = "5.0.3";
+$release_date = "25 January 2007";
+
+
+if (isset($_REQUEST['db_type'])) $db_type = $_REQUEST['db_type'];
+
+if (isset($_REQUEST['db_hostname']))
+{
+	if(strpos($_REQUEST['db_hostname'], ":"))
+	{
+		list($db_hostname,$db_port) = split(":",$_REQUEST['db_hostname']);
+	}	
+	else
+	{
+		$db_hostname = $_REQUEST['db_hostname'];
+		if($db_type == "pgsql")
+		     $db_port = '5432';
+		else
+		     $db_port = '3306';
+	}	
+}
+if (isset($_REQUEST['db_username']))$db_username = $_REQUEST['db_username'];
+
+if (isset($_REQUEST['db_password']))$db_password = $_REQUEST['db_password'];
+
+if (isset($_REQUEST['db_name']))$db_name = $_REQUEST['db_name'];
+
+if (isset($_REQUEST['db_drop_tables'])) $db_drop_tables = $_REQUEST['db_drop_tables'];
+
+if (isset($_REQUEST['db_create'])) $db_create = $_REQUEST['db_create'];
+
+if (isset($_REQUEST['db_populate'])) $db_populate = $_REQUEST['db_populate'];
+
+if (isset($_REQUEST['site_URL'])) $site_URL = $_REQUEST['site_URL'];
+ 
+if (isset($_REQUEST['admin_email'])) $admin_email = $_REQUEST['admin_email'];
+
+if (isset($_REQUEST['admin_password'])) $admin_password = $_REQUEST['admin_password'];
+
+if (isset($_REQUEST['currency_name'])) $currency_name = $_REQUEST['currency_name'];
+
+if (isset($_REQUEST['currency_code'])) $currency_code = $_REQUEST['currency_code'];
+
+if (isset($_REQUEST['currency_symbol'])) $currency_symbol = $_REQUEST['currency_symbol'];
+
+if (isset($_REQUEST['mail_server'])) $mail_server = $_REQUEST['mail_server'];
+
+if (isset($_REQUEST['mail_server_username'])) $mail_server_username = $_REQUEST['mail_server_username'];
+
+if (isset($_REQUEST['mail_server_password'])) $mail_server_password = $_REQUEST['mail_server_password'];
+
+if (isset($_REQUEST['ftpserver'])) $ftpserver = $_REQUEST['ftpserver'];
+
+if (isset($_REQUEST['ftpuser'])) $ftpuser = $_REQUEST['ftpuser'];
+
+if (isset($_REQUEST['ftppassword'])) $ftppassword = $_REQUEST['ftppassword'];
+
+// update default port
+if ($db_port == '')
+{
+	if($db_type == 'mysql')
+	{
+		$db_port = "3306";
+	}
+	elseif($db_type = 'pgsql')
+	{
+		$db_port = "5432";
+	}
+	elseif($db_type = 'oci8')
+	{
+		$db_port = '1521';
+	}
+}
+
+$cache_dir = 'cache/';
+
+
+?>
+	
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+	<title>vtiger CRM 5 - Configuration Wizard - Config File Creation</title>
+	<link href="include/install/install.css" rel="stylesheet" type="text/css">
+</head>
+
+<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
+
+<br><br>
+	<!-- Table for cfgwiz starts -->
+
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
+		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
+
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
+	<tr>
+		<td class="small" bgcolor="#4572BE" align=center>
+			<!-- Master display -->
+			<table border=0 cellspacing=0 cellpadding=0 width=97%>
+			<tr>
+				<td width=20% valign=top>
+
+				<!-- Left side tabs -->
+					<table border=0 cellspacing=0 cellpadding=10 width=100%>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Welcome</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Installation Check</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
+					<tr><td class="small cwSelectedTab" id="configfile_tab" align=right><div align="left"><b>Config File Creation</b></div></td></tr>
+					<tr><td class="small cwUnSelectedTab" id="dbcreate_tab" align=right><div align="left">Database Generation</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Finish</div></td></tr>
+					</table>
+					
+				</td>
+				<td width=80% valign=top class="cwContentDisplay" align=left>
+				<table border=0 cellspacing=0 cellpadding=10 width=100%>
+				<tr><td class=small align=left><img id="title_img" src="include/install/images/confWizConfFile.gif" alt="Config File Creation" title="Config File Creation"><img id="title_img1" src="include/install/images/confWizDbGeneration.gif" style="display:none;" alt="Database Generation" title="Database Generation"><br>
+					  <hr noshade size=1></td></tr>
+				<tr>
+					<td align=left class="small" style="padding-left:20px">
+					<?php
+					if (isset($_REQUEST['root_directory']))
+						$root_directory = $_REQUEST['root_directory'];
+		
+					if (is_file('config.inc.php'))
+					    	$is_writable = is_writable('config.inc.php');
+					else
+	      					$is_writable = is_writable('.');
+
+	      				/* open template configuration file read only */
+	      				$templateFilename = 'config.template.php';
+	      				$templateHandle = fopen($templateFilename, "r");
+	      				if($templateHandle) {
+		      				/* open include configuration file write only */
+		      				$includeFilename = 'config.inc.php';
+					      	$includeHandle = fopen($includeFilename, "w");
+		      				if($includeHandle) {
+			      			   while (!feof($templateHandle)) {
+				      			$buffer = fgets($templateHandle);
+
+				     			/* replace _DBC_ variable */
+				      			$buffer = str_replace( "_DBC_SERVER_", $db_hostname, $buffer);
+				      			$buffer = str_replace( "_DBC_PORT_", $db_port, $buffer);
+				      			$buffer = str_replace( "_DBC_USER_", $db_username, $buffer);
+				      			$buffer = str_replace( "_DBC_PASS_", $db_password, $buffer);
+				      			$buffer = str_replace( "_DBC_NAME_", $db_name, $buffer);
+				      			$buffer = str_replace( "_DBC_TYPE_", $db_type, $buffer);
+
+				      			$buffer = str_replace( "_SITE_URL_", $site_URL, $buffer);
+
+				      			/* replace dir variable */
+				      			$buffer = str_replace( "_VT_ROOTDIR_", $root_directory, $buffer);
+				      			$buffer = str_replace( "_VT_CACHEDIR_", $cache_dir, $buffer);
+				      			$buffer = str_replace( "_VT_TMPDIR_", $cache_dir."images/", $buffer);
+				      			$buffer = str_replace( "_VT_UPLOADDIR_", $cache_dir."upload/", $buffer);
+				      			/* replace mail variable */
+				      			$buffer = str_replace( "_MAIL_SERVER_", $mail_server, $buffer);
+				      			$buffer = str_replace( "_MAIL_USERNAME_", $mail_server_username, $buffer);
+						      	$buffer = str_replace( "_MAIL_PASSWORD_", $mail_server_password, $buffer);
+						      	$buffer = str_replace( "_DB_STAT_", "true", $buffer);
+				
+						      	/* replace the application unique key variable */
+				      			$buffer = str_replace( "_MASTER_CURRENCY_", $currency_name, $buffer);
+
+						      	/* replace the application unique key variable */
+					      		$buffer = str_replace( "_VT_APP_UNIQKEY_", md5($root_directory), $buffer);
+	
+					      		fwrite($includeHandle, $buffer);
+					      		}
+
+				      		fclose($includeHandle);
+				      		}
+
+				      	fclose($templateHandle);
+				      	}
+  
+	if ($templateHandle && $includeHandle) {?>
+			<div id="config_info">
+			<p><strong class="big">Successfully created configuration file (config.inc.php) in :</strong><br><br>
+			<font color="green"><b><?php echo $root_directory; ?></b></font><br><br>
+			The installation will take at least 4 minutes.<p> Grab a coffee,sit back and relax or browse through our <a href='http://blogs.vtiger.com/index.php' target="_blank">blogs</a><br>
+			</p>
+			</div>
+			<br>		
+	<?php } 
+	else {?>
+			<div id="config_info"><p><strong class="big"><font color="red">Cannot write configuration file (config.inc.php ) in : </font></strong><br><br>
+			<font color="green"><b><?php echo $root_directory; ?></b></font><br><br>
+			<P>You can continue this installation by manually creating the config.inc.php file and pasting the configuration information below inside.However, you <strong>must</strong> create the configuration file before you continue to the next step.<P><br><br>
+	<?php			
+	$config = "<?php \n";
+ 	$config .= "/*********************************************************************************\n";
+ 	$config .= " * The contents of this file are subject to the SugarCRM Public License Version 1.1.2\n";
+ 	$config .= " * (\"License\"); You may not use this file except in compliance with the \n";
+ 	$config .= " * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL\n";
+ 	$config .= " * Software distributed under the License is distributed on an  \"AS IS\"  basis,\n";
+ 	$config .= " * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for\n";
+ 	$config .= " * the specific language governing rights and limitations under the License.\n";
+ 	$config .= " * The Original Code is:  SugarCRM Open Source\n";
+ 	$config .= " * The Initial Developer of the Original Code is SugarCRM, Inc.\n";
+ 	$config .= " * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;\n";
+ 	$config .= " * All Rights Reserved.\n";
+ 	$config .= " * Contributor(s): ______________________________________.\n";
+ 	$config .= "********************************************************************************/\n\n";
+ 	$config .= "include('vtigerversion.php');\n\n";
+ 	$config .= "ini_set('memory_limit','64M');\n\n";
+ 	$config .= "// show or hide world clock, calculator and FCKEditor\n\n";
+ 	$config .= "\$WORLD_CLOCK_DISPLAY = 'true';\n";
+ 	$config .= "\$CALCULATOR_DISPLAY = 'true';\n";
+ 	$config .= "\$FCKEDITOR_DISPLAY = 'true';\n\n";
+ 	
+ 	$config .= "//This is the URL for customer portal. (Ex. http://vtiger.com/portal)\n";
+ 	$config .= "\$PORTAL_URL = 'http://yourdomain.com/customerportal';\n\n";
+ 	$config .= "//These two are the HelpDesk support email id and the support name. ";
+ 	$config .= "(Ex. 'support at vtiger.com' and 'vtiger Support')\n";
+ 	$config .= "\$HELPDESK_SUPPORT_EMAIL_ID = 'support at yourdomain.com';\n";
+ 	$config .= "\$HELPDESK_SUPPORT_NAME = 'yourdomain Name';\n\n";
+ 	
+ 	$config .= "/* Database configuration\n";
+ 	$config .= "      db_host_name:     MySQL Database Hostname\n";
+ 	$config .= "      db_user_name:        MySQL Username\n";
+ 	$config .= "      db_password:         MySQL Password\n";
+ 	$config .= "      db_name:             MySQL Database Name\n*/\n";
+ 	$config .= "\$dbconfig['db_server'] =     '".$db_hostname."';\n";
+ 	$config .= "\$dbconfig['db_port'] =     '".$db_port."';\n";
+ 	$config .= "\$dbconfig['db_username'] =     '".$db_username."';\n";
+ 	$config .= "\$dbconfig['db_password'] =         '".$db_password."';\n";
+ 	$config .= "\$dbconfig['db_name'] =             '".$db_name."';\n";
+ 	$config .= "\$dbconfig['db_type'] = '".$db_type."';\n";
+	$config .= "\$dbconfig['db_status'] = 'true';\n";
+
+	$config .= "// TODO: test if port is empty\n";
+	$config .= "// TODO: set db_hostname dependending on db_type\n";
+ 	$config .= "\$dbconfig['db_hostname'] = \$dbconfig['db_server'].\$dbconfig['db_port'];\n\n";
+
+	
+	$config .= "// log_sql default value = false\n";
+	$config .= "\$dbconfig['log_sql'] = false;\n\n";
+	
+	$config .= "// persistent default value = true\n";
+	$config .= "\$dbconfigoption['persistent'] = true;\n\n";
+
+	$config .= "// autofree default value = false\n";
+	$config .= "\$dbconfigoption['autofree'] = false;\n\n";
+	
+	$config .= "// debug default value = 0\n";
+	$config .= "\$dbconfigoption['debug'] = 0;\n\n";
+
+	$config .= "// seqname_format default value = '%s_seq'\n";
+	$config .= "\$dbconfigoption['seqname_format'] = '%s_seq';\n\n";
+
+	$config .= "// portability default value = 0\n";
+	$config .= "\$dbconfigoption['portability'] = 0;\n\n";
+
+	$config .= "// ssl default value = false\n";
+	$config .= "\$dbconfigoption['ssl'] = false;\n\n";
+
+	$config .= "\$host_name = \$dbconfig['db_hostname'];\n\n";
+	
+	$config .= "\$site_URL ='$site_URL';\n\n";
+
+	$config .= "// root directory path\n";
+	$config .= "\$root_directory = '$root_directory';\n\n";
+
+	$config .= "// cache direcory path\n";
+	$config .= "\$cache_dir = '$cache_dir';\n\n";
+
+	$config .= "// tmp_dir default value prepended by cache_dir = images/\n";
+	$config .= "\$tmp_dir = '$cache_dir"."images/';\n\n";
+
+	$config .= "// import_dir default value prepended by cache_dir = import/\n";
+	$config .= "\$tmp_dir = '$cache_dir"."import/';\n\n";
+
+	$config .= "// upload_dir default value prepended by cache_dir = upload/\n";
+	$config .= "\$tmp_dir = '$cache_dir"."upload/';\n\n";
+
+	$config .= "// mail server parameters\n";
+	$config .= "\$mail_server = '$mail_server';\n";
+	$config .= "\$mail_server_username = '$mail_server_username';\n";
+	$config .= "\$mail_server_password = '$mail_server_password';\n\n";
+	
+	$config .= "// maximum file size for uploaded files in bytes also used when uploading import files\n";
+	$config .= "// upload_maxsize default value = 3000000\n";
+	$config .= "\$upload_maxsize = 3000000;\n\n";
+
+	$config .= "// flag to allow export functionality\n";
+	$config .= "// 'all' to allow anyone to use exports \n";
+	$config .= "// 'admin' to only allow admins to export\n";
+	$config .= "// 'none' to block exports completely\n";
+	$config .= "// allow_exports default value = all\n";
+	$config .= "\$allow_exports = 'all';\n\n";
+
+ 	$config .= "// Files with one of these extensions will have '.txt' appended to their filename on upload\n";
+	$config .= "// upload_badext default value = php, php3, php4, php5, pl, cgi, py, asp, cfm, js, vbs, html, htm\n";
+ 	$config .= "\$upload_badext = array('php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', 'asp', 'cfm', 'js', 'vbs', 'html', 'htm');\n\n";
+
+ 	$config .= "// This is the full path to the include directory including the trailing slash\n";
+	$config .= "// includeDirectory default value = $root_directory..'include/\n";
+ 	$config .= "\$includeDirectory = \$root_directory.'include/';\n\n";
+	
+	$config .= "// list_max_entries_per_page default value = 20\n";
+	$config .= "\$list_max_entries_per_page = '20';\n\n";
+
+ 	$config .= "// change this number to whatever you want. This is the number of pages that will appear in the pagination. by Raju \n";
+ 	$config .= "\$limitpage_navigation = '9';\n\n";
+	
+	$config .= "// history_max_viewed default value = 5\n";
+ 	$config .= "\$history_max_viewed = '5';\n\n";
+ 	
+ 	$config .= "// Map Sugar language codes to jscalendar language codes\n";
+ 	$config .= "// Unimplemented until jscalendar language files are fixed\n";
+ 	$config .= "// \$cal_codes = array('en_us'=>'en', 'ja'=>'jp', 'sp_ve'=>'sp', 'it_it'=>'it', 'tw_zh'=>'zh', 'pt_br'=>'pt', 'se'=>'sv', 'cn_zh'=>'zh', 'ge_ge'=>'de', 'ge_ch'=>'de', 'fr'=>'fr');\n\n";
+
+	$config .= "//set default module and action\n";
+ 	$config .= "\$default_module = 'Home';\n";
+ 	$config .= "\$default_action = 'index';\n\n";
+
+ 	$config .= "//set default theme\n";
+ 	$config .= "\$default_theme = 'bluelagoon';\n\n";
+
+ 	$config .= "// If true, the time to compose each page is placed in the browser.\n";
+ 	$config .= "\$calculate_response_time = true;\n";
+
+ 	$config .= "// Default Username - The default text that is placed initially in the login form for user name.\n";
+ 	$config .= "\$default_user_name = '';\n";
+	
+ 	$config .= "// Default Password - The default text that is placed initially in the login form for password.\n";
+ 	$config .= "\$default_password = '';\n";
+
+ 	$config .= "// Create default user - If true, a user with the default username and password is created.\n";
+ 	$config .= "\$create_default_user = false;\n";
+ 	$config .= "\$default_user_is_admin = false;\n";
+
+ 	$config .= "// disable persistent connections - If your MySQL/PHP configuration does not support persistent connections set this to true to avoid a large performance slowdown\n";
+ 	$config .= "\$disable_persistent_connections = false;\n";
+ 	$config .= "// Defined languages available.  The key must be the language file prefix.  E.g. 'en_us' is the prefix for every 'en_us.lang.php' file. \n";
+ 	
+ 	$language_value = "Array('en_us'=>'US English',)";
+ 	if(isset($_SESSION['language_keys']) && isset($_SESSION['language_values']))
+ 	{
+ 	    $language_value = 'Array(';
+ 	    $language_keys = explode(',', urldecode($_SESSION['language_keys']));
+ 	    $language_values = explode(',', urldecode($_SESSION['language_values']));
+ 	    $size = count($language_keys);
+ 	    for($i = 0; $i < $size; $i+=1)
+ 	    {
+ 	        $language_value .= "'$language_keys[$i]'=>'$language_values[$i]',";
+ 	    }
+ 	    $language_value .= ')';
+ 	}
+ 	$config .= "\$languages = $language_value;\n";
+	$config .= "// Master currency name\n";
+ 	$config .= "\$currency_name = '$currency_name';\n";
+ 	$config .= "// Default charset if the language specific character set is not found.\n";
+ 	$config .= "\$default_charset = 'ISO-8859-1';\n";
+ 	$config .= "// Default language in case all or part of the user's language pack is not available.\n";
+ 	$config .= "\$default_language = 'en_us';\n";
+ 	$config .= "// Translation String Prefix - This will add the language pack name to every translation string in the display.\n";
+ 	$config .= "\$translation_string_prefix = false;\n";
+ 	
+ 	$config .= "//Option to cache tabs permissions for speed.\n";
+ 	$config .= "\$cache_tab_perms = true;\n\n";
+ 	
+ 	$config .= "//Option to hide empty home blocks if no entries.\n";
+ 	$config .= "\$display_empty_home_blocks = false;\n\n";
+
+ 	$config .= "// Generating Unique Application Key\n";
+ 	$config .= "\$application_unique_key = '".md5($root_directory)."';\n\n";
+ 	$config .= "?>";
+		
+			echo "<TEXTAREA class=\"dataInput\" rows=\"15\" cols=\"80\">".$config."</TEXTAREA><br><br>";
+			echo "<P>Did you remember to create the config.inc.php file ?</p>";
+	
+				  
+		}	?>
+				</div></td>
+				</tr>
+				<tr><td align="center"><img id="populating_info" src="include/install/images/loading.gif" style="visibility:hidden;"></td></tr>
+				<tr>
+				<td align=right style="height:60px;">
+				 <form action="install.php" method="post" name="form" id="form">
+				 <!--<form action="install.php" method="post" name="form" id="form"> -->
+				 <input type="hidden" name="file" value="5createTables.php">
+				 <input type="hidden" class="dataInput" name="db_hostname" value="<?php if (isset($db_hostname)) echo "$db_hostname"; ?>" />
+				 <input type="hidden" class="dataInput" name="db_username" value="<?php if (isset($db_username)) echo "$db_username"; ?>" />
+				 <input type="hidden" class="dataInput" name="db_password" value="<?php if (isset($db_password)) echo "$db_password"; ?>" />
+				 <input type="hidden" class="dataInput" name="db_name" value="<?php if (isset($db_name)) echo "$db_name"; ?>" />
+				 <input type="hidden" class="dataInput" name="db_drop_tables" value="<?php if (isset($db_drop_tables)) echo "$db_drop_tables"; ?>" />
+				 <input type="hidden" class="dataInput" name="db_create" value="<?php if (isset($db_create)) echo "$db_create"; ?>" />
+				 <input type="hidden" class="dataInput" name="db_populate" value="<?php if (isset($db_populate)) echo "$db_populate"; ?>" />
+				 <input type="hidden" class="dataInput" name="admin_email" value="<?php if (isset($admin_email)) echo "$admin_email"; ?>" />
+				 <input type="hidden" class="dataInput" name="admin_password" value="<?php if (isset($admin_password)) echo "$admin_password"; ?>" />
+				 <input type="hidden" class="dataInput" name="currency_name" value="<?php if (isset($currency_name)) echo "$currency_name"; ?>" />
+				 <input type="hidden" class="dataInput" name="currency_code" value="<?php if (isset($currency_code)) echo "$currency_code"; ?>" />
+				 <input type="hidden" class="dataInput" name="currency_symbol" value="<?php if (isset($currency_symbol)) echo "$currency_symbol"; ?>" />
+				 <input  type="image" name="next" value="Next" id="next_btn" src="include/install/images/cwBtnNext.gif" onClick="window.location=('install.php');createtablejs();" />
+				 </form>
+					
+				</td>
+			</tr>
+
+			</table>
+		</td>
+	</tr>
+	</table>
+	<!-- Master display stops -->
+	<br>
+	</td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+
+		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+
+      	<tr>
+        	<td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
+      	</tr>
+    	</table>	
+	<script>
+	function createtablejs()
+	{
+		document.getElementById('dbcreate_tab').innerHTML = '<div align="left"><b>Database Generation</b></div>';
+		document.getElementById('configfile_tab').className = 'small cwUnSelectedTab';
+		document.getElementById('configfile_tab').innerHTML = '<div align="left">Config File Creation</div>';
+		document.getElementById('dbcreate_tab').className = 'small cwSelectedTab';
+		oImg = document.getElementById('title_img').style.display = 'none';
+		oImg = document.getElementById('title_img1').style.display = 'block';
+		document.getElementById('populating_info').style.visibility='visible';
+		document.getElementById("next_btn").style.display = 'none';
+		window.document.title = 'vtiger CRM 5 - Configuration Wizard - Database Generation ...';
+	}
+	</script>
+</body>
+</html>

Modified: vtigercrm/branches/5.1_jens/install/5createTables.inc.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/5createTables.inc.php (original)
+++ vtigercrm/branches/5.1_jens/install/5createTables.inc.php Mon Apr 16 12:27:44 2007
@@ -1,283 +1,286 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is: SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/5createTables.php,v 1.58 2005/04/19 16:57:08 ray Exp $
- * Description:  Executes a step in the installation process.
- ********************************************************************************/
-
-$new_tables = 0;
-
-require_once('config.php');
-require_once('include/database/PearDatabase.php');
-require_once('include/logging.php');
-require_once('modules/Leads/Leads.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('modules/Accounts/Accounts.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('modules/Calendar/Activity.php');
-require_once('modules/Notes/Notes.php');
-require_once('modules/Emails/Emails.php');
-require_once('modules/Users/Users.php');
-require_once('modules/Import/ImportMap.php');
-require_once('modules/Import/UsersLastImport.php');
-require_once('modules/Users/LoginHistory.php');
-require_once('data/Tracker.php');
-require_once('include/utils/utils.php');
-require_once('modules/Users/DefaultDataPopulator.php');
-require_once('modules/Users/CreateUserPrivilegeFile.php');
-
-// load the config_override.php file to provide default user settings
-if (is_file("config_override.php")) {
-	require_once("config_override.php");
-}
-
-$db = new PearDatabase();
-
-$log =& LoggerManager::getLogger('INSTALL');
-
-function eecho($msg = FALSE) {
-	if ($useHtmlEntities) {
-		echo htmlentities(nl2br($msg));
-	}
-	else {
-		echo $msg;
-	}
-}
-
-function create_default_users() {
-        global $log, $db;
-        global $admin_email;
-        global $admin_password;
-        global $create_default_user;
-        global $default_user_name;
-        global $default_password;
-        global $default_user_is_admin;
-
-        // create default admin user
-    	$user = new Users();
-        $user->column_fields["last_name"] = 'Administrator';
-        $user->column_fields["user_name"] = 'admin';
-        $user->column_fields["status"] = 'Active';
-        $user->column_fields["is_admin"] = 'on';
-        $user->column_fields["user_password"] = $admin_password;
-        $user->column_fields["tz"] = 'Europe/Berlin';
-        $user->column_fields["holidays"] = 'de,en_uk,fr,it,us,';
-        $user->column_fields["workdays"] = '0,1,2,3,4,5,6,';
-        $user->column_fields["weekstart"] = '1';
-        $user->column_fields["namedays"] = '';
-        $user->column_fields["currency_id"] = 1;
-	$user->column_fields["date_format"] = 'yyyy-mm-dd';
-	$user->column_fields["hour_format"] = 'am/pm';
-	$user->column_fields["start_hour"] = '08:00';
-	$user->column_fields["end_hour"] = '23:00';
-	$user->column_fields["imagename"] = '';
-        $user->column_fields["activity_view"] = 'This Year';	
-	$user->column_fields["lead_view"] = 'Today';
-	$user->column_fields["defhomeview"] = 'home_metrics';
-        //added by philip for default default admin emailid
-	if($admin_email == '')
-	$admin_email ="admin at vtigeruser.com";
-        $user->column_fields["email1"] = $admin_email;
-	//to get the role id for standard_user	
-	$role_query = "select roleid from vtiger_role where rolename='CEO'";
-	$db->checkConnection();
-	$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
-	$role_result = $db->query($role_query);
-	$role_id = $db->query_result($role_result,0,"roleid");
-	$user->column_fields["roleid"] = $role_id;
-	$user->column_fields["assigned_org"] = array( "0" => "vtiger");
-	$user->column_fields["primray_org"] = "vtiger";
-
-        $user->save("Users");
-
-        // we need to change the admin user to a fixed id of 1.
-        //$query = "update vtiger_users set id='1' where user_name='$user->user_name'";
-        //$result = $db->query($query, true, "Error updating admin user ID: ");
-
-        $log->info("Created ".$user->table_name." vtiger_table. for user $user->id");
-
-	//Creating the flat files
-	createUserPrivilegesfile($user->id);
-        createUserSharingPrivilegesfile($user->id);
-
-
-	//Creating the Standard User
-    	$user = new Users();
-        $user->column_fields["last_name"] = 'StandardUser';
-        $user->column_fields["user_name"] = 'standarduser';
-        $user->column_fields["is_admin"] = 'off';
-        $user->column_fields["status"] = 'Active';
-        $user->column_fields["user_password"] = 'standarduser';
-        $user->column_fields["tz"] = 'Europe/Berlin';
-        $user->column_fields["holidays"] = 'de,en_uk,fr,it,us,';
-        $user->column_fields["workdays"] = '0,1,2,3,4,5,6,';
-        $user->column_fields["weekstart"] = '1';
-        $user->column_fields["namedays"] = '';
-        $user->column_fields["currency_id"] = 1;
-	$user->column_fields["date_format"] = 'yyyy-mm-dd';
-	$user->column_fields["imagename"] = '';
-        $user->column_fields["activity_view"] = 'This Year';	
-	$user->column_fields["lead_view"] = 'Today';
-	$user->column_fields["defhomeview"] = 'home_metrics';
-        //added by philip for default default admin emailid
-	if($admin_email == '')
-	$std_email ="standarduser at vtigeruser.com";
-        $user->column_fields["email1"] = $std_email;
-	//to get the role id for standard_user	
-	$role_query = "select roleid from vtiger_role where rolename='Vice President'";
-	$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
-	$role_result = $db->query($role_query);
-	$role_id = $db->query_result($role_result,0,"roleid");
-	$user->column_fields["roleid"] = $role_id;
-	$user->column_fields["assigned_org"] = array( "0" => "vtiger");
-	$user->column_fields["primray_org"] = "vtiger";
-
-	$user->save('Users');
-
-	//Creating the flat vtiger_files
-	createUserPrivilegesfile($user->id);
-        createUserSharingPrivilegesfile($user->id);
-
-	//Inserting into vtiger_groups table
-	$db->startTransaction();
-	$result = $db->query("select groupid from vtiger_groups where groupname='Team Selling';");
-	$group1_id = $db->query_result($result,0,"groupid");
-	$result = $db->query("select groupid from vtiger_groups where groupname='Marketing Group';");
-	$group2_id = $db->query_result($result,0,"groupid");
-	$result = $db->query("select groupid from vtiger_groups where groupname='Support Group';");
-	$group3_id = $db->query_result($result,0,"groupid");
-
-	$db->query("insert into vtiger_users2group values ('".$group1_id."',2)");
-	$db->query("insert into vtiger_users2group values ('".$group2_id."',1)");
-	$db->query("insert into vtiger_users2group values ('".$group2_id."',2)");
-	$db->query("insert into vtiger_users2group values ('".$group3_id."',2)");
-	$db->completeTransaction();
-}
-
-//$startTime = microtime();
-$modules = array("DefaultDataPopulator");
-$focus=0;				
-// tables creation
-//eecho("Creating Core tables: ");
-//$adb->setDebug(true);
-$success = $adb->createTables("schema/DatabaseSchema.xml");
-
-//Postgres8 fix - create sequences. 
- if( $adb->dbType == "pgsql" ) {
-     //  Create required functions
-     $adb->query( 'CREATE LANGUAGE plperl');
-     $adb->query( 'CREATE OR REPLACE FUNCTION concat(varchar,varchar)  RETURNS varchar AS $$
-		      my $s = "";
-		      foreach my $t (@_) { $s .= $t; }
-		      return $s;
-		   $$ LANGUAGE plperl');
-     $adb->query( 'CREATE OR REPLACE FUNCTION concat(varchar,varchar,varchar)  RETURNS varchar AS $$
-		      my $s = "";
-		      foreach my $t (@_) { $s .= $t; }
-		      return $s;
-		   $$ LANGUAGE plperl');
-     $adb->query( 'CREATE OR REPLACE FUNCTION concat(varchar,varchar,varchar,varchar)  RETURNS varchar AS $$
-		      my $s = "";
-		      foreach my $t (@_) { $s .= $t; }
-		      return $s;
-		   $$ LANGUAGE plperl');
-
-     //  Create sequences currently not implemented in the database schema
-     $sequences = array(
-	"vtiger_role_roleid_seq",
-	"vtiger_audit_trial_auditid_seq",
-	"vtiger_datashare_relatedmodules_datashare_relatedmodule_id_seq",
-	"vtiger_relatedlists_relation_id_seq",
-	"vtiger_inventory_tandc_id_seq",
-	"vtiger_customview_cvid_seq",
-	"vtiger_crmentity_crmid_seq",
-	"vtiger_seactivityrel_crmid_seq",
-	"vtiger_selectquery_queryid_seq",
-	"vtiger_systems_id_seq",
-	"vtiger_freetags_id_seq",
-	"vtiger_inventorytaxinfo_taxid_seq",
-	"vtiger_shippingtaxinfo_taxid_seq",
-	"vtiger_groups_groupid_seq"
-    );
- 
-     foreach ($sequences as $sequence ) {
- 	$log->info( "Creating sequence ".$sequence);
- 	$adb->query( "CREATE SEQUENCE ".$sequence." INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;");
-     }
- }
-
-
-// TODO HTML
-if($success==0)
-	die("Error: Tables not created.  Table creation failed.\n");
-elseif ($success==1)
-	die("Error: Tables partially created.  Table creation failed.\n");
-	//eecho("Tables Successfully created.\n");
-
-// Populate default data
-foreach ($modules as $module ) 
-{
-	$focus = new $module();
-	$focus->create_tables();
-}
-			
-
-// create and populate combo tables
-require_once('include/PopulateComboValues.php');
-$combo = new PopulateComboValues();
-$combo->create_tables();
-
-//Writing tab data in flat file
-create_tab_data_file();
-create_parenttab_data_file();
-
-// Create the default users
-create_default_users();
-
-// default report population
-require_once('modules/Reports/PopulateReports.php');
-
-// default customview population
-require_once('modules/CustomView/PopulateCustomView.php');
-
-
-// ensure required sequences are created (adodb creates them as needed, but if
-// creation occurs within a transaction we get problems
-$db->getUniqueID("vtiger_crmentity");
-$db->getUniqueID("vtiger_seactivityrel");
-$db->getUniqueID("vtiger_freetags");
-
-//Master currency population
-//Insert into vtiger_currency vtiger_table
-               $db->query("insert into vtiger_currency_info values(".$db->getUniqueID("vtiger_currency_info").",'$currency_name','$currency_code','$currency_symbol',1,'Active','-11')");
-
-// populate the db with seed data
-if ($db_populate) {
-        //eecho ("Populate seed data into $db_name");
-        include("install/populateSeedData.php");
-        //eecho ("...<font color=\"00CC00\">done</font><BR><P>\n");
-}
-
-// populate forums data
-global $log, $db;
-
-//$endTime = microtime();
-//$deltaTime = microtime_diff($startTime, $endTime);
-
-
-// populate calendar data
-
-//eecho ("total time: $deltaTime seconds.\n");
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is: SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/5createTables.php,v 1.58 2005/04/19 16:57:08 ray Exp $
+ * Description:  Executes a step in the installation process.
+ ********************************************************************************/
+
+$new_tables = 0;
+
+require_once('config.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/logging.php');
+require_once('modules/Leads/Leads.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('modules/Accounts/Accounts.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('modules/Calendar/Activity.php');
+require_once('modules/Notes/Notes.php');
+require_once('modules/Emails/Emails.php');
+require_once('modules/Users/Users.php');
+require_once('modules/Import/ImportMap.php');
+require_once('modules/Import/UsersLastImport.php');
+require_once('modules/Users/LoginHistory.php');
+require_once('data/Tracker.php');
+require_once('include/utils/utils.php');
+require_once('modules/Users/DefaultDataPopulator.php');
+require_once('modules/Users/CreateUserPrivilegeFile.php');
+
+// load the config_override.php file to provide default user settings
+if (is_file("config_override.php")) {
+	require_once("config_override.php");
+}
+
+$db = new PearDatabase();
+
+$log =& LoggerManager::getLogger('INSTALL');
+
+function eecho($msg = FALSE) {
+	if ($useHtmlEntities) {
+		echo htmlentities(nl2br($msg));
+	}
+	else {
+		echo $msg;
+	}
+}
+
+function create_default_users() {
+        global $log, $db;
+        global $admin_email;
+        global $admin_password;
+        global $create_default_user;
+        global $default_user_name;
+        global $default_password;
+        global $default_user_is_admin;
+
+        // create default admin user
+    	$user = new Users();
+        $user->column_fields["last_name"] = 'Administrator';
+        $user->column_fields["user_name"] = 'admin';
+        $user->column_fields["status"] = 'Active';
+        $user->column_fields["is_admin"] = 'on';
+        $user->column_fields["user_password"] = $admin_password;
+        $user->column_fields["tz"] = 'Europe/Berlin';
+        $user->column_fields["holidays"] = 'de,en_uk,fr,it,us,';
+        $user->column_fields["workdays"] = '0,1,2,3,4,5,6,';
+        $user->column_fields["weekstart"] = '1';
+        $user->column_fields["namedays"] = '';
+        $user->column_fields["currency_id"] = 1;
+	$user->column_fields["date_format"] = 'yyyy-mm-dd';
+	$user->column_fields["hour_format"] = 'am/pm';
+	$user->column_fields["start_hour"] = '08:00';
+	$user->column_fields["end_hour"] = '23:00';
+	$user->column_fields["imagename"] = '';
+        $user->column_fields["activity_view"] = 'This Year';	
+	$user->column_fields["lead_view"] = 'Today';
+	$user->column_fields["defhomeview"] = 'home_metrics';
+        //added by philip for default admin emailid
+	if($admin_email == '')
+	    $admin_email ="admin at vtigeruser.com";
+        $user->column_fields["email1"] = $admin_email;
+	$role_query = "select roleid from vtiger_role where rolename='CEO'";
+	$db->checkConnection();
+	$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
+	$role_result = $db->query($role_query);
+	$role_id = $db->query_result($role_result,0,"roleid");
+	$user->column_fields["roleid"] = $role_id;
+	$user->column_fields["assigned_org"] = array( "0" => "vtiger");
+	$user->column_fields["primray_org"] = "vtiger";
+
+        $user->save("Users");
+
+        // we need to change the admin user to a fixed id of 1.
+        //$query = "update vtiger_users set id='1' where user_name='$user->user_name'";
+        //$result = $db->query($query, true, "Error updating admin user ID: ");
+
+        $log->info("Created ".$user->table_name." vtiger_table. for user $user->id");
+
+	//Creating the flat files
+	createUserPrivilegesfile($user->id);
+        createUserSharingPrivilegesfile($user->id);
+	$admin_uid = $user->id;
+
+
+	//Creating the Standard User
+    	$user = new Users();
+        $user->column_fields["last_name"] = 'StandardUser';
+        $user->column_fields["user_name"] = 'standarduser';
+        $user->column_fields["is_admin"] = 'off';
+        $user->column_fields["status"] = 'Active';
+        $user->column_fields["user_password"] = 'standarduser';
+        $user->column_fields["tz"] = 'Europe/Berlin';
+        $user->column_fields["holidays"] = 'de,en_uk,fr,it,us,';
+        $user->column_fields["workdays"] = '0,1,2,3,4,5,6,';
+        $user->column_fields["weekstart"] = '1';
+        $user->column_fields["namedays"] = '';
+        $user->column_fields["currency_id"] = 1;
+	$user->column_fields["date_format"] = 'yyyy-mm-dd';
+	$user->column_fields["hour_format"] = '24';
+	$user->column_fields["start_hour"] = '08:00';
+	$user->column_fields["end_hour"] = '23:00';
+	$user->column_fields["imagename"] = '';
+        $user->column_fields["activity_view"] = 'This Year';	
+	$user->column_fields["lead_view"] = 'Today';
+	$user->column_fields["defhomeview"] = 'home_metrics';
+	$std_email ="standarduser at vtigeruser.com";
+        $user->column_fields["email1"] = $std_email;
+	//to get the role id for standard_user	
+	$role_query = "select roleid from vtiger_role where rolename='Vice President'";
+	$db->database->SetFetchMode(ADODB_FETCH_ASSOC);
+	$role_result = $db->query($role_query);
+	$role_id = $db->query_result($role_result,0,"roleid");
+	$user->column_fields["roleid"] = $role_id;
+	$user->column_fields["assigned_org"] = array( "0" => "vtiger");
+	$user->column_fields["primray_org"] = "vtiger";
+
+	$user->save('Users');
+
+	//Creating the flat vtiger_files
+	createUserPrivilegesfile($user->id);
+        createUserSharingPrivilegesfile($user->id);
+
+	//Inserting Entries into vtiger_groups table
+	$db->startTransaction();
+	$result = $db->query("select groupid from vtiger_groups where groupname='Team Selling';");
+ 	$group1_id = $db->query_result($result,0,"groupid");
+ 	$result = $db->query("select groupid from vtiger_groups where groupname='Marketing Group';");
+ 	$group2_id = $db->query_result($result,0,"groupid");
+ 	$result = $db->query("select groupid from vtiger_groups where groupname='Support Group';");
+ 	$group3_id = $db->query_result($result,0,"groupid");
+
+ 	$db->query("insert into vtiger_users2group values ('".$group2_id."',".$admin_uid.")");
+
+	$db->query("insert into vtiger_users2group values ('".$group1_id."',".$user->id.")");
+ 	$db->query("insert into vtiger_users2group values ('".$group2_id."',".$user->id.")");
+ 	$db->query("insert into vtiger_users2group values ('".$group3_id."',".$user->id.")");
+	$db->completeTransaction();
+
+}
+
+//$startTime = microtime();
+$modules = array("DefaultDataPopulator");
+$focus=0;				
+// tables creation
+//eecho("Creating Core tables: ");
+//$adb->setDebug(true);
+$success = $adb->createTables("schema/DatabaseSchema.xml");
+
+//Postgres8 fix - create sequences. 
+//   This should be a part of "createTables" however ...
+ if( $adb->dbType == "pgsql" ) {
+     //  Create required functions
+     $adb->query( 'CREATE LANGUAGE plperl');
+     $adb->query( 'CREATE OR REPLACE FUNCTION concat(varchar,varchar)  RETURNS varchar AS $$
+		      my $s = "";
+		      foreach my $t (@_) { $s .= $t; }
+		      return $s;
+		   $$ LANGUAGE plperl');
+     $adb->query( 'CREATE OR REPLACE FUNCTION concat(varchar,varchar,varchar)  RETURNS varchar AS $$
+		      my $s = "";
+		      foreach my $t (@_) { $s .= $t; }
+		      return $s;
+		   $$ LANGUAGE plperl');
+     $adb->query( 'CREATE OR REPLACE FUNCTION concat(varchar,varchar,varchar,varchar)  RETURNS varchar AS $$
+		      my $s = "";
+		      foreach my $t (@_) { $s .= $t; }
+		      return $s;
+		   $$ LANGUAGE plperl');
+
+     //  Create sequences currently not implemented in the database schema
+     $sequences = array(
+	"vtiger_role_roleid_seq",
+	"vtiger_audit_trial_auditid_seq",
+	"vtiger_datashare_relatedmodules_datashare_relatedmodule_id_seq",
+	"vtiger_relatedlists_relation_id_seq",
+	"vtiger_inventory_tandc_id_seq",
+	"vtiger_customview_cvid_seq",
+	"vtiger_crmentity_crmid_seq",
+	"vtiger_seactivityrel_crmid_seq",
+	"vtiger_selectquery_queryid_seq",
+	"vtiger_systems_id_seq",
+	"vtiger_freetags_id_seq",
+	"vtiger_inventorytaxinfo_taxid_seq",
+	"vtiger_shippingtaxinfo_taxid_seq",
+	"vtiger_groups_groupid_seq"
+    );
+ 
+     foreach ($sequences as $sequence ) {
+ 	$log->info( "Creating sequence ".$sequence);
+ 	$adb->query( "CREATE SEQUENCE ".$sequence." INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;");
+     }
+ }
+
+
+// TODO HTML
+if($success==0)
+	die("Error: Tables not created.  Table creation failed.\n");
+elseif ($success==1)
+	die("Error: Tables partially created.  Table creation failed.\n");
+	//eecho("Tables Successfully created.\n");
+
+foreach ($modules as $module ) 
+{
+	$focus = new $module();
+	$focus->create_tables();
+}
+			
+
+// create and populate combo tables
+require_once('include/PopulateComboValues.php');
+$combo = new PopulateComboValues();
+$combo->create_tables();
+
+//Writing tab data in flat file
+create_tab_data_file();
+create_parenttab_data_file();
+
+// Create the default users
+create_default_users();
+
+// default report population
+require_once('modules/Reports/PopulateReports.php');
+
+// default customview population
+require_once('modules/CustomView/PopulateCustomView.php');
+
+
+// ensure required sequences are created (adodb creates them as needed, but if
+// creation occurs within a transaction we get problems
+$db->getUniqueID("vtiger_crmentity");
+$db->getUniqueID("vtiger_seactivityrel");
+$db->getUniqueID("vtiger_freetags");
+
+//Master currency population
+//Insert into vtiger_currency vtiger_table
+               $db->query("insert into vtiger_currency_info values(".$db->getUniqueID("vtiger_currency_info").",'$currency_name','$currency_code','$currency_symbol',1,'Active','-11')");
+
+// populate the db with seed data
+if ($db_populate) {
+        //eecho ("Populate seed data into $db_name");
+        include("install/populateSeedData.php");
+        //eecho ("...<font color=\"00CC00\">done</font><BR><P>\n");
+}
+
+// populate forums data
+global $log, $db;
+
+//$endTime = microtime();
+//$deltaTime = microtime_diff($startTime, $endTime);
+
+
+// populate calendar data
+
+//eecho ("total time: $deltaTime seconds.\n");
+?>

Modified: vtigercrm/branches/5.1_jens/install/5createTables.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/5createTables.php (original)
+++ vtigercrm/branches/5.1_jens/install/5createTables.php Mon Apr 16 12:27:44 2007
@@ -1,179 +1,193 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is: SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/5createTables.php,v 1.58 2005/04/19 16:57:08 ray Exp $
- * Description:  Executes a step in the installation process.
- ********************************************************************************/
-set_time_limit(600);
-
-if (isset($_REQUEST['db_name'])) $db_name  				= $_REQUEST['db_name'];
-if (isset($_REQUEST['db_drop_tables'])) $db_drop_tables 	= $_REQUEST['db_drop_tables'];
-if (isset($_REQUEST['db_create'])) $db_create 			= $_REQUEST['db_create'];
-if (isset($_REQUEST['db_populate'])) $db_populate		= $_REQUEST['db_populate'];
-if (isset($_REQUEST['admin_email'])) $admin_email		= $_REQUEST['admin_email'];
-if (isset($_REQUEST['admin_password'])) $admin_password	= $_REQUEST['admin_password'];
-if (isset($_REQUEST['currency_name'])) $currency_name	= $_REQUEST['currency_name'];
-if (isset($_REQUEST['currency_code'])) $currency_code	= $_REQUEST['currency_code'];
-if (isset($_REQUEST['currency_symbol'])) $currency_symbol	= $_REQUEST['currency_symbol'];
-
-?>
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>vtiger CRM 5 - Configuration Wizard - Finish</title>
-
-
-<link href="include/install/install.css" rel="stylesheet" type="text/css">
-</head>
-
-<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
-
-	<br><br><br>
-	<!-- Table for cfgwiz starts -->
-
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
-		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
-
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
-	<tr>
-		<td class="small" bgcolor="#4572BE" align=center>
-			<!-- Master display -->
-			<table border=0 cellspacing=0 cellpadding=0 width=97%>
-			<tr>
-				<td width=20% valign=top>
-
-				<!-- Left side tabs -->
-					<table border=0 cellspacing=0 cellpadding=10 width=100%>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Welcome</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Installation Check</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Config File Creation</div></td></tr>
-					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Database Generation</div></td></tr>
-					<tr><td class="small cwSelectedTab" align=right><div align="left"><b>Finish</b></div></td></tr>
-					</table>
-					
-				</td>
-				<td width=80% valign=top class="cwContentDisplay" align=left>
-				<!-- Right side tabs -->
-					<table border=0 cellspacing=0 cellpadding=10 width=100%>
-					<tr><td class=small align=left><img src="include/install/images/confWizFinish.gif" alt="Configuration Completed" title="Configuration Completed"><br>
-					  <hr noshade size=1></td></tr>
-
-					<tr>
-					<td align=center class="small" style="height:250px;"> 
-
-<?php
-
-	// Output html instead of plain text for the web
-	$useHtmlEntities = true;
-
-	require_once('install/5createTables.inc.php');
-
-	
-//populating forums data
-
-//this is to rename the installation file and folder so that no one destroys the setup
-$renamefile = uniqid(rand(), true);
-
-//@rename("install.php", $renamefile."install.php.txt");
-if(!rename("install.php", $renamefile."install.php.txt"))
-{
-	if (copy ("install.php", $renamefile."install.php.txt"))
-       	{
-        	 unlink($renamefile."install.php.txt");
-     	}
-}
-
-//@rename("install/", $renamefile."install/");
-if(!rename("install/", $renamefile."install/"))
-{
-	if (copy ("install/", $renamefile."install/"))
-       	{
-        	 unlink($renamefile."install/");
-     	}
-}
-//populate Calendar data
-
-
-?>
-		<table border=0 cellspacing=0 cellpadding=5 align="center" width=75% style="background-color:#E1E1FD;border:1px dashed #111111;">
-		<tr>
-			<td align=center class=small>
-			<b>vtigercrm-5.0.2 is all set to go!</b>
-			<hr noshade size=1>
-			<div style="width:100%;padding:10px; "align=left>
-			<ul>
-			<li>Your install.php file has been renamed to <?echo $renamefile;?>install.php.txt.
-			<li>Your install folder too has been renamed to <?echo $renamefile;?>install/.  
-			<li>Please log in using the "admin" user name and the password you entered in step 2.
-			</ul>
-			</div>
-
-			</td>
-		</tr>
-		</table>
-		<br>	
-		<table border=0 cellspacing=0 cellpadding=10 width=100%>
-		<tr><td colspan=2 align="center">
-				 <form action="index.php" method="post" name="form" id="form">
-				 <input type="hidden" name="default_user_name" value="admin">
-			 	 <input  type="image" src="include/install/images/cwBtnFinish.gif" name="next" title="Finish" value="Finish" />
-				 </form>
-		</td></tr>
-		</table>		
-		</td>
-
-		</tr>
-		</table>
-		<!-- Master display stops -->
-		
-	</td>
-	</tr>
-	</table>
-	</td>
-	</tr>
-	</table>
-
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-
-		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-	<tr>
-		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
-	</tr>
-	</table>
-    <table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
-
-      <tr>
-        <td class=small align=center> <a href="#">www.vtiger.com</a></td>
-      </tr>
-    </table>
-</body>
-</html>	
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is: SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/5createTables.php,v 1.58 2005/04/19 16:57:08 ray Exp $
+ * Description:  Executes a step in the installation process.
+ ********************************************************************************/
+set_time_limit(600);
+
+if (isset($_REQUEST['db_name'])) $db_name  				= $_REQUEST['db_name'];
+if (isset($_REQUEST['db_drop_tables'])) $db_drop_tables 	= $_REQUEST['db_drop_tables'];
+if (isset($_REQUEST['db_create'])) $db_create 			= $_REQUEST['db_create'];
+if (isset($_REQUEST['db_populate'])) $db_populate		= $_REQUEST['db_populate'];
+if (isset($_REQUEST['admin_email'])) $admin_email		= $_REQUEST['admin_email'];
+if (isset($_REQUEST['admin_password'])) $admin_password	= $_REQUEST['admin_password'];
+if (isset($_REQUEST['currency_name'])) $currency_name	= $_REQUEST['currency_name'];
+if (isset($_REQUEST['currency_code'])) $currency_code	= $_REQUEST['currency_code'];
+if (isset($_REQUEST['currency_symbol'])) $currency_symbol	= $_REQUEST['currency_symbol'];
+
+?>
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title>vtiger CRM 5 - Configuration Wizard - Finish</title>
+
+
+<link href="include/install/install.css" rel="stylesheet" type="text/css">
+</head>
+
+<body class="small cwPageBg" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
+
+	<br><br><br>
+	<!-- Table for cfgwiz starts -->
+
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td class="cwHeadBg" align=left><img src="include/install/images/configwizard.gif" alt="Configuration Wizard" hspace="20" title="Configuration Wizard"></td>
+		<td class="cwHeadBg" align=right><img src="include/install/images/vtigercrm5.gif" alt="vtiger CRM 5" title="vtiger CRM 5"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td background="include/install/images/topInnerShadow.gif" align=left><img src="include/install/images/topInnerShadow.gif" ></td>
+
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=10 width=80% align=center>
+	<tr>
+		<td class="small" bgcolor="#4572BE" align=center>
+			<!-- Master display -->
+			<table border=0 cellspacing=0 cellpadding=0 width=97%>
+			<tr>
+				<td width=20% valign=top>
+
+				<!-- Left side tabs -->
+					<table border=0 cellspacing=0 cellpadding=10 width=100%>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Welcome</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Installation Check</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">System Configuration</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Confirm Settings</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Config File Creation</div></td></tr>
+					<tr><td class="small cwUnSelectedTab" align=right><div align="left">Database Generation</div></td></tr>
+					<tr><td class="small cwSelectedTab" align=right><div align="left"><b>Finish</b></div></td></tr>
+					</table>
+					
+				</td>
+				<td width=80% valign=top class="cwContentDisplay" align=left>
+				<!-- Right side tabs -->
+					<table border=0 cellspacing=0 cellpadding=10 width=100%>
+					<tr><td class=small align=left><img src="include/install/images/confWizFinish.gif" alt="Configuration Completed" title="Configuration Completed"><br>
+					  <hr noshade size=1></td></tr>
+
+					<tr>
+					<td align=center class="small" style="height:250px;"> 
+
+<?php
+
+	// Output html instead of plain text for the web
+	$useHtmlEntities = true;
+
+	require_once('install/5createTables.inc.php');
+
+	
+//populating forums data
+
+//this is to rename the installation file and folder so that no one destroys the setup
+$renamefile = uniqid(rand(), true);
+
+//@rename("install.php", $renamefile."install.php.txt");
+if(!rename("install.php", $renamefile."install.php.txt"))
+{
+	if (copy ("install.php", $renamefile."install.php.txt"))
+       	{
+        	 unlink($renamefile."install.php.txt");
+     	}
+}
+
+//@rename("install/", $renamefile."install/");
+if(!rename("install/", $renamefile."install/"))
+{
+	if (copy ("install/", $renamefile."install/"))
+       	{
+        	 unlink($renamefile."install/");
+     	}
+}
+//populate Calendar data
+
+
+?>
+		<table border=0 cellspacing=0 cellpadding=5 align="center" width=75% style="background-color:#E1E1FD;border:1px dashed #111111;">
+		<tr>
+			<td align=center class=small>
+			<b>vtigercrm-5.0.3 is all set to go!</b>
+			<hr noshade size=1>
+			<div style="width:100%;padding:10px; "align=left>
+			<ul>
+			<li>Your install.php file has been renamed to <?php echo $renamefile;?>install.php.txt.
+			<li>Your install folder too has been renamed to <?php echo $renamefile;?>install/.  
+			<li>Please log in using the "admin" user name and the password you entered in step 2.
+			<li> Do not forget to set the outgoing emailserver setup accessible from Settings->Outgoing Server
+			</ul>
+		
+
+			<ul>
+			<li>
+			<li><b><font color='red'>You are the most important to us!</font></b>
+<li><b> We take pride in being associated with you</li></b>
+			<p>
+			<b>Talk to us at <a href='http://forums.vtiger.com' target="_blank">forums</a></b>
+			<p>
+			<b>Discuss with us at <a href='http://blogs.vtiger.com' target="_blank">blogs</a></b>
+			<p>
+			<b>We aim to be - simply the best. Come on over,there is space for you too!</b>
+			</ul>
+			</div>
+
+			</td>
+		</tr>
+		</table>
+		<br>	
+		<table border=0 cellspacing=0 cellpadding=10 width=100%>
+		<tr><td colspan=2 align="center">
+				 <form action="index.php" method="post" name="form" id="form">
+				 <input type="hidden" name="default_user_name" value="admin">
+			 	 <input  type="image" src="include/install/images/cwBtnFinish.gif" name="next" title="Finish" value="Finish" />
+				 </form>
+		</td></tr>
+		</table>		
+		</td>
+
+		</tr>
+		</table>
+		<!-- Master display stops -->
+		
+	</td>
+	</tr>
+	</table>
+	</td>
+	</tr>
+	</table>
+
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+
+		<td background="include/install/images/bottomGradient.gif"><img src="include/install/images/bottomGradient.gif"></td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+	<tr>
+		<td align=center><img src="include/install/images/bottomShadow.jpg"></td>
+	</tr>
+	</table>
+    <table border=0 cellspacing=0 cellpadding=0 width=80% align=center>
+
+      <tr>
+        <td class=small align=center> <a href="http://www.vtiger.com" target="_blank">www.vtiger.com</a></td>
+      </tr>
+    </table>
+</body>
+</html>	

Modified: vtigercrm/branches/5.1_jens/install/populateSeedData.php
==============================================================================
--- vtigercrm/branches/5.1_jens/install/populateSeedData.php (original)
+++ vtigercrm/branches/5.1_jens/install/populateSeedData.php Mon Apr 16 12:27:44 2007
@@ -1,1171 +1,1173 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/populateSeedData.php,v 1.17 2005/03/25 20:13:52 simian Exp $
- * Description:  Executes a step in the installation process.
- ********************************************************************************/
-
-require_once('config.php');
-
-require_once('modules/Leads/Leads.php');
-require_once('modules/Contacts/contactSeedData.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('modules/Accounts/Accounts.php');
-require_once('modules/Campaigns/Campaigns.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('modules/Calendar/Activity.php');
-require_once('include/database/PearDatabase.php');
-require_once('include/utils/utils.php');
-require_once('include/language/en_us.lang.php');
-require_once('include/ComboStrings.php');
-require_once('include/ComboUtil.php');
-require_once('modules/Products/Products.php');
-require_once('modules/PriceBooks/PriceBooks.php');
-require_once('modules/Vendors/Vendors.php');
-require_once('modules/Faq/Faq.php');
-require_once('modules/HelpDesk/HelpDesk.php');
-require_once('modules/Notes/Notes.php');
-require_once('modules/Quotes/Quotes.php');
-require_once('modules/SalesOrder/SalesOrder.php');
-require_once('modules/PurchaseOrder/PurchaseOrder.php');
-require_once('modules/Invoice/Invoice.php');
-require_once('modules/Emails/Emails.php');
-require_once('include/utils/InventoryUtils.php'); //Included to save inventory related products in demo data
-
-global $first_name_array;
-global $first_name_count;
-global $last_name_array;
-global $last_name_count;
-global $company_name_array;
-global $company_name_count;
-global $street_address_array;
-global $street_address_count;
-global $city_array;
-global $city_array_count;
-global $campaign_name_array,$campaign_type_array,$campaign_status_array;
-global $adb;
- $db = new PearDatabase();
-
-function add_digits($quantity, &$string, $min = 0, $max = 9)
-{
-	for($i=0; $i < $quantity; $i++)
-	{
-		$string .= rand($min,$max);
-	}
-}
-
-function create_phone_number()
-{
-	$phone = "(";
-$phone = $phone; // This line is useless, but gets around a code analyzer warning.  Bug submitted 4/28/04
-	add_digits(3, $phone);
-	$phone .= ") ";
-	add_digits(3, $phone);
-	$phone .= "-";
-	add_digits(4, $phone);
-	
-	return $phone;
-}
-
-function create_date()
-{
-	$date = "";
-	$date .= "2006";
-	$date .= "-";
-	$date .= rand(1,9);
-	$date .= "-";
-	$date .= rand(1,28);
-	
-	return $date;
-}
-
-//$adb->println("PSD dumping started");
-
-$account_ids = Array();
-$opportunity_ids = Array();
-$vendor_ids = Array();
-$contact_ids = Array();
-$product_ids = Array();
-$pricebook_ids = Array();
-$quote_ids = Array();
-$salesorder_ids = Array();
-$purchaseorder_ids = Array();
-$invoice_ids = Array();
-$email_ids = Array();
-
-// Determine the assigned user for all demo data.  This is the default user if set, or admin
-$assigned_user_name = "admin";
-if(isset($default_user_name) && $default_user_name != '' && isset($create_default_user) && $create_default_user)
-{
-	$assigned_user_name = $default_user_name;
-}
-
-// Look up the user id for the assigned user
-$seed_user = new Users();
-
-//$adb->println("PSD assignname=".$assigned_user_name);
-
-$assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);
-
-global $current_user;
-
-$current_user = new Users();
-$result = $current_user->retrieve_entity_info($assigned_user_id,'Users');
-
-$tagkey = 1;
-
-// Get _dom arrays
-$comboFieldNames = Array('leadsource'=>'leadsource_dom'
-		      ,'leadstatus'=>'lead_status_dom'
-		      ,'industry'=>'industry_dom'
-		      ,'rating'=>'rating_dom'
-                      ,'opportunity_type'=>'opportunity_type_dom'
-                      ,'sales_stage'=>'sales_stage_dom');
-$comboFieldArray = getComboArray($comboFieldNames);
-
-//$adb->println("PSD assignid=".$assigned_user_id);
-$adb->println("company_name_array");
-$adb->println($company_name_array);
-
-$cloudtag = Array ('SO_vendtl', 'X-CEED', 'X-CEED', 'vtiger_50usr');
-
-for($i = 0; $i < $company_name_count; $i++)
-{
-	
-	$account_name = $company_name_array[$i];
-
-	// Create new accounts.
-	$account = new Accounts();
-	$account->column_fields["accountname"] = $account_name;
-	$account->column_fields["phone"] = create_phone_number();
-	$account->column_fields["assigned_user_id"] = $assigned_user_id;
-
-	$whitespace = array(" ", ".", "&", "\/");
-	$website = str_replace($whitespace, "", strtolower($account->column_fields["accountname"]));
-	$account->column_fields["website"] = "www.".$website.".com";
-	
-	$account->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
-	$account->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
-	$account->column_fields["bill_state"] = "CA";
-	$account->column_fields["bill_code"] = rand(10000, 99999);
-	$account->column_fields["bill_country"] = 'USA';	
-
-	$account->column_fields["ship_street"] = $account->column_fields["bill_street"];
-	$account->column_fields["ship_city"] = $account->column_fields["bill_city"];
-	$account->column_fields["ship_state"] = $account->column_fields["bill_state"];
-	$account->column_fields["ship_code"] = $account->column_fields["bill_code"];
-	$account->column_fields["ship_country"] = $account->column_fields["bill_country"];	
-
-//      $key = array_rand($app_list_strings['industry_dom']);
-//      $account->industry = $app_list_strings['industry_dom'][$key];
-	$key = array_rand($comboFieldArray['industry_dom']);
-	$account->column_fields["industry"] = $comboFieldArray['industry_dom'][$key];
-
-	$account->column_fields["account_type"] = "Customer";
-
-	//$account->saveentity("Accounts");
-	$account->save("Accounts");
-	
-	$account_ids[] = $account->id;
-	
-	if ($i > 3)
-	{
-		$freetag = $adb->getUniqueId('vtiger_freetags');
-		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[1]', '$cloudtag[1]')";
-		$res = $adb->query($query);
-
-		$date = $adb->formatDate(date('YmdHis')); 
-		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$account->id.", $date, 'Accounts')";
-		$result = $adb->query($query_tag);
-	}
-
-
-//	$adb->println("PSD Account [".$account->id."] - ".$account_name);
-
-		
-//Create new opportunities
-	$opp = new Potentials();
-
-	$opp->column_fields["assigned_user_id"] = $assigned_user_id;
-	$opp->column_fields["potentialname"] = $account_name." - 1000 units";
-	$opp->column_fields["closingdate"] = & create_date();
-
-//      $key = array_rand($app_list_strings['lead_source_dom']);
-//      $opp->lead_source = $app_list_strings['lead_source_dom'][$key];
-	$key = array_rand($comboFieldArray['leadsource_dom']);
-	$opp->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
-
-//      $key = array_rand($app_list_strings['sales_stage_dom']);
-//      $opp->sales_stage = $app_list_strings['sales_stage_dom'][$key];
-	$comboSalesStageArray = Array ("Closed Won");
-	$key = array_rand($comboSalesStageArray);
-	$opp->column_fields["sales_stage"] = $comboSalesStageArray[$key];
-	
-//      $key = array_rand($app_list_strings['opportunity_type_dom']);
-//      $opp->opportunity_type = $app_list_strings['opportunity_type_dom'][$key];
-	$key = array_rand($comboFieldArray['opportunity_type_dom']);
-	$opp->column_fields["opportunity_type"] = $comboFieldArray['opportunity_type_dom'][$key];
-
-	$amount = array("10000", "25000", "50000", "75000"); 
-	$key = array_rand($amount);
-	$opp->column_fields["amount"] = $amount[$key];
-	$opp->column_fields["account_id"] = $account->id;
-
-	//$opp->saveentity("Potentials");
-	$opp->save("Potentials");
-	
-	$opportunity_ids[] = $opp->id;
-
-//	$adb->println("PSD Potential [".$opp->id."] - account[".$account->id."]");
-	
-}
-
-
-for($i=0; $i<10; $i++)
-{
-	$contact = new Contacts();
-	$contact->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
-	$contact->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
-	$contact->column_fields["assigned_user_id"] = $assigned_user_id;
-	
-	$contact->column_fields["email"] = strtolower($contact->column_fields["firstname"])."_".strtolower($contact->column_fields["lastname"])."@company.com";
-
-	$contact->column_fields["phone"] = create_phone_number();
-	$contact->column_fields["homephone"] = create_phone_number();
-	$contact->column_fields["mobile"] = create_phone_number();
-	
-	// Fill in a bogus address
-	$key = array_rand($street_address_array);
-	$contact->column_fields["mailingstreet"] = $street_address_array[$key];
-	$key = array_rand($city_array);
-	$contact->column_fields["mailingcity"] = $city_array[$key];
-	$contact->column_fields["mailingstate"] = "CA";
-	$contact->column_fields["mailingzip"] = '99999';
-	$contact->column_fields["mailingcountry"] = 'USA';	
-	if ($contact->column_fields["mailingcity"] == "San Mateo") 
-		$contact->column_fields["yahooid"] = "clint_oram";
-	elseif ($contact->column_fields["mailingcity"] == "San Francisco") 
-		$contact->column_fields["yahooid"] = "not_a_real_id";
-
-//      $key = array_rand($app_list_strings['lead_source_dom']);
-//      $contact->lead_source = $app_list_strings['lead_source_dom'][$key];
-	$key = array_rand($comboFieldArray['leadsource_dom']);
-	$contact->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
-
-	$titles = array("President", 
-					"VP Operations", 
-					"VP Sales", 
-					"Director Operations", 
-					"Director Sales", 
-					"Mgr Operations", 
-					"IT Developer", 
-					"");
-	$key = array_rand($titles);
-	$contact->column_fields["title"] = $titles[$key];
-	
-	$account_key = array_rand($account_ids);
-	$contact->column_fields["account_id"] = $account_ids[$account_key];
-
-	//$contact->saveentity("Contacts");
-	$contact->save("Contacts");
-	$contact_ids[] = $contact->id;
-
-	
-	if ($i > 8)
-	{
-		$freetag = $adb->getUniqueId('vtiger_freetags');
-		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[2]', '$cloudtag[2]')";
-		$res1 = $adb->query($query);
-
-		$date = $adb->formatDate(date('YmdHis')); 
-		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$contact->id.", $date, 'Contacts')";
-		$result1 = $adb->query($query_tag);
-	}
-	// This assumes that there will be one opportunity per company in the seed data.
-	$opportunity_key = array_rand($opportunity_ids);
-	//$query = "insert into opportunities_contacts set id='".create_guid()."', contact_id='$contact->id', contact_role='".$app_list_strings['opportunity_relationship_type_default_key']."', opportunity_id='".$opportunity_ids[$opportunity_key]."'";
-	//$db->query($query, true, "unable to create seed links between opportunities and contacts");
-
-	$query = "insert into vtiger_contpotentialrel ( contactid, potentialid ) values (".$contact->id.",".$opportunity_ids[$opportunity_key].")";
-	$db->query($query);
-
-//	$adb->println("PSD Contact [".$contact->id."] - account[".$account_ids[$account_key]."] - potential[".$opportunity_ids[$opportunity_key]."]");
-
-	//Create new tasks
-	/*$task = new Task();
-
-	$key = array_rand($task->default_task_name_values);
-	$task->name = $task->default_task_name_values[$key];
-	$task->date_due = & create_date();
-	$task->time_due = date("H:i:s",time());
-	$task->date_due_flag = 'off';
-	$task->assigned_user_id = $assigned_user_id;
-	
-	$key = array_rand($app_list_strings['task_status_dom']);
-	$task->status = $app_list_strings['task_status_dom'][$key];
-	$task->contact_id = $contact->id;
-	if ($contact->primary_address_city == "San Mateo") {
-		$task->parent_id = $account_ids[$account_key];
-		$task->parent_type = 'Accounts';
-		$task->save();
-	}*/
-
-}
-
-	$company_count=0;
-for($i=0; $i<10; $i++)
-{
-	$lead = new Leads();
-	$lead->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
-	$lead->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
-
-	if($i<5)
-       	{
-        	$lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$i]));
-       	}
-       	else
-       	{
-               	$lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$company_count]));
-               	$company_count++;
-       	}
-
-	$lead->column_fields["assigned_user_id"] = $assigned_user_id;
-	
-	$lead->column_fields["email"] = strtolower($lead->column_fields["firstname"])."_".strtolower($lead->column_fields["lastname"])."@company.com";
-	
-	$website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
-        $lead->column_fields["website"] = "www.".$website.".com";
-	
-	$lead->column_fields["phone"] = create_phone_number();
-	$lead->column_fields["mobile"] = create_phone_number();
-	
-	// Fill in a bogus address
-	$key = array_rand($street_address_array);
-	//$lead->address_street = $street_address_array[$key];
-	$lead->column_fields["lane"] = $street_address_array[$key];
-	$key = array_rand($city_array);
-	$lead->column_fields["city"] = $city_array[$key];
-	$lead->column_fields["state"] = "CA";
-	$lead->column_fields["code"] = '99999';
-	$lead->column_fields["country"] = 'USA';	
-	if ($lead->column_fields["city"] == "San Mateo") 
-		$lead->column_fields["yahooid"] = "clint_oram";
-	elseif ($lead->column_fields["city"] == "San Francisco") 
-		$lead->column_fields["yahooid"] = "not_a_real_id";
-
-//      $key = array_rand($app_list_strings['lead_source_dom']);
-//      $lead->lead_source = $app_list_strings['lead_source_dom'][$key];
-	$key = array_rand($comboFieldArray['leadsource_dom']);
-	$lead->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
-
-//      $key = array_rand($app_list_strings['lead_status_dom']);
-//      $lead->lead_status = $app_list_strings['lead_status_dom'][$key];
-	$key = array_rand($comboFieldArray['lead_status_dom']);
-	$lead->column_fields["leadstatus"] = $comboFieldArray['lead_status_dom'][$key];
-
-//      $key = array_rand($app_list_strings['rating_dom']);
-//      $lead->rating = $app_list_strings['rating_dom'][$key];
-	$key = array_rand($comboFieldArray['rating_dom']);
-	$lead->column_fields["rating"] = $comboFieldArray['rating_dom'][$key];	
-
-	$titles = array("President", 
-					"VP Operations", 
-					"VP Sales", 
-					"Director Operations", 
-					"Director Sales", 
-					"Mgr Operations", 
-					"IT Developer", 
-					"");
-	$key = array_rand($titles);
-	$lead->column_fields["designation"] = $titles[$key];
-
-	//$lead->saveentity("Leads");
-	$lead->save("Leads");
-
-//	$adb->println("PSD Lead [".$lead->id."] - name=".$lead->column_fields["lastname"]);
-
-}
-
-// Temp fix since user is not logged in while populating data updating creatorid in crmentity - GS
-
-
-//Populating Vendor Data
-for($i=0; $i<10; $i++)
-{
-	$vendor = new Vendors();
-	$vendor->column_fields["vendorname"] = ucfirst(strtolower($first_name_array[$i]));
-	$vendor->column_fields["phone"] = create_phone_number();
-	$vendor->column_fields["email"] = strtolower($vendor->column_fields["vendorname"])."@company.com";
-	$website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
-        $vendor->column_fields["website"] = "www.".$website.".com";
-
-	$vendor->column_fields["assigned_user_id"] = $assigned_user_id;
-	
-
-	
-	// Fill in a bogus address
-	$vendor->column_fields["street"] = $street_address_array[rand(0,$street_address_count-1)]; 
-	$key = array_rand($city_array);
-	$vendor->column_fields["city"] = $city_array[$key];
-	$vendor->column_fields["state"] = "CA";
-	$vendor->column_fields["postalcode"] = '99999';
-	$vendor->column_fields["country"] = 'USA';	
-
-	$vendor->save("Vendors");
-	$vendor_ids[] = $vendor->id;
-
-
-}
-
-
-//Populating Product Data
-
-$product_name_array= array( "Vtiger Single User Pack", "Vtiger 5 Users Pack", "Vtiger 10 Users Pack",
-        "Vtiger 25 Users Pack", "Vtiger 50 Users Pack", "Double Panel See-thru Clipboard",
-        "abcd1234", "Cd-R CD Recordable", "Sharp - Plain Paper Fax" , "Brother Ink Jet Cartridge"); 
-$product_code_array= array("001","002","003","023","005","sg-106","1324356","sg-108","sg-119","sg-125");
-$subscription_rate=array("149","699","1299","2999","4995");
-//added by jeri to populate product images
-$product_image_array = array("product1.jpeg###","product2.jpeg###product3.jpeg###","product4.jpeg###product5.jpeg###product6
-.jpeg###","product7.jpeg###product8.jpeg###product9.jpeg###product10.jpeg###");
-for($i=0; $i<10; $i++)
-{
-        $product = new Products();
-	if($i>4)
-	{
-		$parent_key = array_rand($opportunity_ids);
-		$product->column_fields["parent_id"]=$opportunity_ids[$parent_key];
-
-		$usageunit	=	"Each";
-		$qty_per_unit	=	1;
-		$qty_in_stock	=	rand(10000, 99999);
-		$category 	= 	"Hardware";		
-		$website 	=	"";
-		$manufacturer	= 	"";
-		$commission_rate=	rand(10,20);
-		$unit_price	=	rand(100,999);
-		$product_image_name = '';
-	}
-	else
-	{
-		$account_key = array_rand($account_ids);
-		$product->column_fields["parent_id"]=$account_ids[$account_key];
-
-		$usageunit	=	"Each";
-		$qty_per_unit	=	1;
-		$qty_in_stock	=	rand(10000, 99999);
-		$category 	= 	"Software";	
-		$website 	=	"www.vtiger.com";
-		$manufacturer	= 	"vtiger";
-		$commission_rate=	rand(1,10);
-		$unit_price	=	$subscription_rate[$i];
-		$product_image_name = $product_image_array[$i];
-	}
-
-        $product->column_fields["productname"] 	= 	$product_name_array[$i];
-        $product->column_fields["productcode"] 	= 	$product_code_array[$i];
-        $product->column_fields["manufacturer"]	= 	$manufacturer;
-
-	$product->column_fields["productcategory"] = 	$category;
-        $product->column_fields["website"] 	=	$website;
-        $product->column_fields["productsheet"] =	"";
-
-	$vendor_key = array_rand($vendor_ids);
-        $product->column_fields["vendor_id"] 	= 	$vendor_ids[$vendor_key];
-	$contact_key = array_rand($contact_ids);
-        $product->column_fields["contact_id"] 	= 	$contact_ids[$contact_key];
-
-        $product->column_fields["start_date"] 	= 	& create_date();
-        $product->column_fields["sales_start_date"] 	= & create_date();
-
-        $product->column_fields["unit_price"] 	= 	$unit_price;
-        $product->column_fields["commissionrate"] = 	$commission_rate;
-        $product->column_fields["taxclass"] 	= 	'SalesTax';
-        $product->column_fields["usageunit"]	= 	$usageunit;
-     	$product->column_fields["qty_per_unit"] = 	$qty_per_unit;
-        $product->column_fields["qtyinstock"] 	= 	$qty_in_stock;
-	$product->column_fields["imagename"] =  $product_image_name;
-
-	$product->save("Products");
-	$product_ids[] = $product ->id;
-}
-
-
-//Populating HelpDesk- FAQ Data
-
-	$status_array=array ("Draft","Reviewed","Published","Draft","Reviewed","Draft","Reviewed","Draft","Reviewed","Draft","Reviewed","Draft");
-	$question_array=array (
-	"How to migrate data from previous versions to the latest version?",
-	"Error message: The file is damaged and could not be repaired.",
-	"A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ",
-	"When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?",
-	" Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
-	"How to migrate data from previous versions to the latest version?",
-	"A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ",
-	" Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
-	"Error message: The file is damaged and could not be repaired.",
-	"When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?",
-	" Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
-	"How to migrate data from previous versions to the latest version?",
-	
-	);
-
-
-	$answer_array=array (
-	"Database migration scripts are available to migrate from the following versions:
-
-	1.0 to 2.0
-
-	2.0 to 2.1
-
-	2.1 to 3.0
-
-	3.0 to 3.2
-
-	3.2 to 4.0
-
-	4.0 to 4.0.1
-
-	4.0.1 to 4.2",
-	
-	"The above error message is due to version incompatibility between FPDF and PHP5. Use PHP 4.3.X version","Published",
-	"The above error message is displayed if you have installed the Microsoft(R) Outlook(R) E-mail Security Update. Please refer to the following URL for complete details:
-
-http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B263074
-
-If you want to continue working with vtiger Outlook Plug-in, select the Allow access for check box and select the time from drop-down box.",
-	" Since, vtigerCRM & all plugins are open source, it is not signed up with third party vendors and IE will ask to download even though the plugin are not signed.
-
-This message if produced by Microsoft Windows XP. I English Windows XP with the SP2 and the last updates. I told IE to accept installation of the ActiveX, but after it, this message has appeared. Provably there is a place where to tall to WinXP to not validate if the code is signed... but I don\'t know where.
-
-In IE from Tools->Internet Options->Security->Custom Level, there you can see various options for downloading plugins which are not signed and you can adjust according to your need, so relax your security settings for a while and give a try to vtiger Office Plugin.",
-	"Before modifying any templates, please ensure that you don\'t have any documents open and only one instance of word is available in your memory."
-	);
-
-$num_array=array(0,1,2,3,4,6,7,8,9,10,11,12);
-for($i=0;$i<12;$i++)
-{
-
-	$faq = new Faq();
-	
-	$rand=array_rand($num_array);
-	$faq->column_fields["product_id"]	= $product_ids[$i];
-	$faq->column_fields["faqcategories"]	= "General";
-	$faq->column_fields["faqstatus"] 	= $status_array[$i];
-	$faq->column_fields["question"]		= $question_array[$i];
-	$faq->column_fields["faq_answer"]	= $answer_array[$i];
-
-	$faq->save("Faq");
-	$faq_ids[] = $faq ->id;
-}
-
-//Populate Quote Data
-
-$sub_array = array ("Prod_Quote", "Cont_Quote", "SO_Quote", "PO_Quote", "Vendor_Quote");
-$stage_array = array ("Created", "Reviewed", "Delivered", "Accepted" , "Rejected");
-$carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
-$validtill_array = array ("2006-09-21", "2006-10-29", "2006-12-11", "2006-10-09", "2006-11-18");
-for($i=0;$i<5;$i++)
-{
-	$quote = new Quotes();
-	
-	$quote->column_fields["assigned_user_id"] = $assigned_user_id;
-	$account_key = array_rand($account_ids);
-	$quote->column_fields["account_id"] = $account_ids[$account_key];
-	$op_key = array_rand($opportunity_ids);
-	$quote->column_fields["potential_id"] = $opportunity_ids[$op_key];
-	$contact_key = array_rand($contact_ids);
-        $quote->column_fields["contact_id"] = $contact_ids[$contact_key];
-	$rand = array_rand($num_array);
-	$quote->column_fields["subject"] = $sub_array[$i];
-	$quote->column_fields["quotestage"] = $stage_array[$i];	
-	$quote->column_fields["carrier"] = $carrier_array[$i];
-	$quote->column_fields["validtill"] = $validtill_array[$i];
-
-	$quote->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
-	$quote->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
-	$quote->column_fields["bill_state"] = "CA";
-	$quote->column_fields["bill_code"] = rand(10000, 99999);
-	$quote->column_fields["bill_country"] = 'USA';	
-
-	$quote->column_fields["ship_street"] = $account->column_fields["bill_street"];
-	$quote->column_fields["ship_city"] = $account->column_fields["bill_city"];
-	$quote->column_fields["ship_state"] = $account->column_fields["bill_state"];
-	$quote->column_fields["ship_code"] = $account->column_fields["bill_code"];
-	$quote->column_fields["ship_country"] = $account->column_fields["bill_country"];	
-
-	
-	$quote->save("Quotes");
-
-	$quote_ids[] = $quote->id;
-
-	$product_key = array_rand($product_ids); 
-	$productid = $product_ids[$product_key];
-
-	//set the inventory product details in request then just call the saveInventoryProductDetails function 
-	$_REQUEST['totalProductCount']	 = 1;
-
-	$_REQUEST['hdnProductId1'] = $productid;
-	$_REQUEST['qty1'] = $qty = 1;
-	$_REQUEST['listPrice1'] = $listprice = 130;
-	$_REQUEST['comment1'] = "This is test comment for product of Quotes";
-	
-	$_REQUEST['deleted1'] = 0;
-	$_REQUEST['discount_type1'] = 'amount';
-	$_REQUEST['discount_amount1'] = $discount_amount = '20';
-
-	$_REQUEST['taxtype'] = $taxtype = 'individual';
-	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
-	$_REQUEST['discount_type_final'] = 'amount';
-	$_REQUEST['discount_amount_final'] = $discount_amount_final = '10';
-	
-	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
-	$_REQUEST['adjustmenttype'] = '+';
-	$_REQUEST['adjustment'] = $adjustment = '10';
-
-	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
-
-	//Upto this added to set the request values which will be used to save the inventory product details
-
-	//Now call the saveInventoryProductDetails function
-	saveInventoryProductDetails(&$quote, 'Quotes');
-}
-
-//Populate SalesOrder Data
-
-$subj_array = array ("SO_vtiger", "SO_zoho", "SO_vtiger5usrp", "SO_vt100usrpk", "SO_vendtl");
-$status_array = array ("Created",  "Delivered", "Approved" , "Cancelled" , "Created");
-$carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
-$duedate_array = array ("2006-09-21", "2006-10-29", "2006-12-11", "2006-10-09", "2006-11-18");
-
-for($i=0;$i<5;$i++)
-{
-	$so = new SalesOrder();
-	
-	$so->column_fields["assigned_user_id"] = $assigned_user_id;
-	$account_key = array_rand($account_ids);
-	$so->column_fields["account_id"] = $account_ids[$account_key];
-	$quote_key = array_rand($quote_ids);
-	$so->column_fields["quote_id"] = $quote_ids[$quote_key];
-	$contact_key = array_rand($contact_ids);
-        $so->column_fields["contact_id"] = $contact_ids[$contact_key];
-	$rand = array_rand($num_array);
-	$so->column_fields["subject"] = $subj_array[$i];
-	$so->column_fields["sostatus"] = $status_array[$i];	
-	$so->column_fields["hdnGrandTotal"] = $sototal_array[$i];
-	$so->column_fields["carrier"] = $carrier_array[$i];
-	$so->column_fields["duedate"] = $duedate_array[$i];
-
-	$so->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
-	$so->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
-	$so->column_fields["bill_state"] = "CA";
-	$so->column_fields["bill_code"] = rand(10000, 99999);
-	$so->column_fields["bill_country"] = 'USA';	
-
-	$so->column_fields["ship_street"] = $account->column_fields["bill_street"];
-	$so->column_fields["ship_city"] = $account->column_fields["bill_city"];
-	$so->column_fields["ship_state"] = $account->column_fields["bill_state"];
-	$so->column_fields["ship_code"] = $account->column_fields["bill_code"];
-	$so->column_fields["ship_country"] = $account->column_fields["bill_country"];	
-
-	
-	$so->save("SalesOrder");
-
-	$salesorder_ids[] = $so->id;
-
-	$product_key = array_rand($product_ids); 
-	$productid = $product_ids[$product_key];
-
-	//set the inventory product details in request then just call the saveInventoryProductDetails function 
-	$_REQUEST['totalProductCount']	 = 1;
-
-	$_REQUEST['hdnProductId1'] = $productid;
-	$_REQUEST['qty1'] = $qty = 1;
-	$_REQUEST['listPrice1'] = $listprice = 1230;
-	$_REQUEST['comment1'] = "This is test comment for product of SalesOrder";
-	
-	$_REQUEST['deleted1'] = 0;
-	$_REQUEST['discount_type1'] = 'amount';
-	$_REQUEST['discount_amount1'] = $discount_amount = '200';
-
-	$_REQUEST['taxtype'] = $taxtype = 'individual';
-	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
-	$_REQUEST['discount_type_final'] = 'amount';
-	$_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
-	
-	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
-	$_REQUEST['adjustmenttype'] = '+';
-	$_REQUEST['adjustment'] = $adjustment = '100';
-
-	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
-
-	//Upto this added to set the request values which will be used to save the inventory product details
-
-	//Now call the saveInventoryProductDetails function
-	saveInventoryProductDetails(&$so, 'SalesOrder');
-
-
-}
-
-
-//Populate PurchaseOrder Data
-
-$psubj_array = array ("PO_vtiger", "PO_zoho", "PO_vtiger5usrp", "PO_vt100usrpk", "PO_vendtl");
-$pstatus_array = array ("Created",  "Delivered", "Approved" , "Cancelled", "Recieved Shipment");
-$carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
-$trkno_array = array ("po1425", "po2587", "po7974", "po7979", "po6411"); 
-$duedate_array = array ("2006-09-21", "2006-10-29", "2006-12-11", "2006-10-09", "2006-11-18");
-
-for($i=0;$i<5;$i++)
-{
-	$po = new PurchaseOrder();
-	
-	$po->column_fields["assigned_user_id"] = $assigned_user_id;
-	$vendor_key = array_rand($vendor_ids);
-	$po->column_fields["vendor_id"] = $vendor_ids[$vendor_key];
-	$contact_key = array_rand($contact_ids);
-        $po->column_fields["contact_id"] = $contact_ids[$contact_key];
-	$rand = array_rand($num_array);
-	$po->column_fields["subject"] = $psubj_array[$i];
-	$po->column_fields["postatus"] = $pstatus_array[$i];	
-	$po->column_fields["carrier"] = $carrier_array[$i];
-	$po->column_fields["tracking_no"] = $trkno_array[$i];
-	$po->column_fields["duedate"] = $duedate_array[$i];
-
-	$po->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
-	$po->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
-	$po->column_fields["bill_state"] = "CA";
-	$po->column_fields["bill_code"] = rand(10000, 99999);
-	$po->column_fields["bill_country"] = 'USA';	
-
-	$po->column_fields["ship_street"] = $account->column_fields["bill_street"];
-	$po->column_fields["ship_city"] = $account->column_fields["bill_city"];
-	$po->column_fields["ship_state"] = $account->column_fields["bill_state"];
-	$po->column_fields["ship_code"] = $account->column_fields["bill_code"];
-	$po->column_fields["ship_country"] = $account->column_fields["bill_country"];	
-		
-	
-	$po->save("PurchaseOrder");
-
-	$purchaseorder_ids[] = $po->id;
-
-	$product_key = array_rand($product_ids); 
-	$productid = $product_ids[$product_key];
-
-	//set the inventory product details in request then just call the saveInventoryProductDetails function 
-	$_REQUEST['totalProductCount']	 = 1;
-
-	$_REQUEST['hdnProductId1'] = $productid;
-	$_REQUEST['qty1'] = $qty = 1;
-	$_REQUEST['listPrice1'] = $listprice = 2200;
-	$_REQUEST['comment1'] = "This is test comment for product of PurchaseOrder";
-	
-	$_REQUEST['deleted1'] = 0;
-	$_REQUEST['discount_type1'] = 'amount';
-	$_REQUEST['discount_amount1'] = $discount_amount = '200';
-
-	$_REQUEST['taxtype'] = $taxtype = 'individual';
-	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
-	$_REQUEST['discount_type_final'] = 'amount';
-	$_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
-	
-	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
-	$_REQUEST['adjustmenttype'] = '+';
-	$_REQUEST['adjustment'] = $adjustment = '100';
-
-	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
-
-	//Upto this added to set the request values which will be used to save the inventory product details
-
-	//Now call the saveInventoryProductDetails function
-	saveInventoryProductDetails(&$po, 'PurchaseOrder');
-
-
-}
-
-//Populate Invoice Data
-
-$isubj_array = array ("vtiger_invoice201", "zoho_inv7841", "vtiger5usrp_invoice71134", "vt100usrpk_inv113", "vendtl_inv214");
-$istatus_array = array ("Created",  "Sent", "Approved" , "Credit Invoice", "Paid");
-$itotal_array = array ("4842.000", "4842.000", "4842.000", "4842.000", "4842.000");
-
-for($i=0;$i<5;$i++)
-{
-	$invoice = new Invoice();
-	
-	$invoice->column_fields["assigned_user_id"] = $assigned_user_id;
-	$account_key = array_rand($account_ids);
-	$invoice->column_fields["account_id"] = $account_ids[$account_key];
-	$so_key = array_rand($salesorder_ids);
-	$invoice->column_fields["salesorder_id"] = $salesorder_ids[$so_key];
-	$contact_key = array_rand($contact_ids);
-        $invoice->column_fields["contactid"] = $contact_ids[$contact_key];
-	$rand = array_rand($num_array);
-	$invoice->column_fields["subject"] = $isubj_array[$i];
-	$invoice->column_fields["invoicestatus"] = $istatus_array[$i];	
-	$invoice->column_fields["hdnGrandTotal"] = $itotal_array[$i];
-
-	$invoice->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
-	$invoice->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
-	$invoice->column_fields["bill_state"] = "CA";
-	$invoice->column_fields["bill_code"] = rand(10000, 99999);
-	$invoice->column_fields["bill_country"] = 'USA';	
-
-	$invoice->column_fields["ship_street"] = $account->column_fields["bill_street"];
-	$invoice->column_fields["ship_city"] = $account->column_fields["bill_city"];
-	$invoice->column_fields["ship_state"] = $account->column_fields["bill_state"];
-	$invoice->column_fields["ship_code"] = $account->column_fields["bill_code"];
-	$invoice->column_fields["ship_country"] = $account->column_fields["bill_country"];	
-	
-	
-	$invoice->save("Invoice");
-
-	$invoice_ids[] = $invoice->id;
-	if ($i > 3)
-	{
-		$freetag = $adb->getUniqueId('vtiger_freetags');
-		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[0]', '$cloudtag[0]')";
-		$res_inv = $adb->query($query);
-
-		$date = $adb->formatDate(date('YmdHis')); 
-		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$invoice->id.", $date, 'Invoice')";
-		$result_inv = $adb->query($query_tag);
-	}
-
-	$product_key = array_rand($product_ids); 
-	$productid = $product_ids[$product_key];
-
-	//set the inventory product details in request then just call the saveInventoryProductDetails function 
-	$_REQUEST['totalProductCount']	 = 1;
-
-	$_REQUEST['hdnProductId1'] = $productid;
-	$_REQUEST['qty1'] = $qty = 1;
-	$_REQUEST['listPrice1'] = $listprice = 4300;
-	$_REQUEST['comment1'] = "This is test comment for product of Invoice";
-	
-	$_REQUEST['deleted1'] = 0;
-	$_REQUEST['discount_type1'] = 'amount';
-	$_REQUEST['discount_amount1'] = $discount_amount = '300';
-
-	$_REQUEST['taxtype'] = $taxtype = 'individual';
-	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
-	$_REQUEST['discount_type_final'] = 'amount';
-	$_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
-	
-	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
-	$_REQUEST['adjustmenttype'] = '+';
-	$_REQUEST['adjustment'] = $adjustment = '100';
-
-	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
-
-	//Upto this added to set the request values which will be used to save the inventory product details
-
-	//Now call the saveInventoryProductDetails function
-	saveInventoryProductDetails(&$invoice, 'Invoice');
-
-}
-
-//Populate RSS Data
-
-
-
-
-//Populate Email Data
-
-$esubj_array =  array ("Vtiger 5 Released", "Try vtigercrm!", "Hi There!!!", "Welcome to Open Source", "Help needed in customization of Vtiger");
-$startdate_array =  array ("2006-1-2","2003-3-4","2003-4-5","2001-2-1","2005-8-8");
-$filename_array = array ("vtiger5alpha.tar.gz", "zohowriter.zip", "hi.doc", "welcome.pps", "sos.doc");
-
-$to_array = array("a at a.com","b at b.com", "tester at testvtiger.com","xanth at yaz.com","violet at bing.com");
-$cc_array = array("andrewa at a.com","casterb at b.com", "indomine at variancevtiger.com","becker at nosbest.com","electra at violet.com");
-$bcc_array = array("nathan at nathantests.com","jeff at karl1.com", "isotope at uranium.com","bunny at bugs.com","explosive at dud.com");
-$from_array = array("harvest at zss.com","rain at sunshine.com", "gloom at rainyday.com");
-$body_array = array("This is a good product! Have a go at it! ","Nice to have you visit us, very nice of you. Stay for sometime and have a look at our product. I am sure you will like it", "This will take some time to fix. Can you provide me more details please?","What a cool tool! I wish I had found it earlier. Oh it has a lot of my friends name in it too! I too can contribute. But how?","Urgent. I need this done last week! Guys, you are the ones I am depending on. Do something!");
-
-for($i=0;$i<5;$i++)
-{
-	$email = new Emails();
-
-	$email->column_fields["assigned_user_id"] = $assigned_user_id;
-	
-	$rand = array_rand($num_array);
-	$email->column_fields["subject"] = $esubj_array[$i];
-	$email->column_fields["filename"] = $filename_array[$i];	
-	$email->column_fields["date_start"] = $startdate_array[$i];
-	$email->column_fields["semodule"] = 'Tasks';
-	$email->column_fields["activitytype"] = 'Emails';
-	$email->column_fields["description"] = $body_array[$i];	
-	$email->save("Emails");
-	$email_ids[] = $email->id;
-	
-	$query = "insert into vtiger_emaildetails(emailid,from_email,to_email,cc_email,bcc_email) values (".$email->id.", '".$from_array[$i]."', '".$to_array[$i]."','".$cc_array[$i]."','".$bcc_array[$i] ."')";
-		$res = $adb->query($query);
-}
-
-
-//Populate PriceBook data
-
-$PB_array = array ("Cd-R PB", "Vtiger PB", "Gator PB", "Kyple PB", "Pastor PB", "Zoho PB", "PB_100", "Per_PB", "CST_PB", "GATE_PB", "Chevron_PB", "Pizza_PB");
-$Active_array = array ("0", "1", "1", "0", "1","0", "1", "1", "0", "1","0","1");
-
-//$num_array = array(0,1,2,3,4);
-for($i=0;$i<12;$i++)
-{
-	$pricebook = new PriceBooks();
-
-	$rand = array_rand($num_array);
-	$pricebook->column_fields["bookname"]   = $PB_array[$i];
-	$pricebook->column_fields["active"]     = $Active_array[$i];
-
-	$pricebook->save("PriceBooks");
-	$pricebook_ids[] = $pricebook ->id;
-}
-
-
-//Populate Notes Data
-
-$notes_array = array ("Cont_Notes", "Prod_Notes", "Vendor_Notes", "Invoice_Notes", "Task_Notes", "Event_Notes", "Email_Notes");
-
-for($i=0;$i<7;$i++)
-{
-	$notes = new Notes();
-
-	$rand = array_rand($num_array);
-	$contact_key = array_rand($contact_ids);
-        $notes->column_fields["contact_id"] 	= 	$contact_ids[$contact_key];
-	$notes->column_fields["notes_title"]		=	$notes_array[$i];
-
-	$notes->save("Notes");
-	$notes_ids[] = $notes ->id;
-	
-	$product_key = array_rand($product_ids);
-        $query = "insert into vtiger_senotesrel (crmid, notesid) values (".$product_ids[$product_key].", ".$notes->id.")";
-	$db->query($query);
-		
-}
-
-
-
-// Populate Ticket data
-
-
-//$severity_array=array("Minor","Major","Critical","");
-$status_array=array("Open","In Progress","Wait For Response","Open","Closed");
-$category_array=array("Big Problem ","Small Problem","Other Problem","Small Problem","Other Problem");
-$ticket_title_array=array("Upload Attachment problem",
-			"Individual Customization -Menu and RSS","Export Output query",
-		"Import Error CSV Leads","How to automatically add a lead from a web form to VTiger");
-
-for($i=0;$i<5;$i++)
-{
-	$helpdesk= new HelpDesk();
-	
-	$rand=array_rand($num_array);
-	$contact_key = array_rand($contact_ids);
-        $helpdesk->column_fields["parent_id"] 	= 	$contact_ids[$contact_key];
-
-	$helpdesk->column_fields["ticketpriorities"]= "Normal";
-	$helpdesk->column_fields["product_id"]	= 	$product_ids[$i];
-
-	$helpdesk->column_fields["ticketseverities"]	= "Minor";
-	$helpdesk->column_fields["ticketstatus"]	= $status_array[$i];
-	$helpdesk->column_fields["ticketcategories"]	= $category_array[$i];
-	//$rand_key = array_rand($s);$contact_key = array_rand($contact_ids);
-        $notes->column_fields["contact_id"] 	= 	$contact_ids[$contact_key];
-	$helpdesk->column_fields["ticket_title"]	= $ticket_title_array[$i];
-        $helpdesk->column_fields["assigned_user_id"] = $assigned_user_id;
-	
-	$helpdesk->save("HelpDesk");
-	$helpdesk_ids[] = $helpdesk->id;
-	
-	if ($i > 3)
-	{
-		$freetag = $adb->getUniqueId('vtiger_freetags');
-		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[3]', '$cloudtag[3]')";
-		$res_tkt = $adb->query($query);
-
-		$date = $adb->formatDate(date('YmdHis')); 
-		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$helpdesk->id.", $date, 'HelpDesk')";
-		$result_tkt = $adb->query($query_tag);
-	}
-
-}
-
-// Populate Activities Data
-$task_array=array("Tele Conference","Call user - John","Send Fax to Mary Smith");
-$event_array=array("","","Call Smith","Team Meeting","Call Richie","Meeting with Don");
-$task_status_array=array("Planned","In Progress","Completed");
-$task_priority_array=array("High","Medium","Low");
-$visibility=array("","","Private","Public","Private","Public");
-
-for($i=0;$i<6;$i++)
-{
-	$event = new Activity();
-	
-	$rand_num=array_rand($num_array);
-
-	$rand_date = & create_date();
-	$en=explode("-",$rand_date);
-	if($en[1]<10)
-		$en[1]="0".$en[1];
-	if($en[2]<10)
-		$en[2]="0".$en[2];
-	$recur_daily_date=date('Y-m-d',mktime(0,0,0,date($en[1]),date($en[2])+5,date($en[0])));
-	$recur_week_date=date('Y-m-d',mktime(0,0,0,date($en[1]),date($en[2])+30,date($en[0])));
-
-
-	$start_time_hr=rand(00,23);
-	$start_time_min=rand(00,59);
-	$end_time_hr=rand(00,23);
-	$end_time_min=rand(00,59);
-	if($start_time_hr<10)
-		$start_time_hr="0".$start_time_hr;
-	if($start_time_min<10)
-		$start_time_min="0".$start_time_min;
-	if($end_time_hr<10)
-		$end_time_hr="0".$end_time_hr;
-	if($end_time_min<10)
-		$end_time_min="0".$end_time_min;
-	$end_time=$end_time_hr.":".$end_time_min;
-	$start_time=$start_time_hr.":".$start_time_min;
-	if($i<2)
-	{
-		$event->column_fields["subject"]	= $task_array[$i];	
-		if($i==1)
-		{
-			$account_key = array_rand($account_ids);
-			$event->column_fields["parent_id"]	= $account_ids[$account_key];;	
-		}
-		$event->column_fields["taskstatus"]	= $task_status_array[$i];	
-		$event->column_fields["taskpriority"]	= $task_priority_array[$i];	
-		$event->column_fields["activitytype"]	= "Task";
-		$event->column_fields["visibility"] = $visibility[$i];	
-				
-	}
-	else
-	{
-		$event->column_fields["subject"]	= $event_array[$i];	
-		$event->column_fields["visibility"] = $visibility[$i];
-		$event->column_fields["duration_hours"]	= rand(0,3);	
-		$event->column_fields["duration_minutes"]= rand(0,59);	
-		$event->column_fields["eventstatus"]	= "Planned";	
-		$event->column_fields["time_end"]     = $end_time;
-	}
-	$event->column_fields["date_start"]	= $rand_date;	
-	$_REQUEST["date_start"] = $rand_date;
-	$event->column_fields["time_start"]	= $start_time;	
-	$event->column_fields["due_date"]	= $rand_date;	
-	$_REQUEST["due_date"] = $rand_date;
-	$contact_key = array_rand($contact_ids);
-        $event->column_fields["contact_id"]	= 	$contact_ids[$contact_key];
-	if($i==4)
-	{
-        	$event->column_fields["recurringtype"] 	= "Daily";
-		$_REQUEST["recurringtype"]  = "Daily";
-		$event->column_fields["activitytype"]	= "Meeting";	
-		$event->column_fields["due_date"]	= $recur_daily_date;	
-	}
-	elseif($i==5)
-	{	
-        	$event->column_fields["recurringtype"] 	= "Weekly";
-		$_REQUEST["recurringtype"]  = "Weekly";
-		$event->column_fields["activitytype"]	= "Meeting";	
-		$event->column_fields["due_date"]	= $recur_week_date;	
-	}
-	elseif($i>1) 
-	{
-		$event->column_fields["activitytype"]	= "Call";	
-	}
-	$event->column_fields["assigned_user_id"] = $assigned_user_id;
-	$event->save("Calendar");
-        $event_ids[] = $event->id;
-
-}
-
-
-$adb->query("update vtiger_crmentity set smcreatorid=".$assigned_user_id);
-
-$expected_revenue = Array("250000","750000","500000");
-$budget_cost = Array("25000","50000","90000");
-$actual_cost = Array("23500","45000","80000");
-$num_sent = Array("2000","2500","3000");
-$clo_date = Array('2003-1-2','2004-2-3','2005-4-12');
-
-$expected_response_count = Array("2500","7500","5000");
-$expected_sales_count = Array("25000","50000","90000");
-$expected_roi = Array("23","45","82");
-
-$actual_response_count = Array("250","750","1500");
-$actual_sales_count = Array("1250","5200","2390");
-$actual_roi = Array("21","14","12");
-
-$sponsor = Array("Finace","Marketing","Sales");
-$targetsize = Array("210000","13390","187424");
-$targetaudience = Array("Managers","CEOs","Rookies");
-
-//$expected_response = Array(null,null,null);
-for($i=0;$i<count($campaign_name_array);$i++)
-{
-	$campaign = new Campaigns();
-	$campaign_name = $campaign_name_array[$i];
-	$campaign->column_fields["campaignname"] = $campaign_name;
-	$campaign->column_fields["campaigntype"] = $campaign_type_array[$i];
-	$campaign->column_fields["campaignstatus"] = $campaign_status_array[$i];
-	$campaign->column_fields["numsent"] = $num_sent[$i];
-	$campaign->column_fields["expectedrevenue"] = $expected_revenue[$i];
-	$campaign->column_fields["budgetcost"] = $budget_cost[$i];
-	$campaign->column_fields["actualcost"] = $actual_cost[$i];
-	$campaign->column_fields["closingdate"] = $clo_date[$i];
-	$campaign->column_fields["expectedresponse"] = $expected_response[$i];
-	$campaign->column_fields["assigned_user_id"] = $assigned_user_id;
-	
-	$campaign->column_fields["expectedresponsecount"] = $expected_response_count[$i];
-	$campaign->column_fields["expectedsalescount"] = $expected_sales_count[$i];
-	$campaign->column_fields["expectedroi"] = $expected_roi[$i];
-	$campaign->column_fields["actualresponsecount"] = $actual_response_count[$i];
-	$campaign->column_fields["actualsalescount"] = $actual_sales_count[$i];
-	$campaign->column_fields["actualroi"] = $actual_roi[$i];
-	$campaign->column_fields["sponsor"] = $sponsor[$i];
-	$campaign->column_fields["targetsize"] = $targetsize[$i];
-	$campaign->column_fields["targetaudience"] = $targetaudience[$i];
-
-
-	
-	$campaign->save("Campaigns");
-}
-
-//Populate My Sites Data 
-
-$portalname = array ("Vtiger", "Vtiger Blogs", "Vtiger Forums", "VtigerForge", "Vtiger Docs");
-$portalurl = array ("http://vtiger.com", "http://blogs.vtiger.com", "http://forums.vtiger.com", "http://vtigerforge.com", "http://wiki.vtiger.com");
-
-for($i=0;$i<5;$i++)
-{
-	$portalid = $adb->getUniqueId('vtiger_portal');
-	$portal_qry = "insert into vtiger_portal values (".$portalid.", '".$portalname[$i]."','".$portalurl[$i]."',0)";
-	$result_qry = $adb->query($portal_qry);
-}
-
-//Populate RSS Data
-$rssname = array("vtiger - Forums","vtiger development - Active Tickets");
-$rssurl = array("http://forums.vtiger.com/rss.php?name=forums&file=rss","http://vtiger.fosslabs.com/cgi-bin/trac.cgi/report/1?format=rss&USER=anonymous");
-
-for($i=0;$i<2;$i++)
-{
-	$rssid = $adb->getUniqueId('vtiger_rss');
-	$rss_qry = "insert into vtiger_rss values (".$rssid.", '".$rssurl[$i]."','".$rssname[$i]."',0,0)";
-	$result_qry = $adb->query($rss_qry);
-}
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/populateSeedData.php,v 1.17 2005/03/25 20:13:52 simian Exp $
+ * Description:  Executes a step in the installation process.
+ ********************************************************************************/
+
+require_once('config.php');
+
+require_once('modules/Leads/Leads.php');
+require_once('modules/Contacts/contactSeedData.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('modules/Accounts/Accounts.php');
+require_once('modules/Campaigns/Campaigns.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('modules/Calendar/Activity.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/utils/utils.php');
+require_once('include/language/en_us.lang.php');
+require_once('include/ComboStrings.php');
+require_once('include/ComboUtil.php');
+require_once('modules/Products/Products.php');
+require_once('modules/PriceBooks/PriceBooks.php');
+require_once('modules/Vendors/Vendors.php');
+require_once('modules/Faq/Faq.php');
+require_once('modules/HelpDesk/HelpDesk.php');
+require_once('modules/Notes/Notes.php');
+require_once('modules/Quotes/Quotes.php');
+require_once('modules/SalesOrder/SalesOrder.php');
+require_once('modules/PurchaseOrder/PurchaseOrder.php');
+require_once('modules/Invoice/Invoice.php');
+require_once('modules/Emails/Emails.php');
+require_once('include/utils/InventoryUtils.php'); //Included to save inventory related products in demo data
+
+global $first_name_array;
+global $first_name_count;
+global $last_name_array;
+global $last_name_count;
+global $company_name_array;
+global $company_name_count;
+global $street_address_array;
+global $street_address_count;
+global $city_array;
+global $city_array_count;
+global $campaign_name_array,$campaign_type_array,$campaign_status_array;
+global $adb;
+ $db = new PearDatabase();
+
+function add_digits($quantity, &$string, $min = 0, $max = 9)
+{
+	for($i=0; $i < $quantity; $i++)
+	{
+		$string .= rand($min,$max);
+	}
+}
+
+function create_phone_number()
+{
+	$phone = "(";
+$phone = $phone; // This line is useless, but gets around a code analyzer warning.  Bug submitted 4/28/04
+	add_digits(3, $phone);
+	$phone .= ") ";
+	add_digits(3, $phone);
+	$phone .= "-";
+	add_digits(4, $phone);
+	
+	return $phone;
+}
+
+function create_date()
+{
+	$date = "";
+	$date .= "2006";
+	$date .= "-";
+	$date .= rand(1,9);
+	$date .= "-";
+	$date .= rand(1,28);
+	
+	return $date;
+}
+
+//$adb->println("PSD dumping started");
+
+$account_ids = Array();
+$opportunity_ids = Array();
+$vendor_ids = Array();
+$contact_ids = Array();
+$product_ids = Array();
+$pricebook_ids = Array();
+$quote_ids = Array();
+$salesorder_ids = Array();
+$purchaseorder_ids = Array();
+$invoice_ids = Array();
+$email_ids = Array();
+
+// Determine the assigned user for all demo data.  This is the default user if set, or admin
+$assigned_user_name = "admin";
+if(isset($default_user_name) && $default_user_name != '' && isset($create_default_user) && $create_default_user)
+{
+	$assigned_user_name = $default_user_name;
+}
+
+// Look up the user id for the assigned user
+$seed_user = new Users();
+
+//$adb->println("PSD assignname=".$assigned_user_name);
+
+$assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);
+
+global $current_user;
+
+$current_user = new Users();
+$result = $current_user->retrieve_entity_info($assigned_user_id,'Users');
+
+$tagkey = 1;
+
+// Get _dom arrays
+$comboFieldNames = Array('leadsource'=>'leadsource_dom'
+		      ,'leadstatus'=>'lead_status_dom'
+		      ,'industry'=>'industry_dom'
+		      ,'rating'=>'rating_dom'
+                      ,'opportunity_type'=>'opportunity_type_dom'
+                      ,'sales_stage'=>'sales_stage_dom');
+$comboFieldArray = getComboArray($comboFieldNames);
+
+//$adb->println("PSD assignid=".$assigned_user_id);
+$adb->println("company_name_array");
+$adb->println($company_name_array);
+
+$cloudtag = Array ('SO_vendtl', 'X-CEED', 'X-CEED', 'vtiger_50usr');
+
+for($i = 0; $i < $company_name_count; $i++)
+{
+	
+	$account_name = $company_name_array[$i];
+
+	// Create new accounts.
+	$account = new Accounts();
+	$account->column_fields["accountname"] = $account_name;
+	$account->column_fields["phone"] = create_phone_number();
+	$account->column_fields["assigned_user_id"] = $assigned_user_id;
+
+	$whitespace = array(" ", ".", "&", "\/");
+	$website = str_replace($whitespace, "", strtolower($account->column_fields["accountname"]));
+	$account->column_fields["website"] = "www.".$website.".com";
+	
+	$account->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
+	$account->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
+	$account->column_fields["bill_state"] = "CA";
+	$account->column_fields["bill_code"] = rand(10000, 99999);
+	$account->column_fields["bill_country"] = 'USA';	
+
+	$account->column_fields["ship_street"] = $account->column_fields["bill_street"];
+	$account->column_fields["ship_city"] = $account->column_fields["bill_city"];
+	$account->column_fields["ship_state"] = $account->column_fields["bill_state"];
+	$account->column_fields["ship_code"] = $account->column_fields["bill_code"];
+	$account->column_fields["ship_country"] = $account->column_fields["bill_country"];	
+
+//      $key = array_rand($app_list_strings['industry_dom']);
+//      $account->industry = $app_list_strings['industry_dom'][$key];
+	$key = array_rand($comboFieldArray['industry_dom']);
+	$account->column_fields["industry"] = $comboFieldArray['industry_dom'][$key];
+
+	$account->column_fields["account_type"] = "Customer";
+
+	//$account->saveentity("Accounts");
+	$account->save("Accounts");
+	
+	$account_ids[] = $account->id;
+	
+	if ($i > 3)
+	{
+		$freetag = $adb->getUniqueId('vtiger_freetags');
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[1]', '$cloudtag[1]')";
+		$res = $adb->query($query);
+
+		$date = $adb->formatDate(date('YmdHis')); 
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$account->id.", $date, 'Accounts')";
+		$result = $adb->query($query_tag);
+	}
+
+
+//	$adb->println("PSD Account [".$account->id."] - ".$account_name);
+
+		
+//Create new opportunities
+	$opp = new Potentials();
+
+	$opp->column_fields["assigned_user_id"] = $assigned_user_id;
+	$opp->column_fields["potentialname"] = $account_name." - 1000 units";
+	$opp->column_fields["closingdate"] = & create_date();
+
+//      $key = array_rand($app_list_strings['lead_source_dom']);
+//      $opp->lead_source = $app_list_strings['lead_source_dom'][$key];
+	$key = array_rand($comboFieldArray['leadsource_dom']);
+	$opp->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
+
+//      $key = array_rand($app_list_strings['sales_stage_dom']);
+//      $opp->sales_stage = $app_list_strings['sales_stage_dom'][$key];
+	$comboSalesStageArray = Array ("Closed Won","Needs Analysis","Value Proposition","Qualification","Prospecting","Id.Decision Makers");
+	$key = array_rand($comboSalesStageArray);
+	$opp->column_fields["sales_stage"] = $comboSalesStageArray[$key];
+	
+//      $key = array_rand($app_list_strings['opportunity_type_dom']);
+//      $opp->opportunity_type = $app_list_strings['opportunity_type_dom'][$key];
+	$key = array_rand($comboFieldArray['opportunity_type_dom']);
+	$opp->column_fields["opportunity_type"] = $comboFieldArray['opportunity_type_dom'][$key];
+
+	$amount = array("10000", "25000", "50000", "75000"); 
+	$key = array_rand($amount);
+	$opp->column_fields["amount"] = $amount[$key];
+	$opp->column_fields["account_id"] = $account->id;
+
+	//$opp->saveentity("Potentials");
+	$opp->save("Potentials");
+	
+	$opportunity_ids[] = $opp->id;
+
+//	$adb->println("PSD Potential [".$opp->id."] - account[".$account->id."]");
+	
+}
+
+
+for($i=0; $i<10; $i++)
+{
+	$contact = new Contacts();
+	$contact->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
+	$contact->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
+	$contact->column_fields["assigned_user_id"] = $assigned_user_id;
+	
+	$contact->column_fields["email"] = strtolower($contact->column_fields["firstname"])."_".strtolower($contact->column_fields["lastname"])."@company.com";
+
+	$contact->column_fields["phone"] = create_phone_number();
+	$contact->column_fields["homephone"] = create_phone_number();
+	$contact->column_fields["mobile"] = create_phone_number();
+	
+	// Fill in a bogus address
+	$key = array_rand($street_address_array);
+	$contact->column_fields["mailingstreet"] = $street_address_array[$key];
+	$key = array_rand($city_array);
+	$contact->column_fields["mailingcity"] = $city_array[$key];
+	$contact->column_fields["mailingstate"] = "CA";
+	$contact->column_fields["mailingzip"] = '99999';
+	$contact->column_fields["mailingcountry"] = 'USA';	
+	if ($contact->column_fields["mailingcity"] == "San Mateo") 
+		$contact->column_fields["yahooid"] = "clint_oram";
+	elseif ($contact->column_fields["mailingcity"] == "San Francisco") 
+		$contact->column_fields["yahooid"] = "not_a_real_id";
+
+//      $key = array_rand($app_list_strings['lead_source_dom']);
+//      $contact->lead_source = $app_list_strings['lead_source_dom'][$key];
+	$key = array_rand($comboFieldArray['leadsource_dom']);
+	$contact->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
+
+	$titles = array("President", 
+					"VP Operations", 
+					"VP Sales", 
+					"Director Operations", 
+					"Director Sales", 
+					"Mgr Operations", 
+					"IT Developer", 
+					"");
+	$key = array_rand($titles);
+	$contact->column_fields["title"] = $titles[$key];
+	
+	$account_key = array_rand($account_ids);
+	$contact->column_fields["account_id"] = $account_ids[$account_key];
+
+	//$contact->saveentity("Contacts");
+	$contact->save("Contacts");
+	$contact_ids[] = $contact->id;
+
+	
+	if ($i > 8)
+	{
+		$freetag = $adb->getUniqueId('vtiger_freetags');
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[2]', '$cloudtag[2]')";
+		$res1 = $adb->query($query);
+
+		$date = $adb->formatDate(date('YmdHis')); 
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$contact->id.", $date, 'Contacts')";
+		$result1 = $adb->query($query_tag);
+	}
+	// This assumes that there will be one opportunity per company in the seed data.
+	$opportunity_key = array_rand($opportunity_ids);
+	//$query = "insert into opportunities_contacts set id='".create_guid()."', contact_id='$contact->id', contact_role='".$app_list_strings['opportunity_relationship_type_default_key']."', opportunity_id='".$opportunity_ids[$opportunity_key]."'";
+	//$db->query($query, true, "unable to create seed links between opportunities and contacts");
+
+	$query = "insert into vtiger_contpotentialrel ( contactid, potentialid ) values (".$contact->id.",".$opportunity_ids[$opportunity_key].")";
+	$db->query($query);
+
+//	$adb->println("PSD Contact [".$contact->id."] - account[".$account_ids[$account_key]."] - potential[".$opportunity_ids[$opportunity_key]."]");
+
+	//Create new tasks
+	/*$task = new Task();
+
+	$key = array_rand($task->default_task_name_values);
+	$task->name = $task->default_task_name_values[$key];
+	$task->date_due = & create_date();
+	$task->time_due = date("H:i:s",time());
+	$task->date_due_flag = 'off';
+	$task->assigned_user_id = $assigned_user_id;
+	
+	$key = array_rand($app_list_strings['task_status_dom']);
+	$task->status = $app_list_strings['task_status_dom'][$key];
+	$task->contact_id = $contact->id;
+	if ($contact->primary_address_city == "San Mateo") {
+		$task->parent_id = $account_ids[$account_key];
+		$task->parent_type = 'Accounts';
+		$task->save();
+	}*/
+
+}
+
+	$company_count=0;
+for($i=0; $i<10; $i++)
+{
+	$lead = new Leads();
+	$lead->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
+	$lead->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
+
+	if($i<5)
+       	{
+        	$lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$i]));
+       	}
+       	else
+       	{
+               	$lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$company_count]));
+               	$company_count++;
+       	}
+
+	$lead->column_fields["assigned_user_id"] = $assigned_user_id;
+	
+	$lead->column_fields["email"] = strtolower($lead->column_fields["firstname"])."_".strtolower($lead->column_fields["lastname"])."@company.com";
+	
+	$website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
+        $lead->column_fields["website"] = "www.".$website.".com";
+	
+	$lead->column_fields["phone"] = create_phone_number();
+	$lead->column_fields["mobile"] = create_phone_number();
+	
+	// Fill in a bogus address
+	$key = array_rand($street_address_array);
+	//$lead->address_street = $street_address_array[$key];
+	$lead->column_fields["lane"] = $street_address_array[$key];
+	$key = array_rand($city_array);
+	$lead->column_fields["city"] = $city_array[$key];
+	$lead->column_fields["state"] = "CA";
+	$lead->column_fields["code"] = '99999';
+	$lead->column_fields["country"] = 'USA';	
+	if ($lead->column_fields["city"] == "San Mateo") 
+		$lead->column_fields["yahooid"] = "clint_oram";
+	elseif ($lead->column_fields["city"] == "San Francisco") 
+		$lead->column_fields["yahooid"] = "not_a_real_id";
+
+//      $key = array_rand($app_list_strings['lead_source_dom']);
+//      $lead->lead_source = $app_list_strings['lead_source_dom'][$key];
+	$key = array_rand($comboFieldArray['leadsource_dom']);
+	$lead->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
+
+//      $key = array_rand($app_list_strings['lead_status_dom']);
+//      $lead->lead_status = $app_list_strings['lead_status_dom'][$key];
+	$key = array_rand($comboFieldArray['lead_status_dom']);
+	$lead->column_fields["leadstatus"] = $comboFieldArray['lead_status_dom'][$key];
+
+//      $key = array_rand($app_list_strings['rating_dom']);
+//      $lead->rating = $app_list_strings['rating_dom'][$key];
+	$key = array_rand($comboFieldArray['rating_dom']);
+	$lead->column_fields["rating"] = $comboFieldArray['rating_dom'][$key];	
+
+	$titles = array("President", 
+					"VP Operations", 
+					"VP Sales", 
+					"Director Operations", 
+					"Director Sales", 
+					"Mgr Operations", 
+					"IT Developer", 
+					"");
+	$key = array_rand($titles);
+	$lead->column_fields["designation"] = $titles[$key];
+
+	//$lead->saveentity("Leads");
+	$lead->save("Leads");
+
+//	$adb->println("PSD Lead [".$lead->id."] - name=".$lead->column_fields["lastname"]);
+
+}
+
+// Temp fix since user is not logged in while populating data updating creatorid in crmentity - GS
+
+
+//Populating Vendor Data
+for($i=0; $i<10; $i++)
+{
+	$vendor = new Vendors();
+	$vendor->column_fields["vendorname"] = ucfirst(strtolower($first_name_array[$i]));
+	$vendor->column_fields["phone"] = create_phone_number();
+	$vendor->column_fields["email"] = strtolower($vendor->column_fields["vendorname"])."@company.com";
+	$website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
+        $vendor->column_fields["website"] = "www.".$website.".com";
+
+	$vendor->column_fields["assigned_user_id"] = $assigned_user_id;
+	
+
+	
+	// Fill in a bogus address
+	$vendor->column_fields["street"] = $street_address_array[rand(0,$street_address_count-1)]; 
+	$key = array_rand($city_array);
+	$vendor->column_fields["city"] = $city_array[$key];
+	$vendor->column_fields["state"] = "CA";
+	$vendor->column_fields["postalcode"] = '99999';
+	$vendor->column_fields["country"] = 'USA';	
+
+	$vendor->save("Vendors");
+	$vendor_ids[] = $vendor->id;
+
+
+}
+
+
+//Populating Product Data
+
+$product_name_array= array( "Vtiger Single User Pack", "Vtiger 5 Users Pack", "Vtiger 10 Users Pack",
+        "Vtiger 25 Users Pack", "Vtiger 50 Users Pack", "Double Panel See-thru Clipboard",
+        "abcd1234", "Cd-R CD Recordable", "Sharp - Plain Paper Fax" , "Brother Ink Jet Cartridge"); 
+$product_code_array= array("001","002","003","023","005","sg-106","1324356","sg-108","sg-119","sg-125");
+$subscription_rate=array("149","699","1299","2999","4995");
+//added by jeri to populate product images
+$product_image_array = array("product1.jpeg###","product2.jpeg###product3.jpeg###","product4.jpeg###product5.jpeg###product6
+.jpeg###","product7.jpeg###product8.jpeg###product9.jpeg###product10.jpeg###");
+for($i=0; $i<10; $i++)
+{
+        $product = new Products();
+	if($i>4)
+	{
+		$parent_key = array_rand($opportunity_ids);
+		$product->column_fields["parent_id"]=$opportunity_ids[$parent_key];
+
+		$usageunit	=	"Each";
+		$qty_per_unit	=	1;
+		$qty_in_stock	=	rand(10000, 99999);
+		$category 	= 	"Hardware";		
+		$website 	=	"";
+		$manufacturer	= 	"";
+		$commission_rate=	rand(10,20);
+		$unit_price	=	rand(100,999);
+		$product_image_name = '';
+	}
+	else
+	{
+		$account_key = array_rand($account_ids);
+		$product->column_fields["parent_id"]=$account_ids[$account_key];
+
+		$usageunit	=	"Each";
+		$qty_per_unit	=	1;
+		$qty_in_stock	=	rand(10000, 99999);
+		$category 	= 	"Software";	
+		$website 	=	"www.vtiger.com";
+		$manufacturer	= 	"vtiger";
+		$commission_rate=	rand(1,10);
+		$unit_price	=	$subscription_rate[$i];
+		$product_image_name = $product_image_array[$i];
+	}
+
+        $product->column_fields["productname"] 	= 	$product_name_array[$i];
+        $product->column_fields["productcode"] 	= 	$product_code_array[$i];
+        $product->column_fields["manufacturer"]	= 	$manufacturer;
+
+	$product->column_fields["productcategory"] = 	$category;
+        $product->column_fields["website"] 	=	$website;
+        $product->column_fields["productsheet"] =	"";
+
+	$vendor_key = array_rand($vendor_ids);
+        $product->column_fields["vendor_id"] 	= 	$vendor_ids[$vendor_key];
+	$contact_key = array_rand($contact_ids);
+        $product->column_fields["contact_id"] 	= 	$contact_ids[$contact_key];
+
+        $product->column_fields["start_date"] 	= 	& create_date();
+        $product->column_fields["sales_start_date"] 	= & create_date();
+
+        $product->column_fields["unit_price"] 	= 	$unit_price;
+        $product->column_fields["commissionrate"] = 	$commission_rate;
+        $product->column_fields["taxclass"] 	= 	'SalesTax';
+        $product->column_fields["usageunit"]	= 	$usageunit;
+     	$product->column_fields["qty_per_unit"] = 	$qty_per_unit;
+        $product->column_fields["qtyinstock"] 	= 	$qty_in_stock;
+	$product->column_fields["imagename"] =  $product_image_name;
+
+	$product->save("Products");
+	$product_ids[] = $product ->id;
+}
+
+
+//Populating HelpDesk- FAQ Data
+
+	$status_array=array ("Draft","Reviewed","Published","Draft","Reviewed","Draft","Reviewed","Draft","Reviewed","Draft","Reviewed","Draft");
+	$question_array=array (
+	"How to migrate data from previous versions to the latest version?",
+	"Error message: The file is damaged and could not be repaired.",
+	"A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ",
+	"When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?",
+	" Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
+	"How to migrate data from previous versions to the latest version?",
+	"A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ",
+	" Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
+	"Error message: The file is damaged and could not be repaired.",
+	"When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?",
+	" Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
+	"How to migrate data from previous versions to the latest version?",
+	
+	);
+
+
+	$answer_array=array (
+	"Database migration scripts are available to migrate from the following versions:
+
+	1.0 to 2.0
+
+	2.0 to 2.1
+
+	2.1 to 3.0
+
+	3.0 to 3.2
+
+	3.2 to 4.0
+
+	4.0 to 4.0.1
+
+	4.0.1 to 4.2",
+	
+	"The above error message is due to version incompatibility between FPDF and PHP5. Use PHP 4.3.X version","Published",
+	"The above error message is displayed if you have installed the Microsoft(R) Outlook(R) E-mail Security Update. Please refer to the following URL for complete details:
+
+http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B263074
+
+If you want to continue working with vtiger Outlook Plug-in, select the Allow access for check box and select the time from drop-down box.",
+	" Since, vtigerCRM & all plugins are open source, it is not signed up with third party vendors and IE will ask to download even though the plugin are not signed.
+
+This message if produced by Microsoft Windows XP. I English Windows XP with the SP2 and the last updates. I told IE to accept installation of the ActiveX, but after it, this message has appeared. Provably there is a place where to tall to WinXP to not validate if the code is signed... but I don\'t know where.
+
+In IE from Tools->Internet Options->Security->Custom Level, there you can see various options for downloading plugins which are not signed and you can adjust according to your need, so relax your security settings for a while and give a try to vtiger Office Plugin.",
+	"Before modifying any templates, please ensure that you don\'t have any documents open and only one instance of word is available in your memory."
+	);
+
+$num_array=array(0,1,2,3,4,6,7,8,9,10,11,12);
+for($i=0;$i<12;$i++)
+{
+
+	$faq = new Faq();
+	
+	$rand=array_rand($num_array);
+	$faq->column_fields["product_id"]	= $product_ids[$i];
+	$faq->column_fields["faqcategories"]	= "General";
+	$faq->column_fields["faqstatus"] 	= $status_array[$i];
+	$faq->column_fields["question"]		= $question_array[$i];
+	$faq->column_fields["faq_answer"]	= $answer_array[$i];
+
+	$faq->save("Faq");
+	$faq_ids[] = $faq ->id;
+}
+
+//Populate Quote Data
+
+$sub_array = array ("Prod_Quote", "Cont_Quote", "SO_Quote", "PO_Quote", "Vendor_Quote");
+$stage_array = array ("Created", "Reviewed", "Delivered", "Accepted" , "Rejected");
+$carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
+$validtill_array = array ("2007-09-21", "2007-10-29", "2007-12-11", "2007-03-29", "2007-06-18");
+for($i=0;$i<5;$i++)
+{
+	$quote = new Quotes();
+	
+	$quote->column_fields["assigned_user_id"] = $assigned_user_id;
+	$account_key = array_rand($account_ids);
+	$quote->column_fields["account_id"] = $account_ids[$account_key];
+	$op_key = array_rand($opportunity_ids);
+	$quote->column_fields["potential_id"] = $opportunity_ids[$op_key];
+	$contact_key = array_rand($contact_ids);
+        $quote->column_fields["contact_id"] = $contact_ids[$contact_key];
+	$rand = array_rand($num_array);
+	$quote->column_fields["subject"] = $sub_array[$i];
+	$quote->column_fields["quotestage"] = $stage_array[$i];	
+	$quote->column_fields["carrier"] = $carrier_array[$i];
+	$quote->column_fields["validtill"] = $validtill_array[$i];
+
+	$quote->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
+	$quote->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
+	$quote->column_fields["bill_state"] = "CA";
+	$quote->column_fields["bill_code"] = rand(10000, 99999);
+	$quote->column_fields["bill_country"] = 'USA';	
+
+	$quote->column_fields["ship_street"] = $account->column_fields["bill_street"];
+	$quote->column_fields["ship_city"] = $account->column_fields["bill_city"];
+	$quote->column_fields["ship_state"] = $account->column_fields["bill_state"];
+	$quote->column_fields["ship_code"] = $account->column_fields["bill_code"];
+	$quote->column_fields["ship_country"] = $account->column_fields["bill_country"];	
+
+	
+	$quote->save("Quotes");
+
+	$quote_ids[] = $quote->id;
+
+	$product_key = array_rand($product_ids); 
+	$productid = $product_ids[$product_key];
+
+	//set the inventory product details in request then just call the saveInventoryProductDetails function 
+	$_REQUEST['totalProductCount']	 = 1;
+
+	$_REQUEST['hdnProductId1'] = $productid;
+	$_REQUEST['qty1'] = $qty = 1;
+	$_REQUEST['listPrice1'] = $listprice = 130;
+	$_REQUEST['comment1'] = "This is test comment for product of Quotes";
+	
+	$_REQUEST['deleted1'] = 0;
+	$_REQUEST['discount_type1'] = 'amount';
+	$_REQUEST['discount_amount1'] = $discount_amount = '20';
+
+	$_REQUEST['taxtype'] = $taxtype = 'individual';
+	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
+	$_REQUEST['discount_type_final'] = 'amount';
+	$_REQUEST['discount_amount_final'] = $discount_amount_final = '10';
+	
+	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
+	$_REQUEST['adjustmenttype'] = '+';
+	$_REQUEST['adjustment'] = $adjustment = '10';
+
+	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
+
+	//Upto this added to set the request values which will be used to save the inventory product details
+
+	//Now call the saveInventoryProductDetails function
+	saveInventoryProductDetails(&$quote, 'Quotes');
+}
+
+//Populate SalesOrder Data
+
+$subj_array = array ("SO_vtiger", "SO_zoho", "SO_vtiger5usrp", "SO_vt100usrpk", "SO_vendtl");
+$status_array = array ("Created",  "Delivered", "Approved" , "Cancelled" , "Created");
+$carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
+$duedate_array = array ("2007-04-21", "2007-05-29", "2007-08-11", "2007-09-09", "2007-02-28");
+
+for($i=0;$i<5;$i++)
+{
+	$so = new SalesOrder();
+	
+	$so->column_fields["assigned_user_id"] = $assigned_user_id;
+	$account_key = array_rand($account_ids);
+	$so->column_fields["account_id"] = $account_ids[$account_key];
+	$quote_key = array_rand($quote_ids);
+	$so->column_fields["quote_id"] = $quote_ids[$quote_key];
+	$contact_key = array_rand($contact_ids);
+        $so->column_fields["contact_id"] = $contact_ids[$contact_key];
+	$rand = array_rand($num_array);
+	$so->column_fields["subject"] = $subj_array[$i];
+	$so->column_fields["sostatus"] = $status_array[$i];	
+	$so->column_fields["hdnGrandTotal"] = $sototal_array[$i];
+	$so->column_fields["carrier"] = $carrier_array[$i];
+	$so->column_fields["duedate"] = $duedate_array[$i];
+
+	$so->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
+	$so->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
+	$so->column_fields["bill_state"] = "CA";
+	$so->column_fields["bill_code"] = rand(10000, 99999);
+	$so->column_fields["bill_country"] = 'USA';	
+
+	$so->column_fields["ship_street"] = $account->column_fields["bill_street"];
+	$so->column_fields["ship_city"] = $account->column_fields["bill_city"];
+	$so->column_fields["ship_state"] = $account->column_fields["bill_state"];
+	$so->column_fields["ship_code"] = $account->column_fields["bill_code"];
+	$so->column_fields["ship_country"] = $account->column_fields["bill_country"];	
+
+	
+	$so->save("SalesOrder");
+
+	$salesorder_ids[] = $so->id;
+
+	$product_key = array_rand($product_ids); 
+	$productid = $product_ids[$product_key];
+
+	//set the inventory product details in request then just call the saveInventoryProductDetails function 
+	$_REQUEST['totalProductCount']	 = 1;
+
+	$_REQUEST['hdnProductId1'] = $productid;
+	$_REQUEST['qty1'] = $qty = 1;
+	$_REQUEST['listPrice1'] = $listprice = 1230;
+	$_REQUEST['comment1'] = "This is test comment for product of SalesOrder";
+	
+	$_REQUEST['deleted1'] = 0;
+	$_REQUEST['discount_type1'] = 'amount';
+	$_REQUEST['discount_amount1'] = $discount_amount = '200';
+
+	$_REQUEST['taxtype'] = $taxtype = 'individual';
+	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
+	$_REQUEST['discount_type_final'] = 'amount';
+	$_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
+	
+	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
+	$_REQUEST['adjustmenttype'] = '+';
+	$_REQUEST['adjustment'] = $adjustment = '100';
+
+	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
+
+	//Upto this added to set the request values which will be used to save the inventory product details
+
+	//Now call the saveInventoryProductDetails function
+	saveInventoryProductDetails(&$so, 'SalesOrder');
+
+
+}
+
+
+//Populate PurchaseOrder Data
+
+$psubj_array = array ("PO_vtiger", "PO_zoho", "PO_vtiger5usrp", "PO_vt100usrpk", "PO_vendtl");
+$pstatus_array = array ("Created",  "Delivered", "Approved" , "Cancelled", "Recieved Shipment");
+$carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
+$trkno_array = array ("po1425", "po2587", "po7974", "po7979", "po6411"); 
+$duedate_array = array ("2007-04-21", "2007-05-29", "2007-07-11", "2007-04-09", "2006-08-18");
+
+for($i=0;$i<5;$i++)
+{
+	$po = new PurchaseOrder();
+	
+	$po->column_fields["assigned_user_id"] = $assigned_user_id;
+	$vendor_key = array_rand($vendor_ids);
+	$po->column_fields["vendor_id"] = $vendor_ids[$vendor_key];
+	$contact_key = array_rand($contact_ids);
+        $po->column_fields["contact_id"] = $contact_ids[$contact_key];
+	$rand = array_rand($num_array);
+	$po->column_fields["subject"] = $psubj_array[$i];
+	$po->column_fields["postatus"] = $pstatus_array[$i];	
+	$po->column_fields["carrier"] = $carrier_array[$i];
+	$po->column_fields["tracking_no"] = $trkno_array[$i];
+	$po->column_fields["duedate"] = $duedate_array[$i];
+
+	$po->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
+	$po->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
+	$po->column_fields["bill_state"] = "CA";
+	$po->column_fields["bill_code"] = rand(10000, 99999);
+	$po->column_fields["bill_country"] = 'USA';	
+
+	$po->column_fields["ship_street"] = $account->column_fields["bill_street"];
+	$po->column_fields["ship_city"] = $account->column_fields["bill_city"];
+	$po->column_fields["ship_state"] = $account->column_fields["bill_state"];
+	$po->column_fields["ship_code"] = $account->column_fields["bill_code"];
+	$po->column_fields["ship_country"] = $account->column_fields["bill_country"];	
+		
+	
+	$po->save("PurchaseOrder");
+
+	$purchaseorder_ids[] = $po->id;
+
+	$product_key = array_rand($product_ids); 
+	$productid = $product_ids[$product_key];
+
+	//set the inventory product details in request then just call the saveInventoryProductDetails function 
+	$_REQUEST['totalProductCount']	 = 1;
+
+	$_REQUEST['hdnProductId1'] = $productid;
+	$_REQUEST['qty1'] = $qty = 1;
+	$_REQUEST['listPrice1'] = $listprice = 2200;
+	$_REQUEST['comment1'] = "This is test comment for product of PurchaseOrder";
+	
+	$_REQUEST['deleted1'] = 0;
+	$_REQUEST['discount_type1'] = 'amount';
+	$_REQUEST['discount_amount1'] = $discount_amount = '200';
+
+	$_REQUEST['taxtype'] = $taxtype = 'individual';
+	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
+	$_REQUEST['discount_type_final'] = 'amount';
+	$_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
+	
+	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
+	$_REQUEST['adjustmenttype'] = '+';
+	$_REQUEST['adjustment'] = $adjustment = '100';
+
+	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
+
+	//Upto this added to set the request values which will be used to save the inventory product details
+
+	//Now call the saveInventoryProductDetails function
+	saveInventoryProductDetails(&$po, 'PurchaseOrder');
+
+
+}
+
+//Populate Invoice Data
+
+$isubj_array = array ("vtiger_invoice201", "zoho_inv7841", "vtiger5usrp_invoice71134", "vt100usrpk_inv113", "vendtl_inv214");
+$invoiceno_array = array ("INV2007_1","INV2007_2","INV2007_3","INV2007_4","INV2007_5");
+$istatus_array = array ("Created",  "Sent", "Approved" , "Credit Invoice", "Paid");
+$itotal_array = array ("4842.000", "4842.000", "4842.000", "4842.000", "4842.000");
+
+for($i=0;$i<5;$i++)
+{
+	$invoice = new Invoice();
+	
+	$invoice->column_fields["assigned_user_id"] = $assigned_user_id;
+	$account_key = array_rand($account_ids);
+	$invoice->column_fields["account_id"] = $account_ids[$account_key];
+	$so_key = array_rand($salesorder_ids);
+	$invoice->column_fields["salesorder_id"] = $salesorder_ids[$so_key];
+	$contact_key = array_rand($contact_ids);
+        $invoice->column_fields["contactid"] = $contact_ids[$contact_key];
+	$rand = array_rand($num_array);
+	$invoice->column_fields["subject"] = $isubj_array[$i];
+	$invoice->column_fields["invoice_no"] = $invoiceno_array[$i];
+	$invoice->column_fields["invoicestatus"] = $istatus_array[$i];	
+	$invoice->column_fields["hdnGrandTotal"] = $itotal_array[$i];
+
+	$invoice->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
+	$invoice->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
+	$invoice->column_fields["bill_state"] = "CA";
+	$invoice->column_fields["bill_code"] = rand(10000, 99999);
+	$invoice->column_fields["bill_country"] = 'USA';	
+
+	$invoice->column_fields["ship_street"] = $account->column_fields["bill_street"];
+	$invoice->column_fields["ship_city"] = $account->column_fields["bill_city"];
+	$invoice->column_fields["ship_state"] = $account->column_fields["bill_state"];
+	$invoice->column_fields["ship_code"] = $account->column_fields["bill_code"];
+	$invoice->column_fields["ship_country"] = $account->column_fields["bill_country"];	
+	
+	
+	$invoice->save("Invoice");
+
+	$invoice_ids[] = $invoice->id;
+	if ($i > 3)
+	{
+		$freetag = $adb->getUniqueId('vtiger_freetags');
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[0]', '$cloudtag[0]')";
+		$res_inv = $adb->query($query);
+
+		$date = $adb->formatDate(date('YmdHis')); 
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$invoice->id.", $date, 'Invoice')";
+		$result_inv = $adb->query($query_tag);
+	}
+
+	$product_key = array_rand($product_ids); 
+	$productid = $product_ids[$product_key];
+
+	//set the inventory product details in request then just call the saveInventoryProductDetails function 
+	$_REQUEST['totalProductCount']	 = 1;
+
+	$_REQUEST['hdnProductId1'] = $productid;
+	$_REQUEST['qty1'] = $qty = 1;
+	$_REQUEST['listPrice1'] = $listprice = 4300;
+	$_REQUEST['comment1'] = "This is test comment for product of Invoice";
+	
+	$_REQUEST['deleted1'] = 0;
+	$_REQUEST['discount_type1'] = 'amount';
+	$_REQUEST['discount_amount1'] = $discount_amount = '300';
+
+	$_REQUEST['taxtype'] = $taxtype = 'individual';
+	$_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
+	$_REQUEST['discount_type_final'] = 'amount';
+	$_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
+	
+	$_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
+	$_REQUEST['adjustmenttype'] = '+';
+	$_REQUEST['adjustment'] = $adjustment = '100';
+
+	$_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
+
+	//Upto this added to set the request values which will be used to save the inventory product details
+
+	//Now call the saveInventoryProductDetails function
+	saveInventoryProductDetails(&$invoice, 'Invoice');
+
+}
+
+//Populate RSS Data
+
+
+
+
+//Populate Email Data
+
+$esubj_array =  array ("Vtiger 5.0.3 Released", "Try vtigercrm!", "Hi There!!!", "Welcome to Open Source", "Help needed in customization of Vtiger");
+$startdate_array =  array ("2007-07-27","2007-05-09","2007-04-05","2007-11-01","2007-08-18");
+$filename_array = array ("vtiger5alpha.tar.gz", "zohowriter.zip", "hi.doc", "welcome.pps", "sos.doc");
+
+$to_array = array("a at a.com","b at b.com", "tester at testvtiger.com","xanth at yaz.com","violet at bing.com");
+$cc_array = array("andrewa at a.com","casterb at b.com", "indomine at variancevtiger.com","becker at nosbest.com","electra at violet.com");
+$bcc_array = array("nathan at nathantests.com","jeff at karl1.com", "isotope at uranium.com","bunny at bugs.com","explosive at dud.com");
+$from_array = array("harvest at zss.com","rain at sunshine.com", "gloom at rainyday.com","joy at vtiger.com","success at vtiger.com");
+$body_array = array("This release has close to 500 fixes in it and has gone through almost 7 rounds of validation. We think it is a stable product that you can directly use in deployment! ","Nice to have you visit us, very nice of you. Stay for sometime and have a look at our product. I am sure you will like it", "This will take some time to fix. Can you provide me more details please?","What a cool tool! I wish I had found it earlier. Oh it has a lot of my friends name in it too! I too can contribute. But how?","Urgent. I need this done last week! Guys, you are the ones I am depending on. Do something!");
+
+for($i=0;$i<5;$i++)
+{
+	$email = new Emails();
+
+	$email->column_fields["assigned_user_id"] = $assigned_user_id;
+	
+	$rand = array_rand($num_array);
+	$email->column_fields["subject"] = $esubj_array[$i];
+	$email->column_fields["filename"] = $filename_array[$i];	
+	$email->column_fields["date_start"] = $startdate_array[$i];
+	$email->column_fields["semodule"] = 'Tasks';
+	$email->column_fields["activitytype"] = 'Emails';
+	$email->column_fields["description"] = $body_array[$i];	
+	$email->save("Emails");
+	$email_ids[] = $email->id;
+	
+	$query = "insert into vtiger_emaildetails(emailid,from_email,to_email,cc_email,bcc_email) values (".$email->id.", '".$from_array[$i]."', '".$to_array[$i]."','".$cc_array[$i]."','".$bcc_array[$i] ."')";
+		$res = $adb->query($query);
+}
+
+
+//Populate PriceBook data
+
+$PB_array = array ("Cd-R PB", "Vtiger PB", "Gator PB", "Kyple PB", "Pastor PB", "Zoho PB", "PB_100", "Per_PB", "CST_PB", "GATE_PB", "Chevron_PB", "Pizza_PB");
+$Active_array = array ("0", "1", "1", "0", "1","0", "1", "1", "0", "1","0","1");
+
+//$num_array = array(0,1,2,3,4);
+for($i=0;$i<12;$i++)
+{
+	$pricebook = new PriceBooks();
+
+	$rand = array_rand($num_array);
+	$pricebook->column_fields["bookname"]   = $PB_array[$i];
+	$pricebook->column_fields["active"]     = $Active_array[$i];
+
+	$pricebook->save("PriceBooks");
+	$pricebook_ids[] = $pricebook ->id;
+}
+
+
+//Populate Notes Data
+
+$notes_array = array ("Cont_Notes", "Prod_Notes", "Vendor_Notes", "Invoice_Notes", "Task_Notes", "Event_Notes", "Email_Notes");
+
+for($i=0;$i<7;$i++)
+{
+	$notes = new Notes();
+
+	$rand = array_rand($num_array);
+	$contact_key = array_rand($contact_ids);
+        $notes->column_fields["contact_id"] 	= 	$contact_ids[$contact_key];
+	$notes->column_fields["notes_title"]		=	$notes_array[$i];
+
+	$notes->save("Notes");
+	$notes_ids[] = $notes ->id;
+	
+	$product_key = array_rand($product_ids);
+        $query = "insert into vtiger_senotesrel (crmid, notesid) values (".$product_ids[$product_key].", ".$notes->id.")";
+	$db->query($query);
+		
+}
+
+
+
+// Populate Ticket data
+
+
+//$severity_array=array("Minor","Major","Critical","");
+$status_array=array("Open","In Progress","Wait For Response","Open","Closed");
+$category_array=array("Big Problem ","Small Problem","Other Problem","Small Problem","Other Problem");
+$ticket_title_array=array("Upload Attachment problem",
+			"Individual Customization -Menu and RSS","Export Output query",
+		"Import Error CSV Leads","How to automatically add a lead from a web form to VTiger");
+
+for($i=0;$i<5;$i++)
+{
+	$helpdesk= new HelpDesk();
+	
+	$rand=array_rand($num_array);
+	$contact_key = array_rand($contact_ids);
+        $helpdesk->column_fields["parent_id"] 	= 	$contact_ids[$contact_key];
+
+	$helpdesk->column_fields["ticketpriorities"]= "Normal";
+	$helpdesk->column_fields["product_id"]	= 	$product_ids[$i];
+
+	$helpdesk->column_fields["ticketseverities"]	= "Minor";
+	$helpdesk->column_fields["ticketstatus"]	= $status_array[$i];
+	$helpdesk->column_fields["ticketcategories"]	= $category_array[$i];
+	//$rand_key = array_rand($s);$contact_key = array_rand($contact_ids);
+        $notes->column_fields["contact_id"] 	= 	$contact_ids[$contact_key];
+	$helpdesk->column_fields["ticket_title"]	= $ticket_title_array[$i];
+        $helpdesk->column_fields["assigned_user_id"] = $assigned_user_id;
+	
+	$helpdesk->save("HelpDesk");
+	$helpdesk_ids[] = $helpdesk->id;
+	
+	if ($i > 3)
+	{
+		$freetag = $adb->getUniqueId('vtiger_freetags');
+		$query = "insert into vtiger_freetags values ($freetag, '$cloudtag[3]', '$cloudtag[3]')";
+		$res_tkt = $adb->query($query);
+
+		$date = $adb->formatDate(date('YmdHis')); 
+		$query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$helpdesk->id.", $date, 'HelpDesk')";
+		$result_tkt = $adb->query($query_tag);
+	}
+
+}
+
+// Populate Activities Data
+$task_array=array("Tele Conference","Call user - John","Send Fax to Mary Smith");
+$event_array=array("","","Call Smith","Team Meeting","Call Richie","Meeting with Don");
+$task_status_array=array("Planned","In Progress","Completed");
+$task_priority_array=array("High","Medium","Low");
+$visibility=array("","","Private","Public","Private","Public");
+
+for($i=0;$i<6;$i++)
+{
+	$event = new Activity();
+	
+	$rand_num=array_rand($num_array);
+
+	$rand_date = & create_date();
+	$en=explode("-",$rand_date);
+	if($en[1]<10)
+		$en[1]="0".$en[1];
+	if($en[2]<10)
+		$en[2]="0".$en[2];
+	$recur_daily_date=date('Y-m-d',mktime(0,0,0,date($en[1]),date($en[2])+5,date($en[0])));
+	$recur_week_date=date('Y-m-d',mktime(0,0,0,date($en[1]),date($en[2])+30,date($en[0])));
+
+
+	$start_time_hr=rand(00,23);
+	$start_time_min=rand(00,59);
+	$end_time_hr=rand(00,23);
+	$end_time_min=rand(00,59);
+	if($start_time_hr<10)
+		$start_time_hr="0".$start_time_hr;
+	if($start_time_min<10)
+		$start_time_min="0".$start_time_min;
+	if($end_time_hr<10)
+		$end_time_hr="0".$end_time_hr;
+	if($end_time_min<10)
+		$end_time_min="0".$end_time_min;
+	$end_time=$end_time_hr.":".$end_time_min;
+	$start_time=$start_time_hr.":".$start_time_min;
+	if($i<2)
+	{
+		$event->column_fields["subject"]	= $task_array[$i];	
+		if($i==1)
+		{
+			$account_key = array_rand($account_ids);
+			$event->column_fields["parent_id"]	= $account_ids[$account_key];;	
+		}
+		$event->column_fields["taskstatus"]	= $task_status_array[$i];	
+		$event->column_fields["taskpriority"]	= $task_priority_array[$i];	
+		$event->column_fields["activitytype"]	= "Task";
+		$event->column_fields["visibility"] = $visibility[$i];	
+				
+	}
+	else
+	{
+		$event->column_fields["subject"]	= $event_array[$i];	
+		$event->column_fields["visibility"] = $visibility[$i];
+		$event->column_fields["duration_hours"]	= rand(0,3);	
+		$event->column_fields["duration_minutes"]= rand(0,59);	
+		$event->column_fields["eventstatus"]	= "Planned";	
+		$event->column_fields["time_end"]     = $end_time;
+	}
+	$event->column_fields["date_start"]	= $rand_date;	
+	$_REQUEST["date_start"] = $rand_date;
+	$event->column_fields["time_start"]	= $start_time;	
+	$event->column_fields["due_date"]	= $rand_date;	
+	$_REQUEST["due_date"] = $rand_date;
+	$contact_key = array_rand($contact_ids);
+        $event->column_fields["contact_id"]	= 	$contact_ids[$contact_key];
+	if($i==4)
+	{
+        	$event->column_fields["recurringtype"] 	= "Daily";
+		$_REQUEST["recurringtype"]  = "Daily";
+		$event->column_fields["activitytype"]	= "Meeting";	
+		$event->column_fields["due_date"]	= $recur_daily_date;	
+	}
+	elseif($i==5)
+	{	
+        	$event->column_fields["recurringtype"] 	= "Weekly";
+		$_REQUEST["recurringtype"]  = "Weekly";
+		$event->column_fields["activitytype"]	= "Meeting";	
+		$event->column_fields["due_date"]	= $recur_week_date;	
+	}
+	elseif($i>1) 
+	{
+		$event->column_fields["activitytype"]	= "Call";	
+	}
+	$event->column_fields["assigned_user_id"] = $assigned_user_id;
+	$event->save("Calendar");
+        $event_ids[] = $event->id;
+
+}
+
+
+$adb->query("update vtiger_crmentity set smcreatorid=".$assigned_user_id);
+
+$expected_revenue = Array("250000","750000","500000");
+$budget_cost = Array("25000","50000","90000");
+$actual_cost = Array("23500","45000","80000");
+$num_sent = Array("2000","2500","3000");
+$clo_date = Array('2003-1-2','2004-2-3','2005-4-12');
+
+$expected_response_count = Array("2500","7500","5000");
+$expected_sales_count = Array("25000","50000","90000");
+$expected_roi = Array("23","45","82");
+
+$actual_response_count = Array("250","750","1500");
+$actual_sales_count = Array("1250","5200","2390");
+$actual_roi = Array("21","14","12");
+
+$sponsor = Array("Finace","Marketing","Sales");
+$targetsize = Array("210000","13390","187424");
+$targetaudience = Array("Managers","CEOs","Rookies");
+
+//$expected_response = Array(null,null,null);
+for($i=0;$i<count($campaign_name_array);$i++)
+{
+	$campaign = new Campaigns();
+	$campaign_name = $campaign_name_array[$i];
+	$campaign->column_fields["campaignname"] = $campaign_name;
+	$campaign->column_fields["campaigntype"] = $campaign_type_array[$i];
+	$campaign->column_fields["campaignstatus"] = $campaign_status_array[$i];
+	$campaign->column_fields["numsent"] = $num_sent[$i];
+	$campaign->column_fields["expectedrevenue"] = $expected_revenue[$i];
+	$campaign->column_fields["budgetcost"] = $budget_cost[$i];
+	$campaign->column_fields["actualcost"] = $actual_cost[$i];
+	$campaign->column_fields["closingdate"] = $clo_date[$i];
+	$campaign->column_fields["expectedresponse"] = $expected_response[$i];
+	$campaign->column_fields["assigned_user_id"] = $assigned_user_id;
+	
+	$campaign->column_fields["expectedresponsecount"] = $expected_response_count[$i];
+	$campaign->column_fields["expectedsalescount"] = $expected_sales_count[$i];
+	$campaign->column_fields["expectedroi"] = $expected_roi[$i];
+	$campaign->column_fields["actualresponsecount"] = $actual_response_count[$i];
+	$campaign->column_fields["actualsalescount"] = $actual_sales_count[$i];
+	$campaign->column_fields["actualroi"] = $actual_roi[$i];
+	$campaign->column_fields["sponsor"] = $sponsor[$i];
+	$campaign->column_fields["targetsize"] = $targetsize[$i];
+	$campaign->column_fields["targetaudience"] = $targetaudience[$i];
+
+
+	
+	$campaign->save("Campaigns");
+}
+
+//Populate My Sites Data 
+
+$portalname = array ("Vtiger", "Vtiger Blogs", "Vtiger Forums", "VtigerForge", "Vtiger Docs");
+$portalurl = array ("http://vtiger.com", "http://blogs.vtiger.com", "http://forums.vtiger.com", "http://vtigerforge.com", "http://wiki.vtiger.com");
+
+for($i=0;$i<5;$i++)
+{
+	$portalid = $adb->getUniqueId('vtiger_portal');
+	$portal_qry = "insert into vtiger_portal values (".$portalid.", '".$portalname[$i]."','".$portalurl[$i]."',0)";
+	$result_qry = $adb->query($portal_qry);
+}
+
+//Populate RSS Data
+$rssname = array("vtiger - Forums","vtiger development - Active Tickets");
+$rssurl = array("http://forums.vtiger.com/rss.php?name=forums&file=rss","http://vtiger.fosslabs.com/cgi-bin/trac.cgi/report/1?format=rss&USER=anonymous");
+
+for($i=0;$i<2;$i++)
+{
+	$rssid = $adb->getUniqueId('vtiger_rss');
+	$rss_qry = "insert into vtiger_rss values (".$rssid.", '".$rssurl[$i]."','".$rssname[$i]."',0,0)";
+	$result_qry = $adb->query($rss_qry);
+}
+?>

Modified: vtigercrm/branches/5.1_jens/jscalendar/lang/calendar-pl.js
==============================================================================
--- vtigercrm/branches/5.1_jens/jscalendar/lang/calendar-pl.js (original)
+++ vtigercrm/branches/5.1_jens/jscalendar/lang/calendar-pl.js Mon Apr 16 12:27:44 2007
@@ -3,17 +3,75 @@
 // Author: Artur Filipiak, <imagen at poczta.fm>
 // January, 2004
 // Encoding: UTF-8
+// Distributed under the same terms as the calendar itself.
+
+// For translators: please use UTF-8 if possible.  We strongly believe that
+// Unicode is the answer to a real internationalized world.  Also please
+// include your contact information in the header, as can be seen above.
+
+// full day names
 Calendar._DN = new Array
-("Niedziela", "PoniedziaÅ‚ek", "Wtorek", "Åšroda", "Czwartek", "PiÄ
tek", "Sobota", "Niedziela");
+("Niedziela",
+ "Poniedziałek",
+ "Wtorek",
+ "Åšroda",
+ "Czwartek",
+ "PiÄ
tek",
+ "Sobota",
+ "Niedziela");
+ 
+ // Please note that the following array of short day names (and the same goes
+// for short month names, _SMN) isn't absolutely necessary.  We give it here
+// for exemplification on how one can customize the short day names, but if
+// they are simply the first N letters of the full name you can simply say:
+//
+//   Calendar._SDN_len = N; // short day name length
+//   Calendar._SMN_len = N; // short month name length
+//
+// If N = 3 then this is not needed either since we assume a value of 3 if not
+// present, to be compatible with translation files that were written before
+// this feature.
 
+// short day names
 Calendar._SDN = new Array
-("N", "Pn", "Wt", "Åšr", "Cz", "Pt", "So", "N");
+("N",
+"Pn",
+"Wt",
+"Åšr",
+"Cz",
+"Pt",
+"So",
+"N");
 
+// full month names
 Calendar._MN = new Array
-("Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień");
+("Styczeń",
+ "Luty",
+ "Marzec",
+ "Kwiecień",
+ "Maj",
+ "Czerwiec",
+ "Lipiec",
+ "Sierpień",
+ "Wrzesień",
+ "Październik",
+ "Listopad",
+ "Grudzień");
 
+// short month names
 Calendar._SMN = new Array
-("Sty", "Lut", "Mar", "Kwi", "Maj", "Cze", "Lip", "Sie", "Wrz", "Paź", "Lis", "Gru");
+("Sty",
+ "Lut",
+ "Mar",
+ "Kwi",
+ "Maj",
+ "Cze",
+ "Lip",
+ "Sie",
+ "Wrz",
+ "Paź",
+ "Lis",
+ "Gru");
 
 // tooltips
 Calendar._TT = {};
@@ -43,14 +101,25 @@
 Calendar._TT["SEL_DATE"] = "Wybierz datÄ™";
 Calendar._TT["DRAG_TO_MOVE"] = "Przesuń okienko";
 Calendar._TT["PART_TODAY"] = " (dziÅ›)";
-Calendar._TT["MON_FIRST"] = "Pokaż Poniedziałek jako pierwszy";
-Calendar._TT["SUN_FIRST"] = "Pokaż NiedzielÄ™ jako pierwszÄ
";
+
+// the following is to inform that "%s" is to be the first day of week
+// %s will be replaced with the day name.
+Calendar._TT["DAY_FIRST"] = "PoczÄ
tek tygodnia - %s";
+
+// This may be locale-dependent.  It specifies the week-end days, as an array
+// of comma-separated numbers.  The numbers are from 0 to 6: 0 means Sunday, 1
+// means Monday, etc.
+Calendar._TT["WEEKEND"] = "0,6";
+
 Calendar._TT["CLOSE"] = "Zamknij";
 Calendar._TT["TODAY"] = "DziÅ›";
-Calendar._TT["TIME_PART"] = "(Shift-)klik | drag, aby zmienić wartość";
+Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
+
 
 // date formats
-Calendar._TT["DEF_DATE_FORMAT"] = "%Y.%m.%d";
+Calendar._TT["DEF_DATE_FORMAT"] = "%d-%m-%Y";
 Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
 
-Calendar._TT["WK"] = "wk";
+Calendar._TT["WK"] = "tydz";
+//Calendar._TT["TIME"] = "Godz.:";
+

Modified: vtigercrm/branches/5.1_jens/log4php/appenders/LoggerAppenderRollingFile.php
==============================================================================
--- vtigercrm/branches/5.1_jens/log4php/appenders/LoggerAppenderRollingFile.php (original)
+++ vtigercrm/branches/5.1_jens/log4php/appenders/LoggerAppenderRollingFile.php Mon Apr 16 12:27:44 2007
@@ -144,7 +144,9 @@
             $this->closeFile(); // keep windows happy.
     
             $file = $fileName;
-            rename($file, $target);
+
+	    //As of now suppress the error in rename. we have to handle in future
+            @rename($file, $target);
         }
         
         $this->setFile($fileName, false);

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/Accounts.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/Accounts.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/Accounts.php Mon Apr 16 12:27:44 2007
@@ -1,750 +1,737 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Accounts/Accounts.php,v 1.53 2005/04/28 08:06:45 rank Exp $
- * Description:  Defines the Account SugarBean Account entity with the necessary
- * methods and variables.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('modules/Calendar/Activity.php');
-require_once('modules/Notes/Notes.php');
-require_once('modules/Emails/Emails.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-// Account is used to store vtiger_account information.
-class Accounts extends CRMEntity {
-	var $log;
-	var $db;
-
-	var $tab_name = Array('vtiger_crmentity','vtiger_account','vtiger_accountbillads','vtiger_accountshipads','vtiger_accountscf');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_account'=>'accountid','vtiger_accountbillads'=>'accountaddressid','vtiger_accountshipads'=>'accountaddressid','vtiger_accountscf'=>'accountid');
-
-
-	var $column_fields = Array();
-
-	var $sortby_fields = Array('accountname','city','website','phone','smownerid');		
-
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-			'Account Name'=>Array('vtiger_account'=>'accountname'),
-			'City'=>Array('vtiger_accountbillads'=>'city'), 
-			'Website'=>Array('vtiger_account'=>'website'),
-			'Phone'=>Array('vtiger_account'=> 'phone'),
-			'Assigned To'=>Array('vtiger_crmentity'=>'smownerid')
-			);
-
-	var $list_fields_name = Array(
-			'Account Name'=>'accountname',
-			'City'=>'bill_city',
-			'Website'=>'website',
-			'Phone'=>'phone',
-			'Assigned To'=>'assigned_user_id'
-			);
-	var $list_link_field= 'accountname';
-
-	var $search_fields = Array(
-			'Account Name'=>Array('vtiger_account'=>'accountname'),
-			'City'=>Array('vtiger_accountbillads'=>'city'), 
-			);
-
-	var $search_fields_name = Array(
-			'Account Name'=>'accountname',
-			'City'=>'bill_city',
-			);
-
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'accountname';
-	var $default_sort_order = 'ASC';
-
-	function Accounts() {
-		$this->log =LoggerManager::getLogger('account');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Accounts');
-	}
-
-	/** Function to handle module specific operations when saving a entity 
-	*/
-	function save_module($module)
-	{
-	}
-
-
-	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
-	/**
-	 * Function to get sort order
- 	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	 */
-	function getSortOrder()
-	{
-		global $log;
-                $log->debug("Entering getSortOrder() method ...");	
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['ACCOUNTS_SORT_ORDER'] != '')?($_SESSION['ACCOUNTS_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder() method ...");
-		return $sorder;
-	}
-	/**
-	 * Function to get order by
-	 * return string  $order_by    - fieldname(eg: 'accountname')
- 	 */
-	function getOrderBy()
-	{
-		global $log;
-                $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['ACCOUNTS_ORDER_BY'] != '')?($_SESSION['ACCOUNTS_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-	// Mike Crowe Mod --------------------------------------------------------
-
-
-	/** Returns a list of the associated contacts
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_contacts($id)
-	{	
-		global $log, $singlepane_view;
-                $log->debug("Entering get_contacts(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Contacts();
-
-		$button = '';
-		if(isPermitted("Contacts",1,"") == 'yes')
-		{
-			$button .= '<input title="New Contact" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Contacts\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_CONTACT'].'">&nbsp;</td>';
-		}
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		//SQL
-		$query = "SELECT vtiger_contactdetails.*,
-			vtiger_crmentity.crmid,
-                        vtiger_crmentity.smownerid,
-			vtiger_users.user_name
-			FROM vtiger_contactdetails
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
-			LEFT JOIN vtiger_contactgrouprelation
-				ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
-			LEFT JOIN vtiger_users
-				ON vtiger_crmentity.smownerid = vtiger_users.id
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_contactdetails.accountid = ".$id;
-		$log->debug("Exiting get_contacts method ...");
-		return GetRelatedList('Accounts','Contacts',$focus,$query,$button,$returnset);
-	}
-
-	/** Returns a list of the associated opportunities
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_opportunities($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_opportunities(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Potentials();
-		$button = '';
-
-		if(isPermitted("Potentials",1,"") == 'yes')
-		{
-			$button .= '<input title="New Potential" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_POTENTIAL'].'">';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_potential.potentialid, vtiger_potential.accountid,
-			vtiger_potential.potentialname, vtiger_potential.sales_stage,
-			vtiger_potential.potentialtype, vtiger_potential.amount,
-			vtiger_potential.closingdate, vtiger_potential.potentialtype,
-			vtiger_users.user_name,
-			vtiger_crmentity.crmid, vtiger_crmentity.smownerid
-			FROM vtiger_potential
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_potential.potentialid
-			LEFT JOIN vtiger_users
-				ON vtiger_crmentity.smownerid = vtiger_users.id
-			LEFT JOIN vtiger_potentialgrouprelation
-				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_potential.accountid = ".$id;
-		$log->debug("Exiting get_opportunities method ...");
-
-		return GetRelatedList('Accounts','Potentials',$focus,$query,$button,$returnset);
-	}
-
-	/** Returns a list of the associated tasks
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_activities($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_activities(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Activity();
-		$button = '';
-		if(isPermitted("Calendar",1,"") == 'yes')
-		{
-
-			$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Accounts\';this.form.activity_mode.value=\'Task\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
-			$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Accounts\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;</td>';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_activity.*,
-			vtiger_seactivityrel.*,
-			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
-			vtiger_crmentity.modifiedtime,
-			vtiger_users.user_name,
-			vtiger_recurringevents.recurringtype
-			FROM vtiger_activity
-			INNER JOIN vtiger_seactivityrel
-				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_activity.activityid
-			LEFT JOIN vtiger_users
-				ON vtiger_users.id = vtiger_crmentity.smownerid
-			LEFT OUTER JOIN vtiger_recurringevents
-				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
-			LEFT JOIN vtiger_activitygrouprelation
-				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
-			WHERE vtiger_seactivityrel.crmid = ".$id."
-			AND (activitytype='Task'
-				OR activitytype='Call'
-				OR activitytype='Meeting')
-			AND vtiger_crmentity.deleted = 0
-			AND ((vtiger_activity.status IS NOT NULL
-					AND vtiger_activity.status != 'Completed')
-				AND (vtiger_activity.status IS NOT NULL
-					AND vtiger_activity.status != 'Deferred')
-				OR (vtiger_activity.eventstatus !=''
-					AND  vtiger_activity.eventstatus != 'Held'))";
-		$log->debug("Exiting get_activities method ...");
-		return GetRelatedList('Accounts','Calendar',$focus,$query,$button,$returnset);
-
-	}
-	/**
-	 * Function to get Account related Task & Event which have activity type Held, Completed or Deferred.
- 	 * @param  integer   $id      - accountid
- 	 * returns related Task or Event record in array format
- 	 */
-	function get_history($id)
-	{
-		global $log;
-                $log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject,
-			vtiger_activity.status, vtiger_activity.eventstatus,
-			vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,
-			vtiger_crmentity.modifiedtime, vtiger_crmentity.createdtime,
-			vtiger_crmentity.description,
-			vtiger_users.user_name
-			FROM vtiger_activity
-			INNER JOIN vtiger_seactivityrel
-				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_activity.activityid
-			LEFT JOIN vtiger_activitygrouprelation
-				ON vtiger_activitygrouprelation.activityid = vtiger_activity.activityid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
-			INNER JOIN vtiger_users
-				ON vtiger_crmentity.smcreatorid = vtiger_users.id
-			WHERE (vtiger_activity.activitytype = 'Meeting'
-				OR vtiger_activity.activitytype = 'Call'
-				OR vtiger_activity.activitytype = 'Task')
-			AND (vtiger_activity.status = 'Completed'
-				OR vtiger_activity.status = 'Deferred'
-				OR (vtiger_activity.eventstatus = 'Held'
-					AND vtiger_activity.eventstatus != ''))
-			AND vtiger_seactivityrel.crmid = ".$id;
-		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-		$log->debug("Exiting get_history method ...");
-		return getHistory('Accounts',$query,$id);
-	}
-	/**
-	 * Function to get Account related Attachments
- 	 * @param  integer   $id      - accountid
- 	 * returns related Attachment record in array format
- 	 */
-	function get_attachments($id)
-	{
-		 global $log;
-                 $log->debug("Entering get_attachments(".$id.") method ...");
-		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		$query = "SELECT vtiger_notes.title, vtiger_notes.notecontent AS description,
-			vtiger_notes.filename, vtiger_notes.notesid AS crmid,
-				'Notes      ' AS ActivityType,
-			vtiger_attachments.type AS FileType,
-				crm2.modifiedtime AS lastmodified, crm2.createdtime,
-			vtiger_seattachmentsrel.attachmentsid,
-			vtiger_users.user_name
-			FROM vtiger_notes
-			INNER JOIN vtiger_senotesrel
-				ON vtiger_senotesrel.notesid = vtiger_notes.notesid
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_senotesrel.crmid
-			INNER JOIN vtiger_crmentity crm2
-				ON crm2.crmid = vtiger_notes.notesid
-				AND crm2.deleted = 0
-			LEFT JOIN vtiger_seattachmentsrel
-				ON vtiger_seattachmentsrel.crmid = vtiger_notes.notesid
-			LEFT JOIN vtiger_attachments
-				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-			INNER JOIN vtiger_users
-				ON crm2.smcreatorid = vtiger_users.id
-			WHERE vtiger_crmentity.crmid = ".$id."
-		 UNION ALL
-			SELECT vtiger_attachments.description AS title, vtiger_attachments.description,
-			vtiger_attachments.name AS filename,
-			vtiger_seattachmentsrel.attachmentsid AS crmid,
-				'Attachments' AS ActivityType,
-			vtiger_attachments.type AS FileType,
-				crm2.modifiedtime AS lastmodified, crm2.createdtime,
-			vtiger_attachments.attachmentsid,
-			vtiger_users.user_name
-			FROM vtiger_attachments
-			INNER JOIN vtiger_seattachmentsrel
-				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_seattachmentsrel.crmid
-			INNER JOIN vtiger_crmentity crm2
-				ON crm2.crmid = vtiger_attachments.attachmentsid
-			INNER JOIN vtiger_users
-				ON crm2.smcreatorid = vtiger_users.id
-			WHERE vtiger_crmentity.crmid = ".$id."
-			ORDER BY createdtime DESC";
-		$log->debug("Exiting get_attachments method ...");
-		return getAttachmentsAndNotes('Accounts',$query,$id);
-	}
-	/**
-	* Function to get Account related Quotes
-	* @param  integer   $id      - accountid
-	* returns related Quotes record in array format
-	*/
-	function get_quotes($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_quotes(".$id.") method ...");
-		global $app_strings;
-		require_once('modules/Quotes/Quotes.php');
-
-		$focus = new Quotes();
-
-		$button = '';
-		if(isPermitted("Quotes",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
-		}
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_users.user_name,
-			vtiger_groups.groupname,
-			vtiger_crmentity.*,
-			vtiger_quotes.*,
-			vtiger_potential.potentialname,
-			vtiger_account.accountname
-			FROM vtiger_quotes
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
-			LEFT OUTER JOIN vtiger_account
-				ON vtiger_account.accountid = vtiger_quotes.accountid
-			LEFT OUTER JOIN vtiger_potential
-				ON vtiger_potential.potentialid = vtiger_quotes.potentialid
-			LEFT JOIN vtiger_quotegrouprelation
-				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
-			LEFT JOIN vtiger_users
-				ON vtiger_crmentity.smownerid = vtiger_users.id
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_account.accountid = ".$id;
-		$log->debug("Exiting get_quotes method ...");
-		return GetRelatedList('Accounts','Quotes',$focus,$query,$button,$returnset);
-	}
-	/**
-	* Function to get Account related Invoices 
-	* @param  integer   $id      - accountid
-	* returns related Invoices record in array format
-	*/
-	function get_invoices($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_invoices(".$id.") method ...");
-		global $app_strings;
-		require_once('modules/Invoice/Invoice.php');
-
-		$focus = new Invoice();
-
-		$button = '';
-		if(isPermitted("Invoice",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_INVOICE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_INVOICE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Invoice\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_INVOICE_BUTTON'].'">&nbsp;</td>';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_users.user_name,
-			vtiger_groups.groupname,
-			vtiger_crmentity.*,
-			vtiger_invoice.*,
-			vtiger_account.accountname,
-			vtiger_salesorder.subject AS salessubject
-			FROM vtiger_invoice
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
-			LEFT OUTER JOIN vtiger_account
-				ON vtiger_account.accountid = vtiger_invoice.accountid
-			LEFT OUTER JOIN vtiger_salesorder
-				ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid
-			LEFT JOIN vtiger_invoicegrouprelation
-				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
-			LEFT JOIN vtiger_users
-				ON vtiger_crmentity.smownerid = vtiger_users.id
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_account.accountid = ".$id;
-		$log->debug("Exiting get_invoices method ...");
-		return GetRelatedList('Accounts','Invoice',$focus,$query,$button,$returnset);
-	}
-
-	/**
-	* Function to get Account related SalesOrder 
-	* @param  integer   $id      - accountid
-	* returns related SalesOrder record in array format
-	*/
-	function get_salesorder($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_salesorder(".$id.") method ...");
-		require_once('modules/SalesOrder/SalesOrder.php');
-		global $app_strings;
-
-		$focus = new SalesOrder();
-
-		$button = '';
-		if(isPermitted("SalesOrder",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_SORDER_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;</td>';
-		}
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_crmentity.*,
-			vtiger_salesorder.*,
-			vtiger_quotes.subject AS quotename,
-			vtiger_account.accountname,
-			vtiger_users.user_name,
-			vtiger_groups.groupname
-			FROM vtiger_salesorder
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
-			LEFT OUTER JOIN vtiger_quotes
-				ON vtiger_quotes.quoteid = vtiger_salesorder.quoteid
-			LEFT OUTER JOIN vtiger_account
-				ON vtiger_account.accountid = vtiger_salesorder.accountid
-			LEFT JOIN vtiger_sogrouprelation
-				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
-			LEFT JOIN vtiger_users
-				ON vtiger_crmentity.smownerid = vtiger_users.id
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_salesorder.accountid = ".$id;
-		$log->debug("Exiting get_salesorder method ...");		
-		return GetRelatedList('Accounts','SalesOrder',$focus,$query,$button,$returnset);
-	}
-	/**
-	* Function to get Account related Tickets
-	* @param  integer   $id      - accountid
-	* returns related Ticket record in array format
-	*/
-	function get_tickets($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_tickets(".$id.") method ...");
-		global $app_strings;
-
-		$focus = new HelpDesk();
-		$button = '';
-
-		$button .= '<td valign="bottom" align="right"><input title="New TICKET" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'HelpDesk\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_TICKET'].'">&nbsp;</td>';
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_users.user_name, vtiger_users.id,
-			vtiger_troubletickets.title, vtiger_troubletickets.ticketid AS crmid,
-			vtiger_troubletickets.status, vtiger_troubletickets.priority,
-			vtiger_troubletickets.parent_id,
-			vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
-			FROM vtiger_troubletickets
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
-			LEFT JOIN vtiger_account
-				ON vtiger_account.accountid = vtiger_troubletickets.parent_id
-			LEFT JOIN vtiger_contactdetails
-			        ON vtiger_contactdetails.contactid=vtiger_troubletickets.parent_id
-			LEFT JOIN vtiger_users
-				ON vtiger_users.id=vtiger_crmentity.smownerid
-			LEFT JOIN vtiger_ticketgrouprelation
-				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
-			WHERE  vtiger_troubletickets.parent_id=".$id." or " ;
-
-		$query .= "vtiger_troubletickets.parent_id in(SELECT vtiger_contactdetails.contactid
-			FROM vtiger_contactdetails
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
-			LEFT JOIN vtiger_contactgrouprelation
-				ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
-			LEFT JOIN vtiger_users
-				ON vtiger_crmentity.smownerid = vtiger_users.id
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_contactdetails.accountid = ".$id;
-
-			
-		//Appending the security parameter
-		global $current_user;
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-		$tab_id=getTabid('Contacts');
-		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
-		{
-			$sec_parameter=getListViewSecurityParameter('Contacts');
-			$query .= ' '.$sec_parameter;
-
-		}
-
-		$query .= ") ";
-		
-		/*
-		$query .= " UNION ALL
-			SELECT vtiger_users.user_name, vtiger_users.id,
-			vtiger_troubletickets.title, vtiger_troubletickets.ticketid AS crmid,
-			vtiger_troubletickets.status, vtiger_troubletickets.priority,
-			vtiger_troubletickets.parent_id,
-			vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
-			FROM vtiger_troubletickets
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
-			LEFT JOIN vtiger_contactdetails
-				ON vtiger_contactdetails.contactid = vtiger_troubletickets.parent_id
-			LEFT JOIN vtiger_account
-				ON vtiger_account.accountid = vtiger_contactdetails.accountid
-			LEFT JOIN vtiger_users
-				ON vtiger_users.id = vtiger_crmentity.smownerid
-			LEFT JOIN vtiger_ticketgrouprelation
-				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
-			WHERE vtiger_account.accountid = ".$id;
-		*/	
-		$log->debug("Exiting get_tickets method ...");
-		return GetRelatedList('Accounts','HelpDesk',$focus,$query,$button,$returnset);
-	}
-	/**
-	* Function to get Account related Products 
-	* @param  integer   $id      - accountid
-	* returns related Products record in array format
-	*/
-	function get_products($id)
-	{
-		global $log, $singlepane_view;
-                $log->debug("Entering get_products(".$id.") method ...");
-		require_once('modules/Products/Products.php');
-		global $app_strings;
-
-		$focus = new Products();
-
-		$button = '';
-
-		if(isPermitted("Products",1,"") == 'yes')
-		{
-
-
-			$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Accounts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_products.productid, vtiger_products.productname,
-			vtiger_products.productcode, vtiger_products.commissionrate,
-			vtiger_products.qty_per_unit, vtiger_products.unit_price,
-			vtiger_crmentity.crmid, vtiger_crmentity.smownerid
-			FROM vtiger_products
-			INNER JOIN vtiger_seproductsrel
-				ON vtiger_products.productid = vtiger_seproductsrel.productid
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid = vtiger_products.productid
-			INNER JOIN vtiger_account
-				ON vtiger_account.accountid = vtiger_seproductsrel.crmid
-			WHERE vtiger_account.accountid = ".$id."
-			AND vtiger_crmentity.deleted = 0";
-		$log->debug("Exiting get_products method ...");
-		return GetRelatedList('Accounts','Products',$focus,$query,$button,$returnset);
-	}
-
-	/** Function to export the account records in CSV Format
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Export Accounts Query.
-	*/
-	function create_export_query(&$order_by, &$where)
-	{
-		global $log;
-		global $current_user;
-                $log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
-
-		include("include/utils/ExportUtils.php");
-
-		//To get the Permitted fields query and the permitted fields list
-		$sql = getPermittedFieldsQuery("Accounts", "detail_view");
-		$fields_list = getFieldsListFromQuery($sql);
-
-		$query = "SELECT $fields_list FROM ".$this->entity_table."
-				INNER JOIN vtiger_account
-					ON vtiger_crmentity.crmid = vtiger_account.accountid
-				LEFT JOIN vtiger_accountbillads
-					ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid
-				LEFT JOIN vtiger_accountshipads
-					ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid
-				LEFT JOIN vtiger_accountscf
-					ON vtiger_accountscf.accountid = vtiger_account.accountid
-				LEFT JOIN vtiger_accountgrouprelation
-                	                ON vtiger_accountscf.accountid = vtiger_accountgrouprelation.accountid
-	                        LEFT JOIN vtiger_groups
-                        	        ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
-				LEFT JOIN vtiger_users
-					ON vtiger_crmentity.smownerid = vtiger_users.id 
-				LEFT JOIN vtiger_account vtiger_account2 
-					ON vtiger_account2.accountid = vtiger_account.parentid
-				";//vtiger_account2 is added to get the Member of account
-
-
-		$where_auto = " vtiger_users.status = 'Active'
-			AND vtiger_crmentity.deleted = 0 ";
-
-		if($where != "")
-			$query .= "WHERE ($where) AND ".$where_auto;
-		else
-			$query .= "WHERE ".$where_auto;
-
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-		//we should add security check when the user has Private Access
-		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3)
-		{
-			//Added security check to get the permitted records only
-			$query = $query." ".getListViewSecurityParameter("Accounts");
-		}
-
-		if(!empty($order_by))
-			$query .= " ORDER BY $order_by";
-
-		$log->debug("Exiting create_export_query method ...");
-		return $query;
-	}
-
-	/** Function to get the Columnnames of the Account Record
-	* Used By vtigerCRM Word Plugin
-	* Returns the Merge Fields for Word Plugin
-	*/
-	function getColumnNames_Acnt()
-	{
-		global $log,$current_user;
-		$log->debug("Entering getColumnNames_Acnt() method ...");
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-		{
-			$sql1 = "SELECT fieldlabel FROM vtiger_field WHERE tabid = 6";
-		}else
-		{
-			$profileList = getCurrentUserProfileList();
-			$sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=6 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-		} 
-		$result = $this->db->query($sql1);
-		$numRows = $this->db->num_rows($result);
-		for($i=0; $i < $numRows;$i++)
-		{
-			$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
-			$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
-			$custom_fields[$i] = strtoupper($custom_fields[$i]);
-		}
-		$mergeflds = $custom_fields;
-		$log->debug("Exiting getColumnNames_Acnt method ...");
-		return $mergeflds;
-	}
-
-}
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Accounts/Accounts.php,v 1.53 2005/04/28 08:06:45 rank Exp $
+ * Description:  Defines the Account SugarBean Account entity with the necessary
+ * methods and variables.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('modules/Calendar/Activity.php');
+require_once('modules/Notes/Notes.php');
+require_once('modules/Emails/Emails.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+// Account is used to store vtiger_account information.
+class Accounts extends CRMEntity {
+	var $log;
+	var $db;
+
+	var $tab_name = Array('vtiger_crmentity','vtiger_account','vtiger_accountbillads','vtiger_accountshipads','vtiger_accountscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_account'=>'accountid','vtiger_accountbillads'=>'accountaddressid','vtiger_accountshipads'=>'accountaddressid','vtiger_accountscf'=>'accountid');
+
+	var $entity_table = "vtiger_crmentity";
+
+	var $column_fields = Array();
+
+	var $sortby_fields = Array('accountname','city','website','phone','smownerid');		
+
+	var $groupTable = Array('vtiger_accountgrouprelation','accountid');
+	
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+			'Account Name'=>Array('vtiger_account'=>'accountname'),
+			'City'=>Array('vtiger_accountbillads'=>'city'), 
+			'Website'=>Array('vtiger_account'=>'website'),
+			'Phone'=>Array('vtiger_account'=> 'phone'),
+			'Assigned To'=>Array('vtiger_crmentity'=>'smownerid')
+			);
+
+	var $list_fields_name = Array(
+			'Account Name'=>'accountname',
+			'City'=>'bill_city',
+			'Website'=>'website',
+			'Phone'=>'phone',
+			'Assigned To'=>'assigned_user_id'
+			);
+	var $list_link_field= 'accountname';
+
+	var $search_fields = Array(
+			'Account Name'=>Array('vtiger_account'=>'accountname'),
+			'City'=>Array('vtiger_accountbillads'=>'city'), 
+			);
+
+	var $search_fields_name = Array(
+			'Account Name'=>'accountname',
+			'City'=>'bill_city',
+			);
+
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'accountname';
+	var $default_sort_order = 'ASC';
+
+	function Accounts() {
+		$this->log =LoggerManager::getLogger('account');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Accounts');
+	}
+
+	/** Function to handle module specific operations when saving a entity 
+	*/
+	function save_module($module)
+	{
+	}
+
+
+	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
+	/**
+	 * Function to get sort order
+ 	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	 */
+	function getSortOrder()
+	{
+		global $log;
+                $log->debug("Entering getSortOrder() method ...");	
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['ACCOUNTS_SORT_ORDER'] != '')?($_SESSION['ACCOUNTS_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder() method ...");
+		return $sorder;
+	}
+	/**
+	 * Function to get order by
+	 * return string  $order_by    - fieldname(eg: 'accountname')
+ 	 */
+	function getOrderBy()
+	{
+		global $log;
+                $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['ACCOUNTS_ORDER_BY'] != '')?($_SESSION['ACCOUNTS_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+	// Mike Crowe Mod --------------------------------------------------------
+
+
+	/** Returns a list of the associated contacts
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_contacts($id)
+	{	
+		global $log, $singlepane_view;
+                $log->debug("Entering get_contacts(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Contacts();
+
+		$button = '';
+		if(isPermitted("Contacts",1,"") == 'yes')
+		{
+			$button .= '<input title="New Contact" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Contacts\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_CONTACT'].'">&nbsp;</td>';
+		}
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		//SQL
+		$query = "SELECT vtiger_contactdetails.*,
+			vtiger_crmentity.crmid,
+                        vtiger_crmentity.smownerid,
+			case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			LEFT JOIN vtiger_contactgrouprelation
+				ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_contactdetails.accountid = ".$id;
+		$log->debug("Exiting get_contacts method ...");
+		return GetRelatedList('Accounts','Contacts',$focus,$query,$button,$returnset);
+	}
+
+	/** Returns a list of the associated opportunities
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_opportunities($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_opportunities(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Potentials();
+		$button = '';
+
+		if(isPermitted("Potentials",1,"") == 'yes')
+		{
+			$button .= '<input title="New Potential" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_POTENTIAL'].'">';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_potential.potentialid, vtiger_potential.accountid,
+			vtiger_potential.potentialname, vtiger_potential.sales_stage,
+			vtiger_potential.potentialtype, vtiger_potential.amount,
+			vtiger_potential.closingdate, vtiger_potential.potentialtype,
+			case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_crmentity.crmid, vtiger_crmentity.smownerid
+			FROM vtiger_potential
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_potential.potentialid
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			LEFT JOIN vtiger_potentialgrouprelation
+				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_potential.accountid = ".$id;
+		$log->debug("Exiting get_opportunities method ...");
+
+		return GetRelatedList('Accounts','Potentials',$focus,$query,$button,$returnset);
+	}
+
+	/** Returns a list of the associated tasks
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_activities($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_activities(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Activity();
+		$button = '';
+		if(isPermitted("Calendar",1,"") == 'yes')
+		{
+
+			$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Accounts\';this.form.activity_mode.value=\'Task\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
+			$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Accounts\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;</td>';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_activity.*,
+			vtiger_seactivityrel.*,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_crmentity.modifiedtime,
+			case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
+			vtiger_recurringevents.recurringtype
+			FROM vtiger_activity
+			INNER JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_activity.activityid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT OUTER JOIN vtiger_recurringevents
+				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			WHERE vtiger_seactivityrel.crmid = ".$id."
+			AND ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred')) 
+			OR (vtiger_activity.activitytype in ('Meeting','Call') and  vtiger_activity.eventstatus not in ('','Held')))";
+		$log->debug("Exiting get_activities method ...");
+		return GetRelatedList('Accounts','Calendar',$focus,$query,$button,$returnset);
+
+	}
+	/**
+	 * Function to get Account related Task & Event which have activity type Held, Completed or Deferred.
+ 	 * @param  integer   $id      - accountid
+ 	 * returns related Task or Event record in array format
+ 	 */
+	function get_history($id)
+	{
+		global $log;
+                $log->debug("Entering get_history(".$id.") method ...");
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject,
+			vtiger_activity.status, vtiger_activity.eventstatus,
+			vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,
+			vtiger_activity.time_start, vtiger_activity.time_end,
+			vtiger_crmentity.modifiedtime, vtiger_crmentity.createdtime,
+			vtiger_crmentity.description,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+			FROM vtiger_activity
+			INNER JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_activity.activityid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id=vtiger_crmentity.smownerid
+			WHERE (vtiger_activity.activitytype = 'Meeting'
+				OR vtiger_activity.activitytype = 'Call'
+				OR vtiger_activity.activitytype = 'Task')
+			AND (vtiger_activity.status = 'Completed'
+				OR vtiger_activity.status = 'Deferred'
+				OR (vtiger_activity.eventstatus = 'Held'
+					AND vtiger_activity.eventstatus != ''))
+			AND vtiger_seactivityrel.crmid = ".$id;
+		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+		$log->debug("Exiting get_history method ...");
+		return getHistory('Accounts',$query,$id);
+	}
+	/**
+	 * Function to get Account related Attachments
+ 	 * @param  integer   $id      - accountid
+ 	 * returns related Attachment record in array format
+ 	 */
+	function get_attachments($id)
+	{
+		 global $log;
+                 $log->debug("Entering get_attachments(".$id.") method ...");
+		// Armando Lüscher 18.10.2005 -> §visibleDescription
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "SELECT vtiger_notes.title, vtiger_notes.notecontent AS description,
+			vtiger_notes.filename, vtiger_notes.notesid AS crmid,
+				'Notes      ' AS ActivityType,
+			vtiger_attachments.type AS FileType,
+				crm2.modifiedtime AS lastmodified, crm2.createdtime,
+			vtiger_seattachmentsrel.attachmentsid,
+			vtiger_users.user_name
+			FROM vtiger_notes
+			INNER JOIN vtiger_senotesrel
+				ON vtiger_senotesrel.notesid = vtiger_notes.notesid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_senotesrel.crmid
+			INNER JOIN vtiger_crmentity crm2
+				ON crm2.crmid = vtiger_notes.notesid
+				AND crm2.deleted = 0
+			LEFT JOIN vtiger_seattachmentsrel
+				ON vtiger_seattachmentsrel.crmid = vtiger_notes.notesid
+			LEFT JOIN vtiger_attachments
+				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_users
+				ON crm2.smcreatorid = vtiger_users.id
+			WHERE vtiger_crmentity.crmid = ".$id."
+		 UNION ALL
+			SELECT vtiger_attachments.description AS title, vtiger_attachments.description,
+			vtiger_attachments.name AS filename,
+			vtiger_seattachmentsrel.attachmentsid AS crmid,
+				'Attachments' AS ActivityType,
+			vtiger_attachments.type AS FileType,
+				crm2.modifiedtime AS lastmodified, crm2.createdtime,
+			vtiger_attachments.attachmentsid,
+			vtiger_users.user_name
+			FROM vtiger_attachments
+			INNER JOIN vtiger_seattachmentsrel
+				ON vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_seattachmentsrel.crmid
+			INNER JOIN vtiger_crmentity crm2
+				ON crm2.crmid = vtiger_attachments.attachmentsid
+			INNER JOIN vtiger_users
+				ON crm2.smcreatorid = vtiger_users.id
+			WHERE vtiger_crmentity.crmid = ".$id."
+			ORDER BY createdtime DESC";
+		$log->debug("Exiting get_attachments method ...");
+		return getAttachmentsAndNotes('Accounts',$query,$id);
+	}
+	/**
+	* Function to get Account related Quotes
+	* @param  integer   $id      - accountid
+	* returns related Quotes record in array format
+	*/
+	function get_quotes($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_quotes(".$id.") method ...");
+		global $app_strings;
+		require_once('modules/Quotes/Quotes.php');
+
+		$focus = new Quotes();
+
+		$button = '';
+		if(isPermitted("Quotes",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
+		}
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
+			vtiger_crmentity.*,
+			vtiger_quotes.*,
+			vtiger_potential.potentialname,
+			vtiger_account.accountname
+			FROM vtiger_quotes
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_quotes.accountid
+			LEFT OUTER JOIN vtiger_potential
+				ON vtiger_potential.potentialid = vtiger_quotes.potentialid
+			LEFT JOIN vtiger_quotegrouprelation
+				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_account.accountid = ".$id;
+		$log->debug("Exiting get_quotes method ...");
+		return GetRelatedList('Accounts','Quotes',$focus,$query,$button,$returnset);
+	}
+	/**
+	* Function to get Account related Invoices 
+	* @param  integer   $id      - accountid
+	* returns related Invoices record in array format
+	*/
+	function get_invoices($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_invoices(".$id.") method ...");
+		global $app_strings;
+		require_once('modules/Invoice/Invoice.php');
+
+		$focus = new Invoice();
+
+		$button = '';
+		if(isPermitted("Invoice",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_INVOICE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_INVOICE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Invoice\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_INVOICE_BUTTON'].'">&nbsp;</td>';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
+			vtiger_crmentity.*,
+			vtiger_invoice.*,
+			vtiger_account.accountname,
+			vtiger_salesorder.subject AS salessubject
+			FROM vtiger_invoice
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_invoice.accountid
+			LEFT OUTER JOIN vtiger_salesorder
+				ON vtiger_salesorder.salesorderid = vtiger_invoice.salesorderid
+			LEFT JOIN vtiger_invoicegrouprelation
+				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_account.accountid = ".$id;
+		$log->debug("Exiting get_invoices method ...");
+		return GetRelatedList('Accounts','Invoice',$focus,$query,$button,$returnset);
+	}
+
+	/**
+	* Function to get Account related SalesOrder 
+	* @param  integer   $id      - accountid
+	* returns related SalesOrder record in array format
+	*/
+	function get_salesorder($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_salesorder(".$id.") method ...");
+		require_once('modules/SalesOrder/SalesOrder.php');
+		global $app_strings;
+
+		$focus = new SalesOrder();
+
+		$button = '';
+		if(isPermitted("SalesOrder",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_SORDER_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;</td>';
+		}
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_crmentity.*,
+			vtiger_salesorder.*,
+			vtiger_quotes.subject AS quotename,
+			vtiger_account.accountname,
+			case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+			FROM vtiger_salesorder
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
+			LEFT OUTER JOIN vtiger_quotes
+				ON vtiger_quotes.quoteid = vtiger_salesorder.quoteid
+			LEFT OUTER JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_salesorder.accountid
+			LEFT JOIN vtiger_sogrouprelation
+				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_salesorder.accountid = ".$id;
+		$log->debug("Exiting get_salesorder method ...");		
+		return GetRelatedList('Accounts','SalesOrder',$focus,$query,$button,$returnset);
+	}
+	/**
+	* Function to get Account related Tickets
+	* @param  integer   $id      - accountid
+	* returns related Ticket record in array format
+	*/
+	function get_tickets($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_tickets(".$id.") method ...");
+		global $app_strings;
+
+		$focus = new HelpDesk();
+		$button = '';
+
+		$button .= '<td valign="bottom" align="right"><input title="New TICKET" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'HelpDesk\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_TICKET'].'">&nbsp;</td>';
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_users.id,
+			vtiger_troubletickets.title, vtiger_troubletickets.ticketid AS crmid,
+			vtiger_troubletickets.status, vtiger_troubletickets.priority,
+			vtiger_troubletickets.parent_id,
+			vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
+			FROM vtiger_troubletickets
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
+			LEFT JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_troubletickets.parent_id
+			LEFT JOIN vtiger_contactdetails
+			        ON vtiger_contactdetails.contactid=vtiger_troubletickets.parent_id
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id=vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_ticketgrouprelation
+				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+			WHERE  vtiger_crmentity.deleted = 0 and ( vtiger_troubletickets.parent_id=".$id." or " ;
+
+		$query .= "vtiger_troubletickets.parent_id in(SELECT vtiger_contactdetails.contactid
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			LEFT JOIN vtiger_contactgrouprelation
+				ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_crmentity.smownerid = vtiger_users.id
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_contactdetails.accountid = ".$id;
+
+			
+		//Appending the security parameter
+		global $current_user;
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		$tab_id=getTabid('Contacts');
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
+		{
+			$sec_parameter=getListViewSecurityParameter('Contacts');
+			$query .= ' '.$sec_parameter;
+
+		}
+
+		$query .= ") )";
+		
+		/*
+		$query .= " UNION ALL
+			SELECT vtiger_users.user_name, vtiger_users.id,
+			vtiger_troubletickets.title, vtiger_troubletickets.ticketid AS crmid,
+			vtiger_troubletickets.status, vtiger_troubletickets.priority,
+			vtiger_troubletickets.parent_id,
+			vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime
+			FROM vtiger_troubletickets
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_troubletickets.parent_id
+			LEFT JOIN vtiger_account
+				ON vtiger_account.accountid = vtiger_contactdetails.accountid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_ticketgrouprelation
+				ON vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+			WHERE vtiger_account.accountid = ".$id;
+		*/	
+		$log->debug("Exiting get_tickets method ...");
+		return GetRelatedList('Accounts','HelpDesk',$focus,$query,$button,$returnset);
+	}
+	/**
+	* Function to get Account related Products 
+	* @param  integer   $id      - accountid
+	* returns related Products record in array format
+	*/
+	function get_products($id)
+	{
+		global $log, $singlepane_view;
+                $log->debug("Entering get_products(".$id.") method ...");
+		require_once('modules/Products/Products.php');
+		global $app_strings;
+
+		$focus = new Products();
+
+		$button = '';
+
+		if(isPermitted("Products",1,"") == 'yes')
+		{
+
+
+			$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Accounts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Accounts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Accounts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_products.productid, vtiger_products.productname,
+			vtiger_products.productcode, vtiger_products.commissionrate,
+			vtiger_products.qty_per_unit, vtiger_products.unit_price,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid
+			FROM vtiger_products
+			INNER JOIN vtiger_seproductsrel ON vtiger_products.productid = vtiger_seproductsrel.productid and vtiger_seproductsrel.setype='Accounts'
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid
+			INNER JOIN vtiger_account ON vtiger_account.accountid = vtiger_seproductsrel.crmid
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_account.accountid = $id";
+
+		$log->debug("Exiting get_products method ...");
+		return GetRelatedList('Accounts','Products',$focus,$query,$button,$returnset);
+	}
+
+	/** Function to export the account records in CSV Format
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Export Accounts Query.
+	*/
+	function create_export_query(&$order_by, &$where)
+	{
+		global $log;
+		global $current_user;
+                $log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
+
+		include("include/utils/ExportUtils.php");
+
+		//To get the Permitted fields query and the permitted fields list
+		$sql = getPermittedFieldsQuery("Accounts", "detail_view");
+		$fields_list = getFieldsListFromQuery($sql);
+
+		$query = "SELECT $fields_list, vtiger_accountgrouprelation.groupname as 'Assigned To Group' 
+	       			FROM ".$this->entity_table."
+				INNER JOIN vtiger_account
+					ON vtiger_crmentity.crmid = vtiger_account.accountid
+				LEFT JOIN vtiger_accountbillads
+					ON vtiger_account.accountid = vtiger_accountbillads.accountaddressid
+				LEFT JOIN vtiger_accountshipads
+					ON vtiger_account.accountid = vtiger_accountshipads.accountaddressid
+				LEFT JOIN vtiger_accountscf
+					ON vtiger_accountscf.accountid = vtiger_account.accountid
+				LEFT JOIN vtiger_accountgrouprelation
+                	                ON vtiger_accountscf.accountid = vtiger_accountgrouprelation.accountid
+	                        LEFT JOIN vtiger_groups
+                        	        ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
+				LEFT JOIN vtiger_users
+					ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status = 'Active'
+				LEFT JOIN vtiger_account vtiger_account2 
+					ON vtiger_account2.accountid = vtiger_account.parentid
+				";//vtiger_account2 is added to get the Member of account
+
+
+		$where_auto = " vtiger_crmentity.deleted = 0 ";
+
+		if($where != "")
+			$query .= "WHERE ($where) AND ".$where_auto;
+		else
+			$query .= "WHERE ".$where_auto;
+
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		//we should add security check when the user has Private Access
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3)
+		{
+			//Added security check to get the permitted records only
+			$query = $query." ".getListViewSecurityParameter("Accounts");
+		}
+
+		if(!empty($order_by))
+			$query .= " ORDER BY $order_by";
+
+		$log->debug("Exiting create_export_query method ...");
+		return $query;
+	}
+
+	/** Function to get the Columnnames of the Account Record
+	* Used By vtigerCRM Word Plugin
+	* Returns the Merge Fields for Word Plugin
+	*/
+	function getColumnNames_Acnt()
+	{
+		global $log,$current_user;
+		$log->debug("Entering getColumnNames_Acnt() method ...");
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+		{
+			$sql1 = "SELECT fieldlabel FROM vtiger_field WHERE tabid = 6";
+		}else
+		{
+			$profileList = getCurrentUserProfileList();
+			$sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=6 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+		} 
+		$result = $this->db->query($sql1);
+		$numRows = $this->db->num_rows($result);
+		for($i=0; $i < $numRows;$i++)
+		{
+			$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
+			$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
+			$custom_fields[$i] = strtoupper($custom_fields[$i]);
+		}
+		$mergeflds = $custom_fields;
+		$log->debug("Exiting getColumnNames_Acnt method ...");
+		return $mergeflds;
+	}
+
+}
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/DetailView.php Mon Apr 16 12:27:44 2007
@@ -83,6 +83,13 @@
 if(isPermitted("Accounts","Delete",$_REQUEST['record']) == 'yes')
 	$smarty->assign("DELETE","permitted");
 
+if(isPermitted("Emails","EditView",'') == 'yes') 
+{ 
+	$smarty->assign("SENDMAILBUTTON","permitted"); 
+	$smarty->assign("EMAIL1", $focus->column_fields['email1']); 
+	$smarty->assign("EMAIL2", $focus->column_fields['email2']); 
+} 
+
 if(isPermitted("Accounts","Merge",'') == 'yes')
 {
 	$smarty->assign("MERGEBUTTON","permitted");
@@ -95,6 +102,7 @@
 		$optionString[$tempVal["templateid"]]=$tempVal["filename"];
 		$tempVal = $adb->fetch_array($wordTemplateResult);
 	}
+	$smarty->assign("TEMPLATECOUNT",$tempCount);
 	$smarty->assign("WORDTEMPLATEOPTIONS",$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']);
         $smarty->assign("TOPTIONS",$optionString);
 }
@@ -113,6 +121,7 @@
 
 $smarty->assign("MODULE",$currentModule);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
 
 if($singlepane_view == 'true')
 {

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/EditView.php Mon Apr 16 12:27:44 2007
@@ -115,6 +115,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE",$_REQUEST['isDuplicate'] );
  
 // Assigned organizations
 $smarty->assign("CURRENT_ORGANIZATION",$current_organization);

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/ListView.php Mon Apr 16 12:27:44 2007
@@ -226,7 +226,6 @@
 }
 if(isPermitted("Accounts","Merge") == 'yes') 
 {
-	$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Accounts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 	$wordTemplateResult = fetchWordTemplateList("Accounts");
 	$tempCount = $adb->num_rows($wordTemplateResult);
 	$tempVal = $adb->fetch_array($wordTemplateResult);
@@ -235,8 +234,23 @@
 		$optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 		$tempVal = $adb->fetch_array($wordTemplateResult);
 	}
-	$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
-}
+	if($tempCount > 0)
+	{
+		$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+
+		$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Accounts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
+	}
+	else
+        {
+		global $current_user;
+                require("user_privileges/user_privileges_".$current_user->id.".php");
+                if($is_admin == true)
+                {
+			$smarty->assign("MERGEBUTTON",'<td><a href=index.php?module=Settings&action=upload&tempModule='.$currentModule.'>'. $app_strings["LBL_CREATE_MERGE_TEMPLATE"].'</td>');
+                }
+        }
+}
+
 //mass merge for word templates
 
 $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
@@ -268,7 +282,7 @@
 $smarty->assign("NAVIGATION", $navigationOutput);
 $smarty->assign("RECORD_COUNTS", $record_string);
 
-$check_button = Button_Check($module);
+$check_button = Button_Check($module); 
 $smarty->assign("CHECK", $check_button);
 
 if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/ListViewTop.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/ListViewTop.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/ListViewTop.php Mon Apr 16 12:27:44 2007
@@ -37,7 +37,17 @@
 	global $current_user;
 	$current_module_strings = return_module_language($current_language, "Accounts");
 
-	$list_query = "select vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) inner join vtiger_account on (vtiger_potential.accountid=vtiger_account.accountid) where vtiger_crmentity.deleted=0 AND vtiger_crmentity.smownerid='".$current_user->id."' and vtiger_potential.sales_stage <> '".$app_strings['LBL_CLOSE_WON']."' and vtiger_potential.sales_stage <> '".$app_strings['LBL_CLOSE_LOST']."' group by vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol order by amount desc;";
+        require('user_privileges/user_privileges_'.$current_user->id.'.php');
+        require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+	$list_query = "select vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol, sum(vtiger_potential.amount) as amount from vtiger_potential inner join vtiger_crmentity on (vtiger_potential.potentialid=vtiger_crmentity.crmid) inner join vtiger_account on (vtiger_potential.accountid=vtiger_account.accountid) where vtiger_crmentity.deleted=0 AND vtiger_crmentity.smownerid='".$current_user->id."' and vtiger_potential.sales_stage not in ('Closed Won', 'Closed Lost','".$app_strings['LBL_CLOSE_WON']."','".$app_strings['LBL_CLOSE_LOST']."') group by vtiger_account.accountid, vtiger_account.accountname, vtiger_account.tickersymbol order by amount desc;";
+	if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[6] == 3)
+	{
+		$sec_parameter=getListViewSecurityParameter('Accounts');
+		$list_query .= $sec_parameter;
+
+	}
+
 	$list_result=$adb->query($list_query);
 	$open_accounts_list = array();
 	$noofrows = min($adb->num_rows($list_result),5);
@@ -74,7 +84,7 @@
 				'AMOUNT' => ($account['amount']),
 				);
 
-		$value[]='<a href="index.php?action=DetailView&module=Accounts&record='.$account['accountid'].'">'.$account['accountname'].'</a>';
+		$value[]='<a href="index.php?action=DetailView&module=Accounts&record='.$account['accountid'].'">'.substr($account['accountname'],0,20).'...'.'</a>';
 		$value[]=convertFromDollar($account['amount'],$rate);
 		$entries[$account['accountid']]=$value;	
 	}

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/Merge.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/Merge.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/Merge.php Mon Apr 16 12:27:44 2007
@@ -1,259 +1,260 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-?>
-<html>
-<body>
-<script>
-if (document.layers)
-{
-	document.write("This feature requires IE 5.5 or higher for Windows on Microsoft Windows 2000, Windows NT4 SP6, Windows XP.");
-	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");
-}	
-else if (document.layers || (!document.all && document.getElementById))
-{
-	document.write("This feature requires IE 5.5 or higher for Windows on Microsoft Windows 2000, Windows NT4 SP6, Windows XP.");
-	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");	
-}
-else if(document.all)
-{
-	document.write("<OBJECT Name='vtigerCRM' codebase='modules/Settings/vtigerCRM.CAB#version=1,5,0,0' id='objMMPage' classid='clsid:0FC436C2-2E62-46EF-A3FB-E68E94705126' width=0 height=0></object>");
-}
-</script>
-<?php
-require_once('include/database/PearDatabase.php');
-require_once('config.php');
-
-$templateid = $_REQUEST['mergefile'];
-
-if($templateid == "")
-{
-	die("Select Mail Merge Template");
-}
-//get the particular file from db and store it in the local hard disk.
-//store the path to the location where the file is stored and pass it  as parameter to the method 
-$sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid;
-
-$result = $adb->query($sql);
-$temparray = $adb->fetch_array($result);
-
-$fileContent = $temparray['data'];
-$filename=$temparray['filename'];
-$filesize=$temparray['filesize'];
-$wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/";
-
-
-$handle = fopen($wordtemplatedownloadpath.$temparray['filename'],"wb");
-fwrite($handle,base64_decode($fileContent),$filesize);
-fclose($handle);
-
-//<<<<<<<<<<<<<<<<<<<<<<<<<<<for mass merge>>>>>>>>>>>>>>>>>>>>>>>>>>>
-$mass_merge = $_REQUEST['idlist'];
-$single_record = $_REQUEST['record'];
-
-if($mass_merge != "")
-{	
-	$mass_merge = explode(";",$mass_merge);
-	$temp_mass_merge = $mass_merge;
-	if(array_pop($temp_mass_merge)=="")
-		array_pop($mass_merge);
-	$mass_merge = implode(",",$mass_merge);
-}else if($single_record != "")
-{
-	$mass_merge = $single_record;	
-}else
-{
-	die("Record Id is not found, cannot merge the document");
-}
-
-//echo $mass_merge;
-//die;
-//for setting vtiger_accountid=0 for the contacts which are deleted
-$ct_query = "select crmid from vtiger_crmentity where setype='Contacts' and deleted=1";
-$result = $adb->query($ct_query);
-
-while($row = $adb->fetch_array($result))
-{
-	$deleted_id[] = $row['crmid'];
-}
-
-if(count($deleted_id) > 0)
-{
-	$deleted_id = implode(",",$deleted_id);
-	$update_query = "update vtiger_contactdetails set accountid = 0 where contactid in (".$deleted_id.")";
-	$result = $adb->query($update_query);
-}
-//End setting vtiger_accountid=0 for the contacts which are deleted
-
-//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
-$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 6 and vtiger_field.block <> 75 order by vtiger_field.tablename";
-
-$result = $adb->query($query1);
-$y=$adb->num_rows($result);
-	
-for ($x=0; $x<$y; $x++)
-{ 
-  $tablename = $adb->query_result($result,$x,"tablename");
-  $columnname = $adb->query_result($result,$x,"columnname");
-  $modulename = $adb->query_result($result,$x,"name");
-  
-  if($tablename == "crmentity")
-  {
-  	if($modulename == "Contacts")
-  	{
-  		$tablename = "vtiger_crmentityContacts";
-  	}
-  }
-  $querycolumns[$x] = $tablename.".".$columnname;
-	if($columnname == "smownerid")
-  {
-      if($modulename == "Accounts")
-      {
-  			$querycolumns[$x] = "concat(vtiger_users.last_name,' ',vtiger_users.first_name) as userjoinname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
-      }
-  		if($modulename == "Contacts")
-      {
-      	$querycolumns[$x] = "concat(vtiger_usersContacts.last_name,' ',vtiger_usersContacts.first_name) as userjoincname";
-      }
-  }
-	if($columnname == "parentid")
-	{
-		$querycolumns[$x] = "vtiger_accountAccount.accountname";
-	}
-	if($columnname == "accountid")
-	{
-		$querycolumns[$x] = "vtiger_accountContacts.accountname";
-	}
-	if($columnname == "reportsto")
-	{
-		$querycolumns[$x] = "vtiger_contactdetailsContacts.lastname";
-	}
-
-	if($modulename == "Accounts")
-  {
-    	$field_label[$x] = "ACCOUNT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
-  		if($columnname == "smownerid")
-  		{
-  		$field_label[$x] = $field_label[$x].",USER_FIRSTNAME,USER_LASTNAME,USER_USERNAME,USER_YAHOOID,USER_TITLE,USER_OFFICEPHONE,USER_DEPARTMENT,USER_MOBILE,USER_OTHERPHONE,USER_FAX,USER_EMAIL,USER_HOMEPHONE,USER_OTHEREMAIL,USER_PRIMARYADDRESS,USER_CITY,USER_STATE,USER_POSTALCODE,USER_COUNTRY";
-  		}
-	}
-	
-	if($modulename == "Contacts")
-  {
-  	$field_label[$x] = "CONTACT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
-  }
-  
-}
-
-$csvheader = implode(",",$field_label);
-//<<<<<<<<<<<<<<<<End>>>>>>>>>>>>>>>>>>>>>>>>
-	
-if(count($querycolumns) > 0)
-{
-	$selectcolumns = implode($querycolumns,",");
-
-$query = "select  ".$selectcolumns." from vtiger_account 
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid 
-				inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid 
-				inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid 
-				inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid 
-				left join vtiger_account as vtiger_accountAccount on vtiger_accountAccount.accountid = vtiger_account.parentid
-				left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
-				left join vtiger_contactdetails on vtiger_contactdetails.accountid=vtiger_account.accountid
-				left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid 
-				left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
-				left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
-				left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
-				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
-				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
-				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
-				where vtiger_crmentity.deleted=0 and (vtiger_crmentityContacts.deleted=0 || vtiger_crmentityContacts.deleted is null) and vtiger_account.accountid in(".$mass_merge.")";
-//echo $query;
-//die;	
-$result = $adb->query($query);
-	
-while($columnValues = $adb->fetch_array($result))
-{
-	$y=$adb->num_fields($result);
-  for($x=0; $x<$y; $x++)
-  {
-  	$value = $columnValues[$x];
-  	//<<<<<<<<<<<<<<<for modifing default values>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-	if($value == "0")
-  	{
-  		$value = "";
-  	}
-  	if(trim($value) == "--None--" || trim($value) == "--none--")
-  	{
-  		$value = "";
-  	}
-	//<<<<<<<<<<<<<<<End>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-		$actual_values[$x] = $value;
-		$actual_values[$x] = str_replace('"'," ",$actual_values[$x]);
-		//if value contains any line feed or carriage return replace the value with ".value."
-		if (preg_match ("/(\r\n)/", $actual_values[$x])) 
-		{
-			$actual_values[$x] = '"'.$actual_values[$x].'"';
-		}
-		$actual_values[$x] = str_replace(","," ",$actual_values[$x]);
-  }
-	$mergevalue[] = implode($actual_values,",");  	
-}
-$csvdata = implode($mergevalue,"###");
-}else
-{
-	die("No fields to do Merge");
-}
-
-$handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb");
-fwrite($handle,$csvheader."\r\n");
-fwrite($handle,str_replace("###","\r\n",$csvdata));
-fclose($handle);
-?>
-<script>
-if (window.ActiveXObject){
-	try 
-	{
-  		ovtigerVM = eval("new ActiveXObject('vtigerCRM.ActiveX');");
-  		if(ovtigerVM)
-  		{
-        	var filename = "<?php echo $filename?>";
-        	if(filename != "")
-        	{
-        		if(objMMPage.bDLTempDoc("<?php echo $site_URL;?>/test/wordtemplatedownload/<?php echo $filename; ?>","MMTemplate.doc"))
-        		{
-        			try
-        			{
-        				if(objMMPage.Init())
-        				{
-        					objMMPage.vLTemplateDoc();
-        					objMMPage.bBulkHDSrc("<?php echo $site_URL;?>/test/wordtemplatedownload/datasrc.csv");
-        					objMMPage.vBulkOpenDoc();
-        					objMMPage.UnInit()
-        					window.history.back();
-        				}		
-        			}catch(errorObject)
-        			{
-        				document.write("Error while processing mail merge operation");
-        			}
-        		}else
-        		{
-        			document.write("Cannot get template document");
-        		}
-        	}
-  		}
-		}
-	catch(e) {
-		document.write("Requires to download ActiveX Control from vtigerCRM. Please, ensure that you have administration privilage");
-	}
-}
-</script>
-</body>
-</html>
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+?>
+<html>
+<body>
+<script>
+if (document.layers)
+{
+	document.write("This feature requires IE 5.5 or higher for Windows on Microsoft Windows 2000, Windows NT4 SP6, Windows XP.");
+	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");
+}	
+else if (document.layers || (!document.all && document.getElementById))
+{
+	document.write("This feature requires IE 5.5 or higher for Windows on Microsoft Windows 2000, Windows NT4 SP6, Windows XP.");
+	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");	
+}
+else if(document.all)
+{
+	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");
+	document.write("<OBJECT Name='vtigerCRM' codebase='modules/Settings/vtigerCRM.CAB#version=1,5,0,0' id='objMMPage' classid='clsid:0FC436C2-2E62-46EF-A3FB-E68E94705126' width=0 height=0></object>");
+}
+</script>
+<?php
+require_once('include/database/PearDatabase.php');
+require_once('config.php');
+
+$templateid = $_REQUEST['mergefile'];
+
+if($templateid == "")
+{
+	die("Select Mail Merge Template");
+}
+//get the particular file from db and store it in the local hard disk.
+//store the path to the location where the file is stored and pass it  as parameter to the method 
+$sql = "select filename,data,filesize from vtiger_wordtemplates where templateid=".$templateid;
+
+$result = $adb->query($sql);
+$temparray = $adb->fetch_array($result);
+
+$fileContent = $temparray['data'];
+$filename=$temparray['filename'];
+$filesize=$temparray['filesize'];
+$wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/";
+
+
+$handle = fopen($wordtemplatedownloadpath.$temparray['filename'],"wb");
+fwrite($handle,base64_decode($fileContent),$filesize);
+fclose($handle);
+
+//<<<<<<<<<<<<<<<<<<<<<<<<<<<for mass merge>>>>>>>>>>>>>>>>>>>>>>>>>>>
+$mass_merge = $_REQUEST['idlist'];
+$single_record = $_REQUEST['record'];
+
+if($mass_merge != "")
+{	
+	$mass_merge = explode(";",$mass_merge);
+	$temp_mass_merge = $mass_merge;
+	if(array_pop($temp_mass_merge)=="")
+		array_pop($mass_merge);
+	$mass_merge = implode(",",$mass_merge);
+}else if($single_record != "")
+{
+	$mass_merge = $single_record;	
+}else
+{
+	die("Record Id is not found, cannot merge the document");
+}
+
+//echo $mass_merge;
+//die;
+//for setting vtiger_accountid=0 for the contacts which are deleted
+$ct_query = "select crmid from vtiger_crmentity where setype='Contacts' and deleted=1";
+$result = $adb->query($ct_query);
+
+while($row = $adb->fetch_array($result))
+{
+	$deleted_id[] = $row['crmid'];
+}
+
+if(count($deleted_id) > 0)
+{
+	$deleted_id = implode(",",$deleted_id);
+	$update_query = "update vtiger_contactdetails set accountid = 0 where contactid in (".$deleted_id.")";
+	$result = $adb->query($update_query);
+}
+//End setting vtiger_accountid=0 for the contacts which are deleted
+
+//<<<<<<<<<<<<<<<<header for csv and select columns for query>>>>>>>>>>>>>>>>>>>>>>>>
+$query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 6 and vtiger_field.block <> 75 order by vtiger_field.tablename";
+
+$result = $adb->query($query1);
+$y=$adb->num_rows($result);
+	
+for ($x=0; $x<$y; $x++)
+{ 
+  $tablename = $adb->query_result($result,$x,"tablename");
+  $columnname = $adb->query_result($result,$x,"columnname");
+  $modulename = $adb->query_result($result,$x,"name");
+  
+  if($tablename == "crmentity")
+  {
+  	if($modulename == "Contacts")
+  	{
+  		$tablename = "vtiger_crmentityContacts";
+  	}
+  }
+  $querycolumns[$x] = $tablename.".".$columnname;
+	if($columnname == "smownerid")
+  {
+      if($modulename == "Accounts")
+      {
+  			$querycolumns[$x] = "concat(vtiger_users.last_name,' ',vtiger_users.first_name) as userjoinname,vtiger_users.first_name,vtiger_users.last_name,vtiger_users.user_name,vtiger_users.yahoo_id,vtiger_users.title,vtiger_users.phone_work,vtiger_users.department,vtiger_users.phone_mobile,vtiger_users.phone_other,vtiger_users.phone_fax,vtiger_users.email1,vtiger_users.phone_home,vtiger_users.email2,vtiger_users.address_street,vtiger_users.address_city,vtiger_users.address_state,vtiger_users.address_postalcode,vtiger_users.address_country";
+      }
+  		if($modulename == "Contacts")
+      {
+      	$querycolumns[$x] = "concat(vtiger_usersContacts.last_name,' ',vtiger_usersContacts.first_name) as userjoincname";
+      }
+  }
+	if($columnname == "parentid")
+	{
+		$querycolumns[$x] = "vtiger_accountAccount.accountname";
+	}
+	if($columnname == "accountid")
+	{
+		$querycolumns[$x] = "vtiger_accountContacts.accountname";
+	}
+	if($columnname == "reportsto")
+	{
+		$querycolumns[$x] = "vtiger_contactdetailsContacts.lastname";
+	}
+
+	if($modulename == "Accounts")
+  {
+    	$field_label[$x] = "ACCOUNT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
+  		if($columnname == "smownerid")
+  		{
+  		$field_label[$x] = $field_label[$x].",USER_FIRSTNAME,USER_LASTNAME,USER_USERNAME,USER_YAHOOID,USER_TITLE,USER_OFFICEPHONE,USER_DEPARTMENT,USER_MOBILE,USER_OTHERPHONE,USER_FAX,USER_EMAIL,USER_HOMEPHONE,USER_OTHEREMAIL,USER_PRIMARYADDRESS,USER_CITY,USER_STATE,USER_POSTALCODE,USER_COUNTRY";
+  		}
+	}
+	
+	if($modulename == "Contacts")
+  {
+  	$field_label[$x] = "CONTACT_".strtoupper(str_replace(" ","",$adb->query_result($result,$x,"fieldlabel")));
+  }
+  
+}
+
+$csvheader = implode(",",$field_label);
+//<<<<<<<<<<<<<<<<End>>>>>>>>>>>>>>>>>>>>>>>>
+	
+if(count($querycolumns) > 0)
+{
+	$selectcolumns = implode($querycolumns,",");
+
+$query = "select  ".$selectcolumns." from vtiger_account 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid 
+				inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid 
+				inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid 
+				inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid 
+				left join vtiger_account as vtiger_accountAccount on vtiger_accountAccount.accountid = vtiger_account.parentid
+				left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid
+				left join vtiger_contactdetails on vtiger_contactdetails.accountid=vtiger_account.accountid
+				left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid 
+				left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
+				left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
+				left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
+				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
+				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
+				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
+				where vtiger_crmentity.deleted=0 and (vtiger_crmentityContacts.deleted=0 || vtiger_crmentityContacts.deleted is null) and vtiger_account.accountid in(".$mass_merge.")";
+//echo $query;
+//die;	
+$result = $adb->query($query);
+	
+while($columnValues = $adb->fetch_array($result))
+{
+	$y=$adb->num_fields($result);
+  for($x=0; $x<$y; $x++)
+  {
+  	$value = $columnValues[$x];
+  	//<<<<<<<<<<<<<<<for modifing default values>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+	if($value == "0")
+  	{
+  		$value = "";
+  	}
+  	if(trim($value) == "--None--" || trim($value) == "--none--")
+  	{
+  		$value = "";
+  	}
+	//<<<<<<<<<<<<<<<End>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+		$actual_values[$x] = $value;
+		$actual_values[$x] = str_replace('"'," ",$actual_values[$x]);
+		//if value contains any line feed or carriage return replace the value with ".value."
+		if (preg_match ("/(\r\n)/", $actual_values[$x])) 
+		{
+			$actual_values[$x] = '"'.$actual_values[$x].'"';
+		}
+		$actual_values[$x] = str_replace(","," ",$actual_values[$x]);
+  }
+	$mergevalue[] = implode($actual_values,",");  	
+}
+$csvdata = implode($mergevalue,"###");
+}else
+{
+	die("No fields to do Merge");
+}
+
+$handle = fopen($wordtemplatedownloadpath."datasrc.csv","wb");
+fwrite($handle,$csvheader."\r\n");
+fwrite($handle,str_replace("###","\r\n",$csvdata));
+fclose($handle);
+?>
+<script>
+if (window.ActiveXObject){
+	try 
+	{
+  		ovtigerVM = eval("new ActiveXObject('vtigerCRM.ActiveX');");
+  		if(ovtigerVM)
+  		{
+        	var filename = "<?php echo $filename?>";
+        	if(filename != "")
+        	{
+        		if(objMMPage.bDLTempDoc("<?php echo $site_URL;?>/test/wordtemplatedownload/<?php echo $filename; ?>","MMTemplate.doc"))
+        		{
+        			try
+        			{
+        				if(objMMPage.Init())
+        				{
+        					objMMPage.vLTemplateDoc();
+        					objMMPage.bBulkHDSrc("<?php echo $site_URL;?>/test/wordtemplatedownload/datasrc.csv");
+        					objMMPage.vBulkOpenDoc();
+        					objMMPage.UnInit()
+        					window.history.back();
+        				}		
+        			}catch(errorObject)
+        			{
+        				document.write("Error while processing mail merge operation");
+        			}
+        		}else
+        		{
+        			document.write("Cannot get template document");
+        		}
+        	}
+  		}
+		}
+	catch(e) {
+		document.write("Requires to download ActiveX Control from vtigerCRM. Please, ensure that you have administration privilage");
+	}
+}
+</script>
+</body>
+</html>

Modified: vtigercrm/branches/5.1_jens/modules/Accounts/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Accounts/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Accounts/Save.php Mon Apr 16 12:27:44 2007
@@ -26,6 +26,26 @@
 //require_once('database/DatabaseConnection.php');
 require_once('include/database/PearDatabase.php');
 
+if(isset($_REQUEST['dup_check']) && $_REQUEST['dup_check'] != '')
+{
+	//started
+	$value = $_REQUEST['accountname'];
+	$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname ='".$value."' and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
+	$result = $adb->query($query);
+        if($adb->num_rows($result) > 0)
+	{
+		echo 'Account Name Already Exists!';
+	}
+	else
+	{
+		echo 'SUCCESS';
+	}
+	die;
+}
+//Ended
+
+
+
 $local_log =& LoggerManager::getLogger('index');
 global $log;
 $focus = new Accounts();
@@ -51,9 +71,7 @@
 	if(isset($_REQUEST[$fieldname]))
 	{
 		$value = $_REQUEST[$fieldname];
-		//echo '<BR>';
-		//echo $fieldname."         ".$value;
-		//echo '<BR>';
+		$log->DEBUG($fieldname."=Field Name &first& Value =".$value);
 		$focus->column_fields[$fieldname] = $value;
 	}
 	if(isset($_REQUEST['annual_revenue']))
@@ -76,6 +94,14 @@
 		
 	}
 }*/
+
+//When changing the Account Address Information  it should also change the related contact address - dina
+if($focus->mode == 'edit' && $_REQUEST['address_change'] == 'yes')
+{
+                $query = "update vtiger_contactaddress set mailingcity='".$focus->column_fields['bill_city']."',mailingstreet='".$focus->column_fields['bill_street']."',mailingcountry='".$focus->column_fields['bill_country']."',mailingzip='".$focus->column_fields['bill_code']."',mailingpobox='".$focus->column_fields['bill_pobox']."',mailingstate='".$focus->column_fields['bill_state']."',othercountry='".$focus->column_fields['ship_country']."',othercity='".$focus->column_fields['ship_city']."',otherstate='".$focus->column_fields['ship_state']."',otherzip='".$focus->column_fields['ship_code']."',otherstreet='".$focus->column_fields['ship_street']."',otherpobox='".$focus->column_fields['ship_pobox']."'  where contactaddressid in (select contactid from vtiger_contactdetails where accountid=".$focus->id.")" ;
+                $adb->query($query);
+}
+//Changing account address - Ends
 
 //$focus->saveentity("Accounts");
 $focus->save("Accounts");

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/Activity.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/Activity.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/Activity.php Mon Apr 16 12:27:44 2007
@@ -1,740 +1,764 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Activities/Activity.php,v 1.26 2005/03/26 10:42:13 rank Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('modules/Calendar/RenderRelatedListUI.php');
-require_once('data/CRMEntity.php');
-
-// Task is used to store customer information.
-class Activity extends CRMEntity {
-	var $log;
-	var $db;
-	var $reminder_table = 'vtiger_activity_reminder';
-	var $tab_name = Array('vtiger_crmentity','vtiger_activity');
-
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_activity'=>'activityid','vtiger_seactivityrel'=>'activityid','vtiger_cntactivityrel'=>'activityid','vtiger_salesmanactivityrel'=>'activityid','vtiger_activity_reminder'=>'activity_id','vtiger_recurringevents'=>'activityid');
-
-	var $column_fields = Array();
-	var $sortby_fields = Array('subject','due_date','date_start','smownerid','activitytype');	//Sorting is added for due date and start date	
-
-	// This is used to retrieve related vtiger_fields from form posts.
-	var $additional_column_fields = Array('assigned_user_name', 'assigned_user_id', 'contactname', 'contact_phone', 'contact_email', 'parent_name');
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-       'Close'=>Array('activity'=>'status'),
-       'Type'=>Array('activity'=>'activitytype'),
-       'Subject'=>Array('activity'=>'subject'),
-       'Related to'=>Array('seactivityrel'=>'activityid'),
-       'Start Date'=>Array('activity'=>'date_start'),
-       'End Date'=>Array('activity'=>'due_date'),
-       'Recurring Type'=>Array('recurringevents'=>'recurringtype'),
-       'Assigned To'=>Array('crmentity'=>'smownerid')
-       );
-
-       var $range_fields = Array(
-	'name',
-	'date_modified',
-	'start_date',
-	'id',
-	'status',
-	'date_due',
-	'time_start',
-	'description',
-	'contact_name',
-	'priority',
-	'duehours',
-	'dueminutes',
-	'location'
-	);
-       
-
-       var $list_fields_name = Array(
-       'Close'=>'status',
-       'Type'=>'activitytype',
-       'Subject'=>'subject',
-       'Contact Name'=>'lastname',
-       'Related to'=>'activityid',
-       'Start Date'=>'date_start',
-       'End Date'=>'due_date',
-	'Recurring Type'=>'recurringtype',	
-       'Assigned To'=>'assigned_user_id');
-
-       var $list_link_field= 'subject';
-	
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'due_date';
-	var $default_sort_order = 'ASC';
-
-	function Activity() {
-		$this->log = LoggerManager::getLogger('Calendar');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Calendar');
-	}
-
-
-	function save_module($module)
-	{
-		//Handling module specific save
-		//Insert into seactivity rel			
-				if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')
-				{
-					$this->insertIntoEntityTable("vtiger_seactivityrel", $module);
-				}
-				elseif($this->column_fields['parent_id']=='' && $insertion_mode=="edit")
-				{
-					$this->deleteRelation("vtiger_seactivityrel");
-				}
-		//Insert into cntactivity rel		
-
-			if(isset($this->column_fields['contact_id']) && $this->column_fields['contact_id'] != '')
-			{
-				$this->insertIntoEntityTable('vtiger_cntactivityrel', $module);
-			}
-			elseif($this->column_fields['contact_id'] =='' && $insertion_mode=="edit")
-			{
-				$this->deleteRelation('vtiger_cntactivityrel');
-			}
-		
-		//Handling for recurring type
-			//Insert into vtiger_activity_remainder table
-			if(isset($this->column_fields['recurringtype']) && $this->column_fields['recurringtype']!='')
-				$recur_type = trim($this->column_fields['recurringtype']);
-			else
-    				$recur_type='';	
-		
-			if($recur_type == "--None--")
-			{
-				$this->insertIntoReminderTable('vtiger_activity_reminder',$module,"");
-			}
-
-			//Insert into vtiger_recurring event table
-			$recur_type = trim($this->column_fields['recurringtype']);
-			if($recur_type != "--None--"  && $recur_type != '')
-		      	{		   
-				$recur_data = getrecurringObjValue();
-				if(is_object($recur_data))
-	      				$this->insertIntoRecurringTable($recur_data);
-			}
-
-		//Handling for invitees
-		if(isset($_REQUEST['inviteesid']) && $_REQUEST['inviteesid']!='')
-		{
-			$selected_users_string =  $_REQUEST['inviteesid'];
-			$invitees_array = explode(';',$selected_users_string);
-			$this->insertIntoInviteeTable('vtiger_invitees',$module,$invitees_array);
-
-		}
-
-		//Inserting into sales man activity rel
-		$this->insertIntoSmActivityRel($module);
-
-
-			
-	}	
-
-
-	/** Function to insert values in vtiger_activity_remainder table for the specified module,
-  	  * @param $table_name -- table name:: Type varchar
-  	  * @param $module -- module:: Type varchar
- 	 */
-	function insertIntoReminderTable($table_name,$module,$recurid)
-	{
-	 	global $log;
-		$log->info("in insertIntoReminderTable  ".$table_name."    module is  ".$module);
-		if($_REQUEST['set_reminder'] == 'Yes')
-		{
-			$log->debug("set reminder is set");
-			$rem_days = $_REQUEST['remdays'];
-			$log->debug("rem_days is ".$rem_days);
-			$rem_hrs = $_REQUEST['remhrs'];
-			$log->debug("rem_hrs is ".$rem_hrs);
-			$rem_min = $_REQUEST['remmin'];
-			$log->debug("rem_minutes is ".$rem_min);
-			$reminder_time = $rem_days * 24 * 60 + $rem_hrs * 60 + $rem_min;
-			$log->debug("reminder_time is ".$reminder_time);
-			if ($recurid == "")
-			{
-				if($_REQUEST['mode'] == 'edit')
-				{
-					$this->activity_reminder($this->id,$reminder_time,0,$recurid,'edit');
-				}
-				else
-				{
-					$this->activity_reminder($this->id,$reminder_time,0,$recurid,'');
-				}
-			}
-			else
-			{
-				$this->activity_reminder($this->id,$reminder_time,0,$recurid,'');
-			}
-		}
-		elseif($_REQUEST['set_reminder'] == 'No')
-		{
-			$this->activity_reminder($this->id,'0',0,$recurid,'delete');
-		}
-	}
-	
-
-	// Code included by Jaguar - starts
-	/** Function to insert values in vtiger_recurringevents table for the specified tablename,module
-  	  * @param $recurObj -- Recurring Object:: Type varchar
- 	 */	
-function insertIntoRecurringTable(& $recurObj)
-{
-	global $log,$adb;
-	$log->info("in insertIntoRecurringTable  ");
-	$st_date = $recurObj->startdate->get_formatted_date();
-	$log->debug("st_date ".$st_date);
-	$end_date = $recurObj->enddate->get_formatted_date();
-	$log->debug("end_date is set ".$end_date);
-	$type = $recurObj->recur_type;
-	$log->debug("type is ".$type);
-        $flag="true";
-
-	if($_REQUEST['mode'] == 'edit')
-	{
-		$activity_id=$this->id;
-
-		$sql='select min(recurringdate) AS min_date,max(recurringdate) AS max_date, recurringtype, activityid from vtiger_recurringevents where activityid='. $activity_id.' group by activityid, recurringtype';
-		
-		$result = $adb->query($sql);
-		$noofrows = $adb->num_rows($result);
-		for($i=0; $i<$noofrows; $i++)
-		{
-			$recur_type_b4_edit = $adb->query_result($result,$i,"recurringtype");
-			$date_start_b4edit = $adb->query_result($result,$i,"min_date");
-			$end_date_b4edit = $adb->query_result($result,$i,"max_date");
-		}
-		if(($st_date == $date_start_b4edit) && ($end_date==$end_date_b4edit) && ($type == $recur_type_b4_edit))
-		{
-			if($_REQUEST['set_reminder'] == 'Yes')
-			{
-				$sql = 'delete from vtiger_activity_reminder where activity_id='.$activity_id;
-				$adb->query($sql);
-				$sql = 'delete  from vtiger_recurringevents where activityid='.$activity_id;
-				$adb->query($sql);
-				$flag="true";
-			}
-			elseif($_REQUEST['set_reminder'] == 'No')
-			{
-				$sql = 'delete  from vtiger_activity_reminder where activity_id='.$activity_id;
-				$adb->query($sql);
-				$flag="false";
-			}
-			else
-				$flag="false";
-		}
-		else
-		{
-			$sql = 'delete from vtiger_activity_reminder where activity_id='.$activity_id;
-			$adb->query($sql);
-			$sql = 'delete  from vtiger_recurringevents where activityid='.$activity_id;
-			$adb->query($sql);
-		}
-	}
-	$date_array = $recurObj->recurringdates;
-	if(isset($recurObj->recur_freq) && $recurObj->recur_freq != null)
-		$recur_freq = $recurObj->recur_freq;
-	else
-		$recur_freq = 1;
-	if($recurObj->recur_type == 'Daily' || $recurObj->recur_type == 'Yearly')
-		$recurringinfo = $recurObj->recur_type;
-	elseif($recurObj->recur_type == 'Weekly')
-	{
-		$recurringinfo = $recurObj->recur_type;
-		if($recurObj->dayofweek_to_rpt != null)
-			$recurringinfo = $recurringinfo.'::'.implode('::',$recurObj->dayofweek_to_rpt);
-	}
-	elseif($recurObj->recur_type == 'Monthly')
-	{
-		$recurringinfo =  $recurObj->recur_type.'::'.$recurObj->repeat_monthby;
-		if($recurObj->repeat_monthby == 'date')
-			$recurringinfo = $recurringinfo.'::'.$recurObj->rptmonth_datevalue;
-		else
-			$recurringinfo = $recurringinfo.'::'.$recurObj->rptmonth_daytype.'::'.$recurObj->dayofweek_to_rpt[0];
-	}
-	else
-	{
-		$recurringinfo = '';
-	}
-	if($flag=="true")
-	{
-		for($k=0; $k< count($date_array); $k++)
-		{
-			$tdate=$date_array[$k];
-			if($tdate <= $end_date)
-			{
-				$max_recurid_qry = 'select max(recurringid) AS recurid from vtiger_recurringevents;';
-				$result = $adb->query($max_recurid_qry);
-				$noofrows = $adb->num_rows($result);
-				for($i=0; $i<$noofrows; $i++)
-				{
-					$recur_id = $adb->query_result($result,$i,"recurid");
-				}
-				$current_id =$recur_id+1;
-				$recurring_insert = "insert into vtiger_recurringevents values ('".$current_id."','".$this->id."','".$tdate."','".$type."','".$recur_freq."','".$recurringinfo."')";
-				$adb->query($recurring_insert);
-				if($_REQUEST['set_reminder'] == 'Yes')
-				{
-					$this->insertIntoReminderTable("vtiger_activity_reminder",$module,$current_id,'');
-				}
-			}
-		}
-	}
-}
-
-
-	/** Function to insert values in vtiger_invitees table for the specified module,tablename ,invitees_array
-  	  * @param $table_name -- table name:: Type varchar
-  	  * @param $module -- module:: Type varchar
-	  * @param $invitees_array Array
- 	 */
-	function insertIntoInviteeTable($table_name,$module,$invitees_array)
-	{
-		global $log,$adb;
-		$log->debug("Entering insertIntoInviteeTable(".$table_name.",".$module.",".$invitees_array.") method ...");
-		foreach($invitees_array as $inviteeid)
-		{
-			if($inviteeid != '')
-			{
-				$query="insert into vtiger_invitees values(".$this->id.",".$inviteeid.")";
-				$adb->query($query);
-			}
-		}
-		$log->debug("Exiting insertIntoInviteeTable method ...");
-
-	}
-
-
-	/** Function to insert values in vtiger_salesmanactivityrel table for the specified module
-  	  * @param $module -- module:: Type varchar
- 	 */
-
-  	function insertIntoSmActivityRel($module)
-  	{
-    		global $adb;
-    		global $current_user;
-    		if($this->mode == 'edit')
-    		{
-
-      			$sql = "delete from vtiger_salesmanactivityrel where activityid=".$this->id." and smid = ".$this->column_fields['assigned_user_id']."";
-      			$adb->query($sql);
-
-    		}
-		$sql_qry = "insert into vtiger_salesmanactivityrel (smid,activityid) values(".$this->column_fields['assigned_user_id'].",".$this->id.")";
-    		$adb->query($sql_qry);
-
-  	}
-	
-	
-	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
-	/**
-	 * Function to get sort order
-	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	 */
-	function getSortOrder()
-	{	
-		global $log;                                                                                                  $log->debug("Entering getSortOrder() method ...");
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['ACTIVITIES_SORT_ORDER'] != '')?($_SESSION['ACTIVITIES_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder method ...");
-		return $sorder;
-	}
-	
-	/**
-	 * Function to get order by
-	 * return string  $order_by    - fieldname(eg: 'subject')
-	 */
-	function getOrderBy()
-	{
-		global $log;
-                 $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['ACTIVITIES_ORDER_BY'] != '')?($_SESSION['ACTIVITIES_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-	// Mike Crowe Mod --------------------------------------------------------
-
-
-
-//Function Call for Related List -- Start
-	/**
-	 * Function to get Activity related Contacts
-	 * @param  integer   $id      - activityid
-	 * returns related Contacts record in array format
-	 */
-        function get_contacts($id)
-	{
-			global $log;
-                        $log->debug("Entering get_contacts(".$id.") method ...");
-			global $app_strings;
-
-			$focus = new Contacts();
-
-			$button = '';
-
-			$returnset = '&return_module=Calendar&return_action=CallRelatedList&activity_mode=Events&return_id='.$id;
-
-			$query = 'select vtiger_users.user_name,vtiger_contactdetails.accountid,vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_contactdetails.department, vtiger_contactdetails.title, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_cntactivityrel.activityid = vtiger_activitygrouprelation.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname where vtiger_cntactivityrel.activityid='.$id.' and vtiger_crmentity.deleted=0';
-			$log->debug("Exiting get_contacts method ...");
-			return GetRelatedList('Calendar','Contacts',$focus,$query,$button,$returnset);
-        }
-	
-	/**
-	 * Function to get Activity related Users
-	 * @param  integer   $id      - activityid
-	 * returns related Users record in array format
-	 */
-
-        function get_users($id)
-	{	
-		global $log;
-                $log->debug("Entering get_contacts(".$id.") method ...");
-		global $app_strings;
-
-		$focus = new Users();
-
-		$button = '';
-
-		$returnset = '&return_module=Calendar&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'SELECT vtiger_users.id, vtiger_users.first_name,vtiger_users.last_name, vtiger_users.user_name, vtiger_users.email1, vtiger_users.email2, vtiger_users.status, vtiger_users.is_admin, vtiger_user2role.roleid, vtiger_users.yahoo_id, vtiger_users.phone_home, vtiger_users.phone_work, vtiger_users.phone_mobile, vtiger_users.phone_other, vtiger_users.phone_fax,vtiger_activity.date_start,vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes from vtiger_users inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.smid=vtiger_users.id  inner join vtiger_activity on vtiger_activity.activityid=vtiger_salesmanactivityrel.activityid inner join vtiger_user2role on vtiger_user2role.userid=vtiger_users.id where vtiger_activity.activityid='.$id;
-		$log->debug("Exiting get_users method ...");
-		return GetRelatedList('Calendar','Users',$focus,$query,$button,$returnset);
-
-
-	}
-
-	/**
-         * Function to get activities for given criteria
-	 * @param   string   $criteria     - query string
-	 * returns  activity records in array format($list) or null value
-         */	 
-  	function get_full_list($criteria)
-  	{
-	 global $log;
-         $log->debug("Entering get_full_list(".$criteria.") method ...");
-    $query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 ".$criteria;
-    $result =& $this->db->query($query);
-        
-    if($this->db->getRowCount($result) > 0){
-		
-      // We have some data.
-      while ($row = $this->db->fetchByAssoc($result)) {
-        foreach($this->list_fields_name as $field)
-        {
-          if (isset($row[$field])) {
-            $this->$field = $row[$field];
-          }
-          else {
-            $this->$field = '';   
-          }
-        }
-        $list[] = $this;
-      }
-    }
-    if (isset($list))
-    	{
-		$log->debug("Exiting get_full_list method ...");
-	    return $list;
-	}
-	else
-	{
-		$log->debug("Exiting get_full_list method ...");
-	    return null;
-	}
-
-  }
-
-	
-//calendarsync
-    /**
-     * Function to get meeting count
-     * @param  string   $user_name        - User Name
-     * return  integer  $row["count(*)"]  - count
-     */
-    function getCount_Meeting($user_name) 
-	{
-		global $log;
-	        $log->debug("Entering getCount_Meeting(".$user_name.") method ...");
-      $query = "select count(*) from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
-
-      $result = $this->db->query($query,true,"Error retrieving contacts count");
-      $rows_found =  $this->db->getRowCount($result);
-      $row = $this->db->fetchByAssoc($result, 0);
-	$log->debug("Exiting getCount_Meeting method ...");
-      return $row["count(*)"];
-    }
-   
-    function get_calendars($user_name,$from_index,$offset)
-    {   
-	    global $log;
-            $log->debug("Entering get_calendars(".$user_name.",".$from_index.",".$offset.") method ...");
-		$query = "select vtiger_activity.location as location,vtiger_activity.duration_hours as duehours, vtiger_activity.duration_minutes as dueminutes,vtiger_activity.time_start as time_start, vtiger_activity.subject as name,vtiger_crmentity.modifiedtime as date_modified, vtiger_activity.date_start start_date,vtiger_activity.activityid as id,vtiger_activity.status as status, vtiger_crmentity.description as description, vtiger_activity.priority as vtiger_priority, vtiger_activity.due_date as date_due ,vtiger_contactdetails.firstname cfn, vtiger_contactdetails.lastname cln from vtiger_activity inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting' limit " .$from_index ."," .$offset;
-	$log->debug("Exiting get_calendars method ...");
-	    return $this->process_list_query1($query);   
-    }       
-//calendarsync
-	/**
-	 * Function to get task count
-	 * @param  string   $user_name        - User Name
-	 * return  integer  $row["count(*)"]  - count
-	 */
-    function getCount($user_name) 
-    {
-	    global $log;
-            $log->debug("Entering getCount(".$user_name.") method ...");
-        $query = "select count(*) from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task'";
-
-        $result = $this->db->query($query,true,"Error retrieving contacts count");
-        $rows_found =  $this->db->getRowCount($result);
-        $row = $this->db->fetchByAssoc($result, 0);
-
-	$log->debug("Exiting getCount method ...");    
-        return $row["count(*)"];
-    }       
-
-    /**
-     * Function to get list of task for user with given limit
-     * @param  string   $user_name        - User Name
-     * @param  string   $from_index       - query string
-     * @param  string   $offset           - query string 
-     * returns tasks in array format
-     */
-    function get_tasks($user_name,$from_index,$offset)
-    {   
-	global $log;
-        $log->debug("Entering get_tasks(".$user_name.",".$from_index.",".$offset.") method ...");
-	 $query = "select vtiger_activity.subject as name,vtiger_crmentity.modifiedtime as date_modified, vtiger_activity.date_start start_date,vtiger_activity.activityid as id,vtiger_activity.status as status, vtiger_crmentity.description as description, vtiger_activity.priority as priority, vtiger_activity.due_date as date_due ,vtiger_contactdetails.firstname cfn, vtiger_contactdetails.lastname cln from vtiger_activity inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task' limit " .$from_index ."," .$offset;
-	 $log->debug("Exiting get_tasks method ...");
-    return $this->process_list_query1($query);
-    
-    }
-	
-    /**
-     * Function to process the activity list query
-     * @param  string   $query     - query string
-     * return  array    $response  - activity lists
-     */
-    function process_list_query1($query)
-    {
-	    global $log;
-            $log->debug("Entering process_list_query1(".$query.") method ...");
-        $result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
-        $list = Array();
-        $rows_found =  $this->db->getRowCount($result);
-        if($rows_found != 0)
-        {
-            $task = Array();
-              for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
-            
-             {
-                foreach($this->range_fields as $columnName)
-                {
-                    if (isset($row[$columnName])) {
-			    
-                        $task[$columnName] = $row[$columnName];
-                    }   
-                    else     
-                    {   
-                            $task[$columnName] = "";
-                    }   
-	            }	
-    
-                $task[contact_name] = return_name($row, 'cfn', 'cln');    
-
-                    $list[] = $task;
-                }
-         }
-
-        $response = Array();
-        $response['list'] = $list;
-        $response['row_count'] = $rows_found;
-        $response['next_offset'] = $next_offset;
-        $response['previous_offset'] = $previous_offset;
-
-
-	$log->debug("Exiting process_list_query1 method ...");
-        return $response;
-    }
-
-    	/**
-	 * Function to get reminder for activity
-	 * @param  integer   $activity_id     - activity id
-	 * @param  string    $reminder_time   - reminder time
-	 * @param  integer   $reminder_sent   - 0 or 1
-	 * @param  integer   $recurid         - recuring eventid
-	 * @param  string    $remindermode    - string like 'edit'	 
-	 */	
-	function activity_reminder($activity_id,$reminder_time,$reminder_sent=0,$recurid,$remindermode='')
-	{
-		global $log;
-		$log->debug("Entering vtiger_activity_reminder(".$activity_id.",".$reminder_time.",".$reminder_sent.",".$recurid.",".$remindermode.") method ...");
-		//Check for vtiger_activityid already present in the reminder_table
-		$query_exist = "SELECT activity_id FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
-		$result_exist = $this->db->query($query_exist);
-
-		if($remindermode == 'edit')
-		{
-			if($this->db->num_rows($result_exist) == 1)
-			{
-				$query = "UPDATE ".$this->reminder_table." SET";
-				$query .=" reminder_sent = ".$reminder_sent.",";
-				$query .=" reminder_time = ".$reminder_time." WHERE activity_id =".$activity_id; 
-			}
-			else
-			{
-				$query = "INSERT INTO ".$this->reminder_table." VALUES (".$activity_id.",".$reminder_time.",0,'".$recurid."')";
-			}
-		}
-		elseif(($remindermode == 'delete') && ($this->db->num_rows($result_exist) == 1))
-		{
-			$query = "DELETE FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
-		}
-		else
-		{
-			$query = "INSERT INTO ".$this->reminder_table." VALUES (".$activity_id.",".$reminder_time.",0,'".$recurid."')";
-		}
-      		$this->db->query($query,true,"Error in processing vtiger_table $this->reminder_table");
-		$log->debug("Exiting vtiger_activity_reminder method ...");
-	}
-
-//Used for vtigerCRM Outlook Add-In
-/**
- * Function to get tasks to display in outlookplugin
- * @param   string    $username     -  User name
- * return   string    $query        -  sql query 
- */
-function get_tasksforol($username)
-{
-	global $log,$adb;
-	$log->debug("Entering get_tasksforol(".$username.") method ...");
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-	
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select tablename,columnname from vtiger_field where tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder'";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'tablename');
-      $permitted_lists[] = $adb->query_result($result1,$i,'columnname');
-      /*if($adb->query_result($result1,$i,'columnname') == "parentid")
-      {
-        $permitted_lists[] = 'vtiger_account';
-        $permitted_lists[] = 'accountname';
-      }*/
-  }
-	$permitted_lists = array_chunk($permitted_lists,2);
-	$column_table_lists = array();
-	for($i=0;$i < count($permitted_lists);$i++)
-	{
-	   $column_table_lists[] = implode(".",$permitted_lists[$i]);
-  }
-   
-	$query = "select vtiger_activity.activityid as taskid, ".implode(',',$column_table_lists)." from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
-			 inner join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid 
-			 left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid 
-			 left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid 
-			 left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid 
-			 where vtiger_users.user_name='".$username."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task'";
-	$log->debug("Exiting get_tasksforol method ...");		 
-	return $query;
-}
-
-/**
- * Function to get calendar query for outlookplugin
- * @param   string    $username     -  User name                                                                            * return   string    $query        -  sql query                                                                            */ 
-function get_calendarsforol($user_name)
-{
-	global $log,$adb;
-	$log->debug("Entering get_calendarsforol(".$user_name.") method ...");
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($user_name);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-	
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select tablename,columnname from vtiger_field where tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder'";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'tablename');
-      $permitted_lists[] = $adb->query_result($result1,$i,'columnname');
-      /*if($adb->query_result($result1,$i,'columnname') == "parentid")
-      {
-        $permitted_lists[] = 'vtiger_account';
-        $permitted_lists[] = 'accountname';
-      }*/
-  }
-	$permitted_lists = array_chunk($permitted_lists,2);
-	$column_table_lists = array();
-	for($i=0;$i < count($permitted_lists);$i++)
-	{
-	   $column_table_lists[] = implode(".",$permitted_lists[$i]);
-  }
-   
-	  $query = "select vtiger_activity.activityid as clndrid, ".implode(',',$column_table_lists)." from vtiger_activity 
-				inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid 
-				inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid 
-				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid 
-				left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid 
-				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid 
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
-				where vtiger_users.user_name='".$user_name."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
-	$log->debug("Exiting get_calendarsforol method ...");
-	return $query;
-}
-//End
-
-}
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Activities/Activity.php,v 1.26 2005/03/26 10:42:13 rank Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/database/Postgres8.php');
+require_once('modules/Calendar/RenderRelatedListUI.php');
+require_once('data/CRMEntity.php');
+
+// Task is used to store customer information.
+class Activity extends CRMEntity {
+	var $log;
+	var $db;
+	var $reminder_table = 'vtiger_activity_reminder';
+	var $tab_name = Array('vtiger_crmentity','vtiger_activity');
+
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_activity'=>'activityid','vtiger_seactivityrel'=>'activityid','vtiger_cntactivityrel'=>'activityid','vtiger_salesmanactivityrel'=>'activityid','vtiger_activity_reminder'=>'activity_id','vtiger_recurringevents'=>'activityid');
+
+	var $column_fields = Array();
+	var $sortby_fields = Array('subject','due_date','date_start','smownerid','activitytype');	//Sorting is added for due date and start date	
+
+	// This is used to retrieve related vtiger_fields from form posts.
+	var $additional_column_fields = Array('assigned_user_name', 'assigned_user_id', 'contactname', 'contact_phone', 'contact_email', 'parent_name');
+
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+       'Close'=>Array('activity'=>'status'),
+       'Type'=>Array('activity'=>'activitytype'),
+       'Subject'=>Array('activity'=>'subject'),
+       'Related to'=>Array('seactivityrel'=>'activityid'),
+       'Start Date & Time'=>Array('activity'=>'date_start'),
+       'End Date & Time'=>Array('activity'=>'due_date'),
+       'Recurring Type'=>Array('recurringevents'=>'recurringtype'),
+       'Assigned To'=>Array('crmentity'=>'smownerid')
+       );
+
+       var $range_fields = Array(
+	'name',
+	'date_modified',
+	'start_date',
+	'id',
+	'status',
+	'date_due',
+	'time_start',
+	'description',
+	'contact_name',
+	'priority',
+	'duehours',
+	'dueminutes',
+	'location'
+	);
+       
+
+       var $list_fields_name = Array(
+       'Close'=>'status',
+       'Type'=>'activitytype',
+       'Subject'=>'subject',
+       'Contact Name'=>'lastname',
+       'Related to'=>'activityid',
+       'Start Date & Time'=>'date_start',
+       'End Date & Time'=>'due_date',
+	'Recurring Type'=>'recurringtype',	
+       'Assigned To'=>'assigned_user_id');
+
+       var $list_link_field= 'subject';
+	
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'due_date';
+	var $default_sort_order = 'ASC';
+
+	var $groupTable = Array('vtiger_activitygrouprelation','activityid');
+
+	function Activity() {
+		$this->log = LoggerManager::getLogger('Calendar');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Calendar');
+	}
+
+
+	function save_module($module)
+	{
+		global $adb;
+		//Handling module specific save
+		//Insert into seactivity rel			
+		if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')
+		{
+			$this->insertIntoEntityTable("vtiger_seactivityrel", $module);
+		}
+		elseif($this->column_fields['parent_id']=='' && $insertion_mode=="edit")
+		{
+			$this->deleteRelation("vtiger_seactivityrel");
+		}
+		//Insert into cntactivity rel		
+		if(isset($this->column_fields['contact_id']) && $this->column_fields['contact_id'] != '')
+		{
+			$this->insertIntoEntityTable('vtiger_cntactivityrel', $module);
+		}
+		elseif($this->column_fields['contact_id'] =='' && $insertion_mode=="edit")
+		{
+			$this->deleteRelation('vtiger_cntactivityrel');
+		}
+	
+		$recur_type='';	
+		if(($recur_type == "--None--" || $recur_type == '') && $this->mode == "edit")
+		{
+			$sql = 'delete  from vtiger_recurringevents where activityid='.$this->id;
+			$adb->query($sql);		
+		}	
+		//Handling for recurring type
+		//Insert into vtiger_recurring event table
+		if(isset($this->column_fields['recurringtype']) && $this->column_fields['recurringtype']!='' && $this->column_fields['recurringtype']!='--None--')
+		{
+			$recur_type = trim($this->column_fields['recurringtype']);
+			$recur_data = getrecurringObjValue();
+			if(is_object($recur_data))
+	      			$this->insertIntoRecurringTable($recur_data);
+		}	
+	
+		//Insert into vtiger_activity_remainder table
+		if(($recur_type == "--None--" || $recur_type=='') && $_REQUEST['set_reminder'] == 'Yes')
+		{
+			$this->insertIntoReminderTable('vtiger_activity_reminder',$module,"");
+		}
+
+		//Handling for invitees
+		if(isset($_REQUEST['inviteesid']) && $_REQUEST['inviteesid']!='')
+		{
+			$selected_users_string =  $_REQUEST['inviteesid'];
+			$invitees_array = explode(';',$selected_users_string);
+			$this->insertIntoInviteeTable($module,$invitees_array);
+
+		}
+
+		//Inserting into sales man activity rel
+		$this->insertIntoSmActivityRel($module);
+			
+	}	
+
+
+	/** Function to insert values in vtiger_activity_remainder table for the specified module,
+  	  * @param $table_name -- table name:: Type varchar
+  	  * @param $module -- module:: Type varchar
+ 	 */
+	function insertIntoReminderTable($table_name,$module,$recurid)
+	{
+	 	global $log;
+		$log->info("in insertIntoReminderTable  ".$table_name."    module is  ".$module);
+		if($_REQUEST['set_reminder'] == 'Yes')
+		{
+			$log->debug("set reminder is set");
+			$rem_days = $_REQUEST['remdays'];
+			$log->debug("rem_days is ".$rem_days);
+			$rem_hrs = $_REQUEST['remhrs'];
+			$log->debug("rem_hrs is ".$rem_hrs);
+			$rem_min = $_REQUEST['remmin'];
+			$log->debug("rem_minutes is ".$rem_min);
+			$reminder_time = $rem_days * 24 * 60 + $rem_hrs * 60 + $rem_min;
+			$log->debug("reminder_time is ".$reminder_time);
+			if ($recurid == "")
+			{
+				if($_REQUEST['mode'] == 'edit')
+				{
+					$this->activity_reminder($this->id,$reminder_time,0,$recurid,'edit');
+				}
+				else
+				{
+					$this->activity_reminder($this->id,$reminder_time,0,$recurid,'');
+				}
+			}
+			else
+			{
+				$this->activity_reminder($this->id,$reminder_time,0,$recurid,'');
+			}
+		}
+		elseif($_REQUEST['set_reminder'] == 'No')
+		{
+			$this->activity_reminder($this->id,'0',0,$recurid,'delete');
+		}
+	}
+	
+
+	// Code included by Jaguar - starts
+	/** Function to insert values in vtiger_recurringevents table for the specified tablename,module
+  	  * @param $recurObj -- Recurring Object:: Type varchar
+ 	 */	
+function insertIntoRecurringTable(& $recurObj)
+{
+	global $log,$adb;
+	$log->info("in insertIntoRecurringTable  ");
+	$st_date = $recurObj->startdate->get_formatted_date();
+	$log->debug("st_date ".$st_date);
+	$end_date = $recurObj->enddate->get_formatted_date();
+	$log->debug("end_date is set ".$end_date);
+	$type = $recurObj->recur_type;
+	$log->debug("type is ".$type);
+        $flag="true";
+
+	if($_REQUEST['mode'] == 'edit')
+	{
+		$activity_id=$this->id;
+
+		$sql='select min(recurringdate) AS min_date,max(recurringdate) AS max_date, recurringtype, activityid from vtiger_recurringevents where activityid='. $activity_id.' group by activityid, recurringtype';
+		
+		$result = $adb->query($sql);
+		$noofrows = $adb->num_rows($result);
+		for($i=0; $i<$noofrows; $i++)
+		{
+			$recur_type_b4_edit = $adb->query_result($result,$i,"recurringtype");
+			$date_start_b4edit = $adb->query_result($result,$i,"min_date");
+			$end_date_b4edit = $adb->query_result($result,$i,"max_date");
+		}
+		if(($st_date == $date_start_b4edit) && ($end_date==$end_date_b4edit) && ($type == $recur_type_b4_edit))
+		{
+			if($_REQUEST['set_reminder'] == 'Yes')
+			{
+				$sql = 'delete from vtiger_activity_reminder where activity_id='.$activity_id;
+				$adb->query($sql);
+				$sql = 'delete  from vtiger_recurringevents where activityid='.$activity_id;
+				$adb->query($sql);
+				$flag="true";
+			}
+			elseif($_REQUEST['set_reminder'] == 'No')
+			{
+				$sql = 'delete  from vtiger_activity_reminder where activity_id='.$activity_id;
+				$adb->query($sql);
+				$flag="false";
+			}
+			else
+				$flag="false";
+		}
+		else
+		{
+			$sql = 'delete from vtiger_activity_reminder where activity_id='.$activity_id;
+			$adb->query($sql);
+			$sql = 'delete  from vtiger_recurringevents where activityid='.$activity_id;
+			$adb->query($sql);
+		}
+	}
+	$date_array = $recurObj->recurringdates;
+	if(isset($recurObj->recur_freq) && $recurObj->recur_freq != null)
+		$recur_freq = $recurObj->recur_freq;
+	else
+		$recur_freq = 1;
+	if($recurObj->recur_type == 'Daily' || $recurObj->recur_type == 'Yearly')
+		$recurringinfo = $recurObj->recur_type;
+	elseif($recurObj->recur_type == 'Weekly')
+	{
+		$recurringinfo = $recurObj->recur_type;
+		if($recurObj->dayofweek_to_rpt != null)
+			$recurringinfo = $recurringinfo.'::'.implode('::',$recurObj->dayofweek_to_rpt);
+	}
+	elseif($recurObj->recur_type == 'Monthly')
+	{
+		$recurringinfo =  $recurObj->recur_type.'::'.$recurObj->repeat_monthby;
+		if($recurObj->repeat_monthby == 'date')
+			$recurringinfo = $recurringinfo.'::'.$recurObj->rptmonth_datevalue;
+		else
+			$recurringinfo = $recurringinfo.'::'.$recurObj->rptmonth_daytype.'::'.$recurObj->dayofweek_to_rpt[0];
+	}
+	else
+	{
+		$recurringinfo = '';
+	}
+	if($flag=="true")
+	{
+		for($k=0; $k< count($date_array); $k++)
+		{
+			$tdate=$date_array[$k];
+			if($tdate <= $end_date)
+			{
+				$max_recurid_qry = 'select max(recurringid) AS recurid from vtiger_recurringevents;';
+				$result = $adb->query($max_recurid_qry);
+				$noofrows = $adb->num_rows($result);
+				for($i=0; $i<$noofrows; $i++)
+				{
+					$recur_id = $adb->query_result($result,$i,"recurid");
+				}
+				$current_id =$recur_id+1;
+				$recurring_insert = "insert into vtiger_recurringevents values ('".$current_id."','".$this->id."','".$tdate."','".$type."','".$recur_freq."','".$recurringinfo."')";
+				$adb->query($recurring_insert);
+				if($_REQUEST['set_reminder'] == 'Yes')
+				{
+					$this->insertIntoReminderTable("vtiger_activity_reminder",$module,$current_id,'');
+				}
+			}
+		}
+	}
+}
+
+
+	/** Function to insert values in vtiger_invitees table for the specified module,tablename ,invitees_array
+  	  * @param $table_name -- table name:: Type varchar
+  	  * @param $module -- module:: Type varchar
+	  * @param $invitees_array Array
+ 	 */
+	function insertIntoInviteeTable($module,$invitees_array)
+	{
+		global $log,$adb;
+		$log->debug("Entering insertIntoInviteeTable(".$module.",".$invitees_array.") method ...");
+		if($this->mode == 'edit'){
+			$sql = "delete from vtiger_invitees where activityid=".$this->id;
+			$adb->query($sql);
+		}	
+		foreach($invitees_array as $inviteeid)
+		{
+			if($inviteeid != '')
+			{
+				$query="insert into vtiger_invitees values(".$this->id.",".$inviteeid.")";
+				$adb->query($query);
+			}
+		}
+		$log->debug("Exiting insertIntoInviteeTable method ...");
+
+	}
+
+
+	/** Function to insert values in vtiger_salesmanactivityrel table for the specified module
+  	  * @param $module -- module:: Type varchar
+ 	 */
+
+  	function insertIntoSmActivityRel($module)
+  	{
+    		global $adb;
+    		global $current_user;
+    		if($this->mode == 'edit'){
+      			$sql = "delete from vtiger_salesmanactivityrel where activityid=".$this->id;
+      			$adb->query($sql);
+    		}
+		$sql_qry = "insert into vtiger_salesmanactivityrel (smid,activityid) values(".$this->column_fields['assigned_user_id'].",".$this->id.")";
+    		$adb->query($sql_qry);
+		if(isset($_REQUEST['inviteesid']) && $_REQUEST['inviteesid']!='')
+		{
+			$selected_users_string =  $_REQUEST['inviteesid'];
+			$invitees_array = explode(';',$selected_users_string);
+			foreach($invitees_array as $inviteeid)
+			{
+				if($inviteeid != '')
+				{
+					$query="insert into vtiger_salesmanactivityrel values(".$inviteeid.",".$this->id.")";
+					$adb->query($query);
+				}
+			}
+		}	
+  	}
+	
+	
+	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
+	/**
+	 * Function to get sort order
+	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	 */
+	function getSortOrder()
+	{	
+		global $log;                                                                                                  $log->debug("Entering getSortOrder() method ...");
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['ACTIVITIES_SORT_ORDER'] != '')?($_SESSION['ACTIVITIES_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder method ...");
+		return $sorder;
+	}
+	
+	/**
+	 * Function to get order by
+	 * return string  $order_by    - fieldname(eg: 'subject')
+	 */
+	function getOrderBy()
+	{
+		global $log;
+                 $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['ACTIVITIES_ORDER_BY'] != '')?($_SESSION['ACTIVITIES_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+	// Mike Crowe Mod --------------------------------------------------------
+
+
+
+//Function Call for Related List -- Start
+	/**
+	 * Function to get Activity related Contacts
+	 * @param  integer   $id      - activityid
+	 * returns related Contacts record in array format
+	 */
+        function get_contacts($id)
+	{
+			global $log;
+                        $log->debug("Entering get_contacts(".$id.") method ...");
+			global $app_strings;
+
+			$focus = new Contacts();
+
+			$button = '';
+
+			$returnset = '&return_module=Calendar&return_action=CallRelatedList&activity_mode=Events&return_id='.$id;
+
+			$query = 'select vtiger_users.user_name,vtiger_contactdetails.accountid,vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_contactdetails.department, vtiger_contactdetails.title, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid=vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_cntactivityrel.activityid = vtiger_activitygrouprelation.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname where vtiger_cntactivityrel.activityid='.$id.' and vtiger_crmentity.deleted=0';
+			$log->debug("Exiting get_contacts method ...");
+			return GetRelatedList('Calendar','Contacts',$focus,$query,$button,$returnset);
+        }
+	
+	/**
+	 * Function to get Activity related Users
+	 * @param  integer   $id      - activityid
+	 * returns related Users record in array format
+	 */
+
+        function get_users($id)
+	{	
+		global $log;
+                $log->debug("Entering get_contacts(".$id.") method ...");
+		global $app_strings;
+
+		$focus = new Users();
+
+		$button = '';
+
+		$returnset = '&return_module=Calendar&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'SELECT vtiger_users.id, vtiger_users.first_name,vtiger_users.last_name, vtiger_users.user_name, vtiger_users.email1, vtiger_users.email2, vtiger_users.status, vtiger_users.is_admin, vtiger_user2role.roleid, vtiger_users.yahoo_id, vtiger_users.phone_home, vtiger_users.phone_work, vtiger_users.phone_mobile, vtiger_users.phone_other, vtiger_users.phone_fax,vtiger_activity.date_start,vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.duration_hours,vtiger_activity.duration_minutes from vtiger_users inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.smid=vtiger_users.id  inner join vtiger_activity on vtiger_activity.activityid=vtiger_salesmanactivityrel.activityid inner join vtiger_user2role on vtiger_user2role.userid=vtiger_users.id where vtiger_activity.activityid='.$id;
+		$log->debug("Exiting get_users method ...");
+		return GetRelatedList('Calendar','Users',$focus,$query,$button,$returnset);
+
+
+	}
+
+	/**
+         * Function to get activities for given criteria
+	 * @param   string   $criteria     - query string
+	 * returns  activity records in array format($list) or null value
+         */	 
+  	function get_full_list($criteria)
+  	{
+	 global $log;
+         $log->debug("Entering get_full_list(".$criteria.") method ...");
+    $query = "SELECT vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid FROM vtiger_activity INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_activity.activityid LEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid= vtiger_activity.activityid left JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid LEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 ".$criteria;
+    //Postgres 8 fixes
+    if( $adb->dbType == "pgsql")
+	$query = fixPostgresQuery( $query, $log, 0);
+
+    $result =& $this->db->query($query);
+        
+    if($this->db->getRowCount($result) > 0){
+		
+      // We have some data.
+      while ($row = $this->db->fetchByAssoc($result)) {
+        foreach($this->list_fields_name as $field)
+        {
+          if (isset($row[$field])) {
+            $this->$field = $row[$field];
+          }
+          else {
+            $this->$field = '';   
+          }
+        }
+        $list[] = $this;
+      }
+    }
+    if (isset($list))
+    	{
+		$log->debug("Exiting get_full_list method ...");
+	    return $list;
+	}
+	else
+	{
+		$log->debug("Exiting get_full_list method ...");
+	    return null;
+	}
+
+  }
+
+	
+//calendarsync
+    /**
+     * Function to get meeting count
+     * @param  string   $user_name        - User Name
+     * return  integer  $row["count(*)"]  - count
+     */
+    function getCount_Meeting($user_name) 
+	{
+		global $log;
+	        $log->debug("Entering getCount_Meeting(".$user_name.") method ...");
+      $query = "select count(*) from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
+
+      $result = $this->db->query($query,true,"Error retrieving contacts count");
+      $rows_found =  $this->db->getRowCount($result);
+      $row = $this->db->fetchByAssoc($result, 0);
+	$log->debug("Exiting getCount_Meeting method ...");
+      return $row["count(*)"];
+    }
+   
+    function get_calendars($user_name,$from_index,$offset)
+    {   
+	    global $log;
+            $log->debug("Entering get_calendars(".$user_name.",".$from_index.",".$offset.") method ...");
+		$query = "select vtiger_activity.location as location,vtiger_activity.duration_hours as duehours, vtiger_activity.duration_minutes as dueminutes,vtiger_activity.time_start as time_start, vtiger_activity.subject as name,vtiger_crmentity.modifiedtime as date_modified, vtiger_activity.date_start start_date,vtiger_activity.activityid as id,vtiger_activity.status as status, vtiger_crmentity.description as description, vtiger_activity.priority as vtiger_priority, vtiger_activity.due_date as date_due ,vtiger_contactdetails.firstname cfn, vtiger_contactdetails.lastname cln from vtiger_activity inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting' limit " .$from_index ."," .$offset;
+	$log->debug("Exiting get_calendars method ...");
+	    return $this->process_list_query1($query);   
+    }       
+//calendarsync
+	/**
+	 * Function to get task count
+	 * @param  string   $user_name        - User Name
+	 * return  integer  $row["count(*)"]  - count
+	 */
+    function getCount($user_name) 
+    {
+	    global $log;
+            $log->debug("Entering getCount(".$user_name.") method ...");
+        $query = "select count(*) from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task'";
+
+        $result = $this->db->query($query,true,"Error retrieving contacts count");
+        $rows_found =  $this->db->getRowCount($result);
+        $row = $this->db->fetchByAssoc($result, 0);
+
+	$log->debug("Exiting getCount method ...");    
+        return $row["count(*)"];
+    }       
+
+    /**
+     * Function to get list of task for user with given limit
+     * @param  string   $user_name        - User Name
+     * @param  string   $from_index       - query string
+     * @param  string   $offset           - query string 
+     * returns tasks in array format
+     */
+    function get_tasks($user_name,$from_index,$offset)
+    {   
+	global $log;
+        $log->debug("Entering get_tasks(".$user_name.",".$from_index.",".$offset.") method ...");
+	 $query = "select vtiger_activity.subject as name,vtiger_crmentity.modifiedtime as date_modified, vtiger_activity.date_start start_date,vtiger_activity.activityid as id,vtiger_activity.status as status, vtiger_crmentity.description as description, vtiger_activity.priority as priority, vtiger_activity.due_date as date_due ,vtiger_contactdetails.firstname cfn, vtiger_contactdetails.lastname cln from vtiger_activity inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task' limit " .$from_index ."," .$offset;
+	 $log->debug("Exiting get_tasks method ...");
+    return $this->process_list_query1($query);
+    
+    }
+	
+    /**
+     * Function to process the activity list query
+     * @param  string   $query     - query string
+     * return  array    $response  - activity lists
+     */
+    function process_list_query1($query)
+    {
+	    global $log;
+            $log->debug("Entering process_list_query1(".$query.") method ...");
+        $result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
+        $list = Array();
+        $rows_found =  $this->db->getRowCount($result);
+        if($rows_found != 0)
+        {
+            $task = Array();
+              for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
+            
+             {
+                foreach($this->range_fields as $columnName)
+                {
+                    if (isset($row[$columnName])) {
+			    
+                        $task[$columnName] = $row[$columnName];
+                    }   
+                    else     
+                    {   
+                            $task[$columnName] = "";
+                    }   
+	            }	
+    
+                $task[contact_name] = return_name($row, 'cfn', 'cln');    
+
+                    $list[] = $task;
+                }
+         }
+
+        $response = Array();
+        $response['list'] = $list;
+        $response['row_count'] = $rows_found;
+        $response['next_offset'] = $next_offset;
+        $response['previous_offset'] = $previous_offset;
+
+
+	$log->debug("Exiting process_list_query1 method ...");
+        return $response;
+    }
+
+    	/**
+	 * Function to get reminder for activity
+	 * @param  integer   $activity_id     - activity id
+	 * @param  string    $reminder_time   - reminder time
+	 * @param  integer   $reminder_sent   - 0 or 1
+	 * @param  integer   $recurid         - recuring eventid
+	 * @param  string    $remindermode    - string like 'edit'	 
+	 */	
+	function activity_reminder($activity_id,$reminder_time,$reminder_sent=0,$recurid,$remindermode='')
+	{
+		global $log;
+		$log->debug("Entering vtiger_activity_reminder(".$activity_id.",".$reminder_time.",".$reminder_sent.",".$recurid.",".$remindermode.") method ...");
+		//Check for vtiger_activityid already present in the reminder_table
+		$query_exist = "SELECT activity_id FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
+		$result_exist = $this->db->query($query_exist);
+
+		if($remindermode == 'edit')
+		{
+			if($this->db->num_rows($result_exist) == 1)
+			{
+				$query = "UPDATE ".$this->reminder_table." SET";
+				$query .=" reminder_sent = ".$reminder_sent.",";
+				$query .=" reminder_time = ".$reminder_time." WHERE activity_id =".$activity_id; 
+			}
+			else
+			{
+				$query = "INSERT INTO ".$this->reminder_table." VALUES (".$activity_id.",".$reminder_time.",0,'".$recurid."')";
+			}
+		}
+		elseif(($remindermode == 'delete') && ($this->db->num_rows($result_exist) == 1))
+		{
+			$query = "DELETE FROM ".$this->reminder_table." WHERE activity_id = ".$activity_id;
+		}
+		else
+		{
+			$query = "INSERT INTO ".$this->reminder_table." VALUES (".$activity_id.",".$reminder_time.",0,'".$recurid."')";
+		}
+      		$this->db->query($query,true,"Error in processing vtiger_table $this->reminder_table");
+		$log->debug("Exiting vtiger_activity_reminder method ...");
+	}
+
+//Used for vtigerCRM Outlook Add-In
+/**
+ * Function to get tasks to display in outlookplugin
+ * @param   string    $username     -  User name
+ * return   string    $query        -  sql query 
+ */
+function get_tasksforol($username)
+{
+	global $log,$adb;
+	$log->debug("Entering get_tasksforol(".$username.") method ...");
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select tablename,columnname from vtiger_field where tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder'";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'tablename');
+      $permitted_lists[] = $adb->query_result($result1,$i,'columnname');
+      /*if($adb->query_result($result1,$i,'columnname') == "parentid")
+      {
+        $permitted_lists[] = 'vtiger_account';
+        $permitted_lists[] = 'accountname';
+      }*/
+  }
+	$permitted_lists = array_chunk($permitted_lists,2);
+	$column_table_lists = array();
+	for($i=0;$i < count($permitted_lists);$i++)
+	{
+	   $column_table_lists[] = implode(".",$permitted_lists[$i]);
+  }
+   
+	$query = "select vtiger_activity.activityid as taskid, ".implode(',',$column_table_lists)." from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
+			 inner join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid 
+			 left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid 
+			 left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid 
+			 left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid 
+			 where vtiger_users.user_name='".$username."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Task'";
+	$log->debug("Exiting get_tasksforol method ...");		 
+	return $query;
+}
+
+/**
+ * Function to get calendar query for outlookplugin
+ * @param   string    $username     -  User name                                                                            * return   string    $query        -  sql query                                                                            */ 
+function get_calendarsforol($user_name)
+{
+	global $log,$adb;
+	$log->debug("Entering get_calendarsforol(".$user_name.") method ...");
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($user_name);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select tablename,columnname from vtiger_field where tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder'";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=9 and tablename <> 'vtiger_recurringevents' and tablename <> 'vtiger_activity_reminder' and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'tablename');
+      $permitted_lists[] = $adb->query_result($result1,$i,'columnname');
+      if($adb->query_result($result1,$i,'columnname') == "date_start")
+      {
+        $permitted_lists[] = 'vtiger_activity';
+        $permitted_lists[] = 'time_start';
+      }
+      if($adb->query_result($result1,$i,'columnname') == "due_date")
+      {
+	$permitted_lists[] = 'vtiger_activity';
+        $permitted_lists[] = 'time_end';
+      }
+  }
+	$permitted_lists = array_chunk($permitted_lists,2);
+	$column_table_lists = array();
+	for($i=0;$i < count($permitted_lists);$i++)
+	{
+	   $column_table_lists[] = implode(".",$permitted_lists[$i]);
+  }
+   
+	  $query = "select vtiger_activity.activityid as clndrid, ".implode(',',$column_table_lists)." from vtiger_activity 
+				inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid 
+				inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid 
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid=vtiger_activity.activityid 
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_cntactivityrel.contactid 
+				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
+				where vtiger_users.user_name='".$user_name."' and vtiger_crmentity.deleted=0 and vtiger_activity.activitytype='Meeting'";
+	$log->debug("Exiting get_calendarsforol method ...");
+	return $query;
+}
+//End
+
+}
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/ActivityAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/ActivityAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/ActivityAjax.php Mon Apr 16 12:27:44 2007
@@ -99,10 +99,6 @@
 		}
 		$calendar_arr['calendar'] = new Calendar($mysel,$date_data);
 		
-		if ($mysel == 'day' || $mysel == 'week' || $mysel == 'month' || $mysel == 'year')
-		{
-			$calendar_arr['calendar']->add_Activities($current_user);
-		}
 		$calendar_arr['view'] = $mysel;
 		if($calendar_arr['calendar']->view == 'day')
 			$start_date = $end_date = $calendar_arr['calendar']->date_time->get_formatted_date();
@@ -146,10 +142,33 @@
 					$activity_type = "Events";
 				}
 				ChangeStatus($status,$return_id,$activity_type);
+				$mail_data = getActivityMailInfo($return_id,$status,$activity_type);
+				if($mail_data['sendnotification'] == 1)
+				{
+					getEventNotification($activity_type,$mail_data['subject'],$mail_data);
+				}
+				$invitee_qry = "select * from vtiger_invitees where activityid=".$return_id;
+				$invitee_res = $adb->query($invitee_qry);
+				$count = $adb->num_rows($invitee_res);
+				if($count != 0)
+				{
+					for($j = 0; $j < $count; $j++)
+					{
+						$invitees_ids[]= $adb->query_result($invitee_res,$j,"inviteeid");
+
+					}
+					$invitees_ids_string = implode(';',$invitees_ids);
+					sendInvitation($invitees_ids_string,$activity_type,$mail_data['subject'],$mail_data);
+				}
 			}
 			if($type == 'activity_postpone')
 			{
 			}
+			if ($mysel == 'day' || $mysel == 'week' || $mysel == 'month' || $mysel == 'year')
+                	{
+                        	$calendar_arr['calendar']->add_Activities($current_user);
+                	}
+
 			if(isset($_REQUEST['viewOption']) && $_REQUEST['viewOption'] != null && $subtab == 'event')
 			{
 				if($_REQUEST['viewOption'] == 'hourview')
@@ -157,19 +176,19 @@
 					$cal_log->debug("going to get calendar Event HourView");
 					if($calendar_arr['view'] == 'day')
 					{
-						echo getDayViewLayout($calendar_arr);
+						echo getDayViewLayout($calendar_arr)."####".getEventTodoInfo($calendar_arr,'listcnt');
 					}
 					elseif($calendar_arr['view'] == 'week')
 					{
-						echo getWeekViewLayout($calendar_arr);	
+						echo getWeekViewLayout($calendar_arr)."####".getEventTodoInfo($calendar_arr,'listcnt');	
 					}
 					elseif($calendar_arr['view'] == 'month')
 					{
-						echo getMonthViewLayout($calendar_arr);
+						echo getMonthViewLayout($calendar_arr)."####".getEventTodoInfo($calendar_arr,'listcnt');
 					}
 					elseif($calendar_arr['view'] == 'year')
 					{
-						echo getYearViewLayout($calendar_arr);
+						echo getYearViewLayout($calendar_arr)."####".getEventTodoInfo($calendar_arr,'listcnt');
 					}
 					else
 					{
@@ -181,7 +200,7 @@
 					$cal_log->debug("going to get calendar Event ListView");
 					//To get Events List
 					$activity_list = getEventList($calendar_arr, $start_date, $end_date);
-					echo constructEventListView($calendar_arr,$activity_list);
+					echo constructEventListView($calendar_arr,$activity_list)."####".getEventTodoInfo($calendar_arr,'listcnt');
 				}
 			}
 			elseif($subtab == 'todo')
@@ -189,7 +208,7 @@
 				$cal_log->debug("going to get calendar Todo ListView");
 				//To get Todos List
 				$todo_list = getTodoList($calendar_arr, $start_date, $end_date);
-				echo constructTodoListView($todo_list,$calendar_arr,$subtab);
+				echo constructTodoListView($todo_list,$calendar_arr,$subtab)."####".getEventTodoInfo($calendar_arr,'listcnt');
 			}
 		}
 		elseif($type == 'view')

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/Appointment.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/Appointment.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/Appointment.php Mon Apr 16 12:27:44 2007
@@ -34,11 +34,15 @@
 	var $activity_type;
 	var $description;
 	var $record;
+	var $temphour;
+	var $tempmin;
 	var $image_name;
 	var $formatted_datetime;
 	var $duration_min;
 	var $duration_hour;
 	var $shared = false;
+	var $recurring;
+	var $dur_hour;
 
 	function Appointment()
 	{
@@ -61,7 +65,9 @@
 		require('user_privileges/user_privileges_'.$current_user->id.'.php');
 		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
 		$shared_ids = getSharedCalendarId($current_user->id);
-                $q= "select vtiger_activity.*, vtiger_crmentity.*, vtiger_activitygrouprelation.groupname FROM vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid left join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname WHERE vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') AND (vtiger_activity.date_start < '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start >= '". $from_datetime->get_formatted_date()."') ";
+		$and = "AND ((vtiger_activity.date_start between '". $from_datetime->get_formatted_date() ."' AND '". $to_datetime->get_formatted_date()."') OR (vtiger_activity.date_start between '". $from_datetime->get_formatted_date() ."' AND '". $to_datetime->get_formatted_date()."') OR (vtiger_activity.date_start < '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start < '". $from_datetime->get_formatted_date()."') OR (vtiger_activity.date_start > '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start < '". $from_datetime->get_formatted_date()."'))";
+		
+                $q= "select vtiger_activity.*, vtiger_crmentity.*, vtiger_activitygrouprelation.groupname FROM vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid left join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname WHERE vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') $and ";
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)
 		{
 			$sec_parameter=getListViewSecurityParameter('Calendar');
@@ -77,19 +83,48 @@
                 $n = $adb->getRowCount($r);
                 $a = 0;
 		$list = Array();
+		
                 while ( $a < $n )
                 {
-                        $obj = &new Appointment();
-                        $result = $adb->fetchByAssoc($r);
-                        $obj->readResult($result, $view);
-                        $a++;
-			$list[] = $obj;
-                        unset($obj);
+			
+			$result = $adb->fetchByAssoc($r);
+			$start_timestamp = strtotime($result["date_start"]);
+			$end_timestamp = strtotime($result["due_date"]);
+			if($from_datetime->ts <= $start_timestamp) $from = $start_timestamp;
+			else $from = $from_datetime->ts;
+			if($to_datetime->ts <= $end_timestamp) $to = $to_datetime->ts;
+			else $to = $end_timestamp;
+			for($j = $from; $j <= $to; $j=$j+(60*60*24))
+			{
+
+				$obj = &new Appointment();
+				$temp_start = date("Y-m-d",$j);
+				$result["date_start"]= $temp_start ;
+				list($obj->temphour,$obj->tempmin) = explode(":",$result["time_start"]);
+				if($start_timestamp != $end_timestamp && $view == 'day'){
+					if($j == $start_timestamp){
+						$result["duration_hours"] = 24 - $obj->temphour;
+					}elseif($j > $start_timestamp && $j < $end_timestamp){
+						list($obj->temphour,$obj->tempmin)= $current_user->start_hour !=''?explode(":",$current_user->start_hour):explode(":","08:00");
+						$result["duration_hours"] = 24 - $obj->temphour;
+					}elseif($j == $end_timestamp){
+						list($obj->temphour,$obj->tempmin)= $current_user->start_hour !=''?explode(":",$current_user->start_hour):explode(":","08:00");
+						list($ehr,$emin) = explode(":",$result["time_end"]);
+						$result["duration_hours"] = $ehr - $obj->temphour;
+					}
+				}
+				$obj->readResult($result, $view);
+				$list[] = $obj;
+				unset($obj);
+
+			}
+			$a++;
+			
                 }
 		//Get Recurring events
 		$q = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_crmentity.description, vtiger_activity.time_start,vtiger_activity.time_end, vtiger_activity.duration_hours, vtiger_activity.duration_minutes,vtiger_activity.due_date, vtiger_activity.priority, vtiger_activity.location,vtiger_activity.eventstatus, vtiger_crmentity.*, vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_activitygrouprelation.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname ";
 
-                $q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') AND (recurringdate < '".$to_datetime->get_formatted_date()."' AND recurringdate >= '".$from_datetime->get_formatted_date(). "') ";
+                $q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') AND (recurringdate between '".$from_datetime->get_formatted_date()."' and '".$to_datetime->get_formatted_date(). "') ";
 
 		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)
 		{
@@ -98,6 +133,7 @@
 		}
 													
                 $q .= " ORDER by vtiger_recurringevents.recurringid";
+		//echo $q;
                 $r = $adb->query($q);
                 $n = $adb->getRowCount($r);
                 $a = 0;
@@ -105,6 +141,7 @@
                 {
 			$obj = &new Appointment();
                         $result = $adb->fetchByAssoc($r);
+			list($obj->temphour,$obj->tempmin) = explode(":",$result["time_start"]);
                         $obj->readResult($result,$view);
                         $a++;
 			$list[] = $obj;
@@ -127,8 +164,6 @@
 		$format_sthour='';
                 $format_stmin='';
 		$this->description       = $act_array["description"];
-		//$this->account_name      = $act_array["accountname"];
-		//$this->account_id        = $act_array["accountid"];
 		$this->eventstatus       = $act_array["eventstatus"];
 		$this->priority		 = $act_array["priority"];
 		$this->subject           = $act_array["subject"];
@@ -148,8 +183,13 @@
 			$this->ownerid = $act_array["smownerid"];
 			if(!is_admin($current_user))
 			{
-				if($act_array["smownerid"] != $current_user->id)
-					$this->shared = true;
+				if($act_array["smownerid"] != $current_user->id && $act_array["visibility"] == "Public"){
+					$que = "select * from vtiger_sharedcalendar where sharedid=".$current_user->id." and userid=".$act_array["smownerid"];
+					$row = $adb->query($que);
+					$no = $adb->getRowCount($row);
+					if($no > 0)
+						$this->shared = true;
+				}	
 			}
 			$this->owner   = getUserName($act_array["smownerid"]);
 			$query="SELECT cal_color FROM vtiger_users where id = ".$this->ownerid;
@@ -160,74 +200,26 @@
 				$this->color = $res['cal_color'];
 			}
 		}
-		if($act_array["activitytype"] == 'Call')
-		{
-			$this->image_name = 'Call.gif';
-		}
-		if($act_array["activitytype"] == 'Meeting')
-		{
-			$this->image_name = 'Meeting.gif';
-		}
+		$this->image_name = $act_array["activitytype"].".gif";
+		if(!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"]))
+			$this->recurring="Recurring.gif";
+		
 		$this->record            = $act_array["activityid"];
 		list($styear,$stmonth,$stday) = explode("-",$act_array["date_start"]);
-		if($act_array["time_start"] != null)
-		{
-			list($st_hour,$st_min,$st_sec) = split(":",$act_array["time_start"]);
-	                if($st_hour <= 9 && strlen(trim($st_hour)) < 2)
-        	        {
-                	        $format_sthour= '0'.$st_hour;
-                	}
-               		else
-                	{
-                        	$format_sthour= $st_hour;
-                	}
-              		if($st_min <= 9 && strlen(trim($st_min)) < 2)
-                	{
-                        	$format_stmin= '0'.$st_min;
-                	}
-               		else
-                	{
-                        	$format_stmin = $st_min;
-                	}
-			$st_hour= $format_sthour;
-		}
-		else
-		{
+		if($act_array["notime"] != 1){
+			$st_hour = twoDigit($this->temphour);
+			list($sthour,$stmin) = split(":",$act_array["time_start"]);
+		}else{
 			$st_hour = 'notime';
-			$format_stmin = '00';
-			$format_sthour= '00';
+			$stmin = '00';
+			$sthour= '00';
 		}
 		list($eyear,$emonth,$eday) = explode("-",$act_array["due_date"]);
-		if($act_array["time_end"] != '')
-		{
-			list($end_hour,$end_min,$end_sec) = split(":",$act_array["time_end"]);
-			if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-			{
-				$format_endhour= '0'.$end_hour;
-			}
-			else
-			{
-				$format_endhour= $end_hour;
-			}
-			if($end_min <= 9 && strlen(trim($end_min)) < 2)
-			{
-				$format_endmin= '0'.$end_min;
-			}
-			else
-			{
-				$format_endmin = $end_min;
-			}
-			$end_hour= $format_endhour;
-		}
-		else
-		{
-			$end_min = '50';
-			$end_hour= '23';
-		}
+		list($end_hour,$end_min) = split(":",$act_array["time_end"]);
 
 		$start_date_arr = Array(
-			'min'   => $format_stmin,
-			'hour'  => $format_sthour,
+			'min'   => $stmin,
+			'hour'  => $sthour,
 			'day'   => $stday,
 			'month' => $stmonth,
 			'year'  => $styear
@@ -239,8 +231,8 @@
 			'month' => $emonth,
 			'year'  => $eyear
 		);
-                $this->start_time        = new DateTime($start_date_arr,true);
-                $this->end_time          = new DateTime($end_date_arr,true);
+                $this->start_time        = new vt_DateTime($start_date_arr,true);
+                $this->end_time          = new vt_DateTime($end_date_arr,true);
 		if($view == 'day' || $view == 'week')
 		{
 			$this->formatted_datetime= $act_array["date_start"].":".$st_hour;

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/Calendar.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/Calendar.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/Calendar.php Mon Apr 16 12:27:44 2007
@@ -29,10 +29,11 @@
 	/*
 	constructor
 	*/
+	var $groupTable = Array('vtiger_activitygrouprelation','activityid');
 	function Calendar($view='',$data=Array())
 	{
 		$this->view = $view;
-		$this->date_time = new DateTime($data,true);
+		$this->date_time = new vt_DateTime($data,true);
 		$this->constructLayout();
 	}
 	/**
@@ -203,16 +204,16 @@
 		if ( $this->view == 'week')
 		{
 			$start_datetime = $this->date_time->getThisweekDaysbyIndex(0);
-			$end_datetime = $this->date_time->get_first_day_of_changed_week('increment');
+			$end_datetime = $this->date_time->getThisweekDaysbyIndex(6);
                 } elseif($this->view == 'month') {
 			$start_datetime = $this->date_time->getThismonthDaysbyIndex(0);
-			$end_datetime = $this->date_time->get_first_day_of_changed_month('increment');
+			$end_datetime = $this->date_time->getThismonthDaysbyIndex($this->date_time->daysinmonth-1);
 		} elseif($this->view == 'year'){
 			$start_datetime = $this->date_time->getThisyearMonthsbyIndex(0);
 			$end_datetime = $this->date_time->get_first_day_of_changed_year('increment');
 		}else {
 			$start_datetime = $this->date_time;
-                        $end_datetime = $this->date_time->get_changed_day('increment');
+                        $end_datetime = $this->date_time->getTodayDatetimebyIndex(23);
                 }
 		
 		$activities = Array();

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/CalendarCommon.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/CalendarCommon.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/CalendarCommon.php Mon Apr 16 12:27:44 2007
@@ -16,16 +16,20 @@
  */
 function getSharedUserId($id)
 {
-        global $adb;
-	$sharedid = Array();
-        $query = "SELECT * from vtiger_sharedcalendar where userid=".$id;
+	global $adb;
+        $sharedid = Array();
+        $query = "SELECT vtiger_users.user_name,vtiger_sharedcalendar.* from vtiger_sharedcalendar left join vtiger_users on vtiger_sharedcalendar.sharedid=vtiger_users.id where userid=".$id;
         $result = $adb->query($query);
         $rows = $adb->num_rows($result);
         for($j=0;$j<$rows;$j++)
         {
-	        $sharedid[] = $adb->query_result($result,$j,'sharedid');
+
+                $id = $adb->query_result($result,$j,'sharedid');
+                $sharedname = $adb->query_result($result,$j,'user_name');
+                $sharedid[$id]=$sharedname;
+
         }
-        return $sharedid;
+	return $sharedid;
 }
 
 /**
@@ -50,18 +54,13 @@
 /**
  * To get userid and username of all vtiger_users except the current user
  * @param $id -- The user id :: Type integer
- * @param $check -- true/false :: Type boolean
  * @returns $user_details -- Array in the following format:
  * $user_details=Array($userid1=>$username, $userid2=>$username,............,$useridn=>$username);
  */
-function getOtherUserName($id,$check)
-{
-	global $adb,$current_user;
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+function getOtherUserName($id)
+{
+	global $adb;
 	$user_details=Array();
-	if($check)
-	{
 		$query="select * from vtiger_users where deleted=0 and status='Active' and id!=".$id;
 		$result = $adb->query($query);
 		$num_rows=$adb->num_rows($result);
@@ -71,20 +70,43 @@
 			$username=$adb->query_result($result,$i,'user_name');
 			$user_details[$userid]=$username;
 		}
-
-	}
-	else
-	{
-		if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid('Calendar')] == 3 or $defaultOrgSharingPermission[getTabid('Calendar')] == 0))
-		{
-			$user_details = get_user_array(FALSE, "Active", $id, 'private');
-			unset($user_details[$id]);
-		}
-		else
-		{
-			$user_details = get_user_array(FALSE, "Active", $id);
-			unset($user_details[$id]);
-		}
+		return $user_details;
+}
+
+/**
+ * To get userid and username of vtiger_users in hierarchy level
+ * @param $id -- The user id :: Type integer
+ * @returns $user_details -- Array in the following format:
+ * $user_details=Array($userid1=>$username, $userid2=>$username,............,$useridn=>$username);
+ */
+
+function getSharingUserName($id)
+{
+	global $adb,$current_user;
+        $user_details=Array();
+	$assigned_user_id = $current_user->id;
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	if($is_admin==false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid('Calendar')] == 3 or $defaultOrgSharingPermission[getTabid('Calendar')] == 0))
+	{
+		$role_seq = implode($parent_roles, "::");
+		$query = "select id as id,user_name as user_name from vtiger_users where id=".$current_user->id." and status='Active' union select vtiger_user2role.userid as id,vtiger_users.user_name as user_name from vtiger_user2role inner join vtiger_users on vtiger_users.id=vtiger_user2role.userid inner join vtiger_role on vtiger_role.roleid=vtiger_user2role.roleid where vtiger_role.parentrole like '".$role_seq."::%' and status='Active' union select shareduserid as id,vtiger_users.user_name as user_name from vtiger_tmp_write_user_sharing_per inner join vtiger_users on vtiger_users.id=vtiger_tmp_write_user_sharing_per.shareduserid where status='Active' and vtiger_tmp_write_user_sharing_per.userid=".$current_user->id." and vtiger_tmp_write_user_sharing_per.tabid=9";
+		if (!empty($assigned_user_id)) {
+			$query .= " OR id='$assigned_user_id'";
+		}
+		$query .= " order by user_name ASC";
+		$result = $adb->query($query, true, "Error filling in user array: ");
+		while($row = $adb->fetchByAssoc($result))
+		{
+			$temp_result[$row['id']] = $row['user_name'];
+		}
+		$user_details = &$temp_result;
+		unset($user_details[$id]);
+	}
+	else
+	{
+		$user_details = get_user_array(FALSE, "Active", $id);
+		unset($user_details[$id]);
 	}
 	return $user_details;
 }
@@ -104,69 +126,25 @@
 	if($format == 'am/pm')
 	{
 		$hr = $sthr+0;
-		if($hr <= 11)
-		{
-			if($hr == 0)
-				$sthr = 12;
-			$timearr['starthour'] = $sthr;
-			$timearr['startfmt'] = 'am';
-		}
-		else
-		{
-			if($hr == 12) $sthr = $hr;
-			else $sthr = $hr - 12;
-				
-			if($sthr <= 9 && strlen(trim($sthr)) < 2)
-                                $hrvalue= '0'.$sthr;
-			else $hrvalue=$sthr;
-			
-			$timearr['starthour'] = $hrvalue;
-			$timearr['startfmt'] = 'pm';
-		}
+		$timearr['startfmt'] = ($hr >= 12) ? "pm" : "am";
+		if($hr == 0) $hr = 12;
+		$timearr['starthour'] = twoDigit(($hr>12)?($hr-12):$hr);
+		$timearr['startmin']  = $stmin;
+
 		$edhr = $edhr+0;
-                if($edhr <= 11)
-                {
-			if($edhr == 0)
-				$edhr = 12;
-				
-			if($edhr <= 9 && strlen(trim($edhr)) < 2)
-				$edhr = '0'.$edhr;
-			$timearr['endhour'] = $edhr;
-                        $timearr['endfmt'] = 'am';
-                }
-                else
-                {
-			$fmt = 'pm';
-			if($edhr == 12)
-				$edhr =	$edhr;
-			else
-			{
-				$edhr = $edhr - 12;
-				if($edhr == 12)
-					$fmt = 'am';
-			}
-                        if($edhr <= 9 && strlen(trim($edhr)) < 2)
-                                $hrvalue= '0'.$edhr;
-			else $hrvalue=$edhr;
-			
-                        $timearr['endhour'] = $hrvalue;
-                        $timearr['endfmt'] = $fmt;
-                }
-		$timearr['startmin']  = $stmin;
+		$timearr['endfmt'] = ($edhr >= 12) ? "pm" : "am";
+		if($edhr == 0) $edhr = 12;
+		$timearr['endhour'] = twoDigit(($edhr>12)?($edhr-12):$edhr);
 		$timearr['endmin']    = $edmin;
 		return $timearr;
 	}
 	if($format == '24')
 	{
-		if($edhr <= 9 && strlen(trim($edhr)) < 2)
-			$edhr = '0'.$edhr;
-		if($sthr <= 9 && strlen(trim($sthr)) < 2)
-			$sthr = '0'.$sthr;
-		$timearr['starthour'] = $sthr;
+		$timearr['starthour'] = twoDigit($sthr);
 		$timearr['startmin']  = $stmin;
 		$timearr['startfmt']  = '';
-		$timearr['endhour']   = $edhr;
-                $timearr['endmin']    = $edmin;
+		$timearr['endhour']   = twoDigit($edhr);
+		$timearr['endmin']    = $edmin;
 		$timearr['endfmt']    = '';
 		return $timearr;
 	}
@@ -179,13 +157,18 @@
  *constructs html select combo box for time selection
  *and returns it in string format.
  */
-function getTimeCombo($format,$bimode,$hour='',$min='',$fmt='')
-{
+function getTimeCombo($format,$bimode,$hour='',$min='',$fmt='',$todocheck=false)
+{
+	global $mod_strings;
 	$combo = '';
 	$min = $min - ($min%5);
+	if($bimode == 'start' && !$todocheck)
+		$jsfn = 'onChange="changeEndtime_StartTime();"';
+	else
+		$jsfn = null;
 	if($format == 'am/pm')
 	{
-		$combo .= '<select class=small name="'.$bimode.'hr" id="'.$bimode.'hr">';
+		$combo .= '<select class=small name="'.$bimode.'hr" id="'.$bimode.'hr" '.$jsfn.'>';
 		for($i=0;$i<12;$i++)
 		{
 			if($i == 0)
@@ -194,87 +177,46 @@
 				$hrvalue = 12;
 			}
 			else
-			{	
-				if($i <= 9 && strlen(trim($i)) < 2)
-				{
-					$hrtext= '0'.$i;
-				}
-				else $hrtext= $i;
-				$hrvalue =  $hrtext;
-			}
-			if($hour == $hrvalue)
-				$hrsel = 'selected';
-			else
-				$hrsel = '';
+				$hrvalue = $hrtext = twoDigit($i);
+			$hrsel = ($hour == $hrvalue)?'selected':'';	
 			$combo .= '<option value="'.$hrvalue.'" '.$hrsel.'>'.$hrtext.'</option>';
 		}
 		$combo .= '</select>&nbsp;';
-		$combo .= '<select name="'.$bimode.'min" id="'.$bimode.'min" class=small>';
+		$combo .= '<select name="'.$bimode.'min" id="'.$bimode.'min" class=small '.$jsfn.'>';
 		for($i=0;$i<12;$i++)
 		{
-			$minvalue = 5;
 			$value = $i*5;
-			if($value <= 9 && strlen(trim($value)) < 2)
-			{
-				$value= '0'.$value;
-			}
-			else $value = $value;
-			if($min == $value)
-				$minsel = 'selected';
-			else
-				$minsel = '';
-				$combo .= '<option value="'.$value.'" '.$minsel.'>'.$value.'</option>';
+			$value = twoDigit($value);
+			$minsel = ($min == $value)?'selected':'';
+			$combo .= '<option value="'.$value.'" '.$minsel.'>'.$value.'</option>';
 		}
 		$combo .= '</select>&nbsp;';
-		$combo .= '<select name="'.$bimode.'fmt" id="'.$bimode.'fmt" class=small>';
-		if($fmt == 'am')
-		{
-			$amselected = 'selected';
-			$pmselected = '';
-		}
-		elseif($fmt == 'pm')
-		{
-			$amselected = '';
-			$pmselected = 'selected';
-		}
+		$combo .= '<select name="'.$bimode.'fmt" id="'.$bimode.'fmt" class=small '.$jsfn.'>';
+		$amselected = ($fmt == 'am')?'selected':'';
+		$pmselected = ($fmt == 'pm')?'selected':'';
 		$combo .= '<option value="am" '.$amselected.'>AM</option>';
 		$combo .= '<option value="pm" '.$pmselected.'>PM</option>';
 		$combo .= '</select>';
 		}
 		else
 		{
-			$combo .= '<select name="'.$bimode.'hr" id="'.$bimode.'hr" class=small>';
+			$combo .= '<select name="'.$bimode.'hr" id="'.$bimode.'hr" class=small '.$jsfn.'>';
 			for($i=0;$i<=23;$i++)
 			{
-				if($i <= 9 && strlen(trim($i)) < 2)
-				{
-					$hrvalue= '0'.$i;
-				}
-				else $hrvalue = $i;
-				if($hour == $hrvalue)
-					$hrsel = 'selected';
-				else
-					$hrsel = '';
+				$hrvalue = twoDigit($i);
+				$hrsel = ($hour == $hrvalue)?'selected':'';
 				$combo .= '<option value="'.$hrvalue.'" '.$hrsel.'>'.$hrvalue.'</option>';
 			}
-			$combo .= '</select>Hr&nbsp;';
-			$combo .= '<select name="'.$bimode.'min" id="'.$bimode.'min" class=small>';
+			$combo .= '</select>'.$mod_strings[LBL_HR].'&nbsp;';
+			$combo .= '<select name="'.$bimode.'min" id="'.$bimode.'min" class=small '.$jsfn.'>';
 			for($i=0;$i<12;$i++)
 			{
-				$minvalue = 5;
 				$value = $i*5;
-				if($value <= 9 && strlen(trim($value)) < 2)
-				{
-					$value= '0'.$value;
-				}
-				else $value=$value;
-				if($min == $value)
-					$minsel = 'selected';
-				else
-					$minsel = '';
+				$value= twoDigit($value);
+				$minsel = ($min == $value)?'selected':'';
 				$combo .= '<option value="'.$value.'" '.$minsel.'>'.$value.'</option>';
 			}
-			$combo .= '</select>&nbsp;min<input type="hidden" name="'.$bimode.'fmt" id="'.$bimode.'fmt">';
+			$combo .= '</select>&nbsp;'.$mod_strings[LBL_MIN].'<input type="hidden" name="'.$bimode.'fmt" id="'.$bimode.'fmt">';
 		}
 		return $combo;
 }
@@ -291,7 +233,10 @@
 {
 	global $adb, $mod_strings;
 	$combo = '';
-	$combo .= '<select name="'.$fieldname.'" id="'.$fieldname.'" class=small>';
+	$js_fn = '';
+	if($fieldname == 'eventstatus')
+		$js_fn = 'onChange = "getSelectedStatus();"';
+	$combo .= '<select name="'.$fieldname.'" id="'.$fieldname.'" class=small '.$js_fn.'>';
 	$q = "select * from ".$tablename;
 	$Res = $adb->query($q);
 	$noofrows = $adb->num_rows($Res);
@@ -348,4 +293,211 @@
 }
 
 //Code Added by Minnie -Ends
+/**
+ * Function to get the vtiger_activity details for mail body
+ * @param   string   $description       - activity description
+ * @param   string   $from              - to differenciate from notification to invitation.
+ * return   string   $list              - HTML in string format
+ */
+function getActivityDetails($description,$user_id,$from='')
+{
+        global $log,$current_user;
+        global $adb,$mod_strings;
+        $log->debug("Entering getActivityDetails(".$description.") method ...");
+
+        $reply = (($description['mode'] == 'edit')?'updated':'created');
+	if($description['activity_mode'] == "Events")
+	{
+		$end_date_lable=$mod_strings['End date and time'];
+	}
+	else
+	{
+		$end_date_lable=$mod_strings['Due Date'];
+	}
+
+	$name = getUserName($user_id);
+	
+	if($from == "invite")
+		$msg = $mod_strings['LBL_ACTIVITY_INVITATION'];
+	else
+		$msg = $mod_strings['LBL_ACTIVITY_NOTIFICATION'];
+
+        $current_username = getUserName($current_user->id);
+        $status = $description['status'];
+
+        $list = $name.',';
+	$list .= '<br><br>'.$msg.' '.$reply.'.<br> '.$mod_strings['LBL_DETAILS_STRING'].':<br>';
+        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_SUBJECT"].' '.$description['subject'];
+	$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Start date and time"].' : '.$description['st_date_time'];
+	$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$end_date_lable.' : '.$description['end_date_time'];
+        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_STATUS"].': '.$status;
+        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Priority"].': '.$description['taskpriority'];
+        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Related To"].': '.$description['relatedto'];
+	if($description['activity_mode'] != 'Events')
+	{
+        	$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_CONTACT"].' '.$description['contact_name'];
+	}
+	else
+		$list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["Location"].' : '.$description['location'];
+			
+        $list .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$mod_strings["LBL_APP_DESCRIPTION"].': '.$description['description'];
+        $list .= '<br><br>'.$mod_strings["LBL_REGARDS_STRING"].' ,';
+        $list .= '<br>'.$current_username.'.';
+
+        $log->debug("Exiting getActivityDetails method ...");
+        return $list;
+}
+
+function twoDigit( $no ){
+	if($no < 10 && strlen(trim($no)) < 2) return "0".$no;
+	else return "".$no;
+}
+
+function timeString($datetime,$fmt){
+
+	if(is_object($datetime)){
+		$hr = $datetime->hour;
+		$min = $datetime->minute;
+	} else {
+		$hr = $datetime['hour'];
+		$min = $datetime['minute'];
+	}
+	$timeStr = "";
+	if($fmt != 'am/pm'){
+		$timeStr .= twoDigit($hr).":".twoDigit($min);
+	}else{
+		$am = ($hr >= 12) ? "pm" : "am";
+		if($hr == 0) $hr = 12;
+		$timeStr .= ($hr>12)?($hr-12):$hr;
+		$timeStr .= ":".twoDigit($min);
+		$timeStr .= $am;
+	}
+	return $timeStr;
+}
+//added to fix Ticket#3068
+function getEventNotification($mode,$subject,$desc)
+{
+	global $current_user,$adb;
+	require_once("modules/Emails/mail.php");
+	$subject = $mode.' : '.$subject;
+	$crmentity = new CRMEntity();
+	if($desc['assingn_type'] == "U")
+	{
+		$to_email = getUserEmailId('id',$desc['user_id']);
+		$description = getActivityDetails($desc,$desc['user_id']);
+		send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
+	}
+	if($desc['assingn_type'] == "T")
+	{
+		$groupname=$desc['group_name'];
+		$resultqry=$adb->query("select groupid from vtiger_groups where groupname='".$groupname."'");
+		$groupid=$adb->query_result($resultqry,0,"groupid");
+		require_once('include/utils/GetGroupUsers.php');
+		$getGroupObj=new GetGroupUsers();
+		$getGroupObj->getAllUsersInGroup($groupid);
+		$userIds=$getGroupObj->group_users;
+		$groupqry="select email1,id from vtiger_users where id in(".implode(',',$userIds).")";
+		$groupqry_res=$adb->query($groupqry);
+		$noOfRows = $adb->num_rows($groupqry_res);
+		for($z=0;$z < $noOfRows;$z++)
+		{
+			$emailadd = $adb->query_result($groupqry_res,$z,'email1');
+			$curr_userid = $adb->query_result($groupqry_res,$z,'id');
+			$description = getActivityDetails($desc,$curr_userid);
+			$mail_status = send_mail('Calendar',$emailadd,getUserName($curr_userid),'',$subject,$description);
+
+		}
+	}
+}
+
+function sendInvitation($inviteesid,$mode,$subject,$desc)
+{
+	global $current_user;
+	require_once("modules/Emails/mail.php");
+	$invitees_array = explode(';',$inviteesid);
+	$subject = $mode.' : '.$subject;
+	$record = $focus->id;
+	foreach($invitees_array as $inviteeid)
+	{
+		if($inviteeid != '')
+		{
+			$description=getActivityDetails($desc,$inviteeid,"invite");
+			$to_email = getUserEmailId('id',$inviteeid);
+			send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
+		}
+	}
+
+}
+
+function getActivityMailInfo($return_id,$status,$activity_type)
+{
+	$mail_data = Array();
+	global $adb;
+	$qry = "select * from vtiger_activity where activityid=".$return_id;
+	$ary_res = $adb->query($qry);
+	$send_notification = $adb->query_result($ary_res,0,"sendnotification");
+	$subject = $adb->query_result($ary_res,0,"subject");
+	$priority = $adb->query_result($ary_res,0,"priority");
+	$st_date = $adb->query_result($ary_res,0,"date_start");
+	$st_time = $adb->query_result($ary_res,0,"time_start");
+	$end_date = $adb->query_result($ary_res,0,"due_date");
+	$end_time = $adb->query_result($ary_res,0,"time_end");
+	$location = $adb->query_result($ary_res,0,"location");
+
+	$usr_qry = "select smownerid from vtiger_crmentity where crmid=".$return_id;
+	$res = $adb->query($usr_qry);
+	$usr_id = $adb->query_result($res,0,"smownerid");
+	$assignType = "U";
+	if($usr_id == 0)
+	{
+		$assignType = "T";
+		$group_qry = "select groupname from vtiger_activitygrouprelation where activityid=".$return_id;
+		$grp_res = $adb->query($group_qry);
+		$grp_name = $adb->query_result($grp_res,0,"groupname");
+	}
+
+
+	$desc_qry = "select description from vtiger_crmentity where crmid=".$return_id;
+	$des_res = $adb->query($desc_qry);
+	$description = $adb->query_result($des_res,0,"description");
+
+		
+	$rel_qry = "select case vtiger_crmentity.setype when 'Leads' then vtiger_leaddetails.lastname when 'Accounts' then vtiger_account.accountname when 'Potentials' then vtiger_potential.potentialname when 'Quotes' then vtiger_quotes.subject when 'PurchaseOrder' then vtiger_purchaseorder.subject when 'SalesOrder' then vtiger_salesorder.subject when 'Invoice' then vtiger_invoice.subject when 'Campaigns' then vtiger_campaign.campaignname when 'HelpDesk' then vtiger_troubletickets.title  end as relname from vtiger_seactivityrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seactivityrel.crmid left join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid  left join vtiger_account on vtiger_account.accountid=vtiger_seactivityrel.crmid left join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_quotes on vtiger_quotes.quoteid= vtiger_seactivityrel.crmid left join vtiger_purchaseorder on vtiger_purchaseorder.purchaseorderid = vtiger_seactivityrel.crmid  left join vtiger_salesorder on vtiger_salesorder.salesorderid = vtiger_seactivityrel.crmid left join vtiger_invoice on vtiger_invoice.invoiceid = vtiger_seactivityrel.crmid  left join vtiger_campaign on vtiger_campaign.campaignid = vtiger_seactivityrel.crmid left join vtiger_troubletickets on vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid where vtiger_seactivityrel.activityid=".$return_id;
+
+	$rel_res = $adb->query($rel_qry);
+	$rel_name = $adb->query_result($rel_res,0,"relname");
+
+
+	$cont_qry = "select * from vtiger_cntactivityrel where activityid=".$return_id;
+	$cont_res = $adb->query($cont_qry);
+	$cont_id = $adb->query_result($cont_res,0,"contactid");
+	$cont_name = '';
+	if($cont_id != '')
+	{
+		$cont_name = getContactName($cont_id);
+	}
+	$mail_data['mode'] = "edit";
+	$mail_data['activity_mode'] = $activity_type;
+	$mail_data['sendnotification'] = $send_notification;
+	$mail_data['user_id'] = $usr_id;
+	$mail_data['subject'] = $subject;
+	$mail_data['status'] = $status;
+	$mail_data['taskpriority'] = $priority;
+	$mail_data['relatedto'] = $rel_name;
+	$mail_data['contact_name'] = $cont_name;
+	$mail_data['description'] = $description;
+	$mail_data['assingn_type'] = $assignType;
+	$mail_data['group_name'] = $grp_name;
+	$value = getaddEventPopupTime($st_time,$end_time,'24');
+	$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
+	if($activity_type != 'Task' )
+		$end_hour = $value['endhour'] .':'.$value['endmin'].''.$value['endfmt'];
+	$mail_data['st_date_time']=getDisplayDate($st_date)." ".$start_hour;
+	$mail_data['end_date_time']=getDisplayDate($end_date)." ".$end_hour;
+	$mail_data['location']=$location;
+	return $mail_data;
+
+
+}
+
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/Date.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/Date.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/Date.php Mon Apr 16 12:27:44 2007
@@ -9,7 +9,7 @@
 *
  ********************************************************************************/
 
-class DateTime
+class vt_DateTime
 {
 	var $second = '00';
 	var $minute = '00';
@@ -35,11 +35,11 @@
 	var $tz;
 	var $ts_def;
 	/**
-	 * Constructor for DateTime class
+	 * Constructor for vt_DateTime class
 	 * @param array  $timearr - collection of string
 	 * @param string $check   - check string
 	 */
-	function DateTime(&$timearr,$check)
+	function vt_DateTime(&$timearr,$check)
 	{
 		if (! isset( $timearr) || count($timearr) == 0 )
                 {
@@ -96,7 +96,7 @@
 	  * @param string        $day   - date  
 	  * @param string        $month - month
 	  * @param string        $year  - year
-	  * return DateTime obj  $datetimevalue
+	  * return vt_DateTime obj  $datetimevalue
 	  */
 	function getTodayDatetimebyIndex($index,$day='', $month='', $year='')
 	{
@@ -116,13 +116,13 @@
                 $day_array['day'] = $day;
                 $day_array['month'] = $month;
                 $day_array['year'] = $year;
-		$datetimevalue = new DateTime($day_array,true);
+		$datetimevalue = new vt_DateTime($day_array,true);
                 return $datetimevalue;
 	}
 	/**
 	 * function to get days in week using index
 	 * @param integer       $index - number between 0 to 6
-	 * return DateTime obj  $datetimevalue
+	 * return vt_DateTime obj  $datetimevalue
 	 */
 
 	function getThisweekDaysbyIndex($index)
@@ -135,7 +135,7 @@
                 $week_array['day'] = $this->day + ($index - $this->dayofweek);
                 $week_array['month'] = $this->month;
                 $week_array['year'] = $this->year;
-                $datetimevalue = new DateTime($week_array,true);
+                $datetimevalue = new vt_DateTime($week_array,true);
                 return $datetimevalue;
         }
 
@@ -145,7 +145,7 @@
 	 * @param string        $day   - date
 	 * @param string        $month - month
 	 * @param string        $year  - year
-	 * return DateTime obj  $datetimevalue
+	 * return vt_DateTime obj  $datetimevalue
 	 */
 
 	function getThismonthDaysbyIndex($index,$day='', $month='', $year='')
@@ -160,14 +160,14 @@
                 $month_array['day'] = $day;
                 $month_array['month'] = $month;
                 $month_array['year'] = $year;
-                $datetimevalue = new DateTime($month_array,true);
+                $datetimevalue = new vt_DateTime($month_array,true);
                 return $datetimevalue;
         }
 
 	/**
 	* function to get months in year using index
 	* @param integer       $index - number between 0 to 11
-	* return DateTime obj  $datetimevalue
+	* return vt_DateTime obj  $datetimevalue
 	*/
 
 	function getThisyearMonthsbyIndex($index)
@@ -180,13 +180,13 @@
                 }
                 $year_array['month'] = $index+1;
                 $year_array['year'] = $this->year;
-                $datetimevalue = new DateTime($year_array,true);
+                $datetimevalue = new vt_DateTime($year_array,true);
                 return $datetimevalue;
         }
 	
 	/**
 	* function to get hour end time 
-	* return DateTime obj  $datetimevalue
+	* return vt_DateTime obj  $datetimevalue
 	*/
 
 	function getHourendtime()
@@ -198,13 +198,13 @@
 		$date_array['sec'] = 59;
                 $date_array['month'] = $this->month;
                 $date_array['year'] = $this->year;
-		$datetimevalue = new DateTime($date_array,true);
+		$datetimevalue = new vt_DateTime($date_array,true);
                 return $datetimevalue;
         }
 
 	/**
 	* function to get day end time
-	* return DateTime obj  $datetimevalue
+	* return vt_DateTime obj  $datetimevalue
 	*/
 	function getDayendtime()
         {
@@ -215,13 +215,13 @@
                 $date_array['day'] = $this->day;
                 $date_array['month'] = $this->month;
                 $date_array['year'] = $this->year;
-		$datetimevalue = new DateTime($date_array,true);
+		$datetimevalue = new vt_DateTime($date_array,true);
                 return $datetimevalue;
         }
 
 	/**
 	* function to get month end time
-	* return DateTime obj  $datetimevalue
+	* return vt_DateTime obj  $datetimevalue
 	*/
 	function getMonthendtime()
         {
@@ -232,7 +232,7 @@
                 $date_array['day'] = $this->daysinmonth;
                 $date_array['month'] = $this->month;
                 $date_array['year'] = $this->year;
-                $datetimevalue = new DateTime($date_array,true);
+                $datetimevalue = new vt_DateTime($date_array,true);
                 return $datetimevalue;
         }
 	
@@ -289,7 +289,7 @@
 	}
 
 	/**
-	* function to set values for DateTime object
+	* function to set values for vt_DateTime object
 	* @param integer   $ts  - Time stamp
 	*/
 	function setDateTime($ts)
@@ -338,7 +338,7 @@
 	}
 
 	/**
-	* function to get values from DateTime object
+	* function to get values from vt_DateTime object
 	*/
 	function getDateTime()
         {
@@ -401,7 +401,7 @@
 	/**
 	* function to get date depends on mode value
 	* @param string $mode  - 'increment' or 'decrement'
-	* return DateTime obj
+	* return vt_DateTime obj
 	*/
 	function get_changed_day($mode)
 	{
@@ -415,13 +415,13 @@
                                         'year'=>$this->year
                                   );
 
-                return new DateTime($date_data,true);
+                return new vt_DateTime($date_data,true);
 	}
 	
 	/**
 	* function to get changed week depends on mode value
 	* @param string $mode  - 'increment' or 'decrement'
-	* return DateTime obj
+	* return vt_DateTime obj
 	*/
 	function get_first_day_of_changed_week($mode)
 	{
@@ -435,13 +435,13 @@
                                         'month'=>$first_day->month,
                                         'year'=>$first_day->year
                                   );
-		return new DateTime($date_data,true);
+		return new vt_DateTime($date_data,true);
 	}
 	
 	/**
 	* function to get month depends on mode value
 	* @param string $mode  - 'increment' or 'decrement'
-	* return DateTime obj
+	* return vt_DateTime obj
 	*/
 	function get_first_day_of_changed_month($mode)
 	{
@@ -469,13 +469,13 @@
 					'year'=>$year
 				  );
 
-                return new DateTime($date_data,true);
+                return new vt_DateTime($date_data,true);
 	}
 
 	/**
 	* function to get year depends on mode value
 	* @param string $mode  - 'increment' or 'decrement'
-	* return DateTime obj
+	* return vt_DateTime obj
 	*/
 	function get_first_day_of_changed_year($mode)
 	{
@@ -489,7 +489,7 @@
                                         'year'=>$year
                                   );
 
-                return new DateTime($date_data,true);	
+                return new vt_DateTime($date_data,true);	
 	}
 	
 	/**

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/DetailView.php Mon Apr 16 12:27:44 2007
@@ -1,306 +1,326 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Activities/DetailView.php,v 1.12 2005/03/17 11:26:49 ray Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Calendar/Activity.php');
-require_once('include/CustomFieldUtil.php');
-require_once('include/database/PearDatabase.php');
-require_once('include/utils/utils.php');
-require_once('modules/Calendar/calendarLayout.php');
-include_once 'modules/Calendar/header.php';
-global $mod_strings, $currentModule;
-if( $_SESSION['mail_send_error']!="")
-{
-	echo '<b><font color=red>'. $mod_strings{"LBL_NOTIFICATION_ERROR"}.'</font></b><br>';
-}
-session_unregister('mail_send_error');
-$focus = new Activity();
-$smarty =  new vtigerCRM_Smarty();
-$activity_mode = $_REQUEST['activity_mode'];
-//If activity_mode == null
-
-if($activity_mode =='' || strlen($activity_mode) < 1)
-{
-	$query = "select activitytype from vtiger_activity where activityid=".$_REQUEST['record'];
-	$result = $adb->query($query);
-	$actType = $adb->query_result($result,0,'activitytype');
-	if( $actType == 'Task')
-	{
-		$activity_mode = $actType;	
-	}
-	elseif($actType == 'Meeting' || $actType == 'Call')
-	{
-		$activity_mode = 'Events';
-	}		
-}	
-
-
-
-if($activity_mode == 'Task')
-{
-        $tab_type = 'Calendar';
-	$smarty->assign("SINGLE_MOD",$mod_strings['LBL_TODO']);
-}
-elseif($activity_mode == 'Events')
-{
-        $tab_type = 'Events';
-	$smarty->assign("SINGLE_MOD",$mod_strings['LBL_EVENT']);
-}
-$tab_id=getTabid($tab_type);
-
-
-if(isset($_REQUEST['record']) && isset($_REQUEST['record'])) {
-    $focus->retrieve_entity_info($_REQUEST['record'],$tab_type);
-    $focus->id = $_REQUEST['record'];	
-    $focus->name=$focus->column_fields['subject'];
-}
-
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
-	$focus->id = "";
-} 
-
-//needed when creating a new task with default values passed in
-if (isset($_REQUEST['contactname']) && is_null($focus->contactname)) {
-	$focus->contactname = $_REQUEST['contactname'];
-}
-if (isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
-	$focus->contact_id = $_REQUEST['contact_id'];
-}
-if (isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
-	$focus->parent_name = $_REQUEST['opportunity_name'];
-}
-if (isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
-	$focus->parent_id = $_REQUEST['opportunity_id'];
-}
-if (isset($_REQUEST['accountname']) && is_null($focus->parent_name)) {
-	$focus->parent_name = $_REQUEST['accountname'];
-}
-if (isset($_REQUEST['accountid']) && is_null($focus->parent_id)) {
-	$focus->parent_id = $_REQUEST['accountid'];
-}
-
-$act_data = getBlocks($tab_type,"detail_view",'',$focus->column_fields);
-foreach($act_data as $block=>$entry)
-{
-	foreach($entry as $key=>$value)
-	{
-		foreach($value as $label=>$field)
-		{
-			$fldlabel[$field['fldname']] = $label;
-			$finaldata[$field['fldname']] = $field['value'];
-		}
-	}
-}
-
-//Start
-//To set user selected hour format
-if($current_user->hour_format == '')
-	$format = 'am/pm';
-else
-	$format = $current_user->hour_format;
-list($stdate,$sttime) = split('&nbsp;',$finaldata['date_start']);
-list($enddate,$endtime) = split('&nbsp;',$finaldata['due_date']);
-$time_arr = getaddEventPopupTime($sttime,$endtime,$format);
-$data['starthr'] = $time_arr['starthour'];
-$data['startmin'] = $time_arr['startmin'];
-$data['startfmt'] = $time_arr['startfmt'];
-$data['endhr'] = $time_arr['endhour'];
-$data['endmin'] = $time_arr['endmin'];
-$data['endfmt'] = $time_arr['endfmt'];
-$data['record'] = $focus->id;
-if(isset($finaldata['sendnotification']) && $finaldata['sendnotification'] == 'yes')
-        $data['sendnotification'] = 'Yes';
-else
-        $data['sendnotification'] = 'No';
-$data['subject'] = $finaldata['subject'];
-$data['date_start'] = $stdate;
-$data['due_date'] = $enddate;
-$data['assigned_user_id'] = $finaldata['assigned_user_id'];
-$data['taskpriority'] = $mod_strings[$finaldata['taskpriority']];
-$data['modifiedtime'] = $finaldata['modifiedtime'];
-$data['createdtime'] = $finaldata['createdtime'];
-$data['parent_name'] = $finaldata['parent_id'];
-$data['description'] = $finaldata['description'];
-if($activity_mode == 'Task')
-{
-	$data['taskstatus'] = $mod_strings[$finaldata['taskstatus']];
-	$data['activitytype'] = $activity_mode;
-	$data['contact_id'] = $finaldata['contact_id'];
-}
-elseif($activity_mode == 'Events')
-{
-	$data['visibility'] = $finaldata['visibility'];
-	$data['eventstatus'] = $mod_strings[$finaldata['eventstatus']];
-	$data['activitytype'] = $finaldata['activitytype'];
-	$data['location'] = $finaldata['location'];
-	//Calculating reminder time
-	$rem_days = 0;
-	$rem_hrs = 0;
-	$rem_min = 0;
-	if($focus->column_fields['reminder_time'] != null)
-	{
-		$data['set_reminder'] = 'Yes';
-		$data['reminder_str'] = $finaldata['reminder_time'];
-	}
-	else
-		$data['set_reminder'] = 'No';
-	//To set recurring details
-	$query = 'select vtiger_recurringevents.recurringfreq,vtiger_recurringevents.recurringinfo from vtiger_recurringevents where vtiger_recurringevents.activityid = '.$focus->id;
-	$res = $adb->query($query);
-	$rows = $adb->num_rows($res);
-	if($rows != 0)
-	{
-		$data['recurringcheck'] = 'Yes';
-		$data['repeat_frequency'] = $adb->query_result($res,0,'recurringfreq');
-		$recurringinfo =  explode("::",$adb->query_result($res,0,'recurringinfo'));
-		$data['recurringtype'] = $recurringinfo[0];
-		if($recurringinfo[0] == 'Weekly')
-		{
-			$weekrpt_str = '';
-			if(count($recurringinfo) > 1)
-			{
-				$weekrpt_str .= 'on ';
-				for($i=1;$i<count($recurringinfo);$i++)
-				{
-					$label = 'LBL_DAY'.$recurringinfo[$i];
-					if($i != 1)
-						$weekrpt_str .= ', ';
-					$weekrpt_str .= $mod_strings[$label];
-				}
-			}
-			$data['repeat_str'] = $weekrpt_str;
-		}
-		elseif($recurringinfo[0] == 'Monthly')
-		{   
-			$monthrpt_str = '';
-			$data['repeatMonth'] = $recurringinfo[1];  
-			if($recurringinfo[1] == 'date')
-			{
-				$data['repeatMonth_date'] = $recurringinfo[2];
-				$monthrpt_str .= 'on '.$recurringinfo[2].' day of the month';
-			}
-			else 
-			{ 
-				$data['repeatMonth_daytype'] = $recurringinfo[2];
-				$data['repeatMonth_day'] = $recurringinfo[3];
-				switch($data['repeatMonth_day'])
-				{
-					case 0 :
-						$day = $mod_strings['LBL_DAY0'];
-						break;
-					case 1 :
-						$day = $mod_strings['LBL_DAY1'];
-						break;
-					case 2 :
-						$day = $mod_strings['LBL_DAY2'];
-						break;
-					case 3 :
-						$day = $mod_strings['LBL_DAY3'];
-						break;
-					case 4 :
-						$day = $mod_strings['LBL_DAY4'];
-						break;
-					case 5 :
-						$day = $mod_strings['LBL_DAY5'];
-						break;
-					case 6 :
-						$day = $mod_strings['LBL_DAY6'];
-						break;
-				}
-
-				$monthrpt_str .= 'on '.$mod_strings[$recurringinfo[2]].' '.$day;
-			}
-			$data['repeat_str'] = $monthrpt_str;
-		}
-	}
-	else 
-	{   
-		$data['recurringcheck'] = 'No';
-		$data['repeat_month_str'] = '';
-	}
-	$related_array = getRelatedLists("Calendar", $focus);
-	$smarty->assign("INVITEDUSERS",$related_array['Users']['entries']);
-	$smarty->assign("CONTACTS",$related_array['Contacts']['entries']);
-
-
-}
-
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-$log->info("Calendar-Activities detail view");
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-$smarty->assign("ACTIVITY_MODE", $activity_mode);
-
-if (isset($focus->name)) 
-$smarty->assign("NAME", $focus->name);
-else 
-$smarty->assign("NAME", "");
-$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-if (isset($_REQUEST['return_module'])) 
-$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
-if (isset($_REQUEST['return_action'])) 
-$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
-if (isset($_REQUEST['return_id'])) 
-$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);
-$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string'].'&activity_mode='.$activity_mode);
-$smarty->assign("ID", $focus->id);
-$smarty->assign("NAME", $focus->name);
-$smarty->assign("BLOCKS", $act_data);
-$smarty->assign("LABEL", $fldlabel);
-$smarty->assign("VIEWTYPE", $_REQUEST['viewtype']);
-$smarty->assign("CUSTOMFIELD", $cust_fld);
-$smarty->assign("ACTIVITYDATA", $data);
-$smarty->assign("ID", $_REQUEST['record']);
-
-//get Description Information
-if(isPermitted("Calendar","EditView",$_REQUEST['record']) == 'yes')
-	$smarty->assign("EDIT_DUPLICATE","permitted");
-
-if(isPermitted("Calendar","Delete",$_REQUEST['record']) == 'yes')
-	$smarty->assign("DELETE","permitted");
-  
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-
- $tabid = getTabid($tab_type);
- $validationData = getDBValidationData($focus->tab_name,$tabid);
- $data2 = split_validationdataArray($validationData);
-
- $smarty->assign("VALIDATION_DATA_FIELDNAME",$data2['fieldname']);
- $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data2['datatype']);
- $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data2['fieldlabel']);
-
-$smarty->assign("MODULE",$currentModule);
-$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
-$smarty->display("ActivityDetailView.tpl");
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Activities/DetailView.php,v 1.12 2005/03/17 11:26:49 ray Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Calendar/Activity.php');
+require_once('include/CustomFieldUtil.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/utils/utils.php');
+require_once('modules/Calendar/calendarLayout.php');
+include_once 'modules/Calendar/header.php';
+global $mod_strings, $currentModule,$adb;
+if( $_SESSION['mail_send_error']!="")
+{
+	echo '<b><font color=red>'. $mod_strings{"LBL_NOTIFICATION_ERROR"}.'</font></b><br>';
+}
+session_unregister('mail_send_error');
+$focus = new Activity();
+$smarty =  new vtigerCRM_Smarty();
+$activity_mode = $_REQUEST['activity_mode'];
+//If activity_mode == null
+
+if($activity_mode =='' || strlen($activity_mode) < 1)
+{
+	$query = "select activitytype from vtiger_activity where activityid=".$_REQUEST['record'];
+	$result = $adb->query($query);
+	$actType = $adb->query_result($result,0,'activitytype');
+	if( $actType == 'Task')
+	{
+		$activity_mode = $actType;	
+	}
+	elseif($actType == 'Meeting' || $actType == 'Call')
+	{
+		$activity_mode = 'Events';
+	}		
+}	
+
+
+
+if($activity_mode == 'Task')
+{
+        $tab_type = 'Calendar';
+	$smarty->assign("SINGLE_MOD",$mod_strings['LBL_TODO']);
+}
+elseif($activity_mode == 'Events')
+{
+        $tab_type = 'Events';
+	$smarty->assign("SINGLE_MOD",$mod_strings['LBL_EVENT']);
+}
+$tab_id=getTabid($tab_type);
+
+
+if(isset($_REQUEST['record']) && isset($_REQUEST['record'])) {
+    $focus->retrieve_entity_info($_REQUEST['record'],$tab_type);
+    $focus->id = $_REQUEST['record'];	
+    $focus->name=$focus->column_fields['subject'];
+}
+
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+	$focus->id = "";
+} 
+
+//needed when creating a new task with default values passed in
+if (isset($_REQUEST['contactname']) && is_null($focus->contactname)) {
+	$focus->contactname = $_REQUEST['contactname'];
+}
+if (isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
+	$focus->contact_id = $_REQUEST['contact_id'];
+}
+if (isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
+	$focus->parent_name = $_REQUEST['opportunity_name'];
+}
+if (isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
+	$focus->parent_id = $_REQUEST['opportunity_id'];
+}
+if (isset($_REQUEST['accountname']) && is_null($focus->parent_name)) {
+	$focus->parent_name = $_REQUEST['accountname'];
+}
+if (isset($_REQUEST['accountid']) && is_null($focus->parent_id)) {
+	$focus->parent_id = $_REQUEST['accountid'];
+}
+
+$act_data = getBlocks($tab_type,"detail_view",'',$focus->column_fields);
+foreach($act_data as $block=>$entry)
+{
+	foreach($entry as $key=>$value)
+	{
+		foreach($value as $label=>$field)
+		{
+			$fldlabel[$field['fldname']] = $label;
+			$finaldata[$field['fldname']] = $field['value'];
+			$finaldata[$field['fldname'].'link'] = $field['link'];
+		}
+	}
+}
+//Start
+//To set user selected hour format
+if($current_user->hour_format == '')
+	$format = 'am/pm';
+else
+	$format = $current_user->hour_format;
+list($stdate,$sttime) = split('&nbsp;',$finaldata['date_start']);
+list($enddate,$endtime) = split('&nbsp;',$finaldata['due_date']);
+$time_arr = getaddEventPopupTime($sttime,$endtime,$format);
+$data['starthr'] = $time_arr['starthour'];
+$data['startmin'] = $time_arr['startmin'];
+$data['startfmt'] = $time_arr['startfmt'];
+$data['endhr'] = $time_arr['endhour'];
+$data['endmin'] = $time_arr['endmin'];
+$data['endfmt'] = $time_arr['endfmt'];
+$data['record'] = $focus->id;
+if(isset($finaldata['sendnotification']) && $finaldata['sendnotification'] == 'yes')
+        $data['sendnotification'] = $mod_strings['LBL_YES'];
+else
+        $data['sendnotification'] = $mod_strings['LBL_NO'];
+$data['subject'] = $finaldata['subject'];
+$data['date_start'] = $stdate;
+$data['due_date'] = $enddate;
+$data['assigned_user_id'] = $finaldata['assigned_user_id'];
+if($mod_strings[$finaldata['taskpriority']] != '')
+	$data['taskpriority'] = $mod_strings[$finaldata['taskpriority']];
+else
+	$data['taskpriority'] = $finaldata['taskpriority'];
+$data['modifiedtime'] = $finaldata['modifiedtime'];
+$data['createdtime'] = $finaldata['createdtime'];
+$data['parent_name'] = $finaldata['parent_id'];
+$data['description'] = $finaldata['description'];
+if($activity_mode == 'Task')
+{
+	if($mod_strings[$finaldata['taskstatus']] != '')
+		$data['taskstatus'] = $mod_strings[$finaldata['taskstatus']];
+	else
+		$data['taskstatus'] = $finaldata['taskstatus'];
+	$data['activitytype'] = $activity_mode;
+	$data['contact_id'] = $finaldata['contact_id'];
+	$data['contact_idlink'] = $finaldata['contact_idlink'];
+}
+elseif($activity_mode == 'Events')
+{
+	$data['visibility'] = $finaldata['visibility'];
+	if($mod_strings[$finaldata['taskstatus']] != '')
+		$data['eventstatus'] = $mod_strings[$finaldata['eventstatus']];
+	else
+		$data['eventstatus'] = $finaldata['eventstatus'];
+	$data['activitytype'] = $finaldata['activitytype'];
+	$data['location'] = $finaldata['location'];
+	//Calculating reminder time
+	$rem_days = 0;
+	$rem_hrs = 0;
+	$rem_min = 0;
+	if($focus->column_fields['reminder_time'] != null)
+	{
+		$data['set_reminder'] = $mod_strings['LBL_YES'];
+		$data['reminder_str'] = $finaldata['reminder_time'];
+	}
+	else
+		$data['set_reminder'] = $mod_strings['LBL_NO'];
+	//To set recurring details
+	$query = 'select vtiger_recurringevents.recurringfreq,vtiger_recurringevents.recurringinfo from vtiger_recurringevents where vtiger_recurringevents.activityid = '.$focus->id;
+	$res = $adb->query($query);
+	$rows = $adb->num_rows($res);
+	if($rows != 0)
+	{
+		$data['recurringcheck'] = $mod_strings['LBL_YES'];
+		$data['repeat_frequency'] = $adb->query_result($res,0,'recurringfreq');
+		$recurringinfo =  explode("::",$adb->query_result($res,0,'recurringinfo'));
+		$data['recurringtype'] = $recurringinfo[0];
+		if($recurringinfo[0] == 'Weekly')
+		{
+			$weekrpt_str = '';
+			if(count($recurringinfo) > 1)
+			{
+				$weekrpt_str .= 'on ';
+				for($i=1;$i<count($recurringinfo);$i++)
+				{
+					$label = 'LBL_DAY'.$recurringinfo[$i];
+					if($i != 1)
+						$weekrpt_str .= ', ';
+					$weekrpt_str .= $mod_strings[$label];
+				}
+			}
+			$data['repeat_str'] = $weekrpt_str;
+		}
+		elseif($recurringinfo[0] == 'Monthly')
+		{   
+			$monthrpt_str = '';
+			$data['repeatMonth'] = $recurringinfo[1];  
+			if($recurringinfo[1] == 'date')
+			{
+				$data['repeatMonth_date'] = $recurringinfo[2];
+				$monthrpt_str .= $mod_strings['on'].'&nbsp;'.$recurringinfo[2].'&nbsp;'.$mod_strings['day of the month'];
+			}
+			else 
+			{ 
+				$data['repeatMonth_daytype'] = $recurringinfo[2];
+				$data['repeatMonth_day'] = $recurringinfo[3];
+				switch($data['repeatMonth_day'])
+				{
+					case 0 :
+						$day = $mod_strings['LBL_DAY0'];
+						break;
+					case 1 :
+						$day = $mod_strings['LBL_DAY1'];
+						break;
+					case 2 :
+						$day = $mod_strings['LBL_DAY2'];
+						break;
+					case 3 :
+						$day = $mod_strings['LBL_DAY3'];
+						break;
+					case 4 :
+						$day = $mod_strings['LBL_DAY4'];
+						break;
+					case 5 :
+						$day = $mod_strings['LBL_DAY5'];
+						break;
+					case 6 :
+						$day = $mod_strings['LBL_DAY6'];
+						break;
+				}
+
+				$monthrpt_str .= 'on '.$mod_strings[$recurringinfo[2]].' '.$day;
+			}
+			$data['repeat_str'] = $monthrpt_str;
+		}
+	}
+	else 
+	{   
+		$data['recurringcheck'] = $mod_strings['LBL_NO'];
+		$data['repeat_month_str'] = '';
+	}
+	$sql = 'select vtiger_users.user_name,vtiger_invitees.* from vtiger_invitees left join vtiger_users on vtiger_invitees.inviteeid=vtiger_users.id where activityid='.$focus->id;
+	$result = $adb->query($sql);
+	$num_rows=$adb->num_rows($result);
+	$invited_users=Array();
+	for($i=0;$i<$num_rows;$i++)
+	{
+		$userid=$adb->query_result($result,$i,'inviteeid');
+		$username=$adb->query_result($result,$i,'user_name');
+		$invited_users[$userid]=$username;
+	}
+	$smarty->assign("INVITEDUSERS",$invited_users);
+	$related_array = getRelatedLists("Calendar", $focus);
+	$smarty->assign("CONTACTS",$related_array['Contacts']['entries']);
+
+
+}
+
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+$log->info("Calendar-Activities detail view");
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("ACTIVITY_MODE", $activity_mode);
+
+if (isset($focus->name)) 
+$smarty->assign("NAME", $focus->name);
+else 
+$smarty->assign("NAME", "");
+$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+if (isset($_REQUEST['return_module'])) 
+$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
+if (isset($_REQUEST['return_action'])) 
+$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
+if (isset($_REQUEST['return_id'])) 
+$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string'].'&activity_mode='.$activity_mode);
+$smarty->assign("ID", $focus->id);
+$smarty->assign("NAME", $focus->name);
+$smarty->assign("BLOCKS", $act_data);
+$smarty->assign("LABEL", $fldlabel);
+$smarty->assign("VIEWTYPE", $_REQUEST['viewtype']);
+$smarty->assign("CUSTOMFIELD", $cust_fld);
+$smarty->assign("ACTIVITYDATA", $data);
+$smarty->assign("ID", $_REQUEST['record']);
+
+//get Description Information
+if(isPermitted("Calendar","EditView",$_REQUEST['record']) == 'yes')
+	$smarty->assign("EDIT_DUPLICATE","permitted");
+
+if(isPermitted("Calendar","Delete",$_REQUEST['record']) == 'yes')
+	$smarty->assign("DELETE","permitted");
+  
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+
+ $tabid = getTabid($tab_type);
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data2 = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data2['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data2['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data2['fieldlabel']);
+
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+$smarty->display("ActivityDetailView.tpl");
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/EditView.php Mon Apr 16 12:27:44 2007
@@ -40,11 +40,13 @@
 if($activity_mode == 'Task')
 {
 	$tab_type = 'Calendar';
+	$taskcheck = true;	
 	$smarty->assign("SINGLE_MOD",$mod_strings['LBL_TODO']);
 }
 elseif($activity_mode == 'Events')
 {
 	$tab_type = 'Events';
+	$taskcheck = false;
 	$smarty->assign("SINGLE_MOD",$mod_strings['LBL_EVENT']);
 }
 
@@ -122,13 +124,19 @@
 	    $value['recurringcheck'] = 'No';
     }
 
+}else
+{
+	if(isset($_REQUEST['contact_id']) && $_REQUEST['contact_id']!=''){
+		$smarty->assign("CONTACTSID",$_REQUEST['contact_id']);
+		$contact_name = getContactName($_REQUEST['contact_id']);
+		$smarty->assign("CONTACTSNAME",$contact_name);
+	}	
 }
 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
 	$focus->id = "";
     	$focus->mode = ''; 	
 }
-$userDetails=getOtherUserName($current_user->id,true);
-//echo '<pre>';print_r($userDetails);echo '</pre>';
+$userDetails=getOtherUserName($current_user->id);
 $to_email = getUserEmailId('id',$current_user->id);
 $smarty->assign("CURRENTUSERID",$current_user->id);
 
@@ -158,11 +166,7 @@
 		}
 	}
 }
-if($current_user->hour_format == '')
-	$format = 'am/pm';
-else
-	$format = $current_user->hour_format;
-//echo '<pre>';print_r($value);echo '</pre>';
+$format = ($current_user->hour_format == '')?'am/pm':$current_user->hour_format;
 $stdate = key($value['date_start']);
 $enddate = key($value['due_date']);
 $sttime = $value['date_start'][$stdate];
@@ -174,9 +178,9 @@
 $value['endhr'] = $time_arr['endhour'];
 $value['endmin'] = $time_arr['endmin'];
 $value['endfmt'] = $time_arr['endfmt'];
-$smarty->assign("STARTHOUR",getTimeCombo($format,'start',$time_arr['starthour'],$time_arr['startmin'],$time_arr['startfmt']));
+$smarty->assign("STARTHOUR",getTimeCombo($format,'start',$time_arr['starthour'],$time_arr['startmin'],$time_arr['startfmt'],$taskcheck));
 $smarty->assign("ENDHOUR",getTimeCombo($format,'end',$time_arr['endhour'],$time_arr['endmin'],$time_arr['endfmt']));
-//echo '<pre>';print_r($value);echo '</pre>';
+$smarty->assign("FOLLOWUP",getTimeCombo($format,'followup_start',$time_arr['endhour'],$time_arr['endmin'],$time_arr['endfmt']));
 $smarty->assign("ACTIVITYDATA",$value);
 $smarty->assign("LABEL",$fldlabel);
 $smarty->assign("secondvalue",$secondvalue);
@@ -189,6 +193,7 @@
 $smarty->assign("USERSLIST",$userDetails);
 $smarty->assign("USEREMAILID",$to_email);
 $smarty->assign("MODULE",$currentModule);
+$smarty->assign("DATEFORMAT",parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 
 global $theme;
 $theme_path="themes/".$theme."/";
@@ -218,17 +223,35 @@
 $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
 
 if (isset($_REQUEST['return_module']))
-$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
+	$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
 if (isset($_REQUEST['return_action']))
-$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
+	$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
 if (isset($_REQUEST['return_id']))
-$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
+	$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
 if (isset($_REQUEST['ticket_id']))
-$smarty->assign("TICKETID", $_REQUEST['ticket_id']);
+	$smarty->assign("TICKETID", $_REQUEST['ticket_id']);
 if (isset($_REQUEST['product_id']))
-$smarty->assign("PRODUCTID", $_REQUEST['product_id']);
+	$smarty->assign("PRODUCTID", $_REQUEST['product_id']);
 if (isset($_REQUEST['return_viewname']))
-$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
+	$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
+if(isset($_REQUEST['view']) && $_REQUEST['view']!='')
+	$smarty->assign("view",$_REQUEST['view']);
+if(isset($_REQUEST['hour']) && $_REQUEST['hour']!='')
+	$smarty->assign("hour",$_REQUEST['hour']);
+if(isset($_REQUEST['day']) && $_REQUEST['day']!='')
+	$smarty->assign("day",$_REQUEST['day']);
+if(isset($_REQUEST['month']) && $_REQUEST['month']!='')
+	$smarty->assign("month",$_REQUEST['month']);
+if(isset($_REQUEST['year']) && $_REQUEST['year']!='')
+	$smarty->assign("year",$_REQUEST['year']);
+if(isset($_REQUEST['viewOption']) && $_REQUEST['viewOption']!='')
+	$smarty->assign("viewOption",$_REQUEST['viewOption']);
+if(isset($_REQUEST['subtab']) && $_REQUEST['subtab']!='')
+	$smarty->assign("subtab",$_REQUEST['subtab']);
+if(isset($_REQUEST['maintab']) && $_REQUEST['maintab']!='')
+	$smarty->assign("maintab",$_REQUEST['maintab']);
+	
+	
 $smarty->assign("THEME", $theme);
 $smarty->assign("IMAGE_PATH", $image_path);
 $smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
@@ -240,6 +263,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 $smarty->display("ActivityEditView.tpl");
 

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/ListView.php Mon Apr 16 12:27:44 2007
@@ -28,6 +28,7 @@
 require_once('include/ListView/ListView.php');
 require_once('include/utils/utils.php');
 require_once('modules/CustomView/CustomView.php');
+require_once('modules/Calendar/CalendarCommon.php');
 require_once('include/database/PearDatabase.php');
 
 global $app_strings;
@@ -55,7 +56,7 @@
 if($_REQUEST['errormsg'] != '')
 {
         $errormsg = $_REQUEST['errormsg'];
-        $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule);
+        $smarty->assign("ERROR",$mod_strings["SHARED_EVENT_DEL_MSG"]);
 }else
 {
         $smarty->assign("ERROR","");
@@ -75,6 +76,13 @@
 $customviewcombo_html = $oCustomView->getCustomViewCombo($viewid);
 $viewnamedesc = $oCustomView->getCustomViewByCvid($viewid);
 //<<<<<customview>>>>>
+$changeOwner = getAssignedTo(16);
+$userList = $changeOwner[0];
+$groupList = $changeOwner[1];
+//echo '<pre>';print_r($changeOwner); echo '</pre>';
+
+$smarty->assign("CHANGE_USER",$userList);
+$smarty->assign("CHANGE_GROUP",$groupList);
 $smarty->assign("CHANGE_OWNER",getUserslist());
 $smarty->assign("CHANGE_GROUP_OWNER",getGroupslist());
 $where = "";
@@ -195,8 +203,8 @@
 
 //Cambiado code to add close button in custom vtiger_field
 if (($viewid!=0)&&($viewid!="")){
-  if (!isset($oCustomView->list_fields['Close'])) $oCustomView->list_fields['Close']=array ( 'activity' => 'status' );
-  if (!isset($oCustomView->list_fields_name['Close'])) $oCustomView->list_fields_name['Close']='status';
+  if (!isset($oCustomView->list_fields['Close'])) $oCustomView->list_fields['Close']=array ( 'vtiger_activity' => 'eventstatus' );
+  if (!isset($oCustomView->list_fields_name['Close'])) $oCustomView->list_fields_name['Close']='eventstatus';
 }
 $listview_header = getListViewHeader($focus,"Calendar",$url_string,$sorder,$order_by,"",$oCustomView);
 $smarty->assign("LISTHEADER", $listview_header);

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/OpenListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/OpenListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/OpenListView.php Mon Apr 16 12:27:44 2007
@@ -20,20 +20,28 @@
  * Contributor(s): ______________________________________..
  ********************************************************************************/
 
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/database/Postgres8.php');
+
 /**
  * Function to get Pending/Upcoming activities
  * @param integer  $mode     - number to differentiate upcoming and pending activities
  * return array    $values   - activities record in array format
  */
-function getPendingActivities($mode)
+function getPendingActivities($mode,$view='')
 {
 	global $log;
         $log->debug("Entering getPendingActivities() method ...");
 	require_once("data/Tracker.php");
 	require_once("include/utils/utils.php");
+	require_once('include/utils/CommonUtils.php'); //new
+	require_once('user_privileges/default_module_view.php');
+	
 
 	global $currentModule;
-
+	global $singlepane_view;
 	global $theme;
 	global $focus;
 	global $action;
@@ -46,6 +54,8 @@
 	$theme_path="themes/".$theme."/";
 	$image_path=$theme_path."images/";
 	require_once($theme_path.'layout_utils.php');
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
 	//code added to customize upcomming and pending activities
 	if($_REQUEST['activity_view']=='')
 	{	
@@ -56,12 +66,12 @@
 
 	$today = date("Y-m-d", time());
 
-	if($activity_view == 'today')
+	if($view == 'today')
 	{	
 		$upcoming_condition = " AND (date_start = '$today' OR vtiger_recurringevents.recurringdate = '$today')";
 		$pending_condition = " AND (due_date = '$today' OR vtiger_recurringevents.recurringdate = '$today')";
 	}	
-	else if($activity_view == 'all')
+	else if($view == 'all')
 	{
 		$upcoming_condition = " AND (date_start >= '$today' OR vtiger_recurringevents.recurringdate >= '$today')";
 		$pending_condition = " AND (due_date <= '$today' OR vtiger_recurringevents.recurringdate <= '$today')";
@@ -69,14 +79,32 @@
 	if($mode != 1)
 	{
 		//for upcoming avtivities
-		$list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_account.accountid, vtiger_account.accountname, vtiger_recurringevents.recurringtype,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid left outer join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Deferred') and  (  vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Held') and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Not Held' ) ".$upcoming_condition." AND vtiger_crmentity.smownerid !=0 AND vtiger_salesmanactivityrel.smid ='$current_user->id'";
+		$list_query = "SELECT vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_account.accountid, vtiger_account.accountname, vtiger_recurringevents.recurringtype,vtiger_recurringevents.recurringdate FROM vtiger_activity INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_activity.activityid LEFT JOIN vtiger_activitygrouprelation ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname LEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid= vtiger_activity.activityid LEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid LEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid LEFT OUTER JOIN vtiger_account ON vtiger_account.accountid = vtiger_contactdetails.accountid LEFT OUTER JOIN vtiger_recurringevents ON vtiger_recurringevents.activityid=vtiger_activity.activityid INNER JOIN vtiger_salesmanactivityrel ON vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 AND vtiger_activity.activitytype IN ('Meeting','Call','Task') AND ( vtiger_activity.status IS NULL OR vtiger_activity.status NOT IN ('Completed','Deferred')) AND  (  vtiger_activity.eventstatus IS NULL OR  vtiger_activity.eventstatus NOT IN ('Held','Not Held') )".$upcoming_condition;
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)
+		{
+			$sec_parameter=getListViewSecurityParameter('Calendar');
+			$list_query .= $sec_parameter;
+		}
+
 	}	
 	else
 	{
 		//for pending activities
-		$list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_account.accountid, vtiger_account.accountname, vtiger_recurringevents.recurringtype,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid left outer join vtiger_account on vtiger_account.accountid = vtiger_contactdetails.accountid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid inner join vtiger_salesmanactivityrel on vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Deferred') and (  vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Held') and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus != 'Not Held' ) ".$pending_condition." AND vtiger_crmentity.smownerid !=0 AND vtiger_salesmanactivityrel.smid ='$current_user->id'";
+		$list_query = "SELECT vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.setype, vtiger_activity.*, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_account.accountid, vtiger_account.accountname, vtiger_recurringevents.recurringtype,vtiger_recurringevents.recurringdate FROM vtiger_activity INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_activity.activityid  LEFT JOIN vtiger_activitygrouprelation ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname LEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid= vtiger_activity.activityid LEFT JOIN vtiger_contactdetails ON vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid LEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid LEFT OUTER JOIN vtiger_account ON vtiger_account.accountid = vtiger_contactdetails.accountid LEFT OUTER JOIN vtiger_recurringevents ON vtiger_recurringevents.activityid=vtiger_activity.activityid INNER JOIN vtiger_salesmanactivityrel ON vtiger_salesmanactivityrel.activityid=vtiger_activity.activityid WHERE vtiger_crmentity.deleted=0 AND (vtiger_activity.activitytype IN ('Meeting','Call','Task')) AND (vtiger_activity.status IS NULL OR vtiger_activity.status NOT IN ('Completed','Deferred')) AND (vtiger_activity.eventstatus IS NULL OR  vtiger_activity.eventstatus NOT IN ('Held','Not Held')) ".$pending_condition;
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)                   
+                {
+			$sec_parameter=getListViewSecurityParameter('Calendar'); 
+	                $list_query .= $sec_parameter; 
+		}
 	}
 	
+	//Postgres 8 fixes
+	if( $adb->dbType == "pgsql")
+	    $list_query = fixPostgresQuery( $list_query, $log, 0);
+	else
+	    $list_query.= " GROUP BY vtiger_activity.activityid";
+
+	$list_query.= " ORDER BY date_start,time_start ASC";
 	$res = $adb->query($list_query);
 	$noofrecords = $adb->num_rows($res);
 	$open_activity_list = array();
@@ -106,7 +134,7 @@
 		}
 	
 	$title=array();
-	$title[]=$activity_view;
+	$title[]=$view;
 	$title[]='myUpcoPendAct.gif';
 	$title[]='home_myact';
 	//$title[]=getActivityView($activity_view);

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/Save.php Mon Apr 16 12:27:44 2007
@@ -23,28 +23,19 @@
 
 require_once('modules/Calendar/Activity.php');
 require_once('include/logging.php');
-//require("modules/Emails/class.phpmailer.php");
 require_once("config.php");
 require_once('include/database/PearDatabase.php');
+require_once('modules/Calendar/CalendarCommon.php');
 global $adb;
 $local_log =& LoggerManager::getLogger('index');
 $focus = new Activity();
 $activity_mode = $_REQUEST['activity_mode'];
-if($activity_mode == 'Task')
-{
-        $tab_type = 'Calendar';
-	$focus->column_fields["activitytype"] = 'Task';
-}
-elseif($activity_mode == 'Events')
-{
-        $tab_type = 'Events';
-}
-
-
+$tab_type = 'Calendar';
+$focus->column_fields["activitytype"] = 'Task';
 if(isset($_REQUEST['record']))
 {
 	$focus->id = $_REQUEST['record'];
-$local_log->debug("id is ".$id);
+	$local_log->debug("id is ".$id);
 }
 if(isset($_REQUEST['mode']))
 {
@@ -66,8 +57,27 @@
 		$status = $_REQUEST['eventstatus'];	
 		$activity_type = "Events";	
 	}
-	
 	ChangeStatus($status,$return_id,$activity_type);
+	$mail_data = getActivityMailInfo($return_id,$status,$activity_type);
+	if($mail_data['sendnotification'] == 1)
+	{
+		getEventNotification($activity_type,$mail_data['subject'],$mail_data);
+	}
+	$invitee_qry = "select * from vtiger_invitees where activityid=".$return_id;
+	$invitee_res = $adb->query($invitee_qry);
+	$count = $adb->num_rows($invitee_res);
+	if($count != 0)
+	{
+		for($j = 0; $j < $count; $j++)
+		{
+			$invitees_ids[]= $adb->query_result($invitee_res,$j,"inviteeid");
+
+		}
+		$invitees_ids_string = implode(';',$invitees_ids);
+		sendInvitation($invitees_ids_string,$activity_type,$mail_data['subject'],$mail_data);
+	}
+
+
 }
 else
 {
@@ -92,13 +102,34 @@
 	else
 	        $focus->column_fields['visibility'] = 'Private';
 	$focus->save($tab_type);
+	$heldevent_id = $focus->id;
+	/* For Followup START -- by Minnie */
+	if(isset($_REQUEST['followup']) && $_REQUEST['followup'] == 'on' && $activity_mode == 'Events' && isset($_REQUEST['followup_time_start']) &&  $_REQUEST['followup_time_start'] != '')
+	{
+		$focus->column_fields['subject'] = '[Followup] '.$focus->column_fields['subject'];
+		$focus->column_fields['date_start'] = $_REQUEST['followup_date'];
+		$focus->column_fields['due_date'] = $_REQUEST['followup_date'];
+		$focus->column_fields['time_start'] = $_REQUEST['followup_time_start'];
+		$focus->column_fields['time_end'] = $_REQUEST['followup_time_end'];
+		$focus->column_fields['eventstatus'] = 'Planned';
+		$focus->mode = 'create';
+		$focus->save($tab_type);
+
+	}
+	/* For Followup END -- by Minnie */
 	$return_id = $focus->id;
 }
-if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
-else $return_module = "Calendar";
-if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
-else $return_action = "DetailView";
-if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
+
+if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") 
+	$return_module = $_REQUEST['return_module'];
+else 
+	$return_module = "Calendar";
+if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") 
+	$return_action = $_REQUEST['return_action'];
+else 
+	$return_action = "DetailView";
+if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") 
+	$return_id = $_REQUEST['return_id'];
 
 if($_REQUEST['mode'] != 'edit' && $_REQUEST['return_module'] == 'Products')
 {
@@ -116,48 +147,53 @@
 	        {
 	                $sql = "insert into vtiger_cntactivityrel values (".$_REQUEST['return_id'].",".$focus->id.")";
 	                $adb->query($sql);
+			if(!empty($heldevent_id)){
+				$sql = "insert into vtiger_cntactivityrel values (".$_REQUEST['return_id'].",".$heldevent_id.")";
+				$adb->query($sql);
+			}
 	        }
 }
 									
 									
 $activemode = "";
-if($activity_mode != '') $activemode = "&activity_mode=".$activity_mode;
-
+if($activity_mode != '') 
+	$activemode = "&activity_mode=".$activity_mode;
+
+function getRequestData()
+{
+	$mail_data = Array();
+	$mail_data['user_id'] = $_REQUEST['assigned_user_id'];
+	$mail_data['subject'] = $_REQUEST['subject'];
+	$mail_data['status'] = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
+	$mail_data['activity_mode'] = $_REQUEST['activity_mode'];
+	$mail_data['taskpriority'] = $_REQUEST['taskpriority'];
+	$mail_data['relatedto'] = $_REQUEST['parent_name'];
+	$mail_data['contact_name'] = $_REQUEST['contact_name'];
+	$mail_data['description'] = $_REQUEST['description'];
+	$mail_data['assingn_type'] = $_REQUEST['assigntype'];
+	$mail_data['group_name'] = $_REQUEST['assigned_group_name'];
+	$mail_data['mode'] = $_REQUEST['mode'];
+	$value = getaddEventPopupTime($_REQUEST['time_start'],$_REQUEST['time_end'],'24');
+	$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
+	if($_REQUEST['activity_mode']!='Task')
+		$end_hour = $value['endhour'] .':'.$value['endmin'].''.$value['endfmt'];
+	$mail_data['st_date_time'] = getDisplayDate($_REQUEST['date_start'])." ".$start_hour;
+	$mail_data['end_date_time']=getDisplayDate($_REQUEST['due_date'])." ".$end_hour;
+	$mail_data['location']=$_REQUEST['location'];
+	return $mail_data;
+}
 //Added code to send mail to the assigned to user about the details of the vtiger_activity if sendnotification = on and assigned to user
-if($_REQUEST['sendnotification'] == 'on' && $_REQUEST['assigntype'] == 'U')
-{
-	global $current_user;
-	$local_log->info("send notification is on");
-        require_once("modules/Emails/mail.php");
-        $to_email = getUserEmailId('id',$_REQUEST['assigned_user_id']);
-
-	$subject = $_REQUEST['activity_mode'].' : '.$_REQUEST['subject'];
-	$description = getActivityDetails($_REQUEST['description']);
-
-        $mail_status  = send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
+if($_REQUEST['sendnotification'] == 'on')
+{
+	$mail_contents = getRequestData();
+	getEventNotification($_REQUEST['activity_mode'],$_REQUEST['subject'],$mail_contents);
 }
 
 //code added to send mail to the vtiger_invitees
 if(isset($_REQUEST['inviteesid']) && $_REQUEST['inviteesid']!='')
 {
-	global $current_user;
-	$local_log->info("send notification is on");
-	require_once("modules/Emails/mail.php");
-	$selected_users_string =  $_REQUEST['inviteesid'];
-	$invitees_array = explode(';',$selected_users_string);
-	$subject = $_REQUEST['activity_mode'].' : '.$_REQUEST['subject'];
-	$description = getActivityDetails($_REQUEST['description']);
-	foreach($invitees_array as $inviteeid)
-	{
-		if($inviteeid != '')
-		{
-			$to_email = getUserEmailId('id',$inviteeid);
-			$mail_status  = send_mail('Calendar',$to_email,$current_user->user_name,'',$subject,$description);
-			$record = $focus->id;
-			$sql = "insert into vtiger_salesmanactivityrel values (".$inviteeid.",".$record.")";
-			$adb->query($sql);
-		}
-	}
+	$mail_contents = getRequestData();
+        sendInvitation($_REQUEST['inviteesid'],$_REQUEST['activity_mode'],$_REQUEST['subject'],$mail_contents);
 }
 
 if(isset($_REQUEST['contactidlist']) && $_REQUEST['contactidlist'] != '')
@@ -176,49 +212,33 @@
 }
 
 
-if(isset($_REQUEST['view']) && $_REQUEST['view']!='') $view=$_REQUEST['view'];
-if(isset($_REQUEST['hour']) && $_REQUEST['hour']!='') $hour=$_REQUEST['hour'];
-if(isset($_REQUEST['day']) && $_REQUEST['day']!='') $day=$_REQUEST['day'];
-if(isset($_REQUEST['month']) && $_REQUEST['month']!='') $month=$_REQUEST['month'];
-if(isset($_REQUEST['year']) && $_REQUEST['year']!='') $year=$_REQUEST['year'];
-if(isset($_REQUEST['viewOption']) && $_REQUEST['viewOption']!='') $viewOption=$_REQUEST['viewOption'];
-if(isset($_REQUEST['subtab']) && $_REQUEST['subtab']!='') $subtab=$_REQUEST['subtab'];
+if(isset($_REQUEST['view']) && $_REQUEST['view']!='')
+	$view=$_REQUEST['view'];
+if(isset($_REQUEST['hour']) && $_REQUEST['hour']!='')
+	$hour=$_REQUEST['hour'];
+if(isset($_REQUEST['day']) && $_REQUEST['day']!='')
+	$day=$_REQUEST['day'];
+if(isset($_REQUEST['month']) && $_REQUEST['month']!='')
+	$month=$_REQUEST['month'];
+if(isset($_REQUEST['year']) && $_REQUEST['year']!='') 
+	$year=$_REQUEST['year'];
+if(isset($_REQUEST['viewOption']) && $_REQUEST['viewOption']!='') 
+	$viewOption=$_REQUEST['viewOption'];
+if(isset($_REQUEST['subtab']) && $_REQUEST['subtab']!='') 
+	$subtab=$_REQUEST['subtab'];
 
 //code added for returning back to the current view after edit from list view
-if($_REQUEST['return_viewname'] == '') $return_viewname='0';
-if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
-if($_REQUEST['parenttab'] != '')$parenttab=$_REQUEST['parenttab'];
-if($_REQUEST['start'] !='')$page='&start='.$_REQUEST['start'];
+if($_REQUEST['return_viewname'] == '') 
+	$return_viewname='0';
+if($_REQUEST['return_viewname'] != '')
+	$return_viewname=$_REQUEST['return_viewname'];
+if($_REQUEST['parenttab'] != '')
+	$parenttab=$_REQUEST['parenttab'];
+if($_REQUEST['start'] !='')
+	$page='&start='.$_REQUEST['start'];
 if($_REQUEST['maintab'] == 'Calendar')
 	header("Location: index.php?action=".$return_action."&module=".$return_module."&view=".$view."&hour=".$hour."&day=".$day."&month=".$month."&year=".$year."&record=".$return_id."&viewOption=".$viewOption."&subtab=".$subtab."&parenttab=$parenttab");
 else
 	header("Location: index.php?action=$return_action&module=$return_module$view$hour$day$month$year&record=$return_id$activemode&viewname=$return_viewname$page&parenttab=$parenttab");
 
-/**
- * Function to get the vtiger_activity details for mail body
- * @param   string   $description       - activity description
- * return   string   $list              - HTML in string format
- */
-function getActivityDetails($description)
-{
-	global $log;
-	$log->debug("Entering getActivityDetails(".$description.") method ...");
-	global $adb;
-
-	$reply = (($_REQUEST['mode'] == 'edit')?'Replied':'Created');
-	$name = getUserName($_REQUEST['assigned_user_id']);
-	$status = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
-
-	$list = 'Dear '.$name.',';
-	$list .= '<br><br> There is an vtiger_activity('.$_REQUEST['activity_mode'].')'.$reply.'. The details are :';
-	$list .= '<br>Subject : '.$_REQUEST['subject'];
-	$list .= '<br>Status : '.$status;
-	$list .= '<br>Priority : '.$_REQUEST['taskpriority'];
-	$list .= '<br>Related to : '.$_REQUEST['parent_name'];
-	$list .= '<br>Contact : '.$_REQUEST['contact_name'];
-	$list .= '<br><br> Description : '.$description;
-
-	$log->debug("Exiting getActivityDetails method ...");
-	return $list;
-}
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/TodoSave.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/TodoSave.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/TodoSave.php Mon Apr 16 12:27:44 2007
@@ -9,12 +9,12 @@
 *
  ********************************************************************************/
 require_once('modules/Calendar/Activity.php');
+require_once('modules/Calendar/CalendarCommon.php');
 require_once('include/logging.php');
 require_once("config.php");
 require_once('include/database/PearDatabase.php');
 
 $local_log =& LoggerManager::getLogger('index');
-
 $focus = new Activity();
 $activity_mode = $_REQUEST['activity_mode'];
 if($activity_mode == 'Task')
@@ -46,6 +46,34 @@
  if(isset($_REQUEST['task_sendnotification']) && $_REQUEST['task_sendnotification'] != null)
  	$focus->column_fields["sendnotification"] =  $_REQUEST["task_sendnotification"];
 
- $focus->save($tab_type);
- header("Location: index.php?action=index&module=Calendar&view=".$_REQUEST['view']."&hour=".$_REQUEST['hour']."&day=".$_REQUEST['day']."&month=".$_REQUEST['month']."&year=".$_REQUEST['year']."&viewOption=".$_REQUEST['viewOption']."&subtab=".$_REQUEST['subtab']."&parenttab=".$_REQUEST['parenttab']);
+ 	$focus->save($tab_type);
+	if($_REQUEST["task_sendnotification"]=='on')
+        {
+		$mail_contents = getRequestedToData();
+		getEventNotification($_REQUEST['activity_mode'],$_REQUEST['task_subject'],$mail_contents);
+
+        }
+function getRequestedToData()
+{
+	$mail_data = Array();
+	$mail_data['user_id'] = $_REQUEST["task_assigned_user_id"];
+	$mail_data['subject'] = $_REQUEST['task_subject'];
+	$mail_data['status'] = (($_REQUEST['activity_mode']=='Task')?($_REQUEST['taskstatus']):($_REQUEST['eventstatus']));
+	$mail_data['activity_mode'] = $_REQUEST['activity_mode'];
+	$mail_data['taskpriority'] = $_REQUEST['taskpriority'];
+	$mail_data['relatedto'] = $_REQUEST['task_parent_name'];
+	$mail_data['contact_name'] = $_REQUEST['task_contact_name'];
+	$mail_data['description'] = $_REQUEST['task_description'];
+	$mail_data['assingn_type'] = $_REQUEST['task_assigntype'];
+	$mail_data['group_name'] = $_REQUEST['task_assigned_group_name'];
+	$mail_data['mode'] = $_REQUEST['task_mode'];
+	$value = getaddEventPopupTime($_REQUEST['task_time_start'],$_REQUEST['task_time_end'],'24');
+	$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
+	$mail_data['st_date_time'] = getDisplayDate($_REQUEST['task_date_start'])." ".$start_hour;
+	$mail_data['end_date_time']=getDisplayDate($_REQUEST['task_due_date']);
+	return $mail_data;
+}
+
+
+ header("Location: index.php?action=index&module=Calendar&view=".$_REQUEST['view']."&hour=".$_REQUEST['hour']."&day=".$_REQUEST['day']."&month=".$_REQUEST['month']."&year=".$_REQUEST['year']."&viewOption=".$_REQUEST['viewOption']."&subtab=todo&parenttab=".$_REQUEST['parenttab']);
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/addEventUI.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/addEventUI.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/addEventUI.php Mon Apr 16 12:27:44 2007
@@ -195,12 +195,15 @@
 	<input type="hidden" name="mode" value="">
 	<input type="hidden" name="time_start" id="time_start">
 	<input type="hidden" name="time_end" id="time_end">
+	<input type="hidden" name="followup_time_start" id="followup_time_start">
+	<input type="hidden" name="followup_time_end" id="followup_time_end">
 	<input type="hidden" name="duration_hours" value="0">                                                                      <input type="hidden" name="duration_minutes" value="0">
 	<input type=hidden name="inviteesid" id="inviteesid" value="">
 	<input type="hidden" name="parenttab" value="<?php echo $category ?>">
 	<input type="hidden" name="viewOption" value="">
 	<input type="hidden" name="subtab" value="">
 	<input type="hidden" name="maintab" value="Calendar">
+	<input type="hidden" name="dateformat" value="<?php echo $date_format ?>">
 		<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerHeadingULine">
 		<tr style="cursor:move;">
 			<td class="layerPopupHeading" id="moveEvent"><?php echo $mod_strings['LBL_ADD_EVENT']?></b></td>
@@ -217,14 +220,14 @@
 			<td width=80% align="left">
 				<table>
 					<tr>
-					<td><input type="radio" name='activitytype' value='Call' style='vertical-align: middle;' checked></td><td><?php echo $mod_strings['LBL_CALL']?></td><td style="width:10px">
-					<td><input type="radio" name='activitytype' value='Meeting' style='vertical-align: middle;'></td><td><?php echo $mod_strings['LBL_MEET']?></td><td style="width:20px">
+					<td><input type="radio" name='activitytype' value='Call' style='vertical-align: middle;' checked onClick="calDuedatetime('call');"></td><td><?php echo $mod_strings['LBL_CALL']?></td>
+					<td><input type="radio" name='activitytype' value='Meeting' style='vertical-align: middle;' onClick="calDuedatetime('meeting');"></td><td><?php echo $mod_strings['LBL_MEET']?></td>
 					</tr>
 				</table>
 			</td>
 			</tr>
 			<tr>
-				<td nowrap align="right"><b><?php echo $mod_strings['LBL_EVENTNAME']?></b></td>
+				<td nowrap align="right"><b><font color="red">*</font><?php echo $mod_strings['LBL_EVENTNAME']?></b></td>
 				<td align="left"><input name="subject" type="text" class="textbox" value="" style="width:50%">&nbsp;&nbsp;&nbsp; 
 			<?php if(getFieldVisibilityPermission('Events',$current_user->id,'visibility') == '0') { ?>	
 			<input name="visibility" value="Public" type="checkbox"><?php echo $mod_strings['LBL_PUBLIC']; ?>
@@ -281,19 +284,19 @@
 			</tr>		
 			</table>
 			<hr noshade size=1>
-			<table border=0 cellspacing=0 cellpadding=5 width=90% align=center bgcolor="#FFFFFF" align=center>
+			<table id="date_table" border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor="#FFFFFF" align=center>
 			<tr>
 			<td >
 				<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
 				<tr>
-				<td width=50% valign=top style="border-right:1px solid #dddddd">
-					<table border=0 cellspacing=0 cellpadding=2 width=90% align=center>
+				<td width=50% id="date_table_firsttd" valign=top style="border-right:1px solid #dddddd">
+					<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
 					<tr><td colspan=3 align="left"><b><?php echo $mod_strings['LBL_EVENTSTAT']?></b></td></tr>
 				        <tr><td colspan=3 align="left">
 						<?php echo  getTimeCombo($calendar_arr['calendar']->hour_format,'start');?>
 					</td></tr>
                                         <tr><td align="left">
-					<input type="text" name="date_start" id="jscal_field_date_start" class="textbox" style="width:90px" value="<?php echo getDisplayDate($calendar_arr['calendar']->date_time->get_formatted_date()) ?>"></td><td width=50% align="left"><img border=0 src="<?php echo $image_path ?>btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_date_start">
+					<input type="text" name="date_start" id="jscal_field_date_start" class="textbox" style="width:90px" onChange="dochange('jscal_field_date_start','jscal_field_due_date');" value="<?php echo getDisplayDate($calendar_arr['calendar']->date_time->get_formatted_date()) ?>"></td><td width=100% align="left"><img border=0 src="<?php echo $image_path?>btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_date_start">
 						<script type="text/javascript">
                 					Calendar.setup ({
 								inputField : "jscal_field_date_start", ifFormat : "<?php  echo $date_format; ?>", showsTime : false, button : "jscal_trigger_date_start", singleClick : true, step : 1
@@ -302,8 +305,8 @@
 					</td></tr>
 					</table>
 				</td>
-				<td width=50% valign=top >
-					<table border=0 cellspacing=0 cellpadding=2 width=90% align=center>
+				<td width=50% valign=top id="date_table_secondtd">
+					<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
 					<tr><td colspan=3 align="left"><b><?php echo $mod_strings['LBL_EVENTEDAT']?></b></td></tr>
 				        <tr><td colspan=3 align="left">
                                                 <?php echo getTimeCombo($calendar_arr['calendar']->hour_format,'end');?>
@@ -318,11 +321,26 @@
 					</td></tr>
 					</table>
 				</td>
+				<td width=34% valign=top style="display:none;border-left:1px solid #dddddd" id="date_table_thirdtd">
+					<table border=0 cellspacing=0 cellpadding=2 width=100% align=center>
+					<tr><td colspan=3 align="left"><b><input type="checkbox" name="followup"><?php echo $mod_strings['LBL_HOLDFOLLOWUP']?></b></td></tr>
+					<tr><td colspan=3 align="left">
+					<?php echo getTimeCombo($calendar_arr['calendar']->hour_format,'followup_start');?>
+					</td></tr>
+					<tr><td align="left">
+						<input type="text" name="followup_date" id="jscal_field_followup_date" class="textbox" style="width:90px" value="<?php echo getDisplayDate($calendar_arr['calendar']->date_time->get_formatted_date()) ?>"></td><td width=100% align="left"><img border=0 src="<?php echo $image_path?>btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_followup_date">
+						<script type="text/javascript">
+						Calendar.setup ({
+							inputField : "jscal_field_followup_date", ifFormat : "<?php echo $date_format; ?>", showsTime : false, button : "jscal_trigger_followup_date", singleClick : true, step : 1
+						})
+						</script>
+					</td></tr>
+					</table>
+				</td>
 				</tr>
 				</table></td>
 			</tr>
 			</table>
-
 
 			<!-- Alarm, Repeat, Invite starts-->
 			<br>
@@ -380,8 +398,8 @@
 								
 							</td>
 							<td width=20% align=center valign=top>
-								<input type=button value="<?php echo $mod_strings['LBL_ADD_BUTTON'] ?> >>" class="crm button small save" style="width:100%" onClick="addColumn()"><br>
-								<input type=button value="<< <?php echo $mod_strings['LBL_RMV_BUTTON'] ?> " class="crm button small cancel" style="width:100%" onClick="delColumn()">
+								<input type=button value="<?php echo $mod_strings['LBL_ADD_BUTTON'] ?> >>" class="crm button small save" style="width:100%" onClick="incUser('availableusers','selectedusers')"><br>
+								<input type=button value="<< <?php echo $mod_strings['LBL_RMV_BUTTON'] ?> " class="crm button small cancel" style="width:100%" onClick="rmvUser('selectedusers')">
 							</td>
 							<td width=40% align=center valign=top>
 								<select name="selectedusers" id="selectedusers" class=small size=5 multiple style="height:70px;width:100%">
@@ -573,7 +591,7 @@
 							<td><b><?php echo $mod_strings['LBL_RELATEDTO']?></b></td>
 							<td>
 								<input name="parent_id" value="" type="hidden">
-								<select name="parent_type" class="small" id="parent_type" onChange="document.EditView.parent_name.value='';">
+								<select name="parent_type" class="small" id="parent_type" onChange="document.EditView.parent_name.value='';document.EditView.parent_id.value=''">
 									<option value="Leads"><?php echo $app_strings['Leads']?></option>
 									<option value="Accounts"><?php echo $app_strings['Accounts']?></option>
 									<option value="Potentials"><?php echo $app_strings['Potentials']?></option>
@@ -592,8 +610,8 @@
 						<td><b><?php echo $app_strings['Contacts'] ?></b></td>
 							<td colspan="2">
 								<input name="contactidlist" id="contactidlist" value="" type="hidden">
-								<textarea rows="5" name="contactlist" readonly="readonly" class="calTxt"></textarea>&nbsp;
-								<input type="button" onclick="return window.open('index.php?module=Contacts&action=Popup&return_module=Calendar&popuptype=detailview&select=enable&form=EditView&form_submit=false','test','width=640,height=602,resizable=0,scrollbars=0');" class="crmButton small edit" name="selectcnt" value="<?php echo $mod_strings['LBL_SELECT_CONTACT'] ; ?>">
+								<textarea rows="5" name="contactlist" readonly="readonly" class="calTxt" id='parentid'></textarea>&nbsp;
+								<input type="button" onclick="selectContact('true','general',document.EditView);" class="crmButton small edit" name="selectcnt" value="<?php echo $mod_strings['LBL_SELECT_CONTACT'] ; ?>">
 							</td>
 						</tr>
 					</table>
@@ -620,22 +638,32 @@
   </form>
   </div>
 							 
-	<script language="JavaScript" type="text/JavaScript">
-setObjects();
-	</script>
-
 	<!-- Add Activity DIV stops-->
 
 <div id="eventcalAction" class="calAction" style="width:125px;" onMouseout="fninvsh('eventcalAction')" onMouseover="fnvshNrm('eventcalAction')">
 	<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
 		<tr>
 			<td>
-				<a href="" id="complete" onClick="fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_HELD']?></a>
-				<a href="" id="pending" onClick="fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_NOTHELD']?></a>
+				<?php
+				if(isPermitted("Calendar","EditView") == "yes")
+				{
+				?>
+					<?php if(getFieldVisibilityPermission('Events',$current_user->id,'eventstatus') == '0') { ?>
+						<a href="javascript:;" id="complete" onClick="fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_HELD']?></a>
+						<a href="javascript:;" id="pending" onClick="fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_NOTHELD']?></a>
+					<?php }?>		
 				<span style="border-top:1px dashed #CCCCCC;width:99%;display:block;"></span>
-				<a href="" id="postpone" onClick="fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_POSTPONE']?></a>
-				<a href="" id="changeowner" onClick="fnvshobj(this,'act_changeowner');fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_CHANGEOWNER']?></a>
+				<a href="javascript:;" id="postpone" onClick="fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_POSTPONE']?></a>
+				<a href="javascript:;" id="changeowner" onClick="fnvshobj(this,'act_changeowner');fninvsh('eventcalAction')" class="calMnu">- <?php echo $mod_strings['LBL_CHANGEOWNER']?></a>
+				<?php
+				}
+				if(isPermitted("Calendar","Delete") == "yes")	
+				{
+				?>
 				<a href="" id="actdelete" onclick ="fninvsh('eventcalAction');return confirm('Are you sure?');" class="calMnu">- <?php echo $mod_strings['LBL_DEL']?></a>
+				<?php
+				}
+				?>
 			</td>
 		</tr>
 	</table>
@@ -676,7 +704,7 @@
         </table>
 	<table border=0 cellspacing=0 cellpadding=5 width=95% bgcolor="#FFFFFF" >
 		<tr>
-                        <td width="20%" align="right"><b><?php echo $mod_strings['LBL_TODONAME'] ?></b></td>
+			<td width="20%" align="right"><b><font color="red">*</font><?php echo $mod_strings['LBL_TODONAME'] ?></b></td>
                         <td width="80%" align="left"><input name="task_subject" type="text" value="" class="textbox" style="width:70%"></td>
                 </tr>
 		<?php if(getFieldVisibilityPermission('Calendar',$current_user->id,'description') == '0') { ?>
@@ -735,9 +763,9 @@
 				<tr><td width=50% valign=top style="border-right:1px solid #dddddd">
 					<table border=0 cellspacing=0 cellpadding=2 width=95% align=center>
 						<tr><td colspan=3 align="left"><b><?php echo $mod_strings['LBL_TODODATETIME'] ?></b></td></tr>
-						<tr><td colspan=3 align="left"><?php echo getTimeCombo($calendar_arr['calendar']->hour_format,'start'); ?></td></tr>
+						<tr><td colspan=3 align="left"><?php echo getTimeCombo($calendar_arr['calendar']->hour_format,'start','','','',true); ?></td></tr>
 						<tr><td align="left">
-							<input type="text" name="task_date_start" id="task_date_start" class="textbox" style="width:90px" value="<?php echo getDisplayDate($calendar_arr['calendar']->date_time->get_formatted_date()) ?>" ></td><td width=100% align="left"><img border=0 src="<?php echo $image_path ?>btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_task_date_start">
+							<input type="text" name="task_date_start" id="task_date_start" class="textbox" style="width:90px" onChange="dochange('task_date_start','task_due_date');" value="<?php echo getDisplayDate($calendar_arr['calendar']->date_time->get_formatted_date()) ?>" ></td><td width=100% align="left"><img border=0 src="<?php echo $image_path ?>btnL3Calendar.gif" alt="Set date.." title="Set date.." id="jscal_trigger_task_date_start">
 						<script type="text/javascript">
 						Calendar.setup ({
 							inputField : "task_date_start", ifFormat : "<?php  echo $date_format; ?>", showsTime : false, button : "jscal_trigger_task_date_start", singleClick : true, step : 1
@@ -820,7 +848,7 @@
 			<td><b><?php echo $mod_strings['LBL_CONTACT_NAME'] ?></b></td>
 			<td colspan="2">
 				<input name="task_contact_name" id="contact_name" readonly type="text" class="calTxt" value=""><input name="task_contact_id" id="contact_id" type="hidden" value="">&nbsp;
-				<input type="button" onclick="return window.open('index.php?module=Contacts&action=Popup&html=Popup_picker&popuptype=specific&form=EditView','test','width=640,height=602,resizable=0,scrollbars=0');" class="crmButton small edit" name="selectcnt" value="<?php echo $mod_strings['LBL_SELECT_CONTACT'] ; ?>">
+				<input type="button" onclick="selectContact('false','task',document.createTodo);" class="crmButton small edit" name="selectcnt" value="<?php echo $mod_strings['LBL_SELECT_CONTACT'] ; ?>">
 			</td>
 			  </tr>
 			<?php } ?>
@@ -840,9 +868,9 @@
 	</td></tr></table>
   </form>
   <script>
-  	var fieldname = new Array('task_subject','task_date_start','task_time_start','taskstatus');
-	var fieldlabel = new Array('Subject','Date','Time','Status');
-	var fielddatatype = new Array('V~M','D~M~time_start','T~O','V~O');
+  	var fieldname = new Array('task_subject','task_date_start','task_time_start','task_due_date','taskstatus');
+	var fieldlabel = new Array('<?php echo $mod_strings['LBL_LIST_SUBJECT']?>','<?php echo $mod_strings['LBL_START_DATE']?>','<?php echo $mod_strings['LBL_TIME']?>','<?php echo $mod_strings['LBL_DUE_DATE']?>','<?php echo $mod_strings['LBL_STATUS']?>');
+	var fielddatatype = new Array('V~M','D~M~time_start','T~O','D~M~OTH~GE~date_start~Start Date & Time','V~O');
   </script>
   </div>
 
@@ -870,9 +898,14 @@
 	<td width="50%"><b><?php echo $app_strings['LBL_TRANSFER_OWNERSHIP']; ?></b></td>
 	        <td width="2%"><b>:</b></td>
         	<td width="48%">
-	        	<select name="activity_owner" id="activity_owner" class="detailedViewTextBox">
+                	<input type = "radio" name = "user_lead_owner"  onclick=checkgroup();  checked><?php echo $app_strings['LBL_USER'];?>&nbsp;
+                        <input type = "radio" name = "user_lead_owner" onclick=checkgroup(); ><?php echo $app_strings['LBL_GROUP'];?><br>
+                        <select name="lead_owner" id="lead_owner" class="detailedViewTextBox" style="display:block">
 				<?php echo getUserslist(); ?>
-		        </select>
+                        </select>
+                        <select name="lead_group_owner" id="lead_group_owner" class="detailedViewTextBox" style="display:none;">
+				<?php echo getGroupslist();?>
+                         </select>
         	</td>
 	</tr>
 	<tr><td colspan="3" style="border-bottom:1px dashed #CCCCCC;">&nbsp;</td></tr>
@@ -892,12 +925,28 @@
         <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
                 <tr>
                         <td>
-                                <a href="" id="taskcomplete" onClick="fninvsh('taskcalAction');" class="calMnu">- <?php echo $mod_strings['LBL_COMPLETED']?></a>
-                                <a href="" id="taskpending" onClick="fninvsh('taskcalAction');" class="calMnu">- <?php echo $mod_strings['LBL_DEFERRED']?></a>
+				<?php
+                                if(isPermitted("Calendar","EditView") == "yes")
+                                {
+                                ?>
+					<?php if(getFieldVisibilityPermission('Calendar',$current_user->id,'taskstatus') == '0') { ?>
+	                                	<a href="" id="taskcomplete" onClick="fninvsh('taskcalAction');" class="calMnu">- <?php echo $mod_strings['LBL_COMPLETED']?></a>
+        	                        	<a href="" id="taskpending" onClick="fninvsh('taskcalAction');" class="calMnu">- <?php echo $mod_strings['LBL_DEFERRED']?></a>
+					<?php } ?>		
+						
                                 <span style="border-top:1px dashed #CCCCCC;width:99%;display:block;"></span>
                                 <a href="" id="taskpostpone" onClick="fninvsh('taskcalAction');" class="calMnu">- <?php echo $mod_strings['LBL_POSTPONE']?></a>
                                 <a href="" id="taskchangeowner" onClick="fnvshobj(this,'act_changeowner'); fninvsh('taskcalAction');" class="calMnu">- <?php echo $mod_strings['LBL_CHANGEOWNER']?></a>
+                                <?php
+                                }
+                                if(isPermitted("Calendar","Delete") == "yes")
+                                {
+                                ?>
                                 <a href="" id="taskactdelete" onClick ="fninvsh('taskcalAction');return confirm('Are you sure?');" class="calMnu">- <?php echo $mod_strings['LBL_DEL']?></a>
+                                <?php
+                                }
+                                ?>
+
                         </td>
                 </tr>
         </table>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/calendarLayout.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/calendarLayout.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/calendarLayout.php Mon Apr 16 12:27:44 2007
@@ -113,7 +113,7 @@
  */
 function get_mini_calendar(& $cal)
 {
-	global $current_user,$adb,$cal_log;
+	global $current_user,$adb,$cal_log,$mod_strings;
 	$category = getParentTab();
 	$cal_log->debug('Entering get_mini_calendar() method...');
 	$count = 0;
@@ -133,7 +133,7 @@
 	                     </td></tr>";
 	$minical .= "<tr class='hdrNameBg'>";
 	//To display days in week 
-	$minical .= '<th width="12%">Week</th>';
+	$minical .= '<th width="12%">'.$mod_strings['LBL_WEEK'].'</th>';
 	for ($i = 0; $i < 7; $i ++)
         {
                 $weekdays_row = $cal['calendar']->month_array[$cal['calendar']->slices[$i]];
@@ -263,8 +263,8 @@
 	global $current_user,$app_strings;
         $date_format = $current_user->date_format;
 	$format = $cal_arr['calendar']->hour_format;
-	$hour_startat = convertTime2UserSelectedFmt($format,$cal_arr['calendar']->day_start_hour,false); 
-	$hour_endat = convertTime2UserSelectedFmt($format,($cal_arr['calendar']->day_start_hour+1),false);
+	$hour_startat = timeString(array('hour'=>date('H:i'),'minute'=>0),'24');
+        $hour_endat = timeString(array('hour'=>date('H:i',(time() + (60 * 60))),'minute'=>0),'24');	
 	$time_arr = getaddEventPopupTime($hour_startat,$hour_endat,$format);
 	$temp_ts = $cal_arr['calendar']->date_time->ts;
 	//To get date in user selected format
@@ -288,15 +288,15 @@
 			{
 				$headerdata .="<tr><td>&nbsp;</td>";
 			}
-			$headerdata .="<td align='center' width='53%'>";
+			$headerdata .="<td align='center' width='53%'><span id='total_activities'>";
 	$headerdata .= getEventTodoInfo($cal_arr,'listcnt'); 
-	$headerdata .= "	</td>
+	$headerdata .= "</span></td>
 				<td align='center' width='30%'><table border=0 cellspacing=0 cellpadding=2><tr><td class=small><b>".$mod_strings['LBL_VIEW']." : </b></td><td>";
 	$view_options = getEventViewOption($cal_arr,$viewBox);
-	$headerdata .=$view_options."</td></tr></form></table>
+	$headerdata .=$view_options."</td></tr></table>
 				</td>
 			</tr>
-		</table>";
+		</table></form>";
 	echo $headerdata;	
 	$cal_log->debug("Exiting get_cal_header_data() method...");
 }
@@ -357,8 +357,7 @@
 	}
 	else
 		die("view is not defined");
-	$view .="</select>
-		</form>";
+	$view .="</select>";
 	$cal_log->debug("Exiting getEventViewOption() method...");
 	return $view;
 }
@@ -657,7 +656,6 @@
  */
 function getDayViewLayout(& $cal)
 {
-	//echo '<pre>';print_r($cal);echo '</pre>';
 	global $current_user,$app_strings,$cal_log,$adb;
 	$no_of_rows = 1;
 	$cal_log->debug("Entering getDayViewLayout() method...");
@@ -686,39 +684,11 @@
 	}
 	for($i=$day_start_hour;$i<=$day_end_hour;$i++)
 	{
-		
-		if($cal['calendar']->hour_format == 'am/pm')
-		{
-			if($i == 12)
-			{
-				$hour = $i;
-				$sub_str = 'pm';
-			}
-			elseif($i>12)
-			{
-				$hour = $i - 12;
-				$sub_str = 'pm';
-			}
-			else
-			{
-				if($i == 0)
-					$hour = 12;
-				else
-					$hour = $i;
-				$sub_str = 'am';
-			}
-			
-		}
-		else
-		{
-			$hour = $i;
-			if($hour <= 9 && strlen(trim($hour)) < 2)
-				$hour = "0".$hour;
-			$sub_str = ':00';
-		}
+		$time = array('hour'=>$i,'minute'=>0);
+		$sub_str = timeString($time,$format);
 		$y = $i+1;
-		$hour_startat = convertTime2UserSelectedFmt($format,$i,false);
-		$hour_endat = convertTime2UserSelectedFmt($format,$y,false);
+		$hour_startat = timeString(array('hour'=>$i,'minute'=>0),'24');
+		$hour_endat = timeString(array('hour'=>$y,'minute'=>0),'24');
 		$time_arr = getaddEventPopupTime($hour_startat,$hour_endat,$format);
 		$temp_ts = $cal['calendar']->date_time->ts;
 		$sttemp_date = (($date_format == 'dd-mm-yyyy')?(date('d-m-Y',$temp_ts)):(($date_format== 'mm-dd-yyyy')?(date('m-d-Y',$temp_ts)):(($date_format == 'yyyy-mm-dd')?(date('Y-m-d', $temp_ts)):(''))));
@@ -736,7 +706,7 @@
 		if(isPermitted("Calendar","EditView") == "yes")
 		              $js_string = 'onClick="fnvshobj(this,\'addEvent\'); gshow(\'addEvent\',\'call\',\''.$sttemp_date.'\',\''.$endtemp_date.'\',\''.$time_arr['starthour'].'\',\''.$time_arr['startmin'].'\',\''.$time_arr['startfmt'].'\',\''.$time_arr['endhour'].'\',\''.$time_arr['endmin'].'\',\''.$time_arr['endfmt'].'\',\'hourview\',\'event\')"';
 		$dayview_layout .= '<tr>
-					<td style="cursor:pointer;" class="lvtCol" valign=top height="75"  width="10%" '.$js_string.'>'.$hour.''.$sub_str.'</td>';
+					<td style="cursor:pointer;" class="lvtCol" valign=top height="75"  width="10%" '.$js_string.'>'.$sub_str.'</td>';
 		//To display events in Dayview
 		$dayview_layout .= getdayEventLayer($cal,$cal['calendar']->slices[$i],$no_of_rows);
 		$dayview_layout .= '</tr>';
@@ -789,44 +759,17 @@
 	for($i=$day_start_hour;$i<=$day_end_hour;$i++)
 	{
 		$count = $i;
-		$hour_startat = convertTime2UserSelectedFmt($format,$i,false);
-	        $hour_endat = convertTime2UserSelectedFmt($format,($i+1),false);
+		$hour_startat = timeString(array('hour'=>$i,'minute'=>0),'24');
+		$hour_endat = timeString(array('hour'=>($i+1),'minute'=>0),'24');
 		$time_arr = getaddEventPopupTime($hour_startat,$hour_endat,$format);
 		$weekview_layout .= '<tr>';
 		for ($column=1;$column<=1;$column++)
         	{
-        	       	if($cal['calendar']->hour_format == 'am/pm')
-                	{
-                       		if($i == 12)
-                       		{
-                               		$hour = $i;
-	                               	$sub_str = 'pm';
-	                        }
-        	       	        elseif($i>12)
-                        	{
-                       	        	$hour = $i - 12;
-	                       	        $sub_str = 'pm';
-	                        }
-        	       	        else
-                        	{
-					if($i == 0)
-						$hour = 12;
-					else
-                       	        		$hour = $i;
-	                       	        $sub_str = 'am';
-        	                }
-
-       	        	}
-       			else
-           		{
-                       		$hour = $i;
-				if($hour <= 9 && strlen(trim($hour)) < 2)
-		                        $hour = "0".$hour;
-                        	$sub_str = ':00';
-       	        	}
-
+			$time = array('hour'=>$i,'minute'=>0);
+			$sub_str = timeString($time,$format);
+			
 			$weekview_layout .= '<td style="border-top: 1px solid rgb(239, 239, 239); background-color: rgb(234, 234, 234); height: 40px;" valign="top" width="12%">';
-			$weekview_layout .=$hour.''.$sub_str;
+			$weekview_layout .=$sub_str;
 	                $weekview_layout .= '</td>';
 		}
 		for ($column=0;$column<=6;$column++)
@@ -879,8 +822,8 @@
                 $rows = 6;
         }
 	$format = $cal['calendar']->hour_format;
-        $hour_startat = convertTime2UserSelectedFmt($format,$cal['calendar']->day_start_hour,false);
-        $hour_endat = convertTime2UserSelectedFmt($format,($cal['calendar']->day_start_hour+1),false);
+	$hour_startat = timeString(array('hour'=>date('H:i'),'minute'=>0),'24');
+        $hour_endat = timeString(array('hour'=>date('H:i',(time() + (60 * 60))),'minute'=>0),'24');
 	$time_arr = getaddEventPopupTime($hour_startat,$hour_endat,$format);
 	$monthview_layout = '';
 	$monthview_layout .= '<table class="calDayHour" style="background-color: rgb(218, 218, 218);" border="0" cellpadding="5" cellspacing="1" width="98%"><tr>';
@@ -1084,8 +1027,6 @@
 			$id = $act[$i]->record;
 			if(strlen($subject)>25)
 				$subject = substr($subject,0,25)."...";
-			$start_time = $act[$i]->start_time->hour.':'.$act[$i]->start_time->minute;
-			$end_time = $act[$i]->end_time->hour.':'.$act[$i]->end_time->minute;
 			$format = $cal['calendar']->hour_format;
 			$duration_hour = $act[$i]->duration_hour;
 			$duration_min =$act[$i]->duration_minute;
@@ -1098,24 +1039,24 @@
 				$rowspan = $duration_hour;
 			}
 			$row_cnt = $rowspan;
-			//$st_end_time = convertStEdTime2UserSelectedFmt($format,$start_time,$duration_hour,$duration_min);
-			//$start_hour = $st_end_time['starttime'];
-			//$end_hour = $st_end_time['endtime'];
-			$value = getaddEventPopupTime($start_time,$end_time,$format);
-			$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
-			$end_hour = $value['endhour'] .':'.$value['endmin'].''.$value['endfmt'];
+			$start_hour = timeString($act[$i]->start_time,$format);
+			$end_hour = timeString($act[$i]->end_time,$format);
 			$account_name = $act[$i]->accountname;
 			$eventstatus = $act[$i]->eventstatus;
-			$shared = $act[$i]->shared;
 			$color = $act[$i]->color;
 			$image = $cal['IMAGE_PATH'].''.$act[$i]->image_name;
+			if($act[$i]->recurring)
+				$recurring = '<img src="'.$cal['IMAGE_PATH'].''.$act[$i]->recurring.'" align="middle" border="0"></img>';
+			else
+				$recurring = '&nbsp;';
 			$height = $rowspan * 75;
 			$javacript_str = '';
+			$idShared = "normal"; if($act[$i]->shared) $idShared = "shared";	
 			/*if($eventstatus != 'Held')
 			{*/
-				if(isPermitted("Calendar","EditView") == "yes")
+				if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
 					$javacript_str = 'onMouseOver="cal_show(\''.$arrow_img_name.'\');" onMouseOut="fnHide_Event(\''.$arrow_img_name.'\');"';
-				$action_str = '<img src="'.$cal['IMAGE_PATH'].'cal_event.jpg" id="'.$arrow_img_name.'" style="visibility: hidden;" onClick="getcalAction(this,\'eventcalAction\','.$id.',\''.$cal['view'].'\',\''.$cal['calendar']->date_time->hour.'\',\''.$cal['calendar']->date_time->day.'\',\''.$cal['calendar']->date_time->month.'\',\''.$cal['calendar']->date_time->year.'\',\'event\');" align="middle" border="0">';
+				$action_str = '<img src="'.$cal['IMAGE_PATH'].'cal_event.jpg" id="'.$arrow_img_name.'" style="visibility: hidden;" onClick="getcalAction(this,\'eventcalAction\','.$id.',\''.$cal['view'].'\',\''.$cal['calendar']->date_time->hour.'\',\''.$cal['calendar']->date_time->get_formatted_date().'\',\'event\',\''.$idShared.'\');" align="middle" border="0">';
 			/*}
 			else
 			{
@@ -1126,18 +1067,18 @@
 			$eventlayer .= '<div id="event_'.$cal['calendar']->day_slice[$slice]->start_time->hour.'_'.$i.'" class="event" style="height:'.$height.'px;" '.$javacript_str.'>
 			<table border="0" cellpadding="1" cellspacing="0" width="100%">
 				<tr>
-					<td><img src="'.$image.'" align="middle" border="0"></td>
-					<td width="100%"><b>'.$start_hour.' - '.$end_hour.'</b></td>
-				</tr>';
-			$eventlayer .= '<tr><td>';
-			if($shared)
+					<td width="10%" align="center"><img src="'.$image.'" align="middle" border="0"></td>
+					<td width="90%"><b>'.$start_hour.' - '.$end_hour.'</b></td></tr>';
+			$eventlayer .= '<tr><td align="center">'.$recurring;
+			$eventlayer .= '</td>
+				<td><a href="index.php?action=DetailView&module=Calendar&record='.$id.'&activity_mode=Events&viewtype=calendar&parenttab='.$category.'"><span class="orgTab">'.$subject.'</span></a></td>
+				</tr>
+				<tr><td align="center">';
+			if($act[$i]->shared)
 				$eventlayer .= '<img src="'.$cal['IMAGE_PATH'].'cal12x12Shared.gif" align="middle" border="0">';
 			else
 				$eventlayer .= '&nbsp;';
-			$eventlayer .= '</td>
-				<td><a href="index.php?action=DetailView&module=Calendar&record='.$id.'&activity_mode=Events&viewtype=calendar&parenttab='.$category.'"><span class="orgTab">'.$subject.'</span></a></td>
-				</tr>
-				<tr><td>'.$action_str.'</td><td>('.$user.' | '.$mod_strings[$eventstatus].' | '.$mod_strings[$priority].')</td>
+			$eventlayer .= '</td><td>('.$user.' | '.$mod_strings[$eventstatus].' | '.$mod_strings[$priority].')</td></tr><tr><td align="center">'.$action_str.'</td><td>&nbsp;</td></tr>
 			</table>
 			
 			</div>';
@@ -1180,46 +1121,45 @@
 			if(strlen($subject)>25)
 				$subject = substr($subject,0,25)."...";
 			$format = $cal['calendar']->hour_format;
-                        $duration_hour = $act[$i]->duration_hour;
-                        $duration_min = $act[$i]->duration_minute;
-			$start_time = $act[$i]->start_time->hour.':'.$act[$i]->start_time->minute;
-			$end_time = $act[$i]->end_time->hour.':'.$act[$i]->end_time->minute;
-                        //$st_end_time = convertStEdTime2UserSelectedFmt($format,$start_time,$duration_hour,$duration_min);
-			//$start_hour = $st_end_time['starttime'];
-                        //$end_hour = $st_end_time['endtime'];
-			$value = getaddEventPopupTime($start_time,$end_time,$format);
-			$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
-			$end_hour = $value['endhour'] .':'.$value['endmin'].''.$value['endfmt'];
+			$start_hour = timeString($act[$i]->start_time,$format);
+                        $end_hour = timeString($act[$i]->end_time,$format);
                         $account_name = $act[$i]->accountname;
 			$eventstatus = $act[$i]->eventstatus;
-			$shared = $act[$i]->shared;
 			$user = $act[$i]->owner;
 			$priority = $act[$i]->priority;
                         $image = $cal['IMAGE_PATH'].''.$act[$i]->image_name;
+			$idShared = "normal"; if($act[$i]->shared) $idShared = "shared";
+			if($act[$i]->recurring)
+				$recurring = '<img src="'.$cal['IMAGE_PATH'].''.$act[$i]->recurring.'" align="middle" border="0"></img>';
+			else
+				$recurring = '&nbsp;';
                         $color = $act[$i]->color;
-			if(isPermitted("Calendar","EditView") == "yes")
+			if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
 				$javacript_str = 'onMouseOver="cal_show(\''.$arrow_img_name.'\');" onMouseOut="fnHide_Event(\''.$arrow_img_name.'\');"';
-			$action_str = '<img src="'.$cal['IMAGE_PATH'].'cal_event.jpg" id="'.$arrow_img_name.'" style="visibility: hidden;" onClick="getcalAction(this,\'eventcalAction\','.$id.',\''.$cal['view'].'\',\''.$cal['calendar']->date_time->hour.'\',\''.$cal['calendar']->date_time->day.'\',\''.$cal['calendar']->date_time->month.'\',\''.$cal['calendar']->date_time->year.'\',\'event\');" align="middle" border="0">';
+			$action_str = '<img src="'.$cal['IMAGE_PATH'].'cal_event.jpg" id="'.$arrow_img_name.'" style="visibility: hidden;" onClick="getcalAction(this,\'eventcalAction\','.$id.',\''.$cal['view'].'\',\''.$cal['calendar']->date_time->hour.'\',\''.$cal['calendar']->date_time->get_formatted_date().'\',\'event\',\''.$idShared.'\');" align="middle" border="0">';
 												 
 			$eventlayer .='<div class ="event" '.$javacript_str.' id="event_'.$cal['calendar']->week_slice[$slice]->start_time->get_formatted_date().'_'.$i.'">
 			<table border="0" cellpadding="1" cellspacing="0" width="100%">
 				<tr>
-					<td><img src="'.$image.'" align="middle" border="0"></td>
-					<td width="100%"><b>'.$start_hour.' - '.$end_hour.'</b></td>
+					<td width="10%" align="center"><img src="'.$image.'" align="middle" border="0"></td>
+					<td width="90%"><b>'.$start_hour.' - '.$end_hour.'</b></td>
 				</tr>
 				<tr>
-					<td>';
-			if($shared)
+					<td align="center">'.$recurring;
+
+			$eventlayer .= '</td>
+					<td><a href="index.php?action=DetailView&module=Calendar&record='.$id.'&activity_mode=Events&viewtype=calendar&parenttab='.$category.'"><span class="orgTab">'.$subject.'</span></a></td>
+				</tr>
+				<tr><td align="center">';
+			if($act[$i]->shared)
 				$eventlayer .= '<img src="'.$cal['IMAGE_PATH'].'cal12x12Shared.gif" align="middle" border="0">';
 			else
 				$eventlayer .= '&nbsp;';
-			$eventlayer .= '	
-				</td>
-					<td><a href="index.php?action=DetailView&module=Calendar&record='.$id.'&activity_mode=Events&viewtype=calendar&parenttab='.$category.'"><span class="orgTab">'.$subject.'</span></a></td>
-				</tr>
-				<tr><td>'.$action_str.'</td><td>('.$user.' | '.$eventstatus.' | '.$priority.')</td>
+			$eventlayer .= '</td><td>('.$user.' | '.$eventstatus.' | '.$priority.')</td></tr>
+			<tr><td align="center">'.$action_str.'</td><td>&nbsp;</td></tr>
+
 			</table>
-		        </div><br>';
+			</div><br>';
                 }
 		$cal_log->debug("Exiting getweekEventLayer() method...");
 		return $eventlayer;
@@ -1261,27 +1201,14 @@
                         $subject = $act[$i]->subject;
                         if(strlen($subject)>10)
                                 $subject = substr($subject,0,10)."...";
-			$start_time = $act[$i]->start_time->hour.':'.$act[$i]->start_time->minute;
-			$end_time = $act[$i]->end_time->hour.':'.$act[$i]->end_time->minute;
 			$format = $cal['calendar']->hour_format;
-                        $duration_hour = $act[$i]->duration_hour;
-                        $duration_min = $act[$i]->duration_minute;
-                        //$st_end_time = convertStEdTime2UserSelectedFmt($format,$start_time,$duration_hour,$duration_min);
-                        //$start_hour = $st_end_time['starttime'];
-                        //$end_hour = $st_end_time['endtime'];
-			$value = getaddEventPopupTime($start_time,$end_time,$format);
-			$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
-			$end_hour = $value['endhour'] .':'.$value['endmin'].''.$value['endfmt'];
+			$start_hour = timeString($act[$i]->start_time,$format);
+                        $end_hour = timeString($act[$i]->end_time,$format);
                         $account_name = $act[$i]->accountname;
                         $image = $cal['IMAGE_PATH'].''.$act[$i]->image_name;
 			$color = $act[$i]->color;
 			$eventlayer .='<div class ="event" id="event_'.$cal['calendar']->month_array[$slice]->start_time->hour.'_'.$i.'">
-					<table border="0" cellpadding="1" cellspacing="0" width="100%">
-						<tr>
-							<td><img src="'.$image.'" align="middle" border="0"></td>
-							<td width="100%"><a href="index.php?action=DetailView&module=Calendar&record='.$id.'&activity_mode=Events&viewtype=calendar&parenttab='.$category.'"><span class="orgTab"><small>'.$start_hour.' - '.$end_hour.'</small></span></td>
-						</tr>
-					</table>
+			<nobr><img src="'.$image.'" border="0"></img>&nbsp;<a href="index.php?action=DetailView&module=Calendar&record='.$id.'&activity_mode=Events&viewtype=calendar&parenttab='.$category.'"><span class="orgTab"><small>'.$start_hour.' - '.$end_hour.'</small></span></nobr>
                                 </div><br>';
                 }
 		if($remin_list != null)
@@ -1314,7 +1241,7 @@
         require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
 	$cal_log->debug("Entering getEventList() method...");
 	$shared_ids = getSharedCalendarId($current_user->id);
-	$query = "SELECT vtiger_groups.groupname, vtiger_users.user_name,
+	$query = "SELECT vtiger_groups.groupname, vtiger_users.user_name,vtiger_crmentity.smownerid,
        		vtiger_activity.* FROM vtiger_activity
 		INNER JOIN vtiger_crmentity
 			ON vtiger_crmentity.crmid = vtiger_activity.activityid
@@ -1328,11 +1255,13 @@
 			ON vtiger_recurringevents.activityid = vtiger_activity.activityid
 		WHERE vtiger_crmentity.deleted = 0
 			AND (vtiger_activity.activitytype = 'Meeting' OR vtiger_activity.activitytype = 'Call')
-			AND (vtiger_activity.date_start BETWEEN '".$start_date."' AND '".$end_date."'
-				OR vtiger_recurringevents.recurringdate BETWEEN '".$start_date."' AND '".$end_date."') ";
+			AND (((vtiger_activity.date_start between '".$start_date."' AND  '".$end_date."') OR (vtiger_activity.due_date between '". $start_date."' AND '".$end_date."') OR (vtiger_activity.date_start<'".$start_date."' and vtiger_activity.due_date>'".$end_date."') AND (vtiger_recurringevents.recurringdate is NULL))
+			OR (vtiger_recurringevents.recurringdate BETWEEN '".$start_date."' AND '".$end_date."')) ";
 	if($info != '')
 	{
-		$com_q = " AND vtiger_crmentity.smownerid = ".$current_user->id."
+		$groupids = fetchUserGroupids($current_user->id);
+		$com_q = " AND (vtiger_crmentity.smownerid = ".$current_user->id."
+				OR vtiger_groups.groupid in (".$groupids."))
 			GROUP BY vtiger_activity.activityid";
 		$pending_query = $query." AND (vtiger_activity.eventstatus = 'Planned')".$com_q;
 		$total_q =  $query."".$com_q;
@@ -1370,31 +1299,33 @@
 		$image_tag = "";
 		$contact_data = "";
 		$more_link = "";
-		$duration_hour = $adb->query_result($result,$i,"duration_hours");
-                $duration_min = $adb->query_result($result,$i,"duration_minutes");
 		$start_time = $adb->query_result($result,$i,"time_start");
 		$end_time = $adb->query_result($result,$i,"time_end");
 		$format = $calendar['calendar']->hour_format;
-		//$st_end_time = convertStEdTime2UserSelectedFmt($format,$start_time,$duration_hour,$duration_min);
 		$value = getaddEventPopupTime($start_time,$end_time,$format);
 		$start_hour = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
 		$end_hour = $value['endhour'] .':'.$value['endmin'].''.$value['endfmt'];
-		if($calendar['view'] == 'day')
-		{
-			$element['starttime'] = $start_hour;
-                	$element['endtime'] = $end_hour;
-		}
-		else
-		{
-			$date_start = $adb->query_result($result,$i,"date_start");
-			$due_date = $adb->query_result($result,$i,"due_date");
-			$element['starttime'] = getDisplayDate($date_start);
-			$element['endtime'] = getDisplayDate($due_date);
-		}
+		$date_start = $adb->query_result($result,$i,"date_start");
+		$due_date = $adb->query_result($result,$i,"due_date");
+		$element['starttime'] = getDisplayDate($date_start).' '.$start_hour;
+		$element['endtime'] = getDisplayDate($due_date).' '.$end_hour;
 		$contact_id = $adb->query_result($result,$i,"contactid");
 		$id = $adb->query_result($result,$i,"activityid");
 		$subject = $adb->query_result($result,$i,"subject");
 		$eventstatus = $adb->query_result($result,$i,"eventstatus");
+		$assignedto = $adb->query_result($result,$i,"user_name");
+		$userid = $adb->query_result($result,$i,"smownerid");
+		$idShared = "normal";
+		if(!empty($assignedto) && $userid != $current_user->id && $adb->query_result($result,$i,"visibility") == "Public")
+		{
+			$que = "select * from vtiger_sharedcalendar where sharedid=".$current_user->id." and userid=".$userid;
+			$row = $adb->query($que);
+			$no = $adb->getRowCount($row);
+			if($no > 0) $idShared = "shared";
+			else  $idShared = "normal";
+				
+
+		}
                 if(strlen($subject)>25)
 	                $subject = substr($subject,0,25)."...";
 		if($contact_id != '')
@@ -1410,17 +1341,16 @@
 			$image_tag = "<img src='".$calendar['IMAGE_PATH']."Meetings.gif' align='middle'>&nbsp;".$app_strings['Meeting'];
         	$element['eventtype'] = $image_tag;
 		$element['eventdetail'] = $contact_data." ".$subject."&nbsp;".$more_link;
-		if(isPermitted("Calendar","EditView") == "yes")
-			$element['action'] ="<img onClick='getcalAction(this,\"eventcalAction\",".$id.",\"".$calendar['view']."\",\"".$calendar['calendar']->date_time->hour."\",\"".$calendar['calendar']->date_time->day."\",\"".$calendar['calendar']->date_time->month."\",\"".$calendar['calendar']->date_time->year."\",\"event\");' src='".$calendar['IMAGE_PATH']."cal_event.jpg' border='0'>";
-		else
-			$element['action'] ="&nbsp;";
+		$element['relatedto']= getRelatedTo('Calendar',$result,$i);
+		if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete")=="yes")
+			$element['action'] ="<img onClick='getcalAction(this,\"eventcalAction\",".$id.",\"".$calendar['view']."\",\"".$calendar['calendar']->date_time->hour."\",\"".$calendar['calendar']->date_time->get_formatted_date()."\",\"event\",\"".$idShared."\");' src='".$calendar['IMAGE_PATH']."cal_event.jpg' border='0'>";
         	$element['status'] = $mod_strings[$adb->query_result($result,$i,"eventstatus")];
-		$assignedto = $adb->query_result($result,$i,"user_name");
 		if(!empty($assignedto))
 			$element['assignedto'] = $assignedto;
 		else
 			$element['assignedto'] = $adb->query_result($result,$i,"groupname");
 	$Entries[] = $element;
+	
 	}
 	$cal_log->debug("Exiting getEventList() method...");
 	return $Entries;
@@ -1464,7 +1394,7 @@
 		$com_q = " AND vtiger_crmentity.smownerid = ".$current_user->id;
                 $pending_query = $query." AND (vtiger_activity.status != 'Completed')".$com_q;
 		$total_q =  $query."".$com_q;
-  		if( $adb->dbType == "pgsql")
+		if( $adb->dbType == "pgsql")
 		{
  		    $pending_query = fixPostgresQuery( $pending_query, $log, 0);
 		    $total_q = fixPostgresQuery( $total_q, $log, 0);
@@ -1493,12 +1423,13 @@
         $rows = $adb->num_rows($result);
 	for($i=0;$i<$rows;$i++)
         {
+		
                 $element = Array();
+		$contact_name = '';
                 $element['no'] = $i+1;
                 $more_link = "";
                 $start_time = $adb->query_result($result,$i,"time_start");
                 $format = $calendar['calendar']->hour_format;
-                //$st_end_time = convertStEdTime2UserSelectedFmt($format,$start_time);
 		$value = getaddEventPopupTime($start_time,$start_time,$format);
                 $element['starttime'] = $value['starthour'].':'.$value['startmin'].''.$value['startfmt'];
 		$date_start = $adb->query_result($result,$i,"date_start");
@@ -1509,14 +1440,20 @@
 
                 $id = $adb->query_result($result,$i,"activityid");
                 $subject = $adb->query_result($result,$i,"subject");
+		$contact_id = $adb->query_result($result,$i,"contactid");
+		if($contact_id!='')
+		{
+			$contact_name = getContactName($contact_id);
+		}
+		
 		$status = $adb->query_result($result,$i,"status");
 		$more_link = "<a href='index.php?action=DetailView&module=Calendar&record=".$id."&activity_mode=Task&viewtype=calendar&parenttab=".$category."' class='webMnu'>".$subject."</a>";
 		$element['tododetail'] = $more_link;
+		$element['task_relatedto'] = getRelatedTo('Calendar',$result,$i); 
+		$element['task_contact'] = "<a href=\"index.php?module=Contacts&action=DetailView&record=".$contact_id."\">".$contact_name."</a>"; 
 		$element['status'] = $adb->query_result($result,$i,"status");
-		if(isPermitted("Calendar","EditView") == "yes")
-			$element['action'] ="<img onClick='getcalAction(this,\"taskcalAction\",".$id.",\"".$calendar['view']."\",\"".$calendar['calendar']->date_time->hour."\",\"".$calendar['calendar']->date_time->day."\",\"".$calendar['calendar']->date_time->month."\",\"".$calendar['calendar']->date_time->year."\",\"todo\");' src='".$calendar['IMAGE_PATH']."cal_event.jpg' border='0'>";
-		else
-			$element['action'] ="&nbsp;";
+		if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+			$element['action'] ="<img onClick='getcalAction(this,\"taskcalAction\",".$id.",\"".$calendar['view']."\",\"".$calendar['calendar']->date_time->hour."\",\"".$calendar['calendar']->date_time->get_formatted_date()."\",\"todo\",\"normal\");' src='".$calendar['IMAGE_PATH']."cal_event.jpg' border='0'>";
 		$assignedto = $adb->query_result($result,$i,"user_name");
 		if(!empty($assignedto))
 			$element['assignedto'] = $assignedto;
@@ -1565,8 +1502,8 @@
 	$cal_log->debug("Entering constructEventListView() method...");
 	$format = $cal['calendar']->hour_format;
 	$date_format = $current_user->date_format;
-	$hour_startat = convertTime2UserSelectedFmt($format,$cal['calendar']->day_start_hour,false);
-	$hour_endat = convertTime2UserSelectedFmt($format,($cal['calendar']->day_start_hour+1),false);
+	$hour_startat = timeString(array('hour'=>date('H:i'),'minute'=>0),'24');
+        $hour_endat = timeString(array('hour'=>date('H:i',(time() + (60 * 60))),'minute'=>0),'24');
 	$time_arr = getaddEventPopupTime($hour_startat,$hour_endat,$format);
 	$temp_ts = $cal['calendar']->date_time->ts;
 	//to get date in user selected date format
@@ -1579,36 +1516,37 @@
 		$endtemp_date = (($date_format == 'dd-mm-yyyy')?(date('d-m-Y',$endtemp_ts)):(($date_format== 'mm-dd-yyyy')?(date('m-d-Y',$endtemp_ts)):(($date_format == 'yyyy-mm-dd')?(date('Y-m-d', $endtemp_ts)):(''))));
 	}
 	$list_view = "";
-	if($cal['view'] == 'day')
-	{
-		$start_datetime = $mod_strings['LBL_APP_START_TIME'];
-		$end_datetime = $mod_strings['LBL_APP_END_TIME'];
-	}
-	else
-	{
-		 $start_datetime = $mod_strings['LBL_APP_START_DATE'];
-		 $end_datetime = $mod_strings['LBL_APP_END_DATE'];
-				 
-	}
+	$start_datetime = $app_strings['LBL_START_DATE_TIME'];
+	$end_datetime = $app_strings['LBL_END_DATE_TIME'];
 	//Events listview header labels
 	$header = Array('0'=>'#',
                         '1'=>$start_datetime,
                         '2'=>$end_datetime,
                         '3'=>$mod_strings['LBL_EVENTTYPE'],
-                        '4'=>$mod_strings['LBL_EVTDTL'],
-                        '5'=>$mod_strings['LBL_ACTION'],
-                        '6'=>$mod_strings['LBL_STATUS'],
-			'7'=>$mod_strings['LBL_ASSINGEDTO'],
+                        '4'=>$mod_strings['LBL_EVENTDETAILS'],
+			'5'=>$mod_strings['LBL_RELATEDTO'],
                         );
+                                if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+                                {
+                                        array_push($header,$mod_strings['LBL_ACTION']);
+                                }
+
+                                array_push($header,$mod_strings['LBL_STATUS'],$mod_strings['LBL_ASSINGEDTO']);
         $header_width = Array('0'=>'5%',
                               '1'=>'10%',
                               '2'=>'10%',
                               '3'=>'10%',
                               '4'=>'28%',
-                              '5'=>'10%',
-                              '6'=>'10%',
-			      '7'=>'15%'
+			      '5'=>'15%',	
                              );
+
+                              if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+                              {
+
+                                        array_push($header_width,'10%');
+                              }
+                              array_push($header_width,'10%','15%');
+
         $list_view .="<table style='background-color: rgb(204, 204, 204);' class='small' align='center' border='0' cellpadding='5' cellspacing='1' width='98%'>
                         <tr>";
 	$header_rows = count($header);
@@ -1632,7 +1570,7 @@
 	}
 	else
 	{
-		$list_view .="<tr><td style='background-color:#efefef;height:340px' align='center' colspan='8'>
+		$list_view .="<tr><td style='background-color:#efefef;height:340px' align='center' colspan='9'>
 				";
 			$list_view .="<div style='border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 45%; position: relative; z-index: 5000;'>
 					<table border='0' cellpadding='5' cellspacing='0' width='98%'>
@@ -1677,8 +1615,8 @@
         global $current_user,$app_strings;
         $date_format = $current_user->date_format;
         $format = $cal['calendar']->hour_format;
-        $hour_startat = convertTime2UserSelectedFmt($format,$cal['calendar']->day_start_hour,false);
-        $hour_endat = convertTime2UserSelectedFmt($format,($cal['calendar']->day_start_hour+1),false);
+	$hour_startat = timeString(array('hour'=>date('H:i'),'minute'=>0),'24');
+        $hour_endat = timeString(array('hour'=>date('H:i',(time() + (60 * 60))),'minute'=>0),'24');
         $time_arr = getaddEventPopupTime($hour_startat,$hour_endat,$format);
         $temp_ts = $cal['calendar']->date_time->ts;
 	//to get date in user selected date format
@@ -1694,37 +1632,58 @@
 	//labels of listview header
 	if($cal['view'] == 'day')
 	{
-		$colspan = 7;
+		$colspan = 9;
 		$header = Array('0'=>'#','1'=>$mod_strings['LBL_TIME'],'2'=>$mod_strings['LBL_LIST_DUE_DATE'],
-				'3'=>$mod_strings['LBL_TODO'],'4'=>$mod_strings['LBL_STATUS'],'5'=>$mod_strings['LBL_ACTION'],'6'=>$mod_strings['LBL_ASSINGEDTO'],);
-		$header_width = Array('0'=>'5%','1'=>'10%','2'=>'10%','3'=>'38%','4'=>'10%','5'=>'10%', '6'=>'15%', );
+				'3'=>$mod_strings['LBL_TODO'],'4'=>$mod_strings['LBL_RELATEDTO'],'5'=>$mod_strings['LBL_CONTACT_NAME'],'6'=>$mod_strings['LBL_STATUS']);
+				if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+	                        {
+				array_push($header,$mod_strings['LBL_ACTION']);
+				}
+				array_push($header,$mod_strings['LBL_ASSINGEDTO']);
+		$header_width = Array('0'=>'5%','1'=>'10%','2'=>'10%','3'=>'38%','4'=>'15%','5'=>'15%','6'=>'10%',);
+				if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+                                {
+                                array_push($header_width,'10%');
+                                }
+                                array_push($header_width,'15%');
 	}
 	else
 	{
-		$colspan = 8;
+		$colspan = 10;
 	        $header = Array('0'=>'#',
                         '1'=>$mod_strings['LBL_TIME'],
-			'2'=>$mod_strings['LBL_APP_START_DATE'],
-			'3'=>$mod_strings['LBL_LIST_DUE_DATE'],
+			'2'=>$mod_strings['LBL_START_DATE'],
+			'3'=>$mod_strings['LBL_DUE_DATE'],
                         '4'=>$mod_strings['LBL_TODO'],
-                        '5'=>$mod_strings['LBL_STATUS'],
-                        '6'=>$mod_strings['LBL_ACTION'],
-			'7'=>$mod_strings['LBL_ASSINGEDTO'],
-                       );
+			'5'=>$mod_strings['LBL_RELATEDTO'],
+			'6'=>$mod_strings['LBL_CONTACT_NAME'],
+			'7'=>$mod_strings['LBL_STATUS'],
+			);
+			if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+			{
+                        	array_push($header,$mod_strings['LBL_ACTION']);
+			}
+			array_push($header,$mod_strings['LBL_ASSINGEDTO']);
         	$header_width = Array('0'=>'5%',
                               '1'=>'10%',
                               '2'=>'10%',
                               '3'=>'10%',
                               '4'=>'28%',
-			      '5'=>'10%',
-			      '6'=>'10%',
-			      '7'=>'15%',
-                             );
+                              '5'=>'15%',
+                              '6'=>'15%',
+			      '7'=>'10%',	
+			       );
+			if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
+                        {
+                        array_push($header_width,'10%');
+                        }
+			array_push($header_width,'15%');
+	
 	}
 	$list_view .="<table align='center' border='0' cellpadding='5' cellspacing='0' width='98%'>
 			<tr><td colspan='3'>&nbsp;</td></tr>";
 			//checking permission for Create/Edit Operation
-			if(isPermitted("Calendar","EditView") == "yes")
+			if(isPermitted("Calendar","EditView") == "yes" || isPermitted("Calendar","Delete") == "yes")
 			{
 			$list_view .="<tr>
 				<td class='calAddButton' onMouseOver='fnAddEvent(this,\"addEventDropDown\",\"".$temp_date."\",\"".$endtemp_date."\",\"".$time_arr['starthour']."\",\"".$time_arr['startmin']."\",\"".$time_arr['startfmt']."\",\"".$time_arr['endhour']."\",\"".$time_arr['endmin']."\",\"".$time_arr['endfmt']."\",\"\",\"".$subtab."\");'style='border: 1px solid #666666;cursor:pointer;height:30px' align='center' width='10%'>
@@ -1735,7 +1694,7 @@
 			{
 				$list_view .="<tr><td>&nbsp;</td>";
 			}
-			$list_view .="<td align='center' width='60%'>&nbsp;</td>
+			$list_view .="<td align='center' width='60%'><span id='total_activities'>".getEventTodoInfo($cal,'listcnt')."</span>&nbsp;</td>
 				<td align='right' width='28%'>&nbsp;</td>
 			</tr>
 		</table>
@@ -1794,175 +1753,4 @@
         return $list_view;
 }
 
-/**
- * Function to convert time to user selected format
- * @param  string    $format                      - hour format. either 'am/pm' or '24'
- * @param  string    $time                        - time
- * @param  boolean   $format_check                - true/false
- * return  string    $hour                        - time string
- */
-function convertTime2UserSelectedFmt($format,$time,$format_check)
-{
-	global $cal_log;
-	$cal_log->debug("Entering convertTime2UserSelectedFmt() method...");
-	if($format == 'am/pm' && $format_check)
-        {
-		if($time>='12')
-                {
-			if($time == '12')
-				$hour = $time;
-			else
-				$hour = $time - 12;
-			$hour = $hour.":00pm";
-		}
-		else
-                {
-                        $hour = $time;
-			$hour = $hour.":00am";
-		}
-		$cal_log->debug("Exiting convertTime2UserSelectedFmt() method...");
-		return $hour;
-	}
-	else
-        {
-                $hour = $time;
-		if($hour <= 9 && strlen(trim($hour)) < 2)
-                                $hour = "0".$hour;
-		$hour = $hour.":00";
-		$cal_log->debug("Exiting convertTime2UserSelectedFmt() method...");
-		return $hour;
-	}
-}
-
-/**
- * Function to convert events/todos start and endtime to user selected format
- * @param  string    $format                      - hour format. either 'am/pm' or '24'
- * @param  string    $start_time                  - time
- * @param  string    $duration_hr                 - duration in hours or empty string
- * @param  string    $duration_min                - duration in minutes or empty string
- * return  array     $return_data                 - start and end time in array format
- */
-function convertStEdTime2UserSelectedFmt($format,$start_time,$duration_hr='',$duration_min='')
-{
-	global $cal_log;
-	$cal_log->debug("Entering convertStEdTime2UserSelectedFmt() method...");
-	list($hour,$min) = explode(":",$start_time);
-	if($format == 'am/pm')
-        {
-                if($hour>'12')
-		{
-			$hour = $hour - 12;
-                        $start_hour = $hour;
-			$start_time = $start_hour.":".$min."pm";
-                        $end_min = $min+$duration_min;
-                        $end_hour = $hour+$duration_hr;
-                        if($end_min>=60)
-                        {
-	                        $end_min = $end_min%60;
-                                $end_hour++;
-                        }
-                        if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-                                $end_hour = "0".$end_hour;
-                        if($end_min <= 9 && strlen(trim($end_min)) < 2)
-                                $end_min = "0".$end_min;
-                        $end_time = $end_hour.":".$end_min."pm";
-		}
-		elseif($hour == '12')
-		{
-			$start_hour = $hour;
-			$start_time = $start_hour.":".$min."pm";
-			$end_min = $min+$duration_min;
-			$end_hour = $hour+$duration_hr;
-			if($end_min>=60)
-			{
-				$end_min = $end_min%60;
-				$end_hour++;
-			}
-			if($end_hour>'12')
-			{
-				$end_hour = $end_hour - 12;
-				if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-					$end_hour = "0".$end_hour;
-				if($end_min <= 9 && strlen(trim($end_min)) < 2)
-					$end_min = "0".$end_min;
-				$end_time = $end_hour.":".$end_min."pm";
-			}
-			else
-			{
-				if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-					$end_hour = "0".$end_hour;
-				if($end_min <= 9 && strlen(trim($end_min)) < 2)
-					$end_min = "0".$end_min;
-				$end_time  = $end_hour.":".$end_min."am";
-			}
-		}
-		else
-		{
-			$start_hour = $hour;
-			$start_time = $start_hour.":".$min."am";
-			$end_min = $min+$duration_min;
-			$end_hour = $hour+$duration_hr;
-			if($end_min>=60)
-			{
-				$end_min = $end_min%60;
-				$end_hour++;
-			}
-			if($end_hour>='12')
-			{
-				if($end_hour == '12' && $end_hour > '00')
-					$end_hour = $end_hour;
-				else
-					$end_hour = $end_hour - 12;
-				if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-					$end_hour = "0".$end_hour;
-				if($end_min <= 9 && strlen(trim($end_min)) < 2)
-					$end_min = "0".$end_min;
-				$end_time = $end_hour.":".$end_min."pm";
-			}
-			else
-			{
-				if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-					$end_hour = "0".$end_hour;
-				if($end_min <= 9 && strlen(trim($end_min)) < 2)
-					$end_min = "0".$end_min;
-				$end_time  = $end_hour.":".$end_min."am";
-			}
-
-		}
-		$return_data = Array(
-					'starttime'=>$start_time,
-					'endtime'  =>$end_time
-				    );
-	}
-	else
-	{
-		$hour = $hour;
-		$min = $min;
-		$end_min = $min+$duration_min;
-		$end_hour = $hour+$duration_hr;
-		if($end_min>=60)
-		{
-			$end_min = $end_min%60;
-			$end_hour++;
-		}
-		if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
-			$end_hour = "0".$end_hour;
-		if($end_min <= 9 && strlen(trim($end_min)) < 2)
-			$end_min = "0".$end_min;
-		$end_time  = $end_hour.":".$end_min;
-		if($hour <= 9 && strlen(trim($hour)) < 2)
-                                $hour = "0".$hour;
-                $start_time = $hour.":".$min;
-		$return_data = Array(
-                                        'starttime'=>$start_time,
-                                        'endtime'  =>$end_time
-                                    );
-	}
-	$cal_log->debug("Exiting convertStEdTime2UserSelectedFmt() method...");
-	return $return_data;
-
-
-}
-
-		
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/calendar_share.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/calendar_share.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/calendar_share.php Mon Apr 16 12:27:44 2007
@@ -1,128 +1,171 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-global $current_user,$mod_strings,$app_strings;
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once ($theme_path."layout_utils.php");
-require_once('include/database/PearDatabase.php');
-require_once('modules/Calendar/CalendarCommon.php');
- $t=Date("Ymd");
- $userDetails=getOtherUserName($current_user->id,true);
- $shareduser_ids = getSharedUserId($current_user->id);
-?>
-<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerHeadingULine">
-	<tr>
-		<td class="layerPopupHeading" align="left"><? echo $mod_strings['LBL_CALSETTINGS']?></td>
-		<td align=right>
-			<a href="javascript:fninvsh('calSettings');"><img src="<?echo $image_path?>close.gif" border="0"  align="absmiddle" /></a>
-		</td>
-	</tr>
-	</table>
-<form name="SharingForm" method="post" action="index.php">
-<input type="hidden" name="module" value="Calendar">
-<input type="hidden" name="action" value="updateCalendarSharing">
-<input type="hidden" name="view" value="<?php echo $_REQUEST['view'] ?>">
-<input type="hidden" name="hour" value="<?php echo $_REQUEST['hour'] ?>">
-<input type="hidden" name="day" value="<?php echo $_REQUEST['day'] ?>">
-<input type="hidden" name="month" value="<?php echo $_REQUEST['month'] ?>">
-<input type="hidden" name="year" value="<?php echo $_REQUEST['year'] ?>">
-<input type="hidden" name="viewOption" value="<?php echo $_REQUEST['viewOption'] ?>">
-<input type="hidden" name="subtab" value="<?php echo $_REQUEST['subtab'] ?>">
-<input type="hidden" name="parenttab" value="<?php echo $_REQUEST['parenttab'] ?>">
-<input type="hidden" name="current_userid" value="<? echo $current_user->id ?>" >
-<table border=0 cellspacing=0 cellpadding=5 width=95% align=center> 
-	<tr>
-		<td class=small >
-			<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
-			<tr>
-		<td align="right" width="10%" valign="top"><img src="<?echo $image_path?>cal_clock.jpg" align="absmiddle"></td>
-		<td align="left" width="90%">
-			<b><?echo $mod_strings['LBL_TIMESETTINGS']?></b><br>
-			<input type="checkbox" name="sttime_check" <? if($current_user->start_hour != ''){?> checked <? } ?> onClick="enableCalstarttime();">&nbsp;<?echo $mod_strings['LBL_CALSTART']?> 
-			<select name="start_hour" <? if($current_user->start_hour == ''){?>disabled <? } ?> >
-				<?
-					for($i=0;$i<=23;$i++)
-					{
-						if($i == 0)
-							$hour = "12:00 am";
-						elseif($i >= 12)
-						{
-							if($i == 12)
-								$hour = $i;
-							else 
-								$hour = $i - 12;
-							$hour = $hour.":00 pm";
-						}
-						else
-               					{
-							$hour = $i.":00 am";
-       						}
-						if($i <= 9 && strlen(trim($i)) < 2)
-						{
-							$value = '0'.$i.':00';
-                       				}
-						else
-							$value = $i.':00';
-							if($value === $current_user->start_hour)
-                                                       	        $selected = 'selected';
-                                                         else
-                                                                $selected = '';
-				?>
-				<option <?echo $selected?> value="<? echo $value?>"><? echo $hour?></option>
-				<?
-					}
-				?>
-			</select><br>
-			<input type="checkbox" name="hour_format" <? if($current_user->hour_format == '24'){?> checked <? } ?> value="24">&nbsp;<?echo $mod_strings['LBL_USE24']?>
-		</td>
-	</tr>
-	<tr><td colspan="2" style="border-bottom:1px dotted #CCCCCC;"></td></tr>
-	<tr>
-		<td align="right" valign="top"><img src="<?echo $image_path?>cal_sharing.jpg" width="45" height="38" align="absmiddle"></td>
-		<td align="left">
-		<b><?echo $mod_strings['LBL_CALSHARE']?></b><br>
-		<?echo $mod_strings['LBL_CALSHAREMESSAGE']?><br><br>
-		<div id="cal_shar" style="border:1px solid #666666;width:90%;height:200px;overflow:auto;position:relative;">
-			<table width="95%" border="0" cellpadding="5" cellspacing="0" align="center">
-				<?php
-					$cnt = 1;
-					echo '<tr>';
-					foreach($userDetails as $id=>$name)
-					{
-						if(in_array($id,$shareduser_ids))
-							$checkbox = "checked";
-						else
-							$checkbox = "";
-						echo '<td width="50%" align="left"><input type="checkbox" name="user[]" value='.$id.' '.$checkbox.'>&nbsp;'.$name.'</td>';
-						if($cnt%2 == 0)
-							echo '</tr>';
-                                                $cnt++;
-					}
-                    		?>
-			</table>
-		</div>
-		</td>
-	</tr>
-	</table>
-	</td>
-	</tr>
-	</table>
-	<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
-	<tr>
-		<td align="center">
-			<input type="submit" name="save" value=" &nbsp;<? echo $app_strings['LBL_SAVE_BUTTON_LABEL'] ?>&nbsp;" class="crmbutton small save" />&nbsp;&nbsp;
-			<input type="button" name="cancel" value=" <? echo $app_strings['LBL_CANCEL_BUTTON_LABEL'] ?> " class="crmbutton small cancel" onclick="fninvsh('calSettings');" />
-		</td>
-	</tr>
-	</table>
-</form>
-
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+global $current_user,$mod_strings,$app_strings;
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once ($theme_path."layout_utils.php");
+require_once('include/database/PearDatabase.php');
+require_once('modules/Calendar/CalendarCommon.php');
+ $t=Date("Ymd");
+ $userDetails=getSharingUserName($current_user->id);
+ $shareduser_ids = getSharedUserId($current_user->id);
+?>
+<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerHeadingULine">
+	<tr>
+		<td class="layerPopupHeading" align="left"><?php echo $mod_strings['LBL_CALSETTINGS']?></td>
+		<td align=right>
+			<a href="javascript:fninvsh('calSettings');"><img src="<?php echo $image_path?>close.gif" border="0"  align="absmiddle" /></a>
+		</td>
+	</tr>
+	</table>
+<form name="SharingForm" method="post" action="index.php">
+<input type="hidden" name="module" value="Calendar">
+<input type="hidden" name="action" value="updateCalendarSharing">
+<input type="hidden" name="view" value="<?php echo $_REQUEST['view'] ?>">
+<input type="hidden" name="hour" value="<?php echo $_REQUEST['hour'] ?>">
+<input type="hidden" name="day" value="<?php echo $_REQUEST['day'] ?>">
+<input type="hidden" name="month" value="<?php echo $_REQUEST['month'] ?>">
+<input type="hidden" name="year" value="<?php echo $_REQUEST['year'] ?>">
+<input type="hidden" name="viewOption" value="<?php echo $_REQUEST['viewOption'] ?>">
+<input type="hidden" name="subtab" value="<?php echo $_REQUEST['subtab'] ?>">
+<input type="hidden" name="parenttab" value="<?php echo $_REQUEST['parenttab'] ?>">
+<input type="hidden" name="current_userid" value="<?php echo $current_user->id ?>" >
+<input type="hidden" name="shar_userid" id="shar_userid" >
+
+<table border=0 cellspacing=0 cellpadding=5 width=95% align=center> 
+	<tr>
+		<td class=small >
+			<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
+			<tr>
+		<td align="right" width="10%" valign="top"><img src="<?php echo $image_path?>cal_clock.jpg" align="absmiddle"></td>
+		<td align="left" width="90%">
+			<b><?php echo $mod_strings['LBL_TIMESETTINGS']?></b><br>
+			<input type="checkbox" name="sttime_check" <?php if($current_user->start_hour != ''){?> checked <?php } ?> onClick="enableCalstarttime();">&nbsp;<?php echo $mod_strings['LBL_CALSTART']?> 
+			<select name="start_hour" <?php if($current_user->start_hour == ''){?>disabled <?php } ?> >
+				<?php
+					for($i=0;$i<=23;$i++)
+					{
+						if($i == 0)
+							$hour = "12:00 am";
+						elseif($i >= 12)
+						{
+							if($i == 12)
+								$hour = $i;
+							else 
+								$hour = $i - 12;
+							$hour = $hour.":00 pm";
+						}
+						else
+               					{
+							$hour = $i.":00 am";
+       						}
+						if($i <= 9 && strlen(trim($i)) < 2)
+						{
+							$value = '0'.$i.':00';
+                       				}
+						else
+							$value = $i.':00';
+							if($value === $current_user->start_hour)
+                                                       	        $selected = 'selected';
+                                                         else
+                                                                $selected = '';
+				?>
+				<option <?php echo $selected?> value="<?php echo $value?>"><?php echo $hour?></option>
+				<?php
+					}
+				?>
+			</select><br>
+			<input type="checkbox" name="hour_format" <?php if($current_user->hour_format == '24'){?> checked <?php } ?> value="24">&nbsp;<?php echo $mod_strings['LBL_USE24']?>
+		</td>
+	</tr>
+	<tr><td colspan="2" style="border-bottom:1px dotted #CCCCCC;"></td></tr>
+	<tr>
+		<td align="right" valign="top"><img src="<?php echo $image_path?>cal_sharing.jpg" width="45" height="38" align="absmiddle"></td>
+		<td align="left">
+		<b><?php echo $mod_strings['LBL_CALSHARE']?></b><br>
+		<?php echo $mod_strings['LBL_CALSHAREMESSAGE']?><br><br>
+		<!-- Calendar sharing UI-->
+			<DIV id="cal_shar" style="display:block;width:100%;height:200px">
+                                <table border=0 cellspacing=0 cellpadding=2 width=100% bgcolor="#FFFFFF">
+                                <tr>
+                                        <td valign=top>
+                                                <table border=0 cellspacing=0 cellpadding=2 width=100%>
+                                                <tr>
+                                                        <td colspan=3>
+                                                                <ul style="padding-left:20px">
+                                                                <li><?php echo $mod_strings['LBL_INVITE_INST1']?>
+                                                                <li><?php echo $mod_strings['LBL_INVITE_INST2']?>
+                                                                </ul>
+                                                        </td>
+                                                </tr>
+                                                <tr>
+                                                        <td><b><?php echo $mod_strings['LBL_AVL_USERS']?></b></td>
+                                                        <td>&nbsp;</td>
+                                                        <td><b><?php echo $mod_strings['LBL_SEL_USERS']?></b></td>
+                                                </tr>
+                                                <tr>
+                                                        <td width=40% align=center valign=top>
+                                                        <select name="available_users" id="available_users" class=small size=5
+ multiple style="height:70px;width:100%">
+                                                        <?php
+                                                                foreach($userDetails as $id=>$name)
+                                                                {
+                                                                        if($id != '')
+                                                                        echo "<option value=".$id.">".$name."</option>";
+                                                                 }
+                                                        ?>
+                                                                </select>
+
+                                                        </td>
+                                                        <td width=20% align=center valign=top>
+                                                                <input type=button value="<?php echo $mod_strings['LBL_ADD_BUTTON'] ?> >>" class="crm button small save" style="width:100%" onClick="incUser('available_users','selected_users')"><br>
+                                                                <input type=button value="<< <?php echo $mod_strings['LBL_RMV_BUTTON'] ?> " class="crm button small cancel" style="width:100%" onClick="rmvUser('selected_users')">
+							</td>
+							<td>
+							<select name="selected_users" id="selected_users" class=small size=5 multiple style="height:70px;width:100%">
+							<?php
+                                                                foreach($shareduser_ids as $shar_id=>$share_user)
+                                                                {
+                                                                        if($shar_id != '')
+                                                                        echo "<option value=".$shar_id.">".$share_user."</option>";
+                                                                }
+                                                        ?>
+                                                                </select>
+	
+
+                                                        </select>
+							<td>
+                                                </tr>
+                                                </table>
+
+
+                                        </td>
+                                </tr>
+                                </table>
+
+		</div>
+		</td>
+	</tr>
+	</table>
+	</td>
+	</tr>
+	</table>
+	<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
+	<tr>
+		<td align="center">
+			<input type="submit" name="save" value=" &nbsp;<?php echo $app_strings['LBL_SAVE_BUTTON_LABEL'] ?>&nbsp;" class="crmbutton small save" onClick = "userEventSharing('shar_userid','selected_users');"/>&nbsp;&nbsp;
+			<input type="button" name="cancel" value=" <?php echo $app_strings['LBL_CANCEL_BUTTON_LABEL'] ?> " class="crmbutton small cancel" onclick="fninvsh('calSettings');" />
+		</td>
+	</tr>
+	</table>
+</form>
+

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/header.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/header.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/header.php Mon Apr 16 12:27:44 2007
@@ -1,109 +1,118 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-require_once('include/utils/CommonUtils.php');
-$category = getParentTab();
-global $theme,$app_strings,$mod_strings;
-
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-
-$html_string = '<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
-
-<tr><td style="height:2px"></td></tr>
-<tr>
-	<td width="10%" style="padding-left:10px;padding-right:30px" class="moduleName" nowrap>'.$app_strings[$category].' > <a class="hdrLink" href="index.php?action=index&module=Calendar&parenttab=My Home Page">'.$app_strings["Calendar"].'</a></td>
-
-	<td  nowrap width="8%">
-		<table border=0 cellspacing=0 cellpadding=0>
-		<tr>
-			<td class="sep1" style="width:1px;"></td>
-			<td class=small>
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-					 <td style="padding-left:10px"><img src="'.$image_path.'btnL3Add-Faded.gif" border=0></td>
-					 <td style="padding-right:10px"><img src="'.$image_path.'btnL3Search-Faded.gif" border=0></td>
-		</tr>
-		</table>
-	</td>
-			</tr>
-			</table>
-	</td>
-	<td width="20">&nbsp;</td>
-                <td class="small" width="10%" align="left">
-
-				<table border=0 cellspacing=0 cellpadding=5>
-
-				<tr>
-					<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick=\'fnvshobj(this,"miniCal");getMiniCal("parenttab='.$category.'");\'><img src="'.$image_path.'btnL3Calendar.gif" alt="'.$app_strings['LBL_CALENDAR_ALT'].'" title="'.$app_strings['LBL_CALENDAR_TITLE'].'" border=0></a></a></td>
-					<td style="padding-right:0px"><a href="javascript:;"><img src="'.$image_path.'btnL3Clock.gif" alt="'.$app_strings['LBL_CLOCK_ALT'].'" title="'.$app_strings['LBL_CLOCK_TITLE'].'" border=0 onClick="fnvshobj(this,\'wclock\');"></a></a></td>
-					<td style="padding-right:0px"><a href="#"><img src="'.$image_path.'btnL3Calc.gif" alt="'.$app_strings['LBL_CALCULATOR_ALT'].'" title="'.$app_strings['LBL_CALCULATOR_TITLE'].'" border=0 onClick="fnvshobj(this,\'calculator_cont\');fetch_calc();"></a></td>
-					<td style="padding-right:10px"><a href="javascript:;" onClick=\'return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");\'><img src="'.$image_path.'tbarChat.gif" alt="'.$app_strings['LBL_CHAT_ALT'].'" title="'.$app_strings['LBL_CHAT_TITLE'].'" border=0></a></td>
-					<td style="padding-right:10px"><img src="'.$image_path.'btnL3Tracker.gif" alt="'.$app_strings['LBL_LAST_VIEWED'].'" title="'.$app_strings['LBL_LAST_VIEWED'].'" border=0 onClick="fnvshobj(this,\'tracker\');"></td>
-				</tr>
-				</table>
-	</td>
-	<td width="20">&nbsp;</td>
-               <td class="small" align="left" width="5%">
-
-		<table border=0 cellspacing=0 cellpadding=5>
-			<tr>
-				<td style="padding-right:0px;padding-left:10px;"><img src="'.$image_path.'tbarImport-Faded.gif" border="0"></td>
-                <td style="padding-right:10px"><img src="'.$image_path.'tbarExport-Faded.gif" border="0"></td>
-			</tr>
-		</table>	
-	</td>
-	<td width="20">&nbsp;</td>
-                <td class="small" align="left">	
-				<table border=0 cellspacing=0 cellpadding=5>
-				<tr>
-				<td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh(\'allMenu\');" onclick="fnvshobj(this,\'allMenu\')"><img src="'.$image_path.'btnL3AllMenu.gif" alt="'.$app_strings['LBL_ALL_MENU_ALT'].'" title="'.$app_strings['LBL_ALL_MENU_TITLE'].'" border="0"></a></td>
-				</tr>
-				</table>
-	</td>			
-	</tr>
-	</table></td>
-	</tr>
-	<tr><td style="height:2px"></td></tr>
-	</TABLE>
-	<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
-	     <tr>
-	             <td valign=top><img src="'.$image_path.'showPanelTopLeft.gif"></td>
-
-		     	<td class="showPanelBg" valign="top" width=100% style="padding:10px;">
-			
-			<!-- Calendar Tabs starts -->
-			<div class="small" style="padding: 10px;">
-			<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
-				<tr>
-					<td>
-						<table class="small" border="0" cellpadding="3" cellspacing="0" width="100%">
-							<tr>
-								<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
-								<td class="dvtSelectedCell" align="center" nowrap="nowrap">'.$app_strings["Calendar"].'</td>	
-								<td class="dvtTabCache" style="width: 10px;">&nbsp;</td>
-								<td class="dvtUnSelectedCell" align="center" nowrap="nowrap"><a href="index.php?action=ListView&module=Calendar&parenttab='.$category.'">'.$mod_strings["LBL_ALL_EVENTS_TODOS"].'</a></td>
-								<td class="dvtTabCache" style="width: 100%;">&nbsp;</td>
-							</tr>
-						</table>
-					</td>
-				</tr>
-				<tr>
-					<td align="left" valign="top">
-						<table class="dvtContentSpace" border="0" cellpadding="3" cellspacing="0" width="100%">
-							<tr>
-								<td align="left">
-								<!-- content cache -->
-									<table border="0" cellpadding="0" cellspacing="0" width="100%">
-									<tr>
-										<td style="padding: 10px;">
-	';
-	echo $html_string;
-?>	
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+require_once('include/utils/CommonUtils.php');
+$category = getParentTab();
+global $theme,$app_strings,$mod_strings;
+global $CALENDAR_DISPLAY, $WORLD_CLOCK_DISPLAY, $CALCULATOR_DISPLAY, $CHAT_DISPLAY;
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+
+$html_string = '<TABLE border=0 cellspacing=0 cellpadding=0 width=100% class=small>
+
+<tr><td style="height:2px"></td></tr>
+<tr>
+	<td width="10%" style="padding-left:10px;padding-right:30px" class="moduleName" nowrap>'.$app_strings[$category].' > <a class="hdrLink" href="index.php?action=index&module=Calendar&parenttab=My Home Page">'.$app_strings["Calendar"].'</a></td>
+
+	<td  nowrap width="8%">
+		<table border=0 cellspacing=0 cellpadding=0>
+		<tr>
+			<td class="sep1" style="width:1px;"></td>
+			<td class=small>
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+					 <td style="padding-left:10px"><img src="'.$image_path.'btnL3Add-Faded.gif" border=0></td>
+					 <td style="padding-right:10px"><img src="'.$image_path.'btnL3Search-Faded.gif" border=0></td>
+		</tr>
+		</table>
+	</td>
+			</tr>
+			</table>
+	</td>
+	<td width="20">&nbsp;</td>
+                <td class="small" width="10%" align="left">
+
+				<table border=0 cellspacing=0 cellpadding=5>
+
+					<tr>'; 
+ 		 
+ 		 
+ 		if($CALENDAR_DISPLAY == 'true') 
+ 		        $html_string .= '               <td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick=\'fnvshobj(this,"miniCal");getMiniCal("parenttab='.$category.'");\'><img src="'.$image_path.'btnL3Calendar.gif" alt="'.$app_strings['LBL_CALENDAR_ALT'].'" title="'.$app_strings['LBL_CALENDAR_TITLE'].'" border=0></a></a></td>'; 
+ 		if($WORLD_CLOCK_DISPLAY == 'true') 
+ 		        $html_string .= '               <td style="padding-right:0px"><a href="javascript:;"><img src="'.$image_path.'btnL3Clock.gif" alt="'.$app_strings['LBL_CLOCK_ALT'].'" title="'.$app_strings['LBL_CLOCK_TITLE'].'" border=0 onClick="fnvshobj(this,\'wclock\');"></a></a></td>'; 
+ 		if($CALCULATOR_DISPLAY == 'true') 
+ 		        $html_string .= '               <td style="padding-right:0px"><a href="#"><img src="'.$image_path.'btnL3Calc.gif" alt="'.$app_strings['LBL_CALCULATOR_ALT'].'" title="'.$app_strings['LBL_CALCULATOR_TITLE'].'" border=0 onClick="fnvshobj(this,\'calculator_cont\');fetch_calc();"></a></td>'; 
+ 		if($CHAT_DISPLAY == 'true') 
+ 		        $html_string .= '               <td style="padding-right:10px"><a href="javascript:;" onClick=\'return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");\'><img src="'.$image_path.'tbarChat.gif" alt="'.$app_strings['LBL_CHAT_ALT'].'" title="'.$app_strings['LBL_CHAT_TITLE'].'" border=0></a></td>'; 
+ 		 
+ 		$html_string .= ' 
+					<td style="padding-right:10px"><img src="'.$image_path.'btnL3Tracker.gif" alt="'.$app_strings['LBL_LAST_VIEWED'].'" title="'.$app_strings['LBL_LAST_VIEWED'].'" border=0 onClick="fnvshobj(this,\'tracker\');"></td>
+				</tr>
+				</table>
+	</td>
+	<td width="20">&nbsp;</td>
+               <td class="small" align="left" width="5%">
+
+		<table border=0 cellspacing=0 cellpadding=5>
+			<tr>
+				<td style="padding-right:0px;padding-left:10px;"><img src="'.$image_path.'tbarImport-Faded.gif" border="0"></td>
+                <td style="padding-right:10px"><img src="'.$image_path.'tbarExport-Faded.gif" border="0"></td>
+			</tr>
+		</table>	
+	</td>
+	<td width="20">&nbsp;</td>
+                <td class="small" align="left">	
+				<table border=0 cellspacing=0 cellpadding=5>
+				<tr>
+				<td style="padding-left:10px;"><a href="javascript:;" onmouseout="fninvsh(\'allMenu\');" onclick="fnvshobj(this,\'allMenu\')"><img src="'.$image_path.'btnL3AllMenu.gif" alt="'.$app_strings['LBL_ALL_MENU_ALT'].'" title="'.$app_strings['LBL_ALL_MENU_TITLE'].'" border="0"></a></td>
+				</tr>
+				</table>
+	</td>			
+	</tr>
+	</table></td>
+	</tr>
+	<tr><td style="height:2px"></td></tr>
+	</TABLE>
+	<table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
+	     <tr>
+	             <td valign=top><img src="'.$image_path.'showPanelTopLeft.gif"></td>
+
+		     	<td class="showPanelBg" valign="top" width=100% style="padding:10px;">
+			
+			<!-- Calendar Tabs starts -->
+			<div class="small" style="padding: 10px;">
+			<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
+				<tr>
+					<td>
+						<table class="small" border="0" cellpadding="3" cellspacing="0" width="100%">
+							<tr>
+								<td class="dvtTabCache" style="width: 10px;" nowrap="nowrap">&nbsp;</td>
+								<td class="dvtSelectedCell" align="center" nowrap="nowrap">'.$app_strings["Calendar"].'</td>	
+								<td class="dvtTabCache" style="width: 10px;">&nbsp;</td>
+								<td class="dvtUnSelectedCell" align="center" nowrap="nowrap"><a href="index.php?action=ListView&module=Calendar&parenttab='.$category.'">'.$mod_strings["LBL_ALL_EVENTS_TODOS"].'</a></td>
+								<td class="dvtTabCache" style="width: 100%;">&nbsp;</td>
+							</tr>
+						</table>
+					</td>
+				</tr>
+				<tr>
+					<td align="left" valign="top">
+						<table class="dvtContentSpace" border="0" cellpadding="3" cellspacing="0" width="100%">
+							<tr>
+								<td align="left">
+								<!-- content cache -->
+									<table border="0" cellpadding="0" cellspacing="0" width="100%">
+									<tr>
+										<td style="padding: 10px;">
+	';
+	echo $html_string;
+?>	

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -25,7 +25,6 @@
 'LBL_MODULE_TITLE'=>'Calendar: Home',
 'LBL_MODULE_APPOINTMENT'=>'Calendar: Appointment',
 'LBL_MODULE_APPOINTMENT_DETAIL'=>'Calendar: Appointment Detail',
-'LBL_CONTACT'=>'Contact:',
 'LBL_SAVE'=>'Save',
 'LBL_RESET'=>'Cancel',
 'LBL_LIST_USER_NAME'=>'User Name',
@@ -39,8 +38,7 @@
 'LBL_USE24'=>'Use 24 hours format',
 'LBL_CALSTART'=>'Start my calendar time at',
 'LBL_TIMESETTINGS'=>'Time Settings',
-'LBL_OPENCAL'=>'Open Calendar',
-
+'LBL_HOLDFOLLOWUP'=>'Hold followup on',
 'LBL_CALL' => 'Call',
 'LBL_MEET' => 'Meeting',
 'LBL_APPNT' => 'Appointment',
@@ -82,10 +80,6 @@
 
 
 'LBL_APPCREATED_BY' => 'Created by',
-'LBL_APP_START_DATE' => 'Start Date',
-'LBL_APP_START_TIME' => 'Start Time',
-'LBL_APP_END_DATE' => 'End Date',
-'LBL_APP_END_TIME' => 'End Time',
 'LBL_AT_DATE_TIME' => 'at',
 
 'LBL_MON' => 'Month',
@@ -94,7 +88,6 @@
 'LBL_PREV_MON' => 'Previous Month',
 'LBL_NEXT_MON' => 'Next Month',
 
-'LBL_YEAR'=>'Year',
 'LBL_YEAR_BUTTON_KEY'=>'Y',
 'LBL_MON_BUTTON_TITLE'=>'Year [Alt+Y]',
 'LBL_PREV_YEAR'=>'Previous Year',
@@ -173,53 +166,53 @@
 "Dec",
 ),
 
+'LBL_TIME'=>'Time',
+'LBL_START_TIME' => 'Start Time',
+'LBL_END_TIME' => 'End Time',
+'LBL_START_DATE'=>'Start Date',
+'LBL_DUE_DATE'=>'Due Date',
+'LBL_START_DATE_TIME'=>'Start Date & Time',
+'LBL_END_DATE_TIME'=>'End Date & Time',
+'LBL_TODO'=>'To Do',
+'LBL_TODOS'=>'To Dos',
 'LBL_EVENTS'=>'Events',
-'LBL_TODOS'=>'To Dos',
-'LBL_TIME'=>'Time',
+'LBL_TOTALEVENTS'=>'My Total Events :',
+'LBL_TOTALTODOS'=>'My Total To Dos :',
+'LBL_VIEW'=>'View',
+'LBL_LISTVIEW'=>'List View',
+'LBL_HRVIEW'=>'Hour View',
+'LBL_WEEKVIEW'=>'Weekly Calendar View',
+'LBL_MONTHVIEW'=>'Monthly Calendar View',
+'LBL_YEARVIEW'=>'Yearly Calendar View',
+'LBL_STATUS'=>'Status',
+'LBL_ACTION'=>'Actions',
+'LBL_ADD'=>'Add',
+'LBL_OPENCAL'=>'Open Calendar',
+
+
 'LBL_ADD_EVENT'=>'Add Event',
-'LBL_ADD'=>'Add',
 'LBL_ADDCALL'=>'Call',
 'LBL_ADDMEETING'=>'Meeting',
 'LBL_ADDTODO'=>'To Do',
-'LBL_INVITE'=>'Invite',
-'LBL_REMINDER'=>'Reminder',
-'LBL_SENDREMINDER'=>'Send Reminder',
 'LBL_BEFOREEVENT'=>'before the event starts',
 'LBL_BEFORETASK'=>'before the task starts',
-'LBL_REPEAT'=>'Repeat',
-'LBL_EVENTTYPE'=>'Event Type',
-'LBL_EVENTNAME'=>'Event Name',
-'LBL_EVENTSTAT'=>'Event starts at',
-'LBL_EVENTEDAT'=>'Event ends on',
-'LBL_HRVIEW'=>'Hour View',
-'LBL_LISTVIEW'=>'List View',
-'LBL_WEEKVIEW'=>'Weekly Calendar View',
-'LBL_MONTHVIEW'=>'Monthly Calendar View',
-'LBL_YEARVIEW'=>'Yearly Calendar View',
-'LBL_TOTALEVENTS'=>'Total Events :',
-'LBL_TOTALTODOS'=>'Total To Dos :',
-'LBL_EVTDTL'=>'Event Details',
-'LBL_ACTION'=>'Actions',
+'LBL_EVENTDETAILS'=>'Event Details',
 'LBL_CURSTATUS'=>'Current Status',
 'LBL_ASSINGEDTO'=>'Assigned To',
 'LBL_RELATEDTO'=>'Related To',
-'LBL_STATUS'=>'Status',
 'LBL_PENDING'=>'Pending',
 'LBL_PUBLIC'=>'Mark Public',
 'LBL_MORE'=>'More',
-'LBL_VIEW'=>'View',
 'LBL_EDIT'=>'Edit',
 'LBL_EVERYDAY'=>'Every Day',
 'LBL_EVERYWEEK'=>'Every Week',
 'LBL_EVERYMON'=>'Every Month',
-'LBL_REPEATEVENT'=>'Repeat once in every',
-'LBL_DAYS'=>'Day(s)',
 'LBL_WEEKS'=>'Week(s)',
 'LBL_MONTHS'=>'Month(s)',
 'LBL_YEAR'=>'Year',
 'LBL_NONE_SCHEDULED'=>'None Scheduled',
 
-'LBL_INVITE_INST1'=>'To invite, select the users from the "Available Users" list and click the "Add" button.',
+'LBL_INVITE_INST1'=>'To share, select the users from the "Available Users" list and click the "Add" button.',
 'LBL_INVITE_INST2'=>'To remove, select the users in the "Selected Users" list and the click "Remove" button.',
 'LBL_SELUSR_INFO'=>' Selected users will receive an email about the Event.',
 'LBL_CALSHAREMESSAGE'=>'Share my calendar with the following selected users',
@@ -229,7 +222,6 @@
 'LBL_ADD_BUTTON'=>'Add',
 'LBL_USERS'=>'Users',
 'LBL_RMV_BUTTON'=>'Remove',
-'LBL_RMD_ON'=>'Remind on',
 'LBL_SDRMD'=>'Send Reminder to',
 'LBL_ENABLE_REPEAT'=>'Enable Repeat',
 'LBL_REPEAT_ONCE'=>'Repeat once in every',
@@ -241,12 +233,13 @@
 
 
 
-//DON'T CONVERT THESE THEY ARE MAPPINGS
+//DON'T CONVERT THESE THEY ARE MAPPINGS - STARTS
 'db_last_name' => 'LBL_LIST_LAST_NAME',
 'db_first_name' => 'LBL_LIST_FIRST_NAME',
 'db_title' => 'LBL_LIST_TITLE',
 'db_email1' => 'LBL_LIST_EMAIL_ADDRESS',
 'db_email2' => 'LBL_LIST_EMAIL_ADDRESS',
+//DON'T CONVERT THESE THEY ARE MAPPINGS -ENDS
 'LBL_COMPLETED'=>'Mark Completed',
 'LBL_DEFERRED'=>'Mark Deferred',
 'LBL_HELD'=>'Mark Held',
@@ -254,7 +247,6 @@
 'LBL_POSTPONE'=>'Postpone',
 'LBL_CHANGEOWNER'=>'Change Owner',
 'LBL_DEL'=>'Delete',
-//END DON'T CONVERT
 
 //Added for actvity merge with calendar
 'LBL_SEARCH_FORM_TITLE'=>'Activity Search',
@@ -262,8 +254,13 @@
 'LBL_NEW_FORM_TITLE'=>'New Activity',
 'LBL_TASK_INFORMATION'=>'Task Information',
 'LBL_EVENT_INFORMATION'=>'Event Information',
+'LBL_CALENDAR_INFORMATION'=>'Calendar Information',
 
 'LBL_NAME'=>'Subject:',
+'LBL_ACTIVITY_NOTIFICATION'=>'This is a notification that an activity is assigned to you that has been',
+'LBL_ACTIVITY_INVITATION'=>'You have been invited for an activity that has been ',
+'LBL_DETAILS_STRING'=>'The details are',
+'LBL_REGARDS_STRING'=>'Thanks & Regards',
 'LBL_CONTACT_NAME'=>'Contact Name',
 'LBL_OPEN_ACTIVITIES'=>'Open Activities',
 'LBL_ACTIVITY'=>'Activity:',
@@ -362,14 +359,14 @@
 'LBL_INVITE'=>'Invite',
 'LBL_REPEAT'=>'Repeat',
 'LBL_REMINDER'=>'Reminder',
-'LBL_ENABLE_REPEAT'=>'Enable Repeat',
 'LBL_SENDREMINDER'=>'Send Reminder',
 'LBL_NOTIFICATION'=>'Notification',
 'LBL_SENDNOTIFICATION'=>'Send Notification',
 'LBL_RMD_ON'=>'Remind on',
 'LBL_REPEATEVENT'=>'Repeat once in every',
 'LBL_TIMEDATE'=>'Time & Date',
-'LBL_TODO'=>'To Do',
+'LBL_HR'=>'Hr',
+'LBL_MIN'=>'min',
 'LBL_EVENT'=>'Event',
 'Daily'=>'Day(s)',
 'Weekly'=>'Week(s)',
@@ -389,6 +386,8 @@
 'Last'=>'Last', 
 'on'=>'on', 
 'day of the month'=>'day of the month',
+'Private'=>'Private',
+'Public'=>'Public',
 
 //Added for existing Picklist entries
 
@@ -405,6 +404,17 @@
 'Call'=>'Call',
 'Meeting'=>'Meeting',
 
+//added to send dates and time in calendar notification/invitation mail.
+
+'Start date and time'=>'Start Date & Time',
+'End date and time'=>'End Date & Time',
+//this is for task
+'End date'=>'End date',
+'LBL_SET_DATE'=>'Set date..',
+'Recurrence'=>'Recurrence',
+'SHARED_EVENT_DEL_MSG'=>'The User does not have permission to Delete this record.',
+
+
 );
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/script.js
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/script.js (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/script.js Mon Apr 16 12:27:44 2007
@@ -23,7 +23,7 @@
                 }
                 else
                 {
-                        alert("Please select at least one user");
+                        alert(alert_arr.SELECT_ATLEAST_ONE_USER);
                         return false;
                 }
         }
@@ -43,11 +43,11 @@
                 }
                 else
                 {
-                        alert("Please select at least one user");
+                        alert(alert_arr.SELECT_ATLEAST_ONE_USER);
                         return false;
                 }
         }
-        if(confirm("Are you sure you want to disable sharing for selected "+xx+" user(s) ?"))
+        if(confirm(alert_arr.DISABLE_SHARING_CONFIRMATION+xx+alert_arr.USERS))
         {
                 document.SharedList.action="index.php?module=Calendar&action=disable_sharing&return_module=Calendar&return_action=calendar_share";
         }
@@ -92,6 +92,8 @@
 
 function gshow(argg1,type,startdate,enddate,starthr,startmin,startfmt,endhr,endmin,endfmt,viewOption,subtab)
 {
+	smin = parseInt(startmin,10);
+        smin = smin - (smin%5);
 	var y=document.getElementById(argg1).style;
 	
 		if(type == 'call' || type == 'meeting')
@@ -100,24 +102,22 @@
 	                        document.EditView.activitytype[0].checked = true;
 	                if(type == 'meeting')
         	                document.EditView.activitytype[1].checked = true;
-
+                        smin = _2digit(smin);
 			document.EditView.date_start.value = startdate;
-			document.EditView.due_date.value = enddate;
 			document.EditView.starthr.value = starthr;
-			document.EditView.startmin.value = startmin;
+			document.EditView.startmin.value = smin;
 			document.EditView.startfmt.value = startfmt;
-			document.EditView.endhr.value = endhr;
-			document.EditView.endmin.value = endmin;
-			document.EditView.endfmt.value = endfmt;
 			document.EditView.viewOption.value = viewOption;
                         document.EditView.subtab.value = subtab;
+			calDuedatetime(type);
 		}
 		if(type == 'todo')
 		{
+                        smin = _2digit(smin);
 			document.createTodo.task_date_start.value = startdate;
 			document.createTodo.task_due_date.value = enddate;
 			document.createTodo.starthr.value = starthr;
-                        document.createTodo.startmin.value = startmin;
+                        document.createTodo.startmin.value = smin;
                         document.createTodo.startfmt.value = startfmt;
 			document.createTodo.viewOption.value = viewOption;
                         document.createTodo.subtab.value = subtab;
@@ -190,57 +190,58 @@
 }
 function maincheck_form()
 {
-	formSelectColumnString('inviteesid');
-	starthour = document.EditView.starthr.value;
-        startmin  = document.EditView.startmin.value;
+	formSelectColumnString('inviteesid','selectedusers');
+	starthour = parseInt(document.EditView.starthr.value,10);
+        startmin  = parseInt(document.EditView.startmin.value,10);
         startformat = document.EditView.startfmt.value;
-	endhour = document.EditView.endhr.value;
-	endmin  = document.EditView.endmin.value;
-	endformat = document.EditView.endfmt.value;	
+        endhour = parseInt(document.EditView.endhr.value,10);
+        endmin  = parseInt(document.EditView.endmin.value,10);
+        endformat = document.EditView.endfmt.value;
+	followupformat = document.EditView.followup_startfmt.value;
+        followuphour = parseInt(document.EditView.followup_starthr.value,10);
+        followupmin = parseInt(document.EditView.followup_startmin.value,10);
 	if(formValidate())
 	{
 		if(startformat != '')
 		{
 			if(startformat == 'pm')
 			{
-				if(starthour == '12')
+				if(starthour == 12)
 					starthour = 12;
 				else
-					starthour = eval(starthour) + 12;
-				startmin  = startmin;
+					starthour = starthour + 12;
 			}
 			else
 			{
-				if(starthour == '12')
+				if(starthour == 12)
                                         starthour = 0;
 				else
 					starthour = starthour;
-				startmin  = startmin;
 			}
 		}
 		if(endformat != '')
 		{
 			if(endformat == 'pm')
 			{
-				if(endhour == '12')
+				if(endhour == 12)
 					endhour = 12;
 				else
-					endhour = eval(endhour) + 12;
-				endmin = endmin;
+					endhour = endhour + 12;
 			}
 			else
 			{
-				if(endhour == '12')
+				if(endhour == 12)
 					endhour = 0;
 				else
 					endhour = endhour;
-				endmin = endmin;
 			}
 		}
 		var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
 	        var dateval2=getObj('due_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
-		var dateelements1=splitDateVal(dateval1)
-      		var dateelements2=splitDateVal(dateval2)
+		var dateval3=getObj('followup_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+		var dateelements1=splitDateVal(dateval1);
+      		var dateelements2=splitDateVal(dateval2);
+		var dateelements3=splitDateVal(dateval3);
 
 	        dd1=dateelements1[0]
         	mm1=dateelements1[1]
@@ -249,8 +250,14 @@
         	dd2=dateelements2[0]
 	        mm2=dateelements2[1]
         	yyyy2=dateelements2[2]
+
+		dd3=dateelements3[0]
+                mm3=dateelements3[1]
+                yyyy3=dateelements3[2]
+
 		var date1=new Date()
 	        var date2=new Date()
+		var date3=new Date()
 
         	date1.setYear(yyyy1)
 	        date1.setMonth(mm1-1)
@@ -259,17 +266,22 @@
 	        date2.setYear(yyyy2)
         	date2.setMonth(mm2-1)
 	        date2.setDate(dd2)
+		
+		date3.setYear(yyyy3)
+                date3.setMonth(mm3-1)
+                date3.setDate(dd3)
+
 		if (date2<=date1)
 		{
-			if((eval(endhour)*60+eval(endmin)) <= (eval(starthour)*60+eval(startmin)))
-			{
-				alert("End Time should be greater than Start Time ");
+			if((endhour*60+endmin) <= (starthour*60+startmin))
+			{
+				alert(alert_arr.ENDTIME_GREATER_THAN_STARTTIME);
 				document.EditView.endhr.focus();
 				return false;
 			}
 			else
 			{
-				durationinmin = (eval(endhour)*60+eval(endmin)) - (eval(starthour)*60+eval(startmin));
+				durationinmin = (endhour*60+endmin) - (starthour*60+startmin);
                 		if(durationinmin >= 60)
               			{
               				hour = durationinmin/60;
@@ -284,8 +296,67 @@
                 		document.EditView.duration_minutes.value = minute;
 			}
 		}
-		document.EditView.time_start.value = starthour+':'+startmin;
-		document.EditView.time_end.value = endhour+':'+endmin;
+		event_starthour = _2digit(starthour);
+		event_startmin = _2digit(startmin);
+		event_endhour = _2digit(endhour);
+		event_endmin = _2digit(endmin);
+                document.EditView.time_start.value = event_starthour+':'+event_startmin;
+                document.EditView.time_end.value = event_endhour+':'+event_endmin;
+		// Added for Aydin Kurt-Elli requirement START -by Minnie
+                if (document.EditView.followup.checked == true && document.getElementById('date_table_thirdtd').style.display == 'block' )
+                {
+                        if(!dateValidate('followup_date','Followup Date','OTH'))
+                        {
+                                return false;
+                        }
+                        if(followupformat != '')
+                        {
+                                if(followupformat == 'pm')
+                                {
+                                        if(followuphour == 12)
+                                                followuphour = 12;
+                                        else
+                                                followuphour = followuphour + 12;
+                                }
+                                else
+                                {
+                                        if(followuphour == 12)
+                                                followuphour = 0;
+                                        else
+                                                followuphour = followuphour;
+                                }
+                        }
+
+                        if ( compareDates(date3,'Followup Date',date2,'End Date','GE'))
+			{
+			 	if (date3 <= date2)
+                                {
+                                        if((followuphour*60+followupmin) <= (endhour*60+endmin))
+                                        {
+                                                alert(alert_arr.FOLLOWUPTIME_GREATER_THAN_STARTTIME);
+                                                document.EditView.followup_starthr.focus();
+                                                return false;
+                                        }
+                                }
+                        }
+                        else
+                                return false;
+
+                        followupendhour = followuphour;
+                        followupendmin = followupmin + 5;
+                        if(followupendmin == 60)
+                        {
+                                followupendmin = 0;
+                                followupendhour = followupendhour + 1;
+                        }
+			followuphour = _2digit(followuphour);
+			followupmin = _2digit(followupmin);
+			followupendhour = _2digit(followupendhour);
+			followupendmin = _2digit(followupendmin);
+                        document.EditView.followup_time_start.value = followuphour+':'+followupmin;
+                        document.EditView.followup_time_end.value = followupendhour+':'+followupendmin;
+                }
+                // Added for Aydin Kurt-Elli requirement END -by Minnie
 		return true;
 	}
 	else return false;
@@ -294,10 +365,10 @@
 }
 function check_form()
 {
-	formSelectColumnString('inviteesid');
+	formSelectColumnString('inviteesid','selectedusers');
         if(trim(document.EditView.subject.value) == "")
         {
-                alert("Missing Event Name");
+                alert(alert_arr.MISSING_EVENT_NAME);
                 document.EditView.subject.focus()
                 return false;
         }
@@ -311,48 +382,47 @@
 		{
 			document.EditView.mode.value = 'create';
 		}
-		starthour = document.EditView.starthr.value;
-		startmin  = document.EditView.startmin.value;
-		startformat = document.EditView.startfmt.value;
-		endhour = document.EditView.endhr.value;
-                endmin  = document.EditView.endmin.value;
+		starthour = parseInt(document.EditView.starthr.value,10);
+                startmin  = parseInt(document.EditView.startmin.value,10);
+                startformat = document.EditView.startfmt.value;
+                endhour = parseInt(document.EditView.endhr.value,10);
+                endmin  = parseInt(document.EditView.endmin.value,10);
                 endformat = document.EditView.endfmt.value;
+		followupformat = document.EditView.followup_startfmt.value;
+                followuphour = parseInt(document.EditView.followup_starthr.value,10);
+                followupmin = parseInt(document.EditView.followup_startmin.value,10);
 		if(startformat != '')
 		{
 			if(startformat == 'pm')
 			{
-				if(starthour == '12')
+				if(starthour == 12)
 					starthour = 12;
 				else
-					starthour = eval(starthour) + 12;
-				startmin  = startmin;
+					starthour = starthour + 12;
 			}
 			else
 			{
-				if(starthour == '12')
+				if(starthour == 12)
                                 	starthour = 0;
 				else
 					starthour = starthour;
-				startmin  = startmin;
 			}
 		}
 		if(endformat != '')
 		{
 			if(endformat == 'pm')
                         {
-				if(endhour == '12')
+				if(endhour == 12)
                                         endhour = 12;
                                 else
-                                        endhour = eval(endhour) + 12;
-				endmin = endmin;
+                                        endhour = endhour + 12;
                         }
 			else
 			{
-				if(endhour == '12')
+				if(endhour == 12)
 					endhour == 0;
 				else
 					endhour = endhour;
-				endmin = endmin;
 			}
 		}
 		if(!dateValidate('date_start','Start date','OTH'))
@@ -367,8 +437,11 @@
 		{
 			var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
         	        var dateval2=getObj('due_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+			var dateval3=getObj('followup_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+
 	                var dateelements1=splitDateVal(dateval1)
                 	var dateelements2=splitDateVal(dateval2)
+			var dateelements3=splitDateVal(dateval3)
 
 	                dd1=dateelements1[0]
         	        mm1=dateelements1[1]
@@ -377,8 +450,14 @@
 	                dd2=dateelements2[0]
         	        mm2=dateelements2[1]
                 	yyyy2=dateelements2[2]
+
+			dd3=dateelements3[0]
+                        mm3=dateelements3[1]
+                        yyyy3=dateelements3[2]
+
 	                var date1=new Date()
         	        var date2=new Date()
+			var date3=new Date()
 
                 	date1.setYear(yyyy1)
 	                date1.setMonth(mm1-1)
@@ -387,15 +466,19 @@
         	        date2.setYear(yyyy2)
 	                date2.setMonth(mm2-1)
                 	date2.setDate(dd2)
+
+			date3.setYear(yyyy3)
+                        date3.setMonth(mm3-1)
+                        date3.setDate(dd3)
                 	if (date2<=date1)
                 	{
-                        	if((eval(endhour)*60+eval(endmin)) <= (eval(starthour)*60+eval(startmin)))
+                        	if((endhour*60+endmin) <= (starthour*60+startmin))
           	        	{
-                	                alert("End Time should be greater than Start Time ");
+                	                alert(alert_arr.ENDTIME_GREATER_THAN_STARTTIME);
                                 	document.EditView.endhr.focus();
      		                        return false;
                 	        }
-				durationinmin = (eval(endhour)*60+eval(endmin)) - (eval(starthour)*60+eval(startmin));
+				durationinmin = (endhour*60+endmin) - (starthour*60+startmin);
 	                        if(durationinmin >= 60)
         	                {
                 	                hour = durationinmin/60;
@@ -410,11 +493,70 @@
 	                        document.EditView.duration_minutes.value = minute;
 
            		}
+			
+                        event_starthour = _2digit(starthour);
+                        event_startmin = _2digit(startmin);
+                        event_endhour = _2digit(endhour);
+                        event_endmin = _2digit(endmin);
+                        document.EditView.time_start.value = event_starthour+':'+event_startmin;
+                        document.EditView.time_end.value = event_endhour+':'+event_endmin;
+			// Added for Aydin Kurt-Elli requirement START -by Minnie
+                        if (document.EditView.followup.checked == true && document.getElementById('date_table_thirdtd').style.display == 'block')
+                        {
+                                if(!dateValidate('followup_date','Followup Date','OTH'))
+                                {
+                                        return false;
+                                }
+                                if(followupformat != '')
+                                {
+                                        if(followupformat == 'pm')
+                                        {
+                                                if(followuphour == 12)
+                                                        followuphour = 12;
+                                                else
+                                                        followuphour = followuphour + 12;
+                                        }
+                                        else
+                                        {
+                                                if(followuphour == 12)
+                                                        followuphour = 0;
+                                                else
+                                                        followuphour = followuphour;
+                                        }
+                                }
+				
+				if ( compareDates(date3,'Followup Date',date2,'End Date','GE'))
+                                {
+                                        if (date3 <= date2)
+                                        {
+                                                if((followuphour*60+followupmin) <= (endhour*60+endmin))
+                                                {
+                                                        alert(alert_arr.FOLLOWUPTIME_GREATER_THAN_STARTTIME);
+                                                        document.EditView.followup_starthr.focus();
+                                                        return false;
+                                                }
+                                        }
+                                }
+                                else return false;
+
+                                followupendhour = followuphour;
+                                followupendmin = followupmin + 5;
+                                if(followupendmin == 60)
+                                {
+                                        followupendmin = 0;
+                                        followupendhour = followupendhour + 1;
+                                }
+				followuphour = _2digit(followuphour);
+			        followupmin = _2digit(followupmin);
+				followupendhour = _2digit(followupendhour);
+			        followupendmin = _2digit(followupendmin);
+                                document.EditView.followup_time_start.value = followuphour+':'+followupmin;
+                                document.EditView.followup_time_end.value = followupendhour+':'+followupendmin;
+                        }
+                        // Added for Aydin Kurt-Elli requirement END -by Minnie -->
 		}	
 		else
 			return false;
-		document.EditView.time_start.value = starthour+':'+startmin;
-		document.EditView.time_end.value = endhour+':'+endmin;
 		if(document.EditView.recurringcheck.checked == false)
                 {
                         document.EditView.recurringtype.value = '--None--';
@@ -425,30 +567,30 @@
 
 function task_check_form()
 {
-	starthour = document.createTodo.starthr.value;
-	startmin  = document.createTodo.startmin.value;
+	starthour = parseInt(document.createTodo.starthr.value,10);
+        startmin  = parseInt(document.createTodo.startmin.value,10);
         startformat = document.createTodo.startfmt.value;
 	if(startformat != '')
 	{
         	if(startformat == 'pm')
                 {
-			if(starthour == '12')
+			if(starthour == 12)
 				starthour = 12;
 			else
-                		starthour = eval(starthour) + 12;
-			
-                        startmin  = startmin;
+                		starthour = starthour + 12;
+
                 }
                 else
                 {
-			if(starthour == '12')
+			if(starthour == 12)
 				starthour = 0;
 			else
 				starthour = starthour;
-                        startmin  = startmin;
-                }
-        }
-	document.createTodo.task_time_start.value = starthour+':'+startmin;
+                }
+        }
+	starthour = _2digit(starthour);
+        startmin = _2digit(startmin);
+        document.createTodo.task_time_start.value = starthour+':'+startmin;
 	if(document.createTodo.record.value != '')
         {
         	document.createTodo.mode.value = 'edit';
@@ -463,131 +605,100 @@
 
 function maintask_check_form()
 {
-        starthour = document.EditView.starthr.value;
-        startmin  = document.EditView.startmin.value;
+	starthour = parseInt(document.EditView.starthr.value,10);
+        startmin  = parseInt(document.EditView.startmin.value,10);
         startformat = document.EditView.startfmt.value;
         if(startformat != '')
         {
                 if(startformat == 'pm')
                 {
-			if(starthour == '12')
+			if(starthour == 12)
 				starthour = 12;
 			else
-				starthour = eval(starthour) + 12;
-                        startmin  = startmin;
+				starthour = starthour + 12;
                 }
                 else
                 {
-			if(starthour == '12')
+			if(starthour == 12)
                                 starthour = 0;
                         else
                                 starthour = starthour;
-                        startmin  = startmin;
-                }
-        }
+                }
+        }
+	starthour = _2digit(starthour);
+        startmin = _2digit(startmin);
         document.EditView.time_start.value = starthour+':'+startmin;
 }
 
 
 var moveupLinkObj,moveupDisabledObj,movedownLinkObj,movedownDisabledObj;
-function setObjects()
-{
-        availListObj=getObj("availableusers")
-        selectedColumnsObj=getObj("selectedusers")
-
-}
-
-
-
-function addColumn()
-{
+
+function userEventSharing(selectedusrid,selcolid)
+{
+        formSelectColumnString(selectedusrid,selcolid);
+}
+
+
+function incUser(avail_users,sel_users)
+{
+	availListObj=getObj(avail_users)
+        selectedColumnsObj=getObj(sel_users)
         var selectlength=selectedColumnsObj.length
         var availlength=availListObj.length
-        var s=0
-        for (i=0;i<selectlength;i++)
-        {
-                selectedColumnsObj.options[i].selected=false
-        }
-        for (i=0;i<availlength;i++)
-        {
-                if (availListObj.options[s].selected==true)
-                {
-                        for (j=0;j<selectlength;j++)
-                        {
-                                if (selectedColumnsObj.options[j].value==availListObj.options[s].value)
-                                {
-                                        var rowFound=true
-                                        var existingObj=selectedColumnsObj.options[j]
-                                        breaK;
-                                }
-                        }
-                        if (rowFound!=true)
-                        {
-                                var newColObj=document.createElement("OPTION")
-                                        newColObj.value=availListObj.options[s].value
-                                        if (browser_ie) newColObj.innerText=availListObj.options[s].innerText
-                                        else if (browser_nn4 || browser_nn6) newColObj.text=availListObj.options[s].text
-                                                selectedColumnsObj.appendChild(newColObj)
-                                        availListObj.removeChild(availListObj.options[s])
-                                        newColObj.selected=true
-                                        rowFound=false
-                        }
-                        else
-                        {
-                                existingObj.selected=true
-                        }
-                }
-		else
-                        s++
-        }
-}
-
-function delColumn()
-{
-        var selectlength=selectedColumnsObj.length
-        var availlength=availListObj.length
-        var s=0
-        for (i=0;i<availlength;i++)
-        {
-                availListObj.options[i].selected=false
-        }
-        for (i=0;i<selectlength;i++)
-        {
-                if (selectedColumnsObj.options[s].selected==true)
-                {
-                        for (j=0;j<availlength;j++)
-                        {
-                                if (availListObj.options[j].value==selectedColumnsObj.options[s].value)
-                                {
-                                        var rowFound=true
-                                        var existingObj=availListObj.options[j]
-                                        breaK;
-                                }
-                        }
-
-                        if (rowFound!=true)
-                        {
-                                var newColObj=document.createElement("OPTION")
-                                        newColObj.value=selectedColumnsObj.options[s].value
-                                        if (browser_ie) newColObj.innerText=selectedColumnsObj.options[s].innerText
-                                        else if (browser_nn4 || browser_nn6) newColObj.text=selectedColumnsObj.options[s].text
-                                                availListObj.appendChild(newColObj)
-                                        selectedColumnsObj.removeChild(selectedColumnsObj.options[s])
-                                        newColObj.selected=true
-                                        rowFound=false
-                        }
-                        else
-                        {
-                                existingObj.selected=true
-                        }
-                }
-		else
-                        s++
-        }
-}
-
-function formSelectColumnString(usr)
-{
+
+	for (i=0;i<selectedColumnsObj.length;i++) 
+	{
+		selectedColumnsObj.options[i].selected=false
+	}
+	for (i=0;i<availListObj.length;i++) 
+	{
+		if (availListObj.options[i].selected==true) 
+		{
+			for (j=0;j<selectedColumnsObj.length;j++) 
+			{
+				if (selectedColumnsObj.options[j].value==availListObj.options[i].value) 
+				{
+					var rowFound=true
+						var existingObj=selectedColumnsObj.options[j]
+						break
+				}
+			}
+			if (rowFound!=true) 
+			{
+				var newColObj=document.createElement("OPTION")
+					newColObj.value=availListObj.options[i].value
+					if (browser_ie) newColObj.innerText=availListObj.options[i].innerText
+					else if (browser_nn4 || browser_nn6) newColObj.text=availListObj.options[i].text
+						selectedColumnsObj.appendChild(newColObj)
+							availListObj.options[i].selected=false
+							newColObj.selected=true
+							rowFound=false
+			}
+			else 
+			{
+				existingObj.selected=true
+			}
+		}
+	}
+}
+
+function rmvUser(sel_users)
+{
+	selectedColumnsObj=getObj(sel_users)
+        var selectlength=selectedColumnsObj.options.length
+	for(i = 0; i <= selectlength; i++)
+	{
+		if(selectedColumnsObj.options.selectedIndex >= 0)
+		selectedColumnsObj.remove(selectedColumnsObj.options.selectedIndex)	
+	}
+	
+}
+
+
+function formSelectColumnString(usr,col)
+{
+	
+	var selectedColumnsObj=getObj(col)
 	usr_id = document.getElementById(usr);
 	var selectedColStr = "";
         for (i=0;i<selectedColumnsObj.options.length;i++)
@@ -676,9 +787,17 @@
                         	postBody: 'module=Calendar&action=ActivityAjax&record='+record+'&'+status+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=change_status&viewOption='+OptionData+'&subtab=event&ajax=true',
                         	onComplete: function(response) {
 					if(OptionData == 'listview')
-						$("listView").innerHTML=response.responseText;
+					{
+						result = response.responseText.split('####');
+                                                $("total_activities").innerHTML = result[1];
+                                                $("listView").innerHTML=result[0];
+					}		
                                 	if(OptionData == 'hourview')
-                        			$("hrView").innerHTML=response.responseText;
+					{
+						result = response.responseText.split('####');
+                                                $("total_activities").innerHTML = result[1];	
+                        			$("hrView").innerHTML=result[0];
+					}
                         	}
                 	}
 		);
@@ -691,20 +810,26 @@
                                 method: 'post',
 				postBody: 'module=Calendar&action=ActivityAjax&record='+record+'&'+status+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=change_status&subtab=todo&ajax=true',
                                 onComplete: function(response) {
-                                        $("mnuTab2").innerHTML=response.responseText;
+					result = response.responseText.split('####');
+					$("total_activities").innerHTML = result[1];
+					$("mnuTab2").innerHTML=result[0];
                                 }
                         }
                 )
 	}
 }
 
-function getcalAction(obj,Lay,id,view,hour,day,month,year,type){
+function getcalAction(obj,Lay,id,view,hour,dateVal,type,isShared){
     var tagName = document.getElementById(Lay);
     var leftSide = findPosX(obj);
     var topSide = findPosY(obj);
     var maxW = tagName.style.width;
     var widthM = maxW.substring(0,maxW.length-2);
     var getVal = eval(leftSide) + eval(widthM);
+    var vtDate = dateVal.split("-");
+    var day = parseInt(vtDate[2],10);
+    var month = parseInt(vtDate[1],10);
+    var year = parseInt(vtDate[0],10);
     if(getVal  > window.innerWidth ){
         leftSide = eval(leftSide) - eval(widthM);
         tagName.style.left = leftSide + 'px';
@@ -746,11 +871,19 @@
     document.change_owner.month.value = month;
     document.change_owner.year.value = year;
     document.change_owner.subtab.value = type;
-    complete.href="javascript:updateStatus("+id+",'"+heldstatus+"','"+view+"',"+hour+","+day+","+month+","+year+",'"+type+"')";
-    pending.href="javascript:updateStatus("+id+",'"+notheldstatus+"','"+view+"',"+hour+","+day+","+month+","+year+",'"+type+"')";
-    postpone.href="index.php?module=Calendar&action=EditView&record="+id+"&activity_mode="+activity_mode;
-    actdelete.href="javascript:delActivity("+id+",'"+view+"',"+hour+","+day+","+month+","+year+",'"+type+"')";
-    changeowner.href="javascript:dispLayer('act_changeowner');";
+    if(complete) complete.href="javascript:updateStatus("+id+",'"+heldstatus+"','"+view+"',"+hour+","+day+","+month+","+year+",'"+type+"')";
+    if(pending) pending.href="javascript:updateStatus("+id+",'"+notheldstatus+"','"+view+"',"+hour+","+day+","+month+","+year+",'"+type+"')";
+
+    if(postpone) postpone.href="index.php?module=Calendar&action=EditView&record="+id+"&return_action=index&activity_mode="+activity_mode+"&view="+view+"&hour="+hour+"&day="+day+"&month="+month+"&year="+year+"&viewOption="+OptionData+"&subtab="+type+"&maintab=Calendar";
+    if(isShared == "shared")
+    {
+	if(actdelete) actdelete.href="javascript:alert('"+alert_arr.SHARED_EVENT_DEL_MSG+"')";	
+    }
+    else
+    {
+	if(actdelete) actdelete.href="javascript:delActivity("+id+",'"+view+"',"+hour+","+day+","+month+","+year+",'"+type+"')";
+    }	
+    if(changeowner) changeowner.href="javascript:dispLayer('act_changeowner');";
 
 }
 
@@ -760,43 +893,83 @@
         tagName.style.visibility = 'visible';
         tagName.style.display = 'block';
 }
+//check whether user form selected or group form selected
+function checkgroup()
+{
+	if(document.change_owner.user_lead_owner[1].checked)
+	{
+		  document.change_owner.lead_group_owner.style.display = "block";
+	          document.change_owner.lead_owner.style.display = "none";
+	}
+	else
+	{
+		document.change_owner.lead_group_owner.style.display = "none";
+                document.change_owner.lead_owner.style.display = "block";
+	}
+}
 
 function calendarChangeOwner()
 {
-	var user_id = document.getElementById('activity_owner').options[document.getElementById('activity_owner').options.selectedIndex].value;
 	var idlist = document.change_owner.idlist.value;
         var view   = document.change_owner.view.value;
         var day    = document.change_owner.day.value;
         var month  = document.change_owner.month.value;
         var year   = document.change_owner.year.value;
         var hour   = document.change_owner.hour.value;
-	var subtab = document.change_owner.subtab.value;
+        var subtab = document.change_owner.subtab.value;
+
+	var checked = document.change_owner.user_lead_owner[0].checked;
+	if(checked==true)
+	{
+		var user_id = document.getElementById('lead_owner').options[document.getElementById('lead_owner').options.selectedIndex].value;
+		var url = 'module=Users&action=updateLeadDBStatus&return_module=Calendar&return_action=ActivityAjax&user_id='+user_id+'&idlist='+idlist+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=change_owner';
+	}
+	else
+	{
+		var group_id = document.getElementById('lead_group_owner').options[document.getElementById('lead_group_owner').options.selectedIndex].value;
+		var url = 'module=Users&action=updateLeadDBStatus&return_module=Calendar&return_action=ActivityAjax&group_id='+group_id+'&idlist='+idlist+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=change_owner';
+	}
+		
 	if(subtab == 'event')
 	{
 		var OptionData = $('view_Option').options[$('view_Option').selectedIndex].value;
+		var eventurl = url+'&viewOption='+OptionData+'&subtab=event&ajax=true';
+		
 	 	new Ajax.Request(
                 	'index.php',
                 	{queue: {position: 'end', scope: 'command'},
                         	method: 'post',
-                        	postBody: 'module=Users&action=updateLeadDBStatus&return_module=Calendar&return_action=ActivityAjax&user_id='+user_id+'&idlist='+idlist+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=change_owner&viewOption='+OptionData+'&subtab=event&ajax=true',
+                        	postBody: eventurl,
                         	onComplete: function(response) {
 					if(OptionData == 'listview')
-						 $("listView").innerHTML=response.responseText;
+					{
+						result = response.responseText.split('####');
+                                                $("total_activities").innerHTML = result[1];
+                                                $("listView").innerHTML=result[0];
+					}
 					if(OptionData == 'hourview')
-                                        	$("hrView").innerHTML=response.responseText;
+					{
+						result = response.responseText.split('####');
+                                                $("total_activities").innerHTML = result[1];
+                                                $("hrView").innerHTML=result[0];
+					}
                         	}
                 	}
 		);
 	}
 	if(subtab == 'todo')
         {
+		
+		var todourl = url+'&subtab=todo&ajax=true';
                 new Ajax.Request(
                         'index.php',
                         {queue: {position: 'end', scope: 'command'},
                                 method: 'post',
-                                postBody: 'module=Users&action=updateLeadDBStatus&return_module=Calendar&return_action=ActivityAjax&user_id='+user_id+'&idlist='+idlist+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=change_owner&subtab=todo&ajax=true',
+                                postBody: todourl,
                                 onComplete: function(response) {
-                                        $("mnuTab2").innerHTML=response.responseText;
+					result = response.responseText.split('####');
+					$("total_activities").innerHTML = result[1];
+					$("mnuTab2").innerHTML=result[0];
                                 }
                         }
                 );
@@ -816,9 +989,18 @@
                         	postBody: 'module=Users&action=massdelete&return_module=Calendar&return_action=ActivityAjax&idlist='+id+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=activity_delete&viewOption='+OptionData+'&subtab=event&ajax=true',
                         	onComplete: function(response) {
 					if(OptionData == 'listview')
-                                        	$("listView").innerHTML=response.responseText;
+		                        {
+                                                result = response.responseText.split('####');
+                                                $("total_activities").innerHTML = result[1];
+                                                $("listView").innerHTML=result[0];
+                                        }
                                 	if(OptionData == 'hourview')
-                                        	$("hrView").innerHTML=response.responseText;
+					{
+
+                                                result = response.responseText.split('####');
+                                                $("total_activities").innerHTML = result[1];
+                                                $("hrView").innerHTML=result[0];
+                                        }
                         	}
                 	}
 		);
@@ -831,7 +1013,9 @@
                                 method: 'post',
                                 postBody: 'module=Users&action=massdelete&return_module=Calendar&return_action=ActivityAjax&idlist='+id+'&view='+view+'&hour='+hour+'&day='+day+'&month='+month+'&year='+year+'&type=activity_delete&subtab=todo&ajax=true',
                                 onComplete: function(response) {
-                                        $("mnuTab2").innerHTML=response.responseText;
+					result = response.responseText.split('####');
+					$("total_activities").innerHTML = result[1];
+					$("mnuTab2").innerHTML=result[0];
                                 }
                         }
                 );
@@ -1013,3 +1197,226 @@
         }
 }
 
+function dochange(start,end)
+{
+        var startdate = document.getElementById(start);
+        document.getElementById(end).value = startdate.value;
+}
+
+function getSelectedStatus()
+{
+        var chosen = document.EditView.eventstatus.value;
+        if(chosen == "Held")
+        {
+                document.getElementById('date_table_firsttd').style.width = "33%";
+                document.getElementById('date_table_secondtd').style.width = "33%";
+                document.getElementById('date_table_thirdtd').style.display = 'block';
+        }
+        else
+        {
+                document.getElementById('date_table_firsttd').style.width = "50%";
+                document.getElementById('date_table_secondtd').style.width = "50%";
+                document.getElementById('date_table_thirdtd').style.display = 'none';
+        }
+
+}
+
+function changeEndtime_StartTime()
+{
+        var select_call = document.EditView.activitytype[0].checked;
+        var select_meeting = document.EditView.activitytype[1].checked;
+        if(select_call)
+                calDuedatetime('call');
+        else if(select_meeting)
+                calDuedatetime('meeting');
+        else
+                alert(alert_arr.EVENT_TYPE_NOT_SELECTED);
+}
+
+function calDuedatetime(type)
+{
+        var datefmt = document.EditView.dateformat.value;
+        var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        var dateelements1=splitDateVal(dateval1);
+        dd1=parseInt(dateelements1[0],10);
+        mm1=dateelements1[1];
+        yyyy1=dateelements1[2];
+        var date1=new Date();
+        //date1.setDate(dd1+1);
+        date1.setYear(yyyy1);
+        date1.setMonth(mm1-1,dd1+1);
+        var yy = date1.getFullYear();
+        var mm = parseInt(date1.getMonth(),10) + 1;
+        var dd = date1.getDate();
+        var date = document.EditView.date_start.value;
+        var hour = parseInt(document.EditView.starthr.value,10);
+        var min = parseInt(document.EditView.startmin.value,10);
+        var fmt = document.EditView.startfmt.value;
+	dd = _2digit(dd);
+        mm = _2digit(mm);	
+        if(datefmt == '%d-%m-%Y')
+        {
+                var tempdate = dd+'-'+mm+'-'+yy;
+        }else if(datefmt == '%m-%d-%Y')
+        {
+                var tempdate = mm+'-'+dd+'-'+yy;
+        }else
+        {
+                var tempdate = yy+'-'+mm+'-'+dd;
+        }
+	if(type == 'meeting')
+        {
+                if(fmt == 'pm')
+                {
+                        if(hour == 11)
+                        {
+                                date = tempdate;
+                                hour = 12;
+                                min = min;
+                                fmt = 'am';
+
+                        }else if(hour == 12)
+                        {
+                                hour = 1;
+                                min = min;
+                                fmt = 'pm';
+			}
+                	else hour = hour + 1;
+			hour = _2digit(hour);
+                        min = _2digit(min);
+			document.EditView.due_date.value = date;
+			document.EditView.endhr.value = hour;
+			document.EditView.endmin.value = min;
+			document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+		}else if(fmt == 'am')
+		{
+                        if(hour == 11)
+                        {
+                                hour = 12; min = min; fmt = 'pm';
+                        }else if(hour == 12)
+                        {
+                                hour = 1; min = min; fmt = 'am';
+                        }
+                        else hour = hour + 1;
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+                        document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+                }else
+		{
+                        hour = hour + 1;
+                        if(hour == 24)
+                        {
+                                hour = 0;
+                                date =  tempdate;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                }
+        }
+	if(type == 'call')
+        {
+                if(fmt == 'pm')
+                {
+                        if(hour == 11 && min == 55)
+                        {
+                                hour = 12; min = 0; fmt = 'am';
+                                date = tempdate;
+                        }
+			else if(hour == 12 && min == 55)
+			{
+				hour = 1; min = 0; fmt = 'pm';
+			}
+                        else
+                        {
+                                if(min == 55)
+                                {
+                                        min = 0;
+                                        hour = hour + 1;
+                                }
+                                else    min = min + 5;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+                        document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+                }else if(fmt == 'am')
+		{
+                        if(hour == 11 && min == 55)
+                        {
+                                hour = 12;
+                                min = 0;
+                                fmt = 'pm';
+                        }
+			else if(hour == 12 && min == 55)
+			{
+				hour = 1;
+                                min = 0;
+				fmt = 'am';
+			}
+                        else
+                        {
+                                if(min == 55)
+                                {
+                                        min = 0;
+                                        hour = hour + 1;
+                                }
+                                else    min = min + 5;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+                        document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+                }
+                else
+		{
+                        if(min == 55)
+                        {
+                                min = 0;
+                                hour = hour + 1;
+                        }else min = min + 5;
+                        if(hour == 24)
+                        {
+                                hour = 0;
+                                date =  tempdate;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                }
+        }
+}
+

Modified: vtigercrm/branches/5.1_jens/modules/Calendar/updateCalendarSharing.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Calendar/updateCalendarSharing.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Calendar/updateCalendarSharing.php Mon Apr 16 12:27:44 2007
@@ -17,7 +17,8 @@
 	$hour_format = 'am/pm';
 $delquery = "delete from vtiger_sharedcalendar where userid=".$_REQUEST["current_userid"];
 $adb->query($delquery);
-$sharedid = $_REQUEST['user'];
+$selectedid = $_REQUEST['shar_userid'];
+$sharedid = explode (";",$selectedid);
 if(isset($sharedid) && $sharedid != null)
 {
         foreach($sharedid as $sid)

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/CallRelatedList.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/CallRelatedList.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/CallRelatedList.php Mon Apr 16 12:27:44 2007
@@ -12,7 +12,6 @@
 
 require_once('Smarty_setup.php');
 require_once('modules/Campaigns/Campaigns.php');
-require_once('modules/CustomView/CustomView.php');
 require_once('include/utils/utils.php');
 //Redirecting Header for single page layout 
 require_once('user_privileges/default_module_view.php');
@@ -38,7 +37,7 @@
 }
 
 global $mod_strings;
-global $app_strings;
+global $app_strings,$adb;
 global $theme;
 global $currentModule;
 $theme_path="themes/".$theme."/";
@@ -57,13 +56,29 @@
 $related_array=getRelatedLists($currentModule,$focus);
 $smarty->assign("RELATEDLISTS", $related_array);
 
-$cvObj = new CustomView("Contacts");
-$cvcombo = $cvObj->getCustomViewCombo();
-$smarty->assign("CONTCVCOMBO","<select id='cont_cv_list' onchange='loadCvList(\"Contacts\",".$_REQUEST["record"].");'><option value='None'>-- ".$mod_strings['Select One']." --</option>".$cvcombo."</select>");
+/* To get Contacts CustomView -START */
+$sql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype where vtiger_tab.tabid=".getTabid('Contacts');
+$result = $adb->query($sql);
+$chtml = "<select id='cont_cv_list'><option value='None'>-- ".$mod_strings['Select One']." --</option>";
+while($cvrow=$adb->fetch_array($result))
+{
+	 $chtml .= "<option value=\"".$cvrow['cvid']."\">".$cvrow['viewname']."</option>";
+}
+$chtml .= "</select>";
+$smarty->assign("CONTCVCOMBO",$chtml);
+/* To get Contacts CustomView -END */
 
-$cvObj = new CustomView("Leads");
-$cvcombo = $cvObj->getCustomViewCombo();
-$smarty->assign("LEADCVCOMBO","<select id='lead_cv_list' onchange='loadCvList(\"Leads\",".$_REQUEST["record"].");'> <option value='None'>-- ".$mod_strings['Select One']." --</option>".$cvcombo."</select>");
+/* To get Leads CustomView -START */
+$sql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype where vtiger_tab.tabid=".getTabid('Leads');
+$result = $adb->query($sql);
+$lhtml = "<select id='lead_cv_list'><option value='None'>-- ".$mod_strings['Select One']." --</option>";
+while($cvrow=$adb->fetch_array($result))
+{
+	 $lhtml .= "<option value=\"".$cvrow['cvid']."\">".$cvrow['viewname']."</option>";
+}
+$lhtml .= "</select>";
+$smarty->assign("LEADCVCOMBO",$lhtml);
+/* To get Leads CustomView -END */
 
 $category = getParentTab();
 $smarty->assign("CATEGORY",$category);
@@ -79,6 +94,9 @@
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
 
-$smarty->display("RelatedLists.tpl");
+if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')
+        $smarty->display("RelatedListContents.tpl");
+else
+	$smarty->display("RelatedLists.tpl");
 }
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/Campaigns.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/Campaigns.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/Campaigns.php Mon Apr 16 12:27:44 2007
@@ -1,252 +1,255 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of txhe License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('include/utils/utils.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('modules/Leads/Leads.php');
-require_once('user_privileges/default_module_view.php');
-
-class Campaigns extends CRMEntity {
-	var $log;
-	var $db;
-
-
-	var $tab_name = Array('vtiger_crmentity','vtiger_campaign','vtiger_campaignscf');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_campaign'=>'campaignid','vtiger_campaignscf'=>'campaignid');
-	var $column_fields = Array();
-
-	var $sortby_fields = Array('campaignname','smownerid','campaigntype','product_id','expectedrevenue','closingdate','campaignstatus','expectedresponse','targetaudience','expectedcost');
-
-	var $list_fields = Array(
-					'Campaign Name'=>Array('campaign'=>'campaignname'),
-					'Campaign Type'=>Array('campaign'=>'campaigntype'),
-					'Campaign Status'=>Array('campaign'=>'campaignstatus'),
-					'Expected Revenue'=>Array('campaign'=>'expectedrevenue'),
-					'Expected Close Date'=>Array('campaign'=>'closingdate'),
-					'Assigned To' => Array('crmentity'=>'smownerid')
-				);
-
-	var $list_fields_name = Array(
-					'Campaign Name'=>'campaignname',
-					'Campaign Type'=>'campaigntype',
-					'Campaign Status'=>'campaignstatus',
-					'Expected Revenue'=>'expectedrevenue',
-					'Expected Close Date'=>'closingdate',
-					'Assigned To'=>'assigned_user_id'
-				     );	  			
-
-	var $list_link_field= 'campaignname';
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'crmid';
-	var $default_sort_order = 'DESC';
-
-	var $search_fields = Array(
-			'Campaign Name'=>Array('vtiger_campaign'=>'campaignname'),
-			'Campaign Type'=>Array('vtiger_campaign'=>'campaigntype'),
-			);
-
-	var $search_fields_name = Array(
-			'Campaign Name'=>'campaignname',
-			'Campaign Type'=>'campaigntype',
-			);
-
-	function Campaigns() 
-	{
-		$this->log =LoggerManager::getLogger('campaign');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Campaigns');
-	}
-
-
-	/** Function to handle module specific operations when saving a entity 
-	*/
-	function save_module($module)
-	{
-	}
-
-	
-	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
-	/**
-	 * Function to get sort order
-	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	 */
-	function getSortOrder()
-	{
-		global $log;
-		$log->debug("Entering getSortOrder() method ...");
-		if(isset($_REQUEST['sorder']))
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['CAMPAIGN_SORT_ORDER'] != '')?($_SESSION['CAMPAIGN_SORT_ORDER']):($this->default_sort_order));
-
-		$log->debug("Exiting getSortOrder method ...");
-		return $sorder;
-	}
-
-	/**
-	 * Function to get order by
-	 * return string  $order_by    - fieldname(eg: 'campaignname')
-	 */
-	function getOrderBy()
-	{
-		global $log;
-		$log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by']))
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['CAMPAIGN_ORDER_BY'] != '')?($_SESSION['CAMPAIGN_ORDER_BY']):($this->default_order_by));
-
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}
-	// Mike Crowe Mod --------------------------------------------------------
-
-	/**
-	 * Function to get Campaign related Contacts
-	 * @param  integer   $id      - campaignid
-	 * returns related Contacts record in array format
-	 */
-	function get_contacts($id)
-        {
-		global $log, $singlepane_view;
-		$log->debug("Entering get_contacts(".$id.") method ...");
-                global $mod_strings;
-
-                $focus = new Contacts();
-		$button = '';
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'select vtiger_contactdetails.accountid, vtiger_users.user_name,vtiger_groups.groupname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_campaigncontrel.campaignid = '.$id.' and vtiger_crmentity.deleted=0';
-		
-		$log->debug("Exiting get_contacts method ...");
-                return GetRelatedList('Campaigns','Contacts',$focus,$query,$button,$returnset);
-        }
-
-	/**
-	 * Function to get Campaign related Leads
-	 * @param  integer   $id      - campaignid
-	 * returns related Leads record in array format
-	 */
-	function get_leads($id)
-        {
-		global $log, $singlepane_view;
-                $log->debug("Entering get_leads(".$id.") method ...");
-                global $mod_strings;
-
-                $focus = new Leads();
-
-                $button = '';
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
-		else
-                	$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid, vtiger_users.user_name, vtiger_groups.groupname, vtiger_crmentity.smownerid from vtiger_leaddetails inner join vtiger_campaignleadrel on vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid left join vtiger_users on vtiger_crmentity.smownerid = vtiger_users.id left join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid left join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_campaignleadrel.campaignid = '.$id;
-		$log->debug("Exiting get_leads method ...");
-                return GetRelatedList('Campaigns','Leads',$focus,$query,$button,$returnset);
-        }
-
-	/**
-	 * Function to get Campaign related Potentials
-	 * @param  integer   $id      - campaignid
-	 * returns related potentials record in array format
-	 */
-	function get_opportunities($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_opportunities(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Potentials();
-
-		$button = '';
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'select vtiger_users.user_name,vtiger_groups.groupname, vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_campaign inner join vtiger_potential on vtiger_campaign.campaignid = vtiger_potential.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_campaign.campaignid = '.$id.' and vtiger_crmentity.deleted=0';
-		if($this->column_fields['account_id'] != 0)
-		$log->debug("Exiting get_opportunities method ...");
-		return GetRelatedList('Campaigns','Potentials',$focus,$query,$button,$returnset);
-
-	}
-
-	/**
-	 * Function to get Campaign related Activities
-	 * @param  integer   $id      - campaignid
-	 * returns related activities record in array format
-	 */
-	function get_activities($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_activities(".$id.") method ...");
-		global $app_strings;
-
-		require_once('modules/Calendar/Activity.php');
-
-		$focus = new Activity();
-
-		$button = '';
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_contactdetails.lastname,
-			vtiger_contactdetails.firstname,
-			vtiger_contactdetails.contactid,
-			vtiger_activity.*,
-			vtiger_seactivityrel.*,
-			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
-			vtiger_crmentity.modifiedtime,
-			vtiger_users.user_name,
-			vtiger_recurringevents.recurringtype
-			FROM vtiger_activity
-			INNER JOIN vtiger_seactivityrel
-				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
-			INNER JOIN vtiger_crmentity
-				ON vtiger_crmentity.crmid=vtiger_activity.activityid
-			LEFT JOIN vtiger_cntactivityrel
-				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
-			LEFT JOIN vtiger_contactdetails
-				ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
-			LEFT JOIN vtiger_users
-				ON vtiger_users.id = vtiger_crmentity.smownerid
-			LEFT OUTER JOIN vtiger_recurringevents
-				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
-			LEFT JOIN vtiger_activitygrouprelation
-				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
-			WHERE vtiger_seactivityrel.crmid=".$id."
-			AND (activitytype = 'Task'
-				OR activitytype = 'Call'
-				OR activitytype = 'Meeting')";
-		$log->debug("Exiting get_activities method ...");
-		return GetRelatedList('Campaigns','Calendar',$focus,$query,$button,$returnset);
-	}
-
-}
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of txhe License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('include/utils/utils.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('modules/Leads/Leads.php');
+require_once('user_privileges/default_module_view.php');
+
+class Campaigns extends CRMEntity {
+	var $log;
+	var $db;
+
+
+	var $tab_name = Array('vtiger_crmentity','vtiger_campaign','vtiger_campaignscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_campaign'=>'campaignid','vtiger_campaignscf'=>'campaignid');
+	var $column_fields = Array();
+
+	var $sortby_fields = Array('campaignname','smownerid','campaigntype','product_id','expectedrevenue','closingdate','campaignstatus','expectedresponse','targetaudience','expectedcost');
+
+	var $list_fields = Array(
+					'Campaign Name'=>Array('campaign'=>'campaignname'),
+					'Campaign Type'=>Array('campaign'=>'campaigntype'),
+					'Campaign Status'=>Array('campaign'=>'campaignstatus'),
+					'Expected Revenue'=>Array('campaign'=>'expectedrevenue'),
+					'Expected Close Date'=>Array('campaign'=>'closingdate'),
+					'Assigned To' => Array('crmentity'=>'smownerid')
+				);
+
+	var $list_fields_name = Array(
+					'Campaign Name'=>'campaignname',
+					'Campaign Type'=>'campaigntype',
+					'Campaign Status'=>'campaignstatus',
+					'Expected Revenue'=>'expectedrevenue',
+					'Expected Close Date'=>'closingdate',
+					'Assigned To'=>'assigned_user_id'
+				     );	  			
+
+	var $list_link_field= 'campaignname';
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'crmid';
+	var $default_sort_order = 'DESC';
+
+	var $groupTable = Array('vtiger_campaigngrouprelation','campaignid');
+
+	var $search_fields = Array(
+			'Campaign Name'=>Array('vtiger_campaign'=>'campaignname'),
+			'Campaign Type'=>Array('vtiger_campaign'=>'campaigntype'),
+			);
+
+	var $search_fields_name = Array(
+			'Campaign Name'=>'campaignname',
+			'Campaign Type'=>'campaigntype',
+			);
+
+	function Campaigns() 
+	{
+		$this->log =LoggerManager::getLogger('campaign');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Campaigns');
+	}
+
+
+	/** Function to handle module specific operations when saving a entity 
+	*/
+	function save_module($module)
+	{
+	}
+
+	
+	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
+	/**
+	 * Function to get sort order
+	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	 */
+	function getSortOrder()
+	{
+		global $log;
+		$log->debug("Entering getSortOrder() method ...");
+		if(isset($_REQUEST['sorder']))
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['CAMPAIGN_SORT_ORDER'] != '')?($_SESSION['CAMPAIGN_SORT_ORDER']):($this->default_sort_order));
+
+		$log->debug("Exiting getSortOrder method ...");
+		return $sorder;
+	}
+
+	/**
+	 * Function to get order by
+	 * return string  $order_by    - fieldname(eg: 'campaignname')
+	 */
+	function getOrderBy()
+	{
+		global $log;
+		$log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by']))
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['CAMPAIGN_ORDER_BY'] != '')?($_SESSION['CAMPAIGN_ORDER_BY']):($this->default_order_by));
+
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}
+	// Mike Crowe Mod --------------------------------------------------------
+
+	/**
+	 * Function to get Campaign related Contacts
+	 * @param  integer   $id      - campaignid
+	 * returns related Contacts record in array format
+	 */
+	function get_contacts($id)
+        {
+		global $log, $singlepane_view;
+		$log->debug("Entering get_contacts(".$id.") method ...");
+                global $mod_strings;
+
+                $focus = new Contacts();
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'select vtiger_contactdetails.accountid, case when (vtiger_users.user_name not like \'\') then vtiger_users.user_name else vtiger_groups.groupname end as user_name , vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_campaigncontrel.campaignid = '.$id.' and vtiger_crmentity.deleted=0';
+		
+		$log->debug("Exiting get_contacts method ...");
+                return GetRelatedList('Campaigns','Contacts',$focus,$query,$button,$returnset);
+        }
+
+	/**
+	 * Function to get Campaign related Leads
+	 * @param  integer   $id      - campaignid
+	 * returns related Leads record in array format
+	 */
+	function get_leads($id)
+        {
+		global $log, $singlepane_view;
+                $log->debug("Entering get_leads(".$id.") method ...");
+                global $mod_strings;
+
+                $focus = new Leads();
+
+                $button = '';
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
+		else
+                	$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid,vtiger_leadaddress.phone,vtiger_leadsubdetails.website, case when (vtiger_users.user_name not like \'\') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid from vtiger_leaddetails inner join vtiger_campaignleadrel on vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid inner join vtiger_leadsubdetails  on vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid = vtiger_leadsubdetails.leadsubscriptionid left join vtiger_users on vtiger_crmentity.smownerid = vtiger_users.id left join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid left join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_campaignleadrel.campaignid = '.$id;
+		$log->debug("Exiting get_leads method ...");
+                return GetRelatedList('Campaigns','Leads',$focus,$query,$button,$returnset);
+        }
+
+	/**
+	 * Function to get Campaign related Potentials
+	 * @param  integer   $id      - campaignid
+	 * returns related potentials record in array format
+	 */
+	function get_opportunities($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_opportunities(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Potentials();
+
+		$button = '';
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'select case when (vtiger_users.user_name not like \'\') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_potential.accountid, vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_campaign inner join vtiger_potential on vtiger_campaign.campaignid = vtiger_potential.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_campaign.campaignid = '.$id.' and vtiger_crmentity.deleted=0';
+		if($this->column_fields['account_id'] != 0)
+		$log->debug("Exiting get_opportunities method ...");
+		return GetRelatedList('Campaigns','Potentials',$focus,$query,$button,$returnset);
+
+	}
+
+	/**
+	 * Function to get Campaign related Activities
+	 * @param  integer   $id      - campaignid
+	 * returns related activities record in array format
+	 */
+	function get_activities($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_activities(".$id.") method ...");
+		global $app_strings;
+
+		require_once('modules/Calendar/Activity.php');
+
+		$focus = new Activity();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Campaigns&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_contactdetails.lastname,
+			vtiger_contactdetails.firstname,
+			vtiger_contactdetails.contactid,
+			vtiger_activity.*,
+			vtiger_seactivityrel.*,
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
+			vtiger_crmentity.modifiedtime,
+			case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,
+			vtiger_recurringevents.recurringtype
+			FROM vtiger_activity
+			INNER JOIN vtiger_seactivityrel
+				ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid=vtiger_activity.activityid
+			LEFT JOIN vtiger_cntactivityrel
+				ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_contactdetails
+				ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT OUTER JOIN vtiger_recurringevents
+				ON vtiger_recurringevents.activityid = vtiger_activity.activityid
+			LEFT JOIN vtiger_activitygrouprelation
+				ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+			LEFT JOIN vtiger_groups
+				ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+			WHERE vtiger_seactivityrel.crmid=".$id."
+			AND (activitytype = 'Task'
+				OR activitytype = 'Call'
+				OR activitytype = 'Meeting')";
+		$log->debug("Exiting get_activities method ...");
+		return GetRelatedList('Campaigns','Calendar',$focus,$query,$button,$returnset);
+	
+	}
+
+}
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/DetailView.php Mon Apr 16 12:27:44 2007
@@ -12,7 +12,6 @@
 require_once('include/database/PearDatabase.php');
 require_once('Smarty_setup.php');
 require_once('modules/Campaigns/Campaigns.php');
-require_once('modules/CustomView/CustomView.php');
 require_once('include/utils/utils.php');
 require_once('user_privileges/default_module_view.php');
 
@@ -29,7 +28,7 @@
 {
         $focus->id = "";
 }
-global $app_strings,$mod_strings,$theme,$currentModule,$default_module_view;
+global $app_strings,$mod_strings,$theme,$currentModule,$default_module_view,$adb;
 
 $theme_path="themes/".$theme."/";
 $image_path=$theme_path."images/";
@@ -70,18 +69,36 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
 
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);
 	$smarty->assign("RELATEDLISTS", $related_array);
-	$cvObj = new CustomView("Contacts");
-	$cvcombo = $cvObj->getCustomViewCombo();
-	$smarty->assign("CONTCVCOMBO","<select id='cont_cv_list' onchange='loadCvList(\"Contacts\",".$_REQUEST["record"].");'><option value='None'>-- ".$mod_strings['Select One']." --</option>".$cvcombo."</select>");
+	/* To get Contacts CustomView -START */
+	$sql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype where vtiger_tab.tabid=".getTabid('Contacts');
+	$result = $adb->query($sql);
+	$chtml = "<select id='cont_cv_list'><option value='None'>-- ".$mod_strings['Select One']." --</option>";
+	while($cvrow=$adb->fetch_array($result))
+	{
+		$chtml .= "<option value=\"".$cvrow['cvid']."\">".$cvrow['viewname']."</option>";
+	}
+	$chtml .= "</select>";
+	$smarty->assign("CONTCVCOMBO",$chtml);
+	/* To get Contacts CustomView -END */
+	
+	/* To get Leads CustomView -START */
+	$sql = "select vtiger_customview.* from vtiger_customview inner join vtiger_tab on vtiger_tab.name = vtiger_customview.entitytype where vtiger_tab.tabid=".getTabid('Leads');
+	$result = $adb->query($sql);
+	$lhtml = "<select id='lead_cv_list'><option value='None'>-- ".$mod_strings['Select One']." --</option>";
+	while($cvrow=$adb->fetch_array($result))
+	{
+		$lhtml .= "<option value=\"".$cvrow['cvid']."\">".$cvrow['viewname']."</option>";
+	}
+	$lhtml .= "</select>";
+	$smarty->assign("LEADCVCOMBO",$lhtml);
+	/* To get Leads CustomView -END */
 
-	$cvObj = new CustomView("Leads");
-	$cvcombo = $cvObj->getCustomViewCombo();
-	$smarty->assign("LEADCVCOMBO","<select id='lead_cv_list' onchange='loadCvList(\"Leads\",".$_REQUEST["record"].");'> <option value='None'>-- ".$mod_strings['Select One']." --</option>".$cvcombo."</select>");
 }
 
 $smarty->assign("SinglePane_View", $singlepane_view);

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/EditView.php Mon Apr 16 12:27:44 2007
@@ -99,7 +99,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
-
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 if($focus->mode == 'edit')
 	$smarty->display("salesEditView.tpl");
 else

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/ListView.php Mon Apr 16 12:27:44 2007
@@ -133,8 +133,8 @@
 	if($order_by == 'smownerid')
 	{
 		if( $adb->dbType == "pgsql")
- 		    $list_query .= ' GROUP BY vtiger_users.user_name';
-		$list_query .= ' ORDER BY vtiger_users.user_name '.$sorder;
+ 		    $list_query .= ' GROUP BY user_name';
+		$list_query .= ' ORDER BY user_name '.$sorder;
 	}
 	else
 	{

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/LoadList.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/LoadList.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/LoadList.php Mon Apr 16 12:27:44 2007
@@ -28,24 +28,6 @@
 	$adb->query("INSERT INTO ".$reltable." VALUES('".$_REQUEST["return_id"]."','".$row["crmid"]."')");
 }
 
-if ($singlepane_view == 'true')
-{
+header("Location: index.php?module=Campaigns&action=CampaignsAjax&file=CallRelatedList&ajax=true&record=".$_REQUEST['return_id']);
+
 ?>
-<script>
-addOnloadEvent(function() {
-	window.location.href = "index.php?action=DetailView&module=Campaigns&record=<? echo $_REQUEST['return_id'];?>";
-});
-</script>
-<?php
-}
-else
-{
-?>
-<script>
-addOnloadEvent(function() {
-	window.location.href = "index.php?action=CallRelatedList&module=Campaigns&record=<? echo $_REQUEST['return_id'];?>";
-});
-</script>
-<?php
-}
-?>

Modified: vtigercrm/branches/5.1_jens/modules/Campaigns/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Campaigns/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Campaigns/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -43,7 +43,7 @@
 'Description'=>'Description',
 'Product'=>'Product',
 'Target Audience'=>'Target Audience',
-'TargetSize'=>'TargetSize',
+'TargetSize'=>'Target Size',
 'Sponsor'=>'Sponsor',
 
 'Expected Sales Count'=>'Expected Sales Count',

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/CallRelatedList.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/CallRelatedList.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/CallRelatedList.php Mon Apr 16 12:27:44 2007
@@ -64,9 +64,11 @@
         $smarty->assign("HIDDEN_PARENTS_LIST",$parent_email);
 $category = getparenttab();
 $smarty->assign("CATEGORY",$category);
-
 $smarty->assign("ID",$focus->id);
 $smarty->assign("NAME",$focus->name);
+$smarty->assign("EMAIL",$focus->column_fields['email']);
+$smarty->assign("YAHOO",$focus->column_fields['yahooid']);
+
 $related_array = getRelatedLists($currentModule,$focus);
 $smarty->assign("RELATEDLISTS", $related_array);
 $smarty->assign("MODULE",$currentmodule);

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/Contacts.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/Contacts.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/Contacts.php Mon Apr 16 12:27:44 2007
@@ -1,869 +1,882 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/Contacts.php,v 1.70 2005/04/27 11:21:49 rank Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('include/utils/utils.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('modules/Calendar/Activity.php');
-require_once('modules/Campaigns/Campaigns.php');
-require_once('modules/Notes/Notes.php');
-require_once('modules/Emails/Emails.php');
-require_once('modules/HelpDesk/HelpDesk.php');
-require_once('user_privileges/default_module_view.php');
-
-
-// Contact is used to store customer information.
-class Contacts extends CRMEntity {
-	var $log;
-	var $db;
-
-	var $table_name = "contactdetails";
-	var $tab_name = Array('vtiger_crmentity','vtiger_contactdetails','vtiger_contactaddress','vtiger_contactsubdetails','vtiger_contactscf','vtiger_customerdetails','vtiger_entity2org');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_contactdetails'=>'contactid','vtiger_contactaddress'=>'contactaddressid','vtiger_contactsubdetails'=>'contactsubscriptionid','vtiger_contactscf'=>'contactid','vtiger_customerdetails'=>'customerid','vtiger_attachments'=>'attachmentsid','vtiger_entity2org'=>'crmid');
-
-	
-
-	var $column_fields = Array();
-	
-	var $sortby_fields = Array('lastname','firstname','title','email','phone','smownerid','accountid');
-
-	var $list_link_field= 'lastname';
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-	'Last Name' => Array('contactdetails'=>'lastname'),
-	'First Name' => Array('contactdetails'=>'firstname'),
-	'Title' => Array('contactdetails'=>'title'),
-	'Account Name' => Array('account'=>'accountname'),
-	'Email' => Array('contactdetails'=>'email'),
-	'Phone' => Array('contactdetails'=>'phone'),
-	'Assigned To' => Array('crmentity'=>'smownerid')
-	);
-
-	var $range_fields = Array(
-		'first_name',
-		'last_name',
-		'primary_address_city',
-		'account_name',     
-		'account_id',
-		'id',   
-		'email1',
-		'salutation',
-		'title',   
-		'phone_mobile',
-		'reports_to_name',
-		'primary_address_street',     
-		'primary_address_city',  
-		'primary_address_state', 
-		'primary_address_postalcode',  
-		'primary_address_country',    
-		'alt_address_city',     
-		'alt_address_street',       
-		'alt_address_city',  
-		'alt_address_state',    
-		'alt_address_postalcode',     
-		'alt_address_country',
-		'office_phone',
-		'home_phone',
-		'other_phone',
-		'fax',
-		'department',
-		'birthdate',
-		'assistant_name',
-		'assistant_phone');
-
-	
-	var $list_fields_name = Array(
-	'Last Name' => 'lastname',
-	'First Name' => 'firstname',
-	'Title' => 'title',
-	'Account Name' => 'accountid',
-	'Email' => 'email',
-	'Phone' => 'phone',
-	'Assigned To' => 'assigned_user_id'
-	);
-
-	var $search_fields = Array(
-	'Name' => Array('contactdetails'=>'lastname'),
-	'Title' => Array('contactdetails'=>'title')
-		);
-	
-	var $search_fields_name = Array(
-	'Name' => 'lastname',
-	'Title' => 'title'
-	);
-
-	// This is the list of vtiger_fields that are required
-	var $required_fields =  array("lastname"=>1);
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'lastname';
-	var $default_sort_order = 'ASC';
-
-	function Contacts() {
-		$this->log = LoggerManager::getLogger('contact');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Contacts');
-	}
-
-    	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
-	/**
-	* Function to get sort order
-	* return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	*/
-	function getSortOrder()
-	{	
-		global $log;
-                $log->debug("Entering getSortOrder() method ...");
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['CONTACTS_SORT_ORDER'] != '')?($_SESSION['CONTACTS_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder method ...");
-		return $sorder;
-	}
-	/**
-	* Function to get order by
-	* return string  $order_by    - fieldname(eg: 'Contactname')
-	*/
-	function getOrderBy()
-	{
-		global $log;
-	        $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['CONTACTS_ORDER_BY'] != '')?($_SESSION['CONTACTS_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-	// Mike Crowe Mod --------------------------------------------------------
-	/** Function to get the number of Contacts assigned to a particular User.
-	*  @param varchar $user name - Assigned to User
-	*  Returns the count of contacts assigned to user.
-	*/
-	function getCount($user_name) 
-	{
-		global $log;
-		$log->debug("Entering getCount(".$user_name.") method ...");
-		$query = "select count(*) from vtiger_contactdetails  inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0";
-
-		$result = $this->db->query($query,true,"Error retrieving contacts count");
-		$rows_found =  $this->db->getRowCount($result);
-		$row = $this->db->fetchByAssoc($result, 0);
-
-
-		$log->debug("Exiting getCount method ...");
-		return $row["count(*)"];
-	}       
-	/** Function to get the Contact Details assigned to a given User ID which has a valid Email Address.
-	* @param varchar $user_name - User Name (eg. Admin)
-	* @param varchar $email_address - Email Addr of each contact record.
-	* Returns the query.
-	*/
-  function get_contacts1($user_name,$email_address)
-	{   
-		global $log;
-		$log->debug("Entering get_contacts1(".$user_name.",".$email_address.") method ...");
-		$query = "select vtiger_users.user_name, vtiger_contactdetails.lastname last_name,vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as account_name,vtiger_account.accountid as account_id   from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid  left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0  and vtiger_contactdetails.email like '%" .$email_address ."%' limit 50";
-
-		$log->debug("Exiting get_contacts1 method ...");
-		return $this->process_list_query1($query);
-	}
-	/** Function to get the Contact Details assigned to a particular User based on the starting count and the number of subsequent records.
-	*  @param varchar $user_name - Assigned User
-	*  @param integer $from_index - Initial record number to be displayed 
-	*  @param integer $offset - Count of the subsequent records to be displayed.
-	*  Returns Query.
-	*/
-    function get_contacts($user_name,$from_index,$offset)
-    {   
-	global $log;
-	$log->debug("Entering get_contacts(".$user_name.",".$from_index.",".$offset.") method ...");
-      $query = "select vtiger_users.user_name,vtiger_groups.groupname,vtiger_contactdetails.department department, vtiger_contactdetails.phone office_phone, vtiger_contactdetails.fax fax, vtiger_contactsubdetails.assistant assistant_name, vtiger_contactsubdetails.otherphone other_phone, vtiger_contactsubdetails.homephone home_phone,vtiger_contactsubdetails.birthday birthdate, vtiger_contactdetails.lastname last_name,vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as account_name,vtiger_account.accountid as account_id, vtiger_contactaddress.mailingcity as primary_address_city,vtiger_contactaddress.mailingstreet as primary_address_street, vtiger_contactaddress.mailingcountry as primary_address_country,vtiger_contactaddress.mailingstate as primary_address_state, vtiger_contactaddress.mailingzip as primary_address_postalcode,   vtiger_contactaddress.othercity as alt_address_city,vtiger_contactaddress.otherstreet as alt_address_street, vtiger_contactaddress.othercountry as alt_address_country,vtiger_contactaddress.otherstate as alt_address_state, vtiger_contactaddress.otherzip as alt_address_postalcode  from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 limit " .$from_index ."," .$offset;
-      
-	$log->debug("Exiting get_contacts method ...");
-      return $this->process_list_query1($query);
-    }
-
-
-    /** Function to process list query for a given query
-    *  @param $query
-    *  Returns the results of query in array format 
-    */
-    function process_list_query1($query)
-    {
-	global $log;
-	$log->debug("Entering process_list_query1(".$query.") method ...");
-	  
-        $result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
-        $list = Array();
-        $rows_found =  $this->db->getRowCount($result);
-        if($rows_found != 0)
-        {
-		   $contact = Array();
-               for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
-            
-             {
-                foreach($this->range_fields as $columnName)
-                {
-                    if (isset($row[$columnName])) {
-			    
-                        $contact[$columnName] = $row[$columnName];
-                    }   
-                    else     
-                    {   
-                            $contact[$columnName] = "";
-                    }   
-	     }
-// TODO OPTIMIZE THE QUERY ACCOUNT NAME AND ID are set separetly for every vtiger_contactdetails and hence 
-// vtiger_account query goes for ecery single vtiger_account row
-
-                    $list[] = $contact;
-                }
-        }   
-
-        $response = Array();
-        $response['list'] = $list;
-        $response['row_count'] = $rows_found;
-        $response['next_offset'] = $next_offset;
-        $response['previous_offset'] = $previous_offset;
-
-
-	$log->debug("Exiting process_list_query1 method ...");
-        return $response;
-    }
-    
-    
-    /** Function to process list query for Plugin with Security Parameters for a given query
-    *  @param $query
-    *  Returns the results of query in array format 
-    */
-    function plugin_process_list_query($query)
-    {
-          global $log,$adb,$current_user;
-          $log->debug("Entering process_list_query1(".$query.") method ...");
-          $permitted_field_lists = Array();
-          require('user_privileges/user_privileges_'.$current_user->id.'.php');
-          if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-          {
-              $sql1 = "select columnname from vtiger_field where tabid=4 and block <> 75";
-          }else
-          {
-              $profileList = getCurrentUserProfileList();
-              $sql1 = "select columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 6 and vtiger_field.block <> 75 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-          }
-          $result1 = $this->db->query($sql1);
-          for($i=0;$i < $adb->num_rows($result1);$i++)
-          {
-              $permitted_field_lists[] = $adb->query_result($result1,$i,'columnname');
-          }
-          
-          $result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
-          $list = Array();
-          $rows_found =  $this->db->getRowCount($result);
-          if($rows_found != 0)
-          {
-              for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
-              {
-                  $contact = Array();
-                  foreach($permitted_field_lists as $columnName)
-                  {
-                      if ($columnName == "lastname" || $columnName == "firstname" || $columnName == "email") 
-                      {
-                          $contact[$columnName] = $row[$columnName];
-                      }   
-                      else     
-                      {   
-                          $contact[$columnName] = "";
-                      }   
-                  }
-                  if(in_array("accountid",$permitted_field_lists))
-                  {
-                      $contact[accountname] = $row[accountname];
-                      $contact[account_id] = $row[accountid];
-                  }
-                  $contact[contactid] =  $row[contactid];
-                  $list[] = $contact;
-              }
-          }   
-          
-          $response = Array();
-          $response['list'] = $list;
-          $response['row_count'] = $rows_found;
-          $response['next_offset'] = $next_offset;
-          $response['previous_offset'] = $previous_offset;
-          $log->debug("Exiting process_list_query1 method ...");
-          return $response;
-    }
-
-
-	/** Returns a list of the associated opportunities
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	*/
-	function get_opportunities($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_opportunities(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Potentials();
-		$button = '';
-
-		if(isPermitted("Potentials",1,"") == 'yes')
-		{
-
-			$button .= '<input title="New Potential" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_POTENTIAL'].'">&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		$log->info("Potential Related List for Contact Displayed");
-
-		// First, get the list of IDs.
-		$query = 'select vtiger_users.user_name,vtiger_groups.groupname,vtiger_contactdetails.accountid, vtiger_contactdetails.contactid , vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_contactdetails inner join vtiger_potential on vtiger_contactdetails.accountid = vtiger_potential.accountid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_contactdetails.contactid = '.$id.' and vtiger_crmentity.deleted=0';
-		if($this->column_fields['account_id'] != 0)
-		$log->debug("Exiting get_opportunities method ...");
-		return GetRelatedList('Contacts','Potentials',$focus,$query,$button,$returnset);
-	}
-	
-  
-	/** Returns a list of the associated tasks
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	*/
-	function get_activities($id)
-	{
-	     	global $log, $singlepane_view;
-                $log->debug("Entering get_activities(".$id.") method ...");
-		global $mod_strings;
-
-    	$focus = new Activity();
-
-		$button = '';
-
-        if(isPermitted("Calendar",1,"") == 'yes')
-        {
-		$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.activity_mode.value=\'Task\';this.form.return_module.value=\'Contacts\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
-		$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Contacts\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		$log->info("Activity Related List for Contact Displayed");
-
-		$query = "SELECT vtiger_users.user_name,vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,  vtiger_activity.activityid , vtiger_activity.subject, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date, vtiger_cntactivityrel.contactid, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_recurringevents.recurringtype  from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid = vtiger_contactdetails.contactid inner join vtiger_activity on vtiger_cntactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_cntactivityrel.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname  where vtiger_contactdetails.contactid=".$id." and vtiger_crmentity.deleted = 0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus != 'Held') ";  //recurring type is added in Query -Jaguar
-		$log->debug("Exiting get_activities method ...");
-		return GetRelatedList('Contacts','Calendar',$focus,$query,$button,$returnset);
-
-	}
-	/**
-	* Function to get Contact related Task & Event which have activity type Held, Completed or Deferred.
-	* @param  integer   $id      - contactid
-	* returns related Task or Event record in array format
-	*/
-	function get_history($id)
-	{
-		global $log;
-		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, vtiger_activity.eventstatus,
-		vtiger_activity.activitytype, vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,
-		vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
-		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
-				from vtiger_activity
-				inner join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
-				inner join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
-				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
-				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
-				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
-				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
-				and vtiger_cntactivityrel.contactid=".$id;
-		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-		$log->debug("Entering get_history method ...");
-		return getHistory('Contacts',$query,$id);
-	}
-	/**
-	* Function to get Contact related Tickets.
-	* @param  integer   $id      - contactid
-	* returns related Ticket records in array format
-	*/
-	function get_tickets($id)
-	{
-		global $log, $singlepane_view;
-		global $app_strings;
-		$log->debug("Entering get_tickets(".$id.") method ...");
-		$focus = new HelpDesk();
-
-		$button = '<td valign="bottom" align="right"><input title="New Ticket" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'HelpDesk\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_TICKET'].'">&nbsp;</td>';
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "select vtiger_users.user_name,vtiger_crmentity.crmid, vtiger_troubletickets.title, vtiger_contactdetails.contactid, vtiger_troubletickets.parent_id, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_troubletickets.status, vtiger_troubletickets.priority, vtiger_crmentity.smownerid from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_troubletickets.parent_id left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_ticketgrouprelation on vtiger_troubletickets.ticketid=vtiger_ticketgrouprelation.ticketid left join vtiger_groups on vtiger_groups.groupname=vtiger_ticketgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_contactdetails.contactid=".$id;
-		$log->info("Ticket Related List for Contact Displayed");
-		$log->debug("Exiting get_tickets method ...");
-		return GetRelatedList('Contacts','HelpDesk',$focus,$query,$button,$returnset);
-	}
-	/**
-	* Function to get Contact related Attachments
-	* @param  integer   $id - contactid
-	* returns related Attachment record in array format
-	*/
-	function get_attachments($id)
-	{
-		global $log;
-		$log->debug("Entering get_attachments(".$id.") method ...");
-		$query = "select vtiger_notes.title,'Notes      ' AS ActivityType,
-		vtiger_notes.filename, vtiger_attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
-		vtiger_seattachmentsrel.attachmentsid AS attachmentsid, vtiger_notes.notesid AS crmid,
-			crm2.createdtime, vtiger_notes.notecontent AS description, vtiger_users.user_name
-		from vtiger_notes
-			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_notes.contact_id
-			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
-			left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
-			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		where vtiger_crmentity.crmid=".$id;
-		$query .= " union all ";
-		$query .= "select vtiger_attachments.description AS title,'Attachments' AS ActivityType,
-		vtiger_attachments.name AS filename, vtiger_attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
-		vtiger_attachments.attachmentsid AS attachmentsid, vtiger_seattachmentsrel.attachmentsid AS crmid,
-			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-		from vtiger_attachments
-			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
-			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
-			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
-			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		where vtiger_crmentity.crmid=".$id."
-		order by createdtime desc";
-	  	$log->info("Notes&Attachmenmts for Contact Displayed");
-		$log->debug("Exiting get_attachments method ...");
-		return getAttachmentsAndNotes('Contacts',$query,$id);
-	  }
-	  /**
-	  * Function to get Contact related Quotes
-	  * @param  integer   $id  - contactid
-	  * returns related Quotes record in array format
-	  */
-	 function get_quotes($id)
-	 {	
-		global $log, $singlepane_view;
-                $log->debug("Entering get_quotes(".$id.") method ...");
-		global $app_strings;
-		require_once('modules/Quotes/Quotes.php');		
-		$focus = new Quotes();
-	
-		$button = '';
-		if(isPermitted("Quotes",1,"") == 'yes')
-        {
-		$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-		$query = "select vtiger_users.user_name,vtiger_crmentity.*, vtiger_quotes.*,vtiger_potential.potentialname,vtiger_contactdetails.lastname from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_quotes.contactid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid  left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_contactdetails.contactid=".$id;
-		$log->debug("Exiting get_quotes method ...");
-		return GetRelatedList('Contacts','Quotes',$focus,$query,$button,$returnset);
-	  }
-	/**
-	 * Function to get Contact related SalesOrder 
- 	 * @param  integer   $id  - contactid
-	 * returns related SalesOrder record in array format
-	 */	 
-	 function get_salesorder($id)
-	 {	
-		 global $log, $singlepane_view;
-                $log->debug("Entering get_salesorder(".$id.") method ...");
-		 require_once('modules/SalesOrder/SalesOrder.php');
-		 global $app_strings;
-		 $focus = new SalesOrder();
-		 $button = '';
-
-		 if(isPermitted("SalesOrder",1,"") == 'yes')
-		 {
-
-			 $button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="O" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\';this.form.return_module.value=\'Contacts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;';
-		 }
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		 $query = "select vtiger_users.user_name,vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_contactdetails.lastname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_salesorder.contactid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.contactid = ".$id;
-		$log->debug("Exiting get_salesorder method ...");
-		 return GetRelatedList('Contacts','SalesOrder',$focus,$query,$button,$returnset);
-	 }
-	 /**
-	 * Function to get Contact related Products 
-	 * @param  integer   $id  - contactid
-	 * returns related Products record in array format
-	 */
-	 function get_products($id)
-	 {
-		 global $log, $singlepane_view;
-		$log->debug("Entering get_products(".$id.") method ...");
-		 global $app_strings;
-		 require_once('modules/Products/Products.php');
-		 $focus = new Products();
-		 $button = '';
-
-		 if(isPermitted("Products",1,"") == 'yes')
-		 {
-
-			 $button .= '<input title="'.$app_strings['LBL_NEW_PRODUCT'].'" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Contacts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
-		 }
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		 $query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_contactdetails.lastname from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_products.contactid where vtiger_contactdetails.contactid = '.$id.' and vtiger_crmentity.deleted = 0';
-		$log->debug("Exiting get_products method ...");
-		 return GetRelatedList('Contacts','Products',$focus,$query,$button,$returnset);
-	 }
-
-	/**
-	 * Function to get Contact related PurchaseOrder 
- 	 * @param  integer   $id  - contactid
-	 * returns related PurchaseOrder record in array format
-	 */	 
-	 function get_purchase_orders($id)
-	 {
-		global $log, $singlepane_view;
-		$log->debug("Entering get_purchase_orders(".$id.") method ...");
-		 global $app_strings;
-		 require_once('modules/PurchaseOrder/PurchaseOrder.php');
-		 $focus = new PurchaseOrder();
-
-		 $button = '';
-
-		 if(isPermitted("PurchaseOrder",1,"") == 'yes')
-		 {
-
-			 $button .= '<input title="'.$app_strings['LBL_PORDER_BUTTON_TITLE'].'" accessyKey="O" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'PurchaseOrder\';this.form.return_module.value=\'Contacts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_PORDER_BUTTON'].'">&nbsp;';
-		 }
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-		 	$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		 $query = "select vtiger_users.user_name,vtiger_crmentity.*, vtiger_purchaseorder.*,vtiger_vendor.vendorname,vtiger_contactdetails.lastname from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_purchaseorder.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.contactid=".$id;
-		$log->debug("Exiting get_purchase_orders method ...");
-		 return GetRelatedList('Contacts','PurchaseOrder',$focus,$query,$button,$returnset);
-	 }
-
-	/** Returns a list of the associated emails
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	*/
-	function get_emails($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_emails(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Emails();
-
-		$button = '';
-
-		if(isPermitted("Emails",1,"") == 'yes')
-		{	
-			$button .= '<input title="New Email" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Emails\';this.form.email_directing_module.value=\'contacts\';this.form.record.value='.$id.';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_EMAIL'].'">';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-
-		$log->info("Email Related List for Contact Displayed");
-
-		$query = "select vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_users.user_name, vtiger_crmentity.modifiedtime, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_activity.date_start from vtiger_activity, vtiger_seactivityrel, vtiger_contactdetails, vtiger_users, vtiger_crmentity left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.activityid = vtiger_activity.activityid and vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid and vtiger_users.id=vtiger_crmentity.smownerid and vtiger_crmentity.crmid = vtiger_activity.activityid  and vtiger_contactdetails.contactid = ".$id." and vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted = 0";
-		$log->debug("Exiting get_emails method ...");
-		return GetRelatedList('Contacts','Emails',$focus,$query,$button,$returnset);
-	}
-
-	/** Returns a list of the associated Campaigns
-	  * @param $id -- campaign id :: Type Integer
-	  * @returns list of campaigns in array format
-	  */
-	      
-	function get_campaigns($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_campaigns(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Campaigns();
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
-		$button = '';
-
-		$log->info("Campaign Related List for Contact Displayed");
-		$query = "SELECT vtiger_users.user_name, vtiger_campaign.campaignid, vtiger_campaign.campaignname, vtiger_campaign.campaigntype, vtiger_campaign.campaignstatus, vtiger_campaign.expectedrevenue, vtiger_campaign.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_campaign inner join vtiger_campaigncontrel on vtiger_campaigncontrel.campaignid=vtiger_campaign.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid left join vtiger_campaigngrouprelation on vtiger_campaign.campaignid=vtiger_campaigngrouprelation.campaignid left join vtiger_groups on vtiger_groups.groupname=vtiger_campaigngrouprelation.groupname left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid where vtiger_campaigncontrel.contactid=".$id." and vtiger_crmentity.deleted=0";
-
-		$log->debug("Exiting get_campaigns method ...");
-		return GetRelatedList('Contacts','Campaigns',$focus,$query,$button,$returnset);
-
-	}
-	/** Function to export the contact records in CSV Format
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Export Contacts Query.
-	*/
-        function create_export_query(&$order_by, &$where)
-        {
-		global $log;
-		global $current_user;
-		$log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
-
-		include("include/utils/ExportUtils.php");
-
-		//To get the Permitted fields query and the permitted fields list
-		$sql = getPermittedFieldsQuery("Contacts", "detail_view");
-		$fields_list = getFieldsListFromQuery($sql);
-
-		$query = "SELECT $fields_list 
-                                FROM vtiger_contactdetails
-                                inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid
-                                LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
-                                LEFT JOIN vtiger_account on vtiger_contactdetails.accountid=vtiger_account.accountid
-				left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
-				left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid=vtiger_contactdetails.contactid
-			        left join vtiger_contactscf on vtiger_contactscf.contactid=vtiger_contactdetails.contactid
-			        left join vtiger_customerdetails on vtiger_customerdetails.customerid=vtiger_contactdetails.contactid
-				LEFT JOIN vtiger_contactgrouprelation
-                	                ON vtiger_contactscf.contactid = vtiger_contactgrouprelation.contactid
-	                        LEFT JOIN vtiger_groups
-                        	        ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
-				LEFT JOIN vtiger_contactdetails vtiger_contactdetails2
-					ON vtiger_contactdetails2.contactid = vtiger_contactdetails.reportsto
-				where vtiger_crmentity.deleted=0 and vtiger_users.status='Active' ";
-				//vtiger_contactdetails2 is added to get the Reports To of Contact
-
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-		//we should add security check when the user has Private Access
-		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[4] == 3)
-		{
-			//Added security check to get the permitted records only
-			$query = $query." ".getListViewSecurityParameter("Contacts");
-		}
-
-                $log->info("Export Query Constructed Successfully");
-		$log->debug("Exiting create_export_query method ...");
-		return $query;
-        }
-
-	
-/** Function to get the Columnnames of the Contacts
-* Used By vtigerCRM Word Plugin
-* Returns the Merge Fields for Word Plugin
-*/
-function getColumnNames()
-{
-	global $log, $current_user;
-	$log->debug("Entering getColumnNames() method ...");
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-	{
-	 $sql1 = "select fieldlabel from vtiger_field where tabid=4 and block <> 75";
-	}else
-	{
-	 $profileList = getCurrentUserProfileList();
-	 $sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 6 and vtiger_field.block <> 75 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-	$result = $this->db->query($sql1);
-	$numRows = $this->db->num_rows($result);
-	for($i=0; $i < $numRows;$i++)
-	{
-	$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
-	$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
-	$custom_fields[$i] = strtoupper($custom_fields[$i]);
-	}
-	$mergeflds = $custom_fields;
-	$log->debug("Exiting getColumnNames method ...");
-	return $mergeflds;
-}
-//End 
-/** Function to get the Contacts assigned to a user with a valid email address.
-* @param varchar $username - User Name
-* @param varchar $emailaddress - Email Addr for each contact.
-* Used By vtigerCRM Outlook Plugin
-* Returns the Query 
-*/
-function get_searchbyemailid($username,$emailaddress)
-{
-	global $log;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-	$log->debug("Entering get_searchbyemailid(".$username.",".$emailaddress.") method ...");
-	$query = "select vtiger_contactdetails.lastname,vtiger_contactdetails.firstname,
-					vtiger_contactdetails.contactid, vtiger_contactdetails.salutation, 
-					vtiger_contactdetails.email,vtiger_contactdetails.title,
-					vtiger_contactdetails.mobile,vtiger_account.accountname,
-					vtiger_account.accountid as accountid  from vtiger_contactdetails 
-						inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
-						inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  
-						left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid 
-						left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
-            LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
-			      LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
-						where vtiger_crmentity.deleted=0  and vtiger_contactdetails.email like '%".$emailaddress."%'";
-  $tab_id = getTabid("Contacts");
-  if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
-	{
-				$sec_parameter=getListViewSecurityParameter("Contacts");
-				$query .= $sec_parameter;
-
-	}
-	$log->debug("Exiting get_searchbyemailid method ...");
-	return $this->plugin_process_list_query($query);
-}
-
-/** Function to get the Contacts associated with the particular User Name.
-*  @param varchar $user_name - User Name
-*  Returns query
-*/
-
-function get_contactsforol($user_name)
-{
-	global $log,$adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($user_name);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-	
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select tablename,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and vtiger_field.block <> 5";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'tablename');
-      $permitted_lists[] = $adb->query_result($result1,$i,'columnname');
-      if($adb->query_result($result1,$i,'columnname') == "accountid")
-      {
-        $permitted_lists[] = 'vtiger_account';
-        $permitted_lists[] = 'accountname';
-      }
-  }
-	$permitted_lists = array_chunk($permitted_lists,2);
-	$column_table_lists = array();
-	for($i=0;$i < count($permitted_lists);$i++)
-	{
-	   $column_table_lists[] = implode(".",$permitted_lists[$i]);
-  }
-	
-	$log->debug("Entering get_contactsforol(".$user_name.") method ...");
-	$query = "select vtiger_contactdetails.contactid as id, ".implode(',',$column_table_lists)." from vtiger_contactdetails 
-						inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
-						inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid 
-						left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid 
-						left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid 
-						left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid
-            LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
-			      LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname 
-						where vtiger_crmentity.deleted=0 and vtiger_users.user_name='".$user_name."'";
-  $log->debug("Exiting get_contactsforol method ...");
-	return $query;
-}
-
-
-	/** Function to handle module specific operations when saving a entity 
-	*/
-	function save_module($module)
-	{
-		$this->insertIntoAttachment($this->id,$module);		
-	}	
-
-	/**
-	 *      This function is used to add the vtiger_attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database.
-	 *      @param int $id  - entity id to which the vtiger_files to be uploaded
-	 *      @param string $module  - the current module name
-	*/
-	function insertIntoAttachment($id,$module)
-	{
-		global $log, $adb;
-		$log->debug("Entering into insertIntoAttachment($id,$module) method.");
-		
-		$file_saved = false;
-
-		//This is to added to store the existing attachment id of the contact where we should delete this when we give new image
-		$old_attachmentid = $adb->query_result($adb->query("select * from vtiger_seattachmentsrel where crmid=$id"),0,'attachmentsid');
-
-		foreach($_FILES as $fileindex => $files)
-		{
-			if($files['name'] != '' && $files['size'] > 0)
-			{
-				$file_saved = $this->uploadAndSaveFile($id,$module,$files);
-			}
-		}
-
-		//This is to handle the delete image for contacts
-		if($module == 'Contacts' && $file_saved)
-		{
-			$del_res1 = $adb->query("delete from vtiger_attachments where attachmentsid=$old_attachmentid");
-			$del_res2 = $adb->query("delete from vtiger_seattachmentsrel where attachmentsid=$old_attachmentid");
-		}
-
-		$log->debug("Exiting from insertIntoAttachment($id,$module) method.");
-	}	
-
-
-//End
-
-}
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/Contacts.php,v 1.70 2005/04/27 11:21:49 rank Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('include/utils/utils.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('modules/Calendar/Activity.php');
+require_once('modules/Campaigns/Campaigns.php');
+require_once('modules/Notes/Notes.php');
+require_once('modules/Emails/Emails.php');
+require_once('modules/HelpDesk/HelpDesk.php');
+require_once('user_privileges/default_module_view.php');
+
+
+// Contact is used to store customer information.
+class Contacts extends CRMEntity {
+	var $log;
+	var $db;
+
+	var $table_name = "contactdetails";
+	var $tab_name = Array('vtiger_crmentity','vtiger_contactdetails','vtiger_contactaddress','vtiger_contactsubdetails','vtiger_contactscf','vtiger_customerdetails','vtiger_attachments','vtiger_entity2org');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_contactdetails'=>'contactid','vtiger_contactaddress'=>'contactaddressid','vtiger_contactsubdetails'=>'contactsubscriptionid','vtiger_contactscf'=>'contactid','vtiger_customerdetails'=>'customerid','vtiger_attachments'=>'attachmentsid','vtiger_entity2org'=>'crmid');
+
+	
+
+	var $column_fields = Array();
+	
+	var $sortby_fields = Array('lastname','firstname','title','email','phone','smownerid','accountid');
+
+	var $list_link_field= 'lastname';
+
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+	'Last Name' => Array('contactdetails'=>'lastname'),
+	'First Name' => Array('contactdetails'=>'firstname'),
+	'Title' => Array('contactdetails'=>'title'),
+	'Account Name' => Array('account'=>'accountid'),
+	'Email' => Array('contactdetails'=>'email'),
+	'Phone' => Array('contactdetails'=>'phone'),
+	'Assigned To' => Array('crmentity'=>'smownerid')
+	);
+
+	var $range_fields = Array(
+		'first_name',
+		'last_name',
+		'primary_address_city',
+		'account_name',     
+		'account_id',
+		'id',   
+		'email1',
+		'salutation',
+		'title',   
+		'phone_mobile',
+		'reports_to_name',
+		'primary_address_street',     
+		'primary_address_city',  
+		'primary_address_state', 
+		'primary_address_postalcode',  
+		'primary_address_country',    
+		'alt_address_city',     
+		'alt_address_street',       
+		'alt_address_city',  
+		'alt_address_state',    
+		'alt_address_postalcode',     
+		'alt_address_country',
+		'office_phone',
+		'home_phone',
+		'other_phone',
+		'fax',
+		'department',
+		'birthdate',
+		'assistant_name',
+		'assistant_phone');
+
+	
+	var $list_fields_name = Array(
+	'Last Name' => 'lastname',
+	'First Name' => 'firstname',
+	'Title' => 'title',
+	'Account Name' => 'accountid',
+	'Email' => 'email',
+	'Phone' => 'phone',
+	'Assigned To' => 'assigned_user_id'
+	);
+
+	var $search_fields = Array(
+	'Name' => Array('contactdetails'=>'lastname'),
+	'Title' => Array('contactdetails'=>'title'),
+	'Account Name'=>Array('contactdetails'=>'account_id'),
+		);
+	
+	var $search_fields_name = Array(
+	'Name' => 'lastname',
+	'Title' => 'title',
+	'Account Name'=>'account_id',
+	);
+
+	// This is the list of vtiger_fields that are required
+	var $required_fields =  array("lastname"=>1);
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'lastname';
+	var $default_sort_order = 'ASC';
+
+	var $groupTable = Array('vtiger_contactgrouprelation','contactid');
+
+	function Contacts() {
+		$this->log = LoggerManager::getLogger('contact');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Contacts');
+	}
+
+    	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
+	/**
+	* Function to get sort order
+	* return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	*/
+	function getSortOrder()
+	{	
+		global $log;
+                $log->debug("Entering getSortOrder() method ...");
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['CONTACTS_SORT_ORDER'] != '')?($_SESSION['CONTACTS_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder method ...");
+		return $sorder;
+	}
+	/**
+	* Function to get order by
+	* return string  $order_by    - fieldname(eg: 'Contactname')
+	*/
+	function getOrderBy()
+	{
+		global $log;
+	        $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['CONTACTS_ORDER_BY'] != '')?($_SESSION['CONTACTS_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+	// Mike Crowe Mod --------------------------------------------------------
+	/** Function to get the number of Contacts assigned to a particular User.
+	*  @param varchar $user name - Assigned to User
+	*  Returns the count of contacts assigned to user.
+	*/
+	function getCount($user_name) 
+	{
+		global $log;
+		$log->debug("Entering getCount(".$user_name.") method ...");
+		$query = "select count(*) from vtiger_contactdetails  inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0";
+
+		$result = $this->db->query($query,true,"Error retrieving contacts count");
+		$rows_found =  $this->db->getRowCount($result);
+		$row = $this->db->fetchByAssoc($result, 0);
+
+
+		$log->debug("Exiting getCount method ...");
+		return $row["count(*)"];
+	}       
+	/** Function to get the Contact Details assigned to a given User ID which has a valid Email Address.
+	* @param varchar $user_name - User Name (eg. Admin)
+	* @param varchar $email_address - Email Addr of each contact record.
+	* Returns the query.
+	*/
+  function get_contacts1($user_name,$email_address)
+	{   
+		global $log;
+		$log->debug("Entering get_contacts1(".$user_name.",".$email_address.") method ...");
+		$query = "select vtiger_users.user_name, vtiger_contactdetails.lastname last_name,vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as account_name,vtiger_account.accountid as account_id   from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid  left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0  and vtiger_contactdetails.email like '%" .$email_address ."%' limit 50";
+
+		$log->debug("Exiting get_contacts1 method ...");
+		return $this->process_list_query1($query);
+	}
+	/** Function to get the Contact Details assigned to a particular User based on the starting count and the number of subsequent records.
+	*  @param varchar $user_name - Assigned User
+	*  @param integer $from_index - Initial record number to be displayed 
+	*  @param integer $offset - Count of the subsequent records to be displayed.
+	*  Returns Query.
+	*/
+    function get_contacts($user_name,$from_index,$offset)
+    {   
+	global $log;
+	$log->debug("Entering get_contacts(".$user_name.",".$from_index.",".$offset.") method ...");
+      $query = "select vtiger_users.user_name,vtiger_groups.groupname,vtiger_contactdetails.department department, vtiger_contactdetails.phone office_phone, vtiger_contactdetails.fax fax, vtiger_contactsubdetails.assistant assistant_name, vtiger_contactsubdetails.otherphone other_phone, vtiger_contactsubdetails.homephone home_phone,vtiger_contactsubdetails.birthday birthdate, vtiger_contactdetails.lastname last_name,vtiger_contactdetails.firstname first_name,vtiger_contactdetails.contactid as id, vtiger_contactdetails.salutation as salutation, vtiger_contactdetails.email as email1,vtiger_contactdetails.title as title,vtiger_contactdetails.mobile as phone_mobile,vtiger_account.accountname as account_name,vtiger_account.accountid as account_id, vtiger_contactaddress.mailingcity as primary_address_city,vtiger_contactaddress.mailingstreet as primary_address_street, vtiger_contactaddress.mailingcountry as primary_address_country,vtiger_contactaddress.mailingstate as primary_address_state, vtiger_contactaddress.mailingzip as primary_address_postalcode,   vtiger_contactaddress.othercity as alt_address_city,vtiger_contactaddress.otherstreet as alt_address_street, vtiger_contactaddress.othercountry as alt_address_country,vtiger_contactaddress.otherstate as alt_address_state, vtiger_contactaddress.otherzip as alt_address_postalcode  from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where user_name='" .$user_name ."' and vtiger_crmentity.deleted=0 limit " .$from_index ."," .$offset;
+      
+	$log->debug("Exiting get_contacts method ...");
+      return $this->process_list_query1($query);
+    }
+
+
+    /** Function to process list query for a given query
+    *  @param $query
+    *  Returns the results of query in array format 
+    */
+    function process_list_query1($query)
+    {
+	global $log;
+	$log->debug("Entering process_list_query1(".$query.") method ...");
+	  
+        $result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
+        $list = Array();
+        $rows_found =  $this->db->getRowCount($result);
+        if($rows_found != 0)
+        {
+		   $contact = Array();
+               for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
+            
+             {
+                foreach($this->range_fields as $columnName)
+                {
+                    if (isset($row[$columnName])) {
+			    
+                        $contact[$columnName] = $row[$columnName];
+                    }   
+                    else     
+                    {   
+                            $contact[$columnName] = "";
+                    }   
+	     }
+// TODO OPTIMIZE THE QUERY ACCOUNT NAME AND ID are set separetly for every vtiger_contactdetails and hence 
+// vtiger_account query goes for ecery single vtiger_account row
+
+                    $list[] = $contact;
+                }
+        }   
+
+        $response = Array();
+        $response['list'] = $list;
+        $response['row_count'] = $rows_found;
+        $response['next_offset'] = $next_offset;
+        $response['previous_offset'] = $previous_offset;
+
+
+	$log->debug("Exiting process_list_query1 method ...");
+        return $response;
+    }
+    
+    
+    /** Function to process list query for Plugin with Security Parameters for a given query
+    *  @param $query
+    *  Returns the results of query in array format 
+    */
+    function plugin_process_list_query($query)
+    {
+          global $log,$adb,$current_user;
+          $log->debug("Entering process_list_query1(".$query.") method ...");
+          $permitted_field_lists = Array();
+          require('user_privileges/user_privileges_'.$current_user->id.'.php');
+          if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+          {
+              $sql1 = "select columnname from vtiger_field where tabid=4 and block <> 75";
+          }else
+          {
+              $profileList = getCurrentUserProfileList();
+              $sql1 = "select columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 6 and vtiger_field.block <> 75 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+          }
+          $result1 = $this->db->query($sql1);
+          for($i=0;$i < $adb->num_rows($result1);$i++)
+          {
+              $permitted_field_lists[] = $adb->query_result($result1,$i,'columnname');
+          }
+          
+          $result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
+          $list = Array();
+          $rows_found =  $this->db->getRowCount($result);
+          if($rows_found != 0)
+          {
+              for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
+              {
+                  $contact = Array();
+                  foreach($permitted_field_lists as $columnName)
+                  {
+                      if ($columnName == "lastname" || $columnName == "firstname" || $columnName == "email") 
+                      {
+                          $contact[$columnName] = $row[$columnName];
+                      }   
+                      else     
+                      {   
+                          $contact[$columnName] = "";
+                      }   
+                  }
+                  if(in_array("accountid",$permitted_field_lists))
+                  {
+                      $contact[accountname] = $row[accountname];
+                      $contact[account_id] = $row[accountid];
+                  }
+                  $contact[contactid] =  $row[contactid];
+                  $list[] = $contact;
+              }
+          }   
+          
+          $response = Array();
+          $response['list'] = $list;
+          $response['row_count'] = $rows_found;
+          $response['next_offset'] = $next_offset;
+          $response['previous_offset'] = $previous_offset;
+          $log->debug("Exiting process_list_query1 method ...");
+          return $response;
+    }
+
+
+	/** Returns a list of the associated opportunities
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	*/
+	function get_opportunities($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_opportunities(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Potentials();
+		$button = '';
+
+		if(isPermitted("Potentials",1,"") == 'yes')
+		{
+
+			$button .= '<input title="New Potential" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_POTENTIAL'].'">&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		$log->info("Potential Related List for Contact Displayed");
+
+		// First, get the list of IDs.
+		$query ='select case when (vtiger_users.user_name not like \'\') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.accountid, vtiger_contactdetails.contactid , vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_contactdetails inner join vtiger_contpotentialrel on vtiger_contpotentialrel.contactid=vtiger_contactdetails.contactid left join vtiger_potential on vtiger_potential.potentialid = vtiger_contpotentialrel.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_contactdetails.contactid ='.$id.' and vtiger_contactdetails.accountid = vtiger_potential.accountid and vtiger_crmentity.deleted=0';
+		
+		if($this->column_fields['account_id'] != 0)
+		$log->debug("Exiting get_opportunities method ...");
+		return GetRelatedList('Contacts','Potentials',$focus,$query,$button,$returnset);
+	}
+	
+  
+	/** Returns a list of the associated tasks
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	*/
+	function get_activities($id)
+	{
+	     	global $log, $singlepane_view;
+                $log->debug("Entering get_activities(".$id.") method ...");
+		global $mod_strings;
+
+    	$focus = new Activity();
+
+		$button = '';
+
+        if(isPermitted("Calendar",1,"") == 'yes')
+        {
+		$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.activity_mode.value=\'Task\';this.form.return_module.value=\'Contacts\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
+		$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Contacts\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		$log->info("Activity Related List for Contact Displayed");
+
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.lastname, vtiger_contactdetails.firstname,  vtiger_activity.activityid , vtiger_activity.subject, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.time_end, vtiger_cntactivityrel.contactid, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_recurringevents.recurringtype  from vtiger_contactdetails inner join vtiger_cntactivityrel on vtiger_cntactivityrel.contactid = vtiger_contactdetails.contactid inner join vtiger_activity on vtiger_cntactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_cntactivityrel.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname  where vtiger_contactdetails.contactid=".$id." and vtiger_crmentity.deleted = 0 and ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred')) or (vtiger_activity.activitytype in ('Meeting','Call') and  vtiger_activity.eventstatus not in ('','Held')))";  //recurring type is added in Query -Jaguar
+		$log->debug("Exiting get_activities method ...");
+		return GetRelatedList('Contacts','Calendar',$focus,$query,$button,$returnset);
+
+	}
+	/**
+	* Function to get Contact related Task & Event which have activity type Held, Completed or Deferred.
+	* @param  integer   $id      - contactid
+	* returns related Task or Event record in array format
+	*/
+	function get_history($id)
+	{
+		global $log;
+		$log->debug("Entering get_history(".$id.") method ...");
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, vtiger_activity.eventstatus,vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.time_end,vtiger_contactdetails.contactid, vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,vtiger_crmentity.createdtime, vtiger_crmentity.description, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+				from vtiger_activity
+				inner join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				inner join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+				and vtiger_cntactivityrel.contactid=".$id;
+		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+		$log->debug("Entering get_history method ...");
+		return getHistory('Contacts',$query,$id);
+	}
+	/**
+	* Function to get Contact related Tickets.
+	* @param  integer   $id      - contactid
+	* returns related Ticket records in array format
+	*/
+	function get_tickets($id)
+	{
+		global $log, $singlepane_view;
+		global $app_strings;
+		$log->debug("Entering get_tickets(".$id.") method ...");
+		$focus = new HelpDesk();
+
+		$button = '<td valign="bottom" align="right"><input title="New Ticket" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'HelpDesk\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_TICKET'].'">&nbsp;</td>';
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_crmentity.crmid, vtiger_troubletickets.title, vtiger_contactdetails.contactid, vtiger_troubletickets.parent_id, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_troubletickets.status, vtiger_troubletickets.priority, vtiger_crmentity.smownerid from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_troubletickets.parent_id left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_ticketgrouprelation on vtiger_troubletickets.ticketid=vtiger_ticketgrouprelation.ticketid left join vtiger_groups on vtiger_groups.groupname=vtiger_ticketgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_contactdetails.contactid=".$id;
+		$log->info("Ticket Related List for Contact Displayed");
+		$log->debug("Exiting get_tickets method ...");
+		return GetRelatedList('Contacts','HelpDesk',$focus,$query,$button,$returnset);
+	}
+	/**
+	* Function to get Contact related Attachments
+	* @param  integer   $id - contactid
+	* returns related Attachment record in array format
+	*/
+	function get_attachments($id)
+	{
+		global $log;
+		$log->debug("Entering get_attachments(".$id.") method ...");
+		$query = "select vtiger_notes.title,'Notes      ' AS ActivityType,
+		vtiger_notes.filename, vtiger_attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
+		vtiger_seattachmentsrel.attachmentsid AS attachmentsid, vtiger_notes.notesid AS crmid,
+			crm2.createdtime, vtiger_notes.notecontent AS description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_notes.contact_id
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
+		$query .= " union all ";
+		$query .= "select vtiger_attachments.description AS title,'Attachments' AS ActivityType,
+		vtiger_attachments.name AS filename, vtiger_attachments.type AS FileType,crm2.modifiedtime AS lastmodified,
+		vtiger_attachments.attachmentsid AS attachmentsid, vtiger_seattachmentsrel.attachmentsid AS crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id."
+		order by createdtime desc";
+	  	$log->info("Notes&Attachmenmts for Contact Displayed");
+		$log->debug("Exiting get_attachments method ...");
+		return getAttachmentsAndNotes('Contacts',$query,$id);
+	  }
+	  /**
+	  * Function to get Contact related Quotes
+	  * @param  integer   $id  - contactid
+	  * returns related Quotes record in array format
+	  */
+	 function get_quotes($id)
+	 {	
+		global $log, $singlepane_view;
+                $log->debug("Entering get_quotes(".$id.") method ...");
+		global $app_strings;
+		require_once('modules/Quotes/Quotes.php');		
+		$focus = new Quotes();
+	
+		$button = '';
+		if(isPermitted("Quotes",1,"") == 'yes')
+        {
+		$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+		$query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_crmentity.*, vtiger_quotes.*,vtiger_potential.potentialname,vtiger_contactdetails.lastname from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_quotes.contactid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid  left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_contactdetails.contactid=".$id;
+		$log->debug("Exiting get_quotes method ...");
+		return GetRelatedList('Contacts','Quotes',$focus,$query,$button,$returnset);
+	  }
+	/**
+	 * Function to get Contact related SalesOrder 
+ 	 * @param  integer   $id  - contactid
+	 * returns related SalesOrder record in array format
+	 */	 
+	 function get_salesorder($id)
+	 {	
+		 global $log, $singlepane_view;
+                $log->debug("Entering get_salesorder(".$id.") method ...");
+		 require_once('modules/SalesOrder/SalesOrder.php');
+		 global $app_strings;
+		 $focus = new SalesOrder();
+		 $button = '';
+
+		 if(isPermitted("SalesOrder",1,"") == 'yes')
+		 {
+
+			 $button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="O" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\';this.form.return_module.value=\'Contacts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;';
+		 }
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		 $query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_contactdetails.lastname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_salesorder.contactid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.contactid = ".$id;
+		$log->debug("Exiting get_salesorder method ...");
+		 return GetRelatedList('Contacts','SalesOrder',$focus,$query,$button,$returnset);
+	 }
+	 /**
+	 * Function to get Contact related Products 
+	 * @param  integer   $id  - contactid
+	 * returns related Products record in array format
+	 */
+	 function get_products($id)
+	 {
+		 global $log, $singlepane_view;
+		$log->debug("Entering get_products(".$id.") method ...");
+		 global $app_strings;
+		 require_once('modules/Products/Products.php');
+		 $focus = new Products();
+		 $button = '';
+
+		 if(isPermitted("Products",1,"") == 'yes')
+		 {
+
+			 $button .= '<input title="'.$app_strings['LBL_NEW_PRODUCT'].'" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Contacts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
+		 }
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		 $query = 'SELECT vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, 
+		 		  vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price,
+				  vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_contactdetails.lastname 
+			   FROM vtiger_products 
+			   INNER JOIN vtiger_seproductsrel 
+			   	ON vtiger_seproductsrel.productid=vtiger_products.productid and vtiger_seproductsrel.setype=\'Contacts\' 
+			   INNER JOIN vtiger_crmentity 
+			   	ON vtiger_crmentity.crmid = vtiger_products.productid 
+			   INNER JOIN vtiger_contactdetails 
+			   	ON vtiger_contactdetails.contactid = vtiger_seproductsrel.crmid 
+			   WHERE vtiger_contactdetails.contactid = '.$id.' and vtiger_crmentity.deleted = 0';
+
+		$log->debug("Exiting get_products method ...");
+		 return GetRelatedList('Contacts','Products',$focus,$query,$button,$returnset);
+	 }
+
+	/**
+	 * Function to get Contact related PurchaseOrder 
+ 	 * @param  integer   $id  - contactid
+	 * returns related PurchaseOrder record in array format
+	 */	 
+	 function get_purchase_orders($id)
+	 {
+		global $log, $singlepane_view;
+		$log->debug("Entering get_purchase_orders(".$id.") method ...");
+		 global $app_strings;
+		 require_once('modules/PurchaseOrder/PurchaseOrder.php');
+		 $focus = new PurchaseOrder();
+
+		 $button = '';
+
+		 if(isPermitted("PurchaseOrder",1,"") == 'yes')
+		 {
+
+			 $button .= '<input title="'.$app_strings['LBL_PORDER_BUTTON_TITLE'].'" accessyKey="O" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'PurchaseOrder\';this.form.return_module.value=\'Contacts\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_PORDER_BUTTON'].'">&nbsp;';
+		 }
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+		 	$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		 $query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_crmentity.*, vtiger_purchaseorder.*,vtiger_vendor.vendorname,vtiger_contactdetails.lastname from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid left outer join vtiger_contactdetails on vtiger_contactdetails.contactid=vtiger_purchaseorder.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.contactid=".$id;
+		$log->debug("Exiting get_purchase_orders method ...");
+		 return GetRelatedList('Contacts','PurchaseOrder',$focus,$query,$button,$returnset);
+	 }
+
+	/** Returns a list of the associated emails
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	*/
+	function get_emails($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_emails(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Emails();
+
+		$button = '';
+
+		if(isPermitted("Emails",1,"") == 'yes')
+		{	
+			$button .= '<input title="New Email" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Emails\';this.form.email_directing_module.value=\'contacts\';this.form.record.value='.$id.';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_EMAIL'].'">';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+
+		$log->info("Email Related List for Contact Displayed");
+
+		$query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_crmentity.modifiedtime, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_activity.date_start from vtiger_activity, vtiger_seactivityrel, vtiger_contactdetails, vtiger_users, vtiger_crmentity left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.activityid = vtiger_activity.activityid and vtiger_contactdetails.contactid = vtiger_seactivityrel.crmid and vtiger_users.id=vtiger_crmentity.smownerid and vtiger_crmentity.crmid = vtiger_activity.activityid  and vtiger_contactdetails.contactid = ".$id." and vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted = 0";
+		$log->debug("Exiting get_emails method ...");
+		return GetRelatedList('Contacts','Emails',$focus,$query,$button,$returnset);
+	}
+
+	/** Returns a list of the associated Campaigns
+	  * @param $id -- campaign id :: Type Integer
+	  * @returns list of campaigns in array format
+	  */
+	      
+	function get_campaigns($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_campaigns(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Campaigns();
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Contacts&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Contacts&return_action=CallRelatedList&return_id='.$id;
+		$button = '';
+
+		$log->info("Campaign Related List for Contact Displayed");
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_campaign.campaignid, vtiger_campaign.campaignname, vtiger_campaign.campaigntype, vtiger_campaign.campaignstatus, vtiger_campaign.expectedrevenue, vtiger_campaign.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_campaign inner join vtiger_campaigncontrel on vtiger_campaigncontrel.campaignid=vtiger_campaign.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid left join vtiger_campaigngrouprelation on vtiger_campaign.campaignid=vtiger_campaigngrouprelation.campaignid left join vtiger_groups on vtiger_groups.groupname=vtiger_campaigngrouprelation.groupname left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid where vtiger_campaigncontrel.contactid=".$id." and vtiger_crmentity.deleted=0";
+
+		$log->debug("Exiting get_campaigns method ...");
+		return GetRelatedList('Contacts','Campaigns',$focus,$query,$button,$returnset);
+
+	}
+	/** Function to export the contact records in CSV Format
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Export Contacts Query.
+	*/
+        function create_export_query(&$order_by, &$where)
+        {
+		global $log;
+		global $current_user;
+		$log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
+
+		include("include/utils/ExportUtils.php");
+
+		//To get the Permitted fields query and the permitted fields list
+		$sql = getPermittedFieldsQuery("Contacts", "detail_view");
+		$fields_list = getFieldsListFromQuery($sql);
+
+		$query = "SELECT vtiger_contactdetails.salutation as 'Salutation',$fields_list, vtiger_contactgrouprelation.groupname as 'Assigned To Group' 
+                                FROM vtiger_contactdetails
+                                inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid
+                                LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id and vtiger_users.status='Active' 
+                                LEFT JOIN vtiger_account on vtiger_contactdetails.accountid=vtiger_account.accountid
+				left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
+				left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid=vtiger_contactdetails.contactid
+			        left join vtiger_contactscf on vtiger_contactscf.contactid=vtiger_contactdetails.contactid
+			        left join vtiger_customerdetails on vtiger_customerdetails.customerid=vtiger_contactdetails.contactid
+				LEFT JOIN vtiger_contactgrouprelation
+                	                ON vtiger_contactscf.contactid = vtiger_contactgrouprelation.contactid
+	                        LEFT JOIN vtiger_groups
+                        	        ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+				LEFT JOIN vtiger_contactdetails vtiger_contactdetails2
+					ON vtiger_contactdetails2.contactid = vtiger_contactdetails.reportsto
+				where vtiger_crmentity.deleted=0";
+				//vtiger_contactdetails2 is added to get the Reports To of Contact
+
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		//we should add security check when the user has Private Access
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[4] == 3)
+		{
+			//Added security check to get the permitted records only
+			$query = $query." ".getListViewSecurityParameter("Contacts");
+		}
+
+                $log->info("Export Query Constructed Successfully");
+		$log->debug("Exiting create_export_query method ...");
+		return $query;
+        }
+
+	
+/** Function to get the Columnnames of the Contacts
+* Used By vtigerCRM Word Plugin
+* Returns the Merge Fields for Word Plugin
+*/
+function getColumnNames()
+{
+	global $log, $current_user;
+	$log->debug("Entering getColumnNames() method ...");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+	{
+	 $sql1 = "select fieldlabel from vtiger_field where tabid=4 and block <> 75";
+	}else
+	{
+	 $profileList = getCurrentUserProfileList();
+	 $sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 6 and vtiger_field.block <> 75 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+	$result = $this->db->query($sql1);
+	$numRows = $this->db->num_rows($result);
+	for($i=0; $i < $numRows;$i++)
+	{
+	$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
+	$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
+	$custom_fields[$i] = strtoupper($custom_fields[$i]);
+	}
+	$mergeflds = $custom_fields;
+	$log->debug("Exiting getColumnNames method ...");
+	return $mergeflds;
+}
+//End 
+/** Function to get the Contacts assigned to a user with a valid email address.
+* @param varchar $username - User Name
+* @param varchar $emailaddress - Email Addr for each contact.
+* Used By vtigerCRM Outlook Plugin
+* Returns the Query 
+*/
+function get_searchbyemailid($username,$emailaddress)
+{
+	global $log;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	$log->debug("Entering get_searchbyemailid(".$username.",".$emailaddress.") method ...");
+	$query = "select vtiger_contactdetails.lastname,vtiger_contactdetails.firstname,
+					vtiger_contactdetails.contactid, vtiger_contactdetails.salutation, 
+					vtiger_contactdetails.email,vtiger_contactdetails.title,
+					vtiger_contactdetails.mobile,vtiger_account.accountname,
+					vtiger_account.accountid as accountid  from vtiger_contactdetails 
+						inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
+						inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid  
+						left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid 
+						left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid
+            LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			      LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+						where vtiger_crmentity.deleted=0  and vtiger_contactdetails.email like '%".$emailaddress."%' and vtiger_contactdetails.email != ''";
+  $tab_id = getTabid("Contacts");
+  if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
+	{
+				$sec_parameter=getListViewSecurityParameter("Contacts");
+				$query .= $sec_parameter;
+
+	}
+	$log->debug("Exiting get_searchbyemailid method ...");
+	return $this->plugin_process_list_query($query);
+}
+
+/** Function to get the Contacts associated with the particular User Name.
+*  @param varchar $user_name - User Name
+*  Returns query
+*/
+
+function get_contactsforol($user_name)
+{
+	global $log,$adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($user_name);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+	
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select tablename,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and vtiger_field.block <> 5";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select tablename,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'tablename');
+      $permitted_lists[] = $adb->query_result($result1,$i,'columnname');
+      if($adb->query_result($result1,$i,'columnname') == "accountid")
+      {
+        $permitted_lists[] = 'vtiger_account';
+        $permitted_lists[] = 'accountname';
+      }
+  }
+	$permitted_lists = array_chunk($permitted_lists,2);
+	$column_table_lists = array();
+	for($i=0;$i < count($permitted_lists);$i++)
+	{
+	   $column_table_lists[] = implode(".",$permitted_lists[$i]);
+  }
+	
+	$log->debug("Entering get_contactsforol(".$user_name.") method ...");
+	$query = "select vtiger_contactdetails.contactid as id, ".implode(',',$column_table_lists)." from vtiger_contactdetails 
+						inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid 
+						inner join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid 
+						left join vtiger_account on vtiger_account.accountid=vtiger_contactdetails.accountid 
+						left join vtiger_contactaddress on vtiger_contactaddress.contactaddressid=vtiger_contactdetails.contactid 
+						left join vtiger_contactsubdetails on vtiger_contactsubdetails.contactsubscriptionid = vtiger_contactdetails.contactid
+            LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			      LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname 
+						where vtiger_crmentity.deleted=0 and vtiger_users.user_name='".$user_name."'";
+  $log->debug("Exiting get_contactsforol method ...");
+	return $query;
+}
+
+
+	/** Function to handle module specific operations when saving a entity 
+	*/
+	function save_module($module)
+	{
+		$this->insertIntoAttachment($this->id,$module);		
+	}	
+
+	/**
+	 *      This function is used to add the vtiger_attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database.
+	 *      @param int $id  - entity id to which the vtiger_files to be uploaded
+	 *      @param string $module  - the current module name
+	*/
+	function insertIntoAttachment($id,$module)
+	{
+		global $log, $adb;
+		$log->debug("Entering into insertIntoAttachment($id,$module) method.");
+		
+		$file_saved = false;
+
+		//This is to added to store the existing attachment id of the contact where we should delete this when we give new image
+		$old_attachmentid = $adb->query_result($adb->query("select * from vtiger_seattachmentsrel where crmid=$id"),0,'attachmentsid');
+
+		foreach($_FILES as $fileindex => $files)
+		{
+			if($files['name'] != '' && $files['size'] > 0)
+			{
+				$file_saved = $this->uploadAndSaveFile($id,$module,$files);
+			}
+		}
+
+		//This is to handle the delete image for contacts
+		if($module == 'Contacts' && $file_saved)
+		{
+			$del_res1 = $adb->query("delete from vtiger_attachments where attachmentsid=$old_attachmentid");
+			$del_res2 = $adb->query("delete from vtiger_seattachmentsrel where attachmentsid=$old_attachmentid");
+		}
+
+		$log->debug("Exiting from insertIntoAttachment($id,$module) method.");
+	}	
+
+
+//End
+
+}
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/DetailView.php Mon Apr 16 12:27:44 2007
@@ -1,138 +1,146 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/DetailView.php,v 1.38 2005/04/25 05:04:46 rank Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('include/CustomFieldUtil.php');
-require_once('include/database/PearDatabase.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-global $log;
-global $mod_strings;
-global $app_strings;
-global $currentModule, $singlepane_view;
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/DetailView.php,v 1.38 2005/04/25 05:04:46 rank Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('include/CustomFieldUtil.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+global $log;
+global $mod_strings;
+global $app_strings;
+global $currentModule, $singlepane_view;
 
 global $current_organization;
 global $user_organizations;
-
-$focus = new Contacts();
-
-if(isset($_REQUEST['record']) && $_REQUEST['record']!='') {
-
-        $focus->id=$_REQUEST['record'];
-        $focus->retrieve_entity_info($_REQUEST['record'],'Contacts');
-	 $log->info("Entity info successfully retrieved for Contact DetailView.");
-	$focus->firstname=$focus->column_fields['firstname'];
-        $focus->lastname=$focus->column_fields['lastname'];
-}
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
-	$focus->id = "";
-}
-
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-$log->info("Contact detail view");
-
-$smarty = new vtigerCRM_Smarty;
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);
-$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-
-if(useInternalMailer() == 1) 
-	$smarty->assign("INT_MAILER","true");
-
-$smarty->assign("NAME",$focus->lastname.' '.$focus->firstname);
-
-$log->info("Detail Block Informations successfully retrieved.");
-$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
-$smarty->assign("CUSTOMFIELD", $cust_fld);
-$smarty->assign("SINGLE_MOD", 'Contact');
-$smarty->assign("REDIR_MOD","contacts");
-
-$smarty->assign("ID", $_REQUEST['record']);
-if(isPermitted("Contacts","EditView",$_REQUEST['record']) == 'yes')
-	$smarty->assign("EDIT_DUPLICATE","permitted");
-
-if(isPermitted("Contacts","Delete",$_REQUEST['record']) == 'yes')
-	$smarty->assign("DELETE","permitted");
-if(isPermitted("Emails","EditView",'') == 'yes')
-{
-	//Added to pass the parents list as hidden for Emails -- 09-11-2005
-	$parent_email = getEmailParentsList('Contacts',$_REQUEST['record']);
-	$smarty->assign("HIDDEN_PARENTS_LIST",$parent_email);
-	$smarty->assign("SENDMAILBUTTON","permitted");
-}
-
-if(isPermitted("Contacts","Merge",'') == 'yes')
-{
-	$smarty->assign("MERGEBUTTON","permitted");
-	require_once('include/utils/UserInfoUtil.php');
-	$wordTemplateResult = fetchWordTemplateList("Contacts");
-	$tempCount = $adb->num_rows($wordTemplateResult);
-	$tempVal = $adb->fetch_array($wordTemplateResult);
-	for($templateCount=0;$templateCount<$tempCount;$templateCount++)
-	{
-		$optionString[$tempVal["templateid"]]=$tempVal["filename"];
-		$tempVal = $adb->fetch_array($wordTemplateResult);
-	}
-	$smarty->assign("WORDTEMPLATEOPTIONS",$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']);
-        $smarty->assign("TOPTIONS",$optionString);
-}
-
-//Security check for related list
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-
-$tabid = getTabid("Contacts");
-$validationData = getDBValidationData($focus->tab_name,$tabid);
-$data = split_validationdataArray($validationData);
-
-$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
-$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
-$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-
-$smarty->assign("MODULE",$currentModule);
-$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
-
-if($singlepane_view == 'true')
-{
-	$related_array = getRelatedLists($currentModule,$focus);
-	$smarty->assign("RELATEDLISTS", $related_array);
-}
-
-$smarty->assign("SinglePane_View", $singlepane_view);
-
+
+$focus = new Contacts();
+
+if(isset($_REQUEST['record']) && $_REQUEST['record']!='') {
+
+        $focus->id=$_REQUEST['record'];
+        $focus->retrieve_entity_info($_REQUEST['record'],'Contacts');
+	 $log->info("Entity info successfully retrieved for Contact DetailView.");
+	$focus->firstname=$focus->column_fields['firstname'];
+        $focus->lastname=$focus->column_fields['lastname'];
+}
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+	$focus->id = "";
+}
+
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+$log->info("Contact detail view");
+
+$smarty = new vtigerCRM_Smarty;
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+
+if(useInternalMailer() == 1) 
+	$smarty->assign("INT_MAILER","true");
+
+$smarty->assign("NAME",$focus->lastname.' '.$focus->firstname);
+
+$log->info("Detail Block Informations successfully retrieved.");
+$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
+$smarty->assign("CUSTOMFIELD", $cust_fld);
+$smarty->assign("SINGLE_MOD", 'Contact');
+
+$smarty->assign("ID", $_REQUEST['record']);
+if(isPermitted("Contacts","EditView",$_REQUEST['record']) == 'yes')
+	$smarty->assign("EDIT_DUPLICATE","permitted");
+
+if(isPermitted("Contacts","Delete",$_REQUEST['record']) == 'yes')
+	$smarty->assign("DELETE","permitted");
+if(isPermitted("Emails","EditView",'') == 'yes')
+{
+	//Added to pass the parents list as hidden for Emails -- 09-11-2005
+	$parent_email = getEmailParentsList('Contacts',$_REQUEST['record']);
+	$smarty->assign("HIDDEN_PARENTS_LIST",$parent_email);
+	$smarty->assign("SENDMAILBUTTON","permitted");
+	$smarty->assign("EMAIL1",$focus->column_fields['email']);
+	$smarty->assign("EMAIL2",$focus->column_fields['yahooid']);
+
+}
+
+if(isPermitted("Contacts","Merge",'') == 'yes')
+{
+	$smarty->assign("MERGEBUTTON","permitted");
+	require_once('include/utils/UserInfoUtil.php');
+	$wordTemplateResult = fetchWordTemplateList("Contacts");
+	$tempCount = $adb->num_rows($wordTemplateResult);
+	$tempVal = $adb->fetch_array($wordTemplateResult);
+	for($templateCount=0;$templateCount<$tempCount;$templateCount++)
+	{
+		$optionString[$tempVal["templateid"]]=$tempVal["filename"];
+		$tempVal = $adb->fetch_array($wordTemplateResult);
+	}
+	 $smarty->assign("TEMPLATECOUNT",$tempCount);
+	$smarty->assign("WORDTEMPLATEOPTIONS",$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']);
+        $smarty->assign("TOPTIONS",$optionString);
+}
+
+//Security check for related list
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+
+$tabid = getTabid("Contacts");
+$validationData = getDBValidationData($focus->tab_name,$tabid);
+$data = split_validationdataArray($validationData);
+
+$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
+if($singlepane_view == 'true')
+{
+	$sql = $adb->query('select accountid from vtiger_contactdetails where contactid='.$focus->id);
+	$accountid = $adb->query_result($sql,0,'accountid');
+	if($accountid == 0) $accountid='';
+	$smarty->assign("accountid",$accountid);
+	$related_array = getRelatedLists($currentModule,$focus);
+	$smarty->assign("RELATEDLISTS", $related_array);
+}
+
+$smarty->assign("SinglePane_View", $singlepane_view);
+
 // Assigned organizations
 $smarty->assign("CURRENT_ORGANIZATION",$current_organization);
 $org_array=array();
@@ -143,6 +151,6 @@
 }
 $smarty->assign("USER_ORGANIZATIONS",$org_array);
 
-$smarty->display("DetailView.tpl");
-?>
-
+$smarty->display("DetailView.tpl");
+?>
+

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/DetailViewAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/DetailViewAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/DetailViewAjax.php Mon Apr 16 12:27:44 2007
@@ -31,11 +31,67 @@
 		 $cntObj->id = $crmid;
 		 $cntObj->mode = "edit";
 		 $cntObj->save("Contacts");
+
+		 $email_res = $adb->query("select email from vtiger_contactdetails where contactid=".$cntObj->id);
+		 $email = $adb->query_result($email_res,0,'email');
+
+		 $check_available = $adb->query("select * from vtiger_portalinfo where id=".$cntObj->id);
+		 $update = '';
 		 if($fieldname =='email')
 		 {
-			 $sql = "update vtiger_portalinfo set user_name='".$fieldvalue."' where id=".$crmid;
-			 $adb->query($sql);
+			 $active = $adb->query_result($check_available,0,'isactive');
+			 $update = false;
+			 if($active != '' && $active == 1)
+			 {
+				$sql = "update vtiger_portalinfo set user_name='".$fieldvalue."',isactive='".$active."' where id=".$crmid;
+				$adb->query($sql);
+				$email = $fieldvalue;
+				$result = $adb->query("select user_password from vtiger_portalinfo where id=".$cntObj->id);
+				$password = $adb->query_result($result,0,'user_password');
+				$update = true;
+		 	 }
 		 }
+
+		 if($fieldname == "portal")
+		 {
+			if($email != '')
+			{
+				$confirm = $adb->query_result($check_available,0,'isactive');
+				if($confirm == '' && $fieldvalue == 1)
+				{
+					$password = makeRandomPassword();
+					$sql = "insert into vtiger_portalinfo (id,user_name,user_password,type,isactive) values(".$cntObj->id.",'".$email."','".$password."','C',1)";
+					$adb->query($sql);
+					$insert = true;
+
+				}
+				elseif($confirm == 0 && $fieldvalue == 1)
+				{
+					$sql = "update vtiger_portalinfo set user_name='".$email."', isactive=1 where id=".$cntObj->id;
+					$adb->query($sql);
+					$result = $adb->query("select user_password from vtiger_portalinfo where id=".$cntObj->id);
+					$password = $adb->query_result($result,0,'user_password');
+					$update = true;
+
+				}
+				elseif($confirm == 1 && $fieldvalue == 0)
+				{
+					$sql = "update vtiger_portalinfo set isactive=0 where id=".$cntObj->id;
+					$adb->query($sql);
+				}
+			}
+		}
+			require_once("modules/Emails/mail.php");
+			global $current_user;
+			$data_array = Array();
+			$data_array['first_name'] = $cntObj->column_fields['firstname'];
+			$data_array['last_name'] = $cntObj->column_fields['lastname'];
+			$data_array['email'] = $email;
+			$data_array['portal_url'] = "<a href=".$PORTAL_URL."/login.php>".$mod_strings['Please Login Here']."</a>";
+			$contents = getmail_contents_portalUser($data_array,$password);
+			if($insert == true || $update == true)
+				send_mail('Contacts',$cntObj->column_fields['email'],$current_user->user_name,'',$mod_strings['Customer Portal Login Details'],$contents);
+
 		 if($cntObj->id != "")
 		 {
 			 echo ":#:SUCCESS";

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/EditView.php Mon Apr 16 12:27:44 2007
@@ -1,228 +1,231 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/EditView.php,v 1.21 2005/03/24 16:18:38 samk Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('include/CustomFieldUtil.php');
-require_once('include/ComboUtil.php');
-require_once('include/utils/utils.php');
-require_once('include/FormValidationUtil.php');
-
-global $log,$mod_strings,$app_strings,$theme,$currentModule;
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/EditView.php,v 1.21 2005/03/24 16:18:38 samk Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('include/CustomFieldUtil.php');
+require_once('include/ComboUtil.php');
+require_once('include/utils/utils.php');
+require_once('include/FormValidationUtil.php');
+
+global $log,$mod_strings,$app_strings,$theme,$currentModule;
 global $current_organization;
 global $user_organizations;
-
-//added for contact image
-$encode_val=$_REQUEST['encode_val'];
-$decode_val=base64_decode($encode_val);
-
- $saveimage=isset($_REQUEST['saveimage'])?$_REQUEST['saveimage']:"false";
- $errormessage=isset($_REQUEST['error_msg'])?$_REQUEST['error_msg']:"false";
- $image_error=isset($_REQUEST['image_error'])?$_REQUEST['image_error']:"false";
-//end
-
-$focus = new Contacts();
-$smarty = new vtigerCRM_Smarty;
-
-if(isset($_REQUEST['record']) && isset($_REQUEST['record'])) 
-{
-    $focus->id = $_REQUEST['record'];
-    $focus->mode = 'edit';
-    $focus->retrieve_entity_info($_REQUEST['record'],"Contacts");
-    $log->info("Entity info successfully retrieved for EditView.");
-    $focus->firstname=$focus->column_fields['firstname'];
-    $focus->lastname=$focus->column_fields['lastname'];
+
+//added for contact image
+$encode_val=$_REQUEST['encode_val'];
+$decode_val=base64_decode($encode_val);
+
+ $saveimage=isset($_REQUEST['saveimage'])?$_REQUEST['saveimage']:"false";
+ $errormessage=isset($_REQUEST['error_msg'])?$_REQUEST['error_msg']:"false";
+ $image_error=isset($_REQUEST['image_error'])?$_REQUEST['image_error']:"false";
+//end
+
+$focus = new Contacts();
+$smarty = new vtigerCRM_Smarty;
+
+if(isset($_REQUEST['record']) && isset($_REQUEST['record'])) 
+{
+    $focus->id = $_REQUEST['record'];
+    $focus->mode = 'edit';
+    $focus->retrieve_entity_info($_REQUEST['record'],"Contacts");
+    $log->info("Entity info successfully retrieved for EditView.");
+    $focus->firstname=$focus->column_fields['firstname'];
+    $focus->lastname=$focus->column_fields['lastname'];
 } else {
     $focus->column_fields["otherorgs"][$current_organization]=1;
-}
-
-if($image_error=="true")
-{
-        $explode_decode_val=explode("&",$decode_val);
-        for($i=1;$i<count($explode_decode_val);$i++)
-        {
-                $test=$explode_decode_val[$i];
-                $values=explode("=",$test);
-                $field_name_val=$values[0];
-                $field_value=$values[1];
-                $focus->column_fields[$field_name_val]=$field_value;
-        }
-}
-
-if(isset($_REQUEST['account_id']) && $_REQUEST['account_id']!='' && $_REQUEST['record']=='')
-{
-        require_once('modules/Accounts/Accounts.php');
-        $focus->column_fields['account_id'] = $_REQUEST['account_id'];
-        $acct_focus = new Accounts();
-        $acct_focus->retrieve_entity_info($_REQUEST['account_id'],"Accounts");
-        $focus->column_fields['fax']=$acct_focus->column_fields['fax'];
-        $focus->column_fields['otherphone']=$acct_focus->column_fields['phone'];
-        $focus->column_fields['mailingcity']=$acct_focus->column_fields['bill_city'];
-        $focus->column_fields['othercity']=$acct_focus->column_fields['ship_city'];
-        $focus->column_fields['mailingstreet']=$acct_focus->column_fields['bill_street'];
-        $focus->column_fields['otherstreet']=$acct_focus->column_fields['ship_street'];
-        $focus->column_fields['mailingstate']=$acct_focus->column_fields['bill_state'];
-        $focus->column_fields['otherstate']=$acct_focus->column_fields['ship_state'];
-        $focus->column_fields['mailingzip']=$acct_focus->column_fields['bill_code'];
-        $focus->column_fields['otherzip']=$acct_focus->column_fields['ship_code'];
-        $focus->column_fields['mailingcountry']=$acct_focus->column_fields['bill_country'];
-        $focus->column_fields['othercountry']=$acct_focus->column_fields['ship_country'];
-        $log->debug("Accountid Id from the request is ".$_REQUEST['account_id']);
-
-}
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') 
-{
-	$focus->id = "";
-	$focus->mode = "";
-}
-
-$disp_view = getView($focus->mode);
-if($disp_view == 'edit_view')
-	$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
-else
-{
-	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
-	$smarty->assign("ADVBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'ADV'));
-}
-
-$smarty->assign("OP_MODE",$disp_view);
-
-//needed when creating a new contact with a default vtiger_account value passed in
-if (isset($_REQUEST['account_name']) && is_null($focus->account_name)) {
-	$focus->account_name = $_REQUEST['account_name'];
-	
-
-}
-if (isset($_REQUEST['account_id']) && is_null($focus->account_id)) {
-	$focus->account_id = $_REQUEST['account_id'];
-}
-
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-//retreiving the combo values array
-$comboFieldNames = Array('leadsource'=>'lead_source_dom'
-                      ,'salutationtype'=>'salutation_dom');
-$comboFieldArray = getComboArray($comboFieldNames);
-
-require_once($theme_path.'layout_utils.php');
-
-$log->info("Contact detail view");
-
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-$smarty->assign("NAME",$focus->lastname." ".$focus->firstname);
-if(isset($cust_fld))
-{
-        $smarty->assign("CUSTOMFIELD", $cust_fld);
-}
-$smarty->assign("ID", $focus->id);
-$smarty->assign("MODULE",$currentModule);
-$smarty->assign("SINGLE_MOD",'Contact');
-
-if($focus->mode == 'edit')
-{
-	$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-        $smarty->assign("MODE", $focus->mode);
-}
-
-if(isset($_REQUEST['activity_mode']) && $_REQUEST['activity_mode'] !='')
-        $smarty->assign("ACTIVITYMODE",$_REQUEST['activity_mode']);
-
-// Unimplemented until jscalendar language vtiger_files are fixed
-$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
-$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
-
-if(isset($_REQUEST['campaignid']))
-$smarty->assign("campaignid",$_REQUEST['campaignid']);
-if (isset($_REQUEST['return_module']))
-$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
-if (isset($_REQUEST['return_action']))
-$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
-if (isset($_REQUEST['return_id']))
-$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
-if (isset($_REQUEST['return_viewname']))
-$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);
-$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-
- $tabid = getTabid("Contacts");
- $validationData = getDBValidationData($focus->tab_name,$tabid);
- $data = split_validationdataArray($validationData);
-
- $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
- $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
- $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-if($errormessage==2)
-{
-        $msg =$mod_strings['LBL_MAXIMUM_LIMIT_ERROR'];
-        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
-}
-else if($errormessage==3)
-{
-        $msg = $mod_strings['LBL_UPLOAD_ERROR'];
-        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
-
-}
-else if($errormessage=="image")
-{
-        $msg = $mod_strings['LBL_IMAGE_ERROR'];
-        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
-}
-else if($errormessage =="invalid")
-{
-        $msg = $mod_strings['LBL_INVALID_IMAGE'];
-        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
-}
-else
-{
-        $errormessage="";
-}
-if($errormessage!="")
-{
-        $smarty->assign("ERROR_MESSAGE",$errormessage);
-}
-
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-
-// Assigned organizations
-$smarty->assign("CURRENT_ORGANIZATION",$current_organization);
-$org_array=array();
-$org=strtok( $user_organizations, "|");
-while( $org !== false) {
-    $org_array[$org] = 1;
-    $org=strtok( "|");
-}
-$smarty->assign("USER_ORGANIZATIONS",$org_array);
-
-if($focus->mode == 'edit')
-$smarty->display("salesEditView.tpl");
-else
-$smarty->display('CreateView.tpl');
-
-
-?>
+}
+
+if($image_error=="true")
+{
+        $explode_decode_val=explode("&",$decode_val);
+        for($i=1;$i<count($explode_decode_val);$i++)
+        {
+                $test=$explode_decode_val[$i];
+                $values=explode("=",$test);
+                $field_name_val=$values[0];
+                $field_value=$values[1];
+                $focus->column_fields[$field_name_val]=$field_value;
+        }
+}
+
+if(isset($_REQUEST['account_id']) && $_REQUEST['account_id']!='' && $_REQUEST['record']=='')
+{
+        require_once('modules/Accounts/Accounts.php');
+        $focus->column_fields['account_id'] = $_REQUEST['account_id'];
+        $acct_focus = new Accounts();
+        $acct_focus->retrieve_entity_info($_REQUEST['account_id'],"Accounts");
+        $focus->column_fields['fax']=$acct_focus->column_fields['fax'];
+        $focus->column_fields['otherphone']=$acct_focus->column_fields['phone'];
+        $focus->column_fields['mailingcity']=$acct_focus->column_fields['bill_city'];
+        $focus->column_fields['othercity']=$acct_focus->column_fields['ship_city'];
+        $focus->column_fields['mailingstreet']=$acct_focus->column_fields['bill_street'];
+        $focus->column_fields['otherstreet']=$acct_focus->column_fields['ship_street'];
+        $focus->column_fields['mailingstate']=$acct_focus->column_fields['bill_state'];
+        $focus->column_fields['otherstate']=$acct_focus->column_fields['ship_state'];
+        $focus->column_fields['mailingzip']=$acct_focus->column_fields['bill_code'];
+        $focus->column_fields['otherzip']=$acct_focus->column_fields['ship_code'];
+        $focus->column_fields['mailingcountry']=$acct_focus->column_fields['bill_country'];
+        $focus->column_fields['othercountry']=$acct_focus->column_fields['ship_country'];
+	$focus->column_fields['mailingpobox']=$acct_focus->column_fields['bill_pobox'];
+	$focus->column_fields['otherpobox']=$acct_focus->column_fields['ship_pobox'];
+
+        $log->debug("Accountid Id from the request is ".$_REQUEST['account_id']);
+
+}
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') 
+{
+	$focus->id = "";
+	$focus->mode = "";
+}
+
+$disp_view = getView($focus->mode);
+if($disp_view == 'edit_view')
+	$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
+else
+{
+	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
+	$smarty->assign("ADVBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'ADV'));
+}
+$smarty->assign("OP_MODE",$disp_view);
+
+//needed when creating a new contact with a default vtiger_account value passed in
+if (isset($_REQUEST['account_name']) && is_null($focus->account_name)) {
+	$focus->account_name = $_REQUEST['account_name'];
+	
+
+}
+if (isset($_REQUEST['account_id']) && is_null($focus->account_id)) {
+	$focus->account_id = $_REQUEST['account_id'];
+}
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+//retreiving the combo values array
+$comboFieldNames = Array('leadsource'=>'lead_source_dom'
+                      ,'salutationtype'=>'salutation_dom');
+$comboFieldArray = getComboArray($comboFieldNames);
+
+require_once($theme_path.'layout_utils.php');
+
+$log->info("Contact detail view");
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("NAME",$focus->lastname." ".$focus->firstname);
+if(isset($cust_fld))
+{
+        $smarty->assign("CUSTOMFIELD", $cust_fld);
+}
+$smarty->assign("ID", $focus->id);
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("SINGLE_MOD",'Contact');
+
+if($focus->mode == 'edit')
+{
+	$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+        $smarty->assign("MODE", $focus->mode);
+}
+
+if(isset($_REQUEST['activity_mode']) && $_REQUEST['activity_mode'] !='')
+        $smarty->assign("ACTIVITYMODE",$_REQUEST['activity_mode']);
+
+// Unimplemented until jscalendar language vtiger_files are fixed
+$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
+$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
+
+if(isset($_REQUEST['campaignid']))
+$smarty->assign("campaignid",$_REQUEST['campaignid']);
+if (isset($_REQUEST['return_module']))
+$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
+if (isset($_REQUEST['return_action']))
+$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
+if (isset($_REQUEST['return_id']))
+$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
+if (isset($_REQUEST['return_viewname']))
+$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+
+ $tabid = getTabid("Contacts");
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+if($errormessage==2)
+{
+        $msg =$mod_strings['LBL_MAXIMUM_LIMIT_ERROR'];
+        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
+}
+else if($errormessage==3)
+{
+        $msg = $mod_strings['LBL_UPLOAD_ERROR'];
+        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
+
+}
+else if($errormessage=="image")
+{
+        $msg = $mod_strings['LBL_IMAGE_ERROR'];
+        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
+}
+else if($errormessage =="invalid")
+{
+        $msg = $mod_strings['LBL_INVALID_IMAGE'];
+        $errormessage ="<B><font color='red'>".$msg."</font></B> <br><br>";
+}
+else
+{
+        $errormessage="";
+}
+if($errormessage!="")
+{
+        $smarty->assign("ERROR_MESSAGE",$errormessage);
+}
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
+
+// Assigned organizations
+$smarty->assign("CURRENT_ORGANIZATION",$current_organization);
+$org_array=array();
+$org=strtok( $user_organizations, "|");
+while( $org !== false) {
+    $org_array[$org] = 1;
+    $org=strtok( "|");
+}
+$smarty->assign("USER_ORGANIZATIONS",$org_array);
+
+if($focus->mode == 'edit')
+$smarty->display("salesEditView.tpl");
+else
+$smarty->display('CreateView.tpl');
+
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/ListView.php Mon Apr 16 12:27:44 2007
@@ -234,7 +234,6 @@
 }
 if(isPermitted("Contacts","Merge") == 'yes') 
 {
-	$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Contacts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 	$wordTemplateResult = fetchWordTemplateList("Contacts");
 	$tempCount = $adb->num_rows($wordTemplateResult);
 	$tempVal = $adb->fetch_array($wordTemplateResult);
@@ -243,7 +242,21 @@
 		$optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 		$tempVal = $adb->fetch_array($wordTemplateResult);
 	}
-	$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+	if($tempCount > 0)
+	{
+		$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+	
+		$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Contacts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
+	}
+	else
+	{ 
+		global $current_user;
+                require("user_privileges/user_privileges_".$current_user->id.".php");
+		if($is_admin == true)
+		{
+			$smarty->assign("MERGEBUTTON","<td><a href=index.php?module=Settings&action=upload&tempModule=".$currentModule.">". $app_strings['LBL_CREATE_MERGE_TEMPLATE']."</td>");
+		}
+	}
 }
 //mass merge for word templates
 

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/Merge.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/Merge.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/Merge.php Mon Apr 16 12:27:44 2007
@@ -24,6 +24,7 @@
 }
 else if(document.all)
 {
+	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");
 	document.write("<OBJECT Name='vtigerCRM' codebase='modules/Settings/vtigerCRM.CAB#version=1,5,0,0' id='objMMPage' classid='clsid:0FC436C2-2E62-46EF-A3FB-E68E94705126' width=0 height=0></object>");
 }
 </script>

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/Save.php Mon Apr 16 12:27:44 2007
@@ -25,29 +25,6 @@
 require_once('include/database/PearDatabase.php');
 require_once("modules/Emails/mail.php");
 
-
-/**
- * This function is used to get a random password.
- * @return a random password with alpha numeric chanreters of length 8
- */
-function makeRandomPassword() 
-{
-	global $log;
-	$log->debug("Entering makeRandomPassword() method ...");
-        $salt = "abcdefghijklmnopqrstuvwxyz0123456789";
-        srand((double)microtime()*1000000);
-        $i = 0;
-        while ($i <= 7)
-	{
-                $num = rand() % 33;
-                $tmp = substr($salt, $num, 1);
-                $pass = $pass . $tmp;
-                $i++;
-	}
-$log->debug("Exiting makeRandomPassword method ...");
-      return $pass;
-}
-
 $local_log =& LoggerManager::getLogger('index');
 
 global $log,$adb;
@@ -193,20 +170,18 @@
 			$adb->query($sql);
 		}
 
-		$subject = "Customer Portal Login Details";
-		$contents = "Dear ".$_REQUEST['firstname'].' '.$_REQUEST['lastname'].',<br><br>';
-		$contents .= 'Your Customer Portal Login details are given below:';
-		$contents .= "<br><br>User Id : ".$_REQUEST['email'];
-		$contents .= '<br>Password : '.$password;
-		$contents .= "<br><br><a href='".$PORTAL_URL."/login.php'>Please Login Here</a>";
-
-		$contents .= '<br><br><b>Note : </b>We suggest you to change your password after logging in first time.';
-		$contents .= '<br><br>Support Team';
+		//changes made to send mail to portal user when we use ajax edit
+		$data_array = Array();
+		$data_array['first_name'] = $_REQUEST['firstname'];
+		$data_array['last_name'] = $_REQUEST['lastname'];
+		$data_array['email'] = $_REQUEST['email'];
+		$data_array['portal_url'] = "<a href=".$PORTAL_URL."/login.php>".$mod_strings['Please Login Here']."</a>";
+		$contents = getmail_contents_portalUser($data_array,$password);
 
 		$log->info("Customer Portal Information Updated in database and details are going to send => '".$_REQUEST['email']."'");
 		if($insert == 'true' || $update == 'true')
 		{
-			$mail_status = send_mail('Contacts',$_REQUEST['email'],$current_user->user_name,'',$subject,$contents);
+			$mail_status = send_mail('Contacts',$_REQUEST['email'],$current_user->user_name,'',$mod_strings['Customer Portal Login Details'],$contents);
 		}
 		$log->info("After return from the SendMailToCustomer function. Now control will go to the header.");
 	}

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -1,237 +1,248 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/language/en_us.lang.php,v 1.14 2005/03/24 17:47:43 rank Exp $
- * Description:  Defines the English language pack
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-$mod_strings = Array(
-// Mike Crowe Mod --------------------------------------------------------Added for general search
-'LBL_GENERAL_INFORMATION'=>'General Information',
-'LBL_MODULE_NAME'=>'Contacts',
-'LBL_INVITEE'=>'Direct Reports',
-'LBL_MODULE_TITLE'=>'Contacts: Home',
-'LBL_SEARCH_FORM_TITLE'=>'Contact Search',
-'LBL_LIST_FORM_TITLE'=>'Contact List',
-'LBL_NEW_FORM_TITLE'=>'New Contact',
-'LBL_CONTACT_OPP_FORM_TITLE'=>'Contact-Opportunity:',
-'LBL_CONTACT'=>'Contact:',
-
-'LBL_LIST_NAME'=>'Name',
-'LBL_LIST_LAST_NAME'=>'Last Name',
-'LBL_LIST_FIRST_NAME'=>'First Name',
-'LBL_LIST_CONTACT_NAME'=>'Contact Name',
-'LBL_LIST_TITLE'=>'Title',
-'LBL_LIST_ACCOUNT_NAME'=>'Account Name',
-'LBL_LIST_EMAIL_ADDRESS'=>'Email',
-'LBL_LIST_PHONE'=>'Phone',
-'LBL_LIST_CONTACT_ROLE'=>'Role',
-
-//DON'T CONVERT THESE THEY ARE MAPPINGS
-'db_last_name' => 'LBL_LIST_LAST_NAME',
-'db_first_name' => 'LBL_LIST_FIRST_NAME',
-'db_title' => 'LBL_LIST_TITLE',
-'db_email1' => 'LBL_LIST_EMAIL_ADDRESS',
-'db_email2' => 'LBL_LIST_EMAIL_ADDRESS',
-//END DON'T CONVERT
-	
-'LBL_EXISTING_CONTACT' => 'Used an existing contact',
-'LBL_CREATED_CONTACT' => 'Created a new contact',
-'LBL_EXISTING_ACCOUNT' => 'Used an existing vtiger_account',
-'LBL_CREATED_ACCOUNT' => 'Created a new vtiger_account',
-'LBL_CREATED_CALL' => 'Created a new call',
-'LBL_CREATED_MEETING' => 'Created a new meeting',
-'LBL_ADDMORE_BUSINESSCARD' =>'Add another business card',
-'LBL_ADD_BUSINESSCARD' => 'Add Business Card',
-
-'LBL_BUSINESSCARD' => 'Business Card',
-
-'LBL_NAME'=>'Name:',
-'LBL_CONTACT_NAME'=>'Contact Name:',
-'LBL_CONTACT_INFORMATION'=>'Contact Information',
-'LBL_CUSTOM_INFORMATION'=>'Custom Information',
-'LBL_FIRST_NAME'=>'First Name:',
-'LBL_OFFICE_PHONE'=>'Office Phone:',
-'LBL_ACCOUNT_NAME'=>'Account Name:',
-'LBL_ANY_PHONE'=>'Any Phone:',
-'LBL_PHONE'=>'Phone:',
-'LBL_LAST_NAME'=>'Last Name:',
-'LBL_MOBILE_PHONE'=>'Mobile:',
-'LBL_HOME_PHONE'=>'Home:',
-'LBL_LEAD_SOURCE'=>'Lead Source:',
-'LBL_OTHER_PHONE'=>'Other Phone:',
-'LBL_FAX_PHONE'=>'Fax:',
-'LBL_TITLE'=>'Title:',
-'LBL_DEPARTMENT'=>'Department:',
-'LBL_BIRTHDATE'=>'Birthdate:',
-'LBL_EMAIL_ADDRESS'=>'Email:',
-'LBL_OTHER_EMAIL_ADDRESS'=>'Other Email:',
-'LBL_ANY_EMAIL'=>'Any Email:',
-'LBL_REPORTS_TO'=>'Reports To:',
-'LBL_ASSISTANT'=>'Assistant:',
-'LBL_YAHOO_ID'=>'Yahoo! ID:',
-'LBL_ASSISTANT_PHONE'=>'Assistant Phone:',
-'LBL_DO_NOT_CALL'=>'Do Not Call:',
-'LBL_EMAIL_OPT_OUT'=>'Email Opt Out:',
-'LBL_PRIMARY_ADDRESS'=>'Primary Address:',
-'LBL_ALTERNATE_ADDRESS'=>'Other Address:',
-'LBL_ANY_ADDRESS'=>'Any Address:',
-'LBL_CITY'=>'City:',
-'LBL_STATE'=>'State:',
-'LBL_POSTAL_CODE'=>'Postal Code:',
-'LBL_COUNTRY'=>'Country:',
-'LBL_DESCRIPTION_INFORMATION'=>'Description Information',
-'LBL_IMAGE_INFORMATION'=>'Contact Image Information:',
-'LBL_ADDRESS_INFORMATION'=>'Address Information',
-'LBL_DESCRIPTION'=>'Description:',
-'LBL_CONTACT_ROLE'=>'Role:',
-'LBL_OPP_NAME'=>'Opportunity Name:',
-'LBL_DUPLICATE'=>'Potential Duplicate Contacts',
-'MSG_DUPLICATE' => 'Creating this contact may vtiger_potentialy create a duplicate contact. You may either select a contact from the list below or you may click on Create New Contact to continue creating a new contact with the previously entered data.',
-
-'LNK_NEW_APPOINTMENT' => 'New Appointment',
-'LBL_ADD_BUSINESSCARD' => 'Add Business Card',
-'NTC_DELETE_CONFIRMATION'=>'Are you sure you want to delete this record?',
-'NTC_REMOVE_CONFIRMATION'=>'Are you sure you want to remove this contact from this case?',
-'NTC_REMOVE_DIRECT_REPORT_CONFIRMATION'=>'Are you sure you want to remove this record as a direct vtiger_report?',
-'ERR_DELETE_RECORD'=>"en_us A record number must be specified to delete the contact.",
-'NTC_COPY_PRIMARY_ADDRESS'=>'Copy primary address to alternate address',
-'NTC_COPY_ALTERNATE_ADDRESS'=>'Copy alternate address to primary address',
-
-'LBL_SELECT_CONTACT'=>'Select Contact',
-//Added for search heading
-'LBL_GENERAL_INFORMATION'=>'General Information',
-
-
-
-//for v4 release added
-'LBL_NEW_POTENTIAL'=>'New Potential',
-'LBL_POTENTIAL_TITLE'=>'Potentials',
-
-'LBL_NEW_TASK'=>'New Task',
-'LBL_TASK_TITLE'=>'Tasks',
-'LBL_NEW_CALL'=>'New Call',
-'LBL_CALL_TITLE'=>'Calls',
-'LBL_NEW_MEETING'=>'New Meeting',
-'LBL_MEETING_TITLE'=>'Meetings',
-'LBL_NEW_EMAIL'=>'New Email',
-'LBL_EMAIL_TITLE'=>'Emails',
-'LBL_NEW_NOTE'=>'New Note',
-'LBL_NOTE_TITLE'=>'Notes',
-
-// Added for 4GA
-'LBL_TOOL_FORM_TITLE'=>'Contact Tools',
-
-'Salutation'=>'Salutation',
-'First Name'=>'First Name',
-'Office Phone'=>'Office Phone',
-'Last Name'=>'Last Name',
-'Mobile'=>'Mobile',
-'Account Name'=>'Account Name',
-'Home Phone'=>'Home Phone',
-'Lead Source'=>'Lead Source',
-'Phone'=>'Phone',
-'Title'=>'Title',
-'Fax'=>'Fax',
-'Department'=>'Department',
-'Birthdate'=>'Birthdate',
-'Email'=>'Email',
-'Reports To'=>'Reports To',
-'Assistant'=>'Assistant',
-'Yahoo Id'=>'Yahoo Id',
-'Assistant Phone'=>'Assistant Phone',
-'Do Not Call'=>'Do Not Call',
-'Email Opt Out'=>'Email Opt Out',
-'Assigned To'=>'Assigned To',
-'Campaign Source'=>'Campaign Source',
-'Reference' =>'Reference',
-'Created Time'=>'Created Time',
-'Modified Time'=>'Modified Time',
-'Mailing Street'=>'Mailing Street',
-'Other Street'=>'Other Street',
-'Mailing City'=>'Mailing City',
-'Mailing State'=>'Mailing State',
-'Mailing Zip'=>'Mailing Postal Code',
-'Mailing Country'=>'Mailing Country',
-'Mailing Po Box'=>'Mailing PO Box',
-'Other Po Box'=>'Other PO Box',
-'Other City'=>'Other City',
-'Other State'=>'Other State',
-'Other Zip'=>'Other Postal Code',
-'Other Country'=>'Other Country',
-'Contact Image'=>'Contact Image',
-'Description'=>'Description',
-
-// Added vtiger_fields for Add Business Card
-'LBL_NEW_CONTACT'=>'New Contact',
-'LBL_NEW_ACCOUNT'=>'New Account',
-'LBL_NOTE_SUBJECT'=>'Note Subject:',
-'LBL_NOTE'=>'Note:',
-'LBL_WEBSITE'=>'Website:',
-'LBL_NEW_APPOINTMENT'=>'New Appointment',
-'LBL_SUBJECT'=>'Subject:',
-'LBL_START_DATE'=>'Start Date:',
-'LBL_START_TIME'=>'Start Time:',
-
-//Added vtiger_field after 4_0_1
-'Portal User'=>'Portal User',
-'LBL_CUSTOMER_PORTAL_INFORMATION'=>'Customer Portal Information',
-'Support Start Date'=>'Support Start Date',
-'Support End Date'=>'Support End Date',
-//Added for 4.2 Release -- CustomView
-'Name'=>'Name',
-'LBL_ALL'=>'All',
-'LBL_MAXIMUM_LIMIT_ERROR'=>'Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a file smaller than 800000 bytes',
-'LBL_UPLOAD_ERROR'=>'Problems in file upload. Please try again!',
-'LBL_IMAGE_ERROR'=>'The given file is not of type image(.gif/.jpg/.png)',
-'LBL_INVALID_IMAGE'=>'Invalid file OR File has no data',
-
-//Added after 5Alpha5
-'Notify Owner'=>'Notify Owner',
-
-//Added for Picklist Values
-'--None--'=>'--None--',
-
-'Mr.'=>'Mr.',
-'Ms.'=>'Ms.',
-'Mrs.'=>'Mrs.',
-'Dr.'=>'Dr.',
-'Prof.'=>'Prof.',
-
-'Cold Call'=>'Cold Call',
-'Existing Customer'=>'Existing Customer',
-'Self Generated'=>'Self Generated',
-'Employee'=>'Employee',
-'Partner'=>'Partner',
-'Public Relations'=>'Public Relations',
-'Direct Mail'=>'Direct Mail',
-'Conference'=>'Conference',
-'Trade Show'=>'Trade Show',
-'Web Site'=>'Web Site',
-'Word of mouth'=>'Word of mouth',
-'Other'=>'Other',
-'User List'=>'User List',
-
-// Added for multi organization support TRAC #2035
-'LBL_COMPANY_ASSIGNMENT'=>'Organization Assignment',
-'Organization Assignment'=>'Assigned to',
-
-
-);
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Contacts/language/en_us.lang.php,v 1.14 2005/03/24 17:47:43 rank Exp $
+ * Description:  Defines the English language pack
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+$mod_strings = Array(
+// Mike Crowe Mod --------------------------------------------------------Added for general search
+'LBL_MODULE_NAME'=>'Contacts',
+'LBL_INVITEE'=>'Direct Reports',
+'LBL_MODULE_TITLE'=>'Contacts: Home',
+'LBL_SEARCH_FORM_TITLE'=>'Contact Search',
+'LBL_LIST_FORM_TITLE'=>'Contact List',
+'LBL_NEW_FORM_TITLE'=>'New Contact',
+'LBL_CONTACT_OPP_FORM_TITLE'=>'Contact-Opportunity:',
+'LBL_CONTACT'=>'Contact:',
+
+'LBL_LIST_NAME'=>'Name',
+'LBL_LIST_LAST_NAME'=>'Last Name',
+'LBL_LIST_FIRST_NAME'=>'First Name',
+'LBL_LIST_CONTACT_NAME'=>'Contact Name',
+'LBL_LIST_TITLE'=>'Title',
+'LBL_LIST_ACCOUNT_NAME'=>'Account Name',
+'LBL_LIST_EMAIL_ADDRESS'=>'Email',
+'LBL_LIST_PHONE'=>'Phone',
+'LBL_LIST_CONTACT_ROLE'=>'Role',
+
+//DON'T CONVERT THESE THEY ARE MAPPINGS
+'db_last_name' => 'LBL_LIST_LAST_NAME',
+'db_first_name' => 'LBL_LIST_FIRST_NAME',
+'db_title' => 'LBL_LIST_TITLE',
+'db_email1' => 'LBL_LIST_EMAIL_ADDRESS',
+'db_email2' => 'LBL_LIST_EMAIL_ADDRESS',
+//END DON'T CONVERT
+	
+'LBL_EXISTING_CONTACT' => 'Used an existing contact',
+'LBL_CREATED_CONTACT' => 'Created a new contact',
+'LBL_EXISTING_ACCOUNT' => 'Used an existing vtiger_account',
+'LBL_CREATED_ACCOUNT' => 'Created a new vtiger_account',
+'LBL_CREATED_CALL' => 'Created a new call',
+'LBL_CREATED_MEETING' => 'Created a new meeting',
+'LBL_ADDMORE_BUSINESSCARD' =>'Add another business card',
+
+'LBL_BUSINESSCARD' => 'Business Card',
+
+'LBL_NAME'=>'Name:',
+'LBL_CONTACT_NAME'=>'Contact Name:',
+'LBL_CONTACT_INFORMATION'=>'Contact Information',
+'LBL_CUSTOM_INFORMATION'=>'Custom Information',
+'LBL_FIRST_NAME'=>'First Name:',
+'LBL_OFFICE_PHONE'=>'Office Phone:',
+'LBL_ACCOUNT_NAME'=>'Account Name:',
+'LBL_ANY_PHONE'=>'Any Phone:',
+'LBL_PHONE'=>'Phone:',
+'LBL_LAST_NAME'=>'Last Name:',
+'LBL_MOBILE_PHONE'=>'Mobile:',
+'LBL_HOME_PHONE'=>'Home:',
+'LBL_LEAD_SOURCE'=>'Lead Source:',
+'LBL_OTHER_PHONE'=>'Other Phone:',
+'LBL_FAX_PHONE'=>'Fax:',
+'LBL_TITLE'=>'Title:',
+'LBL_DEPARTMENT'=>'Department:',
+'LBL_BIRTHDATE'=>'Birthdate:',
+'LBL_EMAIL_ADDRESS'=>'Email:',
+'LBL_OTHER_EMAIL_ADDRESS'=>'Other Email:',
+'LBL_ANY_EMAIL'=>'Any Email:',
+'LBL_REPORTS_TO'=>'Reports To:',
+'LBL_ASSISTANT'=>'Assistant:',
+'LBL_YAHOO_ID'=>'Yahoo! ID:',
+'LBL_ASSISTANT_PHONE'=>'Assistant Phone:',
+'LBL_DO_NOT_CALL'=>'Do Not Call:',
+'LBL_EMAIL_OPT_OUT'=>'Email Opt Out:',
+'LBL_PRIMARY_ADDRESS'=>'Primary Address:',
+'LBL_ALTERNATE_ADDRESS'=>'Other Address:',
+'LBL_ANY_ADDRESS'=>'Any Address:',
+'LBL_CITY'=>'City:',
+'LBL_STATE'=>'State:',
+'LBL_POSTAL_CODE'=>'Postal Code:',
+'LBL_COUNTRY'=>'Country:',
+'LBL_DESCRIPTION_INFORMATION'=>'Description Information',
+'LBL_IMAGE_INFORMATION'=>'Contact Image Information:',
+'LBL_ADDRESS_INFORMATION'=>'Address Information',
+'LBL_DESCRIPTION'=>'Description:',
+'LBL_CONTACT_ROLE'=>'Role:',
+'LBL_OPP_NAME'=>'Opportunity Name:',
+'LBL_DUPLICATE'=>'Potential Duplicate Contacts',
+'MSG_DUPLICATE' => 'Creating this contact may vtiger_potentialy create a duplicate contact. You may either select a contact from the list below or you may click on Create New Contact to continue creating a new contact with the previously entered data.',
+
+'LNK_NEW_APPOINTMENT' => 'New Appointment',
+'LBL_ADD_BUSINESSCARD' => 'Add Business Card',
+'NTC_DELETE_CONFIRMATION'=>'Are you sure you want to delete this record?',
+'NTC_REMOVE_CONFIRMATION'=>'Are you sure you want to remove this contact from this case?',
+'NTC_REMOVE_DIRECT_REPORT_CONFIRMATION'=>'Are you sure you want to remove this record as a direct vtiger_report?',
+'ERR_DELETE_RECORD'=>"en_us A record number must be specified to delete the contact.",
+'NTC_COPY_PRIMARY_ADDRESS'=>'Copy primary address to alternate address',
+'NTC_COPY_ALTERNATE_ADDRESS'=>'Copy alternate address to primary address',
+
+'LBL_SELECT_CONTACT'=>'Select Contact',
+//Added for search heading
+'LBL_GENERAL_INFORMATION'=>'General Information',
+
+
+
+//for v4 release added
+'LBL_NEW_POTENTIAL'=>'New Potential',
+'LBL_POTENTIAL_TITLE'=>'Potentials',
+
+'LBL_NEW_TASK'=>'New Task',
+'LBL_TASK_TITLE'=>'Tasks',
+'LBL_NEW_CALL'=>'New Call',
+'LBL_CALL_TITLE'=>'Calls',
+'LBL_NEW_MEETING'=>'New Meeting',
+'LBL_MEETING_TITLE'=>'Meetings',
+'LBL_NEW_EMAIL'=>'New Email',
+'LBL_EMAIL_TITLE'=>'Emails',
+'LBL_NEW_NOTE'=>'New Note',
+'LBL_NOTE_TITLE'=>'Notes',
+
+// Added for 4GA
+'LBL_TOOL_FORM_TITLE'=>'Contact Tools',
+
+'Salutation'=>'Salutation',
+'First Name'=>'First Name',
+'Office Phone'=>'Office Phone',
+'Last Name'=>'Last Name',
+'Mobile'=>'Mobile',
+'Account Name'=>'Account Name',
+'Home Phone'=>'Home Phone',
+'Lead Source'=>'Lead Source',
+'Phone'=>'Phone',
+'Title'=>'Title',
+'Fax'=>'Fax',
+'Department'=>'Department',
+'Birthdate'=>'Birthdate',
+'Email'=>'Email',
+'Reports To'=>'Reports To',
+'Assistant'=>'Assistant',
+'Yahoo Id'=>'Yahoo Id',
+'Assistant Phone'=>'Assistant Phone',
+'Do Not Call'=>'Do Not Call',
+'Email Opt Out'=>'Email Opt Out',
+'Assigned To'=>'Assigned To',
+'Campaign Source'=>'Campaign Source',
+'Reference' =>'Reference',
+'Created Time'=>'Created Time',
+'Modified Time'=>'Modified Time',
+'Mailing Street'=>'Mailing Street',
+'Other Street'=>'Other Street',
+'Mailing City'=>'Mailing City',
+'Mailing State'=>'Mailing State',
+'Mailing Zip'=>'Mailing Postal Code',
+'Mailing Country'=>'Mailing Country',
+'Mailing Po Box'=>'Mailing PO Box',
+'Other Po Box'=>'Other PO Box',
+'Other City'=>'Other City',
+'Other State'=>'Other State',
+'Other Zip'=>'Other Postal Code',
+'Other Country'=>'Other Country',
+'Contact Image'=>'Contact Image',
+'Description'=>'Description',
+
+// Added vtiger_fields for Add Business Card
+'LBL_NEW_CONTACT'=>'New Contact',
+'LBL_NEW_ACCOUNT'=>'New Account',
+'LBL_NOTE_SUBJECT'=>'Note Subject:',
+'LBL_NOTE'=>'Note:',
+'LBL_WEBSITE'=>'Website:',
+'LBL_NEW_APPOINTMENT'=>'New Appointment',
+'LBL_SUBJECT'=>'Subject:',
+'LBL_START_DATE'=>'Start Date:',
+'LBL_START_TIME'=>'Start Time:',
+
+//Added vtiger_field after 4_0_1
+'Portal User'=>'Portal User',
+'LBL_CUSTOMER_PORTAL_INFORMATION'=>'Customer Portal Information',
+'Support Start Date'=>'Support Start Date',
+'Support End Date'=>'Support End Date',
+//Added for 4.2 Release -- CustomView
+'Name'=>'Name',
+'LBL_ALL'=>'All',
+'LBL_MAXIMUM_LIMIT_ERROR'=>'Sorry, the uploaded file exceeds the maximum vtiger_filesize limit. Please try a file smaller than 800000 bytes',
+'LBL_UPLOAD_ERROR'=>'Problems in file upload. Please try again!',
+'LBL_IMAGE_ERROR'=>'The given file is not of type image(.gif/.jpg/.png)',
+'LBL_INVALID_IMAGE'=>'Invalid file OR File has no data',
+
+//Added after 5Alpha5
+'Notify Owner'=>'Notify Owner',
+
+//Added for Picklist Values
+'--None--'=>'--None--',
+
+'Mr.'=>'Mr.',
+'Ms.'=>'Ms.',
+'Mrs.'=>'Mrs.',
+'Dr.'=>'Dr.',
+'Prof.'=>'Prof.',
+
+'Cold Call'=>'Cold Call',
+'Existing Customer'=>'Existing Customer',
+'Self Generated'=>'Self Generated',
+'Employee'=>'Employee',
+'Partner'=>'Partner',
+'Public Relations'=>'Public Relations',
+'Direct Mail'=>'Direct Mail',
+'Conference'=>'Conference',
+'Trade Show'=>'Trade Show',
+'Web Site'=>'Web Site',
+'Word of mouth'=>'Word of mouth',
+'Other'=>'Other',
+'User List'=>'User List',
+
+// Added for multi organization support TRAC #2035
+'LBL_COMPANY_ASSIGNMENT'=>'Organization Assignment',
+'Organization Assignment'=>'Assigned to',
+
+
+//Added for 5.0.3
+'Customer Portal Login Details'=>'Customer Portal Login Details',
+'Dear'=>'Dear',
+'Your Customer Portal Login details are given below:'=>'Your Customer Portal Login details are given below:',
+'User Id :'=>'User Id :',
+'Password :'=>'Password :',
+'Please Login Here'=>'Please Login Here',
+'Note :'=>'Note :',
+'We suggest you to change your password after logging in first time'=>'We suggest you to change your password after logging in first time.',
+'Support Team'=>'Support Team',
+
+
+'TITLE_AJAX_CSS_POPUP_CHAT'=>'Ajax Css-Popup chat',
+);
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/updateRelations.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/updateRelations.php Mon Apr 16 12:27:44 2007
@@ -8,13 +8,16 @@
  * All Rights Reserved.
 *
  ********************************************************************************/
-
 require_once('include/database/PearDatabase.php');
 require_once('user_privileges/default_module_view.php');
 global $adb, $singlepane_view;
 $idlist = $_REQUEST['idlist'];
-$update_mod = $_REQUEST['destination_module'];
-$rel_table = 'vtiger_campaigncontrel';
+$dest_mod = $_REQUEST['destination_module'];
+$record = $_REQUEST['record'];
+
+if($singlepane_view == 'true') $action = "DetailView";
+else $action = "CallRelatedList";
+
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -23,23 +26,28 @@
 	{
 		if($id != '')
 		{
-		    $sql = "insert into  ".$rel_table." values(".$id.",".$_REQUEST["parentid"].")";
-	            $adb->query($sql);
+			if($dest_mod == 'Products')
+				$adb->query("insert into vtiger_seproductsrel values (".$_REQUEST["parentid"].",".$id.",'Contacts')");	
+			elseif($dest_mod == 'Campaigns')
+				$adb->query("insert into vtiger_campaigncontrel values(".$id.",".$_REQUEST["parentid"].")");
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Contacts&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Contacts&record=".$_REQUEST["parentid"]);
+	$record = $_REQUEST["parentid"];
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
+{
+	if($dest_mod == 'Products')
+		$adb->query("insert into vtiger_seproductsrel values (".$_REQUEST["parid"].",".$_REQUEST["entityid"].",'Contacts')");
+	elseif($dest_mod == 'Campaigns')
+		$adb->query("insert into vtiger_campaigncontrel values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")");
+	$record = $_REQUEST["parid"];
+}
+elseif(isset($_REQUEST['pot_id']) && $_REQUEST['pot_id'] != '')
 {	
-		$sql = "insert into ".$rel_table." values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")";
-		$adb->query($sql);
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Contacts&record=".$_REQUEST["parid"]);
-		else
- 			header("Location: index.php?action=CallRelatedList&module=Contacts&record=".$_REQUEST["parid"]);
+	$sql = "insert into vtiger_contpotentialrel values(".$record.",".$_REQUEST["pot_id"].")";
+	$adb->query($sql);
 }
 
+header("Location: index.php?action=$action&module=Contacts&record=".$record);
+
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Contacts/vtchat.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Contacts/vtchat.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Contacts/vtchat.php Mon Apr 16 12:27:44 2007
@@ -1,107 +1,110 @@
-<?php ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
-<head>
-<meta content="text/html; charset=iso-8859-1" http-equiv="content-type"/>
-<meta name="author" content="rolosworld at gmail.com"/>
-<meta http-equiv="expires" content="-1"/>
-<meta http-equiv="pragma" content="no-cache"/>
-
-<title>Ajax Css-Popup chat</title>
-
-<!-- NEEDED SCRIPTS  -->
-<script type="text/javascript" charset="iso-8859-1" src="modules/Contacts/js/ajax.js"></script>
-<script type="text/javascript" charset="iso-8859-1" src="modules/Contacts/js/dom-drag_p.js"></script>
-<script type="text/javascript" charset="iso-8859-1" src="modules/Contacts/js/css-window_p.js"></script>
-<script type="text/javascript" charset="iso-8859-1" src="modules/Contacts/js/chat.js"></script>
-<!-- /NEEDED SCRIPTS -->
-
-
-<script type="text/javascript">
-<!--
-function showPopup()
-{
-  var conf = new Array();
-  conf["dt"] = 1000;
-  conf["width"] = "400px";
-  conf["height"] = "300px";
-  conf["ulid"] = "uli";
-  conf["pchatid"] = "chat";
-
-
-  // USED TO INITIALIZE THE SESSION, I SUGGEST CALLING THIS ON BODY onload
-  //   Chat(<conf array>);
-  // NOTICE THE ChatStuff IS THE NAME OF THE ABOVE FUNCTION!!!
-  var mychat = new Chat(conf);
-
-}
-
--->
-</script>
-
-<!-- CSS classes for the popups -->
-<link rel="stylesheet" type="text/css" href="modules/Contacts/chat.css"/>
-
-</head>
-
-<body onload="showPopup();" style="background-image:url(modules/Contacts/imgs/site_bg.gif);color:#ffffff;">
-
-
-<!-- THIS IS NEEDED FOR THE USERS LIST TO APPEAR, -->
-<!-- THE id CAN BE CHANGED, BUT HAS TO BE PASSED TO UList() -->
-<!-- <table>
-<tr>	
-	<td rowspan="2">
-		
-		<div id="chat"></div>
-	</td>
-	<td class="chatuserlist">User List</td>
-
-</tr>
-<tr>
-	<td valign="top">
-		<ul id="uli"></ul>
-	</td>	
-</tr>
-</table> -->
-<!-- THIS IS NEEDED FOR DEBUG MSG'S TO APPEAR -->
-
-<table width="550" border="0" cellpadding="0" cellspacing="0">
-	<tr>
-		<td valign="top">
-			<table width="150" border="0" cellpadding="0" cellspacing="0">
-				<tr>
-					<td class="pchathead"></td>
-					<td class="pchathead1"><b><?php echo $mod_strings['User List']; ?></b></td>
-					<td class="pchathead2"></td>
-				</tr>
-				<tr>
-					<td class="pchatbody"></td>
-					<td class="pchatbody1" style="height: 300px;text-align:left;vertical-align:top;">
-						<div class="chatbox" style="overflow-y:auto;overflow-x:hidden; width: 100%; height: 100%;">
-							<span id="uli"></span>
-						</div>
-					</td>
-					<td class="pchatbody2"></td>
-				</tr>
-				<tr>
-					<td class="pchatfoot"></td>
-					<td class="pchatfoot1"></td>
-					<td class="pchatfoot2"></td>
-				</tr>
-			</table>
-		</td>
-		<td width="400" valign="top">
-			<div id="chat"></div>
-		</td>
-	</tr>
-</table>
-
-
-
-<div id="debug"></div>
-
-</body>
-</html>
+<?php 
+global $mod_strings;
+global $app_strings;
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+<meta content="text/html; charset=<?php echo $app_strings['LBL_CHARSET'];?>" http-equiv="content-type"/>
+<meta name="author" content="rolosworld at gmail.com"/>
+<meta http-equiv="expires" content="-1"/>
+<meta http-equiv="pragma" content="no-cache"/>
+
+<title><?php echo $mod_strings['TITLE_AJAX_CSS_POPUP_CHAT'];?></title>
+
+<!-- NEEDED SCRIPTS  -->
+<script type="text/javascript" charset="<?php echo $app_strings['LBL_CHARSET']?>" src="modules/Contacts/js/ajax.js"></script>
+<script type="text/javascript" charset="<?php echo $app_strings['LBL_CHARSET']?>" src="modules/Contacts/js/dom-drag_p.js"></script>
+<script type="text/javascript" charset="<?php echo $app_strings['LBL_CHARSET']?>" src="modules/Contacts/js/css-window_p.js"></script>
+<script type="text/javascript" charset="<?php echo $app_strings['LBL_CHARSET']?>" src="modules/Contacts/js/chat.js"></script>
+<!-- /NEEDED SCRIPTS -->
+
+
+<script type="text/javascript">
+<!--
+function showPopup()
+{
+  var conf = new Array();
+  conf["dt"] = 1000;
+  conf["width"] = "400px";
+  conf["height"] = "300px";
+  conf["ulid"] = "uli";
+  conf["pchatid"] = "chat";
+
+
+  // USED TO INITIALIZE THE SESSION, I SUGGEST CALLING THIS ON BODY onload
+  //   Chat(<conf array>);
+  // NOTICE THE ChatStuff IS THE NAME OF THE ABOVE FUNCTION!!!
+  var mychat = new Chat(conf);
+
+}
+
+-->
+</script>
+
+<!-- CSS classes for the popups -->
+<link rel="stylesheet" type="text/css" href="modules/Contacts/chat.css"/>
+
+</head>
+
+<body onload="showPopup();" style="background-image:url(modules/Contacts/imgs/site_bg.gif);color:#ffffff;">
+
+
+<!-- THIS IS NEEDED FOR THE USERS LIST TO APPEAR, -->
+<!-- THE id CAN BE CHANGED, BUT HAS TO BE PASSED TO UList() -->
+<!-- <table>
+<tr>	
+	<td rowspan="2">
+		
+		<div id="chat"></div>
+	</td>
+	<td class="chatuserlist">User List</td>
+
+</tr>
+<tr>
+	<td valign="top">
+		<ul id="uli"></ul>
+	</td>	
+</tr>
+</table> -->
+<!-- THIS IS NEEDED FOR DEBUG MSG'S TO APPEAR -->
+
+<table width="550" border="0" cellpadding="0" cellspacing="0">
+	<tr>
+		<td valign="top">
+			<table width="150" border="0" cellpadding="0" cellspacing="0">
+				<tr>
+					<td class="pchathead"></td>
+					<td class="pchathead1"><b><?php echo $mod_strings['User List']; ?></b></td>
+					<td class="pchathead2"></td>
+				</tr>
+				<tr>
+					<td class="pchatbody"></td>
+					<td class="pchatbody1" style="height: 300px;text-align:left;vertical-align:top;">
+						<div class="chatbox" style="overflow-y:auto;overflow-x:hidden; width: 100%; height: 100%;">
+							<span id="uli"></span>
+						</div>
+					</td>
+					<td class="pchatbody2"></td>
+				</tr>
+				<tr>
+					<td class="pchatfoot"></td>
+					<td class="pchatfoot1"></td>
+					<td class="pchatfoot2"></td>
+				</tr>
+			</table>
+		</td>
+		<td width="400" valign="top">
+			<div id="chat"></div>
+		</td>
+	</tr>
+</table>
+
+
+
+<div id="debug"></div>
+
+</body>
+</html>

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.js
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.js (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.js Mon Apr 16 12:27:44 2007
@@ -74,7 +74,7 @@
 	}
 	// Here we decide whether to submit the form.
 	if (isError == true) {
-		alert("Missing required fields:" + errorMessage);
+		alert(alert_arr.MISSING_REQUIRED_FIELDS + errorMessage);
 		return false;
 	}
 	//return true;
@@ -102,7 +102,7 @@
 
         // Here we decide whether to submit the form.
         if (isError == true) {
-                alert("Missing required fields: " + errorMessage);
+                alert(alert_arr.MISSING_REQUIRED_FIELDS + errorMessage);
                 return false;
         }
  return true;

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/CustomView.php Mon Apr 16 12:27:44 2007
@@ -22,14 +22,14 @@
 global $adv_filter_options;
 
 $adv_filter_options = array("e"=>"".$mod_strings['equals']."",
-                            "n"=>"".$mod_strings['not_equal_to']."",
-                            "s"=>"".$mod_strings['starts_with']."",
+                            "n"=>"".$mod_strings['not equal to']."",
+                            "s"=>"".$mod_strings['starts with']."",
                             "c"=>"".$mod_strings['contains']."",
-                            "k"=>"".$mod_strings['does_not_contain']."",
-                            "l"=>"".$mod_strings['less_than']."",
-                            "g"=>"".$mod_strings['greater_than']."",
-                            "m"=>"".$mod_strings['less_or_equal']."",
-                            "h"=>"".$mod_strings['greater_or_equal']."",
+                            "k"=>"".$mod_strings['does not contain']."",
+                            "l"=>"".$mod_strings['less than']."",
+                            "g"=>"".$mod_strings['greater than']."",
+                            "m"=>"".$mod_strings['less or equal']."",
+                            "h"=>"".$mod_strings['greater or equal']."",
                             );
 
 class CustomView extends CRMEntity{
@@ -184,27 +184,31 @@
 	{
 		global $adb;
 		$tabid = getTabid($module);
+		if($tabid == 9)
+			$tabid ="9,16";
 		global $current_user;
 	        require('user_privileges/user_privileges_'.$current_user->id.'.php');
 
+			$display_type = " vtiger_field.displaytype in (1,2,3)";
+
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 		{
 			$sql = "select * from vtiger_field ";
-			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block.") and";
-			$sql.= " vtiger_field.displaytype in (1,2)";
+			$sql.= " where vtiger_field.tabid in (".$tabid.") and vtiger_field.block in (".$block.") and";
+			$sql.= $display_type;
 			$sql.= " order by sequence";
 		}
 		else
 		{
+
 			$profileList = getCurrentUserProfileList();
 			$sql = "select * from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid ";
-			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block.") and";
-			$sql.= " vtiger_field.displaytype in (1,2) and vtiger_profile2field.visible=0";
-			$sql.= " and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." order by sequence";
+			$sql.= " where vtiger_field.tabid in (".$tabid.") and vtiger_field.block in (".$block.") and";
+			$sql.= "$display_type and vtiger_profile2field.visible=0";
+			$sql.= " and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." group by columnname order by sequence";
 		}	
-
-
-
+		if($tabid == '9,16')
+                        $tabid ="9";
 		$result = $adb->query($sql);
 		$noofrows = $adb->num_rows($result);
 		//Added on 14-10-2005 -- added ticket id in list
@@ -279,6 +283,7 @@
 		foreach($this->module_list[$module] as $key=>$value)
 		{
 			$columnlist = $this->getColumnsListbyBlock($module,$value);
+			
 			if(isset($columnlist))
 			{
 				$ret_module_list[$module][$key] = $columnlist;
@@ -338,18 +343,17 @@
 		{
 			$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid ";
 			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$blockids.")
-                        and (vtiger_field.uitype =5 or vtiger_field.displaytype=2) ";
+                        and (vtiger_field.uitype in (5,6,23) or vtiger_field.displaytype=2) ";
 			$sql.= " order by vtiger_field.sequence";
 		}
 		else
 		{
 			$profileList = getCurrentUserProfileList();
 			$sql = "select * from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid inner join  vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid ";
-			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$blockids.") and (vtiger_field.uitype =5 or vtiger_field.displaytype=2)";
+			$sql.= " where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$blockids.") and (vtiger_field.uitype in (5,6,23) or vtiger_field.displaytype=2)";
 			$sql.= " and vtiger_profile2field.visible=0";
 			$sql.= " and vtiger_def_org_field.visible=0  and vtiger_profile2field.profileid in ".$profileList." order by vtiger_field.sequence";
 		}			
-
 
 		$result = $adb->query($sql);
 
@@ -476,33 +480,43 @@
 		$nextFY0 = date("Y-m-d",mktime(0, 0, 0, "01", "01",   date("Y")+1));
 		$nextFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y")+1));
     
-		if(date("m") <= 4)
+		if(date("m") <= 3)
 		{
 			$cFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")));
-			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "04","30",date("Y")));
-			$nFq = date("Y-m-d",mktime(0, 0, 0, "05","01",date("Y")));
-			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "08","31",date("Y")));
-			$pFq = date("Y-m-d",mktime(0, 0, 0, "09","01",date("Y")-1));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "03","31",date("Y")));
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "04","01",date("Y")));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "06","30",date("Y")));
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "10","01",date("Y")-1));
 			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")-1));
-		}else if(date("m") > 4 and date("m") <= 8)
-    		{
+		}else if(date("m") > 3 and date("m") <= 6)
+		{
 			$pFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")));
-		  	$pFq1 = date("Y-m-d",mktime(0, 0, 0, "04","30",date("Y")));
-		  	$cFq = date("Y-m-d",mktime(0, 0, 0, "05","01",date("Y")));
-		  	$cFq1 = date("Y-m-d",mktime(0, 0, 0, "08","31",date("Y")));
-      			$nFq = date("Y-m-d",mktime(0, 0, 0, "09","01",date("Y")));
-		  	$nFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")));
-      
-    		}else
-    		{
-		  	$nFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")+1));
-		  	$nFq1 = date("Y-m-d",mktime(0, 0, 0, "04","30",date("Y")+1));
-		  	$pFq = date("Y-m-d",mktime(0, 0, 0, "05","01",date("Y")));
-		  	$pFq1 = date("Y-m-d",mktime(0, 0, 0, "08","31",date("Y")));
-      			$cFq = date("Y-m-d",mktime(0, 0, 0, "09","01",date("Y")));
-		  	$cFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")));      
-    		}
-    
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "03","31",date("Y")));
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "04","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "06","30",date("Y")));
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "07","01",date("Y")));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "09","30",date("Y")));
+
+		}else if(date("m") > 6 and date("m") <= 9)
+		{
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "10","01",date("Y")));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")));
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "04","01",date("Y")));
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "06","30",date("Y")));
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "07","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "09","30",date("Y")));
+		}
+		else if(date("m") > 9 and date("m") <= 12)
+		{
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")+1));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "03","31",date("Y")+1));
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "07","01",date("Y")));
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "09","30",date("Y")));
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "10","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")));
+
+		}
+
 		$sjsStr = '<script language="JavaScript" type="text/javaScript">
 			function showDateRange( type )
 			{
@@ -748,7 +762,7 @@
 					$sqllist_column = $list[0].".".$list[1];
 					if($this->customviewmodule == "Calendar")
 					{
-						if($list[1] == "status")
+						if($list[1] == "status" || $list[1] == "eventstatus")
 						{
 							$sqllist_column = "case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end as activitystatus";
 						}
@@ -764,7 +778,12 @@
 					//Ends
 					
 					$tablefield[$list[0]] = $list[1];
-					$fieldlabel = trim(str_replace($this->escapemodule," ",$list[3]));
+
+					//Changed as the replace of module name may replace the string if the fieldname has module name in it -- Jeri
+					$fieldinfo = explode('_',$list[3],2);
+					$fieldlabel = $fieldinfo[1];
+					$fieldlabel = str_replace("_"," ",$fieldlabel);
+					
 					$this->list_fields[$fieldlabel] = $tablefield;
 					$this->list_fields_name[$fieldlabel] = $list[2];
 				}
@@ -850,7 +869,7 @@
 						}else
 						{
 							//Added for getting vtiger_activity Status -Jaguar
-							if($this->customviewmodule == "Calendar" && $columns[1] == "status")
+							if($this->customviewmodule == "Calendar" && ($columns[1] == "status" || $columns[1] == "eventstatus"))
 							{
 								$advfiltersql[] = "case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end".$this->getAdvComparator($advfltrow["comparator"],trim($advfltrow["value"]),$datatype);
 							}
@@ -880,18 +899,24 @@
 	  */
 	function getRealValues($tablename,$fieldname,$comparator,$value,$datatype)
 	{
-		if($fieldname == "smownerid" || $fieldname == "inventorymanager")
-		{
+		if($fieldname == "smownerid")
+                {
+	                $temp_value = "( vtiger_users.user_name".$this->getAdvComparator($comparator,$value,$datatype);
+	                $temp_value.= " OR  vtiger_groups.groupname".$this->getAdvComparator($comparator,$value,$datatype);
+	                $value=$temp_value.")";
+		}elseif( $fieldname == "inventorymanager")
+                {
 			$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,getUserId_Ol($value),$datatype);
-		}else if($fieldname == "parentid")
+                }else if($fieldname == "parentid")
 		{
 			$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getAccountId($value),$datatype);
 		}else if($fieldname == "accountid")
 		{
 			$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getAccountId($value),$datatype);
-		}else if($fieldname == "contactid")
-		{
-			$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getContactId($value),$datatype);
+		}else if($fieldname == "contactid"  || $fieldname == 'contact_id')
+		{
+			$value = "concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)".$this->getAdvComparator($comparator,$value,$datatype);
+			//$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getContactId($value),$datatype);
 		}else if($fieldname == "vendor_id" || $fieldname == "vendorid")
 		{
 			$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getVendorId($value),$datatype);
@@ -1112,6 +1137,9 @@
 			}elseif(trim($value) == "" && $datatype == "V")
 			{
 				$rtvalue = " = ".$adb->quote($value);	
+			}elseif(trim($value) == "" && $datatype == "E")
+			{
+				$rtvalue = " = ".$adb->quote($value);	
 			}else
 			{
 				$rtvalue = " is NULL";
@@ -1126,6 +1154,9 @@
 			{
 				$rtvalue = " <> ".$adb->quote($value);
 			}elseif(trim($value) == "" && $datatype == "V")
+			{
+				$rtvalue = " <> ".$adb->quote($value);	
+			}elseif(trim($value) == "" && $datatype == "E")
 			{
 				$rtvalue = " <> ".$adb->quote($value);	
 			}else
@@ -1410,10 +1441,11 @@
 	{
 		if($viewid != "" && $listquery != "")
 		{
+			
 			$listviewquery = substr($listquery, strpos($listquery,'FROM'),strlen($listquery));
 			if($module == "Calendar" || $module == "Emails")
 			{
-				$query = "select ".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid,vtiger_activity.* ".$listviewquery;
+				$query = "select ".$this->getCvColumnListSQL($viewid)." , vtiger_activity.activityid, vtiger_activity.activitytype as type, vtiger_activity.priority, case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end as status, vtiger_crmentity.crmid ".$listviewquery;
 			}else if($module == "Notes")
 			{
 				$query = "select ".$this->getCvColumnListSQL($viewid)." ,vtiger_crmentity.crmid,vtiger_notes.* ".$listviewquery;
@@ -1520,8 +1552,14 @@
 		global $current_language;
 		$current_mod_strings = return_specified_module_language($current_language, $module); 
 		$block_info = Array();
-		$Sql = "select distinct block,vtiger_field.tabid,name,blocklabel from vtiger_field inner join vtiger_blocks on vtiger_blocks.blockid=vtiger_field.block inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where displaytype != 3 and vtiger_field.block not in(40,6,75,35,30,54,60,66,72) and vtiger_tab.name='$module' order by block";
+		if($module == "Calendar")
+			$module = "Calendar','Events";
+
+		$Sql = "select distinct block,vtiger_field.tabid,name,blocklabel from vtiger_field inner join vtiger_blocks on vtiger_blocks.blockid=vtiger_field.block inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where displaytype != 3 and vtiger_field.block not in(40,6,75,35,30,54,60,66,72) and vtiger_tab.name in ('".$module."') order by block";
 		$result = $adb->query($Sql);
+		if($module == "Calendar','Events")
+			$module = "Calendar";
+
 		while($block_result = $adb->fetch_array($result))
 		{
 			$block_label = $block_result['blocklabel'];

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/EditView.php Mon Apr 16 12:27:44 2007
@@ -72,7 +72,7 @@
 	$smarty->assign("STDFILTERCRITERIA",$stdfilterhtml);
 	$smarty->assign("STDFILTER_JAVASCRIPT",$stdfilterjs);
 
-	$smarty->assign("MANDATORYCHECK",implode(",",$oCustomView->mandatoryvalues));
+	$smarty->assign("MANDATORYCHECK",implode(",",array_unique($oCustomView->mandatoryvalues)));
 	$smarty->assign("SHOWVALUES",implode(",",$oCustomView->showvalues));
 }
 else
@@ -82,6 +82,7 @@
 	$customviewdtls = $oCustomView->getCustomViewByCvid($recordid);
 	$log->info('CustomView :: Successfully got ViewDetails for the Viewid'.$recordid);
 	$modulecollist = $oCustomView->getModuleColumnsList($cv_module);
+
 	$selectedcolumnslist = $oCustomView->getColumnsListByCvid($recordid);
 	$log->info('CustomView :: Successfully got ColumnsList for the Viewid'.$recordid);
 
@@ -128,7 +129,7 @@
 	$smarty->assign("STDFILTERCRITERIA",$stdfilterhtml);
 	$smarty->assign("STDFILTER_JAVASCRIPT",$stdfilterjs);
 
-	$smarty->assign("MANDATORYCHECK",implode(",",$oCustomView->mandatoryvalues));
+	$smarty->assign("MANDATORYCHECK",implode(",",array_unique($oCustomView->mandatoryvalues)));
 	$smarty->assign("SHOWVALUES",implode(",",$oCustomView->showvalues));
 
 	$cactionhtml = "<input name='customaction' class='button' type='button' value='Create Custom Action' onclick=goto_CustomAction('".$cv_module."');>";
@@ -216,8 +217,9 @@
 	global $oCustomView;
 	global $app_list_strings;
 	$advfilter = array();
-	$mod_strings = return_module_language($current_language,$module);
-
+	$mod_strings = return_specified_module_language($current_language,$module);
+	
+	$check_dup = Array();
 	foreach($oCustomView->module_list[$module] as $key=>$value)
 	{
 		$advfilter = array();			
@@ -226,37 +228,67 @@
 		{
 			foreach($columnslist[$module][$key] as $field=>$fieldlabel)
 			{
-				if(isset($mod_strings[$fieldlabel]))
-				{
-					if($selected == $field)
+				if(!in_array($fieldlabel,$check_dup))
+				{
+					if(isset($mod_strings[$fieldlabel]))
 					{
-						$advfilter_option['value'] = $field;
-						$advfilter_option['text'] = $mod_strings[$fieldlabel];
-						$advfilter_option['selected'] = "selected";
+						if($selected == $field)
+						{
+							$advfilter_option['value'] = $field;
+							$advfilter_option['text'] = $mod_strings[$fieldlabel];
+							$advfilter_option['selected'] = "selected";
+						}else
+						{
+							$advfilter_option['value'] = $field;
+							$advfilter_option['text'] = $mod_strings[$fieldlabel];
+							$advfilter_option['selected'] = "";
+						}
 					}else
 					{
-						$advfilter_option['value'] = $field;
-						$advfilter_option['text'] = $mod_strings[$fieldlabel];
-						$advfilter_option['selected'] = "";
+						if($selected == $field)
+						{
+							$advfilter_option['value'] = $field;
+							$advfilter_option['text'] = $fieldlabel;
+							$advfilter_option['selected'] = "selected";
+						}else
+						{
+							$advfilter_option['value'] = $field;
+							$advfilter_option['text'] = $fieldlabel;
+							$advfilter_option['selected'] = "";
+						}
 					}
-				}else
-				{
-					if($selected == $field)
-					{
-						$advfilter_option['value'] = $field;
-						$advfilter_option['text'] = $fieldlabel;
-						$advfilter_option['selected'] = "selected";
-					}else
-					{
-						$advfilter_option['value'] = $field;
-						$advfilter_option['text'] = $fieldlabel;
-						$advfilter_option['selected'] = "";
-					}
+					$advfilter[] = $advfilter_option;
+					$check_dup [] = $fieldlabel;
 				}
-				$advfilter[] = $advfilter_option;
 			}
 			$advfilter_out[$label]= $advfilter;
 		}
+	}
+	
+	$finalfield = Array();
+	foreach($advfilter_out as $header=>$value)
+	{
+		if($header == $mod_strings['LBL_TASK_INFORMATION'])
+		{
+			$newLabel = $mod_strings['LBL_CALENDAR_INFORMATION'];
+		    	$finalfield[$newLabel] = $advfilter_out[$header];
+		    	
+		}
+		elseif($header == $mod_strings['LBL_EVENT_INFORMATION'])
+		{
+			$index = count($finalfield[$newLabel]);
+			foreach($value as $key=>$result)
+			{
+				$finalfield[$newLabel][$index]=$result;
+				$index++;
+			}
+		}
+		else
+		{
+			$finalfield = $advfilter_out;
+		}
+
+		$advfilter_out=$finalfield;
 	}
 	return $advfilter_out;
 }

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/ListViewTop.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/ListViewTop.php (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/ListViewTop.php Mon Apr 16 12:27:44 2007
@@ -104,8 +104,8 @@
 					'MODULE' => $metriclist['module']
 					);
 
-			$value[]='<a href="index.php?action=index&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.$metriclist['name'].'</a>';
-			$value[]='<a href="index.php?action=index&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.$metriclist['count'].'</a>';
+			$value[]='<a href="index.php?action=ListView&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.substr($metriclist['name'],0,20).'...'.'</a>';
+			$value[]='<a href="index.php?action=ListView&module='.$metriclist['module'].'&viewname='.$metriclist['id'].'">'.$metriclist['count'].'</a>';
 			$entries[$metriclist['id']]=$value;
 		}
 

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/PopulateCustomView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/PopulateCustomView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/PopulateCustomView.php Mon Apr 16 12:27:44 2007
@@ -211,10 +211,10 @@
 		   Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
                          'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
                          'vtiger_contactaddress:mailingstreet:mailingstreet:Contacts_Mailing_Street:V',
-                         'vtiger_contactaddress:mailingcity:mailingcity:Contacts_City:V',
-                         'vtiger_contactaddress:mailingstate:mailingstate:Contacts_State:V',
-			 'vtiger_contactaddress:mailingzip:mailingzip:Contacts_Zip:V',
-			 'vtiger_contactaddress:mailingcountry:mailingcountry:Contacts_Country:V'),
+                         'vtiger_contactaddress:mailingcity:mailingcity:Contacts_Mailing_City:V',
+                         'vtiger_contactaddress:mailingstate:mailingstate:Contacts_Mailing_State:V',
+			 'vtiger_contactaddress:mailingzip:mailingzip:Contacts_Mailing_Zip:V',
+			 'vtiger_contactaddress:mailingcountry:mailingcountry:Contacts_Mailing_Country:V'),
 		   
 		   Array('vtiger_contactdetails:firstname:firstname:Contacts_First_Name:V',
                          'vtiger_contactdetails:lastname:lastname:Contacts_Last_Name:V',
@@ -296,7 +296,7 @@
 				'vtiger_crmentity:smownerid:assigned_user_id:Emails_Sender:V',
                  'vtiger_activity:date_start:date_start:Emails_Date_Sent:D'),
 		
-		   Array('vtiger_crmentity:crmid::Invoice_Invoice_Id:I',
+		   Array('vtiger_invoice:invoice_no:invoice_no:Invoice_invoice_no:V',
                          'vtiger_invoice:subject:subject:Invoice_Subject:V',
                          'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
                          'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
@@ -386,14 +386,16 @@
 			 'vtiger_purchaseorder:carrier:carrier:PurchaseOrder_Carrier:V',
 			 'vtiger_poshipads:ship_street:ship_street:PurchaseOrder_Shipping_Address:V'),
 		
-		 Array(  'vtiger_invoice:subject:subject:Invoice_Subject:V',
+		 Array(  'vtiger_invoice:invoice_no:invoice_no:Invoice_invoice_no:V',
+		 	 'vtiger_invoice:subject:subject:Invoice_Subject:V',
 			 'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I',
 			 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
 			 'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
 			 'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V',
 			 'vtiger_crmentity:createdtime:createdtime:Invoice_Created_Time:T'),
 		 
-		 Array(	 'vtiger_invoice:subject:subject:Invoice_Subject:V',
+		 Array(	 'vtiger_invoice:invoice_no:invoice_no:Invoice_invoice_no:V',
+			 'vtiger_invoice:subject:subject:Invoice_Subject:V',
 			 'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I',
 			 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
 			 'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/Save.php Mon Apr 16 12:27:44 2007
@@ -19,7 +19,7 @@
 $return_action = $_REQUEST["return_action"];
 if($cvmodule != "")
 {
-	$viewname = $_REQUEST["viewName"];
+	$viewname = htmlentities($_REQUEST["viewName"]);
 	if(isset($_REQUEST["setDefault"]))
 	{
 	  $setdefault = 1;
@@ -83,7 +83,7 @@
    	   $string = substr($allKeys[$i], 0, 4);
 	   if($string == "fval")
    	   {
-		   $adv_filter_value[] = $_REQUEST[$allKeys[$i]];
+		   $adv_filter_value[] = htmlentities($_REQUEST[$allKeys[$i]]);
    	   }
 	}
 	//<<<<<<<advancedfilter>>>>>>>>
@@ -120,22 +120,24 @@
 						$columnresult = $adb->query($columnsql);
 					}
 					$log->info("CustomView :: Save :: vtiger_cvcolumnlist created successfully");
-
-					$stdfiltersql = "INSERT INTO vtiger_cvstdfilter
-								(cvid,
-								columnname,
-								stdfilter,
-								startdate,
-								enddate)
+					if($std_filter_list["columnname"] !="")
+					{
+						$stdfiltersql = "INSERT INTO vtiger_cvstdfilter
+							(cvid,
+							 columnname,
+							 stdfilter,
+							 startdate,
+							 enddate)
 							VALUES
-								(".$genCVid.",
-								".$adb->quote($std_filter_list["columnname"]).",
-								
-								".$adb->quote($std_filter_list["stdfilter"]).",
-								".$adb->formatDate($std_filter_list["startdate"]).",
-								".$adb->formatDate($std_filter_list["enddate"]).")";
-					$stdfilterresult = $adb->query($stdfiltersql);
-					$log->info("CustomView :: Save :: vtiger_cvstdfilter created successfully");
+							(".$genCVid.",
+							 ".$adb->quote($std_filter_list["columnname"]).",
+
+							 ".$adb->quote($std_filter_list["stdfilter"]).",
+							 ".$adb->formatDate($std_filter_list["startdate"]).",
+							 ".$adb->formatDate($std_filter_list["enddate"]).")";
+						$stdfilterresult = $adb->query($stdfiltersql);
+						$log->info("CustomView :: Save :: vtiger_cvstdfilter created successfully");
+					}
 					for($i=0;$i<count($adv_filter_col);$i++)
 					{
 						$advfiltersql = "INSERT INTO vtiger_cvadvfilter
@@ -195,20 +197,23 @@
 					$columnresult = $adb->query($columnsql);
 				}
 				$log->info("CustomView :: Save :: vtiger_cvcolumnlist update successfully".$genCVid);
-				$stdfiltersql = "INSERT INTO vtiger_cvstdfilter
-							(cvid,
-							columnname,
-							stdfilter,
-							startdate,
-							enddate)
+				if($std_filter_list["columnname"] !="")
+				{
+					$stdfiltersql = "INSERT INTO vtiger_cvstdfilter
+						(cvid,
+						 columnname,
+						 stdfilter,
+						 startdate,
+						 enddate)
 						VALUES
-							(".$genCVid.",
-							".$adb->quote($std_filter_list["columnname"]).",
-							".$adb->quote($std_filter_list["stdfilter"]).",
-							".$adb->formatDate($std_filter_list["startdate"]).",
-							".$adb->formatDate($std_filter_list["enddate"]).")";
-				$stdfilterresult = $adb->query($stdfiltersql);
-				$log->info("CustomView :: Save :: vtiger_cvstdfilter update successfully".$genCVid);
+						(".$genCVid.",
+						 ".$adb->quote($std_filter_list["columnname"]).",
+						 ".$adb->quote($std_filter_list["stdfilter"]).",
+						 ".$adb->formatDate($std_filter_list["startdate"]).",
+						 ".$adb->formatDate($std_filter_list["enddate"]).")";
+					$stdfilterresult = $adb->query($stdfiltersql);
+					$log->info("CustomView :: Save :: vtiger_cvstdfilter update successfully".$genCVid);
+				}
 				for($i=0;$i<count($adv_filter_col);$i++)
 				{
 					$advfiltersql = "INSERT INTO vtiger_cvadvfilter

Modified: vtigercrm/branches/5.1_jens/modules/CustomView/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/CustomView/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/CustomView/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -77,14 +77,14 @@
 'Next 120 Days'=>'Next 120 Days', 
  
 'equals'=>'equals', 
-'not_equal_to'=>'Not equal to', 
-'starts_with'=>'Starts with', 
+'not equal to'=>'Not equal to', 
+'starts with'=>'Starts with', 
 'contains'=>'Contains', 
-'does_not_contain'=>'does not contain', 
-'less_than'=>'less than', 
-'greater_than'=>'greater than', 
-'less_or_equal'=>'less or equal', 
-'greater_or_equal'=>'greater or equal', 
+'does not contain'=>'does not contain', 
+'less than'=>'less than', 
+'greater than'=>'greater than', 
+'less or equal'=>'less or equal', 
+'greater or equal'=>'greater or equal', 
  
 //Strings added to translate field label vtiger_groups 
 'Address'=>'Address', 

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome.php Mon Apr 16 12:27:44 2007
@@ -26,14 +26,14 @@
 ?>		
 		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
 			  <tr>
-				<td><a name="1"></a><table width="20%"  border="0" cellspacing="0" cellpadding="0" align="left">
+				<td><a name="1"></a><table width="20%"  border="0" cellspacing="3" cellpadding="0" align="left">
 				 		 <tr>
 
 				 		   <td rowspan="2"><span class="dash_count">1</span>&nbsp;&nbsp;</td>
-				 		   <td nowrap><span class="genHeaderSmall"><?echo $mod_strings['LBL_SALES_STAGE_FORM_TITLE']; ?></span></td>
+				 		   <td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_SALES_STAGE_FORM_TITLE']; ?></span></td>
 				 		 </tr>
 					     <tr>
-					       <td><span class="big"><? echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
+					       <td><span class="big"><?php echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
 					     </tr>
 					</table>
 
@@ -61,21 +61,21 @@
 			  <!-- SCEOND CHART  -->
 			  
 			  <tr>
-				<td><a name="2"></a><table width="20%"  border="0" cellspacing="0" cellpadding="0" align="left">
+				<td><a name="2"></a><table width="20%"  border="0" cellspacing="5" cellpadding="0" align="left">
 				 		 <tr>
 				 		   <td rowspan="2"><span class="dash_count">2</span>&nbsp;&nbsp;</td>
 				 		   <td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_MONTH_BY_OUTCOME'];?></span></td>
 				 		 </tr>
 					     <tr>
 
-					       <td><span class="big"><? echo $mod_strings['LBL_VERT_BAR_CHART'];?></span> </td>
+					       <td><span class="big"><?php echo $mod_strings['LBL_VERT_BAR_CHART'];?></span> </td>
 					     </tr>
 					</table>
 				</td>
 				<td  align="right">
 					<table cellpadding="0" cellspacing="0" border="0" class="small">
 						<tr>
-							<td class="small">View Chart :&nbsp;</td>
+							<td class="small"><?php echo $mod_strings['VIEWCHART'];?> :&nbsp;</td>
 							<td class="dash_row_unsel"><a class="dash_href" href="#1">1</a></td>
 							<td class="dash_row_sel">2</td>
 							<td class="dash_row_unsel"><a class="dash_href" href="#3">3</a></td>
@@ -98,21 +98,21 @@
 			  <!-- THIRD CHART  -->
 			  
 			  <tr>
-				<td><a name="3"></a><table width="20%"  border="0" cellspacing="0" cellpadding="0" align="left">
+				<td><a name="3"></a><table width="20%"  border="0" cellspacing="5" cellpadding="0" align="left">
 				 		 <tr>
 				 		   <td rowspan="2"><span class="dash_count">3</span>&nbsp;&nbsp;</td>
 				 		   <td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_LEAD_SOURCE_BY_OUTCOME'];?></span></td>
 				 		 </tr>
 					     <tr>
 
-					       <td><span class="big"><? echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
+					       <td><span class="big"><?php echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
 					     </tr>
 					</table>
 				</td>
 				<td align="right">
 					<table cellpadding="0" cellspacing="0" border="0" class="small">
 						<tr>
-							<td class="small">View Chart :&nbsp;</td>
+							<td class="small"><?php echo $mod_strings['VIEWCHART']; ?> :&nbsp;</td>
 							<td class="dash_row_unsel"><a class="dash_href" href="#1">1</a></td>
 							<td class="dash_row_unsel"><a class="dash_href" href="#2">2</a></td>
 							<td class="dash_row_sel">3</td>
@@ -133,14 +133,14 @@
 			  <!-- FOURTH CHART  -->
 			  
 			  <tr>
-				<td><a name="4"></a><table width="20%"  border="0" cellspacing="0" cellpadding="0" align="left">
+				<td><a name="4"></a><table width="20%"  border="0" cellspacing="5" cellpadding="0" align="left">
 				 		 <tr>
 				 		   <td rowspan="2"><span class="dash_count">4</span>&nbsp;&nbsp;</td>
 				 		   <td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_LEAD_SOURCE_FORM_TITLE'];?></span></td>
 				 		 </tr>
 					     <tr>
 
-					       <td><span class="big"><? echo $mod_strings['LBL_PIE_CHART'];?></span> </td>
+					       <td><span class="big"><?php echo $mod_strings['LBL_PIE_CHART'];?></span> </td>
 					     </tr>
 					</table>
 				</td>

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome_matrix.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome_matrix.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/DashboardHome_matrix.php Mon Apr 16 12:27:44 2007
@@ -33,10 +33,10 @@
 		    		<table width="20%"  border="0" cellspacing="0" cellpadding="0" align="left">
 				<tr>
 	 		   		<td rowspan="2"><span class="dash_count">1</span>&nbsp;&nbsp;</td>
-				 	<td nowrap><span class="genHeaderSmall"><?echo $mod_strings['LBL_SALES_STAGE_FORM_TITLE']; ?></span></td>
+				 	<td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_SALES_STAGE_FORM_TITLE']; ?></span></td>
 				 </tr>
 				 <tr>
-				 	<td><span class="big"><? echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
+				 	<td><span class="big"><?php echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
 				</tr>
 				</table>
 		    	</td>
@@ -57,7 +57,7 @@
 				 	<td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_MONTH_BY_OUTCOME'];?></span></td>
 				</tr>
 				<tr>
-					<td><span class="big"><? echo $mod_strings['LBL_VERT_BAR_CHART'];?></span> </td>
+					<td><span class="big"><?php echo $mod_strings['LBL_VERT_BAR_CHART'];?></span> </td>
 				</tr>
 				</table>
 			</td>
@@ -83,7 +83,7 @@
 				 	<td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_LEAD_SOURCE_BY_OUTCOME'];?></span></td>
 				</tr>
 				<tr>
-				       	<td><span class="big"><? echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
+				       	<td><span class="big"><?php echo $mod_strings['LBL_HORZ_BAR_CHART'];?></span> </td>
 				</tr>
 				</table>
 			</td>
@@ -105,7 +105,7 @@
 				 	<td nowrap><span class="genHeaderSmall"><?php echo $mod_strings['LBL_LEAD_SOURCE_FORM_TITLE'];?></span></td>
 				</tr>
 				<tr>
-			       		<td><span class="big"><? echo $mod_strings['LBL_PIE_CHART'];?></span> </td>
+			       		<td><span class="big"><?php echo $mod_strings['LBL_PIE_CHART'];?></span> </td>
 				</tr>
 				</table>
 			</td>

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/Entity_charts.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/Entity_charts.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/Entity_charts.php Mon Apr 16 12:27:44 2007
@@ -454,7 +454,7 @@
 	}
 
 $sHTML .= "<tr>
-	   <td><a name='1'></a><table width=20%  border=0 cellspacing=0 cellpadding=0 align=left>
+	   <td><a name='1'></a><table width=20%  border=0 cellspacing=12 cellpadding=0 align=left>
 	         <tr>
 	    	   <td rowspan=2 valign=top><span class=\"dash_count\">1</span></td>
 	           <td nowrap><span class=genHeaderSmall>".$graph_title."</span></td>
@@ -523,7 +523,7 @@
 	}
 
 $sHTML .= "<tr>
-	   <td><a name='2'></a><table width=20%  border=0 cellspacing=0 cellpadding=0 align=left>
+	   <td><a name='2'></a><table width=20%  border=0 cellspacing=12 cellpadding=0 align=left>
            	 <tr>
 	           <td rowspan=2 valign=top><span class=\"dash_count\">2</span></td>
 	           <td nowrap><span class=genHeaderSmall>".$graph_title."</span></td>

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/HomepageDB.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/HomepageDB.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/HomepageDB.php Mon Apr 16 12:27:44 2007
@@ -1,53 +1,53 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-require_once("modules/Dashboard/Entity_charts.php");
-
-	global $current_user,$user_id,$date_start,$end_date,$tmp_dir,$mod_strings;
-	$type='recordsforuser';
-	$homepagedb_query = "select * from vtiger_crmentity se left join vtiger_leaddetails le on le.leadid=se.crmid left join vtiger_troubletickets tt on tt.ticketid=se.crmid left join vtiger_activity act on act.activityid=se.crmid where se.deleted=0 and (le.converted=0 or le.converted is null) and (tt.status!='Closed' or tt.status is null) and ((act.status!='Completed' and act.status!='Deferred') or act.status is null) and ((act.eventstatus!='Held' and act.eventstatus!='Not Held') or act.eventstatus is null) and setype in ('Accounts','Contacts','Leads','Potentials','Quotes','Invoice','PurchaseOrder', 'SalesOrder','Calendar','HelpDesk','Campaigns') and se.deleted=0 and se.smownerid=".$current_user->id;
-	$graph_by="setype";
-	$graph_title=$mod_strings['recordsforuser'].' '.$current_user->user_name;
-	$module="Home";
-	$where="";
-	$query=$homepagedb_query;
-
-	//Giving the Cached image name	
-	$cache_file_name=abs(crc32($current_user->id))."_".$type."_".crc32($date_start.$end_date).".png";
-        $html_imagename=$graph_by; //Html image name for the graph
-	$graph_details=module_Chart($current_user->id,$date_start,$end_date,$query,$graph_by,$graph_title,$where,$module,$type);
-	if($graph_details!=0)
-        {
-                $name_val=$graph_details[0];
-                $cnt_val=$graph_details[1];
-                $graph_title=$graph_details[2];
-                $target_val=$graph_details[3];
-                $graph_date=$graph_details[4];
-                $urlstring=$graph_details[5];
-                $cnt_table=$graph_details[6];
-	       	$test_target_val=$graph_details[7];
-
-                $width=425;
-                $height=225;
-                $top=30;
-                $left=140;
-                $bottom=120;
-                $title=$graph_title;
-		$sHTML = render_graph($tmp_dir."vert_".$cache_file_name,$html_imagename."_vert",$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,"vertical");
-		echo $sHTML;
-		
-        }
-	else
-	{
-		echo $mod_strings[LBL_NO_DATA];	
-	}
-
-
-?>
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+require_once("modules/Dashboard/Entity_charts.php");
+
+	global $current_user,$user_id,$date_start,$end_date,$tmp_dir,$mod_strings,$app_strings;
+	$type='recordsforuser';
+	$homepagedb_query = "select * from vtiger_crmentity se left join vtiger_leaddetails le on le.leadid=se.crmid left join vtiger_troubletickets tt on tt.ticketid=se.crmid left join vtiger_activity act on act.activityid=se.crmid  left join vtiger_potential pot on pot.potentialid=se.crmid where se.deleted=0 and (le.converted=0 or le.converted is null) and (pot.sales_stage not in('".$app_strings['LBL_CLOSE_WON']."','".$app_strings['LBL_CLOSE_LOST']."') or pot.sales_stage is null) and (tt.status!='Closed' or tt.status is null) and ((act.status!='Completed' and act.status!='Deferred') or act.status is null) and ((act.eventstatus!='Held' and act.eventstatus!='Not Held') or act.eventstatus is null) and setype in ('Accounts','Contacts','Leads','Potentials','Quotes','Invoice','PurchaseOrder', 'SalesOrder','Calendar','HelpDesk','Campaigns') and se.deleted=0 and se.smownerid=".$current_user->id;
+	$graph_by="setype";
+	$graph_title=$mod_strings['recordsforuser'].' '.$current_user->user_name;
+	$module="Home";
+	$where="";
+	$query=$homepagedb_query;
+
+	//Giving the Cached image name	
+	$cache_file_name=abs(crc32($current_user->id))."_".$type."_".crc32($date_start.$end_date).".png";
+        $html_imagename=$graph_by; //Html image name for the graph
+	$graph_details=module_Chart($current_user->id,$date_start,$end_date,$query,$graph_by,$graph_title,$where,$module,$type);
+	if($graph_details!=0)
+        {
+                $name_val=$graph_details[0];
+                $cnt_val=$graph_details[1];
+                $graph_title=$graph_details[2];
+                $target_val=$graph_details[3];
+                $graph_date=$graph_details[4];
+                $urlstring=$graph_details[5];
+                $cnt_table=$graph_details[6];
+	       	$test_target_val=$graph_details[7];
+
+                $width=560;
+                $height=225;
+                $top=30;
+                $left=140;
+                $bottom=120;
+                $title=$graph_title;
+		$sHTML = render_graph($tmp_dir."vert_".$cache_file_name,$html_imagename."_vert",$cnt_val,$name_val,$width,$height,$left,$right,$top,$bottom,$title,$target_val,"vertical");
+		echo $sHTML;
+		
+        }
+	else
+	{
+		echo $mod_strings['LBL_NO_DATA'];	
+	}
+
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/accumulated_bargraph.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/accumulated_bargraph.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/accumulated_bargraph.php Mon Apr 16 12:27:44 2007
@@ -32,8 +32,9 @@
 
 
 
-
-$color_array=array("#FF8B8B","#8BFF8B","#A8A8FF","#FFFF6E","#C5FFFF","#FFA8FF","#FFE28B","lightpink","burlywood2","cadetblue");
+$color_array=array("#FFD0C7","#C9F7C9","#C2C3EF","#F7F7C1","#28D6D7","#E7BCE7","#DFD8C3","lightpink","burlywood2","cadetblu
+e");
+#$color_array=array("#FF8B8B","#8BFF8B","#A8A8FF","#FFFF6E","#C5FFFF","#FFA8FF","#FFE28B","lightpink","burlywood2","cadetblue");
 
 // Create the graph. These two calls are always required
 $graph = new Graph($width,$height,"auto");    

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/display_charts.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/display_charts.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/display_charts.php Mon Apr 16 12:27:44 2007
@@ -12,6 +12,7 @@
 global $tmp_dir;
 global $mod_strings,$app_strings;
 global $current_user;
+require('user_privileges/user_privileges_'.$current_user->id.'.php');
 
 $period=($_REQUEST['period'])?$_REQUEST['period']:"tmon"; // Period >> lmon- Last Month, tmon- This Month, lweek-LastWeek, tweek-ThisWeek; lday- Last Day 
 $type=($_REQUEST['type'])?$_REQUEST['type']:"leadsource";
@@ -130,7 +131,7 @@
 				<!--char goes here-->
 				<?php 
 				//Charts for Lead Source
-                    if(($type == "leadsource") && (getFieldVisibilityPermission('Leads',$user_id,'leadsource') == "0"))
+                    if($profileTabsPermission[getTabid("Leads")] == 0 && ($type == "leadsource") && (getFieldVisibilityPermission('Leads',$user_id,'leadsource') == "0"))
                     {
                     	$graph_by="leadsource";
                     	$graph_title= $mod_strings['leadsource'];
@@ -141,7 +142,7 @@
                     
                     }
                     // To display the charts  for Lead status                   
-                    elseif (($type == "leadstatus")&& (getFieldVisibilityPermission('Leads',$user_id,'leadstatus') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Leads")] == 0 && ($type == "leadstatus")&& (getFieldVisibilityPermission('Leads',$user_id,'leadstatus') == "0"))
                     {
                     	$graph_by="leadstatus";
                     	$graph_title= $mod_strings['leadstatus'];
@@ -151,7 +152,7 @@
                     	echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Charts for Lead Industry
-                    elseif (($type == "leadindustry") && (getFieldVisibilityPermission('Leads',$user_id,'industry') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Leads")] == 0 && ($type == "leadindustry") && (getFieldVisibilityPermission('Leads',$user_id,'industry') == "0"))
                     {
                     	$graph_by="industry";
                             $graph_title=$mod_strings['leadindustry'];
@@ -161,7 +162,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Sales by Lead Source
-                    elseif (($type == "salesbyleadsource")&& (getFieldVisibilityPermission('Potentials',$user_id,'leadsource') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyleadsource")&& (getFieldVisibilityPermission('Potentials',$user_id,'leadsource') == "0"))
                     {
                             $graph_by="leadsource";
                             $graph_title=$mod_strings['salesbyleadsource'];
@@ -171,9 +172,9 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Sales by Account
-                    elseif (($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'account_id') == "0"))
-                    {
-                    	$graph_by="accountid";
+                    elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyaccount") && (getFieldVisibilityPermission('Potentials',$user_id,'account_id') == "0"))
+                    {
+                    	 $graph_by="accountid";
                          $graph_title=$mod_strings['salesbyaccount'];
                          $module="Potentials";
                          $where=" and vtiger_potential.sales_stage like '%Closed Won%' ";
@@ -181,7 +182,7 @@
                          echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
 		    //Sales by User
-		    elseif (($type == "salesbyuser") && (getFieldVisibilityPermission('Potentials',$user_id,'smownerid') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyuser"))
 		    {
 			$graph_by="smownerid";
 			$graph_title=$mod_strings['salesbyuser'];
@@ -191,7 +192,7 @@
 			echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Sales by team
-		    elseif (($type == "salesbyteam") && (getFieldVisibilityPermission('Potentials',$user_id,'groupname') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Potentials")] == 0 && ($type == "salesbyteam"))
 		    {
 			$graph_by="groupname";
 			$graph_title=$mod_strings['salesbyteam'];
@@ -201,7 +202,7 @@
 			echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
                     //Charts for Account by Industry
-                    elseif (($type == "accountindustry") && (getFieldVisibilityPermission('Accounts',$user_id,'industry') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Accounts")] == 0 && ($type == "accountindustry") && (getFieldVisibilityPermission('Accounts',$user_id,'industry') == "0"))
                     {
                     	$graph_by="industry";
                             $graph_title=$mod_strings['accountindustry'];
@@ -211,7 +212,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Charts for Products by Category
-                    elseif (($type == "productcategory") && (getFieldVisibilityPermission('Products',$user_id,'productcategory') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Products")] == 0 && ($type == "productcategory") && (getFieldVisibilityPermission('Products',$user_id,'productcategory') == "0"))
                     {
                     	$graph_by="productcategory";
                             $graph_title=$mod_strings['productcategory'];
@@ -221,7 +222,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
 		    //Charts for Products by Quantity in stock
-		    elseif (($type == "productbyqtyinstock") && (getFieldVisibilityPermission('Products',$user_id,'qtyinstock') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Products")] == 0 && ($type == "productbyqtyinstock") && (getFieldVisibilityPermission('Products',$user_id,'qtyinstock') == "0"))
 		    {
 			$graph_by="productname";
 			    $graph_title=$mod_strings['productbyqtyinstock'];
@@ -231,9 +232,9 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Charts for Products by PO
-		    elseif (($type == "productbypo") && (getFieldVisibilityPermission('Products',$user_id,'productpurchaseorder') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Products")] == 0 && ($type == "productbypo"))
 		    { 
-			$graph_by="purchaseorderid";
+			$graph_by="";
 			    $graph_title=$mod_strings['productbypo'];
 			    $module="Products";
 			    $where="";
@@ -241,9 +242,9 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Charts for Products by Quotes
-		    elseif (($type == "productbyquotes") && (getFieldVisibilityPermission('Products',$user_id,'productquotes') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Products")] == 0 && ($type == "productbyquotes"))
 		    { 
-                        $graph_by="quoteid";
+                        $graph_by="";
    			    $graph_title=$mod_strings['productbyquotes'];
 			    $module="Products";
 			    $where=""; 
@@ -251,7 +252,7 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Charts for Products by Invoice
-		    elseif (($type == "productbyinvoice") && (getFieldVisibilityPermission('Products',$user_id,'productinvoice') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Products")] == 0 && ($type == "productbyinvoice"))
 		    {
 		        $graph_by="invoiceid";
 			    $graph_title=$mod_strings['productbyinvoice'];
@@ -262,7 +263,7 @@
 		    }
 
                     // Sales Order by Accounts
-                    elseif (($type == "sobyaccounts") && (getFieldVisibilityPermission('SalesOrder',$user_id,'account_id') == "0"))
+                    elseif ($profileTabsPermission[getTabid("SalesOrder")] == 0 && ($type == "sobyaccounts") && (getFieldVisibilityPermission('SalesOrder',$user_id,'account_id') == "0"))
                     {
                     	$graph_by="accountid";
                             $graph_title=$mod_strings['sobyaccounts'];
@@ -272,7 +273,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Sales Order by Status
-                    elseif (($type == "sobystatus") && (getFieldVisibilityPermission('SalesOrder',$user_id,'sostatus') == "0"))
+                    elseif ($profileTabsPermission[getTabid("SalesOrder")] == 0 && ($type == "sobystatus") && (getFieldVisibilityPermission('SalesOrder',$user_id,'sostatus') == "0"))
                     {
                             $graph_by="sostatus";
                             $graph_title=$mod_strings['sobystatus'];
@@ -282,7 +283,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Purchase Order by Status
-                    elseif (($type == "pobystatus") && (getFieldVisibilityPermission('PurchaseOrder',$user_id,'postatus') == "0"))
+                    elseif ($profileTabsPermission[getTabid("PurchaseOrder")] == 0 && ($type == "pobystatus") && (getFieldVisibilityPermission('PurchaseOrder',$user_id,'postatus') == "0"))
                     {
                             $graph_by="postatus";
                             $graph_title=$mod_strings['pobystatus'];
@@ -292,7 +293,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Quotes by Accounts
-                    elseif (($type == "quotesbyaccounts") && (getFieldVisibilityPermission('Quotes',$user_id,'account_id') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Quotes")] == 0 && ($type == "quotesbyaccounts") && (getFieldVisibilityPermission('Quotes',$user_id,'account_id') == "0"))
                     {
                             $graph_by="accountid";
                             $graph_title= $mod_strings['quotesbyaccounts'];
@@ -302,7 +303,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Quotes by Stage
-                    elseif (($type == "quotesbystage") && (getFieldVisibilityPermission('Quotes',$user_id,'quotestage') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Quotes")] == 0 && ($type == "quotesbystage") && (getFieldVisibilityPermission('Quotes',$user_id,'quotestage') == "0"))
                     {
                             $graph_by="quotestage";
                             $graph_title=$mod_strings['quotesbystage'];
@@ -312,7 +313,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Invoice by Accounts
-                    elseif (($type == "invoicebyacnts") && (getFieldVisibilityPermission('Invoice',$user_id,'account_id') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Invoice")] == 0 && ($type == "invoicebyacnts") && (getFieldVisibilityPermission('Invoice',$user_id,'account_id') == "0"))
                     {
                             $graph_by="accountid";
                             $graph_title=$mod_strings['invoicebyacnts'];
@@ -322,7 +323,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Invoices by status
-                    elseif (($type == "invoicebystatus") && (getFieldVisibilityPermission('Invoice',$user_id,'invoicestatus') == "0"))
+                    elseif ($profileTabsPermission[getTabid("Invoice")] == 0 && ($type == "invoicebystatus") && (getFieldVisibilityPermission('Invoice',$user_id,'invoicestatus') == "0"))
                     {
                             $graph_by="invoicestatus";
                             $graph_title=$mod_strings['invoicebystatus'];
@@ -332,7 +333,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Tickets by Status
-                    elseif (($type == "ticketsbystatus") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketstatus') == "0"))
+                    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbystatus") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketstatus') == "0"))
                     {
                             $graph_by="ticketstatus";
                             $graph_title=$mod_strings['ticketsbystatus'];
@@ -342,7 +343,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
                     //Tickets by Priority
-                    elseif (($type == "ticketsbypriority") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketpriorities') == "0"))
+                    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbypriority") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketpriorities') == "0"))
                     {
                             $graph_by="priority";
                             $graph_title=$mod_strings['ticketsbypriority'];
@@ -352,7 +353,7 @@
                             echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
                     }
 		    //Tickets by Category
-		    elseif (($type == "ticketsbycategory") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketcategory') == "0"))
+		    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbycategory") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketcategories') == "0"))
 		    {
 			    $graph_by="category";
 			    $graph_title=$mod_strings['ticketsbycategory'];
@@ -362,7 +363,7 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Tickets by User   
-		    elseif (($type == "ticketsbyuser") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketuser') == "0"))
+		    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyuser"))
 		    {
 			    $graph_by="smownerid";
 			    $graph_title=$mod_strings['ticketsbyuser'];
@@ -372,7 +373,7 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Tickets by Team
-		    elseif (($type == "ticketsbyteam") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketteam') == "0"))
+		    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyteam"))
 		    {
 			    $graph_by="ticketgroupname";
 			    $graph_title=$mod_strings['ticketsbyteam'];
@@ -382,7 +383,7 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }    
 		    //Tickets by Product
-		    elseif (($type == "ticketsbyproduct") && (getFieldVisibilityPermission('HelpDesk',$user_id,'ticketproduct') == "0"))
+		    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyproduct") && (getFieldVisibilityPermission('HelpDesk',$user_id,'product_id') == "0"))
 		    {
 			    $graph_by="product_id";
 			    $graph_title=$mod_strings['ticketsbyproduct'];
@@ -392,17 +393,17 @@
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Campaigns by Contact
-		    elseif (($type == "contactbycampaign") && (getFieldVisibilityPermission('Campaigns',$user_id,'campaignid') == "0"))
+		    elseif ($profileTabsPermission[getTabid("Contacts")] == 0 && ($type == "contactbycampaign") && $profileTabsPermission[getTabid("Campaigns")] == 0)
 		    {
 			    $graph_by="campaignname";
 			    $graph_title=$mod_strings['contactbycampaign'];
-			    $module="Campaigns";
+			    $module="Contacts";
 			    $where="";
 			    $query=$campaign_query." ".dashboard_check($module);
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
 		    //Tickets by Account
-		    elseif (($type == "ticketsbyaccount") && (getFieldVisibilityPermission('HelpDesk',$user_id,'accountid') == "0"))
+		    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbyaccount") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0"))
 		    {
 			    $graph_by="accountid";
 			    $graph_title=$mod_strings['ticketsbyaccount'];
@@ -411,8 +412,8 @@
 			    $query=$tickets_by_account." ".dashboard_check($module);
 			    echo get_graph_by_type($graph_by,$graph_title,$module,$where,$query);
 		    }
-			    //Tickets by Contact
-			    elseif (($type == "ticketsbycontact") && (getFieldVisibilityPermission('HelpDesk',$user_id,'contactid') == "0"))
+		    //Tickets by Contact
+		    elseif ($profileTabsPermission[getTabid("HelpDesk")] == 0 && ($type == "ticketsbycontact") && (getFieldVisibilityPermission('HelpDesk',$user_id,'parent_id') == "0"))
 			    {
 				    $graph_by="contactid";
 				    $graph_title=$mod_strings['ticketsbycontact'];

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/horizontal_bargraph.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/horizontal_bargraph.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/horizontal_bargraph.php Mon Apr 16 12:27:44 2007
@@ -142,7 +142,8 @@
 	//$bplot->value->SetFormat('%d');
 
 	//$graph->SetBackgroundGradient('#E5E5E5','white',GRAD_VER,BGRAD_PLOT);
-	$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
+	$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, '#7a8fee', '#E5E5E5')));
+	//$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
 	//$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER);
 
 	//$graph->SetFrame(false);
@@ -169,7 +170,7 @@
 	$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
 	$gridY->setLineColor('#E5E5E5 at 0.5');
 	$gridY2 =& $plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); 
-	$gridY2->setFillColor('#66CDAA at 0.2'); 
+	$gridY2->setFillColor('#dadada at 0.2');
 
 
 	// Add some grace to y-axis so the bars doesn't go

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/index.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/index.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/index.php Mon Apr 16 12:27:44 2007
@@ -99,10 +99,28 @@
 				<table border=0 cellspacing=0 cellpadding=5>
 
 				<tr>
+<?php 
+if($CALENDAR_DISPLAY == 'true') { 
+?> 
 					<td style="padding-right:0px;padding-left:10px;"><a href="javascript:;" onClick='fnvshobj(this,"miniCal");getMiniCal("parenttab=My Home Page");'><img src="<?php echo $image_path;?>btnL3Calendar.gif" alt="<?php echo $app_strings['LBL_CALENDAR_ALT']; ?>" title="<?php echo $app_strings['LBL_CALENDAR_TITLE']; ?>" border=0></a></a></td>
+<?php 
+} 
+if($WORLD_CLOCK_DISPLAY == 'true') { 
+?> 
 					<td style="padding-right:0px"><a href="javascript:;"><img src="<?php echo $image_path;?>btnL3Clock.gif" alt="<?php echo $app_strings['LBL_CLOCK_ALT']; ?>" title="<?php echo $app_strings['LBL_CLOCK_TITLE']; ?>" border=0 onClick="fnvshobj(this,'wclock');"></a></a></td>
+<?php 
+} 
+if($CALCULATOR_DISPLAY == 'true') { 
+?>
 					<td style="padding-right:0px"><a href="#"><img src="<?php echo $image_path;?>btnL3Calc.gif" alt="<?php echo $app_strings['LBL_CALCULATOR_ALT']; ?>" title="<?php echo $app_strings['LBL_CALCULATOR_TITLE']; ?>" border=0 onClick="fnvshobj(this,'calculator_cont');fetch_calc();"></a></td>
-					<td style="padding-right:10px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="<?php echo $image_path;?>tbarChat.gif" alt="<?php echo $app_strings['LBL_CHAT_ALT']; ?>" title="<?php echo $app_strings['LBL_CHAT_TITLE']; ?>" border=0></a>
+<?php 
+} 
+if($CHAT_DISPLAY == 'true') { 
+?> 		
+			<td style="padding-right:10px"><a href="javascript:;" onClick='return window.open("index.php?module=Contacts&action=vtchat","Chat","width=600,height=450,resizable=1,scrollbars=1");'><img src="<?php echo $image_path;?>tbarChat.gif" alt="<?php echo $app_strings['LBL_CHAT_ALT']; ?>" title="<?php echo $app_strings['LBL_CHAT_TITLE']; ?>" border=0></a>
+<?php 
+} 
+?> 
                     </td>	
 				</tr>
 				</table>

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/line_graph.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/line_graph.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/line_graph.php Mon Apr 16 12:27:44 2007
@@ -89,8 +89,10 @@
 $graph->legend->Pos(0,0.4,"right","center");
 
 // Set some other color then the boring default
-$graph->SetColor("#CCDFCC");
-$graph->SetMarginColor("#98C098");
+$graph->SetColor("#6F96FF");
+//$graph->SetColor("#CCDFCC");
+$graph->SetMarginColor("#2447A7");
+//$graph->SetMarginColor("#98C098");
 $graph->xaxis->SetTickLabels($datax);
 $graph->xaxis->SetLabelAngle(90);
 

Modified: vtigercrm/branches/5.1_jens/modules/Dashboard/pie_graph.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Dashboard/pie_graph.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Dashboard/pie_graph.php Mon Apr 16 12:27:44 2007
@@ -75,7 +75,7 @@
 	);   
 
 	// Generate colours
-	$colors = color_generator(count($datay),'#33CCFF','#3322FF');
+	$colors = color_generator(count($datay),'#33DDFF','#3322FF');
 	$dataset = & Image_Graph::factory('dataset');
 	$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
 	$sum = 0;

Modified: vtigercrm/branches/5.1_jens/modules/Emails/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/DetailView.php Mon Apr 16 12:27:44 2007
@@ -131,8 +131,9 @@
 	else $smarty->assign("NAME", "");
 
 $entries = getBlocks($currentModule,"detail_view",'',$focus->column_fields);
-$entries['Email Information']['4']['Description']['value'] = from_html($entries['Email Information']['4']['Description']['value']);
-$smarty->assign("BLOCKS", $entries['Email Information']);
+$entries[$mod_strings['LBL_EMAIL_INFORMATION']]['5'][$mod_strings['Description']]['value'] = from_html($entries[$mod_strings['LBL_EMAIL_INFORMATION']]['5'][$mod_strings['Description']]['value']);
+//changed this to view description in all langauge - bharath
+$smarty->assign("BLOCKS",$entries[$mod_strings['LBL_EMAIL_INFORMATION']]); 
 $smarty->assign("SINGLE_MOD", 'Email');
 
 $smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);

Modified: vtigercrm/branches/5.1_jens/modules/Emails/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/EditView.php Mon Apr 16 12:27:44 2007
@@ -49,7 +49,6 @@
 	echo parseEmailErrorString($_REQUEST['mail_error']);
 }
 
-
 if(isset($_REQUEST['record']) && $_REQUEST['record'] !='') 
 {
 	$focus->id = $_REQUEST['record'];
@@ -58,7 +57,8 @@
 	if(isset($_REQUEST['forward']) && $_REQUEST['forward'] != '')
 	{
 		$focus->mode = '';
-	}else
+	}
+	else
 	{
 		$query = 'select idlists,from_email,to_email,cc_email,bcc_email from vtiger_emaildetails where emailid ='.$focus->id;
 		$result = $adb->query($query);
@@ -85,7 +85,11 @@
 	$smarty->assign('INT_MAILER',"true");
 	$rec_type = $_REQUEST["type"];
 	$rec_id = $_REQUEST["rec_id"];
-
+	//added for getting list-ids to compose email popup from list view(Accounts,Contacts,Leads)
+	if(isset($_REQUEST['field_id']) && strlen($_REQUEST['field_id']) != 0) {
+             $id_list = $_REQUEST['rec_id'].'@'.$_REQUEST['field_id'].'|';
+             $smarty->assign("IDLISTS", $id_list);
+        }
 	if($rec_type == "record_id") {
 		$rs = $adb->query("select setype from vtiger_crmentity where crmid='".$rec_id."'");
 		$type = $adb->query_result($rs,0,'setype');
@@ -106,12 +110,32 @@
 	$smarty->assign('BCC_MAIL',$current_user->email1);
 }
 
+//handled for replying emails
+if($_REQUEST['reply'] == "true")
+{
+		$fromadd = $_REQUEST['record'];	
+		$query = "select from_email,idlists,cc_email,bcc_email from vtiger_emaildetails where emailid =$fromadd";
+		$result = $adb->query($query);
+		$from_mail = $adb->query_result($result,0,'from_email');	
+		$smarty->assign('TO_MAIL',$from_mail.';');
+		$smarty->assign('CC_MAIL',ereg_replace('###',',',$adb->query_result($result,0,'cc_email')));	
+		$smarty->assign('BCC_MAIL',ereg_replace('###',',',$adb->query_result($result,0,'bcc_email')));	
+		$smarty->assign('IDLISTS',ereg_replace('###',',',$adb->query_result($result,0,'idlists')));	
+}
+
+
+//Added to set the cc when click reply all
+if(isset($_REQUEST['msg_cc']) && $_REQUEST['msg_cc'] != '')
+{
+        $smarty->assign("MAIL_MSG_CC", $_REQUEST['msg_cc']);
+}
+
 // Webmails
 if(isset($_REQUEST["mailid"]) && $_REQUEST["mailid"] != "") {
 	$mailid = $_REQUEST["mailid"];
 	$mailbox = $_REQUEST["mailbox"];
 	require_once('include/utils/UserInfoUtil.php');
-	require_once("modules/Webmails/Webmail.php");
+	require_once("modules/Webmails/Webmails.php");
 	require_once("modules/Webmails/MailParse.php");
 	require_once('modules/Webmails/MailBox.php');
 
@@ -121,37 +145,44 @@
 	$MailBox = new MailBox($mailbox);
 	$mbox = $MailBox->mbox;
 
-	$webmail = new Webmail($mbox,$mailid);
-	$webmail->loadMail();
-
+	$webmail = new Webmails($mbox,$mailid);
+	$array_tab = Array();
+	$webmail->loadMail($array_tab);
+	  $hdr = @imap_headerinfo($mbox, $mailid);
 	$smarty->assign('WEBMAIL',"true");
 	if($_REQUEST["reply"] == "all") {
 		$smarty->assign('TO_MAIL',$webmail->fromaddr);	
-		if(is_array($webmail->cc_list))
+		$smarty->assign('CC_MAIL',$hdr->ccaddress);
+		/*if(is_array($webmail->cc_list))
+		{
 			$smarty->assign('CC_MAIL',implode(",",$webmail->cc_list).",".implode(",",$webmail->to));
-		else
-			$smarty->assign('CC_MAIL',implode(",",$webmail->to));
+		}
+		else
+		{
+			//Commenting this to fix #3231
+		//	$smarty->assign('CC_MAIL',implode(",",$webmail->to));
+		}*/
 		if(preg_match("/RE:/i", $webmail->subject))
 			$smarty->assign('SUBJECT',$webmail->subject);
 		else
 			$smarty->assign('SUBJECT',"RE: ".$webmail->subject);
 
-	} elseif($_REQUEST["reply"] == "single") {
+	} elseif($_REQUEST["reply"] == "single"){
 		$smarty->assign('TO_MAIL',$webmail->reply_to[0]);	
-		$smarty->assign('BCC_MAIL',$webmail->to[0]);
+		//$smarty->assign('BCC_MAIL',$webmail->to[0]);
 		if(preg_match("/RE:/i", $webmail->subject))
 			$smarty->assign('SUBJECT',$webmail->subject);
 		else
 			$smarty->assign('SUBJECT',"RE: ".$webmail->subject);
 
-	} elseif($_REQUEST["forward"] == "true") {
-		$smarty->assign('TO_MAIL',$webmail->reply_to[0]);	
-		$smarty->assign('BCC_MAIL',$webmail->to[0]);
+	} elseif($_REQUEST["forward"] == "true" ) {
+		//$smarty->assign('TO_MAIL',$webmail->reply_to[0]);	
+		//$smarty->assign('BCC_MAIL',$webmail->to[0]);
 		if(preg_match("/FW:/i", $webmail->subject))
 			$smarty->assign('SUBJECT',$webmail->subject);
 		else
 			$smarty->assign('SUBJECT',"FW: ".$webmail->subject);
-	}
+	} 
 	$smarty->assign('DESCRIPTION',$webmail->replyBody());
 	$focus->mode='';
 }
@@ -163,10 +194,10 @@
 
 $disp_view = getView($focus->mode);
 $details = getBlocks($currentModule,$disp_view,$mode,$focus->column_fields);
-$smarty->assign("BLOCKS",$details['Email Information']);
+//changed this below line to view description in all language - bharath
+$smarty->assign("BLOCKS",$details[$mod_strings['LBL_EMAIL_INFORMATION']]); 
 $smarty->assign("MODULE",$currentModule);
 $smarty->assign("SINGLE_MOD",$app_strings['Email']);
-
 
 //needed when creating a new email with default values passed in
 if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) 
@@ -205,12 +236,6 @@
 if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
 else $smarty->assign("NAME", "");
 
-
-//Added to set the cc when click reply all
-if(isset($_REQUEST['msg_cc']) && $_REQUEST['msg_cc'] != '')
-{
-        $smarty->assign("MAIL_MSG_CC", $_REQUEST['msg_cc']);
-}
 
 if($focus->mode == 'edit')
 {

Modified: vtigercrm/branches/5.1_jens/modules/Emails/Emails.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/Emails.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/Emails.php Mon Apr 16 12:27:44 2007
@@ -36,8 +36,13 @@
 	var $db;
 
 	// Stored vtiger_fields
-  // added to check email save from plugin or not
-  var $plugin_save = false;
+  	// added to check email save from plugin or not
+	var $plugin_save = false;
+
+var $rel_users_table = "vtiger_salesmanactivityrel";
+var $rel_contacts_table = "vtiger_cntactivityrel";
+var $rel_serel_table = "vtiger_seactivityrel";
+
 
 
 	var $tab_name = Array('vtiger_crmentity','vtiger_activity');

Modified: vtigercrm/branches/5.1_jens/modules/Emails/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/Save.php Mon Apr 16 12:27:44 2007
@@ -165,6 +165,9 @@
 $focus->save("Emails");
 
 //saving the email details in vtiger_emaildetails vtiger_table
+$qry = 'select email1 from vtiger_users where id = '.$current_user->id;
+$res = $adb->query($qry);
+$user_email = $adb->query_result($res,0,"email1");
 $return_id = $focus->id;
 $email_id = $return_id;
 $query = 'select emailid from vtiger_emaildetails where emailid ='.$email_id;
@@ -176,12 +179,13 @@
 	
 $all_cc_ids = ereg_replace(",","###",$_REQUEST["ccmail"]);
 $all_bcc_ids = ereg_replace(",","###",$_REQUEST["bccmail"]);
+$userid = $current_user->id;
 if($adb->num_rows($result) > 0)
 {
-	$query = 'update vtiger_emaildetails set to_email="'.$all_to_ids.'",cc_email="'.$all_cc_ids.'",bcc_email="'.$all_bcc_ids.'",idlists="'.$_REQUEST["parent_id"].'",email_flag="SAVED" where emailid = '.$email_id;
+	$query = 'update vtiger_emaildetails set to_email="'.$all_to_ids.'",cc_email="'.$all_cc_ids.'",bcc_email="'.$all_bcc_ids.'",idlists="'.$userid."@-1|".$_REQUEST["parent_id"].'",email_flag="SAVED" where emailid = '.$email_id;
 }else
 {
-	$query = 'insert into vtiger_emaildetails values ('.$email_id.',"","'.$all_to_ids.'","'.$all_cc_ids.'","'.$all_bcc_ids.'","","'.$_REQUEST["parent_id"].'","SAVED")';
+	$query = 'insert into vtiger_emaildetails values ('.$email_id.',"'.$user_email.'","'.$all_to_ids.'","'.$all_cc_ids.'","'.$all_bcc_ids.'","","'.$userid."@-1|".$_REQUEST["parent_id"].'","SAVED")';
 }
 $adb->query($query);
 

Modified: vtigercrm/branches/5.1_jens/modules/Emails/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -21,8 +21,8 @@
 // Mike Crowe Mod --------------------------------------------------------added for general search
 'LBL_GENERAL_INFORMATION'=>'General Information',
 
-'LBL_MODULE_NAME'=>'Emails',
-'LBL_MODULE_TITLE'=>'Emails: Home',
+'LBL_MODULE_NAME'=>'Email',
+'LBL_MODULE_TITLE'=>'Email: Home',
 'LBL_SEARCH_FORM_TITLE'=>'Email Search',
 'LBL_LIST_FORM_TITLE'=>'Email List',
 'LBL_NEW_FORM_TITLE'=>'Track Email',
@@ -35,19 +35,19 @@
 
 'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
 'LBL_DATE_SENT'=>'Date Sent:',
-'LBL_SUBJECT'=>'Subject :',
-'LBL_BODY'=>'Body:',
 'LBL_DATE_AND_TIME'=>'Date & Time Sent:',
 'LBL_DATE'=>'Date Sent:',
 'LBL_TIME'=>'Time Sent:',
 'LBL_SUBJECT'=>'Subject:',
 'LBL_BODY'=>'Body:',
 'LBL_CONTACT_NAME'=>' Contact Name: ',
-'LBL_EMAIL'=>'Email:',  
+'LBL_EMAIL'=>'Email:', 
+'LBL_DETAILVIEW_EMAIL'=>'E-Mail', 
 'LBL_COLON'=>':',
 'LBL_CHK_MAIL'=>'Check Mail',
 'LBL_COMPOSE'=>'Compose',
-'LBL_SETTINGS'=>'Settings',
+//Single change for 5.0.3
+'LBL_SETTINGS'=>'Incoming Mail Server Settings',
 'LBL_EMAIL_FOLDERS'=>'Email Folders',
 'LBL_INBOX'=>'Inbox',
 'LBL_SENT_MAILS'=>'Sent Mails',
@@ -74,7 +74,6 @@
 // Contacts-SubPanelViewContactsAndUsers.php
 'LBL_BULK_MAILS'=>'Bulk Mails',
 'LBL_ATTACHMENT'=>'Attachment',
-'LBL_DESCRIPTION'=>'Description',
 'LBL_UPLOAD'=>'Upload',
 'LBL_FILE_NAME'=>'File Name',
 'LBL_SEND'=>'Send',
@@ -132,7 +131,7 @@
 'LBL_ALL'=>'All',
 'MESSAGE_CONTACT_NOT_WANT_MAIL'=>'This Contact does not want to receive mails.',
 'LBL_WEBMAILS_TITLE'=>'WebMails',
-'LBL_EMAILS_TITLE'=>'Emails',
+'LBL_EMAILS_TITLE'=>'Email',
 'LBL_MAIL_CONNECT_ERROR_INFO'=>'Error connecting mail server!<br> Check in My Accounts->List Mail Server -> List Mail Account',
 'LBL_ALLMAILS'=>'All Mails',
 'LBL_TO_USERS'=>'To Users',
@@ -148,6 +147,29 @@
 'LBL_MAILSELECT_INFO2'=>'Select the Email ID types to which,the email should be sent',
 'LBL_MULTIPLE'=>'Multiple',
 'LBL_COMPOSE_EMAIL'=>'Compose E-Mail',
+'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Email Client',
+
+//Added for 5.0.3
+'TITLE_VTIGERCRM_MAIL'=>'vtigerCRM Mail',
+'TITLE_COMPOSE_MAIL'=>'Compose Mail',
+
+'MESSAGE_MAIL_COULD_NOT_BE_SEND'=>'Mail could not be sent to the assigned to user.',
+'MESSAGE_PLEASE_CHECK_ASSIGNED_USER_EMAILID'=>'Please check the assigned to user email id...',
+'MESSAGE_PLEASE_CHECK_THE_FROM_MAILID'=>'Please check the from email id',
+'MESSAGE_MAIL_COULD_NOT_BE_SEND_TO_THIS_EMAILID'=>'Mail could not be sent to this email id',
+'PLEASE_CHECK_THIS_EMAILID'=>'Please check this mail id...',
+'LBL_CC_EMAIL_ERROR'=>'Your cc mailid is not proper',
+'LBL_BCC_EMAIL_ERROR'=>'Your bcc mailid is not proper',
+'LBL_NO_RCPTS_EMAIL_ERROR'=>'No recepients specified',
+'LBL_CONF_MAILSERVER_ERROR'=>'Please configure your outgoing mailserver under Settings ---> Outgoing Server link',
+'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Email Client',
+'LBL_MAILSELECT_INFO3'=>'You don\'t have permission to view email id(s) of the selected Record(s).',
+'LBL_NO_RECORDS' => 'No Records in this folder',
+//Added  for script alerts
+'FEATURE_AVAILABLE_INFO' => 'This feature is currently only available for Microsoft Internet Explorer 5.5+ users\n\nWait f
+or an update!',
+'DOWNLOAD_CONFIRAMATION' => 'Do you want to download the file ?',
+
 );
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Emails/mail.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/mail.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/mail.php Mon Apr 16 12:27:44 2007
@@ -10,7 +10,7 @@
  ********************************************************************************/
 
 
-//require("modules/Emails/class.phpmailer.php");
+require_once("modules/Emails/class.phpmailer.php");
 
 /**   Function used to send email 
   *   $module 		-- current module 
@@ -41,8 +41,8 @@
 	//if module is HelpDesk then from_email will come based on support email id 
 	if($from_email == '')//$module != 'HelpDesk')
 		$from_email = getUserEmailId('user_name',$from_name);
-
-	$contents = addSignature($contents,$from_name);
+	if($module != "Calendar")
+                $contents = addSignature($contents,$from_name);	
 
 	$mail = new PHPMailer();
 
@@ -106,10 +106,10 @@
 	global $adb;
 	$adb->println("Inside the function addSignature");
 
-	$sign = $adb->query_result($adb->query("select signature from vtiger_users where user_name=".$adb->quote($fromname)),0,"signature");
+	$sign = nl2br($adb->query_result($adb->query("select signature from vtiger_users where user_name=".$adb->quote($fromname)),0,"signature"));
 	if($sign != '')
 	{
-		$contents .= '<br><br><font color=darkgrey>'.$sign.'</font>';
+		$contents .= '<br><br>'.$sign;
 		$adb->println("Signature is added with the body => '.".$sign."'");
 	}
 	else
@@ -436,13 +436,13 @@
 			if($status_str[1] == 'connect_host')
 			{
 				$adb->println("if part - Mail sever is not configured");
-				$errorstr .= '<br><b><font color=red>Please Check the Mail Server Name...</font></b>';
+				$errorstr .= '<br><b><font color=red>'.$mod_strings['MESSAGE_CHECK_MAIL_SERVER_NAME'].'</font></b>';
 				break;
 			}
 			elseif($status_str[1] == '0')
 			{
 				$adb->println("first elseif part - status will be 0 which is the case of assigned to vtiger_users's email is empty.");
-				$errorstr .= '<br><b><font color=red> Mail could not be sent to the assigned to user. Please check the assigned to user email id...</font></b>';
+				$errorstr .= '<br><b><font color=red> '.$mod_strings['MESSAGE_MAIL_COULD_NOT_BE_SEND'].' '.$mod_strings['MESSAGE_PLEASE_CHECK_FROM_THE_MAILID'].'</font></b>';
 				//Added to display the message about the CC && BCC mail sending status
 				if($status_str[0] == 'cc_success')
 				{
@@ -454,12 +454,12 @@
 			{
 				$adb->println("second elseif part - from email id is failed.");
 				$from = explode('from_failed',$status_str[1]);
-				$errorstr .= "<br><b><font color=red>Please check the from email id '".$from[1]."'</font></b>";
+				$errorstr .= "<br><b><font color=red>".$mod_strings['MESSAGE_PLEASE_CHECK_THE_FROM_MAILID']." '".$from[1]."'</font></b>";
 			}
 			else
 			{
 				$adb->println("else part - mail send process failed due to the following reason.");
-				$errorstr .= "<br><b><font color=red> Mail could not be sent to this email id '".$status_str[0]."'. Please check this mail id...</font></b>";	
+				$errorstr .= "<br><b><font color=red> ".$mod_strings['MESSAGE_MAIL_COULD_NOT_BE_SEND_TO_THIS_EMAILID']." '".$status_str[0]."'. ".$mod_strings['PLEASE_CHECK_THIS_EMAILID']."</font></b>";	
 			}
 		}
 	}

Modified: vtigercrm/branches/5.1_jens/modules/Emails/mailSelect.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/mailSelect.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/mailSelect.php Mon Apr 16 12:27:44 2007
@@ -12,10 +12,7 @@
 require_once('include/database/PearDatabase.php');
 
 
-global $app_strings;
-global $mod_strings;
-
-global $theme;
+global $app_strings,$mod_strings,$current_user,$theme;
 $image_path = 'themes/'.$theme.'/images/';
 $idlist = $_REQUEST['idlist'];
 $pmodule=$_REQUEST['return_module'];
@@ -26,6 +23,25 @@
 	$single_record = true;
 }
 $smarty = new vtigerCRM_Smarty;
+
+$userid =  $current_user->id;
+if($pmodule == "Contacts")
+{
+	$permit = getFieldVisibilityPermission("Contacts", $userid, "email");
+}
+elseif($pmodule == "Accounts")
+{
+	$permit = getFieldVisibilityPermission("Accounts", $userid, "email1");
+}
+elseif($pmodule == "Leads")
+{
+	$permit = getFieldVisibilityPermission("Leads", $userid, "email");
+}
+if($permit == '0');
+{
+	$smarty->assign("PERMIT", $permit);
+}
+
 if ($pmodule=='Accounts')
 {
 	$querystr="select fieldid,fieldlabel,columnname,tablename from vtiger_field where tabid=6 and uitype=13;"; 
@@ -49,7 +65,6 @@
 	$fieldid=$adb->query_result($result,$i,'fieldid');
 	$value[] =$adb->query_result($result,$i,'fieldlabel');
 	$returnvalue [$fieldid]= $value;
-	
 }
 
 if($single_record)

Modified: vtigercrm/branches/5.1_jens/modules/Emails/mailbox.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/mailbox.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/mailbox.php Mon Apr 16 12:27:44 2007
@@ -73,9 +73,9 @@
 	      
 	   function handleFile(nr) {
 	   	if (b != "ie") {
- 	      		alert("This feature is currently only available for Microsoft Internet Explorer 5.5+ users\n\nWait for an update!");
+ 	      		alert('.$mod_strings['FEATURE_AVAILABLE_INFO'].');
 	   	} else {
-	   		check = confirm("Do you want to download the file ?");
+	   		check = confirm('.$mod_strings['DOWNLOAD_CONFIRAMATION'].');
 			if (check) {
 				setTimeout("this.location.reload()",8000);
 				location.href="index.php?action=gotodownload&module=Emails&download=1&file="+ nr +"&msgno='.$msg.'";					     } else {
@@ -126,7 +126,7 @@
 					$selectBoxDisplay[$k] = $att[$k]->parameters[1]->value;
 				}
    		        } 
-			elseif ($att[$k]->parameters[0]->value != "iso-8859-1" &&    $att[$k]->parameters[0]->value != "ISO-8859-1") {
+			elseif ($att[$k]->parameters[0]->value != $app_strings['LBL_CHARSET'] &&  $att[$k]->parameters[0]->value != $app_strings['LBL_CHARSET']) {
 				$selectBoxDisplay[$k] = $att[$k]->parameters[0]->value;
 			}
 		    }
@@ -341,7 +341,7 @@
   global $log;
         $log->debug("Entering transformHTML(".$str.") method ...");
    if ((strpos($str,"<HTML") < 0) || (strpos($str,"<html")    < 0)) {
-  		$makeHeader = "<html><head><meta http-equiv=\"Content-Type\"    content=\"text/html; charset=iso-8859-1\"></head>\n";
+  		$makeHeader = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$app_strings['LBL_CHARSET']."\"></head>\n";
    	if ((strpos($str,"<BODY") < 0) || (strpos($str,"<body")    < 0)) {
    		$makeBody = "\n<body>\n";
    		$str = $makeHeader . $makeBody . $str ."\n</body></html>";
@@ -349,7 +349,7 @@
    		$str = $makeHeader . $str ."\n</html>";
    	}
    } else {
-   	$str = "<meta http-equiv=\"Content-Type\" content=\"text/html;    charset=iso-8859-1\">\n". $str;
+   	$str = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$app_strings['LBL_CHARSET']."\">\n". $str;
    }
         $log->debug("Exiting transformHTML method ...");
    	return $str;

Modified: vtigercrm/branches/5.1_jens/modules/Emails/mailsend.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/mailsend.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/mailsend.php Mon Apr 16 12:27:44 2007
@@ -71,9 +71,12 @@
 }
 else
 {
+	$query1 = "select email1 from vtiger_users where id =".$current_user->id;
+	$res1 = $adb->query($query1);
+	$val = $adb->query_result($res1,0,"email1");
 	$mail_status = send_mail('Emails',$to_email,$current_user->user_name,'',$_REQUEST['subject'],$_REQUEST['description'],$cc,$bcc,'all',$focus->id);
 	
-	$query = 'update vtiger_emaildetails set email_flag ="SENT" where emailid='.$focus->id;
+	$query = 'update vtiger_emaildetails set email_flag ="SENT",from_email ='."'$val'".' where emailid='.$focus->id;
 	$adb->query($query);
 	//set the errorheader1 to 1 if the mail has not been sent to the assigned to user
 	if($mail_status != 1)//when mail send fails

Modified: vtigercrm/branches/5.1_jens/modules/Emails/sendmail.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Emails/sendmail.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Emails/sendmail.php Mon Apr 16 12:27:44 2007
@@ -51,8 +51,8 @@
         $mail->Subject =$adb->query_result($result1,0,"subject");
 
 	$DESCRIPTION = $adb->query_result($result1,0,"description");
-	$DESCRIPTION .= '<br><br>';
-	$DESCRIPTION .= '<font color=darkgrey>'.nl2br($adb->query_result($adb->query("select * from vtiger_users where user_name=".$adb->quote($from)),0,"signature")).'</font>';
+	$DESCRIPTION .= '<br><br>\n';
+	$DESCRIPTION .= nl2br($adb->query_result($adb->query("select * from vtiger_users where user_name=".$adb->quote($from)),0,"signature"));
 
 	$mail->IsHTML(true);
         $mail->Body    = nl2br($DESCRIPTION);

Modified: vtigercrm/branches/5.1_jens/modules/Faq/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Faq/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Faq/DetailView.php Mon Apr 16 12:27:44 2007
@@ -76,6 +76,8 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
 $tabid = getTabid("Faq");
 $validationData = getDBValidationData($focus->tab_name,$tabid);
 $data = split_validationdataArray($validationData);

Modified: vtigercrm/branches/5.1_jens/modules/Faq/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Faq/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Faq/EditView.php Mon Apr 16 12:27:44 2007
@@ -111,7 +111,7 @@
 	//Added to display the Faq comments information
 	$smarty->assign("COMMENT_BLOCK",$focus->getFAQComments($_REQUEST['record']));
 }
-
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 if($focus->mode == 'edit')
 	$smarty->display("salesEditView.tpl");
 else

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailView.php Mon Apr 16 12:27:44 2007
@@ -85,6 +85,7 @@
                 $optionString[$tempVal["templateid"]]=$tempVal["filename"];
                 $tempVal = $adb->fetch_array($wordTemplateResult);
         }
+	 $smarty->assign("TEMPLATECOUNT",$tempCount);
 	$smarty->assign("WORDTEMPLATEOPTIONS",$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']);
         $smarty->assign("TOPTIONS",$optionString);
 }
@@ -104,6 +105,7 @@
 
 $smarty->assign("MODULE",$currentModule);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
 
 if($singlepane_view == 'true')
 {

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailViewAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailViewAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/DetailViewAjax.php Mon Apr 16 12:27:44 2007
@@ -22,7 +22,7 @@
 	$crmid = $_REQUEST["recordid"];
 	$tablename = $_REQUEST["tableName"];
 	$fieldname = $_REQUEST["fldName"];
-	$fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); 
+	$fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]);
 
 	if($crmid != "")
 	{
@@ -45,7 +45,70 @@
 		$fldvalue = from_html($adb->formatString('vtiger_troubletickets','update_log',$fldvalue),($modObj->mode == 'edit')?true:false);
 		
 		$modObj->save("HelpDesk");
-		
+		global $mod_strings;
+		if($fieldname == "solution" || $fieldname == "comments" || $fieldname =="assigned_user_id" ||($fieldname == "ticketstatus" && $fieldvalue == $mod_strings['Closed']))
+		{
+			require_once('modules/Emails/mail.php');
+			$user_emailid = getUserEmailId('id',$modObj->column_fields['assigned_user_id']);
+			
+			$subject = '[ Ticket ID : '.$modObj->id.' ] Re :'.$modObj->column_fields['ticket_title'];
+			$parent_id = $modObj->column_fields['parent_id'];
+			if($parent_id != '')
+			{
+				$parent_module = getSalesEntityType($parent_id);
+				if($parent_module == 'Contacts')
+				{
+					$result = $adb->query("select * from vtiger_contactdetails where contactid=".$parent_id);
+					$emailoptout = $adb->query_result($result,0,'emailoptout');
+					$contactname = $adb->query_result($result,0,'firstname').' '.$adb->query_result($result,0,'lastname');
+					$parentname = $contactname;
+					$contact_mailid = $adb->query_result($result,0,'email');
+				}
+				if($parent_module == 'Accounts')
+				{
+					$result = $adb->query("select * from vtiger_account where accountid=".$parent_id);
+					$emailoptout = $adb->query_result($result,0,'emailoptout');
+					$parentname = $adb->query_result($result,0,'accountname');
+				}
+			}
+			if($contact_mailid != '')
+			{
+				$sql = "select * from vtiger_portalinfo where user_name='".$contact_mailid."'";
+				$isactive = $adb->query_result($adb->query($sql),0,'isactive');
+			}
+			if($isactive == 1)
+			{
+				$url = "<a href='".$PORTAL_URL."/index.php?module=Tickets&action=index&ticketid=".$id."&fun=detail'>Ticket Details</a>";
+				$email_body = $subject.'<br><br>'.getPortalInfo_Ticket($modObj->id,$sub,$contactname,$url,"edit");
+			}
+			else
+			{
+				$data['sub']=$modObj->column_fields['ticket_title'];
+				$data['parent_name']=$parentname;
+				$data['status']=$modObj->column_fields['ticketstatus'];
+				$data['category']=$modObj->column_fields['ticketcategories'];
+				$data['severity'] = $modObj->column_fields['ticketseverities'];
+				$data['priority']=$modObj->column_fields['ticketpriorities'];
+				$data['description']=$modObj->column_fields['description'];
+				$data['solution'] = $modObj->column_fields['solution'];
+				$data['mode']= 'edit';
+				$email_body = getTicketDetails($modObj->id,$data);
+			}
+			if($user_emailid != '')
+			{
+				$mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+			}
+			if($emailoptout == 0)
+			{
+				//send mail to parent
+				if($parent_id != '' )
+				{
+					$parent_email = getParentMailId($parent_module,$parent_id);
+					$mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+				}
+			}
+
+		}
 		//update the log information for ticket history
 		$adb->query("update vtiger_troubletickets set update_log=$fldvalue where ticketid=".$modObj->id);
 		

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/EditView.php Mon Apr 16 12:27:44 2007
@@ -111,7 +111,7 @@
 	//Added to display the ticket comments information
 	$smarty->assign("COMMENT_BLOCK",$focus->getCommentInformation($_REQUEST['record']));
 }
-
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 if($focus->mode == 'edit')
 	$smarty->display("salesEditView.tpl");
 else

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.js
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.js (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.js Mon Apr 16 12:27:44 2007
@@ -14,12 +14,12 @@
 	{
         	if (form.potential_name.value == "")
 		{
-                	alert("Opportunity Name field cannot be empty");
+                	alert(alert_arr.OPPORTUNITYNAME_CANNOT_BE_EMPTY);
 			return false;	
 		}
 		if (form.closedate.value == "")
 		{
-                	alert("Close Date field cannot be empty");
+                	alert(alert_arr.CLOSEDATE_CANNOT_BE_EMPTY);
 			return false;	
 		}
 		return dateValidate('closedate','Potential Close Date','GECD');

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/HelpDesk.php Mon Apr 16 12:27:44 2007
@@ -1,641 +1,642 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of txhe License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-class HelpDesk extends CRMEntity {
-	var $log;
-	var $db;
-
-	var $tab_name = Array('vtiger_crmentity','vtiger_troubletickets','vtiger_ticketcf');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_troubletickets'=>'ticketid','vtiger_seticketsrel'=>'ticketid','vtiger_ticketcf'=>'ticketid','vtiger_ticketcomments'=>'ticketid','vtiger_attachments'=>'attachmentsid');
-	var $column_fields = Array();
-
-	var $sortby_fields = Array('title','status','priority','crmid','firstname','smownerid');
-
-	var $list_fields = Array(
-					'Ticket ID'=>Array('crmentity'=>'crmid'),
-					'Subject'=>Array('troubletickets'=>'title'),	  			
-					'Related to'=>Array('troubletickets'=>'parent_id'),	  			
-					'Status'=>Array('troubletickets'=>'status'),
-					'Priority'=>Array('troubletickets'=>'priority'),
-					'Assigned To'=>Array('crmentity','smownerid')
-				);
-
-	var $list_fields_name = Array(
-					'Ticket ID'=>'',
-					'Subject'=>'ticket_title',	  			
-					'Related to'=>'parent_id',	  			
-					'Status'=>'ticketstatus',
-					'Priority'=>'ticketpriorities',
-					'Assigned To'=>'assigned_user_id'
-				     );
-
-	var $list_link_field= 'ticket_title';
-			
-	var $range_fields = Array(
-				        'ticketid',
-					'title',
-			        	'firstname',
-				        'lastname',
-			        	'parent_id',
-			        	'productid',
-			        	'productname',
-			        	'priority',
-			        	'severity',
-				        'status',
-			        	'category',
-					'description',
-					'solution',
-					'modifiedtime',
-					'createdtime'
-				);
-	var $search_fields = Array(
-		'Ticket ID' => Array('vtiger_crmentity'=>'crmid'),
-		'Subject' => Array('vtiger_troubletickets'=>'title')
-		);
-	var $search_fields_name = Array(
-		'Ticket ID' => '',
-		'Subject'=>'ticket_title',
-		);
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'crmid';
-	var $default_sort_order = 'DESC';
-
-	/**	Constructor which will set the column_fields in this object
-	 */
-	function HelpDesk() 
-	{
-		$this->log =LoggerManager::getLogger('helpdesk');
-		$this->log->debug("Entering HelpDesk() method ...");
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('HelpDesk');
-		$this->log->debug("Exiting HelpDesk method ...");
-	}
-
-
-	function save_module($module)
-	{
-		//Inserting into Ticket Comment Table
-		$this->insertIntoTicketCommentTable("vtiger_ticketcomments",'HelpDesk');
-
-		//Inserting into vtiger_seticketsrel table
-		
-		if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')
-		{
-			$this->insertIntoEntityTable('vtiger_seticketsrel', 'HelpDesk');
-		}
-		elseif($this->column_fields['parent_id']=='' && $insertion_mode=="edit")
-		{
-			$this->deleteRelation('vtiger_seticketsrel');
-		}
-
-		//Inserting into vtiger_attachments
-		$this->insertIntoAttachment($this->id,'HelpDesk');
-				
-	}	
-
-	/** Function to insert values in vtiger_ticketcomments  for the specified tablename and  module
-  	  * @param $table_name -- table name:: Type varchar
-  	  * @param $module -- module:: Type varchar
- 	 */	
-	function insertIntoTicketCommentTable($table_name, $module)
-	{
-		global $log;
-		$log->info("in insertIntoTicketCommentTable  ".$table_name."    module is  ".$module);
-        	global $adb;
-		global $current_user;
-
-        	$current_time = $adb->formatDate(date('YmdHis'));
-		if($this->column_fields['assigned_user_id'] != '')
-			$ownertype = 'user';
-		else
-			$ownertype = 'customer';
-
-		if($this->column_fields['comments'] != '')
-			$comment = $this->column_fields['comments'];
-		else
-			$comment = $_REQUEST['comments'];
-
-		if($comment != '')
-		{
-			$comment = addslashes($comment);
-			$sql = "insert into vtiger_ticketcomments values('',".$this->id.",'".$comment."','".$current_user->id."','".$ownertype."',".$current_time.")";	
-	        	$adb->query($sql);
-		}
-	}
-
-
-	/**
-	 *      This function is used to add the vtiger_attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database.
-	 *      @param int $id  - entity id to which the vtiger_files to be uploaded
-	 *      @param string $module  - the current module name
-	*/
-	function insertIntoAttachment($id,$module)
-	{
-		global $log, $adb;
-		$log->debug("Entering into insertIntoAttachment($id,$module) method.");
-		
-		$file_saved = false;
-
-		foreach($_FILES as $fileindex => $files)
-		{
-			if($files['name'] != '' && $files['size'] > 0)
-			{
-				$file_saved = $this->uploadAndSaveFile($id,$module,$files);
-			}
-		}
-
-		$log->debug("Exiting from insertIntoAttachment($id,$module) method.");
-	}
-	
-	
-	/**	Function used to get the sort order for HelpDesk listview
-	 *	@return string	$sorder	- first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['HELPDESK_SORT_ORDER'] if this session value is empty then default sort order will be returned. 
-	 */
-	function getSortOrder()
-	{
-		global $log;
-                $log->debug("Entering getSortOrder() method ...");	
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['HELPDESK_SORT_ORDER'] != '')?($_SESSION['HELPDESK_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder() method ...");
-		return $sorder;
-	}
-
-	/**	Function used to get the order by value for HelpDesk listview
-	 *	@return string	$order_by  - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['HELPDESK_ORDER_BY'] if this session value is empty then default order by will be returned. 
-	 */
-	function getOrderBy()
-	{
-		global $log;
-                $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['HELPDESK_ORDER_BY'] != '')?($_SESSION['HELPDESK_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-
-	/**     Function to form the query to get the list of activities
-         *      @param  int $id - ticket id
-	 *	@return array - return an array which will be returned from the function GetRelatedList
-        **/
-	function get_activities($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_activities(".$id.") method ...");
-		global $mod_strings;
-		global $app_strings;
-		require_once('modules/Calendar/Activity.php');
-		$focus = new Activity();
-
-		$button = '';
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=HelpDesk&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=HelpDesk&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_activity.*, vtiger_crmentity.crmid, vtiger_recurringevents.recurringtype, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus != 'Held')";
-		$log->debug("Exiting get_activities method ...");
-		
-		return GetRelatedList('HelpDesk','Calendar',$focus,$query,$button,$returnset);
-	}
-
-	/**     Function to get the Ticket History information as in array format
-	 *	@param int $ticketid - ticket id
-	 *	@return array - return an array with title and the ticket history informations in the following format
-							array(	
-								header=>array('0'=>'title'),
-								entries=>array('0'=>'info1','1'=>'info2',etc.,)
-							     )
-	 */
-	function get_ticket_history($ticketid)
-	{
-		global $log, $adb;
-		$log->debug("Entering into get_ticket_history($ticketid) method ...");
-
-		$query="select title,update_log from vtiger_troubletickets where ticketid=".$ticketid;
-		$result=$adb->query($query);
-		$update_log = $adb->query_result($result,0,"update_log");
-
-		$splitval = split('--//--',trim($update_log,'--//--'));
-
-		$header[] = $adb->query_result($result,0,"title");
-
-		$return_value = Array('header'=>$header,'entries'=>$splitval);
-
-		$log->debug("Exiting from get_ticket_history($ticketid) method ...");
-
-		return $return_value;
-	}
-
-	/**	Function to form the query to get the list of attachments and notes
-	 *	@param  int $id - ticket id
-         *      @return array - return an array which will be returned from the function getAttachmentsAndNotes
-	**/
-	function get_attachments($id)
-	{
-		global $log;
-		$log->debug("Entering get_attachments(".$id.") method ...");
-		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
-		vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
-		vtiger_seattachmentsrel.attachmentsid attachmentsid, vtiger_notes.notesid crmid,
-			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-		from vtiger_notes
-			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
-			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
-			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
-			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
-			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		where vtiger_crmentity.crmid=".$id;
-
-		$query .= ' union all ';
-
-		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
-		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
-		vtiger_attachments.attachmentsid attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-		from vtiger_attachments
-			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
-			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
-			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
-			left join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		where vtiger_crmentity.crmid=".$id;	
-		$log->debug("Exiting get_attachments method ...");
-		return getAttachmentsAndNotes('HelpDesk',$query,$id);
-	}
-
-	/**	Function to get the ticket comments as a array
-	 *	@param  int   $ticketid - ticketid
-	 *	@return array $output - array(	
-						[$i][comments]    => comments
-						[$i][owner]       => name of the user or customer who made the comment
-						[$i][createdtime] => the comment created time
-					     ) 
-				where $i = 0,1,..n which are all made for the ticket
-	**/
-	function get_ticket_comments_list($ticketid)
-	{
-		global $log;
-		$log->debug("Entering get_ticket_comments_list(".$ticketid.") method ...");
-		 $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid." order by createdtime DESC";
-		 $result = $this->db->query($sql);
-		 $noofrows = $this->db->num_rows($result);
-		 for($i=0;$i<$noofrows;$i++)
-		 {
-			 $ownerid = $this->db->query_result($result,$i,"ownerid");
-			 $ownertype = $this->db->query_result($result,$i,"ownertype");
-			 if($ownertype == 'user')
-				 $name = getUserName($ownerid);
-			 elseif($ownertype == 'customer')
-			 {
-				 $sql1 = 'select * from vtiger_portalinfo where id='.$ownerid;
-				 $name = $this->db->query_result($this->db->query($sql1),0,'user_name');
-			 }
-
-			 $output[$i]['comments'] = nl2br($this->db->query_result($result,$i,"comments"));
-			 $output[$i]['owner'] = $name;
-			 $output[$i]['createdtime'] = $this->db->query_result($result,$i,"createdtime");
-		 }
-		$log->debug("Exiting get_ticket_comments_list method ...");
-		 return $output;
-	 }
-		
-	/**	Function to form the query which will give the list of tickets based on customername and id ie., contactname and contactid
-	 *	@param  string $user_name - name of the customer ie., contact name
-	 *	@param  int    $id	 - contact id 
-	 * 	@return array  - return an array which will be returned from the function process_list_query
-	**/
-	function get_user_tickets_list($user_name,$id,$where='',$match='')
-	{
-		global $log;
-		$log->debug("Entering get_user_tickets_list(".$user_name.",".$id.",".$where.",".$match.") method ...");
-
-		$this->db->println("where ==> ".$where);
-
-		$query = "select vtiger_crmentity.crmid, vtiger_troubletickets.*, vtiger_crmentity.smownerid, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_products.productid, vtiger_products.productname, vtiger_ticketcf.* from vtiger_troubletickets inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_contactdetails on vtiger_troubletickets.parent_id=vtiger_contactdetails.contactid left join vtiger_products on vtiger_products.productid = vtiger_troubletickets.product_id left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id  where vtiger_crmentity.deleted=0 and vtiger_contactdetails.email='".$user_name."' and vtiger_troubletickets.parent_id = '".$id."'";
-
-		if(trim($where) != '')
-		{
-			if($match == 'all' || $match == '')
-			{
-				$join = " and ";
-			}
-			elseif($match == 'any')
-			{
-				$join = " or ";
-			}
-			$where = explode("&&&",$where);
-			$count = count($where);
-			$count --;
-			$where_conditions = "";
-			foreach($where as $key => $value)
-			{
-				$this->db->println('key : '.$key.'...........value : '.$value);
-				$val = explode(" = ",$value);
-				$this->db->println('val0 : '.$val[0].'...........val1 : '.$val[1]);
-				if($val[0] == 'vtiger_troubletickets.title')
-				{
-					$where_conditions .= $val[0]."  ".$val[1];
-					if($count != $key) 	$where_conditions .= $join;
-				}
-				elseif($val[1] != '' && $val[1] != 'Any')
-				{
-					$where_conditions .= $val[0]." = ".$val[1];
-					if($count != $key)	$where_conditions .= $join;
-				}
-			}
-			if($where_conditions != '')
-				$where_conditions = " and ( ".$where_conditions." ) ";
-
-			$query .= $where_conditions;
-			$this->db->println("where condition for customer portal tickets search : ".$where_conditions);
-		}
-
-		$query .= " order by vtiger_crmentity.crmid desc";
-		$log->debug("Exiting get_user_tickets_list method ...");
-		return $this->process_list_query($query);
-	}
-
-	/**	Function to process the list query and return the result with number of rows
-	 *	@param  string $query - query 
-	 *	@return array  $response - array(	list           => array(   
-											$i => array(key => val)   
-									       ),
-							row_count      => '',
-							next_offset    => '',
-							previous_offset	=>''		 
-						)
-		where $i=0,1,..n & key = ticketid, title, firstname, ..etc(range_fields) & val = value of the key from db retrieved row 
-	**/
-	function process_list_query($query)
-	{
-		global $log;
-		$log->debug("Entering process_list_query(".$query.") method ...");
-	  
-   		$result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
-		$list = Array();
-	        $rows_found =  $this->db->getRowCount($result);
-        	if($rows_found != 0)
-	        {
-			$ticket = Array();
-			for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
-			{
-		                foreach($this->range_fields as $columnName)
-                		{
-		                	if (isset($row[$columnName])) 
-					{
-			                	$ticket[$columnName] = $row[$columnName];
-                    			}
-		                       	else     
-				        {   
-		                        	$ticket[$columnName] = "";
-			                }   
-	     			}	
-    		                $list[] = $ticket;
-                	}
-        	}   
-
-		$response = Array();
-	        $response['list'] = $list;
-        	$response['row_count'] = $rows_found;
-	        $response['next_offset'] = $next_offset;
-        	$response['previous_offset'] = $previous_offset;
-
-		$log->debug("Exiting process_list_query method ...");
-	        return $response;
-	}
-
-	/**	Function to get the HelpDesk field labels in caps letters without space
-	 *	@return array $mergeflds - array(	key => val	)    where   key=0,1,2..n & val = ASSIGNEDTO,RELATEDTO, .,etc
-	**/
-	function getColumnNames_Hd()
-	{
-		global $log,$current_user;
-		$log->debug("Entering getColumnNames_Hd() method ...");
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-		{
-			$sql1 = "select fieldlabel from vtiger_field where tabid=13 and block <> 30 ";
-		}else
-		{
-			$profileList = getCurrentUserProfileList();
-			$sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=13 and vtiger_field.block <> 30 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-		}
-		$result = $this->db->query($sql1);
-		$numRows = $this->db->num_rows($result);
-		for($i=0; $i < $numRows;$i++)
-		{
-			$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
-			$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
-			$custom_fields[$i] = strtoupper($custom_fields[$i]);
-		}
-		$mergeflds = $custom_fields;
-		$log->debug("Exiting getColumnNames_Hd method ...");
-		return $mergeflds;
-	}
-
-	/**     Function to get the list of comments for the given ticket id
-	 *      @param  int  $ticketid - Ticket id
-	 *      @return list $list - return the list of comments and comment informations as a html output where as these comments and comments informations will be formed in div tag.
-	**/
-	function getCommentInformation($ticketid)
-	{
-		global $log;
-		$log->debug("Entering getCommentInformation(".$ticketid.") method ...");
-		global $adb;
-		global $mod_strings;
-		$sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
-		$result = $adb->query($sql);
-		$noofrows = $adb->num_rows($result);
-
-		if($noofrows == 0)
-		{
-			$log->debug("Exiting getCommentInformation method ...");
-			return '';
-		}
-
-		$list .= '<div style="overflow: auto;height:200px;width:100%;">';
-		for($i=0;$i<$noofrows;$i++)
-		{
-			if($adb->query_result($result,$i,'comments') != '')
-			{
-				//this div is to display the comment
-				$list .= '<div valign="top" style="width:99%;padding-top:10px;" class="dataField">';
-				$list .= make_clickable(nl2br($adb->query_result($result,$i,'comments')));
-
-				$list .= '</div>';
-
-				//this div is to display the author and time
-				$list .= '<div valign="top" style="width:99%;border-bottom:1px dotted #CCCCCC;padding-bottom:5px;" class="dataLabel"><font color=darkred>';
-				$list .= $mod_strings['LBL_AUTHOR'].' : ';
-
-				if($adb->query_result($result,$i,'ownertype') == 'user')
-					$list .= getUserName($adb->query_result($result,$i,'ownerid'));
-				else
-					$list .= $this->getCustomerName($ticketid);
-
-				$list .= ' on '.$adb->query_result($result,$i,'createdtime').' &nbsp;';
-
-				$list .= '</font></div>';
-			}
-		}
-		$list .= '</div>';
-
-		$log->debug("Exiting getCommentInformation method ...");
-		return $list;
-	}
-
-	/**     Function to get the Customer Name who has made comment to the ticket from the customer portal
-	 *      @param  int    $id   - Ticket id
-	 *      @return string $customername - The contact name
-	**/
-	function getCustomerName($id)
-	{
-		global $log;
-		$log->debug("Entering getCustomerName(".$id.") method ...");
-        	global $adb;
-	        $sql = "select * from vtiger_portalinfo inner join vtiger_troubletickets on vtiger_troubletickets.parent_id = vtiger_portalinfo.id where vtiger_troubletickets.ticketid=".$id;
-        	$result = $adb->query($sql);
-	        $customername = $adb->query_result($result,0,'user_name');
-		$log->debug("Exiting getCustomerName method ...");
-        	return $customername;
-	}
-	
-	/**	Function used to get the Activity History
-	 *	@param	int	$id - ticket id to which we want to display the activity history
-	 *	@return  array	- return an array which will be returned from the function getHistory
-	 */
-	function get_history($id)
-	{
-		global $log;
-		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, vtiger_activity.eventstatus, vtiger_activity.date_start, vtiger_activity.due_date,
-		vtiger_activity.activitytype, vtiger_troubletickets.ticketid, vtiger_troubletickets.title, vtiger_crmentity.modifiedtime,
-		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
-				from vtiger_activity
-				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid= vtiger_activity.activityid
-				inner join vtiger_troubletickets on vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
-				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
-				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
-				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
-				and vtiger_seactivityrel.crmid=".$id;
-		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-		$log->debug("Entering get_history method ...");
-		return getHistory('HelpDesk',$query,$id);
-	}
-
-	/** Function to get the update ticket history for the specified ticketid
-	  * @param $id -- $ticketid:: Type Integer 
-	 */	
-	function constructUpdateLog($focus, $mode, $assigned_group_name, $assigntype)
-	{
-		global $adb;
-		global $current_user;
-
-		if($mode != 'edit')//this will be updated when we create new ticket
-		{
-			$updatelog = " Ticket created. Assigned to ";
-
-			if($assigned_group_name != '' && $assigntype == 'T')
-			{
-				$updatelog .= " group ".$assigned_group_name;
-			}
-			elseif($focus->column_fields['assigned_user_id'] != '')
-			{
-				$updatelog .= " user ".getUserName($focus->column_fields['assigned_user_id']);
-			}
-			else
-			{
-				$updatelog .= " user ".getUserName($current_user->id);
-			}
-
-			$fldvalue = date("l dS F Y h:i:s A").' by '.$current_user->user_name;
-			$updatelog .= " -- ".$fldvalue."--//--";
-		}
-		else
-		{
-			$ticketid = $focus->id;
-
-			//First retrieve the existing information
-			$tktresult = $adb->query("select * from vtiger_troubletickets where ticketid='".$ticketid."'");
-			$crmresult = $adb->query("select * from vtiger_crmentity where crmid='".$ticketid."'");
-
-			$updatelog = $adb->query_result($tktresult,0,"update_log");
-
-			$old_user_id = $adb->query_result($crmresult,0,"smownerid");
-			$old_status = $adb->query_result($tktresult,0,"status");
-			$old_priority = $adb->query_result($tktresult,0,"priority");
-			$old_severity = $adb->query_result($tktresult,0,"severity");
-			$old_category = $adb->query_result($tktresult,0,"category");
-
-			//Assigned to change log
-			if($assigned_group_name != '' && $assigntype == 'T')
-			{
-				$group_info = getGroupName($ticketid,'HelpDesk');
-				$group_name = $group_info[0];
-				if($group_name != $assigned_group_name)
-					$updatelog .= ' Transferred to group '.$assigned_group_name.'\.';
-			}
-			elseif($focus->column_fields['assigned_user_id'] != $old_user_id)
-			{
-				$user_name = getUserName($focus->column_fields['assigned_user_id']);
-				$updatelog .= ' Transferred to user '.$user_name.'\.';
-			}
-			//Status change log
-			if($old_status != $focus->column_fields['ticketstatus'])
-			{
-				$updatelog .= ' Status Changed to '.$focus->column_fields['ticketstatus'].'\.';
-			}
-			//Priority change log
-			if($old_priority != $focus->column_fields['ticketpriorities'])
-			{
-				$updatelog .= ' Priority Changed to '.$focus->column_fields['ticketpriorities'].'\.';
-			}
-			//Severity change log
-			if($old_severity != $focus->column_fields['ticketseverities'])
-			{
-				$updatelog .= ' Severity Changed to '.$focus->column_fields['ticketseverities'].'\.';
-			}
-			//Category change log
-			if($old_category != $focus->column_fields['ticketcategories'])
-			{
-				$updatelog .= ' Category Changed to '.$focus->column_fields['ticketcategories'].'\.';
-			}
-
-			$updatelog .= ' -- '.date("l dS F Y h:i:s A").' by '.$current_user->user_name.'--//--';
-		}
-		return $updatelog;
-	}
-
-
-
-}
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of txhe License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+class HelpDesk extends CRMEntity {
+	var $log;
+	var $db;
+
+	var $tab_name = Array('vtiger_crmentity','vtiger_troubletickets','vtiger_ticketcf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_troubletickets'=>'ticketid','vtiger_seticketsrel'=>'ticketid','vtiger_ticketcf'=>'ticketid','vtiger_ticketcomments'=>'ticketid','vtiger_attachments'=>'attachmentsid');
+	var $column_fields = Array();
+
+	var $sortby_fields = Array('title','status','priority','crmid','firstname','smownerid');
+
+	var $list_fields = Array(
+					'Ticket ID'=>Array('crmentity'=>'crmid'),
+					'Subject'=>Array('troubletickets'=>'title'),	  			
+					'Related to'=>Array('troubletickets'=>'parent_id'),	  			
+					'Status'=>Array('troubletickets'=>'status'),
+					'Priority'=>Array('troubletickets'=>'priority'),
+					'Assigned To'=>Array('crmentity','smownerid')
+				);
+
+	var $list_fields_name = Array(
+					'Ticket ID'=>'',
+					'Subject'=>'ticket_title',	  			
+					'Related to'=>'parent_id',	  			
+					'Status'=>'ticketstatus',
+					'Priority'=>'ticketpriorities',
+					'Assigned To'=>'assigned_user_id'
+				     );
+
+	var $list_link_field= 'ticket_title';
+			
+	var $range_fields = Array(
+				        'ticketid',
+					'title',
+			        	'firstname',
+				        'lastname',
+			        	'parent_id',
+			        	'productid',
+			        	'productname',
+			        	'priority',
+			        	'severity',
+				        'status',
+			        	'category',
+					'description',
+					'solution',
+					'modifiedtime',
+					'createdtime'
+				);
+	var $search_fields = Array(
+		'Ticket ID' => Array('vtiger_crmentity'=>'crmid'),
+		'Title' => Array('vtiger_troubletickets'=>'title')
+		);
+	var $search_fields_name = Array(
+		'Ticket ID' => '',
+		'Title'=>'ticket_title',
+		);
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'crmid';
+	var $default_sort_order = 'DESC';
+
+	var $groupTable = Array('vtiger_ticketgrouprelation','ticketid');
+
+	/**	Constructor which will set the column_fields in this object
+	 */
+	function HelpDesk() 
+	{
+		$this->log =LoggerManager::getLogger('helpdesk');
+		$this->log->debug("Entering HelpDesk() method ...");
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('HelpDesk');
+		$this->log->debug("Exiting HelpDesk method ...");
+	}
+
+
+	function save_module($module)
+	{
+		//Inserting into Ticket Comment Table
+		$this->insertIntoTicketCommentTable("vtiger_ticketcomments",'HelpDesk');
+
+		//Inserting into vtiger_seticketsrel table
+		
+		if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')
+		{
+			$this->insertIntoEntityTable('vtiger_seticketsrel', 'HelpDesk');
+		}
+		elseif($this->column_fields['parent_id']=='' && $insertion_mode=="edit")
+		{
+			$this->deleteRelation('vtiger_seticketsrel');
+		}
+
+		//Inserting into vtiger_attachments
+		$this->insertIntoAttachment($this->id,'HelpDesk');
+				
+	}	
+
+	/** Function to insert values in vtiger_ticketcomments  for the specified tablename and  module
+  	  * @param $table_name -- table name:: Type varchar
+  	  * @param $module -- module:: Type varchar
+ 	 */	
+	function insertIntoTicketCommentTable($table_name, $module)
+	{
+		global $log;
+		$log->info("in insertIntoTicketCommentTable  ".$table_name."    module is  ".$module);
+        	global $adb;
+		global $current_user;
+
+        	$current_time = $adb->formatDate(date('YmdHis'));
+		if($this->column_fields['assigned_user_id'] != '')
+			$ownertype = 'user';
+		else
+			$ownertype = 'customer';
+
+		if($this->column_fields['comments'] != '')
+			$comment = $this->column_fields['comments'];
+		else
+			$comment = $_REQUEST['comments'];
+
+		if($comment != '')
+		{
+			$comment = addslashes($comment);
+			$sql = "insert into vtiger_ticketcomments values('',".$this->id.",'".$comment."','".$current_user->id."','".$ownertype."',".$current_time.")";	
+	        	$adb->query($sql);
+		}
+	}
+
+
+	/**
+	 *      This function is used to add the vtiger_attachments. This will call the function uploadAndSaveFile which will upload the attachment into the server and save that attachment information in the database.
+	 *      @param int $id  - entity id to which the vtiger_files to be uploaded
+	 *      @param string $module  - the current module name
+	*/
+	function insertIntoAttachment($id,$module)
+	{
+		global $log, $adb;
+		$log->debug("Entering into insertIntoAttachment($id,$module) method.");
+		
+		$file_saved = false;
+
+		foreach($_FILES as $fileindex => $files)
+		{
+			if($files['name'] != '' && $files['size'] > 0)
+			{
+				$file_saved = $this->uploadAndSaveFile($id,$module,$files);
+			}
+		}
+
+		$log->debug("Exiting from insertIntoAttachment($id,$module) method.");
+	}
+	
+	
+	/**	Function used to get the sort order for HelpDesk listview
+	 *	@return string	$sorder	- first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['HELPDESK_SORT_ORDER'] if this session value is empty then default sort order will be returned. 
+	 */
+	function getSortOrder()
+	{
+		global $log;
+                $log->debug("Entering getSortOrder() method ...");	
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['HELPDESK_SORT_ORDER'] != '')?($_SESSION['HELPDESK_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder() method ...");
+		return $sorder;
+	}
+
+	/**	Function used to get the order by value for HelpDesk listview
+	 *	@return string	$order_by  - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['HELPDESK_ORDER_BY'] if this session value is empty then default order by will be returned. 
+	 */
+	function getOrderBy()
+	{
+		global $log;
+                $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['HELPDESK_ORDER_BY'] != '')?($_SESSION['HELPDESK_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+
+	/**     Function to form the query to get the list of activities
+         *      @param  int $id - ticket id
+	 *	@return array - return an array which will be returned from the function GetRelatedList
+        **/
+	function get_activities($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_activities(".$id.") method ...");
+		global $mod_strings;
+		global $app_strings;
+		require_once('modules/Calendar/Activity.php');
+		$focus = new Activity();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=HelpDesk&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=HelpDesk&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_activity.*, vtiger_crmentity.crmid, vtiger_recurringevents.recurringtype, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') AND ( vtiger_activity.status is NULL OR vtiger_activity.status != 'Completed' ) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity.eventstatus != 'Held')";
+		$log->debug("Exiting get_activities method ...");
+		
+		return GetRelatedList('HelpDesk','Calendar',$focus,$query,$button,$returnset);
+	}
+
+	/**     Function to get the Ticket History information as in array format
+	 *	@param int $ticketid - ticket id
+	 *	@return array - return an array with title and the ticket history informations in the following format
+							array(	
+								header=>array('0'=>'title'),
+								entries=>array('0'=>'info1','1'=>'info2',etc.,)
+							     )
+	 */
+	function get_ticket_history($ticketid)
+	{
+		global $log, $adb;
+		$log->debug("Entering into get_ticket_history($ticketid) method ...");
+
+		$query="select title,update_log from vtiger_troubletickets where ticketid=".$ticketid;
+		$result=$adb->query($query);
+		$update_log = $adb->query_result($result,0,"update_log");
+
+		$splitval = split('--//--',trim($update_log,'--//--'));
+
+		$header[] = $adb->query_result($result,0,"title");
+
+		$return_value = Array('header'=>$header,'entries'=>$splitval);
+
+		$log->debug("Exiting from get_ticket_history($ticketid) method ...");
+
+		return $return_value;
+	}
+
+	/**	Function to form the query to get the list of attachments and notes
+	 *	@param  int $id - ticket id
+         *      @return array - return an array which will be returned from the function getAttachmentsAndNotes
+	**/
+	function get_attachments($id)
+	{
+		global $log;
+		$log->debug("Entering get_attachments(".$id.") method ...");
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;
+
+		$query .= ' union all ';
+
+		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			left join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		where vtiger_crmentity.crmid=".$id;	
+		$log->debug("Exiting get_attachments method ...");
+		return getAttachmentsAndNotes('HelpDesk',$query,$id);
+	}
+
+	/**	Function to get the ticket comments as a array
+	 *	@param  int   $ticketid - ticketid
+	 *	@return array $output - array(	
+						[$i][comments]    => comments
+						[$i][owner]       => name of the user or customer who made the comment
+						[$i][createdtime] => the comment created time
+					     ) 
+				where $i = 0,1,..n which are all made for the ticket
+	**/
+	function get_ticket_comments_list($ticketid)
+	{
+		global $log;
+		$log->debug("Entering get_ticket_comments_list(".$ticketid.") method ...");
+		 $sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid." order by createdtime DESC";
+		 $result = $this->db->query($sql);
+		 $noofrows = $this->db->num_rows($result);
+		 for($i=0;$i<$noofrows;$i++)
+		 {
+			 $ownerid = $this->db->query_result($result,$i,"ownerid");
+			 $ownertype = $this->db->query_result($result,$i,"ownertype");
+			 if($ownertype == 'user')
+				 $name = getUserName($ownerid);
+			 elseif($ownertype == 'customer')
+			 {
+				 $sql1 = 'select * from vtiger_portalinfo where id='.$ownerid;
+				 $name = $this->db->query_result($this->db->query($sql1),0,'user_name');
+			 }
+
+			 $output[$i]['comments'] = nl2br($this->db->query_result($result,$i,"comments"));
+			 $output[$i]['owner'] = $name;
+			 $output[$i]['createdtime'] = $this->db->query_result($result,$i,"createdtime");
+		 }
+		$log->debug("Exiting get_ticket_comments_list method ...");
+		 return $output;
+	 }
+		
+	/**	Function to form the query which will give the list of tickets based on customername and id ie., contactname and contactid
+	 *	@param  string $user_name - name of the customer ie., contact name
+	 *	@param  int    $id	 - contact id 
+	 * 	@return array  - return an array which will be returned from the function process_list_query
+	**/
+	function get_user_tickets_list($user_name,$id,$where='',$match='')
+	{
+		global $log;
+		$log->debug("Entering get_user_tickets_list(".$user_name.",".$id.",".$where.",".$match.") method ...");
+
+		$this->db->println("where ==> ".$where);
+
+		$query = "select vtiger_crmentity.crmid, vtiger_troubletickets.*, vtiger_crmentity.smownerid, vtiger_crmentity.createdtime, vtiger_crmentity.modifiedtime, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_products.productid, vtiger_products.productname, vtiger_ticketcf.* from vtiger_troubletickets inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid left join vtiger_contactdetails on vtiger_troubletickets.parent_id=vtiger_contactdetails.contactid left join vtiger_products on vtiger_products.productid = vtiger_troubletickets.product_id left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id  where vtiger_crmentity.deleted=0 and vtiger_contactdetails.email='".$user_name."' and vtiger_troubletickets.parent_id = '".$id."'";
+
+		if(trim($where) != '')
+		{
+			if($match == 'all' || $match == '')
+			{
+				$join = " and ";
+			}
+			elseif($match == 'any')
+			{
+				$join = " or ";
+			}
+			$where = explode("&&&",$where);
+			$count = count($where);
+			$count --;
+			$where_conditions = "";
+			foreach($where as $key => $value)
+			{
+				$this->db->println('key : '.$key.'...........value : '.$value);
+				$val = explode(" = ",$value);
+				$this->db->println('val0 : '.$val[0].'...........val1 : '.$val[1]);
+				if($val[0] == 'vtiger_troubletickets.title')
+				{
+					$where_conditions .= $val[0]."  ".$val[1];
+					if($count != $key) 	$where_conditions .= $join;
+				}
+				elseif($val[1] != '' && $val[1] != 'Any')
+				{
+					$where_conditions .= $val[0]." = ".$val[1];
+					if($count != $key)	$where_conditions .= $join;
+				}
+			}
+			if($where_conditions != '')
+				$where_conditions = " and ( ".$where_conditions." ) ";
+
+			$query .= $where_conditions;
+			$this->db->println("where condition for customer portal tickets search : ".$where_conditions);
+		}
+
+		$query .= " order by vtiger_crmentity.crmid desc";
+		$log->debug("Exiting get_user_tickets_list method ...");
+		return $this->process_list_query($query);
+	}
+
+	/**	Function to process the list query and return the result with number of rows
+	 *	@param  string $query - query 
+	 *	@return array  $response - array(	list           => array(   
+											$i => array(key => val)   
+									       ),
+							row_count      => '',
+							next_offset    => '',
+							previous_offset	=>''		 
+						)
+		where $i=0,1,..n & key = ticketid, title, firstname, ..etc(range_fields) & val = value of the key from db retrieved row 
+	**/
+	function process_list_query($query)
+	{
+		global $log;
+		$log->debug("Entering process_list_query(".$query.") method ...");
+	  
+   		$result =& $this->db->query($query,true,"Error retrieving $this->object_name list: ");
+		$list = Array();
+	        $rows_found =  $this->db->getRowCount($result);
+        	if($rows_found != 0)
+	        {
+			$ticket = Array();
+			for($index = 0 , $row = $this->db->fetchByAssoc($result, $index); $row && $index <$rows_found;$index++, $row = $this->db->fetchByAssoc($result, $index))
+			{
+		                foreach($this->range_fields as $columnName)
+                		{
+		                	if (isset($row[$columnName])) 
+					{
+			                	$ticket[$columnName] = $row[$columnName];
+                    			}
+		                       	else     
+				        {   
+		                        	$ticket[$columnName] = "";
+			                }   
+	     			}	
+    		                $list[] = $ticket;
+                	}
+        	}   
+
+		$response = Array();
+	        $response['list'] = $list;
+        	$response['row_count'] = $rows_found;
+	        $response['next_offset'] = $next_offset;
+        	$response['previous_offset'] = $previous_offset;
+
+		$log->debug("Exiting process_list_query method ...");
+	        return $response;
+	}
+
+	/**	Function to get the HelpDesk field labels in caps letters without space
+	 *	@return array $mergeflds - array(	key => val	)    where   key=0,1,2..n & val = ASSIGNEDTO,RELATEDTO, .,etc
+	**/
+	function getColumnNames_Hd()
+	{
+		global $log,$current_user;
+		$log->debug("Entering getColumnNames_Hd() method ...");
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+		{
+			$sql1 = "select fieldlabel from vtiger_field where tabid=13 and block <> 30 ";
+		}else
+		{
+			$profileList = getCurrentUserProfileList();
+			$sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=13 and vtiger_field.block <> 30 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+		}
+		$result = $this->db->query($sql1);
+		$numRows = $this->db->num_rows($result);
+		for($i=0; $i < $numRows;$i++)
+		{
+			$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
+			$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
+			$custom_fields[$i] = strtoupper($custom_fields[$i]);
+		}
+		$mergeflds = $custom_fields;
+		$log->debug("Exiting getColumnNames_Hd method ...");
+		return $mergeflds;
+	}
+
+	/**     Function to get the list of comments for the given ticket id
+	 *      @param  int  $ticketid - Ticket id
+	 *      @return list $list - return the list of comments and comment informations as a html output where as these comments and comments informations will be formed in div tag.
+	**/
+	function getCommentInformation($ticketid)
+	{
+		global $log;
+		$log->debug("Entering getCommentInformation(".$ticketid.") method ...");
+		global $adb;
+		global $mod_strings;
+		$sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
+		$result = $adb->query($sql);
+		$noofrows = $adb->num_rows($result);
+
+		if($noofrows == 0)
+		{
+			$log->debug("Exiting getCommentInformation method ...");
+			return '';
+		}
+
+		$list .= '<div style="overflow: auto;height:200px;width:100%;">';
+		for($i=0;$i<$noofrows;$i++)
+		{
+			if($adb->query_result($result,$i,'comments') != '')
+			{
+				//this div is to display the comment
+				$list .= '<div valign="top" style="width:99%;padding-top:10px;" class="dataField">';
+				$list .= make_clickable(nl2br($adb->query_result($result,$i,'comments')));
+
+				$list .= '</div>';
+
+				//this div is to display the author and time
+				$list .= '<div valign="top" style="width:99%;border-bottom:1px dotted #CCCCCC;padding-bottom:5px;" class="dataLabel"><font color=darkred>';
+				$list .= $mod_strings['LBL_AUTHOR'].' : ';
+
+				if($adb->query_result($result,$i,'ownertype') == 'user')
+					$list .= getUserName($adb->query_result($result,$i,'ownerid'));
+				else
+					$list .= $this->getCustomerName($ticketid);
+
+				$list .= ' on '.$adb->query_result($result,$i,'createdtime').' &nbsp;';
+
+				$list .= '</font></div>';
+			}
+		}
+		$list .= '</div>';
+
+		$log->debug("Exiting getCommentInformation method ...");
+		return $list;
+	}
+
+	/**     Function to get the Customer Name who has made comment to the ticket from the customer portal
+	 *      @param  int    $id   - Ticket id
+	 *      @return string $customername - The contact name
+	**/
+	function getCustomerName($id)
+	{
+		global $log;
+		$log->debug("Entering getCustomerName(".$id.") method ...");
+        	global $adb;
+	        $sql = "select * from vtiger_portalinfo inner join vtiger_troubletickets on vtiger_troubletickets.parent_id = vtiger_portalinfo.id where vtiger_troubletickets.ticketid=".$id;
+        	$result = $adb->query($sql);
+	        $customername = $adb->query_result($result,0,'user_name');
+		$log->debug("Exiting getCustomerName method ...");
+        	return $customername;
+	}
+	
+	/**	Function used to get the Activity History
+	 *	@param	int	$id - ticket id to which we want to display the activity history
+	 *	@return  array	- return an array which will be returned from the function getHistory
+	 */
+	function get_history($id)
+	{
+		global $log;
+		$log->debug("Entering get_history(".$id.") method ...");
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status, vtiger_activity.eventstatus, vtiger_activity.date_start, vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.time_end,vtiger_activity.activitytype, vtiger_troubletickets.ticketid, vtiger_troubletickets.title, vtiger_crmentity.modifiedtime,vtiger_crmentity.createdtime, vtiger_crmentity.description,
+case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+				from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid= vtiger_activity.activityid
+				inner join vtiger_troubletickets on vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+				and vtiger_seactivityrel.crmid=".$id;
+		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+		$log->debug("Entering get_history method ...");
+		return getHistory('HelpDesk',$query,$id);
+	}
+
+	/** Function to get the update ticket history for the specified ticketid
+	  * @param $id -- $ticketid:: Type Integer 
+	 */	
+	function constructUpdateLog($focus, $mode, $assigned_group_name, $assigntype)
+	{
+		global $adb;
+		global $current_user;
+
+		if($mode != 'edit')//this will be updated when we create new ticket
+		{
+			$updatelog = " Ticket created. Assigned to ";
+
+			if($assigned_group_name != '' && $assigntype == 'T')
+			{
+				$updatelog .= " group ".$assigned_group_name;
+			}
+			elseif($focus->column_fields['assigned_user_id'] != '')
+			{
+				$updatelog .= " user ".getUserName($focus->column_fields['assigned_user_id']);
+			}
+			else
+			{
+				$updatelog .= " user ".getUserName($current_user->id);
+			}
+
+			$fldvalue = date("l dS F Y h:i:s A").' by '.$current_user->user_name;
+			$updatelog .= " -- ".$fldvalue."--//--";
+		}
+		else
+		{
+			$ticketid = $focus->id;
+
+			//First retrieve the existing information
+			$tktresult = $adb->query("select * from vtiger_troubletickets where ticketid='".$ticketid."'");
+			$crmresult = $adb->query("select * from vtiger_crmentity where crmid='".$ticketid."'");
+
+			$updatelog = $adb->query_result($tktresult,0,"update_log");
+
+			$old_user_id = $adb->query_result($crmresult,0,"smownerid");
+			$old_status = $adb->query_result($tktresult,0,"status");
+			$old_priority = $adb->query_result($tktresult,0,"priority");
+			$old_severity = $adb->query_result($tktresult,0,"severity");
+			$old_category = $adb->query_result($tktresult,0,"category");
+
+			//Assigned to change log
+			if($assigned_group_name != '' && $assigntype == 'T')
+			{
+				$group_info = getGroupName($ticketid,'HelpDesk');
+				$group_name = $group_info[0];
+				if($group_name != $assigned_group_name)
+					$updatelog .= ' Transferred to group '.$assigned_group_name.'\.';
+			}
+			elseif($focus->column_fields['assigned_user_id'] != $old_user_id)
+			{
+				$user_name = getUserName($focus->column_fields['assigned_user_id']);
+				$updatelog .= ' Transferred to user '.$user_name.'\.';
+			}
+			//Status change log
+			if($old_status != $focus->column_fields['ticketstatus'])
+			{
+				$updatelog .= ' Status Changed to '.$focus->column_fields['ticketstatus'].'\.';
+			}
+			//Priority change log
+			if($old_priority != $focus->column_fields['ticketpriorities'])
+			{
+				$updatelog .= ' Priority Changed to '.$focus->column_fields['ticketpriorities'].'\.';
+			}
+			//Severity change log
+			if($old_severity != $focus->column_fields['ticketseverities'])
+			{
+				$updatelog .= ' Severity Changed to '.$focus->column_fields['ticketseverities'].'\.';
+			}
+			//Category change log
+			if($old_category != $focus->column_fields['ticketcategories'])
+			{
+				$updatelog .= ' Category Changed to '.$focus->column_fields['ticketcategories'].'\.';
+			}
+
+			$updatelog .= ' -- '.date("l dS F Y h:i:s A").' by '.$current_user->user_name.'--//--';
+		}
+		return $updatelog;
+	}
+
+
+
+}
+?>

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/ListTickets.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/ListTickets.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/ListTickets.php Mon Apr 16 12:27:44 2007
@@ -59,7 +59,7 @@
 		{
 			$value=array();
 			$ticketid = $adb->query_result($tktresult,$i,"ticketid");
-			$value[]= '<a href="index.php?action=DetailView&module=HelpDesk&record='.$adb->query_result($tktresult,$i,"ticketid").'">'.$adb->query_result($tktresult,$i,"title").'</a>';
+			$value[]= '<a href="index.php?action=DetailView&module=HelpDesk&record='.$adb->query_result($tktresult,$i,"ticketid").'">'.substr($adb->query_result($tktresult,$i,"title"),0,20).'...'.'</a>';
 			$value[]=$ticketid;
 
 			$parent_id = $adb->query_result($tktresult,$i,"parent_id");

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/ListView.php Mon Apr 16 12:27:44 2007
@@ -135,7 +135,7 @@
 	{
 		if( $adb->dbType == "pgsql")
  		    $list_query .= ' GROUP BY vtiger_users.user_name';
-		$list_query .= ' ORDER BY vtiger_users.user_name '.$sorder;
+		$list_query .= " ORDER BY case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end ".$sorder;
 	}
 	else
 	{
@@ -204,7 +204,6 @@
 }
 if(isPermitted("HelpDesk","Merge") == 'yes') 
 {
-	$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('HelpDesk')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 	$wordTemplateResult = fetchWordTemplateList("HelpDesk");
 	$tempCount = $adb->num_rows($wordTemplateResult);
 	$tempVal = $adb->fetch_array($wordTemplateResult);
@@ -213,7 +212,22 @@
 		$optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 		$tempVal = $adb->fetch_array($wordTemplateResult);
 	}
-	$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+	if($tempCount > 0)
+	{
+		$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+
+		$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('HelpDesk')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
+	}
+	else
+        {
+		global $current_user;
+                require("user_privileges/user_privileges_".$current_user->id.".php");
+                if($is_admin == true)
+                {
+			$smarty->assign("MERGEBUTTON",'<td><a href=index.php?module=Settings&action=upload&tempModule='.$currentModule.'>'. $app_strings["LBL_CREATE_MERGE_TEMPLATE"].'</td>');
+                }
+        }
+
 }
 //mass merge for word templates
 

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/Merge.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/Merge.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/Merge.php Mon Apr 16 12:27:44 2007
@@ -19,6 +19,7 @@
 }
 else if(document.all)
 {
+	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");
 	document.write("<OBJECT Name='vtigerCRM' codebase='modules/Settings/vtigerCRM.CAB#version=1,5,0,0' id='objMMPage' classid='clsid:0FC436C2-2E62-46EF-A3FB-E68E94705126' width=0 height=0></object>");
 }
 </script>

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/Save.php Mon Apr 16 12:27:44 2007
@@ -1,227 +1,215 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/vtigercrm/modules/HelpDesk/Save.php,v 1.8 2005/04/25 05:21:46 Mickie Exp $
- * Description:  Saves an Account record and then redirects the browser to the 
- * defined return URL.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('modules/HelpDesk/HelpDesk.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-
-$focus = new HelpDesk();
-
-setObjectValuesFromRequest(&$focus);
-
-global $adb;
-//Added to update the ticket history
-//Before save we have to construct the update log. 
-$mode = $_REQUEST['mode'];
-$fldvalue = $focus->constructUpdateLog(&$focus, $mode, $_REQUEST['assigned_group_name'], $_REQUEST['assigntype']);
-$fldvalue = from_html($adb->formatString('vtiger_troubletickets','update_log',$fldvalue),($mode == 'edit')?true:false);
-
-$focus->save("HelpDesk");
-
-//After save the record, we should update the log
-$adb->query("update vtiger_troubletickets set update_log=$fldvalue where ticketid=".$focus->id);
-
-//Added to retrieve the existing attachment of the ticket and save it for the new duplicated ticket
-if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '')
-{
-        $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
-        $result = $adb->query($sql);
-        if($adb->num_rows($result) != 0)
-	{
-                $attachmentid = $adb->query_result($result,0,'attachmentsid');
-		$filename = $adb->query_result($result,0,'name');
-		$filetype = $adb->query_result($result,0,'type');
-		$filepath = $adb->query_result($result,0,'path');
-
-		$new_attachmentid = $adb->getUniqueID("vtiger_crmentity");
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/vtigercrm/modules/HelpDesk/Save.php,v 1.8 2005/04/25 05:21:46 Mickie Exp $
+ * Description:  Saves an Account record and then redirects the browser to the 
+ * defined return URL.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('modules/HelpDesk/HelpDesk.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+
+$focus = new HelpDesk();
+
+setObjectValuesFromRequest(&$focus);
+global $adb,$mod_strings;
+//Added to update the ticket history
+//Before save we have to construct the update log. 
+$mode = $_REQUEST['mode'];
+if($mode == 'edit')
+{
+	$usr_qry = $adb->query("select * from vtiger_crmentity where crmid='".$focus->id."'");
+	$old_user_id = $adb->query_result($usr_qry,0,"smownerid");
+}
+$fldvalue = $focus->constructUpdateLog(&$focus, $mode, $_REQUEST['assigned_group_name'], $_REQUEST['assigntype']);
+$fldvalue = from_html($adb->formatString('vtiger_troubletickets','update_log',$fldvalue),($mode == 'edit')?true:false);
+
+$focus->save("HelpDesk");
+
+//After save the record, we should update the log
+$adb->query("update vtiger_troubletickets set update_log=$fldvalue where ticketid=".$focus->id);
+
+//Added to retrieve the existing attachment of the ticket and save it for the new duplicated ticket
+if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '')
+{
+        $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
+        $result = $adb->query($sql);
+        if($adb->num_rows($result) != 0)
+	{
+                $attachmentid = $adb->query_result($result,0,'attachmentsid');
+		$filename = $adb->query_result($result,0,'name');
+		$filetype = $adb->query_result($result,0,'type');
+		$filepath = $adb->query_result($result,0,'path');
+
+		$new_attachmentid = $adb->getUniqueID("vtiger_crmentity");
 		$date_var = $adb->formatDate(date('YmdHis'));
-
-		$upload_filepath = decideFilePath();
-
-		//Read the old file contents and write it as a new file with new attachment id
-		$handle = @fopen($upload_filepath.$new_attachmentid."_".$filename,'w');
-		fputs($handle, file_get_contents($filepath.$attachmentid."_".$filename));
-		fclose($handle);	
-
-		$adb->query("update vtiger_troubletickets set filename=\"$filename\" where ticketid=$focus->id");	
-		$adb->query("insert into vtiger_crmentity (crmid,setype,createdtime) values('".$new_attachmentid."','HelpDesk Attachment',".$date_var.")");
-
-		$adb->query("insert into vtiger_attachments values(".$new_attachmentid.",'".$filename."','','".$filetype."','".$upload_filepath."')");
-
-		$adb->query("insert into vtiger_seattachmentsrel values('".$focus->id."','".$new_attachmentid."')");
-	}
-}
-
-
-$return_id = $focus->id;
-
-if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab'];
-if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
-else $return_module = "HelpDesk";
-if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
-else $return_action = "DetailView";
-if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
-
-if($_REQUEST['mode'] == 'edit')
-	$reply = 'Re : ';
-else
-	$reply = '';
-
-$subject = '[ Ticket ID : '.$focus->id.' ] '.$reply.$_REQUEST['ticket_title'];
-$bodysubject = ' Ticket ID : '.$focus->id.'<br> Subject : '.$_REQUEST['ticket_title'];
-
-$emailoptout = 0;
-
-//To get the emailoptout vtiger_field value and then decide whether send mail about the tickets or not
-if($focus->column_fields['parent_id'] != '')
-{
-	$parent_module = getSalesEntityType($focus->column_fields['parent_id']);
-	if($parent_module == 'Contacts')
-	{
-		$result = $adb->query("select * from vtiger_contactdetails where contactid=".$focus->column_fields['parent_id']);
-		$emailoptout = $adb->query_result($result,0,'emailoptout');
-		$contactname = $adb->query_result($result,0,'firstname').' '.$adb->query_result($result,0,'lastname');
-		$parentname = $contactname;
-		$contact_mailid = $adb->query_result($result,0,'email');
-	}
-	if($parent_module == 'Accounts')
-	{
-		$result = $adb->query("select * from vtiger_account where accountid=".$focus->column_fields['parent_id']);
-		$emailoptout = $adb->query_result($result,0,'emailoptout');
-		$parentname = $adb->query_result($result,0,'accountname');
-	}
-}
-
-//Get the status of the vtiger_portal user. if the customer is active then send the vtiger_portal link in the mail
-if($contact_mailid != '')
-{
-	$sql = "select * from vtiger_portalinfo where user_name='".$contact_mailid."'";
-	$isactive = $adb->query_result($adb->query($sql),0,'isactive');
-}
-if($isactive == 1)
-{
-	$bodydetails = "Dear ".$contactname.",<br><br>";
-	$bodydetails .= 'There is a reply to <b>'.$_REQUEST['ticket_title'].'</b> in the "Customer Portal" at VTiger.';
-	$bodydetails .= "You can use the following link to view the replies made:<br>";
-
-	$bodydetails .= "<a href='".$PORTAL_URL."/general.php?action=UserTickets&ticketid=".$focus->id."&fun=detail'>Ticket Details</a>";
-	$bodydetails .= "<br><br>Thanks,<br><br> Vtiger Support Team ";
-
-	$email_body = $bodysubject.'<br><br>'.$bodydetails;
-}
-else
-{
-	$desc = 'Ticket ID : '.$focus->id.'<br> Ticket Title : '.$reply.$_REQUEST['ticket_title'];
-	$desc .= "<br><br>Dear ".$parentname.",<br><br>The Ticket is replied and the details are : <br>";
-	$desc .= "<br> Status : ".$focus->column_fields['ticketstatus'];
-	$desc .= "<br> Category : ".$focus->column_fields['ticketcategories'];
-	$desc .= "<br> Severity : ".$focus->column_fields['ticketseverities'];
-	$desc .= "<br> Priority : ".$focus->column_fields['ticketpriorities'];
-	$desc .= '<br><br>Description : <br>'.$focus->column_fields['description'];
-	$desc .= '<br><br>Solution : <br>'.$focus->column_fields['solution'];
-	$desc .= getTicketComments($focus->id);
-
-	$desc .= '<br><br><br>';
-	$desc .= '<br><br><br>';
-	$desc .= '<br><br><br>';
-	$desc .= '<br>Regards, HelpDesk Team<br>';
-	$email_body = $desc;
-}
-$_REQUEST['return_id'] = $return_id;
-
-if($_REQUEST['product_id'] != '' && $focus->id != '' && $_REQUEST['mode'] != 'edit')
-{
-        $sql = 'insert into vtiger_seticketsrel values('.$_REQUEST['product_id'].' , '.$focus->id.')';
-        $adb->query($sql);
-
-	if($_REQUEST['return_module'] == 'Products')
-	        $return_id = $_REQUEST['product_id'];
-}
-
-//send mail to the assigned to user and the parent to whom this ticket is assigned
-require_once('modules/Emails/mail.php');
-$user_emailid = getUserEmailId('id',$focus->column_fields['assigned_user_id']);
-if($user_emailid != '')
-{
-	$mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
-	$mail_status_str = $user_emailid."=".$mail_status."&&&";
-}
-else
-{
-	$mail_status_str = "'".$to_email."'=0&&&";
-}
-//added condition to check the emailoptout(this is for contacts and vtiger_accounts.)
-if($emailoptout == 0)
-{
-	//send mail to parent
-	if($_REQUEST['parent_id'] != '' && $_REQUEST['parent_type'] != '')
-        {
-                $parentmodule = $_REQUEST['parent_type'];
-                $parentid = $_REQUEST['parent_id'];
-
-		$parent_email = getParentMailId($parentmodule,$parentid);	
-		$mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
-		$mail_status_str .= $parent_email."=".$mail_status."&&&";
-        }
-}
-else
-{
-	$adb->println("'".$parentname."' is not want to get the email about the ticket details as emailoptout is selected");
-}
-
-$mail_error_status = getMailErrorString($mail_status_str);
-
-//code added for returning back to the current view after edit from list view
-if($_REQUEST['return_viewname'] == '') $return_viewname='0';
-if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
-header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&$mail_error_status&viewname=$return_viewname");
-
-/**	Function to get all the comments for a troubleticket
-  *	@param int $ticketid -- troubleticket id
-  *	return all the comments as a sequencial string which are related to this ticket
-**/
-function getTicketComments($ticketid)
-{
-	global $log;
-	$log->debug("Entering getTicketComments(".$ticketid.") method ...");
-	global $adb;
-
-	$commentlist = '';
-	$sql = "select * from vtiger_ticketcomments where ticketid=".$ticketid;
-	$result = $adb->query($sql);
-	for($i=0;$i<$adb->num_rows($result);$i++)
-	{
-		$comment = $adb->query_result($result,$i,'comments');
-		if($comment != '')
-		{
-			$commentlist .= '<br><br>'.$comment;
-		}
-	}
-	if($commentlist != '')
-		$commentlist = '<br><br> The comments are : '.$commentlist;
-
-	$log->debug("Exiting getTicketComments method ...");
-	return $commentlist;
-}
-
-?>
+
+		$upload_filepath = decideFilePath();
+
+		//Read the old file contents and write it as a new file with new attachment id
+		$handle = @fopen($upload_filepath.$new_attachmentid."_".$filename,'w');
+		fputs($handle, file_get_contents($filepath.$attachmentid."_".$filename));
+		fclose($handle);	
+
+		$adb->query("update vtiger_troubletickets set filename=\"$filename\" where ticketid=$focus->id");	
+		$adb->query("insert into vtiger_crmentity (crmid,setype,createdtime) values('".$new_attachmentid."','HelpDesk Attachment',".$date_var.")");
+
+		$adb->query("insert into vtiger_attachments values(".$new_attachmentid.",'".$filename."','','".$filetype."','".$upload_filepath."')");
+
+		$adb->query("insert into vtiger_seattachmentsrel values('".$focus->id."','".$new_attachmentid."')");
+	}
+}
+
+
+$return_id = $focus->id;
+
+if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab'];
+if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
+else $return_module = "HelpDesk";
+if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
+else $return_action = "DetailView";
+if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
+
+if($_REQUEST['mode'] == 'edit')
+	$reply = 'Re : ';
+else
+	$reply = '';
+
+$subject = '[ '.$mod_strings['LBL_TICKET_ID'].' : '.$focus->id.' ] '.$reply.$_REQUEST['ticket_title'];
+$bodysubject = $mod_strings['LBL_TICKET_ID'].' : '.$focus->id.'<br> '.$mod_strings['LBL_SUBJECT'].$_REQUEST['ticket_title'];
+
+$emailoptout = 0;
+
+//To get the emailoptout vtiger_field value and then decide whether send mail about the tickets or not
+if($focus->column_fields['parent_id'] != '')
+{
+	$parent_module = getSalesEntityType($focus->column_fields['parent_id']);
+	if($parent_module == 'Contacts')
+	{
+		$result = $adb->query("select * from vtiger_contactdetails where contactid=".$focus->column_fields['parent_id']);
+		$emailoptout = $adb->query_result($result,0,'emailoptout');
+		$contactname = $adb->query_result($result,0,'firstname').' '.$adb->query_result($result,0,'lastname');
+		$parentname = $contactname;
+		$contact_mailid = $adb->query_result($result,0,'email');
+	}
+	if($parent_module == 'Accounts')
+	{
+		$result = $adb->query("select * from vtiger_account where accountid=".$focus->column_fields['parent_id']);
+		$emailoptout = $adb->query_result($result,0,'emailoptout');
+		$parentname = $adb->query_result($result,0,'accountname');
+	}
+}
+
+//Get the status of the vtiger_portal user. if the customer is active then send the vtiger_portal link in the mail
+if($contact_mailid != '')
+{
+	$sql = "select * from vtiger_portalinfo where user_name='".$contact_mailid."'";
+	$isactive = $adb->query_result($adb->query($sql),0,'isactive');
+}
+if($isactive == 1)
+{
+	$url = "<a href='".$PORTAL_URL."/index.php?module=Tickets&action=index&ticketid=".$focus->id."&fun=detail'>".$mod_strings['LBL_TICKET_DETAILS']."</a>";
+	$email_body = $bodysubject.'<br><br>'.getPortalInfo_Ticket($focus->id,$_REQUEST['ticket_title'],$contactname,$url,$_REQUEST['mode']);
+}
+else
+{
+	$data['sub']=$_REQUEST['ticket_title'];
+	$data['parent_name']=$parentname;
+	$data['status']=$focus->column_fields['ticketstatus'];
+	$data['category']=$focus->column_fields['ticketcategories'];
+	$data['severity'] = $focus->column_fields['ticketseverities'];
+	$data['priority']=$focus->column_fields['ticketpriorities'];
+	$data['description']=$focus->column_fields['description'];
+	$data['solution'] = $focus->column_fields['solution'];
+	$data['mode']= $_REQUEST['mode'];
+	$email_body = getTicketDetails($focus->id,$data);
+}
+$_REQUEST['return_id'] = $return_id;
+
+if($_REQUEST['product_id'] != '' && $focus->id != '' && $_REQUEST['mode'] != 'edit')
+{
+        $sql = 'insert into vtiger_seticketsrel values('.$_REQUEST['product_id'].' , '.$focus->id.')';
+        $adb->query($sql);
+
+	if($_REQUEST['return_module'] == 'Products')
+	        $return_id = $_REQUEST['product_id'];
+}
+
+//send mail to the assigned to user and the parent to whom this ticket is assigned
+require_once('modules/Emails/mail.php');
+$user_emailid = getUserEmailId('id',$focus->column_fields['assigned_user_id']);
+
+if($user_emailid != '')
+{
+	if($_REQUEST['mode'] != 'edit')
+	{
+		$mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+	}
+	else
+	{
+		if(($focus->column_fields['ticketstatus'] == $mod_strings["Closed"]) || ($focus->column_fields['comments'] != '') || ($_REQUEST['helpdesk_solution'] != $_REQUEST['solution']) || ($focus->column_fields['assigned_user_id'] != $old_user_id))	
+		{
+			$mail_status = send_mail('HelpDesk',$user_emailid,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+		}
+
+	}
+
+	$mail_status_str = $user_emailid."=".$mail_status."&&&";
+}
+else
+{
+	$mail_status_str = "'".$to_email."'=0&&&";
+}
+//added condition to check the emailoptout(this is for contacts and vtiger_accounts.)
+if($emailoptout == 0)
+{
+	//send mail to parent
+	if($_REQUEST['parent_id'] != '' && $_REQUEST['parent_type'] != '')
+        {
+                $parentmodule = $_REQUEST['parent_type'];
+                $parentid = $_REQUEST['parent_id'];
+
+		$parent_email = getParentMailId($parentmodule,$parentid);
+		if($_REQUEST['mode'] != 'edit')
+        	{	
+		$mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+		}
+	        else
+        	{
+			if(( $focus->column_fields['ticketstatus']== $mod_strings["Closed"]) || ($focus->column_fields['comments'] != '' ) || ($_REQUEST['helpdesk_solution'] != $_REQUEST['solution']))
+			{
+				$mail_status = send_mail('HelpDesk',$parent_email,$HELPDESK_SUPPORT_NAME,$HELPDESK_SUPPORT_EMAIL_ID,$subject,$email_body);
+			}
+		}
+		$mail_status_str .= $parent_email."=".$mail_status."&&&";
+        }
+}
+else
+{
+	$adb->println("'".$parentname."' is not want to get the email about the ticket details as emailoptout is selected");
+}
+
+$mail_error_status = getMailErrorString($mail_status_str);
+
+//code added for returning back to the current view after edit from list view
+if($_REQUEST['return_viewname'] == '') $return_viewname='0';
+if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
+header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&$mail_error_status&viewname=$return_viewname");
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/HelpDesk/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/HelpDesk/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/HelpDesk/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -36,7 +36,6 @@
 'Accounts'=>'Account',
 'Contacts'=>'Contact',
 'Opportunities'=>'Opportunity',
-'LBL_TICKET_INFORMATION'=>'Ticket Information',
 'LBL_CUSTOM_INFORMATION'=>'Custom Information',
 'LBL_DESCRIPTION_INFORMATION'=>'Description Information',
 
@@ -57,7 +56,6 @@
 'LBL_PRIORITY'=>'Priority',
 'LBL_CATEGORY'=>'Category',
 
-'LBL_QUESTION'=>'Question',
 'LBL_ANSWER'=>'Answer',
 'LBL_COMMENTS'=>'Comments',
 
@@ -83,14 +81,6 @@
 'LBL_SELECT_TICKET'=>'Select Ticket',
 'LBL_CHANGE_OWNER'=>'Change Owner',
 'LBL_CHANGE_STATUS'=>'Change Status',
-
-
-
-
-
-
-
-
 'LBL_TICKET_TITLE'=>'Title',
 'LBL_TICKET_DESCRIPTION'=>'Description',
 'LBL_TICKET_CATEGORY'=>'Category',
@@ -181,6 +171,23 @@
 'Wait For Response'=>'Wait For Response',
 'Closed'=>'Closed',
 
+//added to support i18n in ticket mails
+'Hi' => 'Hi',
+'Dear'=> 'Dear',
+'LBL_PORTAL_BODY_MAILINFO'=> 'The Ticket is',
+'LBL_DETAIL' => 'the details are :',
+'LBL_REGARDS'=> 'Regards',
+'LBL_TEAM'=> 'HelpDesk Team',
+'LBL_TICKET_DETAILS' => 'Ticket Details',
+'LBL_SUBJECT' => 'Subject : ',
+'created' => 'created',
+'replied' => 'replied',
+'reply'=>'There is a reply to',
+'customer_portal' => 'in the "Customer Portal" at VTiger.',
+'link' => 'You can use the following link to view the replies made:',
+'Thanks' => 'Thanks',
+'Support_team' => 'Vtiger Support Team',
+
 );
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Home/UnifiedSearch.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Home/UnifiedSearch.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Home/UnifiedSearch.php Mon Apr 16 12:27:44 2007
@@ -1,288 +1,294 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Home/UnifiedSearch.php,v 1.4 2005/02/21 07:02:49 jack Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('include/logging.php');
-require_once('modules/Home/language/en_us.lang.php');
-require_once('include/database/PearDatabase.php');
-require_once('modules/CustomView/CustomView.php');
-
-require_once('Smarty_setup.php');
-global $mod_strings;
-
-$total_record_count = 0;
-
-$query_string = trim($_REQUEST['query_string']);
-if(isset($query_string) && $query_string != '')//preg_match("/[\w]/", $_REQUEST['query_string'])) 
-{
-
-	//module => object
-	$object_array = getSearchModules();
-	foreach($object_array as $curr_module=>$curr_object)
-	{
-		require_once("modules/$curr_module/$curr_object.php");
-	}
-
-	global $adb;
-	global $current_user;
-	global $theme;
-	$theme_path="themes/".$theme."/";
-	$image_path=$theme_path."images/";
-
-	$search_val = $query_string;
-	$search_module = $_REQUEST['search_module'];
-
-	getSearchModulesComboList($search_module);
-
-	foreach($object_array as $module => $object_name)
-	{
-		if(isPermitted($module,"index") == "yes")
-		{
-			$focus = new $object_name();
-
-			$smarty = new vtigerCRM_Smarty;
-
-			require_once("modules/$module/language/en_us.lang.php");
-			global $mod_strings;
-			global $app_strings;
-
-			$smarty->assign("MOD", $mod_strings);
-			$smarty->assign("APP", $app_strings);
-			$smarty->assign("IMAGE_PATH",$image_path);
-			$smarty->assign("MODULE",$module);
-			$smarty->assign("SEARCH_MODULE",$_REQUEST['search_module']);
-			$smarty->assign("SINGLE_MOD",$module);
-
-	
-			$listquery = getListQuery($module);
-			$oCustomView = '';
-
-			$oCustomView = new CustomView($module);
-		
-			if($search_module != '')//This is for Tag search
-			{
-		
-				$where = getTagWhere($search_val,$current_user->id);
-				$search_msg =  $app_strings['LBL_TAG_SEARCH'];
-				$search_msg .=	"<b>".$search_val."</b>";
-			}
-			else			//This is for Global search
-			{
-				$where = getUnifiedWhere($listquery,$module,$search_val);
-				$search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR'];
-				$search_msg .=	"<b>".$search_val."</b>";
-			}
-
-			if($where != '')
-				$listquery .= ' and ('.$where.')';
-		
-			$list_result = $adb->query($listquery);
-			$noofrows = $adb->num_rows($list_result);
-
-			if($noofrows >= 1)
-				$list_max_entries_per_page = $noofrows;
-			//Here we can change the max list entries per page per module
-			$navigation_array = getNavigationValues(1, $noofrows, $list_max_entries_per_page);
-
-			$listview_header = getListViewHeader($focus,$module,"","","","global",$oCustomView);
-			$listview_entries = getListViewEntries($focus,$module,$list_result,$navigation_array,"","","","",$oCustomView);
-
-			//Do not display the Header if there are no entires in listview_entries
-			if(count($listview_entries) > 0)
-			{
-				$display_header = 1;
-			}
-			else
-			{
-				$display_header = 0;
-			}
-		
-			$smarty->assign("LISTHEADER", $listview_header);
-			$smarty->assign("LISTENTITY", $listview_entries);
-			$smarty->assign("DISPLAYHEADER", $display_header);
-			$smarty->assign("HEADERCOUNT", count($listview_header));
-
-			$total_record_count = $total_record_count + $noofrows;
-
-			$smarty->assign("SEARCH_CRITERIA","( $noofrows )".$search_msg);
-			$smarty->assign("MODULES_LIST", $object_array);
-
-			$smarty->display("GlobalListView.tpl");
-			unset($_SESSION['lvs'][$module]);
-		}
-	}
-
-	//Added to display the Total record count
-?>
-	<script>
-document.getElementById("global_search_total_count").innerHTML = " <? echo $app_strings['LBL_TOTAL_RECORDS_FOUND'] ?><b><?php echo $total_record_count; ?></b>";
-	</script>
-<?php
-
-}
-else {
-	echo "<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>".$mod_strings['ERR_ONE_CHAR']."</em>";
-}
-
-/**	Function to get the where condition for a module based on the field table entries
-  *	@param  string $listquery  -- ListView query for the module 
-  *	@param  string $module     -- module name
-  *	@param  string $search_val -- entered search string value
-  *	@return string $where      -- where condition for the module based on field table entries
-  */
-function getUnifiedWhere($listquery,$module,$search_val)
-{
-	global $adb;
-
-	$query = "SELECT columnname, tablename FROM vtiger_field WHERE tabid = ".getTabid($module);
-	$result = $adb->query($query);
-	$noofrows = $adb->num_rows($result);
-
-	$where = '';
-	for($i=0;$i<$noofrows;$i++)
-	{
-		$columnname = $adb->query_result($result,$i,'columnname');
-		$tablename = $adb->query_result($result,$i,'tablename');
-
-		//Before form the where condition, check whether the table for the field has been added in the listview query
-		if(strstr($listquery,$tablename))
-		{
-			if($where != '')
-				$where .= " OR ";
-			$where .= $tablename.".".$columnname." LIKE ".$adb->quote("%$search_val%");
-		}
-	}
-
-	return $where;
-}
-
-/**	Function to get the Tags where condition
-  *	@param  string $search_val -- entered search string value
-  *	@param  string $current_user_id     -- current user id
-  *	@return string $where      -- where condition with the list of crmids, will like vtiger_crmentity.crmid in (1,3,4,etc.,)
-  */
-function getTagWhere($search_val,$current_user_id)
-{
-	require_once('include/freetag/freetag.class.php');
-
-	$freetag_obj = new freetag();
-
-	$crmid_array = $freetag_obj->get_objects_with_tag_all($search_val,$current_user_id);
-
-	$where = '';
-	if(count($crmid_array) > 0)
-	{
-		$where = " vtiger_crmentity.crmid IN (";
-		foreach($crmid_array as $index => $crmid)
-		{
-			$where .= $crmid.',';
-		}
-		$where = trim($where,',').')';
-	}
-
-	return $where;
-}
-
-
-/**	Function to get the the List of Searchable Modules as a combo list which will be displayed in right corner under the Header
-  *	@param  string $search_module -- search module, this module result will be shown defaultly 
-  */
-function getSearchModulesComboList($search_module)
-{
-	global $object_array;
-	global $app_strings;
-	global $mod_strings;
-	
-	?>
-		<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
-		<script>
-		function displayModuleList(selectmodule_view)
-		{
-			<?php
-			foreach($object_array as $module => $object_name)
-			{
-				?>
-				mod = "global_list_"+"<?php echo $module; ?>";
-				if(selectmodule_view.options[selectmodule_view.options.selectedIndex].value == "All")
-					show(mod);
-				else
-					hide(mod);
-				<?php
-			}
-			?>
-			
-			if(selectmodule_view.options[selectmodule_view.options.selectedIndex].value != "All")
-			{
-				selectedmodule="global_list_"+selectmodule_view.options[selectmodule_view.options.selectedIndex].value;
-				show(selectedmodule);
-			}
-		}
-		</script>
-		 <table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
-		     <tr>
-		        <td colspan="3" id="global_search_total_count" style="padding-left:30px">&nbsp;</td>
-		<td nowrap align="right"><? echo $app_strings['LBL_SHOW_RESULTS'] ?>&nbsp;
-		                <select id="global_search_module" name="global_search_module" onChange="displayModuleList(this);">
-			<option value="All"><? echo $app_strings['COMBO_ALL'] ?></option>
-						<?php
-						foreach($object_array as $module => $object_name)
-						{
-							$selected = '';
-							if($search_module != '' && $module == $search_module)
-								$selected = 'selected';
-							if($search_module == '' && $module == 'All')
-								$selected = 'selected';
-							?>
-							<option value="<?php echo $module; ?>" <?php echo $selected; ?> ><?php echo $app_strings[$module]; ?></option>
-							<?php
-						}
-						?>
-		     		</select>
-		        </td>
-		     </tr>
-		</table>
-	<?php
-}
-
-/*To get the modules allowed for global search this function returns all the 
- * modules which supports global search as an array in the following structure 
- * array($module_name1=>$object_name1,$module_name2=>$object_name2,$module_name3=>$object_name3,$module_name4=>$object_name4,-----);
- */
- function getSearchModules()
- {
-	 global $adb;
-	 $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)';
-	$result = $adb->query($sql);
-	while($module_result = $adb->fetch_array($result))
-	{
-		$modulename = $module_result['name'];
-		if($modulename != 'Calendar')
-		{
-			$return_arr[$modulename] = $modulename;
-		}else
-		{
-			$return_arr[$modulename] = 'Activity';
-		}
-	}
-	return $return_arr;
- }
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Home/UnifiedSearch.php,v 1.4 2005/02/21 07:02:49 jack Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('include/logging.php');
+require_once('modules/Home/language/en_us.lang.php');
+require_once('include/database/PearDatabase.php');
+require_once('modules/CustomView/CustomView.php');
+
+require_once('Smarty_setup.php');
+global $mod_strings;
+
+$total_record_count = 0;
+
+$query_string = trim($_REQUEST['query_string']);
+if(isset($query_string) && $query_string != '')//preg_match("/[\w]/", $_REQUEST['query_string'])) 
+{
+
+	//module => object
+	$object_array = getSearchModules();
+	foreach($object_array as $curr_module=>$curr_object)
+	{
+		require_once("modules/$curr_module/$curr_object.php");
+	}
+
+	global $adb;
+	global $current_user;
+	global $theme;
+	$theme_path="themes/".$theme."/";
+	$image_path=$theme_path."images/";
+
+	$search_val = $query_string;
+	$search_module = $_REQUEST['search_module'];
+
+	getSearchModulesComboList($search_module);
+
+	foreach($object_array as $module => $object_name)
+	{
+		if(isPermitted($module,"index") == "yes")
+		{
+			$focus = new $object_name();
+
+			$smarty = new vtigerCRM_Smarty;
+
+			require_once("modules/$module/language/en_us.lang.php");
+			global $mod_strings;
+			global $app_strings;
+
+			$smarty->assign("MOD", $mod_strings);
+			$smarty->assign("APP", $app_strings);
+			$smarty->assign("IMAGE_PATH",$image_path);
+			$smarty->assign("MODULE",$module);
+			$smarty->assign("SEARCH_MODULE",$_REQUEST['search_module']);
+			$smarty->assign("SINGLE_MOD",$module);
+
+	
+			$listquery = getListQuery($module);
+			$oCustomView = '';
+
+			$oCustomView = new CustomView($module);
+			$viewid = $oCustomView->getViewId($module);
+                        $listquery = $oCustomView->getModifiedCvListQuery($viewid,$listquery,$module);
+                        if ($module == "Calendar"){
+                                if (!isset($oCustomView->list_fields['Close'])) $oCustomView->list_fields['Close']=array ( 'activity' => 'status' );
+                                if (!isset($oCustomView->list_fields_name['Close'])) $oCustomView->list_fields_name['Close']='status';
+                        }
+
+			if($search_module != '')//This is for Tag search
+			{
+		
+				$where = getTagWhere($search_val,$current_user->id);
+				$search_msg =  $app_strings['LBL_TAG_SEARCH'];
+				$search_msg .=	"<b>".$search_val."</b>";
+			}
+			else			//This is for Global search
+			{
+				$where = getUnifiedWhere($listquery,$module,$search_val);
+				$search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR'];
+				$search_msg .=	"<b>".$search_val."</b>";
+			}
+
+			if($where != '')
+				$listquery .= ' and ('.$where.')';
+			
+			$list_result = $adb->query($listquery);
+			$noofrows = $adb->num_rows($list_result);
+
+			if($noofrows >= 1)
+				$list_max_entries_per_page = $noofrows;
+			//Here we can change the max list entries per page per module
+			$navigation_array = getNavigationValues(1, $noofrows, $list_max_entries_per_page);
+
+			$listview_header = getListViewHeader($focus,$module,"","","","global",$oCustomView);
+			$listview_entries = getListViewEntries($focus,$module,$list_result,$navigation_array,"","","","",$oCustomView);
+
+			//Do not display the Header if there are no entires in listview_entries
+			if(count($listview_entries) > 0)
+			{
+				$display_header = 1;
+			}
+			else
+			{
+				$display_header = 0;
+			}
+		
+			$smarty->assign("LISTHEADER", $listview_header);
+			$smarty->assign("LISTENTITY", $listview_entries);
+			$smarty->assign("DISPLAYHEADER", $display_header);
+			$smarty->assign("HEADERCOUNT", count($listview_header));
+
+			$total_record_count = $total_record_count + $noofrows;
+
+			$smarty->assign("SEARCH_CRITERIA","( $noofrows )".$search_msg);
+			$smarty->assign("MODULES_LIST", $object_array);
+
+			$smarty->display("GlobalListView.tpl");
+			unset($_SESSION['lvs'][$module]);
+		}
+	}
+
+	//Added to display the Total record count
+?>
+	<script>
+document.getElementById("global_search_total_count").innerHTML = " <?php echo $app_strings['LBL_TOTAL_RECORDS_FOUND'] ?><b><?php echo $total_record_count; ?></b>";
+	</script>
+<?php
+
+}
+else {
+	echo "<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>".$mod_strings['ERR_ONE_CHAR']."</em>";
+}
+
+/**	Function to get the where condition for a module based on the field table entries
+  *	@param  string $listquery  -- ListView query for the module 
+  *	@param  string $module     -- module name
+  *	@param  string $search_val -- entered search string value
+  *	@return string $where      -- where condition for the module based on field table entries
+  */
+function getUnifiedWhere($listquery,$module,$search_val)
+{
+	global $adb;
+
+	$query = "SELECT columnname, tablename FROM vtiger_field WHERE tabid = ".getTabid($module);
+	$result = $adb->query($query);
+	$noofrows = $adb->num_rows($result);
+
+	$where = '';
+	for($i=0;$i<$noofrows;$i++)
+	{
+		$columnname = $adb->query_result($result,$i,'columnname');
+		$tablename = $adb->query_result($result,$i,'tablename');
+
+		//Before form the where condition, check whether the table for the field has been added in the listview query
+		if(strstr($listquery,$tablename))
+		{
+			if($where != '')
+				$where .= " OR ";
+			$where .= $tablename.".".$columnname." LIKE ".$adb->quote("%$search_val%");
+		}
+	}
+
+	return $where;
+}
+
+/**	Function to get the Tags where condition
+  *	@param  string $search_val -- entered search string value
+  *	@param  string $current_user_id     -- current user id
+  *	@return string $where      -- where condition with the list of crmids, will like vtiger_crmentity.crmid in (1,3,4,etc.,)
+  */
+function getTagWhere($search_val,$current_user_id)
+{
+	require_once('include/freetag/freetag.class.php');
+
+	$freetag_obj = new freetag();
+
+	$crmid_array = $freetag_obj->get_objects_with_tag_all($search_val,$current_user_id);
+
+	$where = '';
+	if(count($crmid_array) > 0)
+	{
+		$where = " vtiger_crmentity.crmid IN (";
+		foreach($crmid_array as $index => $crmid)
+		{
+			$where .= $crmid.',';
+		}
+		$where = trim($where,',').')';
+	}
+
+	return $where;
+}
+
+
+/**	Function to get the the List of Searchable Modules as a combo list which will be displayed in right corner under the Header
+  *	@param  string $search_module -- search module, this module result will be shown defaultly 
+  */
+function getSearchModulesComboList($search_module)
+{
+	global $object_array;
+	global $app_strings;
+	global $mod_strings;
+	
+	?>
+		<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
+		<script>
+		function displayModuleList(selectmodule_view)
+		{
+			<?php
+			foreach($object_array as $module => $object_name)
+			{
+				?>
+				mod = "global_list_"+"<?php echo $module; ?>";
+				if(selectmodule_view.options[selectmodule_view.options.selectedIndex].value == "All")
+					show(mod);
+				else
+					hide(mod);
+				<?php
+			}
+			?>
+			
+			if(selectmodule_view.options[selectmodule_view.options.selectedIndex].value != "All")
+			{
+				selectedmodule="global_list_"+selectmodule_view.options[selectmodule_view.options.selectedIndex].value;
+				show(selectedmodule);
+			}
+		}
+		</script>
+		 <table border=0 cellspacing=0 cellpadding=0 width=98% align=center>
+		     <tr>
+		        <td colspan="3" id="global_search_total_count" style="padding-left:30px">&nbsp;</td>
+		<td nowrap align="right"><?php echo $app_strings['LBL_SHOW_RESULTS'] ?>&nbsp;
+		                <select id="global_search_module" name="global_search_module" onChange="displayModuleList(this);">
+			<option value="All"><?php echo $app_strings['COMBO_ALL'] ?></option>
+						<?php
+						foreach($object_array as $module => $object_name)
+						{
+							$selected = '';
+							if($search_module != '' && $module == $search_module)
+								$selected = 'selected';
+							if($search_module == '' && $module == 'All')
+								$selected = 'selected';
+							?>
+							<option value="<?php echo $module; ?>" <?php echo $selected; ?> ><?php echo $app_strings[$module]; ?></option>
+							<?php
+						}
+						?>
+		     		</select>
+		        </td>
+		     </tr>
+		</table>
+	<?php
+}
+
+/*To get the modules allowed for global search this function returns all the 
+ * modules which supports global search as an array in the following structure 
+ * array($module_name1=>$object_name1,$module_name2=>$object_name2,$module_name3=>$object_name3,$module_name4=>$object_name4,-----);
+ */
+ function getSearchModules()
+ {
+	 global $adb;
+	 $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)';
+	$result = $adb->query($sql);
+	while($module_result = $adb->fetch_array($result))
+	{
+		$modulename = $module_result['name'];
+		if($modulename != 'Calendar')
+		{
+			$return_arr[$modulename] = $modulename;
+		}else
+		{
+			$return_arr[$modulename] = 'Activity';
+		}
+	}
+	return $return_arr;
+ }
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Home/index.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Home/index.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Home/index.php Mon Apr 16 12:27:44 2007
@@ -54,7 +54,7 @@
 }
 if( count($home_section_order) < 1 )
 {
-	$home_section_order = array("ALVT","HDB","PLVT","QLTQ","CVLVT","HLT","OLV","GRT","OLTSO","ILTI","MNL","OLTPO","LTFAQ");
+	$home_section_order = array("HDB","ALVT","PLVT","QLTQ","CVLVT","HLT","OLV","GRT","OLTSO","ILTI","MNL","OLTPO","LTFAQ");
 }
 
 require('user_privileges/user_privileges_'.$current_user->id.'.php');
@@ -67,8 +67,10 @@
 	{
 		$activities = Array();
                 include("modules/Calendar/OpenListView.php") ;
-                $activities[] = getPendingActivities(0);
-                $activities[] = getPendingActivities(1);
+                $activities[] = getPendingActivities(0,"today");
+                $activities[] = getPendingActivities(0,"all");
+                $activities[] = getPendingActivities(1,"today");
+                $activities[] = getPendingActivities(1,"all");
 	}
             break;
         case 'ALVT':
@@ -173,9 +175,13 @@
 }
 
 global $current_language;
+
+global $current_user;
+$user_name = $current_user->column_fields[user_name];
 $current_module_strings = return_module_language($current_language, 'Calendar');
 
 $t=Date("Ymd");
+//echo '<pre>';print_r($home_values); echo '</pre>'; 
 $buttoncheck['Calendar'] = isPermitted('Calendar','index');
 $smarty->assign("CHECK",$buttoncheck);
 $smarty->assign("IMAGE_PATH",$image_path);
@@ -186,6 +192,7 @@
 $smarty->assign("HOMEDETAILS",$home_values);
 $smarty->assign("HOMEDEFAULTVIEW",DefHomeView());
 $smarty->assign("ACTIVITIES",$activities);
+$smarty->assign("CURRENTUSER",$user_name);
 $freetag = new freetag();
 $smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html("",$current_user->id));
 $smarty->display("HomePage.tpl");
@@ -230,11 +237,13 @@
 	global $app_strings;
 	$userid= $current_user->id;
 	$groupids = fetchUserGroupids($userid);
-	if($groupids !='')
+        //Check for permission before constructing the query.
+	if($groupids !='' && (isPermitted('Leads','index') == "yes"  || isPermitted('Calendar','index') == "yes" || isPermitted('HelpDesk','index') == "yes" || isPermitted('Potentials','index') == "yes"  || isPermitted('Accounts','index') == "yes" || isPermitted('Contacts','index') =='yes' || isPermitted('Campaigns','index') =='yes'  || isPermitted('SalesOrder','index') =='yes' || isPermitted('Invoice','index') =='yes' || isPermitted('PurchaseOrder','index') == 'yes'))
 	{
 		$query = '';
 		if(isPermitted('Leads','index') == "yes")
         	{
+
 			//code modified to list the vtiger_groups associates to a user om 21-11-05
 			//Get the leads assigned to group
 			$query = "select vtiger_leaddetails.leadid as id,vtiger_leaddetails.lastname as name,vtiger_leadgrouprelation.groupname as groupname, 'Leads     ' as Type from vtiger_leaddetails inner join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid inner join vtiger_groups on vtiger_leadgrouprelation.groupname=vtiger_groups.groupname where  vtiger_crmentity.deleted=0  and vtiger_leadgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
@@ -254,8 +263,66 @@
 			$query .= "select vtiger_troubletickets.ticketid,vtiger_troubletickets.title as name,vtiger_ticketgrouprelation.groupname,'Tickets   ' as Type from vtiger_troubletickets inner join vtiger_ticketgrouprelation on vtiger_ticketgrouprelation.ticketid=vtiger_troubletickets.ticketid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid inner join vtiger_groups on vtiger_ticketgrouprelation.groupname=vtiger_groups.groupname where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status != 'Closed' and vtiger_ticketgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
 
 		}
+		if(isPermitted('Potentials','index') == "yes")
+		{
+			if($query != '')
+			$query .=" union all ";	
+			//Get the potentials assigned to group(sales stage not Closed Lost or Closed Won-- hardcoded value)
+			$query .= "select vtiger_potential.potentialid,vtiger_potential.potentialname as name,vtiger_potentialgrouprelation.groupname as groupname,'Potentials ' as Type from vtiger_potential inner join vtiger_potentialgrouprelation on vtiger_potentialgrouprelation.potentialid = vtiger_potential.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid inner join vtiger_groups on vtiger_potentialgrouprelation.groupname = vtiger_groups.groupname where vtiger_crmentity.deleted=0  and ((vtiger_potential.sales_stage !='Closed Lost') or (vtiger_potential.sales_stage != 'Closed Won')) and vtiger_potentialgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
+			
+		}
+		if(isPermitted('Accounts','index') == "yes")
+		{
+			if($query != '')
+			$query .=" union all ";
+			//Get the Accounts assigned to group 
+			$query .= "select vtiger_account.accountid as id,vtiger_account.accountname as name,vtiger_accountgrouprelation.groupname as groupname, 'Accounts ' as Type from vtiger_account inner join vtiger_accountgrouprelation on vtiger_account.accountid=vtiger_accountgrouprelation.accountid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid inner join vtiger_groups on vtiger_accountgrouprelation.groupname=vtiger_groups.groupname where vtiger_crmentity.deleted=0  and vtiger_accountgrouprelation.groupname is not null and vtiger_groups.groupid in(".$groupids.")"; 
+		}
+		if(isPermitted('Contacts','index' =='yes'))
+		{
+			if($query != '')
+                        $query .=" union all ";
+                        //Get the Contacts assigned to group
+			$query .= "select vtiger_contactdetails.contactid as id, vtiger_contactdetails.lastname as name ,vtiger_contactgrouprelation.groupname as groupname, 'Contacts ' as Type from vtiger_contactdetails inner join vtiger_contactgrouprelation on vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_contactdetails.contactid inner join vtiger_groups on vtiger_contactgrouprelation.groupname = vtiger_groups.groupname where vtiger_crmentity.deleted=0  and vtiger_contactgrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
+		}
+		if(isPermitted('Campaigns','index' =='yes'))
+		{
+			if($query != '')
+			$query .=" union all ";
+			//Get the Campaigns assigned to group(Campaign status not Complete -- hardcoded value)
+			$query .= "select vtiger_campaign.campaignid as id, vtiger_campaign.campaignname as name, vtiger_campaigngrouprelation.groupname as groupname,'Campaigns ' as Type from vtiger_campaign inner join vtiger_campaigngrouprelation on vtiger_campaign.campaignid=vtiger_campaigngrouprelation.campaignid  inner join  vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid inner join vtiger_groups on vtiger_campaigngrouprelation.groupname = vtiger_groups.groupname where vtiger_crmentity.deleted=0  and (vtiger_campaign.campaignstatus != 'Complete')  and vtiger_campaigngrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
+		}
+		if(isPermitted('Quotes','index' == 'yes'))
+		{
+			if($query != '')
+                        $query .=" union all ";
+                        //Get the Quotes assigned to group(Quotes stage not Rejected -- hardcoded value)
+			$query .="select vtiger_quotes.quoteid as id,vtiger_quotes.subject as name, vtiger_quotegrouprelation.groupname as groupname ,'Quotes 'as Type from vtiger_quotes inner join vtiger_quotegrouprelation on vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid inner join vtiger_groups on vtiger_quotegrouprelation.groupname = vtiger_groups.groupname where vtiger_crmentity.deleted=0  and (vtiger_quotes.quotestage != 'Rejected')  and vtiger_quotegrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
+		}
+		if(isPermitted('SalesOrder','index' =='yes'))
+		{
+			if($query != '')
+                        $query .=" union all ";
+                        //Get the Sales Order assigned to group
+                        $query .="select vtiger_salesorder.salesorderid as id, vtiger_salesorder.subject as name,vtiger_sogrouprelation.groupname as groupname,'SalesOrder ' as Type from vtiger_salesorder inner join vtiger_sogrouprelation on vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_salesorder.salesorderid inner join vtiger_groups on vtiger_sogrouprelation.groupname = vtiger_groups.groupname where vtiger_crmentity.deleted=0  and vtiger_sogrouprelation.groupname is not null and vtiger_groups.groupid in  (".$groupids.")";
+		}	
+		
+		if(isPermitted('Invoice','index' =='yes'))
+                {
+                        if($query != '')
+                        $query .=" union all ";
+                        //Get the Sales Order assigned to group(Invoice status not Paid -- hardcoded value)
+			$query .="select vtiger_invoice.invoiceid as Id , vtiger_invoice.subject as Name, vtiger_invoicegrouprelation.groupname as Groupname,'Invoice ' as Type from vtiger_invoice inner join vtiger_invoicegrouprelation on vtiger_invoice.invoiceid=vtiger_invoicegrouprelation.invoiceid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_invoice.invoiceid inner join vtiger_groups on vtiger_invoicegrouprelation.groupname = vtiger_groups.groupname where vtiger_crmentity.deleted=0 and(vtiger_invoice.invoicestatus != 'Paid') and vtiger_invoicegrouprelation.groupname is not null and vtiger_groups.groupid in  (".$groupids.")";
+		}
+		if(isPermitted('PurchaseOrder','index' == 'yes'))
+		{
+			if($query != '')
+                        $query .=" union all ";
+			 //Get the Purchase Order assigned to group
+			$query .="select vtiger_purchaseorder.purchaseorderid as id,vtiger_purchaseorder.subject as name,vtiger_pogrouprelation.groupname as groupname, 'PurchaseOrder ' as Type from vtiger_purchaseorder inner join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid= vtiger_pogrouprelation.purchaseorderid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid inner join  vtiger_groups on vtiger_pogrouprelation.groupname =vtiger_groups.groupname where vtiger_crmentity.deleted=0 and vtiger_pogrouprelation.groupname is not null and vtiger_groups.groupid in (".$groupids.")";
+		}
 		$log->info("Here is the where clause for the list view: $query");
-		$result = $adb->limitquery($query,0,5) or die("Couldn't get the group listing");
+		$result = $adb->query($query) or die("Couldn't get the group listing");
 
 		$title=array();
 		$title[]='myGroupAllocation.gif';

Modified: vtigercrm/branches/5.1_jens/modules/Import/ImportAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Import/ImportAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Import/ImportAjax.php Mon Apr 16 12:27:44 2007
@@ -14,53 +14,69 @@
 include('modules/Import/Forms.php');
 
 //This is to delete the map
-if($_REQUEST['delete_map'] != '')
+
+if($_REQUEST['ajax_action'] == 'check_dup_map_name')
 {
-	$query = "update vtiger_import_maps set deleted=1 where id = ".$_REQUEST['mapping'];
-	$adb->query($query);
+	$map_name=$_REQUEST['name'];
+	global $adb;
+	$query="select * from vtiger_import_maps where deleted=0 and name='".$map_name."'";
+	$Result = $adb->query($query);
+	$noofrows = $adb->num_rows($Result);
+	if($noofrows > 0)
+		echo "false"; //Map name already exists
+	else
+		echo "true";
+}
+else
+{
+
+	if($_REQUEST['delete_map'] != '')
+	{
+		$query = "update vtiger_import_maps set deleted=1 where id = ".$_REQUEST['mapping'];
+		$adb->query($query);
+	}
+
+	$mapping_file = new ImportMap();
+	$mapping_arr = $mapping_file->getSavedMappingContent($_REQUEST['mapping']);
+
+	$importable_fields = $_SESSION['import_module_object_column_fields'];
+	$field_count = $_SESSION['import_module_field_count'];
+	$required_fields = $_SESSION['import_module_object_required_fields'];
+	$translated_column_fields = $_SESSION['import_module_translated_column_fields'];
+
+	$tablename = '';
+	$has_header = $_SESSION['import_has_header'];
+	$firstrow = $_SESSION['import_firstrow'];
+	$field_map = &$mapping_arr;//$_SESSION['import_field_map'];
+	$smarty_array1 = array();
+
+	for($i=0;$i<$field_count;$i++)
+	{
+		$suggest = '';
+		if ($has_header && isset( $field_map[$firstrow[$i]] ) )
+		{
+			$suggest = $field_map[$firstrow[$i]];
+		}
+		else if (isset($field_map[$i]))
+		{
+			$suggest = $field_map[$i];
+		}
+
+		$smarty_array1[$i+1] = getFieldSelect(	$importable_fields,
+        	                                        $i,
+                	                                $required_fields,
+                        	                        $suggest,
+                                	                $translated_column_fields,
+                                        	        $tablename
+                                        	      );
+	}
+
+	$smarty =  new vtigerCRM_Smarty;
+	$smarty->assign("FIRSTROW",$firstrow);
+	$smarty->assign("SELECTFIELD",$smarty_array1);
+
+	$smarty->display('ImportMap.tpl');
+
 }
 
-$mapping_file = new ImportMap();
-$mapping_arr = $mapping_file->getSavedMappingContent($_REQUEST['mapping']);
-
-$importable_fields = $_SESSION['import_module_object_column_fields'];
-$field_count = $_SESSION['import_module_field_count'];
-$required_fields = $_SESSION['import_module_object_required_fields'];
-$translated_column_fields = $_SESSION['import_module_translated_column_fields'];
-
-$tablename = '';
-$has_header = $_SESSION['import_has_header'];
-$firstrow = $_SESSION['import_firstrow'];
-$field_map = &$mapping_arr;//$_SESSION['import_field_map'];
-$smarty_array1 = array();
-
-for($i=0;$i<$field_count;$i++)
-{
-	$suggest = '';
-	if ($has_header && isset( $field_map[$firstrow[$i]] ) )
-	{
-		$suggest = $field_map[$firstrow[$i]];
-	}
-	else if (isset($field_map[$i]))
-	{
-		$suggest = $field_map[$i];
-	}
-
-	$smarty_array1[$i+1] = getFieldSelect(	$importable_fields,
-                                                $i,
-                                                $required_fields,
-                                                $suggest,
-                                                $translated_column_fields,
-                                                $tablename
-                                              );
-}
-
-$smarty =  new vtigerCRM_Smarty;
-$smarty->assign("FIRSTROW",$firstrow);
-$smarty->assign("SELECTFIELD",$smarty_array1);
-
-$smarty->display('ImportMap.tpl');
-
-
-
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Import/ImportSave.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Import/ImportSave.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Import/ImportSave.php Mon Apr 16 12:27:44 2007
@@ -29,6 +29,7 @@
 {
 	global $current_user;
 	global $adb;
+	global $mod_strings;
 
 // MWC ** Getting vtiger_users
 $temp = get_user_array(FALSE);
@@ -233,7 +234,7 @@
 </script>
 
 <?php
-$_SESSION['import_display_message'] = '<br>'.$start.' to '.$end.' of '.$totalnoofrows.' are imported successfully';
+$_SESSION['import_display_message'] = '<br>'.$start.' '.$mod_strings['to'].' '.$end.' '.$mod_strings['of'].' '.$totalnoofrows.' '.$mod_strings['are_imported_succesfully'];
 //return $_SESSION['import_display_message'];
 }
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Import/ImportStep2.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Import/ImportStep2.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Import/ImportStep2.php Mon Apr 16 12:27:44 2007
@@ -226,10 +226,11 @@
 $list_string_key = strtolower($_REQUEST['module']);
 $list_string_key .= "_import_fields";
 
-$translated_column_fields = $mod_list_strings[$list_string_key];
+//Now we are getting the import fields from DB instead of hard coded array $mod_list_strings
+$translated_column_fields = getImportFieldsList($_REQUEST['module']);//$mod_list_strings[$list_string_key];
 
 // adding custom vtiger_fields translations
-getCustomFieldTrans($_REQUEST['module'],&$translated_column_fields);
+//getCustomFieldTrans($_REQUEST['module'],&$translated_column_fields);
 
 $cnt=1;
 for($field_count = 0; $field_count < $ret_field_count; $field_count++)
@@ -385,7 +386,7 @@
 			else
 			{
 				//if a vtiger_field mapped more than once, alert the user and return
-				alert("'"+tagName.options[tagName.selectedIndex].text+"' is mapped more than once. Please check the mapping.");
+				alert("'"+tagName.options[tagName.selectedIndex].text+"<?php echo $mod_strings['PLEASE_CHECK_MAPPING']?>");
 				return false;
 			}
 		}
@@ -397,7 +398,7 @@
 	{
 		if(seq_string.indexOf(required_fields[inner_loop]) == -1)
 		{
-			alert('Please map the mandatory field "'+required_fields_name[inner_loop]+'"');
+			alert('<?php echo $mod_strings['MAP_MANDATORY_FIELD']?>'+required_fields_name[inner_loop]+'"');
 			return false;
 		}
 	}
@@ -407,7 +408,7 @@
 	{
 		if(trim(document.getElementById("save_map_as").value) == '')
 		{
-			alert("Please Enter Save Map Name");
+			alert("<?php echo $mod_strings['ENTER_SAVEMAP_NAME'] ?>");
 			return false;
 		}
 	}

Modified: vtigercrm/branches/5.1_jens/modules/Import/ImportSteplast.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Import/ImportSteplast.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Import/ImportSteplast.php Mon Apr 16 12:27:44 2007
@@ -145,11 +145,11 @@
 $implict_account = false;
 
 $import_modules_array = Array(
-				"Leads"=>"Lead",
-				"Accounts"=>"Account",
-				"Contacts"=>"Contact",
-				"Potentials"=>"Potential",
-				"Products"=>"Product" 
+				"Leads"=>"Leads",
+				"Accounts"=>"Accounts",
+				"Contacts"=>"Contacts",
+				"Potentials"=>"Potentials",
+				"Products"=>"Products" 
 			     );
 
 foreach($import_modules_array as $module_name => $object_name)
@@ -220,8 +220,8 @@
 		//Retreive the List View Header and Entries
 		$listview_header = getListViewHeader($object,$module_name);
 		$listview_entries = getListViewEntries($object,$module_name,$list_result,$navigation_array,"","","EditView","Delete","");
-
-		$smarty->assign("NAVIGATION", $navigationOutput);
+		//commented to remove navigation buttons from import list view
+		//$smarty->assign("NAVIGATION", $navigationOutput);
 		$smarty->assign("HIDE_CUSTOM_LINKS", 1);//Added to hide the CustomView links in imported records ListView
 		$smarty->assign("LISTHEADER", $listview_header);
 		$smarty->assign("LISTENTITY", $listview_entries);

Modified: vtigercrm/branches/5.1_jens/modules/Import/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Import/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Import/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -125,7 +125,6 @@
 'LBL_LEADS_NOTE_2'=>'Company Name must be mapped.',
 'LBL_IMPORT_NOW'=>'Import Now',
 'LBL_'=>'',
-'LBL_'=>'',
 'LBL_CANNOT_OPEN'=>'Cannot open the imported file for reading',
 'LBL_NOT_SAME_NUMBER'=>'There were not the same number of fields per line in your file',
 'LBL_NO_LINES'=>'There were no lines in your import file',
@@ -163,11 +162,20 @@
 'LBL_STEP_3_3'=>'Step 3 of 3 : ',
 'LBL_MAPPING_RESULTS'=>'Mapping Results ',
 'LBL_LAST_IMPORTED'=>'Last Imported',
+//Added for sript alerts
+'PLEASE_CHECK_MAPPING' => "' is mapped more than once. Please check the mapping.",
+'MAP_MANDATORY_FIELD' => 'Please map the mandatory field "',
+'ENTER_SAVEMAP_NAME' => 'Please Enter Save Map Name',
+
+//Added for 5.0.3
+'to'=>'to',
+'of'=>'of',
+'are_imported_succesfully'=>'are imported successfully',
+
 
 );
 
 /*$mod_list_strings = Array(
-'contacts_import_fields' => Array(
 	"id"=>"Contact ID"
 	,"first_name"=>"First Name"
 	,"last_name"=>"Last Name"

Modified: vtigercrm/branches/5.1_jens/modules/Invoice/CreatePDF.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Invoice/CreatePDF.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Invoice/CreatePDF.php Mon Apr 16 12:27:44 2007
@@ -11,12 +11,13 @@
 
 
 require_once('include/fpdf/pdf.php');
+require_once('include/fpdf/pdfconfig.php');
 require_once('modules/Invoice/Invoice.php');
 require_once('modules/Organization/Organization.php');
 require_once('include/database/PearDatabase.php');
 require_once('include/utils/EditViewUtils.php');
 
-global $adb,$app_strings,$products_per_page,$focus;
+global $adb,$app_strings,$focus;
 global $log;
 
 // for template checking ...
@@ -29,7 +30,6 @@
 
 // would you like and end page?  1 for yes 0 for no
 $endpage="1";
-$products_per_page="6";
 
 $id = $_REQUEST['record'];
 
@@ -37,7 +37,7 @@
 $focus = new Invoice();
 $focus->retrieve_entity_info($_REQUEST['record'],"Invoice");
 $account_name = getAccountName($focus->column_fields[account_id]);
-
+$invoice_no = $focus->column_fields[invoice_no];
 
 // **************** BEGIN POPULATE DATA ********************
 
@@ -57,14 +57,15 @@
 $bill_code = $focus->column_fields["bill_code"];
 $bill_country = $focus->column_fields["bill_country"];
 
+$contact_name =getContactName($focus->column_fields["contact_id"]);
 $ship_street = $focus->column_fields["ship_street"];
 $ship_city = $focus->column_fields["ship_city"];
 $ship_state = $focus->column_fields["ship_state"];
 $ship_code = $focus->column_fields["ship_code"];
 $ship_country = $focus->column_fields["ship_country"];
 
-$conditions = $focus->column_fields["terms_conditions"];
-$description = $focus->column_fields["description"];
+$conditions = from_html($focus->column_fields["terms_conditions"]);
+$description = from_html($focus->column_fields["description"]);
 $status = $focus->column_fields["invoicestatus"];
 
 // Company information
@@ -140,7 +141,11 @@
 if($discount_amount != "")
 	$price_discount = number_format($discount_amount,2,'.',',');
 else if($discount_percent != "")
-	$price_discount = $discount_percent."%";
+{
+	//This will be displayed near Discount label - used in include/fpdf/templates/body.php
+	$final_price_discount_percent = "(".number_format($discount_percent,2,'.',',')." %)";
+	$price_discount = number_format((($discount_percent*$focus->column_fields["hdnSubTotal"])/100),2,'.',',');
+}
 else
 	$price_discount = "0.00";
 
@@ -198,6 +203,8 @@
 	$list_price[$i] = number_format($associated_products[$i]['listPrice'.$i],2,'.',',');
 	$list_pricet[$i] = $associated_products[$i]['listPrice'.$i];
 	$discount_total[$i] = $associated_products[$i]['discountTotal'.$i];
+	//aded for 5.0.3 pdf changes
+	$product_code[$i] = $associated_products[$i]['hdnProductcode'.$i];
 	
 	$taxable_total = $qty[$i]*$list_pricet[$i]-$discount_total[$i];
 
@@ -219,12 +226,47 @@
 	}
 	$prod_total[$i] = number_format($producttotal,2,'.',',');
 
+	$product_line[$j]["Product Code"] = $product_code[$i];
 	$product_line[$j]["Product Name"] = $product_name[$i];
-	$product_line[$j]["Description"] = $prod_description[$i];
 	$product_line[$j]["Qty"] = $qty[$i];
 	$product_line[$j]["Price"] = $list_price[$i];
 	$product_line[$j]["Discount"] = $discount_total[$i];
 	$product_line[$j]["Total"] = $prod_total[$i];
+
+	// Product piecelists
+	$query = "SELECT vtiger_crmentity.crmid,
+	    vtiger_products.productname as productname,
+	    vtiger_products2products_rel.related_productid as prodid,
+	    vtiger_products2products_rel.quantity as quantity,
+	    vtiger_products2products_rel.product_relgroup as product_relgroup
+	    FROM vtiger_products2products_rel
+	    INNER JOIN vtiger_products
+		ON vtiger_products.productid = vtiger_products2products_rel.related_productid
+	    INNER JOIN vtiger_crmentity
+		ON vtiger_crmentity.crmid = vtiger_products.productid
+	    WHERE vtiger_crmentity.deleted = 0
+	    AND vtiger_products2products_rel.productid = ".$product_id[$i]."
+	    AND vtiger_products2products_rel.relation_type = 10";
+	$result = $adb->query($query);
+	$pieces = $adb->num_rows($result);
+	if( $pieces > 0) {
+	    $product_line[++$j]["Product Name"] = "";
+	    $product_line[$j]["Description"] = "consisting of:";
+	    $product_line[$j]["Qty"] = "";
+	    $product_line[$j]["Price"] = "";
+	    $product_line[$j]["Discount"] = "";
+	    $product_line[$j]["Total"] = "";
+	    for( $pl=0; $pl<$pieces; $pl++) {
+	        $product_line[++$j]["Product Name"] = "";
+		$product_line[$j]["Description"] =
+		    $adb->query_result( $result, $pl, "productname");
+		$product_line[$j]["Qty"] =
+		    $adb->query_result( $result, $pl, "quantity");
+		$product_line[$j]["Price"] = "";
+		$product_line[$j]["Discount"] = "";
+		$product_line[$j]["Total"] = "";
+	    }
+	}
 }
 
 //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>';
@@ -236,7 +278,7 @@
 $pdf = new PDF( 'P', 'mm', 'A4' );
 $pdf->Open();
 
-$num_pages=ceil(($num_products/$products_per_page));
+$num_pages=ceil(count($product_line)/$products_per_page);
 
 
 $current_product=0;
@@ -252,15 +294,21 @@
 		$current_product++;
 	}
 
+	//if bottom > 145 then we skip the Description and T&C in every
+	//page and display only in lastpage
+	//if you want to display the description and T&C in each page then
+	//set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php
 	$pdf->AddPage();
 	if( $page_num == "1") {
 	    include("pdf_templates/".$template."/firstpage/header.php");
 	    include("pdf_templates/".$template."/firstpage/body.php");
-	    include("pdf_templates/".$template."/firstpage/footer.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/firstpage/footer.php");
 	} else {
 	    include("pdf_templates/".$template."/pages/header.php");
 	    include("pdf_templates/".$template."/pages/body.php");
-	    include("pdf_templates/".$template."/pages/footer.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/pages/footer.php");
 	}
 
 	$page_num++;

Modified: vtigercrm/branches/5.1_jens/modules/Invoice/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Invoice/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Invoice/DetailView.php Mon Apr 16 12:27:44 2007
@@ -93,6 +93,7 @@
 $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
 
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);

Modified: vtigercrm/branches/5.1_jens/modules/Invoice/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Invoice/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Invoice/EditView.php Mon Apr 16 12:27:44 2007
@@ -31,6 +31,8 @@
 require_once('include/ComboUtil.php');
 require_once('include/utils/utils.php');
 require_once('include/FormValidationUtil.php');
+//Addded for Custom Invoice Number
+require_once('user_privileges/CustomInvoiceNo.php');
 
 global $app_strings,$mod_strings,$currentModule,$log,$current_user;
 global $current_organization;
@@ -351,16 +353,29 @@
 $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
 $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
 
+//Added for Custom Invoice Number
+//we have check the Invoice Number for duplicate only in create view
+if($focus->mode != 'edit')
+{
+        $invoiceno=$inv_str.$inv_no;
+        if(CheckDuplicateInvoiceNumber($invoiceno))
+                echo '<br><font color="#FF0000"><b>Duplicate Invoice Number - Click <a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">here</a> to  Configure the Invoice Number</b></font>'.$num_rows;
+        else
+                $smarty->assign("inv_no",($inv_str.$inv_no));
+}
+
+
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 $organization = new Organization;
 $organization->id = $current_organization;
 $smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
 
 if($focus->mode == 'edit')
-	$smarty->display("Inventory/InventoryEditView.tpl");
+    $smarty->display("Inventory/InventoryEditView.tpl");
 else
-	$smarty->display('Inventory/InventoryCreateView.tpl');
+    $smarty->display('Inventory/InventoryCreateView.tpl');
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Invoice/Invoice.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Invoice/Invoice.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Invoice/Invoice.php Mon Apr 16 12:27:44 2007
@@ -83,6 +83,8 @@
 	var $default_order_by = 'crmid';
 	var $default_sort_order = 'ASC';
 
+	var $groupTable = Array('vtiger_invoicegrouprelation','invoiceid');
+
 	/**	Constructor which will set the column_fields in this object
 	 */
 	function Invoice() {
@@ -107,8 +109,20 @@
         		$query1 = "update vtiger_salesorder set sostatus='Approved' where salesorderid=".$so_id;
         		$this->db->query($query1);
 		}
-		//Based on the total Number of rows we will save the product relationship with this entity
-		saveInventoryProductDetails(&$this, 'Invoice');
+
+		//in ajax save we should not call this function, because this will delete all the existing product values
+		if($_REQUEST['action'] != 'InvoiceAjax' && $_REQUEST['ajxaction'] != 'DETAILVIEW')
+		{
+			//Based on the total Number of rows we will save the product relationship with this entity
+			saveInventoryProductDetails(&$this, 'Invoice');
+		}
+		//Added For Custom Invoice Number 
+		//Here we Incrementing the new InvoiceNumber
+                if($this->mode != 'edit')
+                {
+                        setInventoryInvoiceNumber("increment_invoiceno");
+                }
+
 	}
 
 
@@ -174,7 +188,7 @@
 		else
 			$returnset = '&return_module=Invoice&return_action=CallRelatedList&return_id='.$id;
 
-		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Deferred')";
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Deferred')";
 		$log->debug("Exiting get_activities method ...");
 		return  GetRelatedList('Invoice','Calendar',$focus,$query,$button,$returnset);
 	}
@@ -187,17 +201,15 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,
-			vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,
-			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,vtiger_crmentity.createdtime, vtiger_crmentity.description, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
 			from vtiger_activity
 				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
 				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
 				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
 				left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
 				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname	
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid	
 			where vtiger_activity.activitytype='Task'
 				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred')
 				and vtiger_seactivityrel.crmid=".$id;

Modified: vtigercrm/branches/5.1_jens/modules/Invoice/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Invoice/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Invoice/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -183,7 +183,8 @@
 'Sent'=>'Sent',
 'Credit Invoice'=>'Credit Invoice',
 'Paid'=>'Paid',
-
+//Added to Custom Invoice Number
+'invoice_no'=>'Invoice No',
 );
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/Default/_default/header.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/Default/_default/header.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Invoice/pdf_templates/Default/_default/header.php Mon Apr 16 12:27:44 2007
@@ -51,7 +51,7 @@
 $pdf->addTextBlock( "Shipping Address:", $shipText, $shipLocation );
 
 // billing Address
-$billPositions = array("147","43","60");
+$billPositions = array("147","40","60");
 $billText=$bill_street."\n".$bill_city.", ".$bill_state." ".$bill_code."\n".$bill_country;
 $pdf->addTextBlock("Billing Address:",$billText, $billPositions);
 // ********** End Addresses ******************
@@ -60,16 +60,24 @@
 
 /*  ******** Begin Invoice Data ************************ */ 
 // terms block
-$termBlock=array("10","65");
+$termBlock=array("10","67");
 $pdf->addRecBlock($account_name, "Customer Name", $termBlock);
 
+// issue date block
+$issueBlock=array("80","37");
+$pdf->addRecBlock(date("Y-m-d"), "Issue Date",$issueBlock);
+
 // due date block
-$dueBlock=array("80","65");
+$dueBlock=array("81","52");
 $pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
 
+// Contact Name block
+$conBlock=array("79","67");
+$pdf->addRecBlock($contact_name, "Contact Name",$conBlock);
+
 // vtiger_invoice number block
-$invBlock=array("145","65");
-$pdf->addRecBlock($id, "Invoice Number",$invBlock);
+$invBlock=array("145","67");
+$pdf->addRecBlock($invoice_no, "Invoice Number",$invBlock);
 
 /* ************ End Invoice Data ************************ */
 

Modified: vtigercrm/branches/5.1_jens/modules/Leads/CallRelatedList.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/CallRelatedList.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/CallRelatedList.php Mon Apr 16 12:27:44 2007
@@ -66,10 +66,11 @@
 
 $smarty->assign("ID",$focus->id);
 $smarty->assign("NAME",$focus->lastname.' '.$focus->firstname);
+$smarty->assign("EMAIL",$focus->column_fields['email']);
+$smarty->assign("YAHOO",$focus->column_fields['yahooid']);
 $related_array = getRelatedLists($currentModule,$focus);
 $smarty->assign("RELATEDLISTS", $related_array);
 $smarty->assign("SINGLE_MOD",$app_strings['Lead']);
-$smarty->assign("REDIR_MOD","leads");
 $smarty->assign("MODULE", $currentmodule);
 $smarty->assign("UPDATEINFO",updateInfo($focus->id));
 $smarty->assign("MOD",$mod_strings);

Modified: vtigercrm/branches/5.1_jens/modules/Leads/ConvertLead.html
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/ConvertLead.html (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/ConvertLead.html Mon Apr 16 12:27:44 2007
@@ -96,6 +96,6 @@
         </script>
 {JAVASCRIPT} 
 <script type="text/javascript" language="Javascript" src="include/js/general.js"></script>
-<script type="text/javascript" language="Javascript" src="modules/Leads/Lead.js"></script>
+<script type="text/javascript" language="Javascript" src="modules/Leads/Leads.js"></script>
 
 <!-- END: main -->

Modified: vtigercrm/branches/5.1_jens/modules/Leads/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/DetailView.php Mon Apr 16 12:27:44 2007
@@ -61,7 +61,6 @@
 $smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
 $smarty->assign("ID", $focus->id);
 $smarty->assign("SINGLE_MOD", 'Lead');
-$smarty->assign("REDIR_MOD","leads");
 
 $smarty->assign("NAME",$focus->lastname.' '.$focus->firstname);
 
@@ -97,6 +96,9 @@
 	$parent_email = getEmailParentsList('Leads',$_REQUEST['record']);
         $smarty->assign("HIDDEN_PARENTS_LIST",$parent_email);
 	$smarty->assign("SENDMAILBUTTON","permitted");
+	$smarty->assign("EMAIL1",$focus->column_fields['email']);
+	$smarty->assign("EMAIL2",$focus->column_fields['yahooid']);
+      
 }
 
 if(isPermitted("Leads","Merge",'') == 'yes') 
@@ -110,6 +112,7 @@
 		$optionString[$tempVal["templateid"]] =$tempVal["filename"];
 		$tempVal = $adb->fetch_array($wordTemplateResult);
 	}
+	 $smarty->assign("TEMPLATECOUNT",$tempCount);
 	$smarty->assign("WORDTEMPLATEOPTIONS",$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']);
         $smarty->assign("TOPTIONS",$optionString);
 }
@@ -121,12 +124,14 @@
 $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
 $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
 $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-      
+
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
 
 $smarty->assign("MODULE", $currentModule);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
 
 if($singlepane_view == 'true')
 {

Modified: vtigercrm/branches/5.1_jens/modules/Leads/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/EditView.php Mon Apr 16 12:27:44 2007
@@ -112,6 +112,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE",$_REQUEST['isDuplicate']);
 
 // Assigned organizations
 $smarty->assign("CURRENT_ORGANIZATION",$current_organization);

Modified: vtigercrm/branches/5.1_jens/modules/Leads/LeadConvertToEntities.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/LeadConvertToEntities.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/LeadConvertToEntities.php Mon Apr 16 12:27:44 2007
@@ -13,7 +13,6 @@
 require_once('modules/Leads/Leads.php');
 //Getting the Parameters from the ConvertLead Form
 $id = $_REQUEST["record"];
-
 
 $module = $_REQUEST["module"];
 $createpotential = $_REQUEST["createpotential"];
@@ -228,26 +227,20 @@
 /**	Function used to save the lead related products with other entities Account, Contact and Potential
  *	$leadid - leadid
  *	$relatedid - related entity id (accountid/contactid/potentialid)
- *	$relatedmodule - related entity module name - optional, but for contacts we have to pass Contact because we have to update contactid in vtiger_products table.
  */
-function saveLeadRelatedProducts($leadid, $relatedid, $relatedmodule = '')
+function saveLeadRelatedProducts($leadid, $relatedid)
 {
 	global $adb, $log;
-	$log->debug("Entering into function saveLeadRelatedProducts($leadid, $relatedid, \"$relatedmodule\")");
+	$log->debug("Entering into function saveLeadRelatedProducts($leadid, $relatedid)");
 
 	$product_result = $adb->query("select * from vtiger_seproductsrel where crmid=$leadid");
 	$noofproducts = $adb->num_rows($product_result);
 	for($i = 0; $i < $noofproducts; $i++)
 	{
 		$productid = $adb->query_result($product_result,$i,'productid');
-
-		$adb->query("insert into vtiger_seproductsrel (productid, crmid) values($productid, $relatedid)");
-
-		if($relatedmodule == 'Contacts')
-		{
-			//update contactid in products table then only the products will be shown in contact relatedlist
-			$adb->query("update vtiger_products set contactid=$relatedid where productid=$productid");
-		}
+		$setype = $adb->query_result($product_result,$i,'setype');
+
+		$adb->query("insert into vtiger_seproductsrel values($relatedid, $productid,'".$setype."')");
 	}
 
 	$log->debug("Exit from function saveLeadRelatedProducts.");
@@ -272,7 +265,6 @@
 	}
 	$log->debug("Exit from function saveLeadRelatedCampaigns.");
 }
-
 
 
 /*Code integrated to avoid duplicate Account creation during ConvertLead Operation  START-- by Bharathi*/
@@ -297,10 +289,10 @@
 	/* Modified by Minnie -- END*/
 	$adb->query($sql_insert_account);
 
-	$sql_insert_accountbillads = "INSERT INTO vtiger_accountbillads (accountaddressid,city,code,country,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."')";
+	$sql_insert_accountbillads = "INSERT INTO vtiger_accountbillads (accountaddressid,city,code,country,state,street,pobox) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."','".$row["pobox"]."')";
 	$adb->query($sql_insert_accountbillads);
 
-	$sql_insert_accountshipads = "INSERT INTO vtiger_accountshipads (accountaddressid,city,code,country,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["state"] ."','" .$row["lane"]."')";
+	$sql_insert_accountshipads = "INSERT INTO vtiger_accountshipads (accountaddressid,city,code,country,pobox,state,street) VALUES (".$crmid.",'".$row["city"] ."','" .$row["code"] ."','" .$row["country"] ."','".$row["pobox"]."','".$row["state"] ."','" .$row["lane"]."')";
 	$adb->query($sql_insert_accountshipads);
 
 	//Getting the custom vtiger_field values from leads and inserting into Accounts if the vtiger_field is mapped - Jaguar
@@ -329,7 +321,6 @@
 //Up to this, Account related data save finshed
 
 
-
 $date_entered = $adb->formatDate(date('YmdHis'));
 $date_modified = $adb->formatDate(date('YmdHis'));
 
@@ -351,7 +342,7 @@
 
 $adb->query($sql_insert_contactsubdetails);
 
-$sql_insert_contactaddress = "INSERT INTO vtiger_contactaddress (contactaddressid,mailingcity,mailingstreet,mailingstate,mailingcountry,mailingzip) VALUES (".$contact_id.",'".$row["city"] ."','" .$row["lane"] ."','".$row['state']."','" .$row["country"] ."','".$row['code']."')";
+$sql_insert_contactaddress = "INSERT INTO vtiger_contactaddress (contactaddressid,mailingcity,mailingstreet,mailingstate,mailingcountry,mailingpobox,mailingzip) VALUES (".$contact_id.",'".$row["city"] ."','" .$row["lane"] ."','".$row['state']."','" .$row["country"] ."','".$row["pobox"]."','".$row['code']."')";
 
 $adb->query($sql_insert_contactaddress);
 
@@ -376,7 +367,7 @@
 getRelatedActivities($account_id,$contact_id); //To convert relates Activites  and Email -Jaguar
 
 //Retrieve the lead related products and relate them with this new contact
-saveLeadRelatedProducts($id, $contact_id, "Contacts");
+saveLeadRelatedProducts($id, $contact_id);
 
 //Retrieve the lead related Campaigns and relate them with this new contact --Minnie
 saveLeadRelatedCampaigns($id, $contact_id);

Modified: vtigercrm/branches/5.1_jens/modules/Leads/Leads.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/Leads.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/Leads.php Mon Apr 16 12:27:44 2007
@@ -1,431 +1,443 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of txhe License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('modules/Calendar/Activity.php');
-require_once('modules/Campaigns/Campaigns.php');
-require_once('modules/Notes/Notes.php');
-require_once('modules/Emails/Emails.php');
-require_once('include/ComboUtil.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-class Leads extends CRMEntity {
-	var $log;
-	var $db;
-
-	var $module_id = "leadid";
-
-	var $tab_name = Array('vtiger_crmentity','vtiger_leaddetails','vtiger_leadsubdetails','vtiger_leadaddress','vtiger_leadscf','vtiger_entity2org');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_leaddetails'=>'leadid','vtiger_leadsubdetails'=>'leadsubscriptionid','vtiger_leadaddress'=>'leadaddressid','vtiger_leadscf'=>'leadid','vtiger_entity2org'=>'crmid');
-
-
-
-	//construct this from database;	
-	var $column_fields = Array();
-	var $sortby_fields = Array('lastname','firstname','email','phone','company','smownerid','website');
-
-	// This is used to retrieve related vtiger_fields from form posts.
-	var $additional_column_fields = Array('smcreatorid', 'smownerid', 'contactid','potentialid' ,'crmid');
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-		'Last Name'=>Array('leaddetails'=>'lastname'),
-		'First Name'=>Array('leaddetails'=>'firstname'),
-		'Company'=>Array('leaddetails'=>'company'),
-		'Phone'=>Array('leadaddress'=>'phone'),
-		'Website'=>Array('leadsubdetails'=>'website'),
-		'Email'=>Array('leaddetails'=>'email'),
-		'Assigned To'=>Array('crmentity'=>'smownerid')
-	);
-	var $list_fields_name = Array(
-		'Last Name'=>'lastname',
-		'First Name'=>'firstname',
-		'Company'=>'company',
-		'Phone'=>'phone',
-		'Website'=>'website',
-		'Email'=>'email',
-		'Assigned To'=>'assigned_user_id'
-	);
-	var $list_link_field= 'lastname';
-
-	var $search_fields = Array(
-		'Name'=>Array('leaddetails'=>'lastname'),
-		'Company'=>Array('leaddetails'=>'company')
-	);
-	var $search_fields_name = Array(
-		'Name'=>'lastname',
-		'Company'=>'company'
-	);
-
-	var $required_fields =  array("lastname"=>1, 'company'=>1);
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'lastname';
-	var $default_sort_order = 'ASC';
-
-	function Leads()	{
-		$this->log = LoggerManager::getLogger('lead');
-		$this->log->debug("Entering Leads() method ...");
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Leads');
-		$this->log->debug("Exiting Lead method ...");
-	}
-
-	/** Function to handle module specific operations when saving a entity
-	*/
-	function save_module($module)
-	{
-	}
-
-	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
-	/**
-	 * Function to get sort order
- 	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	 */
-	function getSortOrder()
-	{	
-		global $log;
-		$log->debug("Entering getSortOrder() method ...");
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['LEADS_SORT_ORDER'] != '')?($_SESSION['LEADS_SORT_ORDER']):($this->default_sort_order));
-
-		$log->debug("Exiting getSortOrder method ...");
-		return $sorder;
-	}
-
-	/**
-	 * Function to get order by
-	 * return string  $order_by    - fieldname(eg: 'leadname')
- 	 */
-	function getOrderBy()
-	{
-		global $log;
-		$log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['LEADS_ORDER_BY'] != '')?($_SESSION['LEADS_ORDER_BY']):($this->default_order_by));
-
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-	// Mike Crowe Mod --------------------------------------------------------
-
-
-
-	/** Function to export the lead records in CSV Format
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Export Leads Query.
-	*/
-	function create_export_query(&$order_by, &$where)
-	{
-		global $log;
-		global $current_user;
-		$log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
-
-		include("include/utils/ExportUtils.php");
-
-		//To get the Permitted fields query and the permitted fields list
-		$sql = getPermittedFieldsQuery("Leads", "detail_view");
-		$fields_list = getFieldsListFromQuery($sql);
-
-		$query = "SELECT $fields_list  FROM ".$this->entity_table."
-				INNER JOIN vtiger_leaddetails
-					ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid
-				LEFT JOIN vtiger_leadsubdetails
-					ON vtiger_leaddetails.leadid = vtiger_leadsubdetails.leadsubscriptionid
-				LEFT JOIN vtiger_leadaddress
-					ON vtiger_leaddetails.leadid=vtiger_leadaddress.leadaddressid
-				LEFT JOIN vtiger_leadscf 
-					ON vtiger_leadscf.leadid=vtiger_leaddetails.leadid
-				LEFT JOIN vtiger_leadgrouprelation
-                	                ON vtiger_leadscf.leadid = vtiger_leadgrouprelation.leadid
-	                        LEFT JOIN vtiger_groups
-                        	        ON vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
-				LEFT JOIN vtiger_users
-					ON vtiger_crmentity.smownerid = vtiger_users.id 
-				";
-
-
-		$where_auto = " vtiger_users.status='Active'
-			AND vtiger_crmentity.deleted=0 AND vtiger_leaddetails.converted =0";
-
-		if($where != "")
-			$query .= "where ($where) AND ".$where_auto;
-		else
-			$query .= "where ".$where_auto;
-
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-		//we should add security check when the user has Private Access
-		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[7] == 3)
-		{
-			//Added security check to get the permitted records only
-			$query = $query." ".getListViewSecurityParameter("Leads");
-		}
-
-		if(!empty($order_by))
-			$query .= " ORDER BY $order_by";
-
-		$log->debug("Exiting create_export_query method ...");
-		return $query;
-	}
-
-
-	
-	/** Returns a list of the associated tasks
- 	 * @param  integer   $id      - leadid
- 	 * returns related Task or Event record in array format
-	*/
-function get_activities($id)
-{
-	global $log, $singlepane_view;
-	$log->debug("Entering get_activities(".$id.") method ...");
-	global $app_strings;
-
-	$focus = new Activity();
-	$button = '';
-
-	if(isPermitted("Calendar",1,"") == 'yes')
-	{
-		$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';i;this.form.return_module.value=\'Leads\';this.form.activity_mode.value=\'Task\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
-		$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Leads\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;</td>';
-	}
-	if($singlepane_view == 'true')
-		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
-	else
-		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
-
-
-	// First, get the list of IDs.
-	$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and ((vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus !='' && vtiger_activity.eventstatus != 'Held'))";
-	$log->debug("Exiting get_activities method ...");
-	return  GetRelatedList('Leads','Calendar',$focus,$query,$button,$returnset);
-}
-
-/** Returns a list of the associated Campaigns
-  * @param $id -- campaign id :: Type Integer
-  * @returns list of campaigns in array format
-  */
-function get_campaigns($id)
-{
-	global $log, $singlepane_view;
-	$log->debug("Entering get_campaigns(".$id.") method ...");
-	global $mod_strings;
-	$focus = new Campaigns();
-	$button = '';
-
-	if($singlepane_view == 'true')
-		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
-	else
-		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
-
-	$log->info("Campaign Related List for Lead Displayed");
-	$query = "SELECT vtiger_users.user_name, vtiger_campaign.campaignid, vtiger_campaign.campaignname, vtiger_campaign.campaigntype, vtiger_campaign.campaignstatus, vtiger_campaign.expectedrevenue, vtiger_campaign.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_campaign inner join vtiger_campaignleadrel on vtiger_campaignleadrel.campaignid=vtiger_campaign.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid left join vtiger_campaigngrouprelation on vtiger_campaign.campaignid=vtiger_campaigngrouprelation.campaignid left join vtiger_groups on vtiger_groups.groupname=vtiger_campaigngrouprelation.groupname left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid where vtiger_campaignleadrel.leadid=".$id." and vtiger_crmentity.deleted=0";
-
-	$log->debug("Exiting get_campaigns method ...");
-	return GetRelatedList('Leads','Campaigns',$focus,$query,$button,$returnset);
-
-}
-
-
-	/** Returns a list of the associated emails
- 	 * @param  integer   $id      - leadid
- 	 * returns related emails record in array format
-	*/
-function get_emails($id)
-{
-	global $log, $singlepane_view;	
-	$log->debug("Entering get_emails(".$id.") method ...");
-	global $mod_strings;
-	require_once('include/RelatedListView.php');
-
-	$focus = new Emails();
-
-	$button = '';
-
-	if(isPermitted("Emails",1,"") == 'yes')
-	{
-
-		$button .= '<input title="New Email" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Emails\';this.form.email_directing_module.value=\'leads\';this.form.record.value='.$id.';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_EMAIL'].'">&nbsp;';
-	}
-	if($singlepane_view == 'true')
-		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
-	else
-		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
-
-	$query ="select vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.semodule, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.status, vtiger_activity.priority, vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_users on  vtiger_users.id=vtiger_crmentity.smownerid where vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted=0 and vtiger_seactivityrel.crmid=".$id;
-	$log->debug("Exiting get_emails method ...");
-	return GetRelatedList('Leads','Emails',$focus,$query,$button,$returnset);
-}
-
-/**
- * Function to get Lead related Task & Event which have activity type Held, Completed or Deferred.
- * @param  integer   $id      - leadid
- * returns related Task or Event record in array format
- */
-function get_history($id)
-{
-	global $log;
-	$log->debug("Entering get_history(".$id.") method ...");
-	$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
-	vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_crmentity.modifiedtime,
-	vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name,vtiger_activitygrouprelation.groupname
-			from vtiger_activity
-			inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
-			inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
-			left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-			left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname 
-			left join vtiger_users on vtiger_crmentity.smownerid= vtiger_users.id
-			where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
-			and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
-			and vtiger_seactivityrel.crmid=".$id;
-	//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-
-	$log->debug("Exiting get_history method ...");
-	return getHistory('Leads',$query,$id);
-}
-
-/**
- * Function to get Lead related Attachments
- * @param  integer   $id      - leadid
- * returns related Attachment record in array format
- */
-function get_attachments($id)
-{
-	global $log;
-	$log->debug("Entering get_attachments(".$id.") method ...");
-	// Armando Lüscher 18.10.2005 -> §visibleDescription
-	// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-	// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-	$query = "select vtiger_notes.title,'Notes      ' ActivityType, vtiger_notes.filename,
-	vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
-	vtiger_seattachmentsrel.attachmentsid attachmentsid, vtiger_notes.notesid crmid,
-		crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-			from vtiger_notes
-			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
-			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
-			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
-			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
-			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-			where vtiger_crmentity.crmid=".$id;
-	$query .= ' union all ';
-	// Armando Lüscher 18.10.2005 -> §visibleDescription
-	// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-	// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-	// Inserted order by createdtime desc
-	$query .= "select vtiger_attachments.description title ,'Attachments' ActivityType,
-	vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
-	vtiger_attachments.attachmentsid attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
-		crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-			from vtiger_attachments
-			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
-			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
-			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
-			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-			where vtiger_crmentity.crmid=".$id."
-			order by createdtime desc";
-
-	$log->debug("Exiting get_attachments method ...");
-	return getAttachmentsAndNotes('Leads',$query,$id);
-}
-	
-/**
-* Function to get lead related Products 
-* @param  integer   $id      - leadid
-* returns related Products record in array format
-*/
-function get_products($id)
-{
-	global $log, $singlepane_view;
-	$log->debug("Entering get_products(".$id.") method ...");
-	require_once('modules/Products/Products.php');
-	global $mod_strings;
-	global $app_strings;
-
-	$focus = new Products();
-
-	$button = '';
-
-	if(isPermitted("Products",1,"") == 'yes')
-	{
-		$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Leads\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
-	}
-	if($singlepane_view == 'true')
-		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
-	else
-		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
-
-	$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_products inner join vtiger_seproductsrel on vtiger_products.productid = vtiger_seproductsrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seproductsrel.crmid  where vtiger_leaddetails.leadid = '.$id.' and vtiger_crmentity.deleted = 0';
-	$log->debug("Exiting get_products method ...");
-	return  GetRelatedList('Leads','Products',$focus,$query,$button,$returnset);
-}
-	
-	/** Function to get the Combo List Values of Leads Field
-	 * @param string $list_option 
-	 * Returns Combo List Options 
-	*/
-	function get_lead_field_options($list_option)
-	{
-		global $log;
-		$log->debug("Entering get_lead_field_options(".$list_option.") method ...");
-		$comboFieldArray = getComboArray($this->combofieldNames);
-		$log->debug("Exiting get_lead_field_options method ...");
-		return $comboFieldArray[$list_option];
-	}
-	
-/** Function to get the Columnnames of the Leads Record
-* Used By vtigerCRM Word Plugin
-* Returns the Merge Fields for Word Plugin
-*/
-function getColumnNames_Lead()
-{
-	global $log,$current_user;
-	$log->debug("Entering getColumnNames_Lead() method ...");
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-	{
-		$sql1 = "select fieldlabel from vtiger_field where tabid=7";
-	}else
-	{
-		$profileList = getCurrentUserProfileList();
-		$sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-	}
-	$result = $this->db->query($sql1);
-	$numRows = $this->db->num_rows($result);
-	for($i=0; $i < $numRows;$i++)
-	{
-   	$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
-   	$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
-   	$custom_fields[$i] = strtoupper($custom_fields[$i]);
-	}
-	$mergeflds = $custom_fields;
-	$log->debug("Exiting getColumnNames_Lead method ...");
-	return $mergeflds;
-}
-//End
-
-}
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of txhe License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('modules/Calendar/Activity.php');
+require_once('modules/Campaigns/Campaigns.php');
+require_once('modules/Notes/Notes.php');
+require_once('modules/Emails/Emails.php');
+require_once('include/ComboUtil.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+class Leads extends CRMEntity {
+	var $log;
+	var $db;
+
+	var $module_id = "leadid";
+
+	var $tab_name = Array('vtiger_crmentity','vtiger_leaddetails','vtiger_leadsubdetails','vtiger_leadaddress','vtiger_leadscf','vtiger_entity2org');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_leaddetails'=>'leadid','vtiger_leadsubdetails'=>'leadsubscriptionid','vtiger_leadaddress'=>'leadaddressid','vtiger_leadscf'=>'leadid','vtiger_entity2org'=>'crmid');
+
+	var $entity_table = "vtiger_crmentity";
+
+	//construct this from database;	
+	var $column_fields = Array();
+	var $sortby_fields = Array('lastname','firstname','email','phone','company','smownerid','website');
+
+	// This is used to retrieve related vtiger_fields from form posts.
+	var $additional_column_fields = Array('smcreatorid', 'smownerid', 'contactid','potentialid' ,'crmid');
+
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+		'Last Name'=>Array('leaddetails'=>'lastname'),
+		'First Name'=>Array('leaddetails'=>'firstname'),
+		'Company'=>Array('leaddetails'=>'company'),
+		'Phone'=>Array('leadaddress'=>'phone'),
+		'Website'=>Array('leadsubdetails'=>'website'),
+		'Email'=>Array('leaddetails'=>'email'),
+		'Assigned To'=>Array('crmentity'=>'smownerid')
+	);
+	var $list_fields_name = Array(
+		'Last Name'=>'lastname',
+		'First Name'=>'firstname',
+		'Company'=>'company',
+		'Phone'=>'phone',
+		'Website'=>'website',
+		'Email'=>'email',
+		'Assigned To'=>'assigned_user_id'
+	);
+	var $list_link_field= 'lastname';
+
+	var $search_fields = Array(
+		'Name'=>Array('leaddetails'=>'lastname'),
+		'Company'=>Array('leaddetails'=>'company')
+	);
+	var $search_fields_name = Array(
+		'Name'=>'lastname',
+		'Company'=>'company'
+	);
+
+	var $required_fields =  array("lastname"=>1, 'company'=>1);
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'lastname';
+	var $default_sort_order = 'ASC';
+
+	var $groupTable = Array('vtiger_leadgrouprelation','leadid');
+	
+	function Leads()	{
+		$this->log = LoggerManager::getLogger('lead');
+		$this->log->debug("Entering Leads() method ...");
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Leads');
+		$this->log->debug("Exiting Lead method ...");
+	}
+
+	/** Function to handle module specific operations when saving a entity
+	*/
+	function save_module($module)
+	{
+	}
+
+	// Mike Crowe Mod --------------------------------------------------------Default ordering for us
+	/**
+	 * Function to get sort order
+ 	 * return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	 */
+	function getSortOrder()
+	{	
+		global $log;
+		$log->debug("Entering getSortOrder() method ...");
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['LEADS_SORT_ORDER'] != '')?($_SESSION['LEADS_SORT_ORDER']):($this->default_sort_order));
+
+		$log->debug("Exiting getSortOrder method ...");
+		return $sorder;
+	}
+
+	/**
+	 * Function to get order by
+	 * return string  $order_by    - fieldname(eg: 'leadname')
+ 	 */
+	function getOrderBy()
+	{
+		global $log;
+		$log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['LEADS_ORDER_BY'] != '')?($_SESSION['LEADS_ORDER_BY']):($this->default_order_by));
+
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+	// Mike Crowe Mod --------------------------------------------------------
+
+
+
+	/** Function to export the lead records in CSV Format
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Export Leads Query.
+	*/
+	function create_export_query(&$order_by, &$where)
+	{
+		global $log;
+		global $current_user;
+		$log->debug("Entering create_export_query(".$order_by.",".$where.") method ...");
+
+		include("include/utils/ExportUtils.php");
+
+		//To get the Permitted fields query and the permitted fields list
+		$sql = getPermittedFieldsQuery("Leads", "detail_view");
+		$fields_list = getFieldsListFromQuery($sql);
+
+		$query = "SELECT $fields_list, vtiger_leadgrouprelation.groupname as 'Assigned To Group' 
+	      			FROM ".$this->entity_table."
+				INNER JOIN vtiger_leaddetails
+					ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid
+				LEFT JOIN vtiger_leadsubdetails
+					ON vtiger_leaddetails.leadid = vtiger_leadsubdetails.leadsubscriptionid
+				LEFT JOIN vtiger_leadaddress
+					ON vtiger_leaddetails.leadid=vtiger_leadaddress.leadaddressid
+				LEFT JOIN vtiger_leadscf 
+					ON vtiger_leadscf.leadid=vtiger_leaddetails.leadid
+				LEFT JOIN vtiger_leadgrouprelation
+                	                ON vtiger_leadscf.leadid = vtiger_leadgrouprelation.leadid
+	                        LEFT JOIN vtiger_groups
+                        	        ON vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
+				LEFT JOIN vtiger_users
+					ON vtiger_crmentity.smownerid = vtiger_users.id and vtiger_users.status='Active'
+				";
+
+
+		$where_auto = " vtiger_crmentity.deleted=0 AND vtiger_leaddetails.converted =0";
+
+		if($where != "")
+			$query .= "where ($where) AND ".$where_auto;
+		else
+			$query .= "where ".$where_auto;
+
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		//we should add security check when the user has Private Access
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[7] == 3)
+		{
+			//Added security check to get the permitted records only
+			$query = $query." ".getListViewSecurityParameter("Leads");
+		}
+
+		if(!empty($order_by))
+			$query .= " ORDER BY $order_by";
+
+		$log->debug("Exiting create_export_query method ...");
+		return $query;
+	}
+
+
+	
+	/** Returns a list of the associated tasks
+ 	 * @param  integer   $id      - leadid
+ 	 * returns related Task or Event record in array format
+	*/
+function get_activities($id)
+{
+	global $log, $singlepane_view;
+	$log->debug("Entering get_activities(".$id.") method ...");
+	global $app_strings;
+
+	$focus = new Activity();
+	$button = '';
+
+	if(isPermitted("Calendar",1,"") == 'yes')
+	{
+		$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';i;this.form.return_module.value=\'Leads\';this.form.activity_mode.value=\'Task\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
+		$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Leads\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;</td>';
+	}
+	if($singlepane_view == 'true')
+		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
+	else
+		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
+
+
+	// First, get the list of IDs.
+	$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred')) or (vtiger_activity.activitytype in ('Meeting','Call') and  vtiger_activity.eventstatus not in ('','Held')))";
+	$log->debug("Exiting get_activities method ...");
+	return  GetRelatedList('Leads','Calendar',$focus,$query,$button,$returnset);
+}
+
+/** Returns a list of the associated Campaigns
+  * @param $id -- campaign id :: Type Integer
+  * @returns list of campaigns in array format
+  */
+function get_campaigns($id)
+{
+	global $log, $singlepane_view;
+	$log->debug("Entering get_campaigns(".$id.") method ...");
+	global $mod_strings;
+	$focus = new Campaigns();
+	$button = '';
+
+	if($singlepane_view == 'true')
+		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
+	else
+		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
+
+	$log->info("Campaign Related List for Lead Displayed");
+	$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name ,vtiger_campaign.campaignid, vtiger_campaign.campaignname, vtiger_campaign.campaigntype, vtiger_campaign.campaignstatus, vtiger_campaign.expectedrevenue, vtiger_campaign.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_campaign inner join vtiger_campaignleadrel on vtiger_campaignleadrel.campaignid=vtiger_campaign.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_campaign.campaignid left join vtiger_campaigngrouprelation on vtiger_campaign.campaignid=vtiger_campaigngrouprelation.campaignid left join vtiger_groups on vtiger_groups.groupname=vtiger_campaigngrouprelation.groupname left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid where vtiger_campaignleadrel.leadid=".$id." and vtiger_crmentity.deleted=0";
+
+	$log->debug("Exiting get_campaigns method ...");
+	return GetRelatedList('Leads','Campaigns',$focus,$query,$button,$returnset);
+
+}
+
+
+	/** Returns a list of the associated emails
+ 	 * @param  integer   $id      - leadid
+ 	 * returns related emails record in array format
+	*/
+function get_emails($id)
+{
+	global $log, $singlepane_view;	
+	$log->debug("Entering get_emails(".$id.") method ...");
+	global $mod_strings;
+	require_once('include/RelatedListView.php');
+
+	$focus = new Emails();
+
+	$button = '';
+
+	if(isPermitted("Emails",1,"") == 'yes')
+	{
+
+		$button .= '<input title="New Email" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Emails\';this.form.email_directing_module.value=\'leads\';this.form.record.value='.$id.';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_EMAIL'].'">&nbsp;';
+	}
+	if($singlepane_view == 'true')
+		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
+	else
+		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
+
+	$query ="select vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.semodule, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.status, vtiger_activity.priority, vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_users on  vtiger_users.id=vtiger_crmentity.smownerid where vtiger_activity.activitytype='Emails' and vtiger_crmentity.deleted=0 and vtiger_seactivityrel.crmid=".$id;
+	$log->debug("Exiting get_emails method ...");
+	return GetRelatedList('Leads','Emails',$focus,$query,$button,$returnset);
+}
+
+/**
+ * Function to get Lead related Task & Event which have activity type Held, Completed or Deferred.
+ * @param  integer   $id      - leadid
+ * returns related Task or Event record in array format
+ */
+function get_history($id)
+{
+	global $log;
+	$log->debug("Entering get_history(".$id.") method ...");
+	$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+		vtiger_activity.eventstatus, vtiger_activity.activitytype,vtiger_activity.date_start, 
+		vtiger_activity.due_date,vtiger_activity.time_start,vtiger_activity.time_end,
+		vtiger_crmentity.modifiedtime,vtiger_crmentity.createdtime,
+		vtiger_crmentity.description, vtiger_users.user_name,vtiger_activitygrouprelation.groupname
+			from vtiger_activity
+			inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+			left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+			left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname 
+			left join vtiger_users on vtiger_crmentity.smownerid= vtiger_users.id
+			where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+			and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+			and vtiger_seactivityrel.crmid=".$id;
+	//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+
+	$log->debug("Exiting get_history method ...");
+	return getHistory('Leads',$query,$id);
+}
+
+/**
+ * Function to get Lead related Attachments
+ * @param  integer   $id      - leadid
+ * returns related Attachment record in array format
+ */
+function get_attachments($id)
+{
+	global $log;
+	$log->debug("Entering get_attachments(".$id.") method ...");
+	// Armando Lüscher 18.10.2005 -> §visibleDescription
+	// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+	// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+	$query = "select vtiger_notes.title,'Notes      ' ActivityType, vtiger_notes.filename,
+	vtiger_attachments.type  FileType,crm2.modifiedtime lastmodified,
+	vtiger_seattachmentsrel.attachmentsid attachmentsid, vtiger_notes.notesid crmid,
+		crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+			from vtiger_notes
+			inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+			left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+			left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+			where vtiger_crmentity.crmid=".$id;
+	$query .= ' union all ';
+	// Armando Lüscher 18.10.2005 -> §visibleDescription
+	// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+	// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+	// Inserted order by createdtime desc
+	$query .= "select vtiger_attachments.description title ,'Attachments' ActivityType,
+	vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+	vtiger_attachments.attachmentsid attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+		crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+			from vtiger_attachments
+			inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+			inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+			inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+			inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+			where vtiger_crmentity.crmid=".$id."
+			order by createdtime desc";
+
+	$log->debug("Exiting get_attachments method ...");
+	return getAttachmentsAndNotes('Leads',$query,$id);
+}
+	
+/**
+* Function to get lead related Products 
+* @param  integer   $id      - leadid
+* returns related Products record in array format
+*/
+function get_products($id)
+{
+	global $log, $singlepane_view;
+	$log->debug("Entering get_products(".$id.") method ...");
+	require_once('modules/Products/Products.php');
+	global $mod_strings;
+	global $app_strings;
+
+	$focus = new Products();
+
+	$button = '';
+
+	if(isPermitted("Products",1,"") == 'yes')
+	{
+		$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Leads\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
+	}
+	if($singlepane_view == 'true')
+		$returnset = '&return_module=Leads&return_action=DetailView&return_id='.$id;
+	else
+		$returnset = '&return_module=Leads&return_action=CallRelatedList&return_id='.$id;
+
+	$query = "SELECT vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, 
+			vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, 
+			vtiger_crmentity.crmid, vtiger_crmentity.smownerid 
+		   FROM vtiger_products 
+		   INNER JOIN vtiger_seproductsrel ON vtiger_products.productid = vtiger_seproductsrel.productid and vtiger_seproductsrel.setype = 'Leads'
+		   INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid 
+		   INNER JOIN vtiger_leaddetails ON vtiger_leaddetails.leadid = vtiger_seproductsrel.crmid  
+		   WHERE vtiger_crmentity.deleted = 0 AND vtiger_leaddetails.leadid = $id";
+
+	$log->debug("Exiting get_products method ...");
+	return  GetRelatedList('Leads','Products',$focus,$query,$button,$returnset);
+}
+	
+	/** Function to get the Combo List Values of Leads Field
+	 * @param string $list_option 
+	 * Returns Combo List Options 
+	*/
+	function get_lead_field_options($list_option)
+	{
+		global $log;
+		$log->debug("Entering get_lead_field_options(".$list_option.") method ...");
+		$comboFieldArray = getComboArray($this->combofieldNames);
+		$log->debug("Exiting get_lead_field_options method ...");
+		return $comboFieldArray[$list_option];
+	}
+	
+/** Function to get the Columnnames of the Leads Record
+* Used By vtigerCRM Word Plugin
+* Returns the Merge Fields for Word Plugin
+*/
+function getColumnNames_Lead()
+{
+	global $log,$current_user;
+	$log->debug("Entering getColumnNames_Lead() method ...");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+	{
+		$sql1 = "select fieldlabel from vtiger_field where tabid=7";
+	}else
+	{
+		$profileList = getCurrentUserProfileList();
+		$sql1 = "select fieldlabel from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+	}
+	$result = $this->db->query($sql1);
+	$numRows = $this->db->num_rows($result);
+	for($i=0; $i < $numRows;$i++)
+	{
+   	$custom_fields[$i] = $this->db->query_result($result,$i,"fieldlabel");
+   	$custom_fields[$i] = ereg_replace(" ","",$custom_fields[$i]);
+   	$custom_fields[$i] = strtoupper($custom_fields[$i]);
+	}
+	$mergeflds = $custom_fields;
+	$log->debug("Exiting getColumnNames_Lead method ...");
+	return $mergeflds;
+}
+//End
+
+}
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Leads/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/ListView.php Mon Apr 16 12:27:44 2007
@@ -166,7 +166,7 @@
         $query .= ' and '.$where;
 }
 
-
+/*
 if(isset($order_by) && $order_by != '')
 {
 	$tablename = getTableNameForField('Leads',$order_by);
@@ -177,7 +177,24 @@
 	
         $query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
 }
-
+*/
+if(isset($order_by) && $order_by != '')
+{
+	if($order_by == 'smownerid')
+	{
+		$query .= ' ORDER BY user_name '.$sorder;
+	}
+	else
+	{
+		$tablename = getTableNameForField('Leads',$order_by);
+		$tablename = (($tablename != '')?($tablename."."):'');
+		if( $adb->dbType == "pgsql")
+			$query .= ' GROUP BY '.$tablename.$order_by;
+
+
+		$query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder;
+	}
+}
 //Retreiving the no of rows
 $count_result = $adb->query( mkCountQuery( $query));
 $noofrows = $adb->query_result($count_result,0,"count");
@@ -221,7 +238,6 @@
 }
 if(isPermitted("Leads","Merge") == 'yes') 
 {
-	$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Leads')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
 	$wordTemplateResult = fetchWordTemplateList("Leads");
 	$tempCount = $adb->num_rows($wordTemplateResult);
 	$tempVal = $adb->fetch_array($wordTemplateResult);
@@ -230,7 +246,23 @@
 		$optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
 		$tempVal = $adb->fetch_array($wordTemplateResult);
 	}
-	$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$mod_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+	if($tempCount > 0)
+	{
+		$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$mod_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");
+
+		$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Leads')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
+	}
+	else
+        {
+		global $current_user;
+                require("user_privileges/user_privileges_".$current_user->id.".php");
+                if($is_admin == true)
+                {
+			$smarty->assign("MERGEBUTTON",'<td><a href=index.php?module=Settings&action=upload&tempModule='.$currentModule.'>'. $app_strings["LBL_CREATE_MERGE_TEMPLATE"].'</td>');
+                }
+        }
+
+
 }
 //mass merge for word templates
 

Modified: vtigercrm/branches/5.1_jens/modules/Leads/ListViewTop.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/ListViewTop.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/ListViewTop.php Mon Apr 16 12:27:44 2007
@@ -68,7 +68,7 @@
 		$start_date = date("Y-m-d", strtotime("-1 week"));
 	}	
 
-	$list_query = 'select vtiger_leaddetails.*,vtiger_crmentity.createdtime,vtiger_crmentity.description from vtiger_leaddetails inner join vtiger_crmentity on vtiger_leaddetails.leadid = vtiger_crmentity.crmid where vtiger_crmentity.deleted =0 AND vtiger_leaddetails.converted =0 AND vtiger_crmentity.createdtime >='.$start_date.' AND vtiger_crmentity.smownerid = '.$current_user->id; 
+	$list_query = 'select vtiger_leaddetails.*,vtiger_crmentity.createdtime,vtiger_crmentity.description from vtiger_leaddetails inner join vtiger_crmentity on vtiger_leaddetails.leadid = vtiger_crmentity.crmid where vtiger_crmentity.deleted =0 AND vtiger_leaddetails.converted =0 AND vtiger_leaddetails.leadstatus not in (\'Lost Lead\', \'Junk Lead\',\''.$current_module_strings['Lost Lead'].'\',\''.$current_module_strings['Junk Lead'].'\') AND vtiger_crmentity.createdtime >='.$start_date.' AND vtiger_crmentity.smownerid = '.$current_user->id; 
 	
 	$list_result = $adb->query($list_query);
 	$noofrows = $adb->num_rows($list_result);
@@ -114,7 +114,7 @@
 				'LEAD_ID' => $lead['id'],
 				);
 
-		$value[]= '<a href="index.php?action=DetailView&module=Leads&record='.$lead_fields['LEAD_ID'].'">'.$lead_fields['LEAD_NAME'].'</a>';
+		$value[]= '<a href="index.php?action=DetailView&module=Leads&record='.$lead_fields['LEAD_ID'].'">'.substr($lead_fields['LEAD_NAME'],0,20).'...'.'</a>';
 		$value[]=$lead_fields['COMPANY'];
 		$value[]=$lead_fields['ANNUAL_REVENUE'];
 		$value[]=$lead_fields['LEAD_STATUS'];

Modified: vtigercrm/branches/5.1_jens/modules/Leads/Merge.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/Merge.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/Merge.php Mon Apr 16 12:27:44 2007
@@ -24,6 +24,7 @@
 }
 else if(document.all)
 {
+	document.write("<br><br>Click <a href='#' onclick='window.history.back();'>here</a> to return to the previous page");
 	document.write("<OBJECT Name='vtigerCRM' codebase='modules/Settings/vtigerCRM.CAB#version=1,5,0,0' id='objMMPage' classid='clsid:0FC436C2-2E62-46EF-A3FB-E68E94705126' width=0 height=0></object>");
 }
 </script>

Modified: vtigercrm/branches/5.1_jens/modules/Leads/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Leads/updateRelations.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Leads/updateRelations.php Mon Apr 16 12:27:44 2007
@@ -13,8 +13,11 @@
 require_once('user_privileges/default_module_view.php');
 global $adb, $singlepane_view;
 $idlist = $_REQUEST['idlist'];
-$update_mod = $_REQUEST['destination_module'];
-$rel_table = 'vtiger_campaignleadrel';
+$dest_mod = $_REQUEST['destination_module'];
+
+if($singlepane_view == 'true') $action = "DetailView";
+else $action = "CallRelatedList";
+
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -23,24 +26,25 @@
 	{
 		if($id != '')
 		{
-		    $sql = "insert into  ".$rel_table." values(".$id.",".$_REQUEST["parentid"].")";
-	            $adb->query($sql);
+			if($dest_mod == 'Products')
+				$adb->query("insert into vtiger_seproductsrel values (".$_REQUEST["parentid"].",".$id.",'Leads')");
+			elseif($dest_mod == 'Campaigns')	
+		    		$adb->query("insert into  vtiger_campaignleadrel values(".$id.",".$_REQUEST["parentid"].")");
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Leads&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Leads&record=".$_REQUEST["parentid"]);
+	$record = $_REQUEST["parentid"];
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
-{	
-		$sql = "insert into ".$rel_table." values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")";
-		$adb->query($sql);
-
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Leads&record=".$_REQUEST["parid"]);
-		else
- 			header("Location: index.php?action=CallRelatedList&module=Leads&record=".$_REQUEST["parid"]);
+{
+	if($dest_mod == 'Products')
+		$adb->query("insert into vtiger_seproductsrel values (".$_REQUEST["parid"].",".$_REQUEST["entityid"].",'Leads')");	
+	elseif($dest_mod == 'Campaigns')
+		$adb->query("insert into vtiger_campaignleadrel values(".$_REQUEST["entityid"].",".$_REQUEST["parid"].")");
+	$record = $_REQUEST["parid"];
 }
 
+header("Location: index.php?action=$action&module=Leads&record=".$record);
+
+
+
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Migration/Migration.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Migration/Migration.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Migration/Migration.php Mon Apr 16 12:27:44 2007
@@ -299,8 +299,8 @@
 
 		//To handle the file includes for each and every version
 		//Here we have to decide which files should be included, where the files will be added newly for every public release
-		//Handle Here -- Mickie
-		include("modules/Migration/ModifyDatabase/MigrationInfo.php");
+		//In this included file we have included modules/Migration/DBChanges/42P2_to_50.php which will apply the db changes upto 5.0.
+		include("modules/Migration/MigrationInfo.php");
 
 		$migrationlog->debug("Mickie ---- Ends\n\n\n");
 	}

Modified: vtigercrm/branches/5.1_jens/modules/Migration/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Migration/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Migration/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -75,7 +75,20 @@
 'LBL_MYSQL_SERVER_PATH'=>'MySQL Server Path : ',
 'LBL_MIGRATE_BUTTON'=>'Migrate',
 'LBL_CANCEL_BUTTON'=>'Cancel',
-
+'LBL_UPGRADE_FROM_VTIGER_5X'=>'Upgrade database from vtiger CRM 5.x to next version',
+'LBL_PATCH_OR_MIGRATION'=>'you must specify the source database version (Patch update or Migration)',
+//Added for java script alerts
+'ENTER_SOURCE_HOST' => 'Please enter the Source Host Name',
+'ENTER_SOURCE_MYSQL_PORT' => 'Please enter the Source MySql Port Number',
+'ENTER_SOURCE_MYSQL_USER' => 'Please enter the Source MySql User Name',
+'ENTER_SOURCE_DATABASE' => 'Please enter the Source Database Name',
+'ENTER_SOURCE_MYSQL_DUMP' => 'Please enter the Valid MySQL Dump File',
+'ENTER_HOST' => 'Please enter the Host Name',
+'ENTER_MYSQL_PORT' => 'Please enter the MySql Port Number',
+'ENTER_MYSQL_USER' => 'Please enter the MySql User Name',
+'ENTER_DATABASE' => 'Please enter the Database Name',
+'SELECT_ANYONE_OPTION' => 'Please select any one option',
+'ENTER_CORRECT_MYSQL_PATH' => 'Please enter the Correct MySQL Path',
 
 );
 

Modified: vtigercrm/branches/5.1_jens/modules/Notes/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Notes/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Notes/DetailView.php Mon Apr 16 12:27:44 2007
@@ -1,119 +1,122 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/DetailView.php,v 1.11 2005/03/17 11:21:40 ray Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('data/Tracker.php');
-require_once('Smarty_setup.php');
-require_once('modules/Notes/Notes.php');
-require_once('include/upload_file.php');
-require_once('include/utils/utils.php');
-global $app_strings;
-global $mod_strings;
-global $currentModule;
-
-$focus = new Notes();
-
-if(isset($_REQUEST['record'])) {
-   $focus->retrieve_entity_info($_REQUEST['record'],"Notes");
-   $focus->id = $_REQUEST['record'];
-   $focus->name=$focus->column_fields['notes_title'];
-}
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
-	$focus->id = "";
-}
-
-//needed when creating a new note with default values passed in
-if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
-	$focus->contact_name = $_REQUEST['contact_name'];
-}
-if (isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
-	$focus->contact_id = $_REQUEST['contact_id'];
-}
-if (isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
-	$focus->parent_name = $_REQUEST['opportunity_name'];
-}
-if (isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
-	$focus->parent_id = $_REQUEST['opportunity_id'];
-}
-if (isset($_REQUEST['account_name']) && is_null($focus->parent_name)) {
-	$focus->parent_name = $_REQUEST['account_name'];
-}
-if (isset($_REQUEST['account_id']) && is_null($focus->parent_id)) {
-	$focus->parent_id = $_REQUEST['account_id'];
-}
-
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-$log->info("Note detail view");
-
-$smarty = new vtigerCRM_Smarty;
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
-$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-
-
-if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
-else $smarty->assign("NAME", "");
-
-if (isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
-if (isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
-if (isset($_REQUEST['return_id'])) $smarty->assign("RETURN_ID", $_REQUEST['return_id']);
-
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);
-$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("ID", $focus->id);
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-if ( isset($focus->filename) && $focus->filename != '')
-{
-        $fileurl = "<a href=\"".UploadFile::get_url($focus->filename,$focus->id)."\" target=\"_blank\">". $focus->filename ."</a>";
-	$smarty->assign("FILELINK", $fileurl);
-}
-
-$smarty->assign("SINGLE_MOD", 'Note');
-
-if(isPermitted("Notes","EditView",$_REQUEST['record']) == 'yes')
-	$smarty->assign("EDIT_DUPLICATE","permitted");
-
-if(isPermitted("Notes","Delete",$_REQUEST['record']) == 'yes')
-	$smarty->assign("DELETE","permitted");
-
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-$tabid = getTabid("Notes");
- $validationData = getDBValidationData($focus->tab_name,$tabid);
- $data = split_validationdataArray($validationData);
-
- $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
- $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
- $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-
-$smarty->assign("MODULE",$currentModule);
-$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
-$smarty->display("DetailView.tpl");
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/DetailView.php,v 1.11 2005/03/17 11:21:40 ray Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('data/Tracker.php');
+require_once('Smarty_setup.php');
+require_once('modules/Notes/Notes.php');
+require_once('include/upload_file.php');
+require_once('include/utils/utils.php');
+global $app_strings;
+global $mod_strings;
+global $currentModule;
+
+$focus = new Notes();
+
+if(isset($_REQUEST['record'])) {
+   $focus->retrieve_entity_info($_REQUEST['record'],"Notes");
+   $focus->id = $_REQUEST['record'];
+   $focus->name=$focus->column_fields['notes_title'];
+}
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+	$focus->id = "";
+}
+
+//needed when creating a new note with default values passed in
+if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
+	$focus->contact_name = $_REQUEST['contact_name'];
+}
+if (isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
+	$focus->contact_id = $_REQUEST['contact_id'];
+}
+if (isset($_REQUEST['opportunity_name']) && is_null($focus->parent_name)) {
+	$focus->parent_name = $_REQUEST['opportunity_name'];
+}
+if (isset($_REQUEST['opportunity_id']) && is_null($focus->parent_id)) {
+	$focus->parent_id = $_REQUEST['opportunity_id'];
+}
+if (isset($_REQUEST['account_name']) && is_null($focus->parent_name)) {
+	$focus->parent_name = $_REQUEST['account_name'];
+}
+if (isset($_REQUEST['account_id']) && is_null($focus->parent_id)) {
+	$focus->parent_id = $_REQUEST['account_id'];
+}
+
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+$log->info("Note detail view");
+
+$smarty = new vtigerCRM_Smarty;
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
+$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+
+
+if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
+else $smarty->assign("NAME", "");
+
+if (isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
+if (isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
+if (isset($_REQUEST['return_id'])) $smarty->assign("RETURN_ID", $_REQUEST['return_id']);
+
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("ID", $focus->id);
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+if ( isset($focus->filename) && $focus->filename != '')
+{
+        $fileurl = "<a href=\"".UploadFile::get_url($focus->filename,$focus->id)."\" target=\"_blank\">". $focus->filename ."</a>";
+	$smarty->assign("FILELINK", $fileurl);
+}
+
+$smarty->assign("SINGLE_MOD", 'Note');
+
+if(isPermitted("Notes","EditView",$_REQUEST['record']) == 'yes')
+	$smarty->assign("EDIT_DUPLICATE","permitted");
+
+if(isPermitted("Notes","Delete",$_REQUEST['record']) == 'yes')
+	$smarty->assign("DELETE","permitted");
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
+$tabid = getTabid("Notes");
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+$smarty->display("DetailView.tpl");
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Notes/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Notes/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Notes/EditView.php Mon Apr 16 12:27:44 2007
@@ -1,191 +1,191 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/EditView.php,v 1.13 2005/04/18 10:37:49 samk Exp $
- * Description: TODO:  To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Notes/Notes.php');
-require_once('include/utils/utils.php');
-
-global $app_strings,$app_list_strings,$mod_strings,$theme,$currentModule;
-
-$focus = new Notes();
-$smarty = new vtigerCRM_Smarty();
-
-if($_REQUEST['upload_error'] == true)
-{
-	echo '<br><b><font color="red"> The selected file has no data or a invalid file.</font></b><br>';
-}
-
-if(isset($_REQUEST['record']) && $_REQUEST['record'] !='') 
-{
-	$focus->id = $_REQUEST['record'];
-	$focus->mode = 'edit';
-	$focus->retrieve_entity_info($_REQUEST['record'],"Notes");
-        $focus->name=$focus->column_fields['notes_title'];
-}
-if(isset($_REQUEST['parent_id']))
-{
-        $focus->column_fields['parent_id'] = $_REQUEST['parent_id'];
-}
-//$old_id = '';
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') 
-{
-	$old_id = $_REQUEST['record'];
-	if (! empty($focus->filename) )
-	{	
-	 $old_id = $focus->id;
-	}
-	$focus->id = "";
-	$focus->mode = '';
-}
-
-
-
-//setting default flag value so due date and time not required
-if (!isset($focus->id)) $focus->date_due_flag = 'on';
-
-//needed when creating a new case with default values passed in
-if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
-	$focus->contact_name = $_REQUEST['contact_name'];
-}
-if (isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
-	$focus->contact_id = $_REQUEST['contact_id'];
-}
-if (isset($_REQUEST['parent_name']) && is_null($focus->parent_name)) {
-	$focus->parent_name = $_REQUEST['parent_name'];
-}
-if (isset($_REQUEST['parent_id']) && is_null($focus->parent_id)) {
-	$focus->parent_id = $_REQUEST['parent_id'];
-}
-if (isset($_REQUEST['parent_type'])) {
-	$focus->parent_type = $_REQUEST['parent_type'];
-}
-elseif (!isset($focus->parent_type)) {
-	$focus->parent_type = $app_list_strings['record_type_default_key'];
-}
-
-if (isset($_REQUEST['filename']) && $_REQUEST['isDuplicate'] != 'true') {
-        $focus->filename = $_REQUEST['filename'];
-}
-
-
-
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-$disp_view = getView($focus->mode);
-if($disp_view == 'edit_view')
-	$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
-else	
-{
-	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
-}	
-$smarty->assign("OP_MODE",$disp_view);
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-
-$log->info("Note detail view");
-
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-$smarty->assign("MODULE",$currentModule);
-$smarty->assign("SINGLE_MOD",'Note');
-//Display the FCKEditor or not? -- configure $FCKEDITOR_DISPLAY in config.php 
-$smarty->assign("FCKEDITOR_DISPLAY",$FCKEDITOR_DISPLAY);
-
-if (isset($focus->name))
-$smarty->assign("NAME", $focus->name);
-else
-$smarty->assign("NAME", "");
-
-if($focus->mode == 'edit')
-{
-	$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-        $smarty->assign("MODE", $focus->mode);
-}
-
-if (isset($_REQUEST['return_module']))
-$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
-else
-$smarty->assign("RETURN_MODULE","Notes");
-if (isset($_REQUEST['return_action']))
-$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
-else
-$smarty->assign("RETURN_ACTION","index");
-if (isset($_REQUEST['return_id']))
-$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
-if (isset($_REQUEST['email_id']))
-$smarty->assign("EMAILID", $_REQUEST['email_id']);
-if (isset($_REQUEST['ticket_id'])) $smarty->assign("TICKETID", $_REQUEST['ticket_id']);
-if (isset($_REQUEST['fileid']))
-$smarty->assign("FILEID", $_REQUEST['fileid']);
-if (isset($_REQUEST['record']))
-{
-         $smarty->assign("CANCELACTION", "DetailView");
-}
-else
-{
-         $smarty->assign("CANCELACTION", "index");
-}
-if (isset($_REQUEST['return_viewname']))
-$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);
-$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("ID", $focus->id);
-$smarty->assign("OLD_ID", $old_id );
-
-if ( empty($focus->filename))
-{
-        $smarty->assign("FILENAME_TEXT", "");
-        $smarty->assign("FILENAME", "");
-}
-else
-{
-        $smarty->assign("FILENAME_TEXT", "(".$focus->filename.")");
-        $smarty->assign("FILENAME", $focus->filename);
-}
-
-if (isset($focus->parent_type) && $focus->parent_type != "") {
-        $change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' vtiger_tabindex='3' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
-        $smarty->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
-}
-if ($focus->parent_type == "Account") $smarty->assign("DEFAULT_SEARCH", "&query=true&account_id=$focus->parent_id&account_name=".urlencode($focus->parent_name));
-
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-$tabid = getTabid("Notes");
- $validationData = getDBValidationData($focus->tab_name,$tabid);
- $data = split_validationdataArray($validationData);
-
- $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
- $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
- $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-
-if($focus->mode == 'edit')
-	$smarty->display("salesEditView.tpl");
-else
-	$smarty->display("CreateView.tpl");
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/EditView.php,v 1.13 2005/04/18 10:37:49 samk Exp $
+ * Description: TODO:  To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Notes/Notes.php');
+require_once('include/utils/utils.php');
+
+global $app_strings,$app_list_strings,$mod_strings,$theme,$currentModule;
+
+$focus = new Notes();
+$smarty = new vtigerCRM_Smarty();
+
+if($_REQUEST['upload_error'] == true)
+{
+	echo '<br><b><font color="red"> The selected file has no data or a invalid file.</font></b><br>';
+}
+
+if(isset($_REQUEST['record']) && $_REQUEST['record'] !='') 
+{
+	$focus->id = $_REQUEST['record'];
+	$focus->mode = 'edit';
+	$focus->retrieve_entity_info($_REQUEST['record'],"Notes");
+        $focus->name=$focus->column_fields['notes_title'];
+}
+if(isset($_REQUEST['parent_id']))
+{
+        $focus->column_fields['parent_id'] = $_REQUEST['parent_id'];
+}
+//$old_id = '';
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') 
+{
+	$old_id = $_REQUEST['record'];
+	if (! empty($focus->filename) )
+	{	
+	 $old_id = $focus->id;
+	}
+	$focus->id = "";
+	$focus->mode = '';
+}
+
+
+
+//setting default flag value so due date and time not required
+if (!isset($focus->id)) $focus->date_due_flag = 'on';
+
+//needed when creating a new case with default values passed in
+if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
+	$focus->contact_name = $_REQUEST['contact_name'];
+}
+if (isset($_REQUEST['contact_id']) && is_null($focus->contact_id)) {
+	$focus->contact_id = $_REQUEST['contact_id'];
+}
+if (isset($_REQUEST['parent_name']) && is_null($focus->parent_name)) {
+	$focus->parent_name = $_REQUEST['parent_name'];
+}
+if (isset($_REQUEST['parent_id']) && is_null($focus->parent_id)) {
+	$focus->parent_id = $_REQUEST['parent_id'];
+}
+if (isset($_REQUEST['parent_type'])) {
+	$focus->parent_type = $_REQUEST['parent_type'];
+}
+elseif (!isset($focus->parent_type)) {
+	$focus->parent_type = $app_list_strings['record_type_default_key'];
+}
+
+if (isset($_REQUEST['filename']) && $_REQUEST['isDuplicate'] != 'true') {
+        $focus->filename = $_REQUEST['filename'];
+}
+
+
+
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+$disp_view = getView($focus->mode);
+if($disp_view == 'edit_view')
+	$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
+else	
+{
+	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
+}	
+$smarty->assign("OP_MODE",$disp_view);
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+
+$log->info("Note detail view");
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("SINGLE_MOD",'Note');
+//Display the FCKEditor or not? -- configure $FCKEDITOR_DISPLAY in config.php 
+$smarty->assign("FCKEDITOR_DISPLAY",$FCKEDITOR_DISPLAY);
+
+if (isset($focus->name))
+$smarty->assign("NAME", $focus->name);
+else
+$smarty->assign("NAME", "");
+
+if($focus->mode == 'edit')
+{
+	$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+        $smarty->assign("MODE", $focus->mode);
+}
+
+if (isset($_REQUEST['return_module']))
+$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
+else
+$smarty->assign("RETURN_MODULE","Notes");
+if (isset($_REQUEST['return_action']))
+$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
+else
+$smarty->assign("RETURN_ACTION","index");
+if (isset($_REQUEST['return_id']))
+$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
+if (isset($_REQUEST['email_id']))
+$smarty->assign("EMAILID", $_REQUEST['email_id']);
+if (isset($_REQUEST['ticket_id'])) $smarty->assign("TICKETID", $_REQUEST['ticket_id']);
+if (isset($_REQUEST['fileid']))
+$smarty->assign("FILEID", $_REQUEST['fileid']);
+if (isset($_REQUEST['record']))
+{
+         $smarty->assign("CANCELACTION", "DetailView");
+}
+else
+{
+         $smarty->assign("CANCELACTION", "index");
+}
+if (isset($_REQUEST['return_viewname']))
+$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("ID", $focus->id);
+$smarty->assign("OLD_ID", $old_id );
+
+if ( empty($focus->filename))
+{
+        $smarty->assign("FILENAME_TEXT", "");
+        $smarty->assign("FILENAME", "");
+}
+else
+{
+        $smarty->assign("FILENAME_TEXT", "(".$focus->filename.")");
+        $smarty->assign("FILENAME", $focus->filename);
+}
+
+if (isset($focus->parent_type) && $focus->parent_type != "") {
+        $change_parent_button = "<input title='".$app_strings['LBL_CHANGE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_CHANGE_BUTTON_KEY']."' vtiger_tabindex='3' type='button' class='button' value='".$app_strings['LBL_CHANGE_BUTTON_LABEL']."' name='button' LANGUAGE=javascript onclick='return window.open(\"index.php?module=\"+ document.EditView.parent_type.value + \"&action=Popup&html=Popup_picker&form=TasksEditView\",\"test\",\"width=600,height=400,resizable=1,scrollbars=1\");'>";
+        $smarty->assign("CHANGE_PARENT_BUTTON", $change_parent_button);
+}
+if ($focus->parent_type == "Account") $smarty->assign("DEFAULT_SEARCH", "&query=true&account_id=$focus->parent_id&account_name=".urlencode($focus->parent_name));
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+$tabid = getTabid("Notes");
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+ $smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
+if($focus->mode == 'edit')
+	$smarty->display("salesEditView.tpl");
+else
+	$smarty->display("CreateView.tpl");
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Notes/Notes.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Notes/Notes.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Notes/Notes.php Mon Apr 16 12:27:44 2007
@@ -29,17 +29,18 @@
 
 // Note is used to store customer information.
 class Notes extends CRMEntity {
+	
 	var $log;
 	var $db;
 
 	var $default_note_name_dom = array('Meeting vtiger_notes', 'Reminder');
 
-	var $tab_name = Array('vtiger_crmentity','vtiger_notes');
+	var $tab_name = Array('vtiger_crmentity','vtiger_notes','vtiger_attachments');
 	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_notes'=>'notesid','vtiger_senotesrel'=>'notesid','vtiger_attachments'=>'attachmentsid');
 
 	var $column_fields = Array();
 
-        var $sortby_fields = Array('notes_title','modifiedtime','contact_id','filename');		  
+        var $sortby_fields = Array('title','modifiedtime','contact_id','filename');		  
 
 	// This is used to retrieve related vtiger_fields from form posts.
 	var $additional_column_fields = Array('', '', '', '');
@@ -47,7 +48,7 @@
 	// This is the list of vtiger_fields that are in the lists.
 	var $list_fields = Array(
 				'Subject'=>Array('notes'=>'notes_title'),
-				'Contact Name'=>Array('notes'=>'contact_id'),
+				'Contact Name'=>Array('contactdetails'=>'lastname'),
 				'Related to'=>Array('senotesrel'=>'crmid'),
 				'File'=>Array('notes'=>'filename'),
 				'Last Modified'=>Array('crmentity'=>'modifiedtime')
@@ -64,7 +65,6 @@
 	//Added these variables which are used as default order by and sortorder in ListView
 	var $default_order_by = 'modifiedtime';
 	var $default_sort_order = 'ASC';
-
 	function Notes() {
 		$this->log = LoggerManager::getLogger('notes');
 		$this->log->debug("Entering Notes() method ...");
@@ -75,7 +75,8 @@
 
 	function save_module($module)
 	{
-
+		
+		$insertion_mode = $this->mode;
 		//inserting into vtiger_senotesrel
 		if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')
 		{

Modified: vtigercrm/branches/5.1_jens/modules/Notes/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Notes/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Notes/Save.php Mon Apr 16 12:27:44 2007
@@ -1,139 +1,139 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/Save.php,v 1.7 2005/04/18 10:37:49 samk Exp $
- * Description:  Saves an Account record and then redirects the browser to the
- * defined return URL.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('modules/Notes/Notes.php');
-require_once('include/logging.php');
-require_once('include/upload_file.php');
-
-$local_log =& LoggerManager::getLogger('index');
-
-$focus = new Notes();
-
-setObjectValuesFromRequest(&$focus);
-
-//Check if the file is exist or not.
-if($_FILES["filename"]["size"] == 0 && $_FILES["filename"]["name"] != '')
-{
-	$file_upload_error = true;
-	$_FILES = '';
-}
-
-if (!isset($_REQUEST['date_due_flag'])) $focus->date_due_flag = 'off';
-
-//Save the Note
-$focus->save("Notes");
-
-//Added to retrieve the existing attachment of the notes and save it for the new duplicated note
-if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '')
-{
-        $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
-        $result = $adb->query($sql);
-        if($adb->num_rows($result) != 0)
-	{
-                $attachmentid = $adb->query_result($result,0,'attachmentsid');
-		$filename = $adb->query_result($result,0,'name');
-		$filetype = $adb->query_result($result,0,'type');
-		$filepath = $adb->query_result($result,0,'path');
-
-		$new_attachmentid = $adb->getUniqueID("vtiger_crmentity");
-		$date_var = $adb->formatDate(date('YmdHis'));	
-
-		$upload_filepath = decideFilePath();
-
-		//Read the old file contents and write it as a new file with new attachment id
-		$handle = @fopen($upload_filepath.$new_attachmentid."_".$filename,'w');
-		fputs($handle, file_get_contents($filepath.$attachmentid."_".$filename));
-		fclose($handle);	
-
-		$adb->query("update vtiger_notes set filename=\"$filename\" where notesid=$focus->id");	
-		$adb->query("insert into vtiger_crmentity (crmid,setype,createdtime) values('".$new_attachmentid."','Notes Attachment','".$date_var."')");
-
-		$adb->query("insert into vtiger_attachments values(".$new_attachmentid.",'".$filename."','','".$filetype."','".$upload_filepath."')");
-
-		$adb->query("insert into vtiger_seattachmentsrel values('".$focus->id."','".$new_attachmentid."')");
-	}
-}
-
-
-$return_id = $focus->id;
-$note_id = $return_id;
-
-if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab'];
-if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
-else $return_module = "Notes";
-if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
-else $return_action = "DetailView";
-if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
-
-// Notes added to Contacts should also update Accounts
-// Added by DG 16 Nov 2005
-if($_REQUEST['mode'] != 'edit' && ($_REQUEST['return_module']=='Contacts'))
-{
-	$crmid = $_REQUEST['return_id'];
-	$noteid = $focus->id;
-	$query = 'select accountid from vtiger_contactdetails where contactid='.$crmid;
-	$result = $adb->query($query);
-	if($adb->num_rows($result) != 0)
-	{
-		$associated_account = $adb->query_result($result,0,"accountid");
-	}
-	else
-	{
-		$associated_account = '';
-	}
-	if ($associated_account)
-	{
-		$sql1 = "insert into vtiger_senotesrel (notesid, crmid) values('";
-		$sql1 .= $noteid."','".$associated_account."')";
-		$result = $adb->query($sql1);
-	}
-}
-
-if($_REQUEST['mode'] != 'edit' && (($_REQUEST['return_module']=='Emails') ||($_REQUEST['return_module']=='HelpDesk') ))
-{
-	if($_REQUEST['email_id'] != '')
-		$crmid = $_REQUEST['email_id'];
-	if($_REQUEST['ticket_id'] != '')
-		$crmid = $_REQUEST['ticket_id'];
-	if($crmid != $_REQUEST['parent_id'])
-	{
-		$sql = "insert into vtiger_senotesrel (notesid, crmid) values('".$focus->id."','".$crmid."')";
-		$adb->query($sql);
-	}
-}
-
-$local_log->debug("Saved record with id of ".$return_id);
-
-//Redirect to EditView if the given file is not valid.
-if($file_upload_error)
-{
-	$return_module = 'Notes';
-	$return_action = 'EditView';
-	$return_id = $note_id.'&upload_error=true&return_module='.$_REQUEST['return_module'].'&return_action='.$_REQUEST['return_action'].'&return_id='.$_REQUEST['return_id'];
-}
-
-//code added for returning back to the current view after edit from list view
-if($_REQUEST['return_viewname'] == '') $return_viewname='0';
-if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
-header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&viewname=$return_viewname");
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Notes/Save.php,v 1.7 2005/04/18 10:37:49 samk Exp $
+ * Description:  Saves an Account record and then redirects the browser to the
+ * defined return URL.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('modules/Notes/Notes.php');
+require_once('include/logging.php');
+require_once('include/upload_file.php');
+
+$local_log =& LoggerManager::getLogger('index');
+
+$focus = new Notes();
+
+setObjectValuesFromRequest(&$focus);
+
+//Check if the file is exist or not.
+if($_FILES["filename"]["size"] == 0 && $_FILES["filename"]["name"] != '')
+{
+	$file_upload_error = true;
+	//$_FILES = '';
+}
+
+if (!isset($_REQUEST['date_due_flag'])) $focus->date_due_flag = 'off';
+
+//Save the Note
+$focus->save("Notes");
+
+//Added to retrieve the existing attachment of the notes and save it for the new duplicated note
+if($_FILES['filename']['name'] == '' && $_REQUEST['mode'] != 'edit' && $_REQUEST['old_id'] != '')
+{
+        $sql = "select vtiger_attachments.* from vtiger_attachments inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid=vtiger_attachments.attachmentsid where vtiger_seattachmentsrel.crmid= ".$_REQUEST['old_id'];
+        $result = $adb->query($sql);
+        if($adb->num_rows($result) != 0)
+	{
+                $attachmentid = $adb->query_result($result,0,'attachmentsid');
+		$filename = $adb->query_result($result,0,'name');
+		$filetype = $adb->query_result($result,0,'type');
+		$filepath = $adb->query_result($result,0,'path');
+
+		$new_attachmentid = $adb->getUniqueID("vtiger_crmentity");
+		$date_var = $adb->formatDate(date('YmdHis'));	
+
+		$upload_filepath = decideFilePath();
+
+		//Read the old file contents and write it as a new file with new attachment id
+		$handle = @fopen($upload_filepath.$new_attachmentid."_".$filename,'w');
+		fputs($handle, file_get_contents($filepath.$attachmentid."_".$filename));
+		fclose($handle);	
+
+		$adb->query("update vtiger_notes set filename=\"$filename\" where notesid=$focus->id");	
+		$adb->query("insert into vtiger_crmentity (crmid,setype,createdtime) values('".$new_attachmentid."','Notes Attachment',".$date_var.")");
+
+		$adb->query("insert into vtiger_attachments values(".$new_attachmentid.",'".$filename."','','".$filetype."','".$upload_filepath."')");
+
+		$adb->query("insert into vtiger_seattachmentsrel values('".$focus->id."','".$new_attachmentid."')");
+	}
+}
+
+
+$return_id = $focus->id;
+$note_id = $return_id;
+
+if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab'];
+if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
+else $return_module = "Notes";
+if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
+else $return_action = "DetailView";
+if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
+
+// Notes added to Contacts should also update Accounts
+// Added by DG 16 Nov 2005
+if($_REQUEST['mode'] != 'edit' && ($_REQUEST['return_module']=='Contacts'))
+{
+	$crmid = $_REQUEST['return_id'];
+	$noteid = $focus->id;
+	$query = 'select accountid from vtiger_contactdetails where contactid='.$crmid;
+	$result = $adb->query($query);
+	if($adb->num_rows($result) != 0)
+	{
+		$associated_account = $adb->query_result($result,0,"accountid");
+	}
+	else
+	{
+		$associated_account = '';
+	}
+	if ($associated_account)
+	{
+		$sql1 = "insert into vtiger_senotesrel (notesid, crmid) values('";
+		$sql1 .= $noteid."','".$associated_account."')";
+		$result = $adb->query($sql1);
+	}
+}
+
+if($_REQUEST['mode'] != 'edit' && (($_REQUEST['return_module']=='Emails') ||($_REQUEST['return_module']=='HelpDesk') ))
+{
+	if($_REQUEST['email_id'] != '')
+		$crmid = $_REQUEST['email_id'];
+	if($_REQUEST['ticket_id'] != '')
+		$crmid = $_REQUEST['ticket_id'];
+	if($crmid != $_REQUEST['parent_id'])
+	{
+		$sql = "insert into vtiger_senotesrel (notesid, crmid) values('".$focus->id."','".$crmid."')";
+		$adb->query($sql);
+	}
+}
+
+$local_log->debug("Saved record with id of ".$return_id);
+
+//Redirect to EditView if the given file is not valid.
+if($file_upload_error)
+{
+	$return_module = 'Notes';
+	$return_action = 'EditView';
+	$return_id = $note_id.'&upload_error=true&return_module='.$_REQUEST['return_module'].'&return_action='.$_REQUEST['return_action'].'&return_id='.$_REQUEST['return_id'];
+}
+
+//code added for returning back to the current view after edit from list view
+if($_REQUEST['return_viewname'] == '') $return_viewname='0';
+if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
+header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&viewname=$return_viewname");
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Portal/Portal.js
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Portal/Portal.js (original)
+++ vtigercrm/branches/5.1_jens/modules/Portal/Portal.js Mon Apr 16 12:27:44 2007
@@ -1,115 +1,115 @@
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
-
-function fetchAddSite(id)
-{
-	$("status").style.display="inline";
-	new Ajax.Request(
-		'index.php',
-		{queue: {position: 'end', scope: 'command'},
-			method: 'post',
-			postBody:'module=Portal&action=PortalAjax&file=Popup&record='+id,
-			onComplete: function(response) {
-				$("status").style.display="none";
-				$('editportal_cont').innerHTML = response.responseText;
-			}
-		}
-	);
-}
-
-function fetchContents(mode)
-{
-	$("status").style.display="inline";
-	new Ajax.Request(
-                'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                        method: 'post',
-                        postBody:'action=PortalAjax&mode=ajax&module=Portal&file=ListView&datamode='+mode,
-                        onComplete: function(response) {
-                                $("status").style.display="none";
-                                $('portalcont').innerHTML = response.responseText;
-                        }
-                }
-        );
-}
-function DeleteSite(id)
-{
-	if(confirm("Are you sure you want to delete ?"))
-	{
-		$("status").style.display="inline";
-		new Ajax.Request(
-          	      'index.php',
-                	{queue: {position: 'end', scope: 'command'},
-                        	method: 'post',
-	                        postBody:'action=PortalAjax&mode=ajax&file=Delete&module=Portal&record='+id,
-        	                onComplete: function(response) {
-                	                $("status").style.display="none";
-                        	        $('portalcont').innerHTML = response.responseText;
-                        	}
-                	}
-        	);
-	}
-}
-function SaveSite(id)
-{
-	if ($('portalurl').value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) {
-		alert('Site Url cannot be empty')
-		return false;
-	}
-	if ($('portalname').value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) {
-		alert('Site Name cannot be empty')
-		return false;
-	}
-	Effect.Puff('orgLay');	
-	$("status").style.display="inline";
-	var portalurl = document.getElementById('portalurl').value;
-	var portalurl = portalurl.replace(/&/g, "#$#$#");
-	var portalname = document.getElementById('portalname').value;
-        new Ajax.Request(
-        	'index.php',
-                {queue: {position: 'end', scope: 'command'},
-                	method: 'post',
-                        postBody:'action=PortalAjax&mode=ajax&file=Save&module=Portal&portalname='+portalname+'&portalurl='+portalurl+'&record='+id,
-                        onComplete: function(response) {
-                        		$("status").style.display="none";
-                                        $('portalcont').innerHTML = response.responseText;
-                        }
-                }
-	);
-}
-function setSite(oUrllist)
-{
-	var url = oUrllist.options[oUrllist.options.selectedIndex].value;
-	document.getElementById('locatesite').src = url;
-}
-
-var oRegex = new Object() ;
-oRegex.UriProtocol = new RegExp('') ;
-oRegex.UriProtocol.compile( '^(((http|https|ftp|news):\/\/)|mailto:)', 'gi' ) ;
-
-oRegex.UrlOnChangeProtocol = new RegExp('') ;
-oRegex.UrlOnChangeProtocol.compile( '^(http|https|ftp|news)://(?=.)', 'gi' ) ;
-
-function OnUrlChange()
-{
-    var sUrl;
-    var sProtocol;   
-                   
-          sUrl=document.getElementById("portalurl").value ;
-          sProtocol=oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
-          if ( sProtocol )
-          {
-             sUrl = sUrl.substr( sProtocol[0].length ) ;
-             document.getElementById("portalurl").value = sUrl ;
-          }
-
-        
-}
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+
+function fetchAddSite(id)
+{
+	$("status").style.display="inline";
+	new Ajax.Request(
+		'index.php',
+		{queue: {position: 'end', scope: 'command'},
+			method: 'post',
+			postBody:'module=Portal&action=PortalAjax&file=Popup&record='+id,
+			onComplete: function(response) {
+				$("status").style.display="none";
+				$('editportal_cont').innerHTML = response.responseText;
+			}
+		}
+	);
+}
+
+function fetchContents(mode)
+{
+	$("status").style.display="inline";
+	new Ajax.Request(
+                'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                        method: 'post',
+                        postBody:'action=PortalAjax&mode=ajax&module=Portal&file=ListView&datamode='+mode,
+                        onComplete: function(response) {
+                                $("status").style.display="none";
+                                $('portalcont').innerHTML = response.responseText;
+                        }
+                }
+        );
+}
+function DeleteSite(id)
+{
+	if(confirm(alert_arr.SURE_TO_DELETE))
+	{
+		$("status").style.display="inline";
+		new Ajax.Request(
+          	      'index.php',
+                	{queue: {position: 'end', scope: 'command'},
+                        	method: 'post',
+	                        postBody:'action=PortalAjax&mode=ajax&file=Delete&module=Portal&record='+id,
+        	                onComplete: function(response) {
+                	                $("status").style.display="none";
+                        	        $('portalcont').innerHTML = response.responseText;
+                        	}
+                	}
+        	);
+	}
+}
+function SaveSite(id)
+{
+	if ($('portalurl').value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) {
+		alert(alert_arr.SITEURL_CANNOT_BE_EMPTY)
+		return false;
+	}
+	if ($('portalname').value.replace(/^\s+/g, '').replace(/\s+$/g, '').length==0) {
+		alert(alert_arr.SITENAME_CANNOT_BE_EMPTY)
+		return false;
+	}
+	Effect.Puff('orgLay');	
+	$("status").style.display="inline";
+	var portalurl = document.getElementById('portalurl').value;
+	var portalurl = portalurl.replace(/&/g, "#$#$#");
+	var portalname = document.getElementById('portalname').value;
+        new Ajax.Request(
+        	'index.php',
+                {queue: {position: 'end', scope: 'command'},
+                	method: 'post',
+                        postBody:'action=PortalAjax&mode=ajax&file=Save&module=Portal&portalname='+portalname+'&portalurl='+portalurl+'&record='+id,
+                        onComplete: function(response) {
+                        		$("status").style.display="none";
+                                        $('portalcont').innerHTML = response.responseText;
+                        }
+                }
+	);
+}
+function setSite(oUrllist)
+{
+	var url = oUrllist.options[oUrllist.options.selectedIndex].value;
+	document.getElementById('locatesite').src = url;
+}
+
+var oRegex = new Object() ;
+oRegex.UriProtocol = new RegExp('') ;
+oRegex.UriProtocol.compile( '^(((http|https|ftp|news):\/\/)|mailto:)', 'gi' ) ;
+
+oRegex.UrlOnChangeProtocol = new RegExp('') ;
+oRegex.UrlOnChangeProtocol.compile( '^(http|https|ftp|news)://(?=.)', 'gi' ) ;
+
+function OnUrlChange()
+{
+    var sUrl;
+    var sProtocol;   
+                   
+          sUrl=document.getElementById("portalurl").value ;
+          sProtocol=oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
+          if ( sProtocol )
+          {
+             sUrl = sUrl.substr( sProtocol[0].length ) ;
+             document.getElementById("portalurl").value = sUrl ;
+          }
+
+        
+}

Modified: vtigercrm/branches/5.1_jens/modules/Portal/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Portal/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Portal/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -25,6 +25,6 @@
 'LBL_BOOKMARK_NAME_URL'=>'Bookmark Name &amp; URL',
 'LBL_TOOLS'=>'Tools',
 'LBL_MANAGE_SITES'=>'Manage Sites',
-'LBL_MY_SITES'=>'My Sites',
+'LBL_MY_SITES'=>'Sites',
 );
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/CallRelatedList.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/CallRelatedList.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/CallRelatedList.php Mon Apr 16 12:27:44 2007
@@ -52,6 +52,7 @@
 if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
 $related_array = getRelatedLists($currentModule,$focus);
 $smarty->assign("RELATEDLISTS", $related_array);
+$smarty->assign("BASE_ACCOUNT",getAccountName($focus->column_fields[account_id]));
 $category = getParentTab();
 $smarty->assign("CATEGORY",$category);
 $smarty->assign("UPDATEINFO",updateInfo($focus->id));

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/Charts.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/Charts.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/Charts.php Mon Apr 16 12:27:44 2007
@@ -1,1280 +1,1280 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Charts.php,v 1.12 2005/04/20 20:23:34 ray Exp $
- * Description:  Includes the functions for Customer module specific charts.
- ********************************************************************************/
-
-require_once('config.php');
-require_once('include/logging.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('Image/Graph.php');
-require_once('include/utils/utils.php');
-require_once('include/utils/GraphUtils.php');
-
-
-
-
-class jpgraph {
-	/**
-	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
-	 * param $datax- the month data to display in the x-axis
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function outcome_by_month($date_start='1971-10-15', $date_end='2071-10-15', $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
-		global $log;
-		$log->debug("Entering outcome_by_month(".$date_start.",". $date_end.",". $user_id.") method ...");
-		global $app_strings,$lang_crm, $app_list_strings, $current_module_strings,$current_user, $log, $charset, $tmp_dir;
-		global $theme;
-		include_once ('Image/Graph.php');
-		include_once ('Image/Canvas.php');
-
-		$log =& LoggerManager::getLogger('outcome_by_month chart');
-		// Set the basic parameters of the graph
-		$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
-		$imagemap = $canvas->getImageMap();
-		$graph =& Image_Graph::factory('graph', $canvas);
-		$log->debug("graph object created");
-
-		// add a TrueType font
-		$font =& $graph->addNew('font', calculate_font_name($lang_crm));
-		// set the font size to 11 pixels
-		$font->setSize(8);
-		
-		$graph->setFont($font);
-		// create the plotarea layout
-        $title =& Image_Graph::factory('title', array('Title',10));
-    	$plotarea =& Image_Graph::factory('plotarea',array(
-                    'axis',
-                    'axis'
-                ));
-        $footer =& Image_Graph::factory('title', array('Footer',8));
-		$graph->add(
-		    Image_Graph::vertical($title,
-	        Image_Graph::vertical(
-				$plotarea,
-        	    $footer,
-            	90
-		        ),
-        	5
-	    	)
-		);   
-
-		//$graph->SetScale("textlin");
-
-		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
-			//$font = calculate_font_family($lang_crm);
-
-			$log->debug("date_start is: $date_start");
-			$log->debug("date_end is: $date_end");
-			$log->debug("user_id is: ");
-			$log->debug($user_id);
-			$log->debug("cache_file_name is: $cache_file_name");
-
-			//build the where clause for the query that matches $user
-			$where = "(";
-			$first = true;
-			$current = 0;
-			foreach ($user_id as $the_id) {
-				if (!$first) $where .= "OR ";
-				$first = false;
-				$where .= "vtiger_crmentity.smcreatorid='$the_id' ";
-			}
-			$where .= ") ";
-
-			//build the where clause for the query that matches $date_start and $date_end
-			$where .= "AND closingdate >= '$date_start' AND closingdate <= '$date_end'";
-			$subtitle = $current_module_strings['LBL_DATE_RANGE']." ".getDisplayDate($date_start)." ".$current_module_strings['LBL_DATE_RANGE_TO']." ".getDisplayDate($date_end)."\n";
-
-			//Now do the db queries
-			//query for opportunity data that matches $datay and $user
-			$opp = new Potentials();
-			$opp_list = $opp->get_full_list("amount DESC, closingdate DESC", $where);
-
-			//build pipeline by sales stage data
-			$total = 0;
-			$count = array();
-			$sum = array();
-			$months = array();
-			$other = $current_module_strings['LBL_LEAD_SOURCE_OTHER'];
-			if (isset($opp_list)) {
-				foreach ($opp_list as $record) {
-					$month = substr_replace($record->column_fields['closingdate'],'',-3);
-					if (!in_array($month, $months)) { array_push($months, $month); }
-					if ($record->column_fields['sales_stage'] == 'Closed Won' || $record->column_fields['sales_stage'] == 'Closed Lost') {
-						$sales_stage=$record->column_fields['sales_stage'];
-					}
-					else {
-						$sales_stage=$other;
-					}
-
-					if (!isset($sum[$month][$sales_stage])) {
-						$sum[$month][$sales_stage] = 0;
-					}
-					if (isset($record->column_fields['amount']))	{
-						// Strip all non numbers from this string.
-						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
-						$sum[$month][$sales_stage] = $sum[$month][$sales_stage] + $amount;
-						if (isset($count[$month][$sales_stage])) {
-							$count[$month][$sales_stage]++;
-						}
-						else {
-							$count[$month][$sales_stage] = 1;
-						}
-						$total = $total + ($amount/1000);
-					}
-				}
-			}
-
-			$legend = array();
-			$datax = array();
-			$aTargets = array();
-			$aAlts = array();
-			$stages = array($other, 'Closed Lost', 'Closed Won');
-			//sort the months or push a bogus month on the array so that an empty chart is drawn
-			if (empty($months)) {
-				array_push($months, date('Y-m',time()));
-			}
-			else{
-				sort($months);
-			}
-			foreach($months as $month) {
-			  foreach($stages as $stage) {
-				$log->debug("stage is $stage");
-				if (!isset($datax[$stage])) {
-					$datax[$stage] = array();
-				}
-				if (!isset($aAlts[$stage])) {
-					$aAlts[$stage] = array();
-				}
-				if (!isset($aTargets[$stage])) {
-					$aTargets[$stage] = array();
-				}
-
-				if (isset($sum[$month][$stage])) {
-					array_push($datax[$stage], $sum[$month][$stage]/1000);
-					array_push($aAlts[$stage], $count[$month][$stage]." ".$current_module_strings['LBL_OPPS_OUTCOME']." $stage");
-				}
-				else {
-					array_push($datax[$stage], 0);
-					array_push($aAlts[$stage], "");
-				}
-				array_push($aTargets[$stage], "index.php?module=Potentials&action=ListView&date_closed=$month&sales_stage=".urlencode($stage)."&query=true&type=dbrd");
-			  }
-		  	  array_push($legend,$month);
-			}
-
-			$log->debug("datax is:");
-			$log->debug($datax);
-			$log->debug("aAlts is:");
-			$log->debug($aAlts);
-			$log->debug("aTargets is:");
-			$log->debug($aTargets);
-			$log->debug("sum is:");
-			$log->debug($sum);
-			$log->debug("count is:");
-			$log->debug($count);
-
-			//now build the bar plots for each user across the sales stages
-			$color = array('Closed Lost'=>'#FF9900','Closed Won'=>'#009933', $other=>'#0066CC');
-			$index = 0;
-			$datasets = array();
-			$xlabels = array();
-			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
-			foreach($stages as $stage) {
-				// Now create a bar plot
-				$datasets[$index] = & Image_Graph::factory('dataset');
-				foreach($datax[$stage] as $i => $y) {
-				  	$x = 1+2*$i;
-				    $datasets[$index]->addPoint(
-				        $x,
-				        $y,
-				        array(
-				            'url' => $aTargets[$stage][$i],
-				            'alt' => $aAlts[$stage][$i]
-				        )
-				    );
-				}
-
-				// Set fill colors for bars
-				$fills->addColor($color[$stage]);
-
-				$index++;
-			}
-			for($i=0;$i<count($months); $i++)
-			{
-			  $x = 1+2*$i;
-			  $xlabels[$x] = $months[$i];
-			  $xlabels[$x+1] = '';
-			}
-			
-			// compute maximum value because of grace jpGraph parameter not supported
-			$maximum = 0;
-			foreach($months as $num=>$m) {
-			  	$monthSum = 0;
-			  	foreach($stages as $stage) $monthSum += $datax[$stage][$num];
-				if($monthSum > $maximum) $maximum = $monthSum;
-				$log->debug('maximum = '.$maximum.' month = '.$m.' sum = '.$monthSum);
-			}
-
-			if($theme == "blue")
-			{
-				$font_color = "#212473";
-			}
-			else
-			{
-				$font_color = "#000000";
-			}
-			$font->setColor($font_color);
-
-			// Create the grouped bar plot
-			$gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked'));
-			$gbplot->setFillStyle($fills);
-
-			//You can change the width of the bars if you like
-			$gbplot->setBarWidth(50/count($months),"%");
-
-			// set margin
-			$plotarea->setPadding(array('top'=>0,'bottom'=>0,'left'=>10,'right'=>20));
-
-			// Set white margin color
-			$graph->setBackgroundColor('#F5F5F5');
-
-			// Use a box around the plot area
-			$gbplot->setBorderColor('black');
-
-			// Use a gradient to fill the plot area
-			$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', '#E5E5E5')));
-
-			// Setup title
-			$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
-				//$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
-			
-			$title->setText($titlestr);
-
-			// Create the xaxis labels
-			$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
-			    array($xlabels) 
-			); 
-
-			// Setup X-axis
-			$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
-			$xaxis->setDataPreprocessor($array_data);
-			$xaxis->forceMinimum(0);
-			$xaxis->forceMaximum(2*count($months));
-			$xaxis->setLabelInterval(1);
-			$xaxis->setTickOptions(0,0);
-			$xaxis->setLabelInterval(2,2);
-			$xaxis->setTickOptions(5,0,2);
-
-			// set grid
-			$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
-			$gridY->setLineColor('#E5E5E5 at 0.5');
-
-
-			// Add some grace to y-axis so the bars doesn't go
-			// all the way to the end of the plot area
-			$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
-			$yaxis->forceMaximum($maximum * 1.1);
-			$ticks = get_tickspacing($maximum);
-
-			// Setup the Y-axis to be displayed in the bottom of the
-			// graph. We also finetune the exact layout of the title,
-			// ticks and labels to make them look nice.
-			$yaxis->setAxisIntersection('max');
-
-			// Then fix the tick marks
-			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
-			$yaxis->setFontSize(8);
-			$yaxis->setDataPreprocessor($valueproc);
-			// Arrange Y-Axis tick marks inside
-			$yaxis->setLabelInterval($ticks[0]);
-			$yaxis->setTickOptions(-5,0);
-			$yaxis->setLabelInterval($ticks[1],2);
-			$yaxis->setTickOptions(-2,0,2);
-			$yaxis->setLabelOption('position','inside');
-
-			// Finally setup the title
-			$yaxis->setLabelOption('position','inside');
-			
-			// eliminate zero values
-			$gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
-			
-			// set markers
-			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
-			$marker->setDataPreprocessor($valueproc);
-			$marker->setFillColor('000000 at 0.0');
-			$marker->setBorderColor('000000 at 0.0');
-			$marker->setFontColor('white');
-			$marker->setFontSize(8);
-			$gbplot->setMarker($marker);
-
-			$subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
-			$footer->setText($subtitle);
-			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
-
-			// .. and stroke the graph
-			$imgMap = $graph->done(
-								    array(
-									        'tohtml' => true,
-									        'border' => 0,
-									        'filename' => $cache_file_name,
-									        'filepath' => './',
-									        'urlpath' => ''
-									    ));
-			//$imgMap = htmlspecialchars($output);
-			save_image_map($cache_file_name.'.map', $imgMap);
-		}
-		else {
-			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
-			fclose($imgMap_fp);
-		}
-		$fileModTime = filemtime($cache_file_name.'.map');
-		$return = "\n$imgMap";
-		$log->debug("Exiting outcome_by_month method ...");
-		return $return;
-	}
-
-	/**
-	 * Creates lead_source_by_outcome pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
-	 * param $datay- the lead source data to display in the x-axis
-	 * param $date_start- the begin date of opps to find
-	 * param $date_end- the end date of opps to find
-	 * param $ids - list of assigned vtiger_users of opps to find
-	 * param $cache_file_name - file name to write image to
-	 * param $refresh - boolean whether to rebuild image if exists
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function lead_source_by_outcome($datay=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
-		global $log,$current_user;
-		$log->debug("Entering lead_source_by_outcome(".$datay.",".$user_id.",".$cache_file_name.",".$refresh.") method ...");
-		global $app_strings,$lang_crm, $current_module_strings,$charset, $tmp_dir;
-		global $theme;
-
-		include_once ('Image/Graph.php');
-		include_once ('Image/Canvas.php');
-
-		$log =& LoggerManager::getLogger('lead_source_by_outcome chart');
-		// Set the basic parameters of the graph
-		$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
-		$imagemap = $canvas->getImageMap();
-		$graph =& Image_Graph::factory('graph', $canvas);
-		$log->debug("graph object created");
-		// add a TrueType font
-		$font =& $graph->addNew('font', calculate_font_name($lang_crm));
-		// set the font size to 11 pixels
-		$font->setSize(8);
-		
-		$graph->setFont($font);
-		// create the plotarea layout
-        $title =& Image_Graph::factory('title', array('Test',10));
-    	$plotarea =& Image_Graph::factory('plotarea',array(
-                    'axis',
-                    'axis',
-                    'horizontal'
-                ));
-        $footer =& Image_Graph::factory('title', array('Footer',8));
-		$graph->add(
-		    Image_Graph::vertical($title,
-	        Image_Graph::vertical(
-				$plotarea,
-        	    $footer,
-            	90
-		        ),
-        	5
-	    	)
-		);   
-
-		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
-
-			$log->debug("datay is:");
-			$log->debug($datay);
-			$log->debug("user_id is: ");
-			$log->debug($user_id);
-			$log->debug("cache_file_name is: $cache_file_name");
-
-			$where="";
-			//build the where clause for the query that matches $user
-			$count = count($user_id);
-			if ($count>0) {
-				$where = "(";
-				$first = true;
-				$current = 0;
-				foreach ($user_id as $the_id) {
-					if (!$first) $where .= "OR ";
-					$first = false;
-					$where .= "vtiger_crmentity.smcreatorid='$the_id' ";
-				}
-				$where .= ") ";
-			}
-
-			//build the where clause for the query that matches $datay
-			$count = count($datay);
-			if ($count>0) {
-				$where .= "AND ( ";
-				unset($first);
-				$first = true;
-				foreach ($datay as $key=>$value) {
-					if (!$first) $where .= "OR ";
-					$first = false;
-					$where .= "leadsource ='$key' ";
-				}
-				$where .= ")";
-			}
-
-			//Now do the db queries
-			//query for opportunity data that matches $datay and $user
-			$opp = new Potentials();
-			$opp_list = $opp->get_full_list("amount DESC, closingdate DESC", $where);
-
-			//build pipeline by sales stage data
-			$total = 0;
-			$count = array();
-			$sum = array();
-			$other = $current_module_strings['LBL_LEAD_SOURCE_OTHER'];
-			if (isset($opp_list)) {
-				foreach ($opp_list as $record) {
-					//if lead source is blank, set it to the language's "none" value
-					if (isset($record->column_fields['leadsource']) && $record->column_fields['leadsource'] != '') {
-						$lead_source = $record->column_fields['leadsource'];
-					}
-					else {
-						$lead_source = $current_module_strings['NTC_NO_LEGENDS'];
-					}
-
-					if ($record->column_fields['sales_stage'] == 'Closed Won' || $record->column_fields['sales_stage'] == 'Closed Lost') {
-						$sales_stage=$record->column_fields['sales_stage'];
-					}
-					else {
-						$sales_stage=$other;
-					}
-
-					if (!isset($sum[$lead_source][$sales_stage])) {
-						$sum[$lead_source][$sales_stage] = 0;
-					}
-					if (isset($record->column_fields['amount']))	{
-						// Strip all non numbers from this string.
-						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
-						$sum[$lead_source][$sales_stage] = $sum[$lead_source][$sales_stage] + $amount;
-						if (isset($count[$lead_source][$sales_stage])) {
-							$count[$lead_source][$sales_stage]++;
-						}
-						else {
-							$count[$lead_source][$sales_stage] = 1;
-						}
-						$total = $total + ($amount/1000);
-					}
-				}
-			}
-
-			$legend = array();
-			$datax = array();
-			$aTargets = array();
-			$aAlts = array();
-			$stages = array($other,'Closed Lost', 'Closed Won');
-			foreach($datay as $lead=>$translation) {
-			  if ($lead == '') {
-					$lead = $current_module_strings['NTC_NO_LEGENDS'];
-					$translation = $current_module_strings['NTC_NO_LEGENDS'];
-			  }
-			  foreach($stages as $stage) {
-				$log->debug("stage_key is $stage");
-				if (!isset($datax[$stage])) {
-					$datax[$stage] = array();
-				}
-				if (!isset($aAlts[$stage])) {
-					$aAlts[$stage] = array();
-				}
-				if (!isset($aTargets[$stage])) {
-					$aTargets[$stage] = array();
-				}
-
-				if (isset($sum[$lead][$stage])) {
-					array_push($datax[$stage], $sum[$lead][$stage]/1000);
-					array_push($aAlts[$stage], $count[$lead][$stage]." ".$current_module_strings['LBL_OPPS_OUTCOME']." $stage");
-				}
-				else {
-					array_push($datax[$stage], 0);
-					array_push($aAlts[$stage], "");
-				}
-				array_push($aTargets[$stage], "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead)."&sales_stage=".urlencode($stage)."&query=true&type=dbrd");
-			  }
-			  array_push($legend,$translation);
-			}
-
-			$log->debug("datax is:");
-			$log->debug($datax);
-			$log->debug("aAlts is:");
-			$log->debug($aAlts);
-			$log->debug("aTargets is:");
-			$log->debug($aTargets);
-			$log->debug("sum is:");
-			$log->debug($sum);
-			$log->debug("count is:");
-			$log->debug($count);
-
-			//now build the bar plots for each user across the sales stages
-			$color = array('Closed Lost'=>'FF9900','Closed Won'=>'009933', $other=>'0066CC');
-			$index = 0;
-			$xlabels = array();
-			$datasets = array();
-			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
-			foreach($stages as $stage) {
-				// Now create a bar pot
-				$datasets[$index] = & Image_Graph::factory('dataset');
-				foreach($datax[$stage] as $i => $y) {
-				  	$x = 1+2*$i;
-				    $datasets[$index]->addPoint(
-				        //$datay[$legend[$x]],
-				        $x,
-				        $y,
-				        array(
-				            'url' => $aTargets[$stage][$i],
-				            'alt' => $aAlts[$stage][$i],
-				            'target' => ''
-				        )
-				    );
-				}
-			for($i=0;$i<count($legend); $i++)
-			{
-			  $x = 1+2*$i;
-			  $xlabels[$x] = $legend[$i];
-			  $xlabels[$x+1] = '';
-			}
-
-				// Set fill colors for bars
-				$fills->addColor("#".$color[$stage]);
-
-				$log->debug("datax[$stage] is: ");
-				$log->debug($datax[$stage]);
-				$index++;
-			}
-			
-			// compute maximum value because of grace jpGraph parameter not supported
-			$maximum = 0;
-			foreach($legend as $legendidx=>$legend_text) {
-			  	$dataxSum = 0;
-				foreach($stages as $stage) $dataxSum += $datax[$stage][$legendidx];
-				if($dataxSum > $maximum) $maximum = $dataxSum;
-			}
-
-			if($theme == "blue")
-			{
-				$font_color = "#212473";
-			}
-			else
-			{
-				$font_color = "#000000";
-			}
-			$font->setColor($font_color);
-
-			// Create the grouped bar plot
-			$gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked'));
-			$gbplot->setFillStyle($fills);
-
-			//You can change the width of the bars if you like
-			$gbplot->setBarWidth(50/count($legend),"%");
-
-			// Set white margin color
-			$graph->setBackgroundColor('#F5F5F5');
-
-			// Use a box around the plot area
-			$gbplot->setBorderColor('black');
-
-			// Use a gradient to fill the plot area
-			$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
-
-			// Setup title
-			$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
-			//$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total;
-			$title->setText($titlestr);
-
-			// Create the xaxis labels
-			$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
-			    array($xlabels) 
-			); 
-
-			// Setup X-axis
-			$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
-			$xaxis->setDataPreprocessor($array_data);
-			$xaxis->forceMinimum(0);
-			$xaxis->forceMaximum(2*count($legend));
-			$xaxis->setLabelInterval(1);
-			$xaxis->setTickOptions(0,0);
-			$xaxis->setLabelInterval(2,2);
-			$xaxis->setTickOptions(5,0,2);
-			$xaxis->setInverted(true);
-			
-			// set grid
-			$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
-			$gridY->setLineColor('#E5E5E5 at 0.5');
-
-			// Add some grace to y-axis so the bars doesn't go
-			// all the way to the end of the plot area
-			$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
-			$yaxis->forceMaximum($maximum * 1.1);
-			$ticks = get_tickspacing($maximum);
-
-			// Then fix the tick marks
-			$yaxis->setFontSize(8);
-			$yaxis->setAxisIntersection('max');
-			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
-			$yaxis->setDataPreprocessor($valueproc);
-			$yaxis->setLabelInterval($ticks[0]);
-			$yaxis->setTickOptions(-5,0);
-			$yaxis->setLabelInterval($ticks[1],2);
-			$yaxis->setTickOptions(-2,0,2);
-			
-			// eliminate zero values
-			$gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
-			
-			// set markers
-			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
-			$marker->setDataPreprocessor($valueproc);
-			$marker->setFillColor('#000000 at 0.0');
-			$marker->setBorderColor('#000000 at 0.0');
-			$marker->setFontColor('white');
-			$marker->setFontSize(8);
-			$gbplot->setMarker($marker);
-
-			// Finally setup the title
-			$subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; 
-			$footer->setText($subtitle);
-			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
-
-			// .. and stroke the graph
-			$imgMap = $graph->done(
-								    array(
-									        'tohtml' => true,
-									        'border' => 0,
-									        'filename' => $cache_file_name,
-									        'filepath' => './',
-									        'urlpath' => ''
-									    ));
-			//$imgMap = htmlspecialchars($output);
-			save_image_map($cache_file_name.'.map', $imgMap);
-		}
-		else {
-			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
-			fclose($imgMap_fp);
-		}
-		$fileModTime = filemtime($cache_file_name.'.map');
-		$return = "\n$imgMap";
-		$log->debug("Exiting lead_source_by_outcome method ...");
-		return $return;
-	}
-
-	/**
-	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
-	 * param $datax- the sales stage data to display in the x-axis
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function pipeline_by_sales_stage($datax=array('foo','bar'), $date_start='2071-10-15', $date_end='2071-10-15', $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
-		global $log,$current_user;
-		$log->debug("Entering pipeline_by_sales_stage(".$datax.",".$date_start.",".$date_end.",".$user_id.",".$cache_file_name.",".$refresh.") method ...");
-		global $app_strings,$lang_crm, $current_module_strings, $charset, $tmp_dir;
-		global $theme;
-		include_once ('Image/Graph.php');
-		include_once ('Image/Canvas.php');
-
-		$log =& LoggerManager::getLogger('opportunity charts');
-		// Set the basic parameters of the graph
-
-		
-		$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
-		$imagemap = $canvas->getImageMap();
-		$graph =& Image_Graph::factory('graph', $canvas);
-		//$log->debug("graph object created");
-		// add a TrueType font
-		//$font =& $graph->addNew('font', calculate_font_name($lang_crm));
-		$font =& $graph->addNew('font', calculate_font_name($lang_crm));
-		// set the font size to 11 pixels
-		$font->setSize(8);
-		
-		$graph->setFont($font);
-        $title =& Image_Graph::factory('title', array('Test',10));
-    	$plotarea =& Image_Graph::factory('plotarea',array(
-                    'axis',
-                    'axis',
-                    'horizontal'
-                ));
-        $footer =& Image_Graph::factory('title', array('Footer',8));
-		$graph->add(
-		    Image_Graph::vertical($title,
-	        Image_Graph::vertical(
-				$plotarea,
-        	    $footer,
-            	90
-		        ),
-        	5
-	    	)
-		);   
-		$log->debug("graph object created");
-		
-
-		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
-
-			$log->debug("starting pipeline chart");
-			$log->debug("datax is:");
-			$log->debug($datax);
-			$log->debug("user_id is: ");
-			$log->debug($user_id);
-			$log->debug("cache_file_name is: $cache_file_name");
-
-			$where="";
-			//build the where clause for the query that matches $user
-			$count = count($user_id);
-			if ($count>0) {
-				$where = "(";
-				$first = true;
-				$current = 0;
-				foreach ($user_id as $the_id) {
-					if (!$first) $where .= "OR ";
-					$first = false;
-					//reference post
-					//if I change the owner of a opportunity, the graph shown on Home does not update correctly, this is because the graph is looking for the creatorid and not for the ownerid
-					//fix incorporated based on /sak's feedback
-					$where .= "vtiger_crmentity.smownerid='$the_id' ";
-				}
-				$where .= ") ";
-			}
-
-			//build the where clause for the query that matches $datax
-			$count = count($datax);
-			if ($count>0) {
-				$where .= "AND ( ";
-				unset($first);
-				$first = true;
-				foreach ($datax as $key=>$value) {
-					if (!$first) $where .= "OR ";
-					$first = false;
-					$where .= "sales_stage ='$key' ";
-				}
-				$where .= ")";
-			}
-
-			//build the where clause for the query that matches $date_start and $date_end
-			$where .= "AND closingdate >= '$date_start' AND closingdate <= '$date_end'";
-			$subtitle = $current_module_strings['LBL_DATE_RANGE']." ".getDisplayDate($date_start)." ".$current_module_strings['LBL_DATE_RANGE_TO']." ".getDisplayDate($date_end)."\n";
-
-			//Now do the db queries
-			//query for opportunity data that matches $datax and $user
-			$opp = new Potentials();
-			$opp_list = $opp->get_full_list("amount DESC, closingdate DESC", $where);
-
-			//build pipeline by sales stage data
-			$total = 0;
-			$count = array();
-			$sum = array();
-			if (isset($opp_list)) {
-				foreach ($opp_list as $record) {
-					if (!isset($sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) {
-						$sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = 0;
-					}
-					if (isset($record->column_fields['amount']))	{
-						// Strip all non numbers from this string.
-						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
-						$sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = $sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] + $amount;
-						if (isset($count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) {
-							$count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']]++;
-						}
-						else {
-							$count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = 1;
-						}
-						$total = $total + ($amount/1000);
-					}
-				}
-			}
-
-			$legend = array();
-			$datay = array();
-			$aTargets = array();
-			$aAlts = array();
-			foreach ($datax as $stage_key=>$stage_translation) {
-			  foreach ($user_id as $the_id) {
-			  	$the_user = get_assigned_user_name($the_id);
-				if (!isset($datay[$the_id])) {
-					$datay[$the_id] = array();
-				}
-				if (!isset($aAlts[$the_id])) {
-					$aAlts[$the_id] = array();
-				}
-				if (!isset($aTargets[$the_id])) {
-					$aTargets[$the_id] = array();
-				}
-
-				if (isset($sum[$stage_key][$the_id])) {
-					array_push($datay[$the_id], $sum[$stage_key][$the_id]/1000);
-					array_push($aAlts[$the_id], $the_user.' - '.$count[$stage_key][$the_id]." ".$current_module_strings['LBL_OPPS_IN_STAGE']." $stage_translation");
-				}
-				else {
-					array_push($datay[$the_id], 0);
-					array_push($aAlts[$the_id], "");
-				}
-				array_push($aTargets[$the_id], "index.php?module=Potentials&action=ListView&assigned_user_id=$the_id&sales_stage=".urlencode($stage_key)."&closingdate_start=".urlencode($date_start)."&closingdate_end=".urlencode($date_end)."&query=true&type=dbrd");
-			  }
-			  array_push($legend,$stage_translation);
-			}
-
-			$log->debug("datay is:");
-			$log->debug($datay);
-			$log->debug("aAlts is:");
-			$log->debug($aAlts);
-			$log->debug("aTargets is:");
-			$log->debug($aTargets);
-			$log->debug("sum is:");
-			$log->debug($sum);
-			$log->debug("count is:");
-			$log->debug($count);
-
-			//now build the bar plots for each user across the sales stages
-			$colors = color_generator(count($user_id),'#D50100','#002222');
-			$index = 0;
-			$datasets = array();
-			$xlabels = array();
-			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
-			foreach($user_id as $the_id) {
-				// Now create a bar pot
-				$datasets[$index] = & Image_Graph::factory('dataset');
-				foreach($datay[$the_id] as $i => $y) {
-				    $x = 1+2*$i;
-				    $datasets[$index]->addPoint(
-				        $x,
-				        $y,
-				        array(
-				            'url' => $aTargets[$the_id][$i],
-				            'alt' => $aAlts[$the_id][$i]
-				        )
-				    );
-				}
-
-				// Set fill colors for bars
-				$fills->addColor($colors[$index]);
-
-				$index++;
-			}
-			for($i=0;$i<count($legend); $i++)
-			{
-			  $x = 1+2*$i;
-			  $xlabels[$x] = $legend[$i];
-			  $xlabels[$x+1] = '';
-			}
-			
-			// compute maximum value because of grace jpGraph parameter not supported
-			$maximum = 0;
-			foreach($legend as $legendidx=>$legend_text) {
-			  	$legendsum = 0;
-				foreach($user_id as $the_id) $legendsum += $datay[$the_id][$legendidx];
-				if($legendsum > $maximum) $maximum = $legendsum;
-			}
-			// Create the grouped bar plot
-			$gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked'));
-			$gbplot->setFillStyle($fills);
-
-			//You can change the width of the bars if you like
-			$gbplot->setBarWidth(50/count($legend),"%");
-
-
-			// Set white margin color
-			$graph->setBackgroundColor('#F5F5F5');
-
-			// Use a box around the plot area
-			$gbplot->setBorderColor('black');
-
-			// Use a gradient to fill the plot area
-			$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
-
-			if($theme == "blue")
-			{
-				$font_color = "#212473";
-			}
-			else
-			{
-				$font_color = "#000000";
-			}
-			$font->setColor($font_color);
-
-			// Setup title
-			$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
-			//$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
-			$title->setText($titlestr);
-
-			// Create the xaxis labels
-			$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
-			    array($xlabels) 
-			); 
-
-		
-			// Setup X-axis
-			$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
-			$xaxis->setDataPreprocessor($array_data);
-			$xaxis->forceMinimum(0);
-			$xaxis->forceMaximum(2*count($legend));
-			$xaxis->setLabelInterval(1);
-			$xaxis->setTickOptions(0,0);
-			$xaxis->setLabelInterval(2,2);
-			$xaxis->setTickOptions(5,0,2);
-			$xaxis->setInverted(true);
-
-			// Setup Y-axis
-			$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
-			$yaxis->setFontSize(8);
-			$yaxis->setAxisIntersection('max');
-
-			// Add some grace to y-axis so the bars doesn't go
-			// all the way to the end of the plot area
-			$yaxis->forceMaximum($maximum * 1.1);
-			$ticks = get_tickspacing($maximum);
-			
-			// set grid
-			$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
-			$gridY->setLineColor('#E5E5E5 at 0.5');
-
-			// First make the labels look right
-			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
-			$yaxis->setDataPreprocessor($valueproc);
-			$yaxis->setLabelInterval($ticks[0]);
-			$yaxis->setTickOptions(-5,0);
-			$yaxis->setLabelInterval($ticks[1],2);
-			$yaxis->setTickOptions(-2,0,2);
-			
-			// eliminate zero values
-			$gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
-			
-			// set markers
-			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
-			$marker->setDataPreprocessor($valueproc);
-			$marker->setFillColor('000000 at 0.0');
-			$marker->setBorderColor('000000 at 0.0');
-			$marker->setFontColor('white');
-			$marker->setFontSize(8);
-			$gbplot->setMarker($marker);
-
-			// Finally setup the title
-
-			$subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; 
-			$footer->setText($subtitle);
-			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
-
-			// .. and stroke the graph
-			$imgMap = $graph->done(
-								    array(
-									        'tohtml' => true,
-									        'border' => 0,
-									        'filename' => $cache_file_name,
-									        'filepath' => './',
-									        'urlpath' => ''
-									    ));
-			//$imgMap = $graph->GetHTMLImageMap('pipeline');
-			save_image_map($cache_file_name.'.map', $imgMap);
-		}
-		else {
-			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
-			fclose($imgMap_fp);
-		}
-		$fileModTime = filemtime($cache_file_name.'.map');
-		$return = "\n$imgMap";
-		$log->debug("Exiting pipeline_by_sales_stage method ...");
-		return $return;
-	}
-
-	/**
-	 * Creates pie chart image of opportunities by lead_source.
-	 * param $datax- the sales stage data to display in the x-axis
-	 * param $datay- the sum of opportunity amounts for each opportunity in each sales stage
-	 * to display in the y-axis
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function pipeline_by_lead_source($legends=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=true,$width=900,$height=500){
-		global $log,$current_user;
-		$log->debug("Entering pipeline_by_lead_source(".$legends.") method ...");
-		global $app_strings,$lang_crm, $current_module_strings, $log, $charset, $tmp_dir;
-		global $theme;
-
-		include_once ('Image/Graph.php');
-		include_once ('Image/Canvas.php');
-
-		$font = calculate_font_name($lang_crm);
-
-		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
-			$log =& LoggerManager::getLogger('opportunity charts');
-			$log->debug("starting pipeline chart");
-			$log->debug("legends is:");
-			$log->debug($legends);
-			$log->debug("user_id is: ");
-			$log->debug($user_id);
-			$log->debug("cache_file_name is: $cache_file_name");
-
-			//Now do the db queries
-			//query for opportunity data that matches $legends and $user
-			$where="";
-			//build the where clause for the query that matches $user
-			$count = count($user_id);
-			if ($count>0) {
-				$where = "(";
-				$first = true;
-				foreach ($user_id as $the_id) {
-					if (!$first) $where .= "OR ";
-					$first = false;
-					$where .= "vtiger_crmentity.smcreatorid='$the_id' ";
-				}
-				$where .= ") ";
-			}
-
-			//build the where clause for the query that matches $datax
-			$count = count($legends);
-			if ($count>0) {
-				$where .= "AND ( ";
-				$first = true;
-				foreach ($legends as $key=>$value) {
-					if (!$first) $where .= "OR ";
-					$first = false;
-					$where .= "leadsource	='$key' ";
-				}
-				$where .= ")";
-			}
-
-			$opp = new Potentials();
-			$opp_list = $opp->get_full_list("amount DESC, closingdate DESC", $where);
-
-			//build pipeline by lead source data
-			$total = 0;
-			$count = array();
-			$sum = array();
-			if (isset($opp_list)) {
-				foreach ($opp_list as $record) {
-					if (!isset($sum[$record->column_fields['leadsource']])) $sum[$record->column_fields['leadsource']] = 0;
-					if (isset($record->column_fields['amount']) && isset($record->column_fields['leadsource']))	{
-						// Strip all non numbers from this string.
-						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
-						$sum[$record->column_fields['leadsource']] = $sum[$record->column_fields['leadsource']] + ($amount/1000);
-						if (isset($count[$record->column_fields['leadsource']])) $count[$record->column_fields['leadsource']]++;
-						else $count[$record->column_fields['leadsource']] = 1;
-						$total = $total + ($amount/1000);
-					}
-				}
-			}
-
-			$visible_legends = array();
-			$data= array();
-			$aTargets = array();
-			$aAlts = array();
-			foreach ($legends as $lead_source_key=>$lead_source_translation) {
-				if (isset($sum[$lead_source_key]))
-				{
-					array_push($data, $sum[$lead_source_key]);
-					if($lead_source_key != '')
-					{
-						array_push($visible_legends, $lead_source_translation);
-					}
-					else
-					{
-						// put none in if the vtiger_field is blank.
-						array_push($visible_legends, $current_module_strings['NTC_NO_LEGENDS']);
-					}
-					array_push($aTargets, "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead_source_key)."&query=true&type=dbrd");
-					array_push($aAlts, $count[$lead_source_key]." ".$current_module_strings['LBL_OPPS_IN_LEAD_SOURCE']." $lead_source_translation	");
-				}
-			}
-
-			$log->debug("sum is:");
-			$log->debug($sum);
-			$log->debug("count is:");
-			$log->debug($count);
-			$log->debug("total is: $total");
-			if ($total == 0) {
-$log->debug("Exiting pipeline_by_lead_source method ...");
-				return ($current_module_strings['ERR_NO_OPPS']);
-			}
-
-			if($theme == "blue")
-			{
-				$font_color = "#212473";
-			}
-			else
-			{
-				$font_color = "#000000";
-			}
-
-	
-			$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
-			$imagemap = $canvas->getImageMap();
-			$graph =& Image_Graph::factory('graph', $canvas);
-	
-			$font =& $graph->addNew('font', calculate_font_name($lang_crm));
-			// set the font size to 11 pixels
-			$font->setSize(8);
-			$font->setColor($font_color);
-			
-			$graph->setFont($font);
-			// create the plotarea layout
-	        $title =& Image_Graph::factory('title', array('Test',10));
-	    	$plotarea =& Image_Graph::factory('plotarea',array(
-                    'category',
-                    'axis'
-                ));
-	        $footer =& Image_Graph::factory('title', array('Footer',8));
-			$graph->add(
-			    Image_Graph::vertical($title,
-		        Image_Graph::vertical(
-					$plotarea,
-	        	    $footer,
-	            	90
-			        ),
-	        	5
-		    	)
-			);   
-
-			// Generate colours
-			$colors = color_generator(count($visible_legends),'#33CCFF','#3322FF');
-			$index = 0;
-			$dataset = & Image_Graph::factory('dataset');
-			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
-			foreach($visible_legends as $legend) {
-			    $dataset->addPoint(
-			        $legend,
-			        $data[$index],
-			        array(
-			            'url' => $aTargets[$index],
-			            'alt' => $aAlts[$index]
-			        )
-			    );
-				$fills->addColor($colors[$index]);
-			    $log->debug('point ='.$legend.','.$data[$index]);
-
-				$index++;
-			}
-
-			// create the pie chart and associate the filling colours			
-			$gbplot = & $plotarea->addNew('pie', $dataset);
-			$plotarea->hideAxis();
-			$gbplot->setFillStyle($fills);
-
-			// Setup title
-			$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
-			//$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
-
-			$title->setText($titlestr);
-
-			// format the data values
-			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
-
-			// set markers
-			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
-			$marker->setDataPreprocessor($valueproc);
-			$marker->setFillColor('#FFFFFF');
-			$marker->setBorderColor($font_color);
-			$marker->setFontColor($font_color);
-			$marker->setFontSize(8);
-			$pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker));
-			$gbplot->setMarker($pointingMarker);
-			
-			// set legend
-			$legend_box =& $plotarea->addNew('legend');
-			$legend_box->setPadding(array('top'=>20,'bottom'=>0,'left'=>0,'right'=>0));
-			$legend_box->setFillColor('#F5F5F5');
-			$legend_box->showShadow();
-
-			$subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
-			$footer->setText($subtitle);
-			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_LEFT);
-
-			$imgMap = $graph->done(
-								    array(
-									        'tohtml' => true,
-									        'border' => 0,
-									        'filename' => $cache_file_name,
-									        'filepath' => './',
-									        'urlpath' => ''
-									    ));
-			//$imgMap = htmlspecialchars($output);
-			save_image_map($cache_file_name.'.map', $imgMap);
-		}
-		else {
-			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
-			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
-			fclose($imgMap_fp);
-		}
-		$fileModTime = filemtime($cache_file_name.'.map');
-		$return = "\n$imgMap";
-		$log->debug("Exiting pipeline_by_lead_source method ...");
-		return $return;
-
-	}
-
-}
-
-
-/**
- * Creates a file with the image map
- * param $filename - file name to save to
- * param $image_map - image map string to save
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- */
-function save_image_map($filename,$image_map)
-{
-	global $log;
-	$log->debug("Entering save_image_map(".$filename.",".$image_map.") method ...");
-	// save the image map to file
-	$log =& LoggerManager::getLogger('save_image_file');
-
-	if (!$handle = fopen($filename, 'w')) {
-		$log->debug("Cannot open file ($filename)");
-		$log->debug("Exiting save_image_map method ...");
-		return;
-	}
-
-	// Write $somecontent to our opened file.
-	if (fwrite($handle, $image_map) === FALSE) {
-	   $log->debug("Cannot write to file ($filename)");
-	   $log->debug("Exiting save_image_map method ...");
-	   return false;
-	}
-
-	$log->debug("Success, wrote ($image_map) to file ($filename)");
-
-	fclose($handle);
-	$log->debug("Exiting save_image_map method ...");
-	return true;
-
-}
-
-// retrieve the translated strings.
-$app_strings = return_application_language($current_language);
-
-if(isset($app_strings['LBL_CHARSET']))
-{
-	$charset = $app_strings['LBL_CHARSET'];
-}
-else
-{
-	$charset = $default_charset;
-}
-
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Charts.php,v 1.12 2005/04/20 20:23:34 ray Exp $
+ * Description:  Includes the functions for Customer module specific charts.
+ ********************************************************************************/
+
+require_once('config.php');
+require_once('include/logging.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('Image/Graph.php');
+require_once('include/utils/utils.php');
+require_once('include/utils/GraphUtils.php');
+
+
+
+
+class jpgraph {
+	/**
+	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
+	 * param $datax- the month data to display in the x-axis
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function outcome_by_month($date_start='1971-10-15', $date_end='2071-10-15', $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
+		global $log;
+		$log->debug("Entering outcome_by_month(".$date_start.",". $date_end.",". $user_id.") method ...");
+		global $app_strings,$lang_crm, $app_list_strings, $current_module_strings,$current_user, $log, $charset, $tmp_dir;
+		global $theme;
+		include_once ('Image/Graph.php');
+		include_once ('Image/Canvas.php');
+
+		$log =& LoggerManager::getLogger('outcome_by_month chart');
+		// Set the basic parameters of the graph
+		$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+		$imagemap = $canvas->getImageMap();
+		$graph =& Image_Graph::factory('graph', $canvas);
+		$log->debug("graph object created");
+
+		// add a TrueType font
+		$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+		// set the font size to 11 pixels
+		$font->setSize(8);
+		
+		$graph->setFont($font);
+		// create the plotarea layout
+        $title =& Image_Graph::factory('title', array('Title',10));
+    	$plotarea =& Image_Graph::factory('plotarea',array(
+                    'axis',
+                    'axis'
+                ));
+        $footer =& Image_Graph::factory('title', array('Footer',8));
+		$graph->add(
+		    Image_Graph::vertical($title,
+	        Image_Graph::vertical(
+				$plotarea,
+        	    $footer,
+            	90
+		        ),
+        	5
+	    	)
+		);   
+
+		//$graph->SetScale("textlin");
+
+		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
+			//$font = calculate_font_family($lang_crm);
+
+			$log->debug("date_start is: $date_start");
+			$log->debug("date_end is: $date_end");
+			$log->debug("user_id is: ");
+			$log->debug($user_id);
+			$log->debug("cache_file_name is: $cache_file_name");
+
+			//build the where clause for the query that matches $user
+			$where = "";
+			$first = true;
+			$current = 0;
+			/*foreach ($user_id as $the_id) {
+				if (!$first) $where .= "OR ";
+				$first = false;
+				$where .= "vtiger_crmentity.smcreatorid='$the_id' ";
+			}
+			$where .= ") ";*/
+
+			//build the where clause for the query that matches $date_start and $date_end
+			$where .= " closingdate >= '$date_start' AND closingdate <= '$date_end'";
+			$subtitle = $current_module_strings['LBL_DATE_RANGE']." ".getDisplayDate($date_start)." ".$current_module_strings['LBL_DATE_RANGE_TO']." ".getDisplayDate($date_end)."\n";
+
+			//Now do the db queries
+			//query for opportunity data that matches $datay and $user
+			$opp = new Potentials();
+			$opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where);
+
+			//build pipeline by sales stage data
+			$total = 0;
+			$count = array();
+			$sum = array();
+			$months = array();
+			$other = $current_module_strings['LBL_LEAD_SOURCE_OTHER'];
+			if (isset($opp_list)) {
+				foreach ($opp_list as $record) {
+					$month = substr_replace($record->column_fields['closingdate'],'',-3);
+					if (!in_array($month, $months)) { array_push($months, $month); }
+					if ($record->column_fields['sales_stage'] == 'Closed Won' || $record->column_fields['sales_stage'] == 'Closed Lost') {
+						$sales_stage=$record->column_fields['sales_stage'];
+					}
+					else {
+						$sales_stage=$other;
+					}
+
+					if (!isset($sum[$month][$sales_stage])) {
+						$sum[$month][$sales_stage] = 0;
+					}
+					if (isset($record->column_fields['amount']))	{
+						// Strip all non numbers from this string.
+						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
+						$sum[$month][$sales_stage] = $sum[$month][$sales_stage] + $amount;
+						if (isset($count[$month][$sales_stage])) {
+							$count[$month][$sales_stage]++;
+						}
+						else {
+							$count[$month][$sales_stage] = 1;
+						}
+						$total = $total + ($amount/1000);
+					}
+				}
+			}
+
+			$legend = array();
+			$datax = array();
+			$aTargets = array();
+			$aAlts = array();
+			$stages = array($other, 'Closed Lost', 'Closed Won');
+			//sort the months or push a bogus month on the array so that an empty chart is drawn
+			if (empty($months)) {
+				array_push($months, date('Y-m',time()));
+			}
+			else{
+				sort($months);
+			}
+			foreach($months as $month) {
+			  foreach($stages as $stage) {
+				$log->debug("stage is $stage");
+				if (!isset($datax[$stage])) {
+					$datax[$stage] = array();
+				}
+				if (!isset($aAlts[$stage])) {
+					$aAlts[$stage] = array();
+				}
+				if (!isset($aTargets[$stage])) {
+					$aTargets[$stage] = array();
+				}
+
+				if (isset($sum[$month][$stage])) {
+					array_push($datax[$stage], $sum[$month][$stage]/1000);
+					array_push($aAlts[$stage], $count[$month][$stage]." ".$current_module_strings['LBL_OPPS_OUTCOME']." $stage");
+				}
+				else {
+					array_push($datax[$stage], 0);
+					array_push($aAlts[$stage], "");
+				}
+				array_push($aTargets[$stage], "index.php?module=Potentials&action=ListView&date_closed=$month&sales_stage=".urlencode($stage)."&query=true&type=dbrd");
+			  }
+		  	  array_push($legend,$month);
+			}
+
+			$log->debug("datax is:");
+			$log->debug($datax);
+			$log->debug("aAlts is:");
+			$log->debug($aAlts);
+			$log->debug("aTargets is:");
+			$log->debug($aTargets);
+			$log->debug("sum is:");
+			$log->debug($sum);
+			$log->debug("count is:");
+			$log->debug($count);
+
+			//now build the bar plots for each user across the sales stages
+			$color = array('Closed Lost'=>'#FF9900','Closed Won'=>'#009933', $other=>'#0066CC');
+			$index = 0;
+			$datasets = array();
+			$xlabels = array();
+			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
+			foreach($stages as $stage) {
+				// Now create a bar plot
+				$datasets[$index] = & Image_Graph::factory('dataset');
+				foreach($datax[$stage] as $i => $y) {
+				  	$x = 1+2*$i;
+				    $datasets[$index]->addPoint(
+				        $x,
+				        $y,
+				        array(
+				            'url' => $aTargets[$stage][$i],
+				            'alt' => $aAlts[$stage][$i]
+				        )
+				    );
+				}
+
+				// Set fill colors for bars
+				$fills->addColor($color[$stage]);
+
+				$index++;
+			}
+			for($i=0;$i<count($months); $i++)
+			{
+			  $x = 1+2*$i;
+			  $xlabels[$x] = $months[$i];
+			  $xlabels[$x+1] = '';
+			}
+			
+			// compute maximum value because of grace jpGraph parameter not supported
+			$maximum = 0;
+			foreach($months as $num=>$m) {
+			  	$monthSum = 0;
+			  	foreach($stages as $stage) $monthSum += $datax[$stage][$num];
+				if($monthSum > $maximum) $maximum = $monthSum;
+				$log->debug('maximum = '.$maximum.' month = '.$m.' sum = '.$monthSum);
+			}
+
+			if($theme == "blue")
+			{
+				$font_color = "#212473";
+			}
+			else
+			{
+				$font_color = "#000000";
+			}
+			$font->setColor($font_color);
+
+			// Create the grouped bar plot
+			$gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked'));
+			$gbplot->setFillStyle($fills);
+
+			//You can change the width of the bars if you like
+			$gbplot->setBarWidth(50/count($months),"%");
+
+			// set margin
+			$plotarea->setPadding(array('top'=>0,'bottom'=>0,'left'=>10,'right'=>20));
+
+			// Set white margin color
+			$graph->setBackgroundColor('#F5F5F5');
+
+			// Use a box around the plot area
+			$gbplot->setBorderColor('black');
+
+			// Use a gradient to fill the plot area
+			$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', '#E5E5E5')));
+
+			// Setup title
+			$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+				//$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
+			
+			$title->setText($titlestr);
+
+			// Create the xaxis labels
+			$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
+			    array($xlabels) 
+			); 
+
+			// Setup X-axis
+			$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
+			$xaxis->setDataPreprocessor($array_data);
+			$xaxis->forceMinimum(0);
+			$xaxis->forceMaximum(2*count($months));
+			$xaxis->setLabelInterval(1);
+			$xaxis->setTickOptions(0,0);
+			$xaxis->setLabelInterval(2,2);
+			$xaxis->setTickOptions(5,0,2);
+
+			// set grid
+			$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
+			$gridY->setLineColor('#E5E5E5 at 0.5');
+
+
+			// Add some grace to y-axis so the bars doesn't go
+			// all the way to the end of the plot area
+			$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+			$yaxis->forceMaximum($maximum * 1.1);
+			$ticks = get_tickspacing($maximum);
+
+			// Setup the Y-axis to be displayed in the bottom of the
+			// graph. We also finetune the exact layout of the title,
+			// ticks and labels to make them look nice.
+			$yaxis->setAxisIntersection('max');
+
+			// Then fix the tick marks
+			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
+			$yaxis->setFontSize(8);
+			$yaxis->setDataPreprocessor($valueproc);
+			// Arrange Y-Axis tick marks inside
+			$yaxis->setLabelInterval($ticks[0]);
+			$yaxis->setTickOptions(-5,0);
+			$yaxis->setLabelInterval($ticks[1],2);
+			$yaxis->setTickOptions(-2,0,2);
+			$yaxis->setLabelOption('position','inside');
+
+			// Finally setup the title
+			$yaxis->setLabelOption('position','inside');
+			
+			// eliminate zero values
+			$gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
+			
+			// set markers
+			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+			$marker->setDataPreprocessor($valueproc);
+			$marker->setFillColor('000000 at 0.0');
+			$marker->setBorderColor('000000 at 0.0');
+			$marker->setFontColor('white');
+			$marker->setFontSize(8);
+			$gbplot->setMarker($marker);
+
+			$subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
+			$footer->setText($subtitle);
+			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
+
+			// .. and stroke the graph
+			$imgMap = $graph->done(
+								    array(
+									        'tohtml' => true,
+									        'border' => 0,
+									        'filename' => $cache_file_name,
+									        'filepath' => './',
+									        'urlpath' => ''
+									    ));
+			//$imgMap = htmlspecialchars($output);
+			save_image_map($cache_file_name.'.map', $imgMap);
+		}
+		else {
+			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
+			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			fclose($imgMap_fp);
+		}
+		$fileModTime = filemtime($cache_file_name.'.map');
+		$return = "\n$imgMap";
+		$log->debug("Exiting outcome_by_month method ...");
+		return $return;
+	}
+
+	/**
+	 * Creates lead_source_by_outcome pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
+	 * param $datay- the lead source data to display in the x-axis
+	 * param $date_start- the begin date of opps to find
+	 * param $date_end- the end date of opps to find
+	 * param $ids - list of assigned vtiger_users of opps to find
+	 * param $cache_file_name - file name to write image to
+	 * param $refresh - boolean whether to rebuild image if exists
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function lead_source_by_outcome($datay=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
+		global $log,$current_user;
+		$log->debug("Entering lead_source_by_outcome(".$datay.",".$user_id.",".$cache_file_name.",".$refresh.") method ...");
+		global $app_strings,$lang_crm, $current_module_strings,$charset, $tmp_dir;
+		global $theme;
+
+		include_once ('Image/Graph.php');
+		include_once ('Image/Canvas.php');
+
+		$log =& LoggerManager::getLogger('lead_source_by_outcome chart');
+		// Set the basic parameters of the graph
+		$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+		$imagemap = $canvas->getImageMap();
+		$graph =& Image_Graph::factory('graph', $canvas);
+		$log->debug("graph object created");
+		// add a TrueType font
+		$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+		// set the font size to 11 pixels
+		$font->setSize(8);
+		
+		$graph->setFont($font);
+		// create the plotarea layout
+        $title =& Image_Graph::factory('title', array('Test',10));
+    	$plotarea =& Image_Graph::factory('plotarea',array(
+                    'axis',
+                    'axis',
+                    'horizontal'
+                ));
+        $footer =& Image_Graph::factory('title', array('Footer',8));
+		$graph->add(
+		    Image_Graph::vertical($title,
+	        Image_Graph::vertical(
+				$plotarea,
+        	    $footer,
+            	90
+		        ),
+        	5
+	    	)
+		);   
+
+		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
+
+			$log->debug("datay is:");
+			$log->debug($datay);
+			$log->debug("user_id is: ");
+			$log->debug($user_id);
+			$log->debug("cache_file_name is: $cache_file_name");
+
+			$where="";
+			//build the where clause for the query that matches $user
+			/*$count = count($user_id);
+			if ($count>0) {
+				$where = "(";
+				$first = true;
+				$current = 0;
+				foreach ($user_id as $the_id) {
+					if (!$first) $where .= "OR ";
+					$first = false;
+					$where .= "vtiger_crmentity.smcreatorid='$the_id' ";
+				}
+				$where .= ") ";
+			}*/
+
+			//build the where clause for the query that matches $datay
+			$count = count($datay);
+			if ($count>0) {
+				$where .= " ( ";
+				unset($first);
+				$first = true;
+				foreach ($datay as $key=>$value) {
+					if (!$first) $where .= "OR ";
+					$first = false;
+					$where .= "leadsource ='$key' ";
+				}
+				$where .= ")";
+			}
+
+			//Now do the db queries
+			//query for opportunity data that matches $datay and $user
+			$opp = new Potentials();
+			$opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where);
+
+			//build pipeline by sales stage data
+			$total = 0;
+			$count = array();
+			$sum = array();
+			$other = $current_module_strings['LBL_LEAD_SOURCE_OTHER'];
+			if (isset($opp_list)) {
+				foreach ($opp_list as $record) {
+					//if lead source is blank, set it to the language's "none" value
+					if (isset($record->column_fields['leadsource']) && $record->column_fields['leadsource'] != '') {
+						$lead_source = $record->column_fields['leadsource'];
+					}
+					else {
+						$lead_source = $current_module_strings['NTC_NO_LEGENDS'];
+					}
+
+					if ($record->column_fields['sales_stage'] == 'Closed Won' || $record->column_fields['sales_stage'] == 'Closed Lost') {
+						$sales_stage=$record->column_fields['sales_stage'];
+					}
+					else {
+						$sales_stage=$other;
+					}
+
+					if (!isset($sum[$lead_source][$sales_stage])) {
+						$sum[$lead_source][$sales_stage] = 0;
+					}
+					if (isset($record->column_fields['amount']))	{
+						// Strip all non numbers from this string.
+						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
+						$sum[$lead_source][$sales_stage] = $sum[$lead_source][$sales_stage] + $amount;
+						if (isset($count[$lead_source][$sales_stage])) {
+							$count[$lead_source][$sales_stage]++;
+						}
+						else {
+							$count[$lead_source][$sales_stage] = 1;
+						}
+						$total = $total + ($amount/1000);
+					}
+				}
+			}
+
+			$legend = array();
+			$datax = array();
+			$aTargets = array();
+			$aAlts = array();
+			$stages = array($other,'Closed Lost', 'Closed Won');
+			foreach($datay as $lead=>$translation) {
+			  if ($lead == '') {
+					$lead = $current_module_strings['NTC_NO_LEGENDS'];
+					$translation = $current_module_strings['NTC_NO_LEGENDS'];
+			  }
+			  foreach($stages as $stage) {
+				$log->debug("stage_key is $stage");
+				if (!isset($datax[$stage])) {
+					$datax[$stage] = array();
+				}
+				if (!isset($aAlts[$stage])) {
+					$aAlts[$stage] = array();
+				}
+				if (!isset($aTargets[$stage])) {
+					$aTargets[$stage] = array();
+				}
+
+				if (isset($sum[$lead][$stage])) {
+					array_push($datax[$stage], $sum[$lead][$stage]/1000);
+					array_push($aAlts[$stage], $count[$lead][$stage]." ".$current_module_strings['LBL_OPPS_OUTCOME']." $stage");
+				}
+				else {
+					array_push($datax[$stage], 0);
+					array_push($aAlts[$stage], "");
+				}
+				array_push($aTargets[$stage], "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead)."&sales_stage=".urlencode($stage)."&query=true&type=dbrd");
+			  }
+			  array_push($legend,$translation);
+			}
+
+			$log->debug("datax is:");
+			$log->debug($datax);
+			$log->debug("aAlts is:");
+			$log->debug($aAlts);
+			$log->debug("aTargets is:");
+			$log->debug($aTargets);
+			$log->debug("sum is:");
+			$log->debug($sum);
+			$log->debug("count is:");
+			$log->debug($count);
+
+			//now build the bar plots for each user across the sales stages
+			$color = array('Closed Lost'=>'FF9900','Closed Won'=>'009933', $other=>'0066CC');
+			$index = 0;
+			$xlabels = array();
+			$datasets = array();
+			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
+			foreach($stages as $stage) {
+				// Now create a bar pot
+				$datasets[$index] = & Image_Graph::factory('dataset');
+				foreach($datax[$stage] as $i => $y) {
+				  	$x = 1+2*$i;
+				    $datasets[$index]->addPoint(
+				        //$datay[$legend[$x]],
+				        $x,
+				        $y,
+				        array(
+				            'url' => $aTargets[$stage][$i],
+				            'alt' => $aAlts[$stage][$i],
+				            'target' => ''
+				        )
+				    );
+				}
+			for($i=0;$i<count($legend); $i++)
+			{
+			  $x = 1+2*$i;
+			  $xlabels[$x] = $legend[$i];
+			  $xlabels[$x+1] = '';
+			}
+
+				// Set fill colors for bars
+				$fills->addColor("#".$color[$stage]);
+
+				$log->debug("datax[$stage] is: ");
+				$log->debug($datax[$stage]);
+				$index++;
+			}
+			
+			// compute maximum value because of grace jpGraph parameter not supported
+			$maximum = 0;
+			foreach($legend as $legendidx=>$legend_text) {
+			  	$dataxSum = 0;
+				foreach($stages as $stage) $dataxSum += $datax[$stage][$legendidx];
+				if($dataxSum > $maximum) $maximum = $dataxSum;
+			}
+
+			if($theme == "blue")
+			{
+				$font_color = "#212473";
+			}
+			else
+			{
+				$font_color = "#000000";
+			}
+			$font->setColor($font_color);
+
+			// Create the grouped bar plot
+			$gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked'));
+			$gbplot->setFillStyle($fills);
+
+			//You can change the width of the bars if you like
+			$gbplot->setBarWidth(50/count($legend),"%");
+
+			// Set white margin color
+			$graph->setBackgroundColor('#F5F5F5');
+
+			// Use a box around the plot area
+			$gbplot->setBorderColor('black');
+
+			// Use a gradient to fill the plot area
+			$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
+
+			// Setup title
+			$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+			//$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total;
+			$title->setText($titlestr);
+
+			// Create the xaxis labels
+			$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
+			    array($xlabels) 
+			); 
+
+			// Setup X-axis
+			$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
+			$xaxis->setDataPreprocessor($array_data);
+			$xaxis->forceMinimum(0);
+			$xaxis->forceMaximum(2*count($legend));
+			$xaxis->setLabelInterval(1);
+			$xaxis->setTickOptions(0,0);
+			$xaxis->setLabelInterval(2,2);
+			$xaxis->setTickOptions(5,0,2);
+			$xaxis->setInverted(true);
+			
+			// set grid
+			$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
+			$gridY->setLineColor('#E5E5E5 at 0.5');
+
+			// Add some grace to y-axis so the bars doesn't go
+			// all the way to the end of the plot area
+			$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+			$yaxis->forceMaximum($maximum * 1.1);
+			$ticks = get_tickspacing($maximum);
+
+			// Then fix the tick marks
+			$yaxis->setFontSize(8);
+			$yaxis->setAxisIntersection('max');
+			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
+			$yaxis->setDataPreprocessor($valueproc);
+			$yaxis->setLabelInterval($ticks[0]);
+			$yaxis->setTickOptions(-5,0);
+			$yaxis->setLabelInterval($ticks[1],2);
+			$yaxis->setTickOptions(-2,0,2);
+			
+			// eliminate zero values
+			$gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
+			
+			// set markers
+			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+			$marker->setDataPreprocessor($valueproc);
+			$marker->setFillColor('#000000 at 0.0');
+			$marker->setBorderColor('#000000 at 0.0');
+			$marker->setFontColor('white');
+			$marker->setFontSize(8);
+			$gbplot->setMarker($marker);
+
+			// Finally setup the title
+			$subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; 
+			$footer->setText($subtitle);
+			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
+
+			// .. and stroke the graph
+			$imgMap = $graph->done(
+								    array(
+									        'tohtml' => true,
+									        'border' => 0,
+									        'filename' => $cache_file_name,
+									        'filepath' => './',
+									        'urlpath' => ''
+									    ));
+			//$imgMap = htmlspecialchars($output);
+			save_image_map($cache_file_name.'.map', $imgMap);
+		}
+		else {
+			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
+			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			fclose($imgMap_fp);
+		}
+		$fileModTime = filemtime($cache_file_name.'.map');
+		$return = "\n$imgMap";
+		$log->debug("Exiting lead_source_by_outcome method ...");
+		return $return;
+	}
+
+	/**
+	 * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users.
+	 * param $datax- the sales stage data to display in the x-axis
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function pipeline_by_sales_stage($datax=array('foo','bar'), $date_start='2071-10-15', $date_end='2071-10-15', $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){
+		global $log,$current_user;
+		$log->debug("Entering pipeline_by_sales_stage(".$datax.",".$date_start.",".$date_end.",".$user_id.",".$cache_file_name.",".$refresh.") method ...");
+		global $app_strings,$lang_crm, $current_module_strings, $charset, $tmp_dir;
+		global $theme;
+		include_once ('Image/Graph.php');
+		include_once ('Image/Canvas.php');
+
+		$log =& LoggerManager::getLogger('opportunity charts');
+		// Set the basic parameters of the graph
+
+		
+		$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+		$imagemap = $canvas->getImageMap();
+		$graph =& Image_Graph::factory('graph', $canvas);
+		//$log->debug("graph object created");
+		// add a TrueType font
+		//$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+		$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+		// set the font size to 11 pixels
+		$font->setSize(8);
+		
+		$graph->setFont($font);
+        $title =& Image_Graph::factory('title', array('Test',10));
+    	$plotarea =& Image_Graph::factory('plotarea',array(
+                    'axis',
+                    'axis',
+                    'horizontal'
+                ));
+        $footer =& Image_Graph::factory('title', array('Footer',8));
+		$graph->add(
+		    Image_Graph::vertical($title,
+	        Image_Graph::vertical(
+				$plotarea,
+        	    $footer,
+            	90
+		        ),
+        	5
+	    	)
+		);   
+		$log->debug("graph object created");
+		
+
+		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
+
+			$log->debug("starting pipeline chart");
+			$log->debug("datax is:");
+			$log->debug($datax);
+			$log->debug("user_id is: ");
+			$log->debug($user_id);
+			$log->debug("cache_file_name is: $cache_file_name");
+
+			$where="";
+			//build the where clause for the query that matches $user
+			/*$count = count($user_id);
+			if ($count>0) {
+				$where = "(";
+				$first = true;
+				$current = 0;
+				foreach ($user_id as $the_id) {
+					if (!$first) $where .= "OR ";
+					$first = false;
+					//reference post
+					//if I change the owner of a opportunity, the graph shown on Home does not update correctly, this is because the graph is looking for the creatorid and not for the ownerid
+					//fix incorporated based on /sak's feedback
+					$where .= "vtiger_crmentity.smownerid='$the_id' ";
+				}
+				$where .= ") ";
+			}*/
+
+			//build the where clause for the query that matches $datax
+			$count = count($datax);
+			if ($count>0) {
+				$where .= " ( ";
+				unset($first);
+				$first = true;
+				foreach ($datax as $key=>$value) {
+					if (!$first) $where .= "OR ";
+					$first = false;
+					$where .= "sales_stage ='$key' ";
+				}
+				$where .= ")";
+			}
+
+			//build the where clause for the query that matches $date_start and $date_end
+			$where .= "AND closingdate >= '$date_start' AND closingdate <= '$date_end'";
+			$subtitle = $current_module_strings['LBL_DATE_RANGE']." ".getDisplayDate($date_start)." ".$current_module_strings['LBL_DATE_RANGE_TO']." ".getDisplayDate($date_end)."\n";
+
+			//Now do the db queries
+			//query for opportunity data that matches $datax and $user
+			$opp = new Potentials();
+			$opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where);
+
+			//build pipeline by sales stage data
+			$total = 0;
+			$count = array();
+			$sum = array();
+			if (isset($opp_list)) {
+				foreach ($opp_list as $record) {
+					if (!isset($sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) {
+						$sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = 0;
+					}
+					if (isset($record->column_fields['amount']))	{
+						// Strip all non numbers from this string.
+						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
+						$sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = $sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] + $amount;
+						if (isset($count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) {
+							$count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']]++;
+						}
+						else {
+							$count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = 1;
+						}
+						$total = $total + ($amount/1000);
+					}
+				}
+			}
+
+			$legend = array();
+			$datay = array();
+			$aTargets = array();
+			$aAlts = array();
+			foreach ($datax as $stage_key=>$stage_translation) {
+			  foreach ($user_id as $the_id) {
+			  	$the_user = get_assigned_user_name($the_id);
+				if (!isset($datay[$the_id])) {
+					$datay[$the_id] = array();
+				}
+				if (!isset($aAlts[$the_id])) {
+					$aAlts[$the_id] = array();
+				}
+				if (!isset($aTargets[$the_id])) {
+					$aTargets[$the_id] = array();
+				}
+
+				if (isset($sum[$stage_key][$the_id])) {
+					array_push($datay[$the_id], $sum[$stage_key][$the_id]/1000);
+					array_push($aAlts[$the_id], $the_user.' - '.$count[$stage_key][$the_id]." ".$current_module_strings['LBL_OPPS_IN_STAGE']." $stage_translation");
+				}
+				else {
+					array_push($datay[$the_id], 0);
+					array_push($aAlts[$the_id], "");
+				}
+				array_push($aTargets[$the_id], "index.php?module=Potentials&action=ListView&sales_stage=".urlencode($stage_key)."&closingdate_start=".urlencode($date_start)."&closingdate_end=".urlencode($date_end)."&query=true&type=dbrd");
+			  }
+			  array_push($legend,$stage_translation);
+			}
+
+			$log->debug("datay is:");
+			$log->debug($datay);
+			$log->debug("aAlts is:");
+			$log->debug($aAlts);
+			$log->debug("aTargets is:");
+			$log->debug($aTargets);
+			$log->debug("sum is:");
+			$log->debug($sum);
+			$log->debug("count is:");
+			$log->debug($count);
+
+			//now build the bar plots for each user across the sales stages
+			$colors = color_generator(count($user_id),'#D50100','#002222');
+			$index = 0;
+			$datasets = array();
+			$xlabels = array();
+			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
+			foreach($user_id as $the_id) {
+				// Now create a bar pot
+				$datasets[$index] = & Image_Graph::factory('dataset');
+				foreach($datay[$the_id] as $i => $y) {
+				    $x = 1+2*$i;
+				    $datasets[$index]->addPoint(
+				        $x,
+				        $y,
+				        array(
+				            'url' => $aTargets[$the_id][$i],
+				            'alt' => $aAlts[$the_id][$i]
+				        )
+				    );
+				}
+
+				// Set fill colors for bars
+				$fills->addColor($colors[$index]);
+
+				$index++;
+			}
+			for($i=0;$i<count($legend); $i++)
+			{
+			  $x = 1+2*$i;
+			  $xlabels[$x] = $legend[$i];
+			  $xlabels[$x+1] = '';
+			}
+			
+			// compute maximum value because of grace jpGraph parameter not supported
+			$maximum = 0;
+			foreach($legend as $legendidx=>$legend_text) {
+			  	$legendsum = 0;
+				foreach($user_id as $the_id) $legendsum += $datay[$the_id][$legendidx];
+				if($legendsum > $maximum) $maximum = $legendsum;
+			}
+			// Create the grouped bar plot
+			$gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked'));
+			$gbplot->setFillStyle($fills);
+
+			//You can change the width of the bars if you like
+			$gbplot->setBarWidth(50/count($legend),"%");
+
+
+			// Set white margin color
+			$graph->setBackgroundColor('#F5F5F5');
+
+			// Use a box around the plot area
+			$gbplot->setBorderColor('black');
+
+			// Use a gradient to fill the plot area
+			$gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5')));
+
+			if($theme == "blue")
+			{
+				$font_color = "#212473";
+			}
+			else
+			{
+				$font_color = "#000000";
+			}
+			$font->setColor($font_color);
+
+			// Setup title
+			$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+			//$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
+			$title->setText($titlestr);
+
+			// Create the xaxis labels
+			$array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 
+			    array($xlabels) 
+			); 
+
+		
+			// Setup X-axis
+			$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
+			$xaxis->setDataPreprocessor($array_data);
+			$xaxis->forceMinimum(0);
+			$xaxis->forceMaximum(2*count($legend));
+			$xaxis->setLabelInterval(1);
+			$xaxis->setTickOptions(0,0);
+			$xaxis->setLabelInterval(2,2);
+			$xaxis->setTickOptions(5,0,2);
+			$xaxis->setInverted(true);
+
+			// Setup Y-axis
+			$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
+			$yaxis->setFontSize(8);
+			$yaxis->setAxisIntersection('max');
+
+			// Add some grace to y-axis so the bars doesn't go
+			// all the way to the end of the plot area
+			$yaxis->forceMaximum($maximum * 1.1);
+			$ticks = get_tickspacing($maximum);
+			
+			// set grid
+			$gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
+			$gridY->setLineColor('#E5E5E5 at 0.5');
+
+			// First make the labels look right
+			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
+			$yaxis->setDataPreprocessor($valueproc);
+			$yaxis->setLabelInterval($ticks[0]);
+			$yaxis->setTickOptions(-5,0);
+			$yaxis->setLabelInterval($ticks[1],2);
+			$yaxis->setTickOptions(-2,0,2);
+			
+			// eliminate zero values
+			$gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
+			
+			// set markers
+			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+			$marker->setDataPreprocessor($valueproc);
+			$marker->setFillColor('000000 at 0.0');
+			$marker->setBorderColor('000000 at 0.0');
+			$marker->setFontColor('white');
+			$marker->setFontSize(8);
+			$gbplot->setMarker($marker);
+
+			// Finally setup the title
+
+			$subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; 
+			$footer->setText($subtitle);
+			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT);
+
+			// .. and stroke the graph
+			$imgMap = $graph->done(
+								    array(
+									        'tohtml' => true,
+									        'border' => 0,
+									        'filename' => $cache_file_name,
+									        'filepath' => './',
+									        'urlpath' => ''
+									    ));
+			//$imgMap = $graph->GetHTMLImageMap('pipeline');
+			save_image_map($cache_file_name.'.map', $imgMap);
+		}
+		else {
+			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
+			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			fclose($imgMap_fp);
+		}
+		$fileModTime = filemtime($cache_file_name.'.map');
+		$return = "\n$imgMap";
+		$log->debug("Exiting pipeline_by_sales_stage method ...");
+		return $return;
+	}
+
+	/**
+	 * Creates pie chart image of opportunities by lead_source.
+	 * param $datax- the sales stage data to display in the x-axis
+	 * param $datay- the sum of opportunity amounts for each opportunity in each sales stage
+	 * to display in the y-axis
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function pipeline_by_lead_source($legends=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=true,$width=900,$height=500){
+		global $log,$current_user;
+		$log->debug("Entering pipeline_by_lead_source(".$legends.") method ...");
+		global $app_strings,$lang_crm, $current_module_strings, $log, $charset, $tmp_dir;
+		global $theme;
+
+		include_once ('Image/Graph.php');
+		include_once ('Image/Canvas.php');
+
+		$font = calculate_font_name($lang_crm);
+
+		if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) {
+			$log =& LoggerManager::getLogger('opportunity charts');
+			$log->debug("starting pipeline chart");
+			$log->debug("legends is:");
+			$log->debug($legends);
+			$log->debug("user_id is: ");
+			$log->debug($user_id);
+			$log->debug("cache_file_name is: $cache_file_name");
+
+			//Now do the db queries
+			//query for opportunity data that matches $legends and $user
+			$where="";
+			//build the where clause for the query that matches $user
+			/*$count = count($user_id);
+			if ($count>0) {
+				$where = "(";
+				$first = true;
+				foreach ($user_id as $the_id) {
+					if (!$first) $where .= "OR ";
+					$first = false;
+					$where .= "vtiger_crmentity.smcreatorid='$the_id' ";
+				}
+				$where .= ") ";
+			}*/
+
+			//build the where clause for the query that matches $datax
+			$count = count($legends);
+			if ($count>0) {
+				$where .= " ( ";
+				$first = true;
+				foreach ($legends as $key=>$value) {
+					if (!$first) $where .= "OR ";
+					$first = false;
+					$where .= "leadsource	='$key' ";
+				}
+				$where .= ")";
+			}
+
+			$opp = new Potentials();
+			$opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where);
+
+			//build pipeline by lead source data
+			$total = 0;
+			$count = array();
+			$sum = array();
+			if (isset($opp_list)) {
+				foreach ($opp_list as $record) {
+					if (!isset($sum[$record->column_fields['leadsource']])) $sum[$record->column_fields['leadsource']] = 0;
+					if (isset($record->column_fields['amount']) && isset($record->column_fields['leadsource']))	{
+						// Strip all non numbers from this string.
+						$amount = convertFromMasterCurrency(ereg_replace('[^0-9]', '', floor($record->column_fields['amount'])),$current_user->conv_rate);
+						$sum[$record->column_fields['leadsource']] = $sum[$record->column_fields['leadsource']] + ($amount/1000);
+						if (isset($count[$record->column_fields['leadsource']])) $count[$record->column_fields['leadsource']]++;
+						else $count[$record->column_fields['leadsource']] = 1;
+						$total = $total + ($amount/1000);
+					}
+				}
+			}
+
+			$visible_legends = array();
+			$data= array();
+			$aTargets = array();
+			$aAlts = array();
+			foreach ($legends as $lead_source_key=>$lead_source_translation) {
+				if (isset($sum[$lead_source_key]))
+				{
+					array_push($data, $sum[$lead_source_key]);
+					if($lead_source_key != '')
+					{
+						array_push($visible_legends, $lead_source_translation);
+					}
+					else
+					{
+						// put none in if the vtiger_field is blank.
+						array_push($visible_legends, $current_module_strings['NTC_NO_LEGENDS']);
+					}
+					array_push($aTargets, "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead_source_key)."&query=true&type=dbrd");
+					array_push($aAlts, $count[$lead_source_key]." ".$current_module_strings['LBL_OPPS_IN_LEAD_SOURCE']." $lead_source_translation	");
+				}
+			}
+
+			$log->debug("sum is:");
+			$log->debug($sum);
+			$log->debug("count is:");
+			$log->debug($count);
+			$log->debug("total is: $total");
+			if ($total == 0) {
+$log->debug("Exiting pipeline_by_lead_source method ...");
+				return ($current_module_strings['ERR_NO_OPPS']);
+			}
+
+			if($theme == "blue")
+			{
+				$font_color = "#212473";
+			}
+			else
+			{
+				$font_color = "#000000";
+			}
+
+	
+			$canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
+			$imagemap = $canvas->getImageMap();
+			$graph =& Image_Graph::factory('graph', $canvas);
+	
+			$font =& $graph->addNew('font', calculate_font_name($lang_crm));
+			// set the font size to 11 pixels
+			$font->setSize(8);
+			$font->setColor($font_color);
+			
+			$graph->setFont($font);
+			// create the plotarea layout
+	        $title =& Image_Graph::factory('title', array('Test',10));
+	    	$plotarea =& Image_Graph::factory('plotarea',array(
+                    'category',
+                    'axis'
+                ));
+	        $footer =& Image_Graph::factory('title', array('Footer',8));
+			$graph->add(
+			    Image_Graph::vertical($title,
+		        Image_Graph::vertical(
+					$plotarea,
+	        	    $footer,
+	            	90
+			        ),
+	        	5
+		    	)
+			);   
+
+			// Generate colours
+			$colors = color_generator(count($visible_legends),'#33CCFF','#3322FF');
+			$index = 0;
+			$dataset = & Image_Graph::factory('dataset');
+			$fills =& Image_Graph::factory('Image_Graph_Fill_Array');
+			foreach($visible_legends as $legend) {
+			    $dataset->addPoint(
+			        $legend,
+			        $data[$index],
+			        array(
+			            'url' => $aTargets[$index],
+			            'alt' => $aAlts[$index]
+			        )
+			    );
+				$fills->addColor($colors[$index]);
+			    $log->debug('point ='.$legend.','.$data[$index]);
+
+				$index++;
+			}
+
+			// create the pie chart and associate the filling colours			
+			$gbplot = & $plotarea->addNew('pie', $dataset);
+			$plotarea->hideAxis();
+			$gbplot->setFillStyle($fills);
+
+			// Setup title
+			$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL'];
+			//$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total;
+
+			$title->setText($titlestr);
+
+			// format the data values
+			$valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d");
+
+			// set markers
+			$marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y);
+			$marker->setDataPreprocessor($valueproc);
+			$marker->setFillColor('#FFFFFF');
+			$marker->setBorderColor($font_color);
+			$marker->setFontColor($font_color);
+			$marker->setFontSize(8);
+			$pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker));
+			$gbplot->setMarker($pointingMarker);
+			
+			// set legend
+			$legend_box =& $plotarea->addNew('legend');
+			$legend_box->setPadding(array('top'=>20,'bottom'=>0,'left'=>0,'right'=>0));
+			$legend_box->setFillColor('#F5F5F5');
+			$legend_box->showShadow();
+
+			$subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE'];
+			$footer->setText($subtitle);
+			$footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_LEFT);
+
+			$imgMap = $graph->done(
+								    array(
+									        'tohtml' => true,
+									        'border' => 0,
+									        'filename' => $cache_file_name,
+									        'filepath' => './',
+									        'urlpath' => ''
+									    ));
+			//$imgMap = htmlspecialchars($output);
+			save_image_map($cache_file_name.'.map', $imgMap);
+		}
+		else {
+			$imgMap_fp = fopen($cache_file_name.'.map', "rb");
+			$imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map'));
+			fclose($imgMap_fp);
+		}
+		$fileModTime = filemtime($cache_file_name.'.map');
+		$return = "\n$imgMap";
+		$log->debug("Exiting pipeline_by_lead_source method ...");
+		return $return;
+
+	}
+
+}
+
+
+/**
+ * Creates a file with the image map
+ * param $filename - file name to save to
+ * param $image_map - image map string to save
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ */
+function save_image_map($filename,$image_map)
+{
+	global $log;
+	$log->debug("Entering save_image_map(".$filename.",".$image_map.") method ...");
+	// save the image map to file
+	$log =& LoggerManager::getLogger('save_image_file');
+
+	if (!$handle = fopen($filename, 'w')) {
+		$log->debug("Cannot open file ($filename)");
+		$log->debug("Exiting save_image_map method ...");
+		return;
+	}
+
+	// Write $somecontent to our opened file.
+	if (fwrite($handle, $image_map) === FALSE) {
+	   $log->debug("Cannot write to file ($filename)");
+	   $log->debug("Exiting save_image_map method ...");
+	   return false;
+	}
+
+	$log->debug("Success, wrote ($image_map) to file ($filename)");
+
+	fclose($handle);
+	$log->debug("Exiting save_image_map method ...");
+	return true;
+
+}
+
+// retrieve the translated strings.
+$app_strings = return_application_language($current_language);
+
+if(isset($app_strings['LBL_CHARSET']))
+{
+	$charset = $app_strings['LBL_CHARSET'];
+}
+else
+{
+	$charset = $default_charset;
+}
+
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/DetailView.php Mon Apr 16 12:27:44 2007
@@ -1,112 +1,115 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/DetailView.php,v 1.28 2005/04/18 10:37:49 samk Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('modules/Organization/Organization.php');
-require_once('include/CustomFieldUtil.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-global $mod_strings;
-global $app_strings;
-global $currentModule, $singlepane_view;
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/DetailView.php,v 1.28 2005/04/18 10:37:49 samk Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('modules/Organization/Organization.php');
+require_once('include/CustomFieldUtil.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+global $mod_strings;
+global $app_strings;
+global $currentModule, $singlepane_view;
 global $current_organization;
-
-$focus = new Potentials();
-$smarty = new vtigerCRM_Smarty;
-
-if(isset($_REQUEST['record'])  && $_REQUEST['record']!='') {
-    $focus->retrieve_entity_info($_REQUEST['record'],"Potentials");
-    $focus->id = $_REQUEST['record'];	
-    $focus->name=$focus->column_fields['potentialname'];
-}
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
-	$focus->id = "";
-} 
-
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-$log->info("Potential detail view");
-
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);
-$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("ID", $focus->id);
-$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-
-$smarty->assign("ACCOUNTID",$focus->column_fields['account_id']);
-
-if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
-else $smarty->assign("NAME", "");
-
-$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
-
-$smarty->assign("CUSTOMFIELD", $cust_fld);
-$smarty->assign("SINGLE_MOD", 'Opportunity');
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-
-if(isPermitted("Potentials","EditView",$_REQUEST['record']) == 'yes')
-	$smarty->assign("EDIT_DUPLICATE","permitted");
-if(isPermitted("Invoice","EditView",$_REQUEST['record']) == 'yes')
-	$smarty->assign("CONVERTINVOICE","permitted");
-if(isPermitted("Potentials","Delete",$_REQUEST['record']) == 'yes')
-	$smarty->assign("DELETE","permitted");
-
-$tabid = getTabid("Potentials");
-$validationData = getDBValidationData($focus->tab_name,$tabid);
-$data = split_validationdataArray($validationData);
-
-$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
-$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
-$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-       
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-
-$smarty->assign("CONVERTMODE",'potentoinvoice');
-$smarty->assign("MODULE","Potentials");
-$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
-
-if($singlepane_view == 'true')
-{
-	$related_array = getRelatedLists($currentModule,$focus);
-	$smarty->assign("RELATEDLISTS", $related_array);
-}
-
-$smarty->assign("SinglePane_View", $singlepane_view);
-
+
+$focus = new Potentials();
+$smarty = new vtigerCRM_Smarty;
+
+if(isset($_REQUEST['record'])  && $_REQUEST['record']!='') {
+    $focus->retrieve_entity_info($_REQUEST['record'],"Potentials");
+    $focus->id = $_REQUEST['record'];	
+    $focus->name=$focus->column_fields['potentialname'];
+}
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+	$focus->id = "";
+} 
+
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+$log->info("Potential detail view");
+
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);
+$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("ID", $focus->id);
+$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+
+$smarty->assign("ACCOUNTID",$focus->column_fields['account_id']);
+
+if (isset($focus->name)) $smarty->assign("NAME", $focus->name);
+else $smarty->assign("NAME", "");
+
+$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
+
+$smarty->assign("CUSTOMFIELD", $cust_fld);
+$smarty->assign("SINGLE_MOD", 'Opportunity');
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+
+if(isPermitted("Potentials","EditView",$_REQUEST['record']) == 'yes')
+	$smarty->assign("EDIT_DUPLICATE","permitted");
+if(isPermitted("Invoice","EditView",$_REQUEST['record']) == 'yes')
+	$smarty->assign("CONVERTINVOICE","permitted");
+if(isPermitted("Potentials","Delete",$_REQUEST['record']) == 'yes')
+	$smarty->assign("DELETE","permitted");
+
+$tabid = getTabid("Potentials");
+$validationData = getDBValidationData($focus->tab_name,$tabid);
+$data = split_validationdataArray($validationData);
+
+$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+       
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+
+$smarty->assign("CONVERTMODE",'potentoinvoice');
+$smarty->assign("MODULE","Potentials");
+$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
+
+if($singlepane_view == 'true')
+{
+	$related_array = getRelatedLists($currentModule,$focus);
+	$smarty->assign("RELATEDLISTS", $related_array);
+	$smarty->assign("BASE_ACCOUNT",getAccountName($focus->column_fields[account_id]));	
+}
+
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
+$smarty->assign("SinglePane_View", $singlepane_view);
+
 $organization = new Organization;
 $organization->id = $current_organization;
-$smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
-
-$smarty->display("DetailView.tpl");
-?>
+$smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
+
+$smarty->display("DetailView.tpl");
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/DetailViewAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/DetailViewAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/DetailViewAjax.php Mon Apr 16 12:27:44 2007
@@ -1,51 +1,52 @@
-<?php
-/*********************************************************************************
- ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-  * ("License"); You may not use this file except in compliance with the License
-  * The Original Code is:  vtiger CRM Open Source
-  * The Initial Developer of the Original Code is vtiger.
-  * Portions created by vtiger are Copyright (C) vtiger.
-  * All Rights Reserved.
- *
-  ********************************************************************************/
-
-require_once('include/logging.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('include/database/PearDatabase.php');
-global $adb;
-
-$local_log =& LoggerManager::getLogger('PotentialsAjax');
-
-$ajaxaction = $_REQUEST["ajxaction"];
-if($ajaxaction == "DETAILVIEW")
-{
-	$crmid = $_REQUEST["recordid"];
-	$tablename = $_REQUEST["tableName"];
-	$fieldname = $_REQUEST["fldName"];
-	$fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); 
-	if($crmid != "")
-	{
-		$modObj = new Potentials();
-		$modObj->retrieve_entity_info($crmid,"Potentials");
-		$modObj->column_fields[$fieldname] = $fieldvalue;
-		$_REQUEST[$fieldname] = $fieldvalue;
-		if($fieldname == 'amount')//amount converted to dollar value while saving
-		{
-			$modObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue);
-		}	
-		$modObj->id = $crmid;
-		$modObj->mode = "edit";
-		$modObj->save("Potentials");
-		if($modObj->id != "")
-		{
-			echo ":#:SUCCESS";
-		}else
-		{
-			echo ":#:FAILURE";
-		}   
-	}else
-	{
-		echo ":#:FAILURE";
-	}
-}
-?>
+<?php
+/*********************************************************************************
+ ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+  * ("License"); You may not use this file except in compliance with the License
+  * The Original Code is:  vtiger CRM Open Source
+  * The Initial Developer of the Original Code is vtiger.
+  * Portions created by vtiger are Copyright (C) vtiger.
+  * All Rights Reserved.
+ *
+  ********************************************************************************/
+
+require_once('include/logging.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('include/database/PearDatabase.php');
+global $adb;
+
+$local_log =& LoggerManager::getLogger('PotentialsAjax');
+
+$ajaxaction = $_REQUEST["ajxaction"];
+if($ajaxaction == "DETAILVIEW")
+{
+	$crmid = $_REQUEST["recordid"];
+	$tablename = $_REQUEST["tableName"];
+	$fieldname = $_REQUEST["fldName"];
+	$fieldvalue = utf8RawUrlDecode($_REQUEST["fieldValue"]); 
+	if($crmid != "")
+	{
+		$modObj = new Potentials();
+		$modObj->retrieve_entity_info($crmid,"Potentials");
+		$modObj->column_fields[$fieldname] = $fieldvalue;
+		$_REQUEST[$fieldname] = $fieldvalue;
+		if($fieldname == 'amount')//amount converted to dollar value while saving
+		{
+			$modObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue);
+		}	
+		$modObj->id = $crmid;
+		$modObj->mode = "edit";
+		$modObj->save("Potentials");
+	        sendNotificationToOwner('Potentials',&$modObj);
+		if($modObj->id != "")
+		{
+			echo ":#:SUCCESS";
+		}else
+		{
+			echo ":#:FAILURE";
+		}   
+	}else
+	{
+		echo ":#:FAILURE";
+	}
+}
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/EditView.php Mon Apr 16 12:27:44 2007
@@ -1,148 +1,151 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/EditView.php,v 1.16 2005/03/24 16:18:38 samk Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Potentials/Potentials.php');
-require_once('modules/Organization/Organization.php');
-require_once('include/CustomFieldUtil.php');
-require_once('include/ComboUtil.php');
-require_once('include/utils/utils.php');
-require_once('include/FormValidationUtil.php');
-global $app_strings;
-global $mod_strings;
-global $currentModule;
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/EditView.php,v 1.16 2005/03/24 16:18:38 samk Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Potentials/Potentials.php');
+require_once('modules/Organization/Organization.php');
+require_once('include/CustomFieldUtil.php');
+require_once('include/ComboUtil.php');
+require_once('include/utils/utils.php');
+require_once('include/FormValidationUtil.php');
+global $app_strings;
+global $mod_strings;
+global $currentModule;
 global $current_organization;
 
-$focus = new Potentials();
-$smarty = new vtigerCRM_Smarty();
-
-if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') 
-{
-    $focus->id = $_REQUEST['record'];
-    $focus->mode = 'edit'; 	
-    $focus->retrieve_entity_info($_REQUEST['record'],"Potentials");
-    $focus->name=$focus->column_fields['potentialname'];	
-}
-if(isset($_REQUEST['account_id']))
-{
-        $focus->column_fields['account_id'] = $_REQUEST['account_id'];
-}
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
-	$focus->id = "";
-    	$focus->mode = ''; 	
-}
-
-$disp_view = getView($focus->mode);
-if($disp_view == 'edit_view')
-	$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
-else
-{
-	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
-}
-$smarty->assign("OP_MODE",$disp_view);
-$category = getParentTab();
-$smarty->assign("CATEGORY",$category);
-
-//needed when creating a new opportunity with a default vtiger_account value passed in
-if (isset($_REQUEST['accountname']) && is_null($focus->accountname)) {
-	$focus->accountname = $_REQUEST['accountname'];
-	
-}
-if (isset($_REQUEST['accountid']) && is_null($focus->accountid)) {
-	$focus->accountid = $_REQUEST['accountid'];
-}
-if (isset($_REQUEST['contactid']) && is_null($focus->contactid)) {
-	$focus->contactid = $_REQUEST['contactid'];
-}
-
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-//retreiving the combo values array
-$comboFieldNames = Array('leadsource'=>'leadsource_dom'
-                      ,'opportunity_type'=>'opportunity_type_dom'
-                      ,'sales_stage'=>'sales_stage_dom');
-$comboFieldArray = getComboArray($comboFieldNames);
-require_once($theme_path.'layout_utils.php');
-
-$log->info("Potential detail view");
-$smarty->assign("MOD", $mod_strings);
-$smarty->assign("APP", $app_strings);
-
-if (isset($focus->name)) 
-$smarty->assign("NAME", $focus->name);
-else 
-$smarty->assign("NAME", "");
-
-if(isset($cust_fld))
-{
-        $smarty->assign("CUSTOMFIELD", $cust_fld);
-}
-if($focus->mode == 'edit')
-{
-	$smarty->assign("UPDATEINFO",updateInfo($focus->id));
-	$smarty->assign("MODE", $focus->mode);
-}		
-
-
-
-// Unimplemented until jscalendar language vtiger_files are fixed
-$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
-$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
-
-if (isset($_REQUEST['return_module'])) 
-$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
-if (isset($_REQUEST['return_action'])) 
-$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
-if (isset($_REQUEST['return_id'])) 
-$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
-if (isset($_REQUEST['return_viewname'])) 
-$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("ID", $focus->id);
-$smarty->assign("MODULE",$currentModule);
-$smarty->assign("SINGLE_MOD",'Potential');
-
-
- $tabid = getTabid("Potentials");
- $validationData = getDBValidationData($focus->tab_name,$tabid);
- $data = split_validationdataArray($validationData);
-
- $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
- $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
- $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-
-$check_button = Button_Check($module);
-$smarty->assign("CHECK", $check_button);
-
+$focus = new Potentials();
+$smarty = new vtigerCRM_Smarty();
+
+if(isset($_REQUEST['record']) && $_REQUEST['record'] != '') 
+{
+    $focus->id = $_REQUEST['record'];
+    $focus->mode = 'edit'; 	
+    $focus->retrieve_entity_info($_REQUEST['record'],"Potentials");
+    $focus->name=$focus->column_fields['potentialname'];	
+}
+if(isset($_REQUEST['account_id']))
+{
+        $focus->column_fields['account_id'] = $_REQUEST['account_id'];
+}
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+	$focus->id = "";
+    	$focus->mode = ''; 	
+}
+
+$disp_view = getView($focus->mode);
+if($disp_view == 'edit_view')
+	$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields));
+else
+{
+	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
+}
+$smarty->assign("OP_MODE",$disp_view);
+$category = getParentTab();
+$smarty->assign("CATEGORY",$category);
+
+//needed when creating a new opportunity with a default vtiger_account value passed in
+if (isset($_REQUEST['accountname']) && is_null($focus->accountname)) {
+	$focus->accountname = $_REQUEST['accountname'];
+	
+}
+if (isset($_REQUEST['accountid']) && is_null($focus->accountid)) {
+	$focus->accountid = $_REQUEST['accountid'];
+}
+if (isset($_REQUEST['contactid']) && is_null($focus->contactid)) {
+	$focus->contactid = $_REQUEST['contactid'];
+}
+
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+//retreiving the combo values array
+$comboFieldNames = Array('leadsource'=>'leadsource_dom'
+                      ,'opportunity_type'=>'opportunity_type_dom'
+                      ,'sales_stage'=>'sales_stage_dom');
+$comboFieldArray = getComboArray($comboFieldNames);
+require_once($theme_path.'layout_utils.php');
+
+$log->info("Potential detail view");
+$smarty->assign("MOD", $mod_strings);
+$smarty->assign("APP", $app_strings);
+
+if (isset($focus->name)) 
+$smarty->assign("NAME", $focus->name);
+else 
+$smarty->assign("NAME", "");
+
+if(isset($cust_fld))
+{
+        $smarty->assign("CUSTOMFIELD", $cust_fld);
+}
+if($focus->mode == 'edit')
+{
+	$smarty->assign("UPDATEINFO",updateInfo($focus->id));
+	$smarty->assign("MODE", $focus->mode);
+}		
+
+
+
+// Unimplemented until jscalendar language vtiger_files are fixed
+$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']);
+$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT']));
+
+if (isset($_REQUEST['return_module'])) 
+$smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
+if (isset($_REQUEST['return_action'])) 
+$smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
+if (isset($_REQUEST['return_id'])) 
+$smarty->assign("RETURN_ID", $_REQUEST['return_id']);
+if (isset($_REQUEST['return_viewname'])) 
+$smarty->assign("RETURN_VIEWNAME", $_REQUEST['return_viewname']);
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("ID", $focus->id);
+$smarty->assign("MODULE",$currentModule);
+$smarty->assign("SINGLE_MOD",'Potential');
+
+
+ $tabid = getTabid("Potentials");
+ $validationData = getDBValidationData($focus->tab_name,$tabid);
+ $data = split_validationdataArray($validationData);
+
+ $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+ $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+ $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+
+//fix for potential duplicate header
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
+
+$check_button = Button_Check($module);
+$smarty->assign("CHECK", $check_button);
+
 $organization = new Organization;
 $organization->id = $current_organization;
-$smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
-
-if($focus->mode == 'edit')
-$smarty->display("salesEditView.tpl");
-else
-$smarty->display("CreateView.tpl");
-
-?>
+$smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
+
+if($focus->mode == 'edit')
+$smarty->display("salesEditView.tpl");
+else
+$smarty->display("CreateView.tpl");
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/ListView.php Mon Apr 16 12:27:44 2007
@@ -26,7 +26,7 @@
 require_once('include/DatabaseUtil.php');
 
 
-global $app_strings,$list_max_entries_per_page;
+global $app_strings,$list_max_entries_per_page,$mod_strings;
 
 $log = LoggerManager::getLogger('potential_list');
 
@@ -134,11 +134,12 @@
 	$list_query = getListQuery("Potentials");
 }
 //<<<<<<<<customview>>>>>>>>>
-
 if(isset($where) && $where != '')
 {
 	if(isset($_REQUEST['from_dashboard']) && $_REQUEST['from_dashboard'] == 'true')
-		$list_query .= " AND vtiger_potential.sales_stage = 'Closed Won' AND ".$where;
+		$list_query .= " AND vtiger_potential.sales_stage = '".$mod_strings['Closed Won']."' AND ".$where;
+	elseif(isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true')
+		$list_query .= " AND vtiger_potential.sales_stage not in( '".$mod_strings['Closed Won']."' , '".$mod_strings['Closed Lost']."' )AND ".$where;
 	else
 		$list_query .= " AND ".$where;
 }

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/ListViewTop.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/ListViewTop.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/ListViewTop.php Mon Apr 16 12:27:44 2007
@@ -42,7 +42,7 @@
 	$title[]='myTopOpenPotentials.gif';
 	$title[]=$current_module_strings['LBL_TOP_OPPORTUNITIES'];
 	$title[]='home_mypot';
-	$where = "AND vtiger_potential.sales_stage <> 'Closed Won' AND vtiger_potential.sales_stage <> 'Closed Lost' AND vtiger_crmentity.smownerid='".$current_user->id."'";
+	$where = "AND vtiger_potential.sales_stage not in ('Closed Won','Closed Lost','".$current_module_strings['Closed Won']."','".$current_module_strings['Closed Lost']."') AND vtiger_crmentity.smownerid='".$current_user->id."'";
 	$header=array();
 	$header[]=$current_module_strings['LBL_LIST_OPPORTUNITY_NAME'];
 	$header[]=$current_module_strings['LBL_LIST_ACCOUNT_NAME'];
@@ -70,7 +70,7 @@
 					);
 			$potentialid=$adb->query_result($list_result,$i,'potentialid');                                  
 			$value=array();
-			$value[]='<a href="index.php?action=DetailView&module=Potentials&record='.$adb->query_result($list_result,$i,"potentialid").'">'.$adb->query_result($list_result,$i,"potentialname").'</a>';
+			$value[]='<a href="index.php?action=DetailView&module=Potentials&record='.$adb->query_result($list_result,$i,"potentialid").'">'.substr($adb->query_result($list_result,$i,"potentialname"),0,20).'...'.'</a>';
 			$value[]='<a href="index.php?action=DetailView&module=Accounts&record='.$adb->query_result($list_result,$i,'accountid').'">'.$adb->query_result($list_result,$i,"accountname").'</a>';
 			$value[]=convertFromDollar($adb->query_result($list_result,$i,'amount'),$rate);
 			$value[]=getDisplayDate($adb->query_result($list_result,$i,'closingdate'));

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/Opportunity.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/Opportunity.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/Opportunity.php Mon Apr 16 12:27:44 2007
@@ -1,510 +1,510 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Opportunity.php,v 1.65 2005/04/28 08:08:27 rank Exp $ 
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('modules/Contacts/Contact.php');
-require_once('modules/Calendar/Activity.php');
-require_once('modules/Notes/Note.php');
-require_once('modules/Emails/Email.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-// vtiger_potential is used to store customer information.
-class Potential extends CRMEntity {
-	var $log;
-	var $db;
-
-	var $module_name="Potentials";
-	var $table_name = "vtiger_potential";
-	var $rel_product_table = "vtiger_seproductsrel";
-	var $rel_opportunity_table = "vtiger_contpotentialrel";
-	var $module_id = "potentialid";
-	var $object_name = "potential";
-
-	var $tab_name = Array('vtiger_crmentity','vtiger_potential','vtiger_potentialscf');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_potential'=>'potentialid','vtiger_potentialscf'=>'potentialid');
-
-	var $column_fields = Array();
-
-	var $sortby_fields = Array('potentialname','amount','closingdate','smownerid');
-
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-			'Potential'=>Array('potential'=>'potentialname'),
-			'Account Name'=>Array('account'=>'accountname'),	  			
-			'Sales Stage'=>Array('potential'=>'sales_stage'),
-			'Amount'=>Array('potential'=>'amount'),
-			'Expected Close'=>Array('potential'=>'closingdate'),
-			'Assigned To'=>Array('crmentity','smownerid')
-			);
-
-	var $list_fields_name = Array(
-			'Potential'=>'potentialname',
-			'Account Name'=>'accountid',	  			
-			'Sales Stage'=>'sales_stage',	  			
-			'Amount'=>'amount',
-			'Expected Close'=>'closingdate',
-			'Assigned To'=>'assigned_user_id');
-
-	var $list_link_field= 'potentialname';
-
-	var $search_fields = Array(
-			'Potential'=>Array('potential'=>'potentialname'),
-			'Account Name'=>Array('potential'=>'accountid'),
-			'Expected Close'=>Array('potential'=>'closedate')
-			);
-
-	var $search_fields_name = Array(
-			'Potential'=>'potentialname',
-			'Account Name'=>'account_id',
-			'Expected Close'=>'closingdate'
-			);
-
-	var $required_fields =  array(
-			"potentialname"=>1,
-			"account_id"=>1,
-			"closingdate"=>1,
-			"sales_stage"=>1,
-			"amount"=>1
-			);
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'potentialname';
-	var $default_sort_order = 'ASC';
-
-	function Potential() {
-		$this->log = LoggerManager::getLogger('potential');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Potentials');
-	}
-
-	var $new_schema = true;
-	
-	/**
-	* Function to get sort order
-	* return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	*/
-	function getSortOrder()
-	{
-		global $log;
-                $log->debug("Entering getSortOrder() method ...");	
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['POTENTIALS_SORT_ORDER'] != '')?($_SESSION['POTENTIALS_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder() method ...");
-		return $sorder;
-	}
-
-	/**
-	* Function to get order by
-	* return string  $order_by    - fieldname(eg: 'Potentialname')
-	*/
-	function getOrderBy()
-	{
-		global $log;
-                $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['POTENTIALS_ORDER_BY'] != '')?($_SESSION['POTENTIALS_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-
-	/** Function to create list query 
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Query.
-	*/
-	function create_list_query($order_by, $where)
-	{
-		global $log;
-		$log->debug("Entering create_list_query(".$order_by.",". $where.") method ...");
-		// Determine if the vtiger_account name is present in the where clause.
-		$account_required = ereg("accounts\.name", $where);
-
-		if($account_required)
-		{
-			$query = "SELECT vtiger_potential.potentialid,  vtiger_potential.potentialname, vtiger_potential.dateclosed FROM vtiger_potential, vtiger_account ";
-			$where_auto = "account.accountid = vtiger_potential.accountid AND vtiger_crmentity.deleted=0 ";
-		}
-		else
-		{
-			$query = 'SELECT potentialid, potentialname, smcreatorid, closingdate FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid ';
-			$where_auto = 'AND vtiger_crmentity.deleted=0';
-		}
-
-		if($where != "")
-			$query .= "where $where ".$where_auto;
-		else
-			$query .= "where ".$where_auto;
-
-		if($order_by != "")
-			$query .= " ORDER BY vtiger_potential.$order_by";
-		else
-			$query .= " ORDER BY vtiger_potential.potentialname";
-
-
-
-		$log->debug("Exiting create_list_query method ...");
-		return $query;
-	}
-
-	/** Function to export the Opportunities records in CSV Format
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Export Potentials Query.
-	*/
-	function create_export_query($order_by, $where)
-	{
-		global $log;
-		global $current_user;
-		$log->debug("Entering create_export_query(".$order_by.",". $where.") method ...");
-
-		include("include/utils/ExportUtils.php");
-
-		//To get the Permitted fields query and the permitted fields list
-		$sql = getPermittedFieldsQuery("Potentials", "detail_view");
-		$fields_list = getFieldsListFromQuery($sql);
-
-		$query = "SELECT $fields_list FROM vtiger_potential 
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid 
-				LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
-				LEFT JOIN vtiger_account on vtiger_potential.accountid=vtiger_account.accountid  
-				LEFT JOIN vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid 
-				LEFT JOIN vtiger_potentialgrouprelation
-                	                ON vtiger_potentialscf.potentialid = vtiger_potentialgrouprelation.potentialid
-	                        LEFT JOIN vtiger_groups
-                        	        ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
-				LEFT JOIN vtiger_campaign
-					ON vtiger_campaign.campaignid = vtiger_potential.campaignid
-
-			where vtiger_crmentity.deleted=0 ";
-
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-		//we should add security check when the user has Private Access
-		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[2] == 3)
-		{
-			//Added security check to get the permitted records only
-			$query = $query." ".getListViewSecurityParameter("Potentials");
-		}
-
-		$log->debug("Exiting create_export_query method ...");
-		return $query;
-
-	}
-
-
-
-	/** Returns a list of the associated contacts
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_contacts($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_contacts(".$id.") method ...");
-		global $app_strings;
-
-		$focus = new Contact();
-
-		$button = '';
-
-		if(isPermitted("Contacts",3,"") == 'yes')
-		{
-
-			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_CONTACT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Contacts&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'select vtiger_contactdetails.accountid, vtiger_users.user_name,vtiger_groups.groupname,vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_potential inner join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid inner join vtiger_contactdetails on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted=0';
-		
-		$log->debug("Exiting get_contacts method ...");
-		return GetRelatedList('Potentials','Contacts',$focus,$query,$button,$returnset);
-	}
-
-	/** Returns a list of the associated calls
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_activities($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_activities(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Activity();
-
-		$button = '';
-
-		if(isPermitted("Calendar",1,"") == 'yes')
-		{
-
-			$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.activity_mode.value=\'Task\';this.form.return_module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
-			$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Potentials\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name, vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and vtiger_crmentity.deleted=0 and ((vtiger_activity.status is not NULL AND vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus != '' AND  vtiger_activity.eventstatus != 'Held'))";
-		$log->debug("Exiting get_activities method ...");
-		return GetRelatedList('Potentials','Calendar',$focus,$query,$button,$returnset);
-
-	}
-
-	 /**
-	 * Function to get Contact related Products 
-	 * @param  integer   $id  - contactid
-	 * returns related Products record in array format
-	 */
-	function get_products($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_products(".$id.") method ...");
-		require_once('modules/Products/Product.php');
-		global $app_strings;
-
-		$focus = new Product();
-
-		$button = '';
-
-		if(isPermitted("Products",1,"") == 'yes')
-		{
-
-
-			$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Potentials\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
-		}
-		if(isPermitted("Products",3,"") == 'yes')
-		{
-			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_PRODUCT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Products&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_products inner join vtiger_seproductsrel on vtiger_products.productid = vtiger_seproductsrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_potential on vtiger_potential.potentialid = vtiger_seproductsrel.crmid  where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted = 0';
-		$log->debug("Exiting get_products method ...");
-		return GetRelatedList('Potentials','Products',$focus,$query,$button,$returnset);
-	}
-
-	/**	Function used to get the Sales Stage history of the Potential
-	 *	@param $id - potentialid
-	 *	return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row
-	 */
-	function get_stage_history($id)
-	{	
-		global $log;
-		$log->debug("Entering get_stage_history(".$id.") method ...");
-
-		global $adb;
-		global $mod_strings;
-		global $app_strings;
-
-		$query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = '.$id;
-		$result=$adb->query($query);
-		$noofrows = $adb->num_rows($result);
-
-		$header[] = $app_strings['LBL_AMOUNT'];
-		$header[] = $app_strings['LBL_SALES_STAGE'];
-		$header[] = $app_strings['LBL_PROBABILITY'];
-		$header[] = $app_strings['LBL_CLOSE_DATE'];
-		$header[] = $app_strings['LBL_LAST_MODIFIED'];
-
-		while($row = $adb->fetch_array($result))
-		{
-			$entries = Array();
-
-			$entries[] = $row['amount'];
-			$entries[] = $row['stage'];
-			$entries[] = $row['probability'];
-			$entries[] = getDisplayDate($row['closedate']);
-			$entries[] = getDisplayDate($row['lastmodified']);
-
-			$entries_list[] = $entries;
-		}
-
-		$return_data = Array('header'=>$header,'entries'=>$entries_list);
-
-	 	$log->debug("Exiting get_stage_history method ...");
-
-		return $return_data;
-	}
-	
-	/**
-	* Function to get Potential related Task & Event which have activity type Held, Completed or Deferred.
-	* @param  integer   $id 
-	* returns related Task or Event record in array format
-	*/
-	function get_history($id)
-	{
-			global $log;
-			$log->debug("Entering get_history(".$id.") method ...");
-			$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
-		vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_crmentity.modifiedtime,
-		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
-				from vtiger_activity
-				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
-				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-				left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
-				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
-				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
-				and vtiger_seactivityrel.crmid=".$id;
-		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-
-		$log->debug("Exiting get_history method ...");
-		return getHistory('Potentials',$query,$id);
-	}
-
-	/**
-	* Function to get Potential related Attachments
-	* @param  integer   $id
-	* returns related Attachment record in array format
-	*/
-	function get_attachments($id)
-	{
-		 global $log;
-		$log->debug("Entering get_attachments(".$id.") method ...");
-		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
-		vtiger_attachments.type  FileType, crm2.modifiedtime lastmodified,
-		vtiger_seattachmentsrel.attachmentsid, vtiger_notes.notesid crmid,
-			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-				from vtiger_notes
-				inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
-				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
-				left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
-				left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-				where vtiger_crmentity.crmid=".$id;
-		$query .= ' union all ';
-		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		// Inserted order by createdtime desc
-		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
-		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
-		vtiger_attachments.attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-				from vtiger_attachments
-				inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
-				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
-				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-				where vtiger_crmentity.crmid=".$id."
-				order by createdtime desc";
-
-		$log->debug("Exiting get_attachments method ...");
-		return getAttachmentsAndNotes('Potentials',$query,$id);
-	}
-
-	  /**
-	  * Function to get Potential related Quotes
-	  * @param  integer   $id  - potentialid
-	  * returns related Quotes record in array format
-	  */
-	function get_quotes($id)
-	{
-		 global $log, $singlepane_view;
-		$log->debug("Entering get_quotes(".$id.") method ...");
-		global $app_strings;
-		require_once('modules/Quotes/Quote.php');
-
-		if($this->column_fields['account_id']!='')
-			$focus = new Quote();
-
-		$button = '';
-		if(isPermitted("Quotes",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-
-		$query = "select vtiger_crmentity.*, vtiger_quotes.*, vtiger_potential.potentialname, vtiger_users.user_name from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid=".$id;
-		$log->debug("Exiting get_quotes method ...");
-		return  GetRelatedList('Potentials','Quotes',$focus,$query,$button,$returnset);
-	}
-
-	/**
-	 * Function to get Potential related SalesOrder 
- 	 * @param  integer   $id  - potentialid
-	 * returns related SalesOrder record in array format
-	 */	 
-	function get_salesorder($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_salesorder(".$id.") method ...");
-		require_once('modules/SalesOrder/SalesOrder.php');
-		global $mod_strings;
-		global $app_strings;
-
-		$focus = new SalesOrder();
-
-		$button = '';
-		if(isPermitted("SalesOrder",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_SORDER_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;</td>';
-		}
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-
-		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_potential.potentialname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = ".$id;
-		$log->debug("Exiting get_salesorder method ...");
-		return GetRelatedList('Potentials','SalesOrder',$focus,$query,$button,$returnset);
-
-	}
-
-
-
-
-}
-
-
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Opportunity.php,v 1.65 2005/04/28 08:08:27 rank Exp $ 
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('modules/Contacts/Contact.php');
+require_once('modules/Calendar/Activity.php');
+require_once('modules/Notes/Note.php');
+require_once('modules/Emails/Email.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+// vtiger_potential is used to store customer information.
+class Potential extends CRMEntity {
+	var $log;
+	var $db;
+
+	var $module_name="Potentials";
+	var $table_name = "vtiger_potential";
+	var $rel_product_table = "vtiger_seproductsrel";
+	var $rel_opportunity_table = "vtiger_contpotentialrel";
+	var $module_id = "potentialid";
+	var $object_name = "potential";
+
+	var $tab_name = Array('vtiger_crmentity','vtiger_potential','vtiger_potentialscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_potential'=>'potentialid','vtiger_potentialscf'=>'potentialid');
+
+	var $column_fields = Array();
+
+	var $sortby_fields = Array('potentialname','amount','closingdate','smownerid');
+
+
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+			'Potential'=>Array('potential'=>'potentialname'),
+			'Account Name'=>Array('account'=>'accountname'),	  			
+			'Sales Stage'=>Array('potential'=>'sales_stage'),
+			'Amount'=>Array('potential'=>'amount'),
+			'Expected Close'=>Array('potential'=>'closingdate'),
+			'Assigned To'=>Array('crmentity','smownerid')
+			);
+
+	var $list_fields_name = Array(
+			'Potential'=>'potentialname',
+			'Account Name'=>'accountid',	  			
+			'Sales Stage'=>'sales_stage',	  			
+			'Amount'=>'amount',
+			'Expected Close'=>'closingdate',
+			'Assigned To'=>'assigned_user_id');
+
+	var $list_link_field= 'potentialname';
+
+	var $search_fields = Array(
+			'Potential'=>Array('potential'=>'potentialname'),
+			'Account Name'=>Array('potential'=>'accountid'),
+			'Expected Close'=>Array('potential'=>'closedate')
+			);
+
+	var $search_fields_name = Array(
+			'Potential'=>'potentialname',
+			'Account Name'=>'account_id',
+			'Expected Close'=>'closingdate'
+			);
+
+	var $required_fields =  array(
+			"potentialname"=>1,
+			"account_id"=>1,
+			"closingdate"=>1,
+			"sales_stage"=>1,
+			"amount"=>1
+			);
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'potentialname';
+	var $default_sort_order = 'ASC';
+
+	function Potential() {
+		$this->log = LoggerManager::getLogger('potential');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Potentials');
+	}
+
+	var $new_schema = true;
+	
+	/**
+	* Function to get sort order
+	* return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	*/
+	function getSortOrder()
+	{
+		global $log;
+                $log->debug("Entering getSortOrder() method ...");	
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['POTENTIALS_SORT_ORDER'] != '')?($_SESSION['POTENTIALS_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder() method ...");
+		return $sorder;
+	}
+
+	/**
+	* Function to get order by
+	* return string  $order_by    - fieldname(eg: 'Potentialname')
+	*/
+	function getOrderBy()
+	{
+		global $log;
+                $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['POTENTIALS_ORDER_BY'] != '')?($_SESSION['POTENTIALS_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+
+	/** Function to create list query 
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Query.
+	*/
+	function create_list_query($order_by, $where)
+	{
+		global $log;
+		$log->debug("Entering create_list_query(".$order_by.",". $where.") method ...");
+		// Determine if the vtiger_account name is present in the where clause.
+		$account_required = ereg("accounts\.name", $where);
+
+		if($account_required)
+		{
+			$query = "SELECT vtiger_potential.potentialid,  vtiger_potential.potentialname, vtiger_potential.dateclosed FROM vtiger_potential, vtiger_account ";
+			$where_auto = "account.accountid = vtiger_potential.accountid AND vtiger_crmentity.deleted=0 ";
+		}
+		else
+		{
+			$query = 'SELECT potentialid, potentialname, smcreatorid, closingdate FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid ';
+			$where_auto = 'AND vtiger_crmentity.deleted=0';
+		}
+
+		if($where != "")
+			$query .= "where $where ".$where_auto;
+		else
+			$query .= "where ".$where_auto;
+
+		if($order_by != "")
+			$query .= " ORDER BY vtiger_potential.$order_by";
+		else
+			$query .= " ORDER BY vtiger_potential.potentialname";
+
+
+
+		$log->debug("Exiting create_list_query method ...");
+		return $query;
+	}
+
+	/** Function to export the Opportunities records in CSV Format
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Export Potentials Query.
+	*/
+	function create_export_query($order_by, $where)
+	{
+		global $log;
+		global $current_user;
+		$log->debug("Entering create_export_query(".$order_by.",". $where.") method ...");
+
+		include("include/utils/ExportUtils.php");
+
+		//To get the Permitted fields query and the permitted fields list
+		$sql = getPermittedFieldsQuery("Potentials", "detail_view");
+		$fields_list = getFieldsListFromQuery($sql);
+
+		$query = "SELECT $fields_list FROM vtiger_potential 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid 
+				LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
+				LEFT JOIN vtiger_account on vtiger_potential.accountid=vtiger_account.accountid  
+				LEFT JOIN vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid 
+				LEFT JOIN vtiger_potentialgrouprelation
+                	                ON vtiger_potentialscf.potentialid = vtiger_potentialgrouprelation.potentialid
+	                        LEFT JOIN vtiger_groups
+                        	        ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+				LEFT JOIN vtiger_campaign
+					ON vtiger_campaign.campaignid = vtiger_potential.campaignid
+
+			where vtiger_crmentity.deleted=0 ";
+
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		//we should add security check when the user has Private Access
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[2] == 3)
+		{
+			//Added security check to get the permitted records only
+			$query = $query." ".getListViewSecurityParameter("Potentials");
+		}
+
+		$log->debug("Exiting create_export_query method ...");
+		return $query;
+
+	}
+
+
+
+	/** Returns a list of the associated contacts
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_contacts($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_contacts(".$id.") method ...");
+		global $app_strings;
+
+		$focus = new Contact();
+
+		$button = '';
+
+		if(isPermitted("Contacts",3,"") == 'yes')
+		{
+
+			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_CONTACT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Contacts&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'select vtiger_contactdetails.accountid, vtiger_users.user_name,vtiger_groups.groupname,vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_potential inner join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid inner join vtiger_contactdetails on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted=0';
+		
+		$log->debug("Exiting get_contacts method ...");
+		return GetRelatedList('Potentials','Contacts',$focus,$query,$button,$returnset);
+	}
+
+	/** Returns a list of the associated calls
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_activities($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_activities(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Activity();
+
+		$button = '';
+
+		if(isPermitted("Calendar",1,"") == 'yes')
+		{
+
+			$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.activity_mode.value=\'Task\';this.form.return_module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
+			$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Potentials\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name, vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and vtiger_crmentity.deleted=0 and ((vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus != '' &&  vtiger_activity.eventstatus != 'Held'))";
+		$log->debug("Exiting get_activities method ...");
+		return GetRelatedList('Potentials','Calendar',$focus,$query,$button,$returnset);
+
+	}
+
+	 /**
+	 * Function to get Contact related Products 
+	 * @param  integer   $id  - contactid
+	 * returns related Products record in array format
+	 */
+	function get_products($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_products(".$id.") method ...");
+		require_once('modules/Products/Product.php');
+		global $app_strings;
+
+		$focus = new Product();
+
+		$button = '';
+
+		if(isPermitted("Products",1,"") == 'yes')
+		{
+
+
+			$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Potentials\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
+		}
+		if(isPermitted("Products",3,"") == 'yes')
+		{
+			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_PRODUCT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Products&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_products inner join vtiger_seproductsrel on vtiger_products.productid = vtiger_seproductsrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_potential on vtiger_potential.potentialid = vtiger_seproductsrel.crmid  where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted = 0';
+		$log->debug("Exiting get_products method ...");
+		return GetRelatedList('Potentials','Products',$focus,$query,$button,$returnset);
+	}
+
+	/**	Function used to get the Sales Stage history of the Potential
+	 *	@param $id - potentialid
+	 *	return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row
+	 */
+	function get_stage_history($id)
+	{	
+		global $log;
+		$log->debug("Entering get_stage_history(".$id.") method ...");
+
+		global $adb;
+		global $mod_strings;
+		global $app_strings;
+
+		$query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = '.$id;
+		$result=$adb->query($query);
+		$noofrows = $adb->num_rows($result);
+
+		$header[] = $app_strings['LBL_AMOUNT'];
+		$header[] = $app_strings['LBL_SALES_STAGE'];
+		$header[] = $app_strings['LBL_PROBABILITY'];
+		$header[] = $app_strings['LBL_CLOSE_DATE'];
+		$header[] = $app_strings['LBL_LAST_MODIFIED'];
+
+		while($row = $adb->fetch_array($result))
+		{
+			$entries = Array();
+
+			$entries[] = $row['amount'];
+			$entries[] = $row['stage'];
+			$entries[] = $row['probability'];
+			$entries[] = getDisplayDate($row['closedate']);
+			$entries[] = getDisplayDate($row['lastmodified']);
+
+			$entries_list[] = $entries;
+		}
+
+		$return_data = Array('header'=>$header,'entries'=>$entries_list);
+
+	 	$log->debug("Exiting get_stage_history method ...");
+
+		return $return_data;
+	}
+	
+	/**
+	* Function to get Potential related Task & Event which have activity type Held, Completed or Deferred.
+	* @param  integer   $id 
+	* returns related Task or Event record in array format
+	*/
+	function get_history($id)
+	{
+			global $log;
+			$log->debug("Entering get_history(".$id.") method ...");
+			$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+		vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_crmentity.modifiedtime,
+		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+				from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+				left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
+				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+				and vtiger_seactivityrel.crmid=".$id;
+		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+
+		$log->debug("Exiting get_history method ...");
+		return getHistory('Potentials',$query,$id);
+	}
+
+	/**
+	* Function to get Potential related Attachments
+	* @param  integer   $id
+	* returns related Attachment record in array format
+	*/
+	function get_attachments($id)
+	{
+		 global $log;
+		$log->debug("Entering get_attachments(".$id.") method ...");
+		// Armando Lüscher 18.10.2005 -> §visibleDescription
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType, crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+				from vtiger_notes
+				inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+				left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+				left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+				where vtiger_crmentity.crmid=".$id;
+		$query .= ' union all ';
+		// Armando Lüscher 18.10.2005 -> §visibleDescription
+		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		// Inserted order by createdtime desc
+		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+				from vtiger_attachments
+				inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+				where vtiger_crmentity.crmid=".$id."
+				order by createdtime desc";
+
+		$log->debug("Exiting get_attachments method ...");
+		return getAttachmentsAndNotes('Potentials',$query,$id);
+	}
+
+	  /**
+	  * Function to get Potential related Quotes
+	  * @param  integer   $id  - potentialid
+	  * returns related Quotes record in array format
+	  */
+	function get_quotes($id)
+	{
+		 global $log, $singlepane_view;
+		$log->debug("Entering get_quotes(".$id.") method ...");
+		global $app_strings;
+		require_once('modules/Quotes/Quote.php');
+
+		if($this->column_fields['account_id']!='')
+			$focus = new Quote();
+
+		$button = '';
+		if(isPermitted("Quotes",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+
+		$query = "select vtiger_crmentity.*, vtiger_quotes.*, vtiger_potential.potentialname, vtiger_users.user_name from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid=".$id;
+		$log->debug("Exiting get_quotes method ...");
+		return  GetRelatedList('Potentials','Quotes',$focus,$query,$button,$returnset);
+	}
+
+	/**
+	 * Function to get Potential related SalesOrder 
+ 	 * @param  integer   $id  - potentialid
+	 * returns related SalesOrder record in array format
+	 */	 
+	function get_salesorder($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_salesorder(".$id.") method ...");
+		require_once('modules/SalesOrder/SalesOrder.php');
+		global $mod_strings;
+		global $app_strings;
+
+		$focus = new SalesOrder();
+
+		$button = '';
+		if(isPermitted("SalesOrder",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_SORDER_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;</td>';
+		}
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+
+		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_potential.potentialname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = ".$id;
+		$log->debug("Exiting get_salesorder method ...");
+		return GetRelatedList('Potentials','SalesOrder',$focus,$query,$button,$returnset);
+
+	}
+
+
+
+
+}
+
+
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/Potentials.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/Potentials.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/Potentials.php Mon Apr 16 12:27:44 2007
@@ -1,506 +1,538 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Potentials.php,v 1.65 2005/04/28 08:08:27 rank Exp $ 
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('modules/Contacts/Contacts.php');
-require_once('modules/Calendar/Activity.php');
-require_once('modules/Notes/Notes.php');
-require_once('modules/Emails/Emails.php');
-require_once('include/utils/utils.php');
-require_once('user_privileges/default_module_view.php');
-
-// vtiger_potential is used to store customer information.
-class Potentials extends CRMEntity {
-	var $log;
-	var $db;
-
-
-	var $tab_name = Array('vtiger_crmentity','vtiger_potential','vtiger_potentialscf');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_potential'=>'potentialid','vtiger_potentialscf'=>'potentialid');
-
-	var $column_fields = Array();
-
-	var $sortby_fields = Array('potentialname','amount','closingdate','smownerid');
-
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-			'Potential'=>Array('potential'=>'potentialname'),
-			'Account Name'=>Array('account'=>'accountname'),	  			
-			'Sales Stage'=>Array('potential'=>'sales_stage'),
-			'Amount'=>Array('potential'=>'amount'),
-			'Expected Close'=>Array('potential'=>'closingdate'),
-			'Assigned To'=>Array('crmentity','smownerid')
-			);
-
-	var $list_fields_name = Array(
-			'Potential'=>'potentialname',
-			'Account Name'=>'accountid',	  			
-			'Sales Stage'=>'sales_stage',	  			
-			'Amount'=>'amount',
-			'Expected Close'=>'closingdate',
-			'Assigned To'=>'assigned_user_id');
-
-	var $list_link_field= 'potentialname';
-
-	var $search_fields = Array(
-			'Potential'=>Array('potential'=>'potentialname'),
-			'Account Name'=>Array('potential'=>'accountid'),
-			'Expected Close'=>Array('potential'=>'closedate')
-			);
-
-	var $search_fields_name = Array(
-			'Potential'=>'potentialname',
-			'Account Name'=>'account_id',
-			'Expected Close'=>'closingdate'
-			);
-
-	var $required_fields =  array(
-			"potentialname"=>1,
-			"account_id"=>1,
-			"closingdate"=>1,
-			"sales_stage"=>1,
-			"amount"=>1
-			);
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'potentialname';
-	var $default_sort_order = 'ASC';
-
-	function Potentials() {
-		$this->log = LoggerManager::getLogger('potential');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Potentials');
-	}
-
-	function save_module($module)
-	{
-	}	
-	
-	/**
-	* Function to get sort order
-	* return string  $sorder    - sortorder string either 'ASC' or 'DESC'
-	*/
-	function getSortOrder()
-	{
-		global $log;
-                $log->debug("Entering getSortOrder() method ...");	
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['POTENTIALS_SORT_ORDER'] != '')?($_SESSION['POTENTIALS_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder() method ...");
-		return $sorder;
-	}
-
-	/**
-	* Function to get order by
-	* return string  $order_by    - fieldname(eg: 'Potentialname')
-	*/
-	function getOrderBy()
-	{
-		global $log;
-                $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['POTENTIALS_ORDER_BY'] != '')?($_SESSION['POTENTIALS_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-
-	/** Function to create list query 
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Query.
-	*/
-	function create_list_query($order_by, $where)
-	{
-		global $log;
-		$log->debug("Entering create_list_query(".$order_by.",". $where.") method ...");
-		// Determine if the vtiger_account name is present in the where clause.
-		$account_required = ereg("accounts\.name", $where);
-
-		if($account_required)
-		{
-			$query = "SELECT vtiger_potential.potentialid,  vtiger_potential.potentialname, vtiger_potential.dateclosed FROM vtiger_potential, vtiger_account ";
-			$where_auto = "account.accountid = vtiger_potential.accountid AND vtiger_crmentity.deleted=0 ";
-		}
-		else
-		{
-			$query = 'SELECT potentialid, potentialname, smcreatorid, closingdate FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid ';
-			$where_auto = 'AND vtiger_crmentity.deleted=0';
-		}
-
-		if($where != "")
-			$query .= "where $where ".$where_auto;
-		else
-			$query .= "where ".$where_auto;
-
-		if($order_by != "")
-			$query .= " ORDER BY vtiger_potential.$order_by";
-		else
-			$query .= " ORDER BY vtiger_potential.potentialname";
-
-
-
-		$log->debug("Exiting create_list_query method ...");
-		return $query;
-	}
-
-	/** Function to export the Opportunities records in CSV Format
-	* @param reference variable - order by is passed when the query is executed
-	* @param reference variable - where condition is passed when the query is executed
-	* Returns Export Potentials Query.
-	*/
-	function create_export_query($order_by, $where)
-	{
-		global $log;
-		global $current_user;
-		$log->debug("Entering create_export_query(".$order_by.",". $where.") method ...");
-
-		include("include/utils/ExportUtils.php");
-
-		//To get the Permitted fields query and the permitted fields list
-		$sql = getPermittedFieldsQuery("Potentials", "detail_view");
-		$fields_list = getFieldsListFromQuery($sql);
-
-		$query = "SELECT $fields_list FROM vtiger_potential 
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid 
-				LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
-				LEFT JOIN vtiger_account on vtiger_potential.accountid=vtiger_account.accountid  
-				LEFT JOIN vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid 
-				LEFT JOIN vtiger_potentialgrouprelation
-                	                ON vtiger_potentialscf.potentialid = vtiger_potentialgrouprelation.potentialid
-	                        LEFT JOIN vtiger_groups
-                        	        ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
-				LEFT JOIN vtiger_campaign
-					ON vtiger_campaign.campaignid = vtiger_potential.campaignid
-
-			where vtiger_crmentity.deleted=0 ";
-
-		require('user_privileges/user_privileges_'.$current_user->id.'.php');
-		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-		//we should add security check when the user has Private Access
-		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[2] == 3)
-		{
-			//Added security check to get the permitted records only
-			$query = $query." ".getListViewSecurityParameter("Potentials");
-		}
-
-		$log->debug("Exiting create_export_query method ...");
-		return $query;
-
-	}
-
-
-
-	/** Returns a list of the associated contacts
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_contacts($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_contacts(".$id.") method ...");
-		global $app_strings;
-
-		$focus = new Contacts();
-
-		$button = '';
-
-		if(isPermitted("Contacts",3,"") == 'yes')
-		{
-
-			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_CONTACT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Contacts&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'select vtiger_contactdetails.accountid, vtiger_users.user_name,vtiger_groups.groupname,vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_potential inner join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid inner join vtiger_contactdetails on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted=0';
-		
-		$log->debug("Exiting get_contacts method ...");
-		return GetRelatedList('Potentials','Contacts',$focus,$query,$button,$returnset);
-	}
-
-	/** Returns a list of the associated calls
-	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
-	 * All Rights Reserved..
-	 * Contributor(s): ______________________________________..
-	 */
-	function get_activities($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_activities(".$id.") method ...");
-		global $mod_strings;
-
-		$focus = new Activity();
-
-		$button = '';
-
-		if(isPermitted("Calendar",1,"") == 'yes')
-		{
-
-			$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.activity_mode.value=\'Task\';this.form.return_module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
-			$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Potentials\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name, vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid where vtiger_seactivityrel.crmid=".$id." and (activitytype='Task' or activitytype='Call' or activitytype='Meeting') and vtiger_crmentity.deleted=0 and ((vtiger_activity.status is not NULL && vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL && vtiger_activity.status != 'Deferred') or (vtiger_activity.eventstatus != '' &&  vtiger_activity.eventstatus != 'Held'))";
-		$log->debug("Exiting get_activities method ...");
-		return GetRelatedList('Potentials','Calendar',$focus,$query,$button,$returnset);
-
-	}
-
-	 /**
-	 * Function to get Contact related Products 
-	 * @param  integer   $id  - contactid
-	 * returns related Products record in array format
-	 */
-	function get_products($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_products(".$id.") method ...");
-		require_once('modules/Products/Products.php');
-		global $app_strings;
-
-		$focus = new Products();
-
-		$button = '';
-
-		if(isPermitted("Products",1,"") == 'yes')
-		{
-
-
-			$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Potentials\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
-		}
-		if(isPermitted("Products",3,"") == 'yes')
-		{
-			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_PRODUCT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Products&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_products inner join vtiger_seproductsrel on vtiger_products.productid = vtiger_seproductsrel.productid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid inner join vtiger_potential on vtiger_potential.potentialid = vtiger_seproductsrel.crmid  where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted = 0';
-		$log->debug("Exiting get_products method ...");
-		return GetRelatedList('Potentials','Products',$focus,$query,$button,$returnset);
-	}
-
-	/**	Function used to get the Sales Stage history of the Potential
-	 *	@param $id - potentialid
-	 *	return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row
-	 */
-	function get_stage_history($id)
-	{	
-		global $log;
-		$log->debug("Entering get_stage_history(".$id.") method ...");
-
-		global $adb;
-		global $mod_strings;
-		global $app_strings;
-
-		$query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = '.$id;
-		$result=$adb->query($query);
-		$noofrows = $adb->num_rows($result);
-
-		$header[] = $app_strings['LBL_AMOUNT'];
-		$header[] = $app_strings['LBL_SALES_STAGE'];
-		$header[] = $app_strings['LBL_PROBABILITY'];
-		$header[] = $app_strings['LBL_CLOSE_DATE'];
-		$header[] = $app_strings['LBL_LAST_MODIFIED'];
-
-		while($row = $adb->fetch_array($result))
-		{
-			$entries = Array();
-
-			$entries[] = $row['amount'];
-			$entries[] = $row['stage'];
-			$entries[] = $row['probability'];
-			$entries[] = getDisplayDate($row['closedate']);
-			$entries[] = getDisplayDate($row['lastmodified']);
-
-			$entries_list[] = $entries;
-		}
-
-		$return_data = Array('header'=>$header,'entries'=>$entries_list);
-
-	 	$log->debug("Exiting get_stage_history method ...");
-
-		return $return_data;
-	}
-	
-	/**
-	* Function to get Potential related Task & Event which have activity type Held, Completed or Deferred.
-	* @param  integer   $id 
-	* returns related Task or Event record in array format
-	*/
-	function get_history($id)
-	{
-			global $log;
-			$log->debug("Entering get_history(".$id.") method ...");
-			$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
-		vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_crmentity.modifiedtime,
-		vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
-				from vtiger_activity
-				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
-				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-				left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
-				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
-				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
-				and vtiger_seactivityrel.crmid=".$id;
-		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-
-		$log->debug("Exiting get_history method ...");
-		return getHistory('Potentials',$query,$id);
-	}
-
-	/**
-	* Function to get Potential related Attachments
-	* @param  integer   $id
-	* returns related Attachment record in array format
-	*/
-	function get_attachments($id)
-	{
-		 global $log;
-		$log->debug("Entering get_attachments(".$id.") method ...");
-		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
-		vtiger_attachments.type  FileType, crm2.modifiedtime lastmodified,
-		vtiger_seattachmentsrel.attachmentsid, vtiger_notes.notesid crmid,
-			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
-				from vtiger_notes
-				inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
-				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
-				left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
-				left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
-				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-				where vtiger_crmentity.crmid=".$id;
-		$query .= ' union all ';
-		// Armando Lüscher 18.10.2005 -> §visibleDescription
-		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-		// Inserted order by createdtime desc
-		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
-		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
-		vtiger_attachments.attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
-			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
-				from vtiger_attachments
-				inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
-				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
-				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
-				where vtiger_crmentity.crmid=".$id."
-				order by createdtime desc";
-
-		$log->debug("Exiting get_attachments method ...");
-		return getAttachmentsAndNotes('Potentials',$query,$id);
-	}
-
-	  /**
-	  * Function to get Potential related Quotes
-	  * @param  integer   $id  - potentialid
-	  * returns related Quotes record in array format
-	  */
-	function get_quotes($id)
-	{
-		 global $log, $singlepane_view;
-		$log->debug("Entering get_quotes(".$id.") method ...");
-		global $app_strings;
-		require_once('modules/Quotes/Quotes.php');
-
-		if($this->column_fields['account_id']!='')
-			$focus = new Quotes();
-
-		$button = '';
-		if(isPermitted("Quotes",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
-		}
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-
-		$query = "select vtiger_crmentity.*, vtiger_quotes.*, vtiger_potential.potentialname, vtiger_users.user_name from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid=".$id;
-		$log->debug("Exiting get_quotes method ...");
-		return  GetRelatedList('Potentials','Quotes',$focus,$query,$button,$returnset);
-	}
-
-	/**
-	 * Function to get Potential related SalesOrder 
- 	 * @param  integer   $id  - potentialid
-	 * returns related SalesOrder record in array format
-	 */	 
-	function get_salesorder($id)
-	{
-		global $log, $singlepane_view;
-		$log->debug("Entering get_salesorder(".$id.") method ...");
-		require_once('modules/SalesOrder/SalesOrder.php');
-		global $mod_strings;
-		global $app_strings;
-
-		$focus = new SalesOrder();
-
-		$button = '';
-		if(isPermitted("SalesOrder",1,"") == 'yes')
-		{
-			$button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_SORDER_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;</td>';
-		}
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
-
-
-		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_potential.potentialname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = ".$id;
-		$log->debug("Exiting get_salesorder method ...");
-		return GetRelatedList('Potentials','SalesOrder',$focus,$query,$button,$returnset);
-
-	}
-
-
-
-
-}
-
-
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Potentials.php,v 1.65 2005/04/28 08:08:27 rank Exp $ 
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('modules/Contacts/Contacts.php');
+require_once('modules/Calendar/Activity.php');
+require_once('modules/Notes/Notes.php');
+require_once('modules/Emails/Emails.php');
+require_once('include/utils/utils.php');
+require_once('user_privileges/default_module_view.php');
+
+// vtiger_potential is used to store customer information.
+class Potentials extends CRMEntity {
+	var $log;
+	var $db;
+
+	var $module_name="Potentials";
+	var $module_id = "potentialid";
+
+	var $tab_name = Array('vtiger_crmentity','vtiger_potential','vtiger_potentialscf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_potential'=>'potentialid','vtiger_potentialscf'=>'potentialid');
+
+	var $column_fields = Array();
+
+	var $sortby_fields = Array('potentialname','amount','closingdate','smownerid');
+
+
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+			'Potential'=>Array('potential'=>'potentialname'),
+			'Account Name'=>Array('account'=>'accountname'),	  			
+			'Sales Stage'=>Array('potential'=>'sales_stage'),
+			'Amount'=>Array('potential'=>'amount'),
+			'Expected Close Date'=>Array('potential'=>'closingdate'),
+			'Assigned To'=>Array('crmentity','smownerid')
+			);
+
+	var $list_fields_name = Array(
+			'Potential'=>'potentialname',
+			'Account Name'=>'accountid',	  			
+			'Sales Stage'=>'sales_stage',	  			
+			'Amount'=>'amount',
+			'Expected Close Date'=>'closingdate',
+			'Assigned To'=>'assigned_user_id');
+
+	var $list_link_field= 'potentialname';
+
+	var $search_fields = Array(
+			'Potential'=>Array('potential'=>'potentialname'),
+			'Account Name'=>Array('potential'=>'accountid'),
+			'Expected Close Date'=>Array('potential'=>'closedate')
+			);
+
+	var $search_fields_name = Array(
+			'Potential'=>'potentialname',
+			'Account Name'=>'account_id',
+			'Expected Close Date'=>'closingdate'
+			);
+
+	var $required_fields =  array(
+			"potentialname"=>1,
+			"account_id"=>1,
+			"closingdate"=>1,
+			"sales_stage"=>1,
+			"amount"=>1
+			);
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'potentialname';
+	var $default_sort_order = 'ASC';
+
+	var $groupTable = Array('vtiger_potentialgrouprelation','potentialid');
+	function Potentials() {
+		$this->log = LoggerManager::getLogger('potential');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Potentials');
+	}
+
+	function save_module($module)
+	{
+	}	
+	
+	/**
+	* Function to get sort order
+	* return string  $sorder    - sortorder string either 'ASC' or 'DESC'
+	*/
+	function getSortOrder()
+	{
+		global $log;
+                $log->debug("Entering getSortOrder() method ...");	
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['POTENTIALS_SORT_ORDER'] != '')?($_SESSION['POTENTIALS_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder() method ...");
+		return $sorder;
+	}
+
+	/**
+	* Function to get order by
+	* return string  $order_by    - fieldname(eg: 'Potentialname')
+	*/
+	function getOrderBy()
+	{
+		global $log;
+                $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['POTENTIALS_ORDER_BY'] != '')?($_SESSION['POTENTIALS_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+
+	/** Function to create list query 
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Query.
+	*/
+	function create_list_query($order_by, $where)
+	{
+		global $log,$current_user;
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	        require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+        	$tab_id = getTabid("Potentials");
+		$log->debug("Entering create_list_query(".$order_by.",". $where.") method ...");
+		// Determine if the vtiger_account name is present in the where clause.
+		$account_required = ereg("accounts\.name", $where);
+
+		if($account_required)
+		{
+			$query = "SELECT vtiger_potential.potentialid,  vtiger_potential.potentialname, vtiger_potential.dateclosed FROM vtiger_potential, vtiger_account ";
+			$where_auto = "account.accountid = vtiger_potential.accountid AND vtiger_crmentity.deleted=0 ";
+		}
+		else
+		{
+			$query = 'SELECT vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_crmentity.smcreatorid, vtiger_potential.closingdate FROM vtiger_potential inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid LEFT JOIN vtiger_potentialgrouprelation on vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid LEFT JOIN vtiger_groups on vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid ';
+			$where_auto = 'AND vtiger_crmentity.deleted=0 ';
+		}
+
+		if($where != "")
+			$query .= "where $where ".$where_auto;
+		else
+			$query .= "where ".$where_auto;
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
+                {
+                                $sec_parameter=getListViewSecurityParameter("Potentials");
+                                $query .= $sec_parameter;
+
+                }
+
+		if($order_by != "")
+			$query .= " ORDER BY $order_by";
+		else
+			$query .= " ORDER BY vtiger_potential.potentialname ";
+
+
+
+		$log->debug("Exiting create_list_query method ...");
+		return $query;
+	}
+
+	/** Function to export the Opportunities records in CSV Format
+	* @param reference variable - order by is passed when the query is executed
+	* @param reference variable - where condition is passed when the query is executed
+	* Returns Export Potentials Query.
+	*/
+	function create_export_query($order_by, $where)
+	{
+		global $log;
+		global $current_user;
+		$log->debug("Entering create_export_query(".$order_by.",". $where.") method ...");
+
+		include("include/utils/ExportUtils.php");
+
+		//To get the Permitted fields query and the permitted fields list
+		$sql = getPermittedFieldsQuery("Potentials", "detail_view");
+		$fields_list = getFieldsListFromQuery($sql);
+
+		$query = "SELECT $fields_list, vtiger_potentialgrouprelation.groupname as 'Assigned To Group'
+				FROM vtiger_potential 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid 
+				LEFT JOIN vtiger_users ON vtiger_crmentity.smownerid=vtiger_users.id
+				LEFT JOIN vtiger_account on vtiger_potential.accountid=vtiger_account.accountid  
+				LEFT JOIN vtiger_potentialscf on vtiger_potentialscf.potentialid=vtiger_potential.potentialid 
+				LEFT JOIN vtiger_potentialgrouprelation
+                	                ON vtiger_potentialscf.potentialid = vtiger_potentialgrouprelation.potentialid
+	                        LEFT JOIN vtiger_groups
+                        	        ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+				LEFT JOIN vtiger_campaign
+					ON vtiger_campaign.campaignid = vtiger_potential.campaignid
+
+			where vtiger_crmentity.deleted=0 ";
+
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		//we should add security check when the user has Private Access
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[2] == 3)
+		{
+			//Added security check to get the permitted records only
+			$query = $query." ".getListViewSecurityParameter("Potentials");
+		}
+
+		$log->debug("Exiting create_export_query method ...");
+		return $query;
+
+	}
+
+
+
+	/** Returns a list of the associated contacts
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_contacts($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_contacts(".$id.") method ...");
+		global $app_strings;
+
+		$focus = new Contacts();
+
+		$button = '';
+
+		if(isPermitted("Contacts",3,"") == 'yes')
+		{
+
+			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_CONTACT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Contacts&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+		$query = 'select case when (vtiger_users.user_name not like \'\') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.accountid,vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_potential inner join vtiger_contpotentialrel on vtiger_contpotentialrel.potentialid = vtiger_potential.potentialid inner join vtiger_contactdetails on vtiger_contpotentialrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_potential.potentialid = '.$id.' and vtiger_crmentity.deleted=0';
+		
+		$log->debug("Exiting get_contacts method ...");
+		return GetRelatedList('Potentials','Contacts',$focus,$query,$button,$returnset);
+	}
+
+	/** Returns a list of the associated calls
+	 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
+	 * All Rights Reserved..
+	 * Contributor(s): ______________________________________..
+	 */
+	function get_activities($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_activities(".$id.") method ...");
+		global $mod_strings;
+
+		$focus = new Activity();
+
+		$button = '';
+
+		if(isPermitted("Calendar",1,"") == 'yes')
+		{
+
+			$button .= '<input title="New Task" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.activity_mode.value=\'Task\';this.form.return_module.value=\'Potentials\'" type="submit" name="button" value="'.$mod_strings['LBL_NEW_TASK'].'">&nbsp;';
+			$button .= '<input title="New Event" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.return_action.value=\'DetailView\';this.form.module.value=\'Calendar\';this.form.return_module.value=\'Potentials\';this.form.activity_mode.value=\'Events\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_EVENT'].'">&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid where vtiger_seactivityrel.crmid=".$id." and vtiger_crmentity.deleted=0 and ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred')) or (vtiger_activity.activitytype in ('Meeting','Call') and  vtiger_activity.eventstatus not in ('','Held')))";
+		$log->debug("Exiting get_activities method ...");
+		return GetRelatedList('Potentials','Calendar',$focus,$query,$button,$returnset);
+
+	}
+
+	 /**
+	 * Function to get Contact related Products 
+	 * @param  integer   $id  - contactid
+	 * returns related Products record in array format
+	 */
+	function get_products($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_products(".$id.") method ...");
+		require_once('modules/Products/Products.php');
+		global $app_strings;
+
+		$focus = new Products();
+
+		$button = '';
+
+		if(isPermitted("Products",1,"") == 'yes')
+		{
+
+
+			$button .= '<input title="New Product" accessyKey="F" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Products\';this.form.return_module.value=\'Potentials\';this.form.return_action.value=\'DetailView\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_PRODUCT'].'">&nbsp;';
+		}
+		if(isPermitted("Products",3,"") == 'yes')
+		{
+			$button .= '<input title="Change" accessKey="" tabindex="2" type="button" class="button" value="'.$app_strings['LBL_SELECT_PRODUCT_BUTTON_LABEL'].'" name="Button" LANGUAGE=javascript onclick=\'return window.open("index.php?module=Products&action=Popup&return_module=Potentials&popuptype=detailview&form=EditView&form_submit=false&recordid='.$_REQUEST["record"].'","test","width=600,height=400,resizable=1,scrollbars=1");\'>&nbsp;';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, 
+				vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, 
+				vtiger_crmentity.crmid, vtiger_crmentity.smownerid 
+			   FROM vtiger_products 
+			   INNER JOIN vtiger_seproductsrel ON vtiger_products.productid = vtiger_seproductsrel.productid and vtiger_seproductsrel.setype = 'Potentials' 
+			   INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid 
+			   INNER JOIN vtiger_potential ON vtiger_potential.potentialid = vtiger_seproductsrel.crmid  
+			   WHERE vtiger_crmentity.deleted = 0 AND vtiger_potential.potentialid = $id";
+
+		$log->debug("Exiting get_products method ...");
+		return GetRelatedList('Potentials','Products',$focus,$query,$button,$returnset);
+	}
+
+	/**	Function used to get the Sales Stage history of the Potential
+	 *	@param $id - potentialid
+	 *	return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are array which contains all the column values of an row
+	 */
+	function get_stage_history($id)
+	{	
+		global $log;
+		$log->debug("Entering get_stage_history(".$id.") method ...");
+
+		global $adb;
+		global $mod_strings;
+		global $app_strings;
+
+		$query = 'select vtiger_potstagehistory.*, vtiger_potential.potentialname from vtiger_potstagehistory inner join vtiger_potential on vtiger_potential.potentialid = vtiger_potstagehistory.potentialid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid where vtiger_crmentity.deleted = 0 and vtiger_potential.potentialid = '.$id;
+		$result=$adb->query($query);
+		$noofrows = $adb->num_rows($result);
+
+		$header[] = $app_strings['LBL_AMOUNT'];
+		$header[] = $app_strings['LBL_SALES_STAGE'];
+		$header[] = $app_strings['LBL_PROBABILITY'];
+		$header[] = $app_strings['LBL_CLOSE_DATE'];
+		$header[] = $app_strings['LBL_LAST_MODIFIED'];
+
+		while($row = $adb->fetch_array($result))
+		{
+			$entries = Array();
+
+			$entries[] = $row['amount'];
+			$entries[] = $row['stage'];
+			$entries[] = $row['probability'];
+			$entries[] = getDisplayDate($row['closedate']);
+			$entries[] = getDisplayDate($row['lastmodified']);
+
+			$entries_list[] = $entries;
+		}
+
+		$return_data = Array('header'=>$header,'entries'=>$entries_list);
+
+	 	$log->debug("Exiting get_stage_history method ...");
+
+		return $return_data;
+	}
+	
+	/**
+	* Function to get Potential related Task & Event which have activity type Held, Completed or Deferred.
+	* @param  integer   $id 
+	* returns related Task or Event record in array format
+	*/
+	function get_history($id)
+	{
+			global $log;
+			$log->debug("Entering get_history(".$id.") method ...");
+			$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+		vtiger_activity.eventstatus, vtiger_activity.activitytype,vtiger_activity.date_start, 
+		vtiger_activity.due_date, vtiger_activity.time_start,vtiger_activity.time_end,
+		vtiger_crmentity.modifiedtime, vtiger_crmentity.createdtime, 
+		vtiger_crmentity.description,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name 
+				from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+				left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+				where (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')
+				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred' or (vtiger_activity.eventstatus = 'Held' and vtiger_activity.eventstatus != ''))
+				and vtiger_seactivityrel.crmid=".$id;
+		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+
+		$log->debug("Exiting get_history method ...");
+		return getHistory('Potentials',$query,$id);
+	}
+
+	/**
+	* Function to get Potential related Attachments
+	* @param  integer   $id
+	* returns related Attachment record in array format
+	*/
+	function get_attachments($id)
+	{
+		 global $log;
+		$log->debug("Entering get_attachments(".$id.") method ...");
+		// Armando Lüscher 18.10.2005 -> §visibleDescription
+		// Desc: Inserted crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		$query = "select vtiger_notes.title,'Notes      '  ActivityType, vtiger_notes.filename,
+		vtiger_attachments.type  FileType, crm2.modifiedtime lastmodified,
+		vtiger_seattachmentsrel.attachmentsid, vtiger_notes.notesid crmid,
+			crm2.createdtime, vtiger_notes.notecontent description, vtiger_users.user_name
+				from vtiger_notes
+				inner join vtiger_senotesrel on vtiger_senotesrel.notesid= vtiger_notes.notesid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_senotesrel.crmid
+				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_notes.notesid and crm2.deleted=0
+				left join vtiger_seattachmentsrel  on vtiger_seattachmentsrel.crmid =vtiger_notes.notesid
+				left join vtiger_attachments on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid
+				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+				where vtiger_crmentity.crmid=".$id;
+		$query .= ' union all ';
+		// Armando Lüscher 18.10.2005 -> §visibleDescription
+		// Desc: Inserted crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+		// Inserted inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+		// Inserted order by createdtime desc
+		$query .= "select vtiger_attachments.description title ,'Attachments'  ActivityType,
+		vtiger_attachments.name filename, vtiger_attachments.type FileType,crm2.modifiedtime lastmodified,
+		vtiger_attachments.attachmentsid, vtiger_seattachmentsrel.attachmentsid crmid,
+			crm2.createdtime, vtiger_attachments.description, vtiger_users.user_name
+				from vtiger_attachments
+				inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid= vtiger_attachments.attachmentsid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid= vtiger_seattachmentsrel.crmid
+				inner join vtiger_crmentity crm2 on crm2.crmid=vtiger_attachments.attachmentsid
+				inner join vtiger_users on crm2.smcreatorid= vtiger_users.id
+				where vtiger_crmentity.crmid=".$id."
+				order by createdtime desc";
+
+		$log->debug("Exiting get_attachments method ...");
+		return getAttachmentsAndNotes('Potentials',$query,$id);
+	}
+
+	  /**
+	  * Function to get Potential related Quotes
+	  * @param  integer   $id  - potentialid
+	  * returns related Quotes record in array format
+	  */
+	function get_quotes($id)
+	{
+		 global $log, $singlepane_view;
+		$log->debug("Entering get_quotes(".$id.") method ...");
+		global $app_strings;
+		require_once('modules/Quotes/Quotes.php');
+
+		if($this->column_fields['account_id']!='')
+			$focus = new Quotes();
+
+		$button = '';
+		if(isPermitted("Quotes",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_QUOTE_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_QUOTE_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'Quotes\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_QUOTE_BUTTON'].'">&nbsp;</td>';
+		}
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+
+		$query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.*, vtiger_quotes.*, vtiger_potential.potentialname from vtiger_quotes inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_quotes.potentialid left join vtiger_quotegrouprelation on vtiger_quotes.quoteid=vtiger_quotegrouprelation.quoteid left join vtiger_groups on vtiger_groups.groupname=vtiger_quotegrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid=".$id;
+		$log->debug("Exiting get_quotes method ...");
+		return  GetRelatedList('Potentials','Quotes',$focus,$query,$button,$returnset);
+	}
+
+	/**
+	 * Function to get Potential related SalesOrder 
+ 	 * @param  integer   $id  - potentialid
+	 * returns related SalesOrder record in array format
+	 */	 
+	function get_salesorder($id)
+	{
+		global $log, $singlepane_view;
+		$log->debug("Entering get_salesorder(".$id.") method ...");
+		require_once('modules/SalesOrder/SalesOrder.php');
+		global $mod_strings;
+		global $app_strings;
+
+		$focus = new SalesOrder();
+
+		$button = '';
+		if(isPermitted("SalesOrder",1,"") == 'yes')
+		{
+			$button .= '<input title="'.$app_strings['LBL_NEW_SORDER_BUTTON_TITLE'].'" accessyKey="'.$app_strings['LBL_NEW_SORDER_BUTTON_KEY'].'" class="button" onclick="this.form.action.value=\'EditView\';this.form.module.value=\'SalesOrder\'" type="submit" name="button" value="'.$app_strings['LBL_NEW_SORDER_BUTTON'].'">&nbsp;</td>';
+		}
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Potentials&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Potentials&return_action=CallRelatedList&return_id='.$id;
+
+
+		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname, vtiger_potential.potentialname,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+			from vtiger_salesorder 
+			inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid
+			left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid 
+			left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid 
+			left outer join vtiger_potential on vtiger_potential.potentialid=vtiger_salesorder.potentialid 
+			left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid 
+			left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname
+			left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+			 where vtiger_crmentity.deleted=0 and vtiger_potential.potentialid = ".$id;
+		$log->debug("Exiting get_salesorder method ...");
+		return GetRelatedList('Potentials','SalesOrder',$focus,$query,$button,$returnset);
+
+	}
+
+
+
+
+}
+
+
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/Save.php Mon Apr 16 12:27:44 2007
@@ -1,65 +1,65 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Save.php,v 1.6 2005/03/15 10:02:12 shaw Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('modules/Potentials/Potentials.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-
-$local_log =& LoggerManager::getLogger('index');
-
-$focus = new Potentials();
-global $current_user;
-$currencyid=fetchCurrency($current_user->id);
-$rate_symbol = getCurrencySymbolandCRate($currencyid);
-$rate = $rate_symbol['rate'];
-$curr_symbol= $rate_symbol['symbol'];
-
-setObjectValuesFromRequest(&$focus);
-
-if(isset($_REQUEST['amount']))
-{
-	$value = convertToDollar($_REQUEST['amount'],$rate);
-	$focus->column_fields['amount'] = $value;
-}
-
-$focus->save("Potentials");
-$return_id = $focus->id;
-
-if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab'];
-if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
-else $return_module = "Potentials";
-if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
-else $return_action = "DetailView";
-if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
-
-$local_log->debug("Saved record with id of ".$return_id);
-
-//code added for returning back to the current view after edit from list view
-if($_REQUEST['return_viewname'] == '') $return_viewname='0';
-if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
-
-//Added to send mail to the vtiger_potential-owner about the Potential
-$status = sendNotificationToOwner('Potentials',&$focus);
-
-header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&viewname=$return_viewname");
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Potentials/Save.php,v 1.6 2005/03/15 10:02:12 shaw Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('modules/Potentials/Potentials.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+
+$local_log =& LoggerManager::getLogger('index');
+
+$focus = new Potentials();
+global $current_user;
+$currencyid=fetchCurrency($current_user->id);
+$rate_symbol = getCurrencySymbolandCRate($currencyid);
+$rate = $rate_symbol['rate'];
+$curr_symbol= $rate_symbol['symbol'];
+
+setObjectValuesFromRequest(&$focus);
+
+if(isset($_REQUEST['amount']))
+{
+	$value = convertToDollar($_REQUEST['amount'],$rate);
+	$focus->column_fields['amount'] = $value;
+}
+
+$focus->save("Potentials");
+$pot_id = $return_id = $focus->id;
+
+if(isset($_REQUEST['parenttab']) && $_REQUEST['parenttab'] != "") $parenttab = $_REQUEST['parenttab'];
+if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
+else $return_module = "Potentials";
+if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
+else $return_action = "DetailView";
+if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
+
+$local_log->debug("Saved record with id of ".$return_id);
+
+//code added for returning back to the current view after edit from list view
+if($_REQUEST['return_viewname'] == '') $return_viewname='0';
+if($_REQUEST['return_viewname'] != '')$return_viewname=$_REQUEST['return_viewname'];
+
+//Added to send mail to the vtiger_potential-owner about the Potential
+$status = sendNotificationToOwner('Potentials',&$focus);
+
+header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&pot_id=$pot_id&viewname=$return_viewname");
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Potentials/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Potentials/updateRelations.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Potentials/updateRelations.php Mon Apr 16 12:27:44 2007
@@ -13,7 +13,13 @@
 require_once('user_privileges/default_module_view.php');
 global $adb, $singlepane_view;
 $idlist = $_REQUEST['idlist'];
-$returnmodule = $_REQUEST['return_module'];
+$dest_mod = $_REQUEST['destination_module'];
+
+if($singlepane_view == 'true')
+	$action = "DetailView";
+else
+	$action = "CallRelatedList";
+
 if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 {
 	//split the string and store in an array
@@ -22,27 +28,23 @@
 	{
 		if($id != '')
 		{
-		$sql = "insert into vtiger_contpotentialrel values (".$id.",".$_REQUEST["parentid"] .")";
-		$adb->query($sql);
-		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
-		$adb->query($sql);
+			$sql = "insert into vtiger_contpotentialrel values (".$id.",".$_REQUEST["parentid"] .")";
+			$adb->query($sql);
+			$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.",'Potentials')";
+			$adb->query($sql);
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Potentials&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Potentials&record=".$_REQUEST["parentid"]);
+
+	header("Location: index.php?action=$action&module=Potentials&record=".$_REQUEST["parentid"]);
 }
 elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
 {
-		$sql = "insert into vtiger_contpotentialrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
-		$adb->query($sql);
-		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
-		$adb->query($sql);
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Potentials&record=".$_REQUEST["parid"]);
-		else
- 			header("Location: index.php?action=CallRelatedList&module=Potentials&record=".$_REQUEST["parid"]);
+	$sql = "insert into vtiger_contpotentialrel values (". $_REQUEST["entityid"] .",".$_REQUEST["parid"] .")";
+	$adb->query($sql);
+	$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .",'Potentials')";
+	$adb->query($sql);
+
+	header("Location: index.php?action=$action&module=Potentials&record=".$_REQUEST["parid"]);
 }
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/PriceBooks/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PriceBooks/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PriceBooks/DetailView.php Mon Apr 16 12:27:44 2007
@@ -83,6 +83,7 @@
 	$related_array = getRelatedLists($currentModule,$focus);
 	$smarty->assign("RELATEDLISTS", $related_array);
 }
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
 
 $smarty->assign("SinglePane_View", $singlepane_view);
 

Modified: vtigercrm/branches/5.1_jens/modules/PriceBooks/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PriceBooks/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PriceBooks/EditView.php Mon Apr 16 12:27:44 2007
@@ -94,6 +94,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 // Assigned organizations
 $smarty->assign("CURRENT_ORGANIZATION",$current_organization);
@@ -106,7 +107,7 @@
 $smarty->assign("USER_ORGANIZATIONS",$org_array);
 
 if($focus->mode == 'edit')
-	$smarty->display('Inventory/InventoryEditView.tpl');
+    $smarty->display('Inventory/InventoryEditView.tpl');
 else 
-	$smarty->display('Inventory/InventoryCreateView.tpl');
+    $smarty->display('Inventory/InventoryCreateView.tpl');
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.html
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.html (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.html Mon Apr 16 12:27:44 2007
@@ -116,7 +116,7 @@
 }
 
 </script>
-<script language="javascript" src="modules/Products/Product.js"></script>
+<script language="javascript" src="modules/Products/Products.js"></script>
 <table width="95%" border="0" cellpadding="0" cellspacing="0">
 <tr><td colspan="3">&nbsp;</td></tr>
 <tr>

Modified: vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/AddProductToPriceBooks.php Mon Apr 16 12:27:44 2007
@@ -79,7 +79,7 @@
 
 	//we should not display the Add to PriceBook button if there is no pricebooks to associate
 	if($num_rows != $num_prod_rows)
-        	$other_text .='<input class="crmbutton small save" type="submit" value="Add To PriceBook" onclick="return addtopricebook()"/>&nbsp;';
+        	$other_text .='<input class="crmbutton small save" type="submit" value="'.$mod_strings['LBL_ADD_PRICEBOOK_BUTTON_LABEL'].'" onclick="return addtopricebook()"/>&nbsp;';
 
 $other_text .='<input title="'.$app_strings[LBL_CANCEL_BUTTON_TITLE].'" accessKey="'.$app_strings[LBL_CANCEL_BUTTON_KEY].'" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="'.$app_strings[LBL_CANCEL_BUTTON_LABEL].'"></td>';
 $other_text .='
@@ -115,9 +115,12 @@
 		$field_name=$entity_id."_listprice";
 		$list_body .= '<td><INPUT type=checkbox NAME="selected_id" id="check_'.$entity_id.'" value= '.$entity_id.' onClick=\'toggleSelectAll(this.name,"selectall");updateListPrice("'.$unit_price.'","'.$field_name.'",this)\'></td>';
 		$list_body .= '<td>'.$adb->query_result($list_result,$i,"bookname").'</td>';
-		$list_body .= '<td>'.$unit_price.'</td>';
-		$list_body .= '<td><input type="text" name="'.$field_name.'" style="visibility:hidden;" id="'.$field_name.'"></td>';
-		$list_body .= '</tr>';
+		$list_body .= '<td>'.$unit_price.'</td><td>';
+		if(isPermitted("PriceBooks","EditView","") == 'yes')
+			$list_body .= '<input type="text" name="'.$field_name.'" style="visibility:hidden;" id="'.$field_name.'">';
+		else
+			$list_body .= '<input type="text" name="'.$field_name.'" style="visibility:hidden;" readonly id="'.$field_name.'">';	
+		$list_body .= '</td></tr>';
 	}
 
 }

Modified: vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.html
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.html (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.html Mon Apr 16 12:27:44 2007
@@ -27,7 +27,7 @@
 }
 
 </script>
-<script language="javascript" src="modules/PriceBooks/PriceBook.js"></script>
+<script language="javascript" src="modules/PriceBooks/PriceBooks.js"></script>
 <BR>
 <BR>
 {PRODUCTLISTHEADER}

Modified: vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/AddProductsToPriceBook.php Mon Apr 16 12:27:44 2007
@@ -78,7 +78,7 @@
 
 	//we should not display the Add to PriceBook button if there is no products to associate
 	if($num_rows != $num_prod_rows)
-	        $other_text .='<input class="crmbutton small save" type="submit" value="Add To PriceBook" onclick="return addtopricebook()"/>';
+	        $other_text .='<input class="crmbutton small save" type="submit" value="'.$mod_strings[LBL_ADD_PRICEBOOK_BUTTON_LABEL].'" onclick="return addtopricebook()"/>';
 
 $other_text .='&nbsp;<input title="'.$app_strings[LBL_CANCEL_BUTTON_TITLE].'" accessKey="'.$app_strings[LBL_CANCEL_BUTTON_KEY].'" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="'.$app_strings[LBL_CANCEL_BUTTON_LABEL].'"></td>';
 
@@ -135,8 +135,12 @@
 		$list_body .= '<td><INPUT type=checkbox NAME="selected_id" id="check_'.$entity_id.'" value= '.$entity_id.' onClick=\'toggleSelectAll(this.name,"selectall");updateListPrice("'.$unit_price.'","'.$field_name.'",this)\'></td>';
 		$list_body .= '<td>'.$adb->query_result($list_result,$i,"productname").'</td>';
 		$list_body .= '<td>'.$adb->query_result($list_result,$i,"productcode").'</td>';
-		$list_body .= '<td>'.$unit_price.'</td>';
-		$list_body .= '<td><input type="text" name="'.$field_name.'" id="'.$field_name.'" style="visibility:hidden;"></td></tr>';
+		$list_body .= '<td>'.$unit_price.'</td><td>';
+		if(isPermitted("PriceBooks","EditView","") == 'yes')
+			$list_body .= '<input type="text" name="'.$field_name.'" style="visibility:hidden;" id="'.$field_name.'">';
+		else
+			$list_body .= '<input type="text" name="'.$field_name.'" style="visibility:hidden;" readonly id="'.$field_name.'">';
+		$list_body .= '</td></tr>';	
 	}
 }
 

Modified: vtigercrm/branches/5.1_jens/modules/Products/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/DetailView.php Mon Apr 16 12:27:44 2007
@@ -94,6 +94,8 @@
 $smarty->assign("MODULE", $currentModule);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
 
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);

Modified: vtigercrm/branches/5.1_jens/modules/Products/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/EditView.php Mon Apr 16 12:27:44 2007
@@ -207,6 +207,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 // Assigned organizations
 $smarty->assign("CURRENT_ORGANIZATION",$current_organization);
@@ -219,7 +220,7 @@
 $smarty->assign("USER_ORGANIZATIONS",$org_array);
 
 if($focus->mode == 'edit')
-	$smarty->display('Inventory/InventoryEditView.tpl');
+    $smarty->display('Inventory/InventoryEditView.tpl');
 else
-	$smarty->display('Inventory/InventoryCreateView.tpl');
+    $smarty->display('Inventory/InventoryCreateView.tpl');
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Products/Products.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/Products.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/Products.php Mon Apr 16 12:27:44 2007
@@ -66,6 +66,17 @@
                                         'Unit Price'=>'unit_price'
                                      );
 	
+	var $dependend_fields = Array(
+                                'Product Name'=>Array('products'=>'productname'),
+                                'Part Number'=>Array('products'=>'productcode'),
+                                'Unit Price'=>Array('products'=>'unit_price')
+                                );
+        var $dependend_fields_name = Array(
+                                        'Product Name'=>'productname',
+                                        'Part Number'=>'productcode',
+                                        'Unit Price'=>'unit_price'
+                                     );
+	
 	//Added these variables which are used as default order by and sortorder in ListView
 	var $default_order_by = 'productname';
 	var $default_sort_order = 'ASC';
@@ -82,15 +93,6 @@
 
 	function save_module($module)
 	{
-		//Inserting into vtiger_seproductsrel table
-		if(isset($this->column_fields['parent_id']) && $this->column_fields['parent_id'] != '')
-		{
-			$this->insertIntoEntityTable('vtiger_seproductsrel', 'Products');
-		}
-		elseif($this->column_fields['parent_id']=='' && $insertion_mode=="edit")
-		{
-			$this->deleteRelation('vtiger_seproductsrel');
-		}
 		//Inserting into product_taxrel table
 		if($_REQUEST['ajxaction'] != 'DETAILVIEW')
 		{
@@ -270,30 +272,142 @@
         	return getAttachmentsAndNotes('Products',$query,$id);
 	}
 
+	/**	function used to get the list of leads which are related to the product
+	 *	@param int $id - product id 
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_leads($id)
+	{
+		global $log, $singlepane_view, $mod_strings;
+		$log->debug("Entering get_leads(".$id.") method ...");
+
+		require_once('modules/Leads/Leads.php');
+		$focus = new Leads();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_leaddetails.leadid, vtiger_crmentity.crmid, vtiger_leaddetails.firstname, vtiger_leaddetails.lastname, vtiger_leaddetails.company, vtiger_leadaddress.phone, vtiger_leadsubdetails.website, vtiger_leaddetails.email, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_leaddetails
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_leadaddress ON vtiger_leadaddress.leadaddressid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_leadsubdetails ON vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid=vtiger_leaddetails.leadid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_leadgrouprelation ON vtiger_leaddetails.leadid = vtiger_leadgrouprelation.leadid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+		$log->debug("Exiting get_leads($id) method ...");
+		return GetRelatedList('Products','Leads',$focus,$query,$button,$returnset);
+        }
+
+	/**	function used to get the list of accounts which are related to the product
+	 *	@param int $id - product id 
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_accounts($id)
+	{
+		global $log, $singlepane_view, $mod_strings;
+		$log->debug("Entering get_accounts(".$id.") method ...");
+
+		require_once('modules/Accounts/Accounts.php');
+		$focus = new Accounts();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_account.accountid, vtiger_crmentity.crmid, vtiger_account.accountname, vtiger_accountbillads.city, vtiger_account.website, vtiger_account.phone, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_account
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_account.accountid
+			INNER JOIN vtiger_accountbillads ON vtiger_accountbillads.accountaddressid = vtiger_account.accountid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid=vtiger_account.accountid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_accountgrouprelation ON vtiger_account.accountid = vtiger_accountgrouprelation.accountid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+			
+		$log->debug("Exiting get_accounts method ...");
+		return GetRelatedList('Products','Accounts',$focus,$query,$button,$returnset);
+        }
+
+	/**	function used to get the list of contacts which are related to the product
+	 *	@param int $id - product id 
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_contacts($id)
+	{
+		global $log, $singlepane_view, $mod_strings;
+		$log->debug("Entering get_contacts(".$id.") method ...");
+
+		require_once('modules/Contacts/Contacts.php');
+		$focus = new Contacts();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_contactdetails.title, vtiger_contactdetails.accountid, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
+			FROM vtiger_contactdetails
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid=vtiger_contactdetails.contactid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_contactgrouprelation ON vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+		$log->debug("Exiting get_contacts method ...");
+		return GetRelatedList('Products','Contacts',$focus,$query,$button,$returnset);
+        }
+
+
 	/**	function used to get the list of potentials which are related to the product
 	 *	@param int $id - product id 
-	 *	@return void - but this function will call the function renderRelatedPotentials with parameter query
+	 *	@return array - array which will be returned from the function GetRelatedList
 	 */
 	function get_opportunities($id)
 	{
-		global $log;
+		global $log, $singlepane_view, $mod_strings;
 		$log->debug("Entering get_opportunities(".$id.") method ...");
-		$query = "SELECT vtiger_potential.potentialid, vtiger_potential.potentialname,
-			vtiger_potential.potentialtype, vtiger_products.productid,
-			vtiger_products.productname, vtiger_products.qty_per_unit,
-			vtiger_products.unit_price, vtiger_products.expiry_date
+
+		require_once('modules/Potentials/Potentials.php');
+		$focus = new Potentials();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Products&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT vtiger_potential.potentialid, vtiger_crmentity.crmid, vtiger_potential.potentialname, vtiger_account.accountname, vtiger_potential.accountid, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_crmentity.smownerid, vtiger_products.productname, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_products.expiry_date
 			FROM vtiger_potential
-			INNER JOIN vtiger_products
-				ON vtiger_potential.productid = vtiger_products.productid
-			LEFT JOIN vtiger_potentialgrouprelation
-				ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
-			LEFT JOIN vtiger_groups
-				ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
-			inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid
-			WHERE vtiger_crmentity.deleted = 0
-			AND vtiger_products.productid = ".$id;
-		$log->debug("Exiting get_opportunities method ...");
-          renderRelatedPotentials($query);
+			INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_potential.potentialid
+			INNER JOIN vtiger_account ON vtiger_potential.accountid = vtiger_account.accountid
+			INNER JOIN vtiger_seproductsrel ON vtiger_seproductsrel.crmid = vtiger_potential.potentialid
+			INNER JOIN vtiger_products ON vtiger_seproductsrel.productid = vtiger_products.productid
+			LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid
+			LEFT JOIN vtiger_potentialgrouprelation ON vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+			LEFT JOIN vtiger_groups ON vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+			WHERE vtiger_crmentity.deleted = 0 AND vtiger_products.productid = ".$id;
+
+		$log->debug("Exiting get_opportunities($id) method ...");
+		return GetRelatedList('Products','Potentials',$focus,$query,$button,$returnset);
         }
 
 	/**	function used to get the list of tickets which are related to the product
@@ -315,7 +429,7 @@
 		else
 			$returnset = '&return_module=Products&return_action=CallRelatedList&return_id='.$id;
 
-		$query = "SELECT vtiger_users.user_name, vtiger_users.id,
+		$query = "SELECT  case when (vtiger_users.user_name not like \"\") then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_users.id,
 			vtiger_products.productid, vtiger_products.productname,
 			vtiger_troubletickets.ticketid,
 			vtiger_troubletickets.parent_id, vtiger_troubletickets.title,
@@ -335,7 +449,8 @@
 				ON vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
 			WHERE vtiger_crmentity.deleted = 0
 			AND vtiger_products.productid = ".$id;
-	$log->debug("Exiting get_tickets method ...");
+	
+		$log->debug("Exiting get_tickets method ...");
 		return GetRelatedList('Products','HelpDesk',$focus,$query,$button,$returnset);
 	}
 
@@ -419,7 +534,8 @@
 			vtiger_quotes.*,
 			vtiger_potential.potentialname,
 			vtiger_account.accountname,
-			vtiger_inventoryproductrel.productid
+			vtiger_inventoryproductrel.productid,
+			vtiger_users.user_name
 			FROM vtiger_quotes
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_quotes.quoteid
@@ -433,6 +549,8 @@
 				ON vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
 			LEFT JOIN vtiger_groups
 				ON vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
+			LEFT JOIN vtiger_users 
+				ON vtiger_users.id=vtiger_crmentity.smownerid
 			WHERE vtiger_crmentity.deleted = 0
 			AND vtiger_inventoryproductrel.productid = ".$id;
 		$log->debug("Exiting get_quotes method ...");
@@ -461,7 +579,8 @@
 		$query = "SELECT vtiger_crmentity.*,
 			vtiger_purchaseorder.*,
 			vtiger_products.productname,
-			vtiger_inventoryproductrel.productid
+			vtiger_inventoryproductrel.productid,
+			vtiger_users.user_name
 			FROM vtiger_purchaseorder
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_purchaseorder.purchaseorderid
@@ -473,6 +592,8 @@
 				ON vtiger_purchaseorder.purchaseorderid = vtiger_pogrouprelation.purchaseorderid
 			LEFT JOIN vtiger_groups
 				ON vtiger_groups.groupname = vtiger_pogrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON vtiger_users.id=vtiger_crmentity.smownerid
 			WHERE vtiger_crmentity.deleted = 0
 			AND vtiger_products.productid = ".$id;
 		$log->debug("Exiting get_purchase_orders method ...");
@@ -501,7 +622,8 @@
 		$query = "SELECT vtiger_crmentity.*,
 			vtiger_salesorder.*,
 			vtiger_products.productname AS productname,
-			vtiger_account.accountname
+			vtiger_account.accountname,
+			vtiger_users.user_name
 			FROM vtiger_salesorder
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_salesorder.salesorderid
@@ -515,6 +637,8 @@
 				ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
 			LEFT JOIN vtiger_groups
 				ON vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+			LEFT JOIN vtiger_users 
+				ON vtiger_users.id=vtiger_crmentity.smownerid
 			WHERE vtiger_crmentity.deleted = 0
 			AND vtiger_products.productid = ".$id;
 		$log->debug("Exiting get_salesorder method ...");
@@ -543,7 +667,8 @@
 		$query = "SELECT vtiger_crmentity.*,
 			vtiger_invoice.*,
 			vtiger_inventoryproductrel.quantity,
-			vtiger_account.accountname
+			vtiger_account.accountname,
+			vtiger_users.user_name
 			FROM vtiger_invoice
 			INNER JOIN vtiger_crmentity
 				ON vtiger_crmentity.crmid = vtiger_invoice.invoiceid
@@ -555,6 +680,8 @@
 				ON vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
 			LEFT JOIN vtiger_groups
 				ON vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+			LEFT JOIN vtiger_users
+				ON  vtiger_users.id=vtiger_crmentity.smownerid
 			WHERE vtiger_crmentity.deleted = 0
 			AND vtiger_inventoryproductrel.productid = ".$id;
 		$log->debug("Exiting get_invoices method ...");
@@ -591,6 +718,82 @@
 			AND vtiger_pricebookproductrel.productid = ".$id; 
 		$log->debug("Exiting get_product_pricebooks method ...");
 		return GetRelatedList('Products','PriceBooks',$focus,$query,$button,$returnset);
+	}
+
+	/**	function used to get the piecelist for this product
+	 *	@param int $id - product id
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_product_piecelist($id)
+	{     
+		return $this->get_product_dependencies($id,10);
+	}
+
+	/**	function used to get the list of required products for this product
+	 *	@param int $id - product id
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_product_depends($id)
+	{     
+		return $this->get_product_dependencies($id,20);
+	}
+
+	/**	function used to get the list of products incompatible with this product
+	 *	@param int $id - product id
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_product_incompatibles($id)
+	{     
+		return $this->get_product_dependencies($id,21);
+	}
+
+	/**	function used to get the list of optional products related to this product
+	 *	@param int $id - product id
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_product_options($id)
+	{     
+		return $this->get_product_dependencies($id,30);
+	}
+
+	/**	function used to get the list of products to be purchased to sell this product
+	 *	@param int $id - product id
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_product_purchaselist($id)
+	{     
+		return $this->get_product_dependencies($id,40);
+	}
+
+	/**	function used to get generic product dependencies
+	 *	@param int $id - product id
+	 *	@param int $type - dependency typ (10=piecelist, 20=requirement, 21=incompatible, 30=option, 40=purchaselist)
+	 *	@return array - array which will be returned from the function GetRelatedList
+	 */
+	function get_product_dependencies($id,$type)
+	{     
+		global $log,$singlepane_view;
+		$log->debug("Entering get_product_dependencies(".$id.",".$type.") method ...");
+		global $mod_strings;
+		$button = '';
+		$returnset = '&return_module=Products&return_action=CallDependencyList&return_id='.$id;
+		$focus = new Products();
+
+		$query = "SELECT vtiger_crmentity.crmid,
+			vtiger_products.*,
+			vtiger_products2products_rel.related_productid as prodid,
+			vtiger_products2products_rel.quantity as quantity,
+			vtiger_products2products_rel.product_relgroup as product_relgroup
+			FROM vtiger_products2products_rel
+			INNER JOIN vtiger_products
+				ON vtiger_products.productid = vtiger_products2products_rel.related_productid
+			INNER JOIN vtiger_crmentity
+				ON vtiger_crmentity.crmid = vtiger_products.productid
+			WHERE vtiger_crmentity.deleted = 0
+			AND vtiger_products2products_rel.productid = ".$id."
+			AND vtiger_products2products_rel.relation_type = ".$type; 
+		$log->debug("Exiting get_product_dependencies method ...");
+		return GetRelatedList('Products','Products',$focus,$query,$button,$returnset,'','','',$type);
 	}
 
 	/**	function used to get the number of vendors which are related to the product
@@ -650,18 +853,19 @@
 			LEFT JOIN vtiger_potential vtiger_ProductRelatedToPotential
 				ON vtiger_ProductRelatedToPotential.potentialid = vtiger_seproductsrel.crmid
 	
-			LEFT JOIN vtiger_contactdetails 
-				ON vtiger_contactdetails.contactid = vtiger_products.contactid
+			LEFT JOIN vtiger_contactdetails vtiger_ProductRelatedToContact 
+				ON vtiger_ProductRelatedToContact.contactid = vtiger_seproductsrel.crmid
+
 			LEFT JOIN vtiger_vendor
 				ON vtiger_vendor.vendorid = vtiger_products.vendor_id
 			
 			WHERE vtiger_crmentity.deleted = 0 AND vtiger_users.status = 'Active'
-				AND ((vtiger_seproductsrel.crmid IS NULL
-					AND (vtiger_products.contactid = 0 OR vtiger_products.contactid IS NULL))
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
-				OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
-				OR vtiger_products.contactid IN (".getReadEntityIds('Contacts').")) 
+				AND (
+					(vtiger_seproductsrel.crmid IS NULL)
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Leads').")
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Accounts').")
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Potentials').")
+					OR vtiger_seproductsrel.crmid IN (".getReadEntityIds('Contacts').")) 
 			group by vtiger_products.productid
 			";
 			//ProductRelatedToLead, Account and Potential tables are added to get the Related to field

Modified: vtigercrm/branches/5.1_jens/modules/Products/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/Save.php Mon Apr 16 12:27:44 2007
@@ -24,7 +24,7 @@
 require_once('modules/Products/Products.php');
 require_once('include/logging.php');
 require_once('include/database/PearDatabase.php');
-global $log,$current_user;
+global $log,$current_user,$mod_strings;
 $currencyid=fetchCurrency($current_user->id);
 $rate_symbol = getCurrencySymbolandCRate($currencyid);
 $rate = $rate_symbol['rate'];
@@ -139,14 +139,14 @@
 			$handler_name = getUserName($handler);
 			$sender_name = getUserName($current_user->id);
 			$to_address= getUserEmail($handler);
-			$subject =  $productname.' Stock Level is Low';
-			$body = 'Dear '.$handler_name.',
+			$subject =  $productname.' '.$mod_strings['MSG_STOCK_LEVEL'];
+			$body = $mod_strings['MSG_DEAR'].' '.$handler_name.',<br><br>'.
 
-					The current stock of '.$productname.' in our warehouse is '.$qty_stk.'. Kindly procure required number of units as the stock level is below reorder level '.$reord.'.
+					$mod_strings['MSG_CURRENT_STOCK'].' '.$productname.' '.$mod_strings['MSG_IN_OUR_WAREHOUSE'].' '.$qty_stk.'. '.$mod_strings['MSG_PROCURE_REQUIRED_NUMBER'].' '.$reord.'.<br> '.
 
-					Severity: Major 
-				Thanks,
-				'.$sender_name; 
+					$mod_strings['MSG_SEVERITY'].'<br><br> '.
+				$mod_strings['MSG_THANKS'].'<br> '.
+				$sender_name;
 
 			include("modules/Emails/mail.php");
 			$mail_status = send_mail("Products",$to_address,$current_user->user_name,$current_user->email1,$subject,$body);

Modified: vtigercrm/branches/5.1_jens/modules/Products/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -63,7 +63,6 @@
 'LBL_COLON'=>':',
 
 'LBL_ATTACHMENTS'=>'Attachments',
-'LBL_NEW_ATTACHMENT'=>'New Attachment',
 'LBL_ATTACH_FILE'=>'File Attachment',
 'LBL_DESCRIPTION'=>'Description',
 'LBL_FILE'=>'File Name',
@@ -94,13 +93,18 @@
 
 //Added for 4GA
 'Product Name'=>'Product Name',
-'Product Code'=>'Part Number',
+//'Product Code'=>'Part Number',
+'Part Number'=>'Part Number',
 'Product Active'=>'Product Active',
 'Commission Rate'=>'Commission Rate (%)',
 'Qty/Unit'=>'Qty/Unit',
 'Unit Price'=>'Unit Price',
 'Manufacturer'=>'Manufacturer',
 'Product Category'=>'Product Category',
+'Product Class'=>'Product Class',
+'Product Type'=>'Product Type',
+'Product Validation'=>'Product Validation',
+'Contract Bound'=>'Contract Required',
 'Support Start Date'=>'Support Start Date',
 'Support Expiry Date'=>'Support Expiry Date',
 'Purchase Date'=>'Purchase Date',
@@ -108,14 +112,12 @@
 'Sales End Date'=>'Sales End Date',
 'Created Time'=>'Created Time',
 'Modified Time'=>'Modified Time',
-'Description'=>'Description',
 'Related To'=>'Related To',
 'Usage Unit'=>'Usage Unit',
 'Handler'=>'Handler',
 'Contact Name'=>'Contact Name',
 'Currency'=>'Currency',
 'Reorder Level'=>'Reorder Level',
-'Website'=>'Website',
 'Tax Class'=>'Tax Class',
 'Mfr PartNo'=>'Mfr Part No',
 'Vendor PartNo'=>'Vendor Part No',
@@ -215,6 +217,15 @@
 'LBL_COMPANY_ASSIGNMENT'=>'Organization Assignment',
 'Organization Assignment'=>'Assigned to',
 
+//Added for 5.0.3
+'MSG_STOCK_LEVEL'=>'Stock Level is Low',
+'MSG_DEAR'=>'Dear',
+'MSG_CURRENT_STOCK'=>'The current stock of',
+'MSG_IN_OUR_WAREHOUSE'=>'in our warehouse is',
+'MSG_PROCURE_REQUIRED_NUMBER'=>'Kindly procure required number of units as the stock level is below reorder level',
+'MSG_SEVERITY'=>'Severity: Major',
+'MSG_THANKS'=>'Thanks,',
+
 );
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Products/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Products/updateRelations.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Products/updateRelations.php Mon Apr 16 12:27:44 2007
@@ -11,34 +11,114 @@
 
 require_once('include/database/PearDatabase.php');
 global $adb;
+global $log;
+$dest_mod = $_REQUEST['destination_module'];
 
-//This if will be true, when we select product from vendor related list
-if($_REQUEST['destination_module']=='Products')
+$log->debug("Entering Products/updateRelations.php");
+
+if($singlepane_view == 'true')
+	$return_action = "DetailView";
+else
+	$return_action = "CallRelatedList";
+
+if($_REQUEST['return_module'] != '') $return_module = $_REQUEST['return_module'];
+
+//if select Lead, Account, Contact, Potential from Product RelatedList 
+//we have to insert in vtiger_seproductsrel
+if($dest_mod =='Leads' || $dest_mod =='Accounts' ||$dest_mod =='Contacts' ||$dest_mod =='Potentials')
 {
+	//For Bulk updates
+	if($_REQUEST['idlist'] != '')
+	{
+		$entityids = explode(';',trim($_REQUEST['idlist'],';'));
+		$productid = $_REQUEST['parentid'];
+	}
+	else
+	{
+		$entityids[] = $_REQUEST['entityid'];
+		$productid = $_REQUEST['parid'];
+	}
+	
+	foreach($entityids as $ind => $crmid)
+	{
+		if($crmid != '' && $productid != '')
+		{
+			$sql = "insert into vtiger_seproductsrel values ($crmid,$productid,'".$dest_mod."')";
+			$adb->query($sql);
+		}
+	}
+	
+	$return_module = 'Products';
+	$return_record = $productid;
+}
+
+//if the destination module is also a product, we have to update dependency
+//lists
+else if($dest_mod=='Products') {
+    if( !isset( $_REQUEST['dependency_type']) || $_REQUEST['dependency_type'] == '') {
+
+	//select product from vendor related list
 	if($_REQUEST['parid'] != '' && $_REQUEST['entityid'] != '')
 	{
 		$sql = "update vtiger_products set vendor_id=".$_REQUEST['parid']." where productid=".$_REQUEST['entityid'];
 		$adb->query($sql);
 	}
-}
-if($_REQUEST['destination_module']=='Contacts')
-{
-	if($_REQUEST['smodule']=='VENDOR')
-	{
-		$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
+	
+	$return_module = 'Products';
+	$return_record = $_REQUEST['parid'];
+
+    } else {
+	//module dependency list change
+	$sql = "SELECT count(*) FROM vtiger_products2products_rel
+		    WHERE productid=".$_REQUEST['parentid']." AND relation_type=".$_REQUEST['dependency_type'];
+	$count_result = $adb->query( $sql);
+	$sequence = $adb->query_result($count_result,0,"count");
+
+	//get the list of dependencies from the request
+	$idlist = $_REQUEST['idlist'];
+	$storearray = explode (";",$idlist);
+	$qtylist = $_REQUEST['qtylist'];
+	$tmparray = explode (";",$qtylist);
+	$qtyarray = array();
+	foreach( $tmparray as $avp) {
+	    $avplist = explode( ":",$avp);
+	    $qtyarray[$avplist[0]] = $avplist[1];
+	}
+
+	//get the values from the requies and store them into the database
+	foreach($storearray as $id) {
+	    if($id != '') {
+
+		//We have quantities for piecelists and purchase lists
+		$qty = $grp = 1;
+		if( isset( $qtyarray[$id])) {
+		    if( $_REQUEST['dependency_type'] == 10 || $_REQUEST['dependency_type'] == 40) {
+			$qty = $qtyarray[$id];
+		    } elseif( $_REQUEST['dependency_type'] == 20) {
+			$grp = $qtyarray[$id];
+		    }
+		}
+
+		//database query
+		$sql = "INSERT INTO vtiger_products2products_rel(productid,related_productid,relation_type,sequence_no,quantity,comment,product_relgroup) VALUES(".$_REQUEST["parentid"].",".$id.",".$_REQUEST['dependency_type'].",".++$sequence.",".$qty.",'',".$grp.")";
 		$adb->query($sql);
+	    }
 	}
+
+	//Navigation
+	$return_action = "CallDependencyList";
+	$return_module = "Products";
+	$return_record = $_REQUEST['parentid'];
+    }
 }
 
-$return_action = 'DetailView';
-if($_REQUEST['return_action'] != '')
-	$return_action = $_REQUEST['return_action'];
 
-header("Location:index.php?action=$return_action&module=Vendors&record=".$_REQUEST["parid"]);
+if( $return_action == "") {
+    $return_action = 'DetailView';
+    if($_REQUEST['return_action'] != '')
+	    $return_action = $_REQUEST['return_action'];
+}
 
-
-
-
-
+header("Location:index.php?action=$return_action&module=$return_module&record=$return_record");
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/PurchaseOrder/CreatePDF.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PurchaseOrder/CreatePDF.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PurchaseOrder/CreatePDF.php Mon Apr 16 12:27:44 2007
@@ -10,6 +10,7 @@
  ********************************************************************************/
 
 require('include/fpdf/pdf.php');
+require_once('include/fpdf/pdfconfig.php');
 require_once('modules/PurchaseOrder/PurchaseOrder.php');
 require_once('modules/Organization/Organization.php');
 require_once('include/database/PearDatabase.php');
@@ -28,8 +29,6 @@
 
 // would you like and end page?  1 for yes 0 for no
 $endpage="1";
-global $products_per_page;
-$products_per_page="6";
 
 $id = $_REQUEST['record'];
 //retreiving the vtiger_invoice info
@@ -55,14 +54,15 @@
 $bill_code = $focus->column_fields["bill_code"];
 $bill_country = $focus->column_fields["bill_country"];
 
+$contact_name =getContactName($focus->column_fields["contact_id"]);
 $ship_street = $focus->column_fields["ship_street"];
 $ship_city = $focus->column_fields["ship_city"];
 $ship_state = $focus->column_fields["ship_state"];
 $ship_code = $focus->column_fields["ship_code"];
 $ship_country = $focus->column_fields["ship_country"];
 
-$conditions = $focus->column_fields["terms_conditions"];
-$description = $focus->column_fields["description"];
+$conditions = from_html($focus->column_fields["terms_conditions"]);
+$description = from_html($focus->column_fields["description"]);
 $status = $focus->column_fields["postatus"];
 
 // Company information
@@ -141,7 +141,11 @@
 if($discount_amount != "")
 	$price_discount = number_format($discount_amount,2,'.',',');
 else if($discount_percent != "")
-	$price_discount = $discount_percent."%";
+{
+	//This will be displayed near Discount label - used in include/fpdf/templates/body.php
+	$final_price_discount_percent = "(".number_format($discount_percent,2,'.',',')." %)";
+	$price_discount = number_format((($discount_percent*$focus->column_fields["hdnSubTotal"])/100),2,'.',',');
+}
 else
 	$price_discount = "0.00";
 
@@ -199,6 +203,8 @@
 	$list_price[$i] = number_format($associated_products[$i]['listPrice'.$i],2,'.',',');
 	$list_pricet[$i] = $associated_products[$i]['listPrice'.$i];
 	$discount_total[$i] = $associated_products[$i]['discountTotal'.$i];
+        //aded for 5.0.3 pdf changes
+        $product_code[$i] = $associated_products[$i]['hdnProductcode'.$i];
 	
 	$taxable_total = $qty[$i]*$list_pricet[$i]-$discount_total[$i];
 
@@ -219,13 +225,47 @@
 		$product_line[$j]["Tax"] = number_format($total_taxes,2,'.',',')."\n ($total_tax_percent %) ";
 	}
 	$prod_total[$i] = number_format($producttotal,2,'.',',');
-
+        $product_line[$j]["Product Code"] = $product_code[$i];
 	$product_line[$j]["Product Name"] = $product_name[$i];
-	$product_line[$j]["Description"] = $prod_description[$i];
 	$product_line[$j]["Qty"] = $qty[$i];
 	$product_line[$j]["Price"] = $list_price[$i];
 	$product_line[$j]["Discount"] = $discount_total[$i];
 	$product_line[$j]["Total"] = $prod_total[$i];
+
+	// Product piecelists
+	$query = "SELECT vtiger_crmentity.crmid,
+	    vtiger_products.productname as productname,
+	    vtiger_products2products_rel.related_productid as prodid,
+	    vtiger_products2products_rel.quantity as quantity,
+	    vtiger_products2products_rel.product_relgroup as product_relgroup
+	    FROM vtiger_products2products_rel
+	    INNER JOIN vtiger_products
+		ON vtiger_products.productid = vtiger_products2products_rel.related_productid
+	    INNER JOIN vtiger_crmentity
+		ON vtiger_crmentity.crmid = vtiger_products.productid
+	    WHERE vtiger_crmentity.deleted = 0
+	    AND vtiger_products2products_rel.productid = ".$product_id[$i]."
+	    AND vtiger_products2products_rel.relation_type = 10";
+	$result = $adb->query($query);
+	$pieces = $adb->num_rows($result);
+	if( $pieces > 0) {
+	    $product_line[++$j]["Product Name"] = "";
+	    $product_line[$j]["Description"] = "consisting of:";
+	    $product_line[$j]["Qty"] = "";
+	    $product_line[$j]["Price"] = "";
+	    $product_line[$j]["Discount"] = "";
+	    $product_line[$j]["Total"] = "";
+	    for( $pl=0; $pl<$pieces; $pl++) {
+	        $product_line[++$j]["Product Name"] = "";
+		$product_line[$j]["Description"] =
+		    $adb->query_result( $result, $pl, "productname");
+		$product_line[$j]["Qty"] =
+		    $adb->query_result( $result, $pl, "quantity");
+		$product_line[$j]["Price"] = "";
+		$product_line[$j]["Discount"] = "";
+		$product_line[$j]["Total"] = "";
+	    }
+	}
 }
 //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>';
 //echo '<pre>';print_r($associated_products);echo '</pre>';
@@ -240,7 +280,7 @@
 $pdf = new PDF( 'P', 'mm', 'A4' );
 $pdf->Open();
 
-$num_pages=ceil(($num_products/$products_per_page));
+$num_pages=ceil(count($product_line)/$products_per_page);
 
 
 $current_product=0;
@@ -256,15 +296,21 @@
 		$current_product++;
 	}
 
+	//if bottom > 145 then we skip the Description and T&C in every
+	//page and display only in lastpage
+	//if you want to display the description and T&C in each page then
+	//set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php
 	$pdf->AddPage();
 	if( $page_num == "1") {
 	    include("pdf_templates/".$template."/firstpage/header.php");
 	    include("pdf_templates/".$template."/firstpage/body.php");
-	    include("pdf_templates/".$template."/firstpage/footer.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/firstpage/footer.php");
 	} else {
 	    include("pdf_templates/".$template."/pages/header.php");
 	    include("pdf_templates/".$template."/pages/body.php");
-	    include("pdf_templates/".$template."/pages/footer.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/pages/footer.php");
 	}
 
 	$page_num++;

Modified: vtigercrm/branches/5.1_jens/modules/PurchaseOrder/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PurchaseOrder/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PurchaseOrder/DetailView.php Mon Apr 16 12:27:44 2007
@@ -94,6 +94,8 @@
 $smarty->assign("CHECK", $check_button);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
 
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);

Modified: vtigercrm/branches/5.1_jens/modules/PurchaseOrder/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PurchaseOrder/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PurchaseOrder/EditView.php Mon Apr 16 12:27:44 2007
@@ -200,13 +200,14 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 $organization = new Organization;
 $organization->id = $current_organization;
 $smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
 
 if($focus->mode == 'edit')
-	$smarty->display('Inventory/InventoryEditView.tpl');
+    $smarty->display('Inventory/InventoryEditView.tpl');
 else
-	$smarty->display('Inventory/InventoryCreateView.tpl');
+    $smarty->display('Inventory/InventoryCreateView.tpl');
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/PurchaseOrder/PurchaseOrder.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PurchaseOrder/PurchaseOrder.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PurchaseOrder/PurchaseOrder.php Mon Apr 16 12:27:44 2007
@@ -86,6 +86,8 @@
 	var $default_order_by = 'subject';
 	var $default_sort_order = 'ASC';
 
+	var $groupTable = Array('vtiger_pogrouprelation','purchaseorderid');
+
 	/** Constructor Function for Order class
 	 *  This function creates an instance of LoggerManager class using getLogger method
 	 *  creates an instance for PearDatabase class and get values for column_fields array of Order class.
@@ -98,8 +100,12 @@
 
 	function save_module($module)
 	{
-		//Based on the total Number of rows we will save the product relationship with this entity
-		saveInventoryProductDetails(&$this, 'PurchaseOrder', $this->update_prod_stock);
+		//in ajax save we should not call this function, because this will delete all the existing product values
+		if($_REQUEST['action'] != 'PurchaseOrderAjax' && $_REQUEST['ajxaction'] != 'DETAILVIEW')
+		{
+			//Based on the total Number of rows we will save the product relationship with this entity
+			saveInventoryProductDetails(&$this, 'PurchaseOrder', $this->update_prod_stock);
+		}
 	}	
 
 
@@ -153,7 +159,7 @@
 		else
 			$returnset = '&return_module=PurchaseOrder&return_action=CallRelatedList&return_id='.$id;
 
-		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Deferred') ";
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Deferred') ";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('PurchaseOrder','Calendar',$focus,$query,$button,$returnset);
 	}
@@ -166,17 +172,15 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,
-			vtiger_activity.* ,vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,
-			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.* ,vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,	vtiger_crmentity.createdtime, vtiger_crmentity.description,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
 			from vtiger_activity
 				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
 				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
 				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
 				left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
 				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
                                 left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
 			where vtiger_activity.activitytype='Task'
 				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred')
 				and vtiger_seactivityrel.crmid=".$id;

Modified: vtigercrm/branches/5.1_jens/modules/PurchaseOrder/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PurchaseOrder/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PurchaseOrder/Save.php Mon Apr 16 12:27:44 2007
@@ -33,13 +33,18 @@
 
 //Added code for auto product stock updation on receiving goods
 $focus->update_prod_stock='';
-if($focus->column_fields['postatus'] == 'Received Shipment' && $focus->mode == 'edit')
+if($focus->column_fields['postatus'] == 'Received Shipment')
 {
-        $prev_postatus=getPoStatus($focus->id);
-        if($focus->column_fields['postatus'] != $prev_postatus)
-        {
-                $focus->update_prod_stock='true';
-        }
+	if($focus->mode != 'edit')
+		$focus->update_prod_stock='true';
+	else
+	{
+        	$prev_postatus=getPoStatus($focus->id);
+        	if($focus->column_fields['postatus'] != $prev_postatus)
+        	{
+        	        $focus->update_prod_stock='true';
+        	}
+	}
 
 }
 

Modified: vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/Default/_default/header.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/Default/_default/header.php (original)
+++ vtigercrm/branches/5.1_jens/modules/PurchaseOrder/pdf_templates/Default/_default/header.php Mon Apr 16 12:27:44 2007
@@ -51,7 +51,7 @@
 $pdf->addTextBlock( "Shipping Address:", $shipText, $shipLocation );
 
 // billing Address
-$billPositions = array("147","43","60");
+$billPositions = array("147","40","60");
 $billText=$bill_street."\n".$bill_city.", ".$bill_state." ".$bill_code."\n".$bill_country;
 $pdf->addTextBlock("Billing Address:",$billText, $billPositions);
 // ********** End Addresses ******************
@@ -59,13 +59,22 @@
 
 
 /*  ******** Begin Invoice Data ************************ */ 
+// issue date block
+$issueBlock=array("80","37");
+$pdf->addRecBlock(date("Y-m-d"), "Issue Date",$issueBlock);
+
+// due date block
+$dueBlock=array("81","52");
+$pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
+
 // terms block
 $termBlock=array("10","65");
 $pdf->addRecBlock($vendor_name, "Vendor Name", $termBlock);
 
-// due date block
-$dueBlock=array("80","65");
-$pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
+// Contact Name block
+$conBlock=array("79","67");
+$pdf->addRecBlock($contact_name, "Contact Name",$conBlock);
+
 
 // vtiger_invoice number block
 $invBlock=array("145","65");

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/CreatePDF.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/CreatePDF.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/CreatePDF.php Mon Apr 16 12:27:44 2007
@@ -11,6 +11,7 @@
 
 
 require_once('include/fpdf/pdf.php');
+require_once('include/fpdf/pdfconfig.php');
 require_once('modules/Quotes/Quotes.php');
 require_once('modules/Organization/Organization.php');
 require_once('include/database/PearDatabase.php');
@@ -29,8 +30,6 @@
 
 // would you like and end page?  1 for yes 0 for no
 $endpage="1";
-global $products_per_page;
-$products_per_page="6";
 
 $focus = new Quotes();
 $focus->retrieve_entity_info($_REQUEST['record'],"Quotes");
@@ -54,6 +53,7 @@
 $bill_state = $focus->column_fields["bill_state"];
 $bill_code = $focus->column_fields["bill_code"];
 $bill_country = $focus->column_fields["bill_country"];
+$contact_name =getContactName($focus->column_fields["contact_id"]);
 
 $ship_street = $focus->column_fields["ship_street"];
 $ship_city = $focus->column_fields["ship_city"];
@@ -61,8 +61,8 @@
 $ship_code = $focus->column_fields["ship_code"];
 $ship_country = $focus->column_fields["ship_country"];
 
-$conditions = $focus->column_fields["terms_conditions"];
-$description = $focus->column_fields["description"];
+$conditions = from_html($focus->column_fields["terms_conditions"]);
+$description = from_html($focus->column_fields["description"]);
 $status = $focus->column_fields["quotestage"];
 
 // Company information
@@ -141,7 +141,11 @@
 if($discount_amount != "")
 	$price_discount = number_format($discount_amount,2,'.',',');
 else if($discount_percent != "")
-	$price_discount = $discount_percent."%";
+{
+	//This will be displayed near Discount label - used in include/fpdf/templates/body.php
+	$final_price_discount_percent = "(".number_format($discount_percent,2,'.',',')." %)";
+	$price_discount = number_format((($discount_percent*$focus->column_fields["hdnSubTotal"])/100),2,'.',',');
+}
 else
 	$price_discount = "0.00";
 
@@ -199,6 +203,8 @@
 	$list_price[$i] = number_format($associated_products[$i]['listPrice'.$i],2,'.',',');
 	$list_pricet[$i] = $associated_products[$i]['listPrice'.$i];
 	$discount_total[$i] = $associated_products[$i]['discountTotal'.$i];
+	//aded for 5.0.3 pdf changes
+        $product_code[$i] = $associated_products[$i]['hdnProductcode'.$i];
 	
 	$taxable_total = $qty[$i]*$list_pricet[$i]-$discount_total[$i];
 
@@ -220,13 +226,49 @@
 	}
 	$prod_total[$i] = number_format($producttotal,2,'.',',');
 
+	$product_line[$j]["Product Code"] = $product_code[$i];
 	$product_line[$j]["Product Name"] = $product_name[$i];
-	$product_line[$j]["Description"] = $prod_description[$i];
 	$product_line[$j]["Qty"] = $qty[$i];
 	$product_line[$j]["Price"] = $list_price[$i];
 	$product_line[$j]["Discount"] = $discount_total[$i];
 	$product_line[$j]["Total"] = $prod_total[$i];
-}
+
+	// Product piecelists
+	$query = "SELECT vtiger_crmentity.crmid,
+	    vtiger_products.productname as productname,
+	    vtiger_products2products_rel.related_productid as prodid,
+	    vtiger_products2products_rel.quantity as quantity,
+	    vtiger_products2products_rel.product_relgroup as product_relgroup
+	    FROM vtiger_products2products_rel
+	    INNER JOIN vtiger_products
+		ON vtiger_products.productid = vtiger_products2products_rel.related_productid
+	    INNER JOIN vtiger_crmentity
+		ON vtiger_crmentity.crmid = vtiger_products.productid
+	    WHERE vtiger_crmentity.deleted = 0
+	    AND vtiger_products2products_rel.productid = ".$product_id[$i]."
+	    AND vtiger_products2products_rel.relation_type = 10";
+	$result = $adb->query($query);
+	$pieces = $adb->num_rows($result);
+	if( $pieces > 0) {
+	    $product_line[++$j]["Product Name"] = "";
+	    $product_line[$j]["Description"] = "consisting of:";
+	    $product_line[$j]["Qty"] = "";
+	    $product_line[$j]["Price"] = "";
+	    $product_line[$j]["Discount"] = "";
+	    $product_line[$j]["Total"] = "";
+	    for( $pl=0; $pl<$pieces; $pl++) {
+	        $product_line[++$j]["Product Name"] = "";
+		$product_line[$j]["Description"] =
+		    $adb->query_result( $result, $pl, "productname");
+		$product_line[$j]["Qty"] =
+		    $adb->query_result( $result, $pl, "quantity");
+		$product_line[$j]["Price"] = "";
+		$product_line[$j]["Discount"] = "";
+		$product_line[$j]["Total"] = "";
+	    }
+	}
+}
+
 //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>';
 //echo '<pre>';print_r($associated_products);echo '</pre>';
 
@@ -240,7 +282,7 @@
 $pdf = new PDF( 'P', 'mm', 'A4' );
 $pdf->Open();
 
-$num_pages=ceil(($num_products/$products_per_page));
+$num_pages=ceil(count($product_line)/$products_per_page);
 
 
 $current_product=0;
@@ -256,15 +298,21 @@
 		$current_product++;
 	}
 
+	//if bottom > 145 then we skip the Description and T&C in every
+	//page and display only in lastpage
+	//if you want to display the description and T&C in each page then
+	//set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php
 	$pdf->AddPage();
 	if( $page_num == "1") {
 	    include("pdf_templates/".$template."/firstpage/header.php");
 	    include("pdf_templates/".$template."/firstpage/body.php");
-	    include("pdf_templates/".$template."/firstpage/footer.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/firstpage/footer.php");
 	} else {
 	    include("pdf_templates/".$template."/pages/header.php");
 	    include("pdf_templates/".$template."/pages/body.php");
-	    include("pdf_templates/".$template."/pages/footer.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/pages/footer.php");
 	}
 
 	$page_num++;

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/DetailView.php Mon Apr 16 12:27:44 2007
@@ -104,6 +104,8 @@
 $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
 
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/EditView.php Mon Apr 16 12:27:44 2007
@@ -211,14 +211,15 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 $organization = new Organization;
 $organization->id = $current_organization;
 $smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
 
 if($focus->mode == 'edit')
-	$smarty->display("Inventory/InventoryEditView.tpl");
+    $smarty->display("Inventory/InventoryEditView.tpl");
 else
-	$smarty->display('Inventory/InventoryCreateView.tpl');
+    $smarty->display('Inventory/InventoryCreateView.tpl');
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/ListTopQuotes.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/ListTopQuotes.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/ListTopQuotes.php Mon Apr 16 12:27:44 2007
@@ -60,7 +60,10 @@
 	//<<<<<<<<<customview>>>>>>>>>
 	$date_var = date('Y-m-d');
 
-	$where = ' and vtiger_crmentity.smownerid='.$current_user->id.' and  vtiger_quotes.validtill >= \''.$date_var.'\'';
+	$where = ' and vtiger_crmentity.smownerid='.$current_user->id.' and vtiger_quotes.quotestage != \'Rejected\' and  vtiger_quotes.validtill >= \''.$date_var.'\'';
+	//$where = ' and vtiger_crmentity.smownerid='.$current_user->id.' and  vtiger_quotes.validtill >= \''.$date_var.'\'';
+	
+	
 	$query = getListQuery("Quotes",$where);
 	$query .=" ORDER BY total DESC";
 	//<<<<<<<<customview>>>>>>>>>

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/ListView.php Mon Apr 16 12:27:44 2007
@@ -131,8 +131,8 @@
 	if($order_by == 'smownerid')
         {
 		if( $adb->dbType == "pgsql")
-		    $query .= ' GROUP BY user_name';
-                $query .= ' ORDER BY user_name '.$sorder;
+		    $query .= ' GROUP BY vtiger_users.user_name';
+		$query .= " ORDER BY case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end ".$sorder;
         }
         else
         {

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/Quotes.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/Quotes.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/Quotes.php Mon Apr 16 12:27:44 2007
@@ -1,266 +1,285 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header$
- * Description:  Defines the Account SugarBean Account entity with the necessary
- * methods and variables.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-include_once('config.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('data/SugarBean.php');
-require_once('data/CRMEntity.php');
-require_once('include/utils/utils.php');
-require_once('include/RelatedListView.php');
-require_once('user_privileges/default_module_view.php');
-
-// Account is used to store vtiger_account information.
-class Quotes extends CRMEntity {
-	var $log;
-	var $db;
-		
-	var $table_name = "vtiger_quotes";
-	var $tab_name = Array('vtiger_crmentity','vtiger_quotes','vtiger_quotesbillads','vtiger_quotesshipads','vtiger_quotescf');
-	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_quotes'=>'quoteid','vtiger_quotesbillads'=>'quotebilladdressid','vtiger_quotesshipads'=>'quoteshipaddressid','vtiger_quotescf'=>'quoteid');
-	
-	var $entity_table = "vtiger_crmentity";
-	
-	var $billadr_table = "vtiger_quotesbillads";
-
-	var $object_name = "Quote";
-
-	var $new_schema = true;
-	
-	var $module_id = "quoteid";
-
-	var $column_fields = Array();
-
-	var $sortby_fields = Array('subject','crmid','smownerid');		
-
-	// This is used to retrieve related vtiger_fields from form posts.
-	var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' );
-
-	// This is the list of vtiger_fields that are in the lists.
-	var $list_fields = Array(
-				'Quote Id'=>Array('crmentity'=>'crmid'),
-				'Subject'=>Array('quotes'=>'subject'),
-				'Quote Stage'=>Array('quotes'=>'quotestage'), 
-				'Potential Name'=>Array('quotes'=>'potentialid'),
-				'Account Name'=>Array('account'=> 'accountid'),
-				'Total'=>Array('quotes'=> 'total'),
-				'Assigned To'=>Array('crmentity'=>'smownerid')
-				);
-	
-	var $list_fields_name = Array(
-				        'Quote Id'=>'',
-				        'Subject'=>'subject',
-				        'Quote Stage'=>'quotestage',
-				        'Potential Name'=>'potential_id',
-					'Account Name'=>'account_id',
-					'Total'=>'hdnGrandTotal',
-				        'Assigned To'=>'assigned_user_id'
-				      );
-	var $list_link_field= 'subject';
-
-	var $search_fields = Array(
-				'Quote Id'=>Array('crmentity'=>'crmid'),
-				'Subject'=>Array('quotes'=>'subject'),
-				'Account Name'=>Array('quotes'=>'accountid'),
-				'Quote Stage'=>Array('quotes'=>'quotestage'), 
-				);
-	
-	var $search_fields_name = Array(
-					'Quote Id'=>'',
-				        'Subject'=>'subject',
-				        'Account Name'=>'account_id',
-				        'Quote Stage'=>'quotestage',
-				      );
-
-	// This is the list of vtiger_fields that are required.
-	var $required_fields =  array("accountname"=>1);
-
-	//Added these variables which are used as default order by and sortorder in ListView
-	var $default_order_by = 'crmid';
-	var $default_sort_order = 'ASC';
-
-	/**	Constructor which will set the column_fields in this object
-	 */
-	function Quotes() {
-		$this->log =LoggerManager::getLogger('quote');
-		$this->db = new PearDatabase();
-		$this->column_fields = getColumnFields('Quotes');
-	}
-
-	function save_module()
-	{
-	}	
-	
-	/**	Function used to get the sort order for Quote listview
-	 *	@return string	$sorder	- first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['QUOTES_SORT_ORDER'] if this session value is empty then default sort order will be returned. 
-	 */
-	function getSortOrder()
-	{
-		global $log;
-                $log->debug("Entering getSortOrder() method ...");	
-		if(isset($_REQUEST['sorder'])) 
-			$sorder = $_REQUEST['sorder'];
-		else
-			$sorder = (($_SESSION['QUOTES_SORT_ORDER'] != '')?($_SESSION['QUOTES_SORT_ORDER']):($this->default_sort_order));
-		$log->debug("Exiting getSortOrder() method ...");
-		return $sorder;
-	}
-
-	/**	Function used to get the order by value for Quotes listview
-	 *	@return string	$order_by  - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['QUOTES_ORDER_BY'] if this session value is empty then default order by will be returned. 
-	 */
-	function getOrderBy()
-	{
-		global $log;
-                $log->debug("Entering getOrderBy() method ...");
-		if (isset($_REQUEST['order_by'])) 
-			$order_by = $_REQUEST['order_by'];
-		else
-			$order_by = (($_SESSION['QUOTES_ORDER_BY'] != '')?($_SESSION['QUOTES_ORDER_BY']):($this->default_order_by));
-		$log->debug("Exiting getOrderBy method ...");
-		return $order_by;
-	}	
-
-	/**	function used to get the list of sales orders which are related to the Quotes
-	 *	@param int $id - quote id
-	 *	@return array - return an array which will be returned from the function GetRelatedList
-	 */
-	function get_salesorder($id)
-	{
-		global $log,$singlepane_view;
-		$log->debug("Entering get_salesorder(".$id.") method ...");
-		require_once('modules/SalesOrder/SalesOrder.php');
-	        $focus = new SalesOrder();
- 
-		$button = '';
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname from vtiger_salesorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.quoteid = ".$id;
-		$log->debug("Exiting get_salesorder method ...");
-		return GetRelatedList('Quotes','SalesOrder',$focus,$query,$button,$returnset);
-	}
-
-	/**	function used to get the list of activities which are related to the Quotes
-	 *	@param int $id - quote id
-	 *	@return array - return an array which will be returned from the function GetRelatedList
-	 */
-	function get_activities($id)
-	{	
-		global $log,$singlepane_view;
-		$log->debug("Entering get_activities(".$id.") method ...");
-		global $app_strings;
-		require_once('modules/Calendar/Activity.php');
-	        $focus = new Activity();
-
-		$button = '';
-
-		if($singlepane_view == 'true')
-			$returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id;
-		else
-			$returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id;
-
-		$query = "SELECT vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Deferred')";
-		$log->debug("Exiting get_activities method ...");
-		return GetRelatedList('Quotes','Calendar',$focus,$query,$button,$returnset);
-	}
-
-	/**	function used to get the the activity history related to the quote
-	 *	@param int $id - quote id
-	 *	@return array - return an array which will be returned from the function GetHistory
-	 */
-	function get_history($id)
-	{
-		global $log;
-		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
-			vtiger_activity.eventstatus, vtiger_activity.activitytype, vtiger_contactdetails.contactid,
-			vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
-			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
-			from vtiger_activity
-				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
-				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
-				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
-				left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
-				inner join vtiger_users on vtiger_crmentity.smcreatorid= vtiger_users.id
-				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
-                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
-			where vtiger_activity.activitytype='Task'
-  				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred')
-	 	        	and vtiger_seactivityrel.crmid=".$id;
-		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
-
-		$log->debug("Exiting get_history method ...");
-		return getHistory('Quotes',$query,$id);	
-	}
-
-
-	/**	Function used to get the Quote Stage history of the Quotes
-	 *	@param $id - quote id
-	 *	@return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries
-	 */
-	function get_quotestagehistory($id)
-	{	
-		global $log;
-		$log->debug("Entering get_quotestagehistory(".$id.") method ...");
-
-		global $adb;
-		global $mod_strings;
-		global $app_strings;
-
-		$query = 'select vtiger_quotestagehistory.*, vtiger_quotes.subject from vtiger_quotestagehistory inner join vtiger_quotes on vtiger_quotes.quoteid = vtiger_quotestagehistory.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid where vtiger_crmentity.deleted = 0 and vtiger_quotes.quoteid = '.$id;
-		$result=$adb->query($query);
-		$noofrows = $adb->num_rows($result);
-
-		$header[] = $app_strings['Quote Id'];
-		$header[] = $app_strings['LBL_ACCOUNT_NAME'];
-		$header[] = $app_strings['LBL_AMOUNT'];
-		$header[] = $app_strings['Quote Stage'];
-		$header[] = $app_strings['LBL_LAST_MODIFIED'];
-
-		while($row = $adb->fetch_array($result))
-		{
-			$entries = Array();
-
-			$entries[] = $row['quoteid'];
-			$entries[] = $row['accountname'];
-			$entries[] = $row['total'];
-			$entries[] = $row['quotestage'];
-			$entries[] = getDisplayDate($row['lastmodified']);
-
-			$entries_list[] = $entries;
-		}
-
-		$return_data = Array('header'=>$header,'entries'=>$entries_list);
-
-	 	$log->debug("Exiting get_quotestagehistory method ...");
-
-		return $return_data;
-	}
-
-}
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header$
+ * Description:  Defines the Account SugarBean Account entity with the necessary
+ * methods and variables.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+include_once('config.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('data/SugarBean.php');
+require_once('data/CRMEntity.php');
+require_once('include/utils/utils.php');
+require_once('include/RelatedListView.php');
+require_once('user_privileges/default_module_view.php');
+
+// Account is used to store vtiger_account information.
+class Quotes extends CRMEntity {
+	var $log;
+	var $db;
+		
+	var $table_name = "vtiger_quotes";
+	var $tab_name = Array('vtiger_crmentity','vtiger_quotes','vtiger_quotesbillads','vtiger_quotesshipads','vtiger_quotescf');
+	var $tab_name_index = Array('vtiger_crmentity'=>'crmid','vtiger_quotes'=>'quoteid','vtiger_quotesbillads'=>'quotebilladdressid','vtiger_quotesshipads'=>'quoteshipaddressid','vtiger_quotescf'=>'quoteid');
+	
+	var $entity_table = "vtiger_crmentity";
+	
+	var $billadr_table = "vtiger_quotesbillads";
+
+	var $object_name = "Quote";
+
+	var $new_schema = true;
+	
+	var $module_id = "quoteid";
+
+	var $column_fields = Array();
+
+	var $sortby_fields = Array('subject','crmid','smownerid');		
+
+	// This is used to retrieve related vtiger_fields from form posts.
+	var $additional_column_fields = Array('assigned_user_name', 'smownerid', 'opportunity_id', 'case_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id', 'parent_name', 'member_id' );
+
+	// This is the list of vtiger_fields that are in the lists.
+	var $list_fields = Array(
+				'Quote Id'=>Array('crmentity'=>'crmid'),
+				'Subject'=>Array('quotes'=>'subject'),
+				'Quote Stage'=>Array('quotes'=>'quotestage'), 
+				'Potential Name'=>Array('quotes'=>'potentialid'),
+				'Account Name'=>Array('account'=> 'accountid'),
+				'Total'=>Array('quotes'=> 'total'),
+				'Assigned To'=>Array('crmentity'=>'smownerid')
+				);
+	
+	var $list_fields_name = Array(
+				        'Quote Id'=>'',
+				        'Subject'=>'subject',
+				        'Quote Stage'=>'quotestage',
+				        'Potential Name'=>'potential_id',
+					'Account Name'=>'account_id',
+					'Total'=>'hdnGrandTotal',
+				        'Assigned To'=>'assigned_user_id'
+				      );
+	var $list_link_field= 'subject';
+
+	var $search_fields = Array(
+				'Quote Id'=>Array('crmentity'=>'crmid'),
+				'Subject'=>Array('quotes'=>'subject'),
+				'Account Name'=>Array('quotes'=>'accountid'),
+				'Quote Stage'=>Array('quotes'=>'quotestage'), 
+				);
+	
+	var $search_fields_name = Array(
+					'Quote Id'=>'',
+				        'Subject'=>'subject',
+				        'Account Name'=>'account_id',
+				        'Quote Stage'=>'quotestage',
+				      );
+
+	// This is the list of vtiger_fields that are required.
+	var $required_fields =  array("accountname"=>1);
+
+	//Added these variables which are used as default order by and sortorder in ListView
+	var $default_order_by = 'crmid';
+	var $default_sort_order = 'ASC';
+	var $groupTable = Array('vtiger_quotegrouprelation','quoteid');
+	
+	
+
+	/**	Constructor which will set the column_fields in this object
+	 */
+	function Quotes() {
+		$this->log =LoggerManager::getLogger('quote');
+		$this->db = new PearDatabase();
+		$this->column_fields = getColumnFields('Quotes');
+	}
+
+	function save_module()
+	{
+		//in ajax save we should not call this function, because this will delete all the existing product values
+		if($_REQUEST['action'] != 'QuotesAjax' && $_REQUEST['ajxaction'] != 'DETAILVIEW')
+		{
+			//Based on the total Number of rows we will save the product relationship with this entity
+			saveInventoryProductDetails(&$this, 'Quotes');
+		}
+	}	
+	
+	/**	Function used to get the sort order for Quote listview
+	 *	@return string	$sorder	- first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['QUOTES_SORT_ORDER'] if this session value is empty then default sort order will be returned. 
+	 */
+	function getSortOrder()
+	{
+		global $log;
+                $log->debug("Entering getSortOrder() method ...");	
+		if(isset($_REQUEST['sorder'])) 
+			$sorder = $_REQUEST['sorder'];
+		else
+			$sorder = (($_SESSION['QUOTES_SORT_ORDER'] != '')?($_SESSION['QUOTES_SORT_ORDER']):($this->default_sort_order));
+		$log->debug("Exiting getSortOrder() method ...");
+		return $sorder;
+	}
+
+	/**	Function used to get the order by value for Quotes listview
+	 *	@return string	$order_by  - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['QUOTES_ORDER_BY'] if this session value is empty then default order by will be returned. 
+	 */
+	function getOrderBy()
+	{
+		global $log;
+                $log->debug("Entering getOrderBy() method ...");
+		if (isset($_REQUEST['order_by'])) 
+			$order_by = $_REQUEST['order_by'];
+		else
+			$order_by = (($_SESSION['QUOTES_ORDER_BY'] != '')?($_SESSION['QUOTES_ORDER_BY']):($this->default_order_by));
+		$log->debug("Exiting getOrderBy method ...");
+		return $order_by;
+	}	
+
+	/**	function used to get the list of sales orders which are related to the Quotes
+	 *	@param int $id - quote id
+	 *	@return array - return an array which will be returned from the function GetRelatedList
+	 */
+	function get_salesorder($id)
+	{
+		global $log,$singlepane_view;
+		$log->debug("Entering get_salesorder(".$id.") method ...");
+		require_once('modules/SalesOrder/SalesOrder.php');
+	        $focus = new SalesOrder();
+ 
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "select vtiger_crmentity.*, vtiger_salesorder.*, vtiger_quotes.subject as quotename, vtiger_account.accountname,case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name 
+		from vtiger_salesorder
+		inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid
+		left outer join vtiger_quotes on vtiger_quotes.quoteid=vtiger_salesorder.quoteid 
+		left outer join vtiger_account on vtiger_account.accountid=vtiger_salesorder.accountid 
+		left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid=vtiger_sogrouprelation.salesorderid 
+		left join vtiger_groups on vtiger_groups.groupname=vtiger_sogrouprelation.groupname 
+		left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+		where vtiger_crmentity.deleted=0 and vtiger_salesorder.quoteid = ".$id;
+		$log->debug("Exiting get_salesorder method ...");
+		return GetRelatedList('Quotes','SalesOrder',$focus,$query,$button,$returnset);
+	}
+
+	/**	function used to get the list of activities which are related to the Quotes
+	 *	@param int $id - quote id
+	 *	@return array - return an array which will be returned from the function GetRelatedList
+	 */
+	function get_activities($id)
+	{	
+		global $log,$singlepane_view;
+		$log->debug("Entering get_activities(".$id.") method ...");
+		global $app_strings;
+		require_once('modules/Calendar/Activity.php');
+	        $focus = new Activity();
+
+		$button = '';
+
+		if($singlepane_view == 'true')
+			$returnset = '&return_module=Quotes&return_action=DetailView&return_id='.$id;
+		else
+			$returnset = '&return_module=Quotes&return_action=CallRelatedList&return_id='.$id;
+
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,vtiger_recurringevents.recurringtype from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Deferred')";
+		$log->debug("Exiting get_activities method ...");
+		return GetRelatedList('Quotes','Calendar',$focus,$query,$button,$returnset);
+	}
+
+	/**	function used to get the the activity history related to the quote
+	 *	@param int $id - quote id
+	 *	@return array - return an array which will be returned from the function GetHistory
+	 */
+	function get_history($id)
+	{
+		global $log;
+		$log->debug("Entering get_history(".$id.") method ...");
+		$query = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.status,
+			vtiger_activity.eventstatus, vtiger_activity.activitytype,vtiger_activity.date_start, 
+			vtiger_activity.due_date,vtiger_activity.time_start, vtiger_activity.time_end,
+			vtiger_contactdetails.contactid,
+			vtiger_contactdetails.firstname,vtiger_contactdetails.lastname, vtiger_crmentity.modifiedtime,
+			vtiger_crmentity.createdtime, vtiger_crmentity.description, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+			from vtiger_activity
+				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
+				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
+				left join vtiger_contactdetails on vtiger_contactdetails.contactid= vtiger_cntactivityrel.contactid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
+                                left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+				where vtiger_activity.activitytype='Task'
+  				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred')
+	 	        	and vtiger_seactivityrel.crmid=".$id;
+		//Don't add order by, because, for security, one more condition will be added with this query in include/RelatedListView.php
+
+		$log->debug("Exiting get_history method ...");
+		return getHistory('Quotes',$query,$id);	
+	}
+
+
+	/**	Function used to get the Quote Stage history of the Quotes
+	 *	@param $id - quote id
+	 *	@return $return_data - array with header and the entries in format Array('header'=>$header,'entries'=>$entries_list) where as $header and $entries_list are arrays which contains header values and all column values of all entries
+	 */
+	function get_quotestagehistory($id)
+	{	
+		global $log;
+		$log->debug("Entering get_quotestagehistory(".$id.") method ...");
+
+		global $adb;
+		global $mod_strings;
+		global $app_strings;
+
+		$query = 'select vtiger_quotestagehistory.*, vtiger_quotes.subject from vtiger_quotestagehistory inner join vtiger_quotes on vtiger_quotes.quoteid = vtiger_quotestagehistory.quoteid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_quotes.quoteid where vtiger_crmentity.deleted = 0 and vtiger_quotes.quoteid = '.$id;
+		$result=$adb->query($query);
+		$noofrows = $adb->num_rows($result);
+
+		$header[] = $app_strings['Quote Id'];
+		$header[] = $app_strings['LBL_ACCOUNT_NAME'];
+		$header[] = $app_strings['LBL_AMOUNT'];
+		$header[] = $app_strings['Quote Stage'];
+		$header[] = $app_strings['LBL_LAST_MODIFIED'];
+
+		while($row = $adb->fetch_array($result))
+		{
+			$entries = Array();
+
+			$entries[] = $row['quoteid'];
+			$entries[] = $row['accountname'];
+			$entries[] = $row['total'];
+			$entries[] = $row['quotestage'];
+			$entries[] = getDisplayDate($row['lastmodified']);
+
+			$entries_list[] = $entries;
+		}
+
+		$return_data = Array('header'=>$header,'entries'=>$entries_list);
+
+	 	$log->debug("Exiting get_quotestagehistory method ...");
+
+		return $return_data;
+	}
+
+}
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/Save.php Mon Apr 16 12:27:44 2007
@@ -28,23 +28,10 @@
 
 $local_log =& LoggerManager::getLogger('index');
 
-global $log,$current_user;
-$currencyid=fetchCurrency($current_user->id);
-$rate_symbol = getCurrencySymbolandCRate($currencyid);
-$rate = $rate_symbol['rate'];
-$log->debug("Inside Quote Save");
-
 $focus = new Quotes();
-
 setObjectValuesFromRequest(&$focus);
 
-$log->debug("The Field Value Array -----> ".$focus->column_fields);
 $focus->save("Quotes");
-
-
-//Based on the total Number of rows we will save the product relationship with this entity
-saveInventoryProductDetails(&$focus, 'Quotes');
-
 
 $return_id = $focus->id;
 

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -45,7 +45,6 @@
 //END DON'T CONVERT
 
 'LBL_ACCOUNT'=>'Account:',
-'LBL_ACCOUNT_NAME'=>'Account Name:',
 'LBL_PHONE'=>'Phone:',
 'LBL_WEBSITE'=>'Website:',
 'LBL_FAX'=>'Fax:',

Modified: vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/Default/_default/header.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/Default/_default/header.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Quotes/pdf_templates/Default/_default/header.php Mon Apr 16 12:27:44 2007
@@ -46,7 +46,7 @@
 $pdf->addTextBlock( "Shipping Address:", $shipText, $shipLocation );
 
 // billing Address
-$billPositions = array("147","43","60");
+$billPositions = array("147","40","60");
 $billText=$bill_street."\n".$bill_city.", ".$bill_state." ".$bill_code."\n".$bill_country;
 $pdf->addTextBlock("Billing Address:",$billText, $billPositions);
 // ********** End Addresses ******************
@@ -54,15 +54,25 @@
 
 
 /*  ******** Begin Quote Data ************************ */
-// terms block
+// issue date block
+$issueBlock=array("80","35");
+$pdf->addRecBlock(date("Y-m-d"), "Issue Date",$issueBlock);
+
+// valid till block
+$dueBlock=array("80","50");
+$pdf->addRecBlock($valid_till, "Valid Till",$dueBlock);
+
+// customer name block
 $termBlock=array("10","65");
 $pdf->addRecBlock($account_name, "Customer Name", $termBlock);
 
-// due date block
-$dueBlock=array("80","65");
-$pdf->addRecBlock($valid_till, "Valid Till",$dueBlock);
 
-// vtiger_invoice number block
+// Contact Name block
+$conBlock=array("79","65");
+$pdf->addRecBlock($contact_name, "Contact Name",$conBlock);
+
+
+// quote number block
 $invBlock=array("147","65");
 $pdf->addRecBlock($quote_id, "Quote Number",$invBlock);
 

Modified: vtigercrm/branches/5.1_jens/modules/Reports/AdvancedFilter.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/AdvancedFilter.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/AdvancedFilter.php Mon Apr 16 12:27:44 2007
@@ -140,7 +140,7 @@
 					{
 					  foreach($ogReport->sec_module_columnslist[$secmodule[$i]][$key] as $field=>$fieldlabel)
 					  {
-						if(isset($mod_strings[$fieldlable]))
+						if(isset($mod_strings[$fieldlabel]))
 						{
 							if($selected == $field)
 							{

Modified: vtigercrm/branches/5.1_jens/modules/Reports/CreatePDF.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/CreatePDF.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/CreatePDF.php Mon Apr 16 12:27:44 2007
@@ -52,6 +52,7 @@
 
 function Html2PDF($orientation='P',$unit='mm',$format='A4')
 {
+//echo '<pre>';print_r($format);echo '</pre>';	
     //Call parent constructor
     $this->FPDF($orientation,$unit,$format);
     //Initialization
@@ -295,35 +296,6 @@
 $filterlist = $oReportRun->RunTimeFilter($filtercolumn,$filter,$_REQUEST["startdate"],$_REQUEST["enddate"]);
 
 $arr_val = $oReportRun->GenerateReport("PDF",$filterlist);
-
-if(isset($arr_val))
-{
-        $columnlength = count($arr_val[0]);
-}
-
-if($columnlength > 0 && $columnlength <= 4)
-{
-        $pdf = new Html2PDF('P','mm','A4');
-}elseif($columnlength >= 5 && $columnlength < 8)
-{
-        $pdf = new Html2PDF('L','mm','A4');
-}elseif($columnlength >= 8 && $columnlength <= 12)
-{
-        $pdf = new Html2PDF('P','mm','A3');
-}elseif($columnlength > 12)
-{
-        $pdf = new Html2PDF('L','mm','A3');
-}
-
-$pdf->AddPage();
-
-$pdf->SetFillColor(224,235,255);
-$pdf->SetTextColor(0);
-$pdf->SetFont('Arial','B',14);
-$pdf->Cell(($pdf->columnlength*50),10,$oReport->reportname,0,0,'C',0);
-$pdf->Ln();
-
-$pdf->SetFont('Arial','',10);
 
 if(isset($arr_val))
 {
@@ -396,6 +368,35 @@
 '.$dataHTML.'
 </table>';
 
+if(isset($arr_val))
+{
+	$columnlength = array_sum($col_width);
+}
+
+if($columnlength <= 420 )
+{
+        $pdf = new Html2PDF('P','mm','A5');
+}elseif($columnlength >= 421 && $columnlength <= 600)
+{
+        $pdf = new Html2PDF('L','mm','A4');
+}elseif($columnlength >=601 && $columnlength <= 850)
+{
+        $pdf = new Html2PDF('P','mm','A3');
+}elseif($columnlength >=851 )
+{
+        $pdf = new Html2PDF('L','mm','A1');
+}
+//echo '<pre>';print_r($columnlength);echo '</pre>';
+$pdf->AddPage();
+
+$pdf->SetFillColor(224,235,255);
+$pdf->SetTextColor(0);
+$pdf->SetFont('Arial','B',14);
+$pdf->Cell(($pdf->columnlength*50),10,$oReport->reportname,0,0,'C',0);
+$pdf->Ln();
+
+$pdf->SetFont('Arial','',10);
+
 $pdf->WriteHTML($html);
 $pdf->Output('Reports.pdf','D');
 exit();

Modified: vtigercrm/branches/5.1_jens/modules/Reports/PopulateReports.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/PopulateReports.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/PopulateReports.php Mon Apr 16 12:27:44 2007
@@ -53,19 +53,19 @@
                              'vtiger_contactsubdetails:leadsource:Contacts_Lead_Source:leadsource:V',
                              'vtiger_accountContacts:accountname:Contacts_Account_Name:account_id:I',
 			     'vtiger_account:industry:Accounts_industry:industry:V',
-			     'vtiger_contactdetails:email:Contacts_Email:email:V'),
+			     'vtiger_contactdetails:email:Contacts_Email:email:E'),
 
 		       Array('vtiger_contactdetails:firstname:Contacts_First_Name:firstname:V',
                              'vtiger_contactdetails:lastname:Contacts_Last_Name:lastname:V',
                              'vtiger_contactsubdetails:leadsource:Contacts_Lead_Source:leadsource:V',
                              'vtiger_accountContacts:accountname:Contacts_Account_Name:account_id:I',
                              'vtiger_account:industry:Accounts_industry:industry:V',
-                             'vtiger_contactdetails:email:Contacts_Email:email:V'),
+                             'vtiger_contactdetails:email:Contacts_Email:email:E'),
 
 		       Array('vtiger_contactdetails:firstname:Contacts_First_Name:firstname:V',
                              'vtiger_contactdetails:lastname:Contacts_Last_Name:lastname:V',
                              'vtiger_accountContacts:accountname:Contacts_Account_Name:account_id:I',
-                             'vtiger_contactdetails:email:Contacts_Email:email:V',
+                             'vtiger_contactdetails:email:Contacts_Email:email:E',
                              'vtiger_potential:potentialname:Potentials_Potential_Name:potentialname:V',
                              'vtiger_potential:sales_stage:Potentials_Sales_Stage:sales_stage:V'),
 
@@ -164,7 +164,7 @@
 			     'vtiger_contactdetails:firstname:Contacts_First_Name:firstname:V',
 			     'vtiger_contactdetails:lastname:Contacts_Last_Name:lastname:V',
 			     'vtiger_contactsubdetails:leadsource:Contacts_Lead_Source:leadsource:V',
-			     'vtiger_contactdetails:email:Contacts_Email:email:V'),
+			     'vtiger_contactdetails:email:Contacts_Email:email:E'),
 
 		       Array('vtiger_purchaseorder:subject:PurchaseOrder_Subject:subject:V',
 			     'vtiger_vendorRel:vendorname:PurchaseOrder_Vendor_Name:vendor_id:I',
@@ -562,7 +562,7 @@
 	global $adb;
 	if($queryid != "")
 	{
-		$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$queryid.",'".$filtercolumn."','".$datefilter."','".$adb->formatString("vtiger_crmentity","startdate",$startdate)."','".$adb->formatString("vtiger_crmentity","enddate",$enddate)."')";
+		$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$queryid.",'".$filtercolumn."','".$datefilter."','".$startdate."','".$enddate."')";
 		$ireportmoduleresult = $adb->query($ireportmodulesql);
 	}
 

Modified: vtigercrm/branches/5.1_jens/modules/Reports/PrintReport.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/PrintReport.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/PrintReport.php Mon Apr 16 12:27:44 2007
@@ -13,6 +13,7 @@
 require_once("modules/Reports/Reports.php");
 
 global $app_strings;
+global $mod_strings;
 $oPrint_smarty=new vtigerCRM_Smarty;
 $reportid = $_REQUEST["record"];
 $oReport = new Reports($reportid);
@@ -25,6 +26,7 @@
 $total_report = $oReportRun->GenerateReport("PRINT_TOTAL",$filterlist);
 $oPrint_smarty->assign("COUNT",$arr_values[1]);
 $oPrint_smarty->assign("APP",$app_strings);
+$oPrint_smarty->assign("MOD",$mod_strings);
 $oPrint_smarty->assign("REPORT_NAME",$oReport->reportname);
 $oPrint_smarty->assign("PRINT_CONTENTS",$arr_values[0]);
 $oPrint_smarty->assign("TOTAL_HTML",$total_report);

Modified: vtigercrm/branches/5.1_jens/modules/Reports/ReportColumns.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/ReportColumns.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/ReportColumns.php Mon Apr 16 12:27:44 2007
@@ -64,6 +64,7 @@
 {
 	global $ogReport;
 	global $app_list_strings;
+	global $app_strings;
 	global $current_language;
 
 	$mod_strings = return_module_language($current_language,$module);
@@ -71,7 +72,8 @@
 	{
 		if(isset($ogReport->pri_module_columnslist[$module][$key]))
 		{
-			$shtml .= "<optgroup label=\"".$app_list_strings['moduleList'][$module]." ".$key."\" class=\"select\" style=\"border:none\">";
+			
+			$shtml .= "<optgroup label=\"".$app_list_strings['moduleList'][$module]." ".$app_strings[$key]."\" class=\"select\" style=\"border:none\">";
 			foreach($ogReport->pri_module_columnslist[$module][$key] as $field=>$fieldlabel)
 			{
 				if(isset($mod_strings[$fieldlabel]))
@@ -97,7 +99,7 @@
 function getSecondaryColumnsHTML($module)
 {
 	global $ogReport;
-	global $app_list_strings;
+	global $app_list_strings,$app_strings;
 	global $current_language;
 
 	if($module != "")
@@ -110,7 +112,7 @@
 			{
 				if(isset($ogReport->sec_module_columnslist[$secmodule[$i]][$key]))
 				{
-					$shtml .= "<optgroup label=\"".$app_list_strings['moduleList'][$secmodule[$i]]." ".$key."\" class=\"select\" style=\"border:none\">";
+					$shtml .= "<optgroup label=\"".$app_list_strings['moduleList'][$secmodule[$i]]." ".$app_strings[$key]."\" class=\"select\" style=\"border:none\">";
 					foreach($ogReport->sec_module_columnslist[$secmodule[$i]][$key] as $field=>$fieldlabel)
 					{
 						if(isset($mod_strings[$fieldlabel]))

Modified: vtigercrm/branches/5.1_jens/modules/Reports/ReportRun.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/ReportRun.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/ReportRun.php Mon Apr 16 12:27:44 2007
@@ -68,7 +68,7 @@
 		$ssql .= " where vtiger_report.reportid =".$reportid;
 		$ssql .= " order by vtiger_selectcolumn.columnindex";
 		$result = $adb->query($ssql);
-		
+	
 		$permitted_fields = Array();
 
 		while($columnslistrow = $adb->fetch_array($result))
@@ -81,12 +81,13 @@
 			{
 				list($module,$field) = split("_",$module_field);
 				$permitted_fields = $this->getaccesfield($module);	
+			
 			}
 			$selectedfields = explode(":",$fieldcolname);
 
 			$querycolumns = $this->getEscapedColumns($selectedfields);
 					
-			if(sizeof($permitted_fields) != 0 && !in_array($fieldname,$permitted_fields))
+			if(sizeof($permitted_fields) != 0 && !in_array($colname,$permitted_fields))
 			{
 				continue;
 			}
@@ -94,7 +95,30 @@
 			{
 				if($querycolumns == "")
 				{
-					$columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1].' AS "'.$selectedfields[2].'"';
+					if($selectedfields[0] == 'vtiger_activity' && $selectedfields[1] == 'status')
+					{
+						$columnslist[$fieldcolname] = " case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end as Calendar_Status";
+					}
+					elseif($selectedfields[0] == 'vtiger_activity' && $selectedfields[1] == 'date_start')
+					{
+						$columnslist[$fieldcolname] = "concat(vtiger_activity.date_start,'  ',vtiger_activity.time_start) as Calendar_Start_Date_and_Time";
+					}
+					elseif(stristr($selectedfields[0],"vtiger_users") && ($selectedfields[1] == 'user_name') && $module_field != 'Products_Handler')
+					{
+						$columnslist[$fieldcolname] = " case when (".$selectedfields[0].".user_name not like '') then ".$selectedfields[0].".user_name else vtiger_groups.groupname end as ".$this->primarymodule."_Assigned_To";
+					}
+					elseif(stristr($selectedfields[0],"vtiger_users") && ($selectedfields[1] == 'user_name') && $module_field == 'Products_Handler')//Products cannot be assiged to group only to handler so group is not included
+					{
+						$columnslist[$fieldcolname] = $selectedfields[0].".user_name as ".$this->primarymodule."_Handler";
+					}
+					elseif($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+					{
+						$columnslist[$fieldcolname] = "vtiger_crmentity.".$selectedfields[1]." AS '".$selectedfields[2]."'";
+					}
+					else
+					{
+						$columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1].' AS "'.$selectedfields[2].'"';
+					}
 				}
 				else
 				{
@@ -117,7 +141,15 @@
 		$access_fields = Array();
 		
 		$profileList = getCurrentUserProfileList();
-		$query = "select vtiger_field.fieldname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=(select tabid from vtiger_tab where vtiger_tab.name='".$module."') and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by block,sequence";
+		$query = "select vtiger_field.fieldname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where";
+		if($module == "Calendar")
+		{
+			$query .= " vtiger_field.tabid in (9,16) and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by block,sequence";
+		}
+		else
+		{
+			$query .= " vtiger_field.tabid in (select tabid from vtiger_tab where vtiger_tab.name in ('".$this->primarymodule."','".$this->secondarymodule."')) and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by block,sequence";
+		}
 		
 		$result = $adb->query($query);
 		
@@ -125,6 +157,9 @@
 		{
 			$access_fields[] = $collistrow["fieldname"];
 		}
+		//added to include ticketid for Reports module in select columnlist for all users
+		if($module == "HelpDesk")
+			$access_fields[] = "ticketid";
 		return $access_fields;
 	}
 	
@@ -139,7 +174,7 @@
 		{
 			if($this->primarymodule == "HelpDesk" && $selectedfields[0] == "vtiger_crmentityRelHelpDesk")
 			{
-				$querycolumn = "case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname when 'Contacts' then vtiger_contactdetailsRelHelpDesk.lastname End"." '".$selectedfields[2]."', vtiger_crmentityRelHelpDesk.setype 'Entity_type'";
+				$querycolumn = "case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname when 'Contacts' then concat(vtiger_contactdetailsRelHelpDesk.lastname,' ',vtiger_contactdetailsRelHelpDesk.firstname) End"." '".$selectedfields[2]."', vtiger_crmentityRelHelpDesk.setype 'Entity_type'";
 				return $querycolumn;
 			}
 			if($this->primarymodule == "Products" || $this->secondarymodule == "Products")
@@ -197,6 +232,8 @@
 				if($ordercolumnsequal)
 				{
 					$selectedfields = explode(":",$fieldcolname);
+					if($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+						$selectedfields[0] = "vtiger_crmentity";
 					$sSQLList[] = $selectedfields[0].".".$selectedfields[1]." '".$selectedfields[2]."'";
 				}
 			}
@@ -322,15 +359,42 @@
 					$advorsql = "";
 					for($n=0;$n<count($valuearray);$n++)
 					{
-						$advorsql[] = $selectedfields[0].".".$selectedfields[1].$this->getAdvComparator($comparator,trim($valuearray[$n]),$datatype);
+						if($selectedfields[0] == 'vtiger_crmentityRelHelpDesk' && $selectedfields[1] == 'setype')
+						{
+							$advorsql[] = "(case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname else concat(vtiger_contactdetailsRelHelpDesk.lastname,' ',vtiger_contactdetailsRelHelpDesk.firstname) end) ". $this->getAdvComparator($comparator,trim($valuearray[$n]),$datatype);
+						}elseif($selectedfields[1] == 'status')
+						{
+							$advorsql[] = "(case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end)".$this->getAdvComparator($comparator,trim($valuearray[$n]),$datatype);
+						}else	
+						{
+							$advorsql[] = $selectedfields[0].".".$selectedfields[1].$this->getAdvComparator($comparator,trim($valuearray[$n]),$datatype);
+						}
 					}
 					$advorsqls = implode(" or ",$advorsql);
 					$fieldvalue = " (".$advorsqls.") ";
-				}else
+				}elseif($selectedfields[0] == 'vtiger_activity' && $selectedfields[1] == 'status')	
+				{
+					$fieldvalue = "(case when (vtiger_activity.status not like '') then vtiger_activity.status else vtiger_activity.eventstatus end)".$this->getAdvComparator($comparator,trim($value),$datatype);
+				}
+				elseif($selectedfields[0] == "vtiger_users".$this->primarymodule && $selectedfields[1] == 'user_name')
+				{
+					$fieldvalue = " case when (".$selectedfields[0].".user_name not like '') then ".$selectedfields[0].".user_name else vtiger_groups.groupname end ".$this->getAdvComparator($comparator,trim($value),$datatype);
+				}
+				elseif($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+				{
+					$fieldvalue = "vtiger_crmentity.".$selectedfields[1]." ".$this->getAdvComparator($comparator,trim($value),$datatype);
+				}
+				elseif($selectedfields[0] == 'vtiger_crmentityRelHelpDesk' && $selectedfields[1]=='setype')
+				{
+					$fieldvalue = "(vtiger_accountRelHelpDesk.accountname ".$this->getAdvComparator($comparator,trim($value),$datatype)." or vtiger_contactdetailsRelHelpDesk.lastname ".$this->getAdvComparator($comparator,trim($value),$datatype)." or vtiger_contactdetailsRelHelpDesk.firstname ".$this->getAdvComparator($comparator,trim($value),$datatype).")";
+				}
+				else
 				{
 					$fieldvalue = $selectedfields[0].".".$selectedfields[1].$this->getAdvComparator($comparator,trim($value),$datatype);
 				}
-				$advfilterlist[$fieldcolname] = $fieldvalue;		
+				if(isset($advfilterlist[$fieldcolname]))
+					$advfilterlist[$fieldcolname] = $advfilterlist[$fieldcolname].' and '.$fieldvalue;
+				else $advfilterlist[$fieldcolname] = $fieldvalue;		
 			}
 
 		}
@@ -366,16 +430,17 @@
 
 			if($fieldcolname != "none")
 			{
+				$selectedfields = explode(":",$fieldcolname);
+				if($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+					$selectedfields[0] = "vtiger_crmentity";
 				if($datefilter == "custom")
 				{
 					if($startdate != "0000-00-00" && $enddate != "0000-00-00")
 					{
-						$selectedfields = explode(":",$fieldcolname);
 						$stdfilterlist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." between '".$startdate."' and '".$enddate."'";
 					}
 				}else
 				{
-					$selectedfields = explode(":",$fieldcolname);
 					$startenddate = $this->getStandarFiltersStartAndEndDate($datefilter);
 					if($startenddate[0] != "" && $startenddate[1] != "")
 					{
@@ -401,18 +466,19 @@
 	{
 		if($filtercolumn != "none")
 		{
+			$selectedfields = explode(":",$filtercolumn);
+			if($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+				$selectedfields[0] = "vtiger_crmentity";
 			if($filter == "custom")
 			{
 				if($startdate != "" && $enddate != "")
 				{
-					$selectedfields = explode(":",$filtercolumn);
 					$stdfilterlist[$filtercolumn] = $selectedfields[0].".".$selectedfields[1]." between '".$startdate."' and '".$enddate."'";
 				}
 			}else
 			{
 				if($startdate != "" && $enddate != "")
 				{
-					$selectedfields = explode(":",$filtercolumn);
 					$startenddate = $this->getStandarFiltersStartAndEndDate($filter);
 					if($startenddate[0] != "" && $startenddate[1] != "")
 					{
@@ -453,16 +519,17 @@
 
 			if($fieldcolname != "none")
 			{
+				$selectedfields = explode(":",$fieldcolname);
+				if($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+					$selectedfields[0] = "vtiger_crmentity";
 				if($datefilter == "custom")
 				{
 					if($startdate != "0000-00-00" && $enddate != "0000-00-00")
 					{
-						$selectedfields = explode(":",$fieldcolname);
 						$sSQL .= $selectedfields[0].".".$selectedfields[1]." between '".$startdate."' and '".$enddate."'";
 					}
 				}else
 				{
-					$selectedfields = explode(":",$fieldcolname);
 					$startenddate = $this->getStandarFiltersStartAndEndDate($datefilter);
 					if($startenddate[0] != "" && $startenddate[1] != "")
 					{
@@ -721,6 +788,8 @@
 			if($fieldcolname != "none")
 			{
 				$selectedfields = explode(":",$fieldcolname);
+				if($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+					$selectedfields[0] = "vtiger_crmentity";	
 				$sqlvalue = $selectedfields[0].".".$selectedfields[1]." ".$sortorder;
 				$grouplist[$fieldcolname] = $sqlvalue;
 				$this->groupbylist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." ".$selectedfields[2];
@@ -775,6 +844,8 @@
 					$sSQL .= ", ";
 					$this->orderbylistsql .= ", ";
 				}
+				if($selectedfields[0] == "vtiger_crmentity".$this->primarymodule)
+					$selectedfields[0] = "vtiger_crmentity";
 				$sSQL .= $selectedfields[0].".".$selectedfields[1]." ".$sortorder;
 				$this->orderbylistsql .= $selectedfields[0].".".$selectedfields[1]." ".$selectedfields[2];
 			}
@@ -898,12 +969,12 @@
 			}
 			if($secmodule == "Products")
 			{
-				$query = "left join vtiger_seproductsrel on vtiger_seproductsrel.crmid = vtiger_account.accountid
+				$query = "left join vtiger_seproductsrel on vtiger_seproductsrel.crmid = vtiger_account.accountid and vtiger_seproductsrel.setype = 'Accounts'
 					left join vtiger_products on vtiger_products.productid = vtiger_seproductsrel.productid
 					left join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid
 					left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid
-					left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid
-					left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid
+					left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_products.handler
+					left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_seproductsrel.crmid
 					left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id
 					left join vtiger_crmentity as vtiger_crmentityRel on vtiger_crmentityRel.crmid = vtiger_seproductsrel.crmid
 					left join vtiger_account as vtiger_accountRel on vtiger_accountRel.accountid=vtiger_crmentityRel.crmid
@@ -986,11 +1057,14 @@
 					left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
 			}
 		}
+
+		//Here we will get the Products - Accounts, Contacts relationship (Also Leads, Potentials)
 		if($module == "Products")
 		{
 			if($secmodule == "Accounts")
 			{
-				$query = "left join vtiger_account on vtiger_account.accountid = vtiger_crmentityRelProducts.crmid
+				$query = "
+					left join vtiger_account on vtiger_account.accountid = vtiger_seproductsrel.crmid
 					left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
 					left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
 					left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
@@ -1000,7 +1074,8 @@
 			}
 			if($secmodule == "Contacts")
 			{
-				$query = "left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_products.contactid
+				$query = "
+					left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_seproductsrel.crmid
 					left join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid
 					left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
 					left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
@@ -1058,8 +1133,7 @@
 				$query = "left join vtiger_products on vtiger_products.productid = vtiger_troubletickets.product_id
 					left join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid
 					left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid
-					left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid
-					left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid 
+					left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_products.handler
 					left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id
 					left join vtiger_seproductsrel on vtiger_seproductsrel.productid = vtiger_products.productid
 					left join vtiger_crmentity as vtiger_crmentityRelProducts on vtiger_crmentityRelProducts.crmid = vtiger_seproductsrel.crmid
@@ -1070,6 +1144,29 @@
 		}
 		if($module == "Calendar")
 		{
+			//Added Leads,Accounts,Potentials as secondarymodule for Calendar
+
+			if($secmodule == "Leads")
+			{
+				$query = "left join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid 
+					left join vtiger_crmentity as vtiger_crmentityLeads on vtiger_crmentityLeads.crmid = vtiger_leaddetails.leadid 
+					left join vtiger_leadaddress on vtiger_leaddetails.leadid = vtiger_leadaddress.leadaddressid 
+					left join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid = vtiger_leaddetails.leadid 
+					left join vtiger_leadscf on vtiger_leadscf.leadid = vtiger_leaddetails.leadid 
+					left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentityLeads.smownerid ";
+	
+			}
+			if($secmodule == "Accounts")
+			{
+				$query = "left join vtiger_account on vtiger_account.accountid = vtiger_seactivityrel.crmid
+					left join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid
+					left join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid
+					left join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid
+					left join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid
+					left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
+					left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid ";
+
+			}
 			if($secmodule == "Contacts")
 			{
 				$query = "left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid 
@@ -1082,6 +1179,14 @@
 					left join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid
 					left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid ";
 			}
+			if($secmodule == "Potentials")
+                        {
+				$query = "left join vtiger_potential on vtiger_potential.potentialid = vtiger_seactivityrel.crmid 
+                                        left join vtiger_crmentity as vtiger_crmentityPotentials on vtiger_crmentityPotentials.crmid=vtiger_potential.potentialid
+                                        left join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid
+                                        left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentityPotentials.smownerid ";
+
+                        }
 		}
 		if($module == 'Campaigns')
 		{
@@ -1090,22 +1195,13 @@
 				$query = "left join vtiger_products on vtiger_products.productid = vtiger_campaign.product_id  
 					left join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid
 					left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid
-					left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid
-					left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid 
+					left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_products.handler
 					left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id
 					left join vtiger_seproductsrel on vtiger_seproductsrel.productid = vtiger_products.productid
 					left join vtiger_crmentity as vtiger_crmentityRelProducts on vtiger_crmentityRelProducts.crmid = vtiger_seproductsrel.crmid
 					left join vtiger_account as vtiger_accountRelProducts on vtiger_accountRelProducts.accountid=vtiger_seproductsrel.crmid
 					left join vtiger_leaddetails as vtiger_leaddetailsRelProducts on vtiger_leaddetailsRelProducts.leadid = vtiger_seproductsrel.crmid
 					left join vtiger_potential as vtiger_potentialRelProducts on vtiger_potentialRelProducts.potentialid = vtiger_seproductsrel.crmid ";
-			}
-			elseif($secmodule == 'Contacts')
-			{
-				$query = "left join vtiger_campaigncontrel on vtiger_campaigncontrel.campaignid=vtiger_campaign.campaignid
-					left join vtiger_contactdetails on vtiger_campaigncontrel.contactid=vtiger_contactdetails.contactid
-					left join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid
-					left join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid
-					left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid ";
 			}
 		}
 		$log->info("ReportRun :: Successfully returned getRelatedModulesQuery".$secmodule);
@@ -1122,91 +1218,100 @@
 		if($module == "Leads")
 		{
 			$query = "from vtiger_leaddetails 
-				inner join vtiger_crmentity as vtiger_crmentityLeads on vtiger_crmentityLeads.crmid=vtiger_leaddetails.leadid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid 
 				inner join vtiger_leadsubdetails on vtiger_leadsubdetails.leadsubscriptionid=vtiger_leaddetails.leadid 
 				inner join vtiger_leadaddress on vtiger_leadaddress.leadaddressid=vtiger_leadsubdetails.leadsubscriptionid 
 				inner join vtiger_leadscf on vtiger_leaddetails.leadid = vtiger_leadscf.leadid 
-				left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentityLeads.smownerid
-				where vtiger_crmentityLeads.deleted=0 and vtiger_leaddetails.converted=0";
+				left join vtiger_leadgrouprelation on vtiger_leaddetails.leadid = vtiger_leadgrouprelation.leadid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_leadgrouprelation.groupname
+				left join vtiger_users as vtiger_usersLeads on vtiger_usersLeads.id = vtiger_crmentity.smownerid
+				where vtiger_crmentity.deleted=0 and vtiger_leaddetails.converted=0";
 		}
 		if($module == "Accounts")
 		{
 			$query = "from vtiger_account 
-				inner join vtiger_crmentity as vtiger_crmentityAccounts on vtiger_crmentityAccounts.crmid=vtiger_account.accountid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid 
 				inner join vtiger_accountbillads on vtiger_account.accountid=vtiger_accountbillads.accountaddressid 
 				inner join vtiger_accountshipads on vtiger_account.accountid=vtiger_accountshipads.accountaddressid 
 				inner join vtiger_accountscf on vtiger_account.accountid = vtiger_accountscf.accountid 
+				left join vtiger_accountgrouprelation on vtiger_account.accountid = vtiger_accountgrouprelation.accountid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
 				left join vtiger_account as vtiger_accountAccounts on vtiger_accountAccounts.accountid = vtiger_account.parentid
-				left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentityAccounts.smownerid
+				left join vtiger_users as vtiger_usersAccounts on vtiger_usersAccounts.id = vtiger_crmentity.smownerid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityAccounts.deleted=0 ";
+				where vtiger_crmentity.deleted=0 ";
 		}
 
 		if($module == "Contacts")
 		{
 			$query = "from vtiger_contactdetails
-				inner join vtiger_crmentity as vtiger_crmentityContacts on vtiger_crmentityContacts.crmid = vtiger_contactdetails.contactid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid 
 				inner join vtiger_contactaddress on vtiger_contactdetails.contactid = vtiger_contactaddress.contactaddressid 
 				inner join vtiger_customerdetails on vtiger_customerdetails.customerid = vtiger_contactdetails.contactid
 				inner join vtiger_contactsubdetails on vtiger_contactdetails.contactid = vtiger_contactsubdetails.contactsubscriptionid 
 				inner join vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid 
+				left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid = vtiger_contactgrouprelation.contactid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_contactgrouprelation.groupname
 				left join vtiger_contactdetails as vtiger_contactdetailsContacts on vtiger_contactdetailsContacts.contactid = vtiger_contactdetails.reportsto
 				left join vtiger_account as vtiger_accountContacts on vtiger_accountContacts.accountid = vtiger_contactdetails.accountid 
-				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentityContacts.smownerid
+				left join vtiger_users as vtiger_usersContacts on vtiger_usersContacts.id = vtiger_crmentity.smownerid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)." 
-				where vtiger_crmentityContacts.deleted=0";
+				where vtiger_crmentity.deleted=0";
 		}
 
 		if($module == "Potentials")
 		{
 			$query = "from vtiger_potential 
-				inner join vtiger_crmentity as vtiger_crmentityPotentials on vtiger_crmentityPotentials.crmid=vtiger_potential.potentialid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_potential.potentialid 
 				inner join vtiger_account as vtiger_accountPotentials on vtiger_potential.accountid = vtiger_accountPotentials.accountid 
 				inner join vtiger_potentialscf on vtiger_potentialscf.potentialid = vtiger_potential.potentialid
-				left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentityPotentials.smownerid  
+				left join vtiger_potentialgrouprelation on vtiger_potential.potentialid = vtiger_potentialgrouprelation.potentialid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_potentialgrouprelation.groupname
+				left join vtiger_users as vtiger_usersPotentials on vtiger_usersPotentials.id = vtiger_crmentity.smownerid  
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityPotentials.deleted=0 ";
-		}
-
+				where vtiger_crmentity.deleted=0 ";
+		}
+
+		//For this Product - we can related Accounts, Contacts (Also Leads, Potentials)
 		if($module == "Products")
 		{
 			$query = "from vtiger_products 
-				inner join vtiger_crmentity as vtiger_crmentityProducts on vtiger_crmentityProducts.crmid=vtiger_products.productid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_products.productid 
 				left join vtiger_productcf on vtiger_products.productid = vtiger_productcf.productid 
-				left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_crmentityProducts.smownerid 
-				left join vtiger_contactdetails as vtiger_contactdetailsProducts on vtiger_contactdetailsProducts.contactid = vtiger_products.contactid
-				left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id  
-				left join vtiger_seproductsrel on vtiger_seproductsrel.productid = vtiger_products.productid 
-				left join vtiger_crmentity as vtiger_crmentityRelProducts on vtiger_crmentityRelProducts.crmid = vtiger_seproductsrel.crmid 
-				left join vtiger_account as vtiger_accountRelProducts on vtiger_accountRelProducts.accountid=vtiger_crmentityRelProducts.crmid 
-				left join vtiger_leaddetails as vtiger_leaddetailsRelProducts on vtiger_leaddetailsRelProducts.leadid = vtiger_crmentityRelProducts.crmid 
-				left join vtiger_potential as vtiger_potentialRelProducts on vtiger_potentialRelProducts.potentialid = vtiger_crmentityRelProducts.crmid 
+				left join vtiger_users as vtiger_usersProducts on vtiger_usersProducts.id = vtiger_products.handler 
+				left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_products.vendor_id 
+				left join vtiger_seproductsrel on vtiger_seproductsrel.productid= vtiger_products.productid and vtiger_seproductsrel.setype='".$this->secondarymodule."'	
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityProducts.deleted=0 ";
+				where vtiger_crmentity.deleted=0";
 		}
 
 		if($module == "HelpDesk")
 		{
 			$query = "from vtiger_troubletickets 
-				inner join vtiger_crmentity as vtiger_crmentityHelpDesk 
-				on vtiger_crmentityHelpDesk.crmid=vtiger_troubletickets.ticketid 
+				inner join vtiger_crmentity  
+				on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid 
 				inner join vtiger_ticketcf on vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid
 				left join vtiger_crmentity as vtiger_crmentityRelHelpDesk on vtiger_crmentityRelHelpDesk.crmid = vtiger_troubletickets.parent_id
 				left join vtiger_account as vtiger_accountRelHelpDesk on vtiger_accountRelHelpDesk.accountid=vtiger_crmentityRelHelpDesk.crmid 
 				left join vtiger_contactdetails as vtiger_contactdetailsRelHelpDesk on vtiger_contactdetailsRelHelpDesk.contactid= vtiger_crmentityRelHelpDesk.crmid
 				left join vtiger_products as vtiger_productsRel on vtiger_productsRel.productid = vtiger_troubletickets.product_id 
-				left join vtiger_users as vtiger_usersHelpDesk on vtiger_crmentityHelpDesk.smownerid=vtiger_usersHelpDesk.id 
+				left join vtiger_ticketgrouprelation on vtiger_troubletickets.ticketid = vtiger_ticketgrouprelation.ticketid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_ticketgrouprelation.groupname
+															
+				left join vtiger_users as vtiger_usersHelpDesk on vtiger_crmentity.smownerid=vtiger_usersHelpDesk.id 
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityHelpDesk.deleted=0 ";
+				where vtiger_crmentity.deleted=0 ";
 		}
 
 		if($module == "Calendar")
 		{
 			$query = "from vtiger_activity 
-				inner join vtiger_crmentity as vtiger_crmentityCalendar on vtiger_crmentityCalendar.crmid=vtiger_activity.activityid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid 
 				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid 
 				left join vtiger_contactdetails as vtiger_contactdetailsCalendar on vtiger_contactdetailsCalendar.contactid= vtiger_cntactivityrel.contactid
-				left join vtiger_users as vtiger_usersCalendar on vtiger_usersCalendar.id = vtiger_crmentityCalendar.smownerid
+				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
+				left join vtiger_users as vtiger_usersCalendar on vtiger_usersCalendar.id = vtiger_crmentity.smownerid
 				left join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid
 				left join vtiger_crmentity as vtiger_crmentityRelCalendar on vtiger_crmentityRelCalendar.crmid = vtiger_seactivityrel.crmid
 				left join vtiger_account as vtiger_accountRelCalendar on vtiger_accountRelCalendar.accountid=vtiger_crmentityRelCalendar.crmid
@@ -1216,55 +1321,61 @@
 				left join vtiger_purchaseorder as vtiger_purchaseorderRelCalendar on vtiger_purchaseorderRelCalendar.purchaseorderid = vtiger_crmentityRelCalendar.crmid
 				left join vtiger_invoice as vtiger_invoiceRelCalendar on vtiger_invoiceRelCalendar.invoiceid = vtiger_crmentityRelCalendar.crmid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				WHERE vtiger_crmentityCalendar.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')";
+				WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype = 'Meeting' or vtiger_activity.activitytype='Call' or vtiger_activity.activitytype='Task')";
 		}
 
 		if($module == "Quotes")
 		{
 			$query = "from vtiger_quotes 
-				inner join vtiger_crmentity as vtiger_crmentityQuotes on vtiger_crmentityQuotes.crmid=vtiger_quotes.quoteid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid 
 				inner join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid 
 				inner join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid  
 				left join vtiger_quotescf on vtiger_quotes.quoteid = vtiger_quotescf.quoteid 
-				left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentityQuotes.smownerid
+				left join vtiger_quotegrouprelation on vtiger_quotes.quoteid = vtiger_quotegrouprelation.quoteid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_quotegrouprelation.groupname
+				left join vtiger_users as vtiger_usersQuotes on vtiger_usersQuotes.id = vtiger_crmentity.smownerid
 				left join vtiger_users as vtiger_usersRel1 on vtiger_usersRel1.id = vtiger_quotes.inventorymanager
 				left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_quotes.potentialid
 				left join vtiger_contactdetails as vtiger_contactdetailsQuotes on vtiger_contactdetailsQuotes.contactid = vtiger_quotes.contactid
 				left join vtiger_account as vtiger_accountQuotes on vtiger_accountQuotes.accountid = vtiger_quotes.accountid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityQuotes.deleted=0";
+				where vtiger_crmentity.deleted=0";
 		}
 
 		if($module == "PurchaseOrder")
 		{
 			$query = "from vtiger_purchaseorder 
-				inner join vtiger_crmentity as vtiger_crmentityPurchaseOrder on vtiger_crmentityPurchaseOrder.crmid=vtiger_purchaseorder.purchaseorderid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid 
 				inner join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid 
 				inner join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid 
 				left join vtiger_purchaseordercf on vtiger_purchaseorder.purchaseorderid = vtiger_purchaseordercf.purchaseorderid  
-				left join vtiger_users as vtiger_usersPurchaseOrder on vtiger_usersPurchaseOrder.id = vtiger_crmentityPurchaseOrder.smownerid 
+				left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid = vtiger_pogrouprelation.purchaseorderid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_pogrouprelation.groupname
+				left join vtiger_users as vtiger_usersPurchaseOrder on vtiger_usersPurchaseOrder.id = vtiger_crmentity.smownerid 
 				left join vtiger_vendor as vtiger_vendorRel on vtiger_vendorRel.vendorid = vtiger_purchaseorder.vendorid 
 				left join vtiger_contactdetails as vtiger_contactdetailsPurchaseOrder on vtiger_contactdetailsPurchaseOrder.contactid = vtiger_purchaseorder.contactid 
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityPurchaseOrder.deleted=0";
+				where vtiger_crmentity.deleted=0";
 		}
 
 		if($module == "Invoice")
 		{
 			$query = "from vtiger_invoice 
-				inner join vtiger_crmentity as vtiger_crmentityInvoice on vtiger_crmentityInvoice.crmid=vtiger_invoice.invoiceid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid 
 				inner join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid 
 				inner join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid 
 				left join vtiger_invoicecf on vtiger_invoice.invoiceid = vtiger_invoicecf.invoiceid 
-				left join vtiger_users as vtiger_usersInvoice on vtiger_usersInvoice.id = vtiger_crmentityInvoice.smownerid
+				left join vtiger_invoicegrouprelation on vtiger_invoice.invoiceid = vtiger_invoicegrouprelation.invoiceid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_invoicegrouprelation.groupname
+				left join vtiger_users as vtiger_usersInvoice on vtiger_usersInvoice.id = vtiger_crmentity.smownerid
 				left join vtiger_account as vtiger_accountInvoice on vtiger_accountInvoice.accountid = vtiger_invoice.accountid
 				".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				where vtiger_crmentityInvoice.deleted=0";
+				where vtiger_crmentity.deleted=0";
 		}
 		if($module == "SalesOrder")
 		{
 			$query = "from vtiger_salesorder 
-				inner join vtiger_crmentity as vtiger_crmentitySalesOrder on vtiger_crmentitySalesOrder.crmid=vtiger_salesorder.salesorderid 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_salesorder.salesorderid 
 				inner join vtiger_sobillads on vtiger_salesorder.salesorderid=vtiger_sobillads.sobilladdressid 
 				inner join vtiger_soshipads on vtiger_salesorder.salesorderid=vtiger_soshipads.soshipaddressid 
 				left join vtiger_salesordercf on vtiger_salesorder.salesorderid = vtiger_salesordercf.salesorderid  
@@ -1272,8 +1383,10 @@
 				left join vtiger_quotes as vtiger_quotesSalesOrder on vtiger_quotesSalesOrder.quoteid = vtiger_salesorder.quoteid				
 				left join vtiger_account as vtiger_accountSalesOrder on vtiger_accountSalesOrder.accountid = vtiger_salesorder.accountid
 				left join vtiger_potential as vtiger_potentialRel on vtiger_potentialRel.potentialid = vtiger_salesorder.potentialid 
-				left join vtiger_users as vtiger_usersSalesOrder on vtiger_usersSalesOrder.id = vtiger_crmentitySalesOrder.smownerid 
-				where vtiger_crmentitySalesOrder.deleted=0";
+				left join vtiger_sogrouprelation on vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_sogrouprelation.groupname
+				left join vtiger_users as vtiger_usersSalesOrder on vtiger_usersSalesOrder.id = vtiger_crmentity.smownerid 
+				where vtiger_crmentity.deleted=0";
 
 
 		}	
@@ -1281,10 +1394,13 @@
 		{
 		 $query = "from vtiger_campaign
 			        inner join vtiger_campaignscf as vtiger_campaignscf on vtiger_campaignscf.campaignid=vtiger_campaign.campaignid   
-				inner join vtiger_crmentity as vtiger_crmentityCampaigns on vtiger_crmentityCampaigns.crmid=vtiger_campaign.campaignid
-		                left join vtiger_users as vtiger_usersCampaigns on vtiger_usersCampaigns.id = vtiger_crmentityCampaigns.smownerid
-                                   ".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
-				   where vtiger_crmentityCampaigns.deleted=0";
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_campaign.campaignid
+				left join vtiger_campaigngrouprelation on vtiger_campaign.campaignid = vtiger_campaigngrouprelation.campaignid
+				left join vtiger_groups on vtiger_groups.groupname = vtiger_campaigngrouprelation.groupname
+
+		             left join vtiger_users as vtiger_usersCampaigns on vtiger_usersCampaigns.id = vtiger_crmentity.smownerid
+                                ".$this->getRelatedModulesQuery($module,$this->secondarymodule)."
+				where vtiger_crmentity.deleted=0";
 		}
 		$log->info("ReportRun :: Successfully returned getReportsQuery".$module);
 		return $query;
@@ -1308,6 +1424,10 @@
 		$columnstotallist = $this->getColumnsTotal($reportid);
 		$advfilterlist = $this->getAdvFilterList($reportid);
 		$this->totallist = $columnstotallist;
+		global $current_user;
+		require('user_privileges/user_privileges_'.$current_user->id.'.php');
+		require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+		$tab_id = getTabid($this->primarymodule);
 		if($this->reporttype == "summary")
 		{
 			if(isset($this->groupbylist))
@@ -1322,7 +1442,6 @@
 		{
 			$selectlist = $columnlist;
 		}
-
 		//columns list
 		if(isset($selectlist))
 		{
@@ -1363,7 +1482,6 @@
 		}
 
 		$reportquery = $this->getReportsQuery($this->primarymodule);
-
 		if($type == 'COLUMNSTOTOTAL')
 		{
 			if(trim($groupsquery) != "")
@@ -1389,6 +1507,12 @@
 				$reportquery = "select ".$selectedcolumns." ".$reportquery." ".$wheresql;
 			}
 		}
+		if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
+		{
+			$sec_parameter=getListViewSecurityParameter($this->primarymodule);
+			$reportquery .= $sec_parameter;
+		}
+
 		$log->info("ReportRun :: Successfully returned sGetSQLforReport".$reportid);
 		return $reportquery;
 
@@ -1415,14 +1539,25 @@
 		{
 			$sSQL = $this->sGetSQLforReport($this->reportid,$filterlist);
 			$result = $adb->query($sSQL);
-			$y=$adb->num_fields($result);
 
 			if($result)
 			{
+				$y=$adb->num_fields($result);
+				$arrayHeaders = Array();
 				for ($x=0; $x<$y; $x++)
 				{
 					$fld = $adb->field_name($result, $x);
-					$header .= "<td class='rptCellLabel'>".$this->getLstringforReportHeaders($fld->name)."</td>";
+					if(in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders))
+					{
+						$headerLabel = str_replace("_"," ",$fld->name);
+						$arrayHeaders[] = $headerLabel;
+					}
+					else
+					{
+						$headerLabel = str_replace($modules," ",$this->getLstringforReportHeaders($fld->name));
+						$arrayHeaders[] = $headerLabel;
+					}
+					$header .= "<td class='rptCellLabel'>".$headerLabel."</td>";
 				}
 
 				$noofrows = $adb->num_rows($result);
@@ -1464,6 +1599,14 @@
 						{
 							$fieldvalue = "-";
 						}
+						else if(stristr($fieldvalue,"|##|"))
+						{
+							$fieldvalue = str_ireplace(' |##| ',', ',$fieldvalue);
+						}
+						else if(stristr($fld->name, "_Date") || stristr($fld->name, "_Created_Time") || stristr($fld->name, "_Modified_Time")){
+							$fieldvalue = getDisplayDate($fieldvalue);
+						}
+																				
 						if(($lastvalue == $fieldvalue) && $this->reporttype == "summary")
 						{
 							if($this->reporttype == "summary")
@@ -1530,10 +1673,10 @@
 
 			$sSQL = $this->sGetSQLforReport($this->reportid,$filterlist);
 			$result = $adb->query($sSQL);
-			$y=$adb->num_fields($result);
 
 			if($result)
 			{
+				$y=$adb->num_fields($result);
 				$noofrows = $adb->num_rows($result);
 				$custom_field_values = $adb->fetch_array($result);
 
@@ -1552,7 +1695,17 @@
 						{
 							$fieldvalue = "-";
 						}
-						$arraylists[str_replace($modules," ",$this->getLstringforReportHeaders($fld->name))] = $fieldvalue;
+						else if(stristr($fieldvalue,"|##|"))
+						{
+							$fieldvalue = str_ireplace(' |##| ',', ',$fieldvalue);
+						}
+						else if(stristr($fld->name, "_Date") || stristr($fld->name, "_Created_Time") || stristr($fld->name, "_Modified_Time")){
+							$fieldvalue = getDisplayDate($fieldvalue);
+						}
+						if(array_key_exists($this->getLstringforReportHeaders($fld->name), $arraylists))
+							$arraylists[str_replace("_"," ",$fld->name)] = $fieldvalue;
+						else	
+							$arraylists[str_replace($modules," ",$this->getLstringforReportHeaders($fld->name))] = $fieldvalue;
 					}
 					$arr_val[] = $arraylists;
 				}while($custom_field_values = $adb->fetch_array($result));
@@ -1636,16 +1789,26 @@
 		{
 			$sSQL = $this->sGetSQLforReport($this->reportid,$filterlist);
 			$result = $adb->query($sSQL);
-			$y=$adb->num_fields($result);
 
 			if($result)
 			{
+				$y=$adb->num_fields($result);
+				$arrayHeaders = Array();
 				for ($x=0; $x<$y; $x++)
 				{
 					$fld = $adb->field_name($result, $x);
-					$header .= "<th>".$this->getLstringforReportHeaders($fld->name)."</th>";
-				}
-				
+					if(in_array($this->getLstringforReportHeaders($fld->name), $arrayHeaders))
+					{
+						$headerLabel = str_replace("_"," ",$fld->name);
+						$arrayHeaders[] = $headerLabel;
+					}
+					else
+					{
+						$headerLabel = str_replace($modules," ",$this->getLstringforReportHeaders($fld->name));
+						$arrayHeaders[] = $headerLabel;	
+					}	
+					$header .= "<th>".$headerLabel."</th>";
+				}
 				$noofrows = $adb->num_rows($result);
 				$custom_field_values = $adb->fetch_array($result);
 				$groupslist = $this->getGroupingList($this->reportid);
@@ -1686,6 +1849,13 @@
 						if($fieldvalue == "" )
 						{
 							$fieldvalue = "-";
+						}
+						else if(stristr($fieldvalue,"|##|"))
+						{
+							$fieldvalue = str_ireplace(' |##| ',', ',$fieldvalue);
+						}
+						else if(stristr($fld->name, "_Date") || stristr($fld->name, "_Created_Time") || stristr($fld->name, "_Modified_Time")){
+							$fieldvalue = getDisplayDate($fieldvalue);
 						}
 						if(($lastvalue == $fieldvalue) && $this->reporttype == "summary")
 						{

Modified: vtigercrm/branches/5.1_jens/modules/Reports/Reports.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/Reports.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/Reports.php Mon Apr 16 12:27:44 2007
@@ -41,14 +41,14 @@
 			 'Accounts'=>Array('Potentials','Contacts','Products','Quotes','Invoice'),
 			 'Contacts'=>Array('Accounts','Potentials','Quotes','PurchaseOrder'),
 			 'Potentials'=>Array('Accounts','Contacts','Quotes'),
-			 'Calendar'=>Array('Contacts'),
+			 'Calendar'=>Array('Leads','Accounts','Contacts','Potentials'),
 			 'Products'=>Array('Accounts','Contacts'),
 			 'HelpDesk'=>Array('Products'),
 			 'Quotes'=>Array('Accounts','Contacts','Potentials'),
 			 'PurchaseOrder'=>Array('Contacts'),
 			 'SalesOrder'=>Array(),
 			 'Invoice'=>Array('Accounts'),
-			 'Campaigns'=>Array('Products','Contacts')
+			 'Campaigns'=>Array('Products')
 			);
 
 foreach($report_modules as $values)
@@ -107,7 +107,7 @@
 
 	var $module_list = Array(
 				"Leads"=>Array("Information"=>13,"Address"=>15,"Description"=>16,"Custom Information"=>14),
-				"Contacts"=>Array("Information"=>4,"- Portal Information"=>6,"Address"=>7,"Description"=>8,"Custom Information"=>5),
+				"Contacts"=>Array("Information"=>4,"Portal Information"=>6,"Address"=>7,"Description"=>8,"Custom Information"=>5),
 				"Accounts"=>Array("Information"=>9,"Address"=>11,"Description"=>12,"Custom Information"=>10),
 				"Potentials"=>Array("Information"=>1,"Description"=>3,"Custom Information"=>2),
 				"Calendar"=>Array("Information"=>19,"Description"=>20),
@@ -159,8 +159,7 @@
 	function sgetRptFldr($mode='')
 	{
 
-		global $adb;
-		global $log;
+		global $adb,$log,$mod_strings;
 		$returndata = Array();
 		$sql = "select * from vtiger_reportfolder order by folderid";
 		$result = $adb->query($sql);
@@ -174,7 +173,7 @@
 					$details = Array();	
 					$details['state'] = $reportfldrow["state"]; 
 					$details['id'] = $reportfldrow["folderid"]; 
-					$details['name'] = $reportfldrow["foldername"]; 
+					$details['name'] = ($mod_strings[$reportfldrow["foldername"]] == '' ) ? $reportfldrow["foldername"]:$mod_strings[$reportfldrow["foldername"]]; 
 					$details['description'] = $reportfldrow["description"]; 
 					$details['details'] = $this->sgetRptsforFldr($reportfldrow["folderid"]);
 					$returndata[] = $details;
@@ -187,7 +186,7 @@
 				$details = Array();	
 				$details['state'] = $reportfldrow["state"]; 
 				$details['id'] = $reportfldrow["folderid"]; 
-				$details['name'] = $reportfldrow["foldername"]; 
+				$details['name'] = ($mod_strings[$reportfldrow["foldername"]] == '' ) ? $reportfldrow["foldername"]:$mod_strings[$reportfldrow["foldername"]]; 
 				$details['description'] = $reportfldrow["description"]; 
 				$returndata[] = $details;
 			}while($reportfldrow = $adb->fetch_array($result));
@@ -230,7 +229,8 @@
 				$report_details ['description'] = $report["description"];
 				$report_details ['reportname'] = $report["reportname"];
 
-				$returndata []=$report_details; 
+				if(isPermitted($report["primarymodule"],'index') == "yes")
+					$returndata []=$report_details; 
 			}while($report = $adb->fetch_array($result));
 		}
 
@@ -312,14 +312,26 @@
 		//Security Check 
 		if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] ==0)
 		{
-			$sql = "select * from vtiger_field where vtiger_field.uitype != 50 and vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block .") and vtiger_field.displaytype in (1,2,3) order by sequence";
+			$sql = "select * from vtiger_field where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block .") and vtiger_field.displaytype in (1,2,3) order by sequence";
 		}
 		else
 		{
 			
 			$profileList = getCurrentUserProfileList();
-			$sql = "select * from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.uitype != 50 and vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block .") and vtiger_field.displaytype in (1,2,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by sequence";
-		}
+			$sql = "select * from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=".$tabid." and vtiger_field.block in (".$block .") and vtiger_field.displaytype in (1,2,3) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by sequence";
+		}
+		//Added to include vtiger_activity type for Reports Module
+		if($module == 'Calendar' && $block == 19)
+		{
+			 $module_columnlist['vtiger_activity:activitytype:Calendar_Activity_Type:activitytype:C'] = 'Activity Type';
+		}
+		
+		if($module == 'HelpDesk' && $block == 25)
+                {
+                        $module_columnlist['vtiger_crmentity:crmid:HelpDesk_Ticket_ID:ticketid:I'] = 'Ticket ID';
+                }
+
+
 		$result = $adb->query($sql);
 		$noofrows = $adb->num_rows($result);
 		for($i=0; $i<$noofrows; $i++)
@@ -328,8 +340,13 @@
 			$fieldcolname = $adb->query_result($result,$i,"columnname");
 			$fieldname = $adb->query_result($result,$i,"fieldname");
 			$fieldtype = $adb->query_result($result,$i,"typeofdata");
+			$uitype = $adb->query_result($result,$i,"uitype");
 			$fieldtype = explode("~",$fieldtype);
 			$fieldtypeofdata = $fieldtype[0];
+			if($uitype == 68 || $uitype == 59)
+			{
+				$fieldtypeofdata = 'V';
+			}
 			if($fieldtablename == "vtiger_crmentity")
 			{
 				$fieldtablename = $fieldtablename.$module;
@@ -556,6 +573,42 @@
 		$nextFY0 = date("Y-m-d",mktime(0, 0, 0, "01", "01",   date("Y")+1));
 		$nextFY1 = date("Y-m-t", mktime(0, 0, 0, "12", date("d"), date("Y")+1));
 
+		if(date("m") <= 3)
+		{
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "03","31",date("Y")));
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "04","01",date("Y")));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "06","30",date("Y")));
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "10","01",date("Y")-1));
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")-1));
+		}else if(date("m") > 3 and date("m") <= 6)
+		{
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")));
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "03","31",date("Y")));
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "04","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "06","30",date("Y")));
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "07","01",date("Y")));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "09","30",date("Y")));
+
+		}else if(date("m") > 6 and date("m") <= 9)
+		{
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "10","01",date("Y")));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")));
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "04","01",date("Y")));
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "06","30",date("Y")));
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "07","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "09","30",date("Y")));
+		}
+		else if(date("m") > 9 and date("m") <= 12)
+		{
+			$nFq = date("Y-m-d",mktime(0, 0, 0, "01","01",date("Y")+1));
+			$nFq1 = date("Y-m-d",mktime(0, 0, 0, "03","31",date("Y")+1));
+			$pFq = date("Y-m-d",mktime(0, 0, 0, "07","01",date("Y")));
+			$pFq1 = date("Y-m-d",mktime(0, 0, 0, "09","30",date("Y")));
+			$cFq = date("Y-m-d",mktime(0, 0, 0, "10","01",date("Y")));
+			$cFq1 = date("Y-m-d",mktime(0, 0, 0, "12","31",date("Y")));
+
+		}
 
 		$sjsStr = '<script language="JavaScript" type="text/javaScript">
 			function showDateRange( type )
@@ -711,19 +764,19 @@
 				else if( type == "nextfq" )
 				{
 
-					document.NewReport.startdate.value = "2005-07-01";
-					document.NewReport.enddate.value = "2005-09-30";
+					document.NewReport.startdate.value = "'.$nFq.'";
+					document.NewReport.enddate.value = "'.$nFq1.'";
 				}                        
 				else if( type == "prevfq" )
 				{
 
-					document.NewReport.startdate.value = "2005-01-01";
-					document.NewReport.enddate.value = "2005-03-31";
+					document.NewReport.startdate.value = "'.$pFq.'";
+					document.NewReport.enddate.value = "'.$pFq1.'";
 				}                
 				else if( type == "thisfq" )
 				{
-					document.NewReport.startdate.value = "2005-04-01";
-					document.NewReport.enddate.value = "2005-06-30";
+					document.NewReport.startdate.value = "'.$cFq.'";
+					document.NewReport.enddate.value = "'.$cFq1.'";
 				}                
 				else
 				{
@@ -735,6 +788,53 @@
 
 		return $sjsStr;
 	}
+function getEscapedColumns($selectedfields)
+	{
+		$fieldname = $selectedfields[3];
+		if($fieldname == "parent_id")
+		{
+			if($this->primarymodule == "HelpDesk" && $selectedfields[0] == "vtiger_crmentityRelHelpDesk")
+			{
+				$querycolumn = "case vtiger_crmentityRelHelpDesk.setype when 'Accounts' then vtiger_accountRelHelpDesk.accountname when 'Contacts' then vtiger_contactdetailsRelHelpDesk.lastname End"." '".$selectedfields[2]."', vtiger_crmentityRelHelpDesk.setype 'Entity_type'";
+				return $querycolumn;
+			}
+			if($this->primarymodule == "Products" || $this->secondarymodule == "Products")
+			{
+				$querycolumn = "case vtiger_crmentityRelProducts.setype when 'Accounts' then vtiger_accountRelProducts.accountname when 'Leads' then vtiger_leaddetailsRelProducts.lastname when 'Potentials' then vtiger_potentialRelProducts.potentialname End"." '".$selectedfields[2]."', vtiger_crmentityRelProducts.setype 'Entity_type'";
+			}
+			if($this->primarymodule == "Calendar" || $this->secondarymodule == "Calendar")
+			{
+				$querycolumn = "case vtiger_crmentityRelCalendar.setype when 'Accounts' then vtiger_accountRelCalendar.accountname when 'Leads' then vtiger_leaddetailsRelCalendar.lastname when 'Potentials' then vtiger_potentialRelCalendar.potentialname when 'Quotes' then vtiger_quotesRelCalendar.subject when 'PurchaseOrder' then vtiger_purchaseorderRelCalendar.subject when 'Invoice' then vtiger_invoiceRelCalendar.subject End"." '".$selectedfields[2]."', vtiger_crmentityRelCalendar.setype 'Entity_type'";
+			}
+		}
+		return $querycolumn;
+	}
+	function getaccesfield($module)
+	{
+		global $current_user;
+		global $adb;
+		$access_fields = Array();
+		
+		$profileList = getCurrentUserProfileList();
+		$query = "select vtiger_field.fieldname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where";
+		if($module == "Calendar")
+		{
+			$query .= " vtiger_field.tabid in (9,16) and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by block,sequence";
+		}
+		else
+		{
+			$query .= " vtiger_field.tabid in (select tabid from vtiger_tab where vtiger_tab.name in ('".$this->primodule."','".$this->secmodule."')) and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList." group by vtiger_field.fieldid order by block,sequence";
+		}
+
+		$result = $adb->query($query);
+
+		
+		while($collistrow = $adb->fetch_array($result))
+		{
+			$access_fields[] = $collistrow["fieldname"];
+		}
+		return $access_fields;
+	}
 
 	/** Function to set the order of grouping and to find the columns responsible
 	 *  to the grouping
@@ -777,52 +877,60 @@
 
 	function getSelectedColumnsList($reportid)
 	{
-
 		global $adb;
 		global $modules;
-		global $log;
+		global $log,$current_user;
 
 		$ssql = "select vtiger_selectcolumn.* from vtiger_report inner join vtiger_selectquery on vtiger_selectquery.queryid = vtiger_report.queryid";
-		$ssql .= " left join vtiger_selectcolumn on vtiger_selectcolumn.queryid = vtiger_selectquery.queryid where vtiger_report.reportid =".$reportid;
+		$ssql .= " left join vtiger_selectcolumn on vtiger_selectcolumn.queryid = vtiger_selectquery.queryid";
+		$ssql .= " where vtiger_report.reportid =".$reportid;
 		$ssql .= " order by vtiger_selectcolumn.columnindex";
-
 		$result = $adb->query($ssql);
-		$noofrows = $adb->num_rows($result);
-
-		for($i=0; $i<$noofrows; $i++)
-		{
-			$fieldcolname = $adb->query_result($result,$i,"columnname");
-			$fieldlist = explode(":",$fieldcolname);
-			
-			//Fix for multilanguage support - code contribution by Ding jianting
-			$fieldlabel_array = explode("_",$fieldlist[2]);
-			$mod_strings = return_module_language($current_language,$fieldlabel_array[0]);
-			if($fieldcolname != "")
-			{
-				$fieldlabel = trim(str_replace($modules," ",$fieldlist[2]));
-				if(isset($mod_strings[$fieldlabel])) {
-					$shtml .= "<option value=\"".$fieldcolname."\">".$mod_strings[$fieldlabel]."</option>";
-				} else {
-					$shtml .= "<option value=\"".$fieldcolname."\">".$fieldlabel."</option>";
+		$permitted_fields = Array();
+
+		while($columnslistrow = $adb->fetch_array($result))
+		{
+			$fieldname ="";
+			$fieldcolname = $columnslistrow["columnname"];
+			list($tablename,$colname,$module_field,$fieldname,$single) = split(":",$fieldcolname);
+			require('user_privileges/user_privileges_'.$current_user->id.'.php');
+			if(sizeof($permitted_fields) == 0 && $is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1)
+			{
+				list($module,$field) = split("_",$module_field);
+				$permitted_fields = $this->getaccesfield($module);	
+			}
+			$selectedfields = explode(":",$fieldcolname);
+			$querycolumns = $this->getEscapedColumns($selectedfields);
+
+				$mod_strings = return_module_language($current_language,$module);
+				$fieldlabel = trim(str_replace($module," ",$selectedfields[2]));
+				$fieldlabel = trim(str_replace("_"," ",$fieldlabel));		
+			if(sizeof($permitted_fields) != 0 && !in_array($fieldname,$permitted_fields) && $fieldname != 'ticketid')
+			{
+				if(isset($mod_strings[$fieldlabel])) 
+				{
+					$shtml .= "<option permission='no' value=\"".$fieldcolname."\" disabled = 'true'>".$mod_strings[$fieldlabel]."</option>";
 				}
-			}
-			//Code contribution ends
-		}
-
-		$log->info("Reports :: Successfully returned getSelectedColumnsList");
-		return $shtml;
-	}
-
-	/** Function to Set the selected columns for the advanced filter for the vtiger_report
-	 *  This function accepts the vtiger_reportid as the argument and get the selected columns
-	 *  in the advanced filter and sets the values
-	 *  $this->advft_column[] = The column name
-	 *  $this->advft_option[] = The filter option
-	 *  $this->advft_value[] = The value to be compared
-	 *	and returns true in sucess
-	 */
-
-	//<<<<<<<<advanced filter>>>>>>>>>>>>>>
+				else 
+				{
+					$shtml .= "<option permission='no' value=\"".$fieldcolname."\" disabled = 'true'>".$fieldlabel."</option>";
+				}
+			}
+			else
+			{
+				if(isset($mod_strings[$fieldlabel])) 
+				{
+					$shtml .= "<option permission='yes' value=\"".$fieldcolname."\">".$mod_strings[$fieldlabel]."</option>";
+				}
+			    	else 
+				{
+					$shtml .= "<option permission='yes' value=\"".$fieldcolname."\">".$fieldlabel."</option>";
+				}
+			}
+		}
+		$log->info("ReportRun :: Successfully returned getQueryColumnsList".$reportid);
+		return $shtml;		
+	}
 	function getAdvancedFilterList($reportid)
 	{
 		global $adb;
@@ -929,8 +1037,8 @@
 
 		$log->info("Reports :: Successfully returned sgetColumntoTotalSelected");
 		return $options;
-	}
-
+	
+	}
 
 	/** Function to form the HTML for columns to total	
 	 *  This function formulates the HTML format of the
@@ -989,7 +1097,7 @@
 					}
 
 					$columntototalrow['fieldlabel'] = str_replace(" ","_",$columntototalrow['fieldlabel']);
-					$options []= $columntototalrow['tablabel'].' - '.$columntototalrow['fieldlabel'];
+					$options []= getTranslatedString($columntototalrow['tablabel']).' - '.getTranslatedString($columntototalrow['fieldlabel']);
 					if($selectedcolumn1[2] == "cb:".$columntototalrow['tablename'].':'.$columntototalrow['columnname'].':'.$columntototalrow['fieldlabel']."_SUM:2")
 					{
 						$options []=  '<input checked name="cb:'.$columntototalrow['tablename'].':'.$columntototalrow['columnname'].':'.$columntototalrow['fieldlabel'].'_SUM:2" type="checkbox" value="">';					    
@@ -1022,7 +1130,7 @@
 					}
 				}else
 				{
-					$options []= $columntototalrow['tablabel'].' - '.$columntototalrow['fieldlabel'];
+					$options []= getTranslatedString($columntototalrow['tablabel']).' - '.getTranslatedString($columntototalrow['fieldlabel']);
 					$options []= '<input name="cb:'.$columntototalrow['tablename'].':'.$columntototalrow['columnname'].':'.$columntototalrow['fieldlabel'].'_SUM:2" type="checkbox" value="">';
 					$options []= '<input name="cb:'.$columntototalrow['tablename'].':'.$columntototalrow['columnname'].':'.$columntototalrow['fieldlabel'].'_AVG:3" type="checkbox" value="" >';
 					$options []= '<input name="cb:'.$columntototalrow['tablename'].':'.$columntototalrow['columnname'].':'.$columntototalrow['fieldlabel'].'_MIN:4"type="checkbox" value="" >';

Modified: vtigercrm/branches/5.1_jens/modules/Reports/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/Save.php Mon Apr 16 12:27:44 2007
@@ -34,7 +34,7 @@
 //<<<<<<<reportmodules>>>>>>>>>
 
 //<<<<<<<report>>>>>>>>>
-$reportname = $_REQUEST["reportName"];
+$reportname = addslashes($_REQUEST["reportName"]);
 $reportdescription = $_REQUEST["reportDesc"];
 $reporttype = $_REQUEST["reportType"];
 $folderid = $_REQUEST["folder"];
@@ -48,47 +48,43 @@
 //<<<<<<<standardfilters>>>>>>>>>
 
 //<<<<<<<columnstototal>>>>>>>>>>
-if( is_array( $HTTP_POST_VARS)) {
-    $allKeys = array_keys($HTTP_POST_VARS);
-    for ($i=0;$i<count($allKeys);$i++)
-    {
-       $string = substr($allKeys[$i], 0, 3);
-       if($string == "cb:")
-       {
-	       $columnstototal[] = $allKeys[$i];
-       }
-    }
+$allKeys = array_keys($HTTP_POST_VARS);
+for ($i=0;$i<count($allKeys);$i++)
+{
+   $string = substr($allKeys[$i], 0, 3);
+   if($string == "cb:")
+   {
+	   $columnstototal[] = $allKeys[$i];
+   }
 }
 //<<<<<<<columnstototal>>>>>>>>>
 
 //<<<<<<<advancedfilter>>>>>>>>
 //$adv_filter_col = "kcol";
-if( is_array( $HTTP_POST_VARS)) {
-    $allKeys = array_keys($HTTP_POST_VARS);
-    for ($i=0;$i<count($allKeys);$i++)
-    {
-       $string = substr($allKeys[$i], 0, 4);
-       if($string == "fcol")
-       {
-	       $adv_filter_col[] = $_REQUEST[$allKeys[$i]];
-       }
-    }
-    for ($i=0;$i<count($allKeys);$i++)
-    {
-       $string = substr($allKeys[$i], 0, 3);
-       if($string == "fop")
-       {
-	       $adv_filter_option[] = $_REQUEST[$allKeys[$i]];
-       }
-    }
-    for ($i=0;$i<count($allKeys);$i++)
-    {
-       $string = substr($allKeys[$i], 0, 4);
-       if($string == "fval")
-       {
-	       $adv_filter_value[] = $_REQUEST[$allKeys[$i]];
-       }
-    }
+$allKeys = array_keys($HTTP_POST_VARS);
+for ($i=0;$i<count($allKeys);$i++)
+{
+   $string = substr($allKeys[$i], 0, 4);
+   if($string == "fcol")
+   {
+	   $adv_filter_col[] = $_REQUEST[$allKeys[$i]];
+   }
+}
+for ($i=0;$i<count($allKeys);$i++)
+{
+   $string = substr($allKeys[$i], 0, 3);
+   if($string == "fop")
+   {
+           $adv_filter_option[] = $_REQUEST[$allKeys[$i]];
+   }
+}
+for ($i=0;$i<count($allKeys);$i++)
+{
+   $string = substr($allKeys[$i], 0, 4);
+   if($string == "fval")
+   {
+           $adv_filter_value[] = $_REQUEST[$allKeys[$i]];
+   }
 }
 //<<<<<<<advancedfilter>>>>>>>>
 if($reportid == "")
@@ -148,11 +144,7 @@
 					//<<<<step3 vtiger_reportsortcol>>>>>>>
 
 					//<<<<step5 standarfilder>>>>>>>
-					if( $startdate == '') 
-					    $startdate = date('YmdHis');
-					if( $enddate == '') 
-					    $enddate = date('YmdHis');
-					$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$genQueryId.",'".$stdDateFilterField."','".$stdDateFilter."','".$adb->formatString("vtiger_crmentity","startdate",$startdate)."','".$adb->formatString("vtiger_crmentity","enddate",$enddate)."')";
+					$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$genQueryId.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
 					$ireportmoduleresult = $adb->query($ireportmodulesql);
 					$log->info("Reports :: Save->Successfully saved vtiger_reportdatefilter");
 					//<<<<step5 standarfilder>>>>>>>
@@ -250,7 +242,7 @@
 			$idelreportdatefiltersqlresult = $adb->query($idelreportdatefiltersql);
 
 			//<<<<step5 standarfilder>>>>>>>
-			$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$reportid.",'".$stdDateFilterField."','".$stdDateFilter."','".$adb->formatString("vtiger_crmentity","startdate",$startdate)."','".$adb->formatString("vtiger_crmentity","enddate",$enddate)."')";
+			$ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (".$reportid.",'".$stdDateFilterField."','".$stdDateFilter."','".$startdate."','".$enddate."')";
 			$ireportmoduleresult = $adb->query($ireportmodulesql);
 			$log->info("Reports :: Save->Successfully saved vtiger_reportdatefilter");
 			//<<<<step5 standarfilder>>>>>>>

Modified: vtigercrm/branches/5.1_jens/modules/Reports/SaveReportFolder.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/SaveReportFolder.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/SaveReportFolder.php Mon Apr 16 12:27:44 2007
@@ -13,13 +13,14 @@
 require_once('include/database/PearDatabase.php');
 
 global $adb;
-
+global $default_charset;
 $local_log =& LoggerManager::getLogger('index');
 $focus = new Reports();
 
 $rfid = $_REQUEST['record'];
 $mode = $_REQUEST['savemode'];
 $foldername = addslashes($_REQUEST["foldername"]);
+$foldername = iconv("UTF-8",$default_charset,$foldername);
 $folderdesc = addslashes($_REQUEST["folderdesc"]);
 $foldername = str_replace('*amp*','&',$foldername);
 $folderdesc = str_replace('*amp*','&',$folderdesc);
@@ -29,7 +30,7 @@
 	{
 		$sql = "INSERT INTO vtiger_reportfolder ";
 		$sql .= "(FOLDERID,FOLDERNAME,DESCRIPTION,STATE) ";
-		$sql .= "VALUES (0,'".$foldername."','".$folderdesc."','CUSTOMIZED')";
+		$sql .= "VALUES ('','".$foldername."','".$folderdesc."','CUSTOMIZED')";
 		$result = $adb->query($sql);
 		if($result!=false)
 		{

Modified: vtigercrm/branches/5.1_jens/modules/Reports/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Reports/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Reports/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -37,7 +37,6 @@
 'LBL_NEW_REP0_HDR4'=>'Report Module and related module once selected cannot be modified later',
 'LBL_CONTINUE_BUTTON'=>'Continue',
 'LBL_NEW_REP1_HDR1'=>'Provide the following report information',
-'LBL_REPORT_TYPE'=>'Report Type',
 'LBL_SELECT_COLUMNS'=>'Select Columns',
 'LBL_SPECIFY_GROUPING'=>'Specify Grouping',
 'LBL_COLUMNS_TO_TOTAL'=>'Choose Columns To Total',
@@ -96,8 +95,7 @@
 'LBL_CLICK_HERE'=>'Click Here',
 'LBL_TO_ADD_NEW_GROUP'=>'to add new folder',
 'LBL_CREATE_NEW'=>'Create New',
-'LBL_REPORT_DETAILS'=>'Report Details',
-'LBL_RELATIVE_MODULE'=>'Relative Module',
+'LBL_RELATIVE_MODULE'=>'Related Module',
 'LBL_REPORT_TYPE'=>'Report Type',
 'LBL_REPORT_DETAILS'=>'Report Details',
 'LBL_TYPE_THE_NAME'=>'Type the Name',
@@ -108,7 +106,7 @@
 'LBL_AND'=>'and',
 'LBL_ADD_NEW_GROUP'=>'Add New Folder',
 'LBL_REPORT_MODULE'=>'Report Module',
-'LBL_SELECT_RELATIVE_MODULE_FOR_REPORT'=>'Select Relative Module for Report',
+'LBL_SELECT_RELATIVE_MODULE_FOR_REPORT'=>'Select Related Module for Report',
 'LBL_SELECT_REPORT_TYPE_BELOW'=>'Select Report type Below',
 'LBL_TABULAR_FORMAT'=>'Tabular Format',
 'LBL_TABULAR_REPORTS_ARE_SIMPLEST'=>'Tabular Reports are the simplest and fastest way of getting your data',
@@ -193,6 +191,9 @@
 'Next 60 Days'=>'Next 60 Days',
 'Next 90 Days'=>'Next 90 Days',
 'Next 120 Days'=>'Next 120 Days',
+'TITLE_VTIGERCRM_CREATE_REPORT' => 'vtiger CRM - Create Report',
+'TITLE_VTIGERCRM_PRINT_REPORT' => 'vtiger -  Print Report',
+'NO_FILTER_SELECTED' => 'No filter Selected',
 
 'LBL_GENERATE_NOW'=>'Generate Now',
 'Totals'=>'Totals',
@@ -201,6 +202,9 @@
 'MAX'=>'MAX',
 'MIN'=>'MIN',
 'LBL_CUSTOM_REPORTS'=>'Custom Reports',
+
+'ticketid'=>'Ticket Id',
+
 )
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Rss/Popup.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Rss/Popup.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Rss/Popup.php Mon Apr 16 12:27:44 2007
@@ -14,6 +14,7 @@
 require_once('include/utils/utils.php');
 require_once('modules/Rss/Rss.php');
 
+global $mod_strings;
 $log = LoggerManager::getLogger('rss_save');
 
 if(isset($_REQUEST["record"]))
@@ -35,14 +36,14 @@
 			$result = $oRss->saveRSSUrl($newRssUrl,$setstarred);
         	if($result == false)
         	{
-				echo "Unable to save the RSS Feed URL" ;
+				echo $mod_strings['UNABLE_TO_SAVE'] ;
         	}else
         	{
 				echo $result;
         	}
 	}else
 	{
-		echo "Not a valid RSS Feed URL" ;
+		echo $mod_strings['NOT_A_VALID'];
 
 	}
 }

Modified: vtigercrm/branches/5.1_jens/modules/Rss/Rss.js
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Rss/Rss.js (original)
+++ vtigercrm/branches/5.1_jens/modules/Rss/Rss.js Mon Apr 16 12:27:44 2007
@@ -34,7 +34,7 @@
                 return httpRequest.responseText;
             break;
             default:
-                alert("Problem accessing url: "+targetUrl+" Code: "+httpRequest.status);
+                alert(alert_arr.PROBLEM_ACCESSSING_URL+targetUrl+alert_arr.CODE+httpRequest.status);
                 return null;
             break;
         }       
@@ -48,7 +48,7 @@
         }
         // Here we decide whether to submit the form.
         if (isError == true) {
-                alert("Missing required fields:" + errorMessage);
+                alert(alert_arr.MISSING_REQUIRED_FIELDS + errorMessage);
                 return false;
         }
         return true;

Modified: vtigercrm/branches/5.1_jens/modules/Rss/Rss.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Rss/Rss.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Rss/Rss.php Mon Apr 16 12:27:44 2007
@@ -69,13 +69,17 @@
 
 	function getListViewRSSHtml()
 	{
+		global $default_charset;
 		if(isset($this->rss_object))
 		{
 			$i = 0;
 			foreach($this->rss_object as $key=>$item)
 			{
+				$stringConvert = iconv("UTF-8",$default_charset,$item[title]);
+				$rss_title= addslashes(ltrim(rtrim($stringConvert)));
+				
 				$i = $i + 1;	   
-				$shtml .= "<tr class='prvPrfHoverOff' onmouseover=\"this.className='prvPrfHoverOn'\" onmouseout=\"this.className='prvPrfHoverOff'\"><td><a href=\"javascript:display('".$item[link]."','feedlist_".$i."')\"; id='feedlist_".$i."' class=\"rssNews\">".$item[title]."</a></td><td>".$this->rss_title."</td></tr>";
+				$shtml .= "<tr class='prvPrfHoverOff' onmouseover=\"this.className='prvPrfHoverOn'\" onmouseout=\"this.className='prvPrfHoverOff'\"><td><a href=\"javascript:display('".$item[link]."','feedlist_".$i."')\"; id='feedlist_".$i."' class=\"rssNews\">".$rss_title."</a></td><td>".$this->rss_title."</td></tr>";
 				if($i == 10)
 				{
 					return $shtml;

Modified: vtigercrm/branches/5.1_jens/modules/Rss/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Rss/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Rss/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -31,12 +31,14 @@
 'LBL_STARRED_RSS'=>'Starred Feeds',
 'LBL_POP_CRM_RSS'=>'Popular CRM Related Feeds',
 'LBL_ALL_RSS_FEEDS'=>'All RSS Feeds',
+'LBL_VTIGER_RSS_READER'=>'vtiger RSS Reader',
 
 'LBL_MORE'=>'More...',
 'LBL_SUBJECT'=>'Subject',
 'LBL_SENDER'=>'Sender',
 'LBL_CATEGORY'=>'Category :',
 'LBL_FEED'=>'Feed :',
+'LBL_FEED_SOURCES'=> 'Feed Sources',
 'LBL_ADD_RSS_FEED'=>'Add RSS Feed',
 'LBL_DELETE_BUTTON'=>'Delete',
 'LBL_SET_DEFAULT_BUTTON'=>'Set As Default',
@@ -44,5 +46,7 @@
 'LBL_ERROR_MSG'=>'No RSS Feeds are selected or Your Proxy Settings is not Proper',
 'LBL_REGRET_MSG'=>'Sorry: It\'s not possible to reach RSS URL',
 
+'UNABLE_TO_SAVE'=>'Unable to save the RSS Feed URL',
+'NOT_A_VALID'=>'Not a valid RSS Feed URL',
 );
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/SalesOrder/CreateSOPDF.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/SalesOrder/CreateSOPDF.php (original)
+++ vtigercrm/branches/5.1_jens/modules/SalesOrder/CreateSOPDF.php Mon Apr 16 12:27:44 2007
@@ -11,12 +11,13 @@
 
 
 require('include/fpdf/pdf.php');
+require_once('include/fpdf/pdfconfig.php');
 require_once('modules/SalesOrder/SalesOrder.php');
 require_once('modules/Organization/Organization.php');
 require_once('include/database/PearDatabase.php');
 require_once('include/utils/EditViewUtils.php');
 
-global $adb,$app_strings,$products_per_page;
+global $adb,$app_strings;
 global $log;
 
 // for template checking ...
@@ -27,9 +28,8 @@
 $result = $adb->query($sql);
 $currency_symbol = $adb->query_result($result,0,'currency_symbol');
 
-// would you like an end page?  1 for yes 0 for no
+// would you like and end page?  1 for yes 0 for no
 $endpage="1";
-$products_per_page="6";
 
 $id = $_REQUEST['record'];
 //retreiving the vtiger_invoice info
@@ -53,6 +53,7 @@
 $bill_state = $focus->column_fields["bill_state"];
 $bill_code = $focus->column_fields["bill_code"];
 $bill_country = $focus->column_fields["bill_country"];
+$contact_name =getContactName($focus->column_fields["contact_id"]);
 
 $ship_street = $focus->column_fields["ship_street"];
 $ship_city = $focus->column_fields["ship_city"];
@@ -60,8 +61,8 @@
 $ship_code = $focus->column_fields["ship_code"];
 $ship_country = $focus->column_fields["ship_country"];
 
-$conditions = $focus->column_fields["terms_conditions"];
-$description = $focus->column_fields["description"];
+$conditions = from_html($focus->column_fields["terms_conditions"]);
+$description = from_html($focus->column_fields["description"]);
 $status = $focus->column_fields["sostatus"];
 
 // Company information
@@ -140,7 +141,11 @@
 if($discount_amount != "")
 	$price_discount = number_format($discount_amount,2,'.',',');
 else if($discount_percent != "")
-	$price_discount = $discount_percent."%";
+{
+	//This will be displayed near Discount label - used in include/fpdf/templates/body.php
+	$final_price_discount_percent = "(".number_format($discount_percent,2,'.',',')." %)";
+	$price_discount = number_format((($discount_percent*$focus->column_fields["hdnSubTotal"])/100),2,'.',',');
+}
 else
 	$price_discount = "0.00";
 
@@ -198,6 +203,8 @@
 	$list_price[$i] = number_format($associated_products[$i]['listPrice'.$i],2,'.',',');
 	$list_pricet[$i] = $associated_products[$i]['listPrice'.$i];
 	$discount_total[$i] = $associated_products[$i]['discountTotal'.$i];
+        //aded for 5.0.3 pdf changes
+        $product_code[$i] = $associated_products[$i]['hdnProductcode'.$i];
 	
 	$taxable_total = $qty[$i]*$list_pricet[$i]-$discount_total[$i];
 
@@ -219,12 +226,47 @@
 	}
 	$prod_total[$i] = number_format($producttotal,2,'.',',');
 
+        $product_line[$j]["Product Code"] = $product_code[$i];
 	$product_line[$j]["Product Name"] = $product_name[$i];
-	$product_line[$j]["Description"] = $prod_description[$i];
 	$product_line[$j]["Qty"] = $qty[$i];
 	$product_line[$j]["Price"] = $list_price[$i];
 	$product_line[$j]["Discount"] = $discount_total[$i];
 	$product_line[$j]["Total"] = $prod_total[$i];
+
+	// Product piecelists
+	$query = "SELECT vtiger_crmentity.crmid,
+	    vtiger_products.productname as productname,
+	    vtiger_products2products_rel.related_productid as prodid,
+	    vtiger_products2products_rel.quantity as quantity,
+	    vtiger_products2products_rel.product_relgroup as product_relgroup
+	    FROM vtiger_products2products_rel
+	    INNER JOIN vtiger_products
+		ON vtiger_products.productid = vtiger_products2products_rel.related_productid
+	    INNER JOIN vtiger_crmentity
+		ON vtiger_crmentity.crmid = vtiger_products.productid
+	    WHERE vtiger_crmentity.deleted = 0
+	    AND vtiger_products2products_rel.productid = ".$product_id[$i]."
+	    AND vtiger_products2products_rel.relation_type = 10";
+	$result = $adb->query($query);
+	$pieces = $adb->num_rows($result);
+	if( $pieces > 0) {
+	    $product_line[++$j]["Product Name"] = "";
+	    $product_line[$j]["Description"] = "consisting of:";
+	    $product_line[$j]["Qty"] = "";
+	    $product_line[$j]["Price"] = "";
+	    $product_line[$j]["Discount"] = "";
+	    $product_line[$j]["Total"] = "";
+	    for( $pl=0; $pl<$pieces; $pl++) {
+	        $product_line[++$j]["Product Name"] = "";
+		$product_line[$j]["Description"] =
+		    $adb->query_result( $result, $pl, "productname");
+		$product_line[$j]["Qty"] =
+		    $adb->query_result( $result, $pl, "quantity");
+		$product_line[$j]["Price"] = "";
+		$product_line[$j]["Discount"] = "";
+		$product_line[$j]["Total"] = "";
+	    }
+	}
 }
 //echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>';
 //echo '<pre>';print_r($associated_products);echo '</pre>';
@@ -239,7 +281,7 @@
 $pdf = new PDF( 'P', 'mm', 'A4' );
 $pdf->Open();
 
-$num_pages=ceil(($num_products/$products_per_page));
+$num_pages=ceil(count($product_line)/$products_per_page);
 
 
 $current_product=0;
@@ -255,16 +297,22 @@
 		$current_product++;
 	}
 
+	//if bottom > 145 then we skip the Description and T&C in every
+	//page and display only in lastpage
+	//if you want to display the description and T&C in each page then
+	//set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php
 	$pdf->AddPage();
 	if( $page_num == "1") {
-	    include("pdf_templates/".$template."/firstpage/header.php");
-	    include("pdf_templates/".$template."/firstpage/body.php");
-	    include("pdf_templates/".$template."/firstpage/footer.php");
-	} else {
-	    include("pdf_templates/".$template."/pages/header.php");
-	    include("pdf_templates/".$template."/pages/body.php");
-	    include("pdf_templates/".$template."/pages/footer.php");
-	}
+ 	    include("pdf_templates/".$template."/firstpage/header.php");
+ 	    include("pdf_templates/".$template."/firstpage/body.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/firstpage/footer.php");
+ 	} else {
+ 	    include("pdf_templates/".$template."/pages/header.php");
+ 	    include("pdf_templates/".$template."/pages/body.php");
+	    if($display_desc_tc == 'true' && $bottom <= 145)
+		include("pdf_templates/".$template."/pages/footer.php");
+ 	}
 
 	$page_num++;
 

Modified: vtigercrm/branches/5.1_jens/modules/SalesOrder/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/SalesOrder/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/SalesOrder/DetailView.php Mon Apr 16 12:27:44 2007
@@ -100,6 +100,8 @@
 $smarty->assign("CHECK", $check_button);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
 
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);

Modified: vtigercrm/branches/5.1_jens/modules/SalesOrder/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/SalesOrder/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/SalesOrder/EditView.php Mon Apr 16 12:27:44 2007
@@ -309,14 +309,15 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 $organization = new Organization;
 $organization->id = $current_organization;
 $smarty->assign("ASSIGN_ORGUNIT_LIST", getOrgUnits($organization));
 
 if($focus->mode == 'edit')
-	$smarty->display("Inventory/InventoryEditView.tpl");
+    $smarty->display("Inventory/InventoryEditView.tpl");
 else
-	$smarty->display('Inventory/InventoryCreateView.tpl');
+    $smarty->display('Inventory/InventoryCreateView.tpl');
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/SalesOrder/SalesOrder.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/SalesOrder/SalesOrder.php (original)
+++ vtigercrm/branches/5.1_jens/modules/SalesOrder/SalesOrder.php Mon Apr 16 12:27:44 2007
@@ -95,6 +95,7 @@
 	//Added these variables which are used as default order by and sortorder in ListView
 	var $default_order_by = 'subject';
 	var $default_sort_order = 'ASC';
+	var $groupTable = Array('vtiger_sogrouprelation','salesorderid');
 
 
 	/** Constructor Function for SalesOrder class
@@ -118,10 +119,12 @@
         		$this->db->query($query1);
 		}
 
-		//Based on the total Number of rows we will save the product relationship with this entity
-		saveInventoryProductDetails(&$this, 'SalesOrder');	
-
-		
+		//in ajax save we should not call this function, because this will delete all the existing product values
+		if($_REQUEST['action'] != 'SalesOrderAjax' && $_REQUEST['ajxaction'] != 'DETAILVIEW')
+		{
+			//Based on the total Number of rows we will save the product relationship with this entity
+			saveInventoryProductDetails(&$this, 'SalesOrder');	
+		}
 	}	
 	
 	/**	Function used to get the sort order for Sales Order listview
@@ -173,7 +176,7 @@
 		else
 			$returnset = '&return_module=SalesOrder&return_action=CallRelatedList&return_id='.$id;
 
-		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_users.user_name from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL AND vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL AND vtiger_activity.status !='Deferred')";
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid, vtiger_activity.*,vtiger_seactivityrel.*,vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_activity inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_crmentity.crmid left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname where vtiger_seactivityrel.crmid=".$id." and activitytype='Task' and vtiger_crmentity.deleted=0 and (vtiger_activity.status is not NULL and vtiger_activity.status != 'Completed') and (vtiger_activity.status is not NULL and vtiger_activity.status !='Deferred')";
 		$log->debug("Exiting get_activities method ...");
 		return GetRelatedList('SalesOrder','Calendar',$focus,$query,$button,$returnset);
 	}
@@ -186,17 +189,15 @@
 	{
 		global $log;
 		$log->debug("Entering get_history(".$id.") method ...");
-		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,
-			vtiger_activity.*, vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,
-			vtiger_crmentity.createdtime, vtiger_crmentity.description, vtiger_users.user_name
+		$query = "SELECT vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.contactid,vtiger_activity.*, vtiger_seactivityrel.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime,	vtiger_crmentity.createdtime, vtiger_crmentity.description, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
 			from vtiger_activity
 				inner join vtiger_seactivityrel on vtiger_seactivityrel.activityid=vtiger_activity.activityid
 				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid
 				left join vtiger_cntactivityrel on vtiger_cntactivityrel.activityid= vtiger_activity.activityid
 				left join vtiger_contactdetails on vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
-				inner join vtiger_users on vtiger_crmentity.smcreatorid=vtiger_users.id
 				left join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid
                                 left join vtiger_groups on vtiger_groups.groupname=vtiger_activitygrouprelation.groupname
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
 			where activitytype='Task'
 				and (vtiger_activity.status = 'Completed' or vtiger_activity.status = 'Deferred')
 				and vtiger_seactivityrel.crmid=".$id;
@@ -264,8 +265,16 @@
 		else
 			$returnset = '&return_module=SalesOrder&return_action=CallRelatedList&return_id='.$id;
 
-
-		$query = "select vtiger_crmentity.*, vtiger_invoice.*, vtiger_account.accountname, vtiger_salesorder.subject as salessubject from vtiger_invoice inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid left outer join vtiger_account on vtiger_account.accountid=vtiger_invoice.accountid inner join vtiger_salesorder on vtiger_salesorder.salesorderid=vtiger_invoice.salesorderid left join vtiger_invoicegrouprelation on vtiger_invoice.invoiceid=vtiger_invoicegrouprelation.invoiceid left join vtiger_groups on vtiger_groups.groupname=vtiger_invoicegrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_salesorder.salesorderid=".$id;
+			$query = "select vtiger_crmentity.*, vtiger_invoice.*, vtiger_account.accountname, vtiger_salesorder.subject as salessubject, case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name
+				from vtiger_invoice 
+				inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid 
+				left outer join vtiger_account on vtiger_account.accountid=vtiger_invoice.accountid 
+				inner join vtiger_salesorder on vtiger_salesorder.salesorderid=vtiger_invoice.salesorderid 
+				left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid
+				left join vtiger_invoicegrouprelation on vtiger_invoice.invoiceid=vtiger_invoicegrouprelation.invoiceid 
+				left join vtiger_groups on vtiger_groups.groupname=vtiger_invoicegrouprelation.groupname 
+				where vtiger_crmentity.deleted=0 and vtiger_salesorder.salesorderid=".$id;
+
 		$log->debug("Exiting get_invoices method ...");
 		return GetRelatedList('SalesOrder','Invoice',$focus,$query,$button,$returnset);
 	

Modified: vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/Default/_default/header.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/Default/_default/header.php (original)
+++ vtigercrm/branches/5.1_jens/modules/SalesOrder/pdf_templates/Default/_default/header.php Mon Apr 16 12:27:44 2007
@@ -51,7 +51,7 @@
 $pdf->addTextBlock( "Shipping Address:", $shipText, $shipLocation );
 
 // billing Address
-$billPositions = array("147","43","60");
+$billPositions = array("147","40","60");
 $billText=$bill_street."\n".$bill_city.", ".$bill_state." ".$bill_code."\n".$bill_country;
 $pdf->addTextBlock("Billing Address:",$billText, $billPositions);
 // ********** End Addresses ******************
@@ -59,17 +59,26 @@
 
 
 /*  ******** Begin Invoice Data ************************ */ 
+
+// issue date block
+$issueBlock=array("80","37");
+$pdf->addRecBlock(date("Y-m-d"), "Issue Date",$issueBlock);
+
+// due date block
+$dueBlock=array("81","52");
+$pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
+
 // terms block
-$termBlock=array("10","65");
+$termBlock=array("10","67");
 $pdf->addRecBlock($account_name, "Customer Name", $termBlock);
 
-// due date block
-$dueBlock=array("80","65");
-$pdf->addRecBlock($valid_till, "Due Date",$dueBlock);
+// Contact Name block
+$conBlock=array("79","67");
+$pdf->addRecBlock($contact_name, "Contact Name",$conBlock);
 
 // vtiger_invoice number block
-$invBlock=array("145","65");
-$pdf->addRecBlock($id, "Invoice Number",$invBlock);
+$invBlock=array("145","67");
+$pdf->addRecBlock($id, "Sales Order Number",$invBlock);
 
 /* ************ End Invoice Data ************************ */
 

Modified: vtigercrm/branches/5.1_jens/modules/Settings/AddCustomFieldToDB.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/AddCustomFieldToDB.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/AddCustomFieldToDB.php Mon Apr 16 12:27:44 2007
@@ -61,7 +61,7 @@
 		$fldPickList='';
 	}
 	
-	header("Location:index.php?module=Settings&action=CustomFieldList&fld_module=".$fldmodule."&fldType=".$fldType."&fldlabel=".$fldlabel."&fldlength=".$fldlength."&flddecimal=".$flddecimal."&fldPickList=".$fldPickList."&parenttab=".$parenttab."&duplicate=yes");
+	header("Location:index.php?module=Settings&action=CustomFieldList&fld_module=".$fldmodule."&fldType=".$fldType."&fldlabel=".$fldlabel."&parenttab=".$parenttab."&duplicate=yes");
 
 }
 else

Modified: vtigercrm/branches/5.1_jens/modules/Settings/CreateCustomField.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/CreateCustomField.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/CreateCustomField.php Mon Apr 16 12:27:44 2007
@@ -142,7 +142,7 @@
 		<table width="100%" border="0" cellpadding="5" cellspacing="0" class="layerHeadingULine">
 			<tr>';
 			if($mode == 'edit')
-				$output .= '<td width="60%" align="left" class="layerPopupHeading">'.$mod_strings['LBL_EDIT_FIELD_TYPE'].' - '.$mod_strings[$customfield_typename].'</td>';
+				$output .= '<td width="60%" align="left" class="layerPopupHeading">'.$mod_strings['LBL_EDIT_FIELD_TYPE'].' - '.$customfield_typename.'</td>';
 			else
 				$output .= '<td width="60%" align="left" class="layerPopupHeading">'.$mod_strings['LBL_ADD_FIELD'].'</td>';
 				

Modified: vtigercrm/branches/5.1_jens/modules/Settings/DeleteCustomField.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/DeleteCustomField.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/DeleteCustomField.php Mon Apr 16 12:27:44 2007
@@ -49,7 +49,10 @@
 $dbquery = 'alter table '.$delete_module_tables[$fld_module].' drop column '.$colName;
 $adb->query($dbquery);
 
+//To remove customfield entry from vtiger_field table
+$dbquery = 'delete from vtiger_field where tablename= "'.$delete_module_tables[$fld_module].'" and fieldname="'.$colName.'"';
 
+$adb->query($dbquery);
 //we have to remove the entries in customview and report related tables which have this field ($colName)
 $adb->query("delete from vtiger_cvcolumnlist where columnname like '%".$colName."%'");
 $adb->query("delete from vtiger_cvstdfilter where columnname like '%".$colName."%'");

Modified: vtigercrm/branches/5.1_jens/modules/Settings/EmailConfig.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/EmailConfig.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/EmailConfig.php Mon Apr 16 12:27:44 2007
@@ -19,9 +19,10 @@
 {
         require_once("modules/Emails/mail.php");
         $error_msg = strip_tags(parseEmailErrorString($_REQUEST['mail_error']));
-	if(strstr($error_msg,"Please check the assigned to user email id"))
-		$error_msg = "Mail could not be sent to the admin user. Please check the admin user email id.";
-	$smarty->assign("ERROR_MSG",'<b><font color="red">Test Mail status : '.$error_msg.'</font></b>');
+	//if(strstr($error_msg,"Please check the assigned to user email id"))
+	if(strstr($error_msg,$mod_strings['LBL_CHECK_ASSIGNEDTO_MAILID']))
+		$error_msg = $mod_strings['LBL.MAILSENDERROR'];
+	$smarty->assign("ERROR_MSG",$mod_strings['LBL_TESTMAILSTATUS'].' <b><font color=red>     '.$error_msg.'</font></b>');
 }
 
 global $adb;

Modified: vtigercrm/branches/5.1_jens/modules/Settings/ListMailAccount.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/ListMailAccount.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/ListMailAccount.php Mon Apr 16 12:27:44 2007
@@ -131,7 +131,7 @@
                 }
                 else
                 {
-                        alert("Please select at least one entity");
+                        alert(alert_arr.SELECT);
                         return false;
                 }
         }
@@ -153,7 +153,7 @@
                 }
                 else
                 {
-                        alert("Please select at least one entity");
+                        alert(alert_arr.SELECT);
                         return false;
                 }
         }

Modified: vtigercrm/branches/5.1_jens/modules/Settings/ProxyServerConfig.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/ProxyServerConfig.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/ProxyServerConfig.php Mon Apr 16 12:27:44 2007
@@ -21,7 +21,7 @@
 $smarty = new vtigerCRM_Smarty;
 if($_REQUEST['error'] != '')
 {
-		$smarty->assign("ERROR_MSG",'<b><font color="purple">'.$_REQUEST["error"].'</font></b>');
+		$smarty->assign("ERROR_MSG",'<b><font color="red">'.$mod_strings[$_REQUEST["error"]].'</font></b>');
 }
 $sql="select * from vtiger_systems where server_type = 'proxy'";
 $result = $adb->query($sql);

Modified: vtigercrm/branches/5.1_jens/modules/Settings/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/Save.php Mon Apr 16 12:27:44 2007
@@ -10,6 +10,8 @@
  ********************************************************************************/
 
 require_once("include/database/PearDatabase.php");
+global $mod_strings;
+
 $server=$_REQUEST['server'];
 $port=$_REQUEST['port'];
 $server_username=$_REQUEST['server_username'];
@@ -45,7 +47,7 @@
 		
 		if(substr_count($proxy_cont, "Cache Access Denied") > 0)
 		{
-			$error_str = 'error=Proxy Authentication Required';
+			$error_str = 'error=LBL_PROXY_AUTHENTICATION_REQUIRED';
 			$db_update = false;
 		}
 		else
@@ -100,7 +102,7 @@
 	$to_email = getUserEmailId('id',$current_user->id);
 	$from_email = $to_email;
 	$subject = 'Test mail about the mail server configuration.';
-	$description = 'Dear '.$current_user->user_name.', <br><br> This is a test mail sent to confirm if a mail is actually being sent through the vtiger system. You are free to delete this mail.<br> Thanks  and  Regards<br> Team vTiger <br><br>';
+	$description = 'Dear '.$current_user->user_name.', <br><br><b> This is a test mail sent to confirm if a mail is actually being sent through the smtp server that you have configured. </b><br>Feel free to delete this mail.<br><br>Thanks  and  Regards,<br> Team vTiger <br><br>';
 	if($to_email != '')
 	{
 		$mail_status = send_mail('Users',$to_email,$current_user->user_name,$from_email,$subject,$description);
@@ -115,5 +117,14 @@
 	if($mail_status != 1)
 		$action = 'EmailConfig&emailconfig_mode=edit';
 }
-header("Location: index.php?module=Settings&parenttab=Settings&action=$action&$error_str");
+//While configuring Proxy settings, the submitted values will be retained when exception is thrown - dina
+if($server_type == 'proxy' && $error_str == 'error=LBL_PROXY_AUTHENTICATION_REQUIRED')
+{
+        header("Location: index.php?module=Settings&parenttab=Settings&action=$action&server=$server&port=$port&server_username=$server_username&$error_str");
+}
+else
+{
+        header("Location: index.php?module=Settings&parenttab=Settings&action=$action&$error_str");
+}
+
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Settings/SettingsAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/SettingsAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/SettingsAjax.php Mon Apr 16 12:27:44 2007
@@ -13,5 +13,25 @@
 {
 	require_once('modules/Settings/'.$_REQUEST['file'].'.php');
 }
+if(isset($_REQUEST['orgajax']) && ($_REQUEST['orgajax'] !=''))
+{
+        require_once('modules/Settings/CreateSharingRule.php');
+}
+elseif(isset($_REQUEST['announce_save']) && ($_REQUEST['announce_save'] != ''))
+{
+        $date_var = date('YmdHis');
+        $announcement = $_REQUEST['announcement'];
+	//Change ##$## to & (reverse process has done in Smarty/templates/Settings/Announcements.tpl)
+	$announcement = str_replace("##$##","&",$announcement);
 
+        $title = $_REQUEST['title_announcement'];
+        $sql="select * from vtiger_announcement where creatorid=".$current_user->id;
+        $is_announce=$adb->query($sql);
+        if($adb->num_rows($is_announce) > 0)
+                $query="update vtiger_announcement set announcement=".$adb->formatString("vtiger_announcement","announcement",$announcement).",time=".$adb->formatString("vtiger_announcement","time",$date_var).",title='announcement' where creatorid=".$current_user->id;
+        else
+                $query="insert into vtiger_announcement values (".$current_user->id.",".$adb->formatString("vtiger_announcement","announcement",$announcement).",'announcement',".$adb->formatString("vtiger_announcement","time",$date_var).")";
+        $result=$adb->query($query);
+        echo $announcement;
+}
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Settings/UpdateComboValues.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/UpdateComboValues.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/UpdateComboValues.php Mon Apr 16 12:27:44 2007
@@ -38,7 +38,7 @@
 if($tabname[1]!='')
        	$custom=true;
 
-for($i = 0; $i < $count; $i++)
+/*for($i = 0; $i < $count; $i++)
 {
 	$pickArray[$i] = trim($pickArray[$i]);
 	if($pickArray[$i] != '')
@@ -50,6 +50,20 @@
 
 	        $adb->query($query);
 	}
-}
+}*/
+/* ticket2369 fixed */
+$columnName = $tableName;
+foreach ($pickArray as $index => $data) {
+        $data = trim($data);
+        if(!empty($data)){
+		$data = $adb->formatString("vtiger_$tableName",$columnName,$data);
+		if($uitype == 111)
+			$query = "insert into vtiger_$tableName values('',$data,$index,0)";
+		else
+			$query = "insert into vtiger_$tableName values('',$data,$index,1)";
+		$adb->query($query);
+        }
+} 
+
 header("Location:index.php?action=SettingsAjax&module=Settings&directmode=ajax&file=PickList&fld_module=".$fld_module);
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Settings/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Settings/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Settings/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -139,7 +139,6 @@
 
 //Settings/index.php
 
-'LBL_CUSTOM_FIELD_SETTINGS'=>'Custom Field Settings:',
 
 'LBL_PICKLIST_FIELD_SETTINGS'=>'Picklist Field Settings:',
 
@@ -193,7 +192,6 @@
 
 'PicklistFields'=>' Picklist Fields',
 
-'LBL_PICKLIST_EDITOR'=>'Picklist Editor',
 
 'Edit'=>'Edit',
 
@@ -340,8 +338,6 @@
 
 'LBL_CURRENCY_SETTINGS'=>'Currencies',
 
-'LBL_YES'=>'yes',
-'LBL_NO'=>'no',
 
 'LBL_USERNAME'=>'User Name',
 'LBL_PASWRD'=>'Password',
@@ -358,7 +354,6 @@
 
 'LBL_CREATE_AND_MANAGE_USERS'=>'- Create and Manage Users (e.g., admin)',
 
-'LBL_ROLES'=>'Roles',
 
 'LBL_CREATE_AND_MANAGE_USER_ROLES'=>'- Create and Manage user roles (e.g., Administrator, Standard User, etc.)',
 
@@ -561,7 +556,7 @@
 'LBL_3_MIN'=>'3 minutes',
 'LBL_4_MIN'=>'4 minutes',
 'LBL_5_MIN'=>'5 minutes',
-'LBL_EMAILS_PER_PAGE'=>'Emails per Page',
+'LBL_EMAILS_PER_PAGE'=>'Email per Page',
 
 //Added for Organization Details (4.2 release)
 'LBL_ORGANIZATION_NAME'=>'Company Name',
@@ -725,7 +720,202 @@
 'LBL_ENABLE'=>'Enable',
 'LBL_FAQ_FIELD_ACCESS'=>'Faq Field Access',
 'LBL_ADD_TAX_BUTTON'=>'Add Tax',
+'LBL_NO_TAXES_AVAILABLE'=>'No taxes available',
+'LBL_PLEASE'=>'Please',
+//Added while moving role file from User to Setting Module
+'LBL_ROLES'=>'Roles',
+'LBL_CREATE_NEW_ROLE'=>'Create New Role',
+'LBL_PROPERTIES'=>'Properties of',
+'LBL_NEW_ROLE'=>'New Role',
+'LBL_ROLE_NAME'=>'Role Name',
+'LBL_REPORTS_TO'=>'Reports to',
+'LBL_PROFILE_M'=>'Profile',
+'LBL_PROFILES_AVLBL'=>'Profiles Available',
+'LBL_ASSIGN_PROFILES'=>'Assigned Profiles',
+'LBL_MEMBER'=>'Members',
+'LBL_DELETE_ROLE'=>'Delete Role',
+'LBL_ROLE_TO_BE_DELETED'=>'Role to be Deleted',
+'LBL_TRANSFER_USER_ROLE'=>'Transfer Users to Role',
+'LBL_ASSOCIATED_PROFILES'=>'Associated Profiles :',
+'LBL_ASSOCIATED_USERS'=>'Associated Users :',
+//Added while moving email templates from Users to Settings
+'LBL_EMAIL_TEMPLATES'=>'Email Templates',
+'LBL_EMAIL_TEMPLATE_DESC'=>'Manage email templates used for Campaigns and Mass mailing',
+'LBL_LIST_SELECT'=>'Select',
+'LBL_EMAIL_TEMPLATE'=>'Email Template',
+'LBL_TEMPLATE_TOOLS'=>'Tools',
+'LBL_NEW_TEMPLATE' =>'New Template',
+'LBL_FOLDER'=>'Folder',
+'LBL_NAME'=>'Name',
+'LBL_PERSONAL'=>'Personal',
+'LBL_PUBLIC'=>'Public',
+'LBL_ACCOUNT_FIELDS'=>'Account Fields',
+'LBL_CONTACT_FIELDS'=>'Contact Fields',
+'LBL_LEAD_FIELDS'=>'Lead Fields',
+'LBL_USER_FIELDS'=>'User Fields',
+'LNK_SAMPLE_EMAIL'=>'View Sample Email',
+//Added while moving Mail Merge templates from Users to Settings
+'LBL_TEMPLATE_FILE'=>'Template File',
+'LBL_MODULENAMES'=>'Module',
+'LBL_DOWNLOAD'=>'Download',
+'LBL_ADD_TEMPLATE'=>'Add Template',
+'LBL_WORD_TEMPLATES'=>'Mail Merge Templates',
+//Added while moving Notification Schedulers from Users to Settings
+'LBL_TASK_NOTIFICATION'=>'Delayed Task Notification',
+'LBL_BIG_DEAL'=>'Big Deal Notification',
+'LBL_PENDING_TICKETS'=>'Pending Tickets Notification',
+'LBL_MANY_TICKETS'=>'Too many tickets  Notification',
+'LBL_START_NOTIFICATION'=>'Support Start Notification',
+'LBL_SUPPORT_NOTICIATION'=>'Support End Notification',
+'LBL_ACTIVITY_NOTIFICATION'=>'Event Reminder Notification',
+
+'LBL_TASK_NOTIFICATION_DESCRITPION'=>'Notify when a task is delayed beyond 24 hrs',
+'LBL_BIG_DEAL_DESCRIPTION'=>'Notify on completion of big deal',
+'LBL_TICKETS_DESCRIPTION'=>'Notify for getting attention to status of tickets which are pending',
+'LBL_MANY_TICKETS_DESCRIPTION'=>'Notify when a particular entity is allocated too many tickets, might reflect Service Level commitments',
+'LBL_START_DESCRIPTION'=>'Notifiy stating the start of support/service',
+'LBL_SUPPORT_DESCRIPTION'=>'Notify when support is about to end',
+'LBL_ACTIVITY_REMINDER_DESCRIPTION'=>'Notify before an event to occur based on the reminder set',
+//Added while moving Inventory Notifications from Users to Settings
+'QuoteNotificationDescription'=>'During quote generation if the product stock in warehouse is lesser than the  quantity mentioned in quote then this notification will be sent to the product handler',
+'SalesOrderNotificationDescription'=>'During sales order generation if the product stock in warehouse is lesser than the quantity mentioned in sales order then this notification will be sent to the product handler',
+'Tools'=>'Tools',
+'QuoteNotification'=>'Product Stock Notification during Quote Generation',
+'SalesOrderNotification'=>'Product Stock Notification during Sales Order Generation',
+'LBL_NOTE_DO_NOT_REMOVE_INFO'=>'Note: Donot remove or alter the values within {  }',
+
+//Added while moving Profile file from User to Setting Module
+'LBL_TOTAL'=>'Total :',
+'LBL_NEW_PROFILE'=>'New Profile',
+'LBL_LIST_NO'=>'#',
+'LBL_NEW_PROFILE_NAME'=>'Profile Name',
+'LBL_LIST_TOOLS'=>'Tools',
+'LBL_PROFILE_MESG'=>'Viewing access privileges for',
+'LBL_PROFILE_PRIVILEGES'=>'Profile Privileges',
+'LBL_DEFINE_PRIV_FOR'=>' Define Privileges for ',
+'LBL_USE_OPTION_TO_SET_PRIV'=>'Use the options below to set privileges',
+'LBL_SUPER_USER_PRIV'=>'Global Privileges',
+'LBL_SET_PRIV_FOR_EACH_MODULE'=>'Set Privileges for each Module ',
+'LBL_FIELDS_AND_TOOLS_SETTINGS'=>'Fields & Tools Settings',
+'LBL_VIEW_ALL'=>'View all',
+'LBL_EDIT_ALL'=>'Edit all',
+'LBL_ALLOW'=>'Allows',
+'LBL_MESG_VIEW'=>'to view all information / modules of vtiger CRM',
+'LBL_MESG_EDIT'=>'to edit all information / modules of vtiger CRM',
+'LBL_TAB_MESG_OPTION'=>'modules to be shown',
+'LBL_CREATE_EDIT'=>'Create/Edit',
+'LBL_VIEW'=>'View',
+'LBL_MANDATORY_MSG'=>'Mandatory Fields',
+'LBL_DISABLE_FIELD_MSG'=>'Fields Disabled from Global Field Access Settings',
+'LBL_DELETE'=>'Delete',
+
+'LBL_STEP_2_2'=>'Step 2 of 2',
+'LBL_FINISH_BUTTON'=>'Finish',
+
+//Added while moving Groups file from User to Setting Module
+'LBL_NEW_GROUP'=>'New Group',
+'LBL_GROUPS'=>'Groups',
+'LBL_GROUP_NAME'=>'Group Name',
+'LBL_ROLES_SUBORDINATES'=>'Roles and Subordinates',
+'LBL_MEMBER_AVLBL'=>'Available Entities & Members',
+'LBL_MEMBER_SELECTED'=>'Selected Members',
+'LBL_ENTITY'=>'Entity',
+'LBL_OF'=>'of',
+'LBL_CREATE_NEW_GROUP'=>'Create New Group',
+'LBL_ADD_GROUP_BUTTON'=>'Add Group',
+'LBL_GROUP_MESG1'=>'Groups are a flexible way to assign access rights, when complex access rights has to be defined. You can combine multiple entities like Roles, Users, profiles etc into a single group.',
+'LBL_GROUP_MESG2'=>'To add, select the Entity members from left and click the ">>" button.',
+'LBL_GROUP_MESG3'=>'To remove, select the group members from the right and click the "<<" button.',
+
+//Sharing Privileges
+'LBL_GLOBAL_ACCESS_PRIVILEGES'=>'Organization-level Sharing Rules',
+'LBL_RECALCULATE_BUTTON'=>'Recalculate',
+'LBL_CHANGE'=>'Change',
+'LBL_PRIVILEGES'=>'Privileges',
+'LBL_CUSTOM_ACCESS_PRIVILEGES'=>'Custom Sharing Rules',
+'LBL_ADD_PRIVILEGES_BUTTON'=>'Add Privileges',
+'LBL_RULE_NO'=>'Rule No.',
+'LBL_CAN_BE_ACCESSED'=>'can be accessed by',
+'LBL_CUSTOM_ACCESS_MESG'=>'No Custom Access Rules defined .',
+'LNK_CLICK_HERE'=>'Click here',
+'LBL_CREATE_RULE_MESG'=>'to create a new Rule',
+'LBL_RECALC_MSG'=>'Are you sure, you wish to Recalculate Sharing Access?',
+'LBL_YES'=>'Yes',
+'LBL_NO'=>'No',
+'LBL_IN_PERMISSION'=>'in the permission',
+'LBL_RELATED_MODULE_RIGHTS'=>'Related Module Rights',
+'LBL_USR_CAN_ACCESS'=>'Users can ',
+'LBL_USR_OTHERS'=>' other users ',
+'LBL_USR_CANNOT_ACCESS'=>'Users cannot access other users ',
+ 
+'LBL_ORG_SHARING_PRIVILEGES'=>'Organisation Sharing  Privileges',
+'LBL_EDIT_PERMISSIONS'=>'Edit Permissions',
+'LBL_SAVE_PERMISSIONS'=>'Save Permissions',
+'LBL_READ_ONLY'=>'Public: Read Only',
+'LBL_EDIT_CREATE_ONLY'=>'Public: Read, Create/Edit',
+'LBL_READ_CREATE_EDIT_DEL'=>'Public: Read, Create/Edit, Delete',
+'LBL_PRIVATE'=>'Private',
+ 
+'Public: Read Only'=>'Public: Read Only',
+'Public: Read, Create/Edit'=>'Public: Read, Create/Edit',
+'Public: Read, Create/Edit, Delete'=>'Public: Read, Create/Edit, Delete',
+'Private'=>'Private',
+'Hide Details'=>'Hide Details',
+'Hide Details and Add Events'=>'Hide Details and Add Events',
+'Show Details'=>'Show Details',
+'Show Details and Add Events'=>'Show Details and Add Events',
+
+//Added for User Login History While moving from User to Settings
+'LBL_LOGIN_HISTORY'=>'Login History',
+//Sharing Access module moved to Setting
+'Read/Write'=>'Read/Write',
+'Read Only '=>'Read Only ',
+'LBL_GROUP'=>'Group',
+'LBL_ACCESS_RIGHTS_FOR_MODULES'=>'Access rights for relative modules',
+'LBL_ADD_RULE'=>'Add Rule',
+'LBL_ADD_CUSTOM_RULE'=>'Add Custom Privilege Rule',
+'LBL_RULE_CONSTRUCTION'=>'Rule Construction Display',
+'LBL_STEP'=>'Step',
+'LBL_SELECT_ENTITY'=>'Select an entity below',
+'LBL_CAN_BE_ACCESSED_BY'=>'Can be accessed by',
+'LBL_PERMISSIONS'=>'Permissions',
+'LBL_DOC_MSWORD'=>'File has to be a Document of type doc/msword',
+'LBL_NODOC'=>'No doc File in this directory.Please try again!',
+
+//Added for error messages on Company Info.
+'LOGO_ERROR'=>'Logo has to be an Image of type jpeg/png',
+'Error_Message'=>'Error Message',
+'Invalid_file'=>'Invalid file OR',
+'File_has_no_data'=>'File has no data',
+'Sorry'=>'Sorry',
+'uploaded_file_exceeds_maximum_limit'=>'the uploaded file exceeds the maximum vtiger_filesize limit',
+'try_file_smaller'=>'Please try a file smaller than 800000 bytes',
+'Problems_in_upload'=>'Problems in file upload',
+'Please_try_again'=>'Please try again!',
+//5.0.3 fixes
+'LBL_TESTMAILSTATUS'=>'Test Mail Status : ',
+'LBL_CHECK_ASSIGNEDTO_MAILID'=>'Please check the assigned-to emailid',
+'LBL_MAILSENDERROR'=>'Mail could not be sent to the admin user. Please check the admin emailid',
+'LBL_RECORD_NOEXIST'=>'Record not present',
+'LBL_ENTER_PROFILE'=>'Enter Profile Name',
+'LBL_ENABLE'=>'Enable',
+'LBL_DISABLE'=>'Disable',
+'LBL_PROXY'=>'proxy',
+'LBL_FIELDS_TO_BE_SHOWN'=>'Fields to be shown',
+//Added for alerts
+'SPECIFY_FILE_TO_MERGE' => 'Please Specify a File to Merge',
+'FILESIZE_EXCEEDS_INFO' => 'Sorry, the uploaded file exceeds the maximum filesize limit. Please try a smaller file',
+'PROBLEMS_IN_FILEUPLOAD' => 'Problems in file upload. Please try again!',
+
+//Added fields for Invoice Number labels
+'LBL_CUSTOMIZE_INVOICE_NUMBER'=>'Customize Invoice Number',
+'LBL_CUSTOMIZE_INVOICE_NUMBER_DESCRIPTION'=>'Invoice Number Customization',
+'LBL_CUSTOM_INVOICE_NUMBER_VIEW'=>'Invoice Number Customization',
+'LBL_CUSTOMINVOICE_STRING'=>'Custom Invoice String',
+'LBL_CUSTOMINVOICE_NUMBER'=>'Custom Invoice Number',
+'LBL_INVOICE_NUMBER_PREVIEW'=>'Preview',
+'LBL_INVOICE_NUMBER_BUTTON'=>'Update Invoice Number',
+'LBL_PROXY_AUTHENTICATION_REQUIRED'=>'Proxy Authentication Required',
+
 );
-
-
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/System/includes/system_header.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/System/includes/system_header.php (original)
+++ vtigercrm/branches/5.1_jens/modules/System/includes/system_header.php Mon Apr 16 12:27:44 2007
@@ -18,13 +18,14 @@
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 // $Id: system_header.php,v 1.27 2005/12/10 15:54:41 bigmichi1 Exp $
+global $app_strings;
 if (!defined('IN_PHPSYSINFO')) {
     die("No Hacking");
 }
 
 @header("Cache-Control: no-cache, must-revalidate");
 if (!isset($charset)) {
-  $charset = 'iso-8859-1';
+  $charset = $app_strings['LBL_CHARSET'];
 } 
 
 setlocale (LC_ALL, $text['locale']);

Modified: vtigercrm/branches/5.1_jens/modules/System/systemconfig.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/System/systemconfig.php (original)
+++ vtigercrm/branches/5.1_jens/modules/System/systemconfig.php Mon Apr 16 12:27:44 2007
@@ -16,6 +16,7 @@
 // phpsysinfo release version number
 $VERSION = "2.5.2_rc2";
 $startTime = array_sum( explode( " ", microtime() ) );
+global $app_strings;
 
 
 define('IN_PHPSYSINFO', true);
@@ -137,7 +138,7 @@
 
 $lng = basename($lng);
 if (file_exists(APP_ROOT . '/includes/lang/' . $lng . '.php')) {
-  $charset = 'iso-8859-1';
+  $charset = $app_strings['LBL_CHARSET'];
   require_once(APP_ROOT . '/includes/lang/' . $lng . '.php'); // get our language include
   // Store the current language selection in a cookie, set expire date to 30 days later
  @setcookie("lng", $lng, (time() + 60 * 60 * 24 * 30));
@@ -168,7 +169,7 @@
 require_once(APP_ROOT . '/includes/xml/hddtemp.php');
 
 // build the xml
-$xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
+$xml = "<?xml version=\"1.0\" encoding=\"".$app_strings['LBL_CHARSET']."\"?>\n";
 $xml .= "<!DOCTYPE phpsysinfo SYSTEM \"phpsysinfo.dtd\">\n\n";
 $xml .= created_by();
 $xml .= "<phpsysinfo>\n";
@@ -200,12 +201,12 @@
   $XPath = new XPath();
   $XPath->importFromString($xml); 
 
-  header("Content-type: text/vnd.wap.wml; charset=iso-8859-1");
+  header("Content-type: text/vnd.wap.wml; charset=".$app_strings['LBL_CHARSET']);
   header("");
   header("Cache-Control: no-cache, must-revalidate");
   header("Pragma: no-cache");
 
-  echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
+  echo "<?xml version='1.0' encoding='".$app_strings['LBL_CHARSET']."'?>\n";
   echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\" >\n";
   echo "<wml>\n";
   echo "<card id=\"start\" title=\"phpSysInfo - Menu\">\n";

Modified: vtigercrm/branches/5.1_jens/modules/Users/Authenticate.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/Authenticate.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/Authenticate.php Mon Apr 16 12:27:44 2007
@@ -1,145 +1,145 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the 
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/Authenticate.php,v 1.10 2005/02/28 05:25:22 jack Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('modules/Users/Users.php');
-require_once('modules/Users/CreateUserPrivilegeFile.php');
-require_once('include/logging.php');
-require_once('user_privileges/audit_trail.php');
-
-global $mod_strings;
-
-$focus = new Users();
-
-// Add in defensive code here.
-$focus->column_fields["user_name"] = to_html($_REQUEST['user_name']);
-$user_password = $_REQUEST['user_password'];
-
-$focus->load_user($user_password);
-
-if($focus->is_authenticated())
-{
-
-	//Inserting entries for audit trail during login
-	
-	if($audit_trail == 'true')
-	{
-		if($record == '')
-			$auditrecord = '';						
-		else
-			$auditrecord = $record;	
-
-		$date_var = $adb->formatDate(date('YmdHis'));
- 	    $query = "insert into vtiger_audit_trial values(".$adb->getUniqueID('vtiger_audit_trial').",".$focus->id.",'Users','Authenticate','',$date_var)";	
-			
-		$adb->query($query);
-	}
-
-	
-	// Recording the login info
-        $usip=$_SERVER['REMOTE_ADDR'];
-        $intime=date("Y/m/d H:i:s");
-        require_once('modules/Users/LoginHistory.php');
-        $loghistory=new LoginHistory();
-        $Signin = $loghistory->user_login($focus->column_fields["user_name"],$usip,$intime);
-
-	//Security related entries start
-	require_once('include/utils/UserInfoUtil.php');
-
-	createUserPrivilegesfile($focus->id);
-	
-	//Security related entries end
-	header("Location: index.php?action=index&module=Home");
-	session_unregister('login_password');
-	session_unregister('login_error');
-	session_unregister('login_user_name');
-
-	$_SESSION['authenticated_user_id'] = $focus->id;
-	$_SESSION['app_unique_key'] = $application_unique_key;
-
-	// store the user's theme in the session
-	if (isset($_REQUEST['login_theme'])) {
-		$authenticated_user_theme = $_REQUEST['login_theme'];
-	}
-	elseif (isset($_REQUEST['ck_login_theme']))  {
-		$authenticated_user_theme = $_REQUEST['ck_login_theme'];
-	}
-	else {
-		$authenticated_user_theme = $default_theme;
-	}
-	
-	// store the user's language in the session
-	if (isset($_REQUEST['login_language'])) {
-		$authenticated_user_language = $_REQUEST['login_language'];
-	}
-	elseif (isset($_REQUEST['ck_login_language']))  {
-		$authenticated_user_language = $_REQUEST['ck_login_language'];
-	}
-	else {
-		$authenticated_user_language = $default_language;
-	}
-
-	// If this is the default user and the default user theme is set to reset, reset it to the default theme value on each login
-	if($reset_theme_on_default_user && $focus->user_name == $default_user_name)
-	{
-		$authenticated_user_theme = $default_theme;
-	}
-	if(isset($reset_language_on_default_user) && $reset_language_on_default_user && $focus->user_name == $default_user_name)
-	{
-		$authenticated_user_language = $default_language;	
-	}
-	
-	$_SESSION['authenticated_user_theme'] = $authenticated_user_theme;
-	$_SESSION['authenticated_user_language'] = $authenticated_user_language;
-	
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the 
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/Authenticate.php,v 1.10 2005/02/28 05:25:22 jack Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('modules/Users/Users.php');
+require_once('modules/Users/CreateUserPrivilegeFile.php');
+require_once('include/logging.php');
+require_once('user_privileges/audit_trail.php');
+
+global $mod_strings;
+
+$focus = new Users();
+
+// Add in defensive code here.
+$focus->column_fields["user_name"] = to_html($_REQUEST['user_name']);
+$user_password = $_REQUEST['user_password'];
+
+$focus->load_user($user_password);
+
+if($focus->is_authenticated())
+{
+
+	//Inserting entries for audit trail during login
+	
+	if($audit_trail == 'true')
+	{
+		if($record == '')
+			$auditrecord = '';						
+		else
+			$auditrecord = $record;	
+
+		$date_var = $adb->formatDate(date('YmdHis'));
+ 	    $query = "insert into vtiger_audit_trial values(".$adb->getUniqueID('vtiger_audit_trial').",".$focus->id.",'Users','Authenticate','',$date_var)";	
+			
+		$adb->query($query);
+	}
+
+	
+	// Recording the login info
+        $usip=$_SERVER['REMOTE_ADDR'];
+        $intime=date("Y/m/d H:i:s");
+        require_once('modules/Users/LoginHistory.php');
+        $loghistory=new LoginHistory();
+        $Signin = $loghistory->user_login($focus->column_fields["user_name"],$usip,$intime);
+
+	//Security related entries start
+	require_once('include/utils/UserInfoUtil.php');
+
+	createUserPrivilegesfile($focus->id);
+	
+	//Security related entries end
+	session_unregister('login_password');
+	session_unregister('login_error');
+	session_unregister('login_user_name');
+
+	$_SESSION['authenticated_user_id'] = $focus->id;
+	$_SESSION['app_unique_key'] = $application_unique_key;
+
+	// store the user's theme in the session
+	if (isset($_REQUEST['login_theme'])) {
+		$authenticated_user_theme = $_REQUEST['login_theme'];
+	}
+	elseif (isset($_REQUEST['ck_login_theme']))  {
+		$authenticated_user_theme = $_REQUEST['ck_login_theme'];
+	}
+	else {
+		$authenticated_user_theme = $default_theme;
+	}
+	
+	// store the user's language in the session
+	if (isset($_REQUEST['login_language'])) {
+		$authenticated_user_language = $_REQUEST['login_language'];
+	}
+	elseif (isset($_REQUEST['ck_login_language']))  {
+		$authenticated_user_language = $_REQUEST['ck_login_language'];
+	}
+	else {
+		$authenticated_user_language = $default_language;
+	}
+
+	// If this is the default user and the default user theme is set to reset, reset it to the default theme value on each login
+	if($reset_theme_on_default_user && $focus->user_name == $default_user_name)
+	{
+		$authenticated_user_theme = $default_theme;
+	}
+	if(isset($reset_language_on_default_user) && $reset_language_on_default_user && $focus->user_name == $default_user_name)
+	{
+		$authenticated_user_language = $default_language;	
+	}
+	
+	$_SESSION['authenticated_user_theme'] = $authenticated_user_theme;
+	$_SESSION['authenticated_user_language'] = $authenticated_user_language;
+	
 	// Users default organization --- force loading in index.php
 	$_SESSION['authenticated_user_organizations'] = '';
 	$_SESSION['authenticated_user_current_organization'] = '';
 
-	$log->debug("authenticated_user_theme is $authenticated_user_theme");
-	$log->debug("authenticated_user_language is $authenticated_user_language");
-	$log->debug("authenticated_user_id is ". $focus->id);
-        $log->debug("app_unique_key is $application_unique_key");
-
-	
-// Clear all uploaded import files for this user if it exists
-
-	global $import_dir;
-
-	$tmp_file_name = $import_dir. "IMPORT_".$focus->id;
-
-	if (file_exists($tmp_file_name))
-	{
-		unlink($tmp_file_name);
-	}
-}
-else
-{
-	$_SESSION['login_user_name'] = $focus->column_fields["user_name"];
-	$_SESSION['login_password'] = $user_password;
-	$_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
-	
-	// go back to the login screen.	
-	// create an error message for the user.
-	header("Location: index.php");
-}
-
-?>
+	$log->debug("authenticated_user_theme is $authenticated_user_theme");
+	$log->debug("authenticated_user_language is $authenticated_user_language");
+	$log->debug("authenticated_user_id is ". $focus->id);
+        $log->debug("app_unique_key is $application_unique_key");
+
+	
+// Clear all uploaded import files for this user if it exists
+
+	global $import_dir;
+
+	$tmp_file_name = $import_dir. "IMPORT_".$focus->id;
+
+	if (file_exists($tmp_file_name))
+	{
+		unlink($tmp_file_name);
+	}
+	header("Location: index.php");
+}
+else
+{
+	$_SESSION['login_user_name'] = $focus->column_fields["user_name"];
+	$_SESSION['login_password'] = $user_password;
+	$_SESSION['login_error'] = $mod_strings['ERR_INVALID_PASSWORD'];
+	
+	// go back to the login screen.	
+	// create an error message for the user.
+	header("Location: index.php");
+}
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/ChangePassword.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/ChangePassword.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/ChangePassword.php Mon Apr 16 12:27:44 2007
@@ -1,121 +1,121 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/ChangePassword.php,v 1.2 2004/10/29 09:55:10 jack Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-// This file is used for all popups on this module
-// The popup_picker.html file is used for generating a list from which to find and choose one instance.
-
-global $theme;
-require_once('modules/Users/Users.php');
-require_once('themes/'.$theme.'/layout_utils.php');
-require_once('include/logging.php');
-
-global $app_strings;
-global $mod_strings;
-
-$mod_strings['ERR_ENTER_OLD_PASSWORD'];
-?>
-<script type='text/javascript' language='JavaScript'>
-
-function trim(s) {
-	while (s.substring(0,1) == " ") {
-		s = s.substring(1, s.length);
-	}
-	while (s.substring(s.length-1, s.length) == " ") {
-		s = s.substring(0,s.length-1);
-	}
-
-	return s;
-}
-
-
-function set_password(form) {
-	if (form.is_admin.value == 1 && trim(form.old_password.value) == "") {
-		alert("<?php echo $mod_strings['ERR_ENTER_OLD_PASSWORD']; ?>");
-		return false;
-	}
-	if (trim(form.new_password.value) == "") {
-		alert("<?php echo $mod_strings['ERR_ENTER_NEW_PASSWORD']; ?>");
-		return false;
-	}
-	if (trim(form.confirm_new_password.value) == "") {
-		alert("<?php echo $mod_strings['ERR_ENTER_CONFIRMATION_PASSWORD']; ?>");
-		return false;
-	}
-
-	if (trim(form.new_password.value) == trim(form.confirm_new_password.value)) {
-		if (form.is_admin.value == 1) window.opener.document.DetailView.old_password.value = form.old_password.value;
-		window.opener.document.DetailView.new_password.value = form.new_password.value;
-		window.opener.document.DetailView.return_module.value = 'Users';
-		window.opener.document.DetailView.return_action.value = 'DetailView';
-		window.opener.document.DetailView.changepassword.value = 'true';
-		window.opener.document.DetailView.return_id.value = window.opener.document.DetailView.record.value;
-		window.opener.document.DetailView.action.value = 'Save';
-		window.opener.document.DetailView.submit();
-		return true;
-	}
-	else {
-		alert("<?php echo $mod_strings['ERR_REENTER_PASSWORDS']; ?>");
-		return false;
-	}
-}
-</script>
-<?php insert_popup_header($theme); ?>
-
-<form name="ChangePassword">
-<?php echo get_form_header($mod_strings['LBL_CHANGE_PASSWORD'], "", false); ?>
-
-<table width='100%' cellspacing='0' cellpadding='5' border='0' class="small">
-<tr>
-	<td class="detailedViewHeader" colspan="2"><b>Change Password</b></td>
-</tr>
-<?php if (!is_admin($current_user)) {
-	echo "<tr>";
-	echo "<td width='40%' class='dvtCellLabel' align='right'><b> ".$mod_strings['LBL_OLD_PASSWORD']."</b></td>\n";
-	echo "<td width='60%' class='dvtCellInfo'><input name='old_password' type='password' tabindex='1' size='15' maxlength='15'></td>\n";
-	echo "<input name='is_admin' type='hidden' value='1'>";
-	echo "</tr><tr>\n";
-}
-else echo "<input name='old_password' type='hidden'><input name='is_admin' type='hidden' value='0'>";
-?>
-<td width='40%' class='dvtCellLabel' nowrap align="right"><b><?php echo $mod_strings['LBL_NEW_PASSWORD']; ?></b></td>
-<td width='60%' class='dvtCellInfo'><input name='new_password' type='password' tabindex='1' size='15' maxlength='15'></td>
-</tr><tr>
-<td width='40%' class='dvtCellLabel' nowrap align="right"><b><?php echo $mod_strings['LBL_CONFIRM_PASSWORD']; ?></b></td>
-<td width='60%' class='dvtCellInfo'><input name='confirm_new_password' type='password' tabindex='1' size='15' maxlength='15'></td>
-</tr><tr>
-<td width='40%' class='dataLabel'></td>
-<td width='60%' class='dvtCellInfo'></td>
-</td></tr>
-</table>
-<br>
-<table width='100%' cellspacing='0' cellpadding='1' border='0'>
-<tr>
-<td align='right'><input title='<?php echo $app_strings['LBL_SAVE_BUTTON_TITLE']; ?>' accessKey='<?php echo $app_strings['LBL_SAVE_BUTTON_KEY']; ?>' class='crmbutton small save' LANGUAGE=javascript onclick='if (set_password(this.form)) window.close(); else return false;' type='submit' name='button' value='  <?php echo $app_strings['LBL_SAVE_BUTTON_LABEL']; ?>  '></td>
-<td align='left'><input title='<?php echo $app_strings['LBL_CANCEL_BUTTON_TITLE']; ?>' accessyKey='<?php echo $app_strings['LBL_CANCEL_BUTTON_KEY']; ?>' class='crmbutton small cancel' LANGUAGE=javascript onclick='window.close()' type='submit' name='button' value='  <?php echo $app_strings['LBL_CANCEL_BUTTON_LABEL']; ?>  '></td>
-</tr>
-
-<script language="JavaScript">
-document.ChangePassword.new_password.focus();
-</script>
-</table>
-</form>
-<br>
-
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/ChangePassword.php,v 1.2 2004/10/29 09:55:10 jack Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+// This file is used for all popups on this module
+// The popup_picker.html file is used for generating a list from which to find and choose one instance.
+
+global $theme;
+require_once('modules/Users/Users.php');
+require_once('themes/'.$theme.'/layout_utils.php');
+require_once('include/logging.php');
+
+global $app_strings;
+global $mod_strings;
+
+$mod_strings['ERR_ENTER_OLD_PASSWORD'];
+?>
+<script type='text/javascript' language='JavaScript'>
+
+function trim(s) {
+	while (s.substring(0,1) == " ") {
+		s = s.substring(1, s.length);
+	}
+	while (s.substring(s.length-1, s.length) == " ") {
+		s = s.substring(0,s.length-1);
+	}
+
+	return s;
+}
+
+
+function set_password(form) {
+	if (form.is_admin.value == 1 && trim(form.old_password.value) == "") {
+		alert("<?php echo $mod_strings['ERR_ENTER_OLD_PASSWORD']; ?>");
+		return false;
+	}
+	if (trim(form.new_password.value) == "") {
+		alert("<?php echo $mod_strings['ERR_ENTER_NEW_PASSWORD']; ?>");
+		return false;
+	}
+	if (trim(form.confirm_new_password.value) == "") {
+		alert("<?php echo $mod_strings['ERR_ENTER_CONFIRMATION_PASSWORD']; ?>");
+		return false;
+	}
+
+	if (trim(form.new_password.value) == trim(form.confirm_new_password.value)) {
+		if (form.is_admin.value == 1) window.opener.document.DetailView.old_password.value = form.old_password.value;
+		window.opener.document.DetailView.new_password.value = form.new_password.value;
+		window.opener.document.DetailView.return_module.value = 'Users';
+		window.opener.document.DetailView.return_action.value = 'DetailView';
+		window.opener.document.DetailView.changepassword.value = 'true';
+		window.opener.document.DetailView.return_id.value = window.opener.document.DetailView.record.value;
+		window.opener.document.DetailView.action.value = 'Save';
+		window.opener.document.DetailView.submit();
+		return true;
+	}
+	else {
+		alert("<?php echo $mod_strings['ERR_REENTER_PASSWORDS']; ?>");
+		return false;
+	}
+}
+</script>
+<?php insert_popup_header($theme); ?>
+
+<form name="ChangePassword">
+<?php echo get_form_header($mod_strings['LBL_CHANGE_PASSWORD'], "", false); ?>
+
+<table width='100%' cellspacing='0' cellpadding='5' border='0' class="small">
+<tr>
+	<td class="detailedViewHeader" colspan="2"><b><?php echo $mod_strings['LBL_CHANGE_PASSWORD']; ?></b></td>
+</tr>
+<?php if (!is_admin($current_user)) {
+	echo "<tr>";
+	echo "<td width='40%' class='dvtCellLabel' align='right'><b> ".$mod_strings['LBL_OLD_PASSWORD']."</b></td>\n";
+	echo "<td width='60%' class='dvtCellInfo'><input name='old_password' type='password' tabindex='1' size='15' maxlength='15'></td>\n";
+	echo "<input name='is_admin' type='hidden' value='1'>";
+	echo "</tr><tr>\n";
+}
+else echo "<input name='old_password' type='hidden'><input name='is_admin' type='hidden' value='0'>";
+?>
+<td width='40%' class='dvtCellLabel' nowrap align="right"><b><?php echo $mod_strings['LBL_NEW_PASSWORD']; ?></b></td>
+<td width='60%' class='dvtCellInfo'><input name='new_password' type='password' tabindex='1' size='15' maxlength='15'></td>
+</tr><tr>
+<td width='40%' class='dvtCellLabel' nowrap align="right"><b><?php echo $mod_strings['LBL_CONFIRM_PASSWORD']; ?></b></td>
+<td width='60%' class='dvtCellInfo'><input name='confirm_new_password' type='password' tabindex='1' size='15' maxlength='15'></td>
+</tr><tr>
+<td width='40%' class='dataLabel'></td>
+<td width='60%' class='dvtCellInfo'></td>
+</td></tr>
+</table>
+<br>
+<table width='100%' cellspacing='0' cellpadding='1' border='0'>
+<tr>
+<td align='right'><input title='<?php echo $app_strings['LBL_SAVE_BUTTON_TITLE']; ?>' accessKey='<?php echo $app_strings['LBL_SAVE_BUTTON_KEY']; ?>' class='crmbutton small save' LANGUAGE=javascript onclick='if (set_password(this.form)) window.close(); else return false;' type='submit' name='button' value='  <?php echo $app_strings['LBL_SAVE_BUTTON_LABEL']; ?>  '></td>
+<td align='left'><input title='<?php echo $app_strings['LBL_CANCEL_BUTTON_TITLE']; ?>' accessyKey='<?php echo $app_strings['LBL_CANCEL_BUTTON_KEY']; ?>' class='crmbutton small cancel' LANGUAGE=javascript onclick='window.close()' type='submit' name='button' value='  <?php echo $app_strings['LBL_CANCEL_BUTTON_LABEL']; ?>  '></td>
+</tr>
+
+<script language="JavaScript">
+document.ChangePassword.new_password.focus();
+</script>
+</table>
+</form>
+<br>
+

Modified: vtigercrm/branches/5.1_jens/modules/Users/CreateUserPrivilegeFile.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/CreateUserPrivilegeFile.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/CreateUserPrivilegeFile.php Mon Apr 16 12:27:44 2007
@@ -1359,7 +1359,9 @@
                 $code = 'array(';
                 foreach ($var as $key => $value)
                 {
-                        if($i<$size)
+        //fix for signatue quote(') issue
+        $value=addslashes($value);    
+	            if($i<$size)
                         {
                                 $code .= "'".$key."'=>'".$value."',";
                         }

Modified: vtigercrm/branches/5.1_jens/modules/Users/DefaultDataPopulator.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/DefaultDataPopulator.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/DefaultDataPopulator.php Mon Apr 16 12:27:44 2007
@@ -55,33 +55,33 @@
 	$this->db->completeTransaction();
 
 	$this->db->startTransaction();
-	$this->db->query("INSERT INTO vtiger_tab VALUES (3,'Home',0,1,'Home',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (7,'Leads',0,4,'Leads',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (6,'Accounts',0,5,'Accounts',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (4,'Contacts',0,6,'Contacts',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (2,'Potentials',0,7,'Potentials',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (8,'Notes',0,9,'Notes',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (9,'Calendar',0,3,'Calendar',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (10,'Emails',0,10,'Emails',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (13,'HelpDesk',0,11,'HelpDesk',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (14,'Products',0,8,'Products',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (1,'Dashboard',0,12,'Dashboards',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (15,'Faq',0,14,'Faq',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (16,'Events',2,13,'Events',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (18,'Vendors',0,15,'Vendors',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (19,'PriceBooks',0,16,'PriceBooks',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (20,'Quotes',0,17,'Quotes',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (22,'SalesOrder',0,19,'SalesOrder',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (23,'Invoice',0,20,'Invoice',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (24,'Rss',0,21,'Rss',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (25,'Reports',0,22,'Reports',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (26,'Campaigns',0,23,'Campaigns',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (27,'Portal',0,24,'Portal',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (28,'Webmails',0,25,'Webmails',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (29,'Users',0,26,'Users',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (30,'Organization',0,30,'Organization',null,null,1)");
-	$this->db->query("INSERT INTO vtiger_tab VALUES (31,'OrgUnit',0,31,'OrgUnit',null,null,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (3,'Home',0,1,'Home',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (7,'Leads',0,4,'Leads',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (6,'Accounts',0,5,'Accounts',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (4,'Contacts',0,6,'Contacts',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (2,'Potentials',0,7,'Potentials',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (8,'Notes',0,9,'Notes',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (9,'Calendar',0,3,'Calendar',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (10,'Emails',0,10,'Emails',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (13,'HelpDesk',0,11,'HelpDesk',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (14,'Products',0,8,'Products',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (1,'Dashboard',0,12,'Dashboards',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (15,'Faq',0,14,'Faq',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (16,'Events',2,13,'Events',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (18,'Vendors',0,15,'Vendors',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (19,'PriceBooks',0,16,'PriceBooks',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (20,'Quotes',0,17,'Quotes',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (22,'SalesOrder',0,19,'SalesOrder',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (23,'Invoice',0,20,'Invoice',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (24,'Rss',0,21,'Rss',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (25,'Reports',0,22,'Reports',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (26,'Campaigns',0,23,'Campaigns',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (27,'Portal',0,24,'Portal',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (28,'Webmails',0,25,'Webmails',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (29,'Users',0,26,'Users',null,null,0,1)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (30,'Organization',0,30,'Organization',null,null,0,0)");
+	$this->db->query("INSERT INTO vtiger_tab VALUES (31,'OrgUnit',0,31,'OrgUnit',null,null,0,0)");
 
 	$this->db->completeTransaction();
 
@@ -459,36 +459,38 @@
 	//Product Details -- START
 	//Block31-36 -- Start
 
+	$this->db->query("INSERT INTO vtiger_field VALUES (14,".$this->db->getUniqueID("vtiger_field").",'quantity','vtiger_products2products_rel',1,'1','dependency_qty','LBL_QTY',1,0,0,3,0,33,1,'V~O',1,null,'DEP')");
+	$this->db->query("INSERT INTO vtiger_field VALUES (14,".$this->db->getUniqueID("vtiger_field").",'product_relgroup','vtiger_products2products_rel',1,'1','dependency_grp','LBL_GRP',1,0,0,3,0,33,1,'V~O',1,null,'DEP')");
+
 	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productname','vtiger_products',1,'2','productname','Product Name',1,0,0,100,1,31,1,'V~M',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productcode','vtiger_products',1,'1','productcode','Product Code',1,0,0,100,2,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productcode','vtiger_products',1,'1','productcode','Part Number',1,0,0,100,2,31,1,'V~O',1,null,'BAS')");
 	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'discontinued','vtiger_products',1,'56','discontinued','Product Active',1,0,0,100,3,31,1,'V~O',1,null,'BAS')");
 	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'manufacturer','vtiger_products',1,'15','manufacturer','Manufacturer',1,0,0,100,4,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,0,0,100,4,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,0,0,100,5,31,1,'D~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,0,0,100,6,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,0,0,100,7,31,1,'D~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,0,0,100,8,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS')");
-
-
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'crmid','vtiger_seproductsrel',1,'66','parent_id','Related To',1,0,0,100,10,31,1,'I~O',1,null,'BAS')");
-
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'contactid','vtiger_products',1,'57','contact_id','Contact Name',1,0,0,100,11,31,1,'I~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_products',1,'17','website','Website',1,0,0,100,12,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,0,0,100,13,31,1,'I~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,0,0,100,14,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,0,0,100,15,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,0,0,100,16,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,0,0,100,17,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'glacct','vtiger_products',1,'15','glacct','GL Account',1,0,0,100,18,31,1,'V~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,31,2,'T~O',1,null,'BAS')");
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,31,2,'T~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,0,0,100,5,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("INSERT INTO vtiger_field VALUES ( 14, ".$this->db->getUniqueID("vtiger_field").", 'productclass','vtiger_products',1,'15','productclass','Product Class',1,0,0,100,6,31,1,'V~M',1,null,'BAS')");
+	$this->db->query("INSERT INTO vtiger_field VALUES ( 14, ".$this->db->getUniqueID("vtiger_field").", 'producttype','vtiger_products',1,'15','producttype','Product Type',1,0,0,100,7,31,1,'V~M',1,null,'BAS')");
+	$this->db->query("INSERT INTO vtiger_field VALUES ( 14, ".$this->db->getUniqueID("vtiger_field").", 'productvalidation','vtiger_products',1,'15','productvalidation','Product Validation',1,0,0,100,8,31,1,'V~M',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,0,0,100,9,31,1,'D~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,0,0,100,10,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,0,0,100,11,31,1,'D~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,0,0,100,12,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS')");
+	$this->db->query("INSERT INTO vtiger_field VALUES ( 14, ".$this->db->getUniqueID("vtiger_field").", 'contractbound','vtiger_products',1,'56','contractbound','Contract Bound',1,0,0,100,14,31,1,'V~M',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_products',1,'17','website','Website',1,0,0,100,16,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,0,0,100,17,31,1,'I~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,0,0,100,18,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,0,0,100,19,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,0,0,100,20,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,0,0,100,21,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'glacct','vtiger_products',1,'15','glacct','GL Account',1,0,0,100,22,31,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,23,31,2,'T~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,24,31,2,'T~O',1,null,'BAS')");
 
 
 	//Block32 Pricing Information
 
 	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'unit_price','vtiger_products',1,'71','unit_price','Unit Price',1,0,0,100,1,32,1,'N~O',1,null,'BAS')"); 
 	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'commissionrate','vtiger_products',1,'9','commissionrate','Commission Rate',1,0,0,100,2,32,1,'N~O',1,null,'BAS')"); 
-	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'taxclass','vtiger_producttaxrel',1,'83','taxclass','Tax Class',1,0,0,100,4,32,1,'V~O',1,null,'BAS')");
+	$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'taxclass','vtiger_products',1,'83','taxclass','Tax Class',1,0,0,100,4,32,1,'V~O',1,null,'BAS')");
 
 
 	//Block 33 stock info
@@ -916,7 +918,8 @@
 	$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,74,1,'V~O',1,null,'ADV')");
 	//Block74
 	$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,73,1,'V~O',1,null,'ADV')");
-
+	//Added for Custom invoice Number
+	$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'invoice_no','vtiger_invoice',1,'1','invoice_no','invoice_no',1,0,0,100,3,69,1,'V~M',1,null,'BAS')");
 
 	//Invoice Details -- END
 	//users Details Starts Block 79,80,81
@@ -995,26 +998,26 @@
 
 
 	//The Entity Name for the modules are maintained in this table
-	$this->db->query("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','lastname,firstname','leadid')");
-	$this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid')");
-	$this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid')");
-	$this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid')");
-	$this->db->query("insert into vtiger_entityname values(8,'Notes','vtiger_notes','title','notesid')");
-	$this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid')");
-	$this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid')");
-	$this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid')");
-	$this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid')");
-	$this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','last_name,first_name','id')");
-	$this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid')");
-	$this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid')");
-	$this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid')");
-	$this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid')");
-	$this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid')");
-	$this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid')");
-	$this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid')");
-	$this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id')");
-	$this->db->query("insert into vtiger_entityname values(30,'Organization','vtiger_organizationdetails','organizationname','organizationname')");
-	$this->db->query("insert into vtiger_entityname values(31,'OrgUnit','vtiger_orgunit','name','orgunitid')");
+	$this->db->query("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','lastname,firstname','leadid','leadid')");
+	$this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid','account_id')");
+	$this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid','contact_id')");
+	$this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid','potential_id')");
+	$this->db->query("insert into vtiger_entityname values(8,'Notes','vtiger_notes','title','notesid','notesid')");
+	$this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid','ticketid')");
+	$this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid','activityid')");
+	$this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid','activityid')");
+	$this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid','product_id')");
+	$this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','last_name,first_name','id','id')");
+	$this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid','invoiceid')");
+	$this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid','quote_id')");
+	$this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid','purchaseorderid')");
+	$this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid','salesorder_id')");
+	$this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid','vendor_id')");
+	$this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid','pricebookid')");
+	$this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid','campaignid')");
+	$this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id','id')");
+	$this->db->query("insert into vtiger_entityname values(30,'Organization','vtiger_organizationdetails','organizationname','organizationname','organizationname')");
+	$this->db->query("insert into vtiger_entityname values(31,'OrgUnit','vtiger_orgunit','name','orgunitid','orgunitid')");
 
 	// Insert End
 	
@@ -1751,26 +1754,25 @@
 	//insert into related list vtiger_table
 	//Inserting for vtiger_account related lists
 		$this->db->startTransaction();
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Potentials").",'get_opportunities',1,'Potentials',0)");	
 		
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Contacts").",'get_contacts',2,'Contacts',0)");
-
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Calendar").",'get_activities',3,'Activities',0)");
-
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("HelpDesk").",'get_tickets',4,'HelpDesk',0)");
-	
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Calendar").",'get_history',5,'Activity History',0)");
-
-	
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",0,'get_attachments',6,'Attachments',0)");
-
-	
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Quotes").",'get_quotes',7,'Quotes',0)");
-	
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Invoice").",'get_invoices',8,'Invoice',0)");
-	
-	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("SalesOrder").",'get_salesorder',9,'Sales Order',0)");
-	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Contacts").",'get_contacts',1,'Contacts',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Potentials").",'get_opportunities',2,'Potentials',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Quotes").",'get_quotes',3,'Quotes',0)");
+	
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("SalesOrder").",'get_salesorder',4,'Sales Order',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Invoice").",'get_invoices',5,'Invoice',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Calendar").",'get_activities',6,'Activities',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Calendar").",'get_history',7,'Activity History',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",0,'get_attachments',8,'Attachments',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("HelpDesk").",'get_tickets',9,'HelpDesk',0)");
+
 	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Accounts").",".getTabid("Products").",'get_products',10,'Products',0)");
 
 	//Inserting Lead Related Lists	
@@ -1847,6 +1849,14 @@
 	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Invoice").",'get_invoices',7,'Invoice',0)");
 	
 	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("PriceBooks").",'get_product_pricebooks',8,'PriceBooks',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Leads").",'get_leads',9,'Leads',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Accounts").",'get_accounts',10,'Accounts',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Contacts").",'get_contacts',11,'Contacts',0)");
+
+	$this->db->query("insert into vtiger_relatedlists values(".$this->db->getUniqueID('vtiger_relatedlists').",".getTabid("Products").",".getTabid("Potentials").",'get_opportunities',12,'Potentials',0)");
 	
 		//Inserting Emails Related Lists	
 
@@ -1953,41 +1963,41 @@
 	$this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_notificationscheduler").",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notification','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')");
 
 	//Inserting Inventory Notifications
-	$invoice_body = 'Dear {HANDLER},
-
+	$invoice_body = 'Dear {HANDLER},<br>
+<br>
 The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. Kindly procure required number of units as the stock level is below reorder level {REORDERLEVELVALUE}.
-
+<br><br>
 Please treat this information as Urgent as the invoice is already sent  to the customer.
-
+<br><br>
 Severity: Critical
-
-Thanks,
+<br>
+Thanks,<br>
 {CURRENTUSER}';
 
-	    
-	$this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','".$invoice_body." ','InvoiceNotificationDescription')");
-
-	$quote_body = 'Dear {HANDLER},
+		
+               $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','".$invoice_body." ','InvoiceNotificationDescription')");
+
+		$quote_body = 'Dear {HANDLER},<br><br>
 
 Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 
-
+<br><br>
 Severity: Minor
-
-Thanks,
+<br><br>
+Thanks,<br>
 {CURRENTUSER}';	
-	    
-	    
-	$this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'QuoteNotification','Quote given for {PRODUCTNAME}','".$quote_body." ','QuoteNotificationDescription')");
-
-	$so_body = 'Dear {HANDLER},
-
+		
+		
+               $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (".$this->db->getUniqueID("vtiger_inventorynotification").",'QuoteNotification','Quote given for {PRODUCTNAME}','".$quote_body." ','QuoteNotificationDescription')");
+
+		$so_body = 'Dear {HANDLER},
+<br><br>
 SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 
-
+<br><br>
 Please treat this information  with priority as the sales order is already generated.
-
+<br><br>
 Severity: Major
-
-Thanks,
+<br><br>
+Thanks,<br>
 {CURRENTUSER}';
 
 	    
@@ -2242,7 +2252,7 @@
 	$this->db->query("insert into vtiger_parenttab values (8,'Settings',8,0)");
 
 	$this->db->query("insert into vtiger_parenttabrel values (1,9,2)");
-	$this->db->query("insert into vtiger_parenttabrel values (1,10,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (1,28,4)");
 	$this->db->query("insert into vtiger_parenttabrel values (1,3,1)");
 	$this->db->query("insert into vtiger_parenttabrel values (3,7,1)");
 	$this->db->query("insert into vtiger_parenttabrel values (3,6,2)");
@@ -2275,15 +2285,15 @@
 	$this->db->query("insert into vtiger_parenttabrel values (2,26,1)");
 	$this->db->query("insert into vtiger_parenttabrel values (2,6,2)");
 	$this->db->query("insert into vtiger_parenttabrel values (2,4,3)");
-	$this->db->query("insert into vtiger_parenttabrel values (2,10,4)");
-	$this->db->query("insert into vtiger_parenttabrel values (4,10,7)");
+	$this->db->query("insert into vtiger_parenttabrel values (2,28,4)");
+	$this->db->query("insert into vtiger_parenttabrel values (4,28,7)");
 	$this->db->query("insert into vtiger_parenttabrel values (2,7,5)");
 	$this->db->query("insert into vtiger_parenttabrel values (2,9,6)");
 	$this->db->query("insert into vtiger_parenttabrel values (4,9,8)");
 	$this->db->query("insert into vtiger_parenttabrel values (2,8,8)");
 	$this->db->query("insert into vtiger_parenttabrel values (3,9,11)");
 	$this->db->query("insert into vtiger_parenttabrel values (8,30,2)");
-	$this->db->query("insert into vtiger_parenttabrel values (30,31,2)");
+	$this->db->query("insert into vtiger_parenttabrel values (8,31,2)");
 	$this->db->completeTransaction();
 		
 	//Added to populate the default inventory tax informations
@@ -2313,6 +2323,41 @@
 	$this->db->query("alter table vtiger_inventoryshippingrel add column shtax$shserviceid decimal(7,3) default NULL");
 
 	$this->db->completeTransaction();
+
+	//Added to populate the default dependency and product classes
+	$this->db->startTransaction();
+	$this->db->query("INSERT INTO vtiger_dependendlists VALUES (".$this->db->getUniqueID("vtiger_dependendlists").",14,'get_product_piecelist',1,'Piecelist',0)");
+	$this->db->query("INSERT INTO vtiger_dependendlists VALUES (".$this->db->getUniqueID("vtiger_dependendlists").",14,'get_product_depends',2,'Dependencies',0)");
+	$this->db->query("INSERT INTO vtiger_dependendlists VALUES (".$this->db->getUniqueID("vtiger_dependendlists").",14,'get_product_incompatibles',3,'Incompatibles',0)");
+	$this->db->query("INSERT INTO vtiger_dependendlists VALUES (".$this->db->getUniqueID("vtiger_dependendlists").",14,'get_product_options',4,'Options',0)");
+	$this->db->query("INSERT INTO vtiger_dependendlists VALUES (".$this->db->getUniqueID("vtiger_dependendlists").",14,'get_product_purchaselist',5,'Purchaselist',0)");
+
+	$this->db->query("INSERT into vtiger_productclass VALUES ( ".$this->db->getUniqueID("vtiger_productclass").", 'Sales', 0, 1)");
+	$this->db->query("INSERT into vtiger_productclass VALUES ( ".$this->db->getUniqueID("vtiger_productclass").", 'Purchase', 0, 1)");
+
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'One time fixed', 0, 1)");
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'Periodically fixed', 10, 1)");
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'Rental', 20, 1)");
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'Contingent Accounting', 30, 1)");
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'Usage Accouting', 31, 1)");
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'Manually', 98, 1)");
+	$this->db->query("INSERT into vtiger_producttype VALUES ( ".$this->db->getUniqueID("vtiger_producttype").", 'Free of charge', 99, 1)");
+
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'On delivery', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'On demand', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'Per day', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'Per week', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'Per month', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'Per quarter', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'Per year', 0, 1)");
+	$this->db->query("INSERT into vtiger_productvalidation VALUES ( ".$this->db->getUniqueID("vtiger_productvalidation").", 'Never', 0, 1)");
+
+	$this->db->completeTransaction();
+
+	//version file is included here because without including this
+	//file version cannot be get
+	include('vtigerversion.php');
+	$this->db->query("insert into vtiger_version values(0,'".$vtiger_current_version."','".$vtiger_current_version."')");
     }
 }
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/DeleteGroup.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/DeleteGroup.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/DeleteGroup.php Mon Apr 16 12:27:44 2007
@@ -33,5 +33,5 @@
 deleteGroup($del_id,$transferId,$transferType);
 
 
-header("Location: index.php?action=listgroups&module=Users&parenttab=Settings");
+header("Location: index.php?action=listgroups&module=Settings&parenttab=Settings");
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/DeleteProfile.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/DeleteProfile.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/DeleteProfile.php Mon Apr 16 12:27:44 2007
@@ -14,5 +14,5 @@
 $tran_id = $_REQUEST['transfer_prof_id'];
 //Deleting the Profile
 deleteProfile($del_id,$tran_id);
-header("Location: index.php?module=Users&action=ListProfiles&parenttab=Settings");
+header("Location: index.php?module=Settings&action=ListProfiles&parenttab=Settings");
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/DeleteRole.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/DeleteRole.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/DeleteRole.php Mon Apr 16 12:27:44 2007
@@ -15,5 +15,5 @@
 
 deleteRole($del_id,$tran_id);
 
-header("Location: index.php?action=listroles&module=Users");
+header("Location: index.php?action=listroles&module=Settings");
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/DeleteSharingRule.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/DeleteSharingRule.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/DeleteSharingRule.php Mon Apr 16 12:27:44 2007
@@ -13,5 +13,5 @@
 $shareid =  $_REQUEST['shareid'];
 deleteSharingRule($shareid);
 
-header("Location: index.php?module=Users&action=OrgSharingDetailView&parenttab=Settings");
+header("Location: index.php?module=Settings&action=OrgSharingDetailView&parenttab=Settings");
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/DetailView.php Mon Apr 16 12:27:44 2007
@@ -1,205 +1,247 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/DetailView.php,v 1.21 2005/04/19 14:44:02 ray Exp $
- * Description:  TODO: To be written.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
- * All Rights Reserved.
- * Contributor(s): ______________________________________..
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-require_once('data/Tracker.php');
-require_once('modules/Users/Users.php');
-require_once('include/utils/utils.php');
-require_once('include/utils/CommonUtils.php');
-require_once('include/utils/UserInfoUtil.php');
-require_once('include/database/PearDatabase.php');
-require_once('include/utils/GetUserGroups.php');
-
-global $current_user;
-global $theme;
-global $default_language;
-global $adb;
-global $currentModule;
-global $app_strings;
-global $mod_strings;
-
-$focus = new Users();
-
-if(!empty($_REQUEST['record'])) {
-	$focus->retrieve_entity_info($_REQUEST['record'],'Users');
-	$focus->id = $_REQUEST['record'];	
-}
-else
-{
-
-    echo "
-        <script type='text/javascript'>
-            window.location = 'index.php?module=Users&action=ListView';
-        </script>
-        ";
-}
-
-if( $focus->user_name == "" )
-{  
-   
-    echo "
-            <table>
-                <tr>
-                    <td>
-                        <b>User does not exist.</b>
-                    </td>
-                </tr>
-                <tr>
-                    <td>
-                        <a href='index.php?module=Users&action=ListView'>List Users</a>
-                    </td>
-                </tr>
-            </table>
-        ";
-    exit;  
-}
-
-
-if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
-	$focus->id = "";
-}
-
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-//the user might belong to multiple groups
-$log->info("User detail view");
-
-$category = getParenttab();
-
-$smarty = new vtigerCRM_Smarty;
-
-$smarty->assign("UMOD", $mod_strings);
-global $current_language;
-$smod_strings = return_module_language($current_language, 'Settings');
-$smarty->assign("MOD", $smod_strings);
-
-$smarty->assign("APP", $app_strings);
-
-$oGetUserGroups = new GetUserGroups();
-$oGetUserGroups->getAllUserGroups($focus->id);
-
-
-$smarty->assign("GROUP_COUNT",count($oGetUserGroups->user_groups));
-$smarty->assign("THEME", $theme);
-$smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
-$smarty->assign("ID", $focus->id);
-$smarty->assign("CATEGORY", $category);
-if(isset($focus->imagename) && $focus->imagename!='')
-{
-	$imagestring="<div id='track1' style='margin: 4px 0pt 0pt 10px; width: 200px; background-image: url(themes/images/scaler_slider_track.gif); background-repeat: repeat-x; background-position: left center; height: 18px;'>
-	<div class='selected' id='handle1' style='width: 18px; height: 18px; position: relative; left: 145px;cursor:pointer;'><img src='themes/images/scaler_slider.gif'></div>
-	</div><script language='JavaScript' type='text/javascript' src='include/js/prototype.js'></script>
-<script language='JavaScript' type='text/javascript' src='include/js/slider.js'></script>
-
-	<div class='scale-image' style='padding: 10px; float: left; width: 83.415px;'><img src='test/user/".$focus->imagename."' width='100%'</div>
-	<p><script type='text/javascript' src='include/js/scale_demo.js'></script></p>";
-	//$smarty->assign("USER_IMAGE",$imagestring);
-}
-				
-if(isset($_REQUEST['modechk']) && $_REQUEST['modechk'] != '' )
-{
-	$modepref = $_REQUEST['modechk'];
-}
-	if($_REQUEST['modechk'] == 'prefview')
-		$parenttab = '';
-	else
-		$parenttab = 'Settings';
-
-$smarty->assign("PARENTTAB", $parenttab);
-
-if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id)
-		&& isset($default_user_name)
-		&& $default_user_name == $focus->user_name
-		&& isset($lock_default_user_name)
-		&& $lock_default_user_name == true	) {
-	$buttons = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='crmButton small edit' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='$focus->id'; this.form.action.value='EditView'; this.form.parenttab.value='$parenttab'\" type='submit' name='Edit' value='  ".$app_strings['LBL_EDIT_BUTTON_LABEL']."  '>";
-	$smarty->assign('EDIT_BUTTON',$buttons);
-}
-elseif (is_admin($current_user) || $_REQUEST['record'] == $current_user->id) {
-	$buttons = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='crmButton small edit' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='$focus->id'; this.form.action.value='EditView'; this.form.parenttab.value='$parenttab'\" type='submit' name='Edit' value='  ".$app_strings['LBL_EDIT_BUTTON_LABEL']."  '>";
-	$smarty->assign('EDIT_BUTTON',$buttons);
-	
-		$buttons = "<input title='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_TITLE']."' accessKey='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_KEY']."' class='crmButton password small' LANGUAGE=javascript onclick='return window.open(\"index.php?module=Users&action=ChangePassword&form=DetailView\",\"test\",\"width=320,height=200,resizable=no,scrollbars=0, toolbar=no, titlebar=no, left=200, top=226, screenX=100, screenY=126\");' type='button' name='password' value='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_LABEL']."'>";
-		$smarty->assign('CHANGE_PW_BUTTON',$buttons);
-	
-	
-}
-if (is_admin($current_user)) 
-{
-	$buttons = "<input title='".$app_strings['LBL_DUPLICATE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DUPLICATE_BUTTON_KEY']."' class='crmButton small cancel' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.return_id.value='".$_REQUEST['record']."';this.form.action.value='EditView'\" type='submit' name='Duplicate' value=' ".$app_strings['LBL_DUPLICATE_BUTTON_LABEL']."'   >";
-	$smarty->assign('DUPLICATE_BUTTON',$buttons);
-	
-	//done so that only the admin user can see the customize tab button
-	if($_REQUEST['record'] != $current_user->id)
-	{
-		$buttons = "<input title='".$app_strings['LBL_DELETE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DELETE_BUTTON_KEY']."' class='classBtn' onclick=\"deleteUser('$focus->id')\" type='button' name='Delete' value='  ".$app_strings['LBL_DELETE_BUTTON_LABEL']."  '>";
-		$smarty->assign('DELETE_BUTTON',$buttons);
-	}
-
-	if($_SESSION['authenticated_user_roleid'] == 'administrator')
-	{
-		$buttons = "<input title='".$app_strings['LBL_LISTROLES_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_LISTROLES_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='TabCustomise'; this.form.action.value='listroles'; this.form.record.value= '". $current_user->id ."'\" type='submit' name='ListRoles' value=' ".$app_strings['LBL_LISTROLES_BUTTON_LABEL']." '>";
-		$smarty->assign('LISTROLES_BUTTON',$buttons);
-	}
-
-}
-
-if(is_admin($current_user))
-	$smarty->assign("IS_ADMIN", true);
-else
-	$smarty->assign("IS_ADMIN", false);
-
-$lead_tables = Array('vtiger_users','vtiger_user2role');
-$tabid = getTabid("Users");
-$validationData = getDBValidationData($lead_tables,$tabid);
-$data = split_validationdataArray($validationData);
-
-$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
-$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
-$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
-$smarty->assign("MODULE", 'Users');
-$smarty->assign("CURRENT_USERID", $current_user->id);
-$smarty->assign("HOMEORDER",$focus->getHomeOrder($focus->id));
-$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
-$smarty->assign("USERNAME",$focus->last_name.' '.$focus->first_name);
-
-
-//Organization assignment
-$crmid=$focus->id;
-require('modules/Users/GetUserOrg.php');
-
-//Assign the organization details to the html output
-$smarty->assign("MULTISELECT_COMBO_BOX_ITEM_SEPARATOR_STRING", $org_separator);
-$smarty->assign("ALL_USER_ORGANIZATIONS", $smarty_allorgs);
-$smarty->assign("EDIT_USER_ORGANIZATIONS", $smarty_orgs);
-$smarty->assign("EDIT_USER_ORGUNITS", $smarty_orgunits);
-$smarty->assign("EDIT_USER_PRIMARY_ORGANIZATION", $curorg);
-$smarty->assign("EDIT_USER_ASSIGNED_ORGANIZATIONS", $assigned_org);
-$smarty->assign("EDIT_USER_PRIMARY_ORGUNITS", $prim_orgunits);
-
-$smarty->display("UserDetailView.tpl");
-
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/DetailView.php,v 1.21 2005/04/19 14:44:02 ray Exp $
+ * Description:  TODO: To be written.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________..
+ ********************************************************************************/
+
+require_once('Smarty_setup.php');
+require_once('data/Tracker.php');
+require_once('modules/Users/Users.php');
+require_once('include/utils/utils.php');
+require_once('include/utils/CommonUtils.php');
+require_once('include/utils/UserInfoUtil.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/utils/GetUserGroups.php');
+//to check audittrail if enable or not
+require_once('user_privileges/audit_trail.php');
+
+global $current_user;
+global $theme;
+global $default_language;
+global $adb;
+global $currentModule;
+global $app_strings;
+global $mod_strings;
+
+$focus = new Users();
+
+if(!empty($_REQUEST['record'])) 
+{
+	$focus->retrieve_entity_info($_REQUEST['record'],'Users');
+	$focus->id = $_REQUEST['record'];	
+}
+else
+{
+
+    echo "
+        <script type='text/javascript'>
+            window.location = 'index.php?module=Users&action=ListView';
+        </script>
+        ";
+}
+
+if( $focus->user_name == "" )
+{  
+
+	if(is_admin($current_user))
+	{
+    echo "
+            <table>
+                <tr>
+                    <td>
+                        <b>User does not exist.</b>
+                    </td>
+		    </tr>";
+	
+    echo "
+                <tr>
+                    <td>
+                        <a href='index.php?module=Users&action=ListView'>List Users</a>
+                    </td>
+                </tr>
+            </table>
+	    ";
+    exit;
+	}
+  
+}
+
+
+if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
+	$focus->id = "";
+}
+
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+//the user might belong to multiple groups
+$log->info("User detail view");
+
+$category = getParenttab();
+
+$smarty = new vtigerCRM_Smarty;
+
+$smarty->assign("UMOD", $mod_strings);
+global $current_language;
+$smod_strings = return_module_language($current_language, 'Settings');
+$smarty->assign("MOD", $smod_strings);
+
+$smarty->assign("APP", $app_strings);
+
+$oGetUserGroups = new GetUserGroups();
+$oGetUserGroups->getAllUserGroups($focus->id);
+
+
+$smarty->assign("GROUP_COUNT",count($oGetUserGroups->user_groups));
+$smarty->assign("THEME", $theme);
+$smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
+$smarty->assign("ID", $focus->id);
+$smarty->assign("CATEGORY", $category);
+if(isset($focus->imagename) && $focus->imagename!='')
+{
+	$imagestring="<div id='track1' style='margin: 4px 0pt 0pt 10px; width: 200px; background-image: url(themes/images/scaler_slider_track.gif); background-repeat: repeat-x; background-position: left center; height: 18px;'>
+	<div class='selected' id='handle1' style='width: 18px; height: 18px; position: relative; left: 145px;cursor:pointer;'><img src='themes/images/scaler_slider.gif'></div>
+	</div><script language='JavaScript' type='text/javascript' src='include/scriptaculous/prototype.js'></script>
+<script language='JavaScript' type='text/javascript' src='include/js/slider.js'></script>
+
+	<div class='scale-image' style='padding: 10px; float: left; width: 83.415px;'><img src='test/user/".$focus->imagename."' width='100%'</div>
+	<p><script type='text/javascript' src='include/js/scale_demo.js'></script></p>";
+	//$smarty->assign("USER_IMAGE",$imagestring);
+}
+				
+if(isset($_REQUEST['modechk']) && $_REQUEST['modechk'] != '' )
+{
+	$modepref = $_REQUEST['modechk'];
+}
+	if($_REQUEST['modechk'] == 'prefview')
+		$parenttab = '';
+	else
+		$parenttab = 'Settings';
+
+$smarty->assign("PARENTTAB", $parenttab);
+
+if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id)
+		&& isset($default_user_name)
+		&& $default_user_name == $focus->user_name
+		&& isset($lock_default_user_name)
+		&& $lock_default_user_name == true	) {
+	$buttons = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='crmButton small edit' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='$focus->id'; this.form.action.value='EditView'; this.form.parenttab.value='$parenttab'\" type='submit' name='Edit' value='  ".$app_strings['LBL_EDIT_BUTTON_LABEL']."  '>";
+	$smarty->assign('EDIT_BUTTON',$buttons);
+}
+elseif (is_admin($current_user) || $_REQUEST['record'] == $current_user->id) {
+	$buttons = "<input title='".$app_strings['LBL_EDIT_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_EDIT_BUTTON_KEY']."' class='crmButton small edit' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='$focus->id'; this.form.action.value='EditView'; this.form.parenttab.value='$parenttab'\" type='submit' name='Edit' value='  ".$app_strings['LBL_EDIT_BUTTON_LABEL']."  '>";
+	$smarty->assign('EDIT_BUTTON',$buttons);
+	
+		$buttons = "<input title='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_TITLE']."' accessKey='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_KEY']."' class='crmButton password small' LANGUAGE=javascript onclick='return window.open(\"index.php?module=Users&action=ChangePassword&form=DetailView\",\"test\",\"width=320,height=200,resizable=no,scrollbars=0, toolbar=no, titlebar=no, left=200, top=226, screenX=100, screenY=126\");' type='button' name='password' value='".$mod_strings['LBL_CHANGE_PASSWORD_BUTTON_LABEL']."'>";
+		$smarty->assign('CHANGE_PW_BUTTON',$buttons);
+	
+	
+}
+if (is_admin($current_user)) 
+{
+	$buttons = "<input title='".$app_strings['LBL_DUPLICATE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DUPLICATE_BUTTON_KEY']."' class='crmButton small cancel' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.return_id.value='".$_REQUEST['record']."';this.form.action.value='EditView'\" type='submit' name='Duplicate' value=' ".$app_strings['LBL_DUPLICATE_BUTTON_LABEL']."'   >";
+	$smarty->assign('DUPLICATE_BUTTON',$buttons);
+	
+	//done so that only the admin user can see the customize tab button
+	if($_REQUEST['record'] != $current_user->id)
+	{
+		$buttons = "<input title='".$app_strings['LBL_DELETE_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_DELETE_BUTTON_KEY']."' class='classBtn' onclick=\"deleteUser('$focus->id')\" type='button' name='Delete' value='  ".$app_strings['LBL_DELETE_BUTTON_LABEL']."  '>";
+		$smarty->assign('DELETE_BUTTON',$buttons);
+	}
+
+	if($_SESSION['authenticated_user_roleid'] == 'administrator')
+	{
+		$buttons = "<input title='".$app_strings['LBL_LISTROLES_BUTTON_TITLE']."' accessKey='".$app_strings['LBL_LISTROLES_BUTTON_KEY']."' class='classBtn' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='TabCustomise'; this.form.action.value='listroles'; this.form.record.value= '". $current_user->id ."'\" type='submit' name='ListRoles' value=' ".$app_strings['LBL_LISTROLES_BUTTON_LABEL']." '>";
+		$smarty->assign('LISTROLES_BUTTON',$buttons);
+	}
+
+}
+
+if(is_admin($current_user))
+	$smarty->assign("IS_ADMIN", true);
+else
+	$smarty->assign("IS_ADMIN", false);
+
+$lead_tables = Array('vtiger_users','vtiger_user2role');
+$tabid = getTabid("Users");
+$validationData = getDBValidationData($lead_tables,$tabid);
+$data = split_validationdataArray($validationData);
+
+if($current_user->id == $_REQUEST['record'] || is_admin($current_user) == true)
+{
+$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']);
+$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
+$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+$smarty->assign("MODULE", 'Users');
+$smarty->assign("CURRENT_USERID", $current_user->id);
+$smarty->assign("HOMEORDER",$focus->getHomeOrder($focus->id));
+$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields));
+$smarty->assign("USERNAME",$focus->last_name.' '.$focus->first_name);
+
+//for check audittrail if it is enable or not
+$smarty->assign("AUDITTRAIL",$audit_trail);
+
+//Organization assignment
+$crmid=$focus->id;
+require('modules/Users/GetUserOrg.php');
+
+//Assign the organization details to the html output
+$smarty->assign("MULTISELECT_COMBO_BOX_ITEM_SEPARATOR_STRING", $org_separator);
+$smarty->assign("ALL_USER_ORGANIZATIONS", $smarty_allorgs);
+$smarty->assign("EDIT_USER_ORGANIZATIONS", $smarty_orgs);
+$smarty->assign("EDIT_USER_ORGUNITS", $smarty_orgunits);
+$smarty->assign("EDIT_USER_PRIMARY_ORGANIZATION", $curorg);
+$smarty->assign("EDIT_USER_ASSIGNED_ORGANIZATIONS", $assigned_org);
+$smarty->assign("EDIT_USER_PRIMARY_ORGUNITS", $prim_orgunits);
+
+$smarty->display("UserDetailView.tpl");
+}
+else
+{
+	$output = '<table border="0" cellpadding="5" cellspacing="0" height="450" width="100%">
+		<tr><td align = "center">
+		<div style="border: 3px solid rgb(153, 153, 153); background-color: rgb(255, 255, 255); width: 55%; position: relative; z-index: 10000000;">
+			<table border="0" cellpadding="5" cellspacing="0" width="98%">
+			<tr>
+				<td rowspan="2" width="11%">
+				  	<img src="themes/bluelagoon/images/denied.gif">
+				</td>
+				<td style="border-bottom: 1px solid rgb(204, 204, 204);" nowrap="nowrap" width="70%">
+					<span class="genHeaderSmall">'.$app_strings["LBL_PERMISSION"].'
+					</span>
+				</td>
+			</tr>
+			<tr>
+				<td class="small" align="right" nowrap="nowrap">
+					<a href="javascript:window.history.back();">'.$app_strings["LBL_GO_BACK"].'</a>
+					<br>
+				</td>
+			</tr>
+			</table>
+		</div>
+		</td></tr>
+	</table>';
+	echo $output;
+}
+
+
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/EditView.php Mon Apr 16 12:27:44 2007
@@ -42,7 +42,7 @@
 	$smarty->assign("ID",$_REQUEST['record']);
 	$mode='edit';
 	if (!is_admin($current_user) && $_REQUEST['record'] != $current_user->id) die ("Unauthorized access to user administration.");
-	$focus->retrieve_entity_info($_REQUEST['record'],'Users');
+    $focus->retrieve_entity_info($_REQUEST['record'],'Users');
 	$smarty->assign("USERNAME",$focus->last_name.' '.$focus->first_name);
 }else
 {
@@ -58,11 +58,6 @@
 	$focus->column_fields['user_password']='';
 	$focus->column_fields['confirm_password']='';
 }
-
-if(is_admin($current_user))
-	$smarty->assign("IS_ADMIN", true);
-else
-	$smarty->assign("IS_ADMIN", false);
 
 global $theme;
 $theme_path="themes/".$theme."/";
@@ -115,56 +110,9 @@
 }
 
 $smarty->assign("HOMEORDER",$focus->getHomeOrder($focus->id));
+$smarty->assign("DUPLICATE",$_REQUEST['isDuplicate']);
+
 $smarty->assign('PARENTTAB',$_REQUEST['parenttab']);
-
-//Organization assignment
-if( $mode == "create" ) {
-    $orgs = array();
-    $smarty_orgs = array($orgs);
-
-    //all organizations
-    $sql = "SELECT organizationname FROM vtiger_organizationdetails WHERE deleted=0";
-    $result = $adb->query($sql);
-    $allorgs = array();
-    while($org_result = $adb->fetch_array($result)) {
-	$key = $org_result["organizationname"];
-	$allorgs[$key] = '';
-    }
-    $smarty_allorgs = array($allorgs);
-
-    //Organization untis
-    $orgunits = array();
-    $smarty_orgunits = array($orgunits);
-
-    //The remaining field are intentially left blank
-    $curorg = "";
-    $assigned_org = "";
-    $prim_orgunits = "";
-    $org_separator = "<br>&nbsp;";
-
-    //Set up session variables
-    $_SESSION['all_user_organizations'] = $smarty_allorgs;
-    $_SESSION['edit_user_organizations'] = $smarty_orgs;
-    $_SESSION['edit_user_orgunits'] = $smarty_orgunits;
-    $_SESSION['edit_user_primary_organization'] = $curorg;
-    $_SESSION['edit_user_assigned_organization'] = $assigned_org;
-    $_SESSION['edit_user_primary_orgunits'] = $prim_orgunits;
-}
-
-//In case of edit mode use the predefined gathering fuction
-else {
-    $crmid = $focus->id;
-    require('modules/Users/GetUserOrg.php');
-}
-
-//Assign the organization details to the html output
-$smarty->assign("MULTISELECT_COMBO_BOX_ITEM_SEPARATOR_STRING", $org_separator);
-$smarty->assign("ALL_USER_ORGANIZATIONS", $smarty_allorgs);
-$smarty->assign("EDIT_USER_ORGANIZATIONS", $smarty_orgs);
-$smarty->assign("EDIT_USER_ORGUNITS", $smarty_orgunits);
-$smarty->assign("EDIT_USER_PRIMARY_ORGANIZATION", $curorg);
-$smarty->assign("EDIT_USER_ASSIGNED_ORGANIZATIONS", $assigned_org);
-$smarty->assign("EDIT_USER_PRIMARY_ORGUNITS", $prim_orgunits);
 
 $smarty->display('UserEditView.tpl');
 

Modified: vtigercrm/branches/5.1_jens/modules/Users/Forms.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/Forms.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/Forms.php Mon Apr 16 12:27:44 2007
@@ -40,6 +40,11 @@
 $lbl_user_email1 = $mod_strings['LBL_LIST_EMAIL'];
 $err_missing_required_fields = $app_strings['ERR_MISSING_REQUIRED_FIELDS'];
 $err_invalid_email_address = $app_strings['ERR_INVALID_EMAIL_ADDRESS'];
+$lbl_user_image=$mod_strings['User Image'];
+$the_emailid = $app_strings['THE_EMAILID'];
+$email_field_is = $app_strings['EMAIL_FILED_IS'].$err_invalid_email_address;
+$other_email_field_is = $app_strings['OTHER_EMAIL_FILED_IS'].$err_invalid_email_address;
+$yahoo_email_field_is = $app_strings['YAHOO_EMAIL_FILED_IS'].$err_invalid_email_address;
 
 $the_script  = <<<EOQ
 
@@ -52,6 +57,7 @@
 }
 
 function verify_data(form) {
+
 	var isError = false;
 	var errorMessage = "";
 	if (trim(form.email1.value) == "") {
@@ -82,6 +88,8 @@
 			oField_miss =form.confirm_password;
 		}
 	}
+
+
 	if (trim(form.user_name.value) == "") {
 		isError = true;
 		errorMessage += "\\n$lbl_user_name";
@@ -92,20 +100,30 @@
 		set_fieldfocus(errorMessage,oField_miss);
 	}
 	if (trim(form.email1.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email1.value)) {
-		alert("The email id '"+form.email1.value+"' in the email field is $err_invalid_email_address");
+		alert("$the_emailid"+form.email1.value+"$email_field_is");
 		form.email1.focus();
 		exit();
 	}
 	if (trim(form.email2.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email2.value)) {
-		alert("The email id '"+form.email2.value+"' in other email field is $err_invalid_email_address");
+		alert("$the_emailid"+form.email1.value+"$other_email_field_is");
 		form.email2.focus();
 		exit();
 	}
 	if (trim(form.yahoo_id.value) != "" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.yahoo_id.value)) {
-		alert("The email id '"+form.yahoo_id.value+"' in yahoo email field is $err_invalid_email_address");
+		alert("$the_emailid"+form.yahoo_id.value+"$yahoo_email_field_is");
 		form.yahoo_id.focus();
 		exit();
 	}
+
+
+
+	if(! upload_filter("imagename", "jpg|gif|bmp|png") )
+	{
+		form.imagename.focus();
+		return false;
+	}
+
+
 	if(form.mode.value != 'edit')
 	{
 		if(trim(form.user_password.value) != trim(form.confirm_password.value))

Modified: vtigercrm/branches/5.1_jens/modules/Users/GroupDeleteStep1.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/GroupDeleteStep1.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/GroupDeleteStep1.php Mon Apr 16 12:27:44 2007
@@ -1,115 +1,124 @@
-<?php
-
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
-
-require_once('include/database/PearDatabase.php');
-require_once('include/utils/utils.php');
-
-global $app_strings;
-global $mod_strings;
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-$delete_group_id = $_REQUEST['groupid'];
-$delete_group_name = fetchGroupName($delete_group_id);
-
-
-$output='';
-$output ='<div id="DeleteLay" class="layerPopup">
-<form name="deleteGroupForm" action="index.php">
-<input type="hidden" name="module" value="Users">
-<input type="hidden" name="action" value="DeleteGroup">
-<input type="hidden" name="delete_group_id" value="'.$delete_group_id.'">	
-<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
-<tr>
-	<td class=layerPopupHeading " align="left">'.$mod_strings['LBL_DELETE_GROUP'].'</td>
-	<td align="right" class="small"><img src="'.$image_path.'close.gif" border=0 alt="'.$app_strings["LBL_CLOSE"].'" title="'.$app_strings["LBL_CLOSE"].'" style="cursor:pointer" onClick="document.getElementById(\'DeleteLay\').style.display=\'none\'";></td>
-</tr>
-</table>
-<table border=0 cellspacing=0 cellpadding=5 width=95% align=center>
-<tr>
-	<td class="small">
-	<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
-	<tr>
-		<td width="50%" class="cellLabel small"><b>'.$mod_strings['LBL_DELETE_GROUPNAME'].'</b></td>
-		<td width="50%" class="cellText small"><b>'.$delete_group_name.'</b></td>
-	</tr>
-	<tr>
-		<td align="left" class="cellLabel small" nowrap><b>'.$mod_strings['LBL_TRANSFER_GROUP'].'</b></td>
-		<td align="left" class="cellText small">';
-		global $adb;	
-		$sql = "select groupid,groupname from vtiger_groups";
-		$result = $adb->query($sql);
-		$num_groups = $adb->num_rows($result);
-	
-		$sql1 = "select id,user_name from vtiger_users where deleted=0";
-		$result1= $adb->query($sql1);
-		$num_users = $adb->num_rows($result1);
-	
-
-		$output.= '<input name="assigntype" checked value="U" onclick="toggleAssignType(this.value)" type="radio">&nbsp;User';
-		if($num_groups > 1)
-		{
-			$output .= '<input name="assigntype"  value="T" onclick="toggleAssignType(this.value)" type="radio">&nbsp;Group';
-		}	
-	
-		$output .= '<span id="assign_user" style="display: block;">';
-
-		$output .= '<select class="select" name="transfer_user_id">';
-	
-
-		for($i=0;$i<$num_users;$i++)
-		{
-			$user_name=$adb->query_result($result1,$i,"user_name");
-			$user_id=$adb->query_result($result1,$i,"id");
-		
-	    		$output.='<option value="'.$user_id.'">'.$user_name.'</option>';
-		}	
-	
-		$output .='</select></span>';
-
-		if($num_groups > 1)
-		{	
-			$output .= '<span id="assign_team" style="display: none;">';
-	
-
-			$output.='<select class="select" name="transfer_group_id">';
-	
-			$temprow = $adb->fetch_array($result);
-			do
-			{
-				$group_name=$temprow["groupname"];
-				$group_id=$temprow["groupid"];
-				if($delete_group_id 	!= $group_id)
-				{
-    					$output.='<option value="'.$group_id.'">'.$group_name.'</option>';
-	    			}	
-			}while($temprow = $adb->fetch_array($result));
-			$output.='</select></span>';
-		}	
-
-		$output.='</td>
-	</tr>
-	</table>
-	</td>
-</tr>
-</table>
-<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
-<tr>
-	<td class="small" align="center"><input type="submit" name="Delete" value="'.$app_strings["LBL_SAVE_BUTTON_LABEL"].'" class="crmbutton small save">
-	</td>
-</tr>
-</table>
-</form></div>';
-
-echo $output;
-?>
+<?php
+
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+
+require_once('include/database/PearDatabase.php');
+require_once('include/utils/utils.php');
+
+global $app_strings;
+global $mod_strings;
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+$delete_group_id = $_REQUEST['groupid'];
+$delete_group_name = fetchGroupName($delete_group_id);
+
+
+$output='';
+$output ='<div id="DeleteLay" class="layerPopup" style="width:400px;">
+<form name="deleteGroupForm" action="index.php">
+<input type="hidden" name="module" value="Users">
+<input type="hidden" name="action" value="DeleteGroup">
+<input type="hidden" name="delete_group_id" value="'.$delete_group_id.'">	
+<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
+<tr>
+	<td class=layerPopupHeading " align="left">'.$mod_strings['LBL_DELETE_GROUP'].'</td>
+	<td align="right" class="small"><img src="'.$image_path.'close.gif" border=0 alt="'.$app_strings["LBL_CLOSE"].'" title="'.$app_strings["LBL_CLOSE"].'" style="cursor:pointer" onClick="document.getElementById(\'DeleteLay\').style.display=\'none\'";></td>
+</tr>
+</table>
+<table border=0 cellspacing=0 cellpadding=5 width=95% align=center>
+<tr>
+	<td class="small">
+	<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white>
+	<tr>
+		<td width="50%" class="cellLabel small"><b>'.$mod_strings['LBL_DELETE_GROUPNAME'].'</b></td>
+		<td width="50%" class="cellText small"><b>'.$delete_group_name.'</b></td>
+	</tr>
+	<tr>
+		<td align="left" class="cellLabel small" nowrap><b>'.$mod_strings['LBL_TRANSFER_GROUP'].'</b></td>
+		<td align="left" class="cellText small">';
+		global $adb;	
+		$sql = "select groupid,groupname from vtiger_groups";
+		$result = $adb->query($sql);
+		$num_groups = $adb->num_rows($result);
+	
+		$sql1 = "select id,user_name from vtiger_users where deleted=0";
+		$result1= $adb->query($sql1);
+		$num_users = $adb->num_rows($result1);
+	
+
+		$output.= '<input name="assigntype" checked value="U" onclick="toggleAssignType(this.value)" type="radio">&nbsp;User';
+		if($num_groups > 1)
+		{
+			$output .= '<input name="assigntype"  value="T" onclick="toggleAssignType(this.value)" type="radio">&nbsp;Group';
+		}	
+	
+		$output .= '<span id="assign_user" style="display: block;">';
+
+		$output .= '<select class="select" name="transfer_user_id">';
+	
+
+		for($i=0;$i<$num_users;$i++)
+		{
+			$user_name=$adb->query_result($result1,$i,"user_name");
+			$user_id=$adb->query_result($result1,$i,"id");
+			
+			if(strlen($user_name)>20)
+			{
+				$user_name=substr($user_name,0,20)."...";
+			}
+								
+	    		$output.='<option value="'.$user_id.'">'.$user_name.'</option>';
+		}	
+	
+		$output .='</select></span>';
+
+		if($num_groups > 1)
+		{	
+			$output .= '<span id="assign_team" style="display: none;">';
+	
+
+			$output.='<select class="select" name="transfer_group_id">';
+	
+			$temprow = $adb->fetch_array($result);
+			do
+			{
+				$group_name=$temprow["groupname"];
+				$group_id=$temprow["groupid"];
+				if($delete_group_id 	!= $group_id)
+				{
+					if(strlen($group_name)>20)
+					{
+						$group_name=substr($group_name,0,20)."...";
+					}
+    					$output.='<option value="'.$group_id.'">'.$group_name.'</option>';
+	    			}	
+			}while($temprow = $adb->fetch_array($result));
+			$output.='</select></span>';
+		}	
+
+		$output.='</td>
+	</tr>
+	</table>
+	</td>
+</tr>
+</table>
+<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
+<tr>
+	<td class="small" align="center"><input type="submit" name="Delete" value="'.$app_strings["LBL_SAVE_BUTTON_LABEL"].'" class="crmbutton small save">
+	</td>
+</tr>
+</table>
+</form></div>';
+
+echo $output;
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/Login.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/Login.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/Login.php Mon Apr 16 12:27:44 2007
@@ -86,95 +86,76 @@
 </script>
 
 
+<br><br>
+<div align="center">	
+	<table border="0" cellpadding="0" cellspacing="0" width="700">
+		<tr>
+			<td align="right"><img src="themes/images/honestCRMTop.gif"></td>
+		</tr>
+	</table>
+	<!-- Login Starts -->
+	<table border="0" cellspacing="0" cellpadding="0" width=700>
+		<tr>
+			<td class="bg" width="50%"><img src="themes/images/vtigerName.gif" alt="vtiger CRM" title="vtiger CRM"></td>
+			<td class="bg" align="right" width="50%"><img src="themes/images/honestCRM.gif" alt="The honest Open Source CRM" title="The honest Open Source CRM"></td>
+		</tr>
+		<tr>
+			<td class="small z1" align="center">
 
-<table border="0" cellspacing="0" cellpadding="0" width=100%>
-<tr>
-	<td align=center><br><br><br><br>
-	
-		<!-- Login Starts -->
-		<table border="0" cellspacing="0" cellpadding="0" width=700 style="border:2px solid rgb(119,119,119)">
-		<tr>
-			<td align=left>
-			
-			
-			<table border="0" cellspacing="0" cellpadding='0' width='100%' background="themes/images/loginTopHeaderBg.gif">
-			<tr>
-				<td align=left><img src="themes/images/loginTopHeaderName.gif"></td>
-				<td align=right><!--img src="themes/images/loginTopVersion.gif"--></td>
-			</tr>
-			</table>
-			<table border="0" cellspacing="0" cellpadding='10' width='100%'>
-			<tr>
-				<td align=left valign=top width=50% class=small style="padding:10px">
-					<!-- Promo Text and Image -->
-					<table border=0> 
+				<img src="themes/images/bullets.gif">
+			</td>
+	       		<td class="small z2" align="center">
+			<?php
+				if (isset($_REQUEST['ck_login_language_vtiger'])) {
+					$display_language = $_REQUEST['ck_login_language_vtiger'];
+				}
+				else {
+					$display_language = $default_language;
+				}
+
+				if (isset($_REQUEST['ck_login_theme_vtiger'])) {
+					$display_theme = $_REQUEST['ck_login_theme_vtiger'];
+				}
+				else {
+					$display_theme = $default_theme;
+				}
+			?>
+			<!-- Sign in form -->
+				<br>
+				<form action="index.php" method="post" name="DetailView" id="form">
+				<input type="hidden" name="module" value="Users">
+				<input type="hidden" name="action" value="Authenticate">
+				<input type="hidden" name="return_module" value="Users">
+				<input type="hidden" name="return_action" value="Login">
+					<table border="0" cellpadding="0" cellspacing="0" width="80%">
 					<tr>
-					<td>
-					<img src="themes/images/loginPromoText.gif" alt="vtiger CRM 5 - 100% Open Source CRM" title="vtiger CRM 5 - 100% Open Source CRM">
-					</td>
+						<td class="signinHdr"><img src="themes/images/signin.gif" alt="Sign in" title="Sign in"></td>
 					</tr>
 					<tr>
-					<td class=small style="padding-left:10px; color:#737373">
-- AJAX-based user interface<br>
-- Complete customer life cycle management<br>
-- Collaboration through e-mail, portal, and live chat<br>
-- Customization &  fine-grained security management<br>
-- Ready to use reports & dashboards<br>
-					</td>
-					</tr>
-					</table>
-					
-				</td>
-				<td align=center valign=top width=50%>
-					<?php
-						if (isset($_REQUEST['ck_login_language_vtiger'])) {
-							$display_language = $_REQUEST['ck_login_language_vtiger'];
-						}
-						else {
-							$display_language = $default_language;
-						}
-							
-						if (isset($_REQUEST['ck_login_theme_vtiger'])) {
-							$display_theme = $_REQUEST['ck_login_theme_vtiger'];
-						}
-						else {
-							$display_theme = $default_theme;
-						}
-					?>	
-					<!-- Sign in box -->
-					<form action="index.php" method="post" name="DetailView" id="form">
-					<input type="hidden" name="module" value="Users">
-					<input type="hidden" name="action" value="Authenticate">
-					<input type="hidden" name="return_module" value="Users">
-					<input type="hidden" name="return_action" value="Login">
-					<table border="0" cellspacing="0" cellpadding="0" width=100%>
-					<tr><td align=left><img src="themes/images/loginSignIn.gif" alt="Sign In" title="Sign In" border="0"></td></tr>
-					<tr>
-						<td background="themes/images/loginSignInShade.gif" style="background-repeat: repeat-x;" align=center valign=top class=small>
-						<br>
-							<table border=0 cellspacing=0 cellpadding=5 width=80% class="small">
-							<tr><td width=30% class=small align=right><?php echo $current_module_strings['LBL_USER_NAME'] ?></td><td width=70% class=small><input class="small" style="width:100%" type="text"  name="user_name"   value="<?php echo $login_user_name ?>" tabindex="1"></td></tr>
-							<tr><td class=small align=right><?php echo $current_module_strings['LBL_PASSWORD'] ?></td><td class=small><input class="small" style="width:100%" type="password" size='20' name="user_password"  value="<?php echo $login_password ?>" tabindex="2"></td></tr>
+						<td class="small">
+						<!-- form elements -->
+							<br>
+							<table border="0" cellpadding="5" cellspacing="0" width="100%">
 							<tr>
-								<td colspan=2 style="padding:0px">
-									<table border=0 cellspacing=0 cellpadding=5 width=100%>
-									<tr>
-									<td width=30% style="background-color:#efefef;" class=small align=right>	<?php echo $current_module_strings['LBL_THEME'] ?></td>
-									<td width=70% style="background-color:#efefef;"  class=small>
-									<select class='small' name='login_theme' style="width:100%" tabindex="3">	
-										<?php echo get_select_options_with_id(get_themes(), $display_theme) ?>										     </select>
-									</tr>		
-									<tr>
-									<td style="background-color:#efefef;" class=small align=right><?php echo $current_module_strings['LBL_LANGUAGE'] ?></td>
-									<td style="background-color:#efefef;"  class=small>
-									<select class='small' name='login_language' style="width:100%" vtiger_tabindex="4">
-																													<?php echo get_select_options_with_id(get_languages(), $display_language) ?>
-								        </select>
-									</tr>
-									</table>
-								</td>
+								<td class="small" align="right" width="30%"><?php echo $current_module_strings['LBL_USER_NAME'] ?></td>
+								<td class="small" align="left" width="70%"><input class="small" type="text" name="user_name" value="<?php echo $login_user_name ?>" tabindex="1"></td>
 							</tr>
-							<tr><td colspan=2>&nbsp;</td></tr>
+							<tr>
+								<td class="small" align="right" width="30%"><?php echo $current_module_strings['LBL_PASSWORD'] ?></td>
+								<td class="small" align="left" width="70%"><input class="small" type="password" size='20' name="user_password" value="<?php echo $login_password ?>" tabindex="2"></td>
+							</tr>
+							<tr bgcolor="#f5f5f5">
+								<td class="small" align="right" width="30%"><?php echo $current_module_strings['LBL_THEME'] ?></td>
+								<td class="small" align="left" width="70%"><select class="small" name='login_theme' style="width:70%" tabindex="3">
+									<?php echo get_select_options_with_id(get_themes(), $display_theme) ?>
+								</select></td>
+							</tr>
+							<tr bgcolor="#f5f5f5">
+								<td class="small" align="right" width="30%"><?php echo $current_module_strings['LBL_LANGUAGE'] ?></td>
+								<td class="small" align="left" width="70%"><select class="small" name='login_language' style="width:70%" tabindex="4">
+									<?php echo get_select_options_with_id(get_languages(), $display_language) ?>
+								</select></td>		
+							</tr>
 							<?php
 							if( isset($_SESSION['validation'])){
 							?>
@@ -188,44 +169,23 @@
 							?>
 							<tr>
 								<td colspan="2"><b class="small"><font color="Brown">
-								<?php echo $login_error ?>
-								</font>
-								</b>
-								</td>
+							<?php echo $login_error ?>
+								</font></b></td>
 							</tr>
 							<?php
 							}
 							?>
 							<tr>
-								<td colspan=2 style="padding:0px" align=center>
-								<input class=small title="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>" accesskey="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>"  type="image" src="themes/images/loginBtnSignIn.gif" name="Login" value="  <?php echo $current_module_strings['LBL_LOGIN_BUTTON_LABEL'] ?>  "  tabindex="5">	
-								</td>
+								<td class="small">&nbsp;</td>
+								<td class="small"><input title="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>" accesskey="<?php echo $current_module_strings['LBL_LOGIN_BUTTON_TITLE'] ?>" src="themes/images/btnSignInNEW.gif" type="image" name="Login" value="  <?php echo $current_module_strings['LBL_LOGIN_BUTTON_LABEL'] ?>  "  tabindex="5"></td>
 							</tr>
 							</table>
-						<br>
+							<br><br>
 						</td>
 					</tr>
 					</table>
-					
-				</td>
-			</tr>
-			</table>
-			
+				</form>
 			</td>
 		</tr>
-		</table>
-	
-			<!-- Shadow -->
-			<table border=0 cellspacing=0 cellpadding=0 width=700>
-			<tr>
-				<td><img src="themes/images/loginBottomShadowLeft.gif"></td>
-				<td width=100% background="themes/images/loginBottomShadowBg.gif"><img src="themes/images/loginBottomShadowBg.gif"></td>
-				<td><img src="themes/images/loginBottomShadowRight.gif"></td>
-			</tr>
-			</table>
-	
-	
-	
-	</td>
-</tr>
-</table>
+	</table>
+</div>

Modified: vtigercrm/branches/5.1_jens/modules/Users/RecalculateSharingRules.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/RecalculateSharingRules.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/RecalculateSharingRules.php Mon Apr 16 12:27:44 2007
@@ -11,7 +11,7 @@
 
 RecalculateSharingRules();
 
-header("Location: index.php?action=OrgSharingDetailView&parenttab=Settings&module=Users");
+header("Location: index.php?action=OrgSharingDetailView&parenttab=Settings&module=Settings");
 
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/RoleDragDrop.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/RoleDragDrop.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/RoleDragDrop.php Mon Apr 16 12:27:44 2007
@@ -14,7 +14,7 @@
 $fromid=$_REQUEST['childId'];
 
 
-global $adb;
+global $adb,$mod_strings;
 $query = "select * from vtiger_role where roleid='".$toid."'";
 $result=$adb->query($query);
 $parentRoleList=$adb->query_result($result,0,'parentrole');
@@ -27,7 +27,7 @@
 
 if(in_array($fromid,$parentRoles))
 {
-	echo 'You cannot move a Parent Node under a Child Node';
+	echo $mod_strings['ROLE_DRAG_ERR_MSG'];
         die;
 }
 
@@ -58,5 +58,5 @@
 
 
 
-header("Location: index.php?action=UsersAjax&module=Users&file=listroles&ajax=true");
+header("Location: index.php?action=SettingsAjax&module=Settings&file=listroles&ajax=true");
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/SaveGroup.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/SaveGroup.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/SaveGroup.php Mon Apr 16 12:27:44 2007
@@ -112,7 +112,7 @@
 		$groupMemberArray=constructGroupMemberArray($member_array);
 		updateGroup($groupId,$groupName,$groupMemberArray,$description);
 
-		$loc = "Location: index.php?action=".$returnaction."&module=Users&parenttab=Settings&groupId=".$groupId;
+		$loc = "Location: index.php?action=".$returnaction."&module=Settings&parenttab=Settings&groupId=".$groupId;
 	}
 	elseif(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'create')
 	{
@@ -120,7 +120,7 @@
 		$member_array = explode(';',$selected_col_string);
 		$groupMemberArray=constructGroupMemberArray($member_array);
 		$groupId=createGroup($groupName,$groupMemberArray,$description);
-		$loc = "Location: index.php?action=".$returnaction."&parenttab=Settings&module=Users&groupId=".$groupId; 	 
+		$loc = "Location: index.php?action=".$returnaction."&parenttab=Settings&module=Settings&groupId=".$groupId; 	 
 
 	}
 

Modified: vtigercrm/branches/5.1_jens/modules/Users/SaveOrgSharing.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/SaveOrgSharing.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/SaveOrgSharing.php Mon Apr 16 12:27:44 2007
@@ -39,6 +39,6 @@
 			
 		}
 }
-$loc = "Location: index.php?action=OrgSharingDetailView&module=Users&parenttab=Settings";
+$loc = "Location: index.php?action=OrgSharingDetailView&module=Settings&parenttab=Settings";
 header($loc);
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/SaveProfile.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/SaveProfile.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/SaveProfile.php Mon Apr 16 12:27:44 2007
@@ -13,8 +13,8 @@
 require_once('include/utils/UserInfoUtil.php');
 require_once('include/utils/utils.php');
 global $adb;
-$profilename = $_REQUEST['profile_name'];
-$description= $_REQUEST['profile_description'];
+$profilename = addslashes($_REQUEST['profile_name']);
+$description= addslashes($_REQUEST['profile_description']);
 $def_module = $_REQUEST['selected_module'];
 $def_tab = $_REQUEST['selected_tab'];
 //Inserting values into Profile Table
@@ -27,10 +27,17 @@
         $profileid = $adb->query_result($result2,0,'current_id');
 
 
-//Retreiving the vtiger_tabs permission array
-$tab_perr_result = $adb->query("select * from vtiger_profile2tab where profileid=1");
-$act_perr_result = $adb->query("select * from vtiger_profile2standardpermissions where profileid=1");
-$act_utility_result = $adb->query("select * from vtiger_profile2utility where profileid=1");
+	//Retreiving the vtiger_tabs permission array
+	//
+
+	//Retreiving the first profileid
+	$prof_query="select profileid from vtiger_profile order by profileid ASC";
+	$prof_result = $adb->query($prof_query);
+	$first_prof_id = $adb->query_result($prof_result,0,'profileid');
+
+$tab_perr_result = $adb->query("select * from vtiger_profile2tab where profileid=".$first_prof_id);
+$act_perr_result = $adb->query("select * from vtiger_profile2standardpermissions where profileid=".$first_prof_id);
+$act_utility_result = $adb->query("select * from vtiger_profile2utility where profileid=".$first_prof_id);
 $num_tab_per = $adb->num_rows($tab_perr_result);
 $num_act_per = $adb->num_rows($act_perr_result);
 $num_act_util_per = $adb->num_rows($act_utility_result);
@@ -154,7 +161,7 @@
 
 foreach($modArr as $fld_module => $fld_label)
 {
-	$fieldListResult = getProfile2FieldList($fld_module, 1);
+	$fieldListResult = getProfile2FieldList($fld_module, $first_prof_id);
 	$noofrows = $adb->num_rows($fieldListResult);
 	$tab_id = getTabid($fld_module);
 	for($i=0; $i<$noofrows; $i++)
@@ -171,7 +178,7 @@
 		}
 		//Updating the Mandatory vtiger_fields
 		$uitype = $adb->query_result($fieldListResult,$i,"uitype");
-		if($uitype == 2 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype == 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16)
+		if($uitype == 2 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype == 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16 || $uitype == 53)
 		{
 			$visible_value = 0;
 		}
@@ -180,7 +187,7 @@
                 $adb->query($sql11);
 	}
 }
-	$loc = "Location: index.php?action=ListProfiles&module=Users&mode=view&parenttab=Settings&profileid=".$profileid."&selected_tab=".$def_tab."&selected_module=".$def_module;
+	$loc = "Location: index.php?action=ListProfiles&module=Settings&mode=view&parenttab=Settings&profileid=".$profileid."&selected_tab=".$def_tab."&selected_module=".$def_module;
 	header($loc);
 
 

Modified: vtigercrm/branches/5.1_jens/modules/Users/UpdateProfileChanges.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/UpdateProfileChanges.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/UpdateProfileChanges.php Mon Apr 16 12:27:44 2007
@@ -162,7 +162,7 @@
 		}
 		//Updating the Mandatory vtiger_fields
 		$uitype = $adb->query_result($fieldListResult,$i,"uitype");
-		if($uitype == 2 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype == 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16)
+		if($uitype == 2 || $uitype == 6 || $uitype == 22 || $uitype == 73 || $uitype == 24 || $uitype == 81 || $uitype == 50 || $uitype == 23 || $uitype == 16 || $uitype == 53)
 		{
 			$visible_value = 0;
 		}
@@ -172,7 +172,14 @@
 
 	}
 }
-	$loc = "Location: index.php?action=".$return_action."&module=Users&mode=view&parenttab=Settings&profileid=".$profileid."&selected_tab=".$def_tab."&selected_module=".$def_module;
+	if($return_action == 'profilePrivileges' || $return_action == 'ListProfiles')
+	{
+		$loc = "Location: index.php?action=".$return_action."&module=Settings&mode=view&parenttab=Settings&profileid=".$profileid."&selected_tab=".$def_tab."&selected_module=".$def_module;
+	}
+	else
+	{
+		$loc = "Location: index.php?action=".$return_action."&module=Users&mode=view&parenttab=Settings&profileid=".$profileid."&selected_tab=".$def_tab."&selected_module=".$def_module;
+	}
 	header($loc);
 
  /** returns value 0 if request permission is on else returns value 1

Modified: vtigercrm/branches/5.1_jens/modules/Users/Users.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/Users.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/Users.php Mon Apr 16 12:27:44 2007
@@ -115,7 +115,7 @@
 	var $object_name = "User";
 	var $user_preferences;
 	var $defhomeview;
-	var $homeorder_array = array('ALVT','HDB','PLVT','QLTQ','CVLVT','HLT','OLV','GRT','OLTSO','ILTI','MNL','OLTPO','LTFAQ');
+	var $homeorder_array = array('HDB','ALVT','PLVT','QLTQ','CVLVT','HLT','OLV','GRT','OLTSO','ILTI','MNL','OLTPO','LTFAQ');
 
 	var $encodeFields = Array("first_name", "last_name", "description");
 
@@ -1185,7 +1185,8 @@
 			if($_REQUEST[$this->homeorder_array[$i]] != '')
 				$save_array[] = $this->homeorder_array[$i];
 		}
-		$homeorder = implode(',',$save_array);	
+		if(count($save_array))
+			$homeorder = implode(',',$save_array);	
 		$query = "update vtiger_users set homeorder ='$homeorder' where id=$id";
 		$adb->query($query);
                 $log->debug("Exiting from function saveHomeOrder($id)");

Modified: vtigercrm/branches/5.1_jens/modules/Users/UsersAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/UsersAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/UsersAjax.php Mon Apr 16 12:27:44 2007
@@ -11,27 +11,8 @@
 
 global $current_user;
 global $adb;
-
 if(isset($_REQUEST['file']) && ($_REQUEST['file'] !=''))
 {
 	require_once('modules/Users/'.$_REQUEST['file'].'.php');
 }
-if(isset($_REQUEST['orgajax']) && ($_REQUEST['orgajax'] !=''))
-{
-	require_once('modules/Users/CreateSharingRule.php');	
-}
-elseif(isset($_REQUEST['announce_save']) && ($_REQUEST['announce_save'] != ''))
-{
-	$date_var = date('YmdHis');
-	$announcement = $_REQUEST['announcement'];
-	$title = $_REQUEST['title_announcement'];
-	$sql="select * from vtiger_announcement where creatorid=".$current_user->id;
-	$is_announce=$adb->query($sql);
-	if($adb->num_rows($is_announce) > 0)
-		$query="update vtiger_announcement set announcement=".$adb->formatString("vtiger_announcement","announcement",$announcement).",time=".$adb->formatString("vtiger_announcement","time",$date_var).",title='announcement' where creatorid=".$current_user->id;
-	else
-		$query="insert into vtiger_announcement values (".$current_user->id.",".$adb->formatString("vtiger_announcement","announcement",$announcement).",'announcement',".$adb->formatString("vtiger_announcement","time",$date_var).")";
-	$result=$adb->query($query);
-	echo $announcement;
-}
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/about_us.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/about_us.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/about_us.php Mon Apr 16 12:27:44 2007
@@ -32,9 +32,10 @@
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>vtiger CRM 5 - Free, Commercial grade Open Source CRM</title>
-<link href="<? echo $theme_path;?>style.css" rel="stylesheet" type="text/css">
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $app_strings['LBL_CHARSET'];?>">
+<title><?php echo $mod_strings['TITLE_VTIGER_CRM_5'];?></title>
+<link href="<?php echo $theme_path;?>style.css" rel="stylesheet" type="text/css">
+<script language="javascript" type="text/javascript" src="include/js/popup.js"></script>
 </head>
 <style>
 	.rollOver{
@@ -68,14 +69,11 @@
 		text-align:left;
 		padding-bottom:1px;
 	}
-	
-	
-	
 </style>
 <body>
 <table border="0" cellpadding="0" cellspacing="0" width="500">
 		<tr>
-				<td colspan="3"><img src="<? echo $image_path;?>aboutUS.jpg" width="500" height="301"></td>
+				<td colspan="3"><img src="<?php echo $image_path;?>aboutUS.jpg" width="500" height="301"></td>
 		</tr>
 		<tr>
 				<td width="15%" style="border-left:2px solid #7F7F7F;">&nbsp;</td>
@@ -86,7 +84,9 @@
 										<tr><td>Anusha</td></tr>
 										<tr><td>Bharath</td></tr>
 										<tr><td>Bharathi</td></tr>
+										<tr><td>Dina</td></tr>
 										<tr><td>Don</td></tr>
+										<tr><td>Fenzik</td></tr>
 										<tr><td>Gopal</td></tr>
 										<tr><td>Jeri</td></tr>
 										<tr><td>Mani</td></tr>
@@ -96,6 +96,8 @@
 										<tr><td>Philip</td></tr>
 										<tr><td>Radiant</td></tr>
 										<tr><td>Richie</td></tr>
+										<tr><td>Shahul</td></tr>
+										<tr><td>Tamilmani</td></tr>
 										<tr><td>Vashni</td></tr>
 										<tr><td>&nbsp;</td></tr>
 										<tr><th><?php echo $mod_strings['LBL_CREDITS'];?></th></tr>
@@ -131,35 +133,35 @@
 										<tr><td>Valmir Carlos Trindade</td></tr>
 										<tr><td>&nbsp;</td></tr>
 										<tr><th><?php echo $mod_strings['LBL_CREDITS'];?> - <?php echo $mod_strings['LBL_THIRD_PARTY'];?></th></tr>
-										<tr><td><a href="http://adodb.sourceforge.net" target="_blank">ADOdb</a></td></tr>
-										<tr><td><a href="http://www.os-solution.com/demo/ajaxcsspopupchat/index.php" target="_blank">Ajax Popup Chat</a></td></tr>
-										<tr><td><a href="http://httpd.apache.org/" target="_blank">Apache HTTP Server</a></td></tr>
-										<tr><td><a href="http://www.linuxscope.net/articles/mailAttachmentsPHP.html" target="_blank">Attachments in E-mail Client</a></td></tr>
-										<tr><td><a href="http://www.hmhd.com/steve" target="_blank">Calculator</a></td></tr>
-										<tr><td><a href="http://www.dynamicdrive.com/dynamicindex14/carousel2.htm" target="_blank">Carousel Slideshow</a></td></tr>
-										<tr><td><a href="http://www.troywolf.com/articles/php/class_http/" target="_blank">class_http</a></td></tr>
-										<tr><td><a href="http://freshmeat.net/projects/phpexcelreader/" target="_blank">ExcelReader</a></td></tr>
-										<tr><td><a href="http://www.fckeditor.net/download/default.html" target="_blank">FCKeditor</a></td></tr>
-										<tr><td><a href="http://www.fpdf.org" target="_blank">FPDF</a></td></tr>
-										<tr><td><a href="http://www.getluky.net" target="_blank">freetag</a></td></tr>
-										<tr><td><a href="http://www.boutell.com/gd/" target="_blank">gdwin32</a></td></tr>
-										<tr><td><a href="http://pear.php.net/package/Image_Graph" target="_blank">Graph</a></td></tr>
-										<tr><td><a href="http://slayeroffice.com/code/imageCrossFade/xfade2.html" target="_blank">Image Crossfade Redux</a></td></tr>
-										<tr><td><a href="http://pear.php.net/pepr/pepr-proposal-show.php?id=212" target="_blank">Image_Canvas</a></td></tr>
-										<tr><td><a href="http://pear.php.net/package/Image_Color" target="_blank">Image_Color</a></td></tr>
-										<tr><td><a href="http://www.dynarch.com/projects/calendar/" target="_blank">jscalendar</a></td></tr>
-										<tr><td><a href="http://www.vxr.it/log4php/" target="_blank">log4php</a></td></tr>
-										<tr><td><a href="http://magpierss.sourceforge.net/" target="_blank">MagpieRSS</a></td></tr>
-										<tr><td><a href="http://wiki.wonko.com/software/mailfeed/" target="_blank">Mailfeed</a></td></tr>
-										<tr><td><a href="http://www.mysql.com" target="_blank">MySQL</a></td></tr>
-										<tr><td><a href="http://sourceforge.net/projects/nusoap" target="_blank">nusoap</a></td></tr>
-										<tr><td><a href="http://www.php.net" target="_blank">PHP</a></td></tr>
-										<tr><td><a href="http://phpmailer.sourceforge.net/" target="_blank">PHPMailer</a></td></tr>
-										<tr><td><a href="http://phpsysinfo.sourceforge.net/" target="_blank">phpSysinfo</a></td></tr>
-										<tr><td><a href="http://prototype.conio.net" target="_blank">Prototype</a></td></tr>
-										<tr><td><a href="http://script.aculo.us" target="_blank">script.oculo.us</a></td></tr>
-										<tr><td><a href="http://smarty.php.net/" target="_blank">Smarty Template Engine</a></td></tr>
-										<tr><td><a href="http://www.sugarcrm.com" target="_blank">SugarCRM</a> (SPL 1.1.2)</td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://adodb.sourceforge.net')">ADOdb</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.os-solution.com/demo/ajaxcsspopupchat/index.php')">Ajax Popup Chat</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://httpd.apache.org/')">Apache HTTP Server</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.linuxscope.net/articles/mailAttachmentsPHP.html')">Attachments in E-mail Client</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.hmhd.com/steve')">Calculator</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.dynamicdrive.com/dynamicindex14/carousel2.htm')">Carousel Slideshow</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.troywolf.com/articles/php/class_http/')">class_http</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://freshmeat.net/projects/phpexcelreader/')">ExcelReader</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.fckeditor.net/download/default.html')">FCKeditor</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.fpdf.org')">FPDF</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.getluky.net')">freetag</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.boutell.com/gd/')">gdwin32</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://pear.php.net/package/Image_Graph')">Graph</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://slayeroffice.com/code/imageCrossFade/xfade2.html')">Image Crossfade Redux</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://pear.php.net/pepr/pepr-proposal-show.php?id=212')">Image_Canvas</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://pear.php.net/package/Image_Color')">Image_Color</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.dynarch.com/projects/calendar/')">jscalendar</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.vxr.it/log4php/')">log4php</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://magpierss.sourceforge.net/')">MagpieRSS</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://wiki.wonko.com/software/mailfeed/')">Mailfeed</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.mysql.com')">MySQL</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://sourceforge.net/projects/nusoap')">nusoap</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.php.net')">PHP</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://phpmailer.sourceforge.net/')">PHPMailer</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://phpsysinfo.sourceforge.net/')">phpSysinfo</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://prototype.conio.net')">Prototype</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://script.aculo.us')">script.oculo.us</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://smarty.php.net/')">Smarty Template Engine</a></td></tr>
+										<tr><td><a href="javascript:;" onClick=" newpopup('http://www.sugarcrm.com')">SugarCRM</a> (SPL 1.1.2)</td></tr>
 										<tr><td>&nbsp;</td></tr>
 										<tr><td><b><?php echo $mod_strings['LBL_COMMUNITY'];?></b></td></tr>
 										<tr><td>&nbsp;</td></tr>
@@ -171,13 +173,13 @@
 		</tr>
 		<tr><td colspan="3"  style="border-left:2px solid #7F7F7F;border-right:2px solid #7F7F7F">&nbsp;</td></tr>
 		<tr>
-		  <td colspan="3" background="<? echo $image_path;?>about_btm.jpg" height="75">
+		  <td colspan="3" background="<?php echo $image_path;?>about_btm.jpg" height="75">
 		  		<table width="100%" border="0" cellpadding="5" cellspacing="0">
 						<tr>
 							<td width="70%" align="left" class="small">
 							<span class="small" style="color:#999999;"><?php echo $mod_strings['LBL_VERSION'] ." ".$patch_string;?></span>&nbsp;|&nbsp;
-									<a href="http://www.vtiger.com/copyrights/LICENSE_AGREEMENT.txt" target="_blank"><?php echo $mod_strings['LBL_READ_LICENSE'];?></a>&nbsp;|&nbsp;
-									<a href="http://www.vtiger.com/index.php?option=com_content&task=view&id=26&Itemid=54" target="_blank"><?php echo $mod_strings['LBL_CONTACT_US'];?></a>
+									<a href="javascript:;" onClick=" newpopup('http://www.vtiger.com/copyrights/LICENSE_AGREEMENT.txt')"><?php echo $mod_strings['LBL_READ_LICENSE'];?></a>&nbsp;|&nbsp;
+									<a href="javascript:;" onClick=" newpopup('http://www.vtiger.com/index.php?option=com_content&task=view&id=26&Itemid=54')"><?php echo $mod_strings['LBL_CONTACT_US'];?></a>
 							</td>
 							<td align="right">
 									<input type="button" name="close" value=" &nbsp;<?php echo $mod_strings['LBL_CLOSE'];?>&nbsp; " onClick="window.close();" class="crmbutton small cancel">

Modified: vtigercrm/branches/5.1_jens/modules/Users/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -1,621 +1,659 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/language/en_us.lang.php,v 1.18 2005/04/19 14:45:38 ray Exp $
- * Description:  Defines the English language pack for the Account module.
- ********************************************************************************/
- 
-$mod_strings = Array(
-'LBL_MODULE_NAME'=>'Users',
-'LBL_MODULE_TITLE'=>'Users: Home',
-'LBL_SEARCH_FORM_TITLE'=>'User Search',
-'LBL_LIST_FORM_TITLE'=>'User List',
-'LBL_NEW_FORM_TITLE'=>'New User',
-'LBL_CREATE_NEW_USER'=>'Create New User',
-'LBL_USER'=>'Users:',
-'LBL_LOGIN'=>'Login',
-'LBL_USER_ROLE'=>'Role',
-'LBL_LIST_NAME'=>'Name',
-'LBL_LIST_LAST_NAME'=>'Last Name',
-'LBL_LIST_USER_NAME'=>'User Name',
-'LBL_LIST_DEPARTMENT'=>'Department',
-'LBL_LIST_EMAIL'=>'E-Mail',
-'LBL_LIST_PRIMARY_PHONE'=>'Primary Phone',
-'LBL_LIST_ADMIN'=>'Admin',
-'LBL_LIST_PASSWORD'=>'Password',
-'LBL_LIST_CONFIRM_PASSWORD'=>'Confirm Password',
-'LBL_LIST_USER_NAME_ROLE'=>'User ID , Name & Role',
-'LBL_LIST_SELECT'=>'Select',
-'LBL_LIST_PHONE'=>'Phone',
-'LBL_LIST_NO'=>'#',
-
-'LBL_ADMINS'=>'Admins',
-'LBL_STD_USERS'=>'Standard Users',
-
-'UserName'=>'UserName',
-'Role'=>'Role',
-'Email'=>'Email',
-'Name'=>'Name',
-'Admin'=>'Admin',
-'Tools'=>'Tools',
-
-
-//added for patch2
-'LBL_GROUP'=>'Group',
-'LBL_CURRENCY_NAME'=>'Currency',
-
-'LBL_NEW_USER_BUTTON_TITLE'=>'New User [Alt+N]',
-'LBL_NEW_USER_BUTTON_LABEL'=>'New User',
-'LBL_NEW_USER_BUTTON_KEY'=>'N',
-'LBL_DATE_FORMAT'=>'Date Format',
-
-'LBL_ERROR'=>'Error:',
-'LBL_PASSWORD'=>'Password',
-'LBL_USER_NAME'=>'User Name',
-'LBL_CRM_ID'=>'CRM ID',
-'LBL_FIRST_NAME'=>'First Name',
-'LBL_LAST_NAME'=>'Last Name',
-'LBL_YAHOO_ID'=>'Yahoo ID',
-'LBL_USER_SETTINGS'=>'User Settings',
-'LBL_THEME'=>'Color Theme',
-'LBL_LANGUAGE'=>'Language',
-'LBL_ADMIN'=>'Admin',
-'LBL_USER_INFORMATION'=>'User Information',
-'LBL_OFFICE_PHONE'=>'Office Phone',
-'LBL_REPORTS_TO'=>'Reports to',
-'LBL_OTHER_PHONE'=>'Other Phone',
-'LBL_OTHER_EMAIL'=>'Other Email',
-'LBL_NOTES'=>'Notes',
-'LBL_DEPARTMENT'=>'Department',
-'LBL_STATUS'=>'Status',
-'LBL_TITLE'=>'Title',
-'LBL_ANY_PHONE'=>'Any Phone:',
-'LBL_ANY_EMAIL'=>'Any Email:',
-'LBL_ADDRESS'=>'Street Address',
-'LBL_CITY'=>'City',
-'LBL_STATE'=>'State',
-'LBL_POSTAL_CODE'=>'Postal Code',
-'LBL_COUNTRY'=>'Country',
-'LBL_NAME'=>'Name:',
-'LBL_USER_SETTINGS'=>'User Settings',
-'LBL_USER_INFORMATION'=>'User Information',
-'LBL_MOBILE_PHONE'=>'Mobile',
-'LBL_OTHER'=>'Other',
-'LBL_FAX'=>'Fax',
-'LBL_EMAIL'=>'E-Mail Id',
-'LBL_HOME_PHONE'=>'Home Phone',
-'LBL_ADDRESS_INFORMATION'=>'User Address',
-'LBL_CAL_HRFORMAT'=>'Calendar Time Format',
-'LBL_CAL_DURATION'=>'Day starts at',
-'LBL_PRIMARY_ADDRESS'=>'Primary Address:',
-
-'LBL_ORGANIZATION_INFORMATION'=>'Organizations',
-'LBL_PRIMARY_ORGANIZATION'=>'Primary organization',
-'LBL_ASSIGNED_ORGANIZATIONS'=>'Assigned to organizations',
-'LBL_PRIMARY_ORGUNITS'=>'Primary organization units',
-
-'LBL_CHANGE_PASSWORD_BUTTON_TITLE'=>'Change Password [Alt+P]',
-'LBL_CHANGE_PASSWORD_BUTTON_KEY'=>'P',
-'LBL_CHANGE_PASSWORD_BUTTON_LABEL'=>'Change Password',
-'LBL_LOGIN_BUTTON_TITLE'=>'Login [Alt+L]',
-'LBL_LOGIN_BUTTON_KEY'=>'L',
-'LBL_LOGIN_BUTTON_LABEL'=>'Login',
-'LBL_LOGIN_HISTORY_BUTTON_TITLE'=>'Login History [Alt+H]',
-'LBL_LOGIN_HISTORY_BUTTON_KEY'=>'H',
-'LBL_LOGIN_HISTORY_BUTTON_LABEL'=>'Login History',
-'LBL_LOGIN_HISTORY_TITLE'=>'Users: Login History',
-'LBL_RESET_PREFERENCES'=>'Reset To Default Preferences',
-
-'LBL_CHANGE_PASSWORD'=>'Change Password',
-'LBL_OLD_PASSWORD'=>'Old Password:',
-'LBL_NEW_PASSWORD'=>'New Password:',
-'LBL_CONFIRM_PASSWORD'=>'Confirm Password:',
-'ERR_ENTER_OLD_PASSWORD'=>'Please enter your old password.',
-'ERR_ENTER_NEW_PASSWORD'=>'Please enter your new password.',
-'ERR_ENTER_CONFIRMATION_PASSWORD'=>'Please enter your password confirmation.',
-'ERR_REENTER_PASSWORDS'=>'Please re-enter passwords.  The \"new password\" and \"confirm password\" values do not match.',
-'ERR_INVALID_PASSWORD'=>'You must specify a valid username and password.',
-'ERR_PASSWORD_CHANGE_FAILED_1'=>'User password change failed for ',
-'ERR_PASSWORD_CHANGE_FAILED_2'=>' failed.  The new password must be set.',
-'ERR_PASSWORD_INCORRECT_OLD'=>'Incorrect old password specified. Re-enter password information.',
-'ERR_USER_NAME_EXISTS_1'=>'The user name ',
-'ERR_USER_NAME_EXISTS_2'=>' already exists.  Duplicate user names are not allowed.<br>Change the user name to be unique.',
-'ERR_LAST_ADMIN_1'=>'The user name ',
-'ERR_LAST_ADMIN_2'=>' is the last Admin user.  At least one user must be an Admin user.<br>Check the Admin user setting.',
-
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
-
-// Additional Fields for i18n --- Release vtigerCRM 3.2 Patch 2
-// Users--listroles.php , createrole.php , ListPermissions.php , editpermissions.php
-
-'LBL_ROLES'=>'Roles',
-'LBL_ROLES_SUBORDINATES'=>'Roles and Subordinates',
-'LBL_ROLE_NAME'=>'Role Name',
-'LBL_CREATE_NEW_ROLE'=>'Create New Role',
-
-'LBL_CREATE_NEW_ROLE'=>'Create New Role',
-'LBL_INDICATES_REQUIRED_FIELD'=>'Indicates Required Field',
-'LBL_NEW_ROLE'=>'New Role',
-'LBL_PARENT_ROLE'=>'Parent Role',
-
-'LBL_LIST_ROLES'=>'List Roles',
-'LBL_ENTITY_LEVEL_PERMISSIONS'=>'Entity Level Permissions',
-'LBL_ENTITY'=>'Entity',
-'LBL_CREATE_EDIT'=>'Create/Edit',
-'LBL_DELETE'=>'Delete',
-'LBL_VIEW'=>'View',
-'LBL_LEADS'=>'Leads',
-'LBL_ACCOUNTS'=>'Accounts',
-'LBL_CONTACTS'=>'Contacts',
-'LBL_OPPURTUNITIES'=>'Opportunities',
-'LBL_TASKS'=>'Tasks',
-'LBL_CASES'=>'Cases',
-'LBL_EMAILS'=>'Emails',
-'LBL_NOTES'=>'Notes',
-'LBL_MEETINGS'=>'Meetings',
-'LBL_CALLS'=>'Calls',
-'LBL_IMPORT_PERMISSIONS'=>'Import Permissions',
-'LBL_IMPORT_LEADS'=>'Import Leads',
-'LBL_IMPORT_ACCOUNTS'=>'Import Accounts',
-'LBL_IMPORT_CONTACTS'=>'Import Contacts',
-'LBL_IMPORT_OPPURTUNITIES'=>'Import Opportunities',
-
-'LBL_ROLE_DETAILS'=>'Role Details',
-//added for vtigercrm4 rc
-'LBL_FILE'=> 'File Name',
-'LBL_FILE_TYPE'=>'File Type',
-'LBL_UPLOAD'=>'Upload File',
-'LBL_ATTACH_FILE'=>'Attach Mail Merge Template',
-'LBL_EMAIL_TEMPLATES'=>'Email Templates',
-'LBL_TEMPLATE_NAME'=>'Template Name',
-'LBL_TEMPLATE_HEADER'=>'Template',
-'LBL_TEMPLATE_DETAILS'=>'Template Details',
-'LBL_EDIT_TEMPLATE'=>'Edit Template',
-'LBL_TEMPLATE_FILE'=>'Template File',
-'LBL_DESCRIPTION'=>'Description',
-'LBL_EMAIL_TEMPLATES_LIST'=>'Communication Templates > Email Templates',
-'LBL_MAILMERGE_TEMPLATES_LIST'=>' > Communication Templates > Mail Merge Templates',
-'LBL_MAILMERGE_TEMPLATES_ATTACHMENT' => '> Communication Templates > Attach Mail Merge Template',
-'LBL_DOWNLOAD_NOW'=>'Download Now',
-'LBL_DOWNLOAD'=>'Download',
-'LBL_SELECT_MODULE'=>'Select Module',
-'LBL_MERGE_FILE'=>'File : ',
-'LBL_MERGE_MSG'=>'Select a module to assign this Template',
-'LBL_MERGE_FIELDS'=>'Merge Fields',
-'LBL_COPY_PASTE'=>'Copy & Paste',
-'LNK_GO_TO_TOP'=>'Go to Page Top',
-'LNK_SAMPLE_EMAIL'=>'View Sample Email',
-'LBL_COLON'=>':',
-'LBL_EMAIL_TEMPLATE'=>'Email Template',
-'LBL_NEW_TEMPLATE'=>'New Template',
-'LBL_ADD_TEMPLATE'=>'Add Template',
-'LBL_USE_MERGE_FIELDS_TO_EMAIL_CONTENT'=>'Use merge fields to personalize your email content.',
-'LBL_AVAILABLE_MERGE_FIELDS'=>'Available Merge Fields',
-'LBL_SELECT_FIELD_TYPE'=>'Select Field Type',
-'LBL_SELECT_FIELD'=>'Select Field :',
-'LBL_MERGE_FIELD_VALUE'=>'Copy Merge Field Value :',
-'LBL_ACCOUNT_FIELDS'=>'Account Fields',
-'LBL_CONTACT_FIELDS'=>'Contact Fields',
-'LBL_LEAD_FIELDS'=>'Lead Fields',
-'LBL_COPY_AND_PASTE_MERGE_FIELD'=>'Copy and paste the merge field value into your template below.',
-'LBL_EMAIL_TEMPLATE_INFORMATION'=>'Communication Templates > Email Templates > Viewing',
-'LBL_FOLDER'=>'Folder',
-'LBL_PERSONAL'=>'Personal',
-'LBL_PUBLIC'=>'Public',
-'LBL_TEMPLATE_NAME'=>'Template Name:',
-'LBL_SUBJECT'=>'Subject',
-'LBL_BODY'=>'Email Body',
-'LBL_TEMPLATE_TOOLS'=>'Tools',
-'LBL_TEMPLATE_PUBLIC'=>'Public Access',
-'LBL_TEMPLATE_PRIVATE'=>'Private Access',
-'LBL_TEMPLATE_SUBJECT'=>'Email Subject',
-'LBL_TEMPLATE_MESSAGE'=>'Email Message',
-'LBL_VIEWING'=>'Viewing',
-'LBL_PROPERTIES'=>'Properties of',
-
-
-
-// Added fields in createnewgroup.php
-'LBL_CREATE_NEW_GROUP'=>'Create New Group',
-'LBL_NEW_GROUP'=>'New Group',
-'LBL_EDIT_GROUP'=>'Edit Group',
-'LBL_GROUP_NAME'=>'Group Name',
-'LBL_GROUP_DETAILS'=>'Group Details',
-'LBL_MEMBER'=>'Members',
-'LBL_MEMBER_AVLBL'=>'Available Entities & Members',
-'LBL_MEMBER_SELECTED'=>'Selected Members',
-'LBL_DESCRIPTION'=>'Description',
-'LBL_GROUP_MESG1'=>'Groups are a flexible way to assign access rights, when complex access rights has to be defined. You can combine multiple entities like Roles, Users, profiles etc into a single group.',
-'LBL_GROUP_MESG2'=>'To add, select the Entity members from left and click the ">>" button.',
-'LBL_GROUP_MESG3'=>'To remove, select the group members from the right and click the "<<" button.',
-
-
-// Added fields in detailViewmailtemplate.html,listgroupmembers.php,listgroups.php
-'LBL_DETAIL_VIEW_OF_EMAIL_TEMPLATE'=>'Detail View of Email Template',
-'LBL_DETAIL_VIEW'=>'Detail View of',
-'LBL_EDIT_VIEW'=>'Editing details of the user',
-'LBL_EDITING'=>'Editing user',
-'LBL_GROUP_MEMBERS_LIST'=>'Group members list',
-'LBL_GROUPS'=>'Groups',
-'LBL_MY_GROUPS'=>'My Groups',
-'LBL_ADD_GROUP_BUTTON'=>'Add Group',
-'LBL_WORD_TEMPLATES'=>'Mail Merge Templates',
-'LBL_NEW_WORD_TEMPLATE'=>'New Template',
-'LBL_EMAIL_TEMPLATE_DESC'=>'Manage email templates used for Campaigns and Mass mailing',
-'LBL_NAME'=>'Name',
-
-// Added fields in TabCustomise.php,html and UpdateTab.php,html
-'LBL_CUSTOMISE_TABS'=>'Customize Tabs',
-'LBL_CHOOSE_TABS'=>'Choose Tabs',
-'LBL_AVAILABLE_TABS'=>'Available Tabs',
-'LBL_SELECTED_TABS'=>'Selected Tabs',
-'LBL_USER'=>'User',
-'LBL_TAB_MENU_UPDATED'=>'Tab Menu Updated! kindly go to ',
-'LBL_TO_VIEW_CHANGES'=>' to view the changes',
-
-// Added to change homepage order
-'LBL_CHANGE_HOMEPAGE_LABEL'=>'Homepage Order',
-'LBL_CHANGE_HOMEPAGE_TITLE'=>'Homepage',
-
-// Added fields in binaryfilelist.php
-'LBL_OERATION'=>'Operation',
-
-// Added fields in CreateProfile.php
-'LBL_PROFILE_NAME'=>'Create New Profile:',
-'LBL_NEW_PROFILE'=>'New Profile',
-'LBL_NEW_PROFILE_NAME'=>'Profile Name',
-'LBL_PARENT_PROFILE'=>'Parent Profile',
-'LBL_BASIC_PROFILE_DETAILS'=>'Basic details of Profile',
-'LBL_STEP_1_2'=>'Step 1 of 2',
-'LBL_STEP_2_2'=>'Step 2 of 2',
-'LBL_STEP'=>'Step',
-'LBL_SELECT_BASE_PROFILE'=>'Select Base Profile',
-'LBL_PROFILE_PRIVILEGES'=>'Profile Privileges',
-'LBL_GLOBAL_PRIVILEGES'=>'Global Privileges',
-'LBL_TAB_PRIVILEGES'=>'Tab Privileges',
-'LBL_FIELD_PRIVILEGES'=>'Field Privileges',
-'LBL_STANDARD_PRIVILEGES'=>'Standard Privileges',
-'LBL_UTILITY_PRIVILEGES'=>'Utility Privileges',
-'LBL_UTILITIES'=>'Utilities',
-'LBL_BASE_PROFILE_MESG'=>'I would like to setup a base profile and edit privileges <b>(Recommended)</b>',
-'LBL_BASE_PROFILE'=>'Base Profile:',
-'LBL_OR'=>'OR',
-'LBL_BASE_PROFILE_MESG_ADV'=>'I will choose the privileges from scratch <b>(Advanced Users)</b>',
-'LBL_FOR'=>'for',
-'LBL_GLOBAL_MESG_OPTION'=>'Select the options below to change global privileges',
-'LBL_VIEW_ALL'=>'View all',
-'LBL_EDIT_ALL'=>'Edit all',
-'LBL_ALLOW'=>'Allows',
-'LBL_MESG_VIEW'=>'to view all information / modules of vtiger CRM',
-'LBL_MESG_EDIT'=>'to edit all information / modules of vtiger CRM',
-'LBL_STD_MESG_OPTION'=>'Select the standard actions to be permitted',
-'LBL_TAB_MESG_OPTION'=>'modules to be shown',
-'LBL_UTILITY_MESG_OPTION'=>'Select the utility actions to be permitted',
-'LBL_FIELD_MESG_OPTION'=>'Select the fields to be permitted',
-'LBL_FINISH_BUTTON'=>'Finish',
-'LBL_PROFILE_DETAIL_VIEW'=>'Detail View of Profile',
-'LBL_PROFILE_MESG'=>'Viewing access privileges for',
-'LBL_PROFILE_M'=>'Profile',
-'LBL_DEFINE_PRIV_FOR'=>' Define Privileges for ',
-'LBL_USE_OPTION_TO_SET_PRIV'=>'Use the options below to set privileges',
-'LBL_SUPER_USER_PRIV'=>'Global Privileges',
-'LBL_SET_PRIV_FOR_EACH_MODULE'=>'Set Privileges for each Module ',
-'LBL_FIELDS_AND_TOOLS_SETTINGS'=>'Fields & Tools Settings',
-'LBL_SHOW_FIELDS'=>'Show Fields',
-'LBL_TOOLS_TO_BE_SHOWN'=>'Tools to be shown',
-'LBL_WELCOME_PROFILE_CREATE'=>'Welcome to Privilege Profile Creator ',
-'LBL_SELECT_CHOICE_NEW_PROFILE'=>'Select your choice of creating the new profile',
-'LBL_ADD_CUSTOM_RULE'=>'Add Custom Privilege Rule',
-'LBL_EDIT_CUSTOM_RULE'=>'Edit Custom Privilege Rule',
-'LBL_CLOSE'=>'Close',
-'LBL_SELECT_ENTITY'=>'Select an entity below',
-'LBL_CAN_BE_ACCESSED_BY'=>'Can be accessed by',
-'LBL_PERMISSIONS'=>'Permissions',
-'LBL_ACCESS_RIGHTS_FOR_MODULES'=>'Access rights for relative modules',
-'LBL_RULE_CONSTRUCTION'=>'Rule Construction Display',
-'LBL_ADD_RULE'=>'Add Rule',
-'LBL_RELATED_MODULE_RIGHTS'=>'Related Module Rights',
-'LBL_IN_PERMISSION'=>'in the permission',
-
-//Added fields in createrole.php
-'LBL_HDR_ROLE_NAME'=>'Create New Role:',
-'LBL_TITLE_ROLE_NAME'=>'New Role',
-'LBL_ROLE_NAME'=>'Role Name',
-'LBL_ROLE_PROFILE_NAME'=>'Associate With Profile',
-'LBL_SPECIFY_ROLE_NAME'=>'Specify a name for new role :',
-'LBL_ASSIGN_PROFILE'=>'Assign Profile(s)',
-'LBL_PROFILE_SELECT_TEXT'=>'Select the Profiles below and click on assign button',
-'LBL_PROFILES_AVLBL'=>'Profiles Available',
-'LBL_ASSIGN_PROFILES'=>'Assigned Profiles',
-'LBL_REPORTS_TO_ROLE'=>'Reports to Role',
-'LBL_ASSOCIATED_PROFILES'=>'Associated Profiles :',
-'LBL_ASSOCIATED_USERS'=>'Associated Users :',
-
-
-//Added fields in OrgSharingDetailsView.php
-'LBL_ORG_SHARING_PRIVILEGES'=>'Organisation Sharing  Privileges',
-'LBL_EDIT_PERMISSIONS'=>'Edit Permissions',
-'LBL_SAVE_PERMISSIONS'=>'Save Permissions',
-'LBL_READ_ONLY'=>'Public: Read Only',
-'LBL_EDIT_CREATE_ONLY'=>'Public: Read, Create/Edit',
-'LBL_READ_CREATE_EDIT_DEL'=>'Public: Read, Create/Edit, Delete',
-'LBL_PRIVATE'=>'Private',
-
-//Added fields in listnotificationschedulers.php
-'LBL_HDR_EMAIL_SCHDS'=>'Users : Email Notifications',
-'LBL_EMAIL_SCHDS_DESC'=>'The following is the list of notifications that are activated automatically when the corresponding event has happened.',
-'LBL_ACTIVE'=>'Active',
-'LBL_INACTIVE'=>'Inactive',
-'LBL_NOTIFICATION'=>'Notification',
-'LBL_DESCRIPTION'=>'Description',
-'LBL_TASK_NOTIFICATION'=>'Delayed Task Notification',
-'LBL_TASK_NOTIFICATION_DESCRITPION'=>'Notify when a task is delayed beyond 24 hrs',
-'LBL_MANY_TICKETS'=>'Too many tickets  Notification',
-'LBL_MANY_TICKETS_DESCRIPTION'=>'Notify when a particular entity is allocated too many tickets, might reflect Service Level commitments',
-'LBL_PENDING_TICKETS'=>'Pending Tickets Notification',
-'LBL_TICKETS_DESCRIPTION'=>'Notify for getting attention to status of tickets which are pending',
-'LBL_START_NOTIFICATION'=>'Support Start Notification',
-'LBL_START_DESCRIPTION'=>'Notifiy stating the start of support/service',
-'LBL_BIG_DEAL'=>'Big Deal Notification',
-'LBL_BIG_DEAL_DESCRIPTION'=>'Notify on completion of big deal',
-'LBL_SUPPORT_NOTICIATION'=>'Support End Notification',
-'LBL_SUPPORT_DESCRIPTION'=>'Notify when support is about to end',
-'LBL_BUTTON_UPDATE'=>'Update',
-'LBL_MODULENAMES'=>'Module',
-
-//Added fields in ListFieldPermissions.html
-'LBL_FIELD_PERMISSION_FIELD_NAME'=>'Field Name',
-'LBL_FIELD_PERMISSION_VISIBLE'=>'Visible',
-'LBL_FIELD_PERMISSIOM_TABLE_HEADER'=>'Standard Fields',
-'LBL_FIELD_LEVEL_ACCESS'=>'Field Level Access',
-
-//Added fields after 4.0.1
-'LBL_SIGNATURE'=>'Signature',
-
-//Added for Event Reminder 4.2 Alpha release
-'LBL_ACTIVITY_NOTIFICATION'=>'Event Reminder Notification',
-'LBL_ACTIVITY_REMINDER_DESCRIPTION'=>'Notify before an event to occur based on the reminder set',
-'LBL_MESSAGE'=>'Message',
-
-//Added for Global Privileges
-
-'Public: Read Only'=>'Public: Read Only',
-'Public: Read, Create/Edit'=>'Public: Read, Create/Edit',
-'Public: Read, Create/Edit, Delete'=>'Public: Read, Create/Edit, Delete',
-'Private'=>'Private',
-'Hide Details'=>'Hide Details',
-'Hide Details and Add Events'=>'Hide Details and Add Events',
-'Show Details'=>'Show Details',
-'Show Details and Add Events'=>'Show Details and Add Events',
-
-'LBL_USR_CANNOT_ACCESS'=>'Users cannot access other users ',
-'LBL_USR_CAN_ACCESS'=>'Users can ',
-'LBL_USR_OTHERS'=>' other users ',
-
-'Read Only '=>'Read Only ',
-'Read, Create/Edit, Delete '=>'Read, Create/Edit, Delete ',
-'Read, Create/Edit '=>'Read, Create/Edit ',
-'Read/Write'=>'Read/Write',
-'LBL_GO_TO_TOP'=>'Go to Top',
-'LNK_CLICK_HERE'=>'Click here',
-'LBL_RULE_NO'=>'Rule No.',
-'LBL_CAN_BE_ACCESSED'=>'can be accessed by',
-'LBL_PRIVILEGES'=>'Privileges',
-'LBL_OF'=>'of',
-
-
-
-//Added for 4.2GA support for mail server integration
-'LBL_ADD_MAILSERVER_BUTTON_TITLE'=>'Add Mail Server',
-'LBL_ADD_MAILSERVER_BUTTON_KEY'=>'M',
-'LBL_ADD_MAILSERVER_BUTTON_LABEL'=>'Add Mail Server',
-
-'LBL_LIST_MAILSERVER_BUTTON_TITLE'=>'List Mail Server',
-'LBL_LIST_MAILSERVER_BUTTON_KEY'=>'L',
-'LBL_LIST_MAILSERVER_BUTTON_LABEL'=>'List Mail Server',
-//added for inventory terms and conditions
-'INV_TANDC'=>'Terms & Coditions',
-'INV_TERMSANDCONDITIONS'=>'Inventory Terms & Coditions',
-'LBL_INV_TERMSANDCONDITIONS'=>'Inventory Management', 
-
-
-'INVENTORYNOTIFICATION'=>'Inventory Notifications',
-'LBL_INVENTORY_NOTIFICATIONS'=>'Edit Inventory Email Notifications',
-'LBL_INV_NOT_DESC'=>'The following are the list of notifications that are sent to the product handler regarding the demand and the current quantity in hand during the creation of a Quote, SalesOrder and Invoice.',
-
-'InvoiceNotification'=>'Product Stock Notification during Invoice Generation',
-'InvoiceNotificationDescription'=>'When the product stock level goes below the re-order level, notification will be sent to the product handler',
-
-'QuoteNotification'=>'Product Stock Notification during Quote Generation',
-'QuoteNotificationDescription'=>'During quote generation if the product stock in warehouse is lesser than the  quantity mentioned in quote then this notification will be sent to the product handler',
-
-'SalesOrderNotification'=>'Product Stock Notification during Sales Order Generation',
-'SalesOrderNotificationDescription'=>'During sales order generation if the product stock in warehouse is lesser than the quantity mentioned in sales order then this notification will be sent to the product handler',
-
-//New addition for 4.2 GA
-'LBL_USER_FIELDS'=>'User Fields',
-'LBL_NOTE_DO_NOT_REMOVE_INFO'=>'Note: Donot remove or alter the values within {  }',
-
-//Added for patch2
-'LBL_FILE_INFORMATION'=>'File Information',
-
-//Added after pathc2
-'LBL_LEAD_FIELD_ACCESS'=>'Lead Field Access',
-
-'LBL_ACCOUNT_FIELD_ACCESS'=>'Account Field Access',
-
-'LBL_CONTACT_FIELD_ACCESS'=>'Contact Field Access',
-
-'LBL_OPPORTUNITY_FIELD_ACCESS'=>'Potential Field Access',
-
-'LBL_HELPDESK_FIELD_ACCESS'=>'HelpDesk Field Access',
-
-'LBL_PRODUCT_FIELD_ACCESS'=>'Product Field Access',
-
-'LBL_NOTE_FIELD_ACCESS'=>'Note Field Access',
-
-'LBL_EMAIL_FIELD_ACCESS'=>'Email Field Access',
-
-'LBL_TASK_FIELD_ACCESS'=>'Task Field Access',
-
-'LBL_EVENT_FIELD_ACCESS'=>'Event Field Access',
-'LBL_VENDOR_FIELD_ACCESS'=>'Vendor Field Access',
-'LBL_PB_FIELD_ACCESS'=>'PriceBook Field Access',
-'LBL_QUOTE_FIELD_ACCESS'=>'Quote Field Access',
-'LBL_PO_FIELD_ACCESS'=>'Purchase Order Field Access',
-'LBL_SO_FIELD_ACCESS'=>'Sales Order Access',
-'LBL_INVOICE_FIELD_ACCESS'=>'Invoice Field Access',
-
-//given for calendar color for an user user
-'LBL_COLOR'=>'Color in Calendar',
-//added for activity view in home page
-'LBL_ACTIVITY_VIEW'=>'Default Activity View',
-//Added to change Home page order
-'LBL_HOMEPAGE_ORDER_UPDATE'=>'Update Home Page Block Order',
-'LBL_HOMEPAGE_ID'=>'Block Order',
-'ERR_INVALID_USER'=>'Invalid access--Please call from My Accounts',
-'ALVT'=>'Top Accounts',
-'PLVT'=>'Top Potentials',
-'QLTQ'=>'Top Quotes',
-'CVLVT'=>'Key Metrics',
-'HLT'=>'Top Trouble Tickets',
-'OLV'=>'Upcoming & Pending Activities',
-'GRT'=>'My Group Allocation',
-'OLTSO'=>'Top Sales Orders',
-'ILTI'=>'Top Invoices',
-'HDB'=>'Home Page Dashboard',
-'OLTPO'=>'Top Purchase Orders',
-'LTFAQ'=>'My Recent FAQs',
-
-//Added for 5.0 alpha
-'LBL_GROUP_NAME_ERROR'=>'Group Name already exists!',
-'MNL'=>'My New Leads',
-'LBL_LEAD_VIEW'=>'Default Leads View',
-'LBL_TAG_CLOUD'=>'Tag Cloud',
-'LBL_LIST_TOOLS'=>'Tools',
-'LBL_STATISTICS'=>'Statistics',
-'LBL_TOTAL'=>'Total :',
-'LBL_OTHERS'=>'Others :',
-'LBL_USERS'=>'User(s)',
-'LBL_USER_LOGIN_ROLE'=>'User Login & Role',
-'LBL_USER_MORE_INFN'=>'More Information',
-'LBL_USER_ADDR_INFN'=>'Address Information',
-'LBL_USER_IMAGE'=>'User Image',
-'LBL_USR'=>'Users',
-
-'LBL_MY'=>'My',
-'LBL_MY_DEFAULTS'=>'My Defaults',
-'LBL_MY_DESG'=>'My Designation & Contact Details',
-'LBL_MY_ADDR'=>'My Postal Address',
-'LBL_MY_DETAILS'=>'My Details',
-'LBL_MY_PHOTO'=>'My Photo',
-'LBL_CHANGE_PHOTO'=>'Change Photo...',
-'LBL_CHANGE'=>'Change',
-
-
-//Added for Access Privileges
-
-'LBL_GLOBAL_FIELDS_MANAGER'=>'Global Fields Manager',
-'LBL_GLOBAL_ACCESS_PRIVILEGES'=>'Organization-level Sharing Rules',
-'LBL_CUSTOM_ACCESS_PRIVILEGES'=>'Custom Sharing Rules',
-'LBL_BOTH'=>'Both',
-'LBL_VIEW'=>'View',
-'LBL_RECALCULATE_BUTTON'=>'Recalculate',
-'LBL_ADD_PRIVILEGES_BUTTON'=>'Add Privileges',
-'LBL_CUSTOM_ACCESS_MESG'=>'No Custom Access Rules defined .',
-'LBL_CREATE_RULE_MESG'=>'to create a new Rule',
-'LBL_SELECT_SCREEN'=>'Select the Screen / Module :',
-'LBL_FIELDS_AVLBL'=>'Fields Available in',
-'LBL_FIELDS_SELECT_DESELECT'=>'Fields to be shown',
-'LBL_ROLE_TO_BE_DELETED'=>'Role to be Deleted',
-'LBL_TRANSFER_USER_ROLE'=>'Transfer Users to Role',
-'LBL_DELETE_ROLE'=>'Delete Role',
-'LBL_MORE_INFORMATION'=>'More Information',
-'LBL_USERLOGIN_ROLE'=>'User Login & Role',
-'LBL_USER_IMAGE_INFORMATION'=>'User Photograph',
-
-//Added for 5.0 for all fields
-'Role'=>'Role',
-'Email'=>'Email',
-'Admin'=>'Admin',
-'User Name'=>'User Name',
-'First Name'=>'First Name',
-'Last Name'=>'Last Name',
-'Status'=>'Status',
-'Default Activity View'=>'Default Calendar View',
-'Default Lead View'=>'Default Lead View',
-'Currency'=>'Currency',
-'Title'=>'Title',
-'Office Phone'=>'Office Phone',
-'Department'=>'Department',
-'Mobile'=>'Mobile',
-'Reports To'=>'Reports To',
-'Other Phone'=>'Other Phone',
-'Other Email'=>'Other Email',
-'Fax'=>'Fax',
-'Yahoo id'=>'Yahoo id',
-'Home Phone'=>'Home Phone',
-'User Image'=>'Upload Photograph',
-'Date Format'=>'Date Format',
-'Tag Cloud'=>'Tag Cloud',
-'Signature'=>'Signature',
-'Notes'=>'Notes',
-'Street Address'=>'Street Address',
-'City'=>'City',
-'State'=>'State',
-'Postal Code'=>'Postal Code',
-'Country'=>'Country',
-'Password'=>'Password',
-'Confirm Password'=>'Confirm Password',
-'LBL_SHOWN'=>'Shown',
-'LBL_HIDDEN'=>'Hidden',
-'LBL_SHOW'=>'Show',
-'LBL_HIDE'=>'Hide',
-'LBL_HOME_PAGE_COMP'=>'Home Page Components',
-'LBL_LOGIN_HISTORY'=>'Login History',
-'LBL_USERDETAIL_INFO'=>'Viewing details about the user',
-'LBL_DELETE_GROUP'=>'Delete Group',
-'LBL_DELETE_GROUPNAME'=>'Group to be Deleted',
-'LBL_TRANSFER_GROUP'=>'Transfer Ownership to: ',
-'LBL_DELETE_USER'=>'User to be Deleted',
-'LBL_TRANSFER_USER'=>'Transfer Ownership to User',
-'LBL_DELETE_PROFILE'=>'Delete Profile',
-'LBL_TRANSFER_ROLES_TO_PROFILE'=>'Transfer Roles to Profile',
-'LBL_PROFILE_TO_BE_DELETED'=>'Profile to be Deteted',
-
-//Added for disabling window Recalculate
-
-'LBL_RECALC_MSG'=>'Are you sure, you wish to Recalculate Sharing Access?',
-'LBL_YES'=>'Yes',
-'LBL_NO'=>'No',
-
-'LBL_MANDATORY_MSG'=>'Mandatory Fields',
-'LBL_DISABLE_FIELD_MSG'=>'Fields Disabled from Global Field Access Settings',
-
-//Added for About Us
-
-'LBL_CONTACT_US'=>'Contact Us',
-'LBL_READ_LICENSE'=>'Read License',
-'LBL_VERSION'=>'Version',
-'LBL_TEAM'=>'Team',
-'LBL_CREDITS'=>'Credits',
-'LBL_THIRD_PARTY'=>'Third Party Packages',
-'LBL_COMMUNITY'=>'And vtiger Community',
-
-'LBL_ASSIGN_ROLE'=>'Assign Role',
-
-);
-
-?>
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Users/language/en_us.lang.php,v 1.18 2005/04/19 14:45:38 ray Exp $
+ * Description:  Defines the English language pack for the Account module.
+ ********************************************************************************/
+ 
+$mod_strings = Array(
+'LBL_MODULE_NAME'=>'Users',
+'LBL_MODULE_TITLE'=>'Users: Home',
+'LBL_SEARCH_FORM_TITLE'=>'User Search',
+'LBL_LIST_FORM_TITLE'=>'User List',
+'LBL_NEW_FORM_TITLE'=>'New User',
+'LBL_CREATE_NEW_USER'=>'Create New User',
+'LBL_LOGIN'=>'Login',
+'LBL_USER_ROLE'=>'Role',
+'LBL_LIST_NAME'=>'Name',
+'LBL_LIST_LAST_NAME'=>'Last Name',
+'LBL_LIST_USER_NAME'=>'User Name',
+'LBL_LIST_DEPARTMENT'=>'Department',
+'LBL_LIST_EMAIL'=>'E-Mail',
+'LBL_LIST_PRIMARY_PHONE'=>'Primary Phone',
+'LBL_LIST_ADMIN'=>'Admin',
+'LBL_LIST_CONFIRM_PASSWORD'=>'Confirm Password',
+'LBL_LIST_USER_NAME_ROLE'=>'User ID , Name & Role',
+'LBL_LIST_SELECT'=>'Select',
+'LBL_LIST_PHONE'=>'Phone',
+'LBL_LIST_NO'=>'#',
+
+'LBL_ADMINS'=>'Admins',
+'LBL_STD_USERS'=>'Standard Users',
+
+'UserName'=>'UserName',
+'Name'=>'Name',
+'Tools'=>'Tools',
+
+
+//added for patch2
+'LBL_GROUP'=>'Group',
+'LBL_CURRENCY_NAME'=>'Currency',
+
+'LBL_NEW_USER_BUTTON_TITLE'=>'New User [Alt+N]',
+'LBL_NEW_USER_BUTTON_LABEL'=>'New User',
+'LBL_NEW_USER_BUTTON_KEY'=>'N',
+'LBL_DATE_FORMAT'=>'Date Format',
+
+'LBL_ERROR'=>'Error:',
+'LBL_PASSWORD'=>'Password',
+'LBL_USER_NAME'=>'User Name',
+'LBL_CRM_ID'=>'CRM ID',
+'LBL_FIRST_NAME'=>'First Name',
+'LBL_LAST_NAME'=>'Last Name',
+'LBL_YAHOO_ID'=>'Yahoo ID',
+'LBL_THEME'=>'Color Theme',
+'LBL_LANGUAGE'=>'Language',
+'LBL_ADMIN'=>'Admin',
+'LBL_OFFICE_PHONE'=>'Office Phone',
+'LBL_REPORTS_TO'=>'Reports to',
+'LBL_OTHER_PHONE'=>'Other Phone',
+'LBL_OTHER_EMAIL'=>'Other Email',
+'LBL_DEPARTMENT'=>'Department',
+'LBL_STATUS'=>'Status',
+'LBL_TITLE'=>'Title',
+'LBL_ANY_PHONE'=>'Any Phone:',
+'LBL_ANY_EMAIL'=>'Any Email:',
+'LBL_ADDRESS'=>'Street Address',
+'LBL_CITY'=>'City',
+'LBL_STATE'=>'State',
+'LBL_POSTAL_CODE'=>'Postal Code',
+'LBL_COUNTRY'=>'Country',
+'LBL_USER_SETTINGS'=>'User Settings',
+'LBL_USER_INFORMATION'=>'User Information',
+'LBL_MOBILE_PHONE'=>'Mobile',
+'LBL_OTHER'=>'Other',
+'LBL_FAX'=>'Fax',
+'LBL_EMAIL'=>'E-Mail Id',
+'LBL_HOME_PHONE'=>'Home Phone',
+'LBL_ADDRESS_INFORMATION'=>'User Address',
+'LBL_CAL_HRFORMAT'=>'Calendar Time Format',
+'LBL_CAL_DURATION'=>'Day starts at',
+'LBL_PRIMARY_ADDRESS'=>'Primary Address:',
+
+'LBL_ORGANIZATION_INFORMATION'=>'Organizations',
+'LBL_PRIMARY_ORGANIZATION'=>'Primary organization',
+'LBL_ASSIGNED_ORGANIZATIONS'=>'Assigned to organizations',
+'LBL_PRIMARY_ORGUNITS'=>'Primary organization units',
+
+'LBL_CHANGE_PASSWORD_BUTTON_TITLE'=>'Change Password [Alt+P]',
+'LBL_CHANGE_PASSWORD_BUTTON_KEY'=>'P',
+'LBL_CHANGE_PASSWORD_BUTTON_LABEL'=>'Change Password',
+'LBL_LOGIN_BUTTON_TITLE'=>'Login [Alt+L]',
+'LBL_LOGIN_BUTTON_KEY'=>'L',
+'LBL_LOGIN_BUTTON_LABEL'=>'Login',
+'LBL_LOGIN_HISTORY_BUTTON_TITLE'=>'Login History [Alt+H]',
+'LBL_LOGIN_HISTORY_BUTTON_KEY'=>'H',
+'LBL_LOGIN_HISTORY_BUTTON_LABEL'=>'Login History',
+'LBL_LOGIN_HISTORY_TITLE'=>'Users: Login History',
+'LBL_RESET_PREFERENCES'=>'Reset To Default Preferences',
+
+'LBL_CHANGE_PASSWORD'=>'Change Password',
+'LBL_OLD_PASSWORD'=>'Old Password:',
+'LBL_NEW_PASSWORD'=>'New Password:',
+'LBL_CONFIRM_PASSWORD'=>'Confirm Password:',
+'ERR_ENTER_OLD_PASSWORD'=>'Please enter your old password.',
+'ERR_ENTER_NEW_PASSWORD'=>'Please enter your new password.',
+'ERR_ENTER_CONFIRMATION_PASSWORD'=>'Please enter your password confirmation.',
+'ERR_REENTER_PASSWORDS'=>'Please re-enter passwords.  The \"new password\" and \"confirm password\" values do not match.',
+'ERR_INVALID_PASSWORD'=>'You must specify a valid username and password.',
+'ERR_PASSWORD_CHANGE_FAILED_1'=>'User password change failed for ',
+'ERR_PASSWORD_CHANGE_FAILED_2'=>' failed.  The new password must be set.',
+'ERR_PASSWORD_INCORRECT_OLD'=>'Incorrect old password specified. Re-enter password information.',
+'ERR_USER_NAME_EXISTS_1'=>'The user name ',
+'ERR_USER_NAME_EXISTS_2'=>' already exists.  Duplicate user names are not allowed.<br>Change the user name to be unique.',
+'ERR_LAST_ADMIN_1'=>'The user name ',
+'ERR_LAST_ADMIN_2'=>' is the last Admin user.  At least one user must be an Admin user.<br>Check the Admin user setting.',
+
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the account.",
+
+// Additional Fields for i18n --- Release vtigerCRM 3.2 Patch 2
+// Users--listroles.php , createrole.php , ListPermissions.php , editpermissions.php
+
+'LBL_ROLES'=>'Roles',
+'LBL_ROLES_SUBORDINATES'=>'Roles and Subordinates',
+
+'LBL_CREATE_NEW_ROLE'=>'Create New Role',
+'LBL_INDICATES_REQUIRED_FIELD'=>'Indicates Required Field',
+'LBL_NEW_ROLE'=>'New Role',
+'LBL_PARENT_ROLE'=>'Parent Role',
+
+'LBL_LIST_ROLES'=>'List Roles',
+'LBL_ENTITY_LEVEL_PERMISSIONS'=>'Entity Level Permissions',
+'LBL_ENTITY'=>'Entity',
+'LBL_CREATE_EDIT'=>'Create/Edit',
+'LBL_DELETE'=>'Delete',
+'LBL_LEADS'=>'Leads',
+'LBL_ACCOUNTS'=>'Accounts',
+'LBL_CONTACTS'=>'Contacts',
+'LBL_OPPURTUNITIES'=>'Opportunities',
+'LBL_TASKS'=>'Tasks',
+'LBL_CASES'=>'Cases',
+'LBL_EMAILS'=>'Email',
+'LBL_NOTES'=>'Notes',
+'LBL_MEETINGS'=>'Meetings',
+'LBL_CALLS'=>'Calls',
+'LBL_IMPORT_PERMISSIONS'=>'Import Permissions',
+'LBL_IMPORT_LEADS'=>'Import Leads',
+'LBL_IMPORT_ACCOUNTS'=>'Import Accounts',
+'LBL_IMPORT_CONTACTS'=>'Import Contacts',
+'LBL_IMPORT_OPPURTUNITIES'=>'Import Opportunities',
+
+'LBL_ROLE_DETAILS'=>'Role Details',
+//added for vtigercrm4 rc
+'LBL_FILE'=> 'File Name',
+'LBL_FILE_TYPE'=>'File Type',
+'LBL_UPLOAD'=>'Upload File',
+'LBL_ATTACH_FILE'=>'Attach Mail Merge Template',
+'LBL_EMAIL_TEMPLATES'=>'Email Templates',
+'LBL_TEMPLATE_HEADER'=>'Template',
+'LBL_TEMPLATE_DETAILS'=>'Template Details',
+'LBL_EDIT_TEMPLATE'=>'Edit Template',
+'LBL_TEMPLATE_FILE'=>'Template File',
+'LBL_EMAIL_TEMPLATES_LIST'=>'Communication Templates > Email Templates',
+'LBL_MAILMERGE_TEMPLATES_LIST'=>' > Communication Templates > Mail Merge Templates',
+'LBL_MAILMERGE_TEMPLATES_ATTACHMENT' => '> Communication Templates > Attach Mail Merge Template',
+'LBL_DOWNLOAD_NOW'=>'Download Now',
+'LBL_DOWNLOAD'=>'Download',
+'LBL_SELECT_MODULE'=>'Select Module',
+'LBL_MERGE_FILE'=>'File : ',
+'LBL_MERGE_MSG'=>'Select a module to assign this Template',
+'LBL_MERGE_FIELDS'=>'Merge Fields',
+'LBL_COPY_PASTE'=>'Copy & Paste',
+'LNK_GO_TO_TOP'=>'Go to Page Top',
+'LBL_COLON'=>':',
+'LBL_EMAIL_TEMPLATE'=>'Email Template',
+'LBL_NEW_TEMPLATE'=>'New Template',
+'LBL_ADD_TEMPLATE'=>'Add Template',
+'LBL_USE_MERGE_FIELDS_TO_EMAIL_CONTENT'=>'Use merge fields to personalize your email content.',
+'LBL_AVAILABLE_MERGE_FIELDS'=>'Available Merge Fields',
+'LBL_SELECT_FIELD_TYPE'=>'Select Field Type',
+'LBL_SELECT_FIELD'=>'Select Field :',
+'LBL_MERGE_FIELD_VALUE'=>'Copy Merge Field Value :',
+'LBL_ACCOUNT_FIELDS'=>'Account Fields',
+'LBL_CONTACT_FIELDS'=>'Contact Fields',
+'LBL_LEAD_FIELDS'=>'Lead Fields',
+'LBL_COPY_AND_PASTE_MERGE_FIELD'=>'Copy and paste the merge field value into your template below.',
+'LBL_EMAIL_TEMPLATE_INFORMATION'=>'Communication Templates > Email Templates > Viewing',
+'LBL_FOLDER'=>'Folder',
+'LBL_PERSONAL'=>'Personal',
+'LBL_PUBLIC'=>'Public',
+'LBL_TEMPLATE_NAME'=>'Template Name:',
+'LBL_SUBJECT'=>'Subject',
+'LBL_BODY'=>'Email Body',
+'LBL_TEMPLATE_TOOLS'=>'Tools',
+'LBL_TEMPLATE_PUBLIC'=>'Public Access',
+'LBL_TEMPLATE_PRIVATE'=>'Private Access',
+'LBL_TEMPLATE_SUBJECT'=>'Email Subject',
+'LBL_TEMPLATE_MESSAGE'=>'Email Message',
+'LBL_VIEWING'=>'Viewing',
+'LBL_PROPERTIES'=>'Properties of',
+
+
+
+// Added fields in createnewgroup.php
+'LBL_CREATE_NEW_GROUP'=>'Create New Group',
+'LBL_NEW_GROUP'=>'New Group',
+'LBL_EDIT_GROUP'=>'Edit Group',
+'LBL_GROUP_NAME'=>'Group Name',
+'LBL_GROUP_DETAILS'=>'Group Details',
+'LBL_MEMBER'=>'Members',
+'LBL_MEMBER_AVLBL'=>'Available Entities & Members',
+'LBL_MEMBER_SELECTED'=>'Selected Members',
+'LBL_DESCRIPTION'=>'Description',
+'LBL_GROUP_MESG1'=>'Groups are a flexible way to assign access rights, when complex access rights has to be defined. You can combine multiple entities like Roles, Users, profiles etc into a single group.',
+'LBL_GROUP_MESG2'=>'To add, select the Entity members from left and click the ">>" button.',
+'LBL_GROUP_MESG3'=>'To remove, select the group members from the right and click the "<<" button.',
+
+
+// Added fields in detailViewmailtemplate.html,listgroupmembers.php,listgroups.php
+'LBL_DETAIL_VIEW_OF_EMAIL_TEMPLATE'=>'Detail View of Email Template',
+'LBL_DETAIL_VIEW'=>'Detail View of',
+'LBL_EDIT_VIEW'=>'Editing details of the user',
+'LBL_EDITING'=>'Editing user',
+'LBL_GROUP_MEMBERS_LIST'=>'Group members list',
+'LBL_GROUPS'=>'Groups',
+'LBL_MY_GROUPS'=>'My Groups',
+'LBL_ADD_GROUP_BUTTON'=>'Add Group',
+'LBL_WORD_TEMPLATES'=>'Mail Merge Templates',
+'LBL_NEW_WORD_TEMPLATE'=>'New Template',
+'LBL_EMAIL_TEMPLATE_DESC'=>'Manage email templates used for Campaigns and Mass mailing',
+'LBL_NAME'=>'Name',
+
+// Added fields in TabCustomise.php,html and UpdateTab.php,html
+'LBL_CUSTOMISE_TABS'=>'Customize Tabs',
+'LBL_CHOOSE_TABS'=>'Choose Tabs',
+'LBL_AVAILABLE_TABS'=>'Available Tabs',
+'LBL_SELECTED_TABS'=>'Selected Tabs',
+'LBL_USER'=>'User',
+'LBL_TAB_MENU_UPDATED'=>'Tab Menu Updated! kindly go to ',
+'LBL_TO_VIEW_CHANGES'=>' to view the changes',
+
+// Added to change homepage order
+'LBL_CHANGE_HOMEPAGE_LABEL'=>'Homepage Order',
+'LBL_CHANGE_HOMEPAGE_TITLE'=>'Homepage',
+
+// Added fields in binaryfilelist.php
+'LBL_OERATION'=>'Operation',
+
+// Added fields in CreateProfile.php
+'LBL_PROFILE_NAME'=>'Create New Profile:',
+'LBL_NEW_PROFILE'=>'New Profile',
+'LBL_NEW_PROFILE_NAME'=>'Profile Name',
+'LBL_PARENT_PROFILE'=>'Parent Profile',
+'LBL_BASIC_PROFILE_DETAILS'=>'Basic details of Profile',
+'LBL_STEP_1_2'=>'Step 1 of 2',
+'LBL_STEP_2_2'=>'Step 2 of 2',
+'LBL_STEP'=>'Step',
+'LBL_SELECT_BASE_PROFILE'=>'Select Base Profile',
+'LBL_PROFILE_PRIVILEGES'=>'Profile Privileges',
+'LBL_GLOBAL_PRIVILEGES'=>'Global Privileges',
+'LBL_TAB_PRIVILEGES'=>'Tab Privileges',
+'LBL_FIELD_PRIVILEGES'=>'Field Privileges',
+'LBL_STANDARD_PRIVILEGES'=>'Standard Privileges',
+'LBL_UTILITY_PRIVILEGES'=>'Utility Privileges',
+'LBL_UTILITIES'=>'Utilities',
+'LBL_BASE_PROFILE_MESG'=>'I would like to setup a base profile and edit privileges <b>(Recommended)</b>',
+'LBL_BASE_PROFILE'=>'Base Profile:',
+'LBL_OR'=>'OR',
+'LBL_BASE_PROFILE_MESG_ADV'=>'I will choose the privileges from scratch <b>(Advanced Users)</b>',
+'LBL_FOR'=>'for',
+'LBL_GLOBAL_MESG_OPTION'=>'Select the options below to change global privileges',
+'LBL_VIEW_ALL'=>'View all',
+'LBL_EDIT_ALL'=>'Edit all',
+'LBL_ALLOW'=>'Allows',
+'LBL_MESG_VIEW'=>'to view all information / modules of vtiger CRM',
+'LBL_MESG_EDIT'=>'to edit all information / modules of vtiger CRM',
+'LBL_STD_MESG_OPTION'=>'Select the standard actions to be permitted',
+'LBL_TAB_MESG_OPTION'=>'modules to be shown',
+'LBL_UTILITY_MESG_OPTION'=>'Select the utility actions to be permitted',
+'LBL_FIELD_MESG_OPTION'=>'Select the fields to be permitted',
+'LBL_FINISH_BUTTON'=>'Finish',
+'LBL_PROFILE_DETAIL_VIEW'=>'Detail View of Profile',
+'LBL_PROFILE_MESG'=>'Viewing access privileges for',
+'LBL_PROFILE_M'=>'Profile',
+'LBL_DEFINE_PRIV_FOR'=>' Define Privileges for ',
+'LBL_USE_OPTION_TO_SET_PRIV'=>'Use the options below to set privileges',
+'LBL_SUPER_USER_PRIV'=>'Global Privileges',
+'LBL_SET_PRIV_FOR_EACH_MODULE'=>'Set Privileges for each Module ',
+'LBL_FIELDS_AND_TOOLS_SETTINGS'=>'Fields & Tools Settings',
+'LBL_SHOW_FIELDS'=>'Show Fields',
+'LBL_TOOLS_TO_BE_SHOWN'=>'Tools to be shown',
+'LBL_WELCOME_PROFILE_CREATE'=>'Welcome to Privilege Profile Creator ',
+'LBL_SELECT_CHOICE_NEW_PROFILE'=>'Select your choice of creating the new profile',
+'LBL_ADD_CUSTOM_RULE'=>'Add Custom Privilege Rule',
+'LBL_EDIT_CUSTOM_RULE'=>'Edit Custom Privilege Rule',
+'LBL_CLOSE'=>'Close',
+'LBL_SELECT_ENTITY'=>'Select an entity below',
+'LBL_CAN_BE_ACCESSED_BY'=>'Can be accessed by',
+'LBL_PERMISSIONS'=>'Permissions',
+'LBL_ACCESS_RIGHTS_FOR_MODULES'=>'Access rights for relative modules',
+'LBL_RULE_CONSTRUCTION'=>'Rule Construction Display',
+'LBL_ADD_RULE'=>'Add Rule',
+'LBL_RELATED_MODULE_RIGHTS'=>'Related Module Rights',
+'LBL_IN_PERMISSION'=>'in the permission',
+
+//Added fields in createrole.php
+'LBL_HDR_ROLE_NAME'=>'Create New Role:',
+'LBL_TITLE_ROLE_NAME'=>'New Role',
+'LBL_ROLE_NAME'=>'Role Name',
+'LBL_ROLE_PROFILE_NAME'=>'Associate With Profile',
+'LBL_SPECIFY_ROLE_NAME'=>'Specify a name for new role :',
+'LBL_ASSIGN_PROFILE'=>'Assign Profile(s)',
+'LBL_PROFILE_SELECT_TEXT'=>'Select the Profiles below and click on assign button',
+'LBL_PROFILES_AVLBL'=>'Profiles Available',
+'LBL_ASSIGN_PROFILES'=>'Assigned Profiles',
+'LBL_REPORTS_TO_ROLE'=>'Reports to Role',
+'LBL_ASSOCIATED_PROFILES'=>'Associated Profiles :',
+'LBL_ASSOCIATED_USERS'=>'Associated Users :',
+
+
+//Added fields in OrgSharingDetailsView.php
+'LBL_ORG_SHARING_PRIVILEGES'=>'Organisation Sharing  Privileges',
+'LBL_EDIT_PERMISSIONS'=>'Edit Permissions',
+'LBL_SAVE_PERMISSIONS'=>'Save Permissions',
+'LBL_READ_ONLY'=>'Public: Read Only',
+'LBL_EDIT_CREATE_ONLY'=>'Public: Read, Create/Edit',
+'LBL_READ_CREATE_EDIT_DEL'=>'Public: Read, Create/Edit, Delete',
+'LBL_PRIVATE'=>'Private',
+
+//Added fields in listnotificationschedulers.php
+'LBL_HDR_EMAIL_SCHDS'=>'Users : Email Notifications',
+'LBL_EMAIL_SCHDS_DESC'=>'The following is the list of notifications that are activated automatically when the corresponding event has happened.',
+'LBL_ACTIVE'=>'Active',
+'LBL_INACTIVE'=>'Inactive',
+'LBL_NOTIFICATION'=>'Notification',
+'LBL_DESCRIPTION'=>'Description',
+'LBL_TASK_NOTIFICATION'=>'Delayed Task Notification',
+'LBL_TASK_NOTIFICATION_DESCRITPION'=>'Notify when a task is delayed beyond 24 hrs',
+'LBL_MANY_TICKETS'=>'Too many tickets  Notification',
+'LBL_MANY_TICKETS_DESCRIPTION'=>'Notify when a particular entity is allocated too many tickets, might reflect Service Level commitments',
+'LBL_PENDING_TICKETS'=>'Pending Tickets Notification',
+'LBL_TICKETS_DESCRIPTION'=>'Notify for getting attention to status of tickets which are pending',
+'LBL_START_NOTIFICATION'=>'Support Start Notification',
+'LBL_START_DESCRIPTION'=>'Notifiy stating the start of support/service',
+'LBL_BIG_DEAL'=>'Big Deal Notification',
+'LBL_BIG_DEAL_DESCRIPTION'=>'Notify on completion of big deal',
+'LBL_SUPPORT_NOTICIATION'=>'Support End Notification',
+'LBL_SUPPORT_DESCRIPTION'=>'Notify when support is about to end',
+'LBL_BUTTON_UPDATE'=>'Update',
+'LBL_MODULENAMES'=>'Module',
+
+//Added fields in ListFieldPermissions.html
+'LBL_FIELD_PERMISSION_FIELD_NAME'=>'Field Name',
+'LBL_FIELD_PERMISSION_VISIBLE'=>'Visible',
+'LBL_FIELD_PERMISSIOM_TABLE_HEADER'=>'Standard Fields',
+'LBL_FIELD_LEVEL_ACCESS'=>'Field Level Access',
+
+//Added fields after 4.0.1
+'LBL_SIGNATURE'=>'Signature',
+
+//Added for Event Reminder 4.2 Alpha release
+'LBL_ACTIVITY_NOTIFICATION'=>'Event Reminder Notification',
+'LBL_ACTIVITY_REMINDER_DESCRIPTION'=>'Notify before an event to occur based on the reminder set',
+'LBL_MESSAGE'=>'Message',
+
+//Added for Global Privileges
+
+'Public: Read Only'=>'Public: Read Only',
+'Public: Read, Create/Edit'=>'Public: Read, Create/Edit',
+'Public: Read, Create/Edit, Delete'=>'Public: Read, Create/Edit, Delete',
+'Private'=>'Private',
+'Hide Details'=>'Hide Details',
+'Hide Details and Add Events'=>'Hide Details and Add Events',
+'Show Details'=>'Show Details',
+'Show Details and Add Events'=>'Show Details and Add Events',
+
+'LBL_USR_CANNOT_ACCESS'=>'Users cannot access other users ',
+'LBL_USR_CAN_ACCESS'=>'Users can ',
+'LBL_USR_OTHERS'=>' other users ',
+
+'Read Only '=>'Read Only ',
+'Read, Create/Edit, Delete '=>'Read, Create/Edit, Delete ',
+'Read, Create/Edit '=>'Read, Create/Edit ',
+'Read/Write'=>'Read/Write',
+'LBL_GO_TO_TOP'=>'Go to Top',
+'LNK_CLICK_HERE'=>'Click here',
+'LBL_RULE_NO'=>'Rule No.',
+'LBL_CAN_BE_ACCESSED'=>'can be accessed by',
+'LBL_PRIVILEGES'=>'Privileges',
+'LBL_OF'=>'of',
+
+
+
+//Added for 4.2GA support for mail server integration
+'LBL_ADD_MAILSERVER_BUTTON_TITLE'=>'Add Mail Server',
+'LBL_ADD_MAILSERVER_BUTTON_KEY'=>'M',
+'LBL_ADD_MAILSERVER_BUTTON_LABEL'=>'Add Mail Server',
+
+'LBL_LIST_MAILSERVER_BUTTON_TITLE'=>'List Mail Server',
+'LBL_LIST_MAILSERVER_BUTTON_KEY'=>'L',
+'LBL_LIST_MAILSERVER_BUTTON_LABEL'=>'List Mail Server',
+//added for inventory terms and conditions
+'INV_TANDC'=>'Terms & Coditions',
+'INV_TERMSANDCONDITIONS'=>'Inventory Terms & Coditions',
+'LBL_INV_TERMSANDCONDITIONS'=>'Inventory Management', 
+
+
+'INVENTORYNOTIFICATION'=>'Inventory Notifications',
+'LBL_INVENTORY_NOTIFICATIONS'=>'Edit Inventory Email Notifications',
+'LBL_INV_NOT_DESC'=>'The following are the list of notifications that are sent to the product handler regarding the demand and the current quantity in hand during the creation of a Quote, SalesOrder and Invoice.',
+
+'InvoiceNotification'=>'Product Stock Notification during Invoice Generation',
+'InvoiceNotificationDescription'=>'When the product stock level goes below the re-order level, notification will be sent to the product handler',
+
+'QuoteNotification'=>'Product Stock Notification during Quote Generation',
+'QuoteNotificationDescription'=>'During quote generation if the product stock in warehouse is lesser than the  quantity mentioned in quote then this notification will be sent to the product handler',
+
+'SalesOrderNotification'=>'Product Stock Notification during Sales Order Generation',
+'SalesOrderNotificationDescription'=>'During sales order generation if the product stock in warehouse is lesser than the quantity mentioned in sales order then this notification will be sent to the product handler',
+
+//New addition for 4.2 GA
+'LBL_USER_FIELDS'=>'User Fields',
+'LBL_NOTE_DO_NOT_REMOVE_INFO'=>'Note: Donot remove or alter the values within {  }',
+
+//Added for patch2
+'LBL_FILE_INFORMATION'=>'File Information',
+
+//Added after pathc2
+'LBL_LEAD_FIELD_ACCESS'=>'Lead Field Access',
+
+'LBL_ACCOUNT_FIELD_ACCESS'=>'Account Field Access',
+
+'LBL_CONTACT_FIELD_ACCESS'=>'Contact Field Access',
+
+'LBL_OPPORTUNITY_FIELD_ACCESS'=>'Potential Field Access',
+
+'LBL_HELPDESK_FIELD_ACCESS'=>'HelpDesk Field Access',
+
+'LBL_PRODUCT_FIELD_ACCESS'=>'Product Field Access',
+
+'LBL_NOTE_FIELD_ACCESS'=>'Note Field Access',
+
+'LBL_EMAIL_FIELD_ACCESS'=>'Email Field Access',
+
+'LBL_TASK_FIELD_ACCESS'=>'Task Field Access',
+
+'LBL_EVENT_FIELD_ACCESS'=>'Event Field Access',
+'LBL_VENDOR_FIELD_ACCESS'=>'Vendor Field Access',
+'LBL_PB_FIELD_ACCESS'=>'PriceBook Field Access',
+'LBL_QUOTE_FIELD_ACCESS'=>'Quote Field Access',
+'LBL_PO_FIELD_ACCESS'=>'Purchase Order Field Access',
+'LBL_SO_FIELD_ACCESS'=>'Sales Order Access',
+'LBL_INVOICE_FIELD_ACCESS'=>'Invoice Field Access',
+
+//given for calendar color for an user user
+'LBL_COLOR'=>'Color in Calendar',
+//added for activity view in home page
+'LBL_ACTIVITY_VIEW'=>'Default Activity View',
+//Added to change Home page order
+'LBL_HOMEPAGE_ORDER_UPDATE'=>'Update Home Page Block Order',
+'LBL_HOMEPAGE_ID'=>'Block Order',
+'ERR_INVALID_USER'=>'Invalid access--Please call from My Accounts',
+'ALVT'=>'Top Accounts',
+'PLVT'=>'Top Potentials',
+'QLTQ'=>'Top Quotes',
+'CVLVT'=>'Key Metrics',
+'HLT'=>'Top Trouble Tickets',
+'OLV'=>'Upcoming & Pending Activities',
+'GRT'=>'My Group Allocation',
+'OLTSO'=>'Top Sales Orders',
+'ILTI'=>'Top Invoices',
+'HDB'=>'Home Page Dashboard',
+'OLTPO'=>'Top Purchase Orders',
+'LTFAQ'=>'My Recent FAQs',
+
+//Added for 5.0 alpha
+'LBL_GROUP_NAME_ERROR'=>'Group Name already exists!',
+'MNL'=>'My New Leads',
+'LBL_LEAD_VIEW'=>'Default Leads View',
+'LBL_TAG_CLOUD'=>'Tag Cloud',
+'LBL_LIST_TOOLS'=>'Tools',
+'LBL_STATISTICS'=>'Statistics',
+'LBL_TOTAL'=>'Total :',
+'LBL_OTHERS'=>'Others :',
+'LBL_USERS'=>'User(s)',
+'LBL_USER_LOGIN_ROLE'=>'User Login & Role',
+'LBL_USER_MORE_INFN'=>'More Information',
+'LBL_USER_ADDR_INFN'=>'Address Information',
+'LBL_USER_IMAGE'=>'User Image',
+'LBL_USR'=>'Users',
+
+'LBL_MY'=>'My',
+'LBL_MY_DEFAULTS'=>'My Defaults',
+'LBL_MY_DESG'=>'My Designation & Contact Details',
+'LBL_MY_ADDR'=>'My Postal Address',
+'LBL_MY_PHOTO'=>'My Photo',
+'LBL_CHANGE_PHOTO'=>'Change Photo...',
+'LBL_CHANGE'=>'Change',
+
+
+//Added for Access Privileges
+
+'LBL_GLOBAL_FIELDS_MANAGER'=>'Global Fields Manager',
+'LBL_GLOBAL_ACCESS_PRIVILEGES'=>'Organization-level Sharing Rules',
+'LBL_CUSTOM_ACCESS_PRIVILEGES'=>'Custom Sharing Rules',
+'LBL_BOTH'=>'Both',
+'LBL_VIEW'=>'View',
+'LBL_RECALCULATE_BUTTON'=>'Recalculate',
+'LBL_ADD_PRIVILEGES_BUTTON'=>'Add Privileges',
+'LBL_CUSTOM_ACCESS_MESG'=>'No Custom Access Rules defined .',
+'LBL_CREATE_RULE_MESG'=>'to create a new Rule',
+'LBL_SELECT_SCREEN'=>'Select the Screen / Module :',
+'LBL_FIELDS_AVLBL'=>'Fields Available in',
+'LBL_FIELDS_SELECT_DESELECT'=>'Fields to be shown',
+'LBL_ROLE_TO_BE_DELETED'=>'Role to be Deleted',
+'LBL_TRANSFER_USER_ROLE'=>'Transfer Users to Role',
+'LBL_DELETE_ROLE'=>'Delete Role',
+'LBL_MORE_INFORMATION'=>'More Information',
+'LBL_USERLOGIN_ROLE'=>'User Login & Role',
+'LBL_USER_IMAGE_INFORMATION'=>'User Photograph',
+
+//Added for 5.0 for all fields
+'Role'=>'Role',
+'Email'=>'Email',
+'Admin'=>'Admin',
+'User Name'=>'User Name',
+'First Name'=>'First Name',
+'Last Name'=>'Last Name',
+'Status'=>'Status',
+'Default Activity View'=>'Default Calendar View',
+'Default Lead View'=>'Default Lead View',
+'Currency'=>'Currency',
+'Title'=>'Title',
+'Office Phone'=>'Office Phone',
+'Department'=>'Department',
+'Mobile'=>'Mobile',
+'Reports To'=>'Reports To',
+'Other Phone'=>'Other Phone',
+'Other Email'=>'Other Email',
+'Fax'=>'Fax',
+'Yahoo id'=>'Yahoo id',
+'Home Phone'=>'Home Phone',
+'User Image'=>'Upload Photograph',
+'Date Format'=>'Date Format',
+'Tag Cloud'=>'Tag Cloud',
+'Signature'=>'Signature',
+'Notes'=>'Notes',
+'Street Address'=>'Street Address',
+'City'=>'City',
+'State'=>'State',
+'Postal Code'=>'Postal Code',
+'Country'=>'Country',
+'Password'=>'Password',
+'Confirm Password'=>'Confirm Password',
+'LBL_SHOWN'=>'Shown',
+'LBL_HIDDEN'=>'Hidden',
+'LBL_SHOW'=>'Show',
+'LBL_HIDE'=>'Hide',
+'LBL_HOME_PAGE_COMP'=>'Home Page Components',
+'LBL_LOGIN_HISTORY'=>'Login History',
+'LBL_USERDETAIL_INFO'=>'Viewing details about the user',
+'LBL_DELETE_GROUP'=>'Delete Group',
+'LBL_DELETE_GROUPNAME'=>'Group to be Deleted',
+'LBL_TRANSFER_GROUP'=>'Transfer Ownership to: ',
+'LBL_DELETE_USER'=>'User to be Deleted',
+'LBL_TRANSFER_USER'=>'Transfer Ownership to User',
+'LBL_DELETE_PROFILE'=>'Delete Profile',
+'LBL_TRANSFER_ROLES_TO_PROFILE'=>'Transfer Roles to Profile',
+'LBL_PROFILE_TO_BE_DELETED'=>'Profile to be Deteted',
+
+//Added for disabling window Recalculate
+
+'LBL_RECALC_MSG'=>'Are you sure, you wish to Recalculate Sharing Access?',
+'LBL_YES'=>'Yes',
+'LBL_NO'=>'No',
+
+'LBL_MANDATORY_MSG'=>'Mandatory Fields',
+'LBL_DISABLE_FIELD_MSG'=>'Fields Disabled from Global Field Access Settings',
+
+//Added for About Us
+
+'LBL_CONTACT_US'=>'Contact Us',
+'LBL_READ_LICENSE'=>'Read License',
+'LBL_VERSION'=>'Version',
+'LBL_TEAM'=>'Team',
+'LBL_CREDITS'=>'Credits',
+'LBL_THIRD_PARTY'=>'Third Party Packages',
+'LBL_COMMUNITY'=>'And vtiger Community',
+
+'LBL_ASSIGN_ROLE'=>'Assign Role',
+
+//Moved from Settings to here for Webmail client integration (for 5.0.3 release)
+
+'LBL_ADD_MAIL_ACCOUNT'=>'Add Mail Account',
+'LBL_NEW_MAIL_ACCOUNT_TITLE'=>'New Mail Account [Alt+M]',
+'LBL_NEW_MAIL_ACCOUNT_KEY'=>'M',
+'LBL_NEW_MAIL_ACCOUNT_LABEL'=>'New Mail Account',
+'LBL_GENERAL_INFO'=>'General Information',
+'LBL_DISPLAY_NAME'=>'Display Name',
+'LBL_MAIL_PROTOCOL'=>'Mail Protocol',
+'LBL_LIST_PASSWORD'=>'Password',
+'LBL_MAIL_SERVER_NAME'=>'Mail Server Name or IP',
+'LBL_INCOME_SERVER_SETTINGS'=>'Incoming Server',
+'LBL_TEST_SETTINGS'=>'Test my account setting immediately',
+'LBL_TEST_BUTTON_TITLE'=>'Test my account now! [Alt+T]',
+'LBL_TEST_BUTTON_KEY'=>'T',
+'LBL_TEST_BUTTON_LABEL'=>'Test my account now!',
+'LBL_DEFAULT'=>'Default',
+'LBL_IMAP2'=>'IMAP2',
+'LBL_IMAP4'=>'IMAP4',
+'LBL_POP'=>'POP',
+'LBL_IMAP'=>'IMAP',
+'LBL_MAIL_DISCLAIM'=>'Items marked with <font color="red">*</font> are required<br>Items marked with <font color="red">* *</font> are not fully supported',
+'LBL_SSL_OPTIONS'=>'SSL Options',
+'LBL_TLS'=>'TLS',
+'LBL_NO_TLS'=>'No TLS',
+'LBL_CERT_VAL'=>'Certificate Validations',
+'LBL_INT_MAILER'=>'Use Internal Mailer?',
+'LBL_INT_MAILER_USE'=>'Yes',
+'LBL_INT_MAILER_NOUSE'=>'No',
+'LBL_VAL_SSL_CERT'=>'Validate SSL Cert',
+'LBL_DONOT_VAL_SSL_CERT'=>'Do Not Validate SSL Cert',
+'LBL_WEB_MAIL_CONFIG'=>'Web Mail Configuration',
+'LBL_CONFIGURE_WEB_MAIL'=>' - Configure Web Mail',
+'LBL_LIST_MAIL_ACCOUNT'=>'  List Mail Account',
+'LBL_MY_MAIL_SERVER_DET'=>'My Incoming Mail Server Details',
+'LBL_MY_DETAILS'=>'My Details',
+'LBL_EMAIL_ID'=>'Email ID',
+'LBL_EMAIL_ADDRESS'=>'Email',
+'LBL_NAME_EXAMPLE'=>'(example : John Fenner)',
+'LBL_EMAIL_EXAMPLE'=>'(example : johnfenner at xyz.com)',
+'LBL_REFRESH_TIMEOUT'=>'Refresh Timeout',
+'LBL_1_MIN'=>'1 minute',
+'LBL_2_MIN'=>'2 minutes',
+'LBL_3_MIN'=>'3 minutes',
+'LBL_4_MIN'=>'4 minutes',
+'LBL_5_MIN'=>'5 minutes',
+'LBL_EMAILS_PER_PAGE'=>'Email per Page',
+
+// Added for 5.0.3
+
+'LBL_ENTER_PROFILE'=>'Enter The Profile Name',
+'TITLE_USER_DOCUMENT'=>'Untitled Document',
+'TITLE_VTIGER_CRM_5'=>'vtiger CRM 5 - Free, Commercial grade Open Source CRM',
+'ROLE_DRAG_ERR_MSG'=>'You cannot move a Parent Node under a Child Node',
+);
+
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Users/lookupemailtemplates.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/lookupemailtemplates.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/lookupemailtemplates.php Mon Apr 16 12:27:44 2007
@@ -13,9 +13,8 @@
 require_once('include/database/PearDatabase.php');
 require_once('include/utils/utils.php');
 
-global $theme;
+global $theme,$current_user;
 $theme_path="themes/".$theme."/";
-
 ?>
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -39,16 +38,32 @@
    $sql = "select * from vtiger_emailtemplates order by templateid desc";
    $result = $adb->query($sql);
    $temprow = $adb->fetch_array($result);
+   
 $cnt=1;
 
 require_once('include/utils/UserInfoUtil.php');
+require('user_privileges/user_privileges_'.$current_user->id.'.php');
 do
 {
-  printf("<tr class='lvtColData' onmouseover=\"this.className='lvtColDataHover'\" onmouseout=\"this.className='lvtColData'\" bgcolor='white'> <td height='25'>");
- $templatename = $temprow["templatename"]; 
-  echo "<a href='javascript:submittemplate(".$temprow['templateid'].");'>".$temprow["templatename"]."</a></td>";
-   printf("<td height='25'>%s</td>",$temprow["description"]);
-  $cnt++;
+	$templatename = $temprow["templatename"];
+	if($is_admin == false)
+	{
+		$folderName = $temprow['foldername'];
+		if($folderName != 'Personal')
+		{
+			printf("<tr class='lvtColData' onmouseover=\"this.className='lvtColDataHover'\" onmouseout=\"this.className='lvtColData'\" bgcolor='white'> <td height='25'>");
+			echo "<a href='javascript:submittemplate(".$temprow['templateid'].");'>".$temprow["templatename"]."</a></td>";
+			printf("<td height='25'>%s</td>",$temprow["description"]);
+		}
+	}
+	else
+	{
+		printf("<tr class='lvtColData' onmouseover=\"this.className='lvtColDataHover'\" onmouseout=\"this.className='lvtColData'\" bgcolor='white'> <td height='25'>");
+		echo "<a href='javascript:submittemplate(".$temprow['templateid'].");'>".$temprow["templatename"]."</a></td>";
+		printf("<td height='25'>%s</td>",$temprow["description"]);
+	}	
+        $cnt++;
+
 }while($temprow = $adb->fetch_array($result));
 ?>
 </table>

Modified: vtigercrm/branches/5.1_jens/modules/Users/massdelete.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/massdelete.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/massdelete.php Mon Apr 16 12:27:44 2007
@@ -45,6 +45,8 @@
 
 	    // Perform the delete action
 	    $result = $adb->query($sql);
+	    if($returnmodule == 'Accounts')
+		delAccRelRecords($id);
         }
         else
         {

Modified: vtigercrm/branches/5.1_jens/modules/Users/notify_detail.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/notify_detail.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/notify_detail.php Mon Apr 16 12:27:44 2007
@@ -10,6 +10,8 @@
  ********************************************************************************/
 
 global $theme;
+global $app_strings;
+global $mod_strings;
 $theme_path="themes/".$theme."/";
 $image_path=$theme_path."images/";
 
@@ -20,8 +22,8 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <head>
-<title>Untitled Document</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<title><?php echo $mod_strings['TITLE_USER_DOCUMENT']; ?></title>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $app_strings['LBL_CHARSET']; ?>">
 </head>
 <body>
 <form method="post" action="index.php?module=Users&action=listnotificationschedulers" name="">
@@ -44,7 +46,7 @@
     </tr>
     <tr >
       <td nowrap class="dataLabel">Active: </td>
-      <td> <img src="yes.gif" alt="" width="13" height="12" align="absmiddle"> 
+      <td> <img src="yes.gif" alt="" title="" width="13" height="12" align="absmiddle"> 
         [<a href=#>Deactivate</a>]</td>
     </tr>
     <tr >

Modified: vtigercrm/branches/5.1_jens/modules/Users/updateLeadDBStatus.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Users/updateLeadDBStatus.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Users/updateLeadDBStatus.php Mon Apr 16 12:27:44 2007
@@ -79,7 +79,9 @@
 				//First we have to delete the group relationship
 				$delete_query = "delete from ". $deletegroup_array[$return_module] ." where " . $tableId_array[$return_module] . "='".$id."'";
 				$result = $adb->query($delete_query); 
-
+				//Inserting changed owner information to salesmanactivityrel table
+				$insert = "insert into vtiger_salesmanactivityrel values(".$idval.",".$id.")";
+				$result = $adb->query($insert);
 				//Now we have to update the smownerid
 				$sql = "update vtiger_crmentity set modifiedby=".$current_user->id.",smownerid='" .$idval ."', modifiedtime=".$adb->formatString("vtiger_crmentity","modifiedtime",$date_var)." where crmid='" .$id."'";
 				$result = $adb->query($sql);

Modified: vtigercrm/branches/5.1_jens/modules/Vendors/Delete.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Vendors/Delete.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Vendors/Delete.php Mon Apr 16 12:27:44 2007
@@ -29,11 +29,11 @@
 if(!isset($_REQUEST['record']))
 	die($mod_strings['ERR_DELETE_RECORD']);
 
-
+	
 if($_REQUEST['module'] == $_REQUEST['return_module'])
 {
+	delVendorRelRecords($_REQUEST['record']);
 	$focus->mark_deleted($_REQUEST['record']);
-	$smod ="smodule=VENDOR&";
 }
-header("Location: index.php?".$smod."module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']."&relmodule=".$_REQUEST['module']);
+header("Location: index.php?module=".$_REQUEST['return_module']."&action=".$_REQUEST['return_action']."&record=".$_REQUEST['return_id']."&relmodule=".$_REQUEST['module']);
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Vendors/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Vendors/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Vendors/DetailView.php Mon Apr 16 12:27:44 2007
@@ -74,6 +74,8 @@
 $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
 $smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST[record]));
 
+$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule));
+
 if($singlepane_view == 'true')
 {
 	$related_array = getRelatedLists($currentModule,$focus);

Modified: vtigercrm/branches/5.1_jens/modules/Vendors/EditView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Vendors/EditView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Vendors/EditView.php Mon Apr 16 12:27:44 2007
@@ -99,6 +99,7 @@
 
 $check_button = Button_Check($module);
 $smarty->assign("CHECK", $check_button);
+$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
 
 // Assigned organizations
 $smarty->assign("CURRENT_ORGANIZATION",$current_organization);

Modified: vtigercrm/branches/5.1_jens/modules/Vendors/Vendors.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Vendors/Vendors.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Vendors/Vendors.php Mon Apr 16 12:27:44 2007
@@ -89,7 +89,14 @@
 		else
 			$returnset = '&return_module=Vendors&return_action=CallRelatedList&return_id='.$id;
 
-		$query = 'select vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendor.vendorname from vtiger_products inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_products.productid left outer join vtiger_vendor on vtiger_vendor.vendorid = vtiger_products.vendor_id where vtiger_vendor.vendorid = '.$id.' and vtiger_crmentity.deleted = 0';
+		$query = "SELECT vtiger_products.productid, vtiger_products.productname, vtiger_products.productcode, 
+				vtiger_products.commissionrate, vtiger_products.qty_per_unit, vtiger_products.unit_price, 
+				vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendor.vendorname 
+			  FROM vtiger_products 
+			  INNER JOIN vtiger_vendor ON vtiger_vendor.vendorid = vtiger_products.vendor_id 
+			  INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_products.productid 
+			  WHERE vtiger_crmentity.deleted = 0 AND vtiger_vendor.vendorid = $id";
+
 		$log->debug("Exiting get_products method ...");
 		return GetRelatedList('Vendors','Products',$focus,$query,$button,$returnset);
 	}
@@ -113,7 +120,7 @@
 		else
 			$returnset = '&return_module=Vendors&return_action=CallRelatedList&return_id='.$id;
 
-		$query = "select vtiger_users.user_name,vtiger_groups.groupname,vtiger_crmentity.*, vtiger_purchaseorder.*,vtiger_vendor.vendorname from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.vendorid=".$id;
+		$query = "select case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_crmentity.*, vtiger_purchaseorder.*,vtiger_vendor.vendorname from vtiger_purchaseorder inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_purchaseorder.purchaseorderid left outer join vtiger_vendor on vtiger_purchaseorder.vendorid=vtiger_vendor.vendorid left join vtiger_pogrouprelation on vtiger_purchaseorder.purchaseorderid=vtiger_pogrouprelation.purchaseorderid left join vtiger_groups on vtiger_groups.groupname=vtiger_pogrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_purchaseorder.vendorid=".$id;
 		$log->debug("Exiting get_purchase_orders method ...");
 		return GetRelatedList('Vendors','PurchaseOrder',$focus,$query,$button,$returnset);
 	}
@@ -136,7 +143,7 @@
 		else
 			$returnset = '&return_module=Vendors&return_action=CallRelatedList&return_id='.$id;
 
-		$query = 'SELECT vtiger_users.user_name,vtiger_groups.groupname,vtiger_contactdetails.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendorcontactrel.vendorid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid  inner join vtiger_vendorcontactrel on vtiger_vendorcontactrel.contactid=vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_vendorcontactrel.vendorid = '.$id;
+		$query = "SELECT case when (vtiger_users.user_name not like '') then vtiger_users.user_name else vtiger_groups.groupname end as user_name,vtiger_contactdetails.*, vtiger_crmentity.crmid, vtiger_crmentity.smownerid,vtiger_vendorcontactrel.vendorid from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid  inner join vtiger_vendorcontactrel on vtiger_vendorcontactrel.contactid=vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.deleted=0 and vtiger_vendorcontactrel.vendorid = ".$id;
 		$log->debug("Exiting get_contacts method ...");
 		return GetRelatedList('Vendors','Contacts',$focus,$query,$button,$returnset);
 

Modified: vtigercrm/branches/5.1_jens/modules/Vendors/updateRelations.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Vendors/updateRelations.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Vendors/updateRelations.php Mon Apr 16 12:27:44 2007
@@ -15,40 +15,63 @@
 
 $idlist = $_REQUEST['idlist'];
 
-if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
+if($singlepane_view == 'true')
+	$action = "DetailView";
+else
+	$action = "CallRelatedList";
+
+$dest_mod = $_REQUEST['destination_module'];
+
+//This will be true, when we select product from vendor related list
+if($_REQUEST['destination_module']=='Products')
 {
-	//split the string and store in an array
-	$storearray = explode (";",$idlist);
-	foreach($storearray as $id)
+	if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
 	{
-		if($id != '')
+		$record = $_REQUEST["parentid"];
+		$storearray = explode (";",$idlist);
+		foreach($storearray as $id)
 		{
-			$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST["parentid"].",".$id.")";
-			$adb->query($sql);
-			$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parentid"] .",".$id.")";
-			$adb->query($sql);
+			if($id != '')
+				$adb->query("update vtiger_products set vendor_id=".$record." where productid=".$id);
 		}
 	}
-	if($singlepane_view == 'true')
-		header("Location: index.php?action=DetailView&module=Vendors&record=".$_REQUEST["parentid"]);
-	else
- 		header("Location: index.php?action=CallRelatedList&module=Vendors&record=".$_REQUEST["parentid"]);
+	elseif($_REQUEST['parid'] != '' && $_REQUEST['entityid'] != '')
+	{
+		$sql = "update vtiger_products set vendor_id=".$_REQUEST['parid']." where productid=".$_REQUEST['entityid'];
+		$adb->query($sql);
+		$record = $_REQUEST['parid'];
+	}
 }
 
-elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
+//select contact from vendor relatedlist
+if($_REQUEST['destination_module']=='Contacts')
 {
+	if(isset($_REQUEST['idlist']) && $_REQUEST['idlist'] != '')
+	{
+		$record = $_REQUEST["parentid"];
 
-		$sql = "insert into vtiger_vendorcontactrel values (".$_REQUEST['parid'].",".$_REQUEST['entityid'].")";
+		//split the string and store in an array
+		$storearray = explode (";",$idlist);
+		foreach($storearray as $id)
+		{
+			if($id != '')
+			{
+				$sql = "insert into vtiger_vendorcontactrel values (".$record.",".$id.")";
+				$adb->query($sql);
+			}
+		}
+	}
+	elseif(isset($_REQUEST['entityid']) && $_REQUEST['entityid'] != '')
+	{
+		$record = $_REQUEST["parid"];
+
+		$sql = "insert into vtiger_vendorcontactrel values (".$record.",".$_REQUEST['entityid'].")";
 		$adb->query($sql);
-		$sql = "insert into vtiger_seproductsrel values (". $_REQUEST["parid"] .",".$_REQUEST["entityid"] .")";
-		$adb->query($sql);
-		if($singlepane_view == 'true')
-			header("Location: index.php?action=DetailView&module=Vendors&record=".$_REQUEST["parid"]);
-		else
- 			header("Location:index.php?action=CallRelatedList&module=Vendors&record=".$_REQUEST["parid"]);
+	}
 }
 
 
+header("Location:index.php?action=$action&module=Vendors&record=".$record);
 
 
 

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/CallRelatedList.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/CallRelatedList.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/CallRelatedList.php Mon Apr 16 12:27:44 2007
@@ -18,7 +18,7 @@
 require_once('include/upload_file.php');
 require_once('include/database/PearDatabase.php');
 require_once('include/utils/utils.php');
-require_once('modules/Webmails/Webmail.php');
+require_once('modules/Webmails/Webmails.php');
 require_once('modules/Webmails/MailParse.php');
 
 global $log;
@@ -40,7 +40,7 @@
 $mbox = getImapMbox($mailbox,$temprow);
 
 
-$email = new Webmail($mbox, $mailid);
+$email = new Webmails($mbox, $mailid);
 $from = $email->from;
 $subject=$email->subject;
 $date=$email->date;
@@ -85,7 +85,6 @@
 $smarty->assign("NAME","From: ".$from);
 $smarty->assign("RELATEDLISTS", $block);
 $smarty->assign("SINGLE_MOD","Webmails");
-$smarty->assign("REDIR_MOD","Webmails");
 $smarty->assign("MODULE", "Webmails");
 $smarty->assign("ID",$_REQUEST["record"] );
 $smarty->assign("MOD",$mod_strings);

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/DetailView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/DetailView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/DetailView.php Mon Apr 16 12:27:44 2007
@@ -9,7 +9,7 @@
   *
  ********************************************************************************/
 require_once('include/utils/UserInfoUtil.php');
-require_once("modules/Webmails/Webmail.php");
+require_once("modules/Webmails/Webmails.php");
 require_once("modules/Webmails/MailBox.php");
 
 global $app_strings;
@@ -21,7 +21,7 @@
 global $MailBox;
 $MailBox = new MailBox($mailbox);
 
-$webmail = new Webmail($MailBox->mbox,$mailid);
+$webmail = new Webmails($MailBox->mbox,$mailid);
 $elist = $MailBox->mailList["overview"][($mailid-1)];
 
 echo '<table width="100%" cellpadding="0" cellspacing="0" border="0" class="previewWindow"><tr>';
@@ -29,22 +29,29 @@
 echo '<td>';
 
 echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
-echo '<tr><td width="10%">From:</td><td>'.$elist->from.'</td></tr>';
-echo '<tr><td width="10%">To:</td><td>'.$elist->to.'</td></tr>';
-echo '<tr><td width="10%">Subject:</td><td>'.$elist->subject.'</td></tr>';
-echo '<tr><td width="10%">Date:</td><td>'.$elist->date.'</td></tr>';
+echo '<tr><td width="10%">'.$mod_strings['LBL_FROM'].'</td><td>'.$elist->from.'</td></tr>';
+echo '<tr><td width="10%">'.$mod_strings['LBL_TO'].'</td><td>'.$elist->to.'</td></tr>';
+
+//Added to get the UTF-8 string - 30-11-06 - Mickie
+$elist->subject = utf8_decode(imap_utf8($elist->subject));
+
+echo '<tr><td width="10%">'.$mod_strings['LBL_SUBJECT'].'</td><td>'.$elist->subject.'</td></tr>';
+echo '<tr><td width="10%">'.$mod_strings['LBL_DATE'].'</td><td>'.$elist->date.'</td></tr>';
 echo '</table>';
 
 echo '</td></tr>';
+$array_tab = Array();
+$webmail->loadMail($array_tab);
 
-$webmail->loadMail();
-
-echo '<tr><td align="center"><iframe src="index.php?module=Webmails&action=body&mailid='.$mailid.'&mailbox='.$mailbox.'" width="100%" height="450" frameborder="0" style="border:1px solid gray">No Iframes supported</iframe></td></tr>';
-
-echo "<tr><td><p style='font-weight:bold'>Email Attachments:</p></td></tr>";
-
-foreach($webmail->attachments as $key=>$value) {
+echo '<tr><td align="center"><iframe src="index.php?module=Webmails&action=body&mailid='.$mailid.'&mailbox='.$mailbox.'" width="100%" height="450" frameborder="0" style="border:1px solid gray">'.$mod_strings['LBL_NO_IFRAMES_SUPPORTED'].'</iframe></td></tr>';
+if($webmail->has_attachments)
+{
+	//check for attachments
+	echo "<tr><td><p style='font-weight:bold'>".$mod_strings['LBL_EMAIL_ATTACHMENTS']."</p></td></tr>";
+	echo "<tr><td>".$webmail->att_links."</td></tr>";
+}
+/*foreach($webmail->attachments as $key=>$value) {
 	echo '<tr><td>'.($key+1).') <a href="index.php?module=Webmails&action=dlAttachments&num='.$key.'&mailid='.$mailid.'&mailbox='.$mailbox.'" target="_blank">'.$value["filename"]."</a></td></tr>";
-}
+}*/
 echo '</table>';
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/ListView.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/ListView.php Mon Apr 16 12:27:44 2007
@@ -10,11 +10,28 @@
   ********************************************************************************/
 
 // figure out which page we are on and what mailbox we want to view
-if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
-if($_REQUEST["start"] && $_REQUEST["start"] != "") {$start=$_REQUEST["start"];} else {$start="1";}
+//if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != ""){$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
+if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "")
+{
+	$mailbox=$_REQUEST["mailbox"];
+}
+else
+{
+	$mailbox="INBOX";
+}
+
+if($_REQUEST["start"] && $_REQUEST["start"] != "")
+{
+	$start=$_REQUEST["start"];
+}
+else
+{
+	$start="1";
+}
 $show_hidden=$_REQUEST["show_hidden"];
 
 global $current_user;
+
 require_once('Smarty_setup.php');
 require_once("data/Tracker.php");
 require_once('themes/'.$theme.'/layout_utils.php');
@@ -22,7 +39,7 @@
 require_once('include/utils/utils.php');
 require_once('include/utils/UserInfoUtil.php');
 require_once("modules/Webmails/MailBox.php");
-require_once("modules/Webmails/Webmail.php");
+require_once("modules/Webmails/Webmails.php");
 require_once("modules/Webmails/MailParse.php");
 
 $MailBox = new MailBox($mailbox);
@@ -39,7 +56,6 @@
 $degraded_service='false';
 if($MailBox->mail_protocol == "imap" || $MailBox->mail_protocol == "pop3")
 	$degraded_service='true';
-
 
 if($_POST["command"] == "check_mbox_all") {
 	exit();
@@ -83,38 +99,52 @@
         flush();
         exit();
 }
-
+//This is invoked from Webmails.js as a result of the periodic event function call, checks only for NEW mails; this in turn checks for new mails in all the mailboxes
 if($_POST["command"] == "check_mbox") {
         $adb->println("Inside check_mbox AJAX command");
 
-        $search = imap_search($MailBox->mbox, "ALL NEW");
-        if($search === false) {echo "failed";flush();exit();}
-
-        $data = imap_fetch_overview($MailBox->mbox,implode(',',$search));
+	$search = imap_search($MailBox->mbox, 'NEW');
+
+        //if($search === false) {echo "failed";flush();exit();}
+
+	$adb->println("imap_search($MailBox->mbox, $criteria) ===> ");
+	$adb->println($search);
+	
+	$data = imap_fetch_overview($MailBox->mbox,implode(',',$search));
         $num=sizeof($data);
+
+	$adb->println("fetched data using imap_fetch_overview ==>");
+	$adb->println($data);
 
         $ret = '';
         if($num > 0) {
                 $ret = '{"mails":[';
-                for($i=0;$i<$num;$i++) {
-                        $ret .= '{"mail":';
-                        $ret .= '{';
-                        $ret .= '"mailid":"'.$data[$i]->msgno.'",';
-                        $ret .= '"subject":"'.substr($data[$i]->subject,0,40).'",';
-                        $ret .= '"date":"'.substr($data[$i]->date,0,30).'",';
-                        $ret .= '"from":"'.substr($data[$i]->from,0,20).'",';
-                        $ret .= '"to":"'.$data[$i]->to.'",';
-                        $email = new Webmail($MailBox->mbox,$data[$i]->msgno);
-                        if($email->has_attachments)
-                                $ret .= '"attachments":"1"}';
-                        else
-                                $ret .= '"attachments":"0"}';
-                        if(($i+1) == $num)
-                                $ret .= '}';
-                        else
-                                $ret .= '},';
+                for($i=0;$i<$num;$i++) 
+		{
+			//Added condition to avoid show the deleted mails and readed mails
+			if($data[$i]->deleted == 0)// && $data[$i]->seen == 0)
+			{
+                        	$ret .= '{"mail":';
+                        	$ret .= '{';
+                        	$ret .= '"mailid":"'.$data[$i]->msgno.'",';
+                       		$ret .= '"subject":"'.substr($data[$i]->subject,0,40).'",';
+                        	$ret .= '"date":"'.substr($data[$i]->date,0,30).'",';
+                        	$ret .= '"from":"'.substr($data[$i]->from,0,20).'",';
+				$ret .= '"to":"'.$data[$i]->to.'",';
+				echo  ' to field is  ' .$data[$i]->to;
+                        	$email = new Webmails($MailBox->mbox,$data[$i]->msgno);
+                        	if($email->has_attachments)
+                        	        $ret .= '"attachments":"1"}';
+                        	else
+                        	        $ret .= '"attachments":"0"}';
+                        	if(($i+1) == $num)
+                        	        $ret .= '}';
+                        	else
+                        	        $ret .= '},';
+			}
                 }
                 $ret .= ']}';
+		$adb->println("Ret Value ==> $ret");
         }
 
         echo $ret;
@@ -129,7 +159,15 @@
 
 <script type="text/javascript">
 // Pass our PHP variables to js.
-<?php if($degraded_service == 'true') { echo 'var degraded_service="true";';}else{echo 'var degraded_service="false";';};?>
+<?php if($degraded_service == 'true')
+				{
+					echo 'var degraded_service="true";';
+				}
+else
+{
+	echo 'var degraded_service="false";';
+};
+?>
 var mailbox = "<?php echo $MailBox->mailbox;?>";
 var box_refresh=<?php echo $MailBox->box_refresh;?>;
 var webmail = new Array();
@@ -143,13 +181,20 @@
 	}
 );
 </script>
-<script language="JavaScript" type="text/javascript" src="modules/Webmails/webmails.js"></script>
-<?
+<script language="JavaScript" type="text/javascript" src="modules/Webmails/Webmails.js"></script>
+<?php
 
 global $displayed_msgs;
 // AJAX commands (should be moved)
 if($_POST["command"] == "move_msg" && $_POST["ajax"] == "true") {
-	imap_mail_move($MailBox->mbox,$_REQUEST["mailid"],$_REQUEST["mvbox"]);
+	if(isset($_REQUEST["mailid"]) && $_REQUEST["mailid"] != '')
+	{
+		$mailids = explode(':',$_REQUEST["mailid"]);
+	}
+	foreach($mailids as $mailid)
+	{
+		imap_mail_move($MailBox->mbox,$mailid,$_REQUEST["mvbox"]);
+	}
 	imap_close($MailBox->mbox);
 	echo "SUCCESS";
 	flush();
@@ -176,21 +221,28 @@
 $elist = $MailBox->mailList;
 $numEmails = $elist["count"];
 $headers = $elist["headers"];
+$mails_per_page = $MailBox->mails_per_page;
+
 
 if($start == 1 || $start == "") {
 	$start_message=$numEmails;
 } else {
-	$start_message=($numEmails-($start*$mails_per_page));
-}
+	$start_message=($numEmails-(($start-1)*$mails_per_page));
+}
+
 $c=$numEmails;
 
 if(!isset($_REQUEST["search"])) {
-	$numPages = round($numEmails/$MailBox->mails_per_page);
+	$numPages = ceil($numEmails/$MailBox->mails_per_page);
 	if($numPages > 1) {
+		if($start != 1){
 		$navigationOutput = "<a href='index.php?module=Webmails&action=index&start=1&mailbox=".$mailbox."'><img src='modules/Webmails/images/start.gif' border='0'></a>&nbsp;&nbsp;";
 		$navigationOutput .= "<a href='index.php?module=Webmails&action=index&start=".($start-1)."&mailbox=".$mailbox."'><img src='modules/Webmails/images/previous.gif' border='0'></a> &nbsp;";
+		}
+		if($start <= ($numPages-1)){
 		$navigationOutput .= "<a href='index.php?module=Webmails&action=index&start=".($start+1)."&mailbox=".$mailbox."'><img src='modules/Webmails/images/next.gif' border='0'></a>&nbsp;&nbsp;";
 		$navigationOutput .= "<a href='index.php?module=Webmails&action=index&start=".$numPages."&mailbox=".$mailbox."'><img src='modules/Webmails/images/end.gif' border='0'></a>";
+		}
 	}
 }
 
@@ -202,108 +254,155 @@
 // these are mainly used in the preview window and could be ajaxified/
 // during the preview window load instead.
 var msgCount = "<?php echo $numEmails;?>";
-<?
+<?php
 $mails = array();
-if (is_array($overview)) {
-   foreach ($overview as $val) {
-	$mails[$val->msgno] = $val;
+if (is_array($overview))
+{
+	foreach ($overview as $val)
+	{
+		$mails[$val->msgno] = $val;
+		$hdr = @imap_headerinfo($MailBox->mbox, $val->msgno);	
+		//Added to get the UTF-8 string - 30-11-06 - Mickie
+		//we have to do this utf8 decode for the fields which may contains special characters -- Mickie - 02-02-07
+		$val->from = utf8_decode(imap_utf8(addslashes($val->from)));
+		$val->to = utf8_decode(imap_utf8(addslashes($val->to)));
+		$val->subject = utf8_decode(imap_utf8($val->subject));
 	?>
-	webmail[<?php echo $val->msgno;?>] = new Array();
-	webmail[<?php echo $val->msgno;?>]["from"]="<?php echo addslashes($val->from);?>";
-	webmail[<?php echo $val->msgno;?>]["to"]="<?php echo addslashes($val->to);?>";
-	webmail[<?php echo $val->msgno;?>]["subject"]="<?php echo addslashes($val->subject);?>";
-	webmail[<?php echo $val->msgno;?>]["date"]="<?php echo addslashes($val->date);?>";
-	<?
-   }
+
+		webmail[<?php echo $val->msgno;?>] = new Array();
+		webmail[<?php echo $val->msgno;?>]["from"]="<?php echo addslashes($val->from);?>";
+		webmail[<?php echo $val->msgno;?>]["to"]="<?php echo addslashes($val->to);?>";
+		webmail[<?php echo $val->msgno;?>]["subject"]="<?php echo addslashes($val->subject);?>";
+		webmail[<?php echo $val->msgno;?>]["date"]="<?php echo addslashes($val->date);?>";
+
+		webmail[<?php echo $val->msgno;?>]["cc"]="<?php echo $hdr->ccaddress;?>";
+
+	<?php
+	}
 }
 echo "</script>";
 
-$listview_header = array("<th>Info</th>","<th>Subject</th>","<th>Date</th>","<th>From</th>","<th>Del</th>");
+$search_fields = Array("SUBJECT","BODY","TO","CC","BCC","FROM");
+$listview_header = array("<th width='10%'>".$mod_strings['LBL_INFO']."</th>","<th width='45%'>".$mod_strings['LBL_LIST_SUBJECT']."</th>","<th width='25%'>".$mod_strings['LABEL_DATE']."</th>","<th width='10%'>".$mod_strings['LABEL_FROM']."</th>","<th>".$mod_strings['LBL_DEL']."</th>");
 $listview_entries = array();
 
 $displayed_msgs=0;
 $new_msgs=0;
-if(($numEmails-1) <= 0)
-	$listview_entries[0][] = '<td colspan="6" width="100%" align="center"><b>No Emails In This Folder</b></td>';
+if(($numEmails) <= 0)
+	$listview_entries[0][] = '<td colspan="6" width="100%" align="center"><b>'.$mod_strings['LBL_NO_EMAILS'].'</b></td>';
 else {
 
-if(isset($_REQUEST["search"])) {
-	$searchstring = $_REQUEST["search_type"].' "'.$_REQUEST["search_input"].'"';
-	//echo $searchstring."<br>";
-	$searchlist = imap_search($MailBox->mbox,$searchstring);
-	if($searchlist === false)
-  		echo "The search failed";
-
-	$num_searches = count($searchlist);
-
-	//print_r($searchlist);
-	$c=$numEmails;
-}
-
-flush();
-
-// MAIN LOOP
-// Main loop to create listview entries
-$i=1;
-while ($i<$c) {
-	if(is_array($searchlist)) {
-		for($l=0;$l<$num_searches;$l++) {
-			if($mails[$start_message]->msgno == $searchlist[$l])
+	if(isset($_REQUEST["search"]) && trim($_REQUEST["search_input"]) != '') {
+		$searchstring = $_REQUEST["search_type"].' "'.$_REQUEST["search_input"].'"';
+		//echo $searchstring."<br>";
+		$searchlist = Array();
+		$searchlist = imap_search($MailBox->mbox,$searchstring);
+
+		if(is_array($searchlist))
+		{
+			$num_searches = count($searchlist);
+			$c=$numEmails;
+		}
+
+		while ($i<=$c) {
+			if(is_array($searchlist)) {
+				for($l=0;$l<$num_searches;$l++) {
+					if($mails[$start_message]->msgno == $searchlist[$l])
+						$listview_entries[] = show_msg($mails,$start_message);
+				}
+			}
+			$i++;
+			$start_message--;
+		}
+	}else
+	{
+		$i=1;
+		while ($i<=$c) {
+			if($start_message > 0)
+			{
 				$listview_entries[] = show_msg($mails,$start_message);
-		}
-	} else {
-		$listview_entries[] = show_msg($mails,$start_message);
-		if($displayed_msgs == $MailBox->mails_per_page) {break;}
-	}
-  	$i++;
-  	$start_message--;
-}
-}
+				if($displayed_msgs == $MailBox->mails_per_page) {break;}
+			}
+			$i++;
+			$start_message--;
+		}
+
+	}
+
+	flush();
+	// MAIN LOOP
+	// Main loop to create listview entries
+
+}
+
+$search_html = '<select name="optionSel" class="importBox" id="search_type">';
+foreach($search_fields as $searchfield)
+{
+	if($_REQUEST['search_type'] == $searchfield)
+		$search_html .= '<option selected value="'.$searchfield.'">'.$mod_strings["IN"].' '.$mod_strings[$searchfield].'</option>';
+	else
+		$search_html .= '<option value="'.$searchfield.'">'.$mod_strings["IN"].' '.$mod_strings[$searchfield].'</option>';
+			
+}
+$search_html .= '</select>';
 
 // Build folder list and move_to dropdown box
 $list = imap_getmailboxes($MailBox->mbox, "{".$MailBox->imapServerAddress."}", "*");
 sort($list);
 $i=0;
 if (is_array($list)) {
-      	$boxes = '<select name="mailbox" id="mailbox_select">';
-        foreach ($list as $key => $val) {
+      	$boxes = '<select name="mailbox" id="mailbox_select" onChange="move_messages();">';
+        $boxes .= '<option value="move_to" SELECTED>'.$mod_strings['LBL_MOVE_TO'].'</option>';
+	foreach ($list as $key => $val) {
 		$tmpval = preg_replace(array("/\{.*?\}/i"),array(""),$val->name);
 		if(preg_match("/trash/i",$tmpval))
 			$img = "webmail_trash.gif";
 		elseif(preg_match("/sent/i",$tmpval))
-			$img = "webmail_uparrow.gif";
+			$img = "emailOutFolder.gif";
 		else
-			$img = "webmail_downarrow.gif";
+			$img = "emailInFolder.gif";
 
 		$i++;
 
+		if($_REQUEST["mailbox"] == '')
+			$_REQUEST["mailbox"] = 'INBOX';
+
 		if ($_REQUEST["mailbox"] == $tmpval) {
-                        $boxes .= '<option value="'.$tmpval.'" SELECTED>'.$tmpval;
+		/*	if($tmpval != "INBOX")
+				$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
+		 */
 			$_SESSION["mailboxes"][$tmpval] = $new_msgs;
 
 			if($numEmails==0) {$num=$numEmails;} else {$num=($numEmails-1);}
-			$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu" onmouseover="show_remfolder(\''.$tmpval.'\');" onmouseout="show_remfolder(\''.$tmpval.'\');">'.$tmpval.'</a>&nbsp;&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">(<span id="'.$tmpval.'_unread">'.$new_msgs.'</span> of <span id="'.$tmpval.'_read">'.$num.'</span>)</span>&nbsp;&nbsp;<span id="remove_'.$tmpval.'" style="position:relative;display:none">Remove</span></li>';
+			$folders .= '<li class="tabUnSelected" style="padding-left:0px;"><img src="'.$image_path.'/'.$img.'"align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">';
+			if($new_msgs > 0)
+				$folders .= '(<span id="'.$tmpval.'_unread">'.$new_msgs.'</span>)</span>&nbsp;&nbsp;<span id="remove_'.$tmpval.'" style="position:relative;display:none">Remove</span></li>';
+
 		} else {
 			$box = imap_status($MailBox->mbox, "{".$MailBox->imapServerAddress."}".$tmpval, SA_ALL);
 			$_SESSION["mailboxes"][$tmpval] = $box->unseen;
 
 			if($box->messages==0) {$num=$box->messages;} else {$num=($box->messages-1);}
-                      	$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
-			$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">(<span id="'.$tmpval.'_unread">'.$box->unseen.'</span> of <span id="'.$tmpval.'_read">'.$num.'</span>)</span></li>';
-		}
- 	}
+			$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
+			$folders .= '<li class="lvtColData" onmouseover="this.className=\'lvtColDataHover\'" onmouseout="this.className=\'lvtColData\'"><img src="'.$image_path.'/'.$img.'" align="absmiddle" />&nbsp;&nbsp;<a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a>&nbsp;<span id="'.$tmpval.'_count" style="font-weight:bold">';
+			if($box->unseen > 0)
+				$folders .= '(<span id="'.$tmpval.'_unread">'.$box->unseen.'</span>)</span></li>';
+		}
+	}
         $boxes .= '</select>';
 }
 
 imap_close($MailBox->mbox);
 
 $smarty = new vtigerCRM_Smarty;
+$smarty->assign("SEARCH_VALUE",$_REQUEST['search_input']);
 $smarty->assign("USERID", $current_user->id);
 $smarty->assign("MOD", $mod_strings);
 $smarty->assign("APP", $app_strings);
 $smarty->assign("IMAGE_PATH",$image_path);
 $smarty->assign("LISTENTITY", $listview_entries);
 $smarty->assign("LISTHEADER", $listview_header);
+$smarty->assign("SEARCH_HTML", $search_html);
 $smarty->assign("MODULE","Webmails");
 $smarty->assign("SINGLE_MOD",'Webmails');
 $smarty->assign("BUTTONS",$other_text);

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/MailBox.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/MailBox.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/MailBox.php Mon Apr 16 12:27:44 2007
@@ -1,4 +1,4 @@
-<?php
+<?php
 /*********************************************************************************
  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   * ("License"); You may not use this file except in compliance with the License
@@ -56,12 +56,12 @@
 		$this->mail_protocol=$this->boxinfo["mail_protocol"]; 
 		$this->ssltype=$this->boxinfo["ssltype"]; 
 		$this->sslmeth=$this->boxinfo["sslmeth"]; 
+
 		$this->box_refresh=trim($this->boxinfo["box_refresh"]);
-		$this->mails_per_page=trim($this->boxinf["mails_per_page"]);
+		$this->mails_per_page=trim($this->boxinfo["mails_per_page"]);
 		if($this->mails_per_page < 1)
         		$this->mails_per_page=20;
 
-		$this->mail_protocol=$this->boxinfo["mail_protocol"];
 		$this->account_name=$this->boxinfo["account_name"];
 		$this->display_name=$this->boxinfo["display_name"];
 		//$this->imapServerAddress=$this->boxinfo["mail_servername"];
@@ -105,46 +105,73 @@
 
 		if($this->mail_protocol == "pop3")
 			$port = "110";
-		else {
-	    		if($mods["imap"]["SSL Support"] == "enabled" && $this->ssltype == "ssl")
+		else
+		{
+	    		if($mods["imap"]["SSL Support"] == "enabled" && $this->ssltype == "tls")
 				$port = "993";
 			else
 				$port = "143";
 		}
 
 		$this->db->println("Building connection string");
-                if(preg_match("/@/",$this->login_username)) {
+                if(preg_match("/@/",$this->login_username)) 
+		{
                         $mailparts = split("@",$this->login_username);
                         $user="".trim($mailparts[0])."";
                         $domain="".trim($mailparts[1])."";
 
 			// This section added to fix a bug when connecting as user at domain.com
-			if($this->readonly == "true") {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}/readonly}".$this->mailbox;
+			if($this->readonly == "true") 
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+                                	$connectString = "/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}/readonly";
 				else
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert/user={$user}@{$domain}/readonly}".$this->mailbox;
-			} else {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}}".$this->mailbox;
+                                	$connectString = "/notls/novalidate-cert/user={$user}@{$domain}/readonly";
+			}
+			else
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+                                	$connectString = "/".$this->ssltype."/".$this->sslmeth."/user={$user}@{$domain}";
 				else
-                                	$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert/user={$user}@{$domain}}".$this->mailbox;
-			}
-                } else {
-			if($this->readonly == "true") {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."/readonly}".$this->mailbox;
+                                	$connectString = "/notls/novalidate-cert/user={$user}@{$domain}";
+			}
+		}
+		else
+		{
+			if($this->readonly == "true")
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+					$connectString = "/".$this->ssltype."/".$this->sslmeth."/readonly";
 	    			else
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert/readonly}".$this->mailbox;
-			} else {
-	    			if($mods["imap"]["SSL Support"] == "enabled")
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/".$this->ssltype."/".$this->sslmeth."}".$this->mailbox;
+					$connectString = "/notls/novalidate-cert/readonly";
+			}
+			else
+			{
+	    			if($mods["imap"]["SSL Support"] == "enabled")
+					$connectString = "/".$this->ssltype."/".$this->sslmeth;
 	    			else
-					$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."/notls/novalidate-cert}".$this->mailbox;
-			}
-		}
+					$connectString = "/notls/novalidate-cert";
+			}
+		}
+
+		$connectString = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port.$connectString."}".$this->mailbox;
+		//Reference - http://forums.vtiger.com/viewtopic.php?p=33478#33478 - which has no tls or validate-cert
+		$connectString1 = "{".$this->imapServerAddress."/".$this->mail_protocol.":".$port."}".$this->mailbox; 
+
 		$this->db->println("Done Building Connection String.. Connecting to box");
-		$this->mbox = imap_open($connectString, $this->login_username, $this->secretkey); 
+
+		if(!$this->mbox = @imap_open($connectString, $this->login_username, $this->secretkey))
+		{
+			//try second string which has no tls or validate-cert
+			if(!$this->mbox = @imap_open($connectString1, $this->login_username, $this->secretkey))
+			{
+				global $current_user,$mod_strings;
+				$this->db->println("CONNECTION ERROR - Could not be connected to the server using imap_open function through the connection strings $connectString and $connectString1");
+				echo "<br>&nbsp;<b>".$mod_strings['LBL_MAIL_CONNECT_ERROR']."<a href='index.php?module=Users&action=AddMailAccount&return_module=Webmails&return_action=index&record=".$current_user->id."'> Here </a>. Please <a href='index.php?module=Emails&action=index&parenttab=My Home Page'>".$mod_strings['LBL_CLICK_HERE']."</a>".$mod_strings['LBL_GOTO_EMAILS_MODULE']." </b>";
+				exit;
+			}
+		}
+
 		$this->db->println("Done connecting to box");
 	}
 } // END CLASS

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/MailParse.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/MailParse.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/MailParse.php Mon Apr 16 12:27:44 2007
@@ -1,4 +1,4 @@
-<?php
+<?php
 /*********************************************************************************
  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   * ("License"); You may not use this file except in compliance with the License
@@ -11,60 +11,85 @@
 
 
 // draw a row for the listview entry
-function show_msg($mails,$start_message) {
-        global $MailBox,$displayed_msgs,$show_hidden,$new_msgs;
+function show_msg($mails,$start_message)
+{
+	global $MailBox,$displayed_msgs,$show_hidden,$new_msgs;
 
-        $num = $mails[$start_message]->msgno;
-        $msg_ob = new Webmail($MailBox->mbox,$mails[$start_message]->msgno);
+	$num = $mails[$start_message]->msgno;
+	$msg_ob = new Webmails($MailBox->mbox,$mails[$start_message]->msgno);
 
-        // TODO: scan the current db vtiger_tables to find a
-        // matching email address that will make a good
-        // candidate for record_id
-        // this module will also need to be able to associate to any entity type
-        $record_id='';
+	// TODO: scan the current db vtiger_tables to find a
+	// matching email address that will make a good
+	// candidate for record_id
+	// this module will also need to be able to associate to any entity type
+	$record_id='';
 
-        if($mails[$start_message]->subject=="")
-                $mails[$start_message]->subject="(No Subject)";
+	if($mails[$start_message]->subject=="")
+		$mails[$start_message]->subject="(No Subject)";
 
-        // Let's pre-build our URL parameters since it's too much of a pain not to
-        $detailParams = 'record='.$num.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
+	// Let's pre-build our URL parameters since it's too much of a pain not to
+	$detailParams = 'record='.$num.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
 
-        $displayed_msgs++;
-        if ($mails[$start_message]->deleted && !$show_hidden) {
-                $flags = "<tr id='row_".$num."' class='deletedRow' style='display:none'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
-        $displayed_msgs--;
-        } elseif ($mails[$start_message]->deleted && $show_hidden)
-                $flags = "<tr id='row_".$num."' class='deletedRow'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
-        elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent) {
-                $flags = "<tr class='unread_email' id='row_".$num."'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
-                $new_msgs++;
-        } else
-                $flags = "<tr id='row_".$num."'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
+	$displayed_msgs++;
+	if ($mails[$start_message]->deleted && !$show_hidden)
+	{
+                $flags = "<tr id='row_".$num."' class='mailSelected' style='display:none'><td width='2px'><input type='checkbox' class='msg_check'></td><td colspan='1'>";
+        	$displayed_msgs--;
+	}
+	elseif ($mails[$start_message]->deleted && $show_hidden)
+	{
+		$flags = "<tr id='row_".$num."' class='mailSelected'><td width='2px'><input type='checkbox' class='msg_check'></td><td colspan='1'>";
+	}
+	elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent)
+	{
+			$flags = "<tr class='mailSelected' id='row_".$num."'><td width='2px'><input type='checkbox' name='selected_id' onclick='toggleSelectAll(this.name,\"select_all\")' value='$num' class='msg_check'></td><td colspan='1'>";
+		$new_msgs++;
+	}
+	else
+	{
+	$flags = "<tr id='row_".$num."'><td width='2px'><input type='checkbox' name='selected_id' value='$num' onclick='toggleSelectAll(this.name,\"select_all\")' class='msg_check'></td><td colspan='1'>";
+
+	}
+
+
+
 
         // Attachment Icons
         if($msg_ob->has_attachments)
-                $flags.='<a href="javascript:;" onclick="displayAttachments('.$num.');"><img src="modules/Webmails/images/stock_attach.png" border="0" width="14px" height="14"></a>&nbsp;';
+                $flags.='<a href="javascript:;" onclick="displayAttachments('.$num.');"><img src="modules/Webmails/images/stock_attach.png" border="0" width="14px" height="14" title="Attachment"></a>&nbsp;';
         else
                 $flags.='<img src="modules/Webmails/images/blank.png" border="0" width="14px" height="14" alt="">&nbsp;';
 
+
+
         // read/unread/forwarded/replied
         if(!$mails[$start_message]->seen || $mails[$start_message]->recent)
-        {
-                $flags.='<span id="unread_img_'.$num.'"><a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-unread.png" border="0" width="10" height="14"></a></span>&nbsp;';
-        }
-        elseif ($mails[$start_message]->in_reply_to || $mails[$start_message]->references || preg_match("/^re:/i",$mails[$start_message]->subject))
-                $flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-replied.png" border="0" width="10" height="12"></a>&nbsp;';
-        elseif (preg_match("/^fw:/i",$mails[$start_message]->subject))
-                $flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-forward.png" border="0" width="10" height="13"></a>&nbsp;';
-        else
-                $flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-read.png" border="0" width="10" height="11"></a>&nbsp;';
+	{
+		$flags.='<span id="unread_img_'.$num.'"><a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-unread.png" border="0" width="10" height="14" title="Unread"></a></span>&nbsp;';
+	}
+	elseif ($mails[$start_message]->in_reply_to || $mails[$start_message]->references || preg_match("/^re:/i",$mails[$start_message]->subject))
+	{
+		$flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-replied.png" border="0" width="10" height="12" title="Replied" ></a>&nbsp;';
+	}
+	elseif (preg_match("/^fw:/i",$mails[$start_message]->subject))
+	{
+		$flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-forward.png" border="0" width="10" height="13" title="Forward" ></a>&nbsp;';
+	}
+	else
+	{
+                $flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-read.png" border="0" width="10" height="11" title="Read" ></a>&nbsp;';
+	}
 
         // Set IMAP flag
-        if($mails[$start_message]->flagged)
-                $flags.='<span id="clear_td_'.$num.'"><a href="javascript:runEmailCommand(\'clear_flag\','.$num.');"><img src="modules/Webmails/images/stock_mail-priority-high.png" border="0" width="11" height="11" id="clear_flag_img_'.$num.'"></a></span>';
-        else
-                $flags.='<span id="set_td_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'set_flag\','.$num.');"><img src="modules/Webmails/images/plus.gif" border="0" width="11" height="11" id="set_flag_img_'.$num.'"></a></span>';
+	if($mails[$start_message]->flagged)
+	{
+		$flags.='<span id="clear_td_'.$num.'"><a href="javascript:runEmailCommand(\'clear_flag\','.$num.');"><img src="modules/Webmails/images/stock_mail-priority-high.png" border="0" width="11" height="11" id="clear_flag_img_'.$num.'"title="Important"></a></span>';
+	}
+	else
+	{
+                $flags.='<span id="set_td_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'set_flag\','.$num.');"><img src="modules/Webmails/images/plus.gif" border="0" width="11" height="11" id="set_flag_img_'.$num.'"title="Important"></a></span>';
 
+	}
 
         $tmp=imap_mime_header_decode($mails[$start_message]->from);
         $from = $tmp[0]->text;
@@ -72,24 +97,53 @@
 
         $listview_entries[$num][] = $flags."</td>";
 
-        if ($mails[$start_message]->deleted) {
-                $listview_entries[$num][] = '<td width="20%" nowrap align="left" id="deleted_subject_'.$num.'"><s><a href="javascript:;" onclick="load_webmail(\''.$num.'\');">'.substr($mails[$start_message]->subject,0,50).'</a></s></td>';
-                $listview_entries[$num][] = '<td width="10%" nowrap align="left" nowrap id="deleted_date_'.$num.'"><s>'.substr($mails[$start_message]->date,0,30).'</s></td>';
-                $listview_entries[$num][] = '<td width="10%" nowrap align="left" id="deleted_from_'.$num.'"><s>'.substr($from,0,20).'</s></td>';
-        } elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent) {
-                $listview_entries[$num][] = '<td width="20%" nowrap align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
-                $listview_entries[$num][] = '<td width="10%" nowrap align="left" nowrap id="ndeleted_date_'.$num.'" >'.substr($mails[$start_message]->date,0,30).' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>';
-                $listview_entries[$num][] = '<td  width="10%" nowrap align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,20).'</td>';
-        } else {
-                $listview_entries[$num][] = '<td width="20%" nowrap align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
-                $listview_entries[$num][] = '<td width="10%" npwrap align="left" nowrap id="ndeleted_date_'.$num.'">'.substr($mails[$start_message]->date,0,30).'</td>';
-                $listview_entries[$num][] = '<td width="10%" nowrap align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,20).'</td>';
-        }
+	if ($mails[$start_message]->deleted)
+	{
+		$listview_entries[$num][] = '<td nowrap align="left" style="cursor:pointer;" id="deleted_subject_'.$num.'" onclick="load_webmail(\''.$num.'\');"><s><a href="javascript:;" >'.substr($mails[$start_message]->subject,0,50).'</a></s></td>';
+		$listview_entries[$num][] = '<td nowrap align="left" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\');" nowrap id="deleted_date_'.$num.'"><s>'.substr($mails[$start_message]->date,0,30).'</s></td>';
+		$listview_entries[$num][] = '<td nowrap align="left" id="deleted_from_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\');"><s>'.substr($from,0,20).'</s></td>';
+	}
+	elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent)
+	{
+		$listview_entries[$num][] = '<td nowrap align="left" onclick="load_webmail(\''.$num.'\');" style="cursor:pointer;" ><a href="javascript:;" id="ndeleted_subject_'.$num.'"><font id="fnt_subject_'.$num.'" color="green">'.substr($mails[$start_message]->subject,0,50).'</font></a></td>';
+		$listview_entries[$num][] = '<td nowrap align="left" nowrap id="ndeleted_date_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\');" ><font id="fnt_date_'.$num.'" color="green">'.substr($mails[$start_message]->date,0,30).' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</font></td>';
+		$listview_entries[$num][] = '<td  nowrap align="left" id="ndeleted_from_'.$num.'"><font id="fnt_from_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\');" >'.substr($from,0,20).'</font></td>';
+	}
+	else
+	{
+		//IMPORTANT - This UTF-8 conversion has been done in ListView.php so no need to do again here
+		//Added to shown the original UTF-8 characters - Mickie - 30-11-06 - Starts
+		//we can use the option 1 or option 2
+		//Option 1 - Starts
+		/*
+		$translated_subject = imap_mime_header_decode($mails[$start_message]->subject);
+		for($i=0;$i<count($translated_subject);$i++)
+		{
+			if($translated_subject[$i]->charset != 'default')
+			{
+				$tmp .= $translated_subject[$i]->text;
+				$mails[$start_message]->subject = utf8_decode($tmp);//$tmp;
+			}
+		}
+		//Option 1 - Ends
+		*/
+		//Option 2 - Starts
+		//$mails[$start_message]->subject = utf8_decode(imap_utf8($mails[$start_message]->subject));//imap_utf8($mails[$start_message]->subject);
+		//Option 2 - Ends
+		//Added to shown the original UTF-8 characters - Mickie - 30-11-06 - Ends
 
+		$listview_entries[$num][] = '<td nowrap align="left" onclick="load_webmail(\''.$num.'\');" style="cursor:pointer;" ><a href="javascript:;" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
+		$listview_entries[$num][] = '<td npwrap align="left" nowrap id="ndeleted_date_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\');" >'.substr($mails[$start_message]->date,0,30).'</td>';
+		$listview_entries[$num][] = '<td nowrap align="left" id="ndeleted_from_'.$num.'" style="cursor:pointer;" onClick="load_webmail(\''.$num.'\');" >'.substr($from,0,20).'</td>';
+	}
+
+
+	
         if($mails[$start_message]->deleted)
-                $listview_entries[$num][] = '<td nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-full.png" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
+                $listview_entries[$num][] = '<td nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"  title="Delete"></a></span></td></tr>';
         else
-                $listview_entries[$num][] = '<td nowrap align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
+                $listview_entries[$num][] = '<td nowrap align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"  title="Delete"></a></span></td></tr>';
+
 
         return $listview_entries[$num];
 }

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/Save.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/Save.php Mon Apr 16 12:27:44 2007
@@ -1,130 +1,130 @@
-<?php
-/*********************************************************************************
- ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-  * ("License"); You may not use this file except in compliance with the License
-  * The Initial Developer of the Original Code is FOSS Labs.
-  * Portions created by FOSS Labs are Copyright (C) FOSS Labs.
-  * Portions created by vtiger are Copyright (C) vtiger.
-  * All Rights Reserved.
-  *
-  ********************************************************************************/
-
-require_once('modules/Emails/Emails.php');
-require_once('modules/Webmails/Webmail.php');
-require_once('include/logging.php');
-require_once('include/database/PearDatabase.php');
-require_once('include/utils/UserInfoUtil.php');
-require_once('include/utils/CommonUtils.php');
-require_once('modules/Webmails/MailParse.php');
-require_once('modules/Webmails/MailBox.php');
-global $current_user;
-
-$local_log =& LoggerManager::getLogger('index');
-$focus = new Emails();
-
-$to_address = explode(";",$_REQUEST['to_list']);
-$cc_address = explode(";",$_REQUEST['cc_list']);
-$bcc_address = explode(";",$_REQUEST['bcc_list']);
-
-$start_message=$_REQUEST["start_message"];
-if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
-
-$MailBox = new MailBox($mailbox);
-$email = new Webmail($MailBox->mbox, $_REQUEST["mailid"]);
-$subject = $email->subject;
-$date = $email->date;
-
-$email->loadMail();
-$msgData = $email->body;
-
-$focus->column_fields['subject']=$subject;
-$focus->column_fields["activitytype"]="Emails";
-
-$ddate = date("Y-m-d");
-$dtime = date("h:m");
-$focus->column_fields["assigned_user_id"]=$current_user->id;
-$focus->column_fields["date_start"]=$ddate;
-$focus->column_fields["time_start"]=$dtime;
-
-//$tmpBody = preg_replace(array('/<br(.*?)>/i',"/&gt;/i","/&lt;/i","/&nbsp;/i","/&amp/i","/&copy;/i","/<style(.*?)>(.*?)<\/style>/i","/\{(.*?)\}/i","/BODY/i"),array("\r",">","<"," ","&","(c)","","",""),$msgData);
-//$focus->column_fields["description"]=strip_tags($tmpBody);
-$focus->column_fields["description"]=$msgData;
-
-
-//to save the email details in vtiger_emaildetails vtiger_tables
-$fieldid = $adb->query_result($adb->query('select fieldid from vtiger_field where tablename="contactdetails" and fieldname="email" and columnname="email"'),0,'fieldid');
-
-if($email->relationship != 0) {
-	$focus->column_fields['parent_id']=$email->relationship["id"].'@'.$fieldid.'|';
-
-	if($email->relationship["type"] == "Contacts")
-		add_attachment_to_contact($email->relationship["id"],$email);
-}else {
-	//if relationship is not available create a contact and relate the email to the contact
-	require_once('modules/Contacts/Contacts.php');
-	$contact_focus = new Contacts();	
-	$contact_focus->column_fields['lastname'] =$email->fromname; 
-	$contact_focus->column_fields['email'] = $email->from;
-	$contact_focus->save("Contacts");
-	$focus->column_fields['parent_id']=$contact_focus->id.'@'.$fieldid.'|';
-
-	add_attachment_to_contact($contact_focus->id,$email);
-}
-
-function add_attachment_to_contact($cid,$email) {
-	// add vtiger_attachments to contact
-	global $adb,$current_user;
-	for($j=0;$j<2;$j++) {
-	    if($j==0)
-	    	$attachments=$email->downloadAttachments();
-	    else
-	    	$attachments=$email->downloadInlineAttachments();
-
-	    $upload_filepath = decideFilePath();
-	    for($i=0,$num_files=count($attachments);$i<$num_files;$i++) {
-		$current_id = $adb->getUniqueID("vtiger_crmentity");
-		$date_var = $adb->formatDate(date('YmdHis'));	
-
-		$filename = ereg_replace("[ ()-]+", "_",$attachments[$i]["filename"]);
-        	$filetype= substr($filename,strstr($filename,"."),strlen($filename));
-		$filesize = $attachments[$i]["filesize"];
-
-                $query = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
-                $query .= $current_id."','".$current_user->id."','".$current_user->id."','Contacts Attachment','Uploaded from webmail during qualification',".$date_var.")";
-                $result = $adb->query($query);
-
-                $sql = "insert into vtiger_attachments values(";
-                $sql .= $current_id.",'".$filename."','Uploaded ".$filename." from webmail','".$filetype."','".$upload_filepath."')";
-		echo $query;
-                $result = $adb->query($sql);
-
-                $sql1 = "insert into vtiger_seattachmentsrel values('";
-                $sql1 .= $cid."','".$current_id."')";
-                $result = $adb->query($sql1);
-
-		$fp = fopen($upload_filepath.'/'.$filename, "w") or die("Can't open file");
-		fputs($fp, base64_decode($attachments[$i]["filedata"]));
-		fclose($fp);
-	    }
-	}
-}
-
-$_REQUEST['parent_id'] = $focus->column_fields['parent_id'];
-$focus->save("Emails");
-
-//saving in vtiger_emaildetails vtiger_table
-$id_lists = $focus->column_fields['parent_id'].'@'.$fieldid;
-$all_to_ids = $email->from;
-$query = 'insert into vtiger_emaildetails values ('.$focus->id.',"","'.$all_to_ids.'","","","","'.$id_lists.'","WEBMAIL")';
-$adb->query($query);
-
-$return_id = $_REQUEST["mailid"];
-$return_module='Webmails';
-$return_action='ListView';
-
-
-if($_POST["ajax"] != "true")
-	header("Location: index.php?action=$return_action&module=$return_module&record=$return_id"); 
-
-return;
-?>
+<?php
+/*********************************************************************************
+ ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+  * ("License"); You may not use this file except in compliance with the License
+  * The Initial Developer of the Original Code is FOSS Labs.
+  * Portions created by FOSS Labs are Copyright (C) FOSS Labs.
+  * Portions created by vtiger are Copyright (C) vtiger.
+  * All Rights Reserved.
+  *
+  ********************************************************************************/
+
+require_once('modules/Emails/Emails.php');
+require_once('modules/Webmails/Webmails.php');
+require_once('include/logging.php');
+require_once('include/database/PearDatabase.php');
+require_once('include/utils/UserInfoUtil.php');
+require_once('include/utils/CommonUtils.php');
+require_once('modules/Webmails/MailParse.php');
+require_once('modules/Webmails/MailBox.php');
+global $current_user;
+
+$local_log =& LoggerManager::getLogger('index');
+$focus = new Emails();
+
+$to_address = explode(";",$_REQUEST['to_list']);
+$cc_address = explode(";",$_REQUEST['cc_list']);
+$bcc_address = explode(";",$_REQUEST['bcc_list']);
+
+$start_message=$_REQUEST["start_message"];
+if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
+
+$MailBox = new MailBox($mailbox);
+$email = new Webmails($MailBox->mbox, $_REQUEST["mailid"]);
+$subject = $email->subject;
+$date = $email->date;
+$array_tab = Array();
+$email->loadMail($array_tab);
+$msgData = $email->body;
+
+$focus->column_fields['subject']=$subject;
+$focus->column_fields["activitytype"]="Emails";
+
+$ddate = date("Y-m-d");
+$dtime = date("h:m");
+$focus->column_fields["assigned_user_id"]=$current_user->id;
+$focus->column_fields["date_start"]=$ddate;
+$focus->column_fields["time_start"]=$dtime;
+
+//$tmpBody = preg_replace(array('/<br(.*?)>/i',"/&gt;/i","/&lt;/i","/&nbsp;/i","/&amp/i","/&copy;/i","/<style(.*?)>(.*?)<\/style>/i","/\{(.*?)\}/i","/BODY/i"),array("\r",">","<"," ","&","(c)","","",""),$msgData);
+//$focus->column_fields["description"]=strip_tags($tmpBody);
+$focus->column_fields["description"]=$msgData;
+
+
+//to save the email details in vtiger_emaildetails vtiger_tables
+$fieldid = $adb->query_result($adb->query('select fieldid from vtiger_field where tablename="contactdetails" and fieldname="email" and columnname="email"'),0,'fieldid');
+
+if(count($email->relationship) != 0) {
+	$focus->column_fields['parent_id']=$email->relationship["id"].'@'.$fieldid.'|';
+
+	if($email->relationship["type"] == "Contacts")
+		add_attachment_to_contact($email->relationship["id"],$email);
+}else {
+	//if relationship is not available create a contact and relate the email to the contact
+	require_once('modules/Contacts/Contacts.php');
+	$contact_focus = new Contacts();	
+	$contact_focus->column_fields['lastname'] =$email->fromname; 
+	$contact_focus->column_fields['email'] = $email->from;
+	$contact_focus->save("Contacts");
+	$focus->column_fields['parent_id']=$contact_focus->id.'@'.$fieldid.'|';
+
+	add_attachment_to_contact($contact_focus->id,$email);
+}
+
+function add_attachment_to_contact($cid,$email) {
+	// add vtiger_attachments to contact
+	global $adb,$current_user;
+	for($j=0;$j<2;$j++) {
+	    if($j==0)
+	    	$attachments=$email->downloadAttachments();
+	    else
+	    	$attachments=$email->downloadInlineAttachments();
+
+	    $upload_filepath = decideFilePath();
+	    for($i=0,$num_files=count($attachments);$i<$num_files;$i++) {
+		$current_id = $adb->getUniqueID("vtiger_crmentity");
+		$date_var = $adb->formatDate(date('YmdHis'));	
+
+		$filename = ereg_replace("[ ()-]+", "_",$attachments[$i]["filename"]);
+        	$filetype= substr($filename,strstr($filename,"."),strlen($filename));
+		$filesize = $attachments[$i]["filesize"];
+
+                $query = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
+                $query .= $current_id."','".$current_user->id."','".$current_user->id."','Contacts Attachment','Uploaded from webmail during qualification',".$date_var.")";
+                $result = $adb->query($query);
+
+                $sql = "insert into vtiger_attachments values(";
+                $sql .= $current_id.",'".$filename."','Uploaded ".$filename." from webmail','".$filetype."','".$upload_filepath."')";
+		echo $query;
+                $result = $adb->query($sql);
+
+                $sql1 = "insert into vtiger_seattachmentsrel values('";
+                $sql1 .= $cid."','".$current_id."')";
+                $result = $adb->query($sql1);
+
+		$fp = fopen($upload_filepath.'/'.$filename, "w") or die("Can't open file");
+		fputs($fp, base64_decode($attachments[$i]["filedata"]));
+		fclose($fp);
+	    }
+	}
+}
+
+$_REQUEST['parent_id'] = $focus->column_fields['parent_id'];
+$focus->save("Emails");
+
+//saving in vtiger_emaildetails vtiger_table
+$id_lists = $focus->column_fields['parent_id'].'@'.$fieldid;
+$all_to_ids = $email->from;
+$query = 'insert into vtiger_emaildetails values ('.$focus->id.',"","'.$all_to_ids.'","","","","'.$id_lists.'","WEBMAIL")';
+$adb->query($query);
+
+$return_id = $_REQUEST["mailid"];
+$return_module='Webmails';
+$return_action='ListView';
+
+
+if($_POST["ajax"] != "true")
+	header("Location: index.php?action=$return_action&module=$return_module&record=$return_id"); 
+
+return;
+?>

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/WebmailsAjax.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/WebmailsAjax.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/WebmailsAjax.php Mon Apr 16 12:27:44 2007
@@ -13,7 +13,7 @@
 require_once('include/utils/utils.php');
 require_once('include/utils/UserInfoUtil.php');
 require_once('modules/Webmails/MailBox.php');
-require_once('modules/Webmails/Webmail.php');
+require_once('modules/Webmails/Webmails.php');
 
 global $adb,$current_user;
 
@@ -42,6 +42,17 @@
     $command = $_REQUEST["command"];
     if($command == "expunge") {
     	$MailBox = new MailBox($mailbox);
+	/*
+	$search = imap_search($MailBox->mbox,'DELETED');
+	$data = imap_fetch_overview($MailBox->mbox,implode(',',$search));
+	for($i=0;$i<$num;$i++)
+	{
+        	if($data[$i]->deleted != 0)
+		{
+			imap_delete($MailBox->mbox,$data[$i]->message_id);
+		}
+	}
+	 */
     	imap_expunge($MailBox->mbox);
 	imap_close($MailBox->mbox);
 	flush();
@@ -50,8 +61,8 @@
     if($command == "delete_msg") {
 	$adb->println("DELETE SINGLE WEBMAIL MESSAGE $mailid");
     	$MailBox = new MailBox($mailbox);
-	$email = new Webmail($MailBox->mbox,$mailid);
-       	$email->delete();
+        imap_mail_move($MailBox->mbox,$mailid,"Deleted");
+	$email = new Webmails($MailBox->mbox,$mailid);
 	imap_close($MailBox->mbox);
 	echo $mailid;
 	flush();
@@ -61,9 +72,10 @@
     	$MailBox = new MailBox($mailbox);
 	$tlist = explode(":",$mailid);
 	foreach($tlist as $id) {
+	        imap_mail_move($MailBox->mbox,$id,"Trash");
 		$adb->println("DELETE MULTI MESSAGE $id");
-		$email = new Webmail($MailBox->mbox,$id);
-       	 	$email->delete();
+		$email = new Webmails($MailBox->mbox,$id);
+		$email->delete();
 	}
 	imap_close($MailBox->mbox);
 	echo $mailid;
@@ -72,7 +84,7 @@
     } 
     if($command == "undelete_msg") {
     	$MailBox = new MailBox($mailbox);
-	$email = new Webmail($MailBox->mbox,$mailid);
+	$email = new Webmails($MailBox->mbox,$mailid);
         $email->unDeleteMsg();
 	imap_close($MailBox->mbox);
 	echo $mailid;
@@ -81,17 +93,19 @@
     }
     if($command == "set_flag") {
     	$MailBox = new MailBox($mailbox);
-	$email = new Webmail($MailBox->mbox,$mailid);
+	$email = new Webmails($MailBox->mbox,$mailid);
         $email->setFlag();
 	imap_close($MailBox->mbox);
+	echo $mailid;
 	flush();
 	exit();
     }
     if($command == "clear_flag") {
     	$MailBox = new MailBox($mailbox);
-	$email = new Webmail($MailBox->mbox,$mailid);
+	$email = new Webmails($MailBox->mbox,$mailid);
         $email->delFlag();
 	imap_close($MailBox->mbox);
+	echo $mailid;
 	flush();
 	exit();
     }

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/body.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/body.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/body.php Mon Apr 16 12:27:44 2007
@@ -12,15 +12,24 @@
 global $current_user;
 require_once('include/utils/utils.php');
 require_once('include/utils/UserInfoUtil.php');
-require_once('modules/Webmails/Webmail.php');
+require_once('modules/Webmails/Webmails.php');
 require_once('modules/Webmails/MailBox.php');
+global $mod_strings;
 
 if(!isset($_SESSION["authenticated_user_id"]) || $_SESSION["authenticated_user_id"] != $current_user->id) {echo "ajax failed";flush();exit();}
 $mailid=$_REQUEST["mailid"];
-if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
+if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "")
+{
+	$mailbox=$_REQUEST["mailbox"];
+}
+else
+{
+	$mailbox="INBOX";
+}
 $MailBox = new MailBox($mailbox);
-$email = new Webmail($MailBox->mbox,$mailid);
-
+$mail = $MailBox->mbox;
+$email = new Webmails($MailBox->mbox,$mailid);
+$status=imap_setflag_full($MailBox->mbox,$mailid,"\\Seen");
 ?>
 <script type="text/javascript">
 function show_inline(num) {
@@ -31,40 +40,78 @@
 		el.style.display='block';
 }
 </script>
-<?
-	$email->loadMail();
-	echo $email->body;
-	echo "<br><br>";
-	if(is_array($email->inline)) {
-		$inline = $email->downloadInlineAttachments();
-		$num=sizeof($inline);
-		echo "<p style='border-bottom:1px solid black;font-weight:bold'>Inline Attachments:</p>";
-		for($i=0;$i<$num;$i++) {
-				//var_dump($inline[$i]);
-				// PLAIN TEXT
-				if($inline[$i]["subtype"] == "RFC822") {
-					echo ($i+1).") <a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><blockquote id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;display:none'>";
-					echo nl2br($inline[$i]["filedata"]);
-					echo "</blockquote>";
-				} elseif($inline[$i]["subtype"] == "JPEG" || $inline[$i]["subtype"] == "GIF") {
-					echo ($i+1).") <a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><br><br><div id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;display:none;width:95%;overflow:auto'>";
-					global $root_directory;
-					$save_path=$root_directory.'/modules/Webmails/tmp';
-					if(!is_dir($save_path))
-       		 				mkdir($save_path);
-					$save_dir=$save_path."/cache";
-					if(!is_dir($save_dir))
-       		 				mkdir($save_dir);
-		
-        				$fp = fopen($save_dir.'/'.$inline[$i]["filename"], "w") or die("Can't open file");
-        				fputs($fp, base64_decode($inline[$i]["filedata"]));
-        				$filename = 'modules/Webmails/tmp/cache/'.$inline[$i]['filename'];
-					fclose($fp);
-					echo '<img src="'.$filename.'" border="0" >';
-					echo '</div> <br>';
-				} else 
-					echo ($i+1).") <a target='_BLANK' href='index.php?module=Webmails&action=dlAttachments&inline=true&num=".$i."&mailid=".$mailid."'>".$inline[$i]["filename"]."</a> <br>";
+<?php
+function view_part_detail($mail,$mailid,$part_no, &$transfer, &$msg_charset, &$charset)
+{
+	$text = imap_fetchbody($mail,$mailid,$part_no);
+	if ($transfer == 'BASE64')
+		$str = nl2br(imap_base64($text));
+	elseif($transfer == 'QUOTED-PRINTABLE')
+		$str = nl2br(quoted_printable_decode($text));
+	else
+		$str = nl2br($text);
+	return ($str);
+}
+$attach_tab=array();
+$email->loadMail($attach_tab);
+$content['body'] = '<span id="webmail_body">'.$email->body.'</span>';
+$content['attachtab'] = $email->attachtab;
+//Need to put this along with the subject block
+echo $email->att;
+echo $content['body'];
+
+//test added by Richie
+if (!isset($_REQUEST['display_images']) || $_REQUEST['display_images'] != 1)
+{
+	$content['body'] = eregi_replace('src="[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]"', 'src="none"', $content['body']);
+	$content['body'] = eregi_replace('src=[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]', 'src="none"', $content['body']);
+}
+
+//Display embedded HTML images
+$tmp_attach_tab=$content['attachtab'];
+$i = 0;
+$conf->display_img_attach = true;
+$conf->display_text_attach = true;
+
+while ($tmp = array_pop($tmp_attach_tab)) 
+{
+	if ($conf->display_img_attach && (eregi('image', $tmp['mime']) && ($tmp['number'] != '')))
+	{
+		$exploded = explode('/', $tmp['mime']);
+		$img_type = array_pop($exploded);
+		if (eregi('JPEG', $img_type) || eregi('JPG', $img_type) || eregi('GIF', $img_type) || eregi ('PNG', $img_type))
+		{
+			$new_img_src = 'src="get_img.php?mail=' . $mailid.'&num=' . $tmp['number'] . '&mime=' . $img_type . '&transfer=' . $tmp['transfer'] . '"';
+			$img_id = str_replace('<', '', $tmp['id']);
+			$img_id = str_replace('>', '', $img_id);
+			$content['body'] = str_replace('src="cid:'.$img_id.'"', $new_img_src, $content['body']);
+			$content['body'] = str_replace('src=cid:'.$img_id, $new_img_src, $content['body']);
 		}
-	}
+		}
+}
+while ($tmp = array_pop($content['attachtab']))
+{
+	if ((!eregi('ATTACHMENT', $tmp['disposition'])) && $conf->display_text_attach && (eregi('text/plain', $tmp['mime'])))
+		echo '<hr />'.view_part_detail($mail, $mailid, $tmp['number'], $tmp['transfer'], $tmp['charset'], $charset);
+	if ($conf->display_img_attach && (eregi('image', $tmp['mime']) && ($tmp['number'] != '')))
+	{
+		$exploded = explode('/', $tmp['mime']);
+		$img_type = array_pop($exploded);
+		if (eregi('JPEG', $img_type) || eregi('JPG', $img_type) || eregi('GIF', $img_type) || eregi ('PNG', $img_type))
+                        {
+			echo '<hr />';
+			echo '<center>';
+			echo '<img src="index.php?module=Webmails&action=get_img&mail=' . $mailid.'&num=' . $tmp['number'] . '&mime=' . $img_type . '&transfer=' . $tmp['transfer'] . '" />';
+			echo '</center>';
+	}                
+}                    
+}
+
+
+//test ended by Richie
+
 imap_close($MailBox->mbox);
+
+
 ?>
+<script>parent.document.getElementById('webmail_attachment').innerHTML=document.getElementById('webmail_cont').innerHTML</script>

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/dlAttachments.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/dlAttachments.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/dlAttachments.php Mon Apr 16 12:27:44 2007
@@ -1,4 +1,4 @@
-<?php
+<?php
 /*********************************************************************************
  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   * ("License"); You may not use this file except in compliance with the License
@@ -10,10 +10,10 @@
   ********************************************************************************/
 
 
-include('config.php');
-require_once('include/utils/UserInfoUtil.php');
-require_once('include/utils/utils.php');
-require_once('modules/Webmails/Webmail.php');
+include('config.php');
+require_once('include/utils/UserInfoUtil.php');
+require_once('include/utils/utils.php');
+require_once('modules/Webmails/Webmails.php');
 require_once('modules/Webmails/MailBox.php');
 
 global $MailBox;
@@ -22,56 +22,68 @@
 $mailid=$_REQUEST["mailid"];
 $num=$_REQUEST["num"];
 
-$email = new Webmail($MailBox->mbox,$mailid);
+$email = new Webmails($MailBox->mbox,$mailid);
 $attachments=$email->downloadAttachments();
 $inline=$email->downloadInlineAttachments();
 
-if($num == "" || !isset($num) && count($attachments) >0 ) {
-	echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($attachments)." attachment(s) to choose from:</td></tr>";
+if($num == "" || !isset($num) && count($attachments) >0 )
+{
+	echo "<table class='small' width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td width='10%'>&nbsp;</td><td width='90%'>There are ".count($attachments)." attachment(s) to choose from:</td></tr>";
 
-	for($i=0;$i<count($attachments);$i++) {
-		echo "<tr><td align='center'>".count($attachments).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&mailbox=".$_REQUEST["mailbox"]."'>".$attachments[$i]["filename"]."</td></tr>";
+	for($i=0;$i<count($attachments);$i++)
+	{
+		echo "<tr><td width='10%'>&nbsp;</td><td width='90%'>&nbsp;&nbsp;&nbsp;".($i+1).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&mailbox=".$_REQUEST["mailbox"]."'>".$attachments[$i]["filename"]."</td></tr>";
 	}
 
 	echo "</table><br>";
-	echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($inline)." <b>inline</b> attachment(s) to choose from:</td></tr>";
+	echo "<table class='small' width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td width='10%'>&nbsp;</td><td width='90%'>There are ".count($inline)." <b>inline</b> attachment(s) to choose from:</td></tr>";
 
-	for($i=0;$i<count($inline);$i++) {
-		echo "<tr><td align='center'>".count($inline).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&inline=true&mailbox=".$_REQUEST["mailbox"]."'>".$inline[$i]["filename"]."</td></tr>";
+	for($i=0;$i<count($inline);$i++)
+	{
+		echo "<tr><td width='10%'>&nbsp;</td><td width='90%'>&nbsp;&nbsp;&nbsp;".($i+1).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&inline=true&mailbox=".$_REQUEST["mailbox"]."'>".$inline[$i]["filename"]."</td></tr>";
 	}
 
 	echo "</table><br><br>";
 
-} elseif (count(attachments) == 0 && count($inline) == 0) {
+}
+elseif (count($attachments) == 0 && count($inline) == 0)
+{
 	echo "<center><strong>No vtiger_attachments for this email</strong></center><br><br>";
-} else {
+}
+else
+{
 
-global $root_directory;
-$save_path=$root_directory.'/modules/Webmails/tmp';
-if(!is_dir($save_path))
-	mkdir($save_path);
+	global $root_directory;
+	$save_path=$root_directory.'/modules/Webmails/tmp';
+	if(!is_dir($save_path))
+		mkdir($save_path);
 
-$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
-if(!is_dir($user_dir))
-	mkdir($user_dir);
+	$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
+	if(!is_dir($user_dir))
+		mkdir($user_dir);
 
-if(isset($_REQUEST["inline"]) && $_REQUEST["inline"] == "true") {
-	$fp = fopen($user_dir.'/'.$inline[$num]["filename"], "w") or die("Can't open file");
-	fputs($fp, base64_decode($inline[$num]["filedata"]));
-	$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$inline[$num]['filename'];
-} else {
-	$fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
-	fputs($fp, base64_decode($attachments[$num]["filedata"]));
-	$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
+	if(isset($_REQUEST["inline"]) && $_REQUEST["inline"] == "true")
+	{
+		$fp = fopen($user_dir.'/'.$inline[$num]["filename"], "w") or die("Can't open file");
+		fputs($fp, base64_decode($inline[$num]["filedata"]));
+		$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$inline[$num]['filename'];
+	}
+	else
+	{
+		$fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
+		fputs($fp, base64_decode($attachments[$num]["filedata"]));
+		$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
+	}
+	fclose($fp);
+	imap_close($MailBox->mbox);
+
+	?>
+	<center><h2>File Download</h2></center>
+	<META HTTP-EQUIV="Refresh"
+	CONTENT="0; URL=<?php echo $filename;?>"
+	]"
+	<?php
 }
-fclose($fp);
-imap_close($MailBox->mbox);
+
 
 ?>
-<center><h2>File Download</h2></center>
-<META HTTP-EQUIV="Refresh"
-CONTENT="0; URL=<?php echo $filename;?>"
-]"
-<?
-}
-?>

Modified: vtigercrm/branches/5.1_jens/modules/Webmails/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/Webmails/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/Webmails/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -1,140 +1,164 @@
-<?php
-/*********************************************************************************
- * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
- * ("License"); You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
- * Software distributed under the License is distributed on an  "AS IS"  basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
- * the specific language governing rights and limitations under the License.
- * The Original Code is:  SugarCRM Open Source
- * The Initial Developer of the Original Code is SugarCRM, Inc.
- * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- * All Rights Reserved.
- * Contributor(s): ______________________________________.
- ********************************************************************************/
-/*********************************************************************************
- * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Emails/language/en_us.lang.php,v 1.17 2005/03/28 06:31:38 rank Exp $
- * Description:  Defines the English language pack for the Account module.
- ********************************************************************************/
-
-$mod_strings = Array(
-'LBL_MODULE_NAME'=>'Emails',
-'LBL_MODULE_TITLE'=>'Emails: Home',
-'LBL_SEARCH_FORM_TITLE'=>'Email Search',
-'LBL_LIST_FORM_TITLE'=>'Email List',
-'LBL_NEW_FORM_TITLE'=>'Track Email',
-
-'LBL_LIST_SUBJECT'=>'Subject',
-'LBL_LIST_CONTACT'=>'Contact',
-'LBL_LIST_RELATED_TO'=>'Related to',
-'LBL_LIST_DATE'=>'Date Sent',
-'LBL_LIST_TIME'=>'Time Sent',
+<?php
+/*********************************************************************************
+ * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
+ * ("License"); You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
+ * Software distributed under the License is distributed on an  "AS IS"  basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ * The Original Code is:  SugarCRM Open Source
+ * The Initial Developer of the Original Code is SugarCRM, Inc.
+ * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ********************************************************************************/
+/*********************************************************************************
+ * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Emails/language/en_us.lang.php,v 1.17 2005/03/28 06:31:38 rank Exp $
+ * Description:  Defines the English language pack for the Account module.
+ ********************************************************************************/
+
+$mod_strings = Array(
+'LBL_MODULE_NAME'=>'Email',
+'LBL_MODULE_TITLE'=>'Email: Home',
+'LBL_SEARCH_FORM_TITLE'=>'Email Search',
+'LBL_LIST_FORM_TITLE'=>'Email List',
+'LBL_NEW_FORM_TITLE'=>'Track Email',
+
+'LBL_LIST_SUBJECT'=>'Subject',
+'LBL_LIST_CONTACT'=>'Contact',
+'LBL_LIST_RELATED_TO'=>'Related to',
+'LBL_LIST_DATE'=>'Date Sent',
+'LBL_LIST_TIME'=>'Time Sent',
 'LBL_MOVE_TO'=>'Move To',
 'LBL_DELETE'=>'Delete',
-
-'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
-'LBL_DATE_SENT'=>'Date Sent:',
-'LBL_SUBJECT'=>'Subject :',
-'LBL_DATE_AND_TIME'=>'Date & Time Sent:',
-'LBL_DATE'=>'Date :',
-'LBL_TIME'=>'Time Sent:',
-'LBL_BODY'=>'Body:',
-'LBL_CONTACT_NAME'=>' Contact Name: ',
-'LBL_EMAIL'=>'Email:',  
-'LBL_COLON'=>':',
-'LBL_TO'=>'To :',
-'LBL_CHK_MAIL'=>'Check Mail',
-'LBL_COMPOSE'=>'Compose',
-'LBL_SETTINGS'=>'Settings',
-'LBL_EMAIL_FOLDERS'=>'Email Folders',
-'LBL_INBOX'=>'Inbox',
-'LBL_SENT_MAILS'=>'Sent Mails',
-'LBL_TRASH'=>'Trash',
-'LBL_JUNK_MAILS'=>'Junk Mails',
-'LBL_TO_LEADS'=>'To Leads',
-'LBL_TO_CONTACTS'=>'To Contacts',
-'LBL_TO_ACCOUNTS'=>'To Accounts',
-'LBL_MY_MAILS'=>'My Mails',
-'LBL_QUAL_CONTACT'=>'Qualified Mails (As Contacts)',
-'LBL_MAILS'=>'Mails',
-'LBL_QUALIFY_BUTTON'=>'Qualify',
-'LBL_REPLY_BUTTON'=>'Reply',
-'LBL_FORWARD_BUTTON'=>'Forward',
-'LBL_DOWNLOAD_ATTCH_BUTTON'=>'Download Attachments',
-'LBL_FROM'=>'From :',
-'LBL_CC'=>'CC :',
-'LBL_REPLY_TO_SENDER'=>'Reply to Sender',
-'LBL_REPLY_ALL'=>'Reply All',
-'LBL_SHOW_HIDDEN'=>'Show Hidden',
-'LBL_EXPUNGE_MAILBOX'=>'Expunge Mailbox',
-
-'NTC_REMOVE_INVITEE'=>'Are you sure you want to remove this recipient from the email?',
-'LBL_INVITEE'=>'Recipients',
-
-// Added Fields
-// Contacts-SubPanelViewContactsAndUsers.php
-'LBL_BULK_MAILS'=>'Bulk Mails',
-'LBL_ATTACHMENT'=>'Attachment',
-'LBL_DESCRIPTION'=>'Description',
-'LBL_UPLOAD'=>'Upload',
-'LBL_FILE_NAME'=>'File Name',
-'LBL_SEND'=>'Send',
-
-'LBL_EMAIL_TEMPLATES'=>'Email Templates',
-'LBL_TEMPLATE_NAME'=>'Template Name',
-'LBL_DESCRIPTION'=>'Description',
-'LBL_EMAIL_TEMPLATES_LIST'=>'Email Templates  List',
-'LBL_EMAIL_INFORMATION'=>'Email Information',
-
-
-
-
-//for v4 release added
-'LBL_NEW_LEAD'=>'New Lead',
-'LBL_LEAD_TITLE'=>'Leads',
-
-'LBL_NEW_PRODUCT'=>'New Product',
-'LBL_PRODUCT_TITLE'=>'Products',
-'LBL_NEW_CONTACT'=>'New Contact',
-'LBL_CONTACT_TITLE'=>'Contacts',
-'LBL_NEW_ACCOUNT'=>'New Account',
-'LBL_ACCOUNT_TITLE'=>'Accounts',
-
-// Added vtiger_fields after vtiger4 - Beta
-'LBL_USER_TITLE'=>'Users',
-'LBL_NEW_USER'=>'New User',
-
-// Added for 4 GA
-'LBL_TOOL_FORM_TITLE'=>'Email Tools',
-//Added for 4GA
-'Date & Time Sent'=>'Date & Time Sent',
-'Sales Enity Module'=>'Sales Enity Module',
-'Activtiy Type'=>'Activtiy Type',
-'Related To'=>'Related To',
-'Assigned To'=>'Assigned To',
-'Subject'=>'Subject',
-'Attachment'=>'Attachment',
-'Description'=>'Description',
-'Time Start'=>'Time Start',
-'Created Time'=>'Created Time',
-'Modified Time'=>'Modified Time',
-
-'MESSAGE_CHECK_MAIL_SERVER_NAME'=>'Please Check the Mail Server Name...',
-'MESSAGE_CHECK_MAIL_ID'=>'Please Check the Email Id of "Assigned To" User...',
-'MESSAGE_MAIL_HAS_SENT_TO_USERS'=>'Mail has been sent to the following User(s) :',
-'MESSAGE_MAIL_HAS_SENT_TO_CONTACTS'=>'Mail has been sent to the following Contact(s) :',
-'MESSAGE_MAIL_ID_IS_INCORRECT'=>'Mail Id is incorrect. Please Check this Mail Id...',
-'MESSAGE_ADD_USER_OR_CONTACT'=>'Please Add any User(s) or Contact(s)...',
-'MESSAGE_MAIL_SENT_SUCCESSFULLY'=>' Mail(s) sent successfully!',
-
-// Added for web mail post 4.0.1 release
-'LBL_FETCH_WEBMAIL'=>'Fetch Web Mail',
-//Added for 4.2 Release -- CustomView
-'LBL_ALL'=>'All',
-'MESSAGE_CONTACT_NOT_WANT_MAIL'=>'This Contact does not want to receive mails.',
-'LBL_WEBMAILS_TITLE'=>'WebMails',
-'LBL_EMAILS_TITLE'=>'Emails',
-'LBL_MAIL_CONNECT_ERROR_INFO'=>'Error connecting mail server!<br> Check in My Accounts->List Mail Server -> List Mail Account',
-
-);
-?>
+
+'ERR_DELETE_RECORD'=>"A record number must be specified to delete the vtiger_account.",
+'LBL_DATE_SENT'=>'Date Sent:',
+'LBL_SUBJECT'=>'Subject :',
+'LBL_DATE_AND_TIME'=>'Date & Time Sent:',
+'LBL_DATE'=>'Date :',
+'LBL_TIME'=>'Time Sent:',
+'LBL_BODY'=>'Body:',
+'LBL_CONTACT_NAME'=>' Contact Name: ',
+'LBL_EMAIL'=>'Email:',  
+'LBL_COLON'=>':',
+'LBL_TO'=>'To :',
+'LBL_CHK_MAIL'=>'Check Mail',
+'LBL_COMPOSE'=>'Compose',
+'LBL_SETTINGS'=>'Incmg. MailServer Settings',
+'LBL_EMAIL_FOLDERS'=>'Email Folders',
+'LBL_INBOX'=>'Inbox',
+'LBL_SENT_MAILS'=>'Sent Mails',
+'LBL_TRASH'=>'Trash',
+'LBL_JUNK_MAILS'=>'Junk Mails',
+'LBL_TO_LEADS'=>'To Leads',
+'LBL_TO_CONTACTS'=>'To Contacts',
+'LBL_TO_ACCOUNTS'=>'To Accounts',
+'LBL_MY_MAILS'=>'My Mails',
+'LBL_QUAL_CONTACT'=>'Qualified Mails (As Contacts)',
+'LBL_MAILS'=>'Mails',
+'LBL_QUALIFY_BUTTON'=>'Qualify',
+'LBL_REPLY_BUTTON'=>'Reply',
+'LBL_FORWARD_BUTTON'=>'Forward',
+'LBL_DOWNLOAD_ATTCH_BUTTON'=>'Download Attachments',
+'LBL_FROM'=>'From :',
+'LBL_CC'=>'cc :',
+'LBL_REPLY_TO_SENDER'=>'Reply to Sender',
+'LBL_REPLY_ALL'=>'Reply All',
+'LBL_SHOW_HIDDEN'=>'Show Hidden Mails',
+'LBL_EXPUNGE_MAILBOX'=>'Trim Mailbox',
+
+'NTC_REMOVE_INVITEE'=>'Are you sure you want to remove this recipient from the email?',
+'LBL_INVITEE'=>'Recipients',
+
+// Added Fields
+// Contacts-SubPanelViewContactsAndUsers.php
+'LBL_BULK_MAILS'=>'Bulk Mails',
+'LBL_ATTACHMENT'=>'Attachment',
+'LBL_UPLOAD'=>'Upload',
+'LBL_FILE_NAME'=>'File Name',
+'LBL_SEND'=>'Send',
+
+'LBL_EMAIL_TEMPLATES'=>'Email Templates',
+'LBL_TEMPLATE_NAME'=>'Template Name',
+'LBL_DESCRIPTION'=>'Description',
+'LBL_EMAIL_TEMPLATES_LIST'=>'Email Templates  List',
+'LBL_EMAIL_INFORMATION'=>'Email Information',
+
+
+
+
+//for v4 release added
+'LBL_NEW_LEAD'=>'New Lead',
+'LBL_LEAD_TITLE'=>'Leads',
+
+'LBL_NEW_PRODUCT'=>'New Product',
+'LBL_PRODUCT_TITLE'=>'Products',
+'LBL_NEW_CONTACT'=>'New Contact',
+'LBL_CONTACT_TITLE'=>'Contacts',
+'LBL_NEW_ACCOUNT'=>'New Account',
+'LBL_ACCOUNT_TITLE'=>'Accounts',
+
+// Added vtiger_fields after vtiger4 - Beta
+'LBL_USER_TITLE'=>'Users',
+'LBL_NEW_USER'=>'New User',
+
+// Added for 4 GA
+'LBL_TOOL_FORM_TITLE'=>'Email Tools',
+//Added for 4GA
+'Date & Time Sent'=>'Date & Time Sent',
+'Sales Enity Module'=>'Sales Enity Module',
+'Activtiy Type'=>'Activtiy Type',
+'Related To'=>'Related To',
+'Assigned To'=>'Assigned To',
+'Subject'=>'Subject',
+'Attachment'=>'Attachment',
+'Description'=>'Description',
+'Time Start'=>'Time Start',
+'Created Time'=>'Created Time',
+'Modified Time'=>'Modified Time',
+
+'MESSAGE_CHECK_MAIL_SERVER_NAME'=>'Please Check the Mail Server Name...',
+'MESSAGE_CHECK_MAIL_ID'=>'Please Check the Email Id of "Assigned To" User...',
+'MESSAGE_MAIL_HAS_SENT_TO_USERS'=>'Mail has been sent to the following User(s) :',
+'MESSAGE_MAIL_HAS_SENT_TO_CONTACTS'=>'Mail has been sent to the following Contact(s) :',
+'MESSAGE_MAIL_ID_IS_INCORRECT'=>'Mail Id is incorrect. Please Check this Mail Id...',
+'MESSAGE_ADD_USER_OR_CONTACT'=>'Please Add any User(s) or Contact(s)...',
+'MESSAGE_MAIL_SENT_SUCCESSFULLY'=>' Mail(s) sent successfully!',
+
+// Added for web mail post 4.0.1 release
+'LBL_FETCH_WEBMAIL'=>'Fetch Web Mail',
+//Added for 4.2 Release -- CustomView
+'LBL_ALL'=>'All',
+'MESSAGE_CONTACT_NOT_WANT_MAIL'=>'This Contact does not want to receive mails.',
+'LBL_WEBMAILS_TITLE'=>'WebMails',
+'LBL_EMAILS_TITLE'=>'Email',
+'LBL_MAIL_CONNECT_ERROR_INFO'=>'Error connecting mail server!<br> Check in My Accounts->List Mail Server -> List Mail Account',
+// Added for 5.0.3 release
+'LBL_MAIL_CONNECT_ERROR'=>'Could not connect to the mail server. Please check the mail server details',
+'IN_REPLY_TO_THE_MESSAGE' => 'In reply to the message sent by ',
+'LBL_CLICK_HERE' => 'Click Here ',
+'LBL_GOTO_EMAILS_MODULE' => ' go to Email module',
+'LBL_NO_EMAILS'=>'No Email In This Folder',
+'LBL_MOVE_TO'=>'Move To...',
+'LBL_DEL'=>'Del ',
+'LABEL_FROM'=>'From',
+'LBL_INFO'=>'Info',
+'LABEL_DATE'=>'Date',
+'LBL_NO_IFRAMES_SUPPORTED'=>'No Iframes supported',
+'LBL_EMAIL_ATTACHMENTS'=>'Email Attachments:',
+'LBL_ALLMAILS'=>'Email',
+'LBL_TO_USERS'=>'To Users',
+'LBL_TO_GROUPS'=>'To Groups',
+'SUBJECT' => 'Subject',
+'BODY' => 'Body',
+'TO' => 'To:',
+'CC' => 'CC:',
+'BCC' => 'BCC:',
+'FROM' => 'From:',
+'IN'=>'in',
+'ADD_FOLDER' => 'Add Folder[X]',
+//Added for 5.0.3
+'LBL_LOADING_IMAGE' => 'Loading Image',
+);
+?>

Modified: vtigercrm/branches/5.1_jens/modules/uploads/add2db.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/uploads/add2db.php (original)
+++ vtigercrm/branches/5.1_jens/modules/uploads/add2db.php Mon Apr 16 12:27:44 2007
@@ -18,8 +18,10 @@
 $vtigerpath = str_replace("/index.php?module=uploads&action=add2db", "", $vtigerpath);
 
 $crmid = $_REQUEST['return_id'];
-$log->debug("DGDEBUG In add2db.php");
+$log->debug("DEBUG In add2db.php");
 
+	//fix for space in file name.
+	$_FILES['filename']['name'] = preg_replace('/\s+/', '_', $_FILES['filename']['name']);
 	// Arbitrary File Upload Vulnerability fix - Philip
 	$binFile = $_FILES['filename']['name'];
 
@@ -51,37 +53,35 @@
 			$desc = $_REQUEST['txtDescription'];
 			$description = addslashes($desc);
 			$date_var = $adb->formatDate(date('YmdHis'));	
-
-			$query = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
-			$query .= $current_id."','".$current_user->id."','".$current_user->id."','".$_REQUEST['return_module'].' Attachment'."','".$description."',".$date_var.")";	
+			$current_date = getdate();
+			$current_date = $adb->formatDate(date('YmdHis'));	
+			$query = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('";
+			$query .= $current_id."','".$current_user->id."','".$current_user->id."','".$_REQUEST['return_module'].' Attachment'."','".$description."',".$date_var.",".$current_date.")";	
 			$result = $adb->query($query);
 
 			# Added by DG 26 Oct 2005
 			# Attachments added to contacts are also added to their accounts
-			$log->debug("DGDEBUG Here's the test:");
-			$log->debug("DGDEBUG return_module: ".$_REQUEST['return_module']);
+			$log->debug("DEBUG return_module: ".$_REQUEST['return_module']);
 			if ($_REQUEST['return_module'] == 'Contacts')
 			{
-				$log->debug("DGDEBUG Passed the test.");
 				$crmid = $_REQUEST['return_id'];
 				$query = 'select accountid from vtiger_contactdetails where contactid='.$crmid;
-				$log->debug("DGDEBUG Running query: ".$query);
 				$result = $adb->query($query);
 				if($adb->num_rows($result) != 0)
 				{
-					$log->debug("DGDEBUG Returned a row");
+					$log->debug("DEBUG Returned a row");
 					$associated_account = $adb->query_result($result,0,"accountid");
 					# Now make sure that we haven't already got this attachment associated to this account
 					# Hmmm... if this works, should we NOT upload the attachment again, and just set the relation for the contact too?
-					$log->debug("DGDEBUG Associated Account: ".$associated_account);
+					$log->debug("DEBUG Associated Account: ".$associated_account);
 					$query = "select name,attachmentsize from vtiger_attachments where name= '".$filename."'";
 					$result = $adb->query($query);
 					if($adb->num_rows($result) != 0)
 					{
-						$log->debug("DGDEBUG Matched a row");
+						$log->debug("DEBUG Matched a row");
 						# Whoops! We matched the name. Is it the same size?
 						$dg_size = $adb->query_result($result,0,"attachmentsize");
-						$log->debug("DGDEBUG: These should be the same size: ".$dg_size." ".$filesize);
+						$log->debug("DEBUG: These should be the same size: ".$dg_size." ".$filesize);
 						if ($dg_size == $filesize)
 						{
 							# Yup, it is probably the same file
@@ -97,7 +97,6 @@
 			# DG 19 June 2006
 			# Strip out single quotes from filenames
 			$filename = preg_replace('/\'/', '', $filename);
-
 			$sql = "insert into vtiger_attachments values(";
 			$sql .= $current_id.",'".$filename."','".$description."','".$filetype."','".$upload_filepath."')";
 			$result = $adb->query($sql);
@@ -111,10 +110,9 @@
 			# Attachments added to contacts are also added to their accounts
 			if ($associated_account)
 			{
-				$log->debug("DGDEBUG: inserting into vtiger_seattachmentsrel from add2db 2");
+				$log->debug("DEBUG: inserting into vtiger_seattachmentsrel from add2db 2");
 				$sql1 = "insert into vtiger_seattachmentsrel values('";
 				$sql1 .= $associated_account."','".$current_id."')";
-				$log->debug("DGDEBUG: Here's the query: ".$sql1);
 				$result = $adb->query($sql1);
 			}
 
@@ -126,33 +124,36 @@
 				<li><font color='red'>Invalid file OR</font>
 				<li><font color='red'>File has no data</font>
 				</ul></B></font> <br>" ;
-			echo $errormessage;
-			include "upload.php";
+			header("Location: index.php?module=uploads&action=uploadsAjax&msg=true&file=upload&errormessage=".$errormessage);
 		}			
 	} 
 	else 
 	{
 		$errorCode =  $_FILES['binFile']['error'];
+		$errormessage = "";
 
 		if($errorCode == 4)
 		{
 			$errormessage = "<B><font color='red'>Kindly give a valid file for upload!</font></B> <br>" ;
-			echo $errormessage;
-			include "upload.php";
 		}
 		else if($errorCode == 2)
 		{
-			$errormessage = "<B><font color='red'>Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than 1000000 bytes</font></B> <br>";
-			echo $errormessage;
-			include "upload.php";
-			//echo $errorCode;
+			$errormessage = "<B><font color='red'>Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than $upload_maxsize bytes</font></B> <br>";
+		}
+		else if($errorCode == 6)
+		{
+			$errormessage = "<B>Please configure <font color='red'>upload_tmp_dir</font> variable in php.ini file.</B> <br>" ;
 		}
 		else if($errorCode == 3 || $errorcode == '')
 		{
-			echo "<b><font color='red'>Problems in file upload. Please try again!</font></b><br>";
-			include "upload.php";
+			$errormessage = "<b><font color='red'>Problems in file upload. Please try again!</font></b><br>";
 		}
 
+		if($errormessage != '')
+		{
+			echo $errormessage;
+			include("upload.php");
+		}
 	}
 
 ?>

Modified: vtigercrm/branches/5.1_jens/modules/uploads/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/uploads/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.1_jens/modules/uploads/language/en_us.lang.php Mon Apr 16 12:27:44 2007
@@ -24,6 +24,8 @@
 
 //Added fields for uploads (attach files)
 'LBL_ATTACH_FILE'=>'Attach File',
+'LBL_ATTACH'=>'Attach',
+'LBL_CANCEL'=>'Cancel',
 'LBL_STEP_SELECT_FILE'=>'Step 1 : Select File',
 'LBL_BROWSE_FILES'=>'Click the browse button and select the file to be attached',
 'LBL_DESCRIPTION'=>'Step 2 : Write some description',

Modified: vtigercrm/branches/5.1_jens/modules/uploads/upload.php
==============================================================================
--- vtigercrm/branches/5.1_jens/modules/uploads/upload.php (original)
+++ vtigercrm/branches/5.1_jens/modules/uploads/upload.php Mon Apr 16 12:27:44 2007
@@ -8,13 +8,13 @@
 * 
  ********************************************************************************/
 -->
-<?
+<?php
 global $theme;
 $theme_path="themes/".$theme."/";
 ?>
 <HTML>
 <head>
-	<link type="text/css" href="<? echo $theme_path;?>style.css" rel="stylesheet">
+	<link type="text/css" href="<?php echo $theme_path;?>style.css" rel="stylesheet">
 </head>
 <BODY marginheight="0" marginwidth="0" leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0">
 <FORM METHOD="post" action="index.php?module=uploads&action=add2db&return_module=<?php echo $_REQUEST['return_module']?>" enctype="multipart/form-data" style="margin:0px;">
@@ -25,7 +25,7 @@
 
 ?>
 
-<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="1000000">
+<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="<?php echo $upload_maxsize; ?>">
 <INPUT TYPE="hidden" NAME="return_module" VALUE="<?php echo $ret_module ?>">
 <INPUT TYPE="hidden" NAME="return_action" VALUE="<?php echo $ret_action ?>">
 <INPUT TYPE="hidden" NAME="return_id" VALUE="<?php echo $ret_id ?>">
@@ -34,7 +34,7 @@
 <td>
 	<table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine>
 		<tr>
-			<td class="layerPopupHeading" align="left"><? echo $mod_strings["LBL_ATTACH_FILE"];?></td>
+			<td class="layerPopupHeading" align="left"><?php echo $mod_strings["LBL_ATTACH_FILE"];?></td>
 			<td width="70%" align="right">&nbsp;</td>
 		</tr>
 	</table>
@@ -44,8 +44,8 @@
 				<table border=0 celspacing=0 cellpadding=5 width=100% align=center bgcolor=white class="small">
 					<tr>
 						<td width="30%" colspan="2" align="left">
-							<b><? echo $mod_strings["LBL_STEP_SELECT_FILE"];?></b><br>
-							<? echo $mod_strings["LBL_BROWSE_FILES"]; ?>
+							<b><?php echo $mod_strings["LBL_STEP_SELECT_FILE"];?></b><br>
+							<?php echo $mod_strings["LBL_BROWSE_FILES"]; ?>
 						</td>
 					</tr>
 					<tr>
@@ -54,7 +54,7 @@
 					<tr><td colspan="2">&nbsp;</td></tr>
 					<tr>
 						<td width="30%" colspan="2" align="left">
-							<b> <? echo $mod_strings["LBL_DESCRIPTION"];?> </b><? echo $mod_strings["LBL_OPTIONAL"];?>
+							<b> <?php echo $mod_strings["LBL_DESCRIPTION"];?> </b><?php echo $mod_strings["LBL_OPTIONAL"];?>
 						</td>
 					</tr>
 					<tr><td colspan="2" align="left"><textarea cols="50" rows="5"  name="txtDescription" class="txtBox"></textarea></td></tr>
@@ -66,8 +66,8 @@
 	<table border=0 cellspacing=0 cellpadding=5 width=100% class="layerPopupTransport">
 		<tr>
 			<td colspan="2" align="center">
-					<input type="submit" name="save" value=" &nbsp;Attach&nbsp; " class="crmbutton small save" />&nbsp;&nbsp;
-					<input type="button" name="cancel" value=" Cancel " class="crmbutton small cancel" onclick="self.close();" />
+					<input type="submit" name="save" value="&nbsp;<?php echo $mod_strings["LBL_ATTACH"]; ?>&nbsp;" class="crmbutton small save" />&nbsp;&nbsp;
+					<input type="button" name="cancel" value=" <?php echo $mod_strings["LBL_CANCEL"];?> " class="crmbutton small cancel" onclick="self.close();" />
 			</td>	
 		</tr>
 	</table>

Modified: vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.bat
==============================================================================
--- vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.bat (original)
+++ vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.bat Mon Apr 16 12:27:44 2007
@@ -43,23 +43,23 @@
 echo ""
 echo "making an attempt to kill any existing vtigercrm service"
 echo ""
-bin\apache -k stop -n vtigercrm501
-bin\apache -k uninstall -n vtigercrm501
+bin\apache -k stop -n vtigercrm503
+bin\apache -k uninstall -n vtigercrm503
 echo "Uninstalling apache service again for confirmation after sleeping for 10 seconds"
 echo ""
 %SLEEP_STR% -n 10 127.0.0.1>nul
-bin\apache -k stop -n vtigercrm501
-bin\apache -k uninstall -n vtigercrm501 
+bin\apache -k stop -n vtigercrm503
+bin\apache -k uninstall -n vtigercrm503 
 echo ""
 echo ""
-echo "Installing  vtigercrm501 apache service after sleeping for 10 seconds"
+echo "Installing  vtigercrm503 apache service after sleeping for 10 seconds"
 echo ""
 %SLEEP_STR% -n 10 127.0.0.1>nul
-bin\apache -k install -n vtigercrm501 -f conf\httpd.conf
+bin\apache -k install -n vtigercrm503 -f conf\httpd.conf
 echo ""
-echo "Starting  vtigercrm501 apache service"
+echo "Starting  vtigercrm503 apache service"
 echo ""
-bin\apache -n vtigercrm501 -k start
+bin\apache -n vtigercrm503 -k start
 IF ERRORLEVEL 1 goto stopservice
 goto checkmysql
 
@@ -105,7 +105,7 @@
 echo ""
 echo "Starting MySQL on port specified by the user"
 echo ""
-start mysqld-nt -b .. --skip-bdb --log-queries-not-using-indexes --log-slow-admin-statements --log-error --low-priority-updates --log-slow-queries=vtslowquery.log --datadir=../data --port=%mysql_port%
+start mysqld-nt -b .. --skip-bdb --log-queries-not-using-indexes --log-slow-admin-statements --log-error --low-priority-updates --log-slow-queries=vtslowquery.log --default-storage-engine=InnoDB --datadir=../data --port=%mysql_port%
 %SLEEP_STR% -n 11 127.0.0.1>nul
 mysql --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases" > NUL
 IF ERRORLEVEL 1 goto notstarted
@@ -117,27 +117,27 @@
 
 :checkdatabase
 echo ""
-echo "check to see if vtigercrm501 database already exists"
+echo "check to see if vtigercrm503 database already exists"
 echo ""
-mysql --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases like 'vtigercrm501'" | "%WINDIR%\system32\find.exe" "vtigercrm501" > NUL
+mysql --port=%mysql_port% --user=%mysql_username% --password=%mysql_password% -e "show databases like 'vtigercrm503'" | "%WINDIR%\system32\find.exe" "vtigercrm503" > NUL
 IF ERRORLEVEL 1 goto dbnotexists
 echo ""
-ECHO  "vtigercrm501 database exists"
+ECHO  "vtigercrm503 database exists"
 echo ""
 goto end
 
 
 :dbnotexists
 echo ""
-ECHO "vtigercrm501 database does not exist"
+ECHO "vtigercrm503 database does not exist"
 echo ""
 echo %cd%
 echo ""
-echo "Proceeding to create database vtigercrm501 and populate the same"
+echo "Proceeding to create database vtigercrm503 and populate the same"
 echo ""
-mysql --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database if not exists vtigercrm501"
+mysql --user=%mysql_username% --password=%mysql_password% --port=%mysql_port% -e "create database if not exists vtigercrm503"
 echo ""
-echo "vtigercrm501 database created"
+echo "vtigercrm503 database created"
 echo ""
 goto end
 

Modified: vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.sh
==============================================================================
--- vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.sh (original)
+++ vtigercrm/branches/5.1_jens/pkg/bin/startvTiger.sh Mon Apr 16 12:27:44 2007
@@ -111,14 +111,14 @@
 		
 fi
 echo ""
-echo "Checking if the vtigercrm501 database already exists"
+echo "Checking if the vtigercrm503 database already exists"
 echo ""
-echo "select 1" | ./bin/mysql --user=$mysql_username --password=$mysql_password  --port=$mysql_port --socket=$mysql_socket -D vtigercrm501 >/dev/null
+echo "select 1" | ./bin/mysql --user=$mysql_username --password=$mysql_password  --port=$mysql_port --socket=$mysql_socket -D vtigercrm503 >/dev/null
 if [ $? -ne 0 ]; then
 	echo ""
-	echo "Database vtigercrm501 does not exist. Creating database vtigercrm501"
+	echo "Database vtigercrm503 does not exist. Creating database vtigercrm503"
 	echo ""
-	./bin/mysql --user=$mysql_username --password=$mysql_password  --port=$mysql_port --socket=$mysql_socket -e "create database if not exists vtigercrm501"
+	./bin/mysql --user=$mysql_username --password=$mysql_password  --port=$mysql_port --socket=$mysql_socket -e "create database if not exists vtigercrm503"
 fi
 
 host=`hostname`

Modified: vtigercrm/branches/5.1_jens/pkg/bin/stopvTiger.bat
==============================================================================
--- vtigercrm/branches/5.1_jens/pkg/bin/stopvTiger.bat (original)
+++ vtigercrm/branches/5.1_jens/pkg/bin/stopvTiger.bat Mon Apr 16 12:27:44 2007
@@ -32,13 +32,13 @@
 cd /d %apache_dir%
 rem shut down apache
 echo ""
-echo "stopping vtigercrm501 apache service"
+echo "stopping vtigercrm503 apache service"
 echo ""
-bin\apache -n vtigercrm501 -k stop
+bin\apache -n vtigercrm503 -k stop
 echo ""
-echo "uninstalling vtigercrm501 apache service"
+echo "uninstalling vtigercrm503 apache service"
 echo ""
-bin\apache -k uninstall -n vtigercrm501
+bin\apache -k uninstall -n vtigercrm503
 rem .\bin\ShutdownApache.exe logs\httpd.pid
 goto StopMySQL
 

Modified: vtigercrm/branches/5.1_jens/schema/DatabaseSchema.xml
==============================================================================
--- vtigercrm/branches/5.1_jens/schema/DatabaseSchema.xml (original)
+++ vtigercrm/branches/5.1_jens/schema/DatabaseSchema.xml Mon Apr 16 12:27:44 2007
@@ -1,6300 +1,6484 @@
-<?xml version="1.0"?>
-<schema version="0.2">
-
-	<table name="vtiger_users">
-		<field name="id" type="I" >
-			<key />
-			<autoincrement />
-		</field>
-		<field name="user_name" type="C" size="20" />
-		<field name="user_password" type="C" size="30" />
-		<field name="user_hash" type="C" size="32" />
-		<field name="cal_color" type="C" size="25">
-			<default value="#E6FAD8" />
-		</field>
-		<field name="first_name" type="C" size="30" />
-		<field name="last_name" type="C" size="30" />
-		<field name="reports_to_id" type="C" size="36" />
-		<field name="is_admin" type="C" size="3">
-			<default value="0" />
-		</field>
-		<field name="currency_id" type="I" size="19">
-			<default value="1" />
-			<notnull />
-		</field>
-		<field name="description" type="X" />
-		<field name="date_entered" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="date_modified" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="modified_user_id" type="C" size="36" />
-		<field name="title" type="C" size="50" />
-		<field name="department" type="C" size="50" />
-		<field name="phone_home" type="C" size="50" />
-		<field name="phone_mobile" type="C" size="50" />
-		<field name="phone_work" type="C" size="50" />
-		<field name="phone_other" type="C" size="50" />
-		<field name="phone_fax" type="C" size="50" />
-		<field name="email1" type="C" size="100" />
-		<field name="email2" type="C" size="100" />
-		<field name="yahoo_id" type="C" size="100" />
-		<field name="status" type="C" size="25" />
-		<field name="signature" type="C" size="250" />
-		<field name="address_street" type="C" size="150" />
-		<field name="address_city" type="C" size="100" />
-		<field name="address_state" type="C" size="100" />
-		<field name="address_country" type="C" size="25" />
-		<field name="address_postalcode" type="C" size="9" />
-		<field name="user_preferences" type="X" />
-		<field name="tz" type="C" size="30" />
-		<field name="holidays" type="C" size="60" />
-		<field name="namedays" type="C" size="60" />
-		<field name="workdays" type="C" size="30" />
-		<field name="weekstart" type="I" size="11" />
-		<field name="date_format" type="C" size="30" />
-		<field name="hour_format" type="C" size="30">
-			<default value="am/pm" />
-		</field>
-		<field name="start_hour" type="C" size="30">
-			<default value="10:00" />
-		</field>
-		<field name="end_hour" type="C" size="30">
-			<default value="23:00" />
-		</field>	
-		<field name="homeorder" type="C" size="255">
-			<default value="ALVT,HDB,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL,OLTPO,LTFAQ" />
-		</field>
-		<field name="activity_view" type="C" size="25">
-			<default value="Today" />
-		</field>
-		<field name="lead_view" type="C" size="25">
-			<default value="Today" />
-		</field>
-		<field name="imagename" type="C" size="250" />
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="defhomeview" type="C" size="100" />
-		<field name="confirm_password" type="C" size="30" />
-
-		<index name="user_user_name_idx">
-			<col>user_name</col>
-		</index>
-		<index name="user_user_password_idx">
-			<col>user_password</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
+<?xml version="1.0"?>
+<schema version="0.2">
+
+	<table name="vtiger_users">
+		<field name="id" type="I" >
+			<key />
+			<autoincrement />
+		</field>
+		<field name="user_name" type="C" size="20" />
+		<field name="user_password" type="C" size="30" />
+		<field name="user_hash" type="C" size="32" />
+		<field name="cal_color" type="C" size="25">
+			<default value="#E6FAD8" />
+		</field>
+		<field name="first_name" type="C" size="30" />
+		<field name="last_name" type="C" size="30" />
+		<field name="reports_to_id" type="C" size="36" />
+		<field name="is_admin" type="C" size="3">
+			<default value="0" />
+		</field>
+		<field name="currency_id" type="I" size="19">
+			<default value="1" />
+			<notnull />
+		</field>
+		<field name="description" type="X" />
+		<field name="date_entered" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="date_modified" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="modified_user_id" type="C" size="36" />
+		<field name="title" type="C" size="50" />
+		<field name="department" type="C" size="50" />
+		<field name="phone_home" type="C" size="50" />
+		<field name="phone_mobile" type="C" size="50" />
+		<field name="phone_work" type="C" size="50" />
+		<field name="phone_other" type="C" size="50" />
+		<field name="phone_fax" type="C" size="50" />
+		<field name="email1" type="C" size="100" />
+		<field name="email2" type="C" size="100" />
+		<field name="yahoo_id" type="C" size="100" />
+		<field name="status" type="C" size="25" />
+		<field name="signature" type="C" size="250" />
+		<field name="address_street" type="C" size="150" />
+		<field name="address_city" type="C" size="100" />
+		<field name="address_state" type="C" size="100" />
+		<field name="address_country" type="C" size="25" />
+		<field name="address_postalcode" type="C" size="9" />
+		<field name="user_preferences" type="X" />
+		<field name="tz" type="C" size="30" />
+		<field name="holidays" type="C" size="60" />
+		<field name="namedays" type="C" size="60" />
+		<field name="workdays" type="C" size="30" />
+		<field name="weekstart" type="I" size="11" />
+		<field name="date_format" type="C" size="30" />
+		<field name="hour_format" type="C" size="30">
+			<default value="am/pm" />
+		</field>
+		<field name="start_hour" type="C" size="30">
+			<default value="10:00" />
+		</field>
+		<field name="end_hour" type="C" size="30">
+			<default value="23:00" />
+		</field>	
+		<field name="homeorder" type="C" size="255">
+			<default value="HDB,ALVT,PLVT,QLTQ,CVLVT,HLT,OLV,GRT,OLTSO,ILTI,MNL,OLTPO,LTFAQ" />
+		</field>
+		<field name="activity_view" type="C" size="25">
+			<default value="Today" />
+		</field>
+		<field name="lead_view" type="C" size="25">
+			<default value="Today" />
+		</field>
+		<field name="imagename" type="C" size="250" />
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="defhomeview" type="C" size="100" />
+		<field name="confirm_password" type="C" size="30" />
+
+		<index name="user_user_name_idx">
+			<col>user_name</col>
+		</index>
+		<index name="user_user_password_idx">
+			<col>user_password</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_crmentity">
+		<field name="crmid" type="I" size="19">
+			<key />
+		</field>
+		<field name="smcreatorid" type="I" size="19">
+			<notnull/>
+			<default value="0" />
+		</field>
+		<field name="smownerid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="modifiedby" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="setype" type="C" size="30">
+			<notnull />
+		</field>
+		<field name="description" type="X" />
+		<field name="createdtime" type="T">
+			<notnull />
+		</field>
+		<field name="modifiedtime" type="T">
+			<notnull />
+		</field>
+		<field name="viewedtime" type="T" />
+		<field name="status" type="C" size="50" />
+		<field name="version" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<default value="1" />
+		</field>
+
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="crmentity_smcreatorid_idx">
+			<col>smcreatorid</col>
+		</index>
+		<index name="crmentity_smownerid_idx">
+			<col>smownerid</col>
+		</index>
+		<index name="crmentity_modifiedby_idx">
+			<col>modifiedby</col>
+		</index>
+		<index name="crmentity_deleted_smownerid_idx">
+			<col>deleted</col>
+			<col>smownerid</col>
+		</index>
+		<index name="crmentity_smownerid_deleted_idx">
+			<col>smownerid</col>
+			<col>deleted</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_sharedcalendar">
+		<field name="userid" type="I" size="19">
+			<key />
+		</field>
+		<field name="sharedid" type="I" size="19">
+			<key />
+		</field>
+	</table>
+
+	<table name="vtiger_tab">
+		<field name="tabid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="name" type="C" size="25">
+			<notnull />
+		</field>
+		<field name="presence" type="I" size="19">
+			<notnull />
+			<default value="1" />
+		</field>
+		<field name="tabsequence" type="I" size="10" />
+		<field name="tablabel" type="C" size="25">
+			<notnull />
+		</field>
+		<field name="modifiedby" type="I" size="19" />
+		<field name="modifiedtime" type="I" size="19" />
+		<field name="customized" type="I" size="19" />
+		<field name="ownedby" type="I" size="19" />
+
+		<index name="tab_name_idx">
+			<col>name</col>
+			<unique />
+		</index>
+		<index name="tab_modifiedby_idx">
+			<col>modifiedby</col>
+		</index>
+		<index name="tab_tabid_idx">
+			<col>tabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_blocks">
+		<field name="blockid" type="I" size="19">
+			<key />
+			<notnull />
+		</field>
+		<field name="tabid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="blocklabel" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="sequence" type="I" size="10" />
+		<field name="show_title" type="I" size="2" />
+		<field name="visible" type="I" size="2">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="create_view" type="I" size="2">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="edit_view" type="I" size="2">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="detail_view" type="I" size="2">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="block_tabid_idx">
+			<col>tabid</col>
+		</index>
+	</table>
+
+	<table name="vtiger_blocks" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_blocks FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_field">
+		<field name="tabid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="fieldid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="columnname" type="C" size="30">
+			<notnull />
+		</field>
+		<field name="tablename" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="generatedtype" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="uitype" type="C" size="30">
+			<notnull />
+		</field>
+		<field name="fieldname" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="fieldlabel" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="readonly" type="I" size="1">
+			<notnull />
+		</field>
+		<field name="presence" type="I" size="19">
+			<notnull />
+			<default value="1" />
+		</field>
+		<field name="selected" type="I" size="1">
+			<notnull />
+		</field>
+		<field name="maximumlength" type="I" size="19" />
+		<field name="sequence" type="I" size="19" />
+		<field name="block" type="I" size="19" />
+		<field name="displaytype" type="I" size="19" />
+		<field name="typeofdata" type="C" size="100" />
+		<field name="typeofdata" type="C" size="100" />
+		<field name="quickcreate" type="I" size="10">
+			<notnull />
+			<default value="1" />
+		</field>
+		<field name="quickcreatesequence" type="I" size="19" />
+		<field name="info_type" type="C" size="20" />
+
+		<index name="field_tabid_idx">
+			<col>tabid</col>
+		</index>
+		<index name="field_fieldname_idx">
+			<col>fieldname</col>
+		</index>
+		<index name="field_block_idx">
+			<col>block</col>
+		</index>
+		<index name="field_displaytype_idx">
+			<col>displaytype</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_field" alter="true">
+	<constraint>ADD CONSTRAINT fk_1_vtiger_field FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+	<opt>Type=InnoDB</opt>
+	<data>
+	</data>
+</table>
+
+	<table name="vtiger_account">
+		<field name="accountid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="accountname" type="C" size="100">
+			<unique />
+			<notnull />
+		</field>
+		<field name="parentid" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="account_type" type="C" size="50" />
+		<field name="industry" type="C" size="50" />
+		<field name="annualrevenue" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="rating" type="C" size="50" />
+		<field name="ownership" type="C" size="50" />
+		<field name="siccode" type="C" size="50" />
+		<field name="tickersymbol" type="C" size="30" />
+		<field name="phone" type="C" size="30" />
+		<field name="otherphone" type="C" size="30" />
+		<field name="email1" type="C" size="100" />
+		<field name="email2" type="C" size="100" />
+		<field name="website" type="C" size="100" />
+		<field name="fax" type="C" size="30" />
+		<field name="employees" type="I" size="10">
+			<default value="0" />
+		</field>
+		<field name="emailoptout" type="C" size="3">
+			<default value="0" />
+		</field>
+		<field name="notify_owner" type="C" size="3">
+			<default value="0" />
+		</field>
+
+		<index name="account_account_type_idx">
+			<col>account_type</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_account" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_account FOREIGN KEY (accountid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_accountbillads">
+		<field name="accountaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="city" type="C" size="30" />
+		<field name="code" type="C" size="30" />
+		<field name="country" type="C" size="30" />
+		<field name="state" type="C" size="30" />
+		<field name="street" type="C" size="250" />
+		<field name="pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_accountbillads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_accountbillads FOREIGN KEY (accountaddressid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_accountshipads">
+		<field name="accountaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="city" type="C" size="30" />
+		<field name="code" type="C" size="30" />
+		<field name="country" type="C" size="30" />
+		<field name="state" type="C" size="30" />
+		<field name="pobox" type="C" size="30" />
+		<field name="street" type="C" size="250" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_accountshipads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_accountshipads FOREIGN KEY (accountaddressid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_accountscf">
+		<field name="accountid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_accountscf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_accountscf FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_contactdetails">
+		<field name="contactid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="accountid" type="I" size="19" />
+		<field name="salutation" type="C" size="50">
+			<default value="Mr" />
+		</field>
+		<field name="firstname" type="C" size="40" />
+		<field name="lastname" type="C" size="80">
+			<notnull />
+		</field>
+		<field name="email" type="C" size="100" />
+		<field name="phone" type="C" size="50" />
+		<field name="mobile" type="C" size="50" />
+		<field name="title" type="C" size="50" />
+		<field name="department" type="C" size="30" />
+		<field name="fax" type="C" size="50" />
+		<field name="reportsto" type="C" size="30" />
+		<field name="training" type="C" size="50" />
+		<field name="usertype" type="C" size="50" />
+		<field name="contacttype" type="C" size="50" />
+		<field name="otheremail" type="C" size="100" />
+		<field name="yahooid" type="C" size="100" />
+		<field name="donotcall" type="C" size="3" />
+		<field name="emailoptout" type="C" size="3">
+			<default value="0" />
+		</field>
+		<field name="imagename" type="C" size="150" />
+		<field name="reference" type="C" size="3" />
+		<field name="notify_owner" type="C" size="3">
+			<default value="0"/>
+		</field>
+
+		<index name="contactdetails_accountid_idx">
+			<col>accountid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_contactdetails" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_contactdetails FOREIGN KEY (contactid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_contactsubdetails">
+		<field name="contactsubscriptionid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="homephone" type="C" size="50" />
+		<field name="otherphone" type="C" size="50" />
+		<field name="assistant" type="C" size="30" />
+		<field name="assistantphone" type="C" size="50" />
+		<field name="birthday" type="D" />
+		<field name="laststayintouchrequest" type="I" size="30">
+			<default value="0" />
+		</field>
+		<field name="laststayintouchsavedate" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="leadsource" type="C" size="50" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_contactsubdetails" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_contactsubdetails FOREIGN KEY (contactsubscriptionid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_contactaddress">
+		<field name="contactaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="mailingcity" type="C" size="40" />
+		<field name="mailingstreet" type="C" size="250" />
+		<field name="mailingcountry" type="C" size="40" />
+		<field name="othercountry" type="C" size="30" />
+		<field name="mailingstate" type="C" size="30" />
+		<field name="mailingpobox" type="C" size="30" />
+		<field name="othercity" type="C" size="40" />
+		<field name="otherstate" type="C" size="50" />
+		<field name="mailingzip" type="C" size="30" />
+		<field name="otherzip" type="C" size="30" />
+		<field name="otherstreet" type="C" size="250" />
+		<field name="otherpobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_contactaddress" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_contactaddress FOREIGN KEY (contactaddressid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_contactscf">
+		<field name="contactid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_contactscf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_contactscf FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_portalinfo">
+		<field name="id" type="I" size="11">
+			<key />
+		</field>
+		<field name="user_name" type="C" size="50" />
+		<field name="user_password" type="C" size="30" />
+		<field name="type" type="C" size="5" />
+		<field name="last_login_time" type="T">
+			<notnull />
+		</field>
+		<field name="login_time" type="T">
+			<notnull />
+		</field>
+		<field name="logout_time" type="T">
+			<notnull />
+		</field>
+		<field name="isactive" type="I" size="1" />
+	</table>
+
+<table name="vtiger_portalinfo" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_portalinfo FOREIGN KEY (id) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_customerdetails">
+		<field name="customerid" type="I" size="19">
+			<key />
+		</field>
+		<field name="portal" type="C" size="3" />
+		<field name="support_start_date" type="D" />
+		<field name="support_end_date" type="D" />
+	</table>
+
+<table name="vtiger_customerdetails" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_customerdetails FOREIGN KEY (customerid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leaddetails">
+		<field name="leadid" type="I" size="19">
+			<key />
+		</field>
+		<field name="email" type="C" size="100" />
+		<field name="interest" type="C" size="50" />
+		<field name="firstname" type="C" size="40" />
+		<field name="salutation" type="C" size="10" />
+		<field name="lastname" type="C" size="80">
+			<notnull />
+		</field>
+		<field name="company" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="annualrevenue" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="industry" type="C" size="50" />
+		<field name="campaign" type="C" size="30" />
+		<field name="rating" type="C" size="50" />
+		<field name="leadstatus" type="C" size="50" />
+		<field name="leadsource" type="C" size="50" />
+		<field name="converted" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="designation" type="C" size="50">
+			<default value="SalesMan" />
+		</field>
+		<field name="licencekeystatus" type="C" size="50" />
+		<field name="space" type="C" size="250" />
+		<field name="comments" type="X" />
+		<field name="priority" type="C" size="50" />
+		<field name="demorequest" type="C" size="50" />
+		<field name="partnercontact" type="C" size="50" />
+		<field name="productversion" type="C" size="20" />
+		<field name="product" type="C" size="50" />
+		<field name="maildate" type="D" />
+		<field name="nextstepdate" type="D" />
+		<field name="fundingsituation" type="C" size="50" />
+		<field name="purpose" type="C" size="50" />
+		<field name="evaluationstatus" type="C" size="50" />
+		<field name="transferdate" type="D" />
+		<field name="revenuetype" type="C" size="50" />
+		<field name="noofemployees" type="C" size="50" />
+		<field name="yahooid" type="C" size="100" />
+		<field name="assignleadchk" type="I" size="1">
+			<default value="0" />
+		</field>
+
+		<index name="leaddetails_converted_leadstatus_idx">
+			<col>converted</col>
+			<col>leadstatus</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leaddetails" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leaddetails FOREIGN KEY (leadid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leadsubdetails">
+		<field name="leadsubscriptionid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="website" type="C" size="255" />
+		<field name="callornot" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="readornot" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="empct" type="I" size="10">
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadsubdetails" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadsubdetails FOREIGN KEY (leadsubscriptionid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leadaddress">
+		<field name="leadaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="city" type="C" size="30" />
+		<field name="code" type="C" size="30" />
+		<field name="state" type="C" size="30" />
+		<field name="pobox" type="C" size="30" />
+		<field name="country" type="C" size="30" />
+		<field name="phone" type="C" size="50" />
+		<field name="mobile" type="C" size="50" />
+		<field name="fax" type="C" size="50" />
+		<field name="lane" type="C" size="250" />
+		<field name="leadaddresstype" type="C" size="30">
+			<default value="Billing" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadaddress" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadaddress FOREIGN KEY (leadaddressid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leadscf">
+		<field name="leadid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadscf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadscf FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_notes">
+		<field name="notesid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="contact_id" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="title" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="filename" type="C" size="50" />
+		<field name="notecontent" type="X" />
+
+		<index name="notes_title_idx">
+			<col>title</col>
+		</index>
+		<index name="notes_notesid_idx">
+			<col>notesid</col>
+		</index>
+		<index name="notes_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_notes" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_notes FOREIGN KEY (notesid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_potential">
+		<field name="potentialid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="accountid" type="I" size="19" />
+		<field name="potentialname" type="C" size="120">
+			<notnull />
+		</field>
+		<field name="amount" type="N" size="10.2">
+			<default value="0" />
+		</field>
+		<field name="currency" type="C" size="20" />
+		<field name="closingdate" type="D" />
+		<field name="typeofrevenue" type="C" size="50" />
+		<field name="nextstep" type="C" size="100" />
+		<field name="private" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="probability" type="N" size="7.3">
+			<default value="0" />
+		</field>
+		<field name="campaignid" type="I" size="19" />
+		<field name="sales_stage" type="C" size="50" />
+		<field name="potentialtype" type="C" size="50" />
+		<field name="leadsource" type="C" size="50" />
+		<field name="productid" type="I" size="50" />
+		<field name="productversion" type="C" size="50" />
+		<field name="quotationref" type="C" size="50" />
+		<field name="partnercontact" type="C" size="50" />
+		<field name="remarks" type="C" size="50" />
+		<field name="runtimefee" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="followupdate" type="D" />
+		<field name="evaluationstatus" type="C" size="50" />
+		<field name="description" type="X" />
+		<field name="forecastcategory" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="outcomeanalysis" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="orgunitid" type="I" size="19" />
+
+		<index name="potential_accountid_idx">
+			<col>accountid</col>
+		</index>
+		<index name="potential_potentialid_idx">
+			<col>potentialid</col>
+		</index>
+		<index name="potentail_sales_stage_idx">
+			<col>sales_stage</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_potential" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_potential FOREIGN KEY (potentialid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_potstagehistory">
+		<field name="historyid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="potentialid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="amount" type="N" />
+		<field name="stage" type="C" size="100" />
+		<field name="probability" type="N" size="7.3" />
+		<field name="expectedrevenue" type="N" />
+		<field name="closedate" type="D" />
+		<field name="lastmodified" type="T" />
+
+		<index name="potstagehistory_potentialid_idx">
+			<col>potentialid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_potstagehistory" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_potstagehistory FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_potentialscf">
+		<field name="potentialid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_potentialscf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_potentialscf FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_activity">
+		<field name="activityid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="subject" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="semodule" type="C" size="20" />
+		<field name="activitytype" type="C" size="50">
+			<notnull />
+		</field>
+
+		<field name="date_start" type="D">
+			<notnull />
+		</field>
+		<field name="due_date" type="D" />
+		<field name="time_start" type="C" size="50" />
+		<field name="time_end" type="C" size="50" />
+		<field name="sendnotification" type="C" size="3">
+			<notnull />
+			<default value="0"/>
+		</field>
+		<field name="duration_hours" type="C" size="2" />
+		<field name="duration_minutes" type="C" size="2" />
+		<field name="status" type="C" size="100" />
+		<field name="eventstatus" type="C" size="100" />
+		<field name="priority" type="C" size="150" />
+		<field name="location" type="C" size="150" />
+		<field name="notime" type="C" size="3">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="visibility" type="C" size="50">
+			<notnull />
+			<default value="all" />
+		</field>
+
+		<index name="activity_activityid_subject_idx">
+			<col>activityid</col>
+			<col>subject</col>
+		</index>
+		<index name="activity_activitytype_date_start_idx">
+			<col>activitytype</col>
+			<col>date_start</col>
+		</index>
+		<index name="activity_date_start_due_date_idx">
+			<col>date_start</col>
+			<col>due_date</col>
+		</index>
+		<index name="activity_date_start_time_start_idx">
+			<col>date_start</col>
+			<col>time_start</col>
+		</index>
+		<index name="activity_eventstatus_idx">
+			<col>eventstatus</col>
+		</index>
+		<index name="activity_status_eventstatus_idx">
+			<col>status</col>
+			<col>eventstatus</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_activity" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_activity FOREIGN KEY (activityid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_attachments">
+		<field name="attachmentsid" type="I" size="19">
+			<key />
+		</field>
+		<field name="name" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="description" type="C" size="100" />
+		<field name="type" type="C" size="100" />
+		<field name="path" type="C" size="255" />
+		<index name="attachments_attachmentsid_idx">
+			<col>attachmentsid</col>
+		</index>
+		<index name="attachments_description_name_type_attachmentsid_idx">
+			<col>description</col>
+			<col>name</col>
+			<col>type</col>
+			<col>attachmentsid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_attachments" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_attachments FOREIGN KEY (attachmentsid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_seattachmentsrel">
+		<field name="crmid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="attachmentsid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="seattachmentsrel_attachmentsid_idx">
+			<col>attachmentsid</col>
+		</index>
+		<index name="seattachmentsrel_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<index name="seattachmentsrel_attachmentsid_crmid_idx">
+			<col>attachmentsid</col>
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_seattachmentsrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_seattachmentsrel FOREIGN KEY (attachmentsid) REFERENCES vtiger_attachments(attachmentsid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_seattachmentsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tracker">
+		<field name="id" type="I" size="11">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="user_id" type="C" size="36" />
+		<field name="module_name" type="C" size="25" />
+		<field name="item_id" type="C" size="36" />
+		<field name="item_summary" type="C" size="255" />
+	</table>
+
+	<table name="vtiger_competitor">
+		<field name="competitorid" type="I" size="19">
+			<key />
+		</field>
+		<field name="competitorname" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="website" type="C" size="100" />
+		<field name="strength" type="C" size="250" />
+		<field name="weakness" type="C" size="250" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_competitor" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_competitor FOREIGN KEY (competitorid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_potcompetitorrel">
+		<field name="potentialid" type="I" size="19">
+			<key />
+		</field>
+		<field name="competitorid" type="I" size="19">
+			<key />
+		</field>
+
+		<index name="potcompetitorrel_potentialid_idx">
+			<col>potentialid</col>
+		</index>
+		<index name="potcompetitorrel_competitorid_idx">
+			<col>competitorid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_potcompetitorrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_potcompetitorrel FOREIGN KEY (competitorid) REFERENCES vtiger_competitor(competitorid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_potcompetitorrel FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_vendor">
+		<field name="vendorid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="vendorname" type="C" size="100" />
+		<field name="phone" type="C" size="100" />
+		<field name="email" type="C" size="100" />
+		<field name="website" type="C" size="100" />
+		<field name="glacct" type="C" size="50" />
+		<field name="category" type="C" size="50" />
+		<field name="street" type="X" />
+		<field name="city" type="C" size="30" />
+		<field name="state" type="C" size="30" />
+		<field name="pobox" type="C" size="30" />
+		<field name="postalcode" type="C" size="100" />
+		<field name="country" type="C" size="100" />
+		<field name="description" type="X" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_vendor" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_vendor FOREIGN KEY (vendorid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_products">
+		<field name="productid" type="I" size="11">
+			<key />
+		</field>
+		<field name="productname" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="productcode" type="C" size="40" />
+		<field name="productcategory" type="C" size="40" />
+		<field name="productclass" type="C" size="40">
+			<notnull />
+			<default value="Sales" />
+		</field>
+		<field name="productvalidation" type="C" size="40">
+			<notnull />
+			<default value="On delivery" />
+		</field>
+		<field name="producttype" type="C" size="40">
+			<notnull />
+			<default value="One time fixed" />
+		</field>
+		<field name="contractbound" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="manufacturer" type="C" size="40" />
+		<field name="product_description" type="X" />
+		<field name="qty_per_unit" type="N" size="11.2">
+			<default value="0" />
+		</field>
+		<field name="unit_price" type="N" size="25.2" />
+		<field name="weight" type="N" size="11.3" />
+		<field name="pack_size" type="I" size="11" />
+		<field name="sales_start_date" type="D" />
+		<field name="sales_end_date" type="D" />
+		<field name="start_date" type="D" />
+		<field name="expiry_date" type="D" />
+		<field name="cost_factor" type="I" size="11" />
+		<field name="commissionrate" type="N" size="7.3" />
+		<field name="commissionmethod" type="C" size="50" />
+		<field name="discontinued" type="I" size="1" />
+		<field name="usageunit" type="C" size="200" />
+		<field name="handler" type="I" size="11" />
+		<field name="currency" type="C" size="200" />
+		<field name="reorderlevel" type="I" size="11" />
+		<field name="website" type="C" size="100" />
+		<field name="taxclass" type="C" size="200" />
+		<field name="mfr_part_no" type="C" size="200" />
+		<field name="vendor_part_no" type="C" size="200" />
+		<field name="serialno" type="C" size="200" />
+		<field name="qtyinstock" type="I" size="11" />
+		<field name="productsheet" type="C" size="200" />
+		<field name="qtyindemand" type="I" size="11" />
+		<field name="glacct" type="C" size="200" />
+		<field name="vendor_id" type="I" size="11" />
+		<field name="imagename" type="X" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_products" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_products FOREIGN KEY (productid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_dependendlists">
+		<field name="dependency_id" type="I" size="19">
+			<key />
+			<notnull />
+			<autoincrement />
+		</field>
+		<field name="tabid" type="I" size="19" />
+		<field name="name" type="C" size="100" />
+		<field name="sequence" type="I" size="19" />
+		<field name="label" type="C" size="100" />
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_products2products_rel">
+		<field name="productid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="related_productid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="relation_type" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="sequence_no" type="I" size="19" />
+		<field name="product_relgroup" type="I" size="19" />
+		<field name="quantity" type="I" size="19" />
+		<field name="comment" type="C" size="100" />
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_products2products_rel" alter="true">
+	    <constraint>ADD CONSTRAINT fk_1_products2products_rel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
+	    <constraint>ADD CONSTRAINT fk_2_products2products_rel FOREIGN KEY (related_productid) REFERENCES vtiger_products(productid) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
+	    <opt>Type=InnoDB</opt>
+	    <data>
+	    </data>
+	</table>
+
+	<table name="vtiger_productclass">
+		<field name="productclassid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="productclass" type="C" size="40">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="productclass_productclass_idx">
+			<unique />
+			<col>productclass</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_producttype">
+		<field name="producttypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="producttype" type="C" size="40">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="producttype_producttype_idx">
+			<unique />
+			<col>producttype</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_productvalidation">
+		<field name="productvalidationid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="productvalidation" type="C" size="40">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="productvalidation_productvalidation_idx">
+			<unique />
+			<col>productvalidation</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_currency">
+		<field name="currencyid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="currency" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="currency_currency_idx">
+			<unique />
+			<col>currency</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_visibility">
+		<field name="visibilityid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="visibility" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0"/>
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1"/>
+		</field>
+
+		<index name="visibility_visibility_idx">
+			<col>visibility</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_manufacturer">
+		<field name="manufacturerid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="manufacturer" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="manufacturer_manufacturer_idx">
+			<unique />
+			<col>manufacturer</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_productcollaterals">
+		<field name="productid" type="I" size="11">
+			<key />
+		</field>
+		<field name="date_entered" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="data" type="B">
+			<notnull />
+		</field>
+		<field name="description" type="X" />
+		<field name="filename" type="C" size="50" />
+		<field name="filesize" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="filetype" type="C" size="20">
+			<notnull />
+		</field>
+
+		<index name="productcollaterals_productid_filename_idx">
+			<col>productid</col>
+			<col>filename</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_productcollaterals" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_productcollaterals FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_role">
+		<field name="roleid" type="C" size="255">
+			<key />
+		</field>
+		<field name="rolename" type="C" size="200" />
+		<field name="parentrole" type="C" size="255" />
+		<field name="depth" type="I" size="19" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_user2role">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="roleid" type="C" size="255">
+			<notnull />
+		</field>
+
+		<index name="user2role_roleid_idx">
+			<col>roleid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_user2role" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_user2role FOREIGN KEY (roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_user2role FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_groups">
+		<field name="groupid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100" />
+		<field name="description" type="X" />
+
+		<index name="groups_groupname_idx">
+			<col>groupname</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_users2group">
+		<field name="groupid" type="I" size="19">
+			<key />
+		</field>
+		<field name="userid" type="I" size="19">
+			<key />
+		</field>
+
+		<index name="users2group_groupname_uerid_idx">
+			<col>groupid</col>
+			<col>userid</col>
+		</index>
+	</table>
+
+<table name="vtiger_users2group" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_users2group FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_users2group FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_group2grouprel">
+		<field name="groupid" type="I" size="19">
+			<key />
+		</field>
+		<field name="containsgroupid" type="I" size="19">
+			<key />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_group2grouprel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_group2grouprel FOREIGN KEY (containsgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_group2grouprel FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_group2role">
+		<field name="groupid" type="I" size="19">
+			<key />
+		</field>
+		<field name="roleid" type="C" size="255">
+			<key />
+		</field>
+	</table>
+
+<table name="vtiger_group2role" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_group2role FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_group2role FOREIGN KEY (roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_group2rs">
+		<field name="groupid" type="I" size="19">
+			<key />
+		</field>
+		<field name="roleandsubid" type="C" size="255">
+			<key />
+		</field>
+	</table>
+
+<table name="vtiger_group2rs" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_group2rs FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_group2rs FOREIGN KEY (roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leadpotrel">
+		<field name="leadid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="potentialid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="leadpotrel_leadid_idx">
+			<col>leadid</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadpotrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadpotrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_leadpotrel FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_campaign">
+		<field name="campaignname" type="C" size="255" />
+		<field name="campaigntype" type="C" size="255" />
+		<field name="campaignstatus" type="C" size="255" />
+		<field name="expectedrevenue" type="N" size="25.3" />
+		<field name="budgetcost" type="N" size="25.3" />
+		<field name="actualcost" type="N" size="25.3" />
+		<field name="expectedresponse" type="C" size="255" />
+		<field name="numsent" type="N" size="11.0" />
+		<field name="product_id" type="I" size="19" />
+		<field name="sponsor" type="C" size="255" />
+		<field name="targetaudience" type="C" size="255" />
+		<field name="targetsize" type="I" size="19" />
+		<field name="expectedresponsecount" type="I" size="19" />
+		<field name="expectedsalescount" type="I" size="19" />
+		<field name="expectedroi" type="N" size="25.3" />
+		<field name="actualresponsecount" type="I" size="19" />
+		<field name="actualsalescount" type="I" size="19" />
+		<field name="actualroi" type="N" size="25.3" />
+		<field name="campaignid" type="I" size="19">
+			<key />
+		</field>
+		<field name="closingdate" type="D" />
+
+		<index name="campaign_campaignstatus_idx">
+			<col>campaignstatus</col>
+		</index>
+		<index name="campaign_campaignname_idx">
+			<col>campaignname</col>
+		</index>
+		<index name="campaign_campaignid_idx">
+			<col>campaignid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_campaignscf">
+		<field name="campaignid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_campaignscf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_campaignscf FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_campaigncontrel">
+		<field name="campaignid" type="I" size="19">
+			<key />
+			<default value="0"/>
+		</field>
+		<field name="contactid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0"/>
+		</field>
+
+		<index name="campaigncontrel_contractid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_campaigncontrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_campaigncontrel FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_campaigncontrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_campaignleadrel">
+		<field name="campaignid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="leadid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="campaignleadrel_leadid_campaignid_idx">
+			<col>leadid</col>
+			<col>campaignid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_campaignleadrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_campaignleadrel FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_campaignleadrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leadcontrel">
+		<field name="leadid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="contactid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="leadcontrel_contactid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadcontrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadcontrel FOREIGN KEY (leadcontrel_contactid_idx) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_leadcontrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_leadacctrel">
+		<field name="leadid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="accountid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="leadacctrel_accountid_idx">
+			<col>accountid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadacctrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadacctrel FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_leadacctrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_contpotentialrel">
+		<field name="contactid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="potentialid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="contpotentialrel_potentialid_idx">
+			<col>potentialid</col>
+		</index>
+		<index name="contpotentialrel_contactid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_contpotentialrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_contpotentialrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_contpotentialrel FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_dealintimation">
+		<field name="dealintimationid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="dealname" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="intimationamount" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<field name="dealprobability" type="N" size="3.2">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="dealintimationactive" type="I" size="1" />
+		<field name="fromname" type="C" size="120">
+			<notnull />
+		</field>
+		<field name="fromemailid" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="notifyemails" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="notifybccemails" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="notifyccmails" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="notifypotentialowner" type="I" size="1" />
+
+		<index name="dealintimation_dealname_idx">
+			<col>dealname</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_cntactivityrel">
+		<field name="contactid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="activityid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="cntactivityrel_contactid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_cntactivityrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_cntactivityrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_cntactivityrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_lar">
+		<field name="larid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="name" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="createdby" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="createdon" type="D">
+			<notnull />
+		</field>
+
+		<index name="lar_name_idx">
+			<col>name</col>
+			<unique />
+		</index>
+		<index name="lar_createdby_idx">
+			<col>createdby</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_lar" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_lar FOREIGN KEY (createdby) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_crmentitynotesrel">
+		<field name="crmid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="notesid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="crmentitynotesrel_notesid_idx">
+			<col>notesid</col>
+		</index>
+		<index name="crmentitynotesrel_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_crmentitynotesrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_crmentitynotesrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_crmentitynotesrel FOREIGN KEY (notesid) REFERENCES vtiger_notes(notesid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_troubletickets">
+		<field name="ticketid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100" />
+		<field name="parent_id" type="C" size="100" />
+		<field name="product_id" type="C" size="100" />
+		<field name="priority" type="C" size="150" />
+		<field name="severity" type="C" size="150" />
+		<field name="status" type="C" size="150" />
+		<field name="category" type="C" size="150" />
+		<field name="title" type="C" size="255">
+			<notnull />
+		</field>
+		<field name="filename" type="C" size="50" />
+		<field name="description" type="X" />
+		<field name="solution" type="X" />
+		<field name="update_log" type="X" />
+		<field name="version_id" type="I" size="11" />
+
+		<index name="troubletickets_ticketid_idx">
+			<col>ticketid</col>
+		</index>
+		<index name="troubletickets_status_idx">
+			<col>status</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_troubletickets" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_troubletickets FOREIGN KEY (ticketid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_ticketcomments">
+		<field name="commentid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="ticketid" type="I" size="19">
+		</field>
+		<field name="comments" type="X" />
+		<field name="ownerid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="ownertype" type="C" size="10" />
+		<field name="createdtime" type="T" >
+			<notnull />
+		</field>
+
+		<index name="ticketcomments_ticketid_idx">
+			<col>ticketid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_ticketcomments" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_ticketcomments FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_salesmanactivityrel">
+		<field name="smid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="activityid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="salesmanactivityrel_activityid_idx">
+			<col>activityid</col>
+		</index>
+		<index name="salesmanactivityrel_smid_idx">
+			<col>smid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_salesmanactivityrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_salesmanactivityrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_salesmanactivityrel FOREIGN KEY (smid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_vendorcontactrel">
+		<field name="vendorid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="contactid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="vendorcontactrel_vendorid_idx">
+			<col>vendorid</col>
+		</index>
+		<index name="vendorcontactrel_contact_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_vendorcontactrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_vendorcontactrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_vendorcontactrel FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_salesmanticketrel">
+		<field name="smid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="id" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="salesmanticketrel_smid_idx">
+			<col>smid</col>
+		</index>
+		<index name="salesmanticketrel_id_idx">
+			<col>id</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_salesmanticketrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_salesmanticketrel FOREIGN KEY (id) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_salesmanticketrel FOREIGN KEY (smid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_seactivityrel">
+		<field name="crmid" type="I" size="19">
+			<key />
+		</field>
+		<field name="activityid" type="I" size="19">
+			<key />
+		</field>
+
+		<index name="seactivityrel_activityid_idx">
+			<col>activityid</col>
+		</index>
+		<index name="seactivityrel_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_seactivityrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_seactivityrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_seactivityrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_seproductsrel">
+		<field name="crmid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="productid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="setype" type="C" size="30">
+			<notnull />
+		</field>
+
+		<index name="seproductsrel_productid_idx">
+			<col>productid</col>
+		</index>
+		<index name="seproductrel_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_seproductsrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_seproductsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_seproductsrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_seticketsrel">
+		<field name="crmid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="ticketid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="seticketsrel_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<index name="seticketsrel_ticketid_idx">
+			<col>ticketid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_seticketsrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_seticketsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_seticketsrel FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_headers">
+		<field name="fileid" type="I" size="3">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="headernames" type="C" size="30">
+			<notnull />
+		</field>
+	</table>
+
+	<table name="vtiger_import_maps">
+		<field name="id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="name" type="C" size="36">
+			<notnull />
+		</field>
+		<field name="module" type="C" size="36">
+			<notnull />
+		</field>
+		<field name="content" type="B" />
+		<field name="has_header" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="date_entered" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="date_modified" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="assigned_user_id" type="C" size="36" />
+		<field name="is_published" type="C" size="3">
+			<notnull />
+			<default value="no" />
+		</field>
+
+		<index name="import_maps_assigned_user_id_module_name_deleted_idx">
+			<col>assigned_user_id</col>
+			<col>module</col>
+			<col>name</col>
+			<col>deleted</col>
+		</index>
+	</table>
+
+	<table name="vtiger_leadgrouprelation">
+		<field name="leadid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="leadgrouprelation_leadid_idx">
+			<col>leadid</col>
+		</index>
+		<index name="leadgrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_leadgrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_leadgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_leadgrouprelation FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_accountgrouprelation">
+		<field name="accountid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="accountgrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_accountgrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_accountgrouprelation FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_accountgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_contactgrouprelation">
+		<field name="contactid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="contactgrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_contactgrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_contactgrouprelation FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_contactgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_potentialgrouprelation">
+		<field name="potentialid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="potentialgrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_potentialgrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_potentialgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_potentialgrouprelation FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_campaigngrouprelation">
+		<field name="campaignid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="campaigngrouprelation_IDX1">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_campaigngrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_campaigngrouprelation FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_campaigngrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_activitygrouprelation">
+		<field name="activityid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="activitygrouprelation_activityid_idx">
+			<col>activityid</col>
+		</index>
+		<index name="activitygrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_activitygrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_activitygrouprelation FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_activitygrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_ticketgrouprelation">
+		<field name="ticketid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="ticketgrouprelation_ticketid_idx">
+			<col>ticketid</col>
+		</index>
+		<index name="ticketgrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_ticketgrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_ticketgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_ticketgrouprelation FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_systems">
+		<field name="id" type="I" size="19">
+			<key />
+		</field>
+		<field name="server" type="C" size="30" />
+		<field name="server_port" type="I" size="19" />
+		<field name="server_username" type="C" size="30" />
+		<field name="server_password" type="C" size="30" />
+		<field name="server_type" type="C" size="20" />
+		<field name="smtp_auth" type="C" size="5" />
+	</table>
+
+	<table name="vtiger_currency_info">
+		<field name="id" type="I" >
+			<key />
+			<autoincrement />
+
+		</field>
+		<field name="currency_name" type="C" size="100" />
+		<field name="currency_code" type="C" size="100" />
+		<field name="currency_symbol" type="C" size="30" />
+		<field name="conversion_rate" type="N" size="10.3" />
+		<field name="currency_status" type="C" size="25" />
+		<field name="defaultid" type="C" size="10">
+			<notnull />
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_defaultcv">
+		<field name="tabid" type="I" size="19">
+			<key />
+		</field>
+		<field name="defaultviewname" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="query" type="X" />
+	</table>
+
+<table name="vtiger_defaultcv" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_defaultcv FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_emailtemplates">
+		<field name="foldername" type="C" size="100" />
+		<field name="templatename" type="C" size="100" />
+		<field name="subject" type="C" size="100" />
+		<field name="description" type="X" />
+		<field name="body" type="X" />
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="templateid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+
+		<index name="emailtemplates_foldernamd_templatename_subject_idx">
+			<col>foldername</col>
+			<col>templatename</col>
+			<col>subject</col>
+		</index>
+	</table>
+
+	<table name="vtiger_faq">
+		<field name="id" type="I" size="11">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="product_id" type="C" size="100" />
+		<field name="question" type="X">
+			<notnull />
+		</field>
+		<field name="answer" type="X" />
+		<field name="category" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="status" type="C" size="100">
+			<notnull />
+		</field>
+
+		<index name="faq_id_idx">
+			<col>id</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_faq" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_faq FOREIGN KEY (id) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_faqcomments">
+		<field name="commentid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="faqid" type="I" size="19">
+		</field>
+		<field name="comments" type="X" />
+		<field name="createdtime" type="T">
+			<notnull />
+		</field>
+
+		<index name="faqcomments_faqid_idx">
+			<col>faqid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_faqcomments" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_faqcomments FOREIGN KEY (faqid) REFERENCES vtiger_faq(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_files">
+		<field name="id" type="C" size="36">
+			<key />
+		</field>
+		<field name="name" type="C" size="36" />
+		<field name="content" type="B" />
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="date_entered" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="assigned_user_id" type="C" size="36" />
+
+		<index name="files_assigned_user_id_name_deleted_idx">
+			<col>assigned_user_id</col>
+			<col>name</col>
+			<col>deleted</col>
+		</index>
+	</table>
+
+	<table name="vtiger_loginhistory">
+		<field name="login_id" type="I" size="11">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="user_name" type="C" size="25">
+			<notnull />
+		</field>
+		<field name="user_ip" type="C" size="25">
+			<notnull />
+		</field>
+		<field name="logout_time" type="T">
+			<deftimestamp />
+		</field>
+		<field name="login_time" type="T">
+			<deftimestamp />
+		</field>
+		<field name="status" type="C" size="25" />
+	</table>
+
+	<table name="vtiger_senotesrel">
+		<field name="crmid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="notesid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="senotesrel_notesid_idx">
+			<col>notesid</col>
+		</index>
+		<index name="senotesrel_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_senotesrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_senotesrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_senotesrel FOREIGN KEY (notesid) REFERENCES vtiger_notes(notesid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_ticketstracktime">
+		<field name="ticket_id" type="I" size="11">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="supporter_id" type="I" size="11">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="minutes" type="I" size="11">
+			<default value="0" />
+		</field>
+		<field name="date_logged" type="I" size="11">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="ticketstracktime_ticket_id_idx">
+			<col>ticket_id</col>
+		</index>
+	</table>
+
+	<table name="vtiger_ticketcf">
+		<field name="ticketid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_ticketcf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_ticketcf FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_productcf">
+		<field name="productid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_productcf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_productcf FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_users_last_import">
+		<field name="id" type="I" size="36">
+			<autoincrement />
+			<key />
+		</field>
+		<field name="assigned_user_id" type="C" size="36" />
+		<field name="bean_type" type="C" size="36" />
+		<field name="bean_id" type="C" size="36" />
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="idx_user_id">
+			<col>assigned_user_id</col>
+		</index>
+	</table>
+
+	<table name="vtiger_wordtemplates">
+		<field name="templateid" type="I" size="19">
+			<key />
+		</field>
+		<field name="filename" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="module" type="C" size="30">
+			<notnull />
+		</field>
+		<field name="date_entered" type="T">
+			<notnull />
+			<deftimestamp />
+		</field>
+		<field name="parent_type" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="data" type="B">
+			<notnull />
+		</field>
+		<field name="description" type="X" />
+		<field name="filesize" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="filetype" type="C" size="20">
+			<notnull />
+		</field>
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_accountdepstatus">
+		<field name="deploymentstatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="deploymentstatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="accountdepstatus_deploymentstatus_idx">
+			<col>deploymentstatus</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_accountownership">
+		<field name="acctownershipid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="ownership" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="accountownership_ownership_idx">
+			<col>ownership</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_accountrating">
+		<field name="accountratingid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="rating" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="accountrating_rating_idx">
+			<col>rating</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_accountregion">
+		<field name="accountregionid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="region" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="accountregion_region_idx">
+			<col>region</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_accounttype">
+		<field name="accounttypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="accounttype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="accounttype_accounttype_idx">
+			<col>accounttype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_contacttype">
+		<field name="contacttypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="contacttype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="contacttype_contacttype_idx">
+			<col>contacttype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_leadsource">
+		<field name="leadsourceid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="leadsource" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="leadsource_source_idx">
+			<col>source</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_opportunity_type">
+		<field name="opptypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="opportunity_type" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="opportunity_type_opportunity_type_idx">
+			<col>opportunity_type</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_leadstage">
+		<field name="leadstageid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="stage" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="leadstage_stage_idx">
+			<col>stage</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_leadstatus">
+		<field name="leadstatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="leadstatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="leadstatus_status_idx">
+			<col>status</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_eventstatus">
+		<field name="eventstatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="eventstatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="eventstatus_status_idx">
+			<col>status</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_duration_minutes">
+		<field name="minutesid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="duration_minutes" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="duration_minutes_status_idx">
+			<col>status</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_licencekeystatus">
+		<field name="licencekeystatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="licencekeystatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="licencekeystatus_status_idx">
+			<col>status</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_opportunitystage">
+		<field name="potstageid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="stage" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+		<field name="probability" type="N" size="3.2">
+			<default value="0" />
+		</field>
+
+		<index name="opportunitystage_stage_idx">
+			<col>stage</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_priority">
+		<field name="priorityid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="priority" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="priority_priority_idx">
+			<col>priority</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_businesstype">
+		<field name="businesstypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="businesstype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="businesstype_businesstype_idx">
+			<col>businesstype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_industry">
+		<field name="industryid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="industry" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="industry_industry_idx">
+			<col>industry</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_revenuetype">
+		<field name="revenuetypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="revenuetype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="revenuetype_revenuetype_idx">
+			<col>revenuetype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_salutationtype">
+		<field name="salutationid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="salutationtype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_taskpriority">
+		<field name="taskpriorityid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="taskpriority" type="C" size="100" />
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_taskstatus">
+		<field name="taskstatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="taskstatus" type="C" size="100" />
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_activitytype">
+		<field name="activitytypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="activitytype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="activitytype_activitytype_idx">
+			<col>activitytype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_usertype">
+		<field name="usertypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="usertype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="usertype_usertype_idx">
+			<col>usertype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_sales_stage">
+		<field name="sales_stage_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="sales_stage" type="C" size="200">
+		</field>
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_faqcategories">
+		<field name="faqcategories_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="faqcategories" type="C" size="60" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_faqstatus">
+		<field name="faqstatus_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="faqstatus" type="C" size="60" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_rating">
+		<field name="rating_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="rating" type="C" size="200" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_ticketcategories">
+		<field name="ticketcategories_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="ticketcategories" type="C" size="100" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_ticketpriorities">
+		<field name="ticketpriorities_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="ticketpriorities" type="C" size="100" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_ticketseverities">
+		<field name="ticketseverities_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="ticketseverities" type="C" size="100" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_ticketstatus">
+		<field name="ticketstatus_id" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="ticketstatus" type="C" size="60" />
+		<field name="SORTORDERID" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="PRESENCE" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_activsubtype">
+		<field name="activesubtypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="activsubtype" type="C" size="100" />
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_downloadpurpose">
+		<field name="downloadpurposeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="purpose" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="downloadpurpose_purpose_idx">
+			<col>purpose</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_durationhrs">
+		<field name="hrsid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="hrs" type="C" size="50" />
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_durationmins">
+		<field name="minsid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="mins" type="C" size="50" />
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+	</table>
+
+	<table name="vtiger_evaluationstatus">
+		<field name="evalstatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="status" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="evaluationstatus_status_idx">
+			<col>status</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_profile">
+		<field name="profileid" type="I" size="10">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="profilename" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="description" type="X" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_profile2globalpermissions">
+		<field name="profileid" type="I" size="19">
+			<key />
+		</field>
+		<field name="globalactionid" type="I" size="19">
+			<key />
+		</field>
+		<field name="globalactionpermission" type="I" size="19" />
+
+		<index name="idx_profile2globalpermissions">
+			<col>profileid</col>
+			<col>globalactionid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_profile2globalpermissions" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_profile2globalpermissions FOREIGN KEY (profileid) REFERENCES vtiger_profile(profileid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_profile2tab">
+		<field name="profileid" type="I" size="11" />
+		<field name="tabid" type="I" size="10" />
+		<field name="permissions" type="I" size="10">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="profile2tab_profileid_tabid_idx">
+			<col>profileid</col>
+			<col>tabid</col>
+		</index>
+	</table>
+
+	<table name="vtiger_profile2standardpermissions">
+		<field name="profileid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="10">
+			<key />
+		</field>
+		<field name="Operation" type="I" size="10">
+			<key />
+		</field>
+		<field name="permissions" type="I" size="1" />
+
+		<index name="profile2standardpermissions_profileid_tabid_Operation_idx">
+			<col>profileid</col>
+			<col>tabid</col>
+			<col>Operation</col>
+		</index>
+	</table>
+
+	<table name="vtiger_profile2field">
+		<field name="profileid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="10" />
+		<field name="fieldid" type="I" size="19">
+			<key />
+		</field>
+		<field name="visible" type="I" size="19" />
+		<field name="readonly" type="I" size="19" />
+
+		<index name="profile2field_profileid_tabid_fieldname_idx">
+			<col>profileid</col>
+			<col>tabid</col>
+			<col>fieldname</col>
+		</index>
+		<index name="profile2field_tabid_profileid_idx">
+			<col>tabid</col>
+			<col>profileid</col>
+		</index>
+		<index name="profile2field_visible_profileid_idx">
+			<col>visible</col>
+			<col>profileid</col>
+		</index>
+	</table>
+
+	<table name="vtiger_role2profile">
+		<field name="roleid" type="C" size="255">
+			<key />
+		</field>
+		<field name="profileid" type="I" size="11">
+			<key />
+		</field>
+		<index name="role2profile_roleid_profileid_idx">
+			<col>roleid</col>
+			<col>profileid</col>
+		</index>
+	</table>
+
+	<table name="vtiger_org_share_action_mapping">
+		<field name="share_action_id" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_action_name" type="C" size="200" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_def_org_share">
+		<field name="ruleid" type="I" size="11">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<notnull />
+		</field>
+		<field name="permission" type="I" size="19">
+		</field>
+		<field name="editstatus" type="I" size="19" />
+	</table>
+
+<table name="vtiger_def_org_share" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_def_org_share FOREIGN KEY (permission) REFERENCES vtiger_org_share_action_mapping(share_action_id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_def_org_field">
+		<field name="tabid" type="I" size="10" />
+		<field name="fieldid" type="I" size="19">
+			<key />
+		</field>
+		<field name="visible" type="I" size="19" />
+		<field name="readonly" type="I" size="19" />
+
+		<index name="def_org_field_tabid_fieldid_idx">
+			<col>tabid</col>
+			<col>fieldid</col>
+		</index>
+		<index name="def_org_field_tabid_idx">
+			<col>tabid</col>
+		</index>
+		<index name="def_org_field_visible_fieldid_idx">
+			<col>visible</col>
+			<col>fieldid</col>
+		</index>
+	</table>
+
+	<table name="vtiger_profile2utility">
+		<field name="profileid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="activityid" type="I" size="11">
+			<key />
+		</field>
+		<field name="permission" type="I" size="1" />
+
+		<index name="profile2utility_profileid_tabid_activityid_idx">
+			<col>profileid</col>
+			<col>tabid</col>
+			<col>activityid</col>
+		</index>
+	</table>
+
+	<table name="vtiger_productcategory">
+		<field name="productcategoryid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="productcategory" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="productcategory_productcategory_idx">
+			<col>productcategory</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_salesorder">
+		<field name="salesorderid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="subject" type="C" size="100" />
+		<field name="potentialid" type="I" size="19" />
+		<field name="customerno" type="C" size="100" />
+		<field name="quoteid" type="I" size="19" />
+		<field name="vendorterms" type="C" size="100" />
+		<field name="contactid" type="I" size="19">
+		</field>
+		<field name="vendorid" type="I" size="19">
+		</field>
+		<field name="duedate" type="D" />
+		<field name="carrier" type="C" size='100' />
+		<field name="pending" type="C" size='200' />
+		<field name="type" type="C" size="100" />
+		<field name="salestax" type="N" size="25.3" />
+		<field name="adjustment" type="N" size="25.3" />
+		<field name="salescommission" type="N" size="25.3" />
+		<field name="exciseduty" type="N" size="25.3" />
+		<field name="total" type="N" size="25.3" />
+		<field name="subtotal" type="N" size="25.3" />
+		<field name="taxtype" type="C" size="25" />
+		<field name="discount_percent" type="N" size="25.3" />
+		<field name="discount_amount" type="N" size="25.3" />
+		<field name="s_h_amount" type="N" size="25.3" />
+		<field name="accountid" type="I" size="19" />
+		<field name="terms_conditions" type="X" />
+		<field name="purchaseorder" type="C" size='200' />
+		<field name="sostatus" type="C" size='200' />
+		<field name="orgunitid" type="I" size="19" />
+
+		<index name="salesorder_vendorid_idx">
+			<col>vendorid</col>
+		</index>
+		<index name="salesorder_contactid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_salesorder" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_salesorder FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_salesorder FOREIGN KEY (salesorderid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_salesorder FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_sogrouprelation">
+		<field name="salesorderid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="sogrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_sogrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_sogrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_sogrouprelation FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_sobillads">
+		<field name="sobilladdressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="bill_city" type="C" size="30" />
+		<field name="bill_code" type="C" size="30" />
+		<field name="bill_country" type="C" size="30" />
+		<field name="bill_state" type="C" size="30" />
+		<field name="bill_street" type="C" size="250" />
+		<field name="bill_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_sobillads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_sobillads FOREIGN KEY (sobilladdressid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_soshipads">
+		<field name="soshipaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="ship_city" type="C" size="30" />
+		<field name="ship_code" type="C" size="30" />
+		<field name="ship_country" type="C" size="30" />
+		<field name="ship_state" type="C" size="30" />
+		<field name="ship_street" type="C" size="250" />
+		<field name="ship_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_soshipads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_soshipads FOREIGN KEY (soshipaddressid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_salesordercf">
+		<field name="salesorderid" type="I" size="19">
+			<key />
+			<default value="0"/>
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_salesordercf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_salesordercf FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+
+	<table name="vtiger_notificationscheduler">
+		<field name="schedulednotificationid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="schedulednotificationname" type="C" size="200" />
+		<field name="active" type="I" size="1" />
+		<field name="notificationsubject" type="C" size="200" />
+		<field name="notificationbody" type="X" />
+		<field name="label" type="C" size="50" />
+
+		<index name="notificationscheduler_schedulednotificationname_idx">
+			<col>schedulednotificationname</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_activityproductrel">
+		<field name="activityid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="productid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="activityproductrel_activityid_idx">
+			<col>activityid</col>
+		</index>
+		<index name="activityproductrel_productid_idx">
+			<col>productid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_activityproductrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_activityproductrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_activityproductrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_relatedlists">
+		<field name="relation_id" type="I" size="19">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="10" />
+		<field name="related_tabid" type="I" size="10" />
+		<field name="name" type="C" size="100" />
+		<field name="sequence" type="I" size="10" />
+		<field name="label" type="C" size="100" />
+		<field name="presence" type="I" size="10">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="relatedlists_relation_id_idx">
+			<col>relation_id</col>
+		</index>
+	</table>
+
+	<table name="vtiger_rss">
+		<field name="rssid" type="I" size="19">
+			<key />
+		</field>
+		<field name="rssurl" type="C" size="200">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="rsstitle" type="C" size="200" />
+		<field name="rsstype" type="I" size="10">
+			<default value="0" />
+		</field>
+		<field name="starred" type="I" size="1">
+			<default value="0" />
+		</field>
+	</table>
+
+	<table name="vtiger_vendorcf">
+		<field name="vendorid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_vendorcf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_vendorcf FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_pricebook">
+		<field name="pricebookid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="bookname" type="C" size="100" />
+		<field name="active" type="I" size="1" />
+		<field name="description" type="X" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_pricebook" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_pricebook FOREIGN KEY (pricebookid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_pricebookcf">
+		<field name="pricebookid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_pricebookcf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_pricebookcf FOREIGN KEY (pricebookid) REFERENCES vtiger_pricebook(pricebookid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_pricebookproductrel">
+		<field name="pricebookid" type="I" size="19">
+			<key />
+		</field>
+		<field name="productid" type="I" size="19">
+			<key />
+		</field>
+		<field name="listprice" type="N" size="25.3" />
+
+		<index name="pricebookproductrel_pricebookid_idx">
+			<col>pricebookid</col>
+		</index>
+		<index name="pricebookproductrel_productid_idx">
+			<col>productid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_pricebookproductrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_pricebookproductrel FOREIGN KEY (pricebookid) REFERENCES vtiger_pricebook(pricebookid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_pricebookproductrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_mail_accounts">
+		<field name="account_id" type="I" size="11">
+			<key />
+		</field>
+		<field name="user_id" type="I" size="11">
+			<notnull />
+		</field>
+		<field name="display_name" type="C" size="50" />
+		<field name="mail_id" type="C" size="50" />
+		<field name="account_name" type="C" size="50" />
+		<field name="mail_protocol" type="C" size="20" />
+		<field name="mail_username" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="mail_password" type="C" size="20">
+			<notnull />
+		</field>
+		<field name="mail_servername" type="C" size="50" />
+		<field name="box_refresh" type="I" size="10" />
+		<field name="mails_per_page" type="I" size="10" />
+		<field name="ssltype" type="C" size="50" />
+		<field name="sslmeth" type="C" size="50" />
+		<field name="int_mailer" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="status" type="C" size="10" />
+		<field name="set_default" type="I" size="2" />
+	</table>
+
+	<table name="vtiger_quotes">
+		<field name="quoteid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="subject" type="C" size="100" />
+		<field name="potentialid" type="I" size="19">
+		</field>
+		<field name="quotestage" type="C" size="200" />
+		<field name="validtill" type="D" />
+		<field name="team" type="C" size="200" />
+		<field name="contactid" type="I" size="19">
+		</field>
+		<field name="currency" type="C" size="100" />
+		<field name="subtotal" type="N" size="25.3" />
+		<field name="carrier" type="C" size='100' />
+		<field name="shipping" type="C" size="100" />
+		<field name="inventorymanager" type="I" size="19" />
+		<field name="type" type="C" size="100" />
+		<field name="tax" type="N" size="25.3" />
+		<field name="adjustment" type="N" size="25.3" />
+		<field name="total" type="N" size="25.3" />
+		<field name="taxtype" type="C" size="25" />
+		<field name="discount_percent" type="N" size="25.3" />
+		<field name="discount_amount" type="N" size="25.3" />
+		<field name="s_h_amount" type="N" size="25.3" />
+		<field name="accountid" type="I" size="19" />
+		<field name="terms_conditions" type="X" />
+		<field name="orgunitid" type="I" size="19" />
+
+		<index name="quote_quotestage_idx">
+			<col>quotestage</col>
+		</index>
+		<index name="quotes_potentialid_idx">
+			<col>potentialid</col>
+		</index>
+		<index name="quotes_contactid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_quotes" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_quotes FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_quotes FOREIGN KEY (quoteid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_quotes FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_quotesbillads">
+		<field name="quotebilladdressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="bill_city" type="C" size="30" />
+		<field name="bill_code" type="C" size="30" />
+		<field name="bill_country" type="C" size="30" />
+		<field name="bill_state" type="C" size="30" />
+		<field name="bill_street" type="C" size="250" />
+		<field name="bill_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_quotesbillads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_quotesbillads FOREIGN KEY (quotebilladdressid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_quotesshipads">
+		<field name="quoteshipaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="ship_city" type="C" size="30" />
+		<field name="ship_code" type="C" size="30" />
+		<field name="ship_country" type="C" size="30" />
+		<field name="ship_state" type="C" size="30" />
+		<field name="ship_street" type="C" size="250" />
+		<field name="ship_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_quotesshipads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_quotesshipads FOREIGN KEY (quoteshipaddressid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_quotegrouprelation">
+		<field name="quoteid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="quotegrouprelation_groupname_idx">
+			<col>groupname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_quotegrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_quotegrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_quotegrouprelation FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_quotescf">
+		<field name="quoteid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_quotescf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_quotescf FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_purchaseorder">
+		<field name="purchaseorderid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="subject" type="C" size="100" />
+		<field name="quoteid" type="I" size="19">
+		</field>
+		<field name="vendorid" type="I" size="19">
+		</field>
+		<field name="requisition_no" type="C" size="100" />
+		<field name="tracking_no" type="C" size="100" />
+		<field name="contactid" type="I" size="19">
+		</field>
+		<field name="duedate" type="D" />
+		<field name="carrier" type="C" size='100' />
+		<field name="type" type="C" size="100" />
+		<field name="salestax" type="N" size="25.3" />
+		<field name="adjustment" type="N" size="25.3" />
+		<field name="salescommission" type="N" size="25.3" />
+		<field name="exciseduty" type="N" size="25.3" />
+		<field name="total" type="N" size="25.3" />
+		<field name="subtotal" type="N" size="25.3" />
+		<field name="taxtype" type="C" size="25" />
+		<field name="discount_percent" type="N" size="25.3" />
+		<field name="discount_amount" type="N" size="25.3" />
+		<field name="s_h_amount" type="N" size="25.3" />
+		<field name="terms_conditions" type="X" />
+		<field name="postatus" type="C" size="200" />
+		<field name="orgunitid" type="I" size="19" />
+
+		<index name="purchaseorder_vendorid_idx">
+			<col>vendorid</col>
+		</index>
+		<index name="purchaseorder_quoteid_idx">
+			<col>quoteid</col>
+		</index>
+		<index name="purchaseorder_contactid_idx">
+			<col>contactid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_purchaseorder" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_purchaseorder FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_purchaseorder FOREIGN KEY (purchaseorderid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_purchaseorder FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_4_vtiger_purchaseorder FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_pogrouprelation">
+		<field name="purchaseorderid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="pogrouprelation_groupname_purchaseorderid_idx">
+			<col>groupname</col>
+			<col>purchaseorderid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_pogrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_pogrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_pogrouprelation FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_pobillads">
+		<field name="pobilladdressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="bill_city" type="C" size="30" />
+		<field name="bill_code" type="C" size="30" />
+		<field name="bill_country" type="C" size="30" />
+		<field name="bill_state" type="C" size="30" />
+		<field name="bill_street" type="C" size="250" />
+		<field name="bill_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_pobillads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_pobillads FOREIGN KEY (pobilladdressid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_poshipads">
+		<field name="poshipaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="ship_city" type="C" size="30" />
+		<field name="ship_code" type="C" size="30" />
+		<field name="ship_country" type="C" size="30" />
+		<field name="ship_state" type="C" size="30" />
+		<field name="ship_street" type="C" size="250" />
+		<field name="ship_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_poshipads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_poshipads FOREIGN KEY (poshipaddressid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_purchaseordercf">
+		<field name="purchaseorderid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_purchaseordercf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_purchaseordercf FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+
+	<table name="vtiger_invoice">
+		<field name="invoiceid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="subject" type="C" size="100" />
+		<field name="salesorderid" type="I" size="19">
+		</field>
+		<field name="customerno" type="C" size="100" />
+		<field name="contactid" type="I" size="19" />
+		<field name="notes" type="C" size="100" />
+		<field name="invoicedate" type="D" />
+		<field name="duedate" type="D" />
+		<field name="invoiceterms" type="C" size="100" />
+		<field name="type" type="C" size="100" />
+		<field name="salestax" type="N" size="25.3" />
+		<field name="adjustment" type="N" size="25.3" />
+		<field name="salescommission" type="N" size="25.3" />
+		<field name="exciseduty" type="N" size="25.3" />
+		<field name="subtotal" type="N" size="25.3" />
+		<field name="total" type="N" size="25.3" />
+		<field name="taxtype" type="C" size="25" />
+		<field name="discount_percent" type="N" size="25.3" />
+		<field name="discount_amount" type="N" size="25.3" />
+		<field name="s_h_amount" type="N" size="25.3" />
+		<field name="shipping" type="C" size="100" />
+		<field name="accountid" type="I" size="19" />
+		<field name="terms_conditions" type="X" />
+		<field name="purchaseorder" type="C" size='200' />
+		<field name="invoicestatus" type="C" size='200' />
+		<field name="invoice_no" type="C" size='100' >
+                        <default value="NULL" />
+                        <unique />
+                </field>
+		<field name="orgunitid" type="I" size="19" />
+
+		<index name="invoice_purchaseorderid_idx">
+			<col>invoiceid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_invoice" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_invoice FOREIGN KEY (invoiceid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_invoice FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_invoicegrouprelation">
+		<field name="invoiceid" type="I" size="19">
+			<key />
+		</field>
+		<field name="groupname" type="C" size="100">
+		</field>
+
+		<index name="invoicegrouprelation_groupname_invoiceid_idx">
+			<col>groupname</col>
+			<col>invoiceid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_invoicegrouprelation" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_invoicegrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_invoicegrouprelation FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_invoicebillads">
+		<field name="invoicebilladdressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="bill_city" type="C" size="30" />
+		<field name="bill_code" type="C" size="30" />
+		<field name="bill_country" type="C" size="30" />
+		<field name="bill_state" type="C" size="30" />
+		<field name="bill_street" type="C" size="250" />
+		<field name="bill_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_invoicebillads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_invoicebillads FOREIGN KEY (invoicebilladdressid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_invoiceshipads">
+		<field name="invoiceshipaddressid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="ship_city" type="C" size="30" />
+		<field name="ship_code" type="C" size="30" />
+		<field name="ship_country" type="C" size="30" />
+		<field name="ship_state" type="C" size="30" />
+		<field name="ship_street" type="C" size="250" />
+		<field name="ship_pobox" type="C" size="30" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_invoiceshipads" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_invoiceshipads FOREIGN KEY (invoiceshipaddressid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_invoicecf">
+		<field name="invoiceid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_invoicecf" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_invoicecf FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+
+	<table name="vtiger_activity_reminder">
+		<field name="activity_id" type="I" size="11">
+			<key />
+			<notnull />
+		</field>
+		<field name="reminder_time" type="I" size="11">
+			<notnull />
+		</field>
+		<field name="reminder_sent" type="I" size="2">
+			<notnull />
+		</field>
+		<field name="recurringid" type="I" size="19">
+			<key />
+			<notnull />
+		</field>
+	</table>
+
+	<table name="vtiger_customview">
+		<field name="cvid" type="I" size="19">
+			<key />
+		</field>
+		<field name="viewname" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="setdefault" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="setmetrics" type="I" size="1">
+			<default value="0" />
+		</field>
+		<field name="entitytype" type="C" size="25">
+			<notnull />
+		</field>
+		<index name="customview_entitytype_idx">
+			<col>entitytype</col>
+		</index>
+		
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_customview" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_customview FOREIGN KEY (entitytype) REFERENCES vtiger_tab (name) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_cvcolumnlist">
+		<field name="cvid" type="I" size="19">
+			<key />
+			<notnull />
+		</field>
+		<field name="columnindex" type="I" size="11">
+			<key />
+			<notnull />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<default value="" />
+		</field>
+
+		<index name="cvcolumnlist_columnindex_idx">
+			<col>columnindex</col>
+		</index>
+		<index name="cvcolumnlist_cvid_idx">
+			<col>cvid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_cvcolumnlist" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_cvcolumnlist FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_cvstdfilter">
+		<field name="cvid" type="I" size="19">
+			<key />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="stdfilter" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="startdate" type="D">
+			<default value="NULL" />
+		</field>
+		<field name="enddate" type="D">
+			<default value="NULL" />
+		</field>
+
+		<index name="cvstdfilter_cvid_idx">
+			<col>cvid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_cvstdfilter" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_cvstdfilter FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_cvadvfilter">
+		<field name="cvid" type="I" size="19">
+			<key />
+		</field>
+		<field name="columnindex" type="I" size="11">
+			<key />
+			<notnull />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="comparator" type="C" size="10">
+			<default value="" />
+		</field>
+		<field name="value" type="C" size="200">
+			<default value="" />
+		</field>
+
+		<index name="cvadvfilter_cvid_idx">
+			<col>cvid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_cvadvfilter" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_cvadvfilter FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_customaction">
+		<field name="cvid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="subject" type="C" size="250">
+			<notnull />
+		</field>
+		<field name="module" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="content" type="X">
+			<default value="" />
+		</field>
+
+		<index name="customaction_cvid_idx">
+			<col>cvid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_customaction" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_customaction FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_selectquery">
+		<field name="queryid" type="I" size="19">
+			<key />
+		</field>
+		<field name="startindex" type="I" size="19">
+			<default value="0" />
+		</field>
+		<field name="numofobjects" type="I" size="19">
+			<default value="0" />
+		</field>
+
+		<index name="selectquery_queryid_idx">
+			<col>queryid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_selectcolumn">
+		<field name="queryid" type="I" size="19">
+			<key />
+		</field>
+		<field name="columnindex" type="I" size="11">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<default value="" />
+		</field>
+
+		<index name="selectcolumn_queryid_idx">
+			<col>queryid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_selectcolumn" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_selectcolumn FOREIGN KEY (queryid) REFERENCES vtiger_selectquery (queryid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_relcriteria">
+		<field name="queryid" type="I" size="19">
+			<key />
+		</field>
+		<field name="columnindex" type="I" size="11">
+			<key />
+			<notnull />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="comparator" type="C" size="10">
+			<default value="" />
+		</field>
+		<field name="value" type="C" size="200">
+			<default value="" />
+		</field>
+
+		<index name="relcriteria_queryid_idx">
+			<col>queryid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_relcriteria" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_relcriteria FOREIGN KEY (queryid) REFERENCES vtiger_selectquery (queryid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_reportfolder">
+		<field name="folderid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="foldername" type="C" size="100">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="description" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="state" type="C" size="50">
+			<default value="SAVED" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_report">
+		<field name="reportid" type="I" size="19">
+			<key />
+		</field>
+		<field name="folderid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="reportname" type="C" size="100">
+			<default value="" />
+		</field>
+		<field name="description" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="reporttype" type="C" size="50">
+			<default value="" />
+		</field>
+		<field name="queryid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="state" type="C" size="50">
+			<default value="SAVED" />
+		</field>
+		<field name="customizable" type="I" size="1">
+			<default value="1" />
+		</field>
+		<field name="category" type="I" size="11">
+			<default value="1" />
+		</field>
+
+		<index name="report_queryid_idx">
+			<col>queryid</col>
+		</index>
+		<index name="report_folderid_idx">
+			<col>folderid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_report" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_report FOREIGN KEY (folderid) REFERENCES vtiger_reportfolder (folderid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_report FOREIGN KEY (queryid) REFERENCES vtiger_selectquery (queryid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_reportmodules">
+		<field name="reportmodulesid" type="I" size="19">
+			<key />
+		</field>
+		<field name="primarymodule" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="secondarymodules" type="C" size="250">
+			<default value="" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_reportmodules" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_reportmodules FOREIGN KEY (reportmodulesid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_reportsortcol">
+		<field name="sortcolid" type="I" size="19">
+			<key />
+		</field>
+		<field name="reportid" type="I" size="19">
+			<key />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="sortorder" type="C" size="250">
+			<default value="Asc" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_reportsortcol" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_reportsortcol FOREIGN KEY (reportid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_reportdatefilter">
+		<field name="datefilterid" type="I" size="19">
+			<key />
+		</field>
+		<field name="datecolumnname" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="datefilter" type="C" size="250">
+			<default value="" />
+		</field>
+		<field name="startdate" type="D">
+			<default value="NULL" />
+		</field>
+		<field name="enddate" type="D">
+			<default value="NULL" />
+		</field>
+
+		<index name="reportdatefilter_datefilterid_idx">
+			<col>datefilterid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_reportdatefilter" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_reportdatefilter FOREIGN KEY (datefilterid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_reportsummary">
+		<field name="reportsummaryid" type="I" size="19">
+			<key />
+		</field>
+		<field name="summarytype" type="I" size="19">
+			<key />
+		</field>
+		<field name="columnname" type="C" size="250">
+			<key />
+			<default value="" />
+		</field>
+
+		<index name="reportsummary_reportsummaryid_idx">
+			<col>reportsummaryid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_reportsummary" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_reportsummary FOREIGN KEY (reportsummaryid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_usageunit">
+		<field name="usageunitid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="usageunit" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="usageunit_usageunit_idx">
+			<col>usageunit</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_glacct">
+		<field name="glacctid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="glacct" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="glacct_glacct_idx">
+			<col>glacct</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_quotestage">
+		<field name="quotestageid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="quotestage" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="quotestage_quotestage_idx">
+			<col>quotestage</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_invoicestatus">
+		<field name="inovicestatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="invoicestatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="invoicestatus_invoiestatus_idx">
+			<col>invoicestatus</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_postatus">
+		<field name="postatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="postatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="postatus_postatus_idx">
+			<col>postatus</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_sostatus">
+		<field name="sostatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="sostatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="sostatus_sostatus_idx">
+			<col>sostatus</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+
+	</table>
+
+	<table name="vtiger_carrier">
+		<field name="carrierid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="carrier" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="carrier_carrier_idx">
+			<col>carrier</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_taxclass">
+		<field name="taxclassid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="taxclass" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="taxclass_carrier_idx">
+			<col>taxclass</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_organizationdetails">
+		<field name="organizationname" type="C" size="60">
+			<key />
+		</field>
+		<field name="address" type="C" size="150" />
+		<field name="city" type="C" size="100" />
+		<field name="state" type="C" size="100" />
+		<field name="country" type="C" size="100" />
+		<field name="code" type="C" size="30" />
+		<field name="phone" type="C" size="30" />
+		<field name="fax" type="C" size="30" />
+		<field name="website" type="C" size="100" />
+		<field name="logoname" type="C" size="50" />
+		<field name="logo" type="X" />
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="quote_template" type="C" size="30">
+			<default value="" />
+		</field>
+		<field name="so_template" type="C" size="30">
+			<default value="" />
+		</field>
+		<field name="po_template" type="C" size="30">
+			<default value="" />
+		</field>
+		<field name="invoice_template" type="C" size="30">
+			<default value="" />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_recurringtype">
+		<field name="recurringeventid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="recurringtype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="recurringtype_status_idx">
+			<col>recurringtype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_recurringevents">
+		<field name="recurringid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="activityid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="recurringdate" type="D" />
+		<field name="recurringtype" type="C" size="30" />
+		<field name="recurringfreq" type="I" size="19" />
+		<field name="recurringinfo" type="C" size="50" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_inventorynotification">
+		<field name="notificationid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="notificationname" type="C" size="200" />
+		<field name="notificationsubject" type="C" size="200" />
+		<field name="notificationbody" type="X" />
+		<field name="label" type="C" size="50" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_inventory_tandc">
+		<field name="id" type="I" size="19">
+			<key />
+		</field>
+		<field name="type" type="C" size="30">
+			<notnull />
+		</field>
+		<field name="tandc" type="X" />
+	</table>
+
+	<table name="vtiger_convertleadmapping">
+		<field name="cfmid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="leadfid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="accountfid" type="I" size="19" />
+		<field name="contactfid" type="I" size="19" />
+		<field name="potentialfid" type="I" size="19" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_actionmapping">
+		<field name="actionid" type="I" size="19">
+			<key />
+		</field>
+		<field name="actionname" type="C" size="200">
+			<key />
+		</field>
+		<field name="securitycheck" type="I" size="19" />
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_org_share_action2tab">
+		<field name="share_action_id" type="I" size="19">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="19">
+			<key />
+		</field>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_org_share_action2tab" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_org_share_action2tab FOREIGN KEY (share_action_id) REFERENCES vtiger_org_share_action_mapping(share_action_id) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_org_share_action2tab FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_moduleowners">
+		<field name="tabid" type="I" size="19">
+			<key />
+			<unique />
+			<default value="0" />
+		</field>
+		<field name="user_id" type="C" size="11">
+			<notnull />
+		</field>
+		<index name="moduleowners_tabid_user_id_idx">
+			<col>tabid</col>
+			<col>user_id</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_moduleowners" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_moduleowners FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_ownernotify">
+		<field name="crmid" type="I" size="19" />
+		<field name="smownerid" type="I" size="19" />
+		<field name="flag" type="I" size="3" />
+
+		<index name="ownernotify_crmid_flag_idx">
+			<col>crmid</col>
+			<col>flag</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_datashare_module_rel">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="relationtype" type="C" size="200">
+		</field>
+		<opt platform="mysql">Type=InnoDB</opt>
+		<index name="idx_datashare_module_rel_tabid">
+			<col>tabid</col>
+		</index>
+	</table>
+
+<table name="vtiger_datashare_module_rel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_module_rel FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_grp2grp">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_groupid" type="I" size="19">
+		</field>
+		<field name="to_groupid" type="I" size="19">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_grp2grp_share_groupid_idx">
+			<col>share_groupid</col>
+		</index>
+		<index name="datashare_grp2grp_to_groupid_idx">
+			<col>to_groupid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_grp2grp" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_grp2grp FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_grp2grp FOREIGN KEY (share_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_grp2grp FOREIGN KEY (to_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_grp2role">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_groupid" type="I" size="19">
+		</field>
+		<field name="to_roleid" type="C" size="255">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="idx_datashare_grp2role_share_groupid">
+			<col>share_groupid</col>
+		</index>
+		<index name="idx_datashare_grp2role_to_roleid">
+			<col>to_roleid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_grp2role" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_grp2role FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_grp2role FOREIGN KEY (share_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_grp2role FOREIGN KEY (to_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_grp2rs">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_groupid" type="I" size="19">
+		</field>
+		<field name="to_roleandsubid" type="C" size="255">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_grp2rs_share_groupid_idx">
+			<col>share_groupid</col>
+		</index>
+		<index name="datashare_grp2rs_to_roleandsubid_idx">
+			<col>to_roleandsubid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_grp2rs" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_grp2rs FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_grp2rs FOREIGN KEY (share_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_grp2rs FOREIGN KEY (to_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_role2group">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_roleid" type="C" size="255">
+		</field>
+		<field name="to_groupid" type="I" size="19">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="idx_datashare_role2group_share_roleid">
+			<col>share_roleid</col>
+		</index>
+		<index name="idx_datashare_role2group_to_groupid">
+			<col>to_groupid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_role2group" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_role2group FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_role2group FOREIGN KEY (to_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_role2group FOREIGN KEY (share_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_role2role">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_roleid" type="C" size="255">
+		</field>
+		<field name="to_roleid" type="C" size="255">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_role2role_share_roleid_idx">
+			<col>share_roleid</col>
+		</index>
+		<index name="datashare_role2role_to_roleid_idx">
+			<col>to_roleid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_role2role" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_role2role FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_role2role FOREIGN KEY (share_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_role2role FOREIGN KEY (to_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_role2rs">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_roleid" type="C" size="255">
+		</field>
+		<field name="to_roleandsubid" type="C" size="255">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_role2s_share_roleid_idx">
+			<col>share_roleid</col>
+		</index>
+		<index name="datashare_role2s_to_roleandsubid_idx">
+			<col>to_roleandsubid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_role2rs" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_role2rs FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_role2rs FOREIGN KEY (share_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_role2rs FOREIGN KEY (to_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_rs2grp">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_roleandsubid" type="C" size="255">
+		</field>
+		<field name="to_groupid" type="I" size="19">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_rs2grp_share_roleandsubid_idx">
+			<col>share_roleandsubid</col>
+		</index>
+		<index name="datashare_rs2grp_to_groupid_idx">
+			<col>to_groupid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_rs2grp" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_rs2grp FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_rs2grp FOREIGN KEY (to_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_rs2grp FOREIGN KEY (share_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_rs2role">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_roleandsubid" type="C" size="255">
+		</field>
+		<field name="to_roleid" type="C" size="255">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_rs2role_share_roleandsubid_idx">
+			<col>share_roleandsubid</col>
+		</index>
+		<index name="datashare_rs2role_to_roleid_idx">
+			<col>to_roleid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_rs2role" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_rs2role FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_rs2role FOREIGN KEY (share_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_rs2role FOREIGN KEY (to_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_rs2rs">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="share_roleandsubid" type="C" size="255">
+		</field>
+		<field name="to_roleandsubid" type="C" size="255">
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_rs2rs_share_roleandsubid_idx">
+			<col>share_roleandsubid</col>
+		</index>
+		<index name="idx_datashare_rs2rs_to_roleandsubid_idx">
+			<col>to_roleandsubid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_rs2rs" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_rs2rs FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_rs2rs FOREIGN KEY (share_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_rs2rs FOREIGN KEY (to_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_relatedmodules">
+		<field name="datashare_relatedmodule_id" type="I" size="19">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="19">
+		</field>
+		<field name="relatedto_tabid" type="I" size="19">
+		</field>
+		<index name="datashare_relatedmodules_tabid_idx">
+			<col>tabid</col>
+		</index>
+		<index name="datashare_relatedmodules_relatedto_tabid_idx">
+			<col>relatedto_tabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_datashare_relatedmodules" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_relatedmodules FOREIGN KEY (relatedto_tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_relatedmodules FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_datashare_relatedmodule_permission">
+		<field name="shareid" type="I" size="19">
+			<key />
+		</field>
+		<field name="datashare_relatedmodule_id" type="I" size="19">
+			<key />
+		</field>
+		<field name="permission" type="I" size="19" />
+
+		<index name="datashare_relatedmodule_permission_shareid_permissions_idx">
+			<col>shareid</col>
+			<col>permission</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_parenttab">
+		<field name="parenttabid" type="I" size="19">
+			<notnull />
+			<key />
+		</field>
+		<field name="parenttab_label" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="sequence" type="I" size="10">
+			<notnull />
+		</field>
+		<field name="visible" type="I" size="2">
+			<notnull />
+			<default value="0" />
+		</field>
+		<index name="parenttab_parenttabid_parenttabl_label_visible_idx">
+			<col>parenttabid</col>
+			<col>parenttab_label</col>
+			<col>visible</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_tmp_read_user_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="shareduserid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_read_user_sharing_per_userid_shareduserid_idx">
+			<col>userid</col>
+			<col>shareduserid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_read_user_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_user_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_user_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_user_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_read_group_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="sharedgroupid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_read_group_sharing_per_userid_sharedgroupid_idx">
+			<col>userid</col>
+			<col>sharedgroupid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_read_group_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_group_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_group_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_group_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_write_user_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="shareduserid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_write_user_sharing_per_userid_shareduserid_idx">
+			<col>userid</col>
+			<col>shareduserid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_write_user_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_user_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_user_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_user_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_write_group_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="sharedgroupid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_write_group_sharing_per_UK1">
+			<col>userid</col>
+			<col>sharedgroupid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_write_group_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_group_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_group_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_group_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_read_user_rel_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="relatedtabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="shareduserid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_read_user_rel_sharing_per_userid_shared_reltabid_idx">
+			<col>userid</col>
+			<col>shareduserid</col>
+			<col>relatedtabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_read_user_rel_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_read_group_rel_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="relatedtabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="sharedgroupid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_read_group_rel_sharing_per_userid_sharedgroupid_tabid">
+			<col>userid</col>
+			<col>sharedgroupid</col>
+			<col>tabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_read_group_rel_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_write_user_rel_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="relatedtabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="shareduserid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_write_user_rel_sharing_per_userid_sharduserid_tabid_idx">
+			<col>userid</col>
+			<col>shareduserid</col>
+			<col>tabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_write_user_rel_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_tmp_write_group_rel_sharing_per">
+		<field name="userid" type="I" size="11">
+			<key />
+		</field>
+		<field name="tabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="relatedtabid" type="I" size="11">
+			<key />
+		</field>
+		<field name="sharedgroupid" type="I" size="11">
+			<key />
+		</field>
+
+		<index name="tmp_write_group_rel_sharing_per_userid_sharedgroupid_tabid_idx">
+			<col>userid</col>
+			<col>sharedgroupid</col>
+			<col>tabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_tmp_write_group_rel_sharing_per" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_parenttabrel">
+		<field name="parenttabid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="tabid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="sequence" type="I" size="3">
+			<notnull />
+		</field>
+
+		<index name="parenttabrel_tabid_parenttabid_idx">
+			<col>tabid</col>
+			<col>parenttabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_parenttabrel" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_parenttabrel FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_parenttabrel" alter="true">
+		<constraint>ADD CONSTRAINT fk_2_vtiger_parenttabrel FOREIGN KEY (parenttabid) REFERENCES vtiger_parenttab(parenttabid) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_campaigntype">
+		<field name="campaigntypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="campaigntype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="campaigntype_campaigntype_idx">
+			<col>campaigntype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_campaignstatus">
+		<field name="campaignstatusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="campaignstatus" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="campaignstatus_campaignstatus_idx">
+			<col>campaignstatus</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_expectedresponse">
+		<field name="expectedresponseid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="expectedresponse" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="CampaignExpRes_UK01">
+			<col>expectedresponse</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_portal">
+		<field name="portalid" type="I" size="19">
+			<key />
+		</field>
+		<field name="portalname" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="portalurl" type="C" size="255">
+			<notnull />
+		</field>
+		<field name="sequence" type="I" size="3">
+			<notnull />
+		</field>
+
+		<index name="portal_portalname_idx">
+			<col>portalname</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_announcement">
+		<field name="creatorid" type="I" size="19">
+			<key />
+		</field>
+		<field name="announcement" type="X" />
+		<field name="title" type="C" size="255" />
+		<field name="time" type="T">
+			<deftimestamp />
+		</field>
+
+		<index name="announcement_creatorid_idx">
+			<col>creatorid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_chat_users">
+		<field name="id" type="I" size="20">
+			<autoincrement />
+			<notnull />
+			<key />
+		</field>
+		<field name="nick" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="session" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="ip" type="C" size="20">
+			<default value="000.000.000.000" />
+			<notnull />
+		</field>
+		<field name="ping" type="T">
+			<default value="NULL" />
+		</field>
+
+		<index name="chat_users_nick_idx">
+			<col>nick</col>
+		</index>
+		<index name="chat_users_session_idx">
+			<col>session</col>
+		</index>
+		<index name="chat_users_ping_idx">
+			<col>ping</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_chat_msg">
+		<field name="id" type="I" size="20">
+			<autoincrement />
+			<notnull />
+			<key />
+		</field>
+		<field name="chat_from" type="I" size="20">
+			<default value="0" />
+			<notnull />
+		</field>
+		<field name="chat_to" type="I" size="20">
+			<default value="0" />
+			<notnull />
+		</field>
+		<field name="born" type="T">
+			<default value="NULL" />
+		</field>
+		<field name="msg" type="C" size="255">
+			<notnull />
+		</field>
+
+		<index name="chat_msg_chat_from_idx">
+			<col>chat_from</col>
+		</index>
+		<index name="chat_msg_chat_to_idx">
+			<col>chat_to</col>
+		</index>
+		<index name="chat_msg_born_idx">
+			<col>born</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_chat_msg" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_chat_msg FOREIGN KEY (chat_from) REFERENCES vtiger_chat_users(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_chat_pchat">
+		<field name="id" type="I" size="20">
+			<autoincrement />
+			<notnull />
+			<key />
+		</field>
+		<field name="msg" type="I" size="20">
+			<default value="0"/>
+		</field>
+
+		<index name="chat_pchat_msg_idx">
+			<col>msg</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_chat_pchat" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_chat_pchat FOREIGN KEY (msg) REFERENCES vtiger_chat_msg(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_chat_pvchat">
+		<field name="id" type="I" size="20">
+			<autoincrement />
+			<notnull />
+			<key />
+		</field>
+		<field name="msg" type="I" size="20">
+			<default value="0"/>
+		</field>
+		<index name="chat_pvchat_msg_idx">
+			<col>msg</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_chat_pvchat" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_chat_pvchat FOREIGN KEY (msg) REFERENCES vtiger_chat_msg(id) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_freetags">
+		<field name="id" type="I" size="19">
+			<notnull />
+			<key />
+		</field>
+		<field name="tag" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="raw_tag" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+	</table>
+
+	<table name="vtiger_freetagged_objects">
+		<field name="tag_id" type="I" size="20">
+			<notnull />
+			<default value="0" />
+			<key />
+		</field>
+		<field name="tagger_id" type="I" size="20">
+			<notnull />
+			<default value="0" />
+			<key />
+		</field>
+		<field name="object_id" type="I" size="20">
+			<notnull />
+			<default value="0" />
+			<key />
+		</field>
+		<field name="tagged_on" type="T">
+			<deftimestamp />
+			<notnull />
+		</field>
+		<field name="module" type="C" size="50">
+			<default value="" />
+			<notnull />
+		</field>
+
+		<index name="freetagged_objects_tag_id_tagger_id_object_id_idx">
+			<col>tag_id</col>
+			<col>tagger_id</col>
+			<col>object_id</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_emaildetails">
+		<field name="emailid" type="I" size="19">
+			<notnull />
+			<key />
+		</field>
+		<field name="from_email" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="to_email" type="X">
+			<notnull />
+		</field>
+		<field name="cc_email" type="X">
+			<notnull />
+		</field>
+		<field name="bcc_email" type="X">
+			<notnull />
+		</field>
+		<field name="assigned_user_email" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="idlists" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+		<field name="email_flag" type="C" size="50">
+			<notnull />
+			<default value="" />
+		</field>
+	</table>
+
+	<table name="vtiger_invitees">
+		<field name="activityid" type="I" size="19">
+			<KEY/>
+		</field>
+		<field name="inviteeid" type="I" size="19">
+			<KEY/>
+		</field>
+	</table>
+
+	<table name="vtiger_inventorytaxinfo">
+		<field name="taxid" type="I" size="3">
+			<KEY/>
+			<notnull />
+		</field>
+		<field name="taxname" type="C" size="50">
+		</field>
+		<field name="taxlabel" type="C" size="50">
+		</field>
+		<field name="percentage" type="N" size="7.3">
+		</field>
+		<field name="deleted" type="I" size="1" />
+
+		<index name="inventorytaxinfo_taxname_idx">
+			<col>taxname</col>
+		</index>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_producttaxrel">
+		<field name="productid" type="I" size="11">
+			<notnull />
+		</field>
+		<field name="taxid" type="I" size="3">
+			<notnull />
+		</field>
+		<field name="taxpercentage" type="N" size="7.3">
+		</field>
+
+		<index name="producttaxrel_productid_idx">
+			<col>productid</col>
+		</index>
+		<index name="producttaxrel_taxid_idx">
+			<col>taxid</col>
+		</index>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_producttaxrel" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_producttaxrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_status">
+		<field name="statusid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="status" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="vtiger_status_status_idx">
+			<col>source</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_activity_view">
+		<field name="activity_viewid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="activity_view" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="vtiger_activity_view_status_idx">
+			<col>source</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_lead_view">
+		<field name="lead_viewid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="lead_view" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="vtiger_lead_viewstatus_idx">
+			<col>source</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_date_format">
+		<field name="date_formatid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="date_format" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="vtiger_date_format_status_idx">
+			<col>source</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_postatushistory">
+		<field name="historyid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="purchaseorderid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="vendorname" type="C" size="100" />
+		<field name="total" type="N" />
+		<field name="postatus" type="C" size="200" />
+		<field name="lastmodified" type="T" />
+
+		<index name="postatushistory_purchaseorderid_idx">
+			<col>purchaseorderid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_postatushistory" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_postatushistory FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_sostatushistory">
+		<field name="historyid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="salesorderid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="accountname" type="C" size="100" />
+		<field name="total" type="N" />
+		<field name="sostatus" type="C" size="200" />
+		<field name="lastmodified" type="T" />
+
+		<index name="sostatushistory_salesorderid_idx">
+			<col>salesorderid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_sostatushistory" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_sostatushistory FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_quotestagehistory">
+		<field name="historyid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="quoteid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="accountname" type="C" size="100" />
+		<field name="total" type="N" />
+		<field name="quotestage" type="C" size="200" />
+		<field name="lastmodified" type="T" />
+
+		<index name="quotestagehistory_quoteid_idx">
+			<col>quoteid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_quotestagehistory" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_quotestagehistory FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_invoicestatushistory">
+		<field name="historyid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="invoiceid" type="I" size="19">
+			<notnull />
+		</field>
+		<field name="accountname" type="C" size="100" />
+		<field name="total" type="N" />
+		<field name="invoicestatus" type="C" size="200" />
+		<field name="lastmodified" type="T" />
+
+		<index name="invoicestatushistory_invoiceid_idx">
+			<col>invoiceid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+<table name="vtiger_invoicestatushistory" alter="true">
+<constraint>ADD CONSTRAINT fk_1_vtiger_invoicestatushistory FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
+<opt>Type=InnoDB</opt>
+<data>
+</data>
+</table>
+
+	<table name="vtiger_audit_trial">
+		<field name="auditid" type="I" size="19">
+			<key />
+		</field>
+		<field name="userid" type="I" size="19" />
+		<field name="module" type="C" size="255" />
+		<field name="action" type="C" size="255" />
+		<field name="recordid" type="C" size="20" />
+		<field name="actiondate" type="T"/>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_inventoryproductrel">
+		<field name="id" type="I" size="19" />
+		<field name="productid" type="I" size="19" />
+		<field name="sequence_no" type="I" size="4" />
+		<field name="quantity" type="I" size="19" />
+		<field name="listprice" type="N" size="25.3" />
+		<field name="discount_percent" type="N" size="7.3" />
+		<field name="discount_amount" type="N" size="7.3" />
+		<field name="comment" type="C" size="250" />
+		<field name="description" type="X" />
+
+		<index name="inventoryproductrel_id_idx">
+			<col>id</col>
+		</index>
+		<index name="inventoryproductrel_productid_idx">
+			<col>productid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_shippingtaxinfo">
+		<field name="taxid" type="I" size="3">
+			<KEY/>
+			<notnull />
+		</field>
+		<field name="taxname" type="C" size="50">
+		</field>
+		<field name="taxlabel" type="C" size="50">
+		</field>
+		<field name="percentage" type="N" size="7.3">
+		</field>
+		<field name="deleted" type="I" size="1" />
+
+		<index name="shippingtaxinfo_taxname_idx">
+			<col>taxname</col>
+		</index>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_inventoryshippingrel">
+		<field name="id" type="I" size="19" />
+
+		<index name="inventoryishippingrel_id_idx">
+			<col>id</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_salesmanattachmentsrel">
+		<field name="smid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="attachmentsid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+
+		<index name="salesmanattachmentsrel_smid_idx">
+			<col>smid</col>
+		</index>
+		<index name="salesmanattachmentsrel_attachmentsid_idx">
+			<col>attachmentsid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_salesmanattachmentsrel" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_salesmanattachmentsrel FOREIGN KEY (smid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+		<constraint>ADD CONSTRAINT fk_2_vtiger_salesmanattachmentsrel FOREIGN KEY (attachmentsid) REFERENCES vtiger_attachments(attachmentsid) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_entityname">
+		<field name="tabid" type="I" size="19">
+			<key />
+			<default value="0" />
+		</field>
+		<field name="modulename" type="C" size="50">
+			<notnull />
+		</field>
+		<field name="tablename" type="C" size="100">
+			<notnull />
+		</field>
+		<field name="fieldname" type="C" size="150">
+			<notnull />
+		</field>
+		<field name="entityidfield" type="C" size="150">
+			<notnull />
+		</field>
+		<field name="entityidcolumn" type="C" size="150">
+			<notnull />
+		</field>
+		<index name="entityname_tabid_idx">
+			<col>tabid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_entityname" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_entityname FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
+		<opt>Type=InnoDB</opt>
+		<data>
+		</data>
+	</table>
+
+	<table name="vtiger_version">
+		<field name="id" type="I" size="11">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="old_version" type="C" size="30" />
+		<field name="current_version" type="C" size="30" />
+	</table>
+
+	<table name="vtiger_orgunit">
+		<field name="orgunitid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="organizationname" type="C" size="60">
+			<notnull />
+		</field>
+		<field name="type" type="C" size="30" />
+		<field name="name" type="C" size="60">
+			<notnull />
+		</field>
+		<field name="address" type="C" size="150" />
+		<field name="city" type="C" size="100" />
+		<field name="state" type="C" size="100" />
+		<field name="country" type="C" size="100" />
+		<field name="code" type="C" size="30" />
+		<field name="phone" type="C" size="30" />
+		<field name="fax" type="C" size="30" />
+		<field name="website" type="C" size="100" />
+		<field name="deleted" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="quote_template" type="C" size="30">
+			<default value="" />
+		</field>
+		<field name="so_template" type="C" size="30">
+			<default value="" />
+		</field>
+		<field name="po_template" type="C" size="30">
+			<default value="" />
+		</field>
+		<field name="invoice_template" type="C" size="30">
+			<default value="" />
+		</field>
+
+		<index name="vtiger_orgunit_name_idx">
+			<col>organizationname</col>
+			<col>name</col>
+			<unique />
+		</index>
+		<index name="vtiger_orgunit_type_idx">
+			<col>organizationname</col>
+			<col>type</col>
+		</index>
+
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_orgunit" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_orgunit FOREIGN KEY (organizationname) REFERENCES vtiger_organizationdetails(organizationname) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
+		<opt platform="mysql">Type=InnoDB</opt>
 	</table>
 
-	<table name="vtiger_crmentity">
-		<field name="crmid" type="I" size="19">
-			<key />
-		</field>
-		<field name="smcreatorid" type="I" size="19">
-			<notnull/>
-			<default value="0" />
-		</field>
-		<field name="smownerid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="modifiedby" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="setype" type="C" size="30">
-			<notnull />
-		</field>
-		<field name="description" type="X" />
-		<field name="createdtime" type="T">
-			<notnull />
-		</field>
-		<field name="modifiedtime" type="T">
-			<notnull />
-		</field>
-		<field name="viewedtime" type="T" />
-		<field name="status" type="C" size="50" />
-		<field name="version" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<default value="1" />
-		</field>
+	<table name="vtiger_orgunittype">
+		<field name="orgunittypeid" type="I" size="19">
+			<key />
+			<autoincrement />
+		</field>
+		<field name="orgunittype" type="C" size="200">
+			<notnull />
+		</field>
+		<field name="sortorderid" type="I" size="19">
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="presence" type="I" size="1">
+			<notnull />
+			<default value="1" />
+		</field>
+
+		<index name="vtiger_orgunittype_orgunittype_idx">
+			<col>orgunittype</col>
+			<unique />
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
 
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
+	<table name="vtiger_user2org">
+		<field name="organizationname" type="C" size="60">
+			<key />
+			<notnull />
+		</field>
+		<field name="userid" type="I" size="19">
+			<key />
+			<notnull />
+			<default value="0" />
+		</field>
+		<field name="primarytag" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="vtiger_user2org_organizationname_idx">
+			<col>organizationname</col>
+		</index>
+		<index name="vtiger_user2org_userid_idx">
+			<col>userid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_user2org" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_user2org FOREIGN KEY (organizationname) REFERENCES vtiger_organizationdetails(organizationname) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
+		<constraint>ADD CONSTRAINT fk_2_vtiger_user2org FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
 
-		<index name="crmentity_smcreatorid_idx">
-			<col>smcreatorid</col>
-		</index>
-		<index name="crmentity_smownerid_idx">
-			<col>smownerid</col>
-		</index>
-		<index name="crmentity_modifiedby_idx">
-			<col>modifiedby</col>
-		</index>
-		<index name="crmentity_deleted_smownerid_idx">
-			<col>deleted</col>
-			<col>smownerid</col>
-		</index>
-		<index name="crmentity_smownerid_deleted_idx">
-			<col>smownerid</col>
-			<col>deleted</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_sharedcalendar">
-		<field name="userid" type="I" size="19">
-			<key />
-		</field>
-		<field name="sharedid" type="I" size="19">
-			<key />
-		</field>
-	</table>
-
-	<table name="vtiger_tab">
-		<field name="tabid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="name" type="C" size="25">
-			<notnull />
-		</field>
-		<field name="presence" type="I" size="19">
-			<notnull />
-			<default value="1" />
-		</field>
-		<field name="tabsequence" type="I" size="10" />
-		<field name="tablabel" type="C" size="25">
-			<notnull />
-		</field>
-		<field name="modifiedby" type="I" size="19" />
-		<field name="modifiedtime" type="I" size="19" />
-		<field name="customized" type="I" size="1" />
-
-		<index name="tab_name_idx">
-			<col>name</col>
-			<unique />
-		</index>
-		<index name="tab_modifiedby_idx">
-			<col>modifiedby</col>
-		</index>
-		<index name="tab_tabid_idx">
-			<col>tabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_blocks">
-		<field name="blockid" type="I" size="19">
-			<key />
-			<notnull />
-		</field>
-		<field name="tabid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="blocklabel" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="sequence" type="I" size="10" />
-		<field name="show_title" type="I" size="2" />
-		<field name="visible" type="I" size="2">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="create_view" type="I" size="2">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="edit_view" type="I" size="2">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="detail_view" type="I" size="2">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="block_tabid_idx">
-			<col>tabid</col>
-		</index>
-	</table>
-
-	<table name="vtiger_field">
-		<field name="tabid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="fieldid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="columnname" type="C" size="30">
-			<notnull />
-		</field>
-		<field name="tablename" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="generatedtype" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="uitype" type="C" size="30">
-			<notnull />
-		</field>
-		<field name="fieldname" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="fieldlabel" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="readonly" type="I" size="1">
-			<notnull />
-		</field>
-		<field name="presence" type="I" size="19">
-			<notnull />
-			<default value="1" />
-		</field>
-		<field name="selected" type="I" size="1">
-			<notnull />
-		</field>
-		<field name="maximumlength" type="I" size="19" />
-		<field name="sequence" type="I" size="19" />
-		<field name="block" type="I" size="19" />
-		<field name="displaytype" type="I" size="19" />
-		<field name="typeofdata" type="C" size="100" />
-		<field name="typeofdata" type="C" size="100" />
-		<field name="quickcreate" type="I" size="10">
-			<notnull />
-			<default value="1" />
-		</field>
-		<field name="quickcreatesequence" type="I" size="19" />
-		<field name="info_type" type="C" size="20" />
-
-		<index name="field_tabid_idx">
-			<col>tabid</col>
-		</index>
-		<index name="field_fieldname_idx">
-			<col>fieldname</col>
-		</index>
-		<index name="field_block_idx">
-			<col>block</col>
-		</index>
-		<index name="field_displaytype_idx">
-			<col>displaytype</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_field" alter="true">
-	<constraint>ADD CONSTRAINT fk_1_vtiger_field FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-	<opt>Type=InnoDB</opt>
-	<data>
-	</data>
-</table>
-
-	<table name="vtiger_account">
-		<field name="accountid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="accountname" type="C" size="100">
-			<unique />
-			<notnull />
-		</field>
-		<field name="parentid" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="account_type" type="C" size="50" />
-		<field name="industry" type="C" size="50" />
-		<field name="annualrevenue" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="rating" type="C" size="50" />
-		<field name="ownership" type="C" size="50" />
-		<field name="siccode" type="C" size="50" />
-		<field name="tickersymbol" type="C" size="30" />
-		<field name="phone" type="C" size="30" />
-		<field name="otherphone" type="C" size="30" />
-		<field name="email1" type="C" size="100" />
-		<field name="email2" type="C" size="100" />
-		<field name="website" type="C" size="100" />
-		<field name="fax" type="C" size="30" />
-		<field name="employees" type="I" size="10">
-			<default value="0" />
-		</field>
-		<field name="emailoptout" type="C" size="3">
-			<default value="0" />
-		</field>
-		<field name="notify_owner" type="C" size="3">
-			<default value="0" />
-		</field>
-
-		<index name="account_account_type_idx">
-			<col>account_type</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_account" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_account FOREIGN KEY (accountid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_accountbillads">
-		<field name="accountaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="city" type="C" size="30" />
-		<field name="code" type="C" size="30" />
-		<field name="country" type="C" size="30" />
-		<field name="state" type="C" size="30" />
-		<field name="street" type="C" size="250" />
-		<field name="pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_accountbillads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_accountbillads FOREIGN KEY (accountaddressid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_accountshipads">
-		<field name="accountaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="city" type="C" size="30" />
-		<field name="code" type="C" size="30" />
-		<field name="country" type="C" size="30" />
-		<field name="state" type="C" size="30" />
-		<field name="pobox" type="C" size="30" />
-		<field name="street" type="C" size="250" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_accountshipads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_accountshipads FOREIGN KEY (accountaddressid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_accountscf">
-		<field name="accountid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_accountscf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_accountscf FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_contactdetails">
-		<field name="contactid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="accountid" type="I" size="19" />
-		<field name="salutation" type="C" size="50">
-			<default value="Mr" />
-		</field>
-		<field name="firstname" type="C" size="40" />
-		<field name="lastname" type="C" size="80">
-			<notnull />
-		</field>
-		<field name="email" type="C" size="100" />
-		<field name="phone" type="C" size="50" />
-		<field name="mobile" type="C" size="50" />
-		<field name="title" type="C" size="50" />
-		<field name="department" type="C" size="30" />
-		<field name="fax" type="C" size="50" />
-		<field name="reportsto" type="C" size="30" />
-		<field name="training" type="C" size="50" />
-		<field name="usertype" type="C" size="50" />
-		<field name="contacttype" type="C" size="50" />
-		<field name="otheremail" type="C" size="100" />
-		<field name="yahooid" type="C" size="100" />
-		<field name="donotcall" type="C" size="3" />
-		<field name="emailoptout" type="C" size="3">
-			<default value="0" />
-		</field>
-		<field name="currency" type="C" size="20">
-			<default value="Dollars" />
-		</field>
-		<field name="imagename" type="C" size="150" />
-		<field name="reference" type="C" size="3" />
-		<field name="notify_owner" type="C" size="3">
-			<default value="0"/>
-		</field>
-
-		<index name="contactdetails_accountid_idx">
-			<col>accountid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_contactdetails" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_contactdetails FOREIGN KEY (contactid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_contactsubdetails">
-		<field name="contactsubscriptionid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="homephone" type="C" size="50" />
-		<field name="otherphone" type="C" size="50" />
-		<field name="assistant" type="C" size="30" />
-		<field name="assistantphone" type="C" size="50" />
-		<field name="birthday" type="D" />
-		<field name="laststayintouchrequest" type="I" size="30">
-			<default value="0" />
-		</field>
-		<field name="laststayintouchsavedate" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="leadsource" type="C" size="50" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_contactsubdetails" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_contactsubdetails FOREIGN KEY (contactsubscriptionid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_contactaddress">
-		<field name="contactaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="mailingcity" type="C" size="40" />
-		<field name="mailingstreet" type="C" size="250" />
-		<field name="mailingcountry" type="C" size="40" />
-		<field name="othercountry" type="C" size="30" />
-		<field name="mailingstate" type="C" size="30" />
-		<field name="mailingpobox" type="C" size="30" />
-		<field name="othercity" type="C" size="40" />
-		<field name="otherstate" type="C" size="50" />
-		<field name="mailingzip" type="C" size="30" />
-		<field name="otherzip" type="C" size="30" />
-		<field name="otherstreet" type="C" size="250" />
-		<field name="otherpobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_contactaddress" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_contactaddress FOREIGN KEY (contactaddressid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_contactscf">
-		<field name="contactid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_contactscf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_contactscf FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_portalinfo">
-		<field name="id" type="I" size="11">
-			<key />
-		</field>
-		<field name="user_name" type="C" size="50" />
-		<field name="user_password" type="C" size="30" />
-		<field name="type" type="C" size="5" />
-		<field name="last_login_time" type="T">
-			<notnull />
-		</field>
-		<field name="login_time" type="T">
-			<notnull />
-		</field>
-		<field name="logout_time" type="T">
-			<notnull />
-		</field>
-		<field name="isactive" type="I" size="1" />
-	</table>
-
-<table name="vtiger_portalinfo" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_portalinfo FOREIGN KEY (id) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_customerdetails">
-		<field name="customerid" type="I" size="19">
-			<key />
-		</field>
-		<field name="portal" type="C" size="3" />
-		<field name="support_start_date" type="D" />
-		<field name="support_end_date" type="D" />
-	</table>
-
-<table name="vtiger_customerdetails" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_customerdetails FOREIGN KEY (customerid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leaddetails">
-		<field name="leadid" type="I" size="19">
-			<key />
-		</field>
-		<field name="email" type="C" size="100" />
-		<field name="interest" type="C" size="50" />
-		<field name="firstname" type="C" size="40" />
-		<field name="salutation" type="C" size="10" />
-		<field name="lastname" type="C" size="80">
-			<notnull />
-		</field>
-		<field name="company" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="annualrevenue" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="industry" type="C" size="50" />
-		<field name="campaign" type="C" size="30" />
-		<field name="rating" type="C" size="50" />
-		<field name="leadstatus" type="C" size="50" />
-		<field name="leadsource" type="C" size="50" />
-		<field name="converted" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="designation" type="C" size="50">
-			<default value="SalesMan" />
-		</field>
-		<field name="licencekeystatus" type="C" size="50" />
-		<field name="space" type="C" size="250" />
-		<field name="comments" type="X" />
-		<field name="priority" type="C" size="50" />
-		<field name="demorequest" type="C" size="50" />
-		<field name="partnercontact" type="C" size="50" />
-		<field name="productversion" type="C" size="20" />
-		<field name="product" type="C" size="50" />
-		<field name="maildate" type="D" />
-		<field name="nextstepdate" type="D" />
-		<field name="fundingsituation" type="C" size="50" />
-		<field name="purpose" type="C" size="50" />
-		<field name="evaluationstatus" type="C" size="50" />
-		<field name="transferdate" type="D" />
-		<field name="revenuetype" type="C" size="50" />
-		<field name="noofemployees" type="C" size="50" />
-		<field name="yahooid" type="C" size="100" />
-		<field name="assignleadchk" type="I" size="1">
-			<default value="0" />
-		</field>
-
-		<index name="leaddetails_converted_leadstatus_idx">
-			<col>converted</col>
-			<col>leadstatus</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leaddetails" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leaddetails FOREIGN KEY (leadid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leadsubdetails">
-		<field name="leadsubscriptionid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="currency" type="C" size="20">
-			<default value="Dollars" />
-		</field>
-		<field name="website" type="C" size="255" />
-		<field name="callornot" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="readornot" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="empct" type="I" size="10">
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadsubdetails" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadsubdetails FOREIGN KEY (leadsubscriptionid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leadaddress">
-		<field name="leadaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="city" type="C" size="30" />
-		<field name="code" type="C" size="30" />
-		<field name="state" type="C" size="30" />
-		<field name="pobox" type="C" size="30" />
-		<field name="country" type="C" size="30" />
-		<field name="phone" type="C" size="50" />
-		<field name="mobile" type="C" size="50" />
-		<field name="fax" type="C" size="50" />
-		<field name="lane" type="C" size="250" />
-		<field name="leadaddresstype" type="C" size="30">
-			<default value="Billing" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadaddress" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadaddress FOREIGN KEY (leadaddressid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leadscf">
-		<field name="leadid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadscf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadscf FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_notes">
-		<field name="notesid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="contact_id" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="title" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="filename" type="C" size="50" />
-		<field name="notecontent" type="X" />
-
-		<index name="notes_title_idx">
-			<col>title</col>
-		</index>
-		<index name="notes_notesid_idx">
-			<col>notesid</col>
-		</index>
-		<index name="notes_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_notes" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_notes FOREIGN KEY (notesid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_potential">
-		<field name="potentialid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="accountid" type="I" size="19" />
-		<field name="potentialname" type="C" size="120">
-			<notnull />
-		</field>
-		<field name="amount" type="N" size="10.2">
-			<default value="0" />
-		</field>
-		<field name="currency" type="C" size="20" />
-		<field name="closingdate" type="D" />
-		<field name="typeofrevenue" type="C" size="50" />
-		<field name="nextstep" type="C" size="100" />
-		<field name="private" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="probability" type="N" size="7.3">
-			<default value="0" />
-		</field>
-		<field name="campaignid" type="I" size="19" />
-		<field name="sales_stage" type="C" size="50" />
-		<field name="potentialtype" type="C" size="50" />
-		<field name="leadsource" type="C" size="50" />
-		<field name="productid" type="I" size="50" />
-		<field name="productversion" type="C" size="50" />
-		<field name="quotationref" type="C" size="50" />
-		<field name="partnercontact" type="C" size="50" />
-		<field name="remarks" type="C" size="50" />
-		<field name="runtimefee" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="followupdate" type="D" />
-		<field name="evaluationstatus" type="C" size="50" />
-		<field name="description" type="X" />
-		<field name="forecastcategory" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="outcomeanalysis" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="orgunitid" type="I" size="19" />
-
-		<index name="potential_accountid_idx">
-			<col>accountid</col>
-		</index>
-		<index name="potential_potentialid_idx">
-			<col>potentialid</col>
-		</index>
-		<index name="potentail_sales_stage_idx">
-			<col>sales_stage</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_potential" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_potential FOREIGN KEY (potentialid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_potstagehistory">
-		<field name="historyid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="potentialid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="amount" type="N" />
-		<field name="stage" type="C" size="100" />
-		<field name="probability" type="N" size="7.3" />
-		<field name="expectedrevenue" type="N" />
-		<field name="closedate" type="D" />
-		<field name="lastmodified" type="T" />
-
-		<index name="potstagehistory_potentialid_idx">
-			<col>potentialid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_potstagehistory" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_potstagehistory FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_potentialscf">
-		<field name="potentialid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_potentialscf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_potentialscf FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_activity">
-		<field name="activityid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="subject" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="semodule" type="C" size="20" />
-		<field name="activitytype" type="C" size="50">
-			<notnull />
-		</field>
-
-		<field name="date_start" type="D">
-			<notnull />
-		</field>
-		<field name="due_date" type="D" />
-		<field name="time_start" type="C" size="50" />
-		<field name="time_end" type="C" size="50" />
-		<field name="sendnotification" type="C" size="3">
-			<notnull />
-			<default value="0"/>
-		</field>
-		<field name="duration_hours" type="C" size="2" />
-		<field name="duration_minutes" type="C" size="2" />
-		<field name="status" type="C" size="100" />
-		<field name="eventstatus" type="C" size="100" />
-		<field name="priority" type="C" size="150" />
-		<field name="location" type="C" size="150" />
-		<field name="notime" type="C" size="3">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="visibility" type="C" size="50">
-			<notnull />
-			<default value="all" />
-		</field>
-
-		<index name="activity_activityid_subject_idx">
-			<col>activityid</col>
-			<col>subject</col>
-		</index>
-		<index name="activity_activitytype_date_start_idx">
-			<col>activitytype</col>
-			<col>date_start</col>
-		</index>
-		<index name="activity_date_start_due_date_idx">
-			<col>date_start</col>
-			<col>due_date</col>
-		</index>
-		<index name="activity_date_start_time_start_idx">
-			<col>date_start</col>
-			<col>time_start</col>
-		</index>
-		<index name="activity_eventstatus_idx">
-			<col>eventstatus</col>
-		</index>
-		<index name="activity_status_eventstatus_idx">
-			<col>status</col>
-			<col>eventstatus</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_activity" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_activity FOREIGN KEY (activityid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_attachments">
-		<field name="attachmentsid" type="I" size="19">
-			<key />
-		</field>
-		<field name="name" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="description" type="C" size="100" />
-		<field name="type" type="C" size="100" />
-		<field name="path" type="C" size="255" />
-		<index name="attachments_attachmentsid_idx">
-			<col>attachmentsid</col>
-		</index>
-		<index name="attachments_description_name_type_attachmentsid_idx">
-			<col>description</col>
-			<col>name</col>
-			<col>type</col>
-			<col>attachmentsid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_attachments" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_attachments FOREIGN KEY (attachmentsid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_seattachmentsrel">
-		<field name="crmid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="attachmentsid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="seattachmentsrel_attachmentsid_idx">
-			<col>attachmentsid</col>
-		</index>
-		<index name="seattachmentsrel_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<index name="seattachmentsrel_attachmentsid_crmid_idx">
-			<col>attachmentsid</col>
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_seattachmentsrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_seattachmentsrel FOREIGN KEY (attachmentsid) REFERENCES vtiger_attachments(attachmentsid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_seattachmentsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tracker">
-		<field name="id" type="I" size="11">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="user_id" type="C" size="36" />
-		<field name="module_name" type="C" size="25" />
-		<field name="item_id" type="C" size="36" />
-		<field name="item_summary" type="C" size="255" />
-	</table>
-
-	<table name="vtiger_competitor">
-		<field name="competitorid" type="I" size="19">
-			<key />
-		</field>
-		<field name="competitorname" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="website" type="C" size="100" />
-		<field name="strength" type="C" size="250" />
-		<field name="weakness" type="C" size="250" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_competitor" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_competitor FOREIGN KEY (competitorid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_potcompetitorrel">
-		<field name="potentialid" type="I" size="19">
-			<key />
-		</field>
-		<field name="competitorid" type="I" size="19">
-			<key />
-		</field>
-
-		<index name="potcompetitorrel_potentialid_idx">
-			<col>potentialid</col>
-		</index>
-		<index name="potcompetitorrel_competitorid_idx">
-			<col>competitorid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_potcompetitorrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_potcompetitorrel FOREIGN KEY (competitorid) REFERENCES vtiger_competitor(competitorid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_potcompetitorrel FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_vendor">
-		<field name="vendorid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="vendorname" type="C" size="100" />
-		<field name="phone" type="C" size="100" />
-		<field name="email" type="C" size="100" />
-		<field name="website" type="C" size="100" />
-		<field name="glacct" type="C" size="50" />
-		<field name="category" type="C" size="50" />
-		<field name="street" type="X" />
-		<field name="city" type="C" size="30" />
-		<field name="state" type="C" size="30" />
-		<field name="pobox" type="C" size="30" />
-		<field name="postalcode" type="C" size="100" />
-		<field name="country" type="C" size="100" />
-		<field name="description" type="X" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_vendor" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_vendor FOREIGN KEY (vendorid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_products">
-		<field name="productid" type="I" size="11">
-			<key />
-		</field>
-		<field name="productname" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="productcode" type="C" size="40" />
-		<field name="productcategory" type="C" size="40" />
-		<field name="manufacturer" type="C" size="40" />
-		<field name="product_description" type="X" />
-		<field name="qty_per_unit" type="N" size="11.2">
-			<default value="0" />
-		</field>
-		<field name="unit_price" type="N" size="11.2" />
-		<field name="weight" type="N" size="11.3" />
-		<field name="pack_size" type="I" size="11" />
-		<field name="sales_start_date" type="D" />
-		<field name="sales_end_date" type="D" />
-		<field name="start_date" type="D" />
-		<field name="expiry_date" type="D" />
-		<field name="cost_factor" type="I" size="11" />
-		<field name="commissionrate" type="N" size="7.3" />
-		<field name="commissionmethod" type="C" size="50" />
-		<field name="discontinued" type="I" size="1" />
-		<field name="usageunit" type="C" size="200" />
-		<field name="handler" type="I" size="11" />
-		<field name="contactid" type="I" size="11" />
-		<field name="currency" type="C" size="200" />
-		<field name="reorderlevel" type="I" size="11" />
-		<field name="website" type="C" size="100" />
-		<field name="taxclass" type="C" size="200" />
-		<field name="mfr_part_no" type="C" size="200" />
-		<field name="vendor_part_no" type="C" size="200" />
-		<field name="serialno" type="C" size="200" />
-		<field name="qtyinstock" type="I" size="11" />
-		<field name="productsheet" type="C" size="200" />
-		<field name="qtyindemand" type="I" size="11" />
-		<field name="glacct" type="C" size="200" />
-		<field name="vendor_id" type="I" size="11" />
-		<field name="imagename" type="X" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_products" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_products FOREIGN KEY (productid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_currency">
-		<field name="currencyid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="currency" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="currency_currency_idx">
-			<unique />
-			<col>currency</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_visibility">
-		<field name="visibilityid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="visibility" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0"/>
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1"/>
-		</field>
-
-		<index name="visibility_visibility_idx">
-			<col>visibility</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_manufacturer">
-		<field name="manufacturerid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="manufacturer" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="manufacturer_manufacturer_idx">
-			<unique />
-			<col>manufacturer</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_productcollaterals">
-		<field name="productid" type="I" size="11">
-			<key />
-		</field>
-		<field name="date_entered" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="data" type="B">
-			<notnull />
-		</field>
-		<field name="description" type="X" />
-		<field name="filename" type="C" size="50" />
-		<field name="filesize" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="filetype" type="C" size="20">
-			<notnull />
-		</field>
-
-		<index name="productcollaterals_productid_filename_idx">
-			<col>productid</col>
-			<col>filename</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_productcollaterals" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_productcollaterals FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_role">
-		<field name="roleid" type="C" size="255">
-			<key />
-		</field>
-		<field name="rolename" type="C" size="200" />
-		<field name="parentrole" type="C" size="255" />
-		<field name="depth" type="I" size="19" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_user2role">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="roleid" type="C" size="255">
-			<notnull />
-		</field>
-
-		<index name="user2role_roleid_idx">
-			<col>roleid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_user2role" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_user2role FOREIGN KEY (roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_user2role FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_groups">
-		<field name="groupid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100" />
-		<field name="description" type="X" />
-
-		<index name="groups_groupname_idx">
-			<col>groupname</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_users2group">
-		<field name="groupid" type="I" size="19">
-			<key />
-		</field>
-		<field name="userid" type="I" size="19">
-			<key />
-		</field>
-
-		<index name="users2group_groupname_uerid_idx">
-			<col>groupid</col>
-			<col>userid</col>
-		</index>
-	</table>
-
-<table name="vtiger_users2group" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_users2group FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_users2group FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_group2grouprel">
-		<field name="groupid" type="I" size="19">
-			<key />
-		</field>
-		<field name="containsgroupid" type="I" size="19">
-			<key />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_group2grouprel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_group2grouprel FOREIGN KEY (containsgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_group2grouprel FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_group2role">
-		<field name="groupid" type="I" size="19">
-			<key />
-		</field>
-		<field name="roleid" type="C" size="255">
-			<key />
-		</field>
-	</table>
-
-<table name="vtiger_group2role" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_group2role FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_group2role FOREIGN KEY (roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_group2rs">
-		<field name="groupid" type="I" size="19">
-			<key />
-		</field>
-		<field name="roleandsubid" type="C" size="255">
-			<key />
-		</field>
-	</table>
-
-<table name="vtiger_group2rs" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_group2rs FOREIGN KEY (groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_group2rs FOREIGN KEY (roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leadpotrel">
-		<field name="leadid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="potentialid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="leadpotrel_leadid_idx">
-			<col>leadid</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadpotrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadpotrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_leadpotrel FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_campaign">
-		<field name="campaignname" type="C" size="255" />
-		<field name="campaigntype" type="C" size="255" />
-		<field name="campaignstatus" type="C" size="255" />
-		<field name="expectedrevenue" type="N" size="11.3" />
-		<field name="budgetcost" type="N" size="11.3" />
-		<field name="actualcost" type="N" size="11.3" />
-		<field name="expectedresponse" type="C" size="255" />
-		<field name="numsent" type="N" size="11.0" />
-		<field name="product_id" type="I" size="19" />
-		<field name="sponsor" type="C" size="255" />
-		<field name="targetaudience" type="C" size="255" />
-		<field name="targetsize" type="I" size="19" />
-		<field name="expectedresponsecount" type="I" size="19" />
-		<field name="expectedsalescount" type="I" size="19" />
-		<field name="expectedroi" type="N" size="11.3" />
-		<field name="actualresponsecount" type="I" size="19" />
-		<field name="actualsalescount" type="I" size="19" />
-		<field name="actualroi" type="N" size="11.3" />
-		<field name="campaignid" type="I" size="19">
-			<key />
-		</field>
-		<field name="closingdate" type="D" />
-
-		<index name="campaign_campaignstatus_idx">
-			<col>campaignstatus</col>
-		</index>
-		<index name="campaign_campaignname_idx">
-			<col>campaignname</col>
-		</index>
-		<index name="campaign_campaignid_idx">
-			<col>campaignid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_campaignscf">
-		<field name="campaignid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_campaignscf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_campaignscf FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_campaigncontrel">
-		<field name="campaignid" type="I" size="19">
-			<key />
-			<default value="0"/>
-		</field>
-		<field name="contactid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0"/>
-		</field>
-
-		<index name="campaigncontrel_contractid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_campaigncontrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_campaigncontrel FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_campaigncontrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_campaignleadrel">
-		<field name="campaignid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="leadid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="campaignleadrel_leadid_campaignid_idx">
-			<col>leadid</col>
-			<col>campaignid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_campaignleadrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_campaignleadrel FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_campaignleadrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leadcontrel">
-		<field name="leadid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="contactid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="leadcontrel_contactid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadcontrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadcontrel FOREIGN KEY (leadcontrel_contactid_idx) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_leadcontrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_leadacctrel">
-		<field name="leadid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="accountid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="leadacctrel_accountid_idx">
-			<col>accountid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadacctrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadacctrel FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_leadacctrel FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_contpotentialrel">
-		<field name="contactid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="potentialid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="contpotentialrel_potentialid_idx">
-			<col>potentialid</col>
-		</index>
-		<index name="contpotentialrel_contactid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_contpotentialrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_contpotentialrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_contpotentialrel FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_dealintimation">
-		<field name="dealintimationid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="dealname" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="intimationamount" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<field name="dealprobability" type="N" size="3.2">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="dealintimationactive" type="I" size="1" />
-		<field name="fromname" type="C" size="120">
-			<notnull />
-		</field>
-		<field name="fromemailid" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="notifyemails" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="notifybccemails" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="notifyccmails" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="notifypotentialowner" type="I" size="1" />
-
-		<index name="dealintimation_dealname_idx">
-			<col>dealname</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_cntactivityrel">
-		<field name="contactid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="activityid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="cntactivityrel_contactid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_cntactivityrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_cntactivityrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_cntactivityrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_lar">
-		<field name="larid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="name" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="createdby" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="createdon" type="D">
-			<notnull />
-		</field>
-
-		<index name="lar_name_idx">
-			<col>name</col>
-			<unique />
-		</index>
-		<index name="lar_createdby_idx">
-			<col>createdby</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_lar" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_lar FOREIGN KEY (createdby) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_crmentitynotesrel">
-		<field name="crmid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="notesid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="crmentitynotesrel_notesid_idx">
-			<col>notesid</col>
-		</index>
-		<index name="crmentitynotesrel_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_crmentitynotesrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_crmentitynotesrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_crmentitynotesrel FOREIGN KEY (notesid) REFERENCES vtiger_notes(notesid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_troubletickets">
-		<field name="ticketid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100" />
-		<field name="parent_id" type="C" size="100" />
-		<field name="product_id" type="C" size="100" />
-		<field name="priority" type="C" size="150" />
-		<field name="severity" type="C" size="150" />
-		<field name="status" type="C" size="150" />
-		<field name="category" type="C" size="150" />
-		<field name="title" type="C" size="255">
-			<notnull />
-		</field>
-		<field name="filename" type="C" size="50" />
-		<field name="description" type="X" />
-		<field name="solution" type="X" />
-		<field name="update_log" type="X" />
-		<field name="version_id" type="I" size="11" />
-
-		<index name="troubletickets_ticketid_idx">
-			<col>ticketid</col>
-		</index>
-		<index name="troubletickets_status_idx">
-			<col>status</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_troubletickets" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_troubletickets FOREIGN KEY (ticketid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_ticketcomments">
-		<field name="commentid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="ticketid" type="I" size="19">
-		</field>
-		<field name="comments" type="X" />
-		<field name="ownerid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="ownertype" type="C" size="10" />
-		<field name="createdtime" type="T" >
-			<notnull />
-		</field>
-
-		<index name="ticketcomments_ticketid_idx">
-			<col>ticketid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_ticketcomments" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_ticketcomments FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_salesmanactivityrel">
-		<field name="smid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="activityid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="salesmanactivityrel_activityid_idx">
-			<col>activityid</col>
-		</index>
-		<index name="salesmanactivityrel_smid_idx">
-			<col>smid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_salesmanactivityrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_salesmanactivityrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_salesmanactivityrel FOREIGN KEY (smid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_vendorcontactrel">
-		<field name="vendorid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="contactid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="vendorcontactrel_vendorid_idx">
-			<col>vendorid</col>
-		</index>
-		<index name="vendorcontactrel_contact_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_vendorcontactrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_vendorcontactrel FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_vendorcontactrel FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_salesmanticketrel">
-		<field name="smid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="id" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="salesmanticketrel_smid_idx">
-			<col>smid</col>
-		</index>
-		<index name="salesmanticketrel_id_idx">
-			<col>id</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_salesmanticketrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_salesmanticketrel FOREIGN KEY (id) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_salesmanticketrel FOREIGN KEY (smid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_seactivityrel">
-		<field name="crmid" type="I" size="19">
-			<key />
-		</field>
-		<field name="activityid" type="I" size="19">
-			<key />
-		</field>
-
-		<index name="seactivityrel_activityid_idx">
-			<col>activityid</col>
-		</index>
-		<index name="seactivityrel_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_seactivityrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_seactivityrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_seactivityrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_seproductsrel">
-		<field name="crmid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="productid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="seproductsrel_productid_idx">
-			<col>productid</col>
-		</index>
-		<index name="seproductrel_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_seproductsrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_seproductsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_seproductsrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_seticketsrel">
-		<field name="crmid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="ticketid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="seticketsrel_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<index name="seticketsrel_ticketid_idx">
-			<col>ticketid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_seticketsrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_seticketsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_seticketsrel FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_headers">
-		<field name="fileid" type="I" size="3">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="headernames" type="C" size="30">
-			<notnull />
-		</field>
-	</table>
-
-	<table name="vtiger_import_maps">
-		<field name="id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="name" type="C" size="36">
-			<notnull />
-		</field>
-		<field name="module" type="C" size="36">
-			<notnull />
-		</field>
-		<field name="content" type="B" />
-		<field name="has_header" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="date_entered" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="date_modified" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="assigned_user_id" type="C" size="36" />
-		<field name="is_published" type="C" size="3">
-			<notnull />
-			<default value="no" />
-		</field>
-
-		<index name="import_maps_assigned_user_id_module_name_deleted_idx">
-			<col>assigned_user_id</col>
-			<col>module</col>
-			<col>name</col>
-			<col>deleted</col>
-		</index>
-	</table>
-
-	<table name="vtiger_leadgrouprelation">
-		<field name="leadid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="leadgrouprelation_leadid_idx">
-			<col>leadid</col>
-		</index>
-		<index name="leadgrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_leadgrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_leadgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_leadgrouprelation FOREIGN KEY (leadid) REFERENCES vtiger_leaddetails(leadid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_accountgrouprelation">
-		<field name="accountid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="accountgrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_accountgrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_accountgrouprelation FOREIGN KEY (accountid) REFERENCES vtiger_account(accountid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_accountgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_contactgrouprelation">
-		<field name="contactid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="contactgrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_contactgrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_contactgrouprelation FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_contactgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_potentialgrouprelation">
-		<field name="potentialid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="potentialgrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_potentialgrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_potentialgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_potentialgrouprelation FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_campaigngrouprelation">
-		<field name="campaignid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="campaigngrouprelation_IDX1">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_campaigngrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_campaigngrouprelation FOREIGN KEY (campaignid) REFERENCES vtiger_campaign(campaignid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_campaigngrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_activitygrouprelation">
-		<field name="activityid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="activitygrouprelation_activityid_idx">
-			<col>activityid</col>
-		</index>
-		<index name="activitygrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_activitygrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_activitygrouprelation FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_activitygrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_ticketgrouprelation">
-		<field name="ticketid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="ticketgrouprelation_ticketid_idx">
-			<col>ticketid</col>
-		</index>
-		<index name="ticketgrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_ticketgrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_ticketgrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_ticketgrouprelation FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_systems">
-		<field name="id" type="I" size="19">
-			<key />
-		</field>
-		<field name="server" type="C" size="30" />
-		<field name="server_port" type="I" size="19" />
-		<field name="server_username" type="C" size="30" />
-		<field name="server_password" type="C" size="30" />
-		<field name="server_type" type="C" size="20" />
-		<field name="smtp_auth" type="C" size="5" />
-	</table>
-
-	<table name="vtiger_currency_info">
-		<field name="id" type="I" >
-			<key />
-			<autoincrement />
-
-		</field>
-		<field name="currency_name" type="C" size="100" />
-		<field name="currency_code" type="C" size="100" />
-		<field name="currency_symbol" type="C" size="30" />
-		<field name="conversion_rate" type="N" size="10.3" />
-		<field name="currency_status" type="C" size="25" />
-		<field name="defaultid" type="C" size="10">
-			<notnull />
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_defaultcv">
-		<field name="tabid" type="I" size="19">
-			<key />
-		</field>
-		<field name="defaultviewname" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="query" type="X" />
-	</table>
-
-<table name="vtiger_defaultcv" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_defaultcv FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_emailtemplates">
-		<field name="foldername" type="C" size="100" />
-		<field name="templatename" type="C" size="100" />
-		<field name="subject" type="C" size="100" />
-		<field name="description" type="X" />
-		<field name="body" type="X" />
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="templateid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-
-		<index name="emailtemplates_foldernamd_templatename_subject_idx">
-			<col>foldername</col>
-			<col>templatename</col>
-			<col>subject</col>
-		</index>
-	</table>
-
-	<table name="vtiger_faq">
-		<field name="id" type="I" size="11">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="product_id" type="C" size="100" />
-		<field name="question" type="X">
-			<notnull />
-		</field>
-		<field name="answer" type="X" />
-		<field name="category" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="status" type="C" size="100">
-			<notnull />
-		</field>
-
-		<index name="faq_id_idx">
-			<col>id</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_faq" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_faq FOREIGN KEY (id) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_faqcomments">
-		<field name="commentid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="faqid" type="I" size="19">
-		</field>
-		<field name="comments" type="X" />
-		<field name="createdtime" type="T">
-			<notnull />
-		</field>
-
-		<index name="faqcomments_faqid_idx">
-			<col>faqid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_faqcomments" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_faqcomments FOREIGN KEY (faqid) REFERENCES vtiger_faq(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_files">
-		<field name="id" type="C" size="36">
-			<key />
-		</field>
-		<field name="name" type="C" size="36" />
-		<field name="content" type="B" />
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="date_entered" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="assigned_user_id" type="C" size="36" />
-
-		<index name="files_assigned_user_id_name_deleted_idx">
-			<col>assigned_user_id</col>
-			<col>name</col>
-			<col>deleted</col>
-		</index>
-	</table>
-
-	<table name="vtiger_loginhistory">
-		<field name="login_id" type="I" size="11">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="user_name" type="C" size="25">
-			<notnull />
-		</field>
-		<field name="user_ip" type="C" size="25">
-			<notnull />
-		</field>
-		<field name="logout_time" type="T">
-			<deftimestamp />
-		</field>
-		<field name="login_time" type="T">
-			<deftimestamp />
-		</field>
-		<field name="status" type="C" size="25" />
-	</table>
-
-	<table name="vtiger_senotesrel">
-		<field name="crmid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="notesid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="senotesrel_notesid_idx">
-			<col>notesid</col>
-		</index>
-		<index name="senotesrel_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_senotesrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_senotesrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_senotesrel FOREIGN KEY (notesid) REFERENCES vtiger_notes(notesid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_ticketstracktime">
-		<field name="ticket_id" type="I" size="11">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="supporter_id" type="I" size="11">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="minutes" type="I" size="11">
-			<default value="0" />
-		</field>
-		<field name="date_logged" type="I" size="11">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="ticketstracktime_ticket_id_idx">
-			<col>ticket_id</col>
-		</index>
-	</table>
-
-	<table name="vtiger_ticketcf">
-		<field name="ticketid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_ticketcf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_ticketcf FOREIGN KEY (ticketid) REFERENCES vtiger_troubletickets(ticketid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_productcf">
-		<field name="productid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_productcf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_productcf FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_users_last_import">
-		<field name="id" type="I" size="36">
-			<autoincrement />
-			<key />
-		</field>
-		<field name="assigned_user_id" type="C" size="36" />
-		<field name="bean_type" type="C" size="36" />
-		<field name="bean_id" type="C" size="36" />
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="idx_user_id">
-			<col>assigned_user_id</col>
-		</index>
-	</table>
-
-	<table name="vtiger_wordtemplates">
-		<field name="templateid" type="I" size="19">
-			<key />
-		</field>
-		<field name="filename" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="module" type="C" size="30">
-			<notnull />
-		</field>
-		<field name="date_entered" type="T">
-			<notnull />
-			<deftimestamp />
-		</field>
-		<field name="parent_type" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="data" type="B">
-			<notnull />
-		</field>
-		<field name="description" type="X" />
-		<field name="filesize" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="filetype" type="C" size="20">
-			<notnull />
-		</field>
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_accountdepstatus">
-		<field name="deploymentstatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="deploymentstatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="accountdepstatus_deploymentstatus_idx">
-			<col>deploymentstatus</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_accountownership">
-		<field name="acctownershipid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="ownership" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="accountownership_ownership_idx">
-			<col>ownership</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_accountrating">
-		<field name="accountratingid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="rating" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="accountrating_rating_idx">
-			<col>rating</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_accountregion">
-		<field name="accountregionid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="region" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="accountregion_region_idx">
-			<col>region</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_accounttype">
-		<field name="accounttypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="accounttype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="accounttype_accounttype_idx">
-			<col>accounttype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_contacttype">
-		<field name="contacttypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="contacttype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="contacttype_contacttype_idx">
-			<col>contacttype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_leadsource">
-		<field name="leadsourceid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="leadsource" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="leadsource_source_idx">
-			<col>source</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_opportunity_type">
-		<field name="opptypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="opportunity_type" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="opportunity_type_opportunity_type_idx">
-			<col>opportunity_type</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_leadstage">
-		<field name="leadstageid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="stage" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="leadstage_stage_idx">
-			<col>stage</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_leadstatus">
-		<field name="leadstatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="leadstatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="leadstatus_status_idx">
-			<col>status</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_eventstatus">
-		<field name="eventstatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="eventstatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="eventstatus_status_idx">
-			<col>status</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_duration_minutes">
-		<field name="minutesid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="duration_minutes" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="duration_minutes_status_idx">
-			<col>status</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_licencekeystatus">
-		<field name="licencekeystatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="licencekeystatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="licencekeystatus_status_idx">
-			<col>status</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_opportunitystage">
-		<field name="potstageid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="stage" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-		<field name="probability" type="N" size="3.2">
-			<default value="0" />
-		</field>
-
-		<index name="opportunitystage_stage_idx">
-			<col>stage</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_priority">
-		<field name="priorityid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="priority" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="priority_priority_idx">
-			<col>priority</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_businesstype">
-		<field name="businesstypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="businesstype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="businesstype_businesstype_idx">
-			<col>businesstype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_industry">
-		<field name="industryid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="industry" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="industry_industry_idx">
-			<col>industry</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_revenuetype">
-		<field name="revenuetypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="revenuetype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="revenuetype_revenuetype_idx">
-			<col>revenuetype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_salutationtype">
-		<field name="salutationid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="salutationtype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_taskpriority">
-		<field name="taskpriorityid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="taskpriority" type="C" size="100" />
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_taskstatus">
-		<field name="taskstatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="taskstatus" type="C" size="100" />
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_activitytype">
-		<field name="activitytypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="activitytype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="activitytype_activitytype_idx">
-			<col>activitytype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_usertype">
-		<field name="usertypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="usertype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="usertype_usertype_idx">
-			<col>usertype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_sales_stage">
-		<field name="sales_stage_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="sales_stage" type="C" size="200">
-		</field>
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_faqcategories">
-		<field name="faqcategories_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="faqcategories" type="C" size="60" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_faqstatus">
-		<field name="faqstatus_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="faqstatus" type="C" size="60" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_rating">
-		<field name="rating_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="rating" type="C" size="200" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_ticketcategories">
-		<field name="ticketcategories_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="ticketcategories" type="C" size="100" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_ticketpriorities">
-		<field name="ticketpriorities_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="ticketpriorities" type="C" size="100" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_ticketseverities">
-		<field name="ticketseverities_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="ticketseverities" type="C" size="100" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_ticketstatus">
-		<field name="ticketstatus_id" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="ticketstatus" type="C" size="60" />
-		<field name="SORTORDERID" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="PRESENCE" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_activsubtype">
-		<field name="activesubtypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="activsubtype" type="C" size="100" />
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_downloadpurpose">
-		<field name="downloadpurposeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="purpose" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="downloadpurpose_purpose_idx">
-			<col>purpose</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_durationhrs">
-		<field name="hrsid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="hrs" type="C" size="50" />
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_durationmins">
-		<field name="minsid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="mins" type="C" size="50" />
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-	</table>
-
-	<table name="vtiger_evaluationstatus">
-		<field name="evalstatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="status" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="evaluationstatus_status_idx">
-			<col>status</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_profile">
-		<field name="profileid" type="I" size="10">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="profilename" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="description" type="X" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_profile2globalpermissions">
-		<field name="profileid" type="I" size="19">
-			<key />
-		</field>
-		<field name="globalactionid" type="I" size="19">
-			<key />
-		</field>
-		<field name="globalactionpermission" type="I" size="19" />
-
-		<index name="idx_profile2globalpermissions">
-			<col>profileid</col>
-			<col>globalactionid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_profile2globalpermissions" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_profile2globalpermissions FOREIGN KEY (profileid) REFERENCES vtiger_profile(profileid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_profile2tab">
-		<field name="profileid" type="I" size="11" />
-		<field name="tabid" type="I" size="10" />
-		<field name="permissions" type="I" size="10">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="profile2tab_profileid_tabid_idx">
-			<col>profileid</col>
-			<col>tabid</col>
-		</index>
-	</table>
-
-	<table name="vtiger_profile2standardpermissions">
-		<field name="profileid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="10">
-			<key />
-		</field>
-		<field name="Operation" type="I" size="10">
-			<key />
-		</field>
-		<field name="permissions" type="I" size="1" />
-
-		<index name="profile2standardpermissions_profileid_tabid_Operation_idx">
-			<col>profileid</col>
-			<col>tabid</col>
-			<col>Operation</col>
-		</index>
-	</table>
-
-	<table name="vtiger_profile2field">
-		<field name="profileid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="10" />
-		<field name="fieldid" type="I" size="19">
-			<key />
-		</field>
-		<field name="visible" type="I" size="19" />
-		<field name="readonly" type="I" size="19" />
-
-		<index name="profile2field_profileid_tabid_fieldname_idx">
-			<col>profileid</col>
-			<col>tabid</col>
-			<col>fieldname</col>
-		</index>
-		<index name="profile2field_tabid_profileid_idx">
-			<col>tabid</col>
-			<col>profileid</col>
-		</index>
-		<index name="profile2field_visible_profileid_idx">
-			<col>visible</col>
-			<col>profileid</col>
-		</index>
-	</table>
-
-	<table name="vtiger_role2profile">
-		<field name="roleid" type="C" size="255">
-			<key />
-		</field>
-		<field name="profileid" type="I" size="11">
-			<key />
-		</field>
-		<index name="role2profile_roleid_profileid_idx">
-			<col>roleid</col>
-			<col>profileid</col>
-		</index>
-	</table>
-
-	<table name="vtiger_org_share_action_mapping">
-		<field name="share_action_id" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_action_name" type="C" size="200" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_def_org_share">
-		<field name="ruleid" type="I" size="11">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<notnull />
-		</field>
-		<field name="permission" type="I" size="19">
-		</field>
-		<field name="editstatus" type="I" size="19" />
-	</table>
-
-<table name="vtiger_def_org_share" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_def_org_share FOREIGN KEY (permission) REFERENCES vtiger_org_share_action_mapping(share_action_id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_def_org_field">
-		<field name="tabid" type="I" size="10" />
-		<field name="fieldid" type="I" size="19">
-			<key />
-		</field>
-		<field name="visible" type="I" size="19" />
-		<field name="readonly" type="I" size="19" />
-
-		<index name="def_org_field_tabid_fieldid_idx">
-			<col>tabid</col>
-			<col>fieldid</col>
-		</index>
-		<index name="def_org_field_tabid_idx">
-			<col>tabid</col>
-		</index>
-		<index name="def_org_field_visible_fieldid_idx">
-			<col>visible</col>
-			<col>fieldid</col>
-		</index>
-	</table>
-
-	<table name="vtiger_profile2utility">
-		<field name="profileid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="activityid" type="I" size="11">
-			<key />
-		</field>
-		<field name="permission" type="I" size="1" />
-
-		<index name="profile2utility_profileid_tabid_activityid_idx">
-			<col>profileid</col>
-			<col>tabid</col>
-			<col>activityid</col>
-		</index>
-	</table>
-
-	<table name="vtiger_productcategory">
-		<field name="productcategoryid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="productcategory" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="productcategory_productcategory_idx">
-			<col>productcategory</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_salesorder">
-		<field name="salesorderid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="subject" type="C" size="100" />
-		<field name="potentialid" type="I" size="19" />
-		<field name="customerno" type="C" size="100" />
-		<field name="quoteid" type="I" size="19" />
-		<field name="vendorterms" type="C" size="100" />
-		<field name="contactid" type="I" size="19">
-		</field>
-		<field name="vendorid" type="I" size="19">
-		</field>
-		<field name="duedate" type="D" />
-		<field name="carrier" type="C" size='100' />
-		<field name="pending" type="C" size='200' />
-		<field name="type" type="C" size="100" />
-		<field name="salestax" type="N" size="11.3" />
-		<field name="adjustment" type="N" size="11.3" />
-		<field name="salescommission" type="N" size="11.3" />
-		<field name="exciseduty" type="N" size="11.3" />
-		<field name="total" type="N" size="11.3" />
-		<field name="subtotal" type="N" size="11.3" />
-		<field name="taxtype" type="C" size="25" />
-		<field name="discount_percent" type="N" size="11.3" />
-		<field name="discount_amount" type="N" size="11.3" />
-		<field name="s_h_amount" type="N" size="11.3" />
-		<field name="accountid" type="I" size="19" />
-		<field name="terms_conditions" type="X" />
-		<field name="purchaseorder" type="C" size='200' />
-		<field name="sostatus" type="C" size='200' />
-		<field name="orgunitid" type="I" size="19" />
-
-		<index name="salesorder_vendorid_idx">
-			<col>vendorid</col>
-		</index>
-		<index name="salesorder_contactid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_salesorder" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_salesorder FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_salesorder FOREIGN KEY (salesorderid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_salesorder FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_sogrouprelation">
-		<field name="salesorderid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="sogrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_sogrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_sogrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_sogrouprelation FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_sobillads">
-		<field name="sobilladdressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="bill_city" type="C" size="30" />
-		<field name="bill_code" type="C" size="30" />
-		<field name="bill_country" type="C" size="30" />
-		<field name="bill_state" type="C" size="30" />
-		<field name="bill_street" type="C" size="250" />
-		<field name="bill_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_sobillads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_sobillads FOREIGN KEY (sobilladdressid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_soshipads">
-		<field name="soshipaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="ship_city" type="C" size="30" />
-		<field name="ship_code" type="C" size="30" />
-		<field name="ship_country" type="C" size="30" />
-		<field name="ship_state" type="C" size="30" />
-		<field name="ship_street" type="C" size="250" />
-		<field name="ship_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_soshipads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_soshipads FOREIGN KEY (soshipaddressid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_salesordercf">
-		<field name="salesorderid" type="I" size="19">
-			<key />
-			<default value="0"/>
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_salesordercf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_salesordercf FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-
-	<table name="vtiger_notificationscheduler">
-		<field name="schedulednotificationid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="schedulednotificationname" type="C" size="200" />
-		<field name="active" type="I" size="1" />
-		<field name="notificationsubject" type="C" size="200" />
-		<field name="notificationbody" type="X" />
-		<field name="label" type="C" size="50" />
-
-		<index name="notificationscheduler_schedulednotificationname_idx">
-			<col>schedulednotificationname</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_activityproductrel">
-		<field name="activityid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="productid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="activityproductrel_activityid_idx">
-			<col>activityid</col>
-		</index>
-		<index name="activityproductrel_productid_idx">
-			<col>productid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_activityproductrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_activityproductrel FOREIGN KEY (activityid) REFERENCES vtiger_activity(activityid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_activityproductrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_relatedlists">
-		<field name="relation_id" type="I" size="19">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="10" />
-		<field name="related_tabid" type="I" size="10" />
-		<field name="name" type="C" size="100" />
-		<field name="sequence" type="I" size="10" />
-		<field name="label" type="C" size="100" />
-		<field name="presence" type="I" size="10">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="relatedlists_relation_id_idx">
-			<col>relation_id</col>
-		</index>
-	</table>
-
-	<table name="vtiger_rss">
-		<field name="rssid" type="I" size="19">
-			<key />
-		</field>
-		<field name="rssurl" type="C" size="200">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="rsstitle" type="C" size="200" />
-		<field name="rsstype" type="I" size="10">
-			<default value="0" />
-		</field>
-		<field name="starred" type="I" size="1">
-			<default value="0" />
-		</field>
-	</table>
-
-	<table name="vtiger_vendorcf">
-		<field name="vendorid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_vendorcf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_vendorcf FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_pricebook">
-		<field name="pricebookid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="bookname" type="C" size="100" />
-		<field name="active" type="I" size="1" />
-		<field name="description" type="X" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_pricebook" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_pricebook FOREIGN KEY (pricebookid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_pricebookcf">
-		<field name="pricebookid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_pricebookcf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_pricebookcf FOREIGN KEY (pricebookid) REFERENCES vtiger_pricebook(pricebookid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_pricebookproductrel">
-		<field name="pricebookid" type="I" size="19">
-			<key />
-		</field>
-		<field name="productid" type="I" size="19">
-			<key />
-		</field>
-		<field name="listprice" type="N" size="11.3" />
-
-		<index name="pricebookproductrel_pricebookid_idx">
-			<col>pricebookid</col>
-		</index>
-		<index name="pricebookproductrel_productid_idx">
-			<col>productid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_pricebookproductrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_pricebookproductrel FOREIGN KEY (pricebookid) REFERENCES vtiger_pricebook(pricebookid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_pricebookproductrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_mail_accounts">
-		<field name="account_id" type="I" size="11">
-			<key />
-		</field>
-		<field name="user_id" type="I" size="11">
-			<notnull />
-		</field>
-		<field name="display_name" type="C" size="50" />
-		<field name="mail_id" type="C" size="50" />
-		<field name="account_name" type="C" size="50" />
-		<field name="mail_protocol" type="C" size="20" />
-		<field name="mail_username" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="mail_password" type="C" size="20">
-			<notnull />
-		</field>
-		<field name="mail_servername" type="C" size="50" />
-		<field name="box_refresh" type="I" size="10" />
-		<field name="mails_per_page" type="I" size="10" />
-		<field name="ssltype" type="C" size="50" />
-		<field name="sslmeth" type="C" size="50" />
-		<field name="int_mailer" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="status" type="C" size="10" />
-		<field name="set_default" type="I" size="2" />
-	</table>
-
-	<table name="vtiger_quotes">
-		<field name="quoteid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="subject" type="C" size="100" />
-		<field name="potentialid" type="I" size="19">
-		</field>
-		<field name="quotestage" type="C" size="200" />
-		<field name="validtill" type="D" />
-		<field name="team" type="C" size="200" />
-		<field name="contactid" type="I" size="19">
-		</field>
-		<field name="currency" type="C" size="100" />
-		<field name="subtotal" type="N" size="11.3" />
-		<field name="carrier" type="C" size='100' />
-		<field name="shipping" type="C" size="100" />
-		<field name="inventorymanager" type="I" size="19" />
-		<field name="type" type="C" size="100" />
-		<field name="tax" type="N" size="11.3" />
-		<field name="adjustment" type="N" size="11.3" />
-		<field name="total" type="N" size="11.3" />
-		<field name="taxtype" type="C" size="25" />
-		<field name="discount_percent" type="N" size="11.3" />
-		<field name="discount_amount" type="N" size="11.3" />
-		<field name="s_h_amount" type="N" size="11.3" />
-		<field name="accountid" type="I" size="19" />
-		<field name="terms_conditions" type="X" />
-		<field name="orgunitid" type="I" size="19" />
-
-		<index name="quote_quotestage_idx">
-			<col>quotestage</col>
-		</index>
-		<index name="quotes_potentialid_idx">
-			<col>potentialid</col>
-		</index>
-		<index name="quotes_contactid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_quotes" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_quotes FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_quotes FOREIGN KEY (quoteid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_quotes FOREIGN KEY (potentialid) REFERENCES vtiger_potential(potentialid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_quotesbillads">
-		<field name="quotebilladdressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="bill_city" type="C" size="30" />
-		<field name="bill_code" type="C" size="30" />
-		<field name="bill_country" type="C" size="30" />
-		<field name="bill_state" type="C" size="30" />
-		<field name="bill_street" type="C" size="250" />
-		<field name="bill_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_quotesbillads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_quotesbillads FOREIGN KEY (quotebilladdressid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_quotesshipads">
-		<field name="quoteshipaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="ship_city" type="C" size="30" />
-		<field name="ship_code" type="C" size="30" />
-		<field name="ship_country" type="C" size="30" />
-		<field name="ship_state" type="C" size="30" />
-		<field name="ship_street" type="C" size="250" />
-		<field name="ship_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_quotesshipads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_quotesshipads FOREIGN KEY (quoteshipaddressid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_quotegrouprelation">
-		<field name="quoteid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="quotegrouprelation_groupname_idx">
-			<col>groupname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_quotegrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_quotegrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_quotegrouprelation FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_quotescf">
-		<field name="quoteid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_quotescf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_quotescf FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_purchaseorder">
-		<field name="purchaseorderid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="subject" type="C" size="100" />
-		<field name="quoteid" type="I" size="19">
-		</field>
-		<field name="vendorid" type="I" size="19">
-		</field>
-		<field name="requisition_no" type="C" size="100" />
-		<field name="tracking_no" type="C" size="100" />
-		<field name="contactid" type="I" size="19">
-		</field>
-		<field name="duedate" type="D" />
-		<field name="carrier" type="C" size='100' />
-		<field name="type" type="C" size="100" />
-		<field name="salestax" type="N" size="11.3" />
-		<field name="adjustment" type="N" size="11.3" />
-		<field name="salescommission" type="N" size="11.3" />
-		<field name="exciseduty" type="N" size="11.3" />
-		<field name="total" type="N" size="11.3" />
-		<field name="subtotal" type="N" size="11.3" />
-		<field name="taxtype" type="C" size="25" />
-		<field name="discount_percent" type="N" size="11.3" />
-		<field name="discount_amount" type="N" size="11.3" />
-		<field name="s_h_amount" type="N" size="11.3" />
-		<field name="terms_conditions" type="X" />
-		<field name="postatus" type="C" size="200" />
-		<field name="orgunitid" type="I" size="19" />
-
-		<index name="purchaseorder_vendorid_idx">
-			<col>vendorid</col>
-		</index>
-		<index name="purchaseorder_quoteid_idx">
-			<col>quoteid</col>
-		</index>
-		<index name="purchaseorder_contactid_idx">
-			<col>contactid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_purchaseorder" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_purchaseorder FOREIGN KEY (contactid) REFERENCES vtiger_contactdetails(contactid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_purchaseorder FOREIGN KEY (purchaseorderid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_purchaseorder FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_4_vtiger_purchaseorder FOREIGN KEY (vendorid) REFERENCES vtiger_vendor(vendorid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_pogrouprelation">
-		<field name="purchaseorderid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="pogrouprelation_groupname_purchaseorderid_idx">
-			<col>groupname</col>
-			<col>purchaseorderid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_pogrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_pogrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_pogrouprelation FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_pobillads">
-		<field name="pobilladdressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="bill_city" type="C" size="30" />
-		<field name="bill_code" type="C" size="30" />
-		<field name="bill_country" type="C" size="30" />
-		<field name="bill_state" type="C" size="30" />
-		<field name="bill_street" type="C" size="250" />
-		<field name="bill_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_pobillads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_pobillads FOREIGN KEY (pobilladdressid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_poshipads">
-		<field name="poshipaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="ship_city" type="C" size="30" />
-		<field name="ship_code" type="C" size="30" />
-		<field name="ship_country" type="C" size="30" />
-		<field name="ship_state" type="C" size="30" />
-		<field name="ship_street" type="C" size="250" />
-		<field name="ship_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_poshipads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_poshipads FOREIGN KEY (poshipaddressid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_purchaseordercf">
-		<field name="purchaseorderid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_purchaseordercf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_purchaseordercf FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-
-	<table name="vtiger_invoice">
-		<field name="invoiceid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="subject" type="C" size="100" />
-		<field name="salesorderid" type="I" size="19">
-		</field>
-		<field name="customerno" type="C" size="100" />
-		<field name="contactid" type="I" size="19" />
-		<field name="notes" type="C" size="100" />
-		<field name="invoicedate" type="D" />
-		<field name="duedate" type="D" />
-		<field name="invoiceterms" type="C" size="100" />
-		<field name="type" type="C" size="100" />
-		<field name="salestax" type="N" size="11.3" />
-		<field name="adjustment" type="N" size="11.3" />
-		<field name="salescommission" type="N" size="11.3" />
-		<field name="exciseduty" type="N" size="11.3" />
-		<field name="subtotal" type="N" size="11.3" />
-		<field name="total" type="N" size="11.3" />
-		<field name="taxtype" type="C" size="25" />
-		<field name="discount_percent" type="N" size="11.3" />
-		<field name="discount_amount" type="N" size="11.3" />
-		<field name="s_h_amount" type="N" size="11.3" />
-		<field name="shipping" type="C" size="100" />
-		<field name="accountid" type="I" size="19" />
-		<field name="terms_conditions" type="X" />
-		<field name="purchaseorder" type="C" size='200' />
-		<field name="invoicestatus" type="C" size='200' />
-		<field name="orgunitid" type="I" size="19" />
-
-		<index name="invoice_purchaseorderid_idx">
-			<col>invoiceid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_invoice" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_invoice FOREIGN KEY (invoiceid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_invoice FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_invoicegrouprelation">
-		<field name="invoiceid" type="I" size="19">
-			<key />
-		</field>
-		<field name="groupname" type="C" size="100">
-		</field>
-
-		<index name="invoicegrouprelation_groupname_invoiceid_idx">
-			<col>groupname</col>
-			<col>invoiceid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_invoicegrouprelation" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_invoicegrouprelation FOREIGN KEY (groupname) REFERENCES vtiger_groups(groupname) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_invoicegrouprelation FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_invoicebillads">
-		<field name="invoicebilladdressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="bill_city" type="C" size="30" />
-		<field name="bill_code" type="C" size="30" />
-		<field name="bill_country" type="C" size="30" />
-		<field name="bill_state" type="C" size="30" />
-		<field name="bill_street" type="C" size="250" />
-		<field name="bill_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_invoicebillads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_invoicebillads FOREIGN KEY (invoicebilladdressid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_invoiceshipads">
-		<field name="invoiceshipaddressid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="ship_city" type="C" size="30" />
-		<field name="ship_code" type="C" size="30" />
-		<field name="ship_country" type="C" size="30" />
-		<field name="ship_state" type="C" size="30" />
-		<field name="ship_street" type="C" size="250" />
-		<field name="ship_pobox" type="C" size="30" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_invoiceshipads" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_invoiceshipads FOREIGN KEY (invoiceshipaddressid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_invoicecf">
-		<field name="invoiceid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_invoicecf" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_invoicecf FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-
-	<table name="vtiger_activity_reminder">
-		<field name="activity_id" type="I" size="11">
-			<key />
-			<notnull />
-		</field>
-		<field name="reminder_time" type="I" size="11">
-			<notnull />
-		</field>
-		<field name="reminder_sent" type="I" size="2">
-			<notnull />
-		</field>
-		<field name="recurringid" type="I" size="19">
-			<key />
-			<notnull />
-		</field>
-	</table>
-
-	<table name="vtiger_customview">
-		<field name="cvid" type="I" size="19">
-			<key />
-		</field>
-		<field name="viewname" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="setdefault" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="setmetrics" type="I" size="1">
-			<default value="0" />
-		</field>
-		<field name="entitytype" type="C" size="100">
-			<notnull />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_cvcolumnlist">
-		<field name="cvid" type="I" size="19">
-			<key />
-			<notnull />
-		</field>
-		<field name="columnindex" type="I" size="11">
-			<key />
-			<notnull />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<default value="" />
-		</field>
-
-		<index name="cvcolumnlist_columnindex_idx">
-			<col>columnindex</col>
-		</index>
-		<index name="cvcolumnlist_cvid_idx">
-			<col>cvid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_cvcolumnlist" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_cvcolumnlist FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_cvstdfilter">
-		<field name="cvid" type="I" size="19">
-			<key />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="stdfilter" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="startdate" type="D">
-			<default value="NULL" />
-		</field>
-		<field name="enddate" type="D">
-			<default value="NULL" />
-		</field>
-
-		<index name="cvstdfilter_cvid_idx">
-			<col>cvid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_cvstdfilter" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_cvstdfilter FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_cvadvfilter">
-		<field name="cvid" type="I" size="19">
-			<key />
-		</field>
-		<field name="columnindex" type="I" size="11">
-			<key />
-			<notnull />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="comparator" type="C" size="10">
-			<default value="" />
-		</field>
-		<field name="value" type="C" size="200">
-			<default value="" />
-		</field>
-
-		<index name="cvadvfilter_cvid_idx">
-			<col>cvid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_cvadvfilter" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_cvadvfilter FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_customaction">
-		<field name="cvid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="subject" type="C" size="250">
-			<notnull />
-		</field>
-		<field name="module" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="content" type="X">
-			<default value="" />
-		</field>
-
-		<index name="customaction_cvid_idx">
-			<col>cvid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_customaction" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_customaction FOREIGN KEY (cvid) REFERENCES vtiger_customview (cvid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_selectquery">
-		<field name="queryid" type="I" size="19">
-			<key />
-		</field>
-		<field name="startindex" type="I" size="19">
-			<default value="0" />
-		</field>
-		<field name="numofobjects" type="I" size="19">
-			<default value="0" />
-		</field>
-
-		<index name="selectquery_queryid_idx">
-			<col>queryid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_selectcolumn">
-		<field name="queryid" type="I" size="19">
-			<key />
-		</field>
-		<field name="columnindex" type="I" size="11">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<default value="" />
-		</field>
-
-		<index name="selectcolumn_queryid_idx">
-			<col>queryid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_selectcolumn" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_selectcolumn FOREIGN KEY (queryid) REFERENCES vtiger_selectquery (queryid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_relcriteria">
-		<field name="queryid" type="I" size="19">
-			<key />
-		</field>
-		<field name="columnindex" type="I" size="11">
-			<key />
-			<notnull />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="comparator" type="C" size="10">
-			<default value="" />
-		</field>
-		<field name="value" type="C" size="200">
-			<default value="" />
-		</field>
-
-		<index name="relcriteria_queryid_idx">
-			<col>queryid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_relcriteria" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_relcriteria FOREIGN KEY (queryid) REFERENCES vtiger_selectquery (queryid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_reportfolder">
-		<field name="folderid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="foldername" type="C" size="100">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="description" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="state" type="C" size="50">
-			<default value="SAVED" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_report">
-		<field name="reportid" type="I" size="19">
-			<key />
-		</field>
-		<field name="folderid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="reportname" type="C" size="100">
-			<default value="" />
-		</field>
-		<field name="description" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="reporttype" type="C" size="50">
-			<default value="" />
-		</field>
-		<field name="queryid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="state" type="C" size="50">
-			<default value="SAVED" />
-		</field>
-		<field name="customizable" type="I" size="1">
-			<default value="1" />
-		</field>
-		<field name="category" type="I" size="11">
-			<default value="1" />
-		</field>
-
-		<index name="report_queryid_idx">
-			<col>queryid</col>
-		</index>
-		<index name="report_folderid_idx">
-			<col>folderid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_report" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_report FOREIGN KEY (folderid) REFERENCES vtiger_reportfolder (folderid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_report FOREIGN KEY (queryid) REFERENCES vtiger_selectquery (queryid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_reportmodules">
-		<field name="reportmodulesid" type="I" size="19">
-			<key />
-		</field>
-		<field name="primarymodule" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="secondarymodules" type="C" size="250">
-			<default value="" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_reportmodules" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_reportmodules FOREIGN KEY (reportmodulesid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_reportsortcol">
-		<field name="sortcolid" type="I" size="19">
-			<key />
-		</field>
-		<field name="reportid" type="I" size="19">
-			<key />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="sortorder" type="C" size="250">
-			<default value="Asc" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_reportsortcol" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_reportsortcol FOREIGN KEY (reportid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_reportdatefilter">
-		<field name="datefilterid" type="I" size="19">
-			<key />
-		</field>
-		<field name="datecolumnname" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="datefilter" type="C" size="250">
-			<default value="" />
-		</field>
-		<field name="startdate" type="D">
-			<default value="NULL" />
-		</field>
-		<field name="enddate" type="D">
-			<default value="NULL" />
-		</field>
-
-		<index name="reportdatefilter_datefilterid_idx">
-			<col>datefilterid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_reportdatefilter" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_reportdatefilter FOREIGN KEY (datefilterid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_reportsummary">
-		<field name="reportsummaryid" type="I" size="19">
-			<key />
-		</field>
-		<field name="summarytype" type="I" size="19">
-			<key />
-		</field>
-		<field name="columnname" type="C" size="250">
-			<key />
-			<default value="" />
-		</field>
-
-		<index name="reportsummary_reportsummaryid_idx">
-			<col>reportsummaryid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_reportsummary" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_reportsummary FOREIGN KEY (reportsummaryid) REFERENCES vtiger_report (reportid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_usageunit">
-		<field name="usageunitid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="usageunit" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="usageunit_usageunit_idx">
-			<col>usageunit</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_glacct">
-		<field name="glacctid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="glacct" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="glacct_glacct_idx">
-			<col>glacct</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_quotestage">
-		<field name="quotestageid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="quotestage" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="quotestage_quotestage_idx">
-			<col>quotestage</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_invoicestatus">
-		<field name="inovicestatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="invoicestatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="invoicestatus_invoiestatus_idx">
-			<col>invoicestatus</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_postatus">
-		<field name="postatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="postatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="postatus_postatus_idx">
-			<col>postatus</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_sostatus">
-		<field name="sostatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="sostatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="sostatus_sostatus_idx">
-			<col>sostatus</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-
-	</table>
-
-	<table name="vtiger_carrier">
-		<field name="carrierid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="carrier" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="carrier_carrier_idx">
-			<col>carrier</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_taxclass">
-		<field name="taxclassid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="taxclass" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="taxclass_carrier_idx">
-			<col>taxclass</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_organizationdetails">
-		<field name="organizationname" type="C" size="60">
-			<key />
-		</field>
-		<field name="address" type="C" size="150" />
-		<field name="city" type="C" size="100" />
-		<field name="state" type="C" size="100" />
-		<field name="country" type="C" size="100" />
-		<field name="code" type="C" size="30" />
-		<field name="phone" type="C" size="30" />
-		<field name="fax" type="C" size="30" />
-		<field name="website" type="C" size="100" />
-		<field name="logoname" type="C" size="50" />
-		<field name="logo" type="X" />
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="quote_template" type="C" size="30">
-			<default value="" />
-		</field>
-		<field name="so_template" type="C" size="30">
-			<default value="" />
-		</field>
-		<field name="po_template" type="C" size="30">
-			<default value="" />
-		</field>
-		<field name="invoice_template" type="C" size="30">
-			<default value="" />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_recurringtype">
-		<field name="recurringeventid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="recurringtype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="recurringtype_status_idx">
-			<col>recurringtype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_recurringevents">
-		<field name="recurringid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="activityid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="recurringdate" type="D" />
-		<field name="recurringtype" type="C" size="30" />
-		<field name="recurringfreq" type="I" size="19" />
-		<field name="recurringinfo" type="C" size="50" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_inventorynotification">
-		<field name="notificationid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="notificationname" type="C" size="200" />
-		<field name="notificationsubject" type="C" size="200" />
-		<field name="notificationbody" type="X" />
-		<field name="label" type="C" size="50" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_inventory_tandc">
-		<field name="id" type="I" size="19">
-			<key />
-		</field>
-		<field name="type" type="C" size="30">
-			<notnull />
-		</field>
-		<field name="tandc" type="X" />
-	</table>
-
-	<table name="vtiger_convertleadmapping">
-		<field name="cfmid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="leadfid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="accountfid" type="I" size="19" />
-		<field name="contactfid" type="I" size="19" />
-		<field name="potentialfid" type="I" size="19" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_actionmapping">
-		<field name="actionid" type="I" size="19">
-			<key />
-		</field>
-		<field name="actionname" type="C" size="200">
-			<key />
-		</field>
-		<field name="securitycheck" type="I" size="19" />
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_org_share_action2tab">
-		<field name="share_action_id" type="I" size="19">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="19">
-			<key />
-		</field>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_org_share_action2tab" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_org_share_action2tab FOREIGN KEY (share_action_id) REFERENCES vtiger_org_share_action_mapping(share_action_id) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_org_share_action2tab FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_moduleowners">
-		<field name="tabid" type="I" size="19">
-			<key />
-			<unique />
-			<default value="0" />
-		</field>
-		<field name="user_id" type="C" size="11">
-			<notnull />
-		</field>
-		<index name="moduleowners_tabid_user_id_idx">
-			<col>tabid</col>
-			<col>user_id</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_moduleowners" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_moduleowners FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_ownernotify">
-		<field name="crmid" type="I" size="19" />
-		<field name="smownerid" type="I" size="19" />
-		<field name="flag" type="I" size="3" />
-
-		<index name="ownernotify_crmid_flag_idx">
-			<col>crmid</col>
-			<col>flag</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_datashare_module_rel">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="relationtype" type="C" size="200">
-		</field>
-		<opt platform="mysql">Type=InnoDB</opt>
-		<index name="idx_datashare_module_rel_tabid">
-			<col>tabid</col>
-		</index>
-	</table>
-
-<table name="vtiger_datashare_module_rel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_module_rel FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_grp2grp">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_groupid" type="I" size="19">
-		</field>
-		<field name="to_groupid" type="I" size="19">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_grp2grp_share_groupid_idx">
-			<col>share_groupid</col>
-		</index>
-		<index name="datashare_grp2grp_to_groupid_idx">
-			<col>to_groupid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_grp2grp" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_grp2grp FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_grp2grp FOREIGN KEY (share_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_grp2grp FOREIGN KEY (to_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_grp2role">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_groupid" type="I" size="19">
-		</field>
-		<field name="to_roleid" type="C" size="255">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="idx_datashare_grp2role_share_groupid">
-			<col>share_groupid</col>
-		</index>
-		<index name="idx_datashare_grp2role_to_roleid">
-			<col>to_roleid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_grp2role" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_grp2role FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_grp2role FOREIGN KEY (share_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_grp2role FOREIGN KEY (to_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_grp2rs">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_groupid" type="I" size="19">
-		</field>
-		<field name="to_roleandsubid" type="C" size="255">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_grp2rs_share_groupid_idx">
-			<col>share_groupid</col>
-		</index>
-		<index name="datashare_grp2rs_to_roleandsubid_idx">
-			<col>to_roleandsubid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_grp2rs" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_grp2rs FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_grp2rs FOREIGN KEY (share_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_grp2rs FOREIGN KEY (to_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_role2group">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_roleid" type="C" size="255">
-		</field>
-		<field name="to_groupid" type="I" size="19">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="idx_datashare_role2group_share_roleid">
-			<col>share_roleid</col>
-		</index>
-		<index name="idx_datashare_role2group_to_groupid">
-			<col>to_groupid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_role2group" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_role2group FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_role2group FOREIGN KEY (to_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_role2group FOREIGN KEY (share_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_role2role">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_roleid" type="C" size="255">
-		</field>
-		<field name="to_roleid" type="C" size="255">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_role2role_share_roleid_idx">
-			<col>share_roleid</col>
-		</index>
-		<index name="datashare_role2role_to_roleid_idx">
-			<col>to_roleid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_role2role" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_role2role FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_role2role FOREIGN KEY (share_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_role2role FOREIGN KEY (to_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_role2rs">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_roleid" type="C" size="255">
-		</field>
-		<field name="to_roleandsubid" type="C" size="255">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_role2s_share_roleid_idx">
-			<col>share_roleid</col>
-		</index>
-		<index name="datashare_role2s_to_roleandsubid_idx">
-			<col>to_roleandsubid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_role2rs" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_role2rs FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_role2rs FOREIGN KEY (share_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_role2rs FOREIGN KEY (to_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_rs2grp">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_roleandsubid" type="C" size="255">
-		</field>
-		<field name="to_groupid" type="I" size="19">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_rs2grp_share_roleandsubid_idx">
-			<col>share_roleandsubid</col>
-		</index>
-		<index name="datashare_rs2grp_to_groupid_idx">
-			<col>to_groupid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_rs2grp" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_rs2grp FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_rs2grp FOREIGN KEY (to_groupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_rs2grp FOREIGN KEY (share_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_rs2role">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_roleandsubid" type="C" size="255">
-		</field>
-		<field name="to_roleid" type="C" size="255">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_rs2role_share_roleandsubid_idx">
-			<col>share_roleandsubid</col>
-		</index>
-		<index name="datashare_rs2role_to_roleid_idx">
-			<col>to_roleid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_rs2role" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_rs2role FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_rs2role FOREIGN KEY (share_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_rs2role FOREIGN KEY (to_roleid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_rs2rs">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="share_roleandsubid" type="C" size="255">
-		</field>
-		<field name="to_roleandsubid" type="C" size="255">
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_rs2rs_share_roleandsubid_idx">
-			<col>share_roleandsubid</col>
-		</index>
-		<index name="idx_datashare_rs2rs_to_roleandsubid_idx">
-			<col>to_roleandsubid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_rs2rs" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_rs2rs FOREIGN KEY (shareid) REFERENCES vtiger_datashare_module_rel(shareid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_rs2rs FOREIGN KEY (share_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_datashare_rs2rs FOREIGN KEY (to_roleandsubid) REFERENCES vtiger_role(roleid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_relatedmodules">
-		<field name="datashare_relatedmodule_id" type="I" size="19">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="19">
-		</field>
-		<field name="relatedto_tabid" type="I" size="19">
-		</field>
-		<index name="datashare_relatedmodules_tabid_idx">
-			<col>tabid</col>
-		</index>
-		<index name="datashare_relatedmodules_relatedto_tabid_idx">
-			<col>relatedto_tabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_datashare_relatedmodules" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_datashare_relatedmodules FOREIGN KEY (relatedto_tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_datashare_relatedmodules FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_datashare_relatedmodule_permission">
-		<field name="shareid" type="I" size="19">
-			<key />
-		</field>
-		<field name="datashare_relatedmodule_id" type="I" size="19">
-			<key />
-		</field>
-		<field name="permission" type="I" size="19" />
-
-		<index name="datashare_relatedmodule_permission_shareid_permissions_idx">
-			<col>shareid</col>
-			<col>permission</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_parenttab">
-		<field name="parenttabid" type="I" size="19">
-			<notnull />
-			<key />
-		</field>
-		<field name="parenttab_label" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="sequence" type="I" size="10">
-			<notnull />
-		</field>
-		<field name="visible" type="I" size="2">
-			<notnull />
-			<default value="0" />
-		</field>
-		<index name="parenttab_parenttabid_parenttabl_label_visible_idx">
-			<col>parenttabid</col>
-			<col>parenttab_label</col>
-			<col>visible</col>
-		</index>
-	</table>
-
-	<table name="vtiger_tmp_read_user_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="shareduserid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_read_user_sharing_per_userid_shareduserid_idx">
-			<col>userid</col>
-			<col>shareduserid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_read_user_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_user_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_user_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_user_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_read_group_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="sharedgroupid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_read_group_sharing_per_userid_sharedgroupid_idx">
-			<col>userid</col>
-			<col>sharedgroupid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_read_group_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_group_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_group_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_group_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_write_user_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="shareduserid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_write_user_sharing_per_userid_shareduserid_idx">
-			<col>userid</col>
-			<col>shareduserid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_write_user_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_user_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_user_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_user_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_write_group_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="sharedgroupid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_write_group_sharing_per_UK1">
-			<col>userid</col>
-			<col>sharedgroupid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_write_group_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_group_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_group_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_group_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_read_user_rel_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="relatedtabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="shareduserid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_read_user_rel_sharing_per_userid_shared_reltabid_idx">
-			<col>userid</col>
-			<col>shareduserid</col>
-			<col>relatedtabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_read_user_rel_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_read_user_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_read_group_rel_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="relatedtabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="sharedgroupid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_read_group_rel_sharing_per_userid_sharedgroupid_tabid">
-			<col>userid</col>
-			<col>sharedgroupid</col>
-			<col>tabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_read_group_rel_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_read_group_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_write_user_rel_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="relatedtabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="shareduserid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_write_user_rel_sharing_per_userid_sharduserid_tabid_idx">
-			<col>userid</col>
-			<col>shareduserid</col>
-			<col>tabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_write_user_rel_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (shareduserid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_write_user_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_tmp_write_group_rel_sharing_per">
-		<field name="userid" type="I" size="11">
-			<key />
-		</field>
-		<field name="tabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="relatedtabid" type="I" size="11">
-			<key />
-		</field>
-		<field name="sharedgroupid" type="I" size="11">
-			<key />
-		</field>
-
-		<index name="tmp_write_group_rel_sharing_per_userid_sharedgroupid_tabid_idx">
-			<col>userid</col>
-			<col>sharedgroupid</col>
-			<col>tabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_tmp_write_group_rel_sharing_per" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (sharedgroupid) REFERENCES vtiger_groups(groupid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_2_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (relatedtabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_3_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint>
-<constraint>ADD CONSTRAINT fk_4_vtiger_tmp_write_group_rel_sharing_per FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_parenttabrel">
-		<field name="parenttabid" type="I" size="3">
-			<notnull />
-		</field>
-		<field name="tabid" type="I" size="3">
-			<notnull />
-		</field>
-		<field name="sequence" type="I" size="3">
-			<notnull />
-		</field>
-
-		<index name="parenttabrel_tabid_parenttabid_idx">
-			<col>tabid</col>
-			<col>parenttabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_campaigntype">
-		<field name="campaigntypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="campaigntype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="campaigntype_campaigntype_idx">
-			<col>campaigntype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_campaignstatus">
-		<field name="campaignstatusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="campaignstatus" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="campaignstatus_campaignstatus_idx">
-			<col>campaignstatus</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_expectedresponse">
-		<field name="expectedresponseid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="expectedresponse" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="CampaignExpRes_UK01">
-			<col>expectedresponse</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_portal">
-		<field name="portalid" type="I" size="19">
-			<key />
-		</field>
-		<field name="portalname" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="portalurl" type="C" size="255">
-			<notnull />
-		</field>
-		<field name="sequence" type="I" size="3">
-			<notnull />
-		</field>
-
-		<index name="portal_portalname_idx">
-			<col>portalname</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_announcement">
-		<field name="creatorid" type="I" size="19">
-			<key />
-		</field>
-		<field name="announcement" type="X" />
-		<field name="title" type="C" size="255" />
-		<field name="time" type="T">
-			<deftimestamp />
-		</field>
-
-		<index name="announcement_creatorid_idx">
-			<col>creatorid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_chat_users">
-		<field name="id" type="I" size="20">
-			<autoincrement />
-			<notnull />
-			<key />
-		</field>
-		<field name="nick" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="session" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="ip" type="C" size="20">
-			<default value="000.000.000.000" />
-			<notnull />
-		</field>
-		<field name="ping" type="T">
-			<default value="NULL" />
-		</field>
-
-		<index name="chat_users_nick_idx">
-			<col>nick</col>
-		</index>
-		<index name="chat_users_session_idx">
-			<col>session</col>
-		</index>
-		<index name="chat_users_ping_idx">
-			<col>ping</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_chat_msg">
-		<field name="id" type="I" size="20">
-			<autoincrement />
-			<notnull />
-			<key />
-		</field>
-		<field name="chat_from" type="I" size="20">
-			<default value="0" />
-			<notnull />
-		</field>
-		<field name="chat_to" type="I" size="20">
-			<default value="0" />
-			<notnull />
-		</field>
-		<field name="born" type="T">
-			<default value="NULL" />
-		</field>
-		<field name="msg" type="C" size="255">
-			<notnull />
-		</field>
-
-		<index name="chat_msg_chat_from_idx">
-			<col>chat_from</col>
-		</index>
-		<index name="chat_msg_chat_to_idx">
-			<col>chat_to</col>
-		</index>
-		<index name="chat_msg_born_idx">
-			<col>born</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_chat_msg" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_chat_msg FOREIGN KEY (chat_from) REFERENCES vtiger_chat_users(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_chat_pchat">
-		<field name="id" type="I" size="20">
-			<autoincrement />
-			<notnull />
-			<key />
-		</field>
-		<field name="msg" type="I" size="20">
-			<default value="0"/>
-		</field>
-
-		<index name="chat_pchat_msg_idx">
-			<col>msg</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_chat_pchat" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_chat_pchat FOREIGN KEY (msg) REFERENCES vtiger_chat_msg(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_chat_pvchat">
-		<field name="id" type="I" size="20">
-			<autoincrement />
-			<notnull />
-			<key />
-		</field>
-		<field name="msg" type="I" size="20">
-			<default value="0"/>
-		</field>
-		<index name="chat_pvchat_msg_idx">
-			<col>msg</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_chat_pvchat" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_chat_pvchat FOREIGN KEY (msg) REFERENCES vtiger_chat_msg(id) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_freetags">
-		<field name="id" type="I" size="19">
-			<notnull />
-			<key />
-		</field>
-		<field name="tag" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="raw_tag" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-	</table>
-
-	<table name="vtiger_freetagged_objects">
-		<field name="tag_id" type="I" size="20">
-			<notnull />
-			<default value="0" />
-			<key />
-		</field>
-		<field name="tagger_id" type="I" size="20">
-			<notnull />
-			<default value="0" />
-			<key />
-		</field>
-		<field name="object_id" type="I" size="20">
-			<notnull />
-			<default value="0" />
-			<key />
-		</field>
-		<field name="tagged_on" type="T">
-			<deftimestamp />
-			<notnull />
-		</field>
-		<field name="module" type="C" size="50">
-			<default value="" />
-			<notnull />
-		</field>
-
-		<index name="freetagged_objects_tag_id_tagger_id_object_id_idx">
-			<col>tag_id</col>
-			<col>tagger_id</col>
-			<col>object_id</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_emaildetails">
-		<field name="emailid" type="I" size="19">
-			<notnull />
-			<key />
-		</field>
-		<field name="from_email" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="to_email" type="X">
-			<notnull />
-		</field>
-		<field name="cc_email" type="X">
-			<notnull />
-		</field>
-		<field name="bcc_email" type="X">
-			<notnull />
-		</field>
-		<field name="assigned_user_email" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="idlists" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-		<field name="email_flag" type="C" size="50">
-			<notnull />
-			<default value="" />
-		</field>
-	</table>
-
-	<table name="vtiger_invitees">
-		<field name="activityid" type="I" size="19">
-			<KEY/>
-		</field>
-		<field name="inviteeid" type="I" size="19">
-			<KEY/>
-		</field>
-	</table>
-
-	<table name="vtiger_inventorytaxinfo">
-		<field name="taxid" type="I" size="3">
-			<KEY/>
-			<notnull />
-		</field>
-		<field name="taxname" type="C" size="50">
-		</field>
-		<field name="taxlabel" type="C" size="50">
-		</field>
-		<field name="percentage" type="N" size="7.3">
-		</field>
-		<field name="deleted" type="I" size="1" />
-
-		<index name="inventorytaxinfo_taxname_idx">
-			<col>taxname</col>
-		</index>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_producttaxrel">
-		<field name="productid" type="I" size="11">
-			<notnull />
-		</field>
-		<field name="taxid" type="I" size="3">
-			<notnull />
-		</field>
-		<field name="taxpercentage" type="N" size="7.3">
-		</field>
-
-		<index name="producttaxrel_productid_idx">
-			<col>productid</col>
-		</index>
-		<index name="producttaxrel_taxid_idx">
-			<col>taxid</col>
-		</index>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_producttaxrel" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_producttaxrel FOREIGN KEY (productid) REFERENCES vtiger_products(productid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_status">
-		<field name="statusid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="status" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="vtiger_status_status_idx">
-			<col>source</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_activity_view">
-		<field name="activity_viewid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="activity_view" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="vtiger_activity_view_status_idx">
-			<col>source</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_lead_view">
-		<field name="lead_viewid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="lead_view" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="vtiger_lead_viewstatus_idx">
-			<col>source</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_date_format">
-		<field name="date_formatid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="date_format" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="vtiger_date_format_status_idx">
-			<col>source</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_postatushistory">
-		<field name="historyid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="purchaseorderid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="vendorname" type="C" size="100" />
-		<field name="total" type="N" />
-		<field name="postatus" type="C" size="200" />
-		<field name="lastmodified" type="T" />
-
-		<index name="postatushistory_purchaseorderid_idx">
-			<col>purchaseorderid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_postatushistory" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_postatushistory FOREIGN KEY (purchaseorderid) REFERENCES vtiger_purchaseorder(purchaseorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_sostatushistory">
-		<field name="historyid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="salesorderid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="accountname" type="C" size="100" />
-		<field name="total" type="N" />
-		<field name="sostatus" type="C" size="200" />
-		<field name="lastmodified" type="T" />
-
-		<index name="sostatushistory_salesorderid_idx">
-			<col>salesorderid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_sostatushistory" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_sostatushistory FOREIGN KEY (salesorderid) REFERENCES vtiger_salesorder(salesorderid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_quotestagehistory">
-		<field name="historyid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="quoteid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="accountname" type="C" size="100" />
-		<field name="total" type="N" />
-		<field name="quotestage" type="C" size="200" />
-		<field name="lastmodified" type="T" />
-
-		<index name="quotestagehistory_quoteid_idx">
-			<col>quoteid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_quotestagehistory" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_quotestagehistory FOREIGN KEY (quoteid) REFERENCES vtiger_quotes(quoteid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_invoicestatushistory">
-		<field name="historyid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="invoiceid" type="I" size="19">
-			<notnull />
-		</field>
-		<field name="accountname" type="C" size="100" />
-		<field name="total" type="N" />
-		<field name="invoicestatus" type="C" size="200" />
-		<field name="lastmodified" type="T" />
-
-		<index name="invoicestatushistory_invoiceid_idx">
-			<col>invoiceid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-<table name="vtiger_invoicestatushistory" alter="true">
-<constraint>ADD CONSTRAINT fk_1_vtiger_invoicestatushistory FOREIGN KEY (invoiceid) REFERENCES vtiger_invoice(invoiceid) ON DELETE CASCADE</constraint>
-<opt>Type=InnoDB</opt>
-<data>
-</data>
-</table>
-
-	<table name="vtiger_audit_trial">
-		<field name="auditid" type="I" size="19">
-			<key />
-		</field>
-		<field name="userid" type="I" size="19" />
-		<field name="module" type="C" size="255" />
-		<field name="action" type="C" size="255" />
-		<field name="recordid" type="C" size="20" />
-		<field name="actiondate" type="T"/>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_inventoryproductrel">
-		<field name="id" type="I" size="19" />
-		<field name="productid" type="I" size="19" />
-		<field name="sequence_no" type="I" size="4" />
-		<field name="quantity" type="I" size="19" />
-		<field name="listprice" type="N" size="11.3" />
-		<field name="discount_percent" type="N" size="7.3" />
-		<field name="discount_amount" type="N" size="7.3" />
-		<field name="comment" type="C" size="100" />
-
-		<index name="inventoryproductrel_id_idx">
-			<col>id</col>
-		</index>
-		<index name="inventoryproductrel_productid_idx">
-			<col>productid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_shippingtaxinfo">
-		<field name="taxid" type="I" size="3">
-			<KEY/>
-			<notnull />
-		</field>
-		<field name="taxname" type="C" size="50">
-		</field>
-		<field name="taxlabel" type="C" size="50">
-		</field>
-		<field name="percentage" type="N" size="7.3">
-		</field>
-		<field name="deleted" type="I" size="1" />
-
-		<index name="shippingtaxinfo_taxname_idx">
-			<col>taxname</col>
-		</index>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_inventoryshippingrel">
-		<field name="id" type="I" size="19" />
-
-		<index name="inventoryishippingrel_id_idx">
-			<col>id</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_salesmanattachmentsrel">
-		<field name="smid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="attachmentsid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-
-		<index name="salesmanattachmentsrel_smid_idx">
-			<col>smid</col>
-		</index>
-		<index name="salesmanattachmentsrel_attachmentsid_idx">
-			<col>attachmentsid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_salesmanattachmentsrel" alter="true">
-		<constraint>ADD CONSTRAINT fk_1_vtiger_salesmanattachmentsrel FOREIGN KEY (smid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-		<constraint>ADD CONSTRAINT fk_2_vtiger_salesmanattachmentsrel FOREIGN KEY (attachmentsid) REFERENCES vtiger_attachments(attachmentsid) ON DELETE CASCADE</constraint>
-		<opt>Type=InnoDB</opt>
-		<data>
-		</data>
-	</table>
-
-	<table name="vtiger_entityname">
-		<field name="tabid" type="I" size="19">
-			<key />
-			<default value="0" />
-		</field>
-		<field name="modulename" type="C" size="50">
-			<notnull />
-		</field>
-		<field name="tablename" type="C" size="100">
-			<notnull />
-		</field>
-		<field name="fieldname" type="C" size="150">
-			<notnull />
-		</field>
-		<field name="entityidfield" type="C" size="150">
-			<notnull />
-		</field>
-		<index name="entityname_tabid_idx">
-			<col>tabid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_orgunit">
-		<field name="orgunitid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="organizationname" type="C" size="60">
-			<notnull />
-		</field>
-		<field name="type" type="C" size="30" />
-		<field name="name" type="C" size="60">
-			<notnull />
-		</field>
-		<field name="address" type="C" size="150" />
-		<field name="city" type="C" size="100" />
-		<field name="state" type="C" size="100" />
-		<field name="country" type="C" size="100" />
-		<field name="code" type="C" size="30" />
-		<field name="phone" type="C" size="30" />
-		<field name="fax" type="C" size="30" />
-		<field name="website" type="C" size="100" />
-		<field name="deleted" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="quote_template" type="C" size="30">
-			<default value="" />
-		</field>
-		<field name="so_template" type="C" size="30">
-			<default value="" />
-		</field>
-		<field name="po_template" type="C" size="30">
-			<default value="" />
-		</field>
-		<field name="invoice_template" type="C" size="30">
-			<default value="" />
-		</field>
-
-		<index name="vtiger_orgunit_name_idx">
-			<col>organizationname</col>
-			<col>name</col>
-			<unique />
-		</index>
-		<index name="vtiger_orgunit_type_idx">
-			<col>organizationname</col>
-			<col>type</col>
-		</index>
-
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_orgunit" alter="true">
-		<constraint>ADD CONSTRAINT fk_1_vtiger_orgunit FOREIGN KEY (organizationname) REFERENCES vtiger_organizationdetails(organizationname) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_orgunittype">
-		<field name="orgunittypeid" type="I" size="19">
-			<key />
-			<autoincrement />
-		</field>
-		<field name="orgunittype" type="C" size="200">
-			<notnull />
-		</field>
-		<field name="sortorderid" type="I" size="19">
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="presence" type="I" size="1">
-			<notnull />
-			<default value="1" />
-		</field>
-
-		<index name="vtiger_orgunittype_orgunittype_idx">
-			<col>orgunittype</col>
-			<unique />
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_user2org">
-		<field name="organizationname" type="C" size="60">
-			<key />
-			<notnull />
-		</field>
-		<field name="userid" type="I" size="19">
-			<key />
-			<notnull />
-			<default value="0" />
-		</field>
-		<field name="primarytag" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="vtiger_user2org_organizationname_idx">
-			<col>organizationname</col>
-		</index>
-		<index name="vtiger_user2org_userid_idx">
-			<col>userid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_user2org" alter="true">
-		<constraint>ADD CONSTRAINT fk_1_vtiger_user2org FOREIGN KEY (organizationname) REFERENCES vtiger_organizationdetails(organizationname) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
-		<constraint>ADD CONSTRAINT fk_2_vtiger_user2org FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_user2orgunit">
-		<field name="orgunitid" type="I" size="19">
-			<key />
-			<notnull />
-		</field>
-		<field name="userid" type="I" size="19">
-			<key />
-			<default value="0" />
-			<notnull />
-		</field>
-		<field name="primarytag" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="vtiger_user2orgunit_orgunitid_idx">
-			<col>orgunitid</col>
-		</index>
-		<index name="vtiger_user2orgunit_userid_idx">
-			<col>userid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_user2orgunit" alter="true">
-		<constraint>ADD CONSTRAINT fk_1_vtiger_user2orgunit FOREIGN KEY (orgunitid) REFERENCES vtiger_orgunit(orgunitid) ON DELETE CASCADE</constraint>
-		<constraint>ADD CONSTRAINT fk_2_vtiger_user2orgunit FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_entity2org">
-		<field name="organizationname" type="C" size="60">
-			<key />
-			<notnull />
-		</field>
-		<field name="crmid" type="I" size="19">
-			<key />
-			<default value="0" />
-			<notnull />
-		</field>
-		<field name="primarytag" type="I" size="1">
-			<notnull />
-			<default value="0" />
-		</field>
-
-		<index name="vtiger_entity2org_organizationname_idx">
-			<col>organizationname</col>
-		</index>
-		<index name="vtiger_entity2org_crmid_idx">
-			<col>crmid</col>
-		</index>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	<table name="vtiger_entity2org" alter="true">
+	<table name="vtiger_user2orgunit">
+		<field name="orgunitid" type="I" size="19">
+			<key />
+			<notnull />
+		</field>
+		<field name="userid" type="I" size="19">
+			<key />
+			<default value="0" />
+			<notnull />
+		</field>
+		<field name="primarytag" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="vtiger_user2orgunit_orgunitid_idx">
+			<col>orgunitid</col>
+		</index>
+		<index name="vtiger_user2orgunit_userid_idx">
+			<col>userid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_user2orgunit" alter="true">
+		<constraint>ADD CONSTRAINT fk_1_vtiger_user2orgunit FOREIGN KEY (orgunitid) REFERENCES vtiger_orgunit(orgunitid) ON DELETE CASCADE</constraint>
+		<constraint>ADD CONSTRAINT fk_2_vtiger_user2orgunit FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_entity2org">
+		<field name="organizationname" type="C" size="60">
+			<key />
+			<notnull />
+		</field>
+		<field name="crmid" type="I" size="19">
+			<key />
+			<default value="0" />
+			<notnull />
+		</field>
+		<field name="primarytag" type="I" size="1">
+			<notnull />
+			<default value="0" />
+		</field>
+
+		<index name="vtiger_entity2org_organizationname_idx">
+			<col>organizationname</col>
+		</index>
+		<index name="vtiger_entity2org_crmid_idx">
+			<col>crmid</col>
+		</index>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+	<table name="vtiger_entity2org" alter="true">
 		<constraint>ADD CONSTRAINT fk_1_vtiger_entity2org FOREIGN KEY (organizationname) REFERENCES vtiger_organizationdetails(organizationname) ON UPDATE CASCADE ON DELETE CASCADE</constraint>
 		<constraint>ADD CONSTRAINT fk_2_vtiger_entity2org FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE</constraint>
-		<opt platform="mysql">Type=InnoDB</opt>
-	</table>
-
-	
-</schema>
+		<opt platform="mysql">Type=InnoDB</opt>
+	</table>
+
+
+	
+</schema>

Modified: vtigercrm/branches/5.1_jens/soap/customerportal.php
==============================================================================
--- vtigercrm/branches/5.1_jens/soap/customerportal.php (original)
+++ vtigercrm/branches/5.1_jens/soap/customerportal.php Mon Apr 16 12:27:44 2007
@@ -17,11 +17,12 @@
 
 $log = &LoggerManager::getLogger('customerportal');
 
-//$serializer = new XML_Serializer();
-$NAMESPACE = 'http://www.vtigercrm.com/vtigercrm';
+error_reporting(0);
+
+$NAMESPACE = 'http://www.vtiger.com/products/crm';
 $server = new soap_server;
 
-$server->configureWSDL('vtigersoap');
+$server->configureWSDL('customerportal');
 
 
 
@@ -165,6 +166,17 @@
              )
 );
 
+//Added to return the file content
+$server->wsdl->addComplexType(
+        'get_filecontent_array',
+        'complexType',
+        'array',
+        '',
+        array(
+		'fileid'=>'xsd:string','type'=>'tns:xsd:string',
+             )
+);
+
 $server->wsdl->addComplexType(
         'add_ticket_attachment_array',
         'complexType',
@@ -274,6 +286,12 @@
 	'get_ticket_attachments',
 	array('id'=>'xsd:string','ticketid'=>'xsd:string'),
 	array('return'=>'tns:get_ticket_attachments_array'),
+	$NAMESPACE);
+
+$server->register(
+	'get_filecontent',
+	array('id'=>'xsd:string','fileid'=>'xsd:string','filename'=>'xsd:string'),
+	array('return'=>'tns:get_filecontent_array'),
 	$NAMESPACE);
 
 $server->register(
@@ -569,7 +587,32 @@
   
  		$updatequery = "update vtiger_crmentity set modifiedtime=".$servercreatedtime." where crmid=".$ticketid;
   		$adb->query($updatequery);
-  	}	
+
+		//To get the username and user email id, user means assigned to user of the ticket
+		$result = $adb->query("select user_name, email1 from vtiger_users inner join vtiger_crmentity on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_crmentity.crmid=$ticketid");
+		$owner = $adb->query_result($result,0,'user_name');
+		$to_email = $adb->query_result($result,0,'email1');
+
+		//To get the contact name
+		$result1 = $adb->query("select lastname, firstname, email from vtiger_contactdetails where contactid=$ownerid");
+		$customername = $adb->query_result($result1,0,'firstname').' '.$adb->query_result($result1,0,'lastname');
+		$from_email = $adb->query_result($result1,0,'email');
+
+		//send mail to the assigned to user when customer add comment
+		$subject = "Respond to Ticket ID ## $ticketid ## in Customer Portal - URGENT";
+		$contents = "Dear $owner,<br><br>
+				Customer has provided the following additional information to your reply:<br><br>
+
+				<b>".nl2br($comments)."</b><br><br>
+
+				Kindly respond to above ticket at the earliest.<br><br>
+
+				Regards,<br>
+				Support Administrator
+			    ";
+
+		$mailstatus = send_mail('HelpDesk',$to_email,$customername,$from_email,$subject,$contents);
+  	}
 }
 
 /**	function used to close the ticket
@@ -781,16 +824,43 @@
 		$filesize = filesize($filepath.$fileid."_".$filename);
 		$filetype = $adb->query_result($res,$i,'type');
 
-		$filecontents = base64_encode(file_get_contents($filepath.$fileid."_".$filename));//fread(fopen($filepath.$filename, "r"), $filesize));
+		//Now we will not pass the file content to CP, when the customer click on the link we will retrieve
+		//$filecontents = base64_encode(file_get_contents($filepath.$fileid."_".$filename));//fread(fopen($filepath.$filename, "r"), $filesize));
 
 		$output[$i]['fileid'] = $fileid;
 		$output[$i]['filename'] = $filename;
 		$output[$i]['filetype'] = $filetype;
 		$output[$i]['filesize'] = $filesize;
-		$output[$i]['filecontents'] = $filecontents;
+		//$output[$i]['filecontents'] = $filecontents;
 	}
 
 	return $output;
+}
+
+/**	function used to get the contents of a file
+ *	@param int $contactid - customer ie., contact id 
+ *	@param int $fileid - id of the file to which we want contents
+ *	@param string $filename - name of the file to which we want contents
+ *	return $filecontents array with single file contents like [fileid] => filecontent
+ */
+function get_filecontent($contactid, $fileid, $filename)
+{
+	global $adb;
+	$query = "select vtiger_attachments.path from vtiger_troubletickets 
+		inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid = vtiger_troubletickets.ticketid 
+		inner join vtiger_attachments on vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid 
+		where 	vtiger_troubletickets.parent_id= $contactid and 
+			vtiger_attachments.attachmentsid= $fileid and 
+			vtiger_attachments.name='$filename'";
+	$res = $adb->query($query);
+
+	if($adb->num_rows($res)>0)
+	{
+		$filenamewithpath = $adb->query_result($res,0,'path').$fileid."_".$filename;
+		$filecontents[$fileid] = base64_encode(file_get_contents($filenamewithpath));
+		$adb->println("Going to return the content of the file ==> $filenamewithpath");
+	}
+	return $filecontents;
 }
 
 /**	function to add attachment for a ticket ie., the passed contents will be write in a file and the details will be stored in database

Modified: vtigercrm/branches/5.1_jens/soap/firefoxtoolbar.php
==============================================================================
--- vtigercrm/branches/5.1_jens/soap/firefoxtoolbar.php (original)
+++ vtigercrm/branches/5.1_jens/soap/firefoxtoolbar.php Mon Apr 16 12:27:44 2007
@@ -1,747 +1,759 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
-require_once("config.php");
-require_once('include/logging.php');
-require_once('include/nusoap/nusoap.php');
-require_once('include/database/PearDatabase.php');
-
-$log = &LoggerManager::getLogger('firefoxlog');
-
-$NAMESPACE = 'http://www.vtiger.com/products/crm';
-$server = new soap_server;
-$accessDenied = "You are not authorized for performing this action";
-$server->configureWSDL('vtigersoap');
-
-$server->register(
-    'get_version',
-      array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-       $NAMESPACE);
-
-$server->register(
-	'create_lead_from_webform',
-	array('username'=>'xsd:string', 
-		'lastname'=>'xsd:string',
-		'email'=>'xsd:string', 
-		'phone'=>'xsd:string', 
-		'company'=>'xsd:string', 
-		'country'=>'xsd:string', 
-		'description'=>'xsd:string'),
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
-
-
-
-
-$server->register(
-	'create_site_from_webform',
-	array('username'=>'xsd:string', 
-		'portalname'=>'xsd:string',
-		'portalurl'=>'xsd:string'), 
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
-
-
-
-$server->register(
-	'create_rss_from_webform',
-	array('username'=>'xsd:string', 
-		'rssurl'=>'xsd:string'),
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
-
-
-
-
-	
-$server->register(
-   'create_contacts',
-    array('user_name'=>'xsd:string','lastname'=>'xsd:string','phone'=>'xsd:string','mobile'=>'xsd:string','email'=>'xsd:string','street'=>'xsd:string','city'=>'xsd:string','state'=>'xsd:string','country'=>'xsd:string','zipcode'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-
-
-$server->register(
-	'create_account',
-    array('username'=>'xsd:string', 'accountname'=>'xsd:string', 'email'=>'xsd:string', 'phone'=>'xsd:string','$primary_address_street'=>'xsd:string','$primary_address_city'=>'xsd:string','$primary_address_state'=>'xsd:string','$primary_address_postalcode'=>'xsd:string','$primary_address_country'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-    
-    $server->register(
-	'create_ticket_from_toolbar',
-	array('username'=>'xsd:string', 'title'=>'xsd:string','description'=>'xsd:string','priority'=>'xsd:string','severity'=>'xsd:string','category'=>'xsd:string','user_name'=>'xsd:string','parent_id'=>'xsd:string','product_id'=>'xsd:string'),
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
- 
-
-$server->register(
-	'create_vendor_from_webform',
-	array('username'=>'xsd:string', 'vendorname'=>'xsd:string',
-		'email'=>'xsd:string', 
-		'phone'=>'xsd:string', 
-		'website'=>'xsd:string'), 
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
-
-
-$server->register(
-	'create_product_from_webform',
-	array('username'=>'xsd:string', 'productname'=>'xsd:string',
-		'productcode'=>'xsd:string', 
-		'website'=>'xsd:string'), 
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
-
-
-$server->register(
-	'create_note_from_webform',
-	array('username'=>'xsd:string', 'title'=>'xsd:string',
-		'notecontent'=>'xsd:string'), 
-	array('return'=>'xsd:string'),
-	$NAMESPACE);
-
-$server->register(
-    'LogintoVtigerCRM',
-    array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-    
-$server->register(
-    'CheckLeadPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckContactPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-    
-$server->register(
-    'CheckAccountPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckTicketPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckVendorPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckProductPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE); 
-
-$server->register(
-    'CheckNotePermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckSitePermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckRssPermission',
-    array('username'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-
-function CheckLeadPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Leads","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckContactPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Contacts","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckAccountPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Accounts","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckTicketPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("HelpDesk","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckVendorPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Vendors","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckProductPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Products","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckNotePermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Notes","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckSitePermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Portal","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckRssPermission($username)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("Rss","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-    
-function create_site_from_webform($username,$portalname,$portalurl)
-{
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	require_once("modules/Portal/Portal.php");
-	if(isPermitted("Portals","EditView") == "yes")
-	{
-		$result = SavePortal($portalname,$portalurl);
-
-		$adb->println("Create New Portal from Web Form - Ends");
-
-		if($result != '')
-		  return 'Portal added sucessfully';
-		else
-		  return "Portal creation failed. Try again";
-	}
-	else
-	{
-		return $accessDenied;
-	}
-}
-function LogintoVtigerCRM($user_name,$password)
-{
-	global $log;
-	require_once('modules/Users/Users.php');
-	
-	$return_access = "FALSE";
-	
-	$objuser = new Users();
-	
-	if($password != "")
-	{
-		$objuser->column_fields['user_name'] = $user_name;
-		$objuser->load_user($password);
-		if($objuser->is_authenticated())
-		{
-			$return_access = "TRUE";
-		}else
-		{
-			$return_access = "FALSE";
-		}
-	}else
-	{
-			//$server->setError("Invalid username and/or password");
-			$return_access = "FALSE";
-	}
-	$objuser = $objuser;
-	return $return_access;
-}
-
-function create_rss_from_webform($username,$url)
-{
-
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	require_once("modules/Rss/Rss.php");
-
-	$oRss = new vtigerRSS();
-	if(isPermitted("RSS","EditView") == "yes")
-	{
-		if($oRss->setRSSUrl($url))
-		{
-			if($oRss->saveRSSUrl($url) == false)
-			{
-				return "RSS feed addition failed. Try again";
-			}
-			else
-			{
-					return 'RSS feed added sucessfully.';
-			}
-
-	  }else
-	  {
-	     return "Not a valid RSS Feed or your Proxy Settings is not correct. Try again";
-    }
-	}
-	else
-	{
-		return $accessDenied;
-	}
-
-}
-
-
-function create_note_from_webform($username,$subject,$desc)
-{
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	$adb->println("Create New Note from Web Form - Starts");
-	require_once("modules/Notes/Notes.php");
-
-	$focus = new Notes();
-	if(isPermitted("Notes","EditView") == "yes")
-	{
-		$focus->column_fields['notes_title'] = $subject;
-		$focus->column_fields['notecontent'] = $desc;
-
-		$focus->save("Notes");
-
-		$focus->retrieve_entity_info($focus->id,"Notes");
-
-		$adb->println("Create New Note from Web Form - Ends");
-
-		if($focus->id != '')
-		return 'Note added sucessfully.';
-		else
-		return "Note creation failed. Try again";
-	}
-	else
-	{
-		return $accessDenied;
-	}
-
-}
-
-function create_product_from_webform($username,$productname,$code,$website)
-{
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	$adb->println("Create New Product from Web Form - Starts");
-	
-  require_once("modules/Products/Products.php");
-	if(isPermitted("Products","EditView") == "yes")
-	{
-		$focus = new Products();
-		$focus->column_fields['productname'] = $productname;
-		$focus->column_fields['productcode'] = $code;
-		$focus->column_fields['website'] = $website;
-		$focus->save("Products");
-		$adb->println("Create New Product from Web Form - Ends");
-
-		if($focus->id != '')
-		  return 'Product added sucessfully.';
-		else
-		  return "Product creation failed. Try again";
-	}
-	else
-	{
-		return $accessDenied;
-	}
-
-	
-}
-
-function create_vendor_from_webform($username,$vendorname,$email,$phone,$website)
-{
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	$adb->println("Create New Vendor from Web Form - Starts");
-	require_once("modules/Vendors/Vendors.php");
-	if(isPermitted("Vendors","EditView" ) == "yes")
-	{
-		$focus = new Vendors();
-		$focus->column_fields['vendorname'] = $vendorname;
-		$focus->column_fields['email'] = $email;
-		$focus->column_fields['phone'] = $phone;
-		$focus->column_fields['website'] = $website;
-
-		$focus->save("Vendors");
-
-		$focus->retrieve_entity_info($focus->id,"Vendors");
-
-		$adb->println("Create New Vendor from Web Form - Ends");
-
-		if($focus->id != '')
-		return 'Vendor added sucessfully';
-		else
-		return "Vendor creation failed. Try again";
-  }		
-  else
-	{
-		return $accessDenied;
-	}
-
-	
-}
-
-function create_ticket_from_toolbar($username,$title,$description,$priority,$severity,$category,$user_name,$parent_id,$product_id)
-{
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-
-	if(isPermitted("HelpDesk","EditView") == "yes")
-	{
-
-		$seed_ticket = new HelpDesk();
-		$output_list = Array();
-
-		require_once('modules/HelpDesk/HelpDesk.php');
-		$ticket = new HelpDesk();
-
-		$ticket->column_fields[ticket_title] = $title;
-		$ticket->column_fields[description]=$description;
-		$ticket->column_fields[ticketpriorities]=$priority;
-		$ticket->column_fields[ticketseverities]=$severity;
-		$ticket->column_fields[ticketcategories]=$category;
-		$ticket->column_fields[ticketstatus]='Open';
-
-		$ticket->column_fields[parent_id]=$parent_id;
-		$ticket->column_fields[product_id]=$product_id;
-		$ticket->column_fields[assigned_user_id]=$user_id;
-		//$ticket->saveentity("HelpDesk");
-		$ticket->save("HelpDesk");
-
-		if($ticket->id != '')
-      return "Ticket Created Sucessfully";
-    else
-      return "Error while creating Ticket.Try again";  
-	}
-	else
-	{
-		return $accessDenied;
-	}
-
-
-}
-
-function create_account($username,$accountname,$email,$phone,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country)
-{
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id,'Users');
-	require_once("modules/Accounts/Accounts.php");
-	if(isPermitted("Accounts","EditView") == "yes")
-	{
-		$account=new Accounts();
-		$account->column_fields['accountname']=$accountname;
-		$account->column_fields['email1']=$email;
-		$account->column_fields['phone']=$phone;
-		$account->column_fields['bill_street']=$primary_address_street;
-		$account->column_fields['bill_city']=$primary_address_city;
-		$account->column_fields['bill_state']=$primary_address_state;
-		$account->column_fields['bill_code']=$primary_address_postalcode;
-		$account->column_fields['bill_country']=$primary_address_country;
-		$account->column_fields['ship_street']=$primary_address_street;
-		$account->column_fields['ship_city']=$primary_address_city;
-		$account->column_fields['ship_state']=$primary_address_state;
-		$account->column_fields['ship_code']=$primary_address_postalcode;
-		$account->column_fields['ship_country']=$primary_address_country;
-		$account->column_fields['assigned_user_id']=$user_id;
-		$account->save('Accounts');
-		if($account->id != '')
-      return "Account added Sucessfully";
-    else
-      return "Error while adding Account.Try again";  
-	}
-	else
-	{
-		return $accessDenied;
-	}
-
-}
-
-
-
-function get_version($user_name, $password)
-{
-    return "5.0.0";
-}
-
-
-
-function create_lead_from_webform($username,$lastname,$email,$phone,$company,$country,$description)
-{
-
-	global $log;
-	global $adb;
-	global $current_user;
-	require_once("modules/Users/Users.php");
-	$seed_user=new Users();
-	$user_id=$seed_user->retrieve_user_id($username);
-	$current_user=$seed_user;
-	$current_user->retrieve_entity_info($user_id, 'Users');
-	$adb->println("Create New Lead from Web Form - Starts");
-	require_once("modules/Leads/Leads.php");
-
-	$focus = new Leads();
-	if(isPermitted("Leads","EditView") == "yes")
-	{
-		$focus->column_fields['lastname'] = $lastname;
-		$focus->column_fields['email'] = $email;
-		$focus->column_fields['phone'] = $phone;
-		$focus->column_fields['company'] = $company;
-		$focus->column_fields['country'] = $country;
-		$focus->column_fields['description'] = $description;
-		$focus->column_fields['assigned_user_id'] = $user_id;
-		$focus->save("Leads");
-		$adb->println("Create New Lead from Web Form - Ends");
-		if($focus->id != '')
-		  return 'Thank you for your interest. Information has been successfully added as Lead.';
-		else
-		  return "Lead creation failed. Try again";
-  }
-	else
-	{
-		return $accessDenied;
-	}
-
-
-}
-
-function create_contacts($user_name,$lastname,$phone,$mobile,$email,$street,$city,$state,$country,$zipcode)
-{
-  global $log;
-  $log->debug($user_name);
-  $birthdate = "0000-00-00";
-	
-	return create_contact1($user_name, "", $lastname, $email,"", "","", $mobile, "",$street,$city,$state,$zipcode,$country,$city,$street,$state,$zipcode,$country,$phone,"","","","",$birthdate,"","");
-	
-}
-
-function create_contact1($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone,$home_phone,$other_phone,$fax,$department,$birthdate,$assistant_name,$assistant_phone,$description='')
-{
-	global $adb,$log;
-	global $current_user;
-	require_once('modules/Users/Users.php');
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($user_name);
-	$current_user = $seed_user;
-	$current_user->retrieve_entity_info($user_id,'Users');
-
-	require_once('modules/Contacts/Contacts.php');
-  if(isPermitted("Contacts","EditView") == "yes")
-  {
-   $contact = new Contacts();
-   $contact->column_fields[firstname]= $first_name;
-   $contact->column_fields[lastname]= $last_name;
-   //$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX
-   $contact->column_fields[salutation]=$salutation;
-   // EMAIL IS NOT ADDED
-   $contact->column_fields[title]=$title;
-   $contact->column_fields[email]=$email_address;
-   $contact->column_fields[mobile]=$phone_mobile;
-   //$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
-   $contact->column_fields[mailingstreet]=$primary_address_street;
-   $contact->column_fields[mailingcity]=$primary_address_city;
-   $contact->column_fields[mailingcountry]=$primary_address_country;
-   $contact->column_fields[mailingstate]=$primary_address_state;
-   $contact->column_fields[mailingzip]=$primary_address_postalcode;
-   $contact->column_fields[otherstreet]=$alt_address_street;
-   $contact->column_fields[othercity]=$alt_address_city;
-   $contact->column_fields[othercountry]=$alt_address_country;
-   $contact->column_fields[otherstate]=$alt_address_state;
-   $contact->column_fields[otherzip]=$alt_address_postalcode;
-   $contact->column_fields[assigned_user_id]=$user_id;
-   // new Fields
-   $contact->column_fields[phone]= $office_phone;
-   $contact->column_fields[homephone]= $home_phone;
-   $contact->column_fields[otherphone]= $other_phone;
-   $contact->column_fields[fax]= $fax;
-   $contact->column_fields[department]=$department;
-   $contact->column_fields[birthday]= getDisplayDate($birthdate);
-   $contact->column_fields[assistant]= $assistant_name;
-   $contact->column_fields[assistantphone]= $assistant_phone;
-   $contact->column_fields[description]= $description;
-   $contact->save("Contacts");
-   if($contact->id != '')
-      return 'Contact added Sucessfully';
-   else
-      return "Contact creation failed. Try again";
-  }
-	else
-	{
-		return $accessDenied;
-	}
-
-}
-
-$server->service($HTTP_RAW_POST_DATA); 
-exit(); 
-?>
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+require_once("config.php");
+require_once('include/logging.php');
+require_once('include/nusoap/nusoap.php');
+require_once('include/database/PearDatabase.php');
+
+$log = &LoggerManager::getLogger('firefoxlog');
+
+$NAMESPACE = 'http://www.vtiger.com/products/crm';
+$server = new soap_server;
+$accessDenied = "You are not authorized for performing this action";
+$server->configureWSDL('vtigersoap');
+
+$server->register(
+    'get_version',
+      array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+       $NAMESPACE);
+
+$server->register(
+	'create_lead_from_webform',
+	array('username'=>'xsd:string', 
+		'lastname'=>'xsd:string',
+		'firstname'=>'xsd:string',
+		'email'=>'xsd:string', 
+		'phone'=>'xsd:string', 
+		'company'=>'xsd:string', 
+		'country'=>'xsd:string', 
+		'description'=>'xsd:string'),
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+
+
+
+
+$server->register(
+	'create_site_from_webform',
+	array('username'=>'xsd:string', 
+		'portalname'=>'xsd:string',
+		'portalurl'=>'xsd:string'), 
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+
+
+
+$server->register(
+	'create_rss_from_webform',
+	array('username'=>'xsd:string', 
+		'rssurl'=>'xsd:string'),
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+
+
+
+
+	
+$server->register(
+   'create_contacts',
+    array('user_name'=>'xsd:string','firstname'=>'xsd:string','lastname'=>'xsd:string','phone'=>'xsd:string','mobile'=>'xsd:string','email'=>'xsd:string','street'=>'xsd:string','city'=>'xsd:string','state'=>'xsd:string','country'=>'xsd:string','zipcode'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+
+
+$server->register(
+	'create_account',
+    array('username'=>'xsd:string', 'accountname'=>'xsd:string', 'email'=>'xsd:string', 'phone'=>'xsd:string','$primary_address_street'=>'xsd:string','$primary_address_city'=>'xsd:string','$primary_address_state'=>'xsd:string','$primary_address_postalcode'=>'xsd:string','$primary_address_country'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+    
+    $server->register(
+	'create_ticket_from_toolbar',
+	array('username'=>'xsd:string', 'title'=>'xsd:string','description'=>'xsd:string','priority'=>'xsd:string','severity'=>'xsd:string','category'=>'xsd:string','user_name'=>'xsd:string','parent_id'=>'xsd:string','product_id'=>'xsd:string'),
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+ 
+
+$server->register(
+	'create_vendor_from_webform',
+	array('username'=>'xsd:string', 'vendorname'=>'xsd:string',
+		'email'=>'xsd:string', 
+		'phone'=>'xsd:string', 
+		'website'=>'xsd:string'), 
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+
+
+$server->register(
+	'create_product_from_webform',
+	array('username'=>'xsd:string', 'productname'=>'xsd:string',
+		'productcode'=>'xsd:string', 
+		'website'=>'xsd:string'), 
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+
+
+$server->register(
+	'create_note_from_webform',
+	array('username'=>'xsd:string', 'title'=>'xsd:string',
+		'notecontent'=>'xsd:string'), 
+	array('return'=>'xsd:string'),
+	$NAMESPACE);
+
+$server->register(
+    'LogintoVtigerCRM',
+    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+    
+$server->register(
+    'CheckLeadPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckContactPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+    
+$server->register(
+    'CheckAccountPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckTicketPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckVendorPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckProductPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE); 
+
+$server->register(
+    'CheckNotePermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckSitePermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckRssPermission',
+    array('username'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+
+function CheckLeadPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Leads","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckContactPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Contacts","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckAccountPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Accounts","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckTicketPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("HelpDesk","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckVendorPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Vendors","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckProductPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Products","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckNotePermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Notes","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckSitePermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Portal","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckRssPermission($username)
+{
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("Rss","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+    
+function create_site_from_webform($username,$portalname,$portalurl)
+{
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	require_once("modules/Portal/Portal.php");
+	if(isPermitted("Portals","EditView") == "yes")
+	{
+		$result = SavePortal($portalname,$portalurl);
+
+		$adb->println("Create New Portal from Web Form - Ends");
+
+		if($result != '')
+		  return 'URL added sucessfully';
+		else
+		  return "Portal creation failed. Try again";
+	}
+	else
+	{
+		return $accessDenied;
+	}
+}
+function LogintoVtigerCRM($user_name,$password)
+{
+	global $log;
+	require_once('modules/Users/Users.php');
+	
+	$return_access = "FALSE";
+	
+	$objuser = new Users();
+	
+	if($password != "")
+	{
+		$objuser->column_fields['user_name'] = $user_name;
+		$objuser->load_user($password);
+		if($objuser->is_authenticated())
+		{
+			$return_access = "TRUE";
+		}else
+		{
+			$return_access = "FALSE";
+		}
+	}else
+	{
+			//$server->setError("Invalid username and/or password");
+			$return_access = "FALSE";
+	}
+	$objuser = $objuser;
+	return $return_access;
+}
+
+function create_rss_from_webform($username,$url)
+{
+
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	require_once("modules/Rss/Rss.php");
+
+	$oRss = new vtigerRSS();
+	if(isPermitted("RSS","EditView") == "yes")
+	{
+		if($oRss->setRSSUrl($url))
+		{
+			if($oRss->saveRSSUrl($url) == false)
+			{
+				return "RSS feed addition failed. Try again";
+			}
+			else
+			{
+					return 'RSS feed added sucessfully.';
+			}
+
+	  }else
+	  {
+	     return "Not a valid RSS Feed or your Proxy Settings is not correct. Try again";
+    }
+	}
+	else
+	{
+		return $accessDenied;
+	}
+
+}
+
+
+function create_note_from_webform($username,$subject,$desc)
+{
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	$adb->println("Create New Note from Web Form - Starts");
+	require_once("modules/Notes/Notes.php");
+
+	$focus = new Notes();
+	if(isPermitted("Notes","EditView") == "yes")
+	{
+		$focus->column_fields['notes_title'] = $subject;
+		$focus->column_fields['notecontent'] = $desc;
+
+		$focus->save("Notes");
+
+		$focus->retrieve_entity_info($focus->id,"Notes");
+
+		$adb->println("Create New Note from Web Form - Ends");
+
+		if($focus->id != '')
+		return 'Note added sucessfully.';
+		else
+		return "Note creation failed. Try again";
+	}
+	else
+	{
+		return $accessDenied;
+	}
+
+}
+
+function create_product_from_webform($username,$productname,$code,$website)
+{
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	$adb->println("Create New Product from Web Form - Starts");
+	
+  require_once("modules/Products/Products.php");
+	if(isPermitted("Products","EditView") == "yes")
+	{
+		$focus = new Products();
+		$focus->column_fields['productname'] = $productname;
+		$focus->column_fields['productcode'] = $code;
+		$focus->column_fields['website'] = $website;
+		$focus->save("Products");
+		$adb->println("Create New Product from Web Form - Ends");
+
+		if($focus->id != '')
+		  return 'Product added sucessfully.';
+		else
+		  return "Product creation failed. Try again";
+	}
+	else
+	{
+		return $accessDenied;
+	}
+
+	
+}
+
+function create_vendor_from_webform($username,$vendorname,$email,$phone,$website)
+{
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	$adb->println("Create New Vendor from Web Form - Starts");
+	require_once("modules/Vendors/Vendors.php");
+	if(isPermitted("Vendors","EditView" ) == "yes")
+	{
+		$focus = new Vendors();
+		$focus->column_fields['vendorname'] = $vendorname;
+		$focus->column_fields['email'] = $email;
+		$focus->column_fields['phone'] = $phone;
+		$focus->column_fields['website'] = $website;
+
+		$focus->save("Vendors");
+
+		$focus->retrieve_entity_info($focus->id,"Vendors");
+
+		$adb->println("Create New Vendor from Web Form - Ends");
+
+		if($focus->id != '')
+		return 'Vendor added sucessfully';
+		else
+		return "Vendor creation failed. Try again";
+  }		
+  else
+	{
+		return $accessDenied;
+	}
+
+	
+}
+
+function create_ticket_from_toolbar($username,$title,$description,$priority,$severity,$category,$user_name,$parent_id,$product_id)
+{
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+
+	if(isPermitted("HelpDesk","EditView") == "yes")
+	{
+
+		$seed_ticket = new HelpDesk();
+		$output_list = Array();
+
+		require_once('modules/HelpDesk/HelpDesk.php');
+		$ticket = new HelpDesk();
+
+		$ticket->column_fields[ticket_title] = $title;
+		$ticket->column_fields[description]=$description;
+		$ticket->column_fields[ticketpriorities]=$priority;
+		$ticket->column_fields[ticketseverities]=$severity;
+		$ticket->column_fields[ticketcategories]=$category;
+		$ticket->column_fields[ticketstatus]='Open';
+
+		$ticket->column_fields[parent_id]=$parent_id;
+		$ticket->column_fields[product_id]=$product_id;
+		$ticket->column_fields[assigned_user_id]=$user_id;
+		//$ticket->saveentity("HelpDesk");
+		$ticket->save("HelpDesk");
+
+		if($ticket->id != '')
+      return "Ticket Created Sucessfully";
+    else
+      return "Error while creating Ticket.Try again";  
+	}
+	else
+	{
+		return $accessDenied;
+	}
+
+
+}
+
+function create_account($username,$accountname,$email,$phone,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country)
+{
+	global $current_user,$log,$adb;
+	$log->DEBUG("Entering with data ".$username.$accountname.$email.$phone."<br>".$primary_address_street.$primary_address_city.$primary_address_state.$primary_address_postalcode.$primary_address_country);
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id,'Users');
+	require_once("modules/Accounts/Accounts.php");
+	if(isPermitted("Accounts","EditView") == "yes")
+	{
+		$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname ='".$accountname."' and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
+		$result = $adb->query($query);
+	        if($adb->num_rows($result) > 0)
+		{
+			return "Account Name already exists";
+			die;
+		}
+		$account=new Accounts();
+		$account->column_fields['accountname']=$accountname;
+		$account->column_fields['email1']=$email;
+		$account->column_fields['phone']=$phone;
+		$account->column_fields['bill_street']=$primary_address_street;
+		$account->column_fields['bill_city']=$primary_address_city;
+		$account->column_fields['bill_state']=$primary_address_state;
+		$account->column_fields['bill_code']=$primary_address_postalcode;
+		$account->column_fields['bill_country']=$primary_address_country;
+		$account->column_fields['ship_street']=$primary_address_street;
+		$account->column_fields['ship_city']=$primary_address_city;
+		$account->column_fields['ship_state']=$primary_address_state;
+		$account->column_fields['ship_code']=$primary_address_postalcode;
+		$account->column_fields['ship_country']=$primary_address_country;
+		$account->column_fields['assigned_user_id']=$user_id;
+		$account->save('Accounts');
+		if($account->id != '')
+      return "Account added Sucessfully";
+    else
+      return "Error while adding Account.Try again";  
+	}
+	else
+	{
+		return $accessDenied;
+	}
+
+}
+
+
+
+function get_version($user_name, $password)
+{
+    return "5.0.0";
+}
+
+
+
+function create_lead_from_webform($username,$lastname,$email,$phone,$company,$country,$description,$firstname)
+{
+
+	global $log;
+	global $adb;
+	global $current_user;
+	require_once("modules/Users/Users.php");
+	$seed_user=new Users();
+	$user_id=$seed_user->retrieve_user_id($username);
+	$current_user=$seed_user;
+	$current_user->retrieve_entity_info($user_id, 'Users');
+	$adb->println("Create New Lead from Web Form - Starts");
+	require_once("modules/Leads/Leads.php");
+
+	$focus = new Leads();
+	if(isPermitted("Leads","EditView") == "yes")
+	{
+		$focus->column_fields['lastname'] = $lastname;
+		$focus->column_fields['firstname'] = $firstname;
+		$focus->column_fields['email'] = $email;
+		$focus->column_fields['phone'] = $phone;
+		$focus->column_fields['company'] = $company;
+		$focus->column_fields['country'] = $country;
+		$focus->column_fields['description'] = $description;
+		$focus->column_fields['assigned_user_id'] = $user_id;
+		$focus->save("Leads");
+		$adb->println("Create New Lead from Web Form - Ends");
+		if($focus->id != '')
+		  return 'Thank you for your interest. Information has been successfully added as Lead.';
+		else
+		  return "Lead creation failed. Try again";
+  }
+	else
+	{
+		return $accessDenied;
+	}
+
+
+}
+
+function create_contacts($user_name,$firstname,$lastname,$phone,$mobile,$email,$street,$city,$state,$country,$zipcode)
+{
+	global $log;
+	$log->DEBUG("Entering into create_contacts");
+	$log->DEBUG($firstname."Firstisname");
+	$birthdate = "0000-00-00";
+	
+	return create_contact1($user_name, $firstname, $lastname, $email,"", "","", $mobile, "",$street,$city,$state,$zipcode,$country,$city,$street,$state,$zipcode,$country,$phone,"","","","",$birthdate,"","");
+	
+}
+
+function create_contact1($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone,$home_phone,$other_phone,$fax,$department,$birthdate,$assistant_name,$assistant_phone,$description='')
+{
+	global $adb,$log;
+	global $current_user;
+	require_once('modules/Users/Users.php');
+	$seed_user = new Users();
+	$user_id = $seed_user->retrieve_user_id($user_name);
+	$current_user = $seed_user;
+	$current_user->retrieve_entity_info($user_id,'Users');
+
+	require_once('modules/Contacts/Contacts.php');
+	$log->DEBUG($first_name."First & Name");
+  if(isPermitted("Contacts","EditView") == "yes")
+  {
+   $contact = new Contacts();
+   $contact->column_fields[firstname]= $first_name;
+   $contact->column_fields[lastname]= $last_name;
+   //$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX
+   $contact->column_fields[salutation]=$salutation;
+   // EMAIL IS NOT ADDED
+   $contact->column_fields[title]=$title;
+   $contact->column_fields[email]=$email_address;
+   $contact->column_fields[mobile]=$phone_mobile;
+   //$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
+   $contact->column_fields[mailingstreet]=$primary_address_street;
+   $contact->column_fields[mailingcity]=$primary_address_city;
+   $contact->column_fields[mailingcountry]=$primary_address_country;
+   $contact->column_fields[mailingstate]=$primary_address_state;
+   $contact->column_fields[mailingzip]=$primary_address_postalcode;
+   $contact->column_fields[otherstreet]=$alt_address_street;
+   $contact->column_fields[othercity]=$alt_address_city;
+   $contact->column_fields[othercountry]=$alt_address_country;
+   $contact->column_fields[otherstate]=$alt_address_state;
+   $contact->column_fields[otherzip]=$alt_address_postalcode;
+   $contact->column_fields[assigned_user_id]=$user_id;
+   // new Fields
+   $contact->column_fields[phone]= $office_phone;
+   $contact->column_fields[homephone]= $home_phone;
+   $contact->column_fields[otherphone]= $other_phone;
+   $contact->column_fields[fax]= $fax;
+   $contact->column_fields[department]=$department;
+   $contact->column_fields[birthday]= getDisplayDate($birthdate);
+   $contact->column_fields[assistant]= $assistant_name;
+   $contact->column_fields[assistantphone]= $assistant_phone;
+   $contact->column_fields[description]= $description;
+   $contact->save("Contacts");
+   if($contact->id != '')
+      return 'Contact added Sucessfully';
+   else
+      return "Contact creation failed. Try again";
+  }
+	else
+	{
+		return $accessDenied;
+	}
+
+}
+
+$server->service($HTTP_RAW_POST_DATA); 
+exit(); 
+?>

Modified: vtigercrm/branches/5.1_jens/soap/thunderbirdplugin.php
==============================================================================
--- vtigercrm/branches/5.1_jens/soap/thunderbirdplugin.php (original)
+++ vtigercrm/branches/5.1_jens/soap/thunderbirdplugin.php Mon Apr 16 12:27:44 2007
@@ -1,547 +1,581 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
-require_once("config.php");
-require_once('include/logging.php');
-require_once('include/nusoap/nusoap.php');
-require_once('include/database/PearDatabase.php');
-require_once('modules/Contacts/Contacts.php');
-
-$log = &LoggerManager::getLogger('thunderbirdplugin');
-
-$accessDenied = "You are not authorized for performing this action";
-$NAMESPACE = 'http://www.vtiger.com/products/crm';
-$server = new soap_server;
-
-$server->configureWSDL('vtigersoap');
-
-$server->register(
- 	    'create_session',
- 	    array('user_name'=>'xsd:string','password'=>'xsd:string'),
- 	    array('return'=>'xsd:string'),
- 	    $NAMESPACE);
-
-$server->register(
- 	    'end_session',
- 	    array('user_name'=>'xsd:string'),
- 	    array('return'=>'xsd:string'),
- 	    $NAMESPACE);
-
-$server->register(
-    'SearchContactsByEmail',
-    array('username'=>'xsd:string','emailaddress'=>'xsd:string'),
-    array('return'=>'tns:contactdetails'),
-    $NAMESPACE);
-
-$server->register(
-		'GetContacts',
-    array('username'=>'xsd:string'),
-    array('return'=>'tns:contactdetails'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckContactPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
-
-$server->register(
-    'CheckContactViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
-
-$server->register(
-	  'AddContact',
-    array('user_name'=>'xsd:string',
-          'first_name'=>'xsd:string',
-          'last_name'=>'xsd:string',
-          'email_address'=>'xsd:string',
-          'account_name'=>'xsd:string',
-          'salutation'=>'xsd:string',
-          'title'=>'xsd:string',
-          'phone_mobile'=>'xsd:string',
-          'reports_to'=>'xsd:string',
-          'primary_address_street'=>'xsd:string',
-          'primary_address_city'=>'xsd:string',
-          'primary_address_state'=>'xsd:string' ,
-          'primary_address_postalcode'=>'xsd:string',
-          'primary_address_country'=>'xsd:string',
-          'alt_address_city'=>'xsd:string',
-          'alt_address_street'=>'xsd:string',
-          'alt_address_state'=>'xsd:string',
-          'alt_address_postalcode'=>'xsd:string',
-          'alt_address_country'=>'xsd:string',
-          'office_phone'=>'xsd:string',
-          'home_phone'=>'xsd:string',
-          'fax'=>'xsd:string',
-          'department'=>'xsd:string',
-          'description'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-	  'AddLead',
-    array('user_name'=>'xsd:string',
-          'first_name'=>'xsd:string',
-          'last_name'=>'xsd:string',
-          'email_address'=>'xsd:string',
-          'account_name'=>'xsd:string',
-          'salutation'=>'xsd:string',
-          'title'=>'xsd:string',
-          'phone_mobile'=>'xsd:string',
-          'reports_to'=>'xsd:string',
-          'primary_address_street'=>'xsd:string',
-          'primary_address_city'=>'xsd:string',
-          'primary_address_state'=>'xsd:string' ,
-          'primary_address_postalcode'=>'xsd:string',
-          'primary_address_country'=>'xsd:string',
-          'alt_address_city'=>'xsd:string',
-          'alt_address_street'=>'xsd:string',
-          'alt_address_state'=>'xsd:string',
-          'alt_address_postalcode'=>'xsd:string',
-          'alt_address_country'=>'xsd:string',
-          'office_phone'=>'xsd:string',
-          'home_phone'=>'xsd:string',
-          'fax'=>'xsd:string',
-          'department'=>'xsd:string',
-	  'description'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-	'track_email',
-    array('user_name'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:date', 'email_subject'=>'xsd:string', 'email_body'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->wsdl->addComplexType(
-    'contactdetail',
-    'complexType',
-    'struct',
-    'all',
-    '',
-    array(
-	      'id' => array('name'=>'id','type'=>'xsd:string'),
-        'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
-        'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
-        'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'),
-        'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
-        'middlename' => array('name'=>'middlename','type'=>'xsd:string'),
-        'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'),
-        'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'),
-        'department'=> array('name'=>'department','type'=>'xsd:string'),
-        'title' => array('name'=>'title','type'=>'xsd:string'),
-        'officephone'=> array('name'=>'officephone','type'=>'xsd:string'),
-        'homephone'=> array('name'=>'homephone','type'=>'xsd:string'),
-        'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
-        'fax'=> array('name'=>'fax','type'=>'xsd:string'),
-        'mobile'=> array('name'=>'mobile','type'=>'xsd:string'),
-        'asstname'=> array('name'=>'asstname','type'=>'xsd:string'),
-        'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'),
-        'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'),
-        'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'),
-        'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'),
-        'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'),
-        'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'),
-        'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'),
-        'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'),
-        'othercity'=> array('name'=>'othercity','type'=>'xsd:string'),
-        'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'),
-        'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'),
-        'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'),
-        'description'=> array('name'=>'description','type'=>'xsd:string'),
-        'category'=> array('name'=>'category','type'=>'xsd:string'),
-    )
-);
-
-$server->wsdl->addComplexType(
-    'contactdetails',
-    'complexType',
-    'array',
-    '',
-    'SOAP-ENC:Array',
-    array(),
-    array(
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]')
-    ),
-    'tns:contactdetail'
-);
-
-
-function SearchContactsByEmail($username,$emailaddress)
-{
-     require_once('modules/Contacts/Contacts.php');
-
-     $seed_contact = new Contacts();
-     $output_list = Array();
-
-     $response = $seed_contact->get_searchbyemailid($username,$emailaddress);
-     $contactList = $response['list'];
-
-     // create a return array of names and email addresses.
-     foreach($contactList as $contact)
-     {
-          $output_list[] = Array(
-               "id" => $contact[contactid],
-               "firstname" => $contact[firstname],
-               "lastname" => $contact[lastname],
-               "emailaddress" => $contact[email],
-               "accountname" => $contact[accountname],
-          );
-     }
-
-     //to remove an erroneous compiler warning
-     $seed_contact = $seed_contact;
-     return $output_list;
-}
-
-function track_email($user_name, $contact_ids, $date_sent, $email_subject, $email_body)
-{
-	global $adb;
-	require_once('modules/Users/Users.php');
-	require_once('modules/Emails/Emails.php');
-
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($user_name);
-
-	$email = new Emails();
-	//$log->debug($msgdtls['contactid']);
-	$emailbody = str_replace("'", "''", $email_body);
-	$emailsubject = str_replace("'", "''",$email_subject);
-	$datesent = getDisplayDate($date_sent);
-
-	$email->column_fields[subject] = $emailsubject;
-	$email->column_fields[assigned_user_id] = $user_id;
-	$email->column_fields[date_start] = $datesent;
-	$email->column_fields[description]  = htmlentities($emailbody);
-	$email->column_fields[activitytype] = 'Emails';
-	$email->plugin_save = true;
-	$email->save("Emails");
-
-	$email->set_emails_contact_invitee_relationship($email->id,$contact_ids);
-	$email->set_emails_se_invitee_relationship($email->id,$contact_ids);
-	$email->set_emails_user_invitee_relationship($email->id,$user_id);
-	$sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contact_ids."'";
-	$result = $adb->query($sql);
-	$camodulerow = $adb->fetch_array($result);
-	if(isset($camodulerow))
-	{
-		$emailid = $camodulerow["email"];
-		$query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contact_ids."@77|".'","THUNDERBIRD")';
-		$adb->query($query);
-	}
-	return $email->id;
-}
-
-
-function GetContacts($username)
-{
-	global $adb;
-	global $log;
-	require_once('modules/Contacts/Contacts.php');
-
-	$seed_contact = new Contacts();
-	$output_list = Array();
-
-	$query = $seed_contact->get_contactsforol($username);
-	$result = $adb->query($query);
-
-	while($contact = $adb->fetch_array($result))
-	{
-		if($contact["birthdate"] == "0000-00-00")
-		{
-			$contact["birthdate"] = "";
-		}
-		if($contact["salutation"] == "--None--")
-		{
-			$contact["salutation"] = "";
-		}
-
-		$namelist = explode(" ", $contact["lastname"]);
-		if(isset($namelist))
-		{
-			if(count($namelist) >= 2)
-			{
-				$contact["lastname"] = $namelist[count($namelist)-1];
-				for($i=0; $i<count($namelist)-2; $i++)
-				{
-					$middlename[] = $namelist[$i];
-				}
-				if(isset($middlename))
-				{
-					$middlename = implode(" ",$middlename);
-				}
-			}
-		}
-
-		$output_list[] = Array(
-				"id" => $contact["id"],
-				"title" => $contact["salutation"],
-				"firstname" => $contact["firstname"],
-				"middlename" => trim($middlename),
-				"lastname" => trim($contact["lastname"]),
-				"birthdate" => $contact["birthday"],
-				"emailaddress" => $contact["email"],
-				"jobtitle" => $contact["title"],
-				"department" => $contact["department"],
-				"accountname" => $contact["accountname"],
-				"officephone" => $contact["phone"],
-				"homephone" => $contact["homephone"],
-				"otherphone" => $contact["otherphone"],
-				"fax" => $contact["fax"],
-				"mobile" => $contact["mobile"],
-				"asstname" => $contact["assistant"],
-				"asstphone" => $contact["assistantphone"],
-				"reportsto" => $contact["reports_to_name"],
-				"mailingstreet" => $contact["mailingstreet"],
-				"mailingcity" => $contact["mailingcity"],
-				"mailingstate" => $contact["mailingstate"],
-				"mailingzip" => $contact["mailingzip"],
-				"mailingcountry" => $contact["mailingcountry"],
-				"otherstreet" => $contact["otherstreet"],
-				"othercity" => $contact["othercity"],
-				"otherstate" => $contact["otherstate"],
-				"otherzip" => $contact["otherzip"],
-				"othercountry" => $contact["othercountry"],
-				"description" => "",
-				"category" => "",
-			  );
-	}
-	//to remove an erroneous compiler warning
-	$seed_contact = $seed_contact;
-	return $output_list;
-}
-
-function retrieve_account_id($account_name,$user_id)
-{
-
-	if($account_name=="")
-	{
-		return null;
-	}
-
-	$query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
-
-
-	$db = new PearDatabase();
-	$result=  $db->query($query) or die ("Not able to execute insert");
-
-	$rows_count =  $db->getRowCount($result);
-	if($rows_count==0)
-	{
-		require_once('modules/Accounts/Accounts.php');
-		$account = new Accounts();
-		$account->column_fields[accountname] = $account_name;
-		$account->column_fields[assigned_user_id]=$user_id;
-		//$account->saveentity("Accounts");
-		$account->save("Accounts");
-		//mysql_close();
-		return $account->id;
-	}
-	else if ($rows_count==1)
-	{
-		$row = $db->fetchByAssoc($result, 0);
-		//mysql_close();
-		return $row["accountid"];
-	}
-	else
-	{
-		$row = $db->fetchByAssoc($result, 0);
-		//mysql_close();
-		return $row["accountid"];
-	}
-
-}
-
-function AddContact($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone="",$home_phone="",$fax="",$department="",$description="")
-{
-	global $adb;
-	global $current_user;
-	require_once('modules/Users/Users.php');
-	require_once('modules/Contacts/Contacts.php');
-
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($user_name);
-	$current_user = $seed_user;
-	$current_user->retrieve_entity_info($user_id,"Users");
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
-  }
-
-	$contact = new Contacts();
-	$contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
-	$contact->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
-	$contact->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
-	$contact->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
-	$contact->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
-	$contact->column_fields[department]=in_array('department',$permitted_lists) ? $department : "";
-	$contact->column_fields[account_id]=in_array('account_id',$permitted_lists) ? retrieve_account_id($account_name,$user_id) : "";
-	$contact->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
-	$contact->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
-	$contact->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
-	$contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
-	$contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
-	$contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
-	$contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
-	$contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
-	$contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $primary_address_country : "";
-	$contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $alt_address_street : "";
-	$contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $alt_address_city : "";
-	$contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $alt_address_state : "";
-	$contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $alt_address_postalcode : "";
-	$contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $alt_address_country : "";
-	$contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
-	$contact->column_fields[description]= "";
-	$contact->save("Contacts");
-
-  $contact = $contact;
-	return $contact->id;
-}
-
-function AddLead($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to ,$primary_address_street , $website ,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone="",$home_phone="",$fax="",$department="",$description="")
-{
-	global $adb;
-	global $current_user;
-	require_once('modules/Users/Users.php');
-	require_once('modules/Leads/Leads.php');
-
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($user_name);
-	$current_user = $seed_user;
-	$current_user->retrieve_entity_info($user_id,"Users");
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select fieldname,columnname from vtiger_field where tabid=7 and block <> 14";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.block <> 14 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
-  }
-
-	$Lead = new Leads();
-	$Lead->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
-	$Lead->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
-	$Lead->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
-	$Lead->column_fields[company]=in_array('company',$permitted_lists) ? $account_name : "";
-	$Lead->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
-	$Lead->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
-	$Lead->column_fields[designation]=in_array('designation',$permitted_lists) ? $department : "";
-	$Lead->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
-	$Lead->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
-	$Lead->column_fields[website]=in_array('website',$permitted_lists) ? $website : "";
-	$Lead->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
-	$Lead->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
-	$Lead->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
-	$Lead->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
-	$Lead->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
-	$Lead->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
-	$Lead->column_fields[workCountry]=in_array('mailingcountry',$permitted_lists) ? $workCountry : "";
-	$Lead->column_fields[street]=in_array('street',$permitted_lists) ? $alt_address_street : "";
-	$Lead->column_fields[city]=in_array('city',$permitted_lists) ? $alt_address_city : "";
-	$Lead->column_fields[state]=in_array('state',$permitted_lists) ? $alt_address_state : "";
-	$Lead->column_fields[code]=in_array('code',$permitted_lists) ? $alt_address_postalcode : "";
-	$Lead->column_fields[country]=in_array('country',$permitted_lists) ? $alt_address_country : "";
-	$Lead->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
-	$Lead->column_fields[description]= "";
-//	$log->fatal($Lead->column_fields);
-	$Lead->save("Leads");
-
-  	$Lead = $Lead;
-	return $Lead->id;
-}
-
-function create_session($user_name, $password)
-{
-  global $adb,$log;
-  $return_access = 'failure';
-  require_once('modules/Users/Users.php');
-	$objuser = new Users();
-  if($password != "" && $user_name != '')
-	{
-		$objuser->column_fields['user_name'] = $user_name;
-		$encrypted_password = $objuser->encrypt_password($password);
-		$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
-		$result = $adb->query($query);
-		if($adb->num_rows($result) > 0)
-		{
-			$return_access = 'success';
-			$log->debug("Logged in sucessfully from thunderbirdplugin");
-		}else
-		{
-			$return_access = 'failure';
-			$log->debug("Logged in failure from thunderbirdplugin");
-		}
-	}else
-	{
-		$return_access = 'failure';
-		$log->debug("Logged in failure from thunderbirdplugin");
-  }
-	return $return_access;
-}
-
-function end_session($user_name)
-{
-        return "Success";
-}
-
-function CheckContactPerm($user_name)
-{
-  global $current_user;
-	require_once('modules/Users/Users.php');
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($user_name);
-	$current_user = $seed_user;
-	$current_user->retrieve_entity_info($user_id,"Users");
-	if(isPermitted("Contacts","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckContactViewPerm($user_name)
-{
-  global $current_user,$log;
-	require_once('modules/Users/Users.php');
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($user_name);
-	$current_user = $seed_user;
-	$current_user->retrieve_entity_info($user_id,"Users");
-	if(isPermitted("Contacts","index") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-$server->service($HTTP_RAW_POST_DATA);
-exit();
-?>
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+require_once("config.php");
+require_once('include/logging.php');
+require_once('include/nusoap/nusoap.php');
+require_once('include/database/PearDatabase.php');
+require_once('modules/Contacts/Contacts.php');
+
+$log = &LoggerManager::getLogger('thunderbirdplugin');
+
+$accessDenied = "You are not authorized for performing this action";
+$NAMESPACE = 'http://www.vtiger.com/products/crm';
+$server = new soap_server;
+
+$server->configureWSDL('vtigersoap');
+
+$server->register(
+ 	    'create_session',
+ 	    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+ 	    array('return'=>'xsd:string'),
+ 	    $NAMESPACE);
+
+$server->register(
+ 	    'end_session',
+ 	    array('user_name'=>'xsd:string'),
+ 	    array('return'=>'xsd:string'),
+ 	    $NAMESPACE);
+
+$server->register(
+    'SearchContactsByEmail',
+    array('username'=>'xsd:string','emailaddress'=>'xsd:string'),
+    array('return'=>'tns:contactdetails'),
+    $NAMESPACE);
+
+$server->register(
+		'GetContacts',
+    array('username'=>'xsd:string'),
+    array('return'=>'tns:contactdetails'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckContactPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
+
+$server->register(
+    'CheckContactViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
+
+$server->register(
+	'CheckLeadViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
+
+$server->register(
+	  'AddContact',
+    array('user_name'=>'xsd:string',
+          'first_name'=>'xsd:string',
+          'last_name'=>'xsd:string',
+          'email_address'=>'xsd:string',
+          'account_name'=>'xsd:string',
+          'salutation'=>'xsd:string',
+          'title'=>'xsd:string',
+          'phone_mobile'=>'xsd:string',
+          'reports_to'=>'xsd:string',
+          'primary_address_street'=>'xsd:string',
+          'primary_address_city'=>'xsd:string',
+          'primary_address_state'=>'xsd:string' ,
+          'primary_address_postalcode'=>'xsd:string',
+          'primary_address_country'=>'xsd:string',
+          'alt_address_city'=>'xsd:string',
+          'alt_address_street'=>'xsd:string',
+          'alt_address_state'=>'xsd:string',
+          'alt_address_postalcode'=>'xsd:string',
+          'alt_address_country'=>'xsd:string',
+          'office_phone'=>'xsd:string',
+          'home_phone'=>'xsd:string',
+          'fax'=>'xsd:string',
+          'department'=>'xsd:string',
+          'description'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+	  'AddLead',
+    array('user_name'=>'xsd:string',
+          'first_name'=>'xsd:string',
+          'last_name'=>'xsd:string',
+          'email_address'=>'xsd:string',
+          'account_name'=>'xsd:string',
+          'salutation'=>'xsd:string',
+          'title'=>'xsd:string',
+          'phone_mobile'=>'xsd:string',
+          'reports_to'=>'xsd:string',
+          'primary_address_street'=>'xsd:string',
+          'primary_address_city'=>'xsd:string',
+          'primary_address_state'=>'xsd:string' ,
+          'primary_address_postalcode'=>'xsd:string',
+          'primary_address_country'=>'xsd:string',
+          'alt_address_city'=>'xsd:string',
+          'alt_address_street'=>'xsd:string',
+          'alt_address_state'=>'xsd:string',
+          'alt_address_postalcode'=>'xsd:string',
+          'alt_address_country'=>'xsd:string',
+          'office_phone'=>'xsd:string',
+          'home_phone'=>'xsd:string',
+          'fax'=>'xsd:string',
+          'department'=>'xsd:string',
+	  'description'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+	'track_email',
+    array('user_name'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:date', 'email_subject'=>'xsd:string', 'email_body'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->wsdl->addComplexType(
+    'contactdetail',
+    'complexType',
+    'struct',
+    'all',
+    '',
+    array(
+	      'id' => array('name'=>'id','type'=>'xsd:string'),
+        'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
+        'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
+        'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'),
+        'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
+        'middlename' => array('name'=>'middlename','type'=>'xsd:string'),
+        'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'),
+        'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'),
+        'department'=> array('name'=>'department','type'=>'xsd:string'),
+        'title' => array('name'=>'title','type'=>'xsd:string'),
+        'officephone'=> array('name'=>'officephone','type'=>'xsd:string'),
+        'homephone'=> array('name'=>'homephone','type'=>'xsd:string'),
+        'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
+        'fax'=> array('name'=>'fax','type'=>'xsd:string'),
+        'mobile'=> array('name'=>'mobile','type'=>'xsd:string'),
+        'asstname'=> array('name'=>'asstname','type'=>'xsd:string'),
+        'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'),
+        'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'),
+        'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'),
+        'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'),
+        'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'),
+        'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'),
+        'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'),
+        'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'),
+        'othercity'=> array('name'=>'othercity','type'=>'xsd:string'),
+        'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'),
+        'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'),
+        'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'),
+        'description'=> array('name'=>'description','type'=>'xsd:string'),
+        'category'=> array('name'=>'category','type'=>'xsd:string'),
+    )
+);
+
+$server->wsdl->addComplexType(
+    'contactdetails',
+    'complexType',
+    'array',
+    '',
+    'SOAP-ENC:Array',
+    array(),
+    array(
+        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]')
+    ),
+    'tns:contactdetail'
+);
+
+
+function SearchContactsByEmail($username,$emailaddress)
+{
+     require_once('modules/Contacts/Contacts.php');
+
+     $seed_contact = new Contacts();
+     $output_list = Array();
+
+     $response = $seed_contact->get_searchbyemailid($username,$emailaddress);
+     $contactList = $response['list'];
+
+     // create a return array of names and email addresses.
+     foreach($contactList as $contact)
+     {
+          $output_list[] = Array(
+               "id" => $contact[contactid],
+               "firstname" => $contact[firstname],
+               "lastname" => $contact[lastname],
+               "emailaddress" => $contact[email],
+               "accountname" => $contact[accountname],
+          );
+     }
+
+     //to remove an erroneous compiler warning
+     $seed_contact = $seed_contact;
+     return $output_list;
+}
+
+function track_email($user_name, $contact_ids, $date_sent, $email_subject, $email_body)
+{
+	global $current_user;
+	global $adb;
+	global $log;
+	require_once('modules/Users/Users.php');
+	require_once('modules/Emails/Emails.php');
+
+	$current_user = new Users();
+	$user_id = $current_user->retrieve_user_id($user_name);
+	$query = "select email1 from vtiger_users where id =".$user_id;
+	$result = $adb->query($query);
+	$user_emailid = $adb->query_result($result,0,"email1");
+	$current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
+	$email = new Emails();
+	//$log->debug($msgdtls['contactid']);
+	$emailbody = str_replace("'", "''", $email_body);
+	$emailsubject = str_replace("'", "''",$email_subject);
+	$datesent = getDisplayDate($date_sent);
+
+	$email->column_fields[subject] = $emailsubject;
+	$email->column_fields[assigned_user_id] = $user_id;
+	$email->column_fields[date_start] = $datesent;
+	$email->column_fields[description]  = htmlentities($emailbody);
+	$email->column_fields[activitytype] = 'Emails';
+	$email->plugin_save = true;
+	$email->save("Emails");
+	$query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4";
+	$result = $adb->query($query);
+	$field_id = $adb->query_result($result,0,"fieldid");
+	$email->set_emails_contact_invitee_relationship($email->id,$contact_ids);
+	$email->set_emails_se_invitee_relationship($email->id,$contact_ids);
+	$email->set_emails_user_invitee_relationship($email->id,$user_id);
+	$sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contact_ids."'";
+	$result = $adb->query($sql);
+	$camodulerow = $adb->fetch_array($result);
+	if(isset($camodulerow))
+	{
+		$emailid = $camodulerow["email"];
+		$query = 'insert into vtiger_emaildetails values ('.$email->id.',"'.$emailid.'","'.$user_emailid.'","","","","'.$user_id.'@-1|'.$contact_ids.'@'.$field_id.'|","THUNDERBIRD")';
+		$adb->query($query);
+	}
+	return $email->id;
+}
+
+
+function GetContacts($username)
+{
+	global $adb;
+	global $log;
+	require_once('modules/Contacts/Contacts.php');
+
+	$seed_contact = new Contacts();
+	$output_list = Array();
+
+	$query = $seed_contact->get_contactsforol($username);
+	$result = $adb->query($query);
+
+	while($contact = $adb->fetch_array($result))
+	{
+		if($contact["birthdate"] == "0000-00-00")
+		{
+			$contact["birthdate"] = "";
+		}
+		if($contact["salutation"] == "--None--")
+		{
+			$contact["salutation"] = "";
+		}
+
+		$namelist = explode(" ", $contact["lastname"]);
+		if(isset($namelist))
+		{
+			if(count($namelist) >= 2)
+			{
+				$contact["lastname"] = $namelist[count($namelist)-1];
+				for($i=0; $i<count($namelist)-2; $i++)
+				{
+					$middlename[] = $namelist[$i];
+				}
+				if(isset($middlename))
+				{
+					$middlename = implode(" ",$middlename);
+				}
+			}
+		}
+
+		$output_list[] = Array(
+				"id" => $contact["id"],
+				"title" => $contact["salutation"],
+				"firstname" => $contact["firstname"],
+				"middlename" => trim($middlename),
+				"lastname" => trim($contact["lastname"]),
+				"birthdate" => $contact["birthday"],
+				"emailaddress" => $contact["email"],
+				"jobtitle" => $contact["title"],
+				"department" => $contact["department"],
+				"accountname" => $contact["accountname"],
+				"officephone" => $contact["phone"],
+				"homephone" => $contact["homephone"],
+				"otherphone" => $contact["otherphone"],
+				"fax" => $contact["fax"],
+				"mobile" => $contact["mobile"],
+				"asstname" => $contact["assistant"],
+				"asstphone" => $contact["assistantphone"],
+				"reportsto" => $contact["reports_to_name"],
+				"mailingstreet" => $contact["mailingstreet"],
+				"mailingcity" => $contact["mailingcity"],
+				"mailingstate" => $contact["mailingstate"],
+				"mailingzip" => $contact["mailingzip"],
+				"mailingcountry" => $contact["mailingcountry"],
+				"otherstreet" => $contact["otherstreet"],
+				"othercity" => $contact["othercity"],
+				"otherstate" => $contact["otherstate"],
+				"otherzip" => $contact["otherzip"],
+				"othercountry" => $contact["othercountry"],
+				"description" => "",
+				"category" => "",
+			  );
+	}
+	//to remove an erroneous compiler warning
+	$seed_contact = $seed_contact;
+	return $output_list;
+}
+
+function retrieve_account_id($account_name,$user_id)
+{
+
+	if($account_name=="")
+	{
+		return null;
+	}
+
+	$query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
+
+
+	$db = new PearDatabase();
+	$result=  $db->query($query) or die ("Not able to execute insert");
+
+	$rows_count =  $db->getRowCount($result);
+	if($rows_count==0)
+	{
+		require_once('modules/Accounts/Accounts.php');
+		$account = new Accounts();
+		$account->column_fields[accountname] = $account_name;
+		$account->column_fields[assigned_user_id]=$user_id;
+		//$account->saveentity("Accounts");
+		$account->save("Accounts");
+		//mysql_close();
+		return $account->id;
+	}
+	else if ($rows_count==1)
+	{
+		$row = $db->fetchByAssoc($result, 0);
+		//mysql_close();
+		return $row["accountid"];
+	}
+	else
+	{
+		$row = $db->fetchByAssoc($result, 0);
+		//mysql_close();
+		return $row["accountid"];
+	}
+
+}
+
+function AddContact($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone="",$home_phone="",$fax="",$department="",$description="")
+{
+	global $adb;
+	global $current_user;
+	require_once('modules/Users/Users.php');
+	require_once('modules/Contacts/Contacts.php');
+
+	$seed_user = new Users();
+	$user_id = $seed_user->retrieve_user_id($user_name);
+	$current_user = $seed_user;
+	$current_user->retrieve_entity_info($user_id,"Users");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+  }
+
+	$contact = new Contacts();
+	$contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
+	$contact->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
+	$contact->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
+	$contact->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
+	$contact->column_fields[department]=in_array('department',$permitted_lists) ? $department : "";
+	$contact->column_fields[account_id]=in_array('account_id',$permitted_lists) ? retrieve_account_id($account_name,$user_id) : "";
+	$contact->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
+	$contact->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
+	$contact->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
+	$contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
+	$contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
+	$contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
+	$contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
+	$contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
+	$contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $primary_address_country : "";
+	$contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $alt_address_street : "";
+	$contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $alt_address_city : "";
+	$contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $alt_address_state : "";
+	$contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $alt_address_postalcode : "";
+	$contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $alt_address_country : "";
+	$contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+	$contact->column_fields[description]= "";
+	$contact->save("Contacts");
+
+  $contact = $contact;
+	return $contact->id;
+}
+
+function AddLead($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to ,$primary_address_street , $website ,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone="",$home_phone="",$fax="",$department="",$description="")
+{
+	global $adb;
+	global $current_user;
+	require_once('modules/Users/Users.php');
+	require_once('modules/Leads/Leads.php');
+
+	$seed_user = new Users();
+	$user_id = $seed_user->retrieve_user_id($user_name);
+	$current_user = $seed_user;
+	$current_user->retrieve_entity_info($user_id,"Users");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select fieldname,columnname from vtiger_field where tabid=7 and block <> 14";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.block <> 14 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+  }
+
+	$Lead = new Leads();
+	$Lead->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
+	$Lead->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
+	$Lead->column_fields[company]=in_array('company',$permitted_lists) ? $account_name : "";
+	$Lead->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
+	$Lead->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
+	$Lead->column_fields[designation]=in_array('designation',$permitted_lists) ? $department : "";
+	$Lead->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
+	$Lead->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
+	$Lead->column_fields[website]=in_array('website',$permitted_lists) ? $website : "";
+	$Lead->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
+	$Lead->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
+	$Lead->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
+	$Lead->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
+	$Lead->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
+	$Lead->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
+	$Lead->column_fields[workCountry]=in_array('mailingcountry',$permitted_lists) ? $workCountry : "";
+	$Lead->column_fields[street]=in_array('street',$permitted_lists) ? $alt_address_street : "";
+	$Lead->column_fields[city]=in_array('city',$permitted_lists) ? $alt_address_city : "";
+	$Lead->column_fields[state]=in_array('state',$permitted_lists) ? $alt_address_state : "";
+	$Lead->column_fields[code]=in_array('code',$permitted_lists) ? $alt_address_postalcode : "";
+	$Lead->column_fields[country]=in_array('country',$permitted_lists) ? $alt_address_country : "";
+	$Lead->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+	$Lead->column_fields[description]= "";
+//	$log->fatal($Lead->column_fields);
+	$Lead->save("Leads");
+
+  	$Lead = $Lead;
+	return $Lead->id;
+}
+
+function create_session($user_name, $password)
+{
+  global $adb,$log;
+  $return_access = 'failure';
+  require_once('modules/Users/Users.php');
+	$objuser = new Users();
+	if($password != "" && $user_name != '')
+	{
+		$objuser->column_fields['user_name'] = $user_name;
+		$encrypted_password = $objuser->encrypt_password($password);
+		if($objuser->load_user($password) && $objuser->is_authenticated())
+		{
+			$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
+			$result = $adb->query($query);
+			if($adb->num_rows($result) > 0)
+			{
+				$return_access = 'success';
+				$log->debug("Logged in sucessfully from thunderbirdplugin");
+			}else
+			{
+				$return_access = 'failure';
+				$log->debug("Logged in failure from thunderbirdplugin");
+			}
+		}
+	}else
+	{
+		$return_access = 'failure';
+		$log->debug("Logged in failure from thunderbirdplugin");
+	}
+	return $return_access;
+}
+
+function end_session($user_name)
+{
+        return "Success";
+}
+
+function CheckContactPerm($user_name)
+{
+  global $current_user;
+	require_once('modules/Users/Users.php');
+	$seed_user = new Users();
+	$user_id = $seed_user->retrieve_user_id($user_name);
+	$current_user = $seed_user;
+	$current_user->retrieve_entity_info($user_id,"Users");
+	if(isPermitted("Contacts","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckContactViewPerm($user_name)
+{
+  global $current_user,$log;
+	require_once('modules/Users/Users.php');
+	$seed_user = new Users();
+	$user_id = $seed_user->retrieve_user_id($user_name);
+	$current_user = $seed_user;
+	$current_user->retrieve_entity_info($user_id,"Users");
+	if(isPermitted("Contacts","index") == "yes")
+	{	
+		if(isPermitted("Emails","EditView") == "yes")
+		{
+			return "allowed";
+		}
+		else
+		{
+			return "email";
+		}
+	}else
+	{
+		return "contact";
+	}
+}
+
+function CheckLeadViewPerm($user_name)
+{
+  global $current_user,$log;
+	require_once('modules/Users/Users.php');
+	$seed_user = new Users();
+	$user_id = $seed_user->retrieve_user_id($user_name);
+	$current_user = $seed_user;
+	$current_user->retrieve_entity_info($user_id,"Users");
+	if(isPermitted("Leads","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+$server->service($HTTP_RAW_POST_DATA);
+exit();
+?>

Modified: vtigercrm/branches/5.1_jens/soap/vtigerolservice.php
==============================================================================
--- vtigercrm/branches/5.1_jens/soap/vtigerolservice.php (original)
+++ vtigercrm/branches/5.1_jens/soap/vtigerolservice.php Mon Apr 16 12:27:44 2007
@@ -307,12 +307,17 @@
 
 function AddMessageToContact($username,$contactid,$msgdtls)
 {
+	global $current_user;
 	global $adb;
 	require_once('modules/Users/Users.php');
 	require_once('modules/Emails/Emails.php');
 	
-	$seed_user = new Users();
-	$user_id = $seed_user->retrieve_user_id($username);
+	$current_user = new Users();
+	$user_id = $current_user->retrieve_user_id($username);
+	$query = "select email1 from vtiger_users where id =".$user_id;
+	$result = $adb->query($query);
+	$user_emailid = $adb->query_result($result,0,"email1");
+	$current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
 	
 	foreach($msgdtls as $msgdtl)
 	{
@@ -331,17 +336,19 @@
         $email->column_fields[activitytype] = 'Emails'; 
         $email->plugin_save = true; 
         $email->save("Emails");
-        
+	$query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4";
+	$result = $adb->query($query);
+	$field_id = $adb->query_result($result,0,"fieldid");
         $email->set_emails_contact_invitee_relationship($email->id,$contactid);
         $email->set_emails_se_invitee_relationship($email->id,$contactid);
-        $email->set_emails_user_invitee_relationship($email->id,$user_id);
+	$email->set_emails_user_invitee_relationship($email->id,$user_id);
         $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contactid."'";
         $result = $adb->query($sql);
         $camodulerow = $adb->fetch_array($result);
         if(isset($camodulerow))
         {
             $emailid = $camodulerow["email"];
-            $query = 'insert into vtiger_emaildetails values ('.$email->id.',"","'.$emailid.'","","","","'.$contactid."@77|".'","OUTLOOK")';
+			$query = 'insert into vtiger_emaildetails values ('.$email->id.',"'.$emailid.'","'.$user_emailid.'","","","","'.$user_id.'@-1|'.$contactid.'@'.$field_id.'|","OUTLOOK")';
             $adb->query($query);
         }
         return $email->id;
@@ -353,31 +360,36 @@
 	}
 }
 
-function LoginToVtiger($userid,$password)
-{
+function LoginToVtiger($userid,$password,$version)
+{
+	global $log;
 	global $adb;
+	$log->DEBUG("Entered into vtigerCRM with userid".$userid." and Version".$version);
+	include('vtigerversion.php');	
+	if($version != $vtiger_current_version)
+	{
+		return "VERSION";
+	}
 	require_once('modules/Users/Users.php');
-	
 	$return_access = "FALSE";
-	
 	$objuser = new Users();
-	
 	if($password != "")
 	{
 		$objuser->column_fields['user_name'] = $userid;
 		$objuser->load_user($password);
 		if($objuser->is_authenticated())
 		{
-			$return_access = "TRUE";
+			$return_access = "TRUES";
 		}else
 		{
-			$return_access = "FALSE";
+			$return_access = "LOGIN";
 		}
 	}else
 	{
 			//$server->setError("Invalid username and/or password");
 			$return_access = "FALSE";
 	}
+$log->DEBUG("The return access to outlook was ".$return_access." from vtigerCRM");
 	$objuser = $objuser;
 	return $return_access;
 }
@@ -391,7 +403,7 @@
 	$current_user=$seed_user;
 	$current_user->retrieve_entity_info($user_id, 'Users');
 
-	if(isPermitted("Emails","EditView") == "yes")
+	if(isPermitted("Emails","EditView") == "yes" && (isPermitted("Contacts","index") == 'yes'))
 	{
 		return "allowed";
 	}else
@@ -595,7 +607,7 @@
 	{
 		if(isset($cntrow))
 		{
-		  		$contact->column_fields[salutation]=in_array('salutation',$permitted_lists) ? $cntrow["title"] : "";		
+		  		$contact->column_fields[salutationtype]=in_array('salutationtype',$permitted_lists) ? $cntrow["title"] : "";		
      			$contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $cntrow["firstname"] : "";
     			
     			if($cntrow["middlename"] != "")
@@ -677,7 +689,7 @@
 		if(isset($cntrow))
 		{
 			$contact->retrieve_entity_info($cntrow["id"],"Contacts");
-			$contact->column_fields[salutation]=in_array('salutation',$permitted_lists) ? $cntrow["title"] : "";		
+			$contact->column_fields[salutationtype]=in_array('salutationtype',$permitted_lists) ? $cntrow["title"] : "";		
 			$contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $cntrow["firstname"] : "";
 			if($cntrow["middlename"] != "")
 			{
@@ -751,7 +763,7 @@
 		return null;
 	}
 
-	$query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
+	$query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .addslashes($account_name)."'";
 
 
 	$db = new PearDatabase();

Modified: vtigercrm/branches/5.1_jens/soap/wordplugin.php
==============================================================================
--- vtigercrm/branches/5.1_jens/soap/wordplugin.php (original)
+++ vtigercrm/branches/5.1_jens/soap/wordplugin.php Mon Apr 16 12:27:44 2007
@@ -327,19 +327,22 @@
 	$objuser = new Users();
 	if($password != "" && $user_name != '')
 	{
-		$objuser->column_fields['user_name'] = $user_name;
-		$encrypted_password = $objuser->encrypt_password($password);
-		$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
-		$result = $adb->query($query);
-		if($adb->num_rows($result) > 0)
-		{
-			$return_access = "TempSessionID";
-			$log->debug("Logged in sucessfully from wordplugin");
-		}else
-		{
-			$return_access = "false";
-			$log->debug("Logged in failure from wordplugin");
-		}
+			$objuser->column_fields['user_name'] = $user_name;
+			$encrypted_password = $objuser->encrypt_password($password);
+			if($objuser->load_user($password) && $objuser->is_authenticated())
+			{
+				$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
+				$result = $adb->query($query);
+				if($adb->num_rows($result) > 0)
+				{
+					$return_access = "TempSessionID";
+					$log->debug("Logged in sucessfully from wordplugin");
+				}else
+				{
+					$return_access = "false";
+					$log->debug("Logged in failure from wordplugin");
+				}
+			}
 	}else
 	{
 		$return_access = "false";

Modified: vtigercrm/branches/5.1_jens/tabdata.php
==============================================================================
--- vtigercrm/branches/5.1_jens/tabdata.php (original)
+++ vtigercrm/branches/5.1_jens/tabdata.php Mon Apr 16 12:27:44 2007
@@ -11,7 +11,7 @@
 
 //This file contains the commonly used variables 
 
-$tab_info_array=array('Home'=>3,'Leads'=>7,'Accounts'=>6,'Contacts'=>4,'Potentials'=>2,'Notes'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,'Products'=>14,'Dashboard'=>1,'Faq'=>15,'Events'=>16,'Vendors'=>18,'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,'Webmails'=>28,);
+$tab_info_array=array('Home'=>3,'Leads'=>7,'Accounts'=>6,'Contacts'=>4,'Potentials'=>2,'Notes'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,'Products'=>14,'Dashboard'=>1,'Faq'=>15,'Events'=>16,'Vendors'=>18,'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,'Webmails'=>28,'Users'=>29,);
 
 $tab_seq_array=array('3'=>0,'7'=>0,'6'=>0,'4'=>0,'2'=>0,'8'=>0,'9'=>0,'10'=>0,'13'=>0,'14'=>0,'1'=>0,'15'=>0,'16'=>2,'18'=>0,'19'=>0,'20'=>0,'21'=>0,'22'=>0,'23'=>0,'24'=>0,'25'=>0,'26'=>0,'27'=>0,'28'=>0,);
 ?>

Modified: vtigercrm/branches/5.1_jens/themes/alphagrey/images/aboutUS.jpg
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/branches/5.1_jens/themes/alphagrey/images/cal12x12Shared.gif
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/branches/5.1_jens/themes/alphagrey/style.css
==============================================================================
--- vtigercrm/branches/5.1_jens/themes/alphagrey/style.css (original)
+++ vtigercrm/branches/5.1_jens/themes/alphagrey/style.css Mon Apr 16 12:27:44 2007
@@ -1,2219 +1,2284 @@
-/*********************************************************************************
-
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
- ********************************************************************************/
-
-
-/* ALPHA GRAY  - COLOR THEME*/
-
-.small {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-}
-.big {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 12px;
-	line-height: 18px;
-	color: #000000;
-	font-weight:bold;
-}
-
-.componentName {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	line-height: 18px;
-	color: #000;
-	font-weight:bold;
-	border-left:2px dotted #333;
-	padding:10px;
-}
-
-
-.genHeaderBig{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 16px;
-	line-height: 19px;
-	color: #000000;
-	font-weight:bold;
-}
-.genHeaderSmall{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	line-height: 16px;
-	color: #000000;
-	font-weight:bold;
-	
-}
-
-.moduleName {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	color: #000000;
-	font-weight:bold;
-}
-
-
-.hdrNameBg {
-	 background:#ffffff url(images/hdrNameBg.gif) repeat-x;
-	
-	
-}
-
-.hdrTabBg {
-	/*background:#ffffff url(images/hdrTabBg.gif) bottom repeat-x ;*/
-	background-color:#dadada;
-}  
-
-.tabSelected {
-	background:#eeeeee url(images/tabSelectedBg.gif) repeat-x;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-weight:bold;
-	font-size: 11px;
-	padding-left:10px;
-	padding-right:10px;
-	padding-top:2px;
-	padding-bottom:2px;
-	
-}
-
-.tabSelected a{
-	color:white;
-}
-
-.tabUnSelected {
-	
-	background: #eaeaea url(images/tabUnSelectedBg.gif) bottom repeat-x;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	padding-left:10px;
-	padding-right:10px;
-	padding-top:2px;
-	padding-bottom:2px;
-	border-bottom:1px solid #ffffff;
-}
-
-.tabUnSelected a{
-	color:#000099;
-}
-
-.tabSeperator {
-	background-color:#aaa;
-	width:1px;
-}
-
-
-
-/*.level2text {
-    
-    font-family: Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    padding-left:15px;
-    padding-right:15px;
-    padding-top:5px;
-    padding-bottom:5px;
-    font-weight:bold;
-    color:white;
-}
-
-.level2text a{
-	text-decoration:none;
-	color:#555555;
-}
-
-.level2text a:hover {
-	text-decoration:underline;
-	color:#555555;
-
-}*/
-
-
-.level2Bg {
-	/*background:#999 url(images/level2TabBg.gif) bottom repeat-x;*/
-	background-color:#9a9a9a;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	border-bottom:1px dashed #fff;
-	color:white;
-}
-
-.level2Bg a{
-	/* background:#1F5BFF url(images/level2TabBg.gif) bottom repeat-x; */
-	color:#fff;
-}
-
-
-.level2SelTab{
-	font-weight:bold;
-	color:#000000;
-	padding-left:20px;
-	padding-right:20px;
-	padding-top:5px;
-	padding-bottom:5px;
-	
-}
-	
-.level2UnSelTab{
-	color:#000000;
-	padding-left:20px;
-	padding-right:20px;
-	padding-top:5px;
-	padding-bottom:5px;
-}
-.sep1 {
-	background:#999999;
-}
-
-.showPanelBg {
-	background:url(images/showPanelTopBg.gif) repeat-x;
-}
-
-a {
-	text-decoration:none;
-	color:#000099;
-}
-
-a:hover {
-	text-decoration:underline;
-}
-
-.hdrLink {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	text-decoration:none;
-	color:#000099;
-	font-weight:bold;
-}
-
-.hdrLink:hover {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	text-decoration:underline;
-	color:#000099;
-	font-weight:bold;
-}
-
-.searchBox {
-	border: 0px solid #0000aa;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	padding-left:2px;
-	width:100px;
-	background-color:#ffffef;
-}
-
-.searchBtn {
-	border :0px #cccccc solid;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	font-weight:bold;
-	width:30px;
-	height:19px;
-	background-color:#555;
-	color:white;
-}
-
-
-/* List View Table classes starts  +++++++++++++++++ */
-
-.lvt {
-	background-color:#ccc;
-	border:1px solid #ccc; 
-}
-
-.lvtBg {
-}
-
-.lvtHeaderText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	font-weight:bold;
-}
-
-.lvtCol {
-	border-top:1px solid #eaeaea;
-	border-left:1px solid #eaeaea;
-	border-right:1px solid #999;
-	border-bottom:1px solid #999;
-	background-color:#ccc;
-	font-weight:bold;
-}
-
-.lvtColData {
-	background-color:#ffffff;
-}
-
-.lvtColDataHover {
-	background-color:#ffffee;
-	
-}
-
-
-/* List View Table classes ends --------------------------------*/
-
-
-
-/* Detailed View classes starts +++++++++++++++++++++++ */
-.dvHeaderText{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	color:#000000;
-	font-weight:bold;
-
-}
-
-.dvInnerHeader{
-	border-bottom:2px dotted #555;
-	padding:5px;
-	background-color:#dadada;
-
-}
-
-.dvtSelectedCell {
-	border-left:2px solid #aaaaaa;
-	border-top:2px solid #aaaaaa;
-	border-right:2px solid #aaaaaa;
-	padding-left:20px;
-	padding-right:20px;
-	background-color:white;
-	font-weight:bold;
-}
-
-.dvtUnSelectedCell {
-	border-left:2px solid #aaaaaa;
-	border-top:2px solid #aaaaaa;
-	border-right:2px solid #aaaaaa;
-	border-bottom:2px solid #aaaaaa;
-	padding-left:20px;
-	padding-right:20px;
-	background-color:#f5f5f5;
-	cursor:pointer;
-}
-
-.dvtTabCache {
-	border-bottom:2px solid #aaaaaa;
-}
-
-.dvtContentSpace {
-	border-left:2px solid #aaaaaa;
-	border-right:2px solid #aaaaaa;
-	border-bottom:2px solid #aaaaaa;
-	padding-left:0px;
-}
-.dvtCellLabel, .cellLabel {
-	background-color:#efefef;
-	padding-right:10px;
-	padding-left:10px;
-	border-bottom:1px solid #dddddd;
-	border-top:1px solid #ffffff ;
-	color:#545454;
-	white-space:nowrap;
-	font-weight:bold;
-}
-
-.dvtCellInfo, .cellInfo {
-	padding-left:10px;
-	padding-right:10px;
-	border-bottom:1px dotted #efefef;
-	white-space:nowrap;
-}
-
-.rightMailMerge {
-	border:2px solid #aaa;
-}
-
-.rightMailMergeHeader {
-	border-bottom:1px solid #ddd;
-	padding:5px;
-	background-color:#efefef;
-
-}
-
-.rightMailMergeContent {
-	padding:5px;
-	background-color:#fafafa;
-
-}
-.detailedViewHeader{
-	border-bottom:2px solid #dadada;
-    	padding:5px;
-    	background-color:#aaaaaa;
-}
-
-.detailedViewTextBox {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#ffffff;
-}
-.detailedViewTextBoxOn {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#ffffdd;
-}
-
-.advSearch {
-	padding:10px;
-	border-left:1px solid #eaeaea; 
-	border-right:1px solid #eaeaea; 
-	border-bottom:1px solid #eaeaea; 	
-	overflow:auto;
-	width:600px;
-	height:150px;
-	background-color:#f5f5f5;
-
-}
-
-.searchAlph {
-	border:1px solid #dadada;
-	background-color:#ffffff;
-	cursor:pointer;
-	width:10px
-
-}
-.searchAlphselected {
-	border:1px solid #666666;
-	background-color:#bbbbbb;
-	cursor:pointer;
-	width:10px
-
-}
-.textbox {
-	border:1px solid #999999;
-	background-color:#ffffff;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	width:120px;
-	padding:2px;
-
-}
-.mx {
-}
-.calListTable td{
-	border-bottom:1px solid #efefef;
-	border-left:1px solid #efefef;
-}
-.calDIV {
-	width:100%;
-	border:1px solid #999999;
-	
-}
-.calDayHour {
-	border-top:1px solid #dddddd;
-	border-left:1px solid #dddddd;
-	border-bottom:1px solid #dddddd;
-	border-right:1px solid #dddddd;
-	background-color:#eaeaea;
-}
-.calAddEvent {
-	position:absolute;
-	z-index:10000;
-	width:500px;
-	left:200px;
-	top:150px;
-	background-color:#ffffff;
-}
-.addEventInnerBox {
-	border:1px dotted #dadada;
-
-}
-.cellNormal {
-	border:0px;
-	background-color:#ffffff;
-}
-.EventToDo{
-
-}
-
-.thumbnail{
-    background-color:#ffffff;
-padding: 7px;
-border: 1px solid #ddd;
-float: left;
-	   margin-right: 10px;
-	   margin-bottom: 15px;
-}
-.padTab{
-    padding-top:0px;
-    padding-left:0px;
-    padding-left:10px;
-    padding-bottom:0px;
-    vertical-align:top;
-
-}
-#company{
-    position:relative;
-    width:100%;
-    height:200px;
-    display:block;
-    background-color:#FFFFFF;
-    white-space:nowrap;
-    overflow:auto;
-    border:1px solid #CCCCCC;
-}
-                               
-
-#user{position:relative;left:0px;top:0px;width:100%;display:block;}
-#communication{position:relative;left:0px;top:0px;width:100%;display:block;}
-#config{position:relative;left:0px;top:0px;width:100%;display:block;}
-#userTab{position:relative;left:0px;top:0px;width:100%;display:none;}
-#one{
-	position:relative;
-	display:block;
-	width:245px;
-}
-
-#mnuTab1{
-
-   position:relative;
-
-   overflow:auto;
-
-   width:100%;
-
-   display:none;
-
-}
-
-#mnuTab2{
-
-   position:relative;
-
-   overflow:auto;
-
-   width:100%;
-
-   display:none;
-
-}
-
-
-/* End of Settings */
-
-.bggray{
-	background-color: #dfdfdf;
-}
-.bgwhite{
-	background-color: #FFFFFF;
-}
-.copy{
-	font-size:9px;
-	font-family: Verdana, Arial, Helvetica, Sans-serif;
-}
-
-#basicTab{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:block;
-}
-
-#moreTab{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:none;
-}
-
-/*Added for Advance Seearch*/
-
-#one{
-	position:relative;
-	display:block;
-	width:245px;
-}
-
-
-/* Dashboard CSS */
-a.dash_href{
-	display:block;
-	width:24px;height:24px;
-	vertical-align:middle;
-	margin-top:10px;
-}
-
-
-.dashHeading {
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:24px;
-	font-weight:bold;
-	color:#fff;
-}
-
-.dashSelectBg{
-	background-image:url(images/dashSelectBg.gif);
-	background-repeat:repeat-x;
-}
-.dash_top{
-	background-image:url(images/dashTopBg.gif);
-	background-repeat:repeat-x;
-	height:63px;
-	vertical-align:middle;
-}
-
-.dash_border{
-	background-color:#bfbfbf;
-	padding:5px;
-}
-.dash_white{
-	background-color:#FFFFFF;
-	padding:5px 10px 5px 10px;
-}
-
-.dash_bdr_btm{
-	border-bottom:2px dotted #dadada;
-}
-
-.dash_count{
-	font-size:36px;
-	font-weight:bold;
-	text-decoration:none;
-	color:#000000;
-	padding-left:10px;padding-right:10px;	
-}
-.dash_switch{
-	cursor:pointer;
-	width:26px;
-	height:26px;
-}
-
-.dash_row_sel{
-	background-image:url(images/dash_sel_chart.jpg);
-	background-repeat:no-repeat;
-	background-position:center;
-	width:26px;height:26px;
-	text-align:center;
-	vertical-align:middle;
-	font-weight:bold;
-	font-size:10px;
-	text-decoration:none;
-}
-
-.dash_row_unsel{
-	background-image:url(images/dash_unsel_chart.jpg);
-	background-repeat:no-repeat;
-	background-position:center;
-	width:26px;height:26px;
-	text-align:center;
-	vertical-align:middle;
-	font-weight:normal;
-	font-size:10px;
-	text-decoration:none;
-	cursor:pointer;
-}
-
-.dash_chart_btm{
-	border-bottom:2px solid #000000;
-}
-
-
-.dash_bottom{
-	background-image:url(images/dashBottomBg.gif);
-	background-repeat:repeat-x;
-	height:99px;
-	vertical-align:middle;
-}
-
-.dash_btm{
-	background-image:url(images/dash_btm_center.jpg);
-	background-repeat:repeat-x;
-	position:top;
-}
-  
-/*  menu */
-
-
-
- a.submenu{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:11px;
-	padding-top:5px;
-	padding-bottom:5px;
-	padding-left:10px;
-	border-bottom:1px solid #CCCCCC;
-	background-color:#ECECEC;
-	color:#000000;
-	text-align:left;
-	text-decoration:none;
-	display:block;
-}
-
-a.submenu:Hover{
-	background-color:#DDDDDD;
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:11px;
-	padding-top:5px;
-	padding-bottom:5px;
-	padding-left:10px;
-	border-bottom:1px solid #CCCCCC;
-	color:#000000;
-	text-align:left;
-	text-decoration:none;
-	display:block;
-} 
-
-#mnuKey{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:11px;
-	background-color:#666666;
-	color:#FFFFFF;
-	text-decoration:none;
-	padding:5px;
-	font-weight:bold;
-	width:8px;
-	cursor:pointer;
-	vertical-align:top;
-	height:100px;
-	position:relative;
-	top:0px;
-	left:0px;
-}
-
-#slidemenu{
-	height:525px;
-	vertical-align:top;
-	width:100px;
-	background-color:#CCCCCC;
-	border-right:1px solid #CCCCCC;
-	opacity:.9;
-	display:none;
-}*/
-
-/* clock */
-
-.citystyle{
-	position:relative;
-	top:0px;
-	left:0px;
-	text-align:left;
-	
-}
-#theClockLayer{
-	position:relative;
-	height:180px;
-	left:20px;
-	text-align:center;
-}
-.handsanddotsstyle{
-	margin-top:10px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:2px;
-	height:2px;
-	font-size:2px;
-	background-color:#000000;
-}
-.facestyle{
-	margin-top:10px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:15px;
-	height:15px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-.datestyle{
-	margin-top:20px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:100px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-.ampmstyle{
-	margin-top:23px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:20px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-
-#wclock{
-	position:absolute;
-	left:100px;
-	top:100px;
-	display:none;
-	background-color:#CCCCCC;
-	width:175px;
-}
-
-.leftFormBorder1 {
-	border: 1px solid #AFC8E4;
-	background-color: #FFFFFF;
-	opacity:.7;
-}
-
-
-
-
-/* Calculator */
-.calcResult {
-	width: 100%;
-	height: 25px;
-	background-color: #FFFFCC;/*CBDFD6*/
-	border-top: 1px solid #CCC;
-	border-left: 0px;
-	border-right: 1px solid #CCC;
-	border-bottom: 1px solid #CCC;
-	font-size: 10px;
-	text-align: right;
-}
-.calcMem {
-	width: 100%;
-	height: 25px;
-	border-top: 1px solid #CCC;
-	border-left: 1px solid #CCC;
-	border-right: 0px;
-	border-bottom: 1px solid #CCC;
-	background-color: #FFFFCC;/*CBDFD6*/
-	font-family: Arial;
-	font-size: 10px;
-	color: #BBB;
-	text-align: left;
-}
-.calcBlackBtn, .calcGreyBtn, .calcBigBtn, .calcCancBtn, .calcMemBtn, .calcBackBtn {
-	border: none;
-	height: 20px;
-	font-size: 11px;
-	color: #FFF;
-	text-align:center;
-}
-.calcBackBtn {
-	background: url(images/calc_back_btn.gif) no-repeat;
-	width:25px;
-}
-.calcBlackBtn {
-	background: url(images/calc_black_btn.gif) no-repeat;
-	width:25px;
-}
-.calcGreyBtn {
-	background: url(images/calc_grey_btn.gif) no-repeat;
-	width:25px;
-}
-.calcCancBtn {
-	background: url(images/calc_canc_btn.gif) no-repeat;
-	width:25px;
-	
-}
-.calcMemBtn {
-	background: url(images/calc_mem_btn.gif) no-repeat;
-	width:25px;
-	/*background-color: #CCC;*/
-}
-#calc{
-	position:absolute;
-	left:100px;
-	top:100px;
-	background-color:#FFFFFF;
-	width:185px;
-	border-bottom:2px solid #000000;
-	border-right:2px solid #666666;
-	border-left:2px solid #CCCCCC;
-	border-top:2px solid #CCCCCC;
-}
-
-/* RSS STYLES */
-
-.subHdr{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#FFFFFF;
-	background-image:url(images/rssHeader.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-}
-
-.delBg{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#FFFFFF;
-	background-image:url(images/rssdelete.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-}
-
-#rssScroll{
-	font-family:Arial, Helvetica, sans-serif	;
-	font-size:12px;
-	background-color:#FFFFFF;
-	width:100%;
-	height:130px;
-	overflow:auto;
-	border:0px solid #000000;
-}
-
-.rssTable{
-	width:100%;
-	border:0px solid #CCCCCC;
-}
-
-.rssTable tr th{
-	background-color:#a9a9a9;
-	text-align:left;
-	border-bottom:1px solid #555;
-	border-top:1px solid #FFFFFF;
-	color:#000000;
-	padding-left:5px;
-	padding-right:5px;
-	height:20px;
-}
-
-.rssTable tr td{
-	text-align:left;
-	border-bottom:1px dotted #dadada;
-	border-left:1px dotted #dadada;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	font-weight:normal;
-	white-space:nowrap;
-	padding:2px;
-	
-}
-.forwardBg{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#000000;
-	background-image:url(images/rssforward.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-	background-color:#D7D7D7;
-}
-
-
-/*  New Styles */
-
-.mnuTab{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#000000;
-	width:100%;
-	border:0px solid #000000;
-}
-
-.mnuTab tr td{
-	border-bottom:1px solid #EBEBEB;
-	padding-left:5px;
-	vertical-align:middle;
-}
-/* profile */
-
-.prvPrfBigText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-.prvPrfTopBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfBottomBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfOutline {
-	border:1px solid #ebebeb;
-}
-
-.prvPrfTexture {
-	background:url(images/prvPrfTexture1.gif);
-
-}
-.prvPrfHoverOn {
-	background-color:#ffffef;
-	
-}
-/*  Organization */
-
-.orgTab{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	font-weight:normal;
-	color:#666666;
-	border:0px solid #9B9B9B;
-	border-collapse:collapse;
-	width:100%;
-}
-
-.orgTab tr th{
-	text-align:left;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	text-decoration:none;
-	font-weight:bold;
-	height:20px;
-	padding-left:5px;
-}
-
-.orgTab tr td{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-decoration:none;
-	font-weight:normal;
-	padding-left:5px;
-	height:20px;
-	border-bottom:1px solid #CCCCCC;
-	border-right:1px solid #CCCCCC;
-}
-
-/* Groups */
-.groupli{
-	margin-left:20px;
-	font-family:Arial, Helvetica, sans-serif;
-	font-weight:normal;
-	font-size:12px;
-	text-decoration:none;
-	color:#333333;
-	list-style-type:none;
-	text-align:left;
-}
-
-/* tree menu */
-
-/*Oraganization Edit Features */
-
-#orgLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:500px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	display:block;
-	position:absolute;
-	left:0px;
-	top:0px;
-}
-
-/*  Role */
-
-#roleLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:300px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	display:none;
-	position:absolute;
-}
-
-.classBtn{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	text-decoration:none;
-	font-weight:normal;
-	font-size:10px;
-	background-color:#DBDBDB;
-	border-bottom:2px solid #999999;
-	border-right:2px solid #999999;
-	border-top:2px solid #F5F5F5;
-	border-left:2px solid #F5F5F5;
-	color:#000000;
-	text-align:center;
-	padding-top:3px;
-	padding-bottom:3px;
-}
-
-
-.txtBox{
-	width:85%;
-	border:1px solid #666666;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-}
-
-/*  IMPORT LEADS */
-
-.leadTable{
-	border:3px solid #CCCCCC;
-	border-collapse:collapse;
-}
-
-.leadTable tr td{
-/*	border:0px solid #CCCCCC;*/
-}
-
-.genHeaderGray{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	line-height: 16px;
-	color: #888888;
-	font-weight:bold;
-}
-
-.genHeaderGrayBig{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	line-height: 16px;
-	color: #888888;
-	font-weight:bold;
-}
-
-.importBox{
-	width:125px;
-	border:1px solid #666666;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-}
-.txtGreen{
-	color:green;
-}
-
-/* PICK LIST */
-ul li{
-	padding-bottom:2px;
-	padding-top:2px;
-}
-/* MY PREFERENCES */		
-/* CSS FOR REPORTS */
-
-.reportHdr{
-	background-color:#DDDDDD;
-	font-size:12px;
-	font-weight:bold;
-	vertical-align:middle;
-	text-align:left;
-	height:30px;
-	border-bottom:2px solid #959595;
-	color:#000000;
-	padding-left:10px;
-}
-
-#reportLay{
-	width:175px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-#locateMap{
-	width:120px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-
- a.reportMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:none;
-	display:block;
-	width:155px;
-	height:20px;
-	border-bottom:1px solid #E1E1E1;
-	padding-left:20px;
-	padding-top:3px;
-}
-
-a.reportMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-	display:block;
-	width:155px;
-	height:20px;
-	border-bottom:1px solid #E1E1E1;
-	padding-left:20px;
-	padding-top:3px;
-}	
-
-#Generate{
-	position:relative;
-	width:100%;
-	text-align:center;
-	display:none;
-}
-
-/* END OF REPORT */
-/* WEB MAIL */
- a.webMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-}
-a.webMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-} 
-/*  END OF WEB MAIL */
-/* POPUP */
- a.alpha{
-	font-size:11px;
-	color:gray;
-	text-decoration:none;
-	padding-Left:5px;
-	padding-right:5px;
-	border:1px dotted #CCCCCC;
-	background-color:#FFFFCC;
-}
-
-a.alpha:Hover{
-	font-size:11px;
-	color:gray;
-	text-decoration:underline;
-	padding-Left:5px;
-	padding-right:5px;
-	border:1px dotted #CCCCCC;
-	background-color:#FFFFCC;
-} 
-
-/* Home Page */
-.MatrixLayer{
-	border:2px solid #aaaaaa;
-	background-color:#FFFFFF;
-	width:29%;
-	position:relative;
-	visibility:visible;
-	margin:9px;
-	height:280px;
-}
-
-.fontBold{
-	font-size:13px;
-	color:#000000;
-	text-decoration:none;
-	font-weight:bold;
-}
-
-.style_Gray{
-	color:gray;
-}
-	
-/* End of Home Page */
-
-/* All Menu */
-#allMenu{
-    width:500px;
-    border:4px solid #aaa;
-    left:200px;
-    top:100px;
-    position:absolute;
-    z-index:1000001;
-    display:none;
-    padding:10px;
-    background:#ffffff url(images/layerPopUpBg.gif);
-}
-
-
-.allMnuTable{
-    width:100%;
-    background-color:#FFFFFF;
-}
-
-.allMnuHandle td{
-    height:20px;
-    color:#FFFFFF;
-    font-family:Arial, Helvetica, sans-serif;
-    font-size:12px;
-    font-weight:bold;
-    text-decoration:none;
-    background-color:#555;
-    cursor:move;
-    padding:2px;
-    border-bottom:2px solid #666666;
-}
-
-.allMnuHdr{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-weight:Bold;
-    font-size:11px;
-    text-decoration:none;
-    display:block;
-    background-color:#FFFFFF;
-    color:#333;
-    padding-top:5px;
-    padding-bottom:5px;
-}
-
-a.allMnu{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-size:10px;
-    text-decoration:none;
-    font-weight:normal;
-    display:block;
-    width:125px;
-    height:15px;
-    padding-left:5px;
-    padding-top:0px;
-    padding-bottom:0px;
-    background-color:#FFFFFF;
-    border:1px solid #FFFFFF;
-    color:#000099;
-    margin-left:10px;
-}
-
-a.allMnu:Hover{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-size:10px;
-    text-decoration:none;
-    font-weight:normal;
-    display:block;
-    width:125px;
-    height:15px;
-    padding-left:5px;
-    padding-top:0px;
-    padding-bottom:0px;
-    background-color:#ddd;
-    
-}
-/* End Of All Menu */
-/* Calendar */
-.calHdr{
-	background-image:url(images/mailSubHeaderBg.gif); 
-	background-repeat:repeat-x;
-	background-position:left top;
-}
-
-.calSel{
-	background-image:url(images/dashSelectBg.gif);
-	background-repeat:repeat-x;
-	text-align:center;
-	color:#FFFFFF;
-	font-weight:bold;
-	width:8%;
-}
-
-.calAddButton {
-	border: 1px solid #999;
-	background:#ddd url(images/calAddButtonBg.gif) repeat-x;
-	cursor:pointer;
-	height:20px;
-	
-
-}
-.calInnerBorder {
-	border-left:2px solid #a5a5a5;
-	border-right:2px solid #a5a5a5;
-	border-bottom:2px solid #a5a5a5;
-}
-
-.calBorder {
-	border-left: 1px solid #a5a5a5; 
-	border-right: 1px solid #a5a5a5; 
-	border-bottom: 1px solid #a5a5a5; 
-	background:#fefefe url(images/layerPopupBg.gif);
-
-}
-.calTopRight {
-	border-right: 1px solid #a5a5a5; 
-}
-
-
-.calUnSel{
-	color:#000000;
-	font-weight:normal;
-	text-align:center;
-	width:8%;
-}
-
-a.calMnu{
-	font-size:11px;
-	color:#009;
-	text-decoration:none;
-	display:block;
-	height:20px;
-	padding-left:5px;
-	padding-top:3px;
-}	
-
-a.calMnu:Hover{
-	font-size:11px;
-	color:#009;
-	text-decoration:underline;
-	display:block;
-	height:20px;
-	padding-left:5px;
-	padding-top:3px;
-}
-
-/*.bggray{
-	background-color: #dfdfdf;
-}*/
-.bgwhite{
-	background-color: #FFFFFF;
-}
-.copy{
-	font-size:9px;
-	font-family: Verdana, Arial, Helvetica, Sans-serif;
-}
-
-#mnuTab{
-	position:relative;
-	width:100%;
-	display:block;
-}
-
-#mnuTab2{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:none;
-}
-.style1 {color: #FF0000}
-.event{
-	background-color:#ddd;
-	border:1px solid #999999;
-	text-align:left;
-	width:100%;
-	position:relative;
-	left:0px;
-	top:0px;
-	vertical-align:middle;
-	padding:1px;
-}
-
-#hrView{
-	display:block;
-}
-.calendarNav{
-	font-size:12px;
-	color:#FFFFFF;
-	white-space:nowrap;
-	text-align:center;
-	font-weight:bold;
-	padding-left:10px;
-	padding-right:10px;
-	background-image:url(images/cal_nav.gif);
-	background-repeat:repeat-x;
-}
-#addEventDropDown{
-	position:absolute;
-	display:none;
-	width:150px;
-	border:1px solid #666666;
-	left:0px;
-	top:0px;
-	overflow:visible;
-	z-index:5000;
-}
-
-.calAction{
-	width:175px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-.calSettings{
-	position:absolute;
-	z-index:20000;
-	width:500px;
-	left:200px;
-	top:150px;
-	background-color:#ffffff;
-}
-.outer{
-	border-bottom:1px solid #CCCCCC;
-	border-left:1px solid #CCCCCC;
-	border-right:1px solid #CCCCCC;
-}
-.calTxt{
-	width:50%;
-	border:1px solid #CCCCCC;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	padding-left:5px;
-}
-
-#leadLay{
-	position:relative;
-	width:100%;
-	float:left;
-	visibility:hidden;
-	padding:5px;
-	z-index:10000;
-}
-									
-/* End of Calendar */
-
-/* Cal Year View */
-.eventDay{
-	background-color:#FF9966;
-	font-weight:bold;
-}
-
-.currDay{
-	background-color:#006600;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-.currDay a{
-	color:#FFFFFF;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-
-/* End of Cal Year View */
-
-/* Level 2 Menu Selected*/
-
-level2Sel{
-	color:#000000;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-#DeleteLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:300px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	padding:5px;
-}
-
-#CurrencyDeleteLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:350px;
-}
-
-
-/* For Report HTML Generation*/
-.rptCellLabel {
-    background-color:#f6f6f6;
-    padding-right:10px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom:1px solid #eaeaea;
-    color:#737373;
-    font-weight: bold;
-    white-space:nowrap;
-}
-.rptTable {
-    border-left: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-    border-top: 1px solid #DDDDDD;
-}
-.rptTitle, .rptHead, .rptData, .rptGrpHead{
-    font-family: Verdana, Arial, Helvetica, Sans-serif;
-    font-size: 11px;
-	text-align:left;
-    font-weight: normal;
-	height: 20px;
-	padding: 4px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-	background: #DDDDDD;
-}
-.rptGrp1Total, .rptGrp2Total, .rptTotal {
-    font-family: Verdana, Arial, Helvetica, Sans-serif;
-    font-size: 11px;
-	text-align:center;
-    font-weight: normal;
-    background: #FFF;
-	height: 20px;
-	padding: 4px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-}
-.rptGrpHead {
-	background: #FFF;
-    border-bottom: 1px solid #FFF;
-    border-top: 1px solid #DDDDDD;
-    font-weight: normal;
-}
-
-.rptData {
-            background: #FFF;
-            font-weight: normal;
-}
-.rptEmptyGrp {
-            background: #FFF;
-            border-right: 1px solid #DDDDDD;
-}
-.statechange
-{
-    position:absolute;
-    visibility:hidden;
-    left:10px;
-    top:20px;
-    width:300px;
-    border:3px solid #CCCCCC;
-    background-color:#FFFFFF;
-}
-#PopupLay{
-    position:absolute;
-    font-family:Arial, Helvetica, sans-serif;
-    font-size:11px;
-    text-align:left;
-    width:500px;
-    border:3px solid #CCCCCC;
-    background-color:#FFFFFF;
-    padding:5px;
-    display:none;
-    left:100px;
-    top:100px;
-}
-
-#folderLay{
-    width:175px;
-    background-color:#CCCCCC;
-    border:1px solid #DDDDDD;
-    padding-top:5px;
-    position:absolute;
-    display:none;
-}
-
-/* Css for quick Create */
-
-.qcTransport{
-	    background-color:#dadada;
-
-}
-
-#role_popup{
-        position:relative;
-        left:0px;
-        top:0px;
-        width:95%;
-        height:300px;
-        overflow:auto;
-        border:1px solid #999999;
-        text-align:left;
-        background-color:#FFFFFF;
-    }
-
-.unread_email {
-	font-weight:bold;
-}
-
-								    
-/* MY SITES */
-
-.unread_email {
-	font-weight:bold;
-}
-
-
-.tagCloud {
-    border:1px solid #737373;
-}
-
-   
-.tagCloudTopBg {
-    background: url(images/tagCloudBg.gif) repeat-x;
-   
-}
-
-.tagCloudDisplay {
-    background-color:#e5e5e5;
-    padding:10px;
-    font-family: Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    line-height: 14px;
-    color: #000000;
-
-}
-.h2 {
-
-	font-size:18px;
-	line-height:20px;
-
-}
-
-.gray {
-
-	color:gray;
-}
-ul {
-	list-style:circle;
-	line-height:20px;
-	padding-left:5px;
-	margin-left:20px;
-	font-weight:normal;
-
-}
-.tagCloudTopBg {
-	background-image: url(images/tagCloudBg.gif);
-	background-repeat: repeat-x;	
-}
-
-.tagCloudDisplay {
-	background-color:#e5e5e5;
-	padding:5px;
-}
-
-.heading2 {
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 16px;
-	line-height: 16px;
-	font-weight:bold;
-	color: #000000;
-}
-
-.settingsUI {
-	
-	text-align:left;
-	background-color:#fff;
-	background-image:url(images/layerPopupBg.gif);
-	border:2px solid #aaaaaa;
-
-}
-
-
-.settingsTabHeader {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 12px;
-	line-height:22px;
-	font-weight:bold;
-	color:#333;
-	background-image: url(images/mailSubHeaderBg.gif);
-	 background-color:#dddddd;
-	background-repeat: repeat-x;
-	padding-left:10px;
-	padding-right:10px;
-
-}
-
-.settingsTabList {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:20px;
-	font-weight:normal;
-	color:#000000;
-	background-color:#e5e5e5;
-	padding-left:30px;
-	border-bottom:1px solid #ccc;
-	border-top:1px solid #fff;
-}
-.settingsTabSelected {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:20px;
-	font-weight:bold;
-	color:#000000;
-	background-color:#ffffff;
-	padding-left:30px;
-	border-left:1px solid #ddd;	
-}
-.settingsSelectedUI {
-	padding:10px;
-	background:url(images/settingsSelUIBg.gif) repeat-x;
-	background-color:#ffffff;
-}
-.settingsIconDisplay {
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:14px;
-	padding:10px;
-
-	color:#000000;
-	background-color:#ffffff;
-	padding-left:10px;
-}
-.settingsSelUITopLine{
-	border-bottom:2px dotted #999999;
-
-}
-
-.tableHeading{
-	background-color:#ffffff;
-	border-bottom:2px solid #555;
-}
-.colHeader{
-	background-color:#ddd;
-	border-left:1px solid #fff;
-	border-top:1px solid #fff;
-	border-right:1px solid #aaa;
-	border-bottom:1px solid #aaa;
-	font-weight:bold;
-
-}
-.cellLabel {
-	background-color:#eaebd9;
-	border-top:1px solid #efefef;
-	border-bottom:1px solid #dadada;
-	color:#555555;
-
-}
-.cellText {
-	color:#333333;
-	border-bottom:1px solid #dadada;
-} 
-
-.listTable{
-	border-left:1px solid #cccccc;
-	border-right:1px solid #cccccc;
-	border-bottom:1px solid #cccccc;
-
-}
-
-.listTableRow{
-	border-bottom:1px solid #eaeaea;
-	border-right	:1px solid #eaeaea;
-	border-bottom:1px solid #eaeaea;
-	border-bottom:1px solid #eaeaea;
-}
-.listRow{
-	border-bottom:2px solid #eaeaea;
-
-}
-
-.listTableTopButtons{
-	background-color:#efefef;
-	background-image:url(images/layerPopupBg.gif);
-	
-}
-
-
-/*  Buttons */
-.crmButton{
-	
-	border-left:1px solid #ffffff;
-	border-top:1px solid #ffffff;
-	border-right:1px solid #555555;
-	border-bottom:1px solid #555555;
-}
-
-.create{
-	background-color:#55aa55;
-	color:#fff;
-	font-weight:bold;
-}
-.delete {
-	background-color:#ffaa22;
-	color:#000;
-	font-weight:bold;
-}
-.edit {
-	background-color:#55aa55;
-	color:#fff;
-	font-weight:bold;
-}
-.save{
-	background-color:#55aa55;
-	color:#fff;
-	font-weight:bold;
-}
-.cancel {
-	background-color:#ffaa22;
-	color:#000;
-	font-weight:bold;
-}
-
-.inactive{
-color:#999999;
-}
-
-.active{
-color:#229922;
-
-}
-
-/* Buttons ends */
-
-
-
-textarea {
-	width:95%;
-	height:70px;
-	border:1px solid #dadada;
-}
-.treeTable1{
-	padding:0px;
-}
-
-.prvPrfBigText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-.prvPrfTopBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfBottomBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfOutline {
-	border:1px solid #ebebeb;
-}
-.prvPrfTexture {
-	background:url(images/prvPrfTexture1.gif);
-
-}
-
-.prvPrfHoverOn {
-	background-color:#ffffef;
-	
-}
-.cellBottomDotLine {
-	border-bottom-width: 2px;
-	border-bottom-style: dotted;
-	border-bottom-color: #CCCCCC;
-	background-color:#ededed;
-}
-.crmFormList{
-	border:1px solid #cccccc;
-	width:90%;
-	height:120px;
-
-}
-.cellBottomDotLinePlain {
-	border-bottom-width: 2px;
-	border-bottom-style: dotted;
-	border-bottom-color: #CCCCCC;
-	
-}
-
-.thickBorder {
-	border: 2px solid #999999;
-}
-.trackerHeading {
-	background-color:#efefef;
-}
-.trackerListBullet {
-	border-right:1px dotted #cccccc;
-	background-color:#f9f9f9;
-}
-.trackerList {
-	border-bottom:1px solid #eeeeee;
-}
-
-/* Table Definitions */
-.crmTable {
-	border:1px solid #dadada;
-}
-
-.crmTableRow {
-	border-bottom:1px dotted #dadada;
-	border-right:1px dotted #dadada
-}
-
-/* Inventory */
-
-.lineOnTop {
-	border-top:1px solid #999999;
-}
-
-.discountUI{
-	border:3px solid #CCCCCC;
-	width:250px;
-	padding:5px;
-	position:absolute;
-	background-color:#FFFFFF;
-	display:none;
-}
-
-.TaxShow{
-	display:inline-table;
-}
-
-.TaxHide{
-	display:none;
-}
-
-/* Inventory */
-
-
-/* Email Client Classes ++++++++++++++++++++++ */
-
-.emailSelected{
-	background-color:#eaeaea;
-	color:#000000;
-	font-size:bold;
-}
-
-
-.mailClient{
-	border:2px solid #656565;
-}
-
-.mailClientBg {
-	background-color:#efefef;
-	background-image:url(images/layerPopupBg.gif);
-}
-
-.mailSubHeader {
-	background:#d9d9d9 url(images/mailSubHeaderBg.gif) repeat-x;
-	padding:4px;
-}
-.mailClientWriteEmailHeader {
-	font-family:arial, helvetica, sans-serif;
-	font-size:20px;
-	line-height:24px;
-	font-weight:bold;
-	background:#e0e0e0 url(images/mailSubHeaderBg.gif) repeat-x;
-	padding:10px;
-	border-left:1px solid #eaeaea;
-	border-top:1px solid #eaeaea;
-	border-right:1px solid #999;
-	border-left:1px solid #999;;
-}
-
-.mailClientCSSButton {
-	border-left:1px solid #fff;
-	border-top:1px solid #fff;
-	border-right:1px solid #333;
-	border-bottom:1px solid #333;
-	padding:2px;
-	background-color:#cfcfcf;
-}
-
-/* Email Client Classes ends ------------------------------------ */
-
-
-
-/* Layer Popup */
-.layerPopup {
-	border:3px solid #959595;
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-	position:absolute;
-}
-
-.layerPopupHeading {
-	font-family:arial, helvetica, sans-serif;
-	font-size:16px;
-	line-height:24px;
-	font-weight:bold;
-}
-.layerHeadingULine {
-	border-bottom:2px solid #777;
-}
-.layerPopupTransport {
-	background-color:#eaeaea;
-
-}
-.homePageSeperator {
-	border-right:1px dotted #ddd;
-}
-.homePageMatrixHdr {
-	border-bottom:1px solid #d3d3d3;
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-}
-
-.reportsListTable {
-	background-color:white;
-	border-left:1px solid #aaa;
-	border-right:1px solid #aaa;
-	border-bottom:1px solid #aaa;
-}
-
-.reportGenerateTable{
-	background-image:url(images/layerPopupBg.gif);
-	border-left:2px dotted #aaa;
-	border-right:2px dotted #aaa;
-	border-bottom:2px dotted #aaa;
-}
-.reportCreateBottom{
-	background-color:#eaeaea;
-	border-bottom:2px solid #777;
-
-}
-.importLeadUI{
-	/*background:#ffffff url(images/select.gif) ; */
-	background-color:#fff;
-}
-
-a.customMnu{
-	padding-left:30px;
-	padding-top:5px;
-	padding-bottom:5px;
-	display:block;
-	background-repeat:no-repeat;
-	background-position:left;
-	width:155px;
-	color:#000000;
-	text-decoration:none;
-}
-
-a.customMnuSelected{
-	padding-left:30px;
-	padding-top:5px;
-	padding-bottom:5px;
-	display:block;
-	background-repeat:no-repeat;
-	background-position:left;
-	width:155px;
-	background-color:#0099FF;
-	color:#FFFFFF;
-	text-decoration:none;
-}
-
-
-/* Drop Down Menu */
-.drop_mnu{
-    position:absolute;
-    left:0px;
-    top:0px;
-    z-index:1000000001;
-    border-left:1px solid #a5a5a5;
-    border-right:1px solid #a5a5a5;
-    border-bottom:1px solid #a5a5a5;
-    width:150px;
-    display:none;
-    padding:0px;
-    text-align:left;
-    overflow-x:hidden;
-    overflow-y:hidden;
-    background-color:#eee;
-}
-
-a.drop_down{
-    width:150px;
-    text-align:left;
-    font-family:  Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    line-height:20px;
-    font-weight:normal;
-    color:#009;
-    background-color:#eee;
-    padding:2px 5px 2px 5px;
-    border-top:1px solid #fafafa;
-    border-bottom:1px solid #d3d3d3;
-    display:block;
-}
-
-a.drop_down:Hover{
-    padding:2px 5px 2px 5px;
-    width:150px;
-    text-align:left;
-    color:#33a;
-    font-weight:normal;
-    text-decoration:underline;
-    background-color:#dadada;
-}
-
-.bgwhite{
-	background-color:white;
-}
-
-.searchUIBasic {
-		background-image:url(images/layerPopupBg.gif);
-		border:2px solid #a5a5a5;
-}
-.searchUIAdv1{ 
-		background-image:url(images/layerPopupBg.gif);
-		border-top:2px solid #a5a5a5;
-		border-left:2px solid #a5a5a5;
-		border-right:2px solid #a5a5a5;
-}
-.searchUIAdv2{ 
-		background-image:url(images/layerPopupBg.gif);
-		border-left:2px solid #a5a5a5;
-		border-right:2px solid #a5a5a5;
-}
-.searchUIAdv3{ 
-		background-image:url(images/layerPopupBg.gif);
-		border-bottom:2px solid #a5a5a5;
-		border-left:2px solid #a5a5a5;
-		border-right:2px solid #a5a5a5;
-}
-
-
-
-/* Recalculate Disabling Window */
-
-.veil{
-   background: url(images/layerPopupBg.gif) ;
-    height: 100%;
-    width: 100%;
-    top: 0px;
-    left: 0px;
-    overflow: hidden;
-    z-index: 10000;
-    Filter: Alpha(opacity = 70);
-    -moz-opacity: 0.7;
-    text-align: center;
-    vertical-align: middle;
-    position: absolute;
-}
-
-.veil_new{
-   background: url(images/layerPopupBg.gif) ;
-    height: 100%;
-    width: 100%;
-    top: 0px;
-    left: 0px;
-    overflow: hidden;
-    z-index: 50000;
-    Filter: Alpha(opacity = 70);
-    -moz-opacity: 0.7;
-    text-align: center;
-    vertical-align: middle;
-    position: absolute;
-}
-
-.optioncontainer{
-    vertical-align: middle;   
-    height: 100%;
-    width: 100%;   
-    position: absolute;
-    z-index: 90000;   
-}
-
-
-.options{
-    	vertical-align: middle;   
-	margin-left: 25%;
-	margin-top: 16%;
-	color: #FFFFFF;
-	width:650px;
-	background-color: Black;
-	border: 2px solid #222;	
-    	position: relative;
-	text-align: left;
-    	z-index: 80000;   
-}
-
-.options h2{
-	color: White;
-	font-family: Verdana, Arial, Helvetica, sans-serif;
-	border-bottom: 1px solid #373D4C;
-	margin: 0;
-	font-weight: normal;
-}
-
-/* Recalculate Disable Ends */
-
+/*********************************************************************************
+
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ ********************************************************************************/
+
+
+/* ALPHA GRAY  - COLOR THEME*/
+
+.small {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+}
+.big {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	line-height: 18px;
+	color: #000000;
+	font-weight:bold;
+}
+
+.componentName {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	line-height: 3px;
+	color: #000;
+	font-weight:bold;
+	border-left:2px dotted #333;
+	padding:10px;
+}
+
+
+.genHeaderBig{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	line-height: 19px;
+	color: #000000;
+	font-weight:bold;
+}
+.genHeaderSmall{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	line-height: 16px;
+	color: #000000;
+	font-weight:bold;
+	
+}
+
+.moduleName {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	color: #000000;
+	font-weight:bold;
+}
+
+
+.hdrNameBg {
+	 background:#ffffff url(images/hdrNameBg.gif) repeat-x;
+	
+	
+}
+
+.hdrTabBg {
+	/*background:#ffffff url(images/hdrTabBg.gif) bottom repeat-x ;*/
+	background-color:#dadada;
+}  
+
+.tabSelected {
+	background:#eeeeee url(images/tabSelectedBg.gif) repeat-x;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+
+.tabSelected a{
+	color:white;
+}
+
+.tabUnSelected {
+	
+	background: #eaeaea url(images/tabUnSelectedBg.gif) bottom repeat-x;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	border-bottom:1px solid #ffffff;
+}
+
+.tabUnSelected a{
+	color:#000099;
+}
+
+.tabSeperator {
+	background-color:#aaa;
+	width:1px;
+}
+
+
+
+/*.level2text {
+    
+    font-family: Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    padding-left:15px;
+    padding-right:15px;
+    padding-top:5px;
+    padding-bottom:5px;
+    font-weight:bold;
+    color:white;
+}
+
+.level2text a{
+	text-decoration:none;
+	color:#555555;
+}
+
+.level2text a:hover {
+	text-decoration:underline;
+	color:#555555;
+
+}*/
+
+
+.level2Bg {
+	/*background:#999 url(images/level2TabBg.gif) bottom repeat-x;*/
+	background-color:#9a9a9a;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	border-bottom:1px dashed #fff;
+	color:white;
+}
+
+.level2Bg a{
+	/* background:#1F5BFF url(images/level2TabBg.gif) bottom repeat-x; */
+	color:#fff;
+}
+
+
+.level2SelTab{
+	font-weight:bold;
+	color:#000000;
+	padding-left:20px;
+	padding-right:20px;
+	padding-top:5px;
+	padding-bottom:5px;
+	
+}
+	
+.level2UnSelTab{
+	color:#000000;
+	padding-left:20px;
+	padding-right:20px;
+	padding-top:5px;
+	padding-bottom:5px;
+}
+.sep1 {
+	background:#999999;
+}
+
+.showPanelBg {
+	background:url(images/showPanelTopBg.gif) repeat-x;
+}
+
+a {
+	text-decoration:none;
+	color:#000099;
+}
+
+a:hover {
+	text-decoration:underline;
+}
+
+.hdrLink {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	text-decoration:none;
+	color:#000099;
+	font-weight:bold;
+}
+
+.hdrLink:hover {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	text-decoration:underline;
+	color:#000099;
+	font-weight:bold;
+}
+
+.searchBox {
+	border: 0px solid #0000aa;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	padding-left:2px;
+	width:100px;
+	background-color:#ffffef;
+}
+
+.searchBtn {
+	border :0px #cccccc solid;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	font-weight:bold;
+	width:30px;
+	height:19px;
+	background-color:#555;
+	color:white;
+}
+
+
+/* List View Table classes starts  +++++++++++++++++ */
+
+.lvt {
+	background-color:#ccc;
+	border:1px solid #ccc; 
+}
+
+.lvtBg {
+}
+
+.lvtHeaderText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	font-weight:bold;
+}
+
+.lvtCol {
+	border-top:1px solid #eaeaea;
+	border-left:1px solid #eaeaea;
+	border-right:1px solid #999;
+	border-bottom:1px solid #999;
+	background-color:#ccc;
+	font-weight:bold;
+}
+
+.lvtColData {
+	background-color:#ffffff;
+}
+
+.lvtColDataHover {
+	background-color:#ffffee;
+	
+}
+
+
+/* List View Table classes ends --------------------------------*/
+
+
+
+/* Detailed View classes starts +++++++++++++++++++++++ */
+.dvHeaderText{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	color:#000000;
+	font-weight:bold;
+
+}
+
+.dvInnerHeader{
+	border-bottom:2px dotted #555;
+	padding:5px;
+	background-color:#dadada;
+
+}
+
+.dvtSelectedCell {
+	border-left:2px solid #aaaaaa;
+	border-top:2px solid #aaaaaa;
+	border-right:2px solid #aaaaaa;
+	padding-left:20px;
+	padding-right:20px;
+	background-color:white;
+	font-weight:bold;
+}
+
+.dvtUnSelectedCell {
+	border-left:2px solid #aaaaaa;
+	border-top:2px solid #aaaaaa;
+	border-right:2px solid #aaaaaa;
+	border-bottom:2px solid #aaaaaa;
+	padding-left:20px;
+	padding-right:20px;
+	background-color:#f5f5f5;
+	cursor:pointer;
+}
+
+.dvtTabCache {
+	border-bottom:2px solid #aaaaaa;
+}
+
+.dvtContentSpace {
+	border-left:2px solid #aaaaaa;
+	border-right:2px solid #aaaaaa;
+	border-bottom:2px solid #aaaaaa;
+	padding-left:0px;
+}
+.dvtCellLabel, .cellLabel {
+	background-color:#efefef;
+	padding-right:10px;
+	padding-left:10px;
+	border-bottom:1px solid #dddddd;
+	border-top:1px solid #ffffff ;
+	color:#545454;
+	white-space:nowrap;
+	font-weight:bold;
+}
+
+.dvtCellInfo, .cellInfo {
+	padding-left:10px;
+	padding-right:10px;
+	border-bottom:1px dotted #efefef;
+}
+
+.rightMailMerge {
+	border:2px solid #aaa;
+}
+
+.rightMailMergeHeader {
+	border-bottom:1px solid #ddd;
+	padding:5px;
+	background-color:#efefef;
+
+}
+
+.rightMailMergeContent {
+	padding:5px;
+	background-color:#fafafa;
+
+}
+.detailedViewHeader{
+	border-bottom:2px solid #dadada;
+    	padding:5px;
+    	background-color:#aaaaaa;
+}
+
+.detailedViewTextBox {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#ffffff;
+}
+.detailedViewTextBoxOn {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#ffffdd;
+}
+
+.detailedViewTextBoxDis {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #555555;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#aaaaaa;
+}
+
+.detailedViewTextArea {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:95%;
+	height:100px;
+	background-color:#ffffff;
+	text-align:left;
+}
+
+.advSearch {
+	padding:10px;
+	border-left:1px solid #eaeaea; 
+	border-right:1px solid #eaeaea; 
+	border-bottom:1px solid #eaeaea; 	
+	overflow:auto;
+	width:600px;
+	height:150px;
+	background-color:#f5f5f5;
+
+}
+
+.searchAlph {
+	border:1px solid #dadada;
+	background-color:#ffffff;
+	cursor:pointer;
+	width:10px
+
+}
+.searchAlphselected {
+	border:1px solid #666666;
+	background-color:#bbbbbb;
+	cursor:pointer;
+	width:10px
+
+}
+.textbox {
+	border:1px solid #999999;
+	background-color:#ffffff;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	width:120px;
+	padding:2px;
+
+}
+.mx {
+}
+.calListTable td{
+	border-bottom:1px solid #efefef;
+	border-left:1px solid #efefef;
+}
+.calDIV {
+	width:100%;
+	border:1px solid #999999;
+	
+}
+.calDayHour {
+	border-top:1px solid #dddddd;
+	border-left:1px solid #dddddd;
+	border-bottom:1px solid #dddddd;
+	border-right:1px solid #dddddd;
+	background-color:#eaeaea;
+}
+.calAddEvent {
+	position:absolute;
+	z-index:10000;
+	width:500px;
+	left:200px;
+	top:150px;
+	background-color:#ffffff;
+}
+.addEventInnerBox {
+	border:1px dotted #dadada;
+
+}
+.cellNormal {
+	border:0px;
+	background-color:#ffffff;
+}
+.EventToDo{
+
+}
+
+.thumbnail{
+    background-color:#ffffff;
+padding: 7px;
+border: 1px solid #ddd;
+float: left;
+	   margin-right: 10px;
+	   margin-bottom: 15px;
+}
+.padTab{
+    padding-top:0px;
+    padding-left:0px;
+    padding-left:10px;
+    padding-bottom:0px;
+    vertical-align:top;
+
+}
+#company{
+    position:relative;
+    width:100%;
+    height:200px;
+    display:block;
+    background-color:#FFFFFF;
+    white-space:nowrap;
+    overflow:auto;
+    border:1px solid #CCCCCC;
+}
+                               
+
+#user{position:relative;left:0px;top:0px;width:100%;display:block;}
+#communication{position:relative;left:0px;top:0px;width:100%;display:block;}
+#config{position:relative;left:0px;top:0px;width:100%;display:block;}
+#userTab{position:relative;left:0px;top:0px;width:100%;display:none;}
+#one{
+	position:relative;
+	display:block;
+	width:245px;
+}
+
+#mnuTab1{
+
+   position:relative;
+
+   overflow:auto;
+
+   width:100%;
+
+   display:none;
+
+}
+
+#mnuTab2{
+
+   position:relative;
+
+   overflow:auto;
+
+   width:100%;
+
+   display:none;
+
+}
+
+
+/* End of Settings */
+
+.bggray{
+	background-color: #dfdfdf;
+}
+.bgwhite{
+	background-color: #FFFFFF;
+}
+.copy{
+	font-size:9px;
+	font-family: Verdana, Arial, Helvetica, Sans-serif;
+}
+
+#basicTab{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:block;
+}
+
+#moreTab{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:none;
+}
+
+/*Added for Advance Seearch*/
+
+#one{
+	position:relative;
+	display:block;
+	width:245px;
+}
+
+
+/* Dashboard CSS */
+a.dash_href{
+	display:block;
+	width:24px;height:24px;
+	vertical-align:middle;
+	margin-top:10px;
+}
+
+
+.dashHeading {
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:24px;
+	font-weight:bold;
+	color:#fff;
+}
+
+.dashSelectBg{
+	background-image:url(images/dashSelectBg.gif);
+	background-repeat:repeat-x;
+}
+.dash_top{
+	background-image:url(images/dashTopBg.gif);
+	background-repeat:repeat-x;
+	height:63px;
+	vertical-align:middle;
+}
+
+.dash_border{
+	background-color:#bfbfbf;
+	padding:5px;
+}
+.dash_white{
+	background-color:#FFFFFF;
+	padding:5px 10px 5px 10px;
+}
+
+.dash_bdr_btm{
+	border-bottom:2px dotted #dadada;
+}
+
+.dash_count{
+	font-size:36px;
+	font-weight:bold;
+	text-decoration:none;
+	color:#000000;
+	padding-left:10px;padding-right:10px;	
+}
+.dash_switch{
+	cursor:pointer;
+	width:26px;
+	height:26px;
+}
+
+.dash_row_sel{
+	background-image:url(images/dash_sel_chart.jpg);
+	background-repeat:no-repeat;
+	background-position:center;
+	width:26px;height:26px;
+	text-align:center;
+	vertical-align:middle;
+	font-weight:bold;
+	font-size:10px;
+	text-decoration:none;
+}
+
+.dash_row_unsel{
+	background-image:url(images/dash_unsel_chart.jpg);
+	background-repeat:no-repeat;
+	background-position:center;
+	width:26px;height:26px;
+	text-align:center;
+	vertical-align:middle;
+	font-weight:normal;
+	font-size:10px;
+	text-decoration:none;
+	cursor:pointer;
+}
+
+.dash_chart_btm{
+	border-bottom:2px solid #000000;
+}
+
+
+.dash_bottom{
+	background-image:url(images/dashBottomBg.gif);
+	background-repeat:repeat-x;
+	height:99px;
+	vertical-align:middle;
+}
+
+.dash_btm{
+	background-image:url(images/dash_btm_center.jpg);
+	background-repeat:repeat-x;
+	position:top;
+}
+  
+/*  menu */
+
+
+
+ a.submenu{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:11px;
+	padding-top:5px;
+	padding-bottom:5px;
+	padding-left:10px;
+	border-bottom:1px solid #CCCCCC;
+	background-color:#ECECEC;
+	color:#000000;
+	text-align:left;
+	text-decoration:none;
+	display:block;
+}
+
+a.submenu:Hover{
+	background-color:#DDDDDD;
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:11px;
+	padding-top:5px;
+	padding-bottom:5px;
+	padding-left:10px;
+	border-bottom:1px solid #CCCCCC;
+	color:#000000;
+	text-align:left;
+	text-decoration:none;
+	display:block;
+} 
+
+#mnuKey{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:11px;
+	background-color:#666666;
+	color:#FFFFFF;
+	text-decoration:none;
+	padding:5px;
+	font-weight:bold;
+	width:8px;
+	cursor:pointer;
+	vertical-align:top;
+	height:100px;
+	position:relative;
+	top:0px;
+	left:0px;
+}
+
+#slidemenu{
+	height:525px;
+	vertical-align:top;
+	width:100px;
+	background-color:#CCCCCC;
+	border-right:1px solid #CCCCCC;
+	opacity:.9;
+	display:none;
+}*/
+
+/* clock */
+
+.citystyle{
+	position:relative;
+	top:0px;
+	left:0px;
+	text-align:left;
+	
+}
+#theClockLayer{
+	position:relative;
+	height:180px;
+	left:20px;
+	text-align:center;
+}
+.handsanddotsstyle{
+	margin-top:10px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:2px;
+	height:2px;
+	font-size:2px;
+	background-color:#000000;
+}
+.facestyle{
+	margin-top:10px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:15px;
+	height:15px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+.datestyle{
+	margin-top:20px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:100px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+.ampmstyle{
+	margin-top:23px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:20px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+
+#wclock{
+	position:absolute;
+	left:100px;
+	top:100px;
+	display:none;
+	background-color:#CCCCCC;
+	width:175px;
+}
+
+.leftFormBorder1 {
+	border: 1px solid #AFC8E4;
+	background-color: #FFFFFF;
+	opacity:.7;
+}
+
+
+
+
+/* Calculator */
+.calcResult {
+	width: 100%;
+	height: 25px;
+	background-color: #FFFFCC;/*CBDFD6*/
+	border-top: 1px solid #CCC;
+	border-left: 0px;
+	border-right: 1px solid #CCC;
+	border-bottom: 1px solid #CCC;
+	font-size: 10px;
+	text-align: right;
+}
+.calcMem {
+	width: 100%;
+	height: 25px;
+	border-top: 1px solid #CCC;
+	border-left: 1px solid #CCC;
+	border-right: 0px;
+	border-bottom: 1px solid #CCC;
+	background-color: #FFFFCC;/*CBDFD6*/
+	font-family: Arial;
+	font-size: 10px;
+	color: #BBB;
+	text-align: left;
+}
+.calcBlackBtn, .calcGreyBtn, .calcBigBtn, .calcCancBtn, .calcMemBtn, .calcBackBtn {
+	border: none;
+	height: 20px;
+	font-size: 11px;
+	color: #FFF;
+	text-align:center;
+}
+.calcBackBtn {
+	background: url(images/calc_back_btn.gif) no-repeat;
+	width:25px;
+}
+.calcBlackBtn {
+	background: url(images/calc_black_btn.gif) no-repeat;
+	width:25px;
+}
+.calcGreyBtn {
+	background: url(images/calc_grey_btn.gif) no-repeat;
+	width:25px;
+}
+.calcCancBtn {
+	background: url(images/calc_canc_btn.gif) no-repeat;
+	width:25px;
+	
+}
+.calcMemBtn {
+	background: url(images/calc_mem_btn.gif) no-repeat;
+	width:25px;
+	/*background-color: #CCC;*/
+}
+#calc{
+	position:absolute;
+	left:100px;
+	top:100px;
+	background-color:#FFFFFF;
+	width:185px;
+	border-bottom:2px solid #000000;
+	border-right:2px solid #666666;
+	border-left:2px solid #CCCCCC;
+	border-top:2px solid #CCCCCC;
+}
+
+/* RSS STYLES */
+
+.subHdr{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	background-image:url(images/rssHeader.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+}
+
+.delBg{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	background-image:url(images/rssdelete.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+}
+
+#rssScroll{
+	font-family:Arial, Helvetica, sans-serif	;
+	font-size:12px;
+	background-color:#FFFFFF;
+	width:100%;
+	height:175px;
+	overflow:auto;
+	border:0px solid #000000;
+}
+
+.rssTable{
+	width:100%;
+	border:0px solid #CCCCCC;
+}
+
+.rssTable tr th{
+	background-color:#a9a9a9;
+	text-align:left;
+	border-bottom:1px solid #555;
+	border-top:1px solid #FFFFFF;
+	color:#000000;
+	padding-left:5px;
+	padding-right:5px;
+	height:20px;
+}
+
+.rssTable tr td{
+	text-align:left;
+	border-bottom:1px dotted #dadada;
+	border-left:1px dotted #dadada;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	font-weight:normal;
+	white-space:nowrap;
+	padding:2px;
+	
+}
+.forwardBg{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#000000;
+	background-image:url(images/rssforward.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+	background-color:#D7D7D7;
+}
+
+
+/*  New Styles */
+
+.mnuTab{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#000000;
+	width:100%;
+	border:0px solid #000000;
+}
+
+.mnuTab tr td{
+	border-bottom:1px solid #EBEBEB;
+	padding-left:5px;
+	vertical-align:middle;
+}
+/* profile */
+
+.prvPrfBigText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+.prvPrfTopBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfBottomBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfOutline {
+	border:1px solid #ebebeb;
+}
+
+.prvPrfTexture {
+	background:url(images/prvPrfTexture1.gif);
+
+}
+.prvPrfHoverOn {
+	background-color:#ffffef;
+	
+}
+/*  Organization */
+
+.orgTab{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	font-weight:normal;
+	color:#666666;
+	border:0px solid #9B9B9B;
+	border-collapse:collapse;
+	width:100%;
+}
+
+.orgTab tr th{
+	text-align:left;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	text-decoration:none;
+	font-weight:bold;
+	height:20px;
+	padding-left:5px;
+}
+
+.orgTab tr td{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-decoration:none;
+	font-weight:normal;
+	padding-left:5px;
+	height:20px;
+	border-bottom:1px solid #CCCCCC;
+	border-right:1px solid #CCCCCC;
+}
+
+/* Groups */
+.groupli{
+	margin-left:20px;
+	font-family:Arial, Helvetica, sans-serif;
+	font-weight:normal;
+	font-size:12px;
+	text-decoration:none;
+	color:#333333;
+	list-style-type:none;
+	text-align:left;
+}
+
+/* tree menu */
+
+/*Oraganization Edit Features */
+
+#orgLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:500px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	display:block;
+	position:absolute;
+	left:0px;
+	top:0px;
+}
+
+/*  Role */
+
+#roleLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:300px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	display:none;
+	position:absolute;
+}
+
+.classBtn{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	text-decoration:none;
+	font-weight:normal;
+	font-size:10px;
+	background-color:#DBDBDB;
+	border-bottom:2px solid #999999;
+	border-right:2px solid #999999;
+	border-top:2px solid #F5F5F5;
+	border-left:2px solid #F5F5F5;
+	color:#000000;
+	text-align:center;
+	padding-top:3px;
+	padding-bottom:3px;
+}
+
+
+.txtBox{
+	width:85%;
+	border:1px solid #666666;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+}
+
+/*  IMPORT LEADS */
+
+.leadTable{
+	border:3px solid #CCCCCC;
+	border-collapse:collapse;
+}
+
+.leadTable tr td{
+/*	border:0px solid #CCCCCC;*/
+}
+
+.genHeaderGray{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	line-height: 16px;
+	color: #888888;
+	font-weight:bold;
+}
+
+.genHeaderGrayBig{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	line-height: 16px;
+	color: #888888;
+	font-weight:bold;
+}
+
+.importBox{
+	width:125px;
+	border:1px solid #666666;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+}
+.txtGreen{
+	color:green;
+}
+
+/* PICK LIST */
+ul li{
+	padding-bottom:2px;
+	padding-top:2px;
+}
+/* MY PREFERENCES */		
+/* CSS FOR REPORTS */
+
+.reportHdr{
+	background-color:#DDDDDD;
+	font-size:12px;
+	font-weight:bold;
+	vertical-align:middle;
+	text-align:left;
+	height:30px;
+	border-bottom:2px solid #959595;
+	color:#000000;
+	padding-left:10px;
+}
+
+#reportLay{
+	width:175px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+#locateMap{
+	width:120px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+
+ a.reportMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:none;
+	display:block;
+	width:155px;
+	height:20px;
+	border-bottom:1px solid #E1E1E1;
+	padding-left:20px;
+	padding-top:3px;
+}
+
+a.reportMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+	display:block;
+	width:155px;
+	height:20px;
+	border-bottom:1px solid #E1E1E1;
+	padding-left:20px;
+	padding-top:3px;
+}	
+
+#Generate{
+	position:relative;
+	width:100%;
+	text-align:center;
+	display:none;
+}
+
+/* END OF REPORT */
+/* WEB MAIL */
+ a.webMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+}
+a.webMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+} 
+/*  END OF WEB MAIL */
+/* POPUP */
+ a.alpha{
+	font-size:11px;
+	color:gray;
+	text-decoration:none;
+	padding-Left:5px;
+	padding-right:5px;
+	border:1px dotted #CCCCCC;
+	background-color:#FFFFCC;
+}
+
+a.alpha:Hover{
+	font-size:11px;
+	color:gray;
+	text-decoration:underline;
+	padding-Left:5px;
+	padding-right:5px;
+	border:1px dotted #CCCCCC;
+	background-color:#FFFFCC;
+} 
+
+/* Home Page */
+.MatrixLayer{
+	border:2px solid #aaaaaa;
+	background-color:#FFFFFF;
+	width:29%;
+	position:relative;
+	visibility:visible;
+	margin:9px;
+	height:280px;
+}
+
+.fontBold{
+	font-size:13px;
+	color:#000000;
+	text-decoration:none;
+	font-weight:bold;
+}
+
+.style_Gray{
+	color:gray;
+}
+	
+/* End of Home Page */
+
+/* All Menu */
+#allMenu{
+    width:500px;
+    border:4px solid #aaa;
+    left:200px;
+    top:100px;
+    position:absolute;
+    z-index:1000001;
+    display:none;
+    padding:10px;
+    background:#ffffff url(images/layerPopUpBg.gif);
+}
+
+
+.allMnuTable{
+    width:100%;
+    background-color:#FFFFFF;
+}
+
+.allMnuHandle td{
+    height:20px;
+    color:#FFFFFF;
+    font-family:Arial, Helvetica, sans-serif;
+    font-size:12px;
+    font-weight:bold;
+    text-decoration:none;
+    background-color:#555;
+    cursor:move;
+    padding:2px;
+    border-bottom:2px solid #666666;
+}
+
+.allMnuHdr{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-weight:Bold;
+    font-size:11px;
+    text-decoration:none;
+    display:block;
+    background-color:#FFFFFF;
+    color:#333;
+    padding-top:5px;
+    padding-bottom:5px;
+}
+
+a.allMnu{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-size:10px;
+    text-decoration:none;
+    font-weight:normal;
+    display:block;
+    width:125px;
+    height:15px;
+    padding-left:5px;
+    padding-top:0px;
+    padding-bottom:0px;
+    background-color:#FFFFFF;
+    border:1px solid #FFFFFF;
+    color:#000099;
+    margin-left:10px;
+}
+
+a.allMnu:Hover{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-size:10px;
+    text-decoration:none;
+    font-weight:normal;
+    display:block;
+    width:125px;
+    height:15px;
+    padding-left:5px;
+    padding-top:0px;
+    padding-bottom:0px;
+    background-color:#ddd;
+    
+}
+/* End Of All Menu */
+/* Calendar */
+.calHdr{
+	background-image:url(images/mailSubHeaderBg.gif); 
+	background-repeat:repeat-x;
+	background-position:left top;
+}
+
+.calSel{
+	background-image:url(images/dashSelectBg.gif);
+	background-repeat:repeat-x;
+	text-align:center;
+	color:#FFFFFF;
+	font-weight:bold;
+	width:8%;
+}
+
+.calAddButton {
+	border: 1px solid #999;
+	background:#ddd url(images/calAddButtonBg.gif) repeat-x;
+	cursor:pointer;
+	height:20px;
+	
+
+}
+.calInnerBorder {
+	border-left:2px solid #a5a5a5;
+	border-right:2px solid #a5a5a5;
+	border-bottom:2px solid #a5a5a5;
+}
+
+.calBorder {
+	border-left: 1px solid #a5a5a5; 
+	border-right: 1px solid #a5a5a5; 
+	border-bottom: 1px solid #a5a5a5; 
+	background:#fefefe url(images/layerPopupBg.gif);
+
+}
+.calTopRight {
+	border-right: 1px solid #a5a5a5; 
+}
+
+
+.calUnSel{
+	color:#000000;
+	font-weight:normal;
+	text-align:center;
+	width:8%;
+}
+
+a.calMnu{
+	font-size:11px;
+	color:#009;
+	text-decoration:none;
+	display:block;
+	height:20px;
+	padding-left:5px;
+	padding-top:3px;
+}	
+
+a.calMnu:Hover{
+	font-size:11px;
+	color:#009;
+	text-decoration:underline;
+	display:block;
+	height:20px;
+	padding-left:5px;
+	padding-top:3px;
+}
+
+/*.bggray{
+	background-color: #dfdfdf;
+}*/
+.bgwhite{
+	background-color: #FFFFFF;
+}
+.copy{
+	font-size:9px;
+	font-family: Verdana, Arial, Helvetica, Sans-serif;
+}
+
+#mnuTab{
+	position:relative;
+	width:100%;
+	display:block;
+}
+
+#mnuTab2{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:none;
+}
+.style1 {color: #FF0000}
+.event{
+	background-color:#ddd;
+	border:1px solid #999999;
+	text-align:left;
+	width:100%;
+	position:relative;
+	left:0px;
+	top:0px;
+	vertical-align:middle;
+	padding:1px;
+}
+
+#hrView{
+	display:block;
+}
+.calendarNav{
+	font-size:12px;
+	color:#FFFFFF;
+	white-space:nowrap;
+	text-align:center;
+	font-weight:bold;
+	padding-left:10px;
+	padding-right:10px;
+	background-image:url(images/cal_nav.gif);
+	background-repeat:repeat-x;
+}
+#addEventDropDown{
+	position:absolute;
+	display:none;
+	width:150px;
+	border:1px solid #666666;
+	left:0px;
+	top:0px;
+	overflow:visible;
+	z-index:5000;
+}
+
+.calAction{
+	width:175px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+.calSettings{
+	position:absolute;
+	z-index:20000;
+	width:500px;
+	left:200px;
+	top:150px;
+	background-color:#ffffff;
+}
+.outer{
+	border-bottom:1px solid #CCCCCC;
+	border-left:1px solid #CCCCCC;
+	border-right:1px solid #CCCCCC;
+}
+.calTxt{
+	width:50%;
+	border:1px solid #CCCCCC;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	padding-left:5px;
+}
+
+#leadLay{
+	position:relative;
+	width:100%;
+	float:left;
+	visibility:hidden;
+	padding:5px;
+	z-index:10000;
+}
+									
+/* End of Calendar */
+
+/* Cal Year View */
+.eventDay{
+	background-color:#FF9966;
+	font-weight:bold;
+}
+
+.currDay{
+	background-color:#006600;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+.currDay a{
+	color:#FFFFFF;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+
+/* End of Cal Year View */
+
+/* Level 2 Menu Selected*/
+
+level2Sel{
+	color:#000000;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+#DeleteLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:300px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	padding:5px;
+}
+
+#CurrencyDeleteLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:350px;
+}
+
+
+/* For Report HTML Generation*/
+.rptCellLabel {
+    background-color:#f6f6f6;
+    padding-right:10px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom:1px solid #eaeaea;
+    color:#737373;
+    font-weight: bold;
+    white-space:nowrap;
+}
+.rptTable {
+    border-left: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+    border-top: 1px solid #DDDDDD;
+}
+.rptTitle, .rptHead, .rptData, .rptGrpHead{
+    font-family: Verdana, Arial, Helvetica, Sans-serif;
+    font-size: 11px;
+	text-align:left;
+    font-weight: normal;
+	height: 20px;
+	padding: 4px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+	background: #DDDDDD;
+}
+.rptGrp1Total, .rptGrp2Total, .rptTotal {
+    font-family: Verdana, Arial, Helvetica, Sans-serif;
+    font-size: 11px;
+	text-align:center;
+    font-weight: normal;
+    background: #FFF;
+	height: 20px;
+	padding: 4px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+}
+.rptGrpHead {
+	background: #FFF;
+    border-bottom: 1px solid #FFF;
+    border-top: 1px solid #DDDDDD;
+    font-weight: normal;
+}
+
+.rptData {
+            background: #FFF;
+            font-weight: normal;
+}
+.rptEmptyGrp {
+            background: #FFF;
+            border-right: 1px solid #DDDDDD;
+}
+.statechange
+{
+    position:absolute;
+    visibility:hidden;
+    left:10px;
+    top:20px;
+    width:300px;
+    border:3px solid #CCCCCC;
+    background-color:#FFFFFF;
+}
+#PopupLay{
+    position:absolute;
+    font-family:Arial, Helvetica, sans-serif;
+    font-size:11px;
+    text-align:left;
+    width:500px;
+    border:3px solid #CCCCCC;
+    background-color:#FFFFFF;
+    padding:5px;
+    display:none;
+    left:100px;
+    top:100px;
+}
+
+#folderLay{
+    width:175px;
+    background-color:#CCCCCC;
+    border:1px solid #DDDDDD;
+    padding-top:5px;
+    position:absolute;
+    display:none;
+}
+
+/* Css for quick Create */
+
+.qcTransport{
+	    background-color:#dadada;
+
+}
+
+#role_popup{
+        position:relative;
+        left:0px;
+        top:0px;
+        width:95%;
+        height:300px;
+        overflow:auto;
+        border:1px solid #999999;
+        text-align:left;
+        background-color:#FFFFFF;
+    }
+
+.unread_email {
+	font-weight:bold;
+        background-color:#00FF00;
+}
+.delete_email {
+	font-weight:bold;
+        background-color:#FF5151;
+
+}
+.qualify_email {
+	                   font-weight:bold;
+	                   background-color:#CDB5CD;
+	
+          }
+
+
+
+
+.mailSelected {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+.mailSelected_select {
+	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
+	background-color:#1F5EFF;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+								    
+/* MY SITES */
+
+.unread_email:hover {
+	font-weight:bold;
+}
+
+
+.tagCloud {
+    border:1px solid #737373;
+}
+
+   
+.tagCloudTopBg {
+    background: url(images/tagCloudBg.gif) repeat-x;
+   
+}
+
+.tagCloudDisplay {
+    background-color:#e5e5e5;
+    padding:10px;
+    font-family: Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    line-height: 14px;
+    color: #000000;
+
+}
+.h2 {
+
+	font-size:18px;
+	line-height:20px;
+
+}
+
+.gray {
+
+	color:gray;
+}
+ul {
+	list-style:circle;
+	line-height:20px;
+	padding-left:5px;
+	margin-left:20px;
+	font-weight:normal;
+
+}
+.tagCloudTopBg {
+	background-image: url(images/tagCloudBg.gif);
+	background-repeat: repeat-x;	
+}
+
+.tagCloudDisplay {
+	background-color:#e5e5e5;
+	padding:5px;
+}
+
+.heading2 {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	line-height: 16px;
+	font-weight:bold;
+	color: #000000;
+}
+
+.settingsUI {
+	
+	text-align:left;
+	background-color:#fff;
+	background-image:url(images/layerPopupBg.gif);
+	border:2px solid #aaaaaa;
+
+}
+
+
+.settingsTabHeader {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	line-height:22px;
+	font-weight:bold;
+	color:#333;
+	background-image: url(images/mailSubHeaderBg.gif);
+	 background-color:#dddddd;
+	background-repeat: repeat-x;
+	padding-left:10px;
+	padding-right:10px;
+
+}
+
+.settingsTabList {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:20px;
+	font-weight:normal;
+	color:#000000;
+	background-color:#e5e5e5;
+	padding-left:30px;
+	border-bottom:1px solid #ccc;
+	border-top:1px solid #fff;
+}
+.settingsTabSelected {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:20px;
+	font-weight:bold;
+	color:#000000;
+	background-color:#ffffff;
+	padding-left:30px;
+	border-left:1px solid #ddd;	
+}
+.settingsSelectedUI {
+	padding:10px;
+	background:url(images/settingsSelUIBg.gif) repeat-x;
+	background-color:#ffffff;
+}
+.settingsIconDisplay {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:14px;
+	padding:10px;
+
+	color:#000000;
+	background-color:#ffffff;
+	padding-left:10px;
+}
+.settingsSelUITopLine{
+	border-bottom:2px dotted #999999;
+
+}
+
+.tableHeading{
+	background-color:#ffffff;
+	border-bottom:2px solid #555;
+}
+.colHeader{
+	background-color:#ddd;
+	border-left:1px solid #fff;
+	border-top:1px solid #fff;
+	border-right:1px solid #aaa;
+	border-bottom:1px solid #aaa;
+	font-weight:bold;
+
+}
+.cellLabel {
+	background-color:#eaebd9;
+	border-top:1px solid #efefef;
+	border-bottom:1px solid #dadada;
+	color:#555555;
+
+}
+.cellText {
+	color:#333333;
+	border-bottom:1px solid #dadada;
+} 
+
+.listTable{
+	border-left:1px solid #cccccc;
+	border-right:1px solid #cccccc;
+	border-bottom:1px solid #cccccc;
+
+}
+
+.listTableRow{
+	border-bottom:1px solid #eaeaea;
+	border-right	:1px solid #eaeaea;
+	border-bottom:1px solid #eaeaea;
+	border-bottom:1px solid #eaeaea;
+}
+.listRow{
+	border-bottom:2px solid #eaeaea;
+
+}
+
+.listTableTopButtons{
+	background-color:#efefef;
+	background-image:url(images/layerPopupBg.gif);
+	
+}
+
+
+/*  Buttons */
+.crmButton{
+	
+	border-left:1px solid #ffffff;
+	border-top:1px solid #ffffff;
+	border-right:1px solid #555555;
+	border-bottom:1px solid #555555;
+}
+
+.create{
+	background-color:#55aa55;
+	color:#fff;
+	font-weight:bold;
+}
+.delete {
+	background-color:#ffaa22;
+	color:#000;
+	font-weight:bold;
+}
+.edit {
+	background-color:#55aa55;
+	color:#fff;
+	font-weight:bold;
+}
+.save{
+	background-color:#55aa55;
+	color:#fff;
+	font-weight:bold;
+}
+.cancel {
+	background-color:#ffaa22;
+	color:#000;
+	font-weight:bold;
+}
+
+.inactive{
+color:#999999;
+}
+
+.active{
+color:#229922;
+
+}
+
+/* Buttons ends */
+
+
+
+textarea {
+	width:95%;
+	height:70px;
+	border:1px solid #dadada;
+}
+.treeTable1{
+	padding:0px;
+}
+
+.prvPrfBigText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+.prvPrfTopBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfBottomBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfOutline {
+	border:1px solid #ebebeb;
+}
+.prvPrfTexture {
+	background:url(images/prvPrfTexture1.gif);
+
+}
+
+.prvPrfHoverOn {
+	background-color:#ffffef;
+	
+}
+.cellBottomDotLine {
+	border-bottom-width: 2px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	background-color:#ededed;
+}
+.crmFormList{
+	border:1px solid #cccccc;
+	width:90%;
+	height:120px;
+
+}
+.cellBottomDotLinePlain {
+	border-bottom-width: 2px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	
+}
+
+.thickBorder {
+	border: 2px solid #999999;
+}
+.trackerHeading {
+	background-color:#efefef;
+}
+.trackerListBullet {
+	border-right:1px dotted #cccccc;
+	background-color:#f9f9f9;
+}
+.trackerList {
+	border-bottom:1px solid #eeeeee;
+}
+
+/* Table Definitions */
+.crmTable {
+	border:1px solid #dadada;
+}
+
+.crmTableRow {
+	border-bottom:1px dotted #dadada;
+	border-right:1px dotted #dadada
+}
+
+/* Inventory */
+
+.lineOnTop {
+	border-top:1px solid #999999;
+}
+
+.discountUI{
+	border:3px solid #CCCCCC;
+	width:250px;
+	padding:5px;
+	position:absolute;
+	background-color:#FFFFFF;
+	display:none;
+}
+
+.TaxShow{
+	display:inline-table;
+}
+
+.TaxHide{
+	display:none;
+}
+
+/* Inventory */
+
+
+/* Email Client Classes ++++++++++++++++++++++ */
+
+.emailSelected{
+	background-color:#eaeaea;
+	color:#000000;
+	font-size:bold;
+}
+
+
+.mailClient{
+	border:2px solid #656565;
+}
+
+.mailClientBg {
+	background-color:#efefef;
+	background-image:url(images/layerPopupBg.gif);
+}
+
+.mailSubHeader {
+	background:#d9d9d9 url(images/mailSubHeaderBg.gif) repeat-x;
+	padding:4px;
+}
+.mailClientWriteEmailHeader {
+	font-family:arial, helvetica, sans-serif;
+	font-size:20px;
+	line-height:24px;
+	font-weight:bold;
+	background:#e0e0e0 url(images/mailSubHeaderBg.gif) repeat-x;
+	padding:10px;
+	border-left:1px solid #eaeaea;
+	border-top:1px solid #eaeaea;
+	border-right:1px solid #999;
+	border-left:1px solid #999;;
+}
+
+.mailClientCSSButton {
+	border-left:1px solid #fff;
+	border-top:1px solid #fff;
+	border-right:1px solid #333;
+	border-bottom:1px solid #333;
+	padding:2px;
+	background-color:#cfcfcf;
+}
+
+/* Email Client Classes ends ------------------------------------ */
+
+
+
+/* Layer Popup */
+.layerPopup {
+	border:3px solid #959595;
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+	position:absolute;
+}
+
+.layerPopupHeading {
+	font-family:arial, helvetica, sans-serif;
+	font-size:16px;
+	line-height:24px;
+	font-weight:bold;
+}
+.layerHeadingULine {
+	border-bottom:2px solid #777;
+}
+.layerPopupTransport {
+	background-color:#eaeaea;
+
+}
+.homePageSeperator {
+	border-right:1px dotted #ddd;
+}
+.homePageMatrixHdr {
+	border-bottom:1px solid #d3d3d3;
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+}
+
+.reportsListTable {
+	background-color:white;
+	border-left:1px solid #aaa;
+	border-right:1px solid #aaa;
+	border-bottom:1px solid #aaa;
+}
+
+.reportGenerateTable{
+	background-image:url(images/layerPopupBg.gif);
+	border-left:2px dotted #aaa;
+	border-right:2px dotted #aaa;
+	border-bottom:2px dotted #aaa;
+}
+.reportCreateBottom{
+	background-color:#eaeaea;
+	border-bottom:2px solid #777;
+
+}
+.importLeadUI{
+	/*background:#ffffff url(images/select.gif) ; */
+	background-color:#fff;
+}
+
+a.customMnu{
+	padding-left:30px;
+	padding-top:5px;
+	padding-bottom:5px;
+	display:block;
+	background-repeat:no-repeat;
+	background-position:left;
+	width:155px;
+	color:#000000;
+	text-decoration:none;
+}
+
+a.customMnuSelected{
+	padding-left:30px;
+	padding-top:5px;
+	padding-bottom:5px;
+	display:block;
+	background-repeat:no-repeat;
+	background-position:left;
+	width:155px;
+	background-color:#0099FF;
+	color:#FFFFFF;
+	text-decoration:none;
+}
+
+
+/* Drop Down Menu */
+.drop_mnu{
+    position:absolute;
+    left:0px;
+    top:0px;
+    z-index:1000000001;
+    border-left:1px solid #a5a5a5;
+    border-right:1px solid #a5a5a5;
+    border-bottom:1px solid #a5a5a5;
+    width:150px;
+    display:none;
+    padding:0px;
+    text-align:left;
+    overflow-x:hidden;
+    overflow-y:hidden;
+    background-color:#eee;
+}
+
+a.drop_down{
+    width:150px;
+    text-align:left;
+    font-family:  Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    line-height:20px;
+    font-weight:normal;
+    color:#009;
+    background-color:#eee;
+    padding:2px 5px 2px 5px;
+    border-top:1px solid #fafafa;
+    border-bottom:1px solid #d3d3d3;
+    display:block;
+}
+
+a.drop_down:Hover{
+    padding:2px 5px 2px 5px;
+    width:150px;
+    text-align:left;
+    color:#33a;
+    font-weight:normal;
+    text-decoration:underline;
+    background-color:#dadada;
+}
+
+.bgwhite{
+	background-color:white;
+}
+
+.searchUIBasic {
+		background-image:url(images/layerPopupBg.gif);
+		border:2px solid #a5a5a5;
+}
+.searchUIAdv1{ 
+		background-image:url(images/layerPopupBg.gif);
+		border-top:2px solid #a5a5a5;
+		border-left:2px solid #a5a5a5;
+		border-right:2px solid #a5a5a5;
+}
+.searchUIAdv2{ 
+		background-image:url(images/layerPopupBg.gif);
+		border-left:2px solid #a5a5a5;
+		border-right:2px solid #a5a5a5;
+}
+.searchUIAdv3{ 
+		background-image:url(images/layerPopupBg.gif);
+		border-bottom:2px solid #a5a5a5;
+		border-left:2px solid #a5a5a5;
+		border-right:2px solid #a5a5a5;
+}
+
+
+
+/* Recalculate Disabling Window */
+
+.veil{
+   background: url(images/layerPopupBg.gif) ;
+    height: 100%;
+    width: 100%;
+    top: 0px;
+    left: 0px;
+    overflow: hidden;
+    z-index: 10000;
+    Filter: Alpha(opacity = 70);
+    -moz-opacity: 0.7;
+    text-align: center;
+    vertical-align: middle;
+    position: absolute;
+}
+
+.veil_new{
+   background: url(images/layerPopupBg.gif) ;
+    height: 100%;
+    width: 100%;
+    top: 0px;
+    left: 0px;
+    overflow: hidden;
+    z-index: 50000;
+    Filter: Alpha(opacity = 70);
+    -moz-opacity: 0.7;
+    text-align: center;
+    vertical-align: middle;
+    position: absolute;
+}
+
+.optioncontainer{
+    vertical-align: middle;   
+    height: 100%;
+    width: 100%;   
+    position: absolute;
+    z-index: 90000;   
+}
+
+
+.options{
+    	vertical-align: middle;   
+	margin-left: 25%;
+	margin-top: 16%;
+	color: #FFFFFF;
+	width:650px;
+	background-color: Black;
+	border: 2px solid #222;	
+    	position: relative;
+	text-align: left;
+    	z-index: 80000;   
+}
+
+.options h2{
+	color: White;
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	border-bottom: 1px solid #373D4C;
+	margin: 0;
+	font-weight: normal;
+}
+.groupname{
+		width:125px;
+	  }
+.winmarkModulesdef{
+   background-image:url(images/alphagrayHomeMark.gif);
+   background-position:top;
+   background-repeat:repeat-x;
+
+
+/* Recalculate Disable Ends */
+

Modified: vtigercrm/branches/5.1_jens/themes/bluelagoon/images/aboutUS.jpg
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/branches/5.1_jens/themes/bluelagoon/images/cal12x12Shared.gif
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/branches/5.1_jens/themes/bluelagoon/style.css
==============================================================================
--- vtigercrm/branches/5.1_jens/themes/bluelagoon/style.css (original)
+++ vtigercrm/branches/5.1_jens/themes/bluelagoon/style.css Mon Apr 16 12:27:44 2007
@@ -1,2234 +1,2284 @@
-/*********************************************************************************
-
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
- ********************************************************************************/
-
-
-/* WOOD SPICE  - COLOR THEME*/
-
-.small {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-}
-.big {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 12px;
-	line-height: 18px;
-	color: #000000;
-	font-weight:bold;
-}
-
-.componentName {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	line-height: 18px;
-	color: #3333ff;
-	font-weight:bold;
-	border-left:2px dotted #fff;
-	padding:10px;
-}
-
-
-.genHeaderBig{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 16px;
-	line-height: 19px;
-	color: #000000;
-	font-weight:bold;
-}
-.genHeaderSmall{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	line-height: 16px;
-	color: #000000;
-	font-weight:bold;
-}
-
-.moduleName {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	color: #000033;
-	font-weight:bold;
-}
-
-
-.hdrNameBg {
-	 background:#ffffff url(images/hdrNameBg.gif) repeat-x;
-	
-	
-}
-
-.hdrTabBg {
-	background:#ffffff url(images/hdrTabBg.gif) bottom repeat-x ;
-	background-color:#fff;
-}  
-
-.tabSelected {
-	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
-	background-color:#1F5EFF;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-weight:bold;
-	font-size: 11px;
-	padding-left:10px;
-	padding-right:10px;
-	padding-top:2px;
-	padding-bottom:2px;
-	
-}
-
-.tabSelected a{
-	color:white;
-}
-
-.tabUnSelected {
-	
-	background: #efedd4 url(images/tabUnSelectedBg.gif) bottom repeat-x;
-	background-color:#AFDBFF;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	padding-left:10px;
-	padding-right:10px;
-	padding-top:2px;
-	padding-bottom:2px;
-	border-bottom:1px solid #ffffff;
-}
-
-.tabUnSelected a{
-	color:#000099;
-}
-
-.tabSeperator {
-	background-color:#aae;
-	width:1px;
-}
-
-
-
-.level2text {
-    
-    font-family: Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    padding-left:15px;
-    padding-right:15px;
-    padding-top:5px;
-    padding-bottom:5px;
-    font-weight:bold;
-    color:white;
-}
-
-.level2text a{
-	text-decoration:none;
-	color:#555555;
-}
-
-.level2text a:hover {
-	text-decoration:underline;
-	color:#555555;
-
-}
-
-
-.level2Bg {
-	background:#1F5BFF url(images/level2TabBg.gif) bottom repeat-x;
-	background-color:#1F5BFF;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	border-bottom:1px solid #222255;
-	color:white;
-}
-
-.level2Bg a{
-	/* background:#1F5BFF url(images/level2TabBg.gif) bottom repeat-x; */
-	color:white;
-}
-
-
-.level2SelTab{
-	font-weight:bold;
-	color:#000000;
-	padding-left:20px;
-	padding-right:20px;
-	padding-top:5px;
-	padding-bottom:5px;
-	
-}
-	
-.level2UnSelTab{
-	color:#000000;
-	padding-left:20px;
-	padding-right:20px;
-	padding-top:5px;
-	padding-bottom:5px;
-}
-.sep1 {
-	background:#999999;
-}
-
-.showPanelBg {
-	background:url(images/showPanelTopBg.gif) repeat-x;
-}
-
-a {
-	text-decoration:none;
-	color:#3344bb;
-}
-
-a:hover {
-	text-decoration:underline;
-}
-
-.hdrLink {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	text-decoration:none;
-	color:#0000cc;
-	font-weight:bold;
-}
-
-.hdrLink:hover {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	text-decoration:underline;
-	color:#0000cc;
-	font-weight:bold;
-}
-
-.searchBox {
-	border: 0px solid #0000aa;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	padding-left:2px;
-	width:100px;
-	background-color:#ffffef;
-}
-
-.searchBtn {
-	border :0px #cccccc solid;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	font-weight:bold;
-	width:30px;
-	height:19px;
-	background-color:#009;
-	color:white;
-}
-
-
-/* List View Table classes starts  +++++++++++++++++ */
-
-.lvt {
-	background-color:#ddf;
-	border:1px solid #cce; 
-}
-
-.lvtBg {
-}
-
-.lvtHeaderText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	font-weight:bold;
-}
-
-.lvtCol {
-	border-top:1px solid #eeeeff;
-	border-left:1px solid #eeeeff;
-	border-right:1px solid #9999dd;
-	border-bottom:1px solid #9999dd;
-	background-color:#eef;
-	font-weight:bold;
-}
-
-.lvtColData {
-	background-color:#ffffff;
-}
-
-.lvtColDataHover {
-	background-color:#eeefff;
-	
-}
-
-
-/* List View Table classes ends --------------------------------*/
-
-
-
-/* Detailed View classes starts +++++++++++++++++++++++ */
-.dvHeaderText{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	color:#000000;
-	font-weight:bold;
-
-}
-
-.dvInnerHeader{
-	border-bottom:2px solid #4F94CD;
-	padding:5px;
-	background-color:#afdbff;
-
-}
-
-.dvtSelectedCell {
-	border-left:2px solid #00BFFF;
-	border-top:2px solid #00BFFF;
-	border-right:2px solid #00BFFF;
-	padding-left:20px;
-	padding-right:20px;
-	background-color:white;
-	font-weight:bold;
-}
-
-.dvtUnSelectedCell {
-	border-left:2px solid #00BFFF;
-	border-top:2px solid #00BFFF;
-	border-right:2px solid #00BFFF;
-	border-bottom:2px solid #00BFFF;
-	padding-left:20px;
-	padding-right:20px;
-	background-color:#ffffee;
-	cursor:pointer;
-}
-
-.dvtTabCache {
-	border-bottom:2px solid #00BFFF;
-}
-
-.dvtContentSpace {
-	border-left:2px solid #00BFFF;
-	border-right:2px solid #00BFFF;
-	border-bottom:2px solid #00BFFF;
-	padding-left:0px;
-}
-
-.dvtCellLabel, .cellLabel {
-	background-color:#f5f5ff;
-	padding-right:10px;
-	padding-left:10px;
-	border-bottom:1px solid #dadaee ;
-	border-top:1px solid #ffffff ;
-	color:#545454;
-	white-space:nowrap;
-}
-
-.dvtCellInfo, .cellInfo {
-	padding-left:10px;
-	padding-right:10px;
-	border-bottom:1px solid #efefef;
-	white-space:nowrap;
-}
-
-.rightMailMerge {
-	border:2px solid #aae;
-}
-
-.rightMailMergeHeader {
-	border-bottom:1px solid #dde;
-	padding:5px;
-	background-color:#eef;
-
-}
-
-.rightMailMergeContent {
-	padding:5px;
-	background-color:#fafafa;
-
-}
-
-.detailedViewHeader{
-	border-bottom:2px solid #4F94CD;
-	padding:5px; 
-	background-color:#afdbff;
-}
-
-.detailedViewTextBox {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#ffffff;
-}
-
-.detailedViewTextBoxOn {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#ffffdd;
-}
-
-.detailedViewTextBoxDis {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #555555;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#aaaaaa;
-}
-
-.detailedViewTextArea {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:95%;
-	height:100px;
-	background-color:#ffffff;
-	text-align:left;
-}
-
-.advSearch {
-	padding:10px;
-	border-left:1px solid #eaeaea; 
-	border-right:1px solid #eaeaea; 
-	border-bottom:1px solid #eaeaea; 	
-	overflow:auto;
-	width:600px;
-	height:150px;
-	background-color:#ffffef;
-
-}
-
-.searchAlph {
-	border:1px solid #dadada;
-	background-color:#ffffff;
-	cursor:pointer;
-	width:10px
-
-}
-.searchAlphselected {
-	border:1px solid #666666;
-	background-color:#bbbbbb;
-	cursor:pointer;
-	width:10px
-
-}
-.textbox {
-	border:1px solid #999999;
-	background-color:#ffffff;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	width:120px;
-	padding:2px;
-
-}
-
-
-.mx {
-}
-
-.calListTable td{
-	border-bottom:1px solid #efefef;
-	border-left:1px solid #efefef;
-}
-.calDIV {
-	width:100%;
-	border:1px solid #999999;
-	
-}
-
-.calDayHour {
-	border-top:1px solid #c5d5ff;
-	border-left:1px solid #c5d5ff;
-	border-bottom:1px solid #c5d5ff;
-	border-right:1px solid #c5d5ff;
-	background-color:#eae7da;
-}
-
-.calAddEvent {
-	position:absolute;
-	z-index:10000;
-	width:500px;
-	left:200px;
-	top:150px;
-	background-color:#ffffff;
-}
-.addEventInnerBox {
-	border:1px dotted #dadada;
-
-}
-
-
-.cellNormal {
-	border:0px;
-	background-color:#ffffff;
-}
-
-
-.thumbnail{
-    background-color:#ffffff;
-padding: 7px;
-border: 1px solid #ddd;
-float: left;
-	   margin-right: 10px;
-	   margin-bottom: 15px;
-}
-
-
-.padTab{
-    padding-top:0px;
-    padding-left:0px;
-    padding-left:10px;
-    padding-bottom:0px;
-    vertical-align:top;
-
-}
-#company{
-    position:relative;
-    width:100%;
-    height:200px;
-    display:block;
-    background-color:#FFFFFF;
-    white-space:nowrap;
-    overflow:auto;
-    border:1px solid #CCCCCC;
-}
-                               
-
-#user{position:relative;left:0px;top:0px;width:100%;display:block;}
-/*#studio{position:relative;left:0px;top:0px;width:100%;display:block;}*/
-#communication{position:relative;left:0px;top:0px;width:100%;display:block;}
-#config{position:relative;left:0px;top:0px;width:100%;display:block;}
-
-#userTab{position:relative;left:0px;top:0px;width:100%;display:none;}
-#one{
-	position:relative;
-	display:block;
-	width:245px;
-}
-
-#mnuTab1{
-
-   position:relative;
-
-   overflow:auto;
-
-   width:100%;
-
-   display:none;
-
-}
-
-#mnuTab2{
-
-   position:relative;
-
-   overflow:auto;
-
-   width:100%;
-
-   display:none;
-
-}
-
-
-/* End of Settings */
-
-.bgwhite{
-	background-color: #FFFFFF;
-}
-.copy{
-	font-size:9px;
-	font-family: Verdana, Arial, Helvetica, Sans-serif;
-}
-
-#basicTab{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:block;
-}
-
-#moreTab{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:none;
-}
-
-/*Added for Advance Seearch*/
-
-
-#one{
-	position:relative;
-	display:block;
-	width:245px;
-}
-
-/* Dashboard CSS */
-a.dash_href{
-	display:block;
-	width:24px;height:24px;
-	vertical-align:middle;
-	margin-top:10px;
-}
-.dashHeading {
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:24px;
-	font-weight:bold;
-	color:#fff;
-}
-.dashSelectBg{
-	background-image:url(images/dashSelectBg.gif);
-	background-repeat:repeat-x;
-}
-.dash_top{
-	background-image:url(images/dashTopBg.gif);
-	background-repeat:repeat-x;
-	height:63px;
-	vertical-align:middle;
-}
-
-.dash_border{
-	background-color:#738bff;
-	padding:5px;
-}
-
-
-.dash_white{
-	background-color:#FFFFFF;
-	padding:5px 10px 5px 10px;
-}
-
-.dash_bdr_btm{
-	border-bottom:2px dotted #939271;
-}
-
-.dash_count{
-	font-size:36px;
-	font-weight:bold;
-	text-decoration:none;
-	color:#000000;
-	padding-left:10px;padding-right:10px;	
-}
-.dash_switch{
-	cursor:pointer;
-	width:26px;
-	height:26px;
-}
-
-.dash_row_sel{
-	background-image:url(images/dash_sel_chart.jpg);
-	background-repeat:no-repeat;
-	background-position:center;
-	width:26px;height:26px;
-	text-align:center;
-	vertical-align:middle;
-	font-weight:bold;
-	font-size:10px;
-	text-decoration:none;
-}
-
-.dash_row_unsel{
-	background-image:url(images/dash_unsel_chart.jpg);
-	background-repeat:no-repeat;
-	background-position:center;
-	width:26px;height:26px;
-	text-align:center;
-	vertical-align:middle;
-	font-weight:normal;
-	font-size:10px;
-	text-decoration:none;
-	cursor:pointer;
-}
-
-.dash_chart_btm{
-	border-bottom:2px solid #000000;
-}
-
-
-.dash_bottom{
-	background-image:url(images/dashBottomBg.gif);
-	background-repeat:repeat-x;
-	height:99px;
-	vertical-align:middle;
-}
-
-.dash_btm{
-	background-image:url(images/dash_btm_center.jpg);
-	background-repeat:repeat-x;
-	position:top;
-}
-
-
-/* clock */
-
-.citystyle{
-	position:relative;
-	top:0px;
-	left:0px;
-	text-align:left;
-	
-}
-#theClockLayer{
-	position:relative;
-	height:180px;
-	left:20px;
-	text-align:center;
-}
-.handsanddotsstyle{
-	margin-top:10px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:2px;
-	height:2px;
-	font-size:2px;
-	background-color:#000000;
-}
-.facestyle{
-	margin-top:10px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:15px;
-	height:15px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-.datestyle{
-	margin-top:20px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:100px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-.ampmstyle{
-	margin-top:23px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:20px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-
-#wclock{
-	position:absolute;
-	left:100px;
-	top:100px;
-	display:none;
-	background-color:#CCCCCC;
-	width:175px;
-}
-
-.leftFormBorder1 {
-	border: 1px solid #AFC8E4;
-	background-color: #FFFFFF;
-	opacity:.7;
-}
-
-
-
-
-/* Calculator */
-.calcResult {
-	width: 100%;
-	height: 25px;
-	background-color: #FFFFCC;/*CBDFD6*/
-	border-top: 1px solid #CCC;
-	border-left: 0px;
-	border-right: 1px solid #CCC;
-	border-bottom: 1px solid #CCC;
-	font-size: 10px;
-	text-align: right;
-}
-.calcMem {
-	width: 100%;
-	height: 25px;
-	border-top: 1px solid #CCC;
-	border-left: 1px solid #CCC;
-	border-right: 0px;
-	border-bottom: 1px solid #CCC;
-	background-color: #FFFFCC;/*CBDFD6*/
-	font-family: Arial;
-	font-size: 10px;
-	color: #BBB;
-	text-align: left;
-}
-.calcBlackBtn, .calcGreyBtn, .calcBigBtn, .calcCancBtn, .calcMemBtn, .calcBackBtn {
-	border: none;
-	height: 20px;
-	font-size: 11px;
-	color: #FFF;
-	text-align:center;
-}
-.calcBackBtn {
-	background: url(images/calc_back_btn.gif) no-repeat;
-	width:25px;
-}
-.calcBlackBtn {
-	background: url(images/calc_black_btn.gif) no-repeat;
-	width:25px;
-}
-.calcGreyBtn {
-	background: url(images/calc_grey_btn.gif) no-repeat;
-	width:25px;
-}
-.calcCancBtn {
-	background: url(images/calc_canc_btn.gif) no-repeat;
-	width:25px;
-	
-}
-.calcMemBtn {
-	background: url(images/calc_mem_btn.gif) no-repeat;
-	width:25px;
-	/*background-color: #CCC;*/
-}
-
-#calc{
-	position:absolute;
-	left:100px;
-	top:100px;
-	background-color:#FFFFFF;
-	width:185px;
-	border-bottom:2px solid #000000;
-	border-right:2px solid #666666;
-	border-left:2px solid #CCCCCC;
-	border-top:2px solid #CCCCCC;
-}
-
-/* RSS STYLES */
-
-.subHdr{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#FFFFFF;
-	background-image:url(images/rssHeader.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-}
-
-.delBg{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#FFFFFF;
-	background-image:url(images/rssdelete.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-}
-
-#rssScroll{
-	font-family:Arial, Helvetica, sans-serif	;
-	font-size:12px;
-	background-color:#FFFFFF;
-	width:100%;
-	height:130px;
-	overflow:auto;
-	border:0px solid #000000;
-}
-
-.rssTable{
-	width:100%;
-	border:0px solid #CCCCCC;
-}
-
-.rssTable tr th{
-	background-color:#00BFFF;
-	text-align:left;
-	border-bottom:1px solid #99F;
-	border-top:1px solid #FFFFFF;
-	color:#000000;
-	padding-left:5px;
-	padding-right:5px;
-	height:20px;
-}
-
-.rssTable tr td{
-	text-align:left;
-	border-bottom:1px dotted #dadada;
-	border-left:1px dotted #dadada;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	font-weight:normal;
-	white-space:nowrap;
-	padding:2px;
-	
-}
-
-
-.forwardBg{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#000000;
-	background-image:url(images/rssforward.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-	background-color:#D7D7D7;
-}
-
-
-/*  New Styles */
-
-.mnuTab{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#000000;
-	width:100%;
-	border:0px solid #000000;
-}
-
-.mnuTab tr td{
-	border-bottom:1px solid #EBEBEB;
-	padding-left:5px;
-	vertical-align:middle;
-}
-
-/* profile */
-
-.prvPrfBigText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-.prvPrfTopBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfBottomBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfOutline {
-	border:1px solid #ebebeb;
-}
-
-.prvPrfTexture {
-	background:url(images/prvPrfTexture1.gif);
-
-}
-.prvPrfHoverOn {
-	background-color:#ffffef;
-	
-}
-
-/*  Organization */
-
-.orgTab{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	font-weight:normal;
-	color:#666666;
-	border:0px solid #9B9B9B;
-	border-collapse:collapse;
-	width:100%;
-}
-
-.orgTab tr th{
-	text-align:left;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	text-decoration:none;
-	font-weight:bold;
-	height:20px;
-	padding-left:5px;
-}
-
-.orgTab tr td{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-decoration:none;
-	font-weight:normal;
-	padding-left:5px;
-	height:20px;
-	border-bottom:1px solid #CCCCCC;
-	border-right:1px solid #CCCCCC;
-}
-
-
-.groupli{
-	margin-left:20px;
-	font-family:Arial, Helvetica, sans-serif;
-	font-weight:normal;
-	font-size:12px;
-	text-decoration:none;
-	color:#333333;
-	list-style-type:none;
-	text-align:left;
-}
-
-/* tree menu */
-
-/*Oraganization Edit Features */
-
-#orgLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:500px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	display:block;
-	position:absolute;
-	left:0px;
-	top:0px;
-}
-
-/*  Role */
-
-#roleLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:300px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	display:none;
-	position:absolute;
-}
-
-.classBtn{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	text-decoration:none;
-	font-weight:normal;
-	font-size:10px;
-	background-color:#DBDBDB;
-	border-bottom:2px solid #999999;
-	border-right:2px solid #999999;
-	border-top:2px solid #F5F5F5;
-	border-left:2px solid #F5F5F5;
-	color:#000000;
-	text-align:center;
-	padding-top:3px;
-	padding-bottom:3px;
-}
-
-
-.txtBox{
-	width:85%;
-	border:1px solid #666666;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-}
-
-/*  IMPORT LEADS */
-
-.leadTable{
-	border:3px solid #CCCCCC;
-	border-collapse:collapse;
-}
-
-.leadTable tr td{
-/*	border:0px solid #CCCCCC;*/
-}
-
-.genHeaderGray{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	line-height: 16px;
-	color: #888888;
-	font-weight:bold;
-}
-
-.genHeaderGrayBig{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	line-height: 16px;
-	color: #888888;
-	font-weight:bold;
-}
-
-.importBox{
-	width:125px;
-	border:1px solid #666666;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-}
-
-
-.txtGreen{
-	color:green;
-}
-
-/* PICK LIST */
-ul li{
-	padding-bottom:2px;
-	padding-top:2px;
-}
-/* MY PREFERENCES */		
-
-
-/* CSS FOR REPORTS */
-
-.reportHdr{
-	background-color:#DDDDDD;
-	font-size:12px;
-	font-weight:bold;
-	vertical-align:middle;
-	text-align:left;
-	height:30px;
-	border-bottom:2px solid #959595;
-	color:#000000;
-	padding-left:10px;
-}
-
-#reportLay{
-	width:175px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-#locateMap{
-	width:120px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-
-a.reportMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:none;
-	display:block;
-	width:155px;
-	height:20px;
-	border-bottom:1px solid #E1E1E1;
-	padding-left:20px;
-	padding-top:3px;
-}
-
-a.reportMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-	display:block;
-	width:155px;
-	height:20px;
-	border-bottom:1px solid #E1E1E1;
-	padding-left:20px;
-	padding-top:3px;
-}	
-
-#Generate{
-	position:relative;
-	width:100%;
-	text-align:center;
-	display:none;
-}
-/* END OF REPORT */
-/* WEB MAIL */
-a.webMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-}
-a.webMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-} 
-
-
-/*  END OF WEB MAIL */
-
-/* POPUP */
-
- a.alpha{
-	font-size:11px;
-	color:gray;
-	text-decoration:none;
-	padding-Left:5px;
-	padding-right:5px;
-	border:1px dotted #CCCCCC;
-	background-color:#FFFFCC;
-}
-
-a.alpha:Hover{
-	font-size:11px;
-	color:gray;
-	text-decoration:underline;
-	padding-Left:5px;
-	padding-right:5px;
-	border:1px dotted #CCCCCC;
-	background-color:#FFFFCC;
-} 
-
-/* Home Page */
-.MatrixLayer{
-	border:2px solid #a5b5ee;
-	background-color:#FFFFFF;
-	width:29%;
-	position:relative;
-	visibility:visible;
-	margin:9px;
-	height:280px;
-}
-
-.fontBold{
-	font-size:13px;
-	color:#000000;
-	text-decoration:none;
-	font-weight:bold;
-}
-
-.style_Gray{
-	color:gray;
-}
-	
-/* End of Home Page */
-
-/* All Menu */
-#allMenu{
-    width:500px;
-    border:4px solid #a5b5ff;
-    left:300px;
-    top:100px;
-    position:absolute;
-    z-index:1000001;
-    display:none;
-    padding:10px;
-    background:#ffffff url(images/layerPopUpBg.gif);
-}
-
-
-.allMnuTable{
-    width:100%;
-    background-color:#FFFFFF;
-}
-
-.allMnuHandle td{
-    height:20px;
-    color:#FFFFFF;
-    font-family:Arial, Helvetica, sans-serif;
-    font-size:12px;
-    font-weight:bold;
-    text-decoration:none;
-    background-color:#000066;
-    cursor:move;
-    padding:2px;
-    border-bottom:2px solid #666666;
-}
-
-.allMnuHdr{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-weight:Bold;
-    font-size:11px;
-    text-decoration:none;
-    display:block;
-    background-color:#FFFFFF;
-    color:#000099;
-    padding-top:5px;
-    padding-bottom:5px;
-}
-
-a.allMnu{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-size:10px;
-    text-decoration:none;
-    font-weight:normal;
-    display:block;
-    width:125px;
-    height:15px;
-    padding-left:5px;
-    padding-top:0px;
-    padding-bottom:0px;
-    background-color:#FFFFFF;
-    border:1px solid #FFFFFF;
-    color:#000033;
-    margin-left:20px;
-}
-
-a.allMnu:Hover{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-size:10px;
-    text-decoration:none;
-    font-weight:normal;
-    display:block;
-    width:125px;
-    height:15px;
-    padding-left:5px;
-    padding-top:0px;
-    padding-bottom:0px;
-    background-color:#eef;
-    color:#333;
-}
-/* End Of All Menu */
-
-
-
-/* Calendar */
-.calHdr{
-	background-image:url(images/mailSubHeaderBg.gif); 
-	background-repeat:repeat-x;
-	background-position:left top;
-	
-}
-
-.calSel{
-	background-image:url(images/dashSelectBg.gif);
-	background-repeat:repeat-x;
-	text-align:center;
-	color:#FFFFFF;
-	font-weight:bold;
-	width:8%;
-}
-
-.calAddButton {
-	border: 1px solid #A5B5EF;
-	background:#D6D2AB url(images/calAddButtonBg.gif) repeat-x;
-	cursor:pointer;
-	height:20px;
-	
-
-}
-
-.calInnerBorder {
-	border-left:2px solid #A5B5EE;
-	border-right:2px solid #A5B5EE;
-	border-bottom:2px solid #A5B5EE;
-}
-
-.calBorder {
-	border-left: 1px solid #A5B5EE; 
-	border-right: 1px solid #A5B5EE; 
-	border-bottom: 1px solid #A5B5EE; 
-	background:#fefefe url(images/layerPopupBg.gif);
-
-}
-.calTopRight {
-	border-right: 1px solid #A5B5EE; 
-}
-.calUnSel{
-	color:#000000;
-	font-weight:normal;
-	text-align:center;
-	width:8%;
-}
-
-
-a.calMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:none;
-	display:block;
-	height:20px;
-	padding-left:5px;
-	padding-top:3px;
-}	
-
-a.calMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-	display:block;
-	height:20px;
-	padding-left:5px;
-	padding-top:3px;
-}
-
-.bgwhite{
-	background-color: #FFFFFF;
-}
-.copy{
-	font-size:9px;
-	font-family: Verdana, Arial, Helvetica, Sans-serif;
-}
-
-#mnuTab{
-	position:relative;
-	width:100%;
-	display:block;
-}
-
-#mnuTab2{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:none;
-}
-.style1 {color: #FF0000}
-
-
-.event{
-	background-color:#D3EAF0;
-	border:1px solid #999999;
-	text-align:left;
-	width:100%;
-	position:relative;
-	left:0px;
-	top:0px;
-	vertical-align:middle;
-	padding:1px;
-}
-
-#hrView{
-	display:block;
-}
-
-
-.calendarNav{
-	font-size:12px;
-	color:#FFFFFF;
-	white-space:nowrap;
-	text-align:center;
-	font-weight:bold;
-	padding-left:10px;
-	padding-right:10px;
-	background-image:url(images/cal_nav.gif);
-	background-repeat:repeat-x;
-}
-
-#addEventDropDown{
-	position:absolute;
-	display:none;
-	width:150px;
-	border:1px solid #666666;
-	left:0px;
-	top:0px;
-	overflow:visible;
-	z-index:5000;
-}
-
-.calAction{
-	width:175px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-.calSettings{
-	position:absolute;
-	z-index:20000;
-	width:500px;
-	left:200px;
-	top:150px;
-	background-color:#ffffff;
-}
-
-
-.outer{
-	border-bottom:1px solid #CCCCCC;
-	border-left:1px solid #CCCCCC;
-	border-right:1px solid #CCCCCC;
-}
-
-
-.calTxt{
-	width:50%;
-	border:1px solid #CCCCCC;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	padding-left:5px;
-}
-
-#leadLay{
-	position:relative;
-	width:100%;
-	float:left;
-	visibility:hidden;
-	padding:5px;
-	z-index:10000;
-}
-									
-/* End of Calendar */
-
-/* Cal Year View */
-.eventDay{
-	background-color:#FF9966;
-	font-weight:bold;
-}
-
-.currDay{
-	background-color:#006600;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-.currDay a{
-	color:#FFFFFF;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-
-/* End of Cal Year View */
-
-/* Level 2 Menu Selected*/
-
-level2Sel{
-	color:#000000;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-#DeleteLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:300px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	padding:5px;
-}
-
-#CurrencyDeleteLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:350px;
-}
-
-
-/* For Report HTML Generation*/
-.rptCellLabel {
-    background-color:#f6f6f6;
-    padding-right:10px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom:1px solid #eaeaea;
-    color:#737373;
-    font-weight: bold;
-    white-space:nowrap;
-}
-.rptTable {
-    border-left: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-    border-top: 1px solid #DDDDDD;
-}
-.rptTitle, .rptHead, .rptData, .rptGrpHead{
-    font-family: Verdana, Arial, Helvetica, Sans-serif;
-    font-size: 11px;
-	text-align:left;
-    font-weight: normal;
-	height: 20px;
-	padding: 4px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-	background: #DDDDDD;
-}
-.rptGrp1Total, .rptGrp2Total, .rptTotal {
-    font-family: Verdana, Arial, Helvetica, Sans-serif;
-    font-size: 11px;
-	text-align:center;
-    font-weight: normal;
-    background: #FFF;
-	height: 20px;
-	padding: 4px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-}
-.rptGrpHead {
-	background: #FFF;
-    border-bottom: 1px solid #FFF;
-    border-top: 1px solid #DDDDDD;
-    font-weight: normal;
-}
-
-.rptData {
-            background: #FFF;
-            font-weight: normal;
-}
-.rptEmptyGrp {
-            background: #FFF;
-            border-right: 1px solid #DDDDDD;
-}
-.statechange
-{
-    position:absolute;
-    visibility:hidden;
-    left:10px;
-    top:20px;
-    width:300px;
-    border:3px solid #CCCCCC;
-    background-color:#FFFFFF;
-}
-#PopupLay{
-    position:absolute;
-    font-family:Arial, Helvetica, sans-serif;
-    font-size:11px;
-    text-align:left;
-    width:500px;
-    border:3px solid #CCCCCC;
-    background-color:#FFFFFF;
-    padding:5px;
-    display:none;
-    left:100px;
-    top:100px;
-}
-
-#folderLay{
-    width:175px;
-    background-color:#CCCCCC;
-    border:1px solid #DDDDDD;
-    padding-top:5px;
-    position:absolute;
-    display:none;
-}
-
-/* Css for quick Create */
-
-.qcTransport{
-	    background-color:#d5d6ff;
-
-}
-
-#role_popup{
-        position:relative;
-        left:0px;
-        top:0px;
-        width:95%;
-        height:300px;
-        overflow:auto;
-        border:1px solid #999999;
-        text-align:left;
-        background-color:#FFFFFF;
-    }
-
-.unread_email {
-	font-weight:bold;
-}
-
-								    
-/* MY SITES */
-
-.unread_email {
-	font-weight:bold;
-}
-
-
-.tagCloud {
-    border:1px solid #aaf;
-}
-
-   
-.tagCloudTopBg {
-    background: url(images/tagCloudBg.gif) repeat-x;
-   
-}
-
-.tagCloudDisplay {
-    background-color:#fff;
-    padding:10px;
-    font-family: Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    line-height: 14px;
-    color: #000000;
-
-}
-
-.h2 {
-
-	font-size:18px;
-	line-height:20px;
-
-}
-
-.gray {
-
-	color:gray;
-}
-
-
-ul {
-	list-style:circle;
-	line-height:20px;
-	padding-left:5px;
-	margin-left:20px;
-	font-weight:normal;
-
-}
-.tagCloudTopBg {
-	background-image: url(images/tagCloudBg.gif);
-	background-repeat: repeat-x;	
-}
-
-.tagCloudDisplay {
-	background-color:#fff;
-	padding:5px;
-}
-.heading2 {
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 16px;
-	line-height: 16px;
-	font-weight:bold;
-	color: #000000;
-}
-.settingsUI {
-	
-	text-align:left;
-	background-color:#fff;
-	background-image:url(images/layerPopupBg.gif);
-	border:2px solid #aaaaff;
-}
-
-.settingsTabHeader {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 12px;
-	line-height:22px;
-	font-weight:bold;
-	color:#ddf;
-	 /* background-image: url(images/mailSubHeaderBg.gif); */
-	 background-color:#222299;
-	background-repeat: repeat-x;
-	padding-left:10px;
-	padding-right:10px;
-
-}
-
-.settingsTabList {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:20px;
-	font-weight:normal;
-	color:#000000;
-	background-color:#efefff;
-	padding-left:30px;
-	border-top:1px solid #fff;
-	border-bottom:1px solid #99a;
-	border-right:1px solid #99a;
-	border-left:1px solid #fff;
-}
-.settingsTabSelected {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:20px;
-	font-weight:bold;
-	color:#000000;
-	background-color:#ffffff;
-	padding-left:30px;
-	border-left:2px solid #ddf;	
-	border-bottom:2px solid #ddf;	
-	border-top:2px solid #ddf;	
-}
-.settingsSelectedUI {
-	padding:10px;
-	background:url(images/settingsSelUIBg.gif) repeat-x;
-	background-color:#ffffff;
-}
-.settingsIconDisplay {
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:14px;
-	padding:10px;
-
-	color:#000000;
-	background-color:#ffffff;
-	padding-left:10px;
-}
-.settingsSelUITopLine{
-	border-bottom:2px dotted #999999;
-
-}
-
-.tableHeading{
-	background-color:#ffffff;
-	border-bottom:2px solid #555599;
-}
-.colHeader{
-	background-color:#ddf;
-	border-left:1px solid #fff;
-	border-top:1px solid #fff;
-	border-right:1px solid #aaf;
-	border-bottom:1px solid #aaf;
-	font-weight:bold;
-
-}
-.cellLabel {
-	background-color:#eaebd9;
-	border-top:1px solid #efefef;
-	border-bottom:1px solid #dadada;
-	color:#555555;
-
-}
-.cellText {
-	color:#333333;
-	border-bottom:1px solid #dadada;
-}
-
-.listTable{
-	border-left:1px solid #cccccc;
-	border-right:1px solid #cccccc;
-	border-bottom:1px solid #cccccc;
-
-}
-
-.listTableRow{
-	border-bottom:1px solid #eaeaea;
-	border-right	:1px solid #eaeaea;
-	border-bottom:1px solid #eaeaea;
-	border-bottom:1px solid #eaeaea;
-}
-.listRow{
-	border-bottom:2px solid #eaeaea;
-
-}
-
-.listTableTopButtons{
-	background-color:#efefff;
-	background-image:url(images/layerPopupBg.gif);
-	
-}
-
-
-/*  Buttons */
-.crmButton{
-	
-	border-left:1px solid #ffffff;
-	border-top:1px solid #ffffff;
-	border-right:1px solid #555555;
-	border-bottom:1px solid #555555;
-}
-
-.create{
-	background-color:#0000CD;
-	color:#fff;
-	font-weight:bold;
-}
-.delete {
-	background-color:#C6E2FF;
-	color:#000;
-	font-weight:bold;
-}
-.edit {
-	background-color:#0000CD;
-	color:#fff;
-	font-weight:bold;
-}
-.save{
-	background-color:#0000CD;
-	color:#fff;
-	font-weight:bold;
-}
-.cancel {
-	background-color:#C6E2FF;
-	color:#000;
-	font-weight:bold;
-}
-
-.inactive{
-color:#999999;
-}
-
-.active{
-color:#229922;
-
-}
-
-/* Buttons ends */
-
-
-
-textarea {
-	width:95%;
-	height:70px;
-	border:1px solid #dadada;
-}
-.treeTable1{
-	padding:0px;
-}
-
-.prvPrfBigText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-.prvPrfTopBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfBottomBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfOutline {
-	border:1px solid #ebebeb;
-}
-
-
-
-.prvPrfTexture {
-	background:url(images/prvPrfTexture1.gif);
-
-}
-
-.prvPrfHoverOn {
-	background-color:#ffffef;
-	
-}
-
-.cellBottomDotLine {
-	border-bottom-width: 2px;
-	border-bottom-style: dotted;
-	border-bottom-color: #CCCCCC;
-	background-color:#ededed;
-}
-.crmFormList{
-	border:1px solid #cccccc;
-	width:90%;
-	height:120px;
-
-}
-.cellBottomDotLinePlain {
-	border-bottom-width: 2px;
-	border-bottom-style: dotted;
-	border-bottom-color: #CCCCCC;
-	
-}
-.thickBorder {
-	border: 2px solid #999999;
-}
-.trackerHeading {
-	background-color:#efefef;
-}
-.trackerListBullet {
-	border-right:1px dotted #cccccc;
-	background-color:#f9f9f9;
-}
-.trackerList {
-	border-bottom:1px solid #eeeeee;
-}
-
-/* Table Definitions */
-.crmTable {
-	border:1px solid #dadada;
-}
-.crmTableRow {
-	border-bottom:1px dotted #dadada;
-	border-right:1px dotted #dadada
-}
-/* Inventory */
-
-.lineOnTop {
-	border-top:1px solid #999999;
-}
-
-.discountUI{
-	border:3px solid #CCCCCC;
-	width:250px;
-	padding:5px;
-	position:absolute;
-	background-color:#FFFFFF;
-	display:none;
-}
-
-.TaxShow{
-	display:inline-table;
-}
-
-.TaxHide{
-	display:none;
-}
-
-/* Inventory */
-
-
-
-
-
-/* styles for RSS Display starts */
-/*.rssDisplay{
-	background-color:#e8e3ca;
-}*/
-
-
-/* styles for RSS Display ends */
-
-
-
-
-
-
-
-
-/* Email Client Classes ++++++++++++++++++++++ */
-
-.emailSelected{
-	background-color:#eaeaea;
-	color:#000000;
-	font-size:bold;
-}
-
-
-.mailClient{
-	border:2px solid #6565ee;
-}
-
-.mailClientBg {
-	background-color:#efefff;
-	background-image:url(images/layerPopupBg.gif);
-}
-
-.mailSubHeader {
-	background:#b4b8ff url(images/mailSubHeaderBg.gif) repeat-x;
-	padding:4px;
-}
-
-.mailClientWriteEmailHeader {
-	font-family:arial, helvetica, sans-serif;
-	font-size:20px;
-	line-height:24px;
-	font-weight:bold;
-	background:#e0dbb0 url(images/mailSubHeaderBg.gif) repeat-x;
-	padding:10px;
-	border-left:1px solid #eaeaea;
-	border-top:1px solid #eaeaea;
-	border-right:1px solid #939271;
-	border-left:1px solid #939271;;
-}
-
-.mailClientCSSButton {
-	border-left:1px solid #fff;
-	border-top:1px solid #fff;
-	border-right:1px solid #333;
-	border-bottom:1px solid #333;
-	padding:2px;
-	background-color:#c3c2b1;
-}
-
-/* Email Client Classes ends ------------------------------------ */
-
-
-
-/* Layer Popup */
-.layerPopup {
-	border:3px solid #95a5ff;
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-	position:absolute;
-}
-
-.layerPopupHeading {
-	font-family:arial, helvetica, sans-serif;
-	font-size:16px;
-	line-height:24px;
-	font-weight:bold;
-}
-.layerHeadingULine {
-	border-bottom:2px solid #717351;
-}
-.layerPopupTransport {
-	background-color:#e2e5ff;
-
-}
-.homePageSeperator {
-	border-right:1px dotted #d3d2c1;
-}
-.homePageMatrixHdr {
-	border-bottom:1px solid #d3d2c1;
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-}
-
-.reportsListTable {
-	background-color:white;
-	border-left:1px solid #a3a29f;
-	border-right:1px solid #a3a29f;
-	border-bottom:1px solid #a3a29f;
-}
-
-.reportGenerateTable{
-	background-image:url(images/layerPopupBg.gif);
-	border-left:2px dotted #a5b5ee;
-	border-right:2px dotted #a5b5ee;
-	border-bottom:2px dotted #a5b5ee;
-}
-.reportCreateBottom{
-	background-color:#ddf;
-	border-bottom:2px solid #737251;
-
-}
-.importLeadUI{
-	/*background:#fffff5 url(images/select.gif) ; */
-	background-color:white;
-}
-
-a.customMnu{
-	padding-left:30px;
-	padding-top:5px;
-	padding-bottom:5px;
-	display:block;
-	background-repeat:no-repeat;
-	background-position:left;
-	width:155px;
-	color:#000000;
-	text-decoration:none;
-}
-
-a.customMnuSelected{
-	padding-left:30px;
-	padding-top:5px;
-	padding-bottom:5px;
-	display:block;
-	background-repeat:no-repeat;
-	background-position:left;
-	width:155px;
-	background-color:#0099FF;
-	color:#FFFFFF;
-	text-decoration:none;
-}
-
-
-/* Drop Down Menu */
-.drop_mnu{
-    position:absolute;
-    left:0px;
-    top:0px;
-    z-index:1000000001;
-    border-left:1px solid #a5b5ee;
-    border-right:1px solid #a5b5ee;
-    border-bottom:1px solid #a5b5ee;
-    width:150px;
-    display:none;
-    padding:0px;
-    text-align:left;
-    overflow-x:hidden;
-    overflow-y:hidden;
-    background-color:#eef;
-}
-
-a.drop_down{
-    width:150px;
-    text-align:left;
-    font-family:  Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    line-height:20px;
-    font-weight:normal;
-    color:#33a;
-    background-color:#eef;
-    padding:2px 5px 2px 5px;
-    border-top:1px solid #fafafa;
-    border-bottom:1px solid #d3d3f3;
-    display:block;
-}
-
-a.drop_down:Hover{
-    padding:2px 5px 2px 5px;
-    width:150px;
-    text-align:left;
-    color:#33a;
-    font-weight:normal;
-    text-decoration:underline;
-    background-color:#ccf;
-}
-
-.bgwhite{
-	background-color:white;
-}
-
-.searchUIBasic {
-		background-image:url(images/layerPopupBg.gif);
-		border:2px solid #a5b5ee;
-}
-.searchUIAdv1{ 
-		background-image:url(images/layerPopupBg.gif);
-		border-top:2px solid #a5b5ee;
-		border-left:2px solid #a5b5ee;
-		border-right:2px solid #a5b5ee;
-}
-.searchUIAdv2{ 
-		background-image:url(images/layerPopupBg.gif);
-		border-left:2px solid #a5b5ee;
-		border-right:2px solid #a5b5ee;
-}
-.searchUIAdv3{ 
-		background-image:url(images/layerPopupBg.gif);
-		border-bottom:2px solid #a5b5ee;
-		border-left:2px solid #a5b5ee;
-		border-right:2px solid #a5b5ee;
-}
-
-/* Recalculate Disabling Window */
-
-.veil{
-   background: url(images/layerPopupBg.gif) ;
-    height: 100%;
-    width: 100%;
-    top: 0px;
-    left: 0px;
-    overflow: hidden;
-    z-index: 10000;
-    Filter: Alpha(opacity = 70);
-    -moz-opacity: 0.7;
-    text-align: center;
-    vertical-align: middle;
-    position: absolute;
-}
-
-.veil_new{
-   background: url(images/layerPopupBg.gif) ;
-    height: 100%;
-    width: 100%;
-    top: 0px;
-    left: 0px;
-    overflow: hidden;
-    z-index: 50000;
-    Filter: Alpha(opacity = 70);
-    -moz-opacity: 0.7;
-    text-align: center;
-    vertical-align: middle;
-    position: absolute;
-}
-
-.optioncontainer{
-    vertical-align: middle;   
-    height: 100%;
-    width: 100%;   
-    position: absolute;
-    z-index: 90000;   
-}
-
-
-.options{
-    	vertical-align: middle;   
-	margin-left: 25%;
-	margin-top: 16%;
-	color: #FFFFFF;
-	width:650px;
-	background-color: Black;
-	border: 2px solid #222;	
-    	position: relative;
-	text-align: left;
-    	z-index: 80000;   
-}
-
-.options h2{
-	color: White;
-	font-family: Verdana, Arial, Helvetica, sans-serif;
-	border-bottom: 1px solid #373D4C;
-	margin: 0;
-	font-weight: normal;
-}
-
-/* Recalculate Disable Ends */
-
+/*********************************************************************************
+
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ ********************************************************************************/
+
+
+/* WOOD SPICE  - COLOR THEME*/
+
+.small {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+}
+.big {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	line-height: 18px;
+	color: #000000;
+	font-weight:bold;
+}
+
+.componentName {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	line-height: 18px;
+	color: #3333ff;
+	font-weight:bold;
+	border-left:2px dotted #fff;
+	padding:10px;
+}
+
+
+.genHeaderBig{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	line-height: 19px;
+	color: #000000;
+	font-weight:bold;
+}
+.genHeaderSmall{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	line-height: 16px;
+	color: #000000;
+	font-weight:bold;
+}
+
+.moduleName {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	color: #000033;
+	font-weight:bold;
+}
+
+
+.hdrNameBg {
+	 background:#ffffff url(images/hdrNameBg.gif) repeat-x;
+	
+	
+}
+
+.hdrTabBg {
+	background:#ffffff url(images/hdrTabBg.gif) bottom repeat-x ;
+	background-color:#fff;
+}  
+
+.tabSelected {
+	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
+	background-color:#1F5EFF;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+
+.tabSelected a{
+	color:white;
+}
+
+.tabUnSelected {
+	
+	background: #efedd4 url(images/tabUnSelectedBg.gif) bottom repeat-x;
+	background-color:#AFDBFF;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	border-bottom:1px solid #ffffff;
+}
+
+.tabUnSelected a{
+	color:#000099;
+}
+
+.tabSeperator {
+	background-color:#aae;
+	width:1px;
+}
+
+
+
+.level2text {
+    
+    font-family: Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    padding-left:15px;
+    padding-right:15px;
+    padding-top:5px;
+    padding-bottom:5px;
+    font-weight:bold;
+    color:white;
+}
+
+.level2text a{
+	text-decoration:none;
+	color:#555555;
+}
+
+.level2text a:hover {
+	text-decoration:underline;
+	color:#555555;
+
+}
+
+
+.level2Bg {
+	background:#1F5BFF url(images/level2TabBg.gif) bottom repeat-x;
+	background-color:#1F5BFF;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	border-bottom:1px solid #222255;
+	color:white;
+}
+
+.level2Bg a{
+	/* background:#1F5BFF url(images/level2TabBg.gif) bottom repeat-x; */
+	color:white;
+}
+
+
+.level2SelTab{
+	font-weight:bold;
+	color:#000000;
+	padding-left:20px;
+	padding-right:20px;
+	padding-top:5px;
+	padding-bottom:5px;
+	
+}
+	
+.level2UnSelTab{
+	color:#000000;
+	padding-left:20px;
+	padding-right:20px;
+	padding-top:5px;
+	padding-bottom:5px;
+}
+.sep1 {
+	background:#999999;
+}
+
+.showPanelBg {
+	background:url(images/showPanelTopBg.gif) repeat-x;
+}
+
+a {
+	text-decoration:none;
+	color:#3344bb;
+}
+
+a:hover {
+	text-decoration:underline;
+}
+
+.hdrLink {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	text-decoration:none;
+	color:#0000cc;
+	font-weight:bold;
+}
+
+.hdrLink:hover {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	text-decoration:underline;
+	color:#0000cc;
+	font-weight:bold;
+}
+
+.searchBox {
+	border: 0px solid #0000aa;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	padding-left:2px;
+	width:100px;
+	background-color:#ffffef;
+}
+
+.searchBtn {
+	border :0px #cccccc solid;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	font-weight:bold;
+	width:30px;
+	height:19px;
+	background-color:#009;
+	color:white;
+}
+
+
+/* List View Table classes starts  +++++++++++++++++ */
+
+.lvt {
+	background-color:#ddf;
+	border:1px solid #cce; 
+}
+
+.lvtBg {
+}
+
+.lvtHeaderText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	font-weight:bold;
+}
+
+.lvtCol {
+	border-top:1px solid #eeeeff;
+	border-left:1px solid #eeeeff;
+	border-right:1px solid #9999dd;
+	border-bottom:1px solid #9999dd;
+	background-color:#eef;
+	font-weight:bold;
+}
+
+.lvtColData {
+	background-color:#ffffff;
+}
+
+.lvtColDataHover {
+	background-color:#eeefff;
+	
+}
+
+
+/* List View Table classes ends --------------------------------*/
+
+
+
+/* Detailed View classes starts +++++++++++++++++++++++ */
+.dvHeaderText{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	color:#000000;
+	font-weight:bold;
+
+}
+
+.dvInnerHeader{
+	border-bottom:2px solid #4F94CD;
+	padding:5px;
+	background-color:#afdbff;
+
+}
+
+.dvtSelectedCell {
+	border-left:2px solid #00BFFF;
+	border-top:2px solid #00BFFF;
+	border-right:2px solid #00BFFF;
+	padding-left:20px;
+	padding-right:20px;
+	background-color:white;
+	font-weight:bold;
+}
+
+.dvtUnSelectedCell {
+	border-left:2px solid #00BFFF;
+	border-top:2px solid #00BFFF;
+	border-right:2px solid #00BFFF;
+	border-bottom:2px solid #00BFFF;
+	padding-left:20px;
+	padding-right:20px;
+	background-color:#ffffee;
+	cursor:pointer;
+}
+
+.dvtTabCache {
+	border-bottom:2px solid #00BFFF;
+}
+
+.dvtContentSpace {
+	border-left:2px solid #00BFFF;
+	border-right:2px solid #00BFFF;
+	border-bottom:2px solid #00BFFF;
+	padding-left:0px;
+}
+
+.dvtCellLabel, .cellLabel {
+	background-color:#f5f5ff;
+	padding-right:10px;
+	padding-left:10px;
+	border-bottom:1px solid #dadaee ;
+	border-top:1px solid #ffffff ;
+	color:#545454;
+	white-space:nowrap;
+}
+
+.dvtCellInfo, .cellInfo {
+	padding-left:10px;
+	padding-right:10px;
+	border-bottom:1px solid #efefef;
+}
+
+.rightMailMerge {
+	border:2px solid #aae;
+}
+
+.rightMailMergeHeader {
+	border-bottom:1px solid #dde;
+	padding:5px;
+	background-color:#eef;
+
+}
+
+.rightMailMergeContent {
+	padding:5px;
+	background-color:#fafafa;
+
+}
+
+.detailedViewHeader{
+	border-bottom:2px solid #4F94CD;
+	padding:5px; 
+	background-color:#afdbff;
+}
+
+.detailedViewTextBox {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#ffffff;
+}
+
+.detailedViewTextBoxOn {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#ffffdd;
+}
+
+.detailedViewTextBoxDis {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #555555;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#aaaaaa;
+}
+
+.detailedViewTextArea {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:95%;
+	height:100px;
+	background-color:#ffffff;
+	text-align:left;
+}
+
+.advSearch {
+	padding:10px;
+	border-left:1px solid #eaeaea; 
+	border-right:1px solid #eaeaea; 
+	border-bottom:1px solid #eaeaea; 	
+	overflow:auto;
+	width:600px;
+	height:150px;
+	background-color:#ffffef;
+
+}
+
+.searchAlph {
+	border:1px solid #dadada;
+	background-color:#ffffff;
+	cursor:pointer;
+	width:10px
+
+}
+.searchAlphselected {
+	border:1px solid #666666;
+	background-color:#bbbbbb;
+	cursor:pointer;
+	width:10px
+
+}
+.textbox {
+	border:1px solid #999999;
+	background-color:#ffffff;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	width:120px;
+	padding:2px;
+
+}
+
+
+.mx {
+}
+
+.calListTable td{
+	border-bottom:1px solid #efefef;
+	border-left:1px solid #efefef;
+}
+.calDIV {
+	width:100%;
+	border:1px solid #999999;
+	
+}
+
+.calDayHour {
+	border-top:1px solid #c5d5ff;
+	border-left:1px solid #c5d5ff;
+	border-bottom:1px solid #c5d5ff;
+	border-right:1px solid #c5d5ff;
+	background-color:#eae7da;
+}
+
+.calAddEvent {
+	position:absolute;
+	z-index:10000;
+	width:500px;
+	left:200px;
+	top:150px;
+	background-color:#ffffff;
+}
+.addEventInnerBox {
+	border:1px dotted #dadada;
+
+}
+
+
+.cellNormal {
+	border:0px;
+	background-color:#ffffff;
+}
+
+
+.thumbnail{
+    background-color:#ffffff;
+padding: 7px;
+border: 1px solid #ddd;
+float: left;
+	   margin-right: 10px;
+	   margin-bottom: 15px;
+}
+
+
+.padTab{
+    padding-top:0px;
+    padding-left:0px;
+    padding-left:10px;
+    padding-bottom:0px;
+    vertical-align:top;
+
+}
+#company{
+    position:relative;
+    width:100%;
+    height:200px;
+    display:block;
+    background-color:#FFFFFF;
+    white-space:nowrap;
+    overflow:auto;
+    border:1px solid #CCCCCC;
+}
+                               
+
+#user{position:relative;left:0px;top:0px;width:100%;display:block;}
+/*#studio{position:relative;left:0px;top:0px;width:100%;display:block;}*/
+#communication{position:relative;left:0px;top:0px;width:100%;display:block;}
+#config{position:relative;left:0px;top:0px;width:100%;display:block;}
+
+#userTab{position:relative;left:0px;top:0px;width:100%;display:none;}
+#one{
+	position:relative;
+	display:block;
+	width:245px;
+}
+
+#mnuTab1{
+
+   position:relative;
+
+   overflow:auto;
+
+   width:100%;
+
+   display:none;
+
+}
+
+#mnuTab2{
+
+   position:relative;
+
+   overflow:auto;
+
+   width:100%;
+
+   display:none;
+
+}
+
+
+/* End of Settings */
+
+.bgwhite{
+	background-color: #FFFFFF;
+}
+.copy{
+	font-size:9px;
+	font-family: Verdana, Arial, Helvetica, Sans-serif;
+}
+
+#basicTab{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:block;
+}
+
+#moreTab{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:none;
+}
+
+/*Added for Advance Seearch*/
+
+
+#one{
+	position:relative;
+	display:block;
+	width:245px;
+}
+
+/* Dashboard CSS */
+a.dash_href{
+	display:block;
+	width:24px;height:24px;
+	vertical-align:middle;
+	margin-top:10px;
+}
+.dashHeading {
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:24px;
+	font-weight:bold;
+	color:#fff;
+}
+.dashSelectBg{
+	background-image:url(images/dashSelectBg.gif);
+	background-repeat:repeat-x;
+}
+.dash_top{
+	background-image:url(images/dashTopBg.gif);
+	background-repeat:repeat-x;
+	height:63px;
+	vertical-align:middle;
+}
+
+.dash_border{
+	background-color:#738bff;
+	padding:5px;
+}
+
+
+.dash_white{
+	background-color:#FFFFFF;
+	padding:5px 10px 5px 10px;
+}
+
+.dash_bdr_btm{
+	border-bottom:2px dotted #939271;
+}
+
+.dash_count{
+	font-size:36px;
+	font-weight:bold;
+	text-decoration:none;
+	color:#000000;
+	padding-left:10px;padding-right:10px;	
+}
+.dash_switch{
+	cursor:pointer;
+	width:26px;
+	height:26px;
+}
+
+.dash_row_sel{
+	background-image:url(images/dash_sel_chart.jpg);
+	background-repeat:no-repeat;
+	background-position:center;
+	width:26px;height:26px;
+	text-align:center;
+	vertical-align:middle;
+	font-weight:bold;
+	font-size:10px;
+	text-decoration:none;
+}
+
+.dash_row_unsel{
+	background-image:url(images/dash_unsel_chart.jpg);
+	background-repeat:no-repeat;
+	background-position:center;
+	width:26px;height:26px;
+	text-align:center;
+	vertical-align:middle;
+	font-weight:normal;
+	font-size:10px;
+	text-decoration:none;
+	cursor:pointer;
+}
+
+.dash_chart_btm{
+	border-bottom:2px solid #000000;
+}
+
+
+.dash_bottom{
+	background-image:url(images/dashBottomBg.gif);
+	background-repeat:repeat-x;
+	height:99px;
+	vertical-align:middle;
+}
+
+.dash_btm{
+	background-image:url(images/dash_btm_center.jpg);
+	background-repeat:repeat-x;
+	position:top;
+}
+
+
+/* clock */
+
+.citystyle{
+	position:relative;
+	top:0px;
+	left:0px;
+	text-align:left;
+	
+}
+#theClockLayer{
+	position:relative;
+	height:180px;
+	left:20px;
+	text-align:center;
+}
+.handsanddotsstyle{
+	margin-top:10px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:2px;
+	height:2px;
+	font-size:2px;
+	background-color:#000000;
+}
+.facestyle{
+	margin-top:10px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:15px;
+	height:15px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+.datestyle{
+	margin-top:20px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:100px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+.ampmstyle{
+	margin-top:23px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:20px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+
+#wclock{
+	position:absolute;
+	left:100px;
+	top:100px;
+	display:none;
+	background-color:#CCCCCC;
+	width:175px;
+}
+
+.leftFormBorder1 {
+	border: 1px solid #AFC8E4;
+	background-color: #FFFFFF;
+	opacity:.7;
+}
+
+
+
+
+/* Calculator */
+.calcResult {
+	width: 100%;
+	height: 25px;
+	background-color: #FFFFCC;/*CBDFD6*/
+	border-top: 1px solid #CCC;
+	border-left: 0px;
+	border-right: 1px solid #CCC;
+	border-bottom: 1px solid #CCC;
+	font-size: 10px;
+	text-align: right;
+}
+.calcMem {
+	width: 100%;
+	height: 25px;
+	border-top: 1px solid #CCC;
+	border-left: 1px solid #CCC;
+	border-right: 0px;
+	border-bottom: 1px solid #CCC;
+	background-color: #FFFFCC;/*CBDFD6*/
+	font-family: Arial;
+	font-size: 10px;
+	color: #BBB;
+	text-align: left;
+}
+.calcBlackBtn, .calcGreyBtn, .calcBigBtn, .calcCancBtn, .calcMemBtn, .calcBackBtn {
+	border: none;
+	height: 20px;
+	font-size: 11px;
+	color: #FFF;
+	text-align:center;
+}
+.calcBackBtn {
+	background: url(images/calc_back_btn.gif) no-repeat;
+	width:25px;
+}
+.calcBlackBtn {
+	background: url(images/calc_black_btn.gif) no-repeat;
+	width:25px;
+}
+.calcGreyBtn {
+	background: url(images/calc_grey_btn.gif) no-repeat;
+	width:25px;
+}
+.calcCancBtn {
+	background: url(images/calc_canc_btn.gif) no-repeat;
+	width:25px;
+	
+}
+.calcMemBtn {
+	background: url(images/calc_mem_btn.gif) no-repeat;
+	width:25px;
+	/*background-color: #CCC;*/
+}
+
+#calc{
+	position:absolute;
+	left:100px;
+	top:100px;
+	background-color:#FFFFFF;
+	width:185px;
+	border-bottom:2px solid #000000;
+	border-right:2px solid #666666;
+	border-left:2px solid #CCCCCC;
+	border-top:2px solid #CCCCCC;
+}
+
+/* RSS STYLES */
+
+.subHdr{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	background-image:url(images/rssHeader.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+}
+
+.delBg{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	background-image:url(images/rssdelete.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+}
+
+#rssScroll{
+	font-family:Arial, Helvetica, sans-serif	;
+	font-size:12px;
+	background-color:#FFFFFF;
+	width:100%;
+	height:200px;
+	overflow:auto;
+	border:0px solid #000000;
+}
+
+.rssTable{
+	width:100%;
+	border:0px solid #CCCCCC;
+}
+
+.rssTable tr th{
+	background-color:#00BFFF;
+	text-align:left;
+	border-bottom:1px solid #99F;
+	border-top:1px solid #FFFFFF;
+	color:#000000;
+	padding-left:5px;
+	padding-right:5px;
+	height:20px;
+}
+
+.rssTable tr td{
+	text-align:left;
+	border-bottom:1px dotted #dadada;
+	border-left:1px dotted #dadada;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	font-weight:normal;
+	white-space:nowrap;
+	padding:2px;
+	
+}
+
+
+.forwardBg{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#000000;
+	background-image:url(images/rssforward.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+	background-color:#D7D7D7;
+}
+
+
+/*  New Styles */
+
+.mnuTab{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#000000;
+	width:100%;
+	border:0px solid #000000;
+}
+
+.mnuTab tr td{
+	border-bottom:1px solid #EBEBEB;
+	padding-left:5px;
+	vertical-align:middle;
+}
+
+/* profile */
+
+.prvPrfBigText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+.prvPrfTopBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfBottomBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfOutline {
+	border:1px solid #ebebeb;
+}
+
+.prvPrfTexture {
+	background:url(images/prvPrfTexture1.gif);
+
+}
+.prvPrfHoverOn {
+	background-color:#ffffef;
+	
+}
+
+/*  Organization */
+
+.orgTab{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	font-weight:normal;
+	color:#666666;
+	border:0px solid #9B9B9B;
+	border-collapse:collapse;
+	width:100%;
+}
+
+.orgTab tr th{
+	text-align:left;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	text-decoration:none;
+	font-weight:bold;
+	height:20px;
+	padding-left:5px;
+}
+
+.orgTab tr td{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-decoration:none;
+	font-weight:normal;
+	padding-left:5px;
+	height:20px;
+	border-bottom:1px solid #CCCCCC;
+	border-right:1px solid #CCCCCC;
+}
+
+
+.groupli{
+	margin-left:20px;
+	font-family:Arial, Helvetica, sans-serif;
+	font-weight:normal;
+	font-size:12px;
+	text-decoration:none;
+	color:#333333;
+	list-style-type:none;
+	text-align:left;
+}
+
+/* tree menu */
+
+/*Oraganization Edit Features */
+
+#orgLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:500px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	display:block;
+	position:absolute;
+	left:0px;
+	top:0px;
+}
+
+/*  Role */
+
+#roleLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:300px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	display:none;
+	position:absolute;
+}
+
+.classBtn{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	text-decoration:none;
+	font-weight:normal;
+	font-size:10px;
+	background-color:#DBDBDB;
+	border-bottom:2px solid #999999;
+	border-right:2px solid #999999;
+	border-top:2px solid #F5F5F5;
+	border-left:2px solid #F5F5F5;
+	color:#000000;
+	text-align:center;
+	padding-top:3px;
+	padding-bottom:3px;
+}
+
+
+.txtBox{
+	width:85%;
+	border:1px solid #666666;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+}
+
+/*  IMPORT LEADS */
+
+.leadTable{
+	border:3px solid #CCCCCC;
+	border-collapse:collapse;
+}
+
+.leadTable tr td{
+/*	border:0px solid #CCCCCC;*/
+}
+
+.genHeaderGray{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	line-height: 16px;
+	color: #888888;
+	font-weight:bold;
+}
+
+.genHeaderGrayBig{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	line-height: 16px;
+	color: #888888;
+	font-weight:bold;
+}
+
+.importBox{
+	width:125px;
+	border:1px solid #666666;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+}
+
+
+.txtGreen{
+	color:green;
+}
+
+/* PICK LIST */
+ul li{
+	padding-bottom:2px;
+	padding-top:2px;
+}
+/* MY PREFERENCES */		
+
+
+/* CSS FOR REPORTS */
+
+.reportHdr{
+	background-color:#DDDDDD;
+	font-size:12px;
+	font-weight:bold;
+	vertical-align:middle;
+	text-align:left;
+	height:30px;
+	border-bottom:2px solid #959595;
+	color:#000000;
+	padding-left:10px;
+}
+
+#reportLay{
+	width:175px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+#locateMap{
+	width:120px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+
+a.reportMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:none;
+	display:block;
+	width:155px;
+	height:20px;
+	border-bottom:1px solid #E1E1E1;
+	padding-left:20px;
+	padding-top:3px;
+}
+
+a.reportMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+	display:block;
+	width:155px;
+	height:20px;
+	border-bottom:1px solid #E1E1E1;
+	padding-left:20px;
+	padding-top:3px;
+}	
+
+#Generate{
+	position:relative;
+	width:100%;
+	text-align:center;
+	display:none;
+}
+/* END OF REPORT */
+/* WEB MAIL */
+a.webMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+}
+a.webMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+} 
+
+
+/*  END OF WEB MAIL */
+
+/* POPUP */
+
+ a.alpha{
+	font-size:11px;
+	color:gray;
+	text-decoration:none;
+	padding-Left:5px;
+	padding-right:5px;
+	border:1px dotted #CCCCCC;
+	background-color:#FFFFCC;
+}
+
+a.alpha:Hover{
+	font-size:11px;
+	color:gray;
+	text-decoration:underline;
+	padding-Left:5px;
+	padding-right:5px;
+	border:1px dotted #CCCCCC;
+	background-color:#FFFFCC;
+} 
+
+/* Home Page */
+.MatrixLayer{
+	border:2px solid #a5b5ee;
+	background-color:#FFFFFF;
+	width:29%;
+	position:relative;
+	visibility:visible;
+	margin:9px;
+	height:280px;
+}
+
+.fontBold{
+	font-size:13px;
+	color:#000000;
+	text-decoration:none;
+	font-weight:bold;
+}
+
+.style_Gray{
+	color:gray;
+}
+	
+/* End of Home Page */
+
+/* All Menu */
+#allMenu{
+    width:500px;
+    border:4px solid #a5b5ff;
+    left:300px;
+    top:100px;
+    position:absolute;
+    z-index:1000001;
+    display:none;
+    padding:10px;
+    background:#ffffff url(images/layerPopUpBg.gif);
+}
+
+
+.allMnuTable{
+    width:100%;
+    background-color:#FFFFFF;
+}
+
+.allMnuHandle td{
+    height:20px;
+    color:#FFFFFF;
+    font-family:Arial, Helvetica, sans-serif;
+    font-size:12px;
+    font-weight:bold;
+    text-decoration:none;
+    background-color:#000066;
+    cursor:move;
+    padding:2px;
+    border-bottom:2px solid #666666;
+}
+
+.allMnuHdr{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-weight:Bold;
+    font-size:11px;
+    text-decoration:none;
+    display:block;
+    background-color:#FFFFFF;
+    color:#000099;
+    padding-top:5px;
+    padding-bottom:5px;
+}
+
+a.allMnu{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-size:10px;
+    text-decoration:none;
+    font-weight:normal;
+    display:block;
+    width:125px;
+    height:15px;
+    padding-left:5px;
+    padding-top:0px;
+    padding-bottom:0px;
+    background-color:#FFFFFF;
+    border:1px solid #FFFFFF;
+    color:#000033;
+    margin-left:20px;
+}
+
+a.allMnu:Hover{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-size:10px;
+    text-decoration:none;
+    font-weight:normal;
+    display:block;
+    width:125px;
+    height:15px;
+    padding-left:5px;
+    padding-top:0px;
+    padding-bottom:0px;
+    background-color:#eef;
+    color:#333;
+}
+/* End Of All Menu */
+
+
+
+/* Calendar */
+.calHdr{
+	background-image:url(images/mailSubHeaderBg.gif); 
+	background-repeat:repeat-x;
+	background-position:left top;
+	
+}
+
+.calSel{
+	background-image:url(images/dashSelectBg.gif);
+	background-repeat:repeat-x;
+	text-align:center;
+	color:#FFFFFF;
+	font-weight:bold;
+	width:8%;
+}
+
+.calAddButton {
+	border: 1px solid #A5B5EF;
+	background:#D6D2AB url(images/calAddButtonBg.gif) repeat-x;
+	cursor:pointer;
+	height:20px;
+	
+
+}
+
+.calInnerBorder {
+	border-left:2px solid #A5B5EE;
+	border-right:2px solid #A5B5EE;
+	border-bottom:2px solid #A5B5EE;
+}
+
+.calBorder {
+	border-left: 1px solid #A5B5EE; 
+	border-right: 1px solid #A5B5EE; 
+	border-bottom: 1px solid #A5B5EE; 
+	background:#fefefe url(images/layerPopupBg.gif);
+
+}
+.calTopRight {
+	border-right: 1px solid #A5B5EE; 
+}
+.calUnSel{
+	color:#000000;
+	font-weight:normal;
+	text-align:center;
+	width:8%;
+}
+
+
+a.calMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:none;
+	display:block;
+	height:20px;
+	padding-left:5px;
+	padding-top:3px;
+}	
+
+a.calMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+	display:block;
+	height:20px;
+	padding-left:5px;
+	padding-top:3px;
+}
+
+.bgwhite{
+	background-color: #FFFFFF;
+}
+.copy{
+	font-size:9px;
+	font-family: Verdana, Arial, Helvetica, Sans-serif;
+}
+
+#mnuTab{
+	position:relative;
+	width:100%;
+	display:block;
+}
+
+#mnuTab2{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:none;
+}
+.style1 {color: #FF0000}
+
+
+.event{
+	background-color:#D3EAF0;
+	border:1px solid #999999;
+	text-align:left;
+	width:100%;
+	position:relative;
+	left:0px;
+	top:0px;
+	vertical-align:middle;
+	padding:1px;
+}
+
+#hrView{
+	display:block;
+}
+
+
+.calendarNav{
+	font-size:12px;
+	color:#FFFFFF;
+	white-space:nowrap;
+	text-align:center;
+	font-weight:bold;
+	padding-left:10px;
+	padding-right:10px;
+	background-image:url(images/cal_nav.gif);
+	background-repeat:repeat-x;
+}
+
+#addEventDropDown{
+	position:absolute;
+	display:none;
+	width:150px;
+	border:1px solid #666666;
+	left:0px;
+	top:0px;
+	overflow:visible;
+	z-index:5000;
+}
+
+.calAction{
+	width:175px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+.calSettings{
+	position:absolute;
+	z-index:20000;
+	width:500px;
+	left:200px;
+	top:150px;
+	background-color:#ffffff;
+}
+
+
+.outer{
+	border-bottom:1px solid #CCCCCC;
+	border-left:1px solid #CCCCCC;
+	border-right:1px solid #CCCCCC;
+}
+
+
+.calTxt{
+	width:50%;
+	border:1px solid #CCCCCC;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	padding-left:5px;
+}
+
+#leadLay{
+	position:relative;
+	width:100%;
+	float:left;
+	visibility:hidden;
+	padding:5px;
+	z-index:10000;
+}
+									
+/* End of Calendar */
+
+/* Cal Year View */
+.eventDay{
+	background-color:#FF9966;
+	font-weight:bold;
+}
+
+.currDay{
+	background-color:#006600;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+.currDay a{
+	color:#FFFFFF;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+
+/* End of Cal Year View */
+
+/* Level 2 Menu Selected*/
+
+level2Sel{
+	color:#000000;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+#DeleteLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:300px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	padding:5px;
+}
+
+#CurrencyDeleteLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:350px;
+}
+
+
+/* For Report HTML Generation*/
+.rptCellLabel {
+    background-color:#f6f6f6;
+    padding-right:10px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom:1px solid #eaeaea;
+    color:#737373;
+    font-weight: bold;
+    white-space:nowrap;
+}
+.rptTable {
+    border-left: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+    border-top: 1px solid #DDDDDD;
+}
+.rptTitle, .rptHead, .rptData, .rptGrpHead{
+    font-family: Verdana, Arial, Helvetica, Sans-serif;
+    font-size: 11px;
+	text-align:left;
+    font-weight: normal;
+	height: 20px;
+	padding: 4px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+	background: #DDDDDD;
+}
+.rptGrp1Total, .rptGrp2Total, .rptTotal {
+    font-family: Verdana, Arial, Helvetica, Sans-serif;
+    font-size: 11px;
+	text-align:center;
+    font-weight: normal;
+    background: #FFF;
+	height: 20px;
+	padding: 4px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+}
+.rptGrpHead {
+	background: #FFF;
+    border-bottom: 1px solid #FFF;
+    border-top: 1px solid #DDDDDD;
+    font-weight: normal;
+}
+
+.rptData {
+            background: #FFF;
+            font-weight: normal;
+}
+.rptEmptyGrp {
+            background: #FFF;
+            border-right: 1px solid #DDDDDD;
+}
+.statechange
+{
+    position:absolute;
+    visibility:hidden;
+    left:10px;
+    top:20px;
+    width:300px;
+    border:3px solid #CCCCCC;
+    background-color:#FFFFFF;
+}
+#PopupLay{
+    position:absolute;
+    font-family:Arial, Helvetica, sans-serif;
+    font-size:11px;
+    text-align:left;
+    width:500px;
+    border:3px solid #CCCCCC;
+    background-color:#FFFFFF;
+    padding:5px;
+    display:none;
+    left:100px;
+    top:100px;
+}
+
+#folderLay{
+    width:175px;
+    background-color:#CCCCCC;
+    border:1px solid #DDDDDD;
+    padding-top:5px;
+    position:absolute;
+    display:none;
+}
+
+/* Css for quick Create */
+
+.qcTransport{
+	    background-color:#d5d6ff;
+
+}
+
+#role_popup{
+        position:relative;
+        left:0px;
+        top:0px;
+        width:95%;
+        height:300px;
+        overflow:auto;
+        border:1px solid #999999;
+        text-align:left;
+        background-color:#FFFFFF;
+    }
+
+.unread_email {
+	font-weight:bold;
+        background-color:#00FF00;
+
+}
+
+								    
+/* MY SITES */
+
+.unread_email:hover{
+	font-weight:bold;
+}
+
+
+
+
+.qualify_email {
+	         font-weight:bold;
+	         background-color:#FF7F50;
+	
+ }
+
+
+.delete_email {
+	font-weight:bold;
+        background-color:#FF5151;
+
+}
+
+								    
+.tagCloud {
+    border:1px solid #aaf;
+}
+
+   
+.tagCloudTopBg {
+    background: url(images/tagCloudBg.gif) repeat-x;
+   
+}
+
+.tagCloudDisplay {
+    background-color:#fff;
+    padding:10px;
+    font-family: Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    line-height: 14px;
+    color: #000000;
+
+}
+
+.h2 {
+
+	font-size:18px;
+	line-height:20px;
+
+}
+
+.gray {
+
+	color:gray;
+}
+
+
+ul {
+	list-style:circle;
+	line-height:20px;
+	padding-left:5px;
+	margin-left:20px;
+	font-weight:normal;
+
+}
+.tagCloudTopBg {
+	background-image: url(images/tagCloudBg.gif);
+	background-repeat: repeat-x;	
+}
+
+.tagCloudDisplay {
+	background-color:#fff;
+	padding:5px;
+}
+.heading2 {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	line-height: 16px;
+	font-weight:bold;
+	color: #000000;
+}
+.settingsUI {
+	
+	text-align:left;
+	background-color:#fff;
+	background-image:url(images/layerPopupBg.gif);
+	border:2px solid #aaaaff;
+}
+
+.settingsTabHeader {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	line-height:22px;
+	font-weight:bold;
+	color:#ddf;
+	 /* background-image: url(images/mailSubHeaderBg.gif); */
+	 background-color:#222299;
+	background-repeat: repeat-x;
+	padding-left:10px;
+	padding-right:10px;
+
+}
+
+.settingsTabList {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:20px;
+	font-weight:normal;
+	color:#000000;
+	background-color:#efefff;
+	padding-left:30px;
+	border-top:1px solid #fff;
+	border-bottom:1px solid #99a;
+	border-right:1px solid #99a;
+	border-left:1px solid #fff;
+}
+.settingsTabSelected {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:20px;
+	font-weight:bold;
+	color:#000000;
+	background-color:#ffffff;
+	padding-left:30px;
+	border-left:2px solid #ddf;	
+	border-bottom:2px solid #ddf;	
+	border-top:2px solid #ddf;	
+}
+.settingsSelectedUI {
+	padding:10px;
+	background:url(images/settingsSelUIBg.gif) repeat-x;
+	background-color:#ffffff;
+}
+.settingsIconDisplay {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:14px;
+	padding:10px;
+
+	color:#000000;
+	background-color:#ffffff;
+	padding-left:10px;
+}
+.settingsSelUITopLine{
+	border-bottom:2px dotted #999999;
+
+}
+
+.tableHeading{
+	background-color:#ffffff;
+	border-bottom:2px solid #555599;
+}
+.colHeader{
+	background-color:#ddf;
+	border-left:1px solid #fff;
+	border-top:1px solid #fff;
+	border-right:1px solid #aaf;
+	border-bottom:1px solid #aaf;
+	font-weight:bold;
+
+}
+
+.cellLabel {
+	background-color:#f5f5ff;
+	border-top:1px solid #efefef;
+	border-bottom:1px solid #dadada;
+	color:#555555;
+
+}
+.cellText {
+	color:#333333;
+	border-bottom:1px solid #dadada;
+}
+
+.listTable{
+	border-left:1px solid #cccccc;
+	border-right:1px solid #cccccc;
+	border-bottom:1px solid #cccccc;
+
+}
+
+.listTableRow{
+	border-bottom:1px solid #eaeaea;
+	border-right	:1px solid #eaeaea;
+	border-bottom:1px solid #eaeaea;
+	border-bottom:1px solid #eaeaea;
+}
+.listRow{
+	border-bottom:2px solid #eaeaea;
+
+}
+
+.listTableTopButtons{
+	background-color:#efefff;
+	background-image:url(images/layerPopupBg.gif);
+	
+}
+
+
+/*  Buttons */
+.crmButton{
+	
+	border-left:1px solid #ffffff;
+	border-top:1px solid #ffffff;
+	border-right:1px solid #555555;
+	border-bottom:1px solid #555555;
+}
+
+.create{
+	background-color:#0000CD;
+	color:#fff;
+	font-weight:bold;
+}
+.delete {
+	background-color:#C6E2FF;
+	color:#000;
+	font-weight:bold;
+}
+.edit {
+	background-color:#0000CD;
+	color:#fff;
+	font-weight:bold;
+}
+.save{
+	background-color:#0000CD;
+	color:#fff;
+	font-weight:bold;
+}
+.cancel {
+	background-color:#C6E2FF;
+	color:#000;
+	font-weight:bold;
+}
+
+.inactive{
+color:#999999;
+}
+
+.active{
+color:#229922;
+
+}
+
+/* Buttons ends */
+
+
+
+textarea {
+	width:95%;
+	height:70px;
+	border:1px solid #dadada;
+}
+.treeTable1{
+	padding:0px;
+}
+
+.prvPrfBigText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+.prvPrfTopBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfBottomBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfOutline {
+	border:1px solid #ebebeb;
+}
+
+
+
+.prvPrfTexture {
+	background:url(images/prvPrfTexture1.gif);
+
+}
+
+.prvPrfHoverOn {
+	background-color:#ffffef;
+	
+}
+
+.cellBottomDotLine {
+	border-bottom-width: 2px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	background-color:#ededed;
+}
+.crmFormList{
+	border:1px solid #cccccc;
+	width:90%;
+	height:120px;
+
+}
+.cellBottomDotLinePlain {
+	border-bottom-width: 2px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	
+}
+.thickBorder {
+	border: 2px solid #999999;
+}
+.trackerHeading {
+	background-color:#efefef;
+}
+.trackerListBullet {
+	border-right:1px dotted #cccccc;
+	background-color:#f9f9f9;
+}
+.trackerList {
+	border-bottom:1px solid #eeeeee;
+}
+
+/* Table Definitions */
+.crmTable {
+	border:1px solid #dadada;
+}
+.crmTableRow {
+	border-bottom:1px dotted #dadada;
+	border-right:1px dotted #dadada
+}
+/* Inventory */
+
+.lineOnTop {
+	border-top:1px solid #999999;
+}
+
+.discountUI{
+	border:3px solid #CCCCCC;
+	width:250px;
+	padding:5px;
+	position:absolute;
+	background-color:#FFFFFF;
+	display:none;
+}
+
+.TaxShow{
+	display:inline-table;
+}
+
+.TaxHide{
+	display:none;
+}
+
+/* Inventory */
+
+
+
+
+
+/* styles for RSS Display starts */
+/*.rssDisplay{
+	background-color:#e8e3ca;
+}*/
+
+
+/* styles for RSS Display ends */
+
+
+
+
+
+
+
+
+/* Email Client Classes ++++++++++++++++++++++ */
+
+.emailSelected{
+	background-color:#eaeaea;
+	color:#000000;
+	font-size:bold;
+}
+
+
+.mailClient{
+	border:2px solid #6565ee;
+}
+
+.mailClientBg {
+	background-color:#efefff;
+	background-image:url(images/layerPopupBg.gif);
+}
+
+.mailSubHeader {
+	background:#b4b8ff url(images/mailSubHeaderBg.gif) repeat-x;
+	padding:4px;
+}
+
+.mailClientWriteEmailHeader {
+	font-family:arial, helvetica, sans-serif;
+	font-size:20px;
+	line-height:24px;
+	font-weight:bold;
+	background:#e0dbb0 url(images/mailSubHeaderBg.gif) repeat-x;
+	padding:10px;
+	border-left:1px solid #eaeaea;
+	border-top:1px solid #eaeaea;
+	border-right:1px solid #939271;
+	border-left:1px solid #939271;;
+}
+
+.mailClientCSSButton {
+	border-left:1px solid #fff;
+	border-top:1px solid #fff;
+	border-right:1px solid #333;
+	border-bottom:1px solid #333;
+	padding:2px;
+	background-color:#c3c2b1;
+}
+
+/* Email Client Classes ends ------------------------------------ */
+
+
+
+/* Layer Popup */
+.layerPopup {
+	border:3px solid #95a5ff;
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+	position:absolute;
+}
+
+.layerPopupHeading {
+	font-family:arial, helvetica, sans-serif;
+	font-size:16px;
+	line-height:24px;
+	font-weight:bold;
+}
+.layerHeadingULine {
+	border-bottom:2px solid #717351;
+}
+.layerPopupTransport {
+	background-color:#e2e5ff;
+
+}
+.homePageSeperator {
+	border-right:1px dotted #d3d2c1;
+}
+.homePageMatrixHdr {
+	border-bottom:1px solid #d3d2c1;
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+}
+
+.reportsListTable {
+	background-color:white;
+	border-left:1px solid #a3a29f;
+	border-right:1px solid #a3a29f;
+	border-bottom:1px solid #a3a29f;
+}
+
+.reportGenerateTable{
+	background-image:url(images/layerPopupBg.gif);
+	border-left:2px dotted #a5b5ee;
+	border-right:2px dotted #a5b5ee;
+	border-bottom:2px dotted #a5b5ee;
+}
+.reportCreateBottom{
+	background-color:#ddf;
+	border-bottom:2px solid #737251;
+
+}
+.importLeadUI{
+	/*background:#fffff5 url(images/select.gif) ; */
+	background-color:white;
+}
+
+a.customMnu{
+	padding-left:30px;
+	padding-top:5px;
+	padding-bottom:5px;
+	display:block;
+	background-repeat:no-repeat;
+	background-position:left;
+	width:155px;
+	color:#000000;
+	text-decoration:none;
+}
+
+a.customMnuSelected{
+	padding-left:30px;
+	padding-top:5px;
+	padding-bottom:5px;
+	display:block;
+	background-repeat:no-repeat;
+	background-position:left;
+	width:155px;
+	background-color:#0099FF;
+	color:#FFFFFF;
+	text-decoration:none;
+}
+
+
+/* Drop Down Menu */
+.drop_mnu{
+    position:absolute;
+    left:0px;
+    top:0px;
+    z-index:1000000001;
+    border-left:1px solid #a5b5ee;
+    border-right:1px solid #a5b5ee;
+    border-bottom:1px solid #a5b5ee;
+    width:150px;
+    display:none;
+    padding:0px;
+    text-align:left;
+    overflow-x:hidden;
+    overflow-y:hidden;
+    background-color:#eef;
+}
+
+a.drop_down{
+    width:150px;
+    text-align:left;
+    font-family:  Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    line-height:20px;
+    font-weight:normal;
+    color:#33a;
+    background-color:#eef;
+    padding:2px 5px 2px 5px;
+    border-top:1px solid #fafafa;
+    border-bottom:1px solid #d3d3f3;
+    display:block;
+}
+
+a.drop_down:Hover{
+    padding:2px 5px 2px 5px;
+    width:150px;
+    text-align:left;
+    color:#33a;
+    font-weight:normal;
+    text-decoration:underline;
+    background-color:#ccf;
+}
+
+.bgwhite{
+	background-color:white;
+}
+
+.searchUIBasic {
+		background-image:url(images/layerPopupBg.gif);
+		border:2px solid #a5b5ee;
+}
+.searchUIAdv1{ 
+		background-image:url(images/layerPopupBg.gif);
+		border-top:2px solid #a5b5ee;
+		border-left:2px solid #a5b5ee;
+		border-right:2px solid #a5b5ee;
+}
+.searchUIAdv2{ 
+		background-image:url(images/layerPopupBg.gif);
+		border-left:2px solid #a5b5ee;
+		border-right:2px solid #a5b5ee;
+}
+.searchUIAdv3{ 
+		background-image:url(images/layerPopupBg.gif);
+		border-bottom:2px solid #a5b5ee;
+		border-left:2px solid #a5b5ee;
+		border-right:2px solid #a5b5ee;
+}
+
+/* Recalculate Disabling Window */
+
+.veil{
+   background: url(images/layerPopupBg.gif) ;
+    height: 100%;
+    width: 100%;
+    top: 0px;
+    left: 0px;
+    overflow: hidden;
+    z-index: 10000;
+    Filter: Alpha(opacity = 70);
+    -moz-opacity: 0.7;
+    text-align: center;
+    vertical-align: middle;
+    position: absolute;
+}
+
+.veil_new{
+   background: url(images/layerPopupBg.gif) ;
+    height: 100%;
+    width: 100%;
+    top: 0px;
+    left: 0px;
+    overflow: hidden;
+    z-index: 50000;
+    Filter: Alpha(opacity = 70);
+    -moz-opacity: 0.7;
+    text-align: center;
+    vertical-align: middle;
+    position: absolute;
+}
+
+.optioncontainer{
+    vertical-align: middle;   
+    height: 100%;
+    width: 100%;   
+    position: absolute;
+    z-index: 90000;   
+}
+
+
+.options{
+    	vertical-align: middle;   
+	margin-left: 25%;
+	margin-top: 16%;
+	color: #FFFFFF;
+	width:650px;
+	background-color: Black;
+	border: 2px solid #222;	
+    	position: relative;
+	text-align: left;
+    	z-index: 80000;   
+}
+
+.options h2{
+	color: White;
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	border-bottom: 1px solid #373D4C;
+	margin: 0;
+	font-weight: normal;
+}
+
+/* Recalculate Disable Ends */
+.mailSelected {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+.mailSelected_select {
+	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
+	background-color:#1F5EFF;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+
+.groupname{
+                width:125px;
+          }
+
+.winmarkModulesdef{
+   background-image:url(images/blueLagoonHomeMark.gif);
+   background-position:top left;
+   background-repeat:no-repeat;
+}
+

Modified: vtigercrm/branches/5.1_jens/themes/woodspice/images/aboutUS.jpg
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/branches/5.1_jens/themes/woodspice/images/cal12x12Shared.gif
==============================================================================
Binary files - no diff available.

Modified: vtigercrm/branches/5.1_jens/themes/woodspice/style.css
==============================================================================
--- vtigercrm/branches/5.1_jens/themes/woodspice/style.css (original)
+++ vtigercrm/branches/5.1_jens/themes/woodspice/style.css Mon Apr 16 12:27:44 2007
@@ -1,2259 +1,2326 @@
-/*********************************************************************************
-
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is:  vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
- ********************************************************************************/
-
-.small {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-}
-.big {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 12px;
-	line-height: 18px;
-	color: #000000;
-	font-weight:bold;
-}
-
-.componentName {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	line-height: 18px;
-	color: #998877;
-	font-weight:bold;
-	border-left:2px dotted #332211;
-	padding:10px;
-}
-.genHeaderBig{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 16px;
-	line-height: 19px;
-	color: #000000;
-	font-weight:bold;
-}
-.genHeaderSmall{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	line-height: 16px;
-	color: #000000;
-	font-weight:bold;
-}
-
-.moduleName {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	color: #000000;
-	font-weight:bold;
-}
-.hdrNameBg {
-	background:#ffffff url(images/primeTopBg.gif) repeat-x;
-
-}
-
-.hdrTabBg {
-	/*background:#ffffff url(images/hdrTabBg.gif) bottom repeat-x ;*/
-	background-color:#eae9da;
-}
-
-.tabSelected {
-	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-weight:bold;
-	font-size: 11px;
-	padding-left:10px;
-	padding-right:10px;
-	padding-top:2px;
-	padding-bottom:2px;
-	
-
-}
-
-.tabUnSelected {
-	
-	/* background: #efedd4 url(images/tabUnSelectedBg.gif) repeat-x; */
-	background-color:#D7D5BE;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	padding-left:10px;
-	padding-right:10px;
-	padding-top:2px;
-	padding-bottom:2px;
-	border-bottom:1px solid #efedda;
-}
-
-
-.tabSeperator {
-	background-color:#cccbb5;
-	
-	width:2px;
-}
-
-
-.searchUIBasic {
-	border:2px dotted #aaaaaa;
-	background-color:#FFF6CF;
-	background-image:url(images/searchUIBg.gif);
-}
-
-.searchUIAdv1{
-	border-top:2px dotted #aaaaaa;
-	border-left:2px dotted #aaaaaa;
-	border-right:2px dotted #aaaaaa;
-	background-color:#fff6cf;
-	background-image:url(images/searchUIBg.gif);
-}
-
-.searchUIAdv2{
-	border-left:2px dotted #aaaaaa;
-	border-right:2px dotted #aaaaaa;
-	background-color:#fff6cf;
-	background-image:url(images/searchUIBg.gif);
-}
-
-.searchUIAdv3{
-	border-bottom:2px dotted #aaaaaa;
-	border-left:2px dotted #aaaaaa;
-	border-right:2px dotted #aaaaaa;
-	background-image:url(images/searchUIBg.gif);
-	background-color:#fff6cf;
-}
-.searchUIName {
-	border-right:1px solid #333333;
-	padding-right:40px;
-}
-
-.level2Bg {
-	background:#e0dbb0 url(images/level2TabBg.gif) bottom repeat-x;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	border-bottom:1px solid #a2a77f;
-}
-
-.level2SelTab{
-	font-weight:bold;
-	color:#000000;
-	padding-left:20px;
-	padding-right:20px;
-	padding-top:5px;
-	padding-bottom:5px;
-	
-}
-	
-.level2UnSelTab{
-	color:#000000;
-	padding-left:20px;
-	padding-right:20px;
-	padding-top:5px;
-	padding-bottom:5px;
-}
-
-
-.sep1 {
-	background:#999999;
-}
-
-.showPanelBg {
-	background:url(images/showPanelTopBg.gif) repeat-x;
-}
-
-a {
-	text-decoration:none;
-	color:#776643;
-	
-	
-}
-
-a:hover {
-	text-decoration:underline;
-	
-}
-
-.hdrLink {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	text-decoration:none;
-	color:#333333;
-	font-weight:bold;
-}
-
-.hdrLink:hover {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	text-decoration:underline;
-	color:#333333;
-	font-weight:bold;
-}
-
-.searchBox {
-	border: 0px solid #999999;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	padding-left:2px;
-	width:100px;
-	background-color:#ffffef;
-}
-
-.searchBtn {
-	border : 1px #cccccc solid;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	width:30px;
-	height:19px;
-	background-color:#cccccc;
-}
-
-
-/* List View Table classes starts  +++++++++++++++++ */
-
-.lvt {
-	background-color:#e3e2d1;
-	border:1px solid #939281; 
-}
-
-.lvtBg {
-	
-
-}
-
-.lvtHeaderText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	font-weight:bold;
-}
-
-.lvtCol {
-	border-top:1px solid #eeeecc;
-	border-left:1px solid #fafafa;
-	border-right:1px solid #999988;
-	border-bottom:1px solid #999988;
-	background-color:#d3d2c1;
-	font-weight:bold;
-}
-
-.lvtColData {
-	background-color:#ffffff;
-}
-
-.lvtColDataHover {
-	background-color:#ffffea;
-	
-}
-
-
-/* List View Table classes ends --------------------------------*/
-
-
-
-/* Detailed View classes starts +++++++++++++++++++++++ */
-.dvHeaderText{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	color:#000000;
-	font-weight:bold;
-
-}
-
-.dvInnerHeader{
-	border-bottom:2px solid #999999;
-	padding:5px;
-	background-color:#fffffff;
-
-}
-
-.dvtSelectedCell {
-	border-left:2px solid #ddccaa;
-	border-top:3px solid #ddccaa;
-	border-right:2px solid #ddccaa;
-	padding-left:20px;
-	padding-right:20px;
-	background-color:white;
-	font-weight:bold;
-}
-
-.dvtUnSelectedCell {
-	border-left:2px solid #cacaca;
-	border-top:2px solid #cacaca;
-	border-right:2px solid #cacaca;
-	border-bottom:2px solid #ddccaa;
-	padding-left:20px;
-	padding-right:20px;
-	background-color:#efefef;
-	cursor:pointer;
-}
-
-.dvtTabCache {
-	border-bottom:2px solid #ddccaa;
-}
-
-.dvtContentSpace {
-	border-left:2px solid #ddccaa;
-	border-right:2px solid #ddccaa;
-	border-bottom:2px solid #ddccaa;
-	padding-left:0px;
-}
-
-.dvtCellLabel, .cellLabel {
-	background-color:#efefe2;
-	padding-right:10px;
-	padding-left:10px;
-	border-bottom:1px solid #dadacc ;
-	color:#333333;
-	white-space:nowrap;
-}
-
-.dvtCellInfo, .cellInfo {
-	padding-left:10px;
-	padding-right:10px;
-	border-bottom:1px solid #999;
-	white-space:nowrap;
-}
-
-.rightMailMerge {
-	border:1px solid #dddddd
-}
-
-.rightMailMergeHeader {
-	border-bottom:1px solid #dadaaa;
-	padding:5px;
-	background-color:#eaeacc;
-
-}
-
-.rightMailMergeContent {
-	padding:5px;
-	background-color:#fafafa;
-
-}
-
-.detailedViewHeader{
-	border-bottom:1px solid #ddddcc;
-	padding:5px; 
-	background-color:#ddddcc;
-
-}
-
-.detailedViewTextBox {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#ffffff;
-}
-
-.detailedViewTextBoxOn {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	color: #000000;
-	border:1px solid #bababa;
-	padding-left:5px;
-	width:90%;
-	background-color:#ffffdd;
-}
-
-
-/* Detailed View classes ends  ------------------------------------------- */
-
-
-.advSearch {
-	padding:10px;
-	border-left:1px solid #eaeaea; 
-	border-right:1px solid #eaeaea; 
-	border-bottom:1px solid #eaeaea; 	
-	overflow:auto;
-	width:600px;
-	height:150px;
-	background-color:#ffffef;
-
-}
-
-.searchAlph {
-	border:1px solid #dadada;
-	background-color:#ffffff;
-	cursor:pointer;
-	width:10px
-
-}
-.searchAlphselected {
-	border:1px solid #666666;
-	background-color:#bbbbbb;
-	cursor:pointer;
-	width:10px
-
-}
-
-.textbox {
-	border:1px solid #999999;
-	background-color:#ffffff;
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	width:120px;
-	padding:2px;
-
-}
-
-
-
-.mx {
-}
-
-.calListTable td{
-	border-bottom:1px solid #efefef;
-	border-left:1px solid #efefef;
-}
-.calDIV {
-	width:100%;
-	border:1px solid #999999;
-	
-}
-
-.calDayHour {
-	border-top:1px solid #a8a591;
-	border-left:1px solid #a8a591;
-	border-bottom:1px solid #a8a591;
-	border-right:1px solid #a8a591;
-	background-color:#eae7da;
-}
-
-
-.calAddEvent {
-	position:absolute;
-	z-index:10000;
-	width:500px;
-	left:200px;
-	top:150px;
-	background-color:#ffffff;
-}
-
-
-
-.addEventInnerBox {
-	border:1px dotted #dadada;
-
-}
-
-
-.cellNormal {
-	border:0px;
-	background-color:#ffffff;
-}
-
-.EventToDo{
-
-}
-
-.thumbnail{
-    background-color:#ffffff;
-padding: 7px;
-border: 1px solid #ddd;
-float: left;
-	   margin-right: 10px;
-	   margin-bottom: 15px;
-}
-
-.padTab{
-    padding-top:0px;
-    padding-left:0px;
-    padding-left:10px;
-    padding-bottom:0px;
-    vertical-align:top;
-
-}
-
-#company{
-    position:relative;
-    width:100%;
-    height:200px;
-    display:block;
-    background-color:#FFFFFF;
-    white-space:nowrap;
-    overflow:auto;
-    border:1px solid #CCCCCC;
-}
-                               
-
-#user{position:relative;left:0px;top:0px;width:100%;display:block;}
-
-#communication{position:relative;left:0px;top:0px;width:100%;display:block;}
-#config{position:relative;left:0px;top:0px;width:100%;display:block;}
-
-#userTab{position:relative;left:0px;top:0px;width:100%;display:none;}
-
-
-#one{
-	position:relative;
-	display:block;
-	width:245px;
-}
-
-#mnuTab1{
-
-   position:relative;
-
-   overflow:auto;
-
-   width:100%;
-
-   display:none;
-
-}
-
-#mnuTab2{
-
-   position:relative;
-
-   overflow:auto;
-
-   width:100%;
-
-   display:none;
-
-}
-
-
-/* End of Settings */
-
-
-.bgwhite{
-	background-color: #FFFFFF;
-}
-.copy{
-	font-size:9px;
-	font-family: Verdana, Arial, Helvetica, Sans-serif;
-}
-
-#basicTab{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:block;
-}
-
-#moreTab{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:none;
-}
-
-#one{
-	position:relative;
-	display:block;
-	width:245px;
-}
-
-
-.dashHeading {
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:24px;
-	font-weight:bold;
-	color:#000;
-}
-
-.dashSelectBg{
-	background-image:url(images/dashSelectBg.gif);
-	background-repeat:repeat-x;
-}
-.dash_top{
-	background-image:url(images/dashTopBg.gif);
-	background-repeat:repeat-x;
-	height:63px;
-	vertical-align:middle;
-}
-
-.dash_border{
-	background-color:#e0dbb0;
-	padding:5px;
-}
-
-
-.dash_white{
-	background-color:#FFFFFF;
-	padding:5px 10px 5px 10px;
-}
-
-.dash_bdr_btm{
-	border-bottom:2px dotted #939271;
-}
-
-.dash_count{
-	font-size:36px;
-	font-weight:bold;
-	text-decoration:none;
-	color:#000000;
-	padding-left:10px;padding-right:10px;	
-}
-
-
-.dash_switch{
-	cursor:pointer;
-	width:26px;
-	height:26px;
-}
-
-.dash_row_sel{
-	background-image:url(images/dash_sel_chart.jpg);
-	background-repeat:no-repeat;
-	background-position:center;
-	width:26px;height:26px;
-	text-align:center;
-	vertical-align:middle;
-	font-weight:bold;
-	font-size:10px;
-	text-decoration:none;
-}
-
-.dash_row_unsel{
-	background-image:url(images/dash_unsel_chart.jpg);
-	background-repeat:no-repeat;
-	background-position:center;
-	width:26px;height:26px;
-	text-align:center;
-	vertical-align:middle;
-	font-weight:normal;
-	font-size:10px;
-	text-decoration:none;
-	cursor:pointer;
-}
-
-.dash_chart_btm{
-	border-bottom:2px solid #000000;
-}
-
-
-.dash_bottom{
-	background-image:url(images/dashBottomBg.gif);
-	background-repeat:repeat-x;
-	height:63px;
-	vertical-align:middle;
-}
-
-.dash_btm{
-	background-image:url(images/dash_btm_center.jpg);
-	background-repeat:repeat-x;
-	position:top;
-}
-
-
-/*  menu */
-
-
-
- a.submenu{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:11px;
-	padding-top:5px;
-	padding-bottom:5px;
-	padding-left:10px;
-	border-bottom:1px solid #CCCCCC;
-	background-color:#ECECEC;
-	color:#000000;
-	text-align:left;
-	text-decoration:none;
-	display:block;
-}
-
-a.submenu:Hover{
-	background-color:#DDDDDD;
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:11px;
-	padding-top:5px;
-	padding-bottom:5px;
-	padding-left:10px;
-	border-bottom:1px solid #CCCCCC;
-	color:#000000;
-	text-align:left;
-	text-decoration:none;
-	display:block;
-}
-
-#mnuKey{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:11px;
-	background-color:#666666;
-	color:#FFFFFF;
-	text-decoration:none;
-	padding:5px;
-	font-weight:bold;
-	width:8px;
-	cursor:pointer;
-	vertical-align:top;
-	height:100px;
-	position:relative;
-	top:0px;
-	left:0px;
-}
-
-#slidemenu{
-	height:525px;
-	vertical-align:top;
-	width:100px;
-	background-color:#CCCCCC;
-	border-right:1px solid #CCCCCC;
-	opacity:.9;
-	display:none;
-}
-
-/* clock */
-
-.citystyle{
-	position:relative;
-	top:0px;
-	left:0px;
-	text-align:left;
-	
-}
-#theClockLayer{
-	position:relative;
-	height:180px;
-	left:20px;
-	text-align:center;
-}
-.handsanddotsstyle{
-	margin-top:10px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:2px;
-	height:2px;
-	font-size:2px;
-	background-color:#000000;
-}
-.facestyle{
-	margin-top:10px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:15px;
-	height:15px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-.datestyle{
-	margin-top:20px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:100px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-.ampmstyle{
-	margin-top:23px;
-	position:absolute;
-	top:0px;
-	left:0px;
-	width:20px;
-	text-align:center;
-	font-family:arial,sans-serif;
-	font-size:10px;
-	color:#000000;
-}
-
-#wclock{
-	position:absolute;
-	left:100px;
-	top:100px;
-	display:none;
-	background-color:#CCCCCC;
-	width:175px;
-}
-
-.leftFormBorder1 {
-	border: 1px solid #AFC8E4;
-	background-color: #FFFFFF;
-	opacity:.7;
-}
-
-
-
-
-/* Calculator */
-
-.calcResult {
-	width: 100%;
-	height: 25px;
-	background-color: #FFFFCC;/*CBDFD6*/
-	border-top: 1px solid #CCC;
-	border-left: 0px;
-	border-right: 1px solid #CCC;
-	border-bottom: 1px solid #CCC;
-	font-size: 10px;
-	text-align: right;
-}
-.calcMem {
-	width: 100%;
-	height: 25px;
-	border-top: 1px solid #CCC;
-	border-left: 1px solid #CCC;
-	border-right: 0px;
-	border-bottom: 1px solid #CCC;
-	background-color: #FFFFCC;/*CBDFD6*/
-	font-family: Arial;
-	font-size: 10px;
-	color: #BBB;
-	text-align: left;
-}
-.calcBlackBtn, .calcGreyBtn, .calcBigBtn, .calcCancBtn, .calcMemBtn, .calcBackBtn {
-	border: none;
-	height: 20px;
-	font-size: 11px;
-	color: #FFF;
-	text-align:center;
-}
-.calcBackBtn {
-	background: url(images/calc_back_btn.gif) no-repeat;
-	width:25px;
-}
-.calcBlackBtn {
-	background: url(images/calc_black_btn.gif) no-repeat;
-	width:25px;
-}
-.calcGreyBtn {
-	background: url(images/calc_grey_btn.gif) no-repeat;
-	width:25px;
-}
-.calcCancBtn {
-	background: url(images/calc_canc_btn.gif) no-repeat;
-	width:25px;
-	
-}
-.calcMemBtn {
-	background: url(images/calc_mem_btn.gif) no-repeat;
-	width:25px;
-	/*background-color: #CCC;*/
-}
-#calc{
-	position:absolute;
-	left:100px;
-	top:100px;
-	background-color:#FFFFFF;
-	width:185px;
-	border-bottom:2px solid #000000;
-	border-right:2px solid #666666;
-	border-left:2px solid #CCCCCC;
-	border-top:2px solid #CCCCCC;
-}
-
-/* RSS STYLES */
-
-.subHdr{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#FFFFFF;
-	background-image:url(images/rssHeader.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-}
-
-.delBg{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#FFFFFF;
-	background-image:url(images/rssdelete.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-}
-
-#rssScroll{
-	font-family:Arial, Helvetica, sans-serif	;
-	font-size:12px;
-	background-color:#FFFFFF;
-	width:100%;
-	height:130px;
-	overflow:auto;
-	border:0px solid #000000;
-}
-
-.rssTable{
-	width:100%;
-	border:0px solid #CCCCCC;
-}
-
-.rssTable tr th{
-	background-color:#ead9a2;
-	text-align:left;
-	border-bottom:1px solid #c2c7a2;
-	border-top:1px solid #FFFFFF;
-	color:#000000;
-	padding-left:5px;
-	padding-right:5px;
-	height:20px;
-}
-
-.rssTable tr td{
-	text-align:left;
-	border-bottom:1px dotted #dadada;
-	border-left:1px dotted #dadada;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	font-weight:normal;
-	white-space:nowrap;
-	padding:2px;
-	
-}
-
-.forwardBg{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#000000;
-	background-image:url(images/rssforward.gif);
-	background-position:top left;
-	background-repeat:repeat-x;
-	height:27px;
-	padding:0px 10px 0px 10px;
-	vertical-align:middle;
-	background-color:#D7D7D7;
-}
-
-
-/*  New Styles */
-
-
-
-.mnuTab{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	font-size:12px;
-	color:#000000;
-	width:100%;
-	border:0px solid #000000;
-}
-
-.mnuTab tr td{
-	border-bottom:1px solid #EBEBEB;
-	padding-left:5px;
-	vertical-align:middle;
-}
-
-/* profile */
-
-.prvPrfBigText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-.prvPrfTopBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfBottomBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfOutline {
-	border:1px solid #ebebeb;
-}
-
-
-
-.prvPrfTexture {
-	background:url(images/prvPrfTexture1.gif);
-
-}
-
-.prvPrfHoverOn {
-	background-color:#ffffef;
-	
-}
-
-/*  Organization */
-
-.orgTab{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	font-weight:normal;
-	color:#666666;
-	border:0px solid #9B9B9B;
-	border-collapse:collapse;
-	width:100%;
-}
-
-.orgTab tr th{
-	text-align:left;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:12px;
-	text-decoration:none;
-	font-weight:bold;
-	height:20px;
-	padding-left:5px;
-}
-
-.orgTab tr td{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-decoration:none;
-	font-weight:normal;
-	padding-left:5px;
-	height:20px;
-	border-bottom:1px solid #CCCCCC;
-	border-right:1px solid #CCCCCC;
-}
-
-
-/* Groups */
-
-
-.groupli{
-	margin-left:20px;
-	font-family:Arial, Helvetica, sans-serif;
-	font-weight:normal;
-	font-size:12px;
-	text-decoration:none;
-	color:#333333;
-	list-style-type:none;
-	text-align:left;
-}
-
-/* tree menu */
-
-/*Oraganization Edit Features */
-
-#orgLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:500px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	display:block;
-	position:absolute;
-	left:0px;
-	top:0px;
-}
-
-/*  Role */
-
-#roleLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:300px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	display:none;
-	position:absolute;
-}
-
-.classBtn{
-	font-family:Verdana, Arial, Helvetica, sans-serif;
-	text-decoration:none;
-	font-weight:normal;
-	font-size:10px;
-	background-color:#DBDBDB;
-	border-bottom:2px solid #999999;
-	border-right:2px solid #999999;
-	border-top:2px solid #F5F5F5;
-	border-left:2px solid #F5F5F5;
-	color:#000000;
-	text-align:center;
-	padding-top:3px;
-	padding-bottom:3px;
-}
-
-.txtBox{
-	width:85%;
-	border:1px solid #666666;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-}
-
-/*  IMPORT LEADS */
-
-.leadTable{
-	border:3px solid #CCCCCC;
-	border-collapse:collapse;
-}
-
-.leadTable tr td{
-/*	border:0px solid #CCCCCC;*/
-}
-
-.genHeaderGray{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-	line-height: 16px;
-	color: #888888;
-	font-weight:bold;
-}
-
-.genHeaderGrayBig{
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 18px;
-	line-height: 16px;
-	color: #888888;
-	font-weight:bold;
-}
-
-.importBox{
-	width:125px;
-	border:1px solid #666666;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-}
-
-
-.txtGreen{
-	color:green;
-}
-
-/* PICK LIST */
-ul li{
-	padding-bottom:2px;
-	padding-top:2px;
-}
-/* MY PREFERENCES */		
-
-
-/* CSS FOR REPORTS */
-
-.reportHdr{
-	background-color:#DDDDDD;
-	font-size:12px;
-	font-weight:bold;
-	vertical-align:middle;
-	text-align:left;
-	height:30px;
-	border-bottom:2px solid #959595;
-	color:#000000;
-	padding-left:10px;
-}
-
-#reportLay{
-	width:175px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-#locateMap{
-	width:120px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-
-a.reportMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:none;
-	display:block;
-	width:155px;
-	height:20px;
-	border-bottom:1px solid #E1E1E1;
-	padding-left:20px;
-	padding-top:3px;
-}
-
-a.reportMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-	display:block;
-	width:155px;
-	height:20px;
-	border-bottom:1px solid #E1E1E1;
-	padding-left:20px;
-	padding-top:3px;
-}	
-
-#Generate{
-	position:relative;
-	width:100%;
-	text-align:center;
-	display:none;
-}
-
-
-/* END OF REPORT */
-
-
-
-/* WEB MAIL */
- a.webMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-}
-a.webMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-} 
-
-
-/*  END OF WEB MAIL */
-
-/* POPUP */
-
- a.alpha{
-	font-size:11px;
-	color:gray;
-	text-decoration:none;
-	padding-Left:5px;
-	padding-right:5px;
-	border:1px dotted #CCCCCC;
-	background-color:#FFFFCC;
-}
-
-a.alpha:Hover{
-	font-size:11px;
-	color:gray;
-	text-decoration:underline;
-	padding-Left:5px;
-	padding-right:5px;
-	border:1px dotted #CCCCCC;
-	background-color:#FFFFCC;
-} 
-
-/* Home Page */
-.MatrixLayer{
-	border:2px solid #a3a295;
-	background-color:#FFFFFF;
-	width:29%;
-	position:relative;
-	visibility:visible;
-	margin:9px;
-	height:280px;
-}
-
-.fontBold{
-	font-size:13px;
-	color:#000000;
-	text-decoration:none;
-	font-weight:bold;
-}
-
-.style_Gray{
-	color:gray;
-}
-	
-/* End of Home Page */
-
-/* All Menu */
-#allMenu{
-    width:500px;
-    border:4px solid #C3C2a1;
-    left:300px;
-    top:100px;
-    position:absolute;
-    z-index:1000001;
-    display:none;
-    padding:10px;
-    background:#ffffff url(images/layerPopUpBg.gif);
-}
-
-
-.allMnuTable{
-    width:100%;
-    background-color:#FFFFFF;
-}
-
-.allMnuHandle td{
-    height:20px;
-    color:#FFFFFF;
-    font-family:Arial, Helvetica, sans-serif;
-    font-size:12px;
-    font-weight:bold;
-    text-decoration:none;
-    background-color:#000066;
-    cursor:move;
-    padding:2px;
-    border-bottom:2px solid #666666;
-}
-
-.allMnuHdr{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-weight:Bold;
-    font-size:11px;
-    text-decoration:none;
-    display:block;
-    background-color:#FFFFFF;
-    color:#737251;
-    padding-top:5px;
-    padding-bottom:5px;
-}
-
-a.allMnu{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-size:10px;
-    text-decoration:none;
-    font-weight:normal;
-    display:block;
-    width:125px;
-    height:15px;
-    padding-left:5px;
-    padding-top:0px;
-    padding-bottom:0px;
-    background-color:#FFFFFF;
-    border:1px solid #FFFFFF;
-    color:#000033;
-    margin-left:20px;
-}
-
-a.allMnu:Hover{
-    font-family:Verdana, Arial, Helvetica, sans-serif;
-    font-size:10px;
-    text-decoration:none;
-    font-weight:normal;
-    display:block;
-    width:125px;
-    height:15px;
-    padding-left:5px;
-    padding-top:0px;
-    padding-bottom:0px;
-    background-color:#dad7b5;
-    color:#333;
-}
-/* End Of All Menu */
-
-
-
-/* Calendar */
-.calHdr{
-	background-image:url(images/mailSubHeaderBg.gif); 
-	background-repeat:repeat-x;
-	background-position:left top;
-	
-}
-
-.calSel{
-	background-image:url(images/dashSelectBg.gif);
-	background-repeat:repeat-x;
-	text-align:center;
-	color:#FFFFFF;
-	font-weight:bold;
-	width:8%;
-}
-
-.calAddButton {
-	border: 1px solid #666666;
-	background:#D6D2AB url(images/calAddButtonBg.gif) repeat-x;
-	cursor:pointer;
-	height:20px;
-	
-
-}
-.calInnerBorder {
-	border-left:1px solid #d6d2ab;
-	border-right:1px solid #d6d2ab;
-	border-bottom:1px solid #d6d2ab;
-}
-
-.calBorder {
-	border-left: 1px solid #939271; 
-	border-right: 1px solid #939271; 
-	border-bottom: 1px solid #939271; 
-	background:#fefefe url(images/layerPopupBg.gif);
-
-}
-
-.calTopRight {
-	border-right: 1px solid #939271; 
-}
-
-
-.calUnSel{
-	color:#000000;
-	font-weight:normal;
-	text-align:center;
-	width:8%;
-}
-
-
-a.calMnu{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:none;
-	display:block;
-	height:20px;
-	padding-left:5px;
-	padding-top:3px;
-}	
-
-a.calMnu:Hover{
-	font-size:11px;
-	color:#0070BA;
-	text-decoration:underline;
-	display:block;
-	height:20px;
-	padding-left:5px;
-	padding-top:3px;
-}
-.bgwhite{
-	background-color: #FFFFFF;
-}
-.copy{
-	font-size:9px;
-	font-family: Verdana, Arial, Helvetica, Sans-serif;
-}
-
-#mnuTab{
-	position:relative;
-	width:100%;
-	display:block;
-}
-
-#mnuTab2{
-	position:relative;
-	overflow:auto;
-	width:100%;
-	display:none;
-}
-.style1 {color: #FF0000}
-
-.event{
-	background-color:#D3EAF0;
-	border:1px solid #999999;
-	text-align:left;
-	width:100%;
-	position:relative;
-	left:0px;
-	top:0px;
-	vertical-align:middle;
-	padding:1px;
-}
-
-#hrView{
-	display:block;
-}
-.calendarNav{
-	font-size:12px;
-	color:#FFFFFF;
-	white-space:nowrap;
-	text-align:center;
-	font-weight:bold;
-	padding-left:10px;
-	padding-right:10px;
-	background-image:url(images/cal_nav.gif);
-	background-repeat:repeat-x;
-}
-
-#addEventDropDown{
-	position:absolute;
-	display:none;
-	width:150px;
-	border:1px solid #666666;
-	left:0px;
-	top:0px;
-	overflow:visible;
-	z-index:5000;
-}
-
-.calAction{
-	width:175px;
-	background-color:#CCCCCC;
-	border:1px solid #DDDDDD;
-	padding-top:5px;
-	position:absolute;
-	display:none;
-	z-index:2000;
-}
-
-.calSettings{
-	position:absolute;
-	z-index:20000;
-	width:500px;
-	left:200px;
-	top:150px;
-	background-color:#ffffff;
-}
-
-.outer{
-	border-bottom:1px solid #CCCCCC;
-	border-left:1px solid #CCCCCC;
-	border-right:1px solid #CCCCCC;
-}
-
-.calTxt{
-	width:50%;
-	border:1px solid #CCCCCC;
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	padding-left:5px;
-}
-
-#leadLay{
-	position:relative;
-	width:100%;
-	float:left;
-	visibility:hidden;
-	padding:5px;
-	z-index:10000;
-}
-									
-/* End of Calendar */
-
-/* Cal Year View */
-
-
-.eventDay{
-	background-color:#FF9966;
-	font-weight:bold;
-}
-
-.currDay{
-	background-color:#006600;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-.currDay a{
-	color:#FFFFFF;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-
-/* End of Cal Year View */
-
-/* Level 2 Menu Selected*/
-
-level2Sel{
-	color:#000000;
-	font-weight:bold;
-	text-decoration:underline;
-}
-
-#DeleteLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:300px;
-	border:3px solid #CCCCCC;
-	background-color:#FFFFFF;
-	padding:5px;
-}
-
-#CurrencyDeleteLay{
-	font-family:Arial, Helvetica, sans-serif;
-	font-size:11px;
-	text-align:left;
-	width:350px;
-}
-
-
-/* For Report HTML Generation*/
-.rptCellLabel {
-    background-color:#f6f6f6;
-    padding-right:10px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom:1px solid #eaeaea;
-    color:#737373;
-    font-weight: bold;
-    white-space:nowrap;
-}
-.rptTable {
-    border-left: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-    border-top: 1px solid #DDDDDD;
-}
-.rptTitle, .rptHead, .rptData, .rptGrpHead{
-    font-family: Verdana, Arial, Helvetica, Sans-serif;
-    font-size: 11px;
-	text-align:left;
-    font-weight: normal;
-	height: 20px;
-	padding: 4px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-	background: #DDDDDD;
-}
-.rptGrp1Total, .rptGrp2Total, .rptTotal {
-    font-family: Verdana, Arial, Helvetica, Sans-serif;
-    font-size: 11px;
-	text-align:center;
-    font-weight: normal;
-    background: #FFF;
-	height: 20px;
-	padding: 4px;
-    border-right: 1px solid #DDDDDD;
-    border-bottom: 1px solid #DDDDDD;
-}
-
-.rptGrpHead {
-	background: #FFF;
-    border-bottom: 1px solid #FFF;
-    border-top: 1px solid #DDDDDD;
-    font-weight: normal;
-}
-
-.rptData {
-            background: #FFF;
-            font-weight: normal;
-}
-.rptEmptyGrp {
-            background: #FFF;
-            border-right: 1px solid #DDDDDD;
-}
-.statechange
-{
-    position:absolute;
-    visibility:hidden;
-    left:10px;
-    top:20px;
-    width:300px;
-    border:3px solid #CCCCCC;
-    background-color:#FFFFFF;
-}
-#PopupLay{
-    position:absolute;
-    font-family:Arial, Helvetica, sans-serif;
-    font-size:11px;
-    text-align:left;
-    width:500px;
-    border:3px solid #CCCCCC;
-    background-color:#FFFFFF;
-    padding:5px;
-    display:none;
-    left:100px;
-    top:100px;
-}
-
-#folderLay{
-    width:175px;
-    background-color:#CCCCCC;
-    border:1px solid #DDDDDD;
-    padding-top:5px;
-    position:absolute;
-    display:none;
-}
-
-/* Css for quick Create */
-
-
-.qcTransport{
-	    background-color:#d3d2c1;
-
-}
-
-#role_popup{
-        position:relative;
-        left:0px;
-        top:0px;
-        width:95%;
-        height:300px;
-        overflow:auto;
-        border:1px solid #999999;
-        text-align:left;
-        background-color:#FFFFFF;
-    }
-
-.unread_email {
-	font-weight:bold;
-}
-
-								    
-/* MY SITES */
-
-
-.unread_email {
-	font-weight:bold;
-}
-
-
-.tagCloud {
-    border:1px solid #737373;
-}
-
-   
-.tagCloudTopBg {
-    background: url(images/tagCloudBg.gif) repeat-x;
-   
-}
-
-.tagCloudDisplay {
-    background-color:#e5e5e5;
-    padding:10px;
-    font-family: Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    line-height: 14px;
-    color: #000000;
-
-}
-
-.h2 {
-
-	font-size:18px;
-	line-height:20px;
-
-}
-
-.gray {
-
-	color:gray;
-}
-
-
-ul {
-	list-style:circle;
-	line-height:20px;
-	padding-left:5px;
-	margin-left:20px;
-	font-weight:normal;
-
-}
-
-	
-
-
-
-.tagCloudTopBg {
-	background-image: url(images/tagCloudBg.gif);
-	background-repeat: repeat-x;	
-}
-
-.tagCloudDisplay {
-	background-color:#e5e5e5;
-	padding:5px;
-}
-	
-	
-	
-
-
-.heading2 {
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 16px;
-	line-height: 16px;
-	font-weight:bold;
-	color: #000000;
-}
-
-
-
-.settingsUI {
-	
-	text-align:left;
-	background-color:#d3d4c2;
-	border:2px solid #999a77;
-
-}
-
-
-.settingsTabHeader {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 12px;
-	line-height:25px;
-	font-weight:bold;
-	color:#000000;
-	background-image: url(images/mailSubHeaderBg.gif);
-	background-repeat: repeat-x;
-	padding-left:10px;
-	padding-right:10px;
-	
-
-}
-
-.settingsTabList {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:20px;
-	font-weight:normal;
-	color:#000000;
-	background-color:#efede2;
-	padding-left:30px;
-	border-top:1px solid #eaeaea;
-	border-bottom:1px solid #d3d1a3;
-}
-.settingsTabSelected {
-	text-align:left;
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:20px;
-	font-weight:bold;
-	color:#000000;
-	background-color:#ffffff;
-	padding-left:30px;
-}
-.settingsSelectedUI {
-	padding:10px;
-	background:url(images/settingsSelUIBg.gif) repeat-x;
-	background-color:#ffffff;
-}
-.settingsIconDisplay {
-	font-family:  Arial, Helvetica, sans-serif;
-	font-size: 11px;
-	line-height:14px;
-	padding:10px;
-
-	color:#000000;
-	background-color:#ffffff;
-	padding-left:10px;
-}
-.settingsSelUITopLine{
-	border-bottom:2px dotted #999999;
-
-}
-
-.tableHeading{
-	background-color:#ffffff;
-	border-bottom:2px solid #5a5b41;
-}
-.colHeader{
-	background-color:#EFECD1;
-	border-left:1px solid #eaeaea;
-	border-top:1px solid #eaeaea;
-	border-right:1px solid #999a77;
-	border-bottom:1px solid #999a77;
-	font-weight:bold;
-
-}
-.cellLabel {
-	background-color:#eaebd9;
-	border-top:1px solid #efefef;
-	border-bottom:1px solid #dadada;
-	color:#555555;
-
-}
-.cellText {
-	color:#333333;
-	border-bottom:1px solid #dadada;
-} 
-
-.listTable{
-	border-left:1px solid #cccccc;
-	border-right:1px solid #cccccc;
-	border-bottom:1px solid #cccccc;
-
-}
-
-.listTableRow{
-	border-bottom:1px solid #eaeaea;
-	border-right	:1px solid #eaeaea;
-	border-bottom:1px solid #eaeaea;
-	border-bottom:1px solid #eaeaea;
-}
-.listRow{
-	border-bottom:2px solid #eaeaea;
-
-}
-
-.listTableTopButtons{
-	background-color:#fafbe3;
-	
-}
-
-
-/*  Buttons */
-.crmButton{
-	
-	border-left:1px solid #ffffff;
-	border-top:1px solid #ffffff;
-	border-right:1px solid #555555;
-	border-bottom:1px solid #555555;
-}
-
-.create{
-	background-color:#ddccaa;
-	color:#333333;
-	font-weight:bold;
-}
-.delete {
-	background-color:#8F8C74;
-	color:#ffffff;
-	font-weight:bold;
-}
-.edit {
-	background-color:#ddccaa;
-	color:#333333;
-	font-weight:bold;
-}
-.save{
-	background-color:#ddccaa;
-	color:#333333;
-	font-weight:bold;
-}
-.cancel {
-	background-color:#8F8C74;
-	color:#ffffff;
-	font-weight:bold;
-}
-
-.inactive{
-color:#999999;
-}
-
-.active{
-color:#229922;
-
-}
-
-/* Buttons ends */
-
-
-
-textarea {
-	width:95%;
-	height:70px;
-	border:1px solid #dadada;
-}
-.treeTable1{
-	padding:0px;
-}
-
-.prvPrfBigText {
-	font-family: Arial, Helvetica, sans-serif;
-	font-size: 14px;
-}
-
-.prvPrfTopBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfBottomBg {
-	background-color:#ebebeb;
-}
-
-.prvPrfOutline {
-	border:1px solid #ebebeb;
-}
-
-
-
-.prvPrfTexture {
-	background:url(images/prvPrfTexture1.gif);
-
-}
-
-
-.prvPrfHoverOn {
-	background-color:#ffffef;
-	
-}
-
-
-.cellBottomDotLine {
-	border-bottom-width: 2px;
-	border-bottom-style: dotted;
-	border-bottom-color: #CCCCCC;
-	background-color:#ededed;
-}
-.crmFormList{
-	border:1px solid #cccccc;
-	width:90%;
-	height:120px;
-
-}
-.cellBottomDotLinePlain {
-	border-bottom-width: 2px;
-	border-bottom-style: dotted;
-	border-bottom-color: #CCCCCC;
-	
-}
-
-.thickBorder {
-	border: 2px solid #999999;
-}
-
-.trackerHeading {
-	background-color:#efefef;
-}
-.trackerListBullet {
-	border-right:1px dotted #cccccc;
-	background-color:#f9f9f9;
-}
-.trackerList {
-	border-bottom:1px solid #eeeeee;
-}
-
-/* Table Definitions */
-.crmTable {
-	border:1px solid #dadada;
-}
-
-.crmTableRow {
-	border-bottom:1px dotted #dadada;
-	border-right:1px dotted #dadada
-}
-
-
-/* Inventory */
-
-.lineOnTop {
-	border-top:1px solid #999999;
-}
-
-.discountUI{
-	border:3px solid #CCCCCC;
-	width:250px;
-	padding:5px;
-	position:absolute;
-	background-color:#FFFFFF;
-	display:none;
-}
-
-.TaxShow{
-	display:inline-table;
-}
-
-.TaxHide{
-	display:none;
-}
-
-/* Inventory */
-
-
-/* Email Client Classes ++++++++++++++++++++++ */
-
-.emailSelected{
-	background-color:#eaeaea;
-	color:#000000;
-	font-size:bold;
-}
-
-
-.mailClient{
-	border:2px solid #999a77;
-}
-
-.mailClientBg {
-	background-color:#e3e1cd;
-}
-
-.mailSubHeader {
-	background:#e0dbb0 url(images/mailSubHeaderBg.gif) repeat-x;
-	padding:4px;
-}
-
-
-.mailClientWriteEmailHeader{
-	font-family:arial, helvetica, sans-serif;
-	font-size:20px;
-	line-height:24px;
-	font-weight:bold;
-	background:#e0dbb0 url(images/mailSubHeaderBg.gif) repeat-x;
-	padding:10px;
-	border-left:1px solid #eaeaea;
-	border-top:1px solid #eaeaea;
-	border-right:1px solid #939271;
-	border-left:1px solid #939271;;
-	
-	
-}
-.mailClientCSSButton {
-	border-left:1px solid #fff;
-	border-top:1px solid #fff;
-	border-right:1px solid #333;
-	border-bottom:1px solid #333;
-	padding:2px;
-	background-color:#c3c2b1;
-	
-}
-
-/* Email Client Classes ends ------------------------------------ */
-
-
-
-/* Layer Popup */
-.layerPopup {
-	border:3px solid #939271;
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-	position:absolute;
-}
-
-.layerPopupHeading {
-	font-family:arial, helvetica, sans-serif;
-	font-size:16px;
-	line-height:24px;
-	font-weight:bold;
-}
-.layerHeadingULine {
-	border-bottom:2px solid #717351;
-}
-.layerPopupTransport {
-	background-color:#DFDFC2;
-
-}
-.homePageSeperator {
-	border-right:1px dotted #d3d2c1;
-}
-.homePageMatrixHdr {
-	border-bottom:1px solid #d3d2c1;
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-}
-
-.reportsListTable {
-	background-color:white;
-	border-left:1px solid #a3a29f;
-	border-right:1px solid #a3a29f;
-	border-bottom:1px solid #a3a29f;
-}
-
-.reportGenerateTable{
-	background-image:url(images/searchUIBg.gif);
-	border-left:2px dotted #a3a29a;
-	border-right:2px dotted #a3a29a;
-	border-bottom:2px dotted #a3a29a;
-}
-.reportCreateBottom{
-	background-color:#939271;
-	border-bottom:2px solid #737251;
-
-}
-.importLeadUI{
-	
-	background:#fffff5 url(images/layerPopupBg.gif) ;
-}
-
-a.customMnu{
-	padding-left:30px;
-	padding-top:5px;
-	padding-bottom:5px;
-	display:block;
-	background-repeat:no-repeat;
-	background-position:left;
-	width:155px;
-	color:#000000;
-	text-decoration:none;
-}
-
-a.customMnuSelected{
-	padding-left:30px;
-	padding-top:5px;
-	padding-bottom:5px;
-	display:block;
-	background-repeat:no-repeat;
-	background-position:left;
-	width:155px;
-	background-color:#0099FF;
-	color:#FFFFFF;
-	text-decoration:none;
-}
-
-
-/* Drop Down Menu */
-.drop_mnu{
-    position:absolute;
-    left:0px;
-    top:0px;
-    z-index:1000000001;
-    border-left:1px solid #E7E3C0;
-    border-right:1px solid #E7E3C0;
-    border-bottom:1px solid #E7E3C0;
-    width:150px;
-    display:none;
-    padding:0px;
-    text-align:left;
-    overflow-x:hidden;
-    overflow-y:hidden;
-    background-color:#F6F4E7;
-}
-a.drop_down{
-    width:150px;
-    text-align:left;
-    font-family:  Arial, Helvetica, sans-serif;
-    font-size: 11px;
-    line-height:20px;
-    font-weight:normal;
-    color:#000000;
-    background-color:#F6F4E7;
-    padding:2px 5px 2px 5px;
-    border-top:1px solid #fafafa;
-    border-bottom:1px solid #d3d3c3;
-    display:block;
-}
-
-a.drop_down:Hover{
-    padding:2px 5px 2px 5px;
-    width:150px;
-    text-align:left;
-    color:#FFFFFF;
-    font-weight:normal;
-    text-decoration:underline;
-    background-color:#D7D5BE;
-}
-
-.bgwhite{
-	background-color:white;
-}
-
-/* Recalculate Disabling Window */
-
-.veil{
-   background: url(images/searchUIBg.gif) ;
-    height: 100%;
-    width: 100%;
-    top: 0px;
-    left: 0px;
-    overflow: hidden;
-    z-index: 10000;
-    Filter: Alpha(opacity = 70);
-    -moz-opacity: 0.7;
-    text-align: center;
-    vertical-align: middle;
-    position: absolute;
-}
-
-.veil_new{
-   background: url(images/searchUIBg.gif) ;
-    height: 100%;
-    width: 100%;
-    top: 0px;
-    left: 0px;
-    overflow: hidden;
-    z-index: 50000;
-    Filter: Alpha(opacity = 70);
-    -moz-opacity: 0.7;
-    text-align: center;
-    vertical-align: middle;
-    position: absolute;
-}
-
-.optioncontainer{
-    vertical-align: middle;   
-    height: 100%;
-    width: 100%;   
-    position: absolute;
-    z-index: 90000;   
-}
-
-
-.options{
-    	vertical-align: middle;   
-	margin-left: 25%;
-	margin-top: 16%;
-	color: #FFFFFF;
-	width:650px;
-	background-color: Black;
-	border: 2px solid #222;	
-    	position: relative;
-	text-align: left;
-    	z-index: 80000;   
-}
-
-.options h2{
-	color: White;
-	font-family: Verdana, Arial, Helvetica, sans-serif;
-	border-bottom: 1px solid #373D4C;
-	margin: 0;
-	font-weight: normal;
-}
-
-/* Recalculate Disable Ends */
+/*********************************************************************************
+
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ ********************************************************************************/
+
+.small {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+}
+.big {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	line-height: 18px;
+	color: #000000;
+	font-weight:bold;
+}
+
+.componentName {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	line-height: 3px;
+	color: #998877;
+	font-weight:bold;
+	border-left:2px dotted #332211;
+	padding:10px;
+}
+.genHeaderBig{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	line-height: 19px;
+	color: #000000;
+	font-weight:bold;
+}
+.genHeaderSmall{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	line-height: 16px;
+	color: #000000;
+	font-weight:bold;
+}
+
+.moduleName {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	color: #000000;
+	font-weight:bold;
+}
+.hdrNameBg {
+	background:#ffffff url(images/primeTopBg.gif) repeat-x;
+
+}
+
+.hdrTabBg {
+	/*background:#ffffff url(images/hdrTabBg.gif) bottom repeat-x ;*/
+	background-color:#eae9da;
+}
+
+.tabSelected {
+	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+
+}
+
+.tabUnSelected {
+	
+	/* background: #efedd4 url(images/tabUnSelectedBg.gif) repeat-x; */
+	background-color:#D7D5BE;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	border-bottom:1px solid #efedda;
+}
+
+
+.tabSeperator {
+	background-color:#cccbb5;
+	
+	width:2px;
+}
+
+
+.searchUIBasic {
+	border:2px dotted #aaaaaa;
+	background-color:#FFF6CF;
+	background-image:url(images/searchUIBg.gif);
+}
+
+.searchUIAdv1{
+	border-top:2px dotted #aaaaaa;
+	border-left:2px dotted #aaaaaa;
+	border-right:2px dotted #aaaaaa;
+	background-color:#fff6cf;
+	background-image:url(images/searchUIBg.gif);
+}
+
+.searchUIAdv2{
+	border-left:2px dotted #aaaaaa;
+	border-right:2px dotted #aaaaaa;
+	background-color:#fff6cf;
+	background-image:url(images/searchUIBg.gif);
+}
+
+.searchUIAdv3{
+	border-bottom:2px dotted #aaaaaa;
+	border-left:2px dotted #aaaaaa;
+	border-right:2px dotted #aaaaaa;
+	background-image:url(images/searchUIBg.gif);
+	background-color:#fff6cf;
+}
+.searchUIName {
+	border-right:1px solid #333333;
+	padding-right:40px;
+}
+
+.level2Bg {
+	background:#e0dbb0 url(images/level2TabBg.gif) bottom repeat-x;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	border-bottom:1px solid #a2a77f;
+}
+
+.level2SelTab{
+	font-weight:bold;
+	color:#000000;
+	padding-left:20px;
+	padding-right:20px;
+	padding-top:5px;
+	padding-bottom:5px;
+	
+}
+	
+.level2UnSelTab{
+	color:#000000;
+	padding-left:20px;
+	padding-right:20px;
+	padding-top:5px;
+	padding-bottom:5px;
+}
+
+
+.sep1 {
+	background:#999999;
+}
+
+.showPanelBg {
+	background:url(images/showPanelTopBg.gif) repeat-x;
+}
+
+a {
+	text-decoration:none;
+	color:#776643;
+	
+	
+}
+
+a:hover {
+	text-decoration:underline;
+	
+}
+
+.hdrLink {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	text-decoration:none;
+	color:#333333;
+	font-weight:bold;
+}
+
+.hdrLink:hover {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	text-decoration:underline;
+	color:#333333;
+	font-weight:bold;
+}
+
+.searchBox {
+	border: 0px solid #999999;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	padding-left:2px;
+	width:100px;
+	background-color:#ffffef;
+}
+
+.searchBtn {
+	border : 1px #cccccc solid;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	width:30px;
+	height:19px;
+	background-color:#cccccc;
+}
+
+
+/* List View Table classes starts  +++++++++++++++++ */
+
+.lvt {
+	background-color:#e3e2d1;
+	border:1px solid #939281; 
+}
+
+.lvtBg {
+	
+
+}
+
+.lvtHeaderText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	font-weight:bold;
+}
+
+.lvtCol {
+	border-top:1px solid #eeeecc;
+	border-left:1px solid #fafafa;
+	border-right:1px solid #999988;
+	border-bottom:1px solid #999988;
+	background-color:#d3d2c1;
+	font-weight:bold;
+}
+
+.lvtColData {
+	background-color:#ffffff;
+}
+
+.lvtColDataHover {
+	background-color:#ffffea;
+	
+}
+
+
+/* List View Table classes ends --------------------------------*/
+
+
+
+/* Detailed View classes starts +++++++++++++++++++++++ */
+.dvHeaderText{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	color:#000000;
+	font-weight:bold;
+
+}
+
+.dvInnerHeader{
+	border-bottom:2px solid #999999;
+	padding:5px;
+	background-color:#fffffff;
+
+}
+
+.dvtSelectedCell {
+	border-left:2px solid #ddccaa;
+	border-top:3px solid #ddccaa;
+	border-right:2px solid #ddccaa;
+	padding-left:20px;
+	padding-right:20px;
+	background-color:white;
+	font-weight:bold;
+}
+
+.dvtUnSelectedCell {
+	border-left:2px solid #cacaca;
+	border-top:2px solid #cacaca;
+	border-right:2px solid #cacaca;
+	border-bottom:2px solid #ddccaa;
+	padding-left:20px;
+	padding-right:20px;
+	background-color:#efefef;
+	cursor:pointer;
+}
+
+.dvtTabCache {
+	border-bottom:2px solid #ddccaa;
+}
+
+.dvtContentSpace {
+	border-left:2px solid #ddccaa;
+	border-right:2px solid #ddccaa;
+	border-bottom:2px solid #ddccaa;
+	padding-left:0px;
+}
+
+.dvtCellLabel, .cellLabel {
+	background-color:#efefe2;
+	padding-right:10px;
+	padding-left:10px;
+	border-bottom:1px solid #dadacc ;
+	color:#333333;
+	white-space:nowrap;
+}
+
+.dvtCellInfo, .cellInfo {
+	padding-left:10px;
+	padding-right:10px;
+	border-bottom:1px solid #999;
+}
+
+.rightMailMerge {
+	border:1px solid #dddddd
+}
+
+.rightMailMergeHeader {
+	border-bottom:1px solid #dadaaa;
+	padding:5px;
+	background-color:#eaeacc;
+
+}
+
+.rightMailMergeContent {
+	padding:5px;
+	background-color:#fafafa;
+
+}
+
+.detailedViewHeader{
+	border-bottom:1px solid #ddddcc;
+	padding:5px; 
+	background-color:#ddddcc;
+
+}
+
+.detailedViewTextBox {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#ffffff;
+}
+
+.detailedViewTextBoxOn {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#ffffdd;
+}
+
+.detailedViewTextBoxDis {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #555555;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:90%;
+	background-color:#aaaaaa;
+}
+
+.detailedViewTextArea {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	color: #000000;
+	border:1px solid #bababa;
+	padding-left:5px;
+	width:95%;
+	height:100px;
+	background-color:#ffffff;
+	text-align:left;
+}
+
+
+/* Detailed View classes ends  ------------------------------------------- */
+
+
+.advSearch {
+	padding:10px;
+	border-left:1px solid #eaeaea; 
+	border-right:1px solid #eaeaea; 
+	border-bottom:1px solid #eaeaea; 	
+	overflow:auto;
+	width:600px;
+	height:150px;
+	background-color:#ffffef;
+
+}
+
+.searchAlph {
+	border:1px solid #dadada;
+	background-color:#ffffff;
+	cursor:pointer;
+	width:10px
+
+}
+.searchAlphselected {
+	border:1px solid #666666;
+	background-color:#bbbbbb;
+	cursor:pointer;
+	width:10px
+
+}
+
+.textbox {
+	border:1px solid #999999;
+	background-color:#ffffff;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	width:120px;
+	padding:2px;
+
+}
+
+
+
+.mx {
+}
+
+.calListTable td{
+	border-bottom:1px solid #efefef;
+	border-left:1px solid #efefef;
+}
+.calDIV {
+	width:100%;
+	border:1px solid #999999;
+	
+}
+
+.calDayHour {
+	border-top:1px solid #a8a591;
+	border-left:1px solid #a8a591;
+	border-bottom:1px solid #a8a591;
+	border-right:1px solid #a8a591;
+	background-color:#eae7da;
+}
+
+
+.calAddEvent {
+	position:absolute;
+	z-index:10000;
+	width:500px;
+	left:200px;
+	top:150px;
+	background-color:#ffffff;
+}
+
+
+
+.addEventInnerBox {
+	border:1px dotted #dadada;
+
+}
+
+
+.cellNormal {
+	border:0px;
+	background-color:#ffffff;
+}
+
+.EventToDo{
+
+}
+
+.thumbnail{
+    background-color:#ffffff;
+padding: 7px;
+border: 1px solid #ddd;
+float: left;
+	   margin-right: 10px;
+	   margin-bottom: 15px;
+}
+
+.padTab{
+    padding-top:0px;
+    padding-left:0px;
+    padding-left:10px;
+    padding-bottom:0px;
+    vertical-align:top;
+
+}
+
+#company{
+    position:relative;
+    width:100%;
+    height:200px;
+    display:block;
+    background-color:#FFFFFF;
+    white-space:nowrap;
+    overflow:auto;
+    border:1px solid #CCCCCC;
+}
+                               
+
+#user{position:relative;left:0px;top:0px;width:100%;display:block;}
+
+#communication{position:relative;left:0px;top:0px;width:100%;display:block;}
+#config{position:relative;left:0px;top:0px;width:100%;display:block;}
+
+#userTab{position:relative;left:0px;top:0px;width:100%;display:none;}
+
+
+#one{
+	position:relative;
+	display:block;
+	width:245px;
+}
+
+#mnuTab1{
+
+   position:relative;
+
+   overflow:auto;
+
+   width:100%;
+
+   display:none;
+
+}
+
+#mnuTab2{
+
+   position:relative;
+
+   overflow:auto;
+
+   width:100%;
+
+   display:none;
+
+}
+
+
+/* End of Settings */
+
+
+.bgwhite{
+	background-color: #FFFFFF;
+}
+.copy{
+	font-size:9px;
+	font-family: Verdana, Arial, Helvetica, Sans-serif;
+}
+
+#basicTab{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:block;
+}
+
+#moreTab{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:none;
+}
+
+#one{
+	position:relative;
+	display:block;
+	width:245px;
+}
+
+
+.dashHeading {
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:24px;
+	font-weight:bold;
+	color:#000;
+}
+
+.dashSelectBg{
+	background-image:url(images/dashSelectBg.gif);
+	background-repeat:repeat-x;
+}
+.dash_top{
+	background-image:url(images/dashTopBg.gif);
+	background-repeat:repeat-x;
+	height:63px;
+	vertical-align:middle;
+}
+
+.dash_border{
+	background-color:#e0dbb0;
+	padding:5px;
+}
+
+
+.dash_white{
+	background-color:#FFFFFF;
+	padding:5px 10px 5px 10px;
+}
+
+.dash_bdr_btm{
+	border-bottom:2px dotted #939271;
+}
+
+.dash_count{
+	font-size:36px;
+	font-weight:bold;
+	text-decoration:none;
+	color:#000000;
+	padding-left:10px;padding-right:10px;	
+}
+
+
+.dash_switch{
+	cursor:pointer;
+	width:26px;
+	height:26px;
+}
+
+.dash_row_sel{
+	background-image:url(images/dash_sel_chart.jpg);
+	background-repeat:no-repeat;
+	background-position:center;
+	width:26px;height:26px;
+	text-align:center;
+	vertical-align:middle;
+	font-weight:bold;
+	font-size:10px;
+	text-decoration:none;
+}
+
+.dash_row_unsel{
+	background-image:url(images/dash_unsel_chart.jpg);
+	background-repeat:no-repeat;
+	background-position:center;
+	width:26px;height:26px;
+	text-align:center;
+	vertical-align:middle;
+	font-weight:normal;
+	font-size:10px;
+	text-decoration:none;
+	cursor:pointer;
+}
+
+.dash_chart_btm{
+	border-bottom:2px solid #000000;
+}
+
+
+.dash_bottom{
+	background-image:url(images/dashBottomBg.gif);
+	background-repeat:repeat-x;
+	height:63px;
+	vertical-align:middle;
+}
+
+.dash_btm{
+	background-image:url(images/dash_btm_center.jpg);
+	background-repeat:repeat-x;
+	position:top;
+}
+
+
+/*  menu */
+
+
+
+ a.submenu{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:11px;
+	padding-top:5px;
+	padding-bottom:5px;
+	padding-left:10px;
+	border-bottom:1px solid #CCCCCC;
+	background-color:#ECECEC;
+	color:#000000;
+	text-align:left;
+	text-decoration:none;
+	display:block;
+}
+
+a.submenu:Hover{
+	background-color:#DDDDDD;
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:11px;
+	padding-top:5px;
+	padding-bottom:5px;
+	padding-left:10px;
+	border-bottom:1px solid #CCCCCC;
+	color:#000000;
+	text-align:left;
+	text-decoration:none;
+	display:block;
+}
+
+#mnuKey{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:11px;
+	background-color:#666666;
+	color:#FFFFFF;
+	text-decoration:none;
+	padding:5px;
+	font-weight:bold;
+	width:8px;
+	cursor:pointer;
+	vertical-align:top;
+	height:100px;
+	position:relative;
+	top:0px;
+	left:0px;
+}
+
+#slidemenu{
+	height:525px;
+	vertical-align:top;
+	width:100px;
+	background-color:#CCCCCC;
+	border-right:1px solid #CCCCCC;
+	opacity:.9;
+	display:none;
+}
+
+/* clock */
+
+.citystyle{
+	position:relative;
+	top:0px;
+	left:0px;
+	text-align:left;
+	
+}
+#theClockLayer{
+	position:relative;
+	height:180px;
+	left:20px;
+	text-align:center;
+}
+.handsanddotsstyle{
+	margin-top:10px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:2px;
+	height:2px;
+	font-size:2px;
+	background-color:#000000;
+}
+.facestyle{
+	margin-top:10px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:15px;
+	height:15px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+.datestyle{
+	margin-top:20px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:100px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+.ampmstyle{
+	margin-top:23px;
+	position:absolute;
+	top:0px;
+	left:0px;
+	width:20px;
+	text-align:center;
+	font-family:arial,sans-serif;
+	font-size:10px;
+	color:#000000;
+}
+
+#wclock{
+	position:absolute;
+	left:100px;
+	top:100px;
+	display:none;
+	background-color:#CCCCCC;
+	width:175px;
+}
+
+.leftFormBorder1 {
+	border: 1px solid #AFC8E4;
+	background-color: #FFFFFF;
+	opacity:.7;
+}
+
+
+
+
+/* Calculator */
+
+.calcResult {
+	width: 100%;
+	height: 25px;
+	background-color: #FFFFCC;/*CBDFD6*/
+	border-top: 1px solid #CCC;
+	border-left: 0px;
+	border-right: 1px solid #CCC;
+	border-bottom: 1px solid #CCC;
+	font-size: 10px;
+	text-align: right;
+}
+.calcMem {
+	width: 100%;
+	height: 25px;
+	border-top: 1px solid #CCC;
+	border-left: 1px solid #CCC;
+	border-right: 0px;
+	border-bottom: 1px solid #CCC;
+	background-color: #FFFFCC;/*CBDFD6*/
+	font-family: Arial;
+	font-size: 10px;
+	color: #BBB;
+	text-align: left;
+}
+.calcBlackBtn, .calcGreyBtn, .calcBigBtn, .calcCancBtn, .calcMemBtn, .calcBackBtn {
+	border: none;
+	height: 20px;
+	font-size: 11px;
+	color: #FFF;
+	text-align:center;
+}
+.calcBackBtn {
+	background: url(images/calc_back_btn.gif) no-repeat;
+	width:25px;
+}
+.calcBlackBtn {
+	background: url(images/calc_black_btn.gif) no-repeat;
+	width:25px;
+}
+.calcGreyBtn {
+	background: url(images/calc_grey_btn.gif) no-repeat;
+	width:25px;
+}
+.calcCancBtn {
+	background: url(images/calc_canc_btn.gif) no-repeat;
+	width:25px;
+	
+}
+.calcMemBtn {
+	background: url(images/calc_mem_btn.gif) no-repeat;
+	width:25px;
+	/*background-color: #CCC;*/
+}
+#calc{
+	position:absolute;
+	left:100px;
+	top:100px;
+	background-color:#FFFFFF;
+	width:185px;
+	border-bottom:2px solid #000000;
+	border-right:2px solid #666666;
+	border-left:2px solid #CCCCCC;
+	border-top:2px solid #CCCCCC;
+}
+
+/* RSS STYLES */
+
+.subHdr{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	background-image:url(images/rssHeader.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+}
+
+.delBg{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#FFFFFF;
+	background-image:url(images/rssdelete.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+}
+
+#rssScroll{
+	font-family:Arial, Helvetica, sans-serif	;
+	font-size:12px;
+	background-color:#FFFFFF;
+	width:100%;
+	height:175px;
+	overflow:auto;
+	border:0px solid #000000;
+}
+
+.rssTable{
+	width:100%;
+	border:0px solid #CCCCCC;
+}
+
+.rssTable tr th{
+	background-color:#ead9a2;
+	text-align:left;
+	border-bottom:1px solid #c2c7a2;
+	border-top:1px solid #FFFFFF;
+	color:#000000;
+	padding-left:5px;
+	padding-right:5px;
+	height:20px;
+}
+
+.rssTable tr td{
+	text-align:left;
+	border-bottom:1px dotted #dadada;
+	border-left:1px dotted #dadada;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	font-weight:normal;
+	white-space:nowrap;
+	padding:2px;
+	
+}
+
+.forwardBg{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#000000;
+	background-image:url(images/rssforward.gif);
+	background-position:top left;
+	background-repeat:repeat-x;
+	height:27px;
+	padding:0px 10px 0px 10px;
+	vertical-align:middle;
+	background-color:#D7D7D7;
+}
+
+
+/*  New Styles */
+
+
+
+.mnuTab{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	font-size:12px;
+	color:#000000;
+	width:100%;
+	border:0px solid #000000;
+}
+
+.mnuTab tr td{
+	border-bottom:1px solid #EBEBEB;
+	padding-left:5px;
+	vertical-align:middle;
+}
+
+/* profile */
+
+.prvPrfBigText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+.prvPrfTopBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfBottomBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfOutline {
+	border:1px solid #ebebeb;
+}
+
+
+
+.prvPrfTexture {
+	background:url(images/prvPrfTexture1.gif);
+
+}
+
+.prvPrfHoverOn {
+	background-color:#ffffef;
+	
+}
+
+/*  Organization */
+
+.orgTab{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	font-weight:normal;
+	color:#666666;
+	border:0px solid #9B9B9B;
+	border-collapse:collapse;
+	width:100%;
+}
+
+.orgTab tr th{
+	text-align:left;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:12px;
+	text-decoration:none;
+	font-weight:bold;
+	height:20px;
+	padding-left:5px;
+}
+
+.orgTab tr td{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-decoration:none;
+	font-weight:normal;
+	padding-left:5px;
+	height:20px;
+	border-bottom:1px solid #CCCCCC;
+	border-right:1px solid #CCCCCC;
+}
+
+
+/* Groups */
+
+
+.groupli{
+	margin-left:20px;
+	font-family:Arial, Helvetica, sans-serif;
+	font-weight:normal;
+	font-size:12px;
+	text-decoration:none;
+	color:#333333;
+	list-style-type:none;
+	text-align:left;
+}
+
+/* tree menu */
+
+/*Oraganization Edit Features */
+
+#orgLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:500px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	display:block;
+	position:absolute;
+	left:0px;
+	top:0px;
+}
+
+/*  Role */
+
+#roleLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:300px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	display:none;
+	position:absolute;
+}
+
+.classBtn{
+	font-family:Verdana, Arial, Helvetica, sans-serif;
+	text-decoration:none;
+	font-weight:normal;
+	font-size:10px;
+	background-color:#DBDBDB;
+	border-bottom:2px solid #999999;
+	border-right:2px solid #999999;
+	border-top:2px solid #F5F5F5;
+	border-left:2px solid #F5F5F5;
+	color:#000000;
+	text-align:center;
+	padding-top:3px;
+	padding-bottom:3px;
+}
+
+.txtBox{
+	width:85%;
+	border:1px solid #666666;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+}
+
+/*  IMPORT LEADS */
+
+.leadTable{
+	border:3px solid #CCCCCC;
+	border-collapse:collapse;
+}
+
+.leadTable tr td{
+/*	border:0px solid #CCCCCC;*/
+}
+
+.genHeaderGray{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+	line-height: 16px;
+	color: #888888;
+	font-weight:bold;
+}
+
+.genHeaderGrayBig{
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 18px;
+	line-height: 16px;
+	color: #888888;
+	font-weight:bold;
+}
+
+.importBox{
+	width:125px;
+	border:1px solid #666666;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+}
+
+
+.txtGreen{
+	color:green;
+}
+
+/* PICK LIST */
+ul li{
+	padding-bottom:2px;
+	padding-top:2px;
+}
+/* MY PREFERENCES */		
+
+
+/* CSS FOR REPORTS */
+
+.reportHdr{
+	background-color:#DDDDDD;
+	font-size:12px;
+	font-weight:bold;
+	vertical-align:middle;
+	text-align:left;
+	height:30px;
+	border-bottom:2px solid #959595;
+	color:#000000;
+	padding-left:10px;
+}
+
+#reportLay{
+	width:175px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+#locateMap{
+	width:120px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+
+a.reportMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:none;
+	display:block;
+	width:155px;
+	height:20px;
+	border-bottom:1px solid #E1E1E1;
+	padding-left:20px;
+	padding-top:3px;
+}
+
+a.reportMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+	display:block;
+	width:155px;
+	height:20px;
+	border-bottom:1px solid #E1E1E1;
+	padding-left:20px;
+	padding-top:3px;
+}	
+
+#Generate{
+	position:relative;
+	width:100%;
+	text-align:center;
+	display:none;
+}
+
+
+/* END OF REPORT */
+
+
+
+/* WEB MAIL */
+ a.webMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+}
+a.webMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+} 
+
+
+/*  END OF WEB MAIL */
+
+/* POPUP */
+
+ a.alpha{
+	font-size:11px;
+	color:gray;
+	text-decoration:none;
+	padding-Left:5px;
+	padding-right:5px;
+	border:1px dotted #CCCCCC;
+	background-color:#FFFFCC;
+}
+
+a.alpha:Hover{
+	font-size:11px;
+	color:gray;
+	text-decoration:underline;
+	padding-Left:5px;
+	padding-right:5px;
+	border:1px dotted #CCCCCC;
+	background-color:#FFFFCC;
+} 
+
+/* Home Page */
+.MatrixLayer{
+	border:2px solid #a3a295;
+	background-color:#FFFFFF;
+	width:29%;
+	position:relative;
+	visibility:visible;
+	margin:9px;
+	height:280px;
+}
+
+.fontBold{
+	font-size:13px;
+	color:#000000;
+	text-decoration:none;
+	font-weight:bold;
+}
+
+.style_Gray{
+	color:gray;
+}
+	
+/* End of Home Page */
+
+/* All Menu */
+#allMenu{
+    width:500px;
+    border:4px solid #C3C2a1;
+    left:300px;
+    top:100px;
+    position:absolute;
+    z-index:1000001;
+    display:none;
+    padding:10px;
+    background:#ffffff url(images/layerPopUpBg.gif);
+}
+
+
+.allMnuTable{
+    width:100%;
+    background-color:#FFFFFF;
+}
+
+.allMnuHandle td{
+    height:20px;
+    color:#FFFFFF;
+    font-family:Arial, Helvetica, sans-serif;
+    font-size:12px;
+    font-weight:bold;
+    text-decoration:none;
+    background-color:#000066;
+    cursor:move;
+    padding:2px;
+    border-bottom:2px solid #666666;
+}
+
+.allMnuHdr{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-weight:Bold;
+    font-size:11px;
+    text-decoration:none;
+    display:block;
+    background-color:#FFFFFF;
+    color:#737251;
+    padding-top:5px;
+    padding-bottom:5px;
+}
+
+a.allMnu{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-size:10px;
+    text-decoration:none;
+    font-weight:normal;
+    display:block;
+    width:125px;
+    height:15px;
+    padding-left:5px;
+    padding-top:0px;
+    padding-bottom:0px;
+    background-color:#FFFFFF;
+    border:1px solid #FFFFFF;
+    color:#000033;
+    margin-left:20px;
+}
+
+a.allMnu:Hover{
+    font-family:Verdana, Arial, Helvetica, sans-serif;
+    font-size:10px;
+    text-decoration:none;
+    font-weight:normal;
+    display:block;
+    width:125px;
+    height:15px;
+    padding-left:5px;
+    padding-top:0px;
+    padding-bottom:0px;
+    background-color:#dad7b5;
+    color:#333;
+}
+/* End Of All Menu */
+
+
+
+/* Calendar */
+.calHdr{
+	background-image:url(images/mailSubHeaderBg.gif); 
+	background-repeat:repeat-x;
+	background-position:left top;
+	
+}
+
+.calSel{
+	background-image:url(images/dashSelectBg.gif);
+	background-repeat:repeat-x;
+	text-align:center;
+	color:#FFFFFF;
+	font-weight:bold;
+	width:8%;
+}
+
+.calAddButton {
+	border: 1px solid #666666;
+	background:#D6D2AB url(images/calAddButtonBg.gif) repeat-x;
+	cursor:pointer;
+	height:20px;
+	
+
+}
+.calInnerBorder {
+	border-left:1px solid #d6d2ab;
+	border-right:1px solid #d6d2ab;
+	border-bottom:1px solid #d6d2ab;
+}
+
+.calBorder {
+	border-left: 1px solid #939271; 
+	border-right: 1px solid #939271; 
+	border-bottom: 1px solid #939271; 
+	background:#fefefe url(images/layerPopupBg.gif);
+
+}
+
+.calTopRight {
+	border-right: 1px solid #939271; 
+}
+
+
+.calUnSel{
+	color:#000000;
+	font-weight:normal;
+	text-align:center;
+	width:8%;
+}
+
+
+a.calMnu{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:none;
+	display:block;
+	height:20px;
+	padding-left:5px;
+	padding-top:3px;
+}	
+
+a.calMnu:Hover{
+	font-size:11px;
+	color:#0070BA;
+	text-decoration:underline;
+	display:block;
+	height:20px;
+	padding-left:5px;
+	padding-top:3px;
+}
+.bgwhite{
+	background-color: #FFFFFF;
+}
+.copy{
+	font-size:9px;
+	font-family: Verdana, Arial, Helvetica, Sans-serif;
+}
+
+#mnuTab{
+	position:relative;
+	width:100%;
+	display:block;
+}
+
+#mnuTab2{
+	position:relative;
+	overflow:auto;
+	width:100%;
+	display:none;
+}
+.style1 {color: #FF0000}
+
+.event{
+	background-color:#D3EAF0;
+	border:1px solid #999999;
+	text-align:left;
+	width:100%;
+	position:relative;
+	left:0px;
+	top:0px;
+	vertical-align:middle;
+	padding:1px;
+}
+
+#hrView{
+	display:block;
+}
+.calendarNav{
+	font-size:12px;
+	color:#FFFFFF;
+	white-space:nowrap;
+	text-align:center;
+	font-weight:bold;
+	padding-left:10px;
+	padding-right:10px;
+	background-image:url(images/cal_nav.gif);
+	background-repeat:repeat-x;
+}
+
+#addEventDropDown{
+	position:absolute;
+	display:none;
+	width:150px;
+	border:1px solid #666666;
+	left:0px;
+	top:0px;
+	overflow:visible;
+	z-index:5000;
+}
+
+.calAction{
+	width:175px;
+	background-color:#CCCCCC;
+	border:1px solid #DDDDDD;
+	padding-top:5px;
+	position:absolute;
+	display:none;
+	z-index:2000;
+}
+
+.calSettings{
+	position:absolute;
+	z-index:20000;
+	width:500px;
+	left:200px;
+	top:150px;
+	background-color:#ffffff;
+}
+
+.outer{
+	border-bottom:1px solid #CCCCCC;
+	border-left:1px solid #CCCCCC;
+	border-right:1px solid #CCCCCC;
+}
+
+.calTxt{
+	width:50%;
+	border:1px solid #CCCCCC;
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	padding-left:5px;
+}
+
+#leadLay{
+	position:relative;
+	width:100%;
+	float:left;
+	visibility:hidden;
+	padding:5px;
+	z-index:10000;
+}
+									
+/* End of Calendar */
+
+/* Cal Year View */
+
+
+.eventDay{
+	background-color:#FF9966;
+	font-weight:bold;
+}
+
+.currDay{
+	background-color:#006600;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+.currDay a{
+	color:#FFFFFF;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+
+/* End of Cal Year View */
+
+/* Level 2 Menu Selected*/
+
+level2Sel{
+	color:#000000;
+	font-weight:bold;
+	text-decoration:underline;
+}
+
+#DeleteLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:300px;
+	border:3px solid #CCCCCC;
+	background-color:#FFFFFF;
+	padding:5px;
+}
+
+#CurrencyDeleteLay{
+	font-family:Arial, Helvetica, sans-serif;
+	font-size:11px;
+	text-align:left;
+	width:350px;
+}
+
+
+/* For Report HTML Generation*/
+.rptCellLabel {
+    background-color:#f6f6f6;
+    padding-right:10px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom:1px solid #eaeaea;
+    color:#737373;
+    font-weight: bold;
+    white-space:nowrap;
+}
+.rptTable {
+    border-left: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+    border-top: 1px solid #DDDDDD;
+}
+.rptTitle, .rptHead, .rptData, .rptGrpHead{
+    font-family: Verdana, Arial, Helvetica, Sans-serif;
+    font-size: 11px;
+	text-align:left;
+    font-weight: normal;
+	height: 20px;
+	padding: 4px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+	background: #DDDDDD;
+}
+.rptGrp1Total, .rptGrp2Total, .rptTotal {
+    font-family: Verdana, Arial, Helvetica, Sans-serif;
+    font-size: 11px;
+	text-align:center;
+    font-weight: normal;
+    background: #FFF;
+	height: 20px;
+	padding: 4px;
+    border-right: 1px solid #DDDDDD;
+    border-bottom: 1px solid #DDDDDD;
+}
+
+.rptGrpHead {
+	background: #FFF;
+    border-bottom: 1px solid #FFF;
+    border-top: 1px solid #DDDDDD;
+    font-weight: normal;
+}
+
+.rptData {
+            background: #FFF;
+            font-weight: normal;
+}
+.rptEmptyGrp {
+            background: #FFF;
+            border-right: 1px solid #DDDDDD;
+}
+.statechange
+{
+    position:absolute;
+    visibility:hidden;
+    left:10px;
+    top:20px;
+    width:300px;
+    border:3px solid #CCCCCC;
+    background-color:#FFFFFF;
+}
+#PopupLay{
+    position:absolute;
+    font-family:Arial, Helvetica, sans-serif;
+    font-size:11px;
+    text-align:left;
+    width:500px;
+    border:3px solid #CCCCCC;
+    background-color:#FFFFFF;
+    padding:5px;
+    display:none;
+    left:100px;
+    top:100px;
+}
+
+#folderLay{
+    width:175px;
+    background-color:#CCCCCC;
+    border:1px solid #DDDDDD;
+    padding-top:5px;
+    position:absolute;
+    display:none;
+}
+
+/* Css for quick Create */
+
+
+.qcTransport{
+	    background-color:#d3d2c1;
+
+}
+
+#role_popup{
+        position:relative;
+        left:0px;
+        top:0px;
+        width:95%;
+        height:300px;
+        overflow:auto;
+        border:1px solid #999999;
+        text-align:left;
+        background-color:#FFFFFF;
+    }
+.unread_email {
+	font-weight:bold;
+        background-color:#00FF00;
+}
+
+
+.qualify_email {
+	                   font-weight:bold;
+	                   background-color:#FFA500;
+	
+          }
+
+
+.delete_email {
+	font-weight:bold;
+        background-color:#FF5151;
+
+}
+
+.mailSelected {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+.mailSelected_select {
+	background:#E1DCB3 url(images/tabSelectedBg.gif) repeat-x;
+	background-color:#1F5EFF;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-weight:bold;
+	font-size: 11px;
+	padding-left:10px;
+	padding-right:10px;
+	padding-top:2px;
+	padding-bottom:2px;
+	
+}
+								    
+/* MY SITES */
+
+.unread_email:hover {
+	font-weight:bold;
+}
+
+
+
+.tagCloud {
+    border:1px solid #737373;
+}
+
+   
+.tagCloudTopBg {
+    background: url(images/tagCloudBg.gif) repeat-x;
+   
+}
+
+.tagCloudDisplay {
+    background-color:#e5e5e5;
+    padding:10px;
+    font-family: Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    line-height: 14px;
+    color: #000000;
+
+}
+
+.h2 {
+
+	font-size:18px;
+	line-height:20px;
+
+}
+
+.gray {
+
+	color:gray;
+}
+
+
+ul {
+	list-style:circle;
+	line-height:20px;
+	padding-left:5px;
+	margin-left:20px;
+	font-weight:normal;
+
+}
+
+	
+
+
+
+.tagCloudTopBg {
+	background-image: url(images/tagCloudBg.gif);
+	background-repeat: repeat-x;	
+}
+
+.tagCloudDisplay {
+	background-color:#e5e5e5;
+	padding:5px;
+}
+	
+	
+	
+
+
+.heading2 {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 16px;
+	line-height: 16px;
+	font-weight:bold;
+	color: #000000;
+}
+
+
+
+.settingsUI {
+	
+	text-align:left;
+	background-color:#d3d4c2;
+	border:2px solid #999a77;
+
+}
+
+
+.settingsTabHeader {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 12px;
+	line-height:25px;
+	font-weight:bold;
+	color:#000000;
+	background-image: url(images/mailSubHeaderBg.gif);
+	background-repeat: repeat-x;
+	padding-left:10px;
+	padding-right:10px;
+	
+
+}
+
+.settingsTabList {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:20px;
+	font-weight:normal;
+	color:#000000;
+	background-color:#efede2;
+	padding-left:30px;
+	border-top:1px solid #eaeaea;
+	border-bottom:1px solid #d3d1a3;
+}
+.settingsTabSelected {
+	text-align:left;
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:20px;
+	font-weight:bold;
+	color:#000000;
+	background-color:#ffffff;
+	padding-left:30px;
+}
+.settingsSelectedUI {
+	padding:10px;
+	background:url(images/settingsSelUIBg.gif) repeat-x;
+	background-color:#ffffff;
+}
+.settingsIconDisplay {
+	font-family:  Arial, Helvetica, sans-serif;
+	font-size: 11px;
+	line-height:14px;
+	padding:10px;
+
+	color:#000000;
+	background-color:#ffffff;
+	padding-left:10px;
+}
+.settingsSelUITopLine{
+	border-bottom:2px dotted #999999;
+
+}
+
+.tableHeading{
+	background-color:#ffffff;
+	border-bottom:2px solid #5a5b41;
+}
+.colHeader{
+	background-color:#EFECD1;
+	border-left:1px solid #eaeaea;
+	border-top:1px solid #eaeaea;
+	border-right:1px solid #999a77;
+	border-bottom:1px solid #999a77;
+	font-weight:bold;
+
+}
+.cellLabel {
+	background-color:#eaebd9;
+	border-top:1px solid #efefef;
+	border-bottom:1px solid #dadada;
+	color:#555555;
+
+}
+.cellText {
+	color:#333333;
+	border-bottom:1px solid #dadada;
+} 
+
+.listTable{
+	border-left:1px solid #cccccc;
+	border-right:1px solid #cccccc;
+	border-bottom:1px solid #cccccc;
+
+}
+
+.listTableRow{
+	border-bottom:1px solid #eaeaea;
+	border-right	:1px solid #eaeaea;
+	border-bottom:1px solid #eaeaea;
+	border-bottom:1px solid #eaeaea;
+}
+.listRow{
+	border-bottom:2px solid #eaeaea;
+
+}
+
+.listTableTopButtons{
+	background-color:#fafbe3;
+	
+}
+
+
+/*  Buttons */
+.crmButton{
+	
+	border-left:1px solid #ffffff;
+	border-top:1px solid #ffffff;
+	border-right:1px solid #555555;
+	border-bottom:1px solid #555555;
+}
+
+.create{
+	background-color:#ddccaa;
+	color:#333333;
+	font-weight:bold;
+}
+.delete {
+	background-color:#8F8C74;
+	color:#ffffff;
+	font-weight:bold;
+}
+.edit {
+	background-color:#ddccaa;
+	color:#333333;
+	font-weight:bold;
+}
+.save{
+	background-color:#ddccaa;
+	color:#333333;
+	font-weight:bold;
+}
+.cancel {
+	background-color:#8F8C74;
+	color:#ffffff;
+	font-weight:bold;
+}
+
+.inactive{
+color:#999999;
+}
+
+.active{
+color:#229922;
+
+}
+
+/* Buttons ends */
+
+
+
+textarea {
+	width:95%;
+	height:70px;
+	border:1px solid #dadada;
+}
+.treeTable1{
+	padding:0px;
+}
+
+.prvPrfBigText {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 14px;
+}
+
+.prvPrfTopBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfBottomBg {
+	background-color:#ebebeb;
+}
+
+.prvPrfOutline {
+	border:1px solid #ebebeb;
+}
+
+
+
+.prvPrfTexture {
+	background:url(images/prvPrfTexture1.gif);
+
+}
+
+
+.prvPrfHoverOn {
+	background-color:#ffffef;
+	
+}
+
+
+.cellBottomDotLine {
+	border-bottom-width: 2px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	background-color:#ededed;
+}
+.crmFormList{
+	border:1px solid #cccccc;
+	width:90%;
+	height:120px;
+
+}
+.cellBottomDotLinePlain {
+	border-bottom-width: 2px;
+	border-bottom-style: dotted;
+	border-bottom-color: #CCCCCC;
+	
+}
+
+.thickBorder {
+	border: 2px solid #999999;
+}
+
+.trackerHeading {
+	background-color:#efefef;
+}
+.trackerListBullet {
+	border-right:1px dotted #cccccc;
+	background-color:#f9f9f9;
+}
+.trackerList {
+	border-bottom:1px solid #eeeeee;
+}
+
+/* Table Definitions */
+.crmTable {
+	border:1px solid #dadada;
+}
+
+.crmTableRow {
+	border-bottom:1px dotted #dadada;
+	border-right:1px dotted #dadada
+}
+
+
+/* Inventory */
+
+.lineOnTop {
+	border-top:1px solid #999999;
+}
+
+.discountUI{
+	border:3px solid #CCCCCC;
+	width:250px;
+	padding:5px;
+	position:absolute;
+	background-color:#FFFFFF;
+	display:none;
+}
+
+.TaxShow{
+	display:inline-table;
+}
+
+.TaxHide{
+	display:none;
+}
+
+/* Inventory */
+
+
+/* Email Client Classes ++++++++++++++++++++++ */
+
+.emailSelected{
+	background-color:#eaeaea;
+	color:#000000;
+	font-size:bold;
+}
+
+
+.mailClient{
+	border:2px solid #999a77;
+}
+
+.mailClientBg {
+	background-color:#e3e1cd;
+}
+
+.mailSubHeader {
+	background:#e0dbb0 url(images/mailSubHeaderBg.gif) repeat-x;
+	padding:4px;
+}
+
+
+.mailClientWriteEmailHeader{
+	font-family:arial, helvetica, sans-serif;
+	font-size:20px;
+	line-height:24px;
+	font-weight:bold;
+	background:#e0dbb0 url(images/mailSubHeaderBg.gif) repeat-x;
+	padding:10px;
+	border-left:1px solid #eaeaea;
+	border-top:1px solid #eaeaea;
+	border-right:1px solid #939271;
+	border-left:1px solid #939271;;
+	
+	
+}
+.mailClientCSSButton {
+	border-left:1px solid #fff;
+	border-top:1px solid #fff;
+	border-right:1px solid #333;
+	border-bottom:1px solid #333;
+	padding:2px;
+	background-color:#c3c2b1;
+	
+}
+
+/* Email Client Classes ends ------------------------------------ */
+
+
+
+/* Layer Popup */
+.layerPopup {
+	border:3px solid #939271;
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+	position:absolute;
+}
+
+.layerPopupHeading {
+	font-family:arial, helvetica, sans-serif;
+	font-size:16px;
+	line-height:24px;
+	font-weight:bold;
+}
+.layerHeadingULine {
+	border-bottom:2px solid #717351;
+}
+.layerPopupTransport {
+	background-color:#DFDFC2;
+
+}
+.homePageSeperator {
+	border-right:1px dotted #d3d2c1;
+}
+.homePageMatrixHdr {
+	border-bottom:1px solid #d3d2c1;
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+}
+
+.reportsListTable {
+	background-color:white;
+	border-left:1px solid #a3a29f;
+	border-right:1px solid #a3a29f;
+	border-bottom:1px solid #a3a29f;
+}
+
+.reportGenerateTable{
+	background-image:url(images/searchUIBg.gif);
+	border-left:2px dotted #a3a29a;
+	border-right:2px dotted #a3a29a;
+	border-bottom:2px dotted #a3a29a;
+}
+.reportCreateBottom{
+	background-color:#939271;
+	border-bottom:2px solid #737251;
+
+}
+.importLeadUI{
+	
+	background:#fffff5 url(images/layerPopupBg.gif) ;
+}
+
+a.customMnu{
+	padding-left:30px;
+	padding-top:5px;
+	padding-bottom:5px;
+	display:block;
+	background-repeat:no-repeat;
+	background-position:left;
+	width:155px;
+	color:#000000;
+	text-decoration:none;
+}
+
+a.customMnuSelected{
+	padding-left:30px;
+	padding-top:5px;
+	padding-bottom:5px;
+	display:block;
+	background-repeat:no-repeat;
+	background-position:left;
+	width:155px;
+	background-color:#0099FF;
+	color:#FFFFFF;
+	text-decoration:none;
+}
+
+
+/* Drop Down Menu */
+.drop_mnu{
+    position:absolute;
+    left:0px;
+    top:0px;
+    z-index:1000000001;
+    border-left:1px solid #E7E3C0;
+    border-right:1px solid #E7E3C0;
+    border-bottom:1px solid #E7E3C0;
+    width:150px;
+    display:none;
+    padding:0px;
+    text-align:left;
+    overflow-x:hidden;
+    overflow-y:hidden;
+    background-color:#F6F4E7;
+}
+a.drop_down{
+    width:150px;
+    text-align:left;
+    font-family:  Arial, Helvetica, sans-serif;
+    font-size: 11px;
+    line-height:20px;
+    font-weight:normal;
+    color:#000000;
+    background-color:#F6F4E7;
+    padding:2px 5px 2px 5px;
+    border-top:1px solid #fafafa;
+    border-bottom:1px solid #d3d3c3;
+    display:block;
+}
+
+a.drop_down:Hover{
+    padding:2px 5px 2px 5px;
+    width:150px;
+    text-align:left;
+    color:#FFFFFF;
+    font-weight:normal;
+    text-decoration:underline;
+    background-color:#D7D5BE;
+}
+
+.bgwhite{
+	background-color:white;
+}
+
+/* Recalculate Disabling Window */
+
+.veil{
+   background: url(images/searchUIBg.gif) ;
+    height: 100%;
+    width: 100%;
+    top: 0px;
+    left: 0px;
+    overflow: hidden;
+    z-index: 10000;
+    Filter: Alpha(opacity = 70);
+    -moz-opacity: 0.7;
+    text-align: center;
+    vertical-align: middle;
+    position: absolute;
+}
+
+.veil_new{
+   background: url(images/searchUIBg.gif) ;
+    height: 100%;
+    width: 100%;
+    top: 0px;
+    left: 0px;
+    overflow: hidden;
+    z-index: 50000;
+    Filter: Alpha(opacity = 70);
+    -moz-opacity: 0.7;
+    text-align: center;
+    vertical-align: middle;
+    position: absolute;
+}
+
+.optioncontainer{
+    vertical-align: middle;   
+    height: 100%;
+    width: 100%;   
+    position: absolute;
+    z-index: 90000;   
+}
+
+
+.options{
+    	vertical-align: middle;   
+	margin-left: 25%;
+	margin-top: 16%;
+	color: #FFFFFF;
+	width:650px;
+	background-color: Black;
+	border: 2px solid #222;	
+    	position: relative;
+	text-align: left;
+    	z-index: 80000;   
+}
+
+.options h2{
+	color: White;
+	font-family: Verdana, Arial, Helvetica, sans-serif;
+	border-bottom: 1px solid #373D4C;
+	margin: 0;
+	font-weight: normal;
+}
+.groupname{
+                width:125px;
+          }
+
+
+.winmarkModulesdef{
+   background-image:url(images/woodspiceHomeMark.gif);
+   background-position:top;
+   background-repeat:repeat-x;
+}
+
+/* Recalculate Disable Ends */

Modified: vtigercrm/branches/5.1_jens/user_privileges/default_module_view.php
==============================================================================
--- vtigercrm/branches/5.1_jens/user_privileges/default_module_view.php (original)
+++ vtigercrm/branches/5.1_jens/user_privileges/default_module_view.php Mon Apr 16 12:27:44 2007
@@ -1,14 +1,14 @@
-<?php
-/*********************************************************************************
-  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
-   * ("License"); You may not use this file except in compliance with the License
-   * The Original Code is:  vtiger CRM Open Source
-   * The Initial Developer of the Original Code is vtiger.
-   * Portions created by vtiger are Copyright (C) vtiger.
-   * All Rights Reserved.
-  *
-  ********************************************************************************/
-
+<?php
+/*********************************************************************************
+  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+   * ("License"); You may not use this file except in compliance with the License
+   * The Original Code is:  vtiger CRM Open Source
+   * The Initial Developer of the Original Code is vtiger.
+   * Portions created by vtiger are Copyright (C) vtiger.
+   * All Rights Reserved.
+  *
+  ********************************************************************************/
+
 $singlepane_view = 'false';
-
-?>
+
+?>

Modified: vtigercrm/branches/5.1_jens/vtigerversion.php
==============================================================================
--- vtigercrm/branches/5.1_jens/vtigerversion.php (original)
+++ vtigercrm/branches/5.1_jens/vtigerversion.php Mon Apr 16 12:27:44 2007
@@ -10,5 +10,6 @@
  ********************************************************************************/
 $patch_version = '';
 $modified_database = '';
-$vtiger_current_version = '5.0.2';
+$vtiger_current_version = '5.0.3';
+$_SESSION['vtiger_version'] = $vtiger_current_version;
 ?>





More information about the vtigercrm-commits mailing list