<?php
class eventclass_augmentation_request_item  extends TableEventsBase {
	
	function init() {
		$this->events = array(
	'OnPageLoad' => true,
	'BeforeAdd' => true,
	'BeforeEdit' => true 
);
		$this->fieldValues = array(
	'filterLimit' => array(
		 
	),
	'mapIcon' => array(
		 
	),
	'viewCustom' => array(
		 
	),
	'lookupWhere' => array(
		 
	),
	'viewFileText' => array(
		 
	),
	'defaultValue' => array(
		 
	),
	'autoUpdateValue' => array(
		 
	),
	'uploadFolder' => array(
		 
	),
	'viewPluginInit' => array(
		 
	),
	'editPluginInit' => array(
		 
	) 
);
			}
		function BeforeAdd( &$values, &$sqlValues, &$message, $inline, $pageObject ) {
		// ======================================================
// AUTO-SAVE WAREHOUSE CODE AND NAME
// ======================================================

$warehouseId = intval(
    $values["warehouse_id"] ?? 0
);

if ($warehouseId > 0) {

    $rsWarehouse = DB::Query(
        "SELECT
            warehouse_code,
            name
         FROM warehouse
         WHERE id = " . $warehouseId . "
         LIMIT 1"
    );

    $warehouse = $rsWarehouse->fetchAssoc();

    if ($warehouse) {

        $values["warehouse_code"] =
            $warehouse["warehouse_code"];

        $values["warehouse_name"] =
            $warehouse["name"];
    }
}
return true;
		;
		return true;
	}

	function BeforeEdit( &$values, &$sqlValues, $where, &$oldvalues, &$keys, &$message, $inline, $pageObject ) {
		// ======================================================
// AUTO-SAVE WAREHOUSE CODE AND NAME
// ======================================================

$warehouseId = intval(
    $values["warehouse_id"] ?? 0
);

if ($warehouseId > 0) {

    $rsWarehouse = DB::Query(
        "SELECT
            warehouse_code,
            name
         FROM warehouse
         WHERE id = " . $warehouseId . "
         LIMIT 1"
    );

    $warehouse = $rsWarehouse->fetchAssoc();

    if ($warehouse) {

        $values["warehouse_code"] =
            $warehouse["warehouse_code"];

        $values["warehouse_name"] =
            $warehouse["name"];
    }
}
return true;
		;
		return true;
	}
		

}


?>