Page 1 of 1

Control insert into table at a day

Posted: Sat Aug 24, 2013 7:35 pm
by wfouad

How do I control the number of records insert for a particular table during the day depending on level security.


Re: Control insert into table at a day

Posted: Sat Aug 24, 2013 10:31 pm
by mobhar

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 ...
}
}