function updateProductionCost($jobcard_id, $jobitem_id, $machine_id, $user_id, $minutes, $qty) { $operation = getOperation($jobitem_id); $cost = getMachineCost($machine_id, $minutes); $suspense_acc = qryAccountsName("Production Suspense"); $suspense_acc = $suspense_acc["accid"]; $recovery_acc = qryAccountsName("Production Recovery"); $recovery_acc = $recovery_acc["accid"]; $refnum = getRefnum(); $sysdate = date("Y-m-d"); $details = "Production cost for job number: {$jobcard_id} Step: {$operation}"; writetrans($suspense_acc, $recovery_acc, $sysdate, $refnum, $cost, $details); // Update job costs $sql = "\n\t\tINSERT INTO manufact.job_costs (\n\t\t\tjobcard_id, jobitem_id, machine_id, user_id, \n\t\t\tcost, total_time, qty\n\t\t) VALUES (\n\t\t\t'{$jobcard_id}', '{$jobitem_id}', '{$machine_id}', '{$user_id}', \n\t\t\t'{$cost}', '{$minutes}', '{$qty}'\n\t\t)"; db_exec($sql) or errDie("Unable to update job costs."); $sql = "\n\t\tSELECT (cost_per_hour / 60) AS cost_per_minute, labour_type\n\t\tFROM manufact.jobcard_items\n\t\t\tLEFT JOIN manufact.labour_types ON jobcard_items.labour_type=labour_types.id\n\t\tWHERE jobcard_items.id='{$jobitem_id}'"; $cost_rslt = db_exec($sql) or errDie("Unable to retrieve labour cost."); list($labour_cost, $labour_type) = pg_fetch_array($cost_rslt); $labour_cost *= $minutes; $sql = "\n\tINSERT INTO manufact.labour_cost (jobcard_id, jobitem_id, user_id, cost, total_time, labour_type)\n\tVALUES ('{$jobcard_id}', '{$jobitem_id}', '{$user_id}', '{$labour_cost}', '{$minutes}', '{$labour_type}')"; db_exec($sql) or errDie("Unable to update labour cost."); return 1; }
<?php // Handle some very basic initalization functions... make sure everything // is in place, do requires, and such. Also set up global constants // such as DSN. require_once "Init.php"; require_once "ControllerFunctions.php"; // We do includes based on rInfo; ensure that the only way to set it // is internally. $rInfo['renderer'] = ''; $rInfo['content'] = ''; // This will be used to find out our intended action $opMap = buildOpMap(); $operation = getOperation($_SERVER['REQUEST_URI']); // Get the Action for this operation, or a PageNotFoundAction if there's // no match. $action = new PageErrorAction(); if (isset($opMap[$operation])) { $action = $opMap[$operation]; } // Defined in Init.php if (SITE_MAINTANENCE && getRemoteIp() != DEBUG_IP) { $action = new SiteMaintanenceAction(); } // There's one special case to worry about: the action requires // authentication, and we're not logged in. Handle that and perform the // Action. if ($action->isAuthenticationRequired() && !isLoggedIn()) { $action = new LoginFormAction(); } if ($action->isAdminRequired() && !isAdmin()) {