Skip to content

Commit

Permalink
Can filter on extrafields
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 1, 2025
1 parent 2e4b222 commit 26b6809
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions htdocs/alumni/class/survey.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ class Survey extends CommonObject
"lastname2" => array("type"=>"varchar(128)", "label"=>"Lastname2", "enabled"=>"1", 'position'=>31, 'notnull'=>0, "visible"=>"1", "searchall"=>"1", "csslist"=>"tdoverflowmax150",),
"email" => array("type"=>"mail", "label"=>"Email", "enabled"=>"isModEnabled('alumni')", 'position'=>33, 'notnull'=>1, "visible"=>"1", "index"=>"1", "csslist"=>"tdoverflowmax150",),
"phone" => array("type"=>"phone", "label"=>"Phone", "enabled"=>"isModEnabled('alumni')", 'position'=>34, 'notnull'=>0, "visible"=>"1", "csslist"=>"tdoverflowmax150",),
"comwhatsapp" => array("type"=>"integer", "label"=>"ComWhatsapp", "enabled"=>"isModEnabled('alumni')", 'position'=>40, 'notnull'=>0, "visible"=>"-1",),
//"comwhatsapp" => array("type"=>"integer", "label"=>"ComWhatsapp", "enabled"=>"isModEnabled('alumni')", 'position'=>40, 'notnull'=>0, "visible"=>"-1",),
//"comemail" => array("type"=>"integer", "label"=>"ComEmail", "enabled"=>"isModEnabled('alumni')", 'position'=>41, 'notnull'=>0, "visible"=>"-1",),
"promodesortie" => array("type"=>"integer", "label"=>"Promo de Sortie", "enabled"=>"isModEnabled('alumni')", 'position'=>45, 'notnull'=>0, "visible"=>"1",),
"promodesortie" => array("type"=>"integer", "label"=>"Promo de Sortie", "enabled"=>"isModEnabled('alumni')", 'position'=>45, 'notnull'=>-1, "visible"=>"1",),
"lienavecpromo" => array("type"=>"varchar(128)", "label"=>"Lien avec promo", "enabled"=>"isModEnabled('alumni')", 'position'=>46, 'notnull'=>0, "visible"=>"1",),
"preferencejour" => array("type"=>"varchar(128)", "label"=>"PreferenceJour", "enabled"=>"isModEnabled('alumni')", 'position'=>51, 'notnull'=>0, "visible"=>"-1",),
"preferencemois" => array("type"=>"varchar(255)", "label"=>"PreferenceMois", "enabled"=>"isModEnabled('alumni')", 'position'=>52, 'notnull'=>0, "visible"=>"-1",),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function formFilter()
$arrayfields = $tmp->fields['motivation']['arrayofkeyval'];

$s = '';
$s .= $langs->trans($tmp->fields['motivation']['label']).': ';
$s .= $langs->trans($tmp->fields['motivation']['label']).' ';
$s .= '<select name="filter_motivation" id="filter_motivation" class="flat maxwidth200">';
$s .= '<option value="none">&nbsp;</option>';
foreach ($arrayfields as $key => $val) {
Expand All @@ -76,6 +76,15 @@ public function formFilter()
$s .= ajax_combobox('filter_motivation');
$s .= '<br>';

$extrafields = new ExtraFields($this->db);
$extrafields->fetch_name_optionals_label($tmp->table_element);

foreach($extrafields->attributes[$tmp->table_element]['label'] as $key => $label) {
$s .= $langs->trans($label).' ';
$s .= '<input type="text" value="'.GETPOST($key).'" name="'.$key.'">';
$s .= '<br>';
}

return $s;
}

Expand Down Expand Up @@ -105,15 +114,28 @@ public function add_to_target($mailing_id)
$target = array();
$j = 0;

dol_include_once('/alumni/class/survey.class.php');
$tmp = new Survey($this->db);

$sql = "SELECT asu.rowid as id, asu.firstname, asu.lastname, asu.email";
$sql .= " FROM ".MAIN_DB_PREFIX."alumni_survey as asu LEFT JOIN ".MAIN_DB_PREFIX."alumni_survey_extrafields as ase ON asu.rowid = ase.fk_object";
$sql .= " FROM ".MAIN_DB_PREFIX."alumni_survey as asu";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."alumni_survey_extrafields as ase ON asu.rowid = ase.fk_object";
$sql .= " WHERE asu.email IS NOT NULL AND asu.email <> ''";
/*if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') {
$sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'";
}*/
if (GETPOSTISSET('filter_motivation') && GETPOSTINT('filter_motivation') > 0) {
$sql .= " AND asu.motivation = ".((int) GETPOSTINT('filter_motivation'));
}
$extrafields = new ExtraFields($this->db);
$extrafields->fetch_name_optionals_label($tmp->table_element);

