Skip to content

Commit 8146f3f

Browse files
committed
Fix the count of nb of deployment servers in tab title
1 parent 296eaa4 commit 8146f3f

File tree

9 files changed

+118
-29
lines changed

9 files changed

+118
-29
lines changed

backoffice/index.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php";
5555
require_once DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php";
5656
require_once DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php";
57+
require_once __DIR__.'/../class/deploymentserver.class.php';
5758
dol_include_once("/sellyoursaas/backoffice/lib/refresh.lib.php"); // do not use dol_buildpath to keep global of var into refresh.lib.php working
5859
dol_include_once("/sellyoursaas/backoffice/lib/backoffice.lib.php"); // do not use dol_buildpath to keep global of var into refresh.lib.php working
5960

@@ -133,9 +134,26 @@
133134

134135
llxHeader('', $langs->transnoentitiesnoconv('DoliCloudCustomers'), '');
135136

136-
//print_fiche_titre($langs->trans("DoliCloudArea"));
137+
// Count nb of deployment servers
138+
$object = new Deploymentserver($db);
139+
$sql = 'SELECT count(rowid) as nbtotalofrecords FROM '.MAIN_DB_PREFIX.'sellyoursaas_deploymentserver';
140+
if ($object->ismultientitymanaged == 1) {
141+
$sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
142+
} else {
143+
$sql .= " WHERE 1 = 1";
144+
}
145+
// Count total nb of records
146+
$nbtotalofrecords = '';
147+
$resql = $db->query($sql);
148+
if ($resql) {
149+
$objforcount = $db->fetch_object($resql);
150+
$nbtotalofrecords = $objforcount->nbtotalofrecords;
151+
$db->free($resql);
152+
} else {
153+
dol_print_error($db);
154+
}
137155

138-
$head = sellYourSaasBackofficePrepareHead();
156+
$head = sellYourSaasBackofficePrepareHead($nbtotalofrecords);
139157

140158
//$head = commande_prepare_head(null);
141159
dol_fiche_head($head, 'home', $langs->trans("DoliCloudArea"), -1, 'sellyoursaas@sellyoursaas');

backoffice/notes.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,26 @@
130130

131131
llxHeader('', $langs->transnoentitiesnoconv('DoliCloudCustomers'), '');
132132

133-
//print_fiche_titre($langs->trans("DoliCloudArea"));
133+
// Count nb of deployment servers
134+
$object = new Deploymentserver($db);
135+
$sql = 'SELECT count(rowid) as nbtotalofrecords FROM '.MAIN_DB_PREFIX.'sellyoursaas_deploymentserver';
136+
if ($object->ismultientitymanaged == 1) {
137+
$sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
138+
} else {
139+
$sql .= " WHERE 1 = 1";
140+
}
141+
// Count total nb of records
142+
$nbtotalofrecords = '';
143+
$resql = $db->query($sql);
144+
if ($resql) {
145+
$objforcount = $db->fetch_object($resql);
146+
$nbtotalofrecords = $objforcount->nbtotalofrecords;
147+
$db->free($resql);
148+
} else {
149+
dol_print_error($db);
150+
}
134151

135-
$head = sellYourSaasBackofficePrepareHead();
152+
$head = sellYourSaasBackofficePrepareHead($nbtotalofrecords);
136153

137154

138155
//$head = commande_prepare_head(null);

backoffice/setup_antispam.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,26 @@
124124

125125
llxHeader('', $langs->transnoentitiesnoconv('AntiSpam'), '');
126126

127-
//print_fiche_titre($langs->trans("DoliCloudArea"));
127+
// Count nb of deployment servers
128+
$object = new Deploymentserver($db);
129+
$sql = 'SELECT count(rowid) as nbtotalofrecords FROM '.MAIN_DB_PREFIX.'sellyoursaas_deploymentserver';
130+
if ($object->ismultientitymanaged == 1) {
131+
$sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
132+
} else {
133+
$sql .= " WHERE 1 = 1";
134+
}
135+
// Count total nb of records
136+
$nbtotalofrecords = '';
137+
$resql = $db->query($sql);
138+
if ($resql) {
139+
$objforcount = $db->fetch_object($resql);
140+
$nbtotalofrecords = $objforcount->nbtotalofrecords;
141+
$db->free($resql);
142+
} else {
143+
dol_print_error($db);
144+
}
128145

