Jump to content

unset all variables


l0ve2hat3

Recommended Posts

lol u want to see the code?  yeah maybe u'll understand y

 

<?php
error_reporting(0);
ini_set(max_execution_time,999);


include("functions.php");


//check_posclient_login();

//declared Variables
$buy_back_text=$CONFIG[buy_back_text];
$gift_cert_text=$CONFIG[gift_cert_text];
$party_payment_text=$CONFIG[party_payment_text];
$cc_credit_text=$CONFIG[cc_credit_text];

$additional_discounts=$CONFIG[additional_discounts];
$additional_comps=$CONFIG[additional_comps];

$exceptions_reasons[1]=$CONFIG[exceptions_reasons][1];
$exceptions_reasons[2]=$CONFIG[exceptions_reasons][2];
$exceptions_reasons[3]=$CONFIG[exceptions_reasons][3];
$exceptions_reasons[4]=$CONFIG[exceptions_reasons][4];


//company name
$sql1='SELECT [Company_Info_1] FROM [setup]';
$template['company_name']=mssql_result(mssql_query($sql1),0,0);



//for($p=1;$p<=3;$p++{

////////////////
//START END TIME
$TIMEsql='SELECT TOP 100 * FROM [End_Of_Day] ORDER BY [EndDateTime] DESC';
$TIMEres=mssql_query($TIMEsql);
while($TIMErow=mssql_fetch_assoc($TIMEres)){
    $i++;
    if($i==1&&$_GET[index]=='')$_GET[index]=$TIMErow['Close_Out_Index'];
$template['select'].='<OPTION value="'.$TIMErow['Close_Out_Index'].'">'.$TIMErow['StartDateTime'].' - '.$TIMErow['EndDateTime'].'</OPTION>';
}

$TIMEsql="SELECT * FROM [End_Of_Day] WHERE [Close_Out_Index]='$_GET[index]'";
$TIMEres=mssql_query($TIMEsql);
$TIMErow=mssql_fetch_assoc($TIMEres);

$shift_start=$TIMErow['StartDateTime'];
$shift_end=$TIMErow['EndDateTime'];

