query($sql); while($rowa = $resulta->fetch_assoc()) { $mxdt=$rowa["mxdt"]; // echo "mxdate".$mxdt; } $query = "select bmt.branch_code,region,bmt.branch_id,branch_name,Budget_head_count,Budget_shifts,desig_id,desig from budget_manpower_table bmt,branch_master bm, designation dsg where bmt.branch_id=bm.branch_id and bmt.desig_id=dsg.id and bmt.company_id=".$cmp." and bmt.budget_date='".$mxdt."' order by branch_name"; //echo $query; $result = $connect->query($query); $active_sheet = $file->getActiveSheet(); $file->getActiveSheet()->getColumnDimension('A')->setWidth(10); $file->getActiveSheet()->getColumnDimension('B')->setWidth(40); $active_sheet->setCellValue('A1', 'Date '); $active_sheet->setCellValue('b1', 'Branch Code'); $active_sheet->setCellValue('c1', 'Region '); $active_sheet->setCellValue('d1', 'Site Id'); $active_sheet->setCellValue('e1', 'Site Name'); $active_sheet->setCellValue('f1', 'Budget Head Count'); $active_sheet->setCellValue('g1', 'Budget Shifts'); $active_sheet->setCellValue('h1', 'Desig Id'); $active_sheet->setCellValue('i1', 'Designation'); $stdat=date('d-m-Y'); $count = 2; // foreach($result as $row) while($row = $result->fetch_assoc()) { $active_sheet->setCellValue('A' . $count, $stdat); $active_sheet->setCellValue('B' . $count, $row["branch_code"]); $active_sheet->setCellValue('C' . $count, $row["region"]); $active_sheet->setCellValue('D' . $count, $row["branch_id"]); $active_sheet->setCellValue('e' . $count, $row["branch_name"]); // $active_sheet->setCellValue('f' . $count, $row["Budget_head_count"]); // $active_sheet->setCellValue('g' . $count, $row["Budget_shifts"]); $active_sheet->setCellValue('h' . $count, $row["desig_id"]); $active_sheet->setCellValue('i' . $count, $row["desig"]); $count = $count + 1; } //$sheet->getProtection()->setSheet(true); $file->getActiveSheet()->getProtection()->setSheet(true); $file->getDefaultStyle()->getProtection()->setLocked(false); $active_sheet->getStyle('A1:A5')->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($file, $_POST["file_type"]); $file_name = time() . '.' . strtolower($_POST["file_type"]); $writer->save($file_name); header('Content-Type: application/x-www-form-urlencoded'); header('Content-Transfer-Encoding: Binary'); header("Content-disposition: attachment; filename=\"".$file_name."\""); readfile($file_name); unlink($file_name); exit; } else $_SESSION["favanimal"]=2; $cmp=2; $query = "SELECT concat(group_code,item_code) itemcode,item_desc,uom_code,location FROM itemmaster where op_2018=1 and company_id=$cmp order by group_code,item_code"; //$statement = $connect->prepare($query); //$statement->execute(); //$result = $statement->fetchAll(); $result = $connect->query($query); if(isset($_POST["upload"])) { $dtt= echo "uploading 111"; $file_mimes = array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); echo "uploading 112"; // if(isset($_FILES['file']['name']) && in_array($_FILES['file']['type'], $file_mimes)) { $arr_file = explode('.', $_FILES['file']['name']); $extension = end($arr_file); $file_type="Xlsx"; if('csv' == $extension) { $reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv(); } else { $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); } $spreadsheet1 = $reader->load($_FILES['file']['tmp_name']); $worksheet = $spreadsheet1->getActiveSheet(2); $sheetData = $spreadsheet1->getActiveSheet()->toArray(); echo "uploading"; //} $query = "SELECT concat(group_code,item_code) itemcode,item_desc,uom_code,location FROM itemmaster where group_code='116' order by group_code,item_code"; //op_2018=1 and company_id=$cmp order by group_code,item_code"; //$statement = $connect->prepare($query); //$statement->execute(); //$result = $statement->fetchAll(); $result = $connect->query($query); } ?> jQuery UI Datepicker - Dates in other months '.$dn.' ?>



Upload Budget Data

Export Data From Mysql to Excel using PHPSpreadsheet


From Date :
query($sql); while($rowa = $resulta->fetch_assoc()) { $sid=$rowa["branch_id"]; } } if (strlen($dsgid)==0) { $dsgid=0; $sql="select id from designation where desig='".$dsg."'"; $resulta = $connect->query($sql); while($rowa = $resulta->fetch_assoc()) { $dsgid=$rowa["id"]; } } if ($sid==0) { $mm=0; } if ($dsgid==0) { $mm=0; } if ($mm>0) { echo ' '; $dtt=$_POST["date1"]; $sql="insert into budget_manpower_table ( budget_date,company_id,region,branch_id,desig_id,Budget_head_count,Budget_shifts,branch_code ) values ( "; } if ($mm==0) { echo ' '; } } } ?>
Date Branch Code Region Site Id Site Name Budget Head Count Budget Shifts Desig Id Designation
'.$dt.' '.$bc.' '.$rg.' '.$sid.' '.$snm.' '.$bhc.' '.$bsf.' '.$dsgid.' '.$dsg.'
'.$dt.' '.$bc.' '.$rg.' '.$sid.' '.$snm.' '.$bhc.' '.$bsf.' '.$dsgid.' '.$dsg.'