Proyectos de Subversion LeadersLinked - Backend

Rev

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

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