Skip to content

Commit

Permalink
reset-inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlosb committed Apr 15, 2024
1 parent 9764b83 commit 322cf17
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
41 changes: 41 additions & 0 deletions application/controllers/Inspection.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,47 @@ public function vehicle_delete($id) {

}

public function resetinspection()
{

if ($this->ion_auth->logged_in() && $this->ion_auth->in_group('inspectors'))
{

$id = $this->input->post('id');
$user = $this->ion_auth->user()->row();
$data = $this->data;
$ulang = $data['user_lang'];
$data['userid'] = $user->id;
$data['username'] = $user->first_name." ".$user->last_name;
$inspections = $this->itindata_model->get_inspectionsfull(array('id_inspection' => $id));
$data['inspection'] = $inspections[0];
$inspection = $inspections[0];
$dir ="/home/site/wwwroot/assets/pdfs/";
$grfile = $dir.$inspection->$filename_inspection;
$enfile = $dir.$inspection->$en_filename_inspection;

if (unlink($grfile) && unlink($enfile)) {
$updinsp['status_inspection'] = 0;
$updinsp['filename_inspection'] = '';
$updinsp['en_filename_inspection'] = '';
$this->itindata_model->upd_inspection($id, $updinsp);
$status['reseted'] = "ok";
}


$this->lang->load('itin',$oldlang);
$this->session->set_userdata('site_lang', $oldlang);
//redirect ('inspection/inspection_view/'.$id, 'refresh');
$this->output->set_header("Cache-Control: no-cache, must-revalidate");
$this->output->set_header("Expires: Mon, 4 Apr 1994 04:44:44 GMT");
$this->output->set_header("Content-type: application/json");
echo json_encode($status) ;

}


}
}

public function vindecoder($vinr) {
if ($this->ion_auth->logged_in() && $this->ion_auth->in_group('inspectors'))
Expand Down
32 changes: 30 additions & 2 deletions application/views/inspectionview.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@
<div class="row mb-2">
<div class="col-sm-6 p-1 text-center text-sm-left">
<?php if ($inspection->filename_inspection != NULL) {?>
<p><a href="<?= base_url()?>assets/pdfs/<?= $inspection->filename_inspection ?>" target="_blank"><i class="fal fa-file-pdf"></i> <?= $this->lang->line('inspection_report'); ?> (<?= $this->lang->line('greeklang'); ?>)</a></p>
<p class="inspfile"><a href="<?= base_url()?>assets/pdfs/<?= $inspection->filename_inspection ?>" target="_blank"><i class="fal fa-file-pdf"></i> <?= $this->lang->line('inspection_report'); ?> (<?= $this->lang->line('greeklang'); ?>)</a></p>
<?php } ?>
<?php if ($inspection->en_filename_inspection != NULL) {?>
<p><a href="<?= base_url()?>assets/pdfs/<?= $inspection->en_filename_inspection ?>" target="_blank"><i class="fal fa-file-pdf"></i> <?= $this->lang->line('inspection_report'); ?> (<?= $this->lang->line('englishlang'); ?>)</a></p>
<p class="inspfile"><a href="<?= base_url()?>assets/pdfs/<?= $inspection->en_filename_inspection ?>" target="_blank"><i class="fal fa-file-pdf"></i> <?= $this->lang->line('inspection_report'); ?> (<?= $this->lang->line('englishlang'); ?>)</a></p>
<?php } ?>
<button type="button" id="resetinsp" class="btn btn-outline-danger btn-sm"><i class="fas fa-minus"></i> <?= $this->lang->line('reset_inspection'); ?></button>
</div>
<div class="col-sm-6 text-center text-sm-right p-1 ">
<?php if ( ($inspection->s1score_inspection >= 92) && ($inspection->s2score_inspection >= 53) && ($inspection->s1score_inspection >= 12))
Expand Down Expand Up @@ -302,6 +303,33 @@
}


});
});
$( "#resetinsp" ).click(function() {
$("#spinner").addClass("d-flex").show();
$.ajax({
type: "POST",
dataType: "JSON",
data: {id:<?= $inspection->id_inspection ?>},
url: "<?= base_url()?>inspection/resetinspection",
success: function(data){
//$.each(data, function(i,item){
if (data.reseted == 'ok'){
// alert(data.created);
// alert(data.en_certfile_inspection);
// alert(data.certfile_inspection);
$( "#resetinsp" ).hide();
$('.inspfile').remove();
$("#spinner").removeClass("d-flex").hide();


} else {

}
//});
}


});
});
});
Expand Down

0 comments on commit 322cf17

Please sign in to comment.