Skip to content

Commit 9c0404a

Browse files
authored
Merge pull request #436 from atm-jonathan/NEW/ADD_EXTRAFIELD_SOURCES_CHOICE_THIRDPARTY
New/add extrafield sources choice thirdparty
2 parents f9156a2 + ed1775f commit 9c0404a

File tree

8 files changed

+62
-4
lines changed

8 files changed

+62
-4
lines changed

class/sellyoursaasutils.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ public function doTakePaymentStripe($maxnbofinvoicetotry = 0, $noemailtocustomer
12731273
$sql .= " AND sr.ext_payment_site = '".$this->db->escape($service)."'"; // Only Stripe Live or Test
12741274
// We must add a sort on sr.default_rib to get the default first, and then the last recent if no default found.
12751275
$sql .= " ORDER BY f.datef ASC, f.rowid ASC, sr.default_rib DESC, sr.tms DESC"; // Lines may be duplicated if there is several payment mode. Never mind, we will exclude duplicated invoice later.
1276-
//print $sql;exit;
12771276

12781277
$resql = $this->db->query($sql);
12791278
if ($resql) {

core/modules/modSellYourSaas.class.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,19 @@ public function __construct($db)
146146

147147

148148
// Dictionaries
149-
$this->dictionaries=array();
149+
$this->dictionaries = array(
150+
'langs' => 'sellyoursaas@sellyoursaas',
151+
'tabname' => array('c_sellyoursaas_source_choice'),
152+
'tablib' => array('SourceChoiceDictionary'),
153+
'tabsql' => array('SELECT c.rowid as rowid, c.code, c.label, c.pos, c.active FROM '.MAIN_DB_PREFIX.'c_sellyoursaas_source_choice as c'),
154+
'tabsqlsort' => array("pos ASC"),
155+
'tabfield' => array("code,label,pos"),
156+
'tabfieldvalue' => array("code,label,pos"),
157+
'tabfieldinsert' => array("code,label,pos"),
158+
'tabrowid' => array("rowid"),
159+
'tabcond' => array(isModEnabled('sellyoursaas')),
160+
'tabhelp' => array()
161+
);
150162

151163

152164
// Boxes
@@ -900,6 +912,7 @@ public function init($options = '')
900912
$resultx=$extrafields->addExtraField('ip_confirm_email', "IPConfirmEmail", 'ip', 180, '', 'thirdparty', 0, 0, '', '', 1, '', -1, 0, '', '', 'sellyoursaas@sellyoursaas', 'isModEnabled("sellyoursaas")');
901913
$resultx=$extrafields->addExtraField('source', "Source", 'varchar', 104, '64', 'thirdparty', 0, 0, '', '', 1, '', 1, 0, '', '', 'sellyoursaas@sellyoursaas', 'isModEnabled("sellyoursaas")', 0, 0, array('csslist'=>'tdoverflowmax200'));
902914
$resultx=$extrafields->addExtraField('source_utm', "SourceUtm", 'varchar', 104, '64', 'thirdparty', 0, 0, '', '', 1, '', 1, 0, '', '', 'sellyoursaas@sellyoursaas', 'isModEnabled("sellyoursaas")', 0, 0, array('csslist'=>'tdoverflowmax150'));
915+
$resultx=$extrafields->addExtraField('source_choice', 'SourceChoice', 'chkbxlst', 104, '', 'thirdparty', 0, 0, '', array('options' => array('c_sellyoursaas_source_choice:label:code::active=1' => null)), 1, 'isModEnabled("sellyoursaas")', 1, '', '', '', 'sellyoursaas@sellyoursaas', 'isModEnabled("sellyoursaas")');
903916
$resultx=$extrafields->addExtraField('firstname', "FirstName", 'varchar', 105, '64', 'thirdparty', 0, 0, '', '', 1, '', 1, 0, '', '', 'sellyoursaas@sellyoursaas', 'isModEnabled("sellyoursaas")', 0, 0, array('csslist'=>'tdoverflowmax120'));
904917
$resultx=$extrafields->addExtraField('lastname', "LastName", 'varchar', 106, '64', 'thirdparty', 0, 0, '', '', 1, '', 1, 0, '', '', 'sellyoursaas@sellyoursaas', 'isModEnabled("sellyoursaas")', 0, 0, array('csslist'=>'tdoverflowmax120'));
905918
$param=array('options'=>array('auto'=>null)); // Must use a non reversible password.

langs/en_US/sellyoursaas.lang

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,9 @@ HelpOnOnlyThoseServers=Keep empty to allow deployment on any qualified server. E
945945
DolibarrDeployment=Dolibarr specific
946946
OnlyForCountry=Only for Country
947947
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
948+
HowDidYouHearAboutUs = How did you hear about us?
948949
MyModuleCustomersInstances=Instances of customers of my modules
949950
MyModuleCustomersBilling=My module customer billing
950951
SupplierModule=Module
951952
YouAreAModuleProvider=You are a module provider
952-
YouAreTheProviderOfTheFollowingModules=You provides the following modules
953+
YouAreTheProviderOfTheFollowingModules=You provides the following modules

langs/fr_FR/sellyoursaas.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,3 +939,5 @@ HelpOnAvailableForSale=Si le service est de type « Application », cochez cet
939939
HelpOnDaysForFreePeriod=Lorsque le service est de type « Application », saisissez le nombre de jours pendant lesquels vous souhaitez avoir le service gratuit avant de demander un paiement ou une validation pour conserver l'instance
940940
OnlyThoseServers=Only on those servers
941941
HelpOnOnlyThoseServers=Laissez ce champ vide pour autoriser le déploiement sur n'importe quel serveur qualifié. Saisissez le nom d'un ou plusieurs serveurs si vous souhaitez forcer le déploiement de ce service sur un serveur donné.
942+
SourceChoiceDictionary = Sources du client sur la page d'inscription
943+
HowDidYouHearAboutUs = Comment nous avez-vous connu ?

myaccount/register.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,31 @@ function setButtonDisabled() {
797797
<?php
798798
}
799799

800-
800+
global $db, $extrafields;
801+
$extrafields->fetch_name_optionals_label('societe');
802+
$numActiveEntries = 0;
803+
$sql = "SELECT COUNT(rowid) as nb FROM " . $db->prefix() . "c_sellyoursaas_source_choice WHERE active = 1";
804+
$resql = $db->query($sql);
805+
if ($resql) {
806+
$obj = $db->fetch_object($resql);
807+
if ($obj) {
808+
$numActiveEntries = (int) $obj->nb;
809+
}
810+
}
811+
if ($numActiveEntries > 0) {
812+
?>
813+
<div class="control-group-select2 required">
814+
<label class="control-label-select2" for="options_sellyoursaas_source_choice">
815+
<span class="fa fa-question-circle opacityhigh"></span> <?= $langs->trans("HowDidYouHearAboutUs") ?>
816+
</label>
817+
<div class="controls-select2">
818+
<?php
819+
print $extrafields->showInputField('source_choice', '', '', '', '', '', 0, 'societe');
820+
?>
821+
</div>
822+
</div>
823+
<?php
824+
}
801825
if (empty($mythirdparty->id)) {
802826
?>
803827

myaccount/register_instance.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
$password = dol_trunc(trim(GETPOST('password', 'alpha')), 128, 'right', 'UTF-8', 1);
192192
$password2 = dol_trunc(trim(GETPOST('password2', 'alpha')), 128, 'right', 'UTF-8', 1);
193193
$country_code = trim(GETPOST('country', 'alpha'));
194+
194195
$sldAndSubdomain = trim(GETPOST('sldAndSubdomain', 'alpha'));
195196
$tldid = trim(GETPOST('tldid', 'alpha'));
196197
$optinmessages = (GETPOST('optinmessages', 'aZ09') == '1' ? 1 : 0);
@@ -211,6 +212,11 @@
211212
$plan=GETPOST('plan', 'alpha');
212213
$productref=(GETPOST('productref', 'alpha') ? GETPOST('productref', 'alpha') : ($plan ? $plan : ''));
213214
$extcss=GETPOST('extcss', 'alpha');
215+
$lead_sources_array = array();
216+
if (GETPOSTISARRAY('options_source_choice')) {
217+
$lead_sources_array = GETPOST('options_source_choice', 'array');
218+
}
219+
$lead_sources_string = implode(',', $lead_sources_array);
214220
if (empty($extcss)) {
215221
$extcss = getDolGlobalString('SELLYOURSAAS_EXTCSS', 'dist/css/myaccount.css');
216222
} elseif ($extcss == 'generic') {
@@ -1100,6 +1106,9 @@
11001106
$tmpthirdparty->array_options['options_domain_registration_page'] = getDomainFromURL($_SERVER["SERVER_NAME"], 1);
11011107
$tmpthirdparty->array_options['options_source'] = 'REGISTERFORM'.($origin ? '-'.$origin : '');
11021108
$tmpthirdparty->array_options['options_source_utm'] = (empty($_COOKIE['utm_source_cookie']) ? '' : $_COOKIE['utm_source_cookie']);
1109+
1110+
$tmpthirdparty->array_options['options_source_choice'] = $lead_sources_string;
1111+
11031112
$tmpthirdparty->array_options['options_password'] = $password;
11041113
$tmpthirdparty->array_options['options_optinmessages'] = $optinmessages;
11051114
$tmpthirdparty->array_options['options_checkboxnonprofitorga'] = $checkboxnonprofitorga;

sql/data.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ INSERT INTO llx_c_email_templates (module,type_template,label,lang,position,topi
109109
--INSERT INTO llx_c_ticket_category (code,pos,label,active,use_default,description,fk_parent,force_severity,public) VALUES ('TIGRP-TECHISSUE-SLOW',45,'The application responds slowly',1,0,NULL,4,NULL,1);
110110
--INSERT INTO llx_c_ticket_category (code,pos,label,active,use_default,description,fk_parent,force_severity,public) VALUES ('TIGRP-TECHISSUE-OTHER',46,'Other (bug, error, access broken, ...)',1,0,NULL,4,NULL,1);
111111

112+
INSERT INTO llx_c_sellyoursaas_source_choice (code, label, pos, active) VALUES ('SITE', 'WEB SITE', 10, 0);
113+
INSERT INTO llx_c_sellyoursaas_source_choice (code, label, pos, active) VALUES ('MTM', 'MOUTH TO MOUTH', 20, 0);
114+
INSERT INTO llx_c_sellyoursaas_source_choice (code, label, pos, active) VALUES ('OTHER', 'OTHER', 30, 0);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE llx_c_sellyoursaas_source_choice (
2+
rowid INT(11) AUTO_INCREMENT PRIMARY KEY,
3+
code VARCHAR(255) NOT NULL,
4+
label VARCHAR(255) NOT NULL,
5+
pos INT(11) DEFAULT 0,
6+
active TINYINT(1) DEFAULT 1
7+
) ENGINE=InnoDB;

0 commit comments

Comments
 (0)