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,ifnull(revenue,0) revenue, ifnull(shift_1,0) shift_1,ifnull(shift_2,0) shift_2 ,ifnull(shift_3,0) shift_3 from budget_manpower_table bmt,branch_master bm, designation dsg where is_active=1 and 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; $query = "select g.* from ( select bmt.company_id,budget_date,bmt.branch_code,region,bmt.branch_id,branch_name,Budget_head_count,Budget_shifts,desig_id,desig,ifnull(revenue,0) revenue, ifnull(shift_1,0) shift_1,ifnull(shift_2,0) shift_2 ,ifnull(shift_3,0) shift_3 from budget_manpower_table bmt,branch_master bm, designation dsg where is_active=1 and bmt.branch_id=bm.branch_id and bmt.desig_id=dsg.id and bmt.company_id=".$cmp." and is_active=1 ) g , ( select company_id compid, branch_id brid,max(budget_date) mxdate from budget_manpower_table bm where bm.company_id=".$cmp." and is_active=1 group by branch_id ) h where h.brid=g.branch_id and h.mxdate=g.budget_date and h.compid=g.company_id order by branch_name"; $result = $connect->query($query); $active_sheet = $file->getActiveSheet(); // $file->getActiveSheet()->getColumnDimension('A')->setWidth(10); // $file->getActiveSheet()->getColumnDimension('B')->setWidth(40); $active_sheet->setCellValue('A1', 'Last Upload 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'); $active_sheet->setCellValue('j1', 'Revenue'); $active_sheet->setCellValue('k1', 'Shift A'); $active_sheet->setCellValue('l1', 'Shift B'); $active_sheet->setCellValue('m1', 'Shift C'); $active_sheet->setCellValue('o1', 'Please fill Data and Upload'); $active_sheet->setCellValue('o2', 'If need to add any New Data Please add at the end '); // $file->getActiveSheet()->getStyle('J1') //->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_YELLOW); // $file->getSheet(0)->getStyle('j1')->getFill()->getStartColor()->getRGB(); $file->getActiveSheet()->getStyle('o1:o2')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('DFFF00'); $file->getActiveSheet()->getStyle('a1:m1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('9FE2BF'); $file->getActiveSheet()->setTitle('BUDGET'); $stdat=date('d-m-Y'); $count = 2; // foreach($result as $row) while($row = $result->fetch_assoc()) { $active_sheet->setCellValue('A' . $count, $row["budget_date"]); $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"]); $active_sheet->setCellValue('j' . $count, $row["revenue"]); $active_sheet->setCellValue('k' . $count, $row["shift_1"]); $active_sheet->setCellValue('l' . $count, $row["shift_2"]); $active_sheet->setCellValue('m' . $count, $row["shift_3"]); $count = $count + 1; } //for ($i = 'A'; $i != $file->getActiveSheet()->getHighestColumn(); $i++) { $file->getActiveSheet()->getColumnDimension('A')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('B')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('C')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('D')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('E')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('F')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('G')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('H')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('I')->setAutoSize(TRUE); $file->getActiveSheet()->getColumnDimension('j')->setAutoSize(TRUE); //} //$sheet->getProtection()->setSheet(true); $c=$count-1; $file->getActiveSheet()->getProtection()->setSheet(true); $file->getDefaultStyle()->getProtection()->setLocked(false); $active_sheet->getStyle('A1:A'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('B1:B'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('C1:C'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('D1:D'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('E1:E'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('H1:H'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $active_sheet->getStyle('I1:I'.$c)->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_PROTECTED); $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($file, $_POST["file_type"]); $file_name = 'BudgetData_'.$stdat.'.' . 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"; $dtt=$_POST["date1"]; if (strlen($dtt)==0) { // exit; } $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); } ?> Budget Data Upload '.$dn.' ?>



Upload Budget Data

Upload Budget Data


Effective 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; } // echo array_search($sid,$numberList3); $g=array_search($sid,$numberList3); if (strlen($g)==0) { $numberList3[$arno] = $sid; $arno++; } if ($mm>0) { echo ' '; $dtt=$_POST["date1"]; $date1=date("Y-m-d", strtotime($dtt) ); if (strlen($bhc)==0) { $bhc=0 ; } if (strlen($bsf)==0) { $bsf=0 ; } // budget_date,company_id,region,branch_id,desig_id,Budget_head_count,Budget_shifts,branch_code,is_active if ($cnn==1) { $arr=$arr.$sid; $sqla=$sqla." ( '".$date1."',119,'".$rg."',".$sid.",".$dsgid.",".$bhc.",".$bsf.",'".$bc."',1,".$rvn.",".$sft1.",".$sft2.",".$sft3." )" ; } else { $sqla=$sqla.", ( '".$date1."',119,'".$rg."',".$sid.",".$dsgid.",".$bhc.",".$bsf.",'".$bc."',1,".$rvn.",".$sft1.",".$sft2.",".$sft3." )" ; } } if ($mm==0) { echo ' '; $cnt=0; } $cnn++; } // print_r($numberList3); //echo $arno."
";; //echo "total count ".$cnt; // echo "complete"."
" ; //echo $cnt."
"; //echo $sqla; $cnt=1; if ($cnt>0) { $sqla=$sqlm.$sqla; /* echo ' '; */ if (strlen($dtt)==0) { echo ''; } else { for($i = 0; $i < ($arno); $i++) { $k=($numberList3[$i]); $sql2="update budget_manpower_table set is_active=0 where budget_date='".$date1."' and branch_id=".$k; mysqli_query($connect, $sql2); } //$sql1="update budget_manpower_table set is_active=0 where budget_date='".$date1."'"; //mysqli_query($connect, $sql1); echo $sqla; mysqli_query($connect, $sqla); echo ''; } } } //print_r($numberList3); // print_r(array_unique($numberList3)); ?>
Sl No Download Date Branch Code Region Site Id Site Name Budget Head Count Budget Shifts Desig Id Designation Revenue Shift A Shift B Shift C
'.$cnn.' '.$dt.' '.$bc.' '.$rg.' '.$sid.' '.$snm.' '.$bhc.' '.$bsf.' '.$dsgid.' '.$dsg.' '.$rvn.' '.$sft1.' '.$sft2.' '.$sft3.'
'.$cnn.' '.$dt.' '.$bc.' '.$rg.' '.$sid.' '.$snm.' '.$bhc.' '.$bsf.' '.$dsgid.' '.$dsg.' '.$rvn.' '.$sft1.' '.$sft2.' '.$sft3.'
'.$cnn.' '.$dt.' '.$sqla.'