예제 #1
0
    if ($opt_logLoc === false) {
        $log->add_log($sessionID, 'Warning', 'ModifyItem Warning: Log_File_Location Option missing or invalid.');
    } else {
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($partNumber, "/^.+\$/", "Part Number");
    $IMSBase->verifyData($field, "/^.+\$/", "Item Field");
    $IMSBase->verifyData($value, "/^.+\$/", "Item Value");
    if ($sql->exists($partNumber, 'dbo.Inventory') == FALSE) {
        $statusCode = '1';
        $statusMessage = "ModifyItem Error: Part Number, {$partNumber}, does not exist.";
        $log->add_log($sessionID, 'Warning', $statusMessage);
    } else {
        $sql->command("UPDATE dbo.Inventory SET [{$field}]='{$value}' WHERE Name='{$partNumber}';");
        $statusCode = '0';
        $statusMessage = "Item({$partNumber}) {$field} was updated with {$value}";
        $log->add_log($sessionID, 'Information', $statusMessage, $partNumber);
    }
} catch (PDOException $e) {
    $statusCode = '1';
    $statusMessage = 'ModifyItem SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'ModifyItem Error: ' . $e->getMessage();
    if (!$log->add_log($sessionID, 'Error', $statusMessage, "N/A", true)) {
        $statusMessage = $statusMessage . " **Logging Failed**";
    }
}
        } else {
            $log->opt_debug = true;
        }
    }
    $opt_logLoc = $sql->getOption('Log_File_Location');
    if ($opt_logLoc === false) {
        $log->add_log($sessionID, 'Warning', 'ModifyEmailAddress Warning: Log_File_Location Option missing or invalid.');
    } else {
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($recordID, "/^.+\$/", "Record ID");
    $IMSBase->verifyData($field, "/^.+\$/", "Record Field");
    $IMSBase->verifyData($value, "/^.+\$/", "Record Value");
    $sql->command("UPDATE dbo.Emails SET [{$field}]='{$value}' WHERE ID='{$recordID}';");
    //retrieve new table.
    $sqlQuery = "SELECT * FROM dbo.Emails;";
    $stmt = $sql->prepare($sqlQuery);
    $stmt->execute();
    $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $statusCode = '0';
    $statusMessage = "Email record({$recordID}) - {$field} was updated with {$value}";
    $log->add_log($sessionID, 'Information', $statusMessage);
} catch (PDOException $e) {
    $statusCode = '1';
    $statusMessage = 'ModifyEmailAddress SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'ModifyEmailAddress Error: ' . $e->getMessage();
 $runLevel = $sql->verifySID($sessionID, "1");
 //1 = Requires edit privileges.
 $IMSBase->verifyData($recordID, "/^.+\$/", "Record ID");
 $IMSBase->verifyData($field, "/^.+\$/", "Record Field");
 $IMSBase->verifyData($value, "/^.+\$/", "Record Value");
 $IMSBase->verifyData($sortColumn, "/^.*\$/", "Sort Column");
 if ($sortColumn != "") {
     $IMSBase->verifyData($sortDirection, "/^(ASC|DESC)\$/", "Sort Direction");
 }
 if ($field == 'Part') {
     $stmt = $sql->prepare("SELECT [Part] FROM dbo.Class_Data WHERE [id]='{$recordID}';");
     $stmt->execute();
     $oldPN_array = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $oldPN = $oldPN_array[0]['Part'];
     //remove lab part flag from old part number
     $sql->command("UPDATE dbo.Inventory SET [Lab_Part_Flag]='0' WHERE [Name]='{$oldPN}';");
     //add lab part flag from new part number
     $sql->command("UPDATE dbo.Inventory SET [Lab_Part_Flag]='1' WHERE [Name]='{$value}';");
 }
 $sql->command("UPDATE dbo.Class_Data SET [{$field}]='{$value}' WHERE ID='{$recordID}';");
 //retrieve new table.
 $sqlQuery = "SELECT * FROM dbo.Class_Data";
 if ($sortColumn != "") {
     $sqlQuery = $sqlQuery . " ORDER BY {$sortColumn} {$sortDirection}";
 }
 $sqlQuery = $sqlQuery . ";";
 $stmt = $sql->prepare($sqlQuery);
 $stmt->execute();
 $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
 $partNumber = "N/A";
 //Find Part Number
 //1 = Requires edit privileges.
 $IMSBase->verifyData($classNumber, "/^.+\$/", "Class");
 $IMSBase->verifyData($partNumber, "/^.+\$/", "Part Number");
 $IMSBase->verifyData($quantity, "/^[0-9]+\$/", "Quantity");
 $IMSBase->verifyData($date, "/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\$/", "Date");
 $IMSBase->verifyData($sortColumn, "/^.*\$/", "Sort Column");
 if ($sortColumn != "") {
     $IMSBase->verifyData($sortDirection, "/^(ASC|DESC)\$/", "Sort Direction");
 }
 if ($sql->exists($partNumber, 'dbo.Inventory') == FALSE) {
     $statusCode = '1';
     $statusMessage = "AddNewClassData Error: {$partNumber} does not exist in database.";
     $log->add_log($sessionID, 'Error', $statusMessage);
 } else {
     //add new item
     $sql->command("INSERT INTO dbo.Class_Data (Class,Part,Quantity,Date) VALUES ('{$classNumber}','{$partNumber}',{$quantity},'{$date}');");
     //set flag in dbo.Inventory
     $sql->command("UPDATE dbo.Inventory SET [Lab_Part_Flag]='1' WHERE Name='{$partNumber}';");
     //retrieve new table.
     $sqlQuery = "SELECT * FROM dbo.Class_Data";
     if ($sortColumn != "") {
         $sqlQuery = $sqlQuery . " ORDER BY {$sortColumn} {$sortDirection}";
     }
     $sqlQuery = $sqlQuery . ";";
     $stmt = $sql->prepare($sqlQuery);
     $stmt->execute();
     $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $statusCode = '0';
     $statusMessage = "{$partNumber} added to Class: {$classNumber} data.";
     $log->add_log($sessionID, 'Information', $statusMessage, $partNumber);
 }
            $log->opt_debug = false;
        } else {
            $log->opt_debug = true;
        }
    }
    $opt_logLoc = $sql->getOption('Log_File_Location');
    if ($opt_logLoc === false) {
        $log->add_log($sessionID, 'Warning', 'AddEmailAddress Warning: Log_File_Location Option missing or invalid.');
    } else {
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($emailAddress, "/^.+@.+\\..+\$/", "Email Address");
    //add new item
    $sql->command("INSERT INTO dbo.Emails (Recipients,Email) VALUES ('{$emailAddress}','None');");
    //retrieve new table.
    $sqlQuery = "SELECT * FROM dbo.Emails;";
    $stmt = $sql->prepare($sqlQuery);
    $stmt->execute();
    $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $statusCode = '0';
    $statusMessage = "Email ({$emailAddress}) added to database.";
    $log->add_log($sessionID, 'Information', $statusMessage);
} catch (PDOException $e) {
    $statusCode = '1';
    $statusMessage = 'AddEmailAddress SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'AddEmailAddress Error: ' . $e->getMessage();
예제 #6
0
            $log->opt_debug = false;
        } else {
            $log->opt_debug = true;
        }
    }
    $opt_logLoc = $sql->getOption('Log_File_Location');
    if ($opt_logLoc === false) {
        $log->add_log($sessionID, 'Warning', 'DeleteItem Warning: Log_File_Location Option missing or invalid.');
    } else {
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($partNumber, "/^.+\$/", "Part Number");
    //remove the item number from Class_Data
    $sql->command("DELETE FROM dbo.Class_Data WHERE [Part]='{$partNumber}'");
    //remove the item number from Purchase_List
    //$sql->command("DELETE FROM dbo.Purchase_List WHERE [Part]='$partNumber'");
    //remove the item of Inventory
    $sql->command("DELETE FROM dbo.Inventory WHERE [Name]='{$partNumber}'");
    $statusCode = '0';
    $statusMessage = "Item:{$partNumber} has been deleted from the database.";
    $log->add_log($sessionID, 'Information', $statusMessage);
} catch (PDOException $e) {
    $statusCode = '1';
    $statusMessage = 'DeleteItem SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'DeleteItem Error: ' . $e->getMessage();
    if (!$log->add_log($sessionID, 'Error', $statusMessage, "N/A", true)) {
            $log->opt_debug = false;
        } else {
            $log->opt_debug = true;
        }
    }
    $opt_logLoc = $sql->getOption('Log_File_Location');
    if ($opt_logLoc === false) {
        $log->add_log($sessionID, 'Warning', 'ModifyOption Warning: Log_File_Location Option missing or invalid.');
    } else {
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($option, "/^.+\$/");
    $IMSBase->verifyData($data, "/^.+\$/");
    $dataArray[0] = $sql->command("UPDATE dbo.Options SET [Value]='{$data}' WHERE [Option]='{$option}'");
    $statusCode = "0";
    if ($option == 'SQL_PASS' || $option == 'Email_Pass') {
        $statusMessage = "Option {$option} changed.";
    } else {
        $statusMessage = "Option {$option} changed to {$data}.";
    }
    $log->add_log($sessionID, 'Information', $statusMessage);
} catch (PDOException $e) {
    $statusCode = 1;
    $statusMessage = 'ModifyOption SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'ModifyOption Error: ' . $e->getMessage();
    if (!$log->add_log($sessionID, 'Error', $statusMessage, "N/A", true)) {
    while ($sql->exists($partNumber, 'dbo.Inventory') == TRUE) {
        $oldPN = $partNumber;
        //Check for revision code at end of part number
        $revisionCode = substr($partNumber, -3);
        if (preg_match("/^-[0-9][0-9]\$/", $revisionCode)) {
            $intRev = intval(substr($revisionCode, -2));
            $intRev = $intRev + 1;
            $newRevStr = str_pad($intRev, 2, "0", STR_PAD_LEFT);
            $partNumber = substr($partNumber, 0, strlen($partNumber) - 3) . "-" . $newRevStr;
        } else {
            $partNumber = $partNumber . "-01";
        }
        $log->add_log($sessionID, 'Warning', "CreateNewItem.php: Part number {$oldPN} existed, replaced with {$partNumber}.");
        $partNumberChange[0]['Part'] = $partNumber;
    }
    $sql->command('INSERT INTO dbo.Inventory (Name) VALUES (\'' . $partNumber . '\');');
    $statusCode = '0';
    $statusMessage = 'Item (' . $partNumber . ') created successfully. ';
    $log->add_log($sessionID, 'Information', $statusMessage, $partNumber);
} catch (PDOException $e) {
    $statusCode = '1';
    $statusMessage = 'CreateNewItem SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'CreateNewItem Error: ' . $e->getMessage();
    if (!$log->add_log($sessionID, 'Error', $statusMessage, "N/A", true)) {
        $statusMessage = $statusMessage . " **Logging Failed**";
    }
}
//finally()  PHP 5.5+, currently using 5.3.
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($id, "/^.+\$/", "Record ID");
    $IMSBase->verifyData($sortColumn, "/^.*\$/", "Sort Column");
    if ($sortColumn != "") {
        $IMSBase->verifyData($sortDirection, "/^(ASC|DESC)\$/", "Sort Direction");
    }
    //get part number from ID
    $sqlQuery = "SELECT [Part] FROM dbo.Class_Data WHERE Id={$id}";
    $stmt = $sql->prepare($sqlQuery);
    $stmt->execute();
    $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
    $partNumber = $dataArray[0]['Part'];
    $sql->command("UPDATE dbo.Inventory SET [Lab_Part_Flag]='0' WHERE Name='{$partNumber}';");
    //Delete record
    $sql->command("DELETE FROM dbo.Class_Data WHERE Id={$id};");
    $statusCode = '0';
    $statusMessage = "{$partNumber} has been removed from Class data. (Record {$id})";
    $log->add_log($sessionID, 'Information', $statusMessage, $partNumber);
    //retrieve new table.
    $sqlQuery = "SELECT * FROM dbo.Class_Data";
    if ($sortColumn != "") {
        $sqlQuery = $sqlQuery . " ORDER BY {$sortColumn} {$sortDirection}";
    }
    $sqlQuery = $sqlQuery . ";";
    $stmt = $sql->prepare($sqlQuery);
    $stmt->execute();
    $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
            $log->opt_debug = false;
        } else {
            $log->opt_debug = true;
        }
    }
    $opt_logLoc = $sql->getOption('Log_File_Location');
    if ($opt_logLoc === false) {
        $log->add_log($sessionID, 'Warning', 'DeleteEmailAddress Warning: Log_File_Location Option missing or invalid.');
    } else {
        $log->set_log_location($opt_logLoc);
    }
    $runLevel = $sql->verifySID($sessionID, "1");
    //1 = Requires edit privileges.
    $IMSBase->verifyData($id, "/^.+\$/", "Record ID");
    //Delete record
    $sql->command("DELETE FROM dbo.Emails WHERE Id={$id};");
    $statusCode = '0';
    $statusMessage = "Email ID:{$id} has been deleted from the database.";
    $log->add_log($sessionID, 'Information', $statusMessage);
    //retrieve new table.
    $sqlQuery = "SELECT * FROM dbo.Emails;";
    $stmt = $sql->prepare($sqlQuery);
    $stmt->execute();
    $dataArray = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    $statusCode = '1';
    $statusMessage = 'DeleteEmailAddress SQLError: ' . $e->getMessage();
    $log->add_log($sessionID, 'Error', $statusMessage);
} catch (Exception $e) {
    $statusCode = $e->getCode();
    $statusMessage = 'DeleteEmailAddress Error: ' . $e->getMessage();