Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16141 Rev 16143
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
            }
-
 
95
 
-
 
96
            if ($isJson) {
-
 
97
                $startDate = $this->params()->fromQuery('startDate');
-
 
98
                if (empty($startDate)) {
-
 
99
                    $startDate = date('Y-m-d');
94
        }
100
                }
-
 
101
 
-
 
102
                $endDate = $this->params()->fromQuery('endDate');
-
 
103
                if (empty($endDate)) {
-
 
104
                    $endDate = date('Y-m-d');
-
 
105
                }
-
 
Línea 106... Línea -...
106
 
-
 
107
                $startDate = '2023-01-01';
95
 
108
                $endDate = '2023-05-16';
-
 
109
 
96
        //if ($isJson) {
110
                $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
-
 
111
                $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
112
 
-
 
113
                if (!$dtStartDate || !$dtEndDate) {
97
        $startDate = $this->params()->fromQuery('startDate');
114
                    $startDate = date('Y-m-d');
-
 
115
                    $endDate = date('Y-m-d');
98
        if (empty($startDate)) {
Línea 116... Línea 99...
116
                } else {
99
            $startDate = date('Y-m-d');
117
 
100
        }
Línea -... Línea 101...
-
 
101
 
-
 
102
        $endDate = $this->params()->fromQuery('endDate');
Línea 118... Línea 103...
118
                    if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
103
        if (empty($endDate)) {
119
                        $startDate = date('Y-m-d');
-
 
120
                        $endDate = date('Y-m-d');
-
 
121
                    }
104
            $endDate = date('Y-m-d');
122
                }
-
 
123
 
-
 
124
                $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
-
 
125
                $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
105
        }
126
 
106
 
127
 
107
        $startDate = '2023-01-01';
128
                $total = count($dailyProgress);
108
        $endDate = '2023-05-16';
129
                $users = [];
109
 
130
                $added_on = [];
110
        $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
131
                $total = [];
111
        $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
132
                $data = [
-
 
133
                    'total_by_day' => [],
-
 
134
                    'added_on' => [],
-
 
135
                    'total' => []
112
 
Línea 136... Línea 113...
136
                ];
113
        if (!$dtStartDate || !$dtEndDate) {
137
 
114
            $startDate = date('Y-m-d');
138
                foreach ($dailyProgress as $record) {
-
 
Línea 139... Línea 115...
139
                    $users = $record['user_id'];
115
            $endDate = date('Y-m-d');
-
 
116
        } else {
-
 
117
 
-
 
118
            if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
119
                $startDate = date('Y-m-d');
140
                    $added_on = $record['added_on'];
120
                $endDate = date('Y-m-d');
141
                    $total = count($dailyProgress);
121
            }
142
                    array_push($data['total_by_day'], $users);
122
        }
143
                    array_push($data['added_on'], $added_on);
123
 
-
 
124
        $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
-
 
125
        $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
-
 
126
 
144
                    array_push($data['total'], $total);
127
 
145
                }
128
        //$total = count($dailyProgress);
146
 
129
        $users = [];
-
 
130
        $added_on = [];
-
 
131
        //$total = [];
-
 
132
        $data = [
-
 
133
            //'total_by_day' => [],
-
 
134
            //'added_on' => [],
147
                // array_push($data['total_by_day'], $users);
135
            //'total' => []
148
                // array_push($data['added_on'], $added_on);
136
        ];
-
 
137
 
149
                // array_push($data['total'], $total);
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);
-
 
143
            //($data['added_on'], $added_on);
-
 
144
 
-
 
145
 
-
 
146
            array_push($data, [
-
 
147
                'total_by_day' => $users,
-
 
148
                'added_on' => $added_on
-
 
149
            ]);
-
 
150
            //array_push($data['total'], $total);
-
 
151
        }
-
 
152
 
-
 
153
        // array_push($data['total_by_day'], $users);
-
 
154
        // array_push($data['added_on'], $added_on);
-
 
155
        // array_push($data['total'], $total);
150
 
156
 
151
 
157