Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16143 Rev 16144
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');
119
                        $startDate = date('Y-m-d');
120
                $endDate = date('Y-m-d');
120
                        $endDate = date('Y-m-d');
121
            }
121
                    }
122
        }
122
                }
123
 
123
 
124
        $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
124
                $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
125
        $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
125
                $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
126
 
126
 
127
 
127
 
128
        //$total = count($dailyProgress);
128
                //$total = count($dailyProgress);
129
        $users = [];
129
                $users = [];
130
        $added_on = [];
130
                $added_on = [];
131
        //$total = [];
131
                //$total = [];
132
        $data = [
132
                $data = [
133
            //'total_by_day' => [],
133
                    //'total_by_day' => [],
134
            //'added_on' => [],
134
                    //'added_on' => [],
135
            //'total' => []
135
                    //'total' => []
136
        ];
136
                ];
137
 
137
 
138
        foreach ($dailyProgress as $record) {
138
                foreach ($dailyProgress as $record) {
-
 
139
                    $users = $record['user_id'];
-
 
140
                    $added_on = $record['added_on'];
-
 
141
                    //$total = count($dailyProgress);
-
 
142
                    //array_push($data['total_by_day'], $users);
Línea 139... Línea -...
139
            $users = $record['user_id'];
-
 
140
            $added_on = $record['added_on'];
-
 
141
            //$total = count($dailyProgress);
-
 
142
            //array_push($data['total_by_day'], $users);
143
                    //($data['added_on'], $added_on);
143
            //($data['added_on'], $added_on);
-
 
144
 
144
 
145
 
145
 
146
            array_push($data, [
146
                    array_push($data, [
147
                'total_by_day' => $users,
147
                        'total_by_day' => $users,
148
                'added_on' => $added_on
148
                        'added_on' => $added_on
149
            ]);
149
                    ]);
150
            //array_push($data['total'], $total);
150
                    //array_push($data['total'], $total);
151
        }
151
                }
152
 
152
 
153
        // array_push($data['total_by_day'], $users);
153
                // array_push($data['total_by_day'], $users);
154
        // array_push($data['added_on'], $added_on);
154
                // array_push($data['added_on'], $added_on);
155
        // array_push($data['total'], $total);
155
                // array_push($data['total'], $total);
156
 
156