<link rel="stylesheet" href="css/new_mxerp.css">
<style type="text/css">

h4{margin:15px 0; padding:0;}
.tab_div{line-height: 24px; text-align: left;}
.lh24{line-height: 24px;}
.mb{margin-bottom:10px;}
.full{display: table; width: 100%; margin-bottom:10px;}
.num, .con, .chk{display: table-cell;}
.num{font-weight: 700; padding-right:10px; width:24px;}
.chk{padding-right:40px; width:12px;}
.con{width: 100%;}
.list{list-style: none; margin: 0; padding: 0;}

/*#txt-f input[type="text"]{border:0; border-bottom:#b0b0b0 1px solid; box-shadow: none;}*/
</style>
<?php 
$PageSecurity = 15;
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
include('cocoon_config.php');
$target_rurl="index.php?route=Account/form_gstr_3b&modid=".$modid."&frmid=".$frmid."";

if($_REQUEST['Save'])
{


   $yr=explode("###",$_REQUEST['year']);
  
  $data['year']=$yr[1];
  $data['month']=$_REQUEST['month'];
  $data['created_date']=date('Y-m-d');
  $data['created_by']=$_SESSION['UserID'];
  $data['CompanyId']=$_SESSION['ACGCompanyId'];
  $s->RecordInsert('account_gstr_3b',$data);
  $parent_id=DB_Last_Insert_ID($db,'account_gstr_3b', 'id');


  $data1['parent_id']=$parent_id;
  $data1['os_without_zero_taxable']=$_REQUEST['outward_supplies_without_zero_taxable'];
  $data1['os_without_zero_igst']=$_REQUEST['outward_supplies_without_zero_igst'];
  $data1['os_without_zero_cgst']=$_REQUEST['outward_supplies_without_zero_cgst'];
  $data1['os_without_zero_sgst']=$_REQUEST['outward_supplies_without_zero_sgst'];
  $data1['os_without_zero_cess']=$_REQUEST['outward_supplies_without_zero_cess'];
  $data1['os_with_zero_taxable']=$_REQUEST['outward_supplies_with_zero_taxable'];
  $data1['os_with_zero_igst']=$_REQUEST['outward_supplies_with_zero_igst'];
  $data1['os_with_zero_cgst']=$_REQUEST['outward_supplies_with_zero_cgst'];
  $data1['os_with_zero_sgst']=$_REQUEST['outward_supplies_with_zero_sgst'];
  $data1['os_with_zero_cess']=$_REQUEST['outward_supplies_with_zero_cess'];
  $data1['other_outward_supplies_taxable']=$_REQUEST['other_outward_supplies_taxable'];
  $data1['other_outward_supplies_igst']=$_REQUEST['other_outward_supplies_igst'];
  $data1['other_outward_supplies_cgst']=$_REQUEST['other_outward_supplies_cgst'];
  $data1['other_outward_supplies_sgst']=$_REQUEST['other_outward_supplies_sgst'];
  $data1['other_outward_supplies_cess']=$_REQUEST['other_outward_supplies_cess'];
  $data1['inward_supplies_taxable']=$_REQUEST['inward_supplies_taxable'];
  $data1['inward_supplies_igst']=$_REQUEST['inward_supplies_igst'];
  $data1['inward_supplies_cgst']=$_REQUEST['inward_supplies_cgst'];
  $data1['inward_supplies_sgst']=$_REQUEST['inward_supplies_sgst'];
  $data1['inward_supplies_cess']=$_REQUEST['inward_supplies_cess'];
  $data1['non_gst_total_taxable']=$_REQUEST['non_gst_total_taxable'];
  $data1['non_gst_total_igst']=$_REQUEST['non_gst_total_igst'];
  $data1['non_gst_total_cgst']=$_REQUEST['non_gst_total_cgst'];
  $data1['non_gst_total_sgst']=$_REQUEST['non_gst_total_sgst'];
  $data1['non_gst_total_cess']=$_REQUEST['non_gst_total_cess'];
   $s->RecordInsert('account_gstr_3b_outward_supplies',$data1);


 $data2['parent_id']=$parent_id;
 $data2['unrecognised_sgst']=$_REQUEST['supplies_unrecognised_sgst'];
 $data2['unrecognised_total_taxable']=$_REQUEST['supplies_unrecognised_total_taxable'];
 $data2['unrecognised_igst']=$_REQUEST['supplies_unrecognised_igst'];
 $data2['taxable_sgst']=$_REQUEST['supplies_compostion_taxable_sgst'];
 $data2['total_taxable']=$_REQUEST['supplies_compostion_total_taxable'];
 $data2['total_igst']=$_REQUEST['supplies_compostion_total_igst'];
 $data2['uin_sgst']=$_REQUEST['supplies_compostion_uin_sgst'];
 $data2['uin_total_taxable']=$_REQUEST['supplies_compostion_uin_total_taxable'];
 $data2['uin_igst']=$_REQUEST['supplies_compostion_uin_igst'];
  $s->RecordInsert('account_gstr_3b_unregistered',$data2);


  $data3['parent_id']=$parent_id;
  $data3['goods_igst']=$_REQUEST['itc_import_goods_igst'];
  $data3['goods_cgst']=$_REQUEST['itc_import_goods_cgst'];
  $data3['goods_sgst']=$_REQUEST['itc_import_goods_sgst'];
  $data3['goods_utgst']=$_REQUEST['itc_import_goods_utgst'];
  $data3['goods_cess']=$_REQUEST['itc_import_goods_cess'];
  $data3['services_igst']=$_REQUEST['itc_import_services_igst'];
  $data3['services_cgst']=$_REQUEST['itc_import_services_cgst'];
  $data3['services_sgst']=$_REQUEST['itc_import_services_sgst'];
  $data3['services_utgst']=$_REQUEST['itc_import_services_utgst'];
  $data3['services_cess']=$_REQUEST['itc_import_services_cess'];
  $data3['reverse_charge_igst']=$_REQUEST['itc_reverse_charge_igst'];
  $data3['reverse_charge_cgst']=$_REQUEST['itc_reverse_charge_cgst'];
  $data3['reverse_charge_sgst']=$_REQUEST['itc_reverse_charge_sgst'];
  $data3['reverse_charge_utgst']=$_REQUEST['itc_reverse_charge_utgst'];
  $data3['reverse_charge_cess']=$_REQUEST['itc_reverse_charge_cess'];
  $data3['isd_igst']=$_REQUEST['itc_inward_supplies_isd_igst'];
  $data3['isd_cgst']=$_REQUEST['itc_inward_supplies_isd_cgst'];
  $data3['isd_sgst']=$_REQUEST['itc_inward_supplies_isd_sgst'];
  $data3['isd_ugst']=$_REQUEST['itc_inward_supplies_isd_ugst'];
  $data3['isd_cess']=$_REQUEST['itc_inward_supplies_isd_cess'];
  $data3['other_isd_igst']=$_REQUEST['itc_inward_supplies_other_isd_igst'];
  $data3['other_isd_cgst']=$_REQUEST['itc_inward_supplies_other_isd_cgst'];
  $data3['other_isd_sgst']=$_REQUEST['itc_inward_supplies_other_isd_sgst'];
  $data3['other_isd_ugst']=$_REQUEST['itc_inward_supplies_other_isd_ugst'];
  $data3['other_isd_cess']=$_REQUEST['itc_inward_supplies_other_isd_cess'];
  $data3['itc_reserved_igst']=$_REQUEST['itc_reserved_igst'];
  $data3['itc_reserved_cgst']=$_REQUEST['itc_reserved_cgst'];
  $data3['itc_reserved_sgst']=$_REQUEST['itc_reserved_sgst'];
  $data3['itc_reserved_utgst']=$_REQUEST['itc_reserved_utgst'];
  $data3['itc_reserved_cess']=$_REQUEST['itc_reserved_cess'];
  $data3['reserved_other_igst']=$_REQUEST['itc_reserved_other_igst'];
  $data3['reserved_other_cgst']=$_REQUEST['itc_reserved_other_cgst'];
  $data3['reserved_other_sgst']=$_REQUEST['itc_reserved_other_sgst'];
  $data3['reserved_other_utgst']=$_REQUEST['itc_reserved_other_utgst'];
  $data3['reserved_other_cess']=$_REQUEST['itc_reserved_other_cess'];
  $data3['ineligble_itc_igst']=$_REQUEST['ineligble_itc_igst'];
  $data3['ineligble_itc_cgst']=$_REQUEST['ineligble_itc_cgst'];
  $data3['ineligble_itc_sgst']=$_REQUEST['ineligble_itc_sgst'];
  $data3['ineligble_itc_ugst']=$_REQUEST['ineligble_itc_ugst'];
  $data3['ineligble_itc_cess']=$_REQUEST['ineligble_itc_cess'];
  $data3['ineligble_itc_other_igst']=$_REQUEST['ineligble_itc_other_igst'];
  $data3['ineligble_itc_other_cgst']=$_REQUEST['ineligble_itc_other_cgst'];
  $data3['ineligble_itc_other_sgst']=$_REQUEST['ineligble_itc_other_sgst'];
  $data3['ineligble_itc_other_ugst']=$_REQUEST['ineligble_itc_other_ugst'];
  $data3['ineligble_itc_other_cess']=$_REQUEST['ineligble_itc_other_cess'];
  $s->RecordInsert('account_gstr_3b_itc',$data3);



  $data4['parent_id']=$parent_id;
  $data4['tds_igst']=$_REQUEST['tds_igst'];
  $data4['tds_cgst']=$_REQUEST['tds_cgst'];
  $data4['tds_sgst']=$_REQUEST['tds_sgst'];
  $data4['tcs_igst']=$_REQUEST['tcs_igst'];
  $data4['tcs_cgst']=$_REQUEST['tcs_cgst'];
  $data4['tcs_sgst']=$_REQUEST['tcs_sgst'];
  $s->RecordInsert('account_gstr_3b_tds',$data4);


 $data5['parent_id']=$parent_id;
 $data5['composition_inter_state']=$_REQUEST['non_gst_under_composition_inter_state'];
 $data5['composition_intra_state']=$_REQUEST['non_gst_under_composition_intra_state'];
 $data5['supply_inter_state']=$_REQUEST['supply_inter_state'];
 $data5['supply_intra_state']=$_REQUEST['supply_intra_state'];
 $data5['non_gst_supply_inter_state']=$_REQUEST['non_gst_supply_inter_state'];
 $data5['non_gst_supply_intra_state']=$_REQUEST['non_gst_supply_intra_state'];
 $s->RecordInsert('account_gstr_3b_inward_supplies',$data5);

 
 $data6['parent_id']=$parent_id;
 $data6['igst_total_pay']=$_REQUEST['payment_tax_igst_total_pay'];
 $data6['igst_total_igst']=$_REQUEST['payment_tax_igst_total_igst'];
 $data6['igst_total_cgst']=$_REQUEST['payment_tax_igst_total_cgst'];
 $data6['igst_total_sgst']=$_REQUEST['payment_tax_igst_total_sgst'];
 $data6['igst_total_cess']=$_REQUEST['payment_tax_igst_total_cess'];
 $data6['igst_total_tax_paid']=$_REQUEST['payment_tax_igst_total_tax_paid'];
 $data6['igst_total_tax_paid_cash']=$_REQUEST['payment_tax_igst_total_tax_paid_cash'];
 $data6['igst_total_interest']=$_REQUEST['payment_tax_igst_total_interest'];
 $data6['igst_total_late']=$_REQUEST['payment_tax_igst_total_late'];
 $data6['cgst_total_pay']=$_REQUEST['payment_tax_cgst_total_pay'];
 $data6['cgst_total_igst']=$_REQUEST['payment_tax_cgst_total_igst'];
 $data6['cgst_total_cgst']=$_REQUEST['payment_tax_cgst_total_cgst'];
 $data6['cgst_total_sgst']=$_REQUEST['payment_tax_cgst_total_sgst'];
 $data6['cgst_total_cess']=$_REQUEST['payment_tax_cgst_total_cess'];
 $data6['cgst_total_tax_paid']=$_REQUEST['payment_tax_cgst_total_tax_paid'];
 $data6['cgst_total_tax_paid_cash']=$_REQUEST['payment_tax_cgst_total_tax_paid_cash'];
 $data6['cgst_total_interest']=$_REQUEST['payment_tax_cgst_total_interest'];
 $data6['cgst_total_late']=$_REQUEST['payment_tax_cgst_total_late'];
 $data6['sgst_total_pay']=$_REQUEST['payment_tax_sgst_total_pay'];
 $data6['sgst_total_igst']=$_REQUEST['payment_tax_sgst_total_igst'];
 $data6['sgst_total_cgst']=$_REQUEST['payment_tax_sgst_total_cgst'];
 $data6['sgst_total_sgst']=$_REQUEST['payment_tax_sgst_total_sgst'];
 $data6['sgst_total_cess']=$_REQUEST['payment_tax_sgst_total_cess'];
 $data6['sgst_total_tax_paid']=$_REQUEST['payment_tax_sgst_total_tax_paid'];
 $data6['sgst_total_tax_paid_cash']=$_REQUEST['payment_tax_sgst_total_tax_paid_cash'];
 $data6['sgst_total_interest']=$_REQUEST['payment_tax_sgst_total_interest'];
 $data6['sgst_total_late']=$_REQUEST['payment_tax_sgst_total_late'];
 $data6['cess_total_pay']=$_REQUEST['payment_tax_cess_total_pay'];
 $data6['cess_total_igst']=$_REQUEST['payment_tax_cess_total_igst'];
 $data6['cess_total_cgst']=$_REQUEST['payment_tax_cess_total_cgst'];
 $data6['cess_total_sgst']=$_REQUEST['payment_tax_cess_total_sgst'];
 $data6['cess_total_cess']=$_REQUEST['payment_tax_cess_total_cess'];
 $data6['cess_total_tax_paid']=$_REQUEST['payment_tax_cess_total_tax_paid'];
 $data6['cess_total_tax_paid_cash']=$_REQUEST['payment_tax_cess_total_tax_paid_cash'];
 $data6['cess_total_interest']=$_REQUEST['payment_tax_cess_total_interest'];
 $data6['cess_total_late']=$_REQUEST['payment_tax_cess_total_late'];
 $s->RecordInsert('account_gstr_3b_payment_tax',$data6);



$target_rurl="index.php?route=Account/form_gstr_3b_index&modid=".$modid."&frmid=".$frmid."";
  $s->PageLocation($target_rurl.'&daction=Record Inserted Successfully');






}
  $sql_companies=DB_fetch_array(DB_query("select * from companies where CompanyId='".$_SESSION['ACGCompanyId']."'",$db));

