public function get_field_def()
 {
     $def = parent::get_field_def();
     $def['precision'] = !empty($this->precision) ? $this->precision : 6;
     $def['related_fields'] = array('currency_id', 'base_rate');
     return $def;
 }
Beispiel #2
0
 function get_db_type()
 {
     $precision = !empty($this->precision) ? $this->precision : 6;
     if (empty($this->len)) {
         return parent::get_db_type();
     }
     return " " . sprintf($GLOBALS['db']->getColumnType("decimal_tpl"), $this->len, $precision);
 }
 function get_field_def()
 {
     $def = parent::get_field_def();
     if (!empty($def['default'])) {
         $def['display_default'] = $def['default'];
         $def['default'] = '';
     }
     return $def;
 }
 function save($df)
 {
     //the currency field
     $this->default = unformat_number($this->default);
     $this->default_value = $this->default;
     parent::save($df);
     //currency id
     $currency_id = new TemplateCurrencyId();
     $currency_id->name = 'currency_id';
     $currency_id->vname = 'LBL_CURRENCY';
     $currency_id->label = $currency_id->vname;
     $currency_id->save($df);
     //$df->addLabel($currency_id->vname);
 }
 function populateFromPost()
 {
     parent::populateFromPost();
     // Handle empty massupdate checkboxes
     $this->massupdate = !empty($_REQUEST['massupdate']);
     if (!empty($_REQUEST['defaultDate']) && !empty($_REQUEST['defaultTime'])) {
         $_REQUEST['default'] = $_REQUEST['defaultDate'] . '&' . $_REQUEST['defaultTime'];
         $defaultTime = $_REQUEST['defaultTime'];
         $hours = substr($defaultTime, 0, 2);
         $minutes = substr($defaultTime, 3, 2);
         $meridiem = substr($defaultTime, 5, 2);
         if (empty($meridiem)) {
             if ($hours == '00') {
                 $hours = 12;
                 $meridiem = 'am';
             } else {
                 if ($hours >= 12) {
                     //lets add the PM meridiem, but only subtract 12 if hours is greater than 12
                     if ($hours > 12) {
                         $hours -= 12;
                     }
                     $meridiem = 'pm';
                 } else {
                     $meridiem = 'am';
                 }
             }
             //lets format the string to make sure the leading 0's are added back in for hours and minutes
             $_REQUEST['default'] = $_REQUEST['defaultDate'] . '&' . sprintf('%02d:%02d%s', $hours, $minutes, $meridiem);
         }
     } else {
         $_REQUEST['default'] = '';
     }
     unset($_REQUEST['defaultDate']);
     unset($_REQUEST['defaultTime']);
     foreach ($this->vardef_map as $vardef => $field) {
         if (isset($_REQUEST[$vardef])) {
             //  Bug #48826. Some fields are allowed to have special characters and must be decoded from the request
             // Bug 49774, 49775: Strip html tags from 'formula' and 'dependency'.
             if (is_string($_REQUEST[$vardef]) && in_array($vardef, $this->decode_from_request_fields_map)) {
                 $this->{$vardef} = html_entity_decode(strip_tags(from_html($_REQUEST[$vardef])));
             } else {
                 $this->{$vardef} = $_REQUEST[$vardef];
             }
             if ($vardef != $field) {
                 $this->{$field} = $this->{$vardef};
             }
         }
     }
     $GLOBALS['log']->debug('populate: ' . print_r($this, true));
 }
 function populateFromPost()
 {
     parent::populateFromPost();
     if (!empty($_REQUEST['defaultDate']) && !empty($_REQUEST['defaultTime'])) {
         $_REQUEST['default'] = $_REQUEST['defaultDate'] . '&' . $_REQUEST['defaultTime'];
         $defaultTime = $_REQUEST['defaultTime'];
         $hours = substr($defaultTime, 0, 2);
         $minutes = substr($defaultTime, 3, 2);
         $meridiem = substr($defaultTime, 5, 2);
         if (empty($meridiem)) {
             if ($hours == '00') {
                 $hours = 12;
                 $meridiem = 'am';
             } else {
                 if ($hours > 12) {
                     $hours -= 12;
                     $meridiem = 'pm';
                 } else {
                     $meridiem = 'am';
                 }
             }
             $_REQUEST['default'] = $_REQUEST['defaultDate'] . '&' . $hours . ':' . $minutes . '' . $meridiem;
         }
     } else {
         $_REQUEST['default'] = '';
     }
     unset($_REQUEST['defaultDate']);
     unset($_REQUEST['defaultTime']);
     foreach ($this->vardef_map as $vardef => $field) {
         if (isset($_REQUEST[$vardef])) {
             //  Bug #48826. Some fields are allowed to have special characters and must be decoded from the request
             // Bug 49774, 49775: Strip html tags from 'formula' and 'dependency'.
             if (is_string($_REQUEST[$vardef]) && in_array($vardef, $this->decode_from_request_fields_map)) {
                 $this->{$vardef} = html_entity_decode(strip_tags(from_html($_REQUEST[$vardef])));
             } else {
                 $this->{$vardef} = $_REQUEST[$vardef];
             }
             if ($vardef != $field) {
                 $this->{$field} = $this->{$vardef};
             }
         }
     }
     $GLOBALS['log']->debug('populate: ' . print_r($this, true));
 }
 function populateFromPost()
 {
     parent::populateFromPost();
     if (!empty($_REQUEST['defaultDate']) && !empty($_REQUEST['defaultTime'])) {
         $_REQUEST['default'] = $_REQUEST['defaultDate'] . '&' . $_REQUEST['defaultTime'];
         $defaultTime = $_REQUEST['defaultTime'];
         $hours = substr($defaultTime, 0, 2);
         $minutes = substr($defaultTime, 3, 2);
         $meridiem = substr($defaultTime, 5, 2);
         if (empty($meridiem)) {
             if ($hours == '00') {
                 $hours = 12;
                 $meridiem = 'am';
             } else {
                 if ($hours > 12) {
                     $hours -= 12;
                     $meridiem = 'pm';
                 } else {
                     $meridiem = 'am';
                 }
             }
             $_REQUEST['default'] = $_REQUEST['defaultDate'] . '&' . $hours . ':' . $minutes . '' . $meridiem;
         }
     } else {
         $_REQUEST['default'] = '';
     }
     unset($_REQUEST['defaultDate']);
     unset($_REQUEST['defaultTime']);
     foreach ($this->vardef_map as $vardef => $field) {
         if (isset($_REQUEST[$vardef])) {
             $this->{$vardef} = $_REQUEST[$vardef];
             if ($vardef != $field) {
                 $this->{$field} = $this->{$vardef};
             }
         }
     }
     $GLOBALS['log']->debug('populate: ' . print_r($this, true));
 }
