public static function addNewField(Vtiger_Request $request)
 {
     $log = vglobal('log');
     $adb = PearDatabase::getInstance();
     $newField = self::newFieldValidation($request->get('fieldName'));
     $response = new Vtiger_Response();
     $moduleName = 'Settings:' . $request->getModule();
     if ($newField != false) {
         $query = "SELECT * \n\t\t\t\t\tFROM information_schema.COLUMNS \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tTABLE_SCHEMA = ? \n\t\t\t\t\tAND TABLE_NAME = 'vtiger_organizationdetails' \n\t\t\t\t\tAND COLUMN_NAME = ?";
         $params = array($adb->getDatabaseName(), $newField);
         $result = $adb->pquery($query, $params);
         $rowsNum = $adb->getRowCount($result);
         if ($rowsNum > 0) {
             $response->setResult(array('success' => false, 'message' => vtranslate('LBL_ADDING_ERROR', $moduleName)));
             $log->info("Settings_Vtiger_SaveCompanyField_Action::process - column {$newField} exist in table vtiger_organizationdetails");
         } else {
             $alterFieldQuery = "ALTER TABLE `vtiger_organizationdetails` ADD `{$newField}` VARCHAR(255)";
             $alterFieldResult = $adb->query($alterFieldQuery, $alterFieldParams);
             $rowsNum = $adb->getRowCount($alterFieldResult);
             Settings_Vtiger_CompanyDetailsFieldSave_Action::addFieldToModule($newField);
             $response->setResult(array('success' => true, 'message' => vtranslate('LBL_ADDED_COMPANY_FIELD', $moduleName)));
             $log->info("Settings_Vtiger_SaveCompanyField_Action::process - add column {$newField} in table vtiger_organizationdetails");
         }
     } else {
         $response->setResult(array('success' => false, 'message' => vtranslate('LBL_FIELD_NOT_VALID', $moduleName)));
     }
     $response->emit();
 }
 public static function addNewField(Vtiger_Request $request)
 {
     global $log;
     global $adb;
     $newField = self::newFieldValidation($request->get('field_name'));
     if ($newField != FALSE) {
         $query = "SELECT * \n\t\t\t\t\tFROM information_schema.COLUMNS \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tTABLE_SCHEMA = ? \n\t\t\t\t\tAND TABLE_NAME = 'vtiger_organizationdetails' \n\t\t\t\t\tAND COLUMN_NAME = ?";
         $params = array($adb->dbName, $newField);
         $result = $adb->pquery($query, $params);
         $rowsNum = $adb->getRowCount($result);
         if ($rowsNum > 0) {
             $log->info("Settings_Vtiger_SaveCompanyField_Action::process - column {$newField} exist in table vtiger_organizationdetails");
             $reloadUrl = 'index.php?parent=Settings&module=Vtiger&view=CompanyDetails&AddField=0';
         } else {
             $alterFieldQuery = "ALTER TABLE `vtiger_organizationdetails` ADD {$newField} VARCHAR(255)";
             $alterFieldResult = $adb->query($alterFieldQuery, $alterFieldParams);
             $rowsNum = $adb->getRowCount($alterFieldResult);
             Settings_Vtiger_CompanyDetailsFieldSave_Action::addFieldToModule($newField);
             $reloadUrl = 'index.php?parent=Settings&module=Vtiger&view=CompanyDetails&AddField=1';
             $log->info("Settings_Vtiger_SaveCompanyField_Action::process - add column {$newField} in table vtiger_organizationdetails");
         }
     } else {
         $reloadUrl = 'index.php?parent=Settings&module=Vtiger&view=CompanyDetails&AddField=0';
         $log->info("Settings_Vtiger_SaveCompanyField_Action::process - field not valid");
     }
     header('Location: ' . $reloadUrl);
 }