Current File : /home/inlingua/public_html/dwarka/icentex/admin/05featuredemo1.inc_conveyance1.php |
<?php
/**
* PHPExcel
*
* Copyright (C) 2006 - 2010 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/** Error reporting */
//error_reporting(E_ALL);
/** PHPExcel */
//require_once dirname(__FILE__) . '/Classes/PHPExcel.php';
require_once '../Classes/PHPExcel.php';
//$num1=mysqli_fetch_array($result1);
// Create new PHPExcel object
//echo date('H:i:s') . " Create new PHPExcel object\n";
$objPHPExcel = new PHPExcel();
// Set properties
//echo date('H:i:s') . " Set properties\n";
$objPHPExcel->getProperties()->setCreator("Vikas Umrao")
->setLastModifiedBy("Vikas Umrao")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Reports Timesheet");
$objPHPExcel->setActiveSheetIndex(0);
$sharedStyle1 = new PHPExcel_Style();
$sharedStyle1->applyFromArray(
array('fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('argb' => 'FFFFFF00')
),
'borders' => array(
'bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN),
'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)
)
));
$styleThickBrownBorderOutline = array(
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THICK,
'color' => array('argb' => 'FF000000'),
),
),
);
$i1=0;
$queryR="select a.*,b.name,b.primarycenter from ingl_conveyance_main a left join timesheet_user b on a.instructor=b.recNo where 1=1 && a.status='Send' ";
if($_REQUEST['month']!="All" && $_REQUEST['year']!="All")
{
$queryR.=" && a.sendDate>='".$date1."' && a.sendDate<='".$date2."'";
}
if($_REQUEST['location']!="All")
{
$queryR.=" && b.primarycenter='".$_REQUEST['location']."'";
//$queryR="select a.*,b.name,b.primarycenter from ingl_conveyance_main a left join timesheet_user b on a.instructor=b.recNo where a.sendDate>='".$date1."' && a.sendDate<='".$date2."' && a.status='Send' order by b.name,a.month";
}
if($_REQUEST['user']!="All")
{
$queryR.=" && a.instructor='".$_REQUEST['user']."'";
}
$queryR.=" order by b.name,a.month ";
//echo $queryR;
$resultR=mysqli_query($conn,$queryR);
while($numR=mysqli_fetch_array($resultR))
{
if($numR["primarycenter"]=="S.Extn")
{
$numR["primarycenter"]="South Extension";
}
if($i1!=0)
{
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($i1);
}
$ic=7;
$total=0;
$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':R'.$ic.'')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':R'.$ic.'')->getFill()->getStartColor()->setARGB('FF808080');
$objPHPExcel->getActiveSheet()->setCellValue('A'.$ic.'', 'Date');
$objPHPExcel->getActiveSheet()->setCellValue('B'.$ic.'', 'Start');
$objPHPExcel->getActiveSheet()->setCellValue('C'.$ic.'', 'Center1');
$objPHPExcel->getActiveSheet()->setCellValue('D'.$ic.'', 'Km1');
$objPHPExcel->getActiveSheet()->setCellValue('E'.$ic.'', 'Center2');
$objPHPExcel->getActiveSheet()->setCellValue('F'.$ic.'', 'Km2');
$objPHPExcel->getActiveSheet()->setCellValue('G'.$ic.'', 'Center3 ');
$objPHPExcel->getActiveSheet()->setCellValue('H'.$ic.'', 'Km3');
$objPHPExcel->getActiveSheet()->setCellValue('I'.$ic.'', 'Center4');
$objPHPExcel->getActiveSheet()->setCellValue('J'.$ic.'', 'Km4');
$objPHPExcel->getActiveSheet()->setCellValue('K'.$ic.'', 'End');
$objPHPExcel->getActiveSheet()->setCellValue('L'.$ic.'', 'Km5');
$objPHPExcel->getActiveSheet()->setCellValue('M'.$ic.'', 'Total Kms');
$objPHPExcel->getActiveSheet()->setCellValue('N'.$ic.'', 'Less Kms');
$objPHPExcel->getActiveSheet()->setCellValue('O'.$ic.'', 'Effective Kms');
$objPHPExcel->getActiveSheet()->setCellValue('P'.$ic.'', 'Band');
$objPHPExcel->getActiveSheet()->setCellValue('Q'.$ic.'', 'Total');
$objPHPExcel->getActiveSheet()->setCellValue('R'.$ic.'', 'Remarks');
$ic++;
$monthmk=mktime(0,0,0,$numR['month'],1,$numR['year']);
if($_REQUEST['month']!="All" && $_REQUEST['year']!="All")
{
$pe="(Submitted during period '.$date1.' - '.$date2.' )";
}
else{
$pe="(Submitted on ".$numR['sendDate']." )";
}
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Conveyance Sheet for '.date("F, Y",$monthmk).' '.$pe.'');
$objPHPExcel->getActiveSheet()->setCellValue('A3', 'Name');
$objPHPExcel->getActiveSheet()->setCellValue('B3', ''.stripslashes($numR["name"]).'');
$objPHPExcel->getActiveSheet()->setCellValue('A4', 'Month');
$objPHPExcel->getActiveSheet()->setCellValue('B4', ''.date("F",$monthmk).', '.$numR['year'].'');
$objPHPExcel->getActiveSheet()->setCellValue('A5', 'P.Center');
$objPHPExcel->getActiveSheet()->setCellValue('B5', ''.stripslashes($numR["primarycenter"]).'');
$queryService="select * from ingl_conveyance where basic_recNo='".$numR['recNo']."' order by recNo";
$resultService=mysqli_query($conn,$queryService) or die(mysqli_query($conn,));
$countservice=mysqli_num_rows($resultService);
while($numSevice=mysqli_fetch_array($resultService))
{
$queryloc="select * from timesheet_location where recNo='".$numSevice['center1']."' order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
$num=mysqli_fetch_array($resultloc);
if($numSevice['center1']=="9" || $numSevice['center1']=="Other" || $numSevice['center1']=="Training" || $numSevice['center1']=="Actual Exp.")
{
if($numSevice['center1']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other1']."";
}
else
{
$num['location']="".$numSevice['center1']." , ".$numSevice['other1']."";
}
}
$center1=$num['location'];
//////////////////////////////////////////////////////////
$queryloc="select * from timesheet_location where recNo='".$numSevice['center2']."' order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
$num=mysqli_fetch_array($resultloc);
if($numSevice['center2']=="9" || $numSevice['center2']=="Other" || $numSevice['center2']=="Training" || $numSevice['center2']=="Actual Exp.")
{
if($numSevice['center2']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other2']."";
}
else
{
$num['location']="".$numSevice['center2']." , ".$numSevice['other2']."";
}
}
$center2=$num['location'];
////////////////////////////////////////////////////////////////////
$queryloc="select * from timesheet_location where recNo='".$numSevice['center3']."' order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
$num=mysqli_fetch_array($resultloc);
if($numSevice['center3']=="9" || $numSevice['center3']=="Other" || $numSevice['center3']=="Training" || $numSevice['center3']=="Actual Exp.")
{
if($numSevice['center3']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other3']."";
}
else
{
$num['location']="".$numSevice['center3']." , ".$numSevice['other3']."";
}
}
$center3=$num['location'];
/////////////////////////////////////////////////////////
$queryloc="select * from timesheet_location where recNo='".$numSevice['center4']."' order by location";
$resultloc=mysqli_query($conn,$queryloc) or die(mysqli_query($conn,));
$num=mysqli_fetch_array($resultloc);
if($numSevice['center4']=="9" || $numSevice['center4']=="Other" || $numSevice['center4']=="Training" || $numSevice['center4']=="Actual Exp.")
{
if($numSevice['center4']=="9")
{
$num['location']="".$num['location']." , ".$numSevice['other4']."";
}
else
{
$num['location']="".$numSevice['center4']." , ".$numSevice['other4']."";
}
}
$center4=$num['location'];
$objPHPExcel->getActiveSheet()->setCellValue('A'.$ic.'', ''.$numSevice['date_conveyance'].'');
$objPHPExcel->getActiveSheet()->setCellValue('B'.$ic.'', ''.$numSevice['start_center'].'');
$objPHPExcel->getActiveSheet()->setCellValue('C'.$ic.'', ''.$center1.'');
$objPHPExcel->getActiveSheet()->setCellValue('D'.$ic.'', ''.$numSevice['km1'].'');
$objPHPExcel->getActiveSheet()->setCellValue('E'.$ic.'', ''.$center2.'');
$objPHPExcel->getActiveSheet()->setCellValue('F'.$ic.'', ''.$numSevice['km2'].'');
$objPHPExcel->getActiveSheet()->setCellValue('G'.$ic.'', ''.$center3.' ');
$objPHPExcel->getActiveSheet()->setCellValue('H'.$ic.'', ''.$numSevice['km3'].'');
$objPHPExcel->getActiveSheet()->setCellValue('I'.$ic.'', ''.$center4.'');
$objPHPExcel->getActiveSheet()->setCellValue('J'.$ic.'', ''.$numSevice['km4'].'');
$objPHPExcel->getActiveSheet()->setCellValue('K'.$ic.'', ''.$numSevice['center5'].'');
$objPHPExcel->getActiveSheet()->setCellValue('L'.$ic.'', ''.$numSevice['km5'].'');
$less=$numSevice['km1']+$numSevice['km2']+$numSevice['km3']+$numSevice['km4']+$numSevice['km5']-$numSevice['totalkms'];
$objPHPExcel->getActiveSheet()->setCellValue('M'.$ic.'', '=D'.$ic.'+F'.$ic.'+H'.$ic.'+J'.$ic.'+L'.$ic.'');
$objPHPExcel->getActiveSheet()->setCellValue('N'.$ic.'', ''.$less.'');
$objPHPExcel->getActiveSheet()->setCellValue('O'.$ic.'', '=M'.$ic.'-N'.$ic.'');
$objPHPExcel->getActiveSheet()->setCellValue('P'.$ic.'', ''.$numSevice['Band'].'');
$objPHPExcel->getActiveSheet()->setCellValue('Q'.$ic.'', ''.$numSevice['total'].'');
$objPHPExcel->getActiveSheet()->setCellValue('R'.$ic.'', ''.$numSevice['remarks'].'');
$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':R'.$ic.'')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
//$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':Q'.$ic.'')->getFill()->getStartColor()->setARGB('FF808080');
$total.='+ Q'.$ic.'';
$ic++;
//echo"<br>";
}
$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':R'.$ic.'')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$ic++;
$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':R'.$ic.'')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A'.$ic.':R'.$ic.'')->applyFromArray($styleThickBrownBorderOutline);
$objPHPExcel->getActiveSheet()->setCellValue('O'.$ic.'', 'TOTAL :');
$objPHPExcel->getActiveSheet()->setCellValue('Q'.$ic.'', '='.$total.'');
$objPHPExcel->getActiveSheet()->setTitle(''.stripslashes($numR['name']).'('.$numR['month'].'-'.$numR['year'].')');
$ls=$ic+2;
$ls1=$ls+1;
$objPHPExcel->getActiveSheet()->mergeCells('A'.$ls.':R'.$ls1.'');
$objPHPExcel->getActiveSheet()->setCellValue('A'.$ls.'', 'This is computer generated invoice.Need not to sign.');
// Create new picture object
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('logo');
$objDrawing->setDescription('logo');
//$objDrawing->setHeight(80);
//$objDrawing->setWidth(100);
$objDrawing->setPath('test/images/logo.jpg');
// Insert picture
$objDrawing->setCoordinates('A1');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objPHPExcel->getActiveSheet()->setCellValue('C1', 'inlingua New Delhi');
$i1++;
$objPHPExcel->getActiveSheet()->mergeCells('A1:B1');
$objPHPExcel->getActiveSheet()->mergeCells('C1:R1');
$objPHPExcel->getActiveSheet()->mergeCells('A2:R2');
$objPHPExcel->getActiveSheet()->mergeCells('B3:R3');
$objPHPExcel->getActiveSheet()->mergeCells('B4:R4');
$objPHPExcel->getActiveSheet()->mergeCells('B5:R5');
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(60);
$objPHPExcel->getActiveSheet()->getStyle('A2')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->getStyle('A2')->getFont()->setSize(20);
$objPHPExcel->getActiveSheet()->getStyle('A2')->getFont()->setBold(true);
//$objPHPExcel->getActiveSheet()->getStyle('A2')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$objPHPExcel->getActiveSheet()->getStyle('A2')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_BLACK);
$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->setSize(40);
$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->setBold(true);
//$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$objPHPExcel->getActiveSheet()->getStyle('C1')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_BLACK);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(13);
}
// Set header and footer. When no different headers for odd/even are used, odd header is assumed.
//echo date('H:i:s') . " Set header/footer\n";
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
// Set page orientation and size
//echo date('H:i:s') . " Set page orientation and size\n";
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);