Beispiel #8
0
/**
 * repairSearchFields
 *
 * This method goes through the list of SearchFields files based and calls TemplateRange::repairCustomSearchFields
 * method on the files in an attempt to ensure the range search attributes are properly set in SearchFields.php.
 *
 * @param $globString String value used for glob search defaults to searching for all SearchFields.php files in modules directory
 * @param $path String value used to point to log file should logging be required.  Defaults to empty.
 *
 */
function repairSearchFields($globString = 'modules/*/metadata/SearchFields.php', $path = '')
{
    if (!empty($path)) {
        logThis('Begin repairSearchFields', $path);
    }
    require_once 'include/dir_inc.php';
    require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
    require 'include/modules.php';
    global $beanList;
    $searchFieldsFiles = glob($globString);
    foreach ($searchFieldsFiles as $file) {
        if (preg_match('/modules\\/(.*?)\\/metadata\\/SearchFields\\.php/', $file, $matches) && isset($beanList[$matches[1]])) {
            $module = $matches[1];
            $beanName = $beanList[$module];
            VardefManager::loadVardef($module, $beanName);
            if (isset($GLOBALS['dictionary'][$beanName]['fields'])) {
                if (!empty($path)) {
                    logThis('Calling TemplateRange::repairCustomSearchFields for module ' . $module, $path);
                }
                TemplateRange::repairCustomSearchFields($GLOBALS['dictionary'][$beanName]['fields'], $module);
            }
        }
    }
    if (!empty($path)) {
        logThis('End repairSearchFields', $path);
    }
}
Beispiel #9
0
 function action_searchViewSave()
 {
     $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
     require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php';
     $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName);
     $parser->handleSave();
     //Repair or create a custom SearchFields.php file as needed
     $module_name = $_REQUEST['view_module'];
     global $beanList;
     if (isset($beanList[$module_name]) && $beanList[$module_name] != "") {
         $objectName = BeanFactory::getObjectName($module_name);
         //Load the vardefs for the module to pass to TemplateRange
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $vardefs = $dictionary[$objectName]['fields'];
         require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
         TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
     }
     $this->view = 'searchView';
 }
