function UpdateGrp($Id, $Arr)
{
    global $Db, $Logs, $nsProduct, $CurrentCompany, $nsUser, $Lang;
    extract($Arr);
    if (!ValidVar($Name)) {
        $Logs->Err($Lang['MustFillName']);
        return;
    }
    if (!ValidVar($Watch)) {
        $Watch = 0;
    }
    $Query = "\n\t\tUPDATE " . PFX . "_tracker_client_visitor_grp SET\n\t\t\tNAME=?,\n\t\t\tDESCRIPTION=?\n\t\tWHERE ID={$Id} AND COMPANY_ID=" . $CurrentCompany->ID . "\n\t";
    $Db->Query($Query, $Name, $Descr);
    $CheckWatch = CheckVisWatch($Id, $nsUser->UserId());
    if (ValidVar($Watch) == 1 && !$CheckWatch) {
        SetVisWatch($Id, $nsUser->UserId());
    }
    if (!ValidVar($Watch) && $CheckWatch) {
        RemoveVisWatch($Id, $nsUser->UserId());
    }
    $nsProduct->Redir("visitor_grp", "RUpd=1&EditId={$Id}", "admin");
}
Example #2
0
function UpdateVisitor($Id, $EditArr)
{
    global $Db, $nsProduct, $nsUser, $CurrentCompany, $Lang;
    global $Logs, $NewIp;
    if (!ValidId($CurrentCompany->ID)) {
        $Logs->Err($Lang['ChooseClientForSave']);
        return;
    }
    extract($EditArr);
    if (!ValidVar($Watch)) {
        $Watch = 0;
    }
    $Query = "SELECT ID FROM " . PFX . "_tracker_client_visitor WHERE VISITOR_ID = {$Id} AND COMPANY_ID=" . $CurrentCompany->ID;
    $Check = $Db->ReturnValue($Query);
    if ($Check) {
        $Query = "UPDATE " . PFX . "_tracker_client_visitor SET NAME = ?, DESCRIPTION = ? WHERE VISITOR_ID = {$Id} AND COMPANY_ID=" . $CurrentCompany->ID;
    } else {
        $Query = "INSERT INTO " . PFX . "_tracker_client_visitor (NAME, DESCRIPTION, VISITOR_ID, COMPANY_ID) VALUES (?, ?, {$Id}, " . $CurrentCompany->ID . ")";
    }
    $Db->Query($Query, $Name, $Descr);
    $CheckWatch = CheckVisWatch($Id, $nsUser->UserId());
    if (ValidVar($Watch) == 1 && !$CheckWatch) {
        SetVisWatch($Id, $nsUser->UserId());
    }
    if (!ValidVar($Watch) && $CheckWatch) {
        RemoveVisWatch($Id, $nsUser->UserId());
    }
    $nsProduct->Redir("visitor", "RUpd=1&VisId={$Id}&NewIp={$NewIp}", "admin");
}