javier94
Member
hello,
i have a radiobutton element, named "activar".. with 2 options... yes or not. .so the user must to say one of both options...
if user have 3 registers with "yes" the suscription is ok.. but if user wants one more register the "4" register.. the user must to upgrade to a different suscription.
i have try with the Re-direct plugin form ( so redirects to the upgrade suscriptions plans page)
the trouble is.. if the user go to upgrade suscriptions page, but will not do nothing and turn back to the
form.. the "4" register is added, but the user didn´t make the upgrade...
Once we saved the form.. using the plugin i can not control what the user makes.. and the new register is saved, allowed to the suscriber, work without make the upgrade.
so this option is not working well.
Now, I'm trying use the radio button, but giving a php validation...
1.- i check for the suscriber type
2.- when i know the suscriber --> check how many registers are allowed
3.- if the registers are ok -- suscriber continues.. if are not ok.. should make an upgrade.(go to an article)
the code use is:
$uid = '{cartas_registro___user_id}';
$db = JFactory::getDbo();
/// Contamos registros a Sí
$query1 = $db
->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('cartas_registro'))
->where($db->quoteName('check_1') . " = 1")
->where($db->quoteName('user_id') . " = " . $uid);
// Reset the query using our newly populated query object.
$db->setQuery($query1);
$count = $db->loadResult();
/// Cogemos plan_id de la fecha del último plan suscrito
$query = $db->getQuery(true);
$query->select($db->quoteName(array('plan_subscription_status','plan_subscription_to_date','plan_id','user_id', 'first_name', 'published'))); //published - 1 activo - 0 no es activo
$query->from($db->quoteName('w47fa_osmembership_subscribers'));
$query->where($db->quoteName('user_id') . ' = ' . $uid);
$query->order($db->quoteName('plan_subscription_to_date') . ' DESC');
$db->setQuery($query);
//$row = $db->loadResult();
$row = $db->loadAssoc();
//var_dump("A Sí tenemos: " . $count . " - " . $row['plan_subscription_to_date'] . " - " . $row['plan_id']);
//exit();
$plan = $row['plan_id'];
if($row['published'] == 0){
return true;
} else {
switch ($plan) {
case 1:
if ($count <= 3){
return false;
} else {
return true;
}
break;
case 2:
if ($count <= 6){
return false;
} else {
return true;
}
break;
case 3:
if ($count <= 15){
return false;
} else {
return true;
}
break;
default:
return true;
}
}
=============
Is possible add a re-direct inside this code.. and if the validation is not ok.. go to this page
(https://qrmenudigital.com/index.php?option=com_content&view=article&layout=edit&id=56)
Which would be the best way to re-direct to the article use the validation???
Any suggestion??
thanks
Javier
i have a radiobutton element, named "activar".. with 2 options... yes or not. .so the user must to say one of both options...
if user have 3 registers with "yes" the suscription is ok.. but if user wants one more register the "4" register.. the user must to upgrade to a different suscription.
i have try with the Re-direct plugin form ( so redirects to the upgrade suscriptions plans page)
the trouble is.. if the user go to upgrade suscriptions page, but will not do nothing and turn back to the
form.. the "4" register is added, but the user didn´t make the upgrade...
Once we saved the form.. using the plugin i can not control what the user makes.. and the new register is saved, allowed to the suscriber, work without make the upgrade.
so this option is not working well.
Now, I'm trying use the radio button, but giving a php validation...
1.- i check for the suscriber type
2.- when i know the suscriber --> check how many registers are allowed
3.- if the registers are ok -- suscriber continues.. if are not ok.. should make an upgrade.(go to an article)
the code use is:
$uid = '{cartas_registro___user_id}';
$db = JFactory::getDbo();
/// Contamos registros a Sí
$query1 = $db
->getQuery(true)
->select('COUNT(*)')
->from($db->quoteName('cartas_registro'))
->where($db->quoteName('check_1') . " = 1")
->where($db->quoteName('user_id') . " = " . $uid);
// Reset the query using our newly populated query object.
$db->setQuery($query1);
$count = $db->loadResult();
/// Cogemos plan_id de la fecha del último plan suscrito
$query = $db->getQuery(true);
$query->select($db->quoteName(array('plan_subscription_status','plan_subscription_to_date','plan_id','user_id', 'first_name', 'published'))); //published - 1 activo - 0 no es activo
$query->from($db->quoteName('w47fa_osmembership_subscribers'));
$query->where($db->quoteName('user_id') . ' = ' . $uid);
$query->order($db->quoteName('plan_subscription_to_date') . ' DESC');
$db->setQuery($query);
//$row = $db->loadResult();
$row = $db->loadAssoc();
//var_dump("A Sí tenemos: " . $count . " - " . $row['plan_subscription_to_date'] . " - " . $row['plan_id']);
//exit();
$plan = $row['plan_id'];
if($row['published'] == 0){
return true;
} else {
switch ($plan) {
case 1:
if ($count <= 3){
return false;
} else {
return true;
}
break;
case 2:
if ($count <= 6){
return false;
} else {
return true;
}
break;
case 3:
if ($count <= 15){
return false;
} else {
return true;
}
break;
default:
return true;
}
}
=============
Is possible add a re-direct inside this code.. and if the validation is not ok.. go to this page
(https://qrmenudigital.com/index.php?option=com_content&view=article&layout=edit&id=56)
Which would be the best way to re-direct to the article use the validation???
Any suggestion??
thanks
Javier