0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
SO
/
[
Home
]
File: budget_summary.php
<?php $MAIN_HEADING = "Budget Summary"; $SUB_HEADING =""; include( "../lib/config.php"); include_once("../model/defaults_mdl.php"); //require_once "../model/Notification_mdl.php"; require_once BASE_DIR."/lib/db/connection.php"; require_once "../model/uploader_mdl.php"; require_once "../model/defaultValues_mdl.php"; require_once "ed_models.php"; $u_id= @$_SESSION['user_id']; include("include/ed_header.php"); $u_id= @$_SESSION['user_id']; $project_id = $_GET['project_id']; $sql="select project_code,project_id,project_title,startdate from addproject where project_id=$project_id" ; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)) { $arr = array("project_code"=>$row['project_code'],"startdate"=>$row['startdate']); $project_details[$row['project_id']] = $arr; } if(empty($project_details)){ $url=$server_ip."ed/ed_project_list.php"; echo "<script>window.location='$url'</script>"; } $summary = array(); reset($project_details); $first_key = key($project_details); ?> <?php $startdate =""; $end_date = date("m/d/Y"); if(isset($_POST['submit']) && $_POST['submit'] =='search'){ $startdate =$_POST['startdate']; $end_date =$_POST['end_date']; $startdate = date(DATE_FORMAT,strtotime($startdate)); $end_date = date(DATE_FORMAT,strtotime($end_date)); $summary = Ed_Models::getBudgetSummary($project_id,date('Y-m-d', strtotime($_POST['startdate'])),date('Y-m-d', strtotime($_POST['end_date']))); }else{ $summary = Ed_Models::getBudgetSummary($project_id,NULL,date("Y-m-d")); $end_date = date(DATE_FORMAT); $startdate = date(DATE_FORMAT, strtotime($project_details[$first_key ]['startdate'])); } // echo "<pre>"; // print_r($summary); // echo "</pre>"; ?> <?php include("include/alert_message.php"); ?> <form method="post" class="form-horizontal form-label-left " id="form1" data-parsley-validate> <div class="form-group hide"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Project Code </label> <div class="col-md-6 col-sm-6 col-xs-12"> <select class="form-control col-md-7 col-xs-12 select2_single" name="project_id" id="project_id"> <?php if(!empty($project_details)) foreach ($project_details as $j=> $value) { ?> <option value="<?php echo $j; ?>"> <?php echo $value[ 'project_code']; ?> </option> <?php } ?> </select> <ul class="parsley-errors-list filled" id="parsley-id-5"> <li class="parsley-required"> <?php if(isset($error[ 'project_id'])) { echo $error[ 'project_id']; }?> </li> </ul> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="date_current">Start Date </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input readonly id="startdate" type="text" class="form-control col-md-7 col-xs-12 start_date" name="startdate" value="<?php echo $startdate?>" /> </div> <div class="col-md-2 col-sm-2 col-xs-12"> </div> </div> <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="end_date">End Date </label> <div class="col-md-6 col-sm-6 col-xs-12"> <input data-parsley-csdate="" id="date_current" readonly type="text" class="form-control col-md-7 col-xs-12 end_date" name="end_date" value="<?php echo $end_date ?>" /> <ul class="parsley-errors-list filled" id="parsley-id-5"><li class="parsley-required"><?php if(isset($error['end_date'])) { echo $error['end_date']; }?></li></ul> </div> </div> <div class="form-group"> <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-4"> <button class="btn btn-success" name='submit' value="search" ><i class="fa fa-search"></i> Search</button> </div> </div> </form> <br/> <div class="form-group center" id="spin" style="display:none"><i class="fa fa-refresh fa-spin fa-3x"></i></div> <div class="form-group center" id="error" style="display:none;color:red"></div> </div> </div> </div> <div class="col-md-12 col-sm-12 col-xs-12" id="table"> <div class="x_panel"> <div class="x_title" style=" border-bottom:0px !important; "> <div class="clearfix"></div> </div> <table class="table"> <tr><td>Project Code</td><td><?php echo $summary['project_details']['project_code'] ?></td></tr> <tr><td>Project Name</td><td><?php echo $summary['project_details']['project_title'] ?></td></tr> <tr><td>Project Duration</td><td><?php echo $summary['project_details']['duration'] ?></td></tr> <tr><td>Start Date</td><td><?php echo $summary['project_details']['startdate'] ?></td></tr> <tr><td>End Date</td><td><?php echo $summary['project_details']['end_date'] ?></td></tr> <tr><td>Name of PI</td><td><?php echo ucwords($summary['project_details']['name']) ?></td></tr> <tr><td>Other Pi/s</td><td><?php echo ucwords($summary['project_details']['co_pi']) ?></td></tr> </table> <?php $head= ""; $row = ""; $t_sum= 0; if(!empty($summary['project_outlay'])){ foreach ($summary['project_outlay'] as $key => $value) { $t_sum+= $value['amount']; $head.= "<td class='center'>".($key+1)."</td>"; $row.= "<td>".$value['amount'] ."</td>"; } $head.= "<td><b>Total</b></td>"; $row.= "<td><b>".$t_sum."</b></td>"; } ?> <table class="table table-bordered"> <tr><td rowspan="2" style="vertical-align: middle;" >Project Outlay</td><?php echo $head ?></tr> <tr><?php echo $row ?></tr> </table> <?php $head= ""; $row = ""; $t_sum= 0; if(!empty($summary['received_funds'])){ foreach ($summary['received_funds'] as $key => $value) { $t_sum+= ($value['is_show'] ==1) ? $value['amount'] : 0; $head.= "<td>".substr($value['installment_name'], 0,-16)."</td>"; $row.= "<td>".(($value['is_show'] ==1) ? $value['amount'] : '')."</td>"; } $head.= "<td><b>Total</b></td>"; $row.= "<td><b>".$t_sum."</b></td>"; } ?> <table class="table table-bordered"> <tr><td rowspan="2" style="vertical-align: middle;" > Total Fund Received</td><?php echo $head ?></tr> <tr><?php echo $row ?></tr> </table> <div class="x_content"> <table id="datatable-buttons" class="table table-bordered" > <thead> <tr> <th>Budget Head</th> <th>Fund Received</th> <th>Expenditure</th> <th>Balance</th> </tr> </thead> <tbody> <?php $count = sizeof($summary['installment_details']); $insta_sum = $vouc_sum =$bal_sum=0; if(!empty($summary['installment_details'])){ for ($i=0; $i<$count; $i++) { $inst = $summary['installment_details'][$i]; //$vouc = $summary['voucher_details'][$i]; $inst_amt = (!empty($inst['amount']) )? $inst['amount'] : 0; $vouc_amt = isset($summary['voucher_details'][$inst['bhm_id']] ) && !empty($summary['voucher_details'][$inst['bhm_id']]['amount']) ? $summary['voucher_details'][$inst['bhm_id']]['amount'] : 0; $bal_sum+= $bal = $inst_amt-$vouc_amt; $insta_sum+= $inst_amt ; $vouc_sum+= $vouc_amt ; $alert_class = ($bal <0) ? "danger" :"success"; $alert_class_sum = ($bal_sum <0) ? "danger" :"success"; ?> <tr> <td> <?php echo $inst['debit_name'] ?> </td> <td> <?php echo $inst_amt ?> </td> <td> <?php echo $vouc_amt ?> </td> <td class="<?php echo $alert_class ?>"> <?php echo $bal?> </td> </tr> <?php } ?> <tr class="warning bold"> <td> Total </td> <td> <?php echo $insta_sum ?> </td> <td> <?php echo $vouc_sum ?> </td> <td class="<?php echo $alert_class_sum ?>"> <?php echo $bal_sum?> </td> </tr> <?php }else if(!empty($summary['voucher_details'])){ foreach ($summary['voucher_details'] as $vouher_key => $voucher_value) { $inst_amt = 0; $vouc_amt = $voucher_value["amount"]; $bal_sum+= $bal = $inst_amt-$vouc_amt; $insta_sum+= $inst_amt ; $vouc_sum+= $vouc_amt ; $alert_class = ($bal <0) ? "danger" :"success"; $alert_class_sum = ($bal_sum <0) ? "danger" :"success"; ?> <tr> <td> <?php echo $voucher_value['debit_name'] ?> </td> <td> <?php echo $inst_amt ?> </td> <td> <?php echo $vouc_amt ?> </td> <td class="<?php echo $alert_class ?>"> <?php echo $bal?> </td> </tr> <?php } ?> <tr class="warning bold"> <td> Total </td> <td> <?php echo $insta_sum ?> </td> <td> <?php echo $vouc_sum ?> </td> <td class="<?php echo $alert_class_sum ?>"> <?php echo $bal_sum?> </td> </tr> <?php } else{ ?> <tr> <td colspan="5">No Details Found </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> <?php include "include/footer.php"; ?> <script type="text/javascript"> $(".select2_single").select2({ placeholder: "Select a project code", allowClear: true, noResults: "No project code found. Add project first", }).on('change', function(e) { getDebitHeadAjax(this.value); }) </script> <script type="text/javascript"> datePicker($(".start_date"),'<?php echo date("m-d-Y" ,strtotime($startdate)) ?>') datePicker($(".end_date"),'<?php echo date("m-d-Y" ,strtotime($end_date)) ?>') function validateDate(){ var strStartDate = $('input[name="startdate"]').attr("date-org"); var strEndDate = $('input[name="end_date"]').attr("date-org"); if(isNotBlank(strStartDate) && isNotBlank(strEndDate)){ var a = moment(strStartDate); var b = moment(strEndDate); return !b.isBefore(a); } return true; } $(function () { window.Parsley.addValidator('csdate', { validateString: function(value) { return validateDate(); }, messages: { en: 'End date must be greater than start date', } }); $('#form1').parsley().on('field:validated', function() {}) .on('form:submit', function() { return true; }); }); </script>