$template['from_period']=$shift_start;
$template['to_period']=$shift_end;
$template['to_period_day']=date('l',strtotime($shift_end));
//END START END TIME
////////////////////


    $where='DateTime >= \''.$shift_start.'\' AND DateTime <= \''.$shift_end.'\'';


    //General Totals And Money Track
    $sql_numbers='SELECT * FROM [invoice_Totals] WHERE '.$where.' ORDER BY [invoice_Number] ASC';
    $res_numbers=mssql_query($sql_numbers)or die($sql_numbers."<br>".mssql_get_last_message().": $sql_numbers");

    while($row_numbers=mssql_fetch_assoc($res_numbers)){

    	//only do also this stuff if it's not voided
    	if($row_numbers['Status']!="V"){
    		//General Totals
    		$template['var13']+=$row_numbers['Total_Price'];
    		$template['var14']+=$row_numbers['Total_Tax1'] + $row_numbers['Total_Tax2'] + $row_numbers['Total_Tax3'];
    		$template['var15']+=$row_numbers['Grand_Total'];


            ////TESTING ONLY
            $row_numbers['Cashier_ID']=($row_numbers['Cashier_ID']=='')?'NO CASHIER ID ON INVOICE':$row_numbers['Cashier_ID'];
    //        $empTOTAL[$row_numbers[Cashier_ID]][Total_Price]+=$row_numbers['Total_Price'];
    //        $empTOTAL[$row_numbers[Cashier_ID]][CA_Amount]+=$row_numbers['CA_Amount'];
    //        $empTOTAL[$row_numbers[Cashier_ID]][Total_Tax]+=$row_numbers['Total_Tax1'] + $row_numbers['Total_Tax2'] + $row_numbers['Total_Tax3'];
    //        $empTOTAL[$row_numbers[Cashier_ID]][Grand_Total]+=$row_numbers['Grand_Total'];
    //        $empTOTAL[$row_numbers[Cashier_ID]][Cashier_ID]=$row_numbers['Cashier_ID'];
              $empTOTAL[$row_numbers[Cashier_ID]]+=$row_numbers['CA_Amount'];



    		//total checks
    		$template['var55']++;

    		//total guests
    		$template['var56']+=$row_numbers['Num_People_Party'];

            if($row_numbers['Acc_Balance_due']>0){
                $template['checks_outstanding_num']++;
                $template['checks_outstanding']+=$row_numbers['Acc_Balance_due'];
            }else{
                $template['checks_outstanding_num']+=0;
                $template['checks_outstanding']+=0;
            }



    		//Money Track - Cash
    		if($row_numbers['CA_Amount']>0){
    			$template['var16']++;
    			$template['var17']+=$row_numbers['CA_Amount'];
    		}

    		if($row_numbers['Payment_Method']=="CA"){
    			//Money Track - Applied Gratuity Part 1
    			if($row_numbers['Tip_Amount']>0){
    				$template['var21']++;
    				$template['var22']+=$row_numbers['Tip_Amount'];
    			}
    		}
    		if($row_numbers['Payment_Method']=="ST" || $row_numbers['Payment_Method']=="CC"){
    			//Money Track - CC Tips + Applied Gratuity
    			$sub_amount_sum=0;
    			$sql_sub_tip='SELECT * From [CC_Trans] WHERE [CRENumber] ='.$row_numbers['Invoice_Number'];
    			$sub_tip_res=mssql_query($sql_sub_tip);

    			while($sub_tip_row=mssql_fetch_assoc($sub_tip_res)){
    				//Money Track - CC Tips
    				if($sub_tip_row['TipAmount']>0){
    					$template['var19']++;
    					$template['var18']+=$sub_tip_row['TipAmount'];
    					//old applied grat
    					//$sub_tip_sum+=$sub_tip_row['TipAmount'];
    				}

    				//new applied grat
    				$sub_amount_sum+=$sub_tip_row['Amount'];

    				//Payment Breakdown For CC Array Fill
    				$cc_breakdown[$sub_tip_row['Type']]['count']++;
    				$cc_breakdown[$sub_tip_row['Type']]['sum']+=$sub_tip_row['TipAmount']+$sub_tip_row['Amount'];
    				$cc_breakdown['ALL']['count']++;
    				$cc_breakdown['ALL']['sum']+=$sub_tip_row['TipAmount']+$sub_tip_row['Amount'];

    				//Credit Cards Itemized
    				if($count_cc++%2==1) $bgcolor_cc='white';
    				else $bgcolor_cc='lightgray';
    				$template['cc_itemized'].='<TR style="background-color:'.$bgcolor_cc.'"><TD align=center>'.$sub_tip_row['Type'].'</TD><TD align=center>'.substr($sub_tip_row['Number'],-4).'</TD><TD align=center>$'.number_format($sub_tip_row['Amount'],2,'.','').'</TD><TD align=center>$'.number_format($sub_tip_row['TipAmount'],2,'.','').'</TD><TD align=center>$'.number_format($sub_tip_row['TipAmount']+$sub_tip_row['Amount'],2,'.','').'</TD><TD align=center>'.$row_numbers['Invoice_Number'].'</TD></TR>';
    			}

    			//Money Track - Applied Gratuity Part 2

    			//old applied grat
    			//$sub_applied=$row_numbers['Tip_Amount']-$sub_tip_sum;
    			//new applied grat
    			$sub_applied=$sub_amount_sum-($row_numbers['Grand_Total']-$row_numbers['Amt_Tendered']+$row_numbers['Amt_Change']);
    			if($sub_applied>0){
    				$template['var21']++;
    				$template['var22']+=$sub_applied;
    			}

    		}
    		if($row_numbers['Payment_Method']=="ST" || $row_numbers['Payment_Method']=="CH"){
    			//Payment Breakdown For Gift Certificates
    			$sql_sub_gc='SELECT SUM([Amount]) AS [sum], COUNT([Amount]) AS [count] From [CH_Trans] WHERE [Trans_Number] ='.$row_numbers['Invoice_Number'];
    			$sub_gc_row=mssql_fetch_assoc(mssql_query($sql_sub_gc));
    			$template['var36']+=$sub_gc_row['count'];
    			$template['var37']+=$sub_gc_row['sum'];
    		}

    		//Invoice Exceptions
    		$sql_exceptions='SELECT * FROM [invoice_Exceptions] LEFT JOIN [inventory] ON [invoice_Exceptions].[itemNum]=[inventory].[itemNum] WHERE [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$exceptions_res=mssql_query($sql_exceptions);
    		while($exceptions_row=mssql_fetch_assoc($exceptions_res)){
    			if($exceptions_row['Amount']>0){
    				if($exceptions_row['Exception_Type']==2 && $exceptions_row['Reason_Code']==$buy_back_text){
    					$exceptions_row['Exception_Type']=4;
    				}
    				$exceptions_breakdown[$exceptions_row['Exception_Type']]['count']++;
    				$exceptions_breakdown[$exceptions_row['Exception_Type']]['sum']+=$exceptions_row['Amount'];
    				$exceptions_row['ItemName']=substr($exceptions_row['ItemName'],0,20);
    				$exceptions_row['Reason_Code']=substr($exceptions_row['Reason_Code'],0,20);
    				$exceptions_row['Reason_Code']=substr($exceptions_row['Reason_Code'],0,20);
    				if($exceptions_row['Exception_Type']==3){
    					$row_discount=($exceptions_row['Amount']/$exceptions_row['Price'])*100;
    					$discount_disp=' ('.$row_discount.'%)';
    				}
    				if($count_exceptions++%2==1) $bgcolor_exceptions='white';
    				else $bgcolor_exceptions='lightgray';
    				$template['exceptions_itemized'].='<TR style="background-color:'.$bgcolor_exceptions.'"><TD align=center>'.$exceptions_reasons[$exceptions_row['Exception_Type']].'</TD><TD align=center>'.$exceptions_row['ItemName'].'</TD><TD align=center>$'.number_format($exceptions_row['Amount'],2,'.','').' '.$discount_disp.'</TD><TD align=center>'.$exceptions_row['Reason_Code'].'</TD><TD align=center>'.$exceptions_row['Invoice_Number'].'</TD></TR>';
    			}
    		}

    		//additional discounts
    		$additional_discounts_string='';
    		foreach($additional_discounts as $additional_discount){
    			$additional_discounts_string.='OR [itemNum] = \''.$additional_discount.'\'';
    		}
    		$additional_discounts_string='('.substr($additional_discounts_string,3).') AND';
    		$sql_additional_discounts='SELECT * FROM [invoice_Itemized] WHERE '.$additional_discounts_string.' [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$additional_discounts_res=mssql_query($sql_additional_discounts);
    		while($additional_discounts_row=mssql_fetch_assoc($additional_discounts_res)){
    			$additional_discounts_row['PricePer']=abs($additional_discounts_row['PricePer']);
    			$template['var49']++;
    			$template['var50']+=$additional_discounts_row['PricePer'];
    			if($count_exceptions++%2==1) $bgcolor_exceptions='white';
    			else $bgcolor_exceptions='lightgray';
    			$template['exceptions_itemized'].='<TR style="background-color:'.$bgcolor_exceptions.'"><TD align=center>Discount</TD><TD align=center>Entire Check</TD><TD align=center>$'.number_format($additional_discounts_row['PricePer'],2,'.','').'</TD><TD align=center>'.$additional_discounts_row['ItemNum'].'</TD><TD align=center>'.$additional_discounts_row['Invoice_Number'].'</TD></TR>';
    		}

    		//additional comps
    		$additional_comps_string='';
    		foreach($additional_comps as $additional_comp){
    			$additional_comps_string.='OR [itemNum] = \''.$additional_comp.'\'';
    		}
    		$additional_comps_string='('.substr($additional_comps_string,3).') AND';
    		$sql_additional_comps='SELECT * FROM [invoice_Itemized] WHERE '.$additional_comps_string.' [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$additional_comps_res=mssql_query($sql_additional_comps);
    		while($additional_comps_row=mssql_fetch_assoc($additional_comps_res)){
    			$additional_comps_row['PricePer']=abs($additional_comps_row['PricePer']);
    			$template['var47']++;
    			$template['var48']+=$additional_comps_row['PricePer'];
    			if($count_exceptions++%2==1) $bgcolor_exceptions='white';
    			else $bgcolor_exceptions='lightgray';
    			$template['exceptions_itemized'].='<TR style="background-color:'.$bgcolor_exceptions.'"><TD align=center>Comp</TD><TD align=center>Entire Check</TD><TD align=center>$'.number_format($additional_comps_row['PricePer'],2,'.','').'</TD><TD align=center>'.$additional_comps_row['ItemNum'].'</TD><TD align=center>'.$additional_comps_row['Invoice_Number'].'</TD></TR>';
    		}

    		//Gift Card Payments
    		$sql_gc_sales='SELECT * FROM [Gift_Card_Trans] WHERE [TransType]=1 AND [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$gc_sales_res=mssql_query($sql_gc_sales);
    		while($gc_sales_row=mssql_fetch_assoc($gc_sales_res)){
    			$template['var38']++;
    			$template['var39']+=(-1*$gc_sales_row['Amt']);
    		}

    		//Gift Certificates Sold!
    		$sql_gcert_sales1='SELECT SUM([Quantity]*[PricePer]) as [sum],COUNT(*) as [count] FROM [invoice_Itemized] WHERE [itemNum] = \''.$gift_cert_text.'\' AND [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$gcert_sales_row1=mssql_fetch_assoc(mssql_query($sql_gcert_sales1));
    		$template['var53']+=$gcert_sales_row1['count'];
    		$template['var54']+=$gcert_sales_row1['sum'];

    		//Party Payments!
    		$sql_gcert_sales2='SELECT SUM([Quantity]*[PricePer]) as [sum],COUNT(*) as [count] FROM [invoice_Itemized] WHERE [itemNum] = \''.$cc_credit_text.'\' AND [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$gcert_sales_row2=mssql_fetch_assoc(mssql_query($sql_gcert_sales2));
    		$template['var95']+=$gcert_sales_row2['count'];
    		$template['var96']+=$gcert_sales_row2['sum'];

    		//Credit Card Credits!
    		$sql_gcert_sales3='SELECT SUM([Quantity]*[PricePer]) as [sum],COUNT(*) as [count] FROM [invoice_Itemized] WHERE [itemNum] = \''.$party_payment_text.'\' AND [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$gcert_sales_row3=mssql_fetch_assoc(mssql_query($sql_gcert_sales3));
    		$template['var97']+=$gcert_sales_row3['count'];
    		$template['var98']+=$gcert_sales_row3['sum'];

    		//Gift Cards Sold!
    		$sql_gc_sales4='SELECT SUM([Quantity]*[GC_Sold]) as [sum],COUNT(*) as [count] FROM [invoice_Itemized] WHERE [itemNum] = \'GIFT_C\' AND [invoice_Number] ='.$row_numbers['Invoice_Number'];
    		$gc_sales_row4=mssql_fetch_assoc(mssql_query($sql_gc_sales4));
    		$template['var42']+=$gc_sales_row4['sum'];
    		$template['var43']+=$gc_sales_row4['count'];


            //////////////////////
            /////CATEGORY TOTALS//
            //////////////////////
            $Invoice_Number=$row_numbers['Invoice_Number'];

            $sql_cat="SELECT [invoice_Totals].[invoice_Number],[invoice_Totals].[Discount],[invoice_Itemized].[itemNum],[invoice_Itemized].[Quantity],[invoice_Itemized].[PricePer],[invoice_Itemized].[Tax1Per],[inventory].[Dept_ID],[Departments].[subType],[Categories].[Description]  FROM [invoice_Totals] LEFT JOIN [invoice_Itemized] on [invoice_Itemized].[invoice_Number]=[invoice_Totals].[invoice_Number] LEFT JOIN [inventory] on [inventory].[itemNum]=[invoice_Itemized].[itemNum] LEFT JOIN [Departments] on [Departments].[Dept_ID]=[inventory].[Dept_ID] LEFT JOIN [Categories] on [Categories].[Cat_ID]=[Departments].[subType] WHERE [invoice_Totals].[invoice_Number]='$Invoice_Number'";
            $result_cat=mssql_query($sql_cat) or die("error: <br>$sql_cat: <br>".mssql_get_last_message());
            while($row_cat=mssql_fetch_array($result_cat)){
                $tracking[$row_cat['Description']]['name']=$row_cat['Description'];
                $tracking[$row_cat['Description']]['quantity']+=$row_cat['Quantity'];
                $tracking[$row_cat['Description']]['price']+=number_format((1-$row_cat['Discount'])*$row_cat['PricePer']*$row_cat['Quantity'],2,'.','');
            }
             ///////////////////////
            //END CATEGORY TOTALS//
            ///////////////////////

            ///////////////////////
            ///BREAK DOWN TOTALS///
            ///////////////////////


            //BAR TOTALS
            if(in_array($row_numbers['Station_ID'],$CONFIG[bar])&&$row_numbers['InvType']=='0'){
                //SALES
                $template['2_bar_checks']++;
                $template['2_bar_net_sales']+=$row_numbers['Total_Price'];
                //GIFT cert/cards
                $template['3_bar_giftcert_redeemed_total']+=$gcert_sales_row1['sum'];
                $template['3_bar_giftcert_redeemed_count']+=$gcert_sales_row1['count'];
                $template['3_bar_giftcard_redeemed_total']+=$gc_sales_row['sum'];
                $template['3_bar_giftcard_redeemed_count']+=$gc_sales_row['count'];
            }else{
                $template['2_bar_checks']+=0;
            }
            //TOGO TOTALS
            if($row_numbers['InvType']>0){
                //SALES
                $template['2_togo_checks']++;
                $template['2_togo_net_sales']+=$row_numbers['Total_Price'];
                //GIFT CARDS
                $template['3_togo_giftcert_redeemed_total']+=$gcert_sales_row1['sum'];
                $template['3_togo_giftcert_redeemed_count']+=$gcert_sales_row1['count'];
                $template['3_togo_giftcard_redeemed_total']+=$gc_sales_row['sum'];
                $template['3_togo_giftcard_redeemed_count']+=$gc_sales_row['count'];
            }else{
                $template['2_togo_checks']+=0;
            }
            //DINING TOTALS
            if(!in_array($row_numbers['Station_ID'],$CONFIG[bar])&&$row_numbers['InvType']=='0'){
                //SALES
                $template['2_dining_checks']++;
                $template['2_dining_guests']+=$row_numbers['Num_People_Party'];
                $template['2_dining_net_sales']+=$row_numbers['Total_Price'];
                //GIFT CARDS
                $template['3_dining_giftcert_redeemed_total']+=$gcert_sales_row1['sum'];
                $template['3_dining_giftcert_redeemed_count']+=$gcert_sales_row1['count'];
                $template['3_dining_giftcard_redeemed_total']+=$gc_sales_row['sum'];
                $template['3_dining_giftcard_redeemed_count']+=$gc_sales_row['count'];
            }else{
                $template['2_dining_checks']+=0;
                $template['2_dining_guests']+=0;
            }

            ///////////////////////////
            ///END BREAK DOWN TOTALS///
            ///////////////////////////


    	} else {

    		//add the voided check to the exceptions table
    		$template['var91']++;
    		$template['var92']+=$row_numbers['Total_Price'];
    		if($count_exceptions++%2==1) $bgcolor_exceptions='white';
    		else $bgcolor_exceptions='lightgray';
    		$template['exceptions_itemized'].='<TR style="background-color:'.$bgcolor_exceptions.'"><TD align=center>Check Void</TD><TD align=center>Entire Check</TD><TD align=center>$'.number_format($row_numbers['Total_Price'],2,'.','').'</TD><TD align=center>***</TD><TD align=center>'.$row_numbers['Invoice_Number'].'</TD></TR>';
    	}
    }
    //////////////////////
    /////CATEGORY TOTALS//
    //////////////////////
    foreach($tracking as $Description){
        $quantTotal+=$Description['quantity'];
        $priceTotal+=$Description['price'];

        $template['cat_table'].='<tr><td NOWRAP align=left">'.$Description['name'].'</td><td NOWRAP align=right>'.$Description['quantity'].'</td><td NOWRAP align=right>'.number_format($Description['price'],2,'.','').'</td></tr>';
    }
    $template['cat_table'].='<tr><td NOWRAP align=right style="font-weight:bold;border-top: 2px solid black;">Sub Total</td><td NOWRAP style="font-weight:bold;border-top: 2px solid black;" align=right>'.$quantTotal.'</td><td NOWRAP style="font-weight:bold;border-top: 2px solid black;" align=right>'.number_format($priceTotal,2,'.','').'</td></tr>';
    //////////////////////////
    /////END CATEGORY TOTALS//
    //////////////////////////
    //Money Track - Payouts
    $sql_payouts='SELECT * From [Payouts] WHERE DateTime >= \''.$shift_start.'\' AND DateTime <= \''.$shift_end.'\' AND [Cashier_ID]='.$template['var6'];
    $payouts_res=mssql_query($sql_payouts);
    while($payouts_row=mssql_fetch_assoc($payouts_res)){
    	$template['var23']++;
    	$template['var24']+=$payouts_row['Amount'];
    	if($count_payouts++%2==1) $bgcolor_payouts='white';
    	else $bgcolor_payouts='lightgray';
    	$template['payout_itemized'].='<TR style="background-color:'.$bgcolor_payouts.'"><TD align=center>$'.number_format($payouts_row['Amount'],2,'.','').'</TD><TD align=center>'.$payouts_row['Vendor_Number'].'</TD><TD align=center>'.$payouts_row['Description'].'</TD></TR>';
    }

    //fix CC tips
    $template['var18']=number_format($template['var18'],2,'.','');
    $template['var20']=number_format($template['var18'] *1,2,'.','');

    //Money Track - Owe Outs
    $template['var25']=$template['var17'] + $template['var59'] - $template['var20'] - $template['var22'] - $template['var24'];
    if($template['var25']<0){
    	$template['owe_statement']=$template['var1'].' Owes '.$template['var5'];
    	$template['owe_coupon_start']='';
    	$template['owe_coupon_end']='';
    } else {
    	$template['owe_statement']=$template['var5'].' Owes '.$template['var1'];
    	$template['owe_coupon_start']='<!--';
    	$template['owe_coupon_end']='-->';
    }

    $template['var25']=number_format(abs($template['var25']),2,'.','');

    //Payment Breakdown By CC Extraction
    $template['var26']=$cc_breakdown['Visa']['count']+0;
    $template['var27']=number_format($cc_breakdown['Visa']['sum'],2,'.','');
    $template['var28']=$cc_breakdown['MC']['count']+0;
    $template['var29']=number_format($cc_breakdown['MC']['sum'],2,'.','');
    $template['var30']=$cc_breakdown['Amex']['count']+0;
    $template['var31']=number_format($cc_breakdown['Amex']['sum'],2,'.','');
    $template['var32']=$cc_breakdown['Dine']['count']+0;
    $template['var33']=number_format($cc_breakdown['Dine']['sum'],2,'.','');
    $template['var87']=$cc_breakdown['Disc']['count']+0;
    $template['var88']=number_format($cc_breakdown['Disc']['sum'],2,'.','');
    $template['var89']=$cc_breakdown['Othr']['count']+0;
    $template['var90']=number_format($cc_breakdown['Othr']['sum'],2,'.','');
    $template['var34']=$cc_breakdown['ALL']['count']+0;
    $template['var35']=number_format($cc_breakdown['ALL']['sum'],2,'.','');

    //Invoice Exception Breakdown
    $template['var45']=$exceptions_breakdown[1]['count']+0;
    $template['var46']=number_format($exceptions_breakdown[1]['sum'],2,'.','');
    $template['var47']=$template['var47'] + $exceptions_breakdown[2]['count']+0;
    $template['var48']=number_format($template['var48'] + $exceptions_breakdown[2]['sum'],2,'.','');
    $template['var49']=$template['var49'] + $exceptions_breakdown[3]['count']+0;
    $template['var50']=number_format($template['var50'] + $exceptions_breakdown[3]['sum'],2,'.','');
    $template['var51']=$exceptions_breakdown[4]['count']+0;
    $template['var52']=number_format($exceptions_breakdown[4]['sum'],2,'.','');


    //Format Numbers
    $template['var13']=number_format($template['var13']-$template['var54'],2,'.','');
    $template['var14']=number_format($template['var14'],2,'.','');
    $template['var15']=number_format($template['var15']-$template['var42']-$template['var54'],2,'.','');
    $template['var16']=$template['var16']+0;
    $template['var17']=number_format($template['var17'],2,'.','');
    $template['var19']=$template['var19']+0;
    $template['var20']=number_format($template['var20'],2,'.','');
    $template['var21']=$template['var21']+0;
    $template['var22']=number_format($template['var22'],2,'.','');
    $template['var23']=$template['var23']+0;
    $template['var24']=number_format($template['var24'],2,'.','');
    $template['var25']=number_format($template['var25'],2,'.','');
    $template['var36']=$template['var36']+0;
    $template['var37']=number_format($template['var37'],2,'.','');
    $template['var38']=$template['var38']+0;
    $template['var39']=number_format($template['var39'],2,'.','');
    $template['var40']=$template['var36']+$template['var38']+0;
    $template['var41']=number_format($template['var37']+$template['var39'],2,'.','');
    $template['var42']=number_format($template['var42'],2,'.','');
    $template['var43']=$template['var43']+0;
    $template['var53']=$template['var53']+0;
    $template['var54']=number_format($template['var54'],2,'.','');
    $template['var55']=$template['var55']+0;
    $template['var56']=$template['var56']+0;
    $template['var57']=number_format($template['var13']/$template['var56'],2,'.','');
    $template['var58']=number_format($template['var13']/$template['var55'],2,'.','');
    $template['var59']=number_format($template['var59'],2,'.','');
    $template['var60']=number_format($template['var59']+$template['var17']-$template['var24'],2,'.','');
    $template['var85']=number_format($template['var85'],2,'.','');
    $template['var86']=$template['var85']-$template['var60'];
    $template['var91']=$template['var91']+0;
    $template['var92']=number_format($template['var92'],2,'.','');
    $predisc_net=$template['var13']+$template['var48']+$template['var50']+$template['var52'];
    $template['var93']=number_format($predisc_net/$template['var56'],2,'.','');
    $template['var94']=number_format($predisc_net/$template['var55'],2,'.','');
    $template['var95']=$template['var95']+0;
    $template['var96']=number_format($template['var96'],2,'.','');
    $template['var97']=$template['var97']+0;
    $template['var98']=number_format($template['var98'],2,'.','');
    $template['var001']=number_format($template['var60']-$template['var59'],2,'.','');

    //do over under statement
    if($template['var86']>0){
    	$template['over_under_statement']='Drawer Over By';
    	$template['drawer_under_show_start']='<!--';
    	$template['drawer_under_show_end']='-->';
    } else {
    	$template['over_under_statement']='Drawer Under By';
    	$template['drawer_under_show_start']='';
    	$template['drawer_under_show_end']='';
    }

    if($row63to84['ID']!=$_GET['id']){
    	$template['drawer_under_show_start']='';
    	$template['drawer_under_show_end']='';
    }

    $template['var86']=number_format(abs($template['var86']),2,'.','');

    //force replacements
    $template['cc_itemized']=$template['cc_itemized'];
    $template['exceptions_itemized']=$template['exceptions_itemized'];
    $template['payout_itemized']=$template['payout_itemized'];


    //MAKE TEMPLATE FIELDS
    $template['net_sales']=$template['var13'];
    $template['service_charge']=number_format($template['var20']+$template['var22'],2,'.','');
    $template['tax_collected']=number_format($template['var14'],2,'.','');
    $template['total_revenue']=number_format($template['tax_collected']+$template['service_charge']+$template['var13'],2,'.','');
    $template['item_discount']=$template['var50'];
    $template['subtotal_discount']='0.00';
    $template['total_discount']=number_format($template['subtotal_discount']+$template['item_discount'],2,'.','');
    $template['voids_num']=$template['var91'];
    $template['voids']=$template['var92'];
    $template['checks_num']=$template['var55'];
    $template['checks']=$template['total_revenue'];
    $template['checks_paid_num']=$template['checks_num']-$template['checks_outstanding_num'];
    $template['checks_paid']=number_format($template['checks']-$template['checks_outstanding'],2,'.','');
    $template['checks_outstanding']=number_format($template['checks_outstanding'],2,'.','');
    $template['gross_receipts']=$template['var17'];
    $template['charged_receipts']='0.00';
    $template['service_charges']=$template['var22'];
    $template['charged_tips']=number_format($template['var20'],2,'.','');
    $template['cash_tips_dec']='0.00';
    $template['indirect_tips_dec']='0.00';
    $template['total_tips']=$template['service_charge'];
    $template['total_tips_percent']=number_format(($template['total_tips']/$template['gross_receipts'])*100,2,'.','');
    $template['var56']=$template['2_togo_guests']+$template['2_dining_guests'];




    $template['2_dining_net_sales']=number_format($template['2_dining_net_sales']-$template['3_dining_giftcert_redeemed_total'],2,'.','');
    $template['2_dining_net_sales_percent']=number_format(($template['2_dining_net_sales']/$template['var13'])*100,2,'.','');
    $template['2_dining_guests_percent']=number_format(($template['2_dining_guests']/$template['var56'])*100,2,'.','');
    $template['2_dining_guests_average']=number_format($template['2_dining_net_sales']/$template['2_dining_guests'],2,'.','');
    $template['2_dining_checks_percent']=number_format(($template['2_dining_checks']/$template['var55'])*100,2,'.','');
    $template['2_dining_checks_average']=number_format($template['2_dining_net_sales']/$template['2_dining_checks'],2,'.','');
    $template['2_dining_tables']=$template['2_dining_checks'];
    $template['2_dining_tables_percent']=number_format(($template['2_dining_tables']/$template['var55'])*100,2,'.','');
    $template['2_dining_tables_average']=number_format($template['2_dining_net_sales']/$template['2_dining_tables'],2,'.','');

    $template['2_bar_net_sales']=number_format($template['2_bar_net_sales']-$template['3_bar_giftcert_redeemed_total'],2,'.','');
    $template['2_bar_net_sales_percent']=number_format(($template['2_bar_net_sales']/$template['var13'])*100,2,'.','');
    $template['2_bar_guests']=0;
    $template['2_bar_guests_percent']=number_format(0,2,'.','');
    $template['2_bar_guests_average']=number_format(0,2,'.','');
    $template['2_bar_checks_percent']=number_format(($template['2_bar_checks']/$template['var55'])*100,2,'.','');
    $template['2_bar_checks_average']=number_format($template['2_bar_net_sales']/$template['2_bar_checks'],2,'.','');
    $template['2_bar_tables']=0;
    $template['2_bar_tables_percent']=number_format(0,2,'.','');
    $template['2_bar_tables_average']=number_format(0,2,'.','');

    $template['2_togo_net_sales']=number_format($template['2_togo_net_sales']-$template['3_togo_giftcert_redeemed_total'],2,'.','');
    $template['2_togo_net_sales_percent']=number_format(($template['2_togo_net_sales']/$template['var13'])*100,2,'.','');
    $template['2_togo_guests']=0;
    $template['2_togo_guests_percent']=number_format(($template['2_togo_guests']/$template['var56'])*100,2,'.','');
    $template['2_togo_guests_average']=number_format($template['2_togo_net_sales']/$template['2_togo_guests'],2,'.','');
    $template['2_togo_checks_percent']=number_format(($template['2_togo_checks']/$template['var55'])*100,2,'.','');
    $template['2_togo_checks_average']=number_format($template['2_togo_net_sales']/$template['2_togo_checks'],2,'.','');
    $template['2_togo_tables']=0;
    $template['2_togo_tables_percent']=number_format(0,2,'.','');
    $template['2_togo_tables_average']=number_format(0,2,'.','');

    $template['2_total_net_sales']=number_format($template['2_togo_net_sales']+$template['2_bar_net_sales']+$template['2_dining_net_sales'],2,'.','');
    $template['2_total_guests']=$template['var56'];
    $template['2_total_checks']=$template['var55'];
    $template['2_total_tables']=$template['2_dining_tables'];

    $template['priceTotal-var54']=number_format($priceTotal-$template['var54'],2,'.','');

    $template['service_charge_num']=$template['var19']+$template['var21'];
    $template['cash_due_num']=$template['var16']+$template['service_charge_num']+$template['var23'];
    $template['cash_due']=number_format($template['var17']-($template['service_charge']-$template['var24']),2,'.','');
    $template['cards_total']=number_format($template['var27']+$template['var29']+$template['var31']+$template['var33'],2,'.','');
    $template['cards_total_num']=$template['var26']+$template['var28']+$template['var30']+$template['var32']+$template['var88']+$template['var90'];

    $i++;

