EVOLUTION-NINJA
Edit File: management.php
<?php echo view('includes/header');?> <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> <script src="<?php echo base_url('public/assets/js/jquery-ui.js');?>"></script> <section class="content-header"> <h1> Commission form </h1> </section> <!--- section 1 --> <style type="text/css"> p{ color:#af0100; } </style> <section class="content"> <div class="row"> <div class="col-md-12"> <div> <ul class="nav nav-tabs" id="myTab" role="tablist"> <li id="m36" role="presentation"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Agreement</a></li> <li id="m37" role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Registration</a></li> </ul> <!-- Tab panes --> <div class="tab-content"> <div role="tabpanel" class="tab-pane" id="home"> <table class="table table-striped table-hover brokers_table" style=""> <thead> <tr class="default" > <th class="col-xs-1">Agreement Date</th> <!-- <th class="col-xs-1">Registration Date</th> --> <th class="col-xs-2">Customer Name</th> <th class="col-xs-1">Site Number</th> <th class="col-xs-1">Associate</th> <th class="col-xs-1">Project</th> <th class="col-xs-1">Action</th> </tr> </thead> <tbody id="notification_div"> <?php foreach($agreement as $value){ if($value->ad_s == 'ACTIVE' && $value->b_ds == 'ACTIVE' && $value->cd_s == 'ACTIVE' && $value->dd_s == 'ACTIVE' && $value->ed_s == 'ACTIVE') { //print_r($value->statuss); if($value->statuss == "PENDING" && $value->commission_agreement == "Available" && $value->agreement_date != '0000-00-00' && $value->associate > 0) { ?> <tr> <td><?php echo $value->agreement_date; ?></td> <td><?php echo $value->customer_name; ?></td> <td><?php echo $value->site_number; ?></td> <td><?php echo $value->associate_name; ?></td> <td><?php echo $value->project_name; ?></td> <td><a href="<?php echo site_url("add-commission/$value->booking_id");?>" target="_blank"><button type="button">Add commission</button></a></td> </tr> <?php } ?> <?php } } ?> </tbody> </table> <!-- <div class="col-md-12" id="notification_div"> --> <!-- </div> --> </div> <div role="tabpanel" class="tab-pane" id="profile"> <table class="table table-striped table-hover brokers_table1" style=""> <thead> <tr class="default" > <th class="col-xs-1">Registration Date</th> <!-- <th class="col-xs-1">Registration Date</th> --> <th class="col-xs-2">Customer Name</th> <th class="col-xs-1">Site Number</th> <th class="col-xs-1">Associate</th> <th class="col-xs-1">Project</th> <th class="col-xs-1">Action</th> </tr> </thead> <tbody id="notification_div"> <?php foreach($registration as $value){ if($value->ad_s == 'ACTIVE' && $value->b_ds == 'ACTIVE' && $value->cd_s == 'ACTIVE' && $value->dd_s == 'ACTIVE') { if($value->statuss == "PENDING" && $value->commission_registration == "Available" && $value->registration_date != '0000-00-00' && $value->registration_date != '0' && $value->associate > 0 ) { ?> <tr> <td><?php echo $value->registration_date; ?></td> <td><?php echo $value->customer_name; ?></td> <td><?php echo $value->site_number; ?></td> <td><?php echo $value->associate_name; ?></td> <td><?php echo $value->project_name; ?></td> <td><a href="<?php echo site_url("add-regcommission/$value->booking_id");?>" target="_blank"><button type="button">Add commission</button></a></td></tr> <?php } ?> <?php } } ?> </tbody> </table> <!-- <div class="col-md-12" id="registration_div"> --> <!-- </div> --> </div> </div> </div> </div> </div> <div class="row"> <div class="col-sm-12 col-md-11"> <!-- form End --> </div> <!--- col-sm-8 --> </div> <div class="col-sm-0 col-md-1"></div> </section> <!--- section 2 --> <style type="text/css"> .content-wrapper, .right-side { //min-height: 1100px !important; } </style> <script type="text/javascript"> $(document).ready(function(){ //alert(); var datatable; var tbody = $('#notification_div'); datatable = $('.brokers_table').DataTable({ //"scrollY": 350, //"scrollX": true }); var tbody = $('#registration_div'); datatable = $('.brokers_table1').DataTable({ //"scrollY": 350, //"scrollX": true }); //setInterval(notifications, 2000); //notifications(); //registration(); function registration() { //alert(); $.ajax({ type : 'get', url : '<?php echo site_url("notifications")?>', success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { var i = 1; var content = ''; var table_content = ''; $.each(response.notifications,function(key,val){ if(val.ad_s == 'ACTIVE' && val.b_ds == 'ACTIVE' && val.cd_s == 'ACTIVE' && val.dd_s == 'ACTIVE') { if(val.status == "PENDING") { // if(val.commission_agreement == "Available" && val.commission_registration == "Available") // { //content += '<p>'+' Agreement and Registration has done for site number '+val.site_number+' of project '+val.project_name+' - <a href="</?php echo site_url("add-commission");?>/'+val.booking_id+'" target="_blank"><button type="button">Add commission</button></a></p>'; // } // else if(val.commission_agreement == "Available") // { //content += '<p>'+' Agreement has done for site number '+val.site_number+' of project '+val.project_name+' - <a href="</?php echo site_url("add-commission");?>/'+val.booking_id+'" target="_blank"><button type="button">Add commission</button></a></p>'; // } if(val.commission_registration == "Available" && val.registration_date != '0000-00-00' && val.associate > 0 ) { var agreement_date=changeDateFormat(val.agreement_date); var registration_date=changeDateFormat(val.registration_date); content += '<p>'+' Registration Date : '+registration_date+' Customer Name :'+val.customer_name+' ,Site number :'+val.site_number+',Project :'+val.project_name+' - <a href="<?php echo site_url("add-commission");?>/'+val.booking_id+'" target="_blank"><button type="button">Add commission</button></a></p>'; table_content+= '<tr>'; table_content+= '<td>'+registration_date+'</td>'; table_content+= '<td>'+val.customer_name+'</td>'; table_content+= '<td>'+val.site_number+'</td>'; table_content+= '<td>'+val.project_name+'</td>'; table_content+= '<td>'+'<a href="<?php echo site_url("add-regcommission");?>/'+val.booking_id+'" target="_blank"><button type="button">Add commission</button></a>'+'</td>'; table_content+= '<tr>'; } } } i++; }); // $("#registration_div").html(content); $("#registration_div").html(table_content); } else { $("#registration_div").empty(); } } }); } var datatable; var tbody = $('#table_body'); datatable = $('.management_table').DataTable({ "scrollY": 350, "scrollX": true, "ordering": false, }); toastr.options.timeOut = 3000; $('.date_picker').datepicker({ changeMonth:true, changeYear:true, yearRange: "2000:c", dateFormat: 'yy-mm-dd' }); $(".site_number").keyup(function (e) { var agreement_date = ''; var registration_date = ''; var project_id = $('.project_list :selected').val(); var site_number = $(this).val(); $(".submit").attr('disabled', 'disabled'); $.ajax({ type : 'post', url : '<?php echo site_url("details-for-management")?>', data : {project_id:project_id,site_number:site_number}, success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { $(".submit").removeAttr('disabled'); $("input[name=booking_id]").val(response.booking_details.booking_id); $("input[name=detail_id]").val(response.booking_details.detail_id); $("input[name=tsv]").val(response.booking_details.tsv); $("select option[value='"+response.booking_details.project_id+"']").attr("selected","selected"); $("input[name=site_number]").val(response.booking_details.site_number); $("input[name=site_dimension]").val(response.booking_details.dimension); $("input[name=per_sqft]").val(response.booking_details.tsv_per_sft_rs); $(".project_list option[value='" + response.booking_details.project_id + "']").attr("selected","selected"); $(".reference option[value='" + response.booking_details.reference + "']").attr("selected","selected"); $(".associate option[value='" + response.booking_details.associate + "']").attr("selected","selected"); $.each(response.dates,function(idx,vx){ if(vx.agreement_date != "0000-00-00") { agreement_date = vx.agreement_date; } if(vx.registration_date != "0000-00-00") { registration_date = vx.registration_date; } }); $(".agreement_executed_on").val(agreement_date); $(".registration_on").val(registration_date); $('.date_picker').datepicker({ changeMonth:true, changeYear:true, yearRange: "2000:c", dateFormat: 'yy-mm-dd' }); } else if(response.result==2) { toastr["error"](response.message); //$('.management_form')[0].reset(); $(".submit").removeAttr('disabled'); } else if(response.result == 3) { toastr["error"](response.message); // $('.management_form')[0].reset(); $(".submit").removeAttr('disabled'); } else if(response.result==0) { toastr["error"](response.message); $(".submit").removeAttr('disabled'); //$('.management_form')[0].reset(); } } }); }); // % to Rs. $("input[name=total_commission_perc]").keyup(function (e) { var percentage = $(this).val(); var tsv = $("input[name=tsv]").val(); if(tsv == "") { toastr["error"]("Enter tsv value"); } else { var price = tsv; var calcPrice = (price * percentage / 100 ).toFixed(2); $("input[name=total_commission_rs]").val(calcPrice); } }); // Rs. to % $("input[name=total_commission_rs]").keyup(function (e) { var Rupees = $(this).val(); var tsv = $("input[name=tsv]").val(); if(tsv == "") { toastr["error"]("Enter tsv value"); } else { var price = tsv; calcPerc = (Rupees*100) / (tsv), discountPerc = calcPerc.toFixed(); $("input[name=total_commission_perc]").val(discountPerc); } }); $('.management_form').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $(".submit").attr('disabled', 'disabled'); $(".submit_button").text("Submitting..."); $.ajax({ type : 'post', url : '<?php echo site_url("add-management-details")?>', data : formdata, contentType: false, processData: false, success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { toastr["success"](response.message); $('.management_form')[0].reset(); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); } else if(response.result==2) { toastr["error"](response.message); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); } else if(response.result==3) { toastr["error"](response.message); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); } else { toastr["error"](response.message); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); } } }); }); }); function changeDateFormat(inputDate){ // expects Y-m-d var splitDate = inputDate.split('-'); if(splitDate.count == 0){ return null; } var year = splitDate[0]; var month = splitDate[1]; var day = splitDate[2]; return day + '-' + month + '-' + year; } </script> <?php echo view('includes/footer');?>