Skip to content

Commit 8b548bc

Browse files
committed
FIX dashboard for module suppliers
1 parent 4970399 commit 8b548bc

File tree

3 files changed

+131
-41
lines changed

3 files changed

+131
-41
lines changed

langs/en_US/sellyoursaas.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ NbOfInstances=Nb of instances
221221
NbOfTickets=Nb of tickets
222222
SeeDetailsAndOptions=See details and options of my instances
223223
SeeDetailsAndOptionsOfMyCustomers=See details and options of my customers instances
224+
SeeDetailsOfInstancesWithMyModules=See details of instances with my modules
224225
SeeOrEditProfile=See or edit profile
225226
SeeDetailsOfPayments=See details of my payments and my payment mode
226227
SeeDetailsOfTickets=See details of my tickets
@@ -232,6 +233,7 @@ YourPersonalInformation=My personal information
232233
ERPCRMOnlineSubscription=%s ERP and CRM online subscription form
233234
MyInstances=My applications & options
234235
InstancesOfMyCustomers=Instances & options of my customers
236+
InstancesWithMyModules=Instances with my modules
235237
BillingDesc=Review your billing situation, update your payment method
236238
CancellationForms=Cancellation forms
237239
ListOfCancellationForms=List of cancellation forms

myaccount/index.php

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,14 @@
311311
}
312312

313313
// Define if the thirdparty is a reseller
314-
$mythirdpartyaccount->isareseller = 0; // TODO Use $mythirdpartyaccount->context['isareseller']
314+
$mythirdpartyaccount->isareseller = 0; // @deprecated Use $mythirdpartyaccount->context['isareseller']
315+
$mythirdpartyaccount->context['isareseller'] = 0;
315316
if (getDolGlobalInt('SELLYOURSAAS_DEFAULT_RESELLER_CATEG') > 0) {
316317
$categorie=new Categorie($db);
317318
$categorie->fetch(getDolGlobalString('SELLYOURSAAS_DEFAULT_RESELLER_CATEG'));
318319
if ($categorie->containsObject('supplier', $mythirdpartyaccount->id) > 0) {
319320
$mythirdpartyaccount->isareseller = 1;
321+
$mythirdpartyaccount->context['isareseller'] = 1;
320322
}
321323
}
322324

@@ -2483,7 +2485,7 @@
24832485
// Divider
24842486
print '<li class="dropdown-divider"></li>';
24852487
// My customers invoices
2486-
print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mycustomerbilling"><i class="fa fa-usd"></i> '.$langs->trans("MyCustomersBilling").'</a></li>';
2488+
print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mycustomerbilling"><i class="fa fa-usd pictofixedwidth"></i> '.$langs->trans("MyCustomersBilling").'</a></li>';
24872489
print '
24882490
</ul>
24892491
</li>
@@ -2504,7 +2506,7 @@
25042506
// Divider
25052507
print '<li class="dropdown-divider"></li>';
25062508
// Customers ofmy module area
2507-
print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mymodulecustomerbilling"><i class="fa fa-usd"></i> '.$langs->trans("MyModuleCustomersBilling").'</a></li>';
2509+
print '<li><a class="dropdown-item" href="'.$_SERVER["PHP_SELF"].'?mode=mymodulecustomerbilling"><i class="fa fa-usd pictofixedwidth"></i> '.$langs->trans("MyModuleCustomersBilling").'</a></li>';
25082510
print '
25092511
</ul>
25102512
</li>
@@ -3049,7 +3051,7 @@
30493051
$nbpaymentmodeok = count($arrayofcompanypaymentmode);
30503052

30513053

3052-
// Fill var to count nb of instances
3054+
// Fill var to count nb of customer instances
30533055
$nbofinstances = 0;
30543056
$nbofinstancesinprogress = 0;
30553057
$nbofinstancesdone = 0;
@@ -3084,6 +3086,7 @@
30843086

30853087
$nboftickets = $langs->trans("SoonAvailable");
30863088

3089+
30873090
// Analyse list of child instances for resellers
30883091
$nbofinstancesreseller = 0;
30893092
$nbofinstancesinprogressreseller = 0;
@@ -3120,6 +3123,42 @@
31203123
}
31213124
}
31223125

