Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16128 Rev 16131
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) {
87
            foreach ($prioritized as $key => $value) {
88
                    $raw = trim($value->getRaw());
88
                $raw = trim($value->getRaw());
89
 
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');
104
                    $endDate = date('Y-m-d');
105
        }
105
                }
106
 
106
 
107
        $startDate = '2023-01-01';
107
                $startDate = '2023-01-01';
108
        $endDate = '2023-05-16';
108
                $endDate = '2023-05-16';
109
 
109
 
110
        $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
110
                $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
111
        $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
111
                $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
112
 
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 115... Línea 115...
115
            $endDate = date('Y-m-d');
115
                    $endDate = date('Y-m-d');
116
        } else {
116
                } else {
117
 
117
 
118
            if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
118
                    if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
119
                $startDate = date('Y-m-d');
-
 
120
                $endDate = date('Y-m-d');
119
                        $startDate = date('Y-m-d');
121
            }
120
                        $endDate = date('Y-m-d');
122
        }
121
                    }
123
 
122
                }
124
        $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
123
 
125
        $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
124
                $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
126
 
125
                $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
127
 
126
 
128
        $total = count($dailyProgress);
127
 
129
        $users = [];
128
                $total = count($dailyProgress);
130
        $added_on = [];
129
                $users = [];
131
        $total = [];
130
                $added_on = [];
132
        $data = [];
131
                $total = [];
133
        $data = [
132
                $data = [
-
 
133
                    'total_by_day' => [],
-
 
134
                    'added_on' => [],
-
 
135
                    'total' => []
-
 
136
                ];
Línea 134... Línea -...
134
            'total_by_day' => [],
-
 
135
            'added_on' => [],
-
 
136
            'total' => []
-
 
137
        ];
137
 
138
 
-
 
139
        foreach ($dailyProgress as $record) {
138
                foreach ($dailyProgress as $record) {
140
            $users = $record['user_id'];
139
                    $users = $record['user_id'];
141
            $added_on = $record['added_on'];
140
                    $added_on = $record['added_on'];
142
            $total = count($dailyProgress);
141
                    $total = count($dailyProgress);
143
            array_push($data['total_by_day'], $users);
142
                    array_push($data['total_by_day'], $users);
144
            array_push($data['added_on'], $added_on);
143
                    array_push($data['added_on'], $added_on);
145
            array_push($data['total'], $total);
144
                    array_push($data['total'], $total);
146
        }
145
                }
147
 
146
 
148
        // array_push($data['total_by_day'], $users);
147
                // array_push($data['total_by_day'], $users);
149
        // array_push($data['added_on'], $added_on);
148
                // array_push($data['added_on'], $added_on);
150
        // array_push($data['total'], $total);
149
                // array_push($data['total'], $total);
151
 
150