<?php 
$header_file=APPPATH.'views/include/header.php';
require($header_file);
$this->db2 = $this->load->database('otherdb', TRUE);
?>
<!-- BEGIN: Content-->
<div class="app-content content">
    <div class="content-overlay"></div>
    <div class="content-wrapper">
        <div class="content-header row">
            <div class="content-header-left col-md-12 col-12 mb-2 breadcrumb-new">
                <h3 class="content-header-title mb-0 d-inline-block">Monthly Costing</h3>
                <div class="row breadcrumbs-top d-inline-block">
                    <div class="breadcrumb-wrapper col-12">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="#">Home</a>
                            </li>
                            <li class="breadcrumb-item">
                                <a href="#">Report</a>
                            </li>
                            <li class="breadcrumb-item active">Costing Report
                            </li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
        <div class="content-body"><!-- Zero configuration table -->
            <section id="configuration">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-content collapse show">
                                <div class="card-body card-dashboard">
                                    <div class="card-content collapse show constrain-movement-container">
											<div class="card-body">								
												<div class="jqueryui-ele-container">
													<div class="tabs-default">
														<ul>
															<li>
																<a href="#finished_prdct" class="tab-col"> Finished Product</a>
															</li>
														</ul>
														
														<div id="finished_prdct">
												<?php
												$mon1 = date('M', strtotime('-6 month', time()));
												$mon2 = date('M', strtotime('-5 month', time()));
												$mon3 = date('M', strtotime('-4 month', time()));
												$mon4 = date('M', strtotime('-3 month', time()));
												$mon5 = date('M', strtotime('-2 month', time()));
												$mon6 = date('M', strtotime('-1 month', time()));
												?>
												<?php foreach($pcat as $pcrow)
												{
											?>
														    <a style="width: 100%;text-align:left;" href="#demo<?php echo $pcrow->pr_cat_id; ?>" class="btn btn-primary category_list" data-toggle="collapse"><?php echo $pcrow->pr_cat_name; ?></a>
														    <div id="demo<?php echo $pcrow->pr_cat_id; ?>" class="collapse">
														        <table border="1" class="uk-table">
												<tr style="text-align:center;">
													<th>Item Name</th>
													<th>Selling Price</th>
													<th><?php echo $mon1; ?></th>
													<th><?php echo $mon2; ?></th>
													<th><?php echo $mon3; ?></th>
													<th><?php echo $mon4; ?></th>
													<th><?php echo $mon5; ?></th>
													<th><?php echo $mon6; ?></th>
												</tr>
												<?php
												    $pc_id = $pcrow->pr_cat_id;
												    $prq = $this->db->query("select * from recipe where pr_cat_id='$pc_id' and branchname='CW_CHF'");
												    $items = $prq->result_array();
												    foreach($items as $irow)
    								{
    								    $rc_id = $irow['recipe_id'];
    								    $rc_yeild = $irow['yeild'];
    								    $sel_price = $irow['total_price'];
    								    $prq1 = $this->db->query("select sum(A.$mon1) as mon1,sum(A.$mon2) as mon2,sum(A.$mon3) as mon3,sum(A.$mon4) as mon4,sum(A.$mon5) as mon5,sum(A.$mon6) as mon6 from item_avg_price A inner join recipe_item B on A.item_id=B.item_id where B.recipe_id=$rc_id");
    								    $mcost = $prq1->row_array();
    								    $costm1 = round(($mcost['mon1']/$rc_yeild),2);
    								    $costm2 = round(($mcost['mon2']/$rc_yeild),2);
    								    $costm3 = round(($mcost['mon3']/$rc_yeild),2);
    								    $costm4 = round(($mcost['mon4']/$rc_yeild),2);
    								    $costm5 = round(($mcost['mon5']/$rc_yeild),2);
    								    $costm6 = round(($mcost['mon6']/$rc_yeild),2);
    								    ?>
												<tr style="text-align:center;">
												    <td><?php echo $irow['rname']; ?></td>
												    <td><?php echo $sel_price; ?></td>
												    <td><?php echo $costm1; ?></td>
												    <td><?php echo $costm2; ?></td>
												    <td><?php echo $costm3; ?></td>
												    <td><?php echo $costm4; ?></td>
												    <td><?php echo $costm5; ?></td>
												    <td><?php echo $costm6; ?></td>
												</tr>
										<?php } ?>
												
											</table>
														 </div>
										<?php } ?>
														</div>
													
													</div>
												</div>
											</div>
										</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
<?php 
    $footer_file=APPPATH.'views/include/footer.php';
    require($footer_file);
?>
<script type="text/javascript">
	$(function() {
		$('.date-picker').datepicker({
			changeMonth: true,
			changeYear: true,
			showButtonPanel: true,
		//	dateFormat: 'MM yy',
		    dateFormat: 'dd-mm-yy',
		/*	onClose: function(dateText, inst) { 
				$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
			}*/
		});
	});	
</script>
<script>
    $("#branch").change(function (){
		var branch_code = $(this).find("option:selected").text();
		$("#bcode").val(branch_code);
	});
	
	$("#pcategory").change(function (){
		var pcat = $(this).find("option:selected").text();
		$("#pcat").val(pcat);
	});
</script>
</body>
<!-- END: Body-->

<!-- Mirrored from pixinvent.com/modern-admin-clean-bootstrap-4-dashboard-html-template/html/ltr/vertical-modern-menu-template/form-layout-basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Apr 2020 09:38:02 GMT -->
</html>