edit fileupload

This commit is contained in:
venbatechnologies 2018-06-04 17:53:59 +05:30
parent 702a9a71e2
commit 80560ca704
6 changed files with 516 additions and 96 deletions

View File

@ -229,7 +229,7 @@ function add($pathname)
$picture = '';
if(!empty($_FILES[$pathname]['name']))
{
$config['upload_path'] = 'uploads/BillFiles/';
$config['allowed_types'] = '*';
//$config['allowed_types'] = 'jpg|jpeg|png|gif';
@ -483,6 +483,8 @@ function add($pathname)
$count = $this->input->post('hidecounters');
$constant = $this->input->post('hideconstants');
for($i=1;$i<=$constant;$i++){
$pathname = 'browseFiles'.$i;
if(!empty($_FILES[$pathname]['name']))
@ -797,6 +799,19 @@ $RequestedBy = $this->input->post('drpDepartment');
$igrM = $this->inwardgateregister_model->addigrM($igr);
@ -811,6 +826,12 @@ $RequestedBy = $this->input->post('drpDepartment');
// echo $IGRNO;
if($Qualitycheck==0)
{
@ -964,32 +985,33 @@ $RequestedBy = $this->input->post('drpDepartment');
}
// $file =$this->addfile();
//$myfile = array('FilePath'=>$filename);
// $emergencyitemcode = $this->input->post('emergencyitemcode'.$i);
// ($this->input->post('materialCode'.$i));
// $myfile = array('FilePath'=>$file,'MaterialCode'=>$emergencyitemcode,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// // print_r($myfile);
// $result= $this->purchaseorder_model->fileupload($myfile);
}
// $file =$this->addfile();
// $emergencyitemcode = $this->input->post('materialCode'.$i);
// $myfile = array('FilePath'=>$file,'MaterialCode'=>$emergencyitemcode,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// $result= $this->purchaseorder_model->fileupload($myfile);
$counts = $this->input->post('hidecounter');
$counts = $this->input->post('hidecounter');
$constants = $this->input->post('hideconstant');
// if(empty($filename))
// {
// // echo $IGRNO;
// // echo $PONO;
// $myfile = array('FilePath'=>$filename,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// // print_r($myfile);
// $this->purchaseorder_model->fileupload($myfile);
// }
// else{
for($i=1;$i<=$constants;$i++){
$pathname = 'browseFiles'.$i;
if(!empty($_FILES[$pathname]['name']))
{
@ -998,12 +1020,15 @@ $RequestedBy = $this->input->post('drpDepartment');
//echo $Picture;
$arr[] = array($Picture);
}
}
}
//print_r($arr);
foreach($arr as $ma){
$index = 0;
$filename = null;
foreach($ma as $key=>$value){
$index++;
if($index == 1){
@ -1011,21 +1036,40 @@ $RequestedBy = $this->input->post('drpDepartment');
}
}
$myfile = array('FilePath'=>$filename);
$emergencyitemcode = $this->input->post('materialCode'.$i);
$myfile = array('FilePath'=>$filename,'MaterialCode'=>$emergencyitemcode,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
//$myfile = array('FilePath'=>$filename);
//$emergencyitemcode = $this->input->post('materialCode'.$i);
$myfile = array('FilePath'=>$filename,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// print_r($myfile);
$this->purchaseorder_model->fileupload($myfile);
//addfiledetails($addfilelist);
//print_r($myfile);
}
}
}
// $file =$this->addfile();
// $emergencyitemcode = $this->input->post('materialCode'.$i);
// $myfile = array('FilePath'=>$file,'MaterialCode'=>$emergencyitemcode,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// $result= $this->purchaseorder_model->fileupload($myfile);
// if($ItemStatus = SPECIAL_PO){
}
//if($result > 0)
// }
//if($result > 0)
// {

View File

