<!DOCTYPE html>
<html>

<head>
    <title>Quote 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="clearfix"></div>
    <div class="title">
        <div class="col-6">
          <div style="height: 10px;"></div>
      </div>
      <div class="col-6 text-right">
        <h1>QUOTE LIST</h1>
        <div class="details-box">
        </div>
    </div>
</div>
<div class="clearfix"></div>
<div class="table-body">
    <table id="tbl_enquiry_table" class="table table-fixed table-primary dataTable">
       <thead>
           <tr>
                <th>No</th>
                <th>Enquiry Reference</th> 
                <th>Company Name</th> 
                <th>Currency</th> 
                <th>Grand Total</th> 
                <th>Exchange Rate</th>                 
   		<th>Start Date</th>
                <th>Close Date</th>
                <th>Delivery Date</th>
                <th>Quotation Validity</th>
                <th>Quotation Date</th>
                <th>Expected Order Date</th>
                <th>Billing Address</th>
                <th>Shipping Address</th>
                <th>Probability</th>
                <th>Qtn Close Reason</th>
                <th>Type of Contract</th>
                <th>Contact Name</th>
                <th>Mobile</th>
                <th>Email</th>   

           </tr>
       </thead>
       <tbody>
       <?php 
        $condition = '1=1'; ;
            if($qtn_start_from_date != ''){   
                $qtn_start_from_date = str_replace('/', '-', $qtn_start_from_date);
                $qtn_start_from_date = date('Y-m-d',strtotime($qtn_start_from_date));
                $condition .= ' AND t.qtn_start_from_date >="'.$qtn_start_from_date.'"';
            }
            if($qtn_start_to_date != ''){   
                $qtn_start_to_date = str_replace('/', '-', $qtn_start_to_date);
                $qtn_start_to_date = date('Y-m-d',strtotime($qtn_start_to_date));
                $condition .= ' AND t.qtn_start_to_date <="'.$qtn_start_to_date.'"';
            }
            if($qtn_close_from_date != ''){    
                $qtn_close_from_date = str_replace('/', '-', $qtn_close_from_date);
                $qtn_close_from_date = date('Y-m-d',strtotime($qtn_close_from_date));
                $condition .= ' AND t.qtn_close_from_date >="' . $qtn_close_from_date.'"';
            }
             if($qtn_close_to_date != ''){    
                $qtn_close_to_date = str_replace('/', '-', $qtn_close_to_date);
                $qtn_close_to_date = date('Y-m-d',strtotime($qtn_close_to_date));
                $condition .= ' AND t.qtn_close_to_date <="' . $qtn_close_to_date.'"';
            }
            if($qtn_delivery_from_date != ''){    
                $qtn_delivery_from_date = str_replace('/', '-', $qtn_delivery_from_date);
                $qtn_delivery_from_date = date('Y-m-d',strtotime($qtn_delivery_from_date));
                $condition .= ' AND t.qtn_delivery_from_date >="' . $qtn_delivery_from_date.'"';
            }
            if($qtn_delivery_to_date != ''){    
                $qtn_delivery_to_date = str_replace('/', '-', $qtn_delivery_to_date);
                $qtn_delivery_to_date = date('Y-m-d',strtotime($qtn_delivery_to_date));
                $condition .= ' AND t.qtn_delivery_to_date <="' . $qtn_delivery_to_date.'"';
            }
            if($sales_group != ''){               
                $condition .= ' AND t.sales_group ="' . $sales_group.'"';
            }
            if($leadowner_id != ''){               
                $condition .= ' AND t.leadowner_id ="' . $leadowner_id.'"';
            }
             if($type_of_contract != ''){               
                $condition .= ' AND t.type_of_contract ="' . $type_of_contract.'"';
            }
            if($payment_terms != ''){               
                $condition .= ' AND t.payment_terms ="' . $payment_terms.'"';
            }
             if($status != ''){               
                $condition .= ' AND t.status ="' . $status.'"';
            }
            $model_quote = Quotes::model()->with('customer','customercontact')->findAll(array('condition'=>$condition));
        foreach ($model_quote as $i => $model) {
            ?>
        <input type="hidden" id="qtn_start_from_date" name="qtn_start_from_date" value="<?php echo $qtn_start_from_date;?>">
        <input type="hidden" id="qtn_start_to_date" name="qtn_start_to_date" value="<?php echo $qtn_start_to_date;?>">
        <input type="hidden" id="qtn_close_from_date" name="qtn_close_from_date" value="<?php echo $qtn_close_from_date;?>">
        <input type="hidden" id="qtn_close_to_date" name="qtn_close_to_date" value="<?php echo $qtn_close_to_date;?>">
        <input type="hidden" id="qtn_delivery_from_date" name="qtn_delivery_from_date" value="<?php echo $qtn_delivery_from_date;?>">
        <input type="hidden" id="qtn_delivery_to_date" name="qtn_delivery_to_date" value="<?php echo $qtn_delivery_to_date;?>">
        <input type="hidden" id="sales_group" name="sales_group" value="<?php echo $sales_group;?>">
        <input type="hidden" id="leadowner_id" name="leadowner_id" value="<?php echo $leadowner_id;?>">
        <input type="hidden" id="type_of_contract" name="type_of_contract" value="<?php echo $type_of_contract;?>">
        <input type="hidden" id="payment_terms" name="payment_terms" value="<?php echo $payment_terms;?>">
                
        <input type="hidden" id="status" name="status" value="<?php echo $status;?>">
  	 	<tr>                    
  	 	<td><?php echo $i+1;?></td>
                <!--<td><?php// echo $model->title; ?></td>-->
                <td><?php echo $model->enq_ref;?></td>
  	 	<td><?php echo $model->customer->customer_name;?></td>
                <td><?php echo $model->currencyname->currency_code;?></td>
                <td><?php echo $model->grand_total;?></td>
                <td><?php echo $model->exchange_rate;?></td>
                <?php if($model->qtn_start_date!='0000-00-00'){ ?>
                <td><?php echo date("d/m/Y", strtotime($model->qtn_start_date));?></td>
                <?php }else{ ?>
                <td>&nbsp;</td>
                <?php } ?>
                <?php if($model->qtn_close_date!='0000-00-00'){ ?>
                <td><?php echo date("d/m/Y", strtotime($model->qtn_close_date));?></td>
                <?php }else{ ?>
                <td>&nbsp;</td>
                <?php } ?>
                <?php if($model->qtn_delivery_date!='0000-00-00'){ ?>
                <td><?php echo date("d/m/Y", strtotime($model->qtn_delivery_date));?></td>
                <?php }else{ ?>
                <td>&nbsp;</td>
                <?php } ?>
                <?php if($model->qtn_validity!='0000-00-00'){ ?>
                <td><?php echo date("d/m/Y", strtotime($model->qtn_validity));?></td>
                <?php }else{ ?>
                <td>&nbsp;</td>
                <?php } ?>
                <?php if($model->qtn_date!='0000-00-00'){ ?>
                <td><?php echo date("d/m/Y", strtotime($model->qtn_date));?></td>
                <?php }else{ ?>
                <td>&nbsp;</td>
                <?php } ?>
                <?php if($model->expected_order_date!='0000-00-00'){ ?>
                <td><?php echo date("d/m/Y", strtotime($model->expected_order_date));?></td>
                <?php }else{ ?>
                <td>&nbsp;</td>
                <?php } ?>
                <td><?php echo $model->billing_address;?></td>                
                <td><?php echo $model->shipping_address;?></td>
                <td><?php echo $model->probability->probability;?></td>
                <td><?php echo $model->closereason->reason;?></td>
                <td><?php echo $model->typeofcontract->service_group_name;?></td>
                <td><?php echo $model->customercontact->person_name;?></td>
                <td><?php echo $model->mobile;?></td> 
                <td><?php echo $model->email;?></td> 
                </tr>
                 <?php } ?>
                
       </tbody>
   </table>
</div>
<!--    mpdf
        <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%">This report is auto generated by Bluesky project on 
                    <?php
                  date_default_timezone_set("Asia/Dubai");
                 echo date('d/m/Y')." ".date("h:i:sa"); ?></div>
                <div style="text-align:center;width:100%">Page {PAGENO} of {nb} </div>
            </div>
        </htmlpagefooter>
        <sethtmlpagefooter name="myfooter" page="all" value="on" />    -->
</body>

</html>
