<?php  use Cake\ORM\TableRegistry;
    $bproducts = TableRegistry::get('Branches'); 
    $uproducts = TableRegistry::get('Users');
    $brproducts = TableRegistry::get('Brokers');  	
?>

<STYLE type="text/css">
    .tableTd {
        border-width: 0.5pt;
        border: 0.5px solid;
    }
    .tableTdContent{
        border-width: 0.5pt;
        border: 0.5px solid;
    }
    #titles{
        font-weight: bolder;
        background-color:#ccc;
    }

    table {
        border-spacing:0;
        border-collapse: collapse;
    }

    table th,table td {
        font-size: 10px;
    }




</STYLE>

<div class="">
    <h3><?= __('Date Range Wise FD Maturity Data') ?></h3>
    <table cellpadding="0" cellspacing="0">
        <thead>
        	<tr>
		<th class="tableTd" scope="col" colspan="3"><b>
			  
			  <div style="clear: both;">Report: Date Range Wise FD Maturity Data</div>
</th>			  
<th class="tableTd" scope="col" colspan="2"><b>
			  	  
			  <?php 
			  if($customer_name != '')
			  {
				
				echo 'Investor Name :'.$customer_name;
			  }
			  else{
			  echo 'Investor Name : all' ;
			  }
			  
			  ?></b>
			  </th>
			  <th class="tableTd" scope="col" colspan="2"><b>
			  
			 
			  
			  <?php 
			 
                 if($companyname != ''){
                           echo 'Company Name :'.$companyname;
						   }
						   else{
                    echo 'Company Name : all';
                 }
                  ?></b></th>
              <th class="tableTd" scope="col" colspan="5"><b>
			  <?php 
			 
                 if($datedform != '' && $datedto != '' ){
                             echo 'Date :  '.$dated2;
						   echo ' - '.$dated1; 
                          // echo 'Date :  '. $datedform;
						   //echo ' - '.$datedto;     
						   }
						   else{
                     echo 'Date : all' ;
                 }
                  ?></b></th>
				  				 
				  </tr>
            <tr>
                <th class="tableTd" style="width:40px;" scope="col">Sr No</th>
                <th class="tableTd" scope="col">Investor Name</th>
                <th class="tableTd" scope="col">Pan No</th>
				<th class="tableTd" scope="col">Email</th>
				<th class="tableTd" scope="col">Mobile</th>
				<th class="tableTd" scope="col">Sub Broker</th>
				<th class="tableTd" scope="col">Institution Name</th>
                <th class="tableTd" scope="col">Investment Date</th>
			    <!--<th class="tableTd" scope="col">Payment Mode</th>-->
				<!--<th class="tableTd" scope="col">Cheque No</th>-->
				<!--<th class="tableTd" scope="col">UTR/FDR No</th>-->
				<th class="tableTd" scope="col">Investment Amount</th>
				<th class="tableTd" scope="col">Tenure</th>
				<th class="tableTd" scope="col">Maturity Date</th>
				<!--<th class="tableTd" scope="col">Address</th>-->
				<!--<th class="tableTd" scope="col">Product name</th>-->
				<!--<th class="tableTd" scope="col">Investment Branch</th>-->
				<th class="tableTd" scope="col">Branch User</th>
				<!--<th class="tableTd" scope="col">Sub Broker Name</th>-->
				<th class="tableTd" scope="col">Investor Remark</th>

            </tr>
        </thead>
        <tbody>
            <?php   $srlno = 1;
            $j=1;
            foreach ($mdatas as $mdata): if(!$mdata->branch_id > 0){ $trstyl = "style='background:#dbefec;'";$tdstyl = "style='color:#000;'"; }else{$trstyl = "style='background:none;'";$tdstyl = "style='color:#000;'";} ?>
            <tr <?= $trstyl ?>>
                <td class="tableTdContent" <?= $tdstyl ?>><?= $srlno ?><?php $srlno++; ?></td>
                <td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->customer_name) ?></td>
                <td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->pan_no) ?></td>
				<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->email) ?></td>
				<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->mobileno) ?></td>
				<td class="tableTdContent">
				<?php
			if($mdata->sub_broker > 0){
				
				$brproductids = explode(",",  $mdata["sub_broker"]);
				foreach($brproductids as $brproductid){
				$brproductdata = $brproducts->find()->where(['id' => $brproductid]);
				$brdata2 = $brproductdata->toArray();
				echo $brproductname = $brdata2[0]->name;
				}
			     }
		        ?>
				</td>
                <td class="tableTdContent" <?= $tdstyl ?>>
                    <?php
                    /*$defaultInstitutionCompany = array(3,17,19);
                    if(in_array(h($mdata->csvid),$defaultInstitutionCompany)){
                        echo $filenames[h($mdata->csvid)];
                    }else {
                        echo h($mdata->institution_name);
                    }*/
                    echo h($mdata->institution_name);
                    ?>
                </td>
                <td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->application_date) ?></td>
				<!--<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->payment_mode) ?></td>-->
				<!--<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->cheque_no) ?></td>-->
				<!--<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->utr_fdr_no) ?></td>-->
				<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->investment_amount) ?></td>
				<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->period) ?></td>
				<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->maturity_date) ?></td>
				<!--<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->address) ?></td>-->
				<!--<td class="tableTdContent" <?= $tdstyl ?>><?= h($mdata->product_name) ?></td>-->
				<!--<td class="tableTdContent"><?//= h($mdata->branch_id) ?></td>-->
			    <td class="tableTdContent">
		<?php
			/*if($mdata->branch_id > 0){
				
				$bproductids = explode(",",  $mdata["branch_id"]);
				foreach($bproductids as $bproductid){
				$bproductdata = $bproducts->find()->where(['id' => $bproductid]);
				$bdata2 = $bproductdata->toArray();
				echo $bproductname = $bdata2[0]->branchname;
				}
			}*/
           // $columname = 'branch_id';
            //$fieldid = $mdata->id.'___'.$columname;
            //echo $this->Form->input('branch_id',['class' => __('add-column cbranch'),'empty'=>'Choose branch','label' => false,'options' => $branches,'id'=>$fieldid,'value'=>$mdata->branch_id]);

        echo !empty($branches[$mdata->branch_id]) ? $branches[$mdata->branch_id] :'';
		?>
	            </td>
				<!--<td class="tableTdContent">
				
				<?php
			if($mdata->modifiedby > 0){
				
				$uproductids = explode(",",  $mdata["modifiedby"]);
				foreach($uproductids as $uproductid){
				$uproductdata = $uproducts->find()->where(['id' => $uproductid]);
				$udata2 = $uproductdata->toArray();
				//echo $uproductname = $udata2[0]->firstname;
				}
			     }
		        ?>
				</td>-->
				
				<!---->
				 <td class="tableTdContent">
				    <?php
                    $remark_options = remarkOptions();
                    echo !empty($remark_options[$mdata->remark]) ? $remark_options[$mdata->remark] :'';
                    ?>
                </td>

               </tr>
            <?php $j++;
            endforeach; ?>
        </tbody>
    </table>

</div>
