How do I control the number of records insert for a particular table during the day depending on level security.
Control insert into table at a day
-
- User
- Posts: 11905
Similar to this topic: http://www.hkvforums.com/viewtopic.php?f=4&t=32363
For checking user level security, then all you have to do is by adding the "if - else" control block.
For example:
// this code belongs to the "Page_Load" server event of the "Add Page".
function Page_Load() {
$levelid = CurrentUserLevel();
$val = ew_ExecuteScalar("SELECT COUNT(*) FROM YourTable
WHERE YourUserLevelField
= ".$levelid." AND YourDateField
= '".date("Y-m-d")."'");
if ($levelid == 1 && $val >= 10) {
$this->setFailureMessage("Sorry, you are limited to entry 10 records for today!");
$this->Page_Terminate("YourTablelist.php");
} elseif ($levelid == 2 && $val >= 20) {
$this->setFailureMessage("Sorry, you are limited to entry 20 records for today!");
$this->Page_Terminate("YourTablelist.php");
} else {
// ... and so forth ...
}
}