function vtEditExpressions($adb, $appStrings, $current_language, $theme, $formodule = '') { $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $smarty = new vtigerCRM_Smarty(); $smarty->assign('APP', $appStrings); $mod = array_merge(return_module_language($current_language, 'FieldFormulas'), return_module_language($current_language, 'Settings')); $jsStrings = array('NEED_TO_ADD_A' => $mod['NEED_TO_ADD_A'], 'CUSTOM_FIELD' => $mod['LBL_CUSTOM_FIELD'], 'LBL_USE_FUNCTION_DASHDASH' => $mod['LBL_USE_FUNCTION_DASHDASH'], 'LBL_USE_FIELD_VALUE_DASHDASH' => $mod['LBL_USE_FIELD_VALUE_DASHDASH'], 'LBL_DELETE_EXPRESSION_CONFIRM' => $mod['LBL_DELETE_EXPRESSION_CONFIRM']); $smarty->assign("JS_STRINGS", Zend_Json::encode($jsStrings)); $smarty->assign("MOD", $mod); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE_NAME", 'FieldFormulas'); $smarty->assign("PAGE_NAME", 'LBL_FIELDFORMULAS'); $smarty->assign("PAGE_TITLE", 'LBL_FIELDFORMULAS'); $smarty->assign("PAGE_DESC", 'LBL_FIELDFORMULAS_DESCRIPTION'); $smarty->assign("FORMODULE", $formodule); if (file_exists("modules/{$formodule}/{$formodule}.php")) { $focus = CRMEntity::getInstance($formodule); $validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, getTabid($formodule))); $smarty->assign('VALIDATION_DATA_FIELDNAME', $validationArray['fieldname']); $smarty->assign('VALIDATION_DATA_FIELDDATATYPE', $validationArray['datatype']); $smarty->assign('VALIDATION_DATA_FIELDLABEL', $validationArray['fieldlabel']); } $smarty->display(vtlib_getModuleTemplate('FieldFormulas', 'EditExpressions.tpl')); }
$smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action'])); } else { $smarty->assign("RETURN_ACTION", "index"); } if (isset($_REQUEST['return_id'])) { $smarty->assign("RETURN_ID", vtlib_purify($_REQUEST['return_id'])); } if (isset($_REQUEST['return_viewname'])) { $smarty->assign("RETURN_VIEWNAME", vtlib_purify($_REQUEST['return_viewname'])); } $smarty->assign("UPLOADSIZE", $upload_maxsize / 1000000); //Convert to MB $smarty->assign("UPLOAD_MAXSIZE", $upload_maxsize); // Field Validation Information $tabid = getTabid($currentModule); $validationData = getDBValidationData($focus->tab_name, $tabid); $validationArray = split_validationdataArray($validationData); $smarty->assign("VALIDATION_DATA_FIELDNAME", $validationArray['fieldname']); $smarty->assign("VALIDATION_DATA_FIELDDATATYPE", $validationArray['datatype']); $smarty->assign("VALIDATION_DATA_FIELDLABEL", $validationArray['fieldlabel']); // In case you have a date field $smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']); $smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT'])); // Module Sequence Numbering $mod_seq_field = getModuleSequenceField($currentModule); if ($focus->mode != 'edit' && $mod_seq_field != null) { $autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE'); $mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1", array($currentModule)); $mod_seq_prefix = $adb->query_result($mod_seq_string, 0, 'prefix'); $mod_seq_no = $adb->query_result($mod_seq_string, 0, 'cur_id'); if ($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix . $mod_seq_no)) {
$mod_seq_field = getModuleSequenceField($currentModule); if ($mod_seq_field != null) { $mod_seq_id = $focus->column_fields[$mod_seq_field['name']]; } else { $mod_seq_id = $focus->id; } $smarty->assign('MOD_SEQ_ID', $mod_seq_id); //Added to display the Tax informations $tax_details = getTaxDetailsForProduct($focus->id); for ($i = 0; $i < count($tax_details); $i++) { $tax_details[$i]['percentage'] = getProductTaxPercentage($tax_details[$i]['taxname'], $focus->id); } $smarty->assign("TAX_DETAILS", $tax_details); $price_details = getPriceDetailsForProduct($focus->id, $focus->unit_price, 'available_associated', $currentModule); $smarty->assign('PRICE_DETAILS', $price_details); $validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, $tabid)); $smarty->assign('VALIDATION_DATA_FIELDNAME', $validationArray['fieldname']); $smarty->assign('VALIDATION_DATA_FIELDDATATYPE', $validationArray['datatype']); $smarty->assign('VALIDATION_DATA_FIELDLABEL', $validationArray['fieldlabel']); $smarty->assign('EDIT_PERMISSION', isPermitted($currentModule, 'EditView', $record)); $smarty->assign('CHECK', $tool_buttons); if (PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule . '_listquery'])) { $recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id); VT_detailViewNavigation($smarty, $recordNavigationInfo, $focus->id); } $smarty->assign('IS_REL_LIST', isPresentRelatedLists($currentModule)); $smarty->assign('SinglePane_View', $singlepane_view); if ($singlepane_view == 'true') { $related_array = getRelatedLists($currentModule, $focus); $smarty->assign("RELATEDLISTS", $related_array); require_once 'include/ListView/RelatedListViewSession.php';
$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->getHomeStuffOrder($focus->id)); //Added to provide User based Tagcloud $smarty->assign("TAGCLOUDVIEW", getTagCloudView($focus->id)); $smarty->assign("BLOCKS", getBlocks($currentModule, "detail_view", '', $focus->column_fields)); $smarty->assign("USERNAME", $focus->last_name . ' ' . $focus->first_name); $smarty->assign("HOUR_FORMAT", $focus->hour_format); $smarty->assign("START_HOUR", $focus->start_hour); $_SESSION['Users_FORM_TOKEN'] = rand(5, 2000) * rand(2, 7);
public function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $record = $request->get('record'); if (!empty($record) && $request->get('isDuplicate') == true) { $recordModel = $this->record ? $this->record : Vtiger_Record_Model::getInstanceById($record, $moduleName); $viewer->assign('MODE', ''); //While Duplicating record, If the related record is deleted then we are removing related record info in record model $mandatoryFieldModels = $recordModel->getModule()->getMandatoryFieldModels(); foreach ($mandatoryFieldModels as $fieldModel) { if ($fieldModel->isReferenceField()) { $fieldName = $fieldModel->get('name'); if (Vtiger_Util_Helper::checkRecordExistance($recordModel->get($fieldName))) { $recordModel->set($fieldName, ''); } } } } else { if (!empty($record)) { $recordModel = $this->record ? $this->record : Vtiger_Record_Model::getInstanceById($record, $moduleName); $viewer->assign('RECORD_ID', $record); $viewer->assign('MODE', 'edit'); } else { $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName); $viewer->assign('MODE', ''); } } if (!$this->record) { $this->record = $recordModel; } $moduleModel = $recordModel->getModule(); $fieldList = $moduleModel->getFields(); $requestFieldList = array_intersect_key($request->getAll(), $fieldList); foreach ($requestFieldList as $fieldName => $fieldValue) { $fieldModel = $fieldList[$fieldName]; $specialField = false; // We collate date and time part together in the EditView UI handling // so a bit of special treatment is required if we come from QuickCreate if ($moduleName == 'Calendar' && empty($record) && $fieldName == 'time_start' && !empty($fieldValue)) { $specialField = true; // Convert the incoming user-picked time to GMT time // which will get re-translated based on user-time zone on EditForm $fieldValue = DateTimeField::convertToDBTimeZone($fieldValue)->format("H:i"); } if ($moduleName == 'Calendar' && empty($record) && $fieldName == 'date_start' && !empty($fieldValue)) { $startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($requestFieldList['time_start']); $startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($fieldValue . " " . $startTime); list($startDate, $startTime) = explode(' ', $startDateTime); $fieldValue = Vtiger_Date_UIType::getDisplayDateValue($startDate); } if ($fieldModel->isEditable() || $specialField) { $recordModel->set($fieldName, $fieldModel->getDBInsertValue($fieldValue)); } } // SalesPlatform.ru begin Unifying method for EditView preparing $recordModel = prepareEditView($recordModel, $_REQUEST, $viewer); // SalesPlatform.ru end // SalesPlatform.ru begin Set company if ($request->get('relationOperation')) { $sourceRecordModel = Vtiger_Record_Model::getInstanceById($request->get('sourceRecord')); if ($sourceRecordModel->get('spcompany') != null && $sourceRecordModel->get('spcompany') != '') { if ($recordModel->getField('spcompany')) { $recordModel->set('spcompany', $sourceRecordModel->get('spcompany')); } } } // SalesPlatform.ru end $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDIT); $picklistDependencyDatasource = Vtiger_DependencyPicklist::getPicklistDependencyDatasource($moduleName); // SalesPlatform.ru begin Field Validation Information $tabid = getTabid($moduleName); $validationData = getDBValidationData($recordModel->get('tab_name'), $tabid); $validationArray = split_validationdataArray($validationData); $viewer->assign("VALIDATION_DATA_FIELDNAME", $validationArray['fieldname']); $viewer->assign("VALIDATION_DATA_FIELDDATATYPE", $validationArray['datatype']); $viewer->assign("VALIDATION_DATA_FIELDLABEL", $validationArray['fieldlabel']); $viewer->assign('ID', $record); // SalesPlatform.ru end $viewer->assign('PICKIST_DEPENDENCY_DATASOURCE', Zend_Json::encode($picklistDependencyDatasource)); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure()); $viewer->assign('MODULE', $moduleName); $viewer->assign('CURRENTDATE', date('Y-n-j')); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $isRelationOperation = $request->get('relationOperation'); //if it is relation edit $viewer->assign('IS_RELATION_OPERATION', $isRelationOperation); if ($isRelationOperation) { $viewer->assign('SOURCE_MODULE', $request->get('sourceModule')); $viewer->assign('SOURCE_RECORD', $request->get('sourceRecord')); } $viewer->assign('MAX_UPLOAD_LIMIT_MB', Vtiger_Util_Helper::getMaxUploadSize()); $viewer->assign('MAX_UPLOAD_LIMIT', vglobal('upload_maxsize')); // SalesPlatform.ru begin enable/disable button Import $instance = Vtiger_Module::getInstance('SPSocialConnector'); $fl_import_button = true; if (empty($record) || $instance->presence == 1) { $fl_import_button = false; } $viewer->assign("FL_IMPORT_BUTTON", $fl_import_button); // SalesPlatform.ru end $viewer->view('EditView.tpl', $moduleName); }
public function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $record = $request->get('record'); $sourceRecord = $request->get('sourceRecord'); $sourceModule = $request->get('sourceModule'); if (!empty($record) && $request->get('isDuplicate') == true) { $recordModel = Inventory_Record_Model::getInstanceById($record, $moduleName); $currencyInfo = $recordModel->getCurrencyInfo(); $taxes = $recordModel->getProductTaxes(); $shippingTaxes = $recordModel->getShippingTaxes(); $relatedProducts = $recordModel->getProducts(); $viewer->assign('MODE', ''); //While Duplicating record, If the related record is deleted then we are removing related record info in record model $mandatoryFieldModels = $recordModel->getModule()->getMandatoryFieldModels(); foreach ($mandatoryFieldModels as $fieldModel) { if ($fieldModel->isReferenceField()) { $fieldName = $fieldModel->get('name'); if (Vtiger_Util_Helper::checkRecordExistance($recordModel->get($fieldName))) { $recordModel->set($fieldName, ''); } } } } elseif (!empty($record)) { $recordModel = Inventory_Record_Model::getInstanceById($record, $moduleName); $currencyInfo = $recordModel->getCurrencyInfo(); $taxes = $recordModel->getProductTaxes(); $shippingTaxes = $recordModel->getShippingTaxes(); $relatedProducts = $recordModel->getProducts(); $viewer->assign('RECORD_ID', $record); $viewer->assign('MODE', 'edit'); // SalesPlatform.ru begin Relation between Invoice & Consignment } elseif ($request->get('salesorder_id') || $request->get('quote_id') || $request->get('invoice_id')) { //} elseif ($request->get('salesorder_id') || $request->get('quote_id') || $request->get('invoice_id')) { // SalesPlatform.ru end if ($request->get('salesorder_id')) { $referenceId = $request->get('salesorder_id'); // SalesPlatform.ru begin Relation between Invoice & Consignment } elseif ($request->get('invoice_id')) { $referenceId = $request->get('invoice_id'); // SalesPlatform.ru end } else { $referenceId = $request->get('quote_id'); } $parentRecordModel = Inventory_Record_Model::getInstanceById($referenceId); $currencyInfo = $parentRecordModel->getCurrencyInfo(); $taxes = $parentRecordModel->getProductTaxes(); $shippingTaxes = $parentRecordModel->getShippingTaxes(); $relatedProducts = $parentRecordModel->getProducts(); $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName); $recordModel->setRecordFieldValues($parentRecordModel); /** EventHandler START */ $recordModel = EventHandler_Module_Model::do_filter('vtiger.filter.' . strtolower($moduleName) . '.convert', $recordModel, $parentRecordModel); /** EventHandler ENDE */ } else { $taxes = Inventory_Module_Model::getAllProductTaxes(); $shippingTaxes = Inventory_Module_Model::getAllShippingTaxes(); $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName); $viewer->assign('MODE', ''); //The creation of Inventory record from action and Related list of product/service detailview the product/service details will calculated by following code if ($request->get('product_id') || $sourceModule === 'Products') { if ($sourceRecord) { $productRecordModel = Products_Record_Model::getInstanceById($sourceRecord); } else { $productRecordModel = Products_Record_Model::getInstanceById($request->get('product_id')); } $relatedProducts = $productRecordModel->getDetailsForInventoryModule($recordModel); } elseif ($request->get('service_id') || $sourceModule === 'Services') { if ($sourceRecord) { $serviceRecordModel = Services_Record_Model::getInstanceById($sourceRecord); } else { $serviceRecordModel = Services_Record_Model::getInstanceById($request->get('service_id')); } $relatedProducts = $serviceRecordModel->getDetailsForInventoryModule($recordModel); } elseif ($sourceRecord && ($sourceModule === 'Accounts' || $sourceModule === 'Contacts' || $sourceModule === 'Potentials' || $sourceModule === 'Vendors' && $moduleName === 'PurchaseOrder')) { $parentRecordModel = Vtiger_Record_Model::getInstanceById($sourceRecord, $sourceModule); $recordModel->setParentRecordData($parentRecordModel); } } $moduleModel = $recordModel->getModule(); $fieldList = $moduleModel->getFields(); $requestFieldList = array_intersect_key($request->getAll(), $fieldList); //get the inventory terms and conditions $inventoryRecordModel = Inventory_Record_Model::getCleanInstance($moduleName); $termsAndConditions = $inventoryRecordModel->getInventoryTermsandConditions(); foreach ($requestFieldList as $fieldName => $fieldValue) { $fieldModel = $fieldList[$fieldName]; if ($fieldModel->isEditable()) { $recordModel->set($fieldName, $fieldModel->getDBInsertValue($fieldValue)); } } // SalesPlatform.ru begin Set default invoice status for SalesOrder if ($moduleName == "SalesOrder") { if (empty($record)) { $recordModel->set("invoicestatus", "AutoCreated"); } else { $checkbox = $recordModel->get("enable_recurring"); if ($checkbox != 1) { $recordModel->set("invoicestatus", "AutoCreated"); } } } // SalesPlatform.ru end // SalesPlatform.ru begin Unifying method for EditView preparing $recordModel = prepareEditView($recordModel, $_REQUEST, $viewer); // SalesPlatform.ru end $recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($recordModel, Vtiger_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDIT); // SalesPlatform.ru begin Field Validation Information $tabid = getTabid($moduleName); $validationData = getDBValidationData($recordModel->get('tab_name'), $tabid); $validationArray = split_validationdataArray($validationData); $viewer->assign("VALIDATION_DATA_FIELDNAME", $validationArray['fieldname']); $viewer->assign("VALIDATION_DATA_FIELDDATATYPE", $validationArray['datatype']); $viewer->assign("VALIDATION_DATA_FIELDLABEL", $validationArray['fieldlabel']); $viewer->assign('ID', $record); // SalesPlatform.ru end $viewer->assign('VIEW_MODE', "fullForm"); $isRelationOperation = $request->get('relationOperation'); //if it is relation edit //SalesPlatform.ru begin add relation create for Act from Invoice $isFromInvoiceCreate = $request->get('convertFromInvoice'); $viewer->assign('IS_FROM_INVOICE_CREATE', $isFromInvoiceCreate); //SalesPlatform.ru end $viewer->assign('IS_RELATION_OPERATION', $isRelationOperation); //SalesPlatform.ru begin add relation create for Act from Invoice if ($isRelationOperation || $isFromInvoiceCreate) { //if($isRelationOperation) //SalesPlatform.ru end $viewer->assign('SOURCE_MODULE', $sourceModule); $viewer->assign('SOURCE_RECORD', $sourceRecord); } if (!empty($record) && $request->get('isDuplicate') == true) { $viewer->assign('IS_DUPLICATE', true); } else { $viewer->assign('IS_DUPLICATE', false); } $currencies = Inventory_Module_Model::getAllCurrencies(); $picklistDependencyDatasource = Vtiger_DependencyPicklist::getPicklistDependencyDatasource($moduleName); $viewer->assign('PICKIST_DEPENDENCY_DATASOURCE', Zend_Json::encode($picklistDependencyDatasource)); $viewer->assign('RECORD', $recordModel); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure()); $viewer->assign('MODULE', $moduleName); $viewer->assign('CURRENTDATE', date('Y-n-j')); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->assign('RELATED_PRODUCTS', $relatedProducts); $viewer->assign('SHIPPING_TAXES', $shippingTaxes); $viewer->assign('TAXES', $taxes); $viewer->assign('CURRENCINFO', $currencyInfo); $viewer->assign('CURRENCIES', $currencies); $viewer->assign('TERMSANDCONDITIONS', $termsAndConditions); $productModuleModel = Vtiger_Module_Model::getInstance('Products'); $viewer->assign('PRODUCT_ACTIVE', $productModuleModel->isActive()); $serviceModuleModel = Vtiger_Module_Model::getInstance('Services'); $viewer->assign('SERVICE_ACTIVE', $serviceModuleModel->isActive()); $viewer->view('EditView.tpl', 'Inventory'); }