0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
ADMIN
/
[
Home
]
File: fund_ctrl.php
<?php require_once "../lib/config.php"; require_once BASE_DIR."/lib/db/connection.php"; //$u_id= @$_SESSION['user_id']; $p_id=@$_SESSION['project_id_a']; $sql="select name from pi"; $sql=mysql_query($sql); $i=0; while($row=mysql_fetch_array($sql)) { $acc_name=$row['name']; $i=$i+1; $acc_name_array[$i]=$acc_name; } $error_flag=0; $error_flag=0; //$completeday= @$_POST['checkcompleteday']; if(isset($_POST['show'])) { //22 $accname_restore=@$_POST['cmbaccname']; $a_name=$acc_name_array[$accname_restore]; $fin_year_1= @$_POST['txtfin1']; $fin_year_2= @$_POST['txtfin2']; /*$fromdate_yy=@$_POST['txtLfromyy']; $from_date=$fromdate_yy."-".$fromdate_mm."-".$fromdate_dd; $todate_mm= @$_POST['cmbLtomm']; $todate_dd=@$_POST['cmbLtodd']; $todate_yy=@$_POST['txtLtoyy']; $to_date=$todate_yy."-".$todate_mm."-".$todate_dd;*/ if (!is_numeric(@$_POST['txtfin1'])) { $error['year_numeric']="Please enter valid year"; $error_flag=1; } if (@$_POST['txtfin1'] == "") { $error['year_numeric']="Please enter valid year"; $error_flag=1; } if($error_flag==1) { /*$url=$server_ip."/USER/ledger.php?message=$message"; echo "<script>window.location='$url'</script>"; */ include "fund.php"; exit(); /*$url="http://".$server_ip."/CPFMS/USER/ledger.php?pcode=".$p_code_value; echo "<script>window.location='$url'</script>"; */ } if($error_flag==0) { //23 $p_id=@$_SESSION['project_id_a']; $sql="select * from pi where name ='$a_name'"; $sql=mysql_query($sql); while($row=mysql_fetch_array($sql)) { $pi_id=$row['pi_id']; $pi_name=$row['name']; } @$_SESSION['sl_no']=0; @$_SESSION['budget_var_s']=0; @$_SESSION['exp_var_s']=0; @$_SESSION['rem_var_s']=0; @$_SESSION['gen_var_s']=0; //Planned fund ?> <style type="text/css"> .style1 {color: #CC0000} .style2 {color: #339900} .style3 {color: #339900; font-weight: bold; } </style> <div align="center"><strong><?php echo "Fund Details of PI : "?> <span class="style1"><?php echo $pi_name;?></span> </strong></div> <br /><div align="center" class="style3"><strong>Planned Funded projects</strong></div> <?php $sql_var="select * from addproject where principle_investigator ='$pi_id' and fundtype=0"; $sql=mysql_query($sql_var); if(mysql_affected_rows()>0) { ledgerreport::printHeader($planned_per,$fin_year_1); $sql="select * from addproject where principle_investigator ='$pi_id' and fundtype=0"; ledgerreport::printDetails($sql,$planned_per,$fin_year_1,$fin_year_from,$fin_year_to); } else { echo "No Data"; } @$_SESSION['sl_no']=0; @$_SESSION['budget_var_s']=0; @$_SESSION['exp_var_s']=0; @$_SESSION['rem_var_s']=0; @$_SESSION['gen_var_s']=0; //External fund ?> <br /><div align="center" class="style3">External Funded projects</div> <?php $sql="select * from addproject where principle_investigator ='$pi_id' and fundtype=1"; $sql=mysql_query($sql); if(mysql_affected_rows()>0) { ledgerreport::printHeader($external_per,$fin_year_1); $sql="select * from addproject where principle_investigator ='$pi_id' and fundtype=1"; ledgerreport::printDetails($sql,$external_per,$fin_year_1,$fin_year_from,$fin_year_to); } else { echo "No Data"; } @$_SESSION['sl_no']=0; @$_SESSION['budget_var_s']=0; @$_SESSION['exp_var_s']=0; @$_SESSION['rem_var_s']=0; @$_SESSION['gen_var_s']=0; //Consultancy fund ?> <br /><div align="center" class="style3"><strong>Consultancy projects</strong></div> <?php $sql="select * from addproject where principle_investigator ='$pi_id' and fundtype=2"; $sql=mysql_query($sql); if(mysql_affected_rows()>0) { ledgerreport::printHeader($consultancy_per,$fin_year_1); $sql="select * from addproject where principle_investigator ='$pi_id' and fundtype=2"; ledgerreport::printDetails($sql,$consultancy_per,$fin_year_1,$fin_year_from,$fin_year_to); } else { echo "No Data"; } ?> <blockquote> <p> </p> <p><a href="#" class="projectboldtxt style2" onclick="window.print()">Print</a> <a href="reports.php">Back</a></p> </blockquote> <?php } //23 }//22 class ledgerreport { //7 public function printHeader($perc,$f_year) { $f_year2=$f_year+1; ?> <table width="1015" height="76" border="1" align="center" id="ledgertable"> <tr> <th width="31" height="42"> S No </th> <th width="74">Project Code </th> <th width="112">Title</th> <th width="88">Investigators</th> <th width="50">Fund Agency</th> <th width="59">Duration</th> <th width="51">Project Outlay</th> <th width="53">Start Date</th> <th width="49">End Date</th> <th width="86"><p>Budget</p> <p>(<?php echo $f_year;echo "-"; echo $f_year2;?>)</p></th> <th width="86"><p>Expenditure</p> <p>(<?php echo $f_year;echo "-"; echo $f_year2;?>)</p></th> <th width="97"><p>Remaining</p> <p>(<?php echo $f_year;echo "-"; echo $f_year2;?>)</p></th> <th width="97"><p>Fund Generated(<?php echo $perc;echo "%";?>)</p> <p>(<?php echo $f_year;echo "-"; echo $f_year2;?>)</p></th> </tr> <?php } public function printDetails($sql1,$perc,$f_year,$fin_year_from,$fin_year_to) {//10 $sql=mysql_query($sql1); if(mysql_affected_rows()>0) {//14 $f_year2=$f_year+1; $fin_date1= $f_year.$fin_year_from; $fin_date2= $f_year2.$fin_year_to; ?> <tr><?php $i=0; while($row=mysql_fetch_array($sql)) {//32 $budget_loop_var=0; $exp_loop_var=0; ?> <td><div align="center"> <?php @$_SESSION['sl_no']=@$_SESSION['sl_no']+1; echo @$_SESSION['sl_no']; ?> </div></td> <td><div align="center"> <?php $project_code=$row['project_code']; echo $project_code; ?> </div></td> <td><div align="center"> <?php echo $row['project_title']; ?> </div></td> <td><div align="center"> <?php echo $row['investigators']; ?> </div></td> <td><div align="center"> <?php echo $row['fundagency']; ?> </div></td> <td><div align="center"> <?php echo $row['duration']; ?> </div></td> <td><div align="center"> <?php echo $row['project_outlay']; ?> </div></td> <td><div align="center"> <?php echo $row['startdate']; ?> </div></td> <td><div align="center"> <?php echo $row['end_date']; ?> </div></td> <td><div align="center"> <?php $p_id=$row['project_id']; // Budget is taken only from custom ac table not from recipt in the pirticular fin year $sql_budget="select credit from custemaccount_cashentry where project_id ='$p_id' and credit>0 and date between '$fin_date1' and '$fin_date2'"; $sql_budget=mysql_query($sql_budget); if(mysql_affected_rows()>0) { while($row_budget=mysql_fetch_array($sql_budget)) { $budget_loop_var=$budget_loop_var+ $row_budget['credit']; } } //echo $row['account_name']; @$_SESSION['budget_var_s'] = @$_SESSION['budget_var_s'] + $budget_loop_var; ?> <div align="center"><div><a href="budget_expand_ctrl.php?<?php echo "pid=$p_id";?>&fyear=<?php echo "$f_year"; ?>" ><?php echo $budget_loop_var; ?></a></div> </div></td> <td><div align="center"> <?php //payment $sql_exp="select amount from payment where project_id ='$p_id' and p_date between '$fin_date1' and '$fin_date2'"; $sql_exp=mysql_query($sql_exp); if(mysql_affected_rows()>0) { while($row_exp=mysql_fetch_array($sql_exp)) { $exp_loop_var=$exp_loop_var+ $row_exp['amount']; } } //custom account $sql_exp="select debit from custemaccount_cashentry where project_id ='$p_id' and debit>0 and date between '$fin_date1' and '$fin_date2'"; $sql_exp=mysql_query($sql_exp); if(mysql_affected_rows()>0) { while($row_exp=mysql_fetch_array($sql_exp)) { $exp_loop_var=$exp_loop_var+ $row_exp['debit']; } } //echo $exp_loop_var; @$_SESSION['exp_var_s'] = @$_SESSION['exp_var_s'] + $exp_loop_var; ?> <div><a href="expense_expand_ctrl.php?<?php echo "pid=$p_id";?>&fyear=<?php echo "$f_year"; ?>" ><?php echo $exp_loop_var; ?></a></div> </div></td> <td><div align="center"> <?php //echo $row['account_name']; $rem_var=$budget_loop_var - $exp_loop_var; if ($rem_var < 0) { $rem_var = 0; } echo $rem_var; @$_SESSION['rem_var_s']=@$_SESSION['rem_var_s']+$rem_var; ?> </div></td> <td><div align="center"> <?php //echo $row['type_id']; $gen_var=$budget_loop_var * ($perc/100); echo $gen_var; @$_SESSION['gen_var_s']=@$_SESSION['gen_var_s']+$gen_var; ?> </div></td> </tr> <?php }//32 while close ?></table> <table width="1023" align="right"> <tr> <th width="33" height="42"> </th> <th width="75"> </th> <th width="114"><div align="center"><strong>Grand total</strong></div></th> <th width="91"></th> <th width="52"> </th> <th width="62"> </th> <th width="53"> </th> <th width="54"> </th> <th width="58"> </th> <th width="89"><div align="center" class="style1"><strong><?php echo @$_SESSION['budget_var_s'];?></strong></div></th> <th width="89"><div align="center" class="style1"><strong><?php echo @$_SESSION['exp_var_s'];?></strong></div></th> <th width="98"><div align="center" class="style1"><strong><?php echo @$_SESSION['rem_var_s'];?></strong></div></th> <th width="99"><div align="center" class="style1"><strong><?php echo @$_SESSION['gen_var_s'];?></strong></div></th> </tr> </table> <?php }//14 if close }//10 function close } //7 ?>