'suppliers-list', 'icon' => 'table', 'title' => __('Every supplier in one table', 'ai-eshop-optimizer'), 'description' => __('Every supplier the shop buys from, with its ERP identity, contact details and commercial terms. Edit fills the form below; Save writes through the same store the term screen uses, so the two never disagree. This is the list the reorder chain resolves against when an order needs a restock contact.', 'ai-eshop-optimizer'), 'flush' => true, )); echo $aieo_sup_open; ?> __('Where are suppliers created?', 'ai-eshop-optimizer'), 'html' => '' . esc_html__('The term screen at Products → Suppliers stays the canonical place a supplier is created or deleted.', 'ai-eshop-optimizer') . '') ); echo $aieo_sup_term_link; ?> term_id; $aieo_e = isset($extras_by_term[$aieo_tid]) ? $extras_by_term[$aieo_tid] : array(); $aieo_sup_rows[] = array( 'id' => $aieo_tid, 'name' => $aieo_t->name, 'term_url' => (string) get_edit_term_link($aieo_tid, 'supplier'), 'term_sub' => __('term screen', 'ai-eshop-optimizer'), 'erp_id' => $aieo_x($aieo_e, 'erp_id'), 'email' => '' !== $aieo_x($aieo_e, 'email') ? $aieo_x($aieo_e, 'email') : $aieo_x($aieo_e, 'corporate_email'), 'phone' => $aieo_x($aieo_e, 'tel_1'), 'city' => $aieo_x($aieo_e, 'address_city'), 'lead' => $aieo_x($aieo_e, 'lead_time_days'), 'brands' => isset($brand_counts[$aieo_tid]) ? (int) $brand_counts[$aieo_tid] : 0, 'skus' => isset($sku_counts[$aieo_tid]) ? (int) $sku_counts[$aieo_tid] : 0, 'products' => (int) $aieo_t->count, ); } AIEO_Table::render(array( 'id' => 'aieo-sup-list', 'caption' => __('Every supplier in one table', 'ai-eshop-optimizer'), 'caps' => array('search' => true), 'chooser' => true, 'page_id' => 'suppliers', 'row_key' => 'id', 'rows' => $aieo_sup_rows, 'cap' => 500, 'total' => (int) $total, 'capped' => (int) $total > count($terms), 'empty' => __('No suppliers yet. Create the first one below.', 'ai-eshop-optimizer'), 'columns' => array( array( 'key' => 'name', 'label' => __('Supplier', 'ai-eshop-optimizer'), 'type' => 'link', 'format' => array('href' => 'term_url'), 'subline' => 'term_sub', ), array('key' => 'erp_id', 'label' => __('ERP id', 'ai-eshop-optimizer'), 'type' => 'id'), array('key' => 'email', 'label' => __('Email', 'ai-eshop-optimizer')), array('key' => 'phone', 'label' => __('Phone', 'ai-eshop-optimizer'), 'nowrap' => true), array('key' => 'city', 'label' => __('City', 'ai-eshop-optimizer')), array('key' => 'lead', 'label' => __('Lead (d)', 'ai-eshop-optimizer'), 'type' => 'integer', 'width' => '70px'), array('key' => 'brands', 'label' => __('Brands', 'ai-eshop-optimizer'), 'type' => 'integer', 'width' => '70px'), array('key' => 'skus', 'label' => __('SKUs', 'ai-eshop-optimizer'), 'type' => 'integer', 'width' => '80px'), array('key' => 'products', 'label' => __('Products', 'ai-eshop-optimizer'), 'type' => 'integer', 'width' => '80px'), ), 'actions' => array( array('id' => 'edit', 'label' => __('Edit', 'ai-eshop-optimizer')), ), )); ?> 'suppliers-form', 'icon' => 'plus', 'title' => __('New supplier', 'ai-eshop-optimizer'), 'description' => __('Add a supplier, or edit one picked from the list, with the details the ordering screens use.', 'ai-eshop-optimizer'), 'footer' => \Rooster\Admin\States::save_button('aieo-sup-form', array('label' => __('Save supplier', 'ai-eshop-optimizer'))) . \Rooster\Admin\Ui::button(__('New supplier', 'ai-eshop-optimizer'), array('attrs' => array('id' => 'aieo-sup-new'))) . '', )); echo $aieo_sup_open; $aieo_sup_ui = '\Rooster\Admin\Ui'; $aieo_sup_in = static function ($field, array $opts = array()) use ($aieo_sup_ui) { $opts['id'] = 'aieo-sup-' . str_replace('_', '-', $field); $opts['attrs'] = array('data-sup-field' => $field); return $aieo_sup_ui::input($field, '', $opts); }; $aieo_sup_part = static function ($label, $field, array $opts = array()) use ($aieo_sup_in) { return array('label' => $label, 'id' => 'aieo-sup-' . str_replace('_', '-', $field), 'control' => $aieo_sup_in($field, $opts)); }; $aieo_sup_owner_options = array('' => __('— nobody —', 'ai-eshop-optimizer')); foreach ($owners as $aieo_u) { $aieo_sup_owner_options[(string) $aieo_u->ID] = $aieo_u->display_name; } $aieo_sup_rows = '' . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-name', 'label' => __('Name', 'ai-eshop-optimizer'), 'required' => true, 'control' => $aieo_sup_ui::input('name', '', array('id' => 'aieo-sup-name', 'medium' => true, 'required' => true)), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-erp', 'label' => __('ERP identity', 'ai-eshop-optimizer'), 'parts' => array( $aieo_sup_part(__('ERP id', 'ai-eshop-optimizer'), 'erp_id', array('medium' => true, 'code' => true)), $aieo_sup_part(__('ERP SKU code', 'ai-eshop-optimizer'), 'erp_sku_code', array('medium' => true, 'code' => true)), $aieo_sup_part(__('VAT', 'ai-eshop-optimizer'), 'vat_code', array('short' => true, 'code' => true)), ), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-address', 'label' => __('Address', 'ai-eshop-optimizer'), 'group' => true, 'control' => '
' . $aieo_sup_in('address_line_1', array('medium' => true, 'placeholder' => __('Street', 'ai-eshop-optimizer'), 'aria-label' => __('Street', 'ai-eshop-optimizer'))) . '
' . \Rooster\Admin\Fields::compound(array( $aieo_sup_part(__('City', 'ai-eshop-optimizer'), 'address_city', array('medium' => true)), $aieo_sup_part(__('Region', 'ai-eshop-optimizer'), 'address_region', array('medium' => true)), $aieo_sup_part(__('Postal code', 'ai-eshop-optimizer'), 'address_postal_code', array('short' => true)), ), array('label' => __('Address', 'ai-eshop-optimizer'))), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-phones', 'label' => __('Contact', 'ai-eshop-optimizer'), 'parts' => array( $aieo_sup_part(__('Phone 1', 'ai-eshop-optimizer'), 'tel_1', array('short' => true, 'type' => 'tel')), $aieo_sup_part(__('Phone 2', 'ai-eshop-optimizer'), 'tel_2', array('short' => true, 'type' => 'tel')), $aieo_sup_part(__('Fax', 'ai-eshop-optimizer'), 'fax', array('short' => true, 'type' => 'tel')), ), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-email', 'label' => __('Email', 'ai-eshop-optimizer'), 'control' => $aieo_sup_in('email', array('medium' => true, 'type' => 'email')), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-corporate-email', 'label' => __('Corporate email', 'ai-eshop-optimizer'), 'control' => $aieo_sup_in('corporate_email', array('medium' => true, 'type' => 'email')), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-corporate-url', 'label' => __('Website', 'ai-eshop-optimizer'), 'control' => $aieo_sup_in('corporate_url', array('type' => 'url', 'placeholder' => 'https://')), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-terms', 'label' => __('Commercial terms', 'ai-eshop-optimizer'), 'parts' => array( $aieo_sup_part(__('Lead time (days)', 'ai-eshop-optimizer'), 'lead_time_days', array('xs' => true, 'type' => 'number', 'min' => '0')), $aieo_sup_part(__('Payment terms (days)', 'ai-eshop-optimizer'), 'payment_terms_days', array('xs' => true, 'type' => 'number', 'min' => '0')), $aieo_sup_part(__('Special discount %', 'ai-eshop-optimizer'), 'special_discount_pct', array('xs' => true, 'type' => 'number', 'step' => 'any')), ), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-owner', 'label' => __('Owner', 'ai-eshop-optimizer'), 'help' => __('Who manages this supplier relationship.', 'ai-eshop-optimizer'), 'control' => $aieo_sup_ui::select('supplier_owner_user_id', $aieo_sup_owner_options, '', array('id' => 'aieo-sup-owner', 'attrs' => array('data-sup-field' => 'supplier_owner_user_id'))), )) . $aieo_sup_ui::field_row(array( 'id' => 'aieo-sup-notes', 'label' => __('Notes', 'ai-eshop-optimizer'), 'control' => $aieo_sup_ui::textarea('notes', '', array('id' => 'aieo-sup-notes', 'rows' => 3, 'attrs' => array('data-sup-field' => 'notes'))), )); $aieo_sup_form = AIEO_DMM_UI::card_form('aieo_dmm_supplier_save', 'suppliers', 'aieo-sup-form', '
' . $aieo_sup_rows . '
'); echo $aieo_sup_form; echo $aieo_sup_close; ?>