3126+
// Analyse list of child instances for module providers
3127+
$nbofinstancesmodules = 0;
3128+
$nbofinstancesinprogressmodules = 0;
3129+
$nbofinstancesdonemodules = 0;
3130+
$nbofinstancessuspendedmodules = 0;
3131+
if (!empty($mythirdpartyaccount->context['isamoduleprovider']) && count($listofcontractidmodulesupplier)) {
3132+
// Fill var to count nb of instances
3133+
foreach ($listofcontractidmodulesupplier as $contractid => $contract) {
3134+
if ($contract->array_options['options_deployment_status'] == 'undeployed') {
3135+
continue;
3136+
}
3137+
if ($contract->array_options['options_deployment_status'] == 'processing') {
3138+
$nbofinstancesmodules++;
3139+
$nbofinstancesinprogressmodules++;
3140+
continue;
3141+
}
3142+
3143+
$suspended = 0;
3144+
foreach ($contract->lines as $keyline => $line) {
3145+
if ($line->statut == ContratLigne::STATUS_CLOSED && $contract->array_options['options_deployment_status'] != 'undeployed') {
3146+
$suspended = 1;
3147+
break;
3148+
}
3149+
}
3150+
3151+
$nbofinstancesmodules++;
3152+
if ($suspended) {
3153+
$nbofinstancessuspendedmodules++;
3154+
} else {
3155+
if (!preg_match('/^http/i', $contract->array_options['options_suspendmaintenance_message'])) {
3156+
$nbofinstancesdonemodules++;
3157+
}
3158+
}
3159+
}
3160+
}
3161+
31233162

31243163
$atleastonecontractwithtrialended = 0;
31253164
$atleastonepaymentinerroronopeninvoice = 0;

myaccount/tpl/dashboard.tpl.php

Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,34 @@
3131
<!-- BEGIN PHP TEMPLATE dashboard.tpl.php -->
3232
<?php
3333

34-
print '
34+
print '
3535
<div class="page-content-wrapper">
3636
<div class="page-content">
3737
38-
<!-- BEGIN PAGE HEADER-->
38+
<!-- BEGIN PAGE HEADER-->
3939
<!-- BEGIN PAGE HEAD -->
4040
<div class="page-head">
41-
<!-- BEGIN PAGE TITLE -->
42-
<div class="page-title">
43-
<h1>'.$langs->trans("Dashboard").'</h1>
44-
</div>
45-
<!-- END PAGE TITLE -->
46-
47-
41+
<!-- BEGIN PAGE TITLE -->
42+
<div class="page-title">
43+
<h1>'.$langs->trans("Dashboard").'</h1>
44+
</div>
45+
<!-- END PAGE TITLE -->
4846
</div>
4947
<!-- END PAGE HEAD -->
5048
<!-- END PAGE HEADER-->
5149
5250
53-
<div class="row">';
54-
51+
<div class="row">';
5552