129-
$head = sellYourSaasBackofficePrepareHead();
146+
$head = sellYourSaasBackofficePrepareHead($nbtotalofrecords);
130147

131148

132149
//$head = commande_prepare_head(null);

class/actions_sellyoursaas.class.php

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ public function afterPDFCreation($parameters, &$pdfhandler, &$action)
15421542
*/
15431543
public function loadDataForCustomReports($parameters, &$action, $hookmanager)
15441544
{
1545-
global $langs;
1545+
global $db, $langs;
15461546

15471547
$langs->load("sellyoursaas@sellyoursaas");
15481548

@@ -1558,19 +1558,41 @@ public function loadDataForCustomReports($parameters, &$action, $hookmanager)
15581558
$head[$h][2] = 'home';
15591559
$h++;
15601560

1561+
// Count nb of deployment servers
1562+
$object = new Deploymentserver($db);
1563+
$sql = 'SELECT count(rowid) as nbtotalofrecords FROM '.MAIN_DB_PREFIX.'sellyoursaas_deploymentserver';
1564+
if ($object->ismultientitymanaged == 1) {
1565+
$sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
1566+
} else {
1567+
$sql .= " WHERE 1 = 1";
1568+
}
1569+
// Count total nb of records
1570+
$nbtotalofrecords = '';
1571+
$resql = $db->query($sql);
1572+
if ($resql) {
1573+
$objforcount = $db->fetch_object($resql);
1574+
$nbtotalofrecords = $objforcount->nbtotalofrecords;
1575+
$db->free($resql);
1576+
} else {
1577+
dol_print_error($db);
1578+
}
1579+
15611580
if (!getDolGlobalString('SELLYOURSAAS_OBJECT_DEPLOYMENT_SERVER_MIGRATION')) {
15621581
$head[$h][0] = dol_buildpath('/sellyoursaas/backoffice/deployment_servers.php', 1);
15631582
$head[$h][1] = $langs->trans("DeploymentServers");
1583+
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbtotalofrecords.'</span>';
15641584
$head[$h][2] = 'deploymentservers';
15651585
$h++;
15661586
} else {
15671587
$head[$h][0] = '/custom/sellyoursaas/deploymentserver_list.php';
15681588
$head[$h][0] = dol_buildpath('/sellyoursaas/deploymentserver_list.php', 1);
15691589
$head[$h][1] = $langs->trans("DeploymentServers");
1590+
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbtotalofrecords.'</span>';
15701591
$head[$h][2] = 'deploymentservers';
15711592
$h++;
15721593
}
15731594

1595+
15741596
$head[$h][0] = dol_buildpath('/sellyoursaas/backoffice/setup_antispam.php', 1);
15751597
$head[$h][1] = $langs->trans("AntiSpam");
15761598
$head[$h][2] = 'antispam';
@@ -1581,16 +1603,16 @@ public function loadDataForCustomReports($parameters, &$action, $hookmanager)
15811603
}
15821604

15831605
if ($parameters['tabfamily'] == 'sellyoursaas') {
1584-
$head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
1585-
$head[$h][1] = $langs->trans("CustomReports");
1586-
$head[$h][2] = 'customreports';
1606+
$head[$h][0] = dol_buildpath('/sellyoursaas/backoffice/notes.php', 1);
1607+
$head[$h][1] = $langs->trans("Notes");
1608+
$head[$h][2] = 'notes';
15871609
$h++;
15881610
}
15891611

15901612
if ($parameters['tabfamily'] == 'sellyoursaas') {
1591-
$head[$h][0] = dol_buildpath('/sellyoursaas/backoffice/notes.php', 1);
1592-
$head[$h][1] = $langs->trans("Notes");
1593-
$head[$h][2] = 'notes';
1613+
$head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
1614+
$head[$h][1] = $langs->trans("CustomReports");
1615+
$head[$h][2] = 'customreports';
15941616
$h++;
15951617
}
15961618

deploymentserver_list.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@
277277

278278
$form = new Form($db);
279279

