OS Property support center
Adding Number of Properties
- cmtrig
-
Topic Author
- Offline
- Senior Member
-
Less
More
11 years 10 months ago #32168
by cmtrig
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Adding Number of Properties was created by cmtrig
Hi, I tried to submit a trouble ticket about this subject, but as usual, did not get an answer, just a "good luck in programming it yourself", so I have been trying. Here is what I need:
OSProperty is programmed to reduce the value of "number of properties" by "1" in the osrs_agent_account table nproperties field when adding a property to the system. So if you have a limit of 50 properties you can list, it reduces the nproperties value to 49 when you add a property. Great.
When an Agent DELETES a property, it does not ADD the nproperties value back to to table. So you add 40 properties, delete 30 of them, and you can still only post 10 more.
I am trying to create a new Function in Common.php called disaddSubscription, based on the Function to reduce the number of nproperties. I placed this code in the common.php, right under the "Discount Property from subscription" function:
Now to activate this function, I added this to the Delete Property Function in listing.php:
Right before the //Remove Images section, but no matter what variant I try, it will not add a nproperty to the Agent's agent_account table. Can any of you PHP gurus (or the developers) help me get this to work? It really should be in the program already...
Thanks in advance!
OSProperty is programmed to reduce the value of "number of properties" by "1" in the osrs_agent_account table nproperties field when adding a property to the system. So if you have a limit of 50 properties you can list, it reduces the nproperties value to 49 when you add a property. Great.
When an Agent DELETES a property, it does not ADD the nproperties value back to to table. So you add 40 properties, delete 30 of them, and you can still only post 10 more.
I am trying to create a new Function in Common.php called disaddSubscription, based on the Function to reduce the number of nproperties. I placed this code in the common.php, right under the "Discount Property from subscription" function:
Code:
function disaddSubscription($sub_id){
global $mainframe;
$user = JFactory::getUser();
$db = JFactory::getDbo();
$db->setQuery("Select id from #__osrs_agents where user_id = '$user->id'");
$agent_id = $db->loadResult();
$db->setQuery("UPDATE #__osrs_agent_account SET nproperties = nproperties + 1 WHERE agent_id = '$agent_id' and sub_id = '$sub_id'");
$db->query();
}
Code:
$membership_sub_id = JRequest::getVar('membership_sub_id',0);
if($membership_sub_id > 0){
$db->setQuery("Select * from #__osrs_agent_account where sub_id = '$membership_sub_id'");
$account = $db->loadObject();
HelperOspropertyCommon::disaddSubscription($account->sub_id);
}
Right before the //Remove Images section, but no matter what variant I try, it will not add a nproperty to the Agent's agent_account table. Can any of you PHP gurus (or the developers) help me get this to work? It really should be in the program already...
Thanks in advance!
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 13023
- Thank you received: 1688
11 years 10 months ago #32171
by Mr. Dam
Replied by Mr. Dam on topic Re: Adding Number of Properties
Hi,
The main problem in your code
$membership_sub_id = JRequest::getVar('membership_sub_id',0);
You get the $membership_sub_id in POST varriables parameters, but the main issue is we don't pass the membership_id in the "remove properties" button. We can find the membership_id of agent from table : #__osrs_agent_accounts, but in case agent purchase more than one subscription. we can't find the correct subscription plan ($membership_sub_id). But if this is not problem, we can solve it by using this code:
$db->setQuery("Select sub_id from #__osrs_agent_account where agent_id = '$agent_id'");
$sub_id = $db->loadResult();
if($sub_id > 0){
.....
}
Of course you must find the agent_id before run above code.
Thanks
Dam
The main problem in your code
$membership_sub_id = JRequest::getVar('membership_sub_id',0);
You get the $membership_sub_id in POST varriables parameters, but the main issue is we don't pass the membership_id in the "remove properties" button. We can find the membership_id of agent from table : #__osrs_agent_accounts, but in case agent purchase more than one subscription. we can't find the correct subscription plan ($membership_sub_id). But if this is not problem, we can solve it by using this code:
$db->setQuery("Select sub_id from #__osrs_agent_account where agent_id = '$agent_id'");
$sub_id = $db->loadResult();
if($sub_id > 0){
.....
}
Of course you must find the agent_id before run above code.
Thanks
Dam
Please Log in or Create an account to join the conversation.
- cmtrig
-
Topic Author
- Offline
- Senior Member
-
11 years 10 months ago - 11 years 10 months ago #32399
by cmtrig
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Replied by cmtrig on topic Re: Adding Number of Properties
Ok, I got it to work, for anyone that wants this in their OSProperty.
Add this code to classes/listing.php in the Delete Properties area (I put mine right before the //remove images line):
This now adds a +1 to the nproperties of the Agent.
Add this code to classes/listing.php in the Delete Properties area (I put mine right before the //remove images line):
Code:
//Add +1 properties to Agent Table
$user = JFactory::getUser();
$db->setQuery("Select id from #__osrs_agents where user_id = '$user->id'");
$agent_id = $db->loadResult();
$db->setQuery("Select sub_id from #__osrs_agent_account where agent_id = '$agent_id'");
$sub_id = $db->loadResult();
if($sub_id > 0){
$db->setQuery("UPDATE #__osrs_agent_account SET nproperties = nproperties + 1 WHERE agent_id = '$agent_id' and sub_id = '$sub_id'");
$db->query();
}
This now adds a +1 to the nproperties of the Agent.
Charlie Trig, Trig Web Design
www.trigwebdesign.com
Last edit: 11 years 10 months ago by cmtrig.
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 13023
- Thank you received: 1688
11 years 10 months ago #32410
by Mr. Dam
Replied by Mr. Dam on topic Re: Adding Number of Properties
Congratulation

Please Log in or Create an account to join the conversation.
Moderators: Mr. Dam, Nguyen Phu Quan
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.