@ -516,7 +516,7 @@ function edited(){
}
$data['getdata'] = $this->purchaseorder_model->getfunction($PONO);
$data['getdata'] = $this->purchaseorder_model->getfunctionr($PONO);
$data['MaxPODate'] = $this->purchaseorder_model->getLastReleasedPODate();
$data['TaxType'] = $this->purchaseorder_model->getConfigValue('C006');
@ -1488,13 +1488,119 @@ function edited(){
}
}
$counts = $this->input->post('hidecounter');
$constants = $this->input->post('hideconstant');
//$oldfile = $this->input->post('param2');
$newfile = $this->input->post('param1');
// if(empty($newfile))
// {
// // echo $IGRNO;
// // echo $PONO;
// $myfile = array('FilePath'=>$oldfile,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// // print_r($myfile);
// $this->purchaseorder_model->fileupload($myfile);
// }
// else{
for($i=1;$i<=$constants;$i++){
$pathname = 'browseFiles'.$i;
if(!empty($_FILES[$pathname]['name']))
{
$Picture = $this->addfile($pathname);
//echo $Picture;
$arr[] = array($Picture);
}
}
//print_r($arr);
foreach($arr as $ma){
$index = 0;
$newfile = null;
foreach($ma as $key=>$value){
$index++;
if($index == 1){
$newfile = $value;
}
}
//$myfile = array('FilePath'=>$filename);
//$emergencyitemcode = $this->input->post('materialCode'.$i);
$myfile = array('FilePath'=>$newfile,'PONO'=>$PONO,'IGRNO'=>$IGRNO);
// print_r($myfile);
$this->purchaseorder_model->fileupload($myfile);
//addfiledetails($addfilelist);
//print_r($myfile);
}
// }
}
echo 'Purchase Order Updated Successfully! PO Number Is: '.$PONO ;
}
function addfile($pathname)
{
// echo "add files";
// die();
//echo $pathname; die();
$picture = '';
if(!empty($_FILES[$pathname]['name']))
{
$config['upload_path'] = 'uploads/BillFiles/';
$config['allowed_types'] = '*';
//$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['file_name'] = $_FILES[$pathname]['name'];
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload($pathname))
{
$uploadData = $this->upload->data();
$picture = $uploadData['file_name'];
}
else
{
$error = array('error' => $this->upload->display_errors());
$picture = '';
}
}
else
{
$picture = '';
}
return $picture ;
}
function pageNotFound()
{
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
@ -4165,56 +4271,59 @@ public function enquiry()
}
/*--------------------------------------------------------------------------------------*/
// function uploadfile()
// {
// $bill= $this->input->post('param1');
// $oldfile= $this->input->post('param2');
function addloadfile()
{
// if(!empty($_FILES['file']['name']))
// {
// $Picture = $this->add();
// }
$pono= $this->input->post('PONO');
$new_file_name =$_FILES['param1']['name'];
//echo $new_file_name;
if(!empty($new_file_name))
{
$Picture = $this->adfile();
}
else
{
$Picture ='';
}
//echo $Picture;die;
$filelist =array('PONO'=>$pono,'FilePath'=>$Picture);
// $uploadfile = $this->purchaseorder_model->updatefile($bill,$Picture,$oldfile);
$uploadfile = $this->purchaseorder_model->insertfile($filelist);
// if($uploadfile > 0){
// echo "file updated successfully!";
// }
// else{
// echo "file not updated!";
// }
// }
if($uploadfile > 0){
echo "file updated successfully!";
}
else{
echo "file not updated!";
}
}
// function add()
// {
// $picture = '';
// if(!empty($_FILES['file']['name']))
// {
// $config['upload_path'] = 'uploads/BillFiles/';
// $config['allowed_types'] = 'docx|pdf|doc|png|jpg';
// $config['file_name'] = $_FILES['file']['name'];
// //print_r($config) ;
// //Load upload library and initialize configuration
// $this->load->library('upload',$config);
// $this->upload->initialize($config);
// if($this->upload->do_upload('file'))
// {
// $uploadData = $this->upload->data();
// $picture = $uploadData['file_name'];
// }
// else
// {
// $error = array('error' => $this->upload->display_errors());
// $picture = '';
// }
// }
// else
// {
// $picture = '';
// }
function adfile()
{
$picture = '';
if(!empty($_FILES['param1']['name']))
{
$config['upload_path'] = 'uploads/BillFiles/';
$config['allowed_types'] = 'docx|pdf|doc|png|jpg';
$config['file_name'] = $_FILES['param1']['name'];
// print_r($config) ;
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
$uploadData = $this->upload->data();
$picture = $uploadData['file_name'];
}
else
{
$picture = '';
}
// return $picture ;
// }
return $picture ;
}
function uploadfile()
{
@ -4228,6 +4337,13 @@ function uploadfile()
$CourierNo= $this->input->post('param6');
$MaterialRcvdDate =$this->input->post('param7');
// $oldfile = $this->input->post('param2');
// $newfile = $this->input->post('param8');
$newfile =$this->input->post('param8');
$invdate = date('Y-m-d',strtotime($invdate));
$MaterialRcvdDate =date('Y-m-d',strtotime($MaterialRcvdDate));
@ -4250,7 +4366,8 @@ function uploadfile()
if(!empty($_FILES['file']['name']))
if(!empty($_FILES['param8']['name']))
{
@ -4268,6 +4385,8 @@ function uploadfile()
// uploadfile();
$igrM = $this->purchaseorder_model->updateigrM($PONO,$IGRNo,$igrMaster);
// $file =$this->purchaseorder_model->fileup($PONO,$IGRNo,$newfile)
// if($uploadfile > 0){
echo "updated successfully!";
@ -4280,16 +4399,16 @@ function uploadfile()
function add()
{
$picture = '';
if(!empty($_FILES['file']['name']))
if(!empty($_FILES['param8']['name']))
{
$config['upload_path'] = 'uploads/BillFiles/';
$config['allowed_types'] = 'docx|pdf|doc|png|jpg';
$config['file_name'] = $_FILES['file']['name'];
//print_r($config) ;
$config['file_name'] = $_FILES['param8']['name'];
// print_r($config) ;
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload('file'))
if($this->upload->do_upload('param8'))
{
$uploadData = $this->upload->data();
$picture = $uploadData['file_name'];

View File

@ -142,6 +142,9 @@ Where IGRM.PONO = ? ';
function fileupload($myfile)
{
//print_r($myfile);die;
$this->db->insert('T_PurchaseOrder_BillUpload',$myfile);
$myfile=$this->db->affected_rows();
return $myfile;
@ -161,6 +164,54 @@ Where IGRM.PONO = ? ';
$this->db->where('bill.PONO',$pono);
//$this->db->or_where('pom.status',SPECIAL_PO);
$this->db->group_by('bill.BillNo');
// $this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo,
// mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate,
// mstr.CourierNo,bill.BillNo,bill.FilePath,pom.Status,pom.POType');
// $this->db->from('T_IGR_Master mstr');
// $this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left');
// $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left');
// // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode');
// $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO');
// $this->db->where('mstr.PONO',$pono);
$query = $this->db->get();
return $query->result();
}
function getfunctionr($pono)
{
$this->db->distinct();
// $this->db->select('bill.PONO,mstr.IGRNO,bill.BillNo,mstr.MaterialRcvdDate,bill.FilePath,mstr.DeliveryChellanOrInvoiceNo,mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.CourierNo,dtl.QuantityAsPerInvoice,pom.POType');
// $this->db->from('T_PurchaseOrder_BillUpload bill');
// $this->db->join('T_IGR_Master mstr','bill.PONO = mstr.PONO','left');
// $this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left');
// // $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode');
// $this->db->join('T_PurchaseOrder_Master pom','pom.PONO = bill.PONO');
// $this->db->where('bill.PONO',$pono);
// //$this->db->or_where('pom.status',SPECIAL_PO);
// $this->db->group_by('bill.BillNo');
$this->db->select('mstr.PONO,mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo,
mstr.DeliveryChellanDate,mstr.VehicleNo,mstr.MaterialRcvdDate,
mstr.CourierNo,bill.BillNo,bill.FilePath,pom.Status,pom.POType');
$this->db->from('T_IGR_Master mstr');
$this->db->join('T_PurchaseOrder_BillUpload bill','bill.PONO = mstr.PONO','left');
$this->db->join('T_IGR_Details dtl','mstr.IGRNO = dtl.IGRNO','left');
// $this->db->join('T_MaterialMaster mm','mm.MaterialCode = bill.MaterialCode');
$this->db->join('T_PurchaseOrder_Master pom','pom.PONO = mstr.PONO');
$this->db->where('mstr.PONO',$pono);
$query = $this->db->get();
@ -2223,9 +2274,9 @@ function DeleteCounter($DelId)
function updatefile($bill,$Picture,$oldfile)
{
if($oldfile != ''){
unlink("uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too
}
// if($oldfile != ''){
// //unlink("uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too
// }
$this->db->set('FilePath', $Picture); //value that used to update column
$this->db->where('BillNo', $bill); //which row want to upgrade
@ -2336,6 +2387,15 @@ $logpodtl = $this->db->query($SQL);
// }
function insertfile($filelist)
{
//print_r($myfile);die;
$this->db->insert('T_PurchaseOrder_BillUpload',$filelist);
$myfile=$this->db->affected_rows();
return $myfile;
}
/*------------------------------------------------------------------------------*/

View File

@ -102,18 +102,19 @@
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script>
<!-- <script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script> -->
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script>
$(function () {
$.fn.dataTable.moment( 'DD-MM-YYYY' );
$('#dataTableHistoriek').DataTable({
"paging" : true,
"ordering" : true,
"scrollCollapse" : true,
"searching" : true,
"columnDefs" : [{"targets":3, "type":"date-eu"}],
// "columnDefs" : [{"targets":3, "type":"date-eu"}],
"bInfo": true
});
});

View File

@ -1769,7 +1769,7 @@ function SpecialPOcheck()
{
$('#txtSpecial').val(1);
$('#txtQuality').val(1);
//addtable();
// addtable();
RevenueSave(3);
}
@ -8525,7 +8525,7 @@ var specialrow=0;
var VehicleNo1 = $('#VehicleNo').val();
var CourierNo1 = $('#CourierNo').val();
var Quantity123 = $('#AQuantity').val();
var images = $('#images').val();
var images = $('#imag').val();
//var actqty=$('#quantity'+temp);
@ -8583,7 +8583,7 @@ var specialrow=0;
}
else if (images == ''){
alert("Please Upload File to be saved");
$('#images').focus();
$('#imag').focus();
return false;
@ -8598,7 +8598,7 @@ var specialrow=0;
var theForm=$(".CreatealterPO");
addHidden(theForm,"emergencyitemcode"+temp,emergencyitemcode );
addHidden(theForm,"images"+temp,images );
addHidden(theForm,"imag"+temp,images );
// var a=$('#emergencyitemcode'+temp).val();
// var b=$('#images'+temp).val();
@ -8838,10 +8838,15 @@ var file = $('#imag'+counterConstant).val();
if (file=='')
{
alert('File not found');
SpecialPOcheck();
SpecialPOcheck();
// addtable();
}
else{
SpecialPOcheck();
SpecialPOcheck();
// addtable();
}
}

View File

@ -4173,8 +4173,31 @@ function calculateEditTaxValue()
<div class="col-md-12" id="splpodiv">
<div class="col-md-12"><label>Special po Table List</label>
<table id="table2" class="table table-hover table-bordered" style="background-color:#fff;font-size:12px;" >
<table id="table2" class="table table-hover table-bordered" style="background-color:#fff;font-size:12px;" > <div class="col-md-12">
<div class="col-md-offset-10 col-md-8" >
<input type="button" class="btn btn-primary" id ="addmorebutton" value=" ADD FILES..">
</div>
<div id="newdiv"></div>
<input type="hidden" name="hidecounter" id="hidecounter" value="0" />
<input type="hidden" name="hideconstant" id="hideconstant" value="0" />
</div>
<thead style="background-color:#ddf">
<tr>
<th>Bill No </th>
@ -4411,7 +4434,27 @@ function calculateEditTaxValue()
<label for="oldimagename">Old file Name :</label><?php echo $getdata[0]->FilePath; ?> <br/><?php } ?> -->
<input type = "file" size = "20" input accept=".docx,.pdf,.doc.JPG,.PNG,.jpg" id="imag" name="images" onChange="filecheck();"/>
<label for="images">Select file <br/><small>(only .pdf,.excel,.doc,.png,.jpg)</small></label>
</div>
</div>
<!-- <div class="col-md-7">
<div class="col-md-offset-1 col-md-1" >
<input type="button" class="btn btn-primary" id ="addmorebutton" value=" + ADD FILES..">
</div>
<div id="newdiv"></div>
<input type="hidden" name="hidecounter" id="hidecounter" value="0" />
<input type="hidden" name="hideconstant" id="hideconstant" value="0" />
</div> -->
</div>
<input type="hidden" name="hideoldfile" id="hideoldfile" value="<?php echo $getdata[0]->FilePath; ?>" class="form-control" readonly>
<input type="hidden" name="hidebillno" id="hidebillno" value="<?php echo $getdata[0]->BillNo ?>" class="form-control" readonly>
@ -4419,7 +4462,13 @@ function calculateEditTaxValue()
<div class="modal-footer">
<div class="col-md-12 text-right">
<div class="col-md-4 col-md-offset-8">
<a class="btn btn-primary" onclick="splpoupdate()" >&nbsp;&nbsp;<span class="bold">Update</span>
<!-- <input id="tag-form-submit" type="submit" class="btn btn-primary bold" value="Update"> --></a>
@ -5801,12 +5850,16 @@ $("#Date").datepicker();
function splpoupdate(){
var formData = new FormData();
var file = $("#imag").prop('files')[0];
// var file = $("#images").prop('files')[0];
// console.log(file);
var param1 = $('#hidebillno').val();
var param2 = $('#hideoldfile').val();
var filename = $("#imag").val();
filename = filename.split('\\');
// var filename = $("#imag").val();
// filename = filename.split('\\');
var param8 =$('#imag').prop('files')[0];
// console.log(param8);
var param3 =$('#ChallanInvNo').val();
var param4 =$('#PODate1').val();
//alert(param4);
@ -5818,7 +5871,7 @@ function splpoupdate(){
formData.append('file',file);
//formData.append('file',file);
formData.append('param1',param1);
formData.append('param2',param2);
@ -5827,6 +5880,7 @@ function splpoupdate(){
formData.append('param5',param5);
formData.append('param6',param6);
formData.append('param7',param7);
formData.append('param8',param8);
@ -5851,6 +5905,41 @@ function splpoupdate(){
}
function fileupload()
{
var formData = new FormData();
var file = $("#images").prop('files')[0];
//console.log(file);
var param1 =$('#images').prop('files')[0];
var PONO =$('#txtPONO').val();
formData.append('param1',param1);
formData.append('PONO',PONO);
$('.content').loader('show');
$.ajax({
data:formData,
type:"POST",
url:"<?php echo base_url() ?>purchaseorder/addloadfile",
cache : false,
contentType : false,
processData : false,
success:function(data) {
if(data){
alert(data);
$('.content').loader('hide');
// $('#spl').find('td').eq(5).text(filename[2]);
$('#EditRevenueSplPOModel').modal('hide');
}
}
});
}
function filecheck()
{
@ -5871,4 +5960,106 @@ var sizef = document.getElementById('imag').files[0].size;
</script>
<script>
var counter = 0;
var counterConstant = 0;
$("#addmorebutton").click(function(){
//alert('sda');
// if(counter>4){
// alert("No more files to add");//this allows only 5 files;
// return false;
// }
// else{
// counter++;
// counterConstant++;
var div = document.createElement('div');
div.id = "divid";
div.className="row";
div.innerHTML='<div class="col-md-12">'+
// '<div class="col-md-3">'+
// '<label>File Name</label>'+
// '<input type="text" id="maint_filename'+counterConstant+'" name="filename'+counterConstant+'" class="form-control" onkeypress="return false;" readonly/>'+
// '</div>'+
'<div class="col-md-3">'+
'<label><br></label>'+
'<input type="file" name="browseFiles" id="images" onchange="Copyfilename(this.name); "><br>'+
'</div>'+
// '<div class="col-md-3">'
// '<label><br><br></label>'+
// '<button class="btn btn-danger remove remove_this" id="removebtn'+counterConstant+'" onclick="removeRow(this.id)"><i class="fa fa-trash"></i> Remove</button></div>'+
'<div class="col-md-2">'+
'<label><br><br></label>'+
'<button class="btn btn-primary add add_this" id="addbtn" onclick="addRow()">ADD</button></div>'+
'</div>'+
'</div>';
$('#newdiv').append(div);
// $('#hidecounter').val(counter);
// $('#hideconstant').val(counterConstant);
//}
});
function addRow()
{
//var file = $('#imag').val();
var file = $('#images').val();
if (file=='')
{
alert('File not found');
fileupload();
}
else{
fileupload();
}
}
function Copyfilename(id)
{
var size = $('input[name='+id+']')[0].files[0].size;
var number = id.replace(/[^0-9]+/ig,"");
if(size > 2100000){
//alert(id);
alert('Sorry Your File is Large To 2MB');
removeRow(id);
//$('input[name = browseFiles'+number+']').val(' ');
}else {
var name = $('input[name='+id+']')[0].files[0].name;
//alert(name);
$("#maint_filename"+number).val(name);
}
}
function removeRow(input) {
var number = input.replace(/[^0-9]+/ig,"");
if(counter >= 1){
counter--;
$("#divid"+number).remove();
$('#hidecounter').val(counter);
}
}
</script>