function onAction()
 {
     $AddCustomAttributeForm = array();
     $AddCustomAttributeForm = $_POST;
     $AddCustomAttributeForm["ErrorsArray"] = array();
     // convert to the universal user interface.
     $AddCustomAttributeForm['view_tag'] = _ml_ucfirst(_ml_strtolower($AddCustomAttributeForm['view_tag']));
     // check "Attribute Tag"
     if (isEmptyKey('view_tag', $AddCustomAttributeForm)) {
         // a required attribute
         $AddCustomAttributeForm["ErrorsArray"]["view_tag"] = new ActionMessage("ADDCUSTOM_001");
     }
     if (preg_match("/[^a-zA-Z0-9_]+/", $AddCustomAttributeForm['view_tag'])) {
         // the attribute should require the rules of naming the PHP variables
         $AddCustomAttributeForm["ErrorsArray"]["view_tag"] = new ActionMessage("ADDCUSTOM_002");
     }
     if ($AddCustomAttributeForm['product_type_id'] != "") {
         // there should be no copies of real custom attributes...
         $product_type = modApiFunc('Catalog', 'getProductType', $AddCustomAttributeForm['product_type_id']);
         foreach ($product_type['attr'] as $key => $value) {
             if (_ml_strtolower($AddCustomAttributeForm['view_tag']) === _ml_strtolower($key)) {
                 $AddCustomAttributeForm["ErrorsArray"]["view_tag"] = new ActionMessage(array("ADDCUSTOM_005", 'Product' . $AddCustomAttributeForm['view_tag'] . 'Custom'));
                 break;
             }
         }
         // ...             custom
         $custom_attributes = modApiFunc('Catalog', 'getTempCustomAttributes', $AddCustomAttributeForm['form_id']);
         if (is_array($custom_attributes) && array_key_exists($AddCustomAttributeForm['view_tag'], $custom_attributes)) {
             $AddCustomAttributeForm["ErrorsArray"]["view_tag"] = new ActionMessage(array("ADDCUSTOM_005", 'Product' . $AddCustomAttributeForm['view_tag'] . 'Custom'));
         }
     } else {
         // there should be no copies
         $custom_attributes = modApiFunc('Catalog', 'getTempCustomAttributes', $AddCustomAttributeForm['form_id']);
         if (is_array($custom_attributes) && array_key_exists($AddCustomAttributeForm['view_tag'], $custom_attributes)) {
             $AddCustomAttributeForm["ErrorsArray"]["view_tag"] = new ActionMessage(array("ADDCUSTOM_005", 'Product' . $AddCustomAttributeForm['view_tag'] . 'Custom'));
         }
     }
     // check "Attribute Tag"
     if (isEmptyKey('name', $AddCustomAttributeForm)) {
         //
         // a required attribute
         $AddCustomAttributeForm["ErrorsArray"]["name"] = new ActionMessage("ADDCUSTOM_003");
     }
     // check "Attribute Description"
     if (isEmptyKey('descr', $AddCustomAttributeForm)) {
         //   a required attribute
         $AddCustomAttributeForm["ErrorsArray"]["descr"] = new ActionMessage("ADDCUSTOM_004");
     }
     if (empty($AddCustomAttributeForm["ErrorsArray"])) {
         $input_type_name = "";
         $input_type_id = "";
         switch ($AddCustomAttributeForm['type_id']) {
             case 1:
                 $input_type_name = 'text';
                 $input_type_id = 1;
                 break;
             case 2:
                 $input_type_name = 'textarea';
                 $input_type_id = 2;
                 break;
             case 3:
                 $input_type_name = 'select';
                 $res = execQuery('SELECT_MAX_INPUT_TYPE_ID');
                 $input_type_id = $res[0]['max_id'] + 1;
                 foreach ($AddCustomAttributeForm['input_type_values'] as $key => $item) {
                     if (empty($item)) {
                         unset($AddCustomAttributeForm['input_type_values'][$key]);
                     }
                 }
                 break;
             default:
                 $input_type_name = 'text';
         }
         $AddCustomAttributeForm['input_type_values'] = isset($AddCustomAttributeForm['input_type_values']) ? $AddCustomAttributeForm['input_type_values'] : array();
         $attr = array('id' => null, 'pta_id' => null, 'name' => prepareHTMLDisplay($AddCustomAttributeForm['name']), 'descr' => prepareHTMLDisplay($AddCustomAttributeForm['descr']), 'size' => 70, 'min' => 2, 'max' => 255, 'view_tag' => prepareHTMLDisplay($AddCustomAttributeForm['view_tag']), 'group' => array('id' => 6, 'name' => 'Custom Attributes', 'sort' => 6), 'required' => false, 'visible' => true, 'default' => '', 'sort' => 1, 'type' => 'custom', 'patt' => null, 'patt_type' => null, 'input_type_id' => $input_type_id, 'input_type_name' => $input_type_name, 'unit_type_value' => null, 'vanishing' => true, 'allow_html' => $input_type_id == 2 ? 1 : 0, 'input_type_values' => $AddCustomAttributeForm['input_type_values']);
         modApiFunc('Catalog', 'addTempCustomAttribute', $AddCustomAttributeForm['form_id'], $attr);
         $AddCustomAttributeForm["close"] = true;
     }
     modApiFunc('Session', 'set', 'AddCustomAttributeForm', $AddCustomAttributeForm);
 }
 function getTag($tag)
 {
     $value = null;
     switch ($tag) {
         case 'Local_PersonInfoShipping':
         case 'Local_PersonInfoBilling':
             $group_name = _ml_strtolower(str_replace('Local_PersonInfo', '', $tag));
             $lang_suffix = _ml_strtoupper($group_name . '_info');
             $this->current_info_group = array('name' => $group_name, 'lang_suffix' => $lang_suffix);
             $value = $this->templateFiller->fill('GroupHeader');
             $value .= $this->out_CustomerInfoGroup(_ml_ucfirst($group_name));
             break;
         case 'Local_KeyDetails':
             $this->current_info_group = array('name' => 'key', 'lang_suffix' => 'KEY_DETAILS');
             $value = $this->templateFiller->fill('GroupHeader');
             $value .= $this->out_KeyDetails();
             break;
         case 'Local_ProductsDetails':
             $this->current_info_group = array('name' => 'products', 'lang_suffix' => 'ORDERED_PRODUCTS');
             $value = $this->templateFiller->fill('GroupHeader');
             $value .= $this->templateFiller->fill('ProductsContainer');
             break;
         default:
             $value = parent::getTag($tag);
             break;
     }
     return $value;
 }
 function getAttributesForExport($group_name)
 {
     $attrs = array();
     switch ($group_name) {
         case 'system':
             $attrs = array('id' => array('tag' => 'ID', 'visible' => 'ID'), 'account' => array('tag' => 'AccountName', 'visible' => 'Account Name'), 'status' => array('tag' => 'Status', 'visible' => 'Status'));
             break;
         case 'orders':
             $attrs = array('quantity' => array('tag' => 'OrdersQuantity', 'visible' => 'Orders Quantity'), 'amount' => array('tag' => 'OrdersTotalAmount', 'visible' => 'Total Amount'), 'paid_amount' => array('tag' => 'OrdersTotalFullyPaidAmount', 'visible' => 'Total Paid Amount'));
             break;
         default:
             $group_info = $this->getPersonInfoGroupInfoByName(_ml_ucfirst(_ml_strtolower($group_name)));
             $group_attrs = $this->getPersonInfoGroupAttrs($group_info['group_id'], PERSON_INFO_GROUP_ATTR_VISIBLE);
             foreach ($group_attrs as $attr_info) {
                 if (preg_match("/password/i", $attr_info['attr_name'])) {
                     continue;
                 }
                 $tag_prefix = '';
                 if (_ml_strtolower($group_name) != 'customer') {
                     $tag_prefix = _ml_ucfirst(_ml_strtolower($group_name));
                 }
                 $attrs[_ml_strtolower($attr_info['attr_name'])] = array('tag' => $tag_prefix . $attr_info['attr_name'], 'visible' => $attr_info['visible_name']);
             }
             break;
     }
     return $attrs;
 }
 function out_Items()
 {
     $html_code = '';
     foreach ($this->order_info_groups as $group_name => $group_lang_suffix) {
         $this->current_info_group = array('name' => $group_name, 'lang_suffix' => $group_lang_suffix);
         switch ($group_name) {
             case 'key':
                 $html_code .= $this->templateFiller->fill('GroupHeader');
                 $html_code .= $this->out_KeyDetails();
                 break;
             case 'billing':
             case 'shipping':
                 if (modApiFunc('Customer_Account', 'isPersionInfoGroupActive', _ml_ucfirst($group_name))) {
                     $html_code .= $this->templateFiller->fill('GroupHeader');
                     $html_code .= $this->out_CustomerInfoGroup(_ml_ucfirst($group_name));
                 }
                 break;
             case 'products':
                 $html_code .= $this->templateFiller->fill('GroupHeader');
                 $html_code .= $this->templateFiller->fill('ProductsContainer');
                 break;
         }
     }
     return $html_code;
 }