I have been trying to edit a button from an open source web program to call on a php script I made. The original script creates a new window, calls on a php script to generate a barcode, places the barcode on the new window then causes the browser to print. My php script generates a raw file then calls on an exe to send it to a network printer. My php script works, I just cannot figure out how to edit the existing code to use my script without creating a new window.
Original related source:
[php]
// Setup Print Asset Tag button
protected function btnPrintAssetTag_Create() {
$this->btnPrintAssetTag = new QButton($this);
$this->btnPrintAssetTag->Text = QApplication::Translate(‘Print Asset Tag’);
$this->btnPrintAssetTag->AddAction(new QClickEvent(), new QAjaxControlAction($this, ‘btnPrintAssetTag_Click’));
$this->btnPrintAssetTag->AddAction(new QEnterKeyEvent(), new QAjaxControlAction($this, ‘btnPrintAssetTag_Click’));
$this->btnPrintAssetTag->AddAction(new QEnterKeyEvent(), new QTerminateAction());
$this->btnPrintAssetTag->CausesValidation = false;
}
// Print Asset Tag button Click Action
public function btnPrintAssetTag_Click($strFormId, $strControlId, $strParameter) {
$strImagePath = sprintf(’…/includes/php/barcode.php?code=%s&encoding=128&scale=1’, $this->objAsset->AssetCode);
QApplication::ExecuteJavaScript(‘var pwin = window.open("", “Image”);’);
QApplication::ExecuteJavaScript(sprintf(‘if (pwin) { pwin.document.writeln("<style type=“text/css”>body { margin:0; padding:0; } <img src="%s" />");pwin.document.close();pwin.focus();pwin.print(); }’, $strImagePath));
}
[/php]
My edit which works but has a popup window that I want to get rid of:
[php]
// Print Asset Tag button Click Action
public function btnPrintAssetTag_Click($strFormId, $strControlId, $strParameter) {
$strImagePath = sprintf(’…/includes/php/print.php?code=%s’, $this->objAsset->AssetCode);
QApplication::ExecuteJavaScript(‘var pwin = window.open("", “Image”);’);
QApplication::ExecuteJavaScript(sprintf(‘if (pwin) { pwin.document.writeln("<style type=“text/css”>body { margin:0; padding:0; } <img src="%s" />");pwin.document.close(); }’, $strImagePath));
}
[/php]
The full source of the file can be found at http://code.google.com/p/tracmor/source/browse/trunk/includes/qcodo/qform/QAssetEditComposite.class.php?spec=svn770&r=770
Any help would be greatly appreciated.