0 ) AS has_request, w.last_submitted_at FROM {prefix}aieo_dmm_preorder_vitals_stats s LEFT JOIN {prefix}aieo_dmm_branch_sales bs ON bs.branch_id = {$aieo_pw_id} AND bs.sku_norm = s.sku_norm LEFT JOIN {prefix}aieo_dmm_preorder_worksheet w ON w.product_id = s.product_id AND w.branch_id = {$aieo_pw_id} "; $aieo_pw_defs[] = array( 'id' => 'preorder_worksheet_' . $aieo_pw_slug, 'label' => $aieo_pw_label, 'description' => '', 'tier' => 'pro', 'scope' => 'local', 'source' => 'sql', 'sql' => $aieo_pw_sql, 'registry_id' => 'branch_scanner.worksheet_' . $aieo_pw_slug, 'version' => '1', 'per_page' => 50, 'row_key' => 'product_id', 'default_sort' => array( 'sales_30d', 'desc' ), 'empty_state' => 'The board source is empty. The nightly analytics pipeline (the store_sales_stats and preorder_vitals jobs) builds the preorder-eligible catalogue with per-branch sales; once it has run, the worksheet fills.', 'capabilities' => array( 'view' => 'aieo_preorder_ws_' . $aieo_pw_slug, 'edit' => 'aieo_preorder_ws_' . $aieo_pw_slug, 'execute' => 'aieo_preorder_ws_' . $aieo_pw_slug, ), 'bulk_actions' => array( array( 'id' => 'submit', 'label' => 'Submit requests', 'scope' => 'filter', 'confirm' => 'Submit requests from %1$s worksheet lines? Lines without a quantity are skipped, and a line with an open request updates that request instead of creating a duplicate.', ), array( 'id' => 'clear', 'label' => 'Clear quantities', 'scope' => 'filter', 'destructive' => true, 'confirm' => 'Clear the typed quantities on %1$s lines? Nothing is submitted.', ), ), 'columns' => array( array( 'key' => 'product_id', 'label' => 'Product ID', 'type' => 'id', 'sortable' => true, 'searchable' => true, 'hidden' => true, ), array( 'key' => 'select', 'label' => '', 'type' => 'selector', 'width' => '28px', 'sortable' => false, 'select' => "''", ), array( 'key' => 'image_url', 'label' => '', 'sr_label' => 'Product image', 'type' => 'image', 'format' => array( 'size' => 44, 'rehost' => true ), 'width' => '58px', 'sortable' => false, 'empty' => '', ), array( 'key' => 'name', 'label' => 'Product', 'type' => 'text', 'sortable' => true, 'searchable' => true, 'truncate' => 48, 'tooltip' => true, ), array( 'key' => 'sku', 'label' => 'SKU', 'type' => 'code', 'sortable' => true, 'searchable' => true, ), array( 'key' => 'brand', 'label' => 'Brand', 'type' => 'text', 'sortable' => true, 'filter' => 'select', ), array( 'key' => 'supplier', 'label' => 'Supplier', 'type' => 'text', 'sortable' => true, 'filter' => 'select', 'empty' => '— unresolved —', ), array( 'key' => 'menu_category', 'label' => 'Menu category', 'type' => 'text', 'filter' => 'select', 'truncate' => 28, 'tooltip' => true, ), array( 'key' => 'sales_30d', 'label' => 'Sales 30d', 'type' => 'integer', 'sortable' => true, 'filter' => 'number_range', ), array( 'key' => 'sales_60d', 'label' => 'Sales 60d', 'type' => 'integer', 'sortable' => true, ), array( 'key' => 'trend', 'label' => 'Trend', 'type' => 'decimal', 'width' => '80px', 'sortable' => true, 'format' => array( 'precision' => 2 ), 'empty' => '—', ), array( 'key' => 'existing_stock', 'label' => 'Existing Stock', 'type' => 'integer', 'width' => '110px', 'sortable' => true, 'editable' => true, 'format' => array( 'min' => 0 ), 'empty' => '', ), array( 'key' => 'desired_qty', 'label' => 'Requested Qty', 'type' => 'integer', 'width' => '110px', 'sortable' => true, 'editable' => true, 'format' => array( 'min' => 0 ), 'settable' => true, 'empty' => '', ), array( 'key' => 'has_request', 'label' => 'Has quantity', 'type' => 'boolean', 'filter' => 'select', ), array( 'key' => 'last_submitted_at', 'label' => 'Last submitted', 'type' => 'datetime', 'width' => '150px', 'nowrap' => true, 'tone' => 'secondary', 'sortable' => true, 'format' => array( 'tz' => 'utc' ), 'empty' => '—', ), array( 'key' => 'gtin', 'label' => 'GTIN', 'type' => 'code', 'searchable' => true, 'hidden' => true, ), ), ); } return $aieo_pw_defs;