* License: * GPL v3 or above * * Website: * http://www.simpleinvoices.org */ //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); #get the invoice id $invoice_id = $_GET['id']; $invoiceobj = new invoice(); $invoice = $invoiceobj->select($invoice_id); $preference = getPreference($invoice['preference_id']); $biller = getBiller($invoice['biller_id']); $customer = getCustomer($invoice['customer_id']); $invoiceType = getInvoiceType($invoice['type_id']); #create PDF name $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $pdf_file_name = $spc2us_pref . '.pdf'; if ($_GET['stage'] == 2) { #echo $block_stage2; // Create invoice $export = new export(); $export->format = "pdf"; $export->file_location = 'file'; $export->module = 'invoice'; $export->id = $invoice_id; $export->execute(); #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name); $email = new email(); $email->format = 'invoice';
function hotLink( $type, $id, $displayvalue='', $useimage=false, $functioncall='', $placement='reg_body', $showinvtype=false ) { global $db; global $lang; global $domain; global $usetemplate; global $RootPath; global $language; global $masterdatabase; //global $modeldatabase; global $UserID; include_once($RootPath."/language/".$language."/includes/general_functions.inc"); if ( $id == '' || $id == 0 ) return ''; $authorized = false; //set some var's based on $type switch( $type ) { //Invoice (lightbox) //08.23.2012 jss - ( 23166 ) changed case 1 to bring the invoice up in a lightbox. The old //case 1 is now case 9 and it takes you to the invoice section and pulls it up. case 1: if ( isAuth( 1,81,232,211 ) ) $authorized = true; $useimage = true; $displayvaluequery = 'select CustomInvoiceNumber as DisplayValue from invInvoice where InvoiceID = ' . $id; //TKS 11.13.2013 #43002 got rid of globalInvoiceID being set when loading in overlay //01.20.2014 naj - changed get_mv_view_invoice to get_mv_viewinvoice, since we have moved to //the new invoice format. $myfunctioncall .= ' get_menu_includes( 231,81 ); get_menu_includes( 628,98 ); get_menu_includes( 636,98 ); globalOverlayInvoiceID=' . $id . '; globalOverlayContactID = document.getElementById( \'global_contactid\' ).value; var tempmaster = readCookie( \'ssi_menumaster\' ); var tempmenu = readCookie( \'ssi_menuid\' ); createCookie( \'ssi_menuid\', tempmenu ); createCookie( \'ssi_menumaster\', tempmaster ); get_mv_viewinvoice( \'overlay2\' );'; //$title = $lang[ 'ViewInvoice' ]; $title = $lang[ 'hpl_ViewInvoice' ]; //04.25.2013 jss - for me, get the invoice location and add it to the image title if ( compareSecurityLevel($UserID) == 1 ) { include_once( "$RootPath/invoicing/general_invoice_functions.php" ); $invoicelocation = " (" . getLocationName(getInvoiceLocation($id)) . ")"; $title .= $invoicelocation; //05.21.2013 jss - add customer name to hint for compare user $query3 = "select ContactID from invInvoice where InvoiceID = $id"; if ( !$result3 = $db->sql_query( $query3 ) ) { LogError( 000, $query3 ."<br>".$db->sql_error() ); return false; } $row3 = $db->sql_fetchrow( $result3 ); ////08.16.2013 ghh - added var so we only call once $rn = contactRealName( $row3[ 'ContactID' ] ); $title .= ' - ' . $rn; $invoicelocation .= ' - ' . $rn; } $myfunctioncall2 .= 'globalInvoiceID=' . $id . '; get_menu_getpage( \'' . $placement . '\', 232, 81 );'; break; //PO case 2: if ( isAuth( 3,50,292,273 ) ) $authorized = true; //12.14.2012 jss - ( 27855 ) changed to run the query here instead so we can add the //consignment flag if needed //$displayvaluequery = 'select PONumber as DisplayValue from actPO where POID = ' . $id; $query = "select PONumber, ConsignmentPartsPO, LocationID from actPO where POID = $id"; if ( !$result = $db->sql_query( $query ) ) { LogError( 000, $query ."<br>".$db->sql_error() ); return false; } $row = $db->sql_fetchrow( $result ); $displayvalue = $row[PONumber]; if ( $row[ConsignmentPartsPO] ) $displayvalue .= "(C)"; $myfunctioncall .= "globalPOID=$id;"; //12.07.2011 jss - changed to take you to the accounting module first cuz the bin controls look at cookies to see what module you're in //and act accordingly when selecting a bin. Calling a po from the inventory section was causing the wrong "select" links to appear on it. //$myfunctioncall .= 'document.getElementById( \'header2\' ).innerHTML = \'Accounting\'; get_menu_master( \'reg_left1\', 3 );'; //06.04.2012 jss - no longer needed as tim and i have re-written the header //$myfunctioncall .= "document.getElementById( 'header2' ).innerHTML = '" . $lang[ 'accounting' ] . "';"; $myfunctioncall .= "get_menu_master( 'reg_left1', 3 );"; $myfunctioncall .= "try { get_menu_main( 'mnu_Payables', 50 ); } catch(err) {}"; $myfunctioncall .= "get_menu_getpage( '$placement', 292, 50 );"; $title = $lang[ 'hpl_ViewPO' ]; //04.25.2013 jss - for me, get the invoice location and add it to the image title if ( compareSecurityLevel($UserID) == 1 ) { $title .= " ( " . getLocationName($row['LocationID']) . " )"; } break; //Unit (vin) case 3: if ( isAuth( 16, 65, 181, 160 ) ) $authorized = true; $displayvaluequery = 'select VIN as DisplayValue from untUnitInfo where UnitID = ' . $id; //TKS 09.05.2012 added the closing of video_overlay since unit controls are loading in overlay //in new invoice flow. $myfunctioncall .= 'globalUnitID=' . $id . '; get_menu_getpage( \'' . $placement . '\', 181, 65 ); close_overlay( \'video_overlay\' );'; $title = $lang[ 'hpl_ViewUnit' ]; break; //Unit (stockno) case 4: if ( isAuth( 16, 65, 181, 160 ) ) $authorized = true; $displayvaluequery = 'select StockNo as DisplayValue from untUnitInfo where UnitID = ' . $id; //TKS 09.05.2012 added the closing of video_overlay since unit controls are loading in overlay //in new invoice flow. $myfunctioncall .= 'globalUnitID=' . $id . '; get_menu_getpage( \'' . $placement . '\', 181, 65 ); close_overlay( \'video_overlay\' );'; $title = $lang[ 'hpl_ViewUnit' ]; break; //Unit (model#) case 5: if ( isAuth( 16, 65, 181, 160 ) ) $authorized = true; //TKS 09.05.2012 added the closing of video_overlay since unit controls are loading in overlay //in new invoice flow. //11.26.2011 ghh - changed masterdatabase to modeldatabase to work with new database for model numbers //05.10.2013 jss - removed $modeldatabase var as it's old and the table is back to being local /* $displayvaluequery = 'select t2.ModelNumber as DisplayValue from ( untUnitInfo as t1, ' . $modeldatabase . '.untModels as t2 ) where t1.UnitID = ' . $id . ' and t1.ModelID = t2.ModelID'; */ $displayvaluequery = "select t2.ModelNumber as DisplayValue from ( untUnitInfo as t1, untModels as t2 ) where t1.UnitID = $id and t1.ModelID = t2.ModelID"; $myfunctioncall .= 'globalUnitID=' . $id . '; get_menu_getpage( \'' . $placement . '\', 181, 65 ); close_overlay( \'video_overlay\' );'; $title = $lang[ 'hpl_ViewUnit' ]; break; //Part # case 6: if ( isAuth( 9, 44, 208, 187 ) ) $authorized = true; //if ( ( $id ) < 5000000 ) $displayvaluequery = 'select ItemNumber as DisplayValue from itmItems where ItemID = ' . $id; $myfunctioncall .= 'global_item=' . $id . ';'; //06.26.2012 jss - recently changed to bring up the inventory module, but due to complaints //i added an if statement to only do it for me if ( compareSecurityLevel($UserID) == 1 ) $myfunctioncall .= "get_menu_master( 'reg_left1', 9 );"; $myfunctioncall .= 'get_menu_getpage( \'' . $placement . '\', 208, 44 );'; //TKS 08.23.2013 #39971 added the close_overlay call as there are cases where you //click on a part # link and in overlay and it needs to close $myfunctioncall .= 'close_overlay(\'video_overlay\' );'; $title = $lang[ 'hpl_ViewItem' ]; break; //ARID case 7: if ( isAuth( 3, 49, 290, 270 ) ) $authorized = true; $displayvaluequery = 'select ARID as DisplayValue, ContactID from actAR where ARID = ' . $id; //09.28.2011 jss - get contactid $query = $displayvaluequery; if ( !$result = $db->sql_query( $query ) ) { LogError( 8472, $query ."<br>".$db->sql_error() ); exit; } $row = $db->sql_fetchrow( $result ); $contactid = $row[ 'ContactID' ]; $myfunctioncall .= 'document.getElementById( \'global_contactid\' ).value = \'' . $contactid . '\'; get_menu_getpage(\'reg_body\',447,81); get_menu_master(\'reg_left1\',3); get_menu_main( \'mnu_Receivables\', 49); get_menu_getpage( \'reg_body\', 290,49 );'; $title = $lang[ 'hpl_ViewAR' ]; break; //CHECKID case 8: if ( isAuth( 3, 62, 168, 147 ) ) $authorized = true; $displayvaluequery = 'select CheckNumber as DisplayValue from chkChecks where CheckID = ' . $id; //04.11.2012 jss - get more checking info in order to create myfunctioncall $query = "select * from chkChecks where checkid = $id"; if ( !$result = $db->sql_query( $query ) ) { LogError( 000, $query ."<br>".$db->sql_error() ); exit; } $row = $db->sql_fetchrow( $result ); //$myfunctioncall .= 'chk_reg_datefrom = \'\';'; //$myfunctioncall .= 'chk_reg_dateto = \'\';'; $myfunctioncall .= 'chk_reg_account = ' . $row[ 'AccountID' ] . ';'; $myfunctioncall .= 'chk_reg_checknum = \'' . $row[CheckNumber] . '\';'; $myfunctioncall .= 'chk_reg_checkamount = \'\';'; //06.04.2012 jss - no longer needed as tim and i have re-written the header //$myfunctioncall .= 'document.getElementById( \'header2\' ).innerHTML = \'Accounting\';'; $myfunctioncall .= 'get_menu_master( \'reg_left1\', 3 );'; $myfunctioncall .= 'get_menu_main( \'mnu_Checking\', 62 );'; $myfunctioncall .= 'get_menu_getpage( \'reg_body\', 168, 62 );'; $title = $lang[ 'hpl_ViewCheck' ]; break; } //get displayvalue if it's not passed in ( ie. Invoice #, PO #, Check #, etc... ) if ( $displayvalue == '' ) { if ( !$result = $db->sql_query( $displayvaluequery ) ) { LogError( 8148, $displayvaluequery .$dblang[ "ErrorInSQL" ]."<br>".$db->sql_error() ); exit; } $row = $db->sql_fetchrow( $result ); $displayvalue = $row[ 'DisplayValue' ]; } ####################################################################################################################### if ( $authorized ) { //start building the anchor $link = '<a href="javascript:'; //build the link function if ( $functioncall == '' ) $link .= $myfunctioncall; else $link .= $functioncall; $link .= '"'; //IMAGE TITLE $link .= ' title="' . $title . ' ..."'; //05.15.2013 jss - $link .= ' tabindex="-1"'; $link .= '>'; //IMAGE if ( $useimage ) { switch( $type ) { case 1: $imagename = 'overlay_icon.png'; break; case 9: $imagename = 'overlay_icon.png'; break; default: $imagename = 'view.png'; break; } $link .= "<img src=\"$domain/templates/$usetemplate/images/$imagename\" border=\"0\">"; } else $link .= $displayvalue; //close the anchor $link .= '</a>'; //08.31.2012 jss - if doing an invoice link, we'll have something in $myfunctioncall2 which means //we will display both an icon ( used for lightbox ) and a link ( that takes you to the invoice section ) //04.25.2013 jss - added invoice location for me //05.15.2013 jss - added tabindex="-1" if ( $myfunctioncall2 != '' ) //$link .= ' <a href="javascript:' . $myfunctioncall2 . '"' . ' title="' . $lang[hpl_GoToInvoice] . '">' . $displayvalue; $link .= " <a href=\"javascript:$myfunctioncall2\" tabindex=\"-1\" title=\"$lang[hpl_GoToInvoice] $invoicelocation\">$displayvalue</a>"; } //TKS 08.23.2013 got rid of span class=data as the class is no longer used else $link = $displayvalue; //06.06.2013 jss - ( 35794 ) add invtype icon to end of invoice # link if ( $type == 1 && $showinvtype ) { $invtype = getInvType( $id ); include_once( "$RootPath/invoicing/general_invoice_functions.php" ); $link .= ' '.getInvoiceType( $invtype, false ); } return $link; }
function getData() { //echo "export - get data"; global $smarty; global $siUrl; switch ($this->module) { case "statement": $invoice = new invoice(); $invoice->biller = $this->biller_id; $invoice->customer = $this->customer_id; if ($this->filter_by_date == "yes") { if (isset($this->start_date)) { $invoice->start_date = $this->start_date; } if (isset($this->end_date)) { $invoice->end_date = $this->end_date; } if (isset($this->start_date) and isset($this->end_date)) { $invoice->having = "date_between"; } $having_count = 1; } if ($this->show_only_unpaid == "yes") { if ($having_count == 1) { $invoice->having_and = "money_owed"; } else { $invoice->having = "money_owed"; } } $invoice_all = $invoice->select_all('count'); $invoices = $invoice_all->fetchAll(); foreach ($invoices as $i => $row) { $statement['total'] = $statement['total'] + $row['invoice_total']; $statement['owing'] = $statement['owing'] + $row['owing']; $statement['paid'] = $statement['paid'] + $row['INV_PAID']; } $templatePath = "./templates/default/statement/index.tpl"; $biller_details = getBiller($this->biller_id); $customer_details = getCustomer($this->customer_id); $this->file_name = "statement_" . $this->biller_id . "_" . $this->customer_id . "_" . $invoice->start_date . "_" . $invoice->end_date; $smarty->assign('biller_id', $biller_id); $smarty->assign('biller_details', $biller_details); $smarty->assign('customer_id', $customer_id); $smarty->assign('customer_details', $customer_details); $smarty->assign('show_only_unpaid', $show_only_unpaid); $smarty->assign('filter_by_date', $this->filter_by_date); $smarty->assign('invoices', $invoices); $smarty->assign('start_date', $this->start_date); $smarty->assign('end_date', $this->end_date); $smarty->assign('invoices', $invoices); $smarty->assign('statement', $statement); $data = $smarty->fetch("." . $templatePath); break; case "payment": $payment = getPayment($this->id); /*Code to get the Invoice preference - so can link from this screen back to the invoice - START */ $invoice = getInvoice($payment['ac_inv_id']); $biller = getBiller($payment['biller_id']); $logo = getLogo($biller); $logo = str_replace(" ", "%20", $logo); $customer = getCustomer($payment['customer_id']); $invoiceType = getInvoiceType($invoice['type_id']); $customFieldLabels = getCustomFieldLabels(); $paymentType = getPaymentType($payment['ac_payment_type']); $preference = getPreference($invoice['preference_id']); $smarty->assign("payment", $payment); $smarty->assign("invoice", $invoice); $smarty->assign("biller", $biller); $smarty->assign("logo", $logo); $smarty->assign("customer", $customer); $smarty->assign("invoiceType", $invoiceType); $smarty->assign("paymentType", $paymentType); $smarty->assign("preference", $preference); $smarty->assign("customFieldLabels", $customFieldLabels); $smarty->assign('pageActive', 'payment'); $smarty->assign('active_tab', '#money'); $css = $siUrl . "/templates/invoices/default/style.css"; $smarty->assign('css', $css); $templatePath = "./templates/default/payments/print.tpl"; $data = $smarty->fetch("." . $templatePath); break; case "invoice": $invoice = invoice::select($this->id); $invoice_number_of_taxes = numberOfTaxesForInvoice($this->id); $customer = getCustomer($invoice['customer_id']); $biller = biller::select($invoice['biller_id']); $preference = getPreference($invoice['preference_id']); $defaults = getSystemDefaults(); $logo = getLogo($biller); $logo = str_replace(" ", "%20", $logo); $invoiceItems = invoice::getInvoiceItems($this->id); $spc2us_pref = str_replace(" ", "_", $invoice['index_name']); $this->file_name = $spc2us_pref; $customFieldLabels = getCustomFieldLabels(); /*Set the template to the default*/ $template = $defaults['template']; $templatePath = "./templates/invoices/{$template}/template.tpl"; $template_path = "../templates/invoices/{$template}"; $css = $siUrl . "/templates/invoices/{$template}/style.css"; $pluginsdir = "./templates/invoices/{$template}/plugins/"; //$smarty = new Smarty(); $smarty->plugins_dir = $pluginsdir; $pageActive = "invoices"; $smarty->assign('pageActive', $pageActive); if (file_exists($templatePath)) { //echo "test"; $smarty->assign('biller', $biller); $smarty->assign('customer', $customer); $smarty->assign('invoice', $invoice); $smarty->assign('invoice_number_of_taxes', $invoice_number_of_taxes); $smarty->assign('preference', $preference); $smarty->assign('logo', $logo); $smarty->assign('template', $template); $smarty->assign('invoiceItems', $invoiceItems); $smarty->assign('template_path', $template_path); $smarty->assign('css', $css); $smarty->assign('customFieldLabels', $customFieldLabels); $data = $smarty->fetch("." . $templatePath); } break; } return $data; }