Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16118 | Rev 16125 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16118 Rev 16124
Línea 73... Línea 73...
73
        $currentUser = $currentUserPlugin->getUser();
73
        $currentUser = $currentUserPlugin->getUser();
74
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
74
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
75
        $currentNetwork = $currentNetworkPlugin->getNetwork();
75
        $currentNetwork = $currentNetworkPlugin->getNetwork();
76
        $request = $this->getRequest();
76
        $request = $this->getRequest();
Línea 77... Línea 77...
77
 
77
 
78
        if ($request->isGet()) {
78
        //if ($request->isGet()) {
79
            $headers  = $request->getHeaders();
79
        $headers  = $request->getHeaders();
Línea 80... Línea 80...
80
            $isJson = false;
80
        $isJson = false;
81
 
81
 
Línea 82... Línea 82...
82
            if ($headers->has('Accept')) {
82
        if ($headers->has('Accept')) {
Línea 83... Línea 83...
83
                $accept = $headers->get('Accept');
83
            $accept = $headers->get('Accept');
84
 
84
 
Línea 85... Línea 85...
85
                $prioritized = $accept->getPrioritized();
85
            $prioritized = $accept->getPrioritized();
86
 
86
 
87
                foreach ($prioritized as $key => $value) {
-
 
88
                    $raw = trim($value->getRaw());
87
            foreach ($prioritized as $key => $value) {
89
 
88
                $raw = trim($value->getRaw());
-
 
89
 
Línea 90... Línea 90...
90
                    if (!$isJson) {
90
                if (!$isJson) {
91
                        $isJson = strpos($raw, 'json');
91
                    $isJson = strpos($raw, 'json');
92
                    }
92
                }
93
                }
93
            }
94
            }
94
        }
Línea 95... Línea 95...
95
 
95
 
96
            if ($isJson) {
96
        if ($isJson) {
97
                $startDate = $this->params()->fromQuery('startDate');
97
            $startDate = $this->params()->fromQuery('startDate');
98
                if (empty($startDate)) {
98
            if (empty($startDate)) {
Línea 99... Línea 99...
99
                    $startDate = date('Y-m-d');
99
                $startDate = date('Y-m-d');
100
                }
100
            }
Línea 101... Línea 101...
101
 
101
 
102
                $endDate = $this->params()->fromQuery('endDate');
102
            $endDate = $this->params()->fromQuery('endDate');
Línea 103... Línea 103...
103
                if (empty($endDate)) {
103
            if (empty($endDate)) {
-
 
104
                $endDate = date('Y-m-d');
-
 
105
            }
-
 
106
 
-
 
107
            $startDate = '2023-01-01';
-
 
108
            $endDate = '2023-05-16';
104
                    $endDate = date('Y-m-d');
109
 
105
                }
110
            $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
106
 
-
 
107
                $startDate = '2023-01-01';
-
 
108
                $endDate = '2023-05-16';
-
 
109
 
-
 
110
                $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
-
 
111
                $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
112
 
111
            $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
112
 
Línea 113... Línea 113...
113
                if (!$dtStartDate || !$dtEndDate) {
113
            if (!$dtStartDate || !$dtEndDate) {
114
                    $startDate = date('Y-m-d');
114
                $startDate = date('Y-m-d');
Línea -... Línea 115...
-
 
115
                $endDate = date('Y-m-d');
-
 
116
            } else {
-
 
117
 
-
 
118
                if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
119
                    $startDate = date('Y-m-d');
-
 
120
                    $endDate = date('Y-m-d');
-
 
121
                }
-
 
122
            }
-
 
123
 
-
 
124
            $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
-
 
125
            $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
-
 
126
 
-
 
127
 
115
                    $endDate = date('Y-m-d');
128
            $total = count($dailyProgress);
116
                } else {
-
 
117
 
-
 
118
                    if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
119
                        $startDate = date('Y-m-d');
-
 
120
                        $endDate = date('Y-m-d');
-
 
121
                    }
-
 
122
                }
-
 
123
 
-
 
124
                $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
-
 
125
                $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
-
 
126
 
-
 
127
 
-
 
128
                $total = count($dailyProgress);
-
 
129
                $users = [];
129
            $users = [];
130
                $added_on = [];
130
            $added_on = [];
131
                $total = [];
131
            $total = [];
132
                $data = [
132
            $data = [
Línea 133... Línea 133...
133
                    'total_by_day' => [],
133
                'total_by_day' => [],
134
                    'added_on' => [],
134
                'added_on' => [],
135
                    'total' => []
135
                'total' => []
Línea 136... Línea 136...
136
                ];
136
            ];
137
 
137
 
138
                foreach ($dailyProgress as $record) {
138
            foreach ($dailyProgress as $record) {
139
                    $users = $record['user_id'];
139
                $users = $record['user_id'];
140
                    $added_on = $record['added_on'];
140
                $added_on = $record['added_on'];
141
                    $total = count($dailyProgress);
141
                $total = count($dailyProgress);
142
                    array_push($data['total_by_day'], $users);
142
                array_push($data['total_by_day'], $users);
143
                    array_push($data['added_on'], $added_on);
143
                array_push($data['added_on'], $added_on);
144
                    array_push($data['total'], $total);
144
                array_push($data['total'], $total);
145
                }
-
 
146
 
145
            }
-
 
146
 
147
                // array_push($data['total_by_day'], $users);
147
            // array_push($data['total_by_day'], $users);
148
                // array_push($data['added_on'], $added_on);
148
            // array_push($data['added_on'], $added_on);