56-
if ($mythirdpartyaccount->client > 0) {
57-
print '<div class="col-md-6">
5853

59-
<div class="portlet light" id="planSection">
54+
print '
55+
<!-- BEGIN COL MY INSTANCES -->
56+
<div class="col-md-6">
57+
<!-- BEGIN PORTLET id=planSection -->
58+
<div class="portlet light" id="planSection">';
6059

60+
if ($mythirdpartyaccount->client > 0) {
61+
print '
6162
<div class="portlet-title">
6263
<div class="caption">
6364
<i class="fa fa-server font-green-sharp paddingright"></i><span class="caption-subject font-green-sharp bold uppercase">'.$langs->trans("MyInstances").'</span>
@@ -73,31 +74,33 @@
7374
<div class="col-md-4 right">
7475
<h2>'.$nbofinstancesdone.'</h2>
7576
</div>
76-
</div> <!-- END ROW -->
77+
</div>
7778
7879
';
79-
if ($nbofinstancessuspended) {
80-
print '
81-
<div class="row">
82-
<div class="col-md-8">
83-
'.$langs->trans("NbOfSuspendedInstances").'
84-
</div>
85-
<div class="col-md-4 right">
86-
<h2 style="color:orange">'.$nbofinstancessuspended.'</h2>
87-
</div>
88-
</div> <!-- END ROW -->
89-
';
90-
}
80+
if ($nbofinstancessuspended) {
81+
print '
82+
<div class="row">
83+
<div class="col-md-8">
84+
'.$langs->trans("NbOfSuspendedInstances").'
85+
</div>
86+
<div class="col-md-4 right">
87+
<h2 style="color:orange">'.$nbofinstancessuspended.'</h2>
88+
</div>
89+
</div>
90+
';
91+
}
9192

92-
print '
93+
print '
9394
<div class="row">
9495
<div class="center col-md-12">
9596
<br>
9697
<a class="wordbreak btn" href="'.$_SERVER["PHP_SELF"].'?mode=instances" class="btn default btn-xs green-stripe">'.$langs->trans("SeeDetailsAndOptions").'</a>
97-
</div></div>';
98+
</div>
99+
</div>';
98100

99-
print '
101+
print '
100102
</div>'; // end protlet-body
103+
}
101104

102105
if ($mythirdpartyaccount->isareseller) {
103106
print '
@@ -116,7 +119,7 @@
116119
<div class="col-md-4 right">
117120
<h2>'.$nbofinstancesdonereseller.'</h2>
118121
</div>
119-
</div> <!-- END ROW -->
122+
</div>
120123
121124
';
122125
if ($nbofinstancessuspendedreseller) {
@@ -128,7 +131,7 @@
128131
<div class="col-md-4 right">
129132
<h2 style="color:orange">'.$nbofinstancessuspendedreseller.'</h2>
130133
</div>
131-
</div> <!-- END ROW -->
134+
</div>
132135
';
133136
}
134137

@@ -137,17 +140,63 @@
137140
<div class="center col-md-12">
138141
<br>
139142
<a class="wordbreak btn" href="'.$_SERVER["PHP_SELF"].'?mode=mycustomerinstances" class="btn default btn-xs green-stripe">'.$langs->trans("SeeDetailsAndOptionsOfMyCustomers").'</a>
140-
</div></div>';
143+
</div>
144+
</div>';
141145

142146
print '</div>'; // end portlet-body
143147
}
144148

145-
print '
146149

147-
</div> <!-- END PORTLET -->
150+
if (!empty($mythirdpartyaccount->context['isamoduleprovider'])) {
151+
print '
152+
<div class="portlet-title">
153+
<div class="caption"><br><br>
154+
<i class="fa fa-server font-green-sharp paddingright"></i><span class="caption-subject font-green-sharp bold uppercase">'.$langs->trans("InstancesWithMyModules").'</span>
155+
</div>
156+
</div>
148157
149-
</div> <!-- END COL MY INSTANCES-->';
150-
}
158+
<div class="portlet-body">
159+
160+
<div class="row">
161+
<div class="col-md-8">
162+
'.$langs->trans("NbOfActiveInstances").'
163+
</div>
164+
<div class="col-md-4 right">
165+
<h2>'.$nbofinstancesdonemodules.'</h2>
166+
</div>
167+
</div>
168+
169+
';
170+
if ($nbofinstancessuspendedmodules) {
171+
print '
172+
<div class="row">
173+
<div class="col-md-8">
174+
'.$langs->trans("NbOfSuspendedInstances").'
175+
</div>
176+
<div class="col-md-4 right">
177+
<h2 style="color:orange">'.$nbofinstancessuspendedmodules.'</h2>
178+
</div>
179+
</div>
180+
';
181+
}
182+
183+
print '
184+
<div class="row">
185+
<div class="center col-md-12">
186+
<br>
187+
<a class="wordbreak btn" href="'.$_SERVER["PHP_SELF"].'?mode=mymodulecustomerinstances" class="btn default btn-xs green-stripe">'.$langs->trans("SeeDetailsOfInstancesWithMyModules").'</a>
188+
</div>
189+
</div>';
190+
191+
print '</div>'; // end portlet-body
192+
}
193+
194+
195+
196+
print '
197+
198+
</div> <!-- END PORTLET id=planSection -->
199+
</div> <!-- END COL MY INSTANCES-->';
151200

152201

153202
print '

0 commit comments

Comments
 (0)