<?php
js::set('removeQuotation', $lang->contract->warning->removeQuotation);
$removeHtml = html::hidden('remove', 'no');
?>

<table class='companyInfo hide'>
  <tbody>
    <?php if(count($companies) > 1):?>
    <tr>
      <th class='w-70px'><?php echo $lang->contract->company;?></th>
      <td><?php echo html::select('company', $companies, $contract->company, "class='form-control'");?></td>
    </tr>
    <?php else:?>
    <tr class='hidden'><td colspan='2'><?php echo html::hidden('company', (!empty($companies) ? key($companies) : 0));?></td></tr>
    <?php endif;?>
  </tbody>
</table>

<script>
$('.side-col > .panel').first().find('.table tbody tr').first().before($('.companyInfo tbody').html());
$('#amount').closest('tr').append(<?php echo json_encode($removeHtml);?>);
</script>

<?php
$totalMoney = 0;
foreach($contract->quotations as $quotation)
{
    if(empty($quotation->orderID)) $totalMoney += $quotation->amount;
}
?>
<?php if(!empty($totalMoney)):?>
<?php
$output  = "<tr><th>" . $lang->contract->quotation . "</th>";
$output .= "<td><div class='row'><div class='col-sm-2'><div class='input-group'>";
$output .= "<div class='input-group-addon'>" . zget($currencySign, $contract->currency, '') . "</div>";
$output .= html::input('real[]', $totalMoney, "class='order-real form-control' readonly='readonly'") ."</div></div>";
$output .= "<div class='col-sm-10'><span class='text-info'>" . $lang->contract->moneyTips . "</span></div></div></td>";
?>
<script>
$('#amount').closest('tr').before(<?php echo json_encode($output);?>);
</script>
<?php endif;?>
