|
|
@@ -186,12 +186,19 @@ class TB_Shared_Ent_TeamData_Contract extends Francis_Db_Row |
|
|
if ( 0 < count( $appIds ) )
|
|
|
if ( 0 < count( $appIds ) )
|
|
|
{
|
|
|
{
|
|
|
$in = str_repeat('?,', count( $appIds ) - 1 ) . '?';
|
|
|
$in = str_repeat('?,', count( $appIds ) - 1 ) . '?';
|
|
|
$sql = "SELECT SUM( price_factor ) AS `current_total` FROM `appointment` WHERE ";
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM `appointment` WHERE ";
|
|
|
$sql .= "id IN ( $in )";
|
|
|
$sql .= "id IN ( $in )";
|
|
|
$stmt = $dbh->prepare( $sql );
|
|
|
$stmt = $dbh->prepare( $sql );
|
|
|
$stmt->execute( $appIds );
|
|
|
$stmt->execute( $appIds );
|
|
|
$rowSum = $stmt->fetch( PDO::FETCH_ASSOC );
|
|
|
|
|
|
$sumPriceFactor = $rowSum[ 'current_total' ];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$appointments = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
|
$appointmentsById = [];
|
|
|
|
|
|
foreach ($appointments as $app) {
|
|
|
|
|
|
$appointmentsById[$app['id']] = $app;
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach ($appIds as $appId) {
|
|
|
|
|
|
$sumPriceFactor += $appointmentsById[$appId]['price_factor'];
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
$contract = TB_Shared_Ent_TeamData_Contract::get( $contractId );
|
|
|
$contract = TB_Shared_Ent_TeamData_Contract::get( $contractId );
|
|
|
|