📝 Update and organize project documentation and assets

This commit is contained in:
2026-01-26 22:46:14 +00:00
parent 4194dcfeff
commit b20e2185b2
1433 changed files with 64484 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
class ApplianceChangeController
{
public static function get($key)
{
global $ovdb;
$key = $key;
$results = $ovdb->perform("SELECT
date_entered,
reason,
items_changed,
base_plate_sku,
pouch_sku,
entered_by,
DATEDIFF(date_entered, @prev) AS DaysDifference,
@prev := date_entered as DateChanged
FROM
gastrotrack_vault.appliance_change,
(SELECT @prev := NULL) AS vars
WHERE entered_by = '$key' AND ItemsChanged = 'Appliance'
ORDER BY date_entered ASC;");
// if (is_array($results)) {
// foreach ($results as &$result) {
// $result['data'] = json_decode($result['data']);
// }
// }
echo Response::json($results, 'No appliance changes could be detected.');
die;
}
public static function post()
{
global $ovdb;
if (!page::post('weight') && !page::post('username')) {
echo Response::json(null, 'This post request did not include all mandatory parameters.');
die;
}
$reason = page::post('weight');
$item = page::post('item');
$pouchSKU = page::post('pouchSKU');
$bpSKU = page::post('bpSKU');
$username = page::post('username');
//$data = rtrim(json_encode(page::post("data")));
$applianceRan = false;
$pouchRan = false;
$bpRan = false;
// does a record exist?
//if(!self::doesRecordExist($id, $factory)){
// No record exists for this app+factory. Insert it.
if ($item == 'Pouch') {
$applianceRan = self::_applianceChange($reason, $item, null, $pouchSKU, $username);
$pouchRan = self::_pouchReduce($pouchSKU, $username);
$bpRan = true;
} else {
$applianceRan = self::_applianceChange($reason, $item, $bpSKU, $pouchSKU, $username);
$pouchRan = self::_pouchReduce($pouchSKU, $username);
$bpRan = self::_bpReduce($bpSKU, $username);
}
// } else {
// $results = $ovdb->insert("UPDATE freepoint.applications SET factory = '$factory', data = '$data' WHERE id = '$id' AND factory = '$factory'");
// }
if ($applianceRan && $pouchRan && $bpRan) {
echo Response::json(array('id' => 'success', 'message' => 'The weight data has been saved.'));
} else {
echo Response::json(array('id' => 'error', 'message' => 'The weight data could not be saved.'));
}
}
private static function _applianceChange($reason, $item, $bpSKU, $pouchSKU, $username)
{
global $ovdb;
// get all users that match this email (should only be one)
$results = $ovdb->perform("INSERT INTO
gastrotrack_vault.appliance_change (date_entered, reason, items_changed, base_plate_sku, pouch_sku, entered_by )
VALUES (DATE_ADD(NOW(),INTERVAL 3 HOUR), '$reason', '$item', '$bpSKU', '$pouchSKU',DATE_ADD(NOW(),INTERVAL 3 HOUR), '$username');");
// check if there are results and return the first or false
if (is_object($results)) {
return true;
} else {
return false;
}
}
private static function _pouchReduce($pouchSKU, $username)
{
global $ovdb;
// get all users that match this email (should only be one)
$results = $ovdb->perform("INSERT INTO gastrotrack_vault.product_stock (sku, units,
date_entered, entered_by )
VALUES ('$pouchSKU',-1,DATE_ADD(NOW(),INTERVAL 3 HOUR),'$username');");
// check if there are results and return the first or false
if (is_object($results)) {
return true;
} else {
return false;
}
}
private static function _bpReduce($bpSKU, $username)
{
global $ovdb;
// get all users that match this email (should only be one)
$results = $ovdb->perform("INSERT INTO gastrotrack_vault.product_stock (sku, units,
date_entered,entered_by )
VALUES ('$bpSKU',-1,DATE_ADD(NOW(),INTERVAL 3 HOUR),'$username');");
// check if there are results and return the first or false
if (is_object($results)) {
return true;
} else {
return false;
}
}
}