Ejemplo n.º 1
0
			<label>Regular Cost:</label><span id="displayCost"><?php 
echo $wine->getCost();
?>
</span><br>
			<label>Regular Selling Price:</label><span id="displaySellPrice"><?php 
echo $wine->getSellPrice();
?>
</span><br>
			<label>Current Inventory:</label><span id="currentInventory"><?php 
echo $wine->getCurrentInventory();
?>
</span><br>
			<span class="expand-click" onClick="$('#inventory-detail').css('display','block');">Click for Location Details</span><br>
			<div id="inventory-detail" style="display:none;">
				<?php 
$details = $wine->getDetailInventory();
foreach ($details as $loc => $qty) {
    echo $loc . ': ' . $qty . '<br>';
}
?>
			</div>
			<input class="action" type="button" value="Edit" onClick="$('#show').css('display','none');$('#edit').css('display','block');">&nbsp;<input class="action" type="button" value="Inventory" onClick="window.location.assign('/showinventory/<?php 
echo $_GET['upc'];
?>
')">
			</div>
		</div>
		<div id="footer">
		</div>
	</div>
		<script>
Ejemplo n.º 2
0
function exportPDF($arr, $dbh)
{
    if (isset($arr['reportType']) && $arr['reportType'] == 'summaryByUPC') {
        $wine = new Wine($dbh);
        $wine->fetchWineByUPC($arr['upc']);
        if (isset($arr['toDate']) && $arr['toDate'] != null && $arr['toDate'] != '') {
            $to = $arr['toDate'];
        } else {
            $to = null;
        }
        if (isset($arr['fromDate']) && $arr['fromDate'] != null && $arr['fromDate'] != '') {
            $from = $arr['fromDate'];
        } else {
            $from = null;
        }
        $json = $wine->getInventorySummary($from, $to);
        //Generate HTML and echo it out;
        $data = json_decode($json, true);
        if (!isset($data[0])) {
            die('No data was found matching your criteria.');
        }
        $args = array('date' => $from);
        if (is_null($from)) {
            $curInv = 0;
        } else {
            $curInv = $wine->getCurrentInventory($args);
        }
        $runTot = $curInv;
        $HTML = <<<EOF
<style>
h3 {
\tfont-size:20px;
\tmargin-top:20px;
\tcolor: #760101;
\tmargin-bottom:15px;
}
label {
\tdisplay:inline;
}
p {
\tdisplay:inline;
\tfont-size:12px;
\tcolor: #000;
\tmargin-bottom:15px;
}
td,th {
\tborder: 1px solid #000;
\tpadding:2px;
}
th {
\tfont-size:18px;
\tbackground-color:#ADADAD;
}
</style>
EOF;
        $HTML .= '<h3>Inventory Summary</h3>';
        $HTML .= '<table><tr><td style="border:none;">Name:</td><td style="border:none;">' . $data[0]['name'] . '</td></tr>';
        $HTML .= '<tr><td style="border:none;">UPC:</td><td style="border:none;">' . $data[0]['upc'] . '</td></tr>';
        $HTML .= '<tr><td style="border:none;">Beginning Inventory:</td><td style="border:none;">' . $curInv . '</td></tr>';
        $TABLE = '<table>';
        $TABLE .= '<tr><th align="center" valign="middle" width="30%" height="24px"><font size="13px">Date/Time</font></th><th align="center" valign="middle" width="8%"><font size="13px">Qty</font></th><th align="center" valign="middle" width="15%"><font size="13px">Location</font></th><th align="center" valign="middle" width="15%"><font size="13px">Cost</font></th><th align="center" valign="middle" width="13%"><font size="13px">Price</font></th><th align="center" valign="middle"><font size="13px">Total</font></th></tr>';
        foreach ($data as $row) {
            $runTot = $runTot + $row['quantity'];
            $TABLE .= '<tr><td align="center" valign="middle" width="30%" height="20px">' . $row['datetime'] . '</td><td align="center" valign="middle" width="8%">' . $row['quantity'] . '</td><td align="center" valign="middle" width="15%">' . $row['locname'] . '</td><td align="center" valign="middle" width="15%">' . $row['cost'] . '</td><td align="center" valign="middle" width="13%">' . $row['sell_price'] . '</td><td align="center" valign="middle">' . $runTot . '</td></tr>';
        }
        $TABLE .= '</table>';
        $HTML .= '<tr><td style="border:none;">Ending Inventory:</td><td style="border:none;">' . $runTot . '</td></tr></table>';
        $details = $wine->getDetailInventory($args);
        $details = $wine->getDetailInventory($args);
        foreach ($details as $key => $inv) {
            $HTML .= '<div class="location-inventory">' . $key . ': ' . $inv . '</div>';
        }
        $HTML .= '<br><br>';
        $HTML .= $TABLE;
        //Create PDF
        // create new PDF document
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Highland Country Club');
        $pdf->SetTitle('Inventory Summary');
        $pdf->SetSubject('Inventory Summary');
        $pdf->SetKeywords('PDF, Inventory Summary');
        // set default header data
        $pdf->SetHeaderData('', '', date('Y-m-d'), '');
        // set header and footer fonts
        $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        // set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        // set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        // set image scale factor
        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
        $pdf->SetFont('dejavusans', '', 10);
        $pdf->addPage();
        $pdf->writeHTML($HTML, true, false, true, false, '');
        $pdf->lastPage();
        $pdf->Output('summaryByUPC.pdf', 'I');
        //END CREATE PDF
    } else {
        if (isset($arr['reportType']) && $arr['reportType'] == 'completeInventory') {
            $wine = new Wine($dbh);
            if (isset($arr['toDate']) && $arr['toDate'] != null) {
                $to = $arr['toDate'];
            } else {
                $to = null;
            }
            $wines = $wine->fetchAllWines();
            $arr = json_decode($wines, true);
            $HTML = <<<EOF
<style>
h3 {
\tfont-size:20px;
\tmargin-top:20px;
\tcolor: #760101;
\tmargin-bottom:15px;
}
label {
\tdisplay:inline;
}
p {
\tdisplay:inline;
\tfont-size:12px;
\tcolor: #000;
\tmargin-bottom:15px;
}
td,th {
\tborder: 1px solid #000;
\tpadding:2px;
}
th {
\tfont-size:18px;
\tbackground-color:#ADADAD;
}
</style>
EOF;
            $HTML = '<h3>Complete Inventory</h3>';
            $HTML .= '<label style="width:7em;">Criteria:</label><p>' . ($to != null ? 'As Of - ' . $to : 'As Of - N/A') . '</p>';
            $HTML .= '<div class="wine-inventory-report">';
            foreach ($arr as $a) {
                $curWine = new Wine($dbh);
                $curWine->fetchWineByUPC($a['upc']);
                $args = array('date' => $to);
                $inv = $curWine->getCurrentInventory($args);
                //cur is json summary of inventory
                $HTML .= '<div class="wine-detail" style="display:block;width:100%;min-height:50px;background:#eee; border: 2px solid #bbb;padding:5px;">';
                $HTML .= '<div class="wine-title" style="font-size: 15px; font-weight:bold;">' . $curWine->getUPC() . ' - ' . $curWine->getName() . '</div>';
                $HTML .= '<div class="wine-info" style="font-size: 12px; margin-top:5px;">Total Inventory: ' . $curWine->getCurrentInventory($args) . ' Cost/Bottle: ' . number_format($curWine->getCost(), 2) . ' Total Cost: ' . number_format($curWine->getCurrentInventory($args) * $curWine->getCost(), 2) . ' Selling Price: ' . number_format($curWine->getSellPrice(), 2) . '</div>';
                $HTML .= '<div class="inventory-detail" style="font-size: 12px; margin-top:5px; text-indent: 20px;">';
                $details = $curWine->getDetailInventory($args);
                foreach ($details as $key => $inv) {
                    $HTML .= '<div class="location-inventory">' . $key . ': ' . $inv . '</div>';
                }
                $HTML .= '</div></div>';
                //$HTML .= '<tr><td>' . $curWine->getUPC() . '</td><td>' . $curWine->getName() . '</td><td>' . $curWine->getCurrentInventory($args) . '</td><td>' . '' . '</td><td>' . number_format($curWine->getCost(),2) . '</td><td>' . number_format($curWine->getCurrentInventory($args)*$curWine->getCost(),2) . '</td><td>' . number_format($curWine->getSellPrice(),2) . '</td><td>' . $curWine->getCost()/$curWine->getSellPrice() . '</td></tr>';
            }
            $HTML .= '</div>';
            //Create PDF
            // create new PDF document
            $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
            // set document information
            $pdf->SetCreator(PDF_CREATOR);
            $pdf->SetAuthor('Highlands Country Club');
            $pdf->SetTitle('Complete Inventory');
            $pdf->SetSubject('Complete Inventory');
            $pdf->SetKeywords('PDF,Complete Inventory');
            // set default header data
            $pdf->SetHeaderData('', '', date('Y-m-d'), '');
            // set header and footer fonts
            $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
            $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
            // set default monospaced font
            $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
            // set margins
            $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
            $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
            $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
            // set auto page breaks
            $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
            // set image scale factor
            $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
            $pdf->SetFont('dejavusans', '', 10);
            $pdf->addPage();
            $pdf->writeHTML($HTML, true, false, true, false, '');
            $pdf->lastPage();
            $pdf->Output('completeInventory.pdf', 'I');
        } else {
            die('Invalid Report Type');
        }
    }
}