Cheers Steve, I'd confused myself from constantly looking at this: It still doesn't work..Currently I get a permission denied error. However, I'm sure that's down to how I've written stuff in the table delegate class.
First off, I have a load of SQL that does a load of calculations (which works fine). I shall list it below - Apologies for the length.
- Code: Select all
function __sql__(){
return "select c.*, (c.ContractSupplier1DayRate*m.DayCons) AS Supplier1DayCostEst
, (c.ContractSupplier1NightRate * m.NightCons) AS Supplier1NightCostEst
, (c.ContractSupplier1AddRate1 * m.AddCons1) AS Supplier1AddRate1CostEst
, (c.ContractSupplier1AddRate2 * m.AddCons2) AS Supplier1AddRate2CostEst
, (c.ContractSupplier1AddRate3 * m.AddCons3) AS Supplier1AddRate3CostEst
, (c.ContractSupplier1AddRate4 * m.AddCons4) AS Supplier1AddRate4CostEst
, (c.ContractSupplier1AddRate5 * m.AddCons5) AS Supplier1AddRate5CostEst
, (c.ContractSupplier1AddRate6 * m.AddCons6) AS Supplier1AddRate6CostEst
, (c.ContractSupplier1AddRate7 * m.AddCons7) AS Supplier1AddRate7CostEst
, (c.ContractSupplier1AddRate8 * m.AddCons8) AS Supplier1AddRate8CostEst
, (c.ContractSupplier1DayRate * m.DayCons)
+ (c.ContractSupplier1NightRate * m.NightCons)
+ (c.ContractSupplier1AddRate1 * m.AddCons1)
+ (c.ContractSupplier1AddRate2 * m.AddCons2)
+ (c.ContractSupplier1AddRate3 * m.AddCons3)
+ (c.ContractSupplier1AddRate4 * m.AddCons4)
+ (c.ContractSupplier1AddRate5 * m.AddCons5)
+ (c.ContractSupplier1AddRate6 * m.AddCons6)
+ (c.ContractSupplier1AddRate7 * m.AddCons7)
+ (c.ContractSupplier1AddRate8 * m.AddCons8) AS Supplier1TotalCostEst
, (c.ContractSupplier2DayRate*m.DayCons) AS Supplier2DayCostEst
, (c.ContractSupplier2NightRate * m.NightCons) AS Supplier2NightCostEst
, (c.ContractSupplier2AddRate1 * m.AddCons1) AS Supplier2AddRate1CostEst
, (c.ContractSupplier2AddRate2 * m.AddCons1) AS Supplier2AddRate2CostEst
, (c.ContractSupplier2AddRate3 * m.AddCons1) AS Supplier2AddRate3CostEst
, (c.ContractSupplier2AddRate4 * m.AddCons1) AS Supplier2AddRate4CostEst
, (c.ContractSupplier2AddRate5 * m.AddCons1) AS Supplier2AddRate5CostEst
, (c.ContractSupplier2AddRate6 * m.AddCons1) AS Supplier2AddRate6CostEst
, (c.ContractSupplier2AddRate7 * m.AddCons1) AS Supplier2AddRate7CostEst
, (c.ContractSupplier2AddRate8 * m.AddCons1) AS Supplier2AddRate8CostEst
, (c.ContractSupplier2DayRate * m.DayCons)
+ ifnull((c.ContractSupplier2NightRate * m.NightCons),0)
+ (c.ContractSupplier2AddRate1 * m.AddCons1)
+ (c.ContractSupplier2AddRate2 * m.AddCons2)
+ (c.ContractSupplier2AddRate3 * m.AddCons3)
+ (c.ContractSupplier2AddRate4 * m.AddCons4)
+ (c.ContractSupplier2AddRate5 * m.AddCons5)
+ (c.ContractSupplier2AddRate6 * m.AddCons6)
+ (c.ContractSupplier2AddRate7 * m.AddCons7)
+ (c.ContractSupplier2AddRate8 * m.AddCons8) AS Supplier2TotalCostEst
, (c.ContractSupplier3DayRate*m.DayCons) AS Supplier3DayCostEst
, (c.ContractSupplier3NightRate * m.NightCons) AS Supplier3NightCostEst
, (c.ContractSupplier3AddRate1 * m.AddCons1) AS Supplier3AddRate1CostEst
, (c.ContractSupplier3AddRate2 * m.AddCons1) AS Supplier3AddRate2CostEst
, (c.ContractSupplier3AddRate3 * m.AddCons1) AS Supplier3AddRate3CostEst
, (c.ContractSupplier3AddRate4 * m.AddCons1) AS Supplier3AddRate4CostEst
, (c.ContractSupplier3AddRate5 * m.AddCons1) AS Supplier3AddRate5CostEst
, (c.ContractSupplier3AddRate6 * m.AddCons1) AS Supplier3AddRate6CostEst
, (c.ContractSupplier3AddRate7 * m.AddCons1) AS Supplier3AddRate7CostEst
, (c.ContractSupplier3AddRate8 * m.AddCons1) AS Supplier3AddRate8CostEst
, (c.ContractSupplier3DayRate * m.DayCons)
+ (c.ContractSupplier3NightRate * m.NightCons)
+ (c.ContractSupplier3AddRate1 * m.AddCons1)
+ (c.ContractSupplier3AddRate2 * m.AddCons2)
+ (c.ContractSupplier3AddRate3 * m.AddCons3)
+ (c.ContractSupplier3AddRate4 * m.AddCons4)
+ (c.ContractSupplier3AddRate5 * m.AddCons5)
+ (c.ContractSupplier3AddRate6 * m.AddCons6)
+ (c.ContractSupplier3AddRate7 * m.AddCons7)
+ (c.ContractSupplier3AddRate8 * m.AddCons8) AS Supplier3TotalCostEst
, datediff(c.ContractEndDate,c.ContractStartDate) as ContractLength, if(c.ContractStatus='Accepted' and c.ContractStartDate<=NOW() and c.ContractEndDate>=NOW(),'YES','NO') as ContractActive
FROM ContractData c
left join MPANData_ContractData mc ON c.ContractDataID = mc.ContractDataID
left join MPANData m ON mc.MPANCore = m.MPANCore";
}
Now what I need to say is if the field "NoSupplierQuote3" contains a value, then multiply that value by a stuff (some of which is used above) (shown below)
- Code: Select all
function NoSupplierQuote3__validate(&$record,$value) {
if ( isset ($value) ) {
$sql = "select c.*, (c.ContractSupplier1NightRate * m.NightCons)
+ (c.ContractSupplier1AddRate1 * m.AddCons1)
+ (c.ContractSupplier1AddRate2 * m.AddCons2)
+ (c.ContractSupplier1AddRate3 * m.AddCons3)
+ (c.ContractSupplier1AddRate4 * m.AddCons4)
+ (c.ContractSupplier1AddRate5 * m.AddCons5)
+ (c.ContractSupplier1AddRate6 * m.AddCons6)
+ (c.ContractSupplier1AddRate7 * m.AddCons7)
+ (c.ContractSupplier1AddRate8 * m.AddCons8)
* $value)
AS ContractSupplier3TotalCostEst
FROM ContractData c
left join MPANData_ContractData mc ON c.ContractDataID = mc.ContractDataID";
}
}
else just run the code that I've detailed first.
Sorry if I keep asking for help on this but I can't quite get my head round it. I figure it should be really simple and perhaps I'm over complicating it
If NoSupplierQuote3 has a value then use it (as per the second code block), else ignore the field completely and run the stuff in the first code block.
Is it possible?
Thanks so much for the time you spend helping me.