foreach($extrafields->attributes[$tmp->table_element]['label'] as $key => $label) {
if (GETPOST($key)) {
$sql .= " AND ase.".$this->db->sanitize($key)." LIKE '".$this->db->escape(GETPOST($key))."'";
}
}

$sql .= " ORDER BY asu.email";

// Store recipients in target
Expand Down
8 changes: 4 additions & 4 deletions htdocs/alumni/core/modules/modAlumni.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,17 @@ public function __construct($db)
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
$this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 0 + 1);
$this->rights[$r][1] = 'Read Survey object of Alumni';
$this->rights[$r][1] = 'Read event choices of Alumni';
$this->rights[$r][4] = 'survey';
$this->rights[$r][5] = 'read';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 1 + 1);
$this->rights[$r][1] = 'Create/Update Survey object of Alumni';
$this->rights[$r][1] = 'Create/Update event choice of Alumni';
$this->rights[$r][4] = 'survey';
$this->rights[$r][5] = 'write';
$r++;
$this->rights[$r][0] = $this->numero . sprintf('%02d', (0 * 10) + 2 + 1);
$this->rights[$r][1] = 'Delete Survey object of Alumni';
$this->rights[$r][1] = 'Delete event choice of Alumni';
$this->rights[$r][4] = 'survey';
$this->rights[$r][5] = 'delete';
$r++;
Expand Down Expand Up @@ -289,7 +289,7 @@ public function __construct($db)
$this->menu[$r++]=array(
'fk_menu' => 'fk_mainmenu=alumni',
'type' => 'left',
'titre' => 'Survey',
'titre' => 'EventChoices',
'mainmenu' => 'alumni',
'leftmenu' => 'survey',
'url' => '/alumni/survey_list.php',
Expand Down
5 changes: 3 additions & 2 deletions htdocs/alumni/langs/en_US/alumni.lang
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ ActiviteAssocieesNature=Nature of activities
PreferenceJour=Favorite day
PreferenceMois=Favorite month
Results=Results
NewVoteEntry=New vote
NbOfVotes=Number of votes
EventChoices=Event choices
NewVoteEntry=New event choice
NbOfVotes=Number of event choices
2 changes: 1 addition & 1 deletion htdocs/alumni/survey_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
$formfile = new FormFile($db);
$formproject = new FormProjets($db);

$title = $langs->trans("Survey")." - ".$langs->trans('Card');
$title = $langs->trans("EventChoice")." - ".$langs->trans('Card');
//$title = $object->ref." - ".$langs->trans('Card');
if ($action == 'create') {
$title = $langs->trans("NewVoteEntry");
Expand Down
2 changes: 1 addition & 1 deletion htdocs/alumni/survey_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@

$now = dol_now();

$title = $langs->trans("Surveys");
$title = $langs->trans("EventChoices");
//$help_url = "EN:Module_Survey|FR:Module_Survey_FR|ES:Módulo_Survey";
$help_url = '';
$morejs = array();
Expand Down
4 changes: 2 additions & 2 deletions htdocs/google/admin/google_contactsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ function initfields()
if (!empty($_SESSION['google_web_token_'.$conf->entity]['created'])) {
print ' since '.dol_print_date($_SESSION['google_web_token_'.$conf->entity]['created'], 'dayhour');
}
print ':<br>';
if (! empty($_SESSION['google_web_token_'.$conf->entity])) {
print ' :<br>';
if (!empty($_SESSION['google_web_token_'.$conf->entity])) {
//print '<div class="quatrevingtpercent" style="max-width: 800px; overflow: scroll; border: 1px solid #aaa;">';
if (is_array($_SESSION['google_web_token_'.$conf->entity]) && key_exists('access_token', $_SESSION['google_web_token_'.$conf->entity])) {
$valuetoshow = json_encode($_SESSION['google_web_token_'.$conf->entity]);
Expand Down

0 comments on commit 26b6809

Please sign in to comment.