outputreport.blade.php 3.86 KB
<?php
use App\Models\User; 
if(Auth::user()->id=="1" || Auth::user()->id == "199"){ ?>
<div class="container">
	<div style="text-align:center">
		<h2>Output Report</h2>
		<p></p>
	</div>

	<div class="row">
		<div class="column">
			<form class="form-horizontal"  id="output-report" name="output-report">
				<div class="table-responsive" style="background: #fff;">

					<table class="table">	
						<thead>
							<tr>
								<th>No.of Attempts</th>
								<th>{{$noOfAttempts}}
									<input type="hidden" name="noOfAttempts" value="{{$noOfAttempts}}">
								</th>
							</tr>
							<tr>
								<th>No.of Contacts</th>
								<th>{{$noOfContacts}}
									<input type="hidden" name="noOfContacts" value="{{$noOfContacts}}">
								</th>
							</tr>
							<tr>
								<th>Unique Contacts</th>

								<th>{{$uniqueContacts}}
									<input type="hidden" name="uniqueContacts" value="{{$uniqueContacts}}">
								</th>
							</tr>
							<tr>
								<th>Income Achievement</th>
								<th><span id="showCalculatedAmt">{{$totalIncome}}</span></th>
							</tr>
							
							<tr>
								<th>Product</th>
								<th>LG</th>
								<th>Expected Amount(If Applicable)</th>
								<th>LC</th>
								<th>Amount(If Applicable)</th>
							</tr>
						</thead>
						<tbody>
							<?php				
							$i=1;	
							foreach ($products as $key => $value) {
								?>
								<tr>
									<td> <input type="hidden" name="products[<?= $i ?>][productId]" value="{{$value['productId']}}">
										<input type="hidden" name="products[<?= $i ?>][product]" value="{{ $value['name'] }} " >{{ $value['name'] }}</td>
										<td><input type="number" name="products[<?= $i ?>][lg]" min="0" value="{{isset($value['lead_generated'])?$value['lead_generated']:'0'}}" oninput="validity.valid||(value='');" $disabled></td>
										<td><input type="number" min="0" step="0.01" name="products[<?= $i ?>][lgAmt]"  value="{{isset($value['lead_generated_amount'])?$value['lead_generated_amount']:'0'}}" oninput="validity.valid||(value='');" $disabled></td>
										<td><input type="number" min="0" name="products[<?= $i ?>][lc]" value="{{isset($value['lead_closed'])?$value['lead_closed']:'0'}}"  class="calculateIncome" id="products<?= $i ?>Lc" oninput="validity.valid||(value='');" $disabled></td>
										<td><input type="number" min="0" step="0.01" name="products[<?= $i ?>][lcAmt]" value="{{isset($value['lead_closed_amount'])?$value['lead_closed_amount']:'0'}}"  oninput="validity.valid||(value='');" class="calculateIncome" id="products<?= $i ?>LcAmt"  $disabled></td>
									</tr>
									<?php
									$i++;
								} ?>

								@if($disabled == "")
								<tr>
									<td><button type="submit" class="btn btn-primary" onclick='createOutputReport();return false;'>Save</button></td>
								</tr>
								@endif

								</tbody>
							</table>
						</div>
					</form>
<script>

function createOutputReport()
{
	
	var putdata = $('#output-report').serialize();
	//console.log("--->"+putdata);
	doAjax('outputreport?action=createOutputReport',putdata,'__fake__div__','ajax_create_output_report','singlethis','POST',function(retstr)
	{
		if(retstr.responseText.indexOf('Error')<0)
		{
			simpleNotification("success","topRight","User Created Successfully");
			menuAction('outputreport/reportdata');
		}
		else
		{
			simpleNotification("error","topRight",retstr.responseText);
		}
	});
}


$( document ).ready(function() {
    $( ".calculateIncome" ).change(function() {

    	var numItems = $('.calculateIncome').length;
    	var lc = 0;
    	var lcAmt = 0;
    	var totalIncome = 0;
    	for (var i = 1; i <= (numItems/2); i++) {
    		lc = $('#products'+i+'Lc').val();
    		lcAmt = $('#products'+i+'LcAmt').val();

    		if(lc != '' && lcAmt != ''){
    			totalIncome = totalIncome + (lc * lcAmt);	
    		}
    	}
    	$('#showCalculatedAmt').html(totalIncome);

	});
});


</script>


</div>
</div>
</div>
<?php } ?>