Code Duplication    Length = 26-26 lines in 2 locations

code/reports/PaymentsReport.php 1 location

@@ 178-203 (lines=26) @@
175
    }
176
177
178
    public function setstatus()
179
    {
180
        $id = $this->urlParams['ID'];
181
        if (!is_numeric($id)) {
182
            return "could not update payment status";
183
        }
184
        $payment = DataObject::get_by_id('Payment', $id);
185
        if ($payment) {
186
            $oldStatus = $payment->Status;
187
            $newStatus = $this->urlParams['OtherID'];
188
            if ($oldStatus != $newStatus) {
189
                $payment->Status = $newStatus;
190
                $payment->write();
191
                $orderLog = new OrderStatusLog();
192
                $orderLog->OrderID = $orderLog->OrderID;
193
                $orderLog->Status = "Payment status changed from ".$oldStatus." to ".$newStatus.".";
194
                $orderLog->Note = "Payment changed from ".$oldStatus." to ".$newStatus.".";
195
                $orderLog->write();
196
            } else {
197
                return "no change";
198
            }
199
        } else {
200
            return "payment not found";
201
        }
202
        return "updated to ".$newStatus;
203
    }
204
}
205

code/reports/SalesReport.php 1 location

@@ 243-268 (lines=26) @@
240
    }
241
242
243
    public function setstatus()
244
    {
245
        $id = $this->urlParams['ID'];
246
        if (!is_numeric($id)) {
247
            return "could not update order status";
248
        }
249
        $order = DataObject::get_by_id('Order', $id);
250
        if ($order) {
251
            $oldStatus = $order->Status;
252
            $newStatus = $this->urlParams['OtherID'];
253
            if ($oldStatus != $newStatus) {
254
                $order->Status = $newStatus;
255
                $order->write();
256
                $orderlog = new OrderStatusLog();
257
                $orderlog->OrderID = $order->ID;
258
                $orderlog->Status = "Status changed from ".$oldStatus." to ".$newStatus.".";
259
                $orderlog->Note = "Status changed from ".$oldStatus." to ".$newStatus.".";
260
                $orderlog->write();
261
            } else {
262
                return "no change";
263
            }
264
        } else {
265
            return "order not found";
266
        }
267
        return "updated to ".$newStatus;
268
    }
269
270
    public function fullsalesexport()
271
    {