@@ -882,7 +882,23 @@ static function getAllStatusArray($withmetaforsearch = false) {
882882 return $ all_status ;
883883 }
884884
885- static function getProcessingCriteria () {
885+ static function getAllCriteria () {
886+ return ['criteria ' => [['field ' => 4 ,
887+ 'searchtype ' => 'equals ' ,
888+ 'value ' => 'all ' ],
889+ ],
890+ 'reset ' => 'reset ' ];
891+ }
892+
893+ static function getNewCriteria () {
894+ return ['criteria ' => [['field ' => 4 ,
895+ 'searchtype ' => 'equals ' ,
896+ 'value ' => Ticket::INCOMING ],
897+ ],
898+ 'reset ' => 'reset ' ];
899+ }
900+
901+ static function getAssignedCriteria () {
886902 return ['criteria ' => [['field ' => 4 ,
887903 'searchtype ' => 'equals ' ,
888904 'value ' => 'process ' ],
@@ -909,38 +925,47 @@ static function getValidateCriteria() {
909925 }
910926
911927 static function getSolvedCriteria () {
912- $ currentUser = Session::getLoginUserID ();
913928 return ['criteria ' => [
914- [' link ' => ' AND ' ,
929+ [
915930 'criteria ' => [[
916- 'link ' => 'AND ' ,
931+ 'link ' => 'OR ' ,
917932 'field ' => 4 ,
918933 'searchtype ' => 'equals ' ,
919- 'value ' => ' old ' , // see Ticket::getAllStatusArray()
934+ 'value ' => Ticket:: SOLVED , // see Ticket::getAllStatusArray()
920935 ],
921936 ['field ' => 4 ,
922937 'searchtype ' => 'equals ' ,
923938 'value ' => PluginFormcreatorFormAnswer::STATUS_REFUSED ,
924939 'link ' => 'OR ' ]
925940 ]],
926- ['link ' => 'OR ' ,
941+ ],
942+ 'reset ' => 'reset ' ];
943+ }
944+
945+ static function getClosedCriteria () {
946+ return ['criteria ' => [['field ' => 4 ,
947+ 'searchtype ' => 'equals ' ,
948+ 'value ' => Ticket::CLOSED ],
949+ ],
950+ 'reset ' => 'reset ' ];
951+ }
952+
953+ static function getOldCriteria () {
954+ $ currentUser = Session::getLoginUserID ();
955+ return ['criteria ' => [
956+ ['link ' => 'AND ' ,
927957 'criteria ' => [[
928958 'link ' => 'AND ' ,
929- 'field ' => 9 ,
930- 'searchtype ' => 'equals ' ,
931- 'value ' => $ currentUser ,
932- ],
933- ['link ' => 'OR ' ,
934- 'field ' => 16 ,
959+ 'field ' => 4 ,
935960 'searchtype ' => 'equals ' ,
936- 'value ' => 'mygroups ' ,
961+ 'value ' => 'old ' , // see Ticket::getAllStatusArray()
937962 ],
938- ]],
939- ['link ' => 'AND ' ,
940- 'field ' => 4 ,
963+ ['field ' => 4 ,
941964 'searchtype ' => 'equals ' ,
942965 'value ' => PluginFormcreatorFormAnswer::STATUS_REFUSED ,
966+ 'link ' => 'OR ' ]
943967 ]],
968+ ],
944969 'reset ' => 'reset ' ];
945970 }
946971
@@ -982,25 +1007,52 @@ public function prepareInputForUpdate($input) {
9821007 }
9831008
9841009 public static function nbIssues (array $ params ): array {
1010+ $ default_params = [
1011+ 'label ' => "" ,
1012+ 'icon ' => Ticket::getIcon (),
1013+ 'apply_filters ' => [],
1014+ ];
1015+ $ params = array_merge ($ default_params , $ params );
1016+
9851017 switch ($ params ['status ' ]) {
986- case 'processing ' :
987- $ searchCriteria = PluginFormcreatorIssue::getProcessingCriteria ();
988- $ icon = '' ;
1018+ case 'all ' :
1019+ $ searchCriteria = PluginFormcreatorIssue::getAllCriteria ();
1020+ $ params ['icon ' ] = "" ;
1021+ break ;
1022+
1023+ case 'incoming ' :
1024+ $ searchCriteria = PluginFormcreatorIssue::getNewCriteria ();
1025+ $ params ['icon ' ] = Ticket::getIcon ();
9891026 break ;
9901027
9911028 case 'waiting ' :
9921029 $ searchCriteria = PluginFormcreatorIssue::getWaitingCriteria ();
993- $ icon = 'far fa-clock ' ;
1030+ $ params ['icon ' ] = "fas fa-pause-circle " ;
1031+ break ;
1032+
1033+ case 'assigned ' :
1034+ $ searchCriteria = PluginFormcreatorIssue::getAssignedCriteria ();
1035+ $ params ['icon ' ] = "fas fa-users " ;
9941036 break ;
9951037
9961038 case 'validate ' :
1039+ $ params ['icon ' ] = "far fa-eye " ;
9971040 $ searchCriteria = PluginFormcreatorIssue::getValidateCriteria ();
998- $ icon = '' ;
9991041 break ;
10001042
10011043 case 'solved ' :
1044+ $ params ['icon ' ] = "far fa-check-square " ;
10021045 $ searchCriteria = PluginFormcreatorIssue::getSolvedCriteria ();
1003- $ icon = '' ;
1046+ break ;
1047+
1048+ case 'closed ' :
1049+ $ params ['icon ' ] = "fas fa-archive " ;
1050+ $ searchCriteria = PluginFormcreatorIssue::getClosedCriteria ();
1051+ break ;
1052+
1053+ case 'old ' :
1054+ $ params ['icon ' ] = "fas fa-archive " ;
1055+ $ searchCriteria = PluginFormcreatorIssue::getOldCriteria ();
10041056 break ;
10051057 }
10061058 $ searchWaiting = Search::getDatas (
@@ -1014,14 +1066,79 @@ public static function nbIssues(array $params): array {
10141066
10151067 $ url = self ::getSearchURL ();
10161068 $ url .= '? ' . Toolbox::append_params ($ searchCriteria );
1017- $ label = $ params ['label ' ];
10181069 return [
10191070 'number ' => $ count ,
10201071 'url ' => $ url ,
1021- 'label ' => $ label ,
1022- 'icon ' => $ icon ,
1072+ 'label ' => $ params [ ' label ' ] ,
1073+ 'icon ' => $ params [ ' icon ' ] ,
10231074 's_criteria ' => $ searchCriteria ,
10241075 'itemtype ' => 'Ticket ' ,
10251076 ];
10261077 }
1078+
1079+ public static function getIssuesSummary (array $ params = []) {
1080+ $ default_params = [
1081+ 'label ' => "" ,
1082+ 'icon ' => "" ,
1083+ 'apply_filters ' => [],
1084+ ];
1085+ $ params = array_merge ($ default_params , $ params );
1086+
1087+ $ all = self ::nbIssues ($ params + ['status ' => 'all ' ]);
1088+ $ new = self ::nbIssues ($ params + ['status ' => 'incoming ' ]);
1089+ $ waiting = self ::nbIssues ($ params + ['status ' => 'waiting ' ]);
1090+ $ incoming = self ::nbIssues ($ params + ['status ' => 'assigned ' ]);
1091+ $ validate = self ::nbIssues ($ params + ['status ' => 'validate ' ]);
1092+ $ solved = self ::nbIssues ($ params + ['status ' => 'solved ' ]);
1093+ $ closed = self ::nbIssues ($ params + ['status ' => 'closed ' ]);
1094+
1095+ return [
1096+ 'data ' => [
1097+ [
1098+ 'number ' => $ all ['number ' ],
1099+ 'label ' => __ ("All " , 'formcreator ' ),
1100+ 'url ' => $ all ['url ' ],
1101+ // 'color' => '#3bc519',
1102+ ],
1103+ [
1104+ 'number ' => $ new ['number ' ],
1105+ 'label ' => __ ("New " ),
1106+ 'url ' => $ new ['url ' ],
1107+ 'color ' => '#3bc519 ' ,
1108+ ],
1109+ [
1110+ 'number ' => $ incoming ['number ' ],
1111+ 'label ' => __ ("Assigned " ),
1112+ 'url ' => $ incoming ['url ' ],
1113+ 'color ' => '#f1cd29 ' ,
1114+ ],
1115+ [
1116+ 'number ' => $ waiting ['number ' ],
1117+ 'label ' => __ ("Waiting " ),
1118+ 'url ' => $ waiting ['url ' ],
1119+ 'color ' => '#f1a129 ' ,
1120+ ],
1121+ [
1122+ 'number ' => $ validate ['number ' ],
1123+ 'label ' => __ ("To validate " ),
1124+ 'url ' => $ validate ['url ' ],
1125+ 'color ' => '#266ae9 ' ,
1126+ ],
1127+ [
1128+ 'number ' => $ solved ['number ' ],
1129+ 'label ' => __ ("Solved " ),
1130+ 'url ' => $ solved ['url ' ],
1131+ 'color ' => '#edc949 ' ,
1132+ ],
1133+ [
1134+ 'number ' => $ closed ['number ' ],
1135+ 'label ' => __ ("Closed " ),
1136+ 'url ' => $ closed ['url ' ],
1137+ 'color ' => '#555555 ' ,
1138+ ],
1139+ ],
1140+ // 'label' => '$params['label']',
1141+ 'icon ' => $ params ['icon ' ],
1142+ ];
1143+ }
10271144}
0 commit comments