280-
$now = dol_now();
281-
282280
$title = $langs->trans("DeploymentServers");
283281
//$help_url = "EN:Module_Deploymentserver|FR:Module_Deploymentserver_FR|ES:Módulo_Deploymentserver";
284282
$help_url = '';

langs/en_US/sellyoursaas.lang

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ HelpOnOnlyThoseServers=Keep empty to allow deployment on any qualified server. E
943943
DolibarrDeployment=Dolibarr specific
944944
OnlyForCountry=Only for Country
945945
OnlyForCountryHelp=Country code list allowing installation of the product or service.To have several countries, add a comma between the country codes.<br>Exemple : fr,us,es
946-
MyModuleCustomersInstances=My module customer instances
946+
MyModuleCustomersInstances=Instances of customers of my modules
947947
MyModuleCustomersBilling=My module customer billing
948-
SupplierModule=Module
948+
SupplierModule=Module
949+
YouAreAModuleProvider=You are a module provider
950+
YouAreTheProviderOfTheFollowingModules=You provides the following modules

myaccount/index.php

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129

130130
//$langs=new Translate('', $conf);
131131
//$langs->setDefaultLang(GETPOST('lang', 'aZ09') ? GETPOST('lang', 'aZ09') : 'auto');
132-
$langs->loadLangs(array("main","companies","bills","sellyoursaas@sellyoursaas","other","errors",'mails','paypal','paybox','stripe','withdrawals','other','admin','website'));
132+
$langs->loadLangs(array("main","companies","bills","sellyoursaas@sellyoursaas","other","products","errors",'mails','paypal','paybox','stripe','withdrawals','other','admin','website'));
133133

134134
if ($langs->defaultlang == 'en_US') {
135135
$langsen = $langs;
@@ -316,7 +316,7 @@
316316
}
317317