/*
    $template['test']= "CASH: ".$template['var17']."  CREDIT: ".$template['var35']."  CCTIP: ".$template['var20']." TOTAL: ".$template['var15']."   :: ".($template['var15']-$template['var35']-$template['var17']-$template['var20']);

    $template['empTOTAL']="<table width=5 border=1 style='border-collapse: collapse;'><tr><td NOWRAP>Employee Name</td><td NOWRAP>ID</td><td NOWRAP>Cash</td><td NOWRAP>Credit</td><td NOWRAP>Tax</td><td NOWRAP>Total</td></tr>";
    foreach($empTOTAL as $emp=>$val){
        foreach ($key as $emp){
            $empSQL='SELECT [EmpName] FROM [Employee] WHERE Cashier_ID=\''.$emp.'\'';
            $name=mssql_result(mssql_query($empSQL),0,0);
            $template['empTOTAL'].="<tr><td NOWRAP>$name</td><td NOWRAP>$emp</td><td NOWRAP>$val</td><td NOWRAP></td><td NOWRAP>$emp[Total_Tax]</td><td NOWRAP>$emp[Grand_Total]</td></tr>";
            $grandCASH+=$;
            $grandTAX+=$;
            $grandCC+=$;
            $grandTOTAL+=$;
        }
    }
    $template['empTOTAL'].="<tr><td colspan=2>GRAND TOTAL</td><td NOWRAP>$grandTOTAL</td></tr>";
    $template['empTOTAL'].="</table>";
*/





$template[todays_datetime]=date('l, F j, Y - g:iA');
$template[logged_username]=$_SESSION[posclient_firstname];

$fcontents=get_page($template_file,$CONFIG[customer_name]." Administration Page","templates/html_print_template.html",$_GET[msg]);
echo parse_template($template,$fcontents);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.