Exemplo n.º 1
0
 function build_form_html($action, $id = '')
 {
     global $db, $messageStack, $currencies, $integer_lengths, $decimal_lengths, $check_box_choices;
     if ($action != 'new' && $this->error == false) {
         $result = $db->Execute("select * from " . TABLE_EXTRA_FIELDS . " where id='{$this->id}'");
         $params = unserialize($result->fields['params']);
         foreach ($result->fields as $key => $value) {
             $this->{$key} = $value;
         }
         if (is_array($params)) {
             foreach ($params as $key => $value) {
                 $this->{$key} = $value;
             }
         }
         switch ($this->entry_type) {
             case 'data_list':
             case 'multi_check_box':
             case 'drop_down':
             case 'radio':
                 $this->radio_default = $this->default;
                 break;
             case 'hyperlink':
             case 'image_link':
             case 'inventory_link':
                 $this->link_default = $this->default;
                 break;
             case 'text':
             case 'html':
                 $this->text_default = $this->default;
                 break;
             case 'decimal':
                 $this->decimal_range = $this->select;
                 $this->decimal_default = number_format($this->default, $this->display, $currencies->currencies[DEFAULT_CURRENCY]['decimal_point'], $currencies->currencies[DEFAULT_CURRENCY]['thousands_point']);
                 $this->decimal_display = $this->display;
                 break;
             case 'integer':
                 $this->integer_range = $this->select;
                 $this->integer_default = $this->default;
                 break;
             case 'check_box':
                 $this->check_box_range = $this->select;
                 break;
         }
     }
     // build the tab list
     $tab_list = gen_build_pull_down(xtra_field_get_tabs($this->module));
     array_shift($tab_list);
     if ($action == 'new' && sizeof($tab_list) < 1) {
         $messageStack->add(EXTRA_FIELDS_ERROR_NO_TABS, 'error');
     }
     $choices = explode(':', $params[$this->type_params]);
     $disabled = $this->tab_id !== '0' ? '' : 'disabled="disabled" ';
     $readonly = $this->tab_id !== '0' ? '' : 'readonly="readonly" ';
     $output = '<table style="border-collapse:collapse;margin-left:auto; margin-right:auto;">' . chr(10);
     $output .= '  <thead class="ui-widget-header">' . "\n";
     $output .= '  <tr>' . chr(10);
     $output .= '    <th colspan="2">' . ($action == 'new' ? TEXT_NEW_FIELD : TEXT_SETTINGS) . '</th>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  </thead>' . "\n";
     $output .= '  <tbody class="ui-widget-content">' . "\n";
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . INV_FIELD_NAME . '</td>' . chr(10);
     $output .= '	<td>' . html_input_field('field_name', $this->field_name, $readonly . 'size="33" maxlength="32"') . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td colspan="2">' . INV_FIELD_NAME_RULES . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . TEXT_DESCRIPTION . '</td>' . chr(10);
     $output .= '	<td>' . html_input_field('description', $this->description, 'size="65" maxlength="64"') . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . TEXT_SORT_ORDER . '</td>' . chr(10);
     $output .= '	<td>' . html_input_field('sort_order', $this->sort_order, 'size="65" maxlength="64"') . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . TEXT_GROUP . '</td>' . chr(10);
     $output .= '	<td>' . html_input_field('group_by', $this->group_by, 'size="65" maxlength="64"') . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     if (is_array($this->type_array)) {
         $output .= '  <tr>' . chr(10);
         $output .= '	<td>' . $this->type_desc . '</td>' . chr(10);
         $output .= '	<td>';
         while ($type = array_shift($this->type_array)) {
             if (!is_array($choices)) {
                 $output .= html_checkbox_field('type_' . $type['id'], true, false, '', '') . $type['text'];
                 $output .= '<br />';
             } elseif (in_array($type['id'], $choices)) {
                 $output .= html_checkbox_field('type_' . $type['id'], true, true, '', '') . $type['text'];
                 $output .= '<br />';
             } else {
                 $output .= html_checkbox_field('type_' . $type['id'], true, false, '', '') . $type['text'];
                 $output .= '<br />';
             }
         }
         $output .= '	</td>';
         $output .= '</tr>' . chr(10);
     }
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . INV_CATEGORY_MEMBER . '</td>' . chr(10);
     $output .= '	<td>' . html_pull_down_menu('tab_id', $tab_list, $this->tab_id, $disabled) . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr class="ui-widget-header">' . chr(10);
     $output .= '	<th colspan="2">' . TEXT_PROPERTIES . '</th>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>';
     $output .= html_radio_field('entry_type', 'text', $this->entry_type == 'text' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_TEXT_FIELD . '<br />';
     $output .= html_radio_field('entry_type', 'html', $this->entry_type == 'html' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_HTML_TEXT_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_MAX_NUM_CHARS;
     $output .= '<br />' . html_input_field('length', $this->length ? $this->length : DEFAULT_TEXT_LENGTH, $readonly . 'size="10" maxlength="9"');
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE . '<br />' . INV_LABEL_MAX_255;
     $output .= '<br />' . html_textarea_field('text_default', 35, 6, $this->text_default, $readonly);
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr class="ui-widget-content">' . chr(10);
     $output .= '	<td>';
     $output .= html_radio_field('entry_type', 'hyperlink', $this->entry_type == 'hyperlink' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_HYPERLINK . '<br />';
     $output .= html_radio_field('entry_type', 'image_link', $this->entry_type == 'image_link' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_IMAGE_LINK . '<br />';
     $output .= html_radio_field('entry_type', 'inventory_link', $this->entry_type == 'inventory_link' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_INVENTORY_LINK;
     $output .= '	</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_FIXED_255_CHARS;
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE;
     $output .= '<br />' . html_textarea_field('link_default', 35, 3, $this->link_default, $readonly);
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'integer', $this->entry_type == 'integer' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_INTEGER_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_INTEGER_RANGE;
     $output .= '<br />' . html_pull_down_menu('integer_range', gen_build_pull_down($integer_lengths), $this->integer_range, $disabled);
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE . html_input_field('integer_default', $this->integer_default, $readonly . 'size="16"');
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr class="ui-widget-content">' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'decimal', $this->entry_type == 'decimal' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_DECIMAL_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_DECIMAL_RANGE;
     $output .= html_pull_down_menu('decimal_range', gen_build_pull_down($decimal_lengths), $this->decimal_range, $disabled);
     $output .= '<br />' . INV_LABEL_DEFAULT_DISPLAY_VALUE . html_input_field('decimal_display', $this->decimal_display ? $this->decimal_display : DEFAULT_REAL_DISPLAY_FORMAT, $readonly . 'size="6" maxlength="5"');
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE . html_input_field('decimal_default', $this->decimal_default, $readonly . 'size="16"');
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>';
     $output .= html_radio_field('entry_type', 'multi_check_box', $this->entry_type == 'multi_check_box' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_MULTI_SELECT_FIELD . '<br />';
     $output .= html_radio_field('entry_type', 'drop_down', $this->entry_type == 'drop_down' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_DROP_DOWN_FIELD . '<br />';
     $output .= html_radio_field('entry_type', 'data_list', $this->entry_type == 'data_list' ? true : false, '', $disabled) . '&nbsp;' . TEXT_DATA_LIST . '<br />';
     $output .= html_radio_field('entry_type', 'radio', $this->entry_type == 'radio' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_RADIO_FIELD;
     $output .= '	</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_CHOICES . '<br />' . html_textarea_field('radio_default', 35, 6, $this->radio_default, $readonly) . '<br />';
     $output .= INV_LABEL_RADIO_EXPLANATION . '<br />' . TEXT_DATA_LIST_EXPLANATION . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr class="ui-widget-content">' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'check_box', $this->entry_type == 'check_box' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_CHECK_BOX_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_DEFAULT_TEXT_VALUE . html_pull_down_menu('check_box_range', gen_build_pull_down($check_box_choices), $this->check_box_range, $disabled) . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '   <td>';
     $output .= html_radio_field('entry_type', 'date', $this->entry_type == 'date' ? true : false, '', $disabled) . '&nbsp;' . TEXT_DATE . '<br />';
     $output .= html_radio_field('entry_type', 'time', $this->entry_type == 'time' ? true : false, '', $disabled) . '&nbsp;' . TEXT_TIME . '<br />';
     $output .= html_radio_field('entry_type', 'date_time', $this->entry_type == 'date_time' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_DATE_TIME_FIELD . '<br />';
     $output .= html_radio_field('entry_type', 'time_stamp', $this->entry_type == 'time_stamp' ? true : false, '', $disabled) . '&nbsp;' . INV_LABEL_TIME_STAMP_FIELD;
     $output .= '   </td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_TIME_STAMP_VALUE . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  </tbody>' . "\n";
     $output .= '</table>' . chr(10);
     return $output;
 }
Exemplo n.º 2
0
 function build_form_html($action, $id = '')
 {
     global $db, $messageStack;
     global $integer_lengths, $decimal_lengths, $check_box_choices;
     $cInfo = '';
     if ($action != 'new') {
         $result = $db->Execute("select id, entry_type, field_name, description, id, params \n\t    from " . TABLE_EXTRA_FIELDS . " where id = '" . $id . "'");
         $params = unserialize($result->fields['params']);
         foreach ($params as $key => $value) {
             $result->fields[$key] = $value;
         }
         $form_array = xtra_field_prep_form($result->fields);
         $cInfo = new objectInfo($form_array);
     }
     // build the tab list
     $tab_list = gen_build_pull_down(xtra_field_get_tabs('assets'));
     array_shift($tab_list);
     if ($action == 'new' && sizeof($tab_list) < 1) {
         $messageStack->add(EXTRA_FIELDS_ERROR_NO_TABS, 'error');
         echo $messageStack->output();
     }
     $output = '<table style="border-collapse:collapse;margin-left:auto; margin-right:auto;">' . chr(10);
     $output .= '  <thead class="ui-widget-header">' . "\n";
     $output .= '  <tr>' . chr(10);
     $output .= '    <th colspan="2">' . ($action == 'new' ? TEXT_NEW_FIELD : TEXT_EDIT_FIELD) . '</th>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  </thead>' . "\n";
     $output .= '  <tbody class="ui-widget-content">' . "\n";
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . INV_FIELD_NAME . '</td>' . chr(10);
     $output .= '	<td>' . html_input_field('field_name', $cInfo->field_name, 'size="33" maxlength="32"') . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td colspan="2">' . INV_FIELD_NAME_RULES . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . TEXT_DESCRIPTION . '</td>' . chr(10);
     $output .= '	<td>' . html_input_field('description', $cInfo->description, 'size="65" maxlength="64"') . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . INV_CATEGORY_MEMBER . '</td>' . chr(10);
     $output .= '	<td>' . html_pull_down_menu('tab_id', $tab_list, $cInfo->tab_id) . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr class="ui-widget-header">' . chr(10);
     $output .= '	<th colspan="2">' . TEXT_PROPERTIES . '</th>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>';
     $output .= html_radio_field('entry_type', 'text', $cInfo->entry_type == 'text' ? true : false) . '&nbsp;' . INV_LABEL_TEXT_FIELD . '<br />';
     $output .= html_radio_field('entry_type', 'html', $cInfo->entry_type == 'html' ? true : false) . '&nbsp;' . INV_LABEL_HTML_TEXT_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_MAX_NUM_CHARS;
     $output .= '<br />' . html_input_field('text_length', $cInfo->text_length ? $cInfo->text_length : DEFAULT_TEXT_LENGTH, 'size="10" maxlength="9"');
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE . '<br />' . INV_LABEL_MAX_255;
     $output .= '<br />' . html_textarea_field('text_default', 35, 6, $cInfo->text_default);
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>';
     $output .= html_radio_field('entry_type', 'hyperlink', $cInfo->entry_type == 'hyperlink' ? true : false) . '&nbsp;' . INV_LABEL_HYPERLINK . '<br />';
     $output .= html_radio_field('entry_type', 'image_link', $cInfo->entry_type == 'image_link' ? true : false) . '&nbsp;' . INV_LABEL_IMAGE_LINK . '<br />';
     $output .= html_radio_field('entry_type', 'inventory_link', $cInfo->entry_type == 'inventory_link' ? true : false) . '&nbsp;' . INV_LABEL_INVENTORY_LINK;
     $output .= '	</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_FIXED_255_CHARS;
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE;
     $output .= '<br />' . html_textarea_field('link_default', 35, 3, $cInfo->link_default);
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'integer', $cInfo->entry_type == 'integer' ? true : false) . '&nbsp;' . INV_LABEL_INTEGER_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_INTEGER_RANGE;
     $output .= '<br />' . html_pull_down_menu('integer_range', gen_build_pull_down($integer_lengths), $cInfo->integer_range);
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE . html_input_field('integer_default', $cInfo->integer_default, 'size="16"');
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'decimal', $cInfo->entry_type == 'decimal' ? true : false) . '&nbsp;' . INV_LABEL_DECIMAL_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_DECIMAL_RANGE;
     $output .= html_pull_down_menu('decimal_range', gen_build_pull_down($decimal_lengths), $cInfo->decimal_range);
     $output .= '<br />' . INV_LABEL_DEFAULT_DISPLAY_VALUE . html_input_field('decimal_display', $cInfo->decimal_display ? $cInfo->decimal_display : DEFAULT_REAL_DISPLAY_FORMAT, 'size="6" maxlength="5"');
     $output .= '<br />' . INV_LABEL_DEFAULT_TEXT_VALUE . html_input_field('decimal_default', $cInfo->decimal_default, 'size="16"');
     $output .= '	</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>';
     $output .= html_radio_field('entry_type', 'drop_down', $cInfo->entry_type == 'drop_down' ? true : false) . '&nbsp;' . INV_LABEL_DROP_DOWN_FIELD . '<br />';
     $output .= html_radio_field('entry_type', 'radio', $cInfo->entry_type == 'radio' ? true : false) . '&nbsp;' . INV_LABEL_RADIO_FIELD;
     $output .= '	</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_CHOICES . '<br />' . html_textarea_field('radio_default', 35, 6, $cInfo->radio_default) . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'check_box', $cInfo->entry_type == 'check_box' ? true : false) . '&nbsp;' . INV_LABEL_CHECK_BOX_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_DEFAULT_TEXT_VALUE . html_pull_down_menu('check_box_range', gen_build_pull_down($check_box_choices), $cInfo->check_box_range) . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'date', $cInfo->entry_type == 'date' ? true : false) . '&nbsp;' . TEXT_DATE . '</td>' . chr(10);
     $output .= '	<td>&nbsp;</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'time', $cInfo->entry_type == 'time' ? true : false) . '&nbsp;' . TEXT_TIME . '</td>' . chr(10);
     $output .= '	<td>&nbsp;</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'date_time', $cInfo->entry_type == 'date_time' ? true : false) . '&nbsp;' . INV_LABEL_DATE_TIME_FIELD . '</td>' . chr(10);
     $output .= '	<td>&nbsp;</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  <tr>' . chr(10);
     $output .= '	<td>' . html_radio_field('entry_type', 'time_stamp', $cInfo->entry_type == 'time_stamp' ? true : false) . '&nbsp;' . INV_LABEL_TIME_STAMP_FIELD . '</td>' . chr(10);
     $output .= '	<td>' . INV_LABEL_TIME_STAMP_VALUE . '</td>' . chr(10);
     $output .= '  </tr>' . chr(10);
     $output .= '  </tbody>' . "\n";
     $output .= '</table>' . chr(10);
     return $output;
 }
Exemplo n.º 3
0
                if ($balance['qty_so'] != $so[$sku]) {
                    $messageStack->add(sprintf(INV_TOOLS_SO_ERROR, $sku, $balance['qty_so'], $so[$sku]), 'caution');
                    $db->Execute("update " . TABLE_INVENTORY . " set quantity_on_sales_order = " . $so[$sku] . " where id = " . $balance['id']);
                    $fix++;
                }
                $cnt++;
            }
        }
        $messageStack->Add(sprintf(INV_TOOLS_SO_PO_RESULT, $cnt, $fix), 'success');
        gen_add_audit_log(sprintf(INV_TOOLS_AUTDIT_LOG_SO_PO, $cnt), 'Fixed: ' . $fix);
        $default_tab_id = 'tools';
        break;
    default:
}
/*****************   prepare to display templates  *************************/
$category_array = xtra_field_get_tabs();
// build some general pull down arrays
$sel_yes_no = array(array('id' => '0', 'text' => TEXT_NO), array('id' => '1', 'text' => TEXT_YES));
$cost_methods = array(array('id' => 'f', 'text' => INV_TEXT_FIFO), array('id' => 'l', 'text' => INV_TEXT_LIFO), array('id' => 'a', 'text' => INV_TEXT_AVERAGE));
$sel_item_cost = array(array('id' => '0', 'text' => TEXT_NO), array('id' => 'PO', 'text' => TEXT_PURCH_ORDER), array('id' => 'PR', 'text' => TEXT_PURCHASE));
$sel_sales_tax = ord_calculate_tax_drop_down('c');
$sel_purch_tax = ord_calculate_tax_drop_down('v');
// some pre-defined gl accounts
$cog_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(32));
// cogs types only
$inc_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(30));
// income types only
$inv_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(4, 34));
// inv, expenses types only
$include_header = true;
$include_footer = true;