<!DOCTYPE html>
<html>

<head>
    <title>Contract List</title>
</head>

<body>
    <div class="heading">
        <div class="logo col-6">
            <img src="images/pdf/logo.png">
        </div>
        <div class="companay_name col-6 text-right">
           <?php
                
                $model_Company = MasCompany::model()->find();
                
                ?>
                
                <h3><?php echo $model_Company->company_name; ?></h3>
                <p><?php echo $model_Company->company_address; ?>
                <?php echo ', '.$model_Company->company_location; ?>
                <?php echo ', '.$model_Company->country->country_name; ?></p>
                <p><?php echo 'Phone : '. $model_Company->company_phone_no; ?></p>
                <p><?php echo 'Email : '.$model_Company->company_email_id; ?></p>
        </div>
    </div>
    <div class="">
         <div class="col-4">
             <br>
             <?php
                         $modelQ1 = Contract::model()->find(array('condition'=>'t.id="'.$id.'"'));

                   $model_cust = Customers::model()->find(array('condition'=>'id = "'.$modelQ1->customer_id.'"'));
?>
            <!--<span style="color:#1e62a3;font-size: 18px;margin-bottom: 25px"><b><?php// echo $title." # ".$model->id;?></b></span><br>-->
            
            <b><?php echo QUOTATION; ?></b><br/>
             <?php echo $model_cust->customer_name; ?><br/>
  
            <?php echo  $model_cust->customer_location; ?><br/>

            <?php echo  $model_cust->customer_phone_no; ?><br/>
            
            <?php echo  $model_cust->customer_email_id; ?><br/>

        </div>
        <div class="col-6" style="margin-left:25%;color:#101010;">

        <br>

        <table class="table" style="width:100%">
        <tr>

            <td>Contract No</td>

            <td><b><?php echo $id;?></b></td>

        </tr>
        <tr>
            <?php
            $modelQ = Contract::model()->find(array('condition'=>'t.id="'.$id.'"'));
                 
            ?>

            <td>File ID</td>

            <td><?php echo $modelQ->file_id;?></td>

        </tr>
        <tr>

            <td>Company ID</td>

            <td><?php echo $model_Company->id;?></td>

        </tr>

       
         <tr>

            <td>Contract Date From</td>

            <td><?php echo date('d/m/Y',STRTOTIME($model->contract_date_from));?></td>

        </tr>
         <tr>

            <td>Contract Date To</td>

            <td><?php echo date('d/m/Y',STRTOTIME($model->contract_date_to));?></td>

        </tr>
        
        <tr>

            <td>Currency</td>

            <td><?php echo "AED";?></td>

        </tr>

    </table>

         </div>
        </div>

    <br>
    
    <div class="col-md-12">

        <table id="" class="table table-fixed table-primary dataTable">

            <thead>

                <tr>
                       <th class="text-center">Sl No</th>
                    <th class="text-center">Description</th>

                    <th class="text-center">Qty</th>
                     <th class="text-center">Unit</th>
                
                       <th class="text-center">Rate</th>
                 <th class="text-center">Net Amount</th>
                         
                   

                </tr>

            </thead>

            <tbody>

                    <tr>
                        <?php
                        $m=1;
                        $condition .= '1=1';
                        $condition .= ' AND t.contract_id ="' . $id.'"';
 $model_Quotes = ContractItem::model()->findAll(array('condition'=>$condition));
        foreach ( $model_Quotes as $i =>  $model_Quotes) {
            ?>
                          <td><?php echo $m;?></td>
                        <td><?php echo $model_Quotes->description;?></td>
                <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($model_Quotes->quantity," ");?></td>

                     
                        <?php
                        
         $model_unit = MasUnit::model()->find(array('condition'=>'t.id ="' . $model_Quotes->unit.'"'));
         
echo $model_unit->id;
        ?>
                        
                        
                        
                        
                         <td><?php echo $model_unit->unit_name;?></td>
                         <?php $rate=$model_Quotes->net_amount/$model_Quotes->quantity;?>
                            <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($rate," ");?></td>

                    
   <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($model_Quotes->net_amount," ");?></td>

                          
                        <!--<td class="text-right"><?php //echo number_format($model_Quotes->amount, 2, '.', ',');?></td>-->

                    </tr>
        
                    <tr>
                        <?
                        $m=$m+1;
        }?>

                        <td class="text-right" colspan="5"><b>Net Total  </b></td>
                        <!--<td></td>-->
                        
                        <?php 
                        $total=$total+$model_Quotes->amount;
                        ?>
                           <td class="text-right"><?php echo Yii::app()->numberFormatter->formatCurrency($total," ");?></td>


                    </tr>

<!--          <tr>
       <td class="text-right" colspan="5"><b><?php //echo ucfirst($this->widget('ext.NumtoWord.NumtoWord', array('num' => floatval($total)))->result) . ' only';  ?></b></td>

                    </tr>-->
   

            </tbody>

            

        </table>
        <?php
        $condition1 .= '1=1';
        $condition1 .= ' AND t.id ="' . $id.'"';
        $model_Quotes2 = Contract::model()->find(array('condition'=>$condition1));
        
            ?>
    <h5>Terms and Conditions</h5>

      <?php echo  nl2br($model_Quotes2->terms_and_conditions);?> 
    
    <h5>Notes</h5>

      <?php  echo  nl2br($model_Quotes2->notes);?> 
    
    </div>

  <br/>
   <br/>
   <br/>
   <br/>
   <br/>
   <br/>
   <br/>
   <br/>
   
<div style="text-align:center;width:100%;font-size:10px">This report is auto generated by Bluesky CRM on 
                    <?php
                  date_default_timezone_set("Asia/Dubai");
                 echo date('d/m/Y')." ".date("h:i:sa"); ?> </div>
  
<htmlpagefooter name="myfooter">
            <div style="border-top: 1px dotted #000000; font-size: 12px; text-align: center; padding-top: 10px; ">
                <div style="text-align:center;width:100%"><b><?php echo $model_Company->company_name; ?></b> <br/><?php echo $model_Company->company_address; ?>
                   <?php echo ', '.$model_Company->company_location; ?><?php echo ', '.$model_Company->country->country_name; ?></div>
                <div style="text-align:center;width:100%">Page {PAGENO} of {nb} </div>
            </div>
        </htmlpagefooter>
    
</body>


</html>