Beispiel #10
0
 function get_field_def()
 {
     $def = parent::get_field_def();
     $def['precision'] = !empty($this->precision) ? $this->precision : 6;
     return $def;
 }
Beispiel #11
0
 function save($df)
 {
     $next = false;
     if (!empty($this->auto_increment) && (!empty($this->autoinc_next) || !empty($this->autoinc_start)) && isset($this->module)) {
         if (!empty($this->autoinc_start) && $this->autoinc_start > $this->autoinc_next) {
             $this->autoinc_next = $this->autoinc_start;
         }
         if (isset($this->module->table_name)) {
             global $db;
             $helper = $db->gethelper();
             //Check that the new value is greater than the old value
             $oldNext = $helper->getAutoIncrement($this->module->table_name, $this->name);
             if ($this->autoinc_next > $oldNext) {
                 $helper->setAutoIncrementStart($this->module->table_name, $this->name, $this->autoinc_next);
             }
         }
         $next = $this->autoinc_next;
         $this->autoinc_next = false;
     }
     parent::save($df);
     if ($next) {
         $this->autoinc_next = $next;
     }
 }
Beispiel #12
0
 /**
  * testActionAdvancedSearchSaveWithoutAnyRangeSearchFields
  * One last test to check what would happen if we had a module that did not have any range search fields enabled
  */
 public function testActionAdvancedSearchSaveWithoutAnyRangeSearchFields()
 {
     //Load the vardefs for the module to pass to TemplateRange
     VardefManager::loadVardef('Cases', 'aCase', true);
     global $dictionary;
     $vardefs = $dictionary['Case']['fields'];
     foreach ($vardefs as $key => $def) {
         if (!empty($def['enable_range_search'])) {
             unset($vardefs[$key]['enable_range_search']);
         }
     }
     require_once 'modules/DynamicFields/templates/Fields/TemplateRange.php';
     TemplateRange::repairCustomSearchFields($vardefs, 'Cases');
     //In this case there would be no custom SearchFields.php file created
     $this->assertTrue(!file_exists('custom/modules/Cases/metadata/SearchFields.php'));
     //Yet we have the defaults set still in out of box settings
     require 'modules/Cases/metadata/SearchFields.php';
     $this->assertTrue(isset($searchFields['Cases']['range_date_entered']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_entered']['enable_range_search']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_modified']));
     $this->assertTrue(isset($searchFields['Cases']['range_date_modified']['enable_range_search']));
 }
Beispiel #13
0
 public function action_searchViewSave()
 {
     $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null;
     // Bug 56789 - Set the client from the view to ensure the proper viewdef file
     $client = MetaDataFiles::getClientByView($_REQUEST['view']);
     if (isModuleBWC($_REQUEST['view_module'])) {
         $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName, $client);
     } else {
         $client = empty($client) ? 'base' : $client;
         $parser = new SidecarFilterLayoutMetaDataParser($_REQUEST['view_module'], $packageName, $client);
     }
     $parser->handleSave();
     //Repair or create a custom SearchFields.php file as needed
     $module_name = $_REQUEST['view_module'];
     global $beanList;
     if (isset($beanList[$module_name]) && $beanList[$module_name] != "") {
         $objectName = BeanFactory::getObjectName($module_name);
         //Load the vardefs for the module to pass to TemplateRange
         VardefManager::loadVardef($module_name, $objectName, true);
         global $dictionary;
         $vardefs = $dictionary[$objectName]['fields'];
         TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
     }
     $this->view = 'searchView';
 }
Beispiel #14
0
 function populateFromPost()
 {
     parent::populateFromPost();
     // Handle empty massupdate checkboxes
     $this->massupdate = !empty($_REQUEST['massupdate']);
 }
Beispiel #15
0
 function populateFromRow($row = array())
 {
     parent::populateFromRow($row);
 }