idNextcloud = $UserId; $this->myDb = $myDb; $this->urlGenerator = $urlGenerator; $this->mailer = $mailer; $this->config = $config; $this->orderService = $orderService; $this->navigationService = $navigationService; $this->configurationService = $configurationService; $this->logger = $logger; $this->orderPdfService = $orderPdfService; if ($userSession->isLoggedIn()) { $this->user = $userSession->getUser(); } if ($this->user != null) { $groups = $groupManager->getUserGroups($this->user); $this->groups = []; foreach ($groups as $group) { $this->groups[] = $group->getGID(); } } try{ $this->storage = $rootFolder->getUserFolder($this->idNextcloud); }catch(\OC\User\NoUserException $e){ } } private function getLogo(){ try { if(isset($this->storage)){ $file = $this->storage->get('/.gestion/logo.png'); }else{ return "nothing"; } } catch(\OCP\Files\NotFoundException $e) { return "nothing"; } return base64_encode($file->getContent()); } /** * @NoAdminRequired * @NoCSRFRequired */ public function order() { return new TemplateResponse('gestion', 'order', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); } /** * @NoAdminRequired * @NoCSRFRequired */ public function getOrdersWithDetails() { $orders = $this->orderService->getOrdersWithDetailsAsArray(); return json_encode($orders); } /** * @NoAdminRequired * @NoCSRFRequired */ public function createDefaultOrder() { try{ $this->orderService->createDefaultOrder($this->idNextcloud); return true; } catch(Exception $e){ return null; } } /** * @NoAdminRequired * @NoCSRFRequired */ public function updateOrderDate($orderId,$orderDate) { try{ $this->orderService->updateOrderDate($orderId,$orderDate); return true; } catch(Exception $e){ return null; } } /** * @NoAdminRequired * @NoCSRFRequired */ public function thanatoProductFee() { return new TemplateResponse('gestion', 'thanatoProductFee', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); } /** * @NoAdminRequired * @NoCSRFRequired */ public function getThanatoProductsFees() { $thanatoProductsFees = $this->orderService->getThanatoProductsFees(); return json_encode($thanatoProductsFees); } /** * @NoAdminRequired * @NoCSRFRequired */ public function createDefaultThanatoProductFee() { try{ $this->orderService->createDefaultThanatoProductFee(); return true; } catch(Exception $e){ return null; } } /** * @NoAdminRequired * @NoCSRFRequired * @param string $orderId */ public function orderDetails($orderId) { $orderWithDetail = $this->orderService->getOrderByIdWithDetails($orderId); return new TemplateResponse( 'gestion', 'orderDetails', array( 'groups' => $this->groups, 'user' => $this->user, "configuration" => json_decode(json_encode($this->configurationService->getDefaultConfiguration())), 'order'=>json_decode(json_encode($orderWithDetail)), 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink(), 'logo' => $this->getLogo() )); } /** * @NoAdminRequired * @NoCSRFRequired * @param string $orderId */ public function getOrderItemsByOrderId($orderId) { $orderProducts = $this->orderService->getOrderItemsByOrderId($orderId); return json_encode($orderProducts); } /** * @NoAdminRequired * @NoCSRFRequired * @param string $orderId */ public function getOrderTotalAmount($orderId) { $configuration = $this->configurationService->getDefaultConfiguration(); $orderTotalAmount = $this->orderService->getOrderTotalAmount($orderId,$configuration["tva_default"] ?? 0); return json_encode($orderTotalAmount); } /** * @NoAdminRequired * @NoCSRFRequired * @param string $orderId */ public function exportOrderToPdf($orderId) { try{ $factureFilenames = $this->orderPdfService->generateOrderPdfByOrderId($orderId,$this->idNextcloud); return json_encode($factureFilenames["filenames"]); } catch(\OCP\Files\NotFoundException $e) { } } /** * @NoAdminRequired * @NoCSRFRequired */ public function orderProduct() { return new TemplateResponse('gestion', 'orderProduct', array('groups' => $this->groups, 'user' => $this->user, 'path' => $this->idNextcloud, 'url' => $this->navigationService->getNavigationLink())); } /** * @NoAdminRequired * @NoCSRFRequired */ public function createDefaultOrderProduct() { try{ $this->orderService->createDefaultOrderProduct($this->idNextcloud); return true; } catch(Exception $e){ return null; } } /** * @NoAdminRequired * @NoCSRFRequired */ public function addOrderItems($orderId) { try{ $this->orderService->addDefaultOrderItem($orderId); return true; } catch(Exception $e){ return null; } } /** * @NoAdminRequired * @NoCSRFRequired */ public function getOrderProducts() { $orderProducts = $this->orderService->getOrderProducts(); return $orderProducts; } /** * @NoAdminRequired * @NoCSRFRequired * @param string $devisId */ public function getOrderDevisProduitsByDevisId($devisId) { return $this->orderService->getOrderDevisProduitsByDevisId($devisId); } /** * @NoAdminRequired * @NoCSRFRequired * @param string $devisId */ public function getTotalOrderDevisAmount($devisId) { $total = $this->orderService->getTotalOrderDevisAmount($devisId); $res = array(); $res['total'] = $total; return json_encode($res); } }