PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.12
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.12
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
fluent-boards / app / Hooks / Handlers / FluentCrmIntegration.php

FluentCrmIntegration.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.12, at app/Hooks/Handlers/FluentCrmIntegration.php

205 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Hooks\Handlers;
4
5 use FluentBoards\App\Models\Board;
6 use FluentBoards\App\Models\Meta;
7 use FluentBoards\App\Models\User;
8 use FluentBoards\App\Models\Task;
9 use FluentBoards\App\Services\Constant;
10
11 class FluentCrmIntegration
12 {
13 public function registerCustomSection()
14 {
15 $key = 'fluent_boards_in_fluent_crm';
16 $sectionTitle = __('FluentBoards', 'fluent-boards');
17 FluentCrmApi('extender')->addProfileSection($key, $sectionTitle, function ($contentArr, $subscriber) {
18 $contentArr['heading'] = __('Fluent Boards', 'fluent-boards');
19 $contentArr['content_html'] = $this->prepareHtml($subscriber);
20
21 return $contentArr;
22 });
23 }
24
25 public function prepareHtml($subscriber)
26 {
27 $temp = Meta::query()->where('value', $subscriber->id)
28 ->where('key', Constant::BOARD_ASSOCIATED_CRM_CONTACT)
29 ->where('object_type', Constant::OBJECT_TYPE_BOARD)
30 ->pluck('object_id');
31
32 $boards = Board::query()->whereIn('id', $temp)->get();
33
34 $taskGroups = Task::where('crm_contact_id', $subscriber->id)->with('board')->get()->groupBy((function ($data) {
35 return $data->board->title;
36 }));
37
38
39
40 $html = '';
41 $html .= '<style>
42 .fbs_associated_boards_wrap {
43 background: #FFFFFF;
44 box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
45 border-radius: 10px;
46 overflow: hidden;
47 margin-bottom: 30px;
48 }
49 .fbs_associated_boards_wrap .fbs_associated_board_header {
50 display: flex;
51 gap: 10px;
52 align-items: center;
53 justify-content: space-between;
54 padding: 14px 16px;
55 }
56 .fbs_associated_boards_wrap .fbs_associated_board_header h3 {
57 font-weight: 500;
58 font-size: 16px;
59 line-height: 140%;
60 color: #1F2022;
61 margin: 0;
62 }
63 .fbs_associated_boards_wrap .fbs_associated_board_header .fbs-go-to-board {
64 display: block;
65 background: #409eff;
66 color: #ffffff;
67 border-radius: 4px;
68 padding: 4px 10px;
69 font-size: 12px;
70 }
71 .fbs_associated_board_no_board{
72 background: #F6F7FA;
73 padding: 5px 15px;
74 }
75 .fbs_associated_board_all_boards{
76 padding: 15px 10px;
77 border-top: 2px solid #F6F7FA;
78 }
79 .fbs_associated_single-board{
80 height: auto;
81 padding: 5px;
82 line-height: 24px;
83 font-size: 11px;
84 white-space: normal;
85 word-break: break-all;
86 background: #e6ebf0;
87 margin-right: 10px;
88 color: #3c434a;
89 }
90 .fbs_associated_boards_wrap table {
91 width: 100%;
92 border-collapse: collapse;
93 background: white;
94 }
95 .fbs_associated_boards_wrap table thead tr {
96 border: none;
97 }
98 .fbs_associated_boards_wrap table thead tr th {
99 border: none;
100 background: #F6F7FA;
101 font-weight: 600;
102 font-size: 12px;
103 line-height: 120%;
104 color: #60646B;
105 padding: 13px 16px;
106 }
107 .fbs_associated_boards_wrap table thead tr th:first-child {
108 text-align: left;
109 }
110 .fbs_associated_boards_wrap table tbody tr td {
111 text-align: center;
112 font-weight: 400;
113 font-size: 14px;
114 line-height: 120%;
115 color: #60646B;
116 padding: 13px 16px;
117 border-bottom: 1px solid #E5E9EF;
118 }
119 .fbs_associated_boards_wrap table tbody tr td a {
120 color: #60646B;
121 display: block;
122 }
123 .fbs_associated_boards_wrap table tbody tr td a:hover {
124 color: #3C90FF;
125 }
126 .fbs_associated_boards_wrap table tbody tr td:first-child {
127 text-align: left;
128 }
129 </style>';
130
131 $html .= '<div class="fbs_associated_boards_wrap">';
132 $html .= '<div class="fbs_associated_board_header">
133 <h3>All Boards</h3>
134 </div>';
135 if (!$boards || $boards->isEmpty()) {
136 $html .= '<div class="fbs_associated_board_no_board">
137 <p>No Board is associated with this contact</p>
138 </div>';
139 }else{
140 $html .= '<div class="fbs_associated_board_all_boards">';
141 foreach ($boards as $board) {
142 $html .= '<a href="'. fluent_boards_page_url() .'boards/'. $board->id .'" class="fbs_associated_single-board">'. $board->title .'</a>';
143 }
144 $html .= '</div>';
145 }
146
147 $html .= '</div>';
148
149 if (!$taskGroups || $taskGroups->isEmpty()) {
150 $html .= '<div>
151 <p>No associated Tasks with this contact</p>
152 </div>
153 ';
154 }
155
156 foreach ($taskGroups as $board) {
157 $html .= '<div class="fbs_associated_boards_wrap">';
158 $html .= '<div class="fbs_associated_board_header">
159 <h3>' . $board[0]->board->title . '</h3>
160 <a href="' . fluent_boards_page_url() . 'boards/' . $board[0]->board->id . '" class="fbs-go-to-board">
161 Go To Board
162 </a>
163 </div>';
164 $html .= '<table>';
165 $html .= '<thead>
166 <tr>
167 <th style="width: 250px;">' . __('Task Title', 'fluent-boards') . '</th>
168 <th style="width: 130px;">' . __('Stage', 'fluent-boards') . '</th>
169 <th style="width: 120px;">' . __('Start Date', 'fluent-boards') . '</th>
170 <th style="width: 130px;">' . __('Due Date', 'fluent-boards') . '</th>
171 <th style="width: 100px;">' . __('Priority', 'fluent-boards') . '</th>
172 </tr>
173 </thead>';
174 $html .= '<tbody>';
175 foreach ($board as $task) {
176 $start = $task->start_at ? gmdate('jS F Y h:i A', strtotime($task->start_at)) : 'n/a';
177 $due = $task->due_date ? gmdate('jS F Y h:i A', strtotime($task->due_date)) : 'n/a';
178 $task->url = fluent_boards_page_url() . 'boards/' . $task->board_id . '/tasks/' . $task->id . '-' . substr(sanitize_title($task->title), 0, 40);
179 $html .= '<tr>';
180 $html .= "<td><a href=\"{$task->url}\">{$this->substring($task->title, 40)}</a></td>";
181 $html .= "<td>{$task->stage->title}</td>";
182 $html .= '<td>' . $start . '</td>';
183 $html .= '<td>' . $due . '</td>';
184 $html .= "<td>{$task->priority}</td>";
185
186 $html .= '</tr>';
187 }
188 $html .= '</tbody>';
189 $html .= '</table>';
190 $html .= '</div>';
191 }
192
193 return $html;
194 }
195
196 public function substring($string, $length)
197 {
198 if (strlen($string) > $length) {
199 return substr($string, 0, $length) . '...';
200 }
201
202 return $string;
203 }
204 }
205