|
|
@@ -1000,10 +1000,12 @@ class common {
|
|
|
$Management = common::getdefaultManagement();
|
|
|
}else{
|
|
|
$Management = json_decode($user_management,true);
|
|
|
+ $Management = common::insertRevenueSpent($Management,_isRevenueDisplay());
|
|
|
foreach($Management as $key =>$val){
|
|
|
- $Management[$key]['id'] = intval($val['id']);
|
|
|
+ $Management[$key]['id'] = ($key +1);
|
|
|
$Management[$key]['switchValue'] = $val['switchValue'] == "true" ? true : false;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
$user_dashboard_filter = $user_management_data['dashboard_filter'];
|
|
|
$dashboard_filter =array();
|
|
|
@@ -1076,6 +1078,72 @@ class common {
|
|
|
return array("Management" => $Management,"dashboard_filter" =>$dashboard_filter);
|
|
|
}
|
|
|
|
|
|
+ public static function insertRevenueSpent($array, $isRevenueDisplay) {
|
|
|
+ if (!$isRevenueDisplay){
|
|
|
+ // 移除 Revenue Spent(如果存在)
|
|
|
+ foreach ($array as $index => $item) {
|
|
|
+ if (isset($item['title']) && $item['title'] === "Revenue Spent") {
|
|
|
+ unset($array[$index]);
|
|
|
+ // 重置索引
|
|
|
+ $array = array_values($array);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $array;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否已经存在 Revenue Spent
|
|
|
+ foreach ($array as $item) {
|
|
|
+ if (isset($item['title']) && $item['title'] === 'Revenue Spent') {
|
|
|
+ return; // 已存在,不插入
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找插入位置
|
|
|
+ $insertAfterTitles = ["Container Count", "ETD to ETA (Days)", "Pending", "KPI"];
|
|
|
+ $insertIndex = null;
|
|
|
+ // 遍历数组,记录每个优先级字段的位置
|
|
|
+ $positions = [];
|
|
|
+
|
|
|
+ foreach ($array as $index => $item) {
|
|
|
+ if (isset($item['title'])) {
|
|
|
+ $key = array_search($item['title'], $insertAfterTitles);
|
|
|
+ if ($key !== false) {
|
|
|
+ $positions[$key] = $index;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 找出最早出现的那个标题
|
|
|
+ ksort($positions); // 按优先级排序
|
|
|
+ foreach ($positions as $pos) {
|
|
|
+ $insertIndex = $pos + 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果都没有匹配项,插到开头
|
|
|
+ if ($insertIndex === null) {
|
|
|
+ $newItem = [
|
|
|
+ "id" => 0, // 可选:生成唯一 ID
|
|
|
+ "title" => "Revenue Spent",
|
|
|
+ "switchValue" => "true",
|
|
|
+ "text" => "Description for Revenue Spent"
|
|
|
+ ];
|
|
|
+ array_unshift($array, $newItem);
|
|
|
+ } else {
|
|
|
+ // 要插入的新元素
|
|
|
+ $newItem = [
|
|
|
+ "id" => 0, // 可选:重新排序后,最后都要循环,重新赋值id
|
|
|
+ "title" => "Revenue Spent",
|
|
|
+ "switchValue" => "true",
|
|
|
+ "text" => "Description for Revenue Spent"
|
|
|
+ ];
|
|
|
+ array_splice($array, $insertIndex, 0, [$newItem]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return array_values($array);
|
|
|
+ }
|
|
|
+
|
|
|
public static function getItemStyle($type,$code){
|
|
|
if($type == 'r1'){
|
|
|
$data = array("0-20 Days" =>"#ffc594",
|
|
|
@@ -2929,7 +2997,7 @@ class common {
|
|
|
$timeline_view = "## Timeline View: \n";
|
|
|
}
|
|
|
foreach($dateGroups as $key => $tv_count){
|
|
|
- $timeline_view.="- ".$tv_count['_eventdate'].": ".$tv_count['total_count']." containers have been updated \n";
|
|
|
+ $timeline_view.="- ".$tv_count['_insert_date'].": ".$tv_count['total_count']." containers have been updated \n";
|
|
|
}
|
|
|
$total = array("Timeline View" =>$timeline_view);
|
|
|
$reference = utils::replacementsFixed($total,$reference,array("Timeline View"));
|