318318
// Define if the thirdparty is a module provider
319-
$mythirdpartyaccount->context['isamoduleprovider'] = array(); // TODO Use $mythirdpartyaccount->context['isamoduleprovider']
319+
$mythirdpartyaccount->context['isamoduleprovider'] = array();
320320
if (getDolGlobalInt('SELLYOURSAAS_ALLOW_MODULE_PROVIDER_PROGRAM') > 0) {
321321
$sql = "SELECT p.rowid FROM ".MAIN_DB_PREFIX."product as p";
322322
$sql.= " JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
@@ -429,7 +429,7 @@
429429
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as d ON d.fk_contrat = c.rowid';
430430
$sql.= ', '.MAIN_DB_PREFIX.'product as p';
431431
$sql.= " WHERE d.fk_product = p.rowid";
432-
$sql.= " AND d.fk_product IN (".(implode(",", $mythirdpartyaccount->context['isamoduleprovider'])).")";
432+
$sql.= " AND d.fk_product IN (".$db->sanitize(implode(",", array_keys($mythirdpartyaccount->context['isamoduleprovider']))).")";
433433
$sql.= " AND d.statut = 4";
434434

435435
if ($search_instance_name) {
@@ -2817,8 +2817,8 @@
28172817
}
28182818

28192819

2820-
// Show partner links
2821-
if ($mythirdpartyaccount->isareseller) {
2820+
// Show resellection section
2821+
if ($mythirdpartyaccount->isareseller && !in_array($mode, array('mymodulecustomerinstances', 'mymodulecustomerbilling'))) {
28222822
print '
28232823
<!-- Info reseller -->
28242824
<div class="note note-info">
@@ -2963,6 +2963,21 @@
29632963
}
29642964

29652965

2966+
// Show module provider section
2967+
if (!empty($mythirdpartyaccount->context['isamoduleprovider']) && !in_array($mode, array('mycustomerinstances', 'mycustomerbilling'))) {
2968+
print '
2969+
<!-- Info module provider -->
2970+
<div class="note note-info">
2971+
<h4 class="block"><span class="fa fa-briefcase"></span> '.$langs->trans("YouAreAModuleProvider").'.</h4>
2972+
';
2973+
print '<span class="opacitymedium">'.$langs->trans("YouAreTheProviderOfTheFollowingModules").':</span><br>';
2974+
foreach ($mythirdpartyaccount->context['isamoduleprovider'] as $id => $val) {
2975+
$tmpproduct = new Product($db);
2976+
$tmpproduct->fetch($id);
2977+
print '- '.$tmpproduct->ref.($tmpproduct->label != $tmpproduct->ref ? ' '.$tmpproduct->label : '').' &nbsp; - &nbsp; <span class="small opacitymedium">'.$langs->trans("SellingPriceHT").'</span> = '.price($tmpproduct->price, 0, '', 1, -1, -1, $conf->currency).' / '.$langs->trans("month").'<br>';
2978+
}
2979+
print '</div>';
2980+
}
29662981

29672982
// Fill array of company payment modes
29682983
$arrayofcompanypaymentmode = array();
@@ -3073,18 +3088,18 @@
30733088
$atleastonepaymentinerroronopeninvoice = 0;
30743089
$atleastoneinvoicedisputed = 0;
30753090

3076-
// Show warnings
30773091

3092+
// Show warnings
30783093

30793094
if (empty($welcomecid) && ! in_array($action, array('instanceverification', 'autoupgrade'))) {
30803095
$companypaymentmode = new CompanyPaymentMode($db);
30813096
$result = $companypaymentmode->fetch(0, null, $mythirdpartyaccount->id);
30823097

30833098
foreach ($listofcontractid as $contractid => $contract) {
3084-
if ($mode == 'mycustomerbilling') {
3099+
if (in_array($mode, array('mycustomerinstances', 'mycustomerbilling'))) {
30853100
continue;
30863101
}
3087-
if ($mode == 'mycustomerinstances') {
3102+
if (in_array($mode, array('mymodulecustomerinstances', 'mymodulecustomerbilling'))) {
30883103
continue;
30893104
}
30903105
if ($contract->array_options['options_deployment_status'] == 'undeployed') {

myaccount/tpl/mymodulecustomerbilling.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
$sql.= ' WHERE fd.fk_facture = f.rowid';
264264
$sql.= ' AND fd.fk_product = p.rowid';
265265
$sql.= ' AND fpf.fk_product = p.rowid';
266-
$sql.= ' AND fd.fk_product IN ('.implode(",", $mythirdpartyaccount->context['isamoduleprovider']).')';
266+
$sql.= ' AND fd.fk_product IN ('.$db->sanitize(implode(",", array_keys($mythirdpartyaccount->context['isamoduleprovider']))).')';
267267

268268
$sql.=$db->order($sortfield2, $sortorder2);
269269

@@ -407,7 +407,7 @@
407407
//$sql.=' WHERE fe.reseller IN ('.join(',', $listofcustomeridreseller).')';
408408
$sql.= ', '.MAIN_DB_PREFIX.'facturedet as fd';
409409
$sql.= ' WHERE fd.fk_facture = f.rowid';
410-
$sql.=' AND fd.fk_product IN ('.implode(",", $mythirdpartyaccount->context['isamoduleprovider']).')';
410+
$sql.=' AND fd.fk_product IN ('.$db->sanitize(implode(",", array_keys($mythirdpartyaccount->context['isamoduleprovider']))).')';
411411
$sql.=' AND fk_statut <> '.Facture::STATUS_DRAFT;
412412
$sql.=' AND paye = 1';
413413

myaccount/tpl/mymodulecustomerinstances.tpl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
} else {
295295
$total_ht = 0;
296296
foreach ($templateinvoice->lines as $key => $templateline) {
297-
if (in_array($templateline->fk_product, $mythirdpartyaccount->context['isamoduleprovider'])) {
297+
if (array_key_exists($templateline->fk_product, $mythirdpartyaccount->context['isamoduleprovider'])) {
298298
$total_ht += $templateline->total_ht;
299299
}
300300
}
@@ -351,7 +351,7 @@
351351
<div class="areaforresources" style="padding-bottom: 12px;">';
352352
foreach ($contract->lines as $keyline => $line) {
353353
//var_dump($line);
354-
if ($line->fk_product > 0 && !in_array($line->fk_product, $mythirdpartyaccount->context['isamoduleprovider'])) {
354+
if ($line->fk_product > 0 && !array_key_exists($line->fk_product, $mythirdpartyaccount->context['isamoduleprovider'])) {
355355
continue;
356356
}
357357

0 commit comments

Comments
 (0)