Untitled
unknown
plain_text
a month ago
4.4 kB
5
Indexable
Never
else if ($action == 'getIk' || $action == 'getIkManual') { $query->leftJoin('bom_articles', 'bom_articles.id', '=', 'iks.bom_article_id'); $query->leftJoin('items', 'items.id', '=', 'bom_articles.finished_article_id'); $query->leftJoin('category_sizes', 'category_sizes.id', '=', 'iks.category_size_id'); $query->leftJoin('items as sole_article', 'sole_article.id', '=', 'iks.sole_article_id'); $query->leftJoin('items as upper_article', 'upper_article.id', '=', 'iks.upper_article_id'); $query->leftJoin('users as created_user', 'created_user.id', '=', 'iks.created_by'); $query->leftJoin('users as updated_user', 'updated_user.id', '=', 'iks.updated_by'); $query->leftJoin('users as deleted_user', 'deleted_user.id', '=', 'iks.deleted_by'); $query->leftJoin('ik_print_slipper_details', 'ik_print_slipper_details.ik_id', '=', 'iks.id'); $query->leftJoin('ik_print_upper_details', 'ik_print_upper_details.ik_id', '=', 'iks.id'); $query->leftJoin('ik_transactions', 'ik_transactions.ik_id', '=', 'iks.id'); $query->leftJoin(DB::raw("(SELECT ik_id, STRING_AGG(DISTINCT transaction_code, ', ') AS sales_order_code FROM ik_transactions WHERE table_name = 'sales_orders' GROUP BY ik_id) as sales_orders"), 'sales_orders.ik_id', '=', 'iks.id'); $query->leftJoin(DB::raw("(SELECT ik_id, STRING_AGG(DISTINCT transaction_code, ', ') AS marketing_order_code FROM ik_transactions WHERE table_name = 'marketing_orders' GROUP BY ik_id) as marketing_orders"), 'marketing_orders.ik_id', '=', 'iks.id'); $query->select( 'iks.*', 'bom_articles.code as bom_article_code', 'bom_articles.id as bom_article_id', 'items.id as item_id', 'items.code as finished_article_code', 'items.name as finished_article_name', 'items.conversion2 as conversion2', 'items.conversion3 as conversion3', 'category_sizes.name as category_size_name', 'category_sizes.code as category_size_code', 'category_sizes.id as category_size_id', 'sole_article.id as sole_article_id', 'sole_article.code as sole_article_code', 'upper_article.id as upper_article_id', 'upper_article.code as upper_article_code', DB::raw("STRING_AGG(DISTINCT ik_print_slipper_details.size, '|') as ik_print_slipper_detail_size"), DB::raw("STRING_AGG(DISTINCT ik_print_upper_details.size, '|') as ik_print_upper_detail_size"), DB::raw("STRING_AGG(DISTINCT ik_print_slipper_details.size, '|') as ik_take_slipper_stock_detail_size"), DB::raw("STRING_AGG(DISTINCT ik_print_upper_details.size, '|') as ik_take_upper_stock_detail_size"), 'sales_orders.sales_order_code', 'marketing_orders.marketing_order_code', 'created_user.name AS created_by', 'updated_user.name AS updated_by', 'deleted_user.name AS deleted_by' ); $query->groupBy( 'iks.id', 'bom_articles.code', 'bom_articles.id', 'items.id', 'items.code', 'items.name', 'items.conversion2', 'items.conversion3', 'category_sizes.id', 'sole_article.id', 'sole_article.code', 'upper_article.id', 'upper_article.code', 'category_sizes.name', 'category_sizes.code', 'sales_orders.sales_order_code', 'marketing_orders.marketing_order_code', 'created_user.name', 'updated_user.name', 'deleted_user.name' ); if ($action == 'getIk') { $query->where('is_manual', false); } else { $query->where('is_manual', true); } }
Leave a Comment