EVOLUTION-NINJA
Edit File: project_form.php
<?php echo view('includes/header');?> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/admin_dashboard/css/ui.jqgrid-bootstrap.css'); ?>" /> <script type="text/ecmascript" src="<?php echo base_url('public/assets/jqgrid/jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('public/assets/jqgrid/jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <section class="content-header"> <h1> Create project </h1> </section> <!--- section 1 --> <section class="content"> <div class="col-sm-12 col-md-11"> <form id="land_owner" class="form-inline project_form" enctype="multipart/form-data"> <div class="row land_owner_a" > <div class="col-sm-12 col-md-6" > <label class="radio-inline" style="margin-left: 15px !important;margin-bottom: 15px !important;"> <input style="width: 21% !important;margin-top: -5px;" type="radio" value="DTCP" name="site_type">DTCP</label> <label class="radio-inline"> <input style="width: 19% !important;margin-top: -5px;" type="radio" value="MUDA" name="site_type">MUDA</label> </div> </div> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Project Name</label> <input type="text" class="form-control col-sm-8" name="project_name" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Land owner / Developer</label> <select class="form-control" name="land_owner"> <!-- <option value="Gss">Gss</option> --> <?php foreach($owners as $value) { ?> <option value="<?php echo $value->owner_id;?>"><?php echo $value->name;?></option> <?php } ?> </select> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <!-- <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Land developer</label> <select class="form-control" name="land_developer"> <!-- <option value="Gss">Gss</option> --> <!--<?php //foreach($developers as $value) { ?> // <option value="<?php //echo $value->developer_id;?>"><?php //echo $value->name;?></option> <?php } ?> </select> </div> --> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Marketing</label> <select class="form-control" name="marketing"> <option value="Gss">Gss</option> </select> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Total sqft</label> <input type="number" min="0" class="col-sm-8" name="total_sqft" required="required"> </div> </div> <!-- row 2--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">9 & 11</label> <input type="file" class="col-sm-8 text-center center-block well well-sm" name="nine_and_eleven_image" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Land images</label> <input type="file" class="col-sm-8 text-center center-block well well-sm" name="land_images[]" multiple required="required"> </div> </div> <!-- row 3--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Approval</label> <input type="file" class="col-sm-8 text-center center-block well well-sm" name="approval_image" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Conversion</label> <input type="file" class="col-sm-8 text-center center-block well well-sm" name="conversion_image" required="required"> </div> </div> <!-- row 3--> <h4 class="site_dim">Site dimensions</h4> <div class="row land_owner_a"> <table class="table dimensions_table"> <tr> <th>Dimension</th> <th></th> <th>Dimension</th> <th></th> <th>Sqft</th> <th></th> <th>No. of sites</th> <th></th> <th>Total sqft</th> <th></th> </tr> <tr> <td><input type="number" min="0" class="col-sm-2 site_dimension1" name="site_dimension1[]" required="required" style="width: 100% !important;"></td> <td><i class="fa fa-times" aria-hidden="true"></i></td> <td><input type="number" min="0" class="col-sm-2 site_dimension2" name="site_dimension2[]" required="required" style="width: 100% !important;"></td> <td><i class="fa fa-exchange" aria-hidden="true"></i></td> <td><input type="number" min="0" class="col-sm-2 sqft" name="sqft[]" required="required" readonly style="width: 100% !important;"></td> <td><i class="fa fa-times" aria-hidden="true"></i></td> <td><input type="number" min="0" class="col-sm-2 no_of_sites" name="no_of_sites[]" required="required" style="width: 100% !important;"></td> <td><i class="fa fa-exchange" aria-hidden="true"></i></td> <td><input type="number" min="0" class="col-sm-2 total_sqft" name="total_sqfts[]" required="required" readonly style="width: 100% !important;"></td> <td></td> </tr> <div id="dimensions"></div> </table> </div> <!-- row 4--> <div class="row land_owner_a"> <button type="button" class="btn btn-sm -btn-primary add_dimension">Add</button> </div><!-- row 5--> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4"> <button type="submit" class="btn btn-primary center-block submit">Create Project</button> </div> <div class="col-sm-4 col-md-4"></div> </div><!-- row 6--> </form> <!-- form End--> <div class="row" style="padding-left:20px; padding-top:25px;"> <div style="margin-left:20px"> <table class="table table-striped table-hover projects_table" style=""> <thead> <tr class="default" > <th class="col-xs-2">Sl No</th> <th class="col-xs-3">Project</th> <th class="col-xs-2">Total sqft</th> <th class="col-xs-2">Owner</th> <!-- <th class="">Developer</th> --> <th class="col-xs-1">Marketing</th> <th class="">Status</th> <th class="col-xs-1">Action</th> </tr> </thead> <tbody id="table_body"> </tbody> </table> </div> </div> </div> <!--- col-sm-8 --> <div class="col-sm-0 col-md-1"></div> </section> <!--- section 2 --> <!-- Modal --> <div class="modal fade" id="edit_modal" role="dialog"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Update land owner details</h4> </div> <div class="modal-body"> <form id="land_owner" class="form-inline update_form" enctype="multipart/form-data"> <input type="hidden" class="form-control col-sm-8 owner_id_pk" name="owner_id" required="required"> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Name or ID</label> <input type="text" class="form-control col-sm-8 name" name="name" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Contact No</label> <input type="number" class="form-control col-sm-8 mobile" name="mobile" required="required"> </div> </div> <!-- row 1--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">PAN / Aadhar No</label> <input type="text" class="form-control col-sm-8 pan_or_adhar" name="pan_or_adhar" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 ">Mail Id</label> <input type="email" class="form-control col-sm-8 email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" required="required"> </div> </div> <!-- row 2--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">ID Proof attach</label> <input type="file" class="col-sm-8 text-center center-block well well-sm id_proof_image" name="id_proof_image"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Address</label> <textarea class="form-control col-sm-8 address" rows="" cols="31" name="address" required="required"></textarea> </div> </div> <!-- row 3--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">ID Proof image</label> <div class="id_proof_image"></div> </div> </div> <!-- row 4--> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4"> <button type="submit" class="btn btn-primary center-block submit">Update</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 5--> </form> </div> </div> </div> </div> <style type="text/css"> .content-wrapper, .right-side { min-height:1200px !important; } a { color: inherit; } .sqft_row input{ width: 100% !important; } </style> <script type="text/javascript"> $(document).ready(function(){ function isNumberKey(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } $('.add_dimension').click(function(e){ $('.dimensions_table').append('<tr class="sqft_row"><td><input type="number" min="0" class="col-sm-2 site_dimension1" name="site_dimension1[]" required="required" ></td><td><i class="fa fa-times" aria-hidden="true"></i></td><td><input type="number" min="0" class="col-sm-2 site_dimension2" name="site_dimension2[]" required="required"></td><td><i class="fa fa-exchange" aria-hidden="true"></i></td><td><input type="number" min="0" class="col-sm-2 sqft" name="sqft[]" required="required" readonly></td><td><i class="fa fa-times" aria-hidden="true"></i></td><td><input type="number" min="0" class="col-sm-2 no_of_sites" name="no_of_sites[]" required="required"></td><td><i class="fa fa-exchange" aria-hidden="true"></i></td><td><input type="number" min="0" class="col-sm-2 total_sqft" name="total_sqfts[]" required="required" readonly></td><td><a href="javascript:void(0);" class="remove_dimension"><span class="glyphicon glyphicon-trash"></span></a></td></tr>'); $(".site_dimension2").keyup(function (e) { calc1($(this)); }); $(".site_dimension1").keyup(function (e) { calc2($(this)); }); $(".no_of_sites").keyup(function (e) { TotalSqft($(this)); }); $(".remove_dimension").click(function(){ $(this).closest('tr').remove(); }); }); $(".site_dimension2").keyup(function (e) { calc1($(this)); }); $(".site_dimension1").keyup(function (e) { calc2($(this)); }); $(".no_of_sites").keyup(function (e) { TotalSqft($(this)); }); function calc1($formElement) { site_dimension2 = parseFloat($formElement.val()); site_dimension1 = parseFloat($formElement.closest('tr').find("input").val()); sqft = site_dimension2 * site_dimension1; $formElement.parent().next().next().find('input.sqft').val(sqft.toFixed(2)); } function calc2($formElement) { site_dimension1 = parseFloat($formElement.val()); site_dimension2 = parseFloat($formElement.parent().next().next().find('input.site_dimension2').val()); sqft = site_dimension2 * site_dimension1; $formElement.parent().next().next().next().next().find('input.sqft').val(sqft.toFixed(2)); } function TotalSqft($formElement) { var sites = parseFloat($formElement.val()); var totalsqft = parseFloat($formElement.closest('tr').find("input.sqft").val()); var grand_total_sqft = sites * totalsqft; $formElement.parent().next().next().find('input.total_sqft').val(grand_total_sqft.toFixed(2)); } var datatable; var tbody = $('#table_body'); datatable = $('.projects_table').DataTable({ "scrollY": 350, "scrollX": true }); ProjectsList(); function ProjectsList() { tbody.empty(); var table_row = []; $.ajax({ type : 'get', url : '<?php echo site_url("projects-list")?>', success:function(response){ //response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { var slno = 1; var index = 1; $.each(response.projects_list,function(idx,vx){ var row = []; row.push(slno); row.push(vx.land_project); row.push(vx.total_sqft); row.push(vx.owner); // row.push(vx.developer); row.push(vx.marketing); row.push(vx.project_status); var table_content = ''; table_content += '<div style="float:left;">'; //table_content += '<a class="edit" project_id="'+vx.project_id+'" href="javascript:void(0);"><span class="glyphicon glyphicon-edit"></span></a> <a class="delete" project_id="'+vx.project_id+'" href="javascript:void(0);"><span class="glyphicon glyphicon-trash"></span></a>'; table_content += '<a class="" href="<?php echo site_url("project-details")?>/'+vx.project_id+'"/><span class="glyphicon glyphicon-search"></span></a> <a class="delete" project_id="'+vx.project_id+'" href="javascript:void(0);"><span class="glyphicon glyphicon-trash"></span></a>'; table_content += '</div>' row.push(table_content); table_row.push(row); slno++; index ++; }); datatable.clear(); datatable.rows.add(table_row).draw(); datatable.draw(); $(".projects_table").on("click", ".delete", function(){ var project_id = $(this).attr('project_id'); var test = $(this); var row = $(this).closest('tr'); swal({ title: "Are you sure?", text: "You will not be able to recover this data!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete it!", cancelButtonText: "No, cancel plz!", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm){ if (isConfirm) { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); test.attr('disabled', 'disabled'); test.text("Deleting..."); $.ajax({ type : 'post', url : '<?php echo site_url("delete-project")?>', data : {project_id:project_id}, success:function(response) { //response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { toastr["success"](response.message); ProjectsList(); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); }); $(".projects_table").on("click", ".edit", function(){ var project_id = $(this).attr('project_id'); $.ajax({ type : 'post', url : '<?php echo site_url("edit-project")?>', data : {owner_id:owner_id}, success:function(response) { //response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { // $(".owner_id_pk").val(response.land_owners_details.owner_id); // $(".name").val(response.land_owners_details.name); // $(".mobile").val(response.land_owners_details.mobile); // $(".pan_or_adhar").val(response.land_owners_details.pan_or_adhar_number); // $(".email").val(response.land_owners_details.email); // $(".address").val(response.land_owners_details.address); // $(".id_proof_image").html('<img src ="<?php echo base_url("land_owners_images");?>/'+response.land_owners_details.id_proof_image+'" style="width:80px;height:70px"/>'); // $("#edit_modal").modal("show"); } } }); }); } } }); } $('.project_form').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $(".submit").text("Submitting..."); $.ajax({ type : 'post', url : '<?php echo site_url("add-project")?>', data : formdata, contentType: false, processData: false, success:function(response){ //response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { ProjectsList(); toastr["success"](response.message); //$('.project_form')[0].reset(); $(".submit").text("Submit"); } else if(response.result==2) { toastr["error"](response.message); $(".submit").text("Submit"); } else if(response.result==3) { toastr["error"](response.message); $(".submit").text("Submit"); } else { toastr["error"](response.message); $(".submit").text("Submit"); } } }); }); $('.update_form').submit(function(e){ e.preventDefault(); formdata = new FormData($(this)[0]); $(".submit").text("Updating..."); $.ajax({ type : 'post', url : '<?php echo site_url("update-land-owner")?>', data : formdata, contentType: false, processData: false, success:function(response){ // response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { $("#edit_modal").modal("hide"); OwnersList(); toastr["success"](response.message); $('.update_form')[0].reset(); $(".submit").text("Submit"); } else if(response.result==2) { toastr["error"](response.message); $(".submit").text("Submit"); } else { toastr["error"](response.message); $(".submit").text("Submit"); } } }); }); }); </script> <?php echo view('includes/footer');?>