$fin_start_year=explode("-",$_SESSION['financialYrStart']);
$start_year=$fin_start_year[0];
$fin_end_year=explode("-",$_SESSION['financialYrEnd']);
$end_year=$fin_end_year[0];


 ?>

<div class="body_contain">
<div class="tab_div">
<div class="col-lg-1 col-md-1 col-sm-1"></div>
<div class="col-lg-10 col-md-10 col-sm-10">
	<form action=""method="post">
  <div id="txt-f">
  
  <h4 class="text-center"><u>Form GSTR-3B</u></h4>
  <p class="text-center"><i>[See rule 61(5)]</i></p>
  <div class="row">
    <div class="col-sm-4 pull-right">
      <div class="full">
        <div class="col-sm-5 text-right">
            <div class="con pull-right"><strong>Year: </strong><br>
            </div>
          </div>
        <div class="col-sm-5 text-left"><select name="year" id="year" style="width:100%;" onchange="get_month(this.value);" >
                                          <option value="">Select Year</option>
                                          <option value="<?php echo "0"."###".$start_year; ?>"><?php echo $start_year; ?></option>
                                          <option value="<?php echo "1"."###".$end_year; ?>"><?php echo $end_year; ?></option>
                                        </select> 
        </div>
      </div>
      <div class="full">
        <div class="col-sm-5 text-right">
            <div class="con pull-right"><strong>Month: </strong><br>
            </div>
          </div>
        <div class="col-sm-5 text-left"><select name="month" id="month" style="width:100%;" onchange="get_data();">
                                          <option value="0">Select Month</option>  
                                         <?php //foreach($month_array as $key=>$val) { ?>
                                           <!--<option value="<?php //$key; ?>"><?php //echo $val; ?></option>  -->                                       
 
                                         <?php// } ?> 
                                         </select>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-sm-12">
      <div class="full">
        <div class="col-sm-2">
            <div class="num">1.</div>
            <div class="con"><strong>GSTIN:</strong><br>
            </div>
          </div>
        <div class="col-sm-10 text-left"><input type="text" name="gst_no" value="<?php echo $sql_companies['gstno']; ?>" readonly style="width:50%;" /></div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-sm-12">
      <div class="full">
        <div class="col-sm-4">
            <div class="num">2.</div>
            <div class="con"><strong>Legal Name of the Taxable Person:</strong></div>
          </div>
        <div class="col-sm-8 text-left"><input type="text" name="company_name" id="company_name" value="<?php echo $sql_companies['CompanyName'];  ?>" style="width:50%;" placeholder="Auto Populated" readonly /></div>
      </div>
    </div>
  </div>
  <div class="row" id="get_data">
    </div>


<script type="text/javascript">
  function validate()
  {
   var year=$("#year").val();
   var month=$("#month").val();
   var company=$("#company_name").val();

    if(year=='0')
    {
      alert("Please Select Year");
      return false;
    }

     if(month=='')
    {
      alert("Please Select Month");
      return false;
    }

    if(company=='0')
    {
      alert("Please Enter Company Name");
      return false;
    }
  }


  function get_month(str)
  {
    var get_pre=str.split("###");
    $.post("ajax_get_month_gstr.php",{year:get_pre[0]},function(data) {
     $("#month").html(data);

    });
  }

  function get_data()
  {
    
    var month=$("#month").val();
    var year=$("#year").val();
  
    $.post("ajax_get_gstr_3b_data.php",{year:year,month:month},function(data) {
     $("#get_data").html(data);

    });
  }



</script>
