<?php
/* $Id: index.php 6941 2014-10-26 23:18:08Z daintree $*/
error_reporting(E_ALL & ~E_NOTICE);
$PageSecurity=0;
//include('includes/DefineCustAllocsClass.php');
include('includes/session.inc');
$Title = _('Debtors Journa');
$ViewTopic= 'ARTransactions';
$BookMark = 'CustomerAllocations';
include('includes/newheader.php');
include('includes/SQL_CommonFunctions.inc');
$userid = $_SESSION['UserID'];

?>

		
  					
	<script src="angular/angular.min.js"></script>  
        
 
     
     
		

   
  
 									
									<?php
//this is where you paste. Below paste it:

echo '<div class="col-sm-12">';
		//echo '<div class="aflpanel" style="margin-bottom:10px">';
		
    include('xcrud/xcrud.php');
    $ebusiness = Xcrud::get_instance();
    $ebusiness->table('debtortrans');
	$ebusiness->table_name('Debtors Journal Entries');
   $ebusiness->where('type','15');

//$ebusiness->relation('bank','bankaccounts','accountcode',array('bankaccountnumber','bankaccountname'));
$ebusiness->relation('debtorno','debtorsmaster','debtorno',array('name','debtorno'));
//$ebusiness->relation('electronic_bank_details','bankaccounts','accountcode',array('bank_name','bankaccountnumber'));
$ebusiness->relation('account_number','debtoraccount','account_number',array('account_number','billing_name'),'','','','','','debtorno','debtorno'); 
	
$ebusiness->order_by('id','desc');
//$ebusiness->button('CancelReceipt.php?id={id}&transno={transno}', 'Cancel this Receipt','	glyphicon glyphicon-retweet','approve');
//$ebusiness->button('PDFReceipt.php?id={id}&transno={transno}', 'Print Receipt','glyphicon glyphicon-download-alt','westpac');
	//$ebusiness->button('CustomerAllocations.php?account={account_number}&debtorno={debtorno}&transno={transno}', 'Allocations','glyphicon glyphicon-list-alt','westpac');

//$ebusiness->button('PrintReceipt.php?id={id}&transno={transno}', 'Print-Thermal Printer','glyphicon glyphicon-download-alt','westpac');
$ebusiness->column_name('transno','Debtors Journal No:');
$ebusiness->column_name('debtorno','customer:');
$ebusiness->label('debtorno','customer:');
$ebusiness->column_name('inputdate','Date:');
$ebusiness->column_name('ovamount','Amount Paid:');
$ebusiness->label('transno','Debtors Journal No:');
//$ebusiness->label('manual_inv_number','Manual Receipt No:');
$ebusiness->label('ovamount','Amount(Positive for Debit Entry and Negative for Credit Entry)');
//$ebusiness->label('amount_tendered','Amount Tendered(Only for Cash Receipts/POS/Counter Receipts):');
$ebusiness->columns('id,transno,type,trandate,debtorno,account_number,ovamount,reference,entered_by,entered_date,notes');
$ebusiness->fields('id,transno,type,trandate,debtorno,account_number,ovamount,reference,entered_by,entered_date,notes');
$ebusiness->disabled('id,type');
	//$ebusiness->relation('oldglcode','oldglcode','oldglcode',array('name','oldglcode'),array('sub_category'=>'Net Trade Debtors'));
//	$ebusiness->change_type('payment_method','select','Cash','Cash,Cheque,EFPOS,Credit Card,Direct Deposit');
	
$ebusiness->unset_remove();
$ebusiness->unset_view();
//$ebusiness->unset_edit();
$userfullname = $_SESSION['UsersRealName'];
$ebusiness->pass_var('settled','0' );
$ebusiness->pass_var('entered_by',$userid );
$ebusiness->pass_var('type','15' );

$ebusiness->before_insert('addjournal','functiondebtorsjournal.php');
//$ebusiness->before_update('updatejournal','functiondebtorsjournal.php');
$ebusiness->button('PDFJournals.php?id={id}&transno={transno}', 'Print Journal Note','glyphicon glyphicon-download-alt','westpac');

	//$xcrud = $ebusiness->nested_table('Allocation','id','receipts_allocation_invoices','id'); 
	
	//$xcrud->relation('invoice_number','debtortrans','transno',array('account_number','reference','transno'),array('type' => '10','settled' => '0'));
	
	//$xcrud->before_insert('settleinvoice','functionreceipt.php');
//$xcrud->before_update('settleinvoice','functionreceipt.php');
	
//$ebusiness->unset_add();
    echo $ebusiness->render();
	
	

echo '</div>';
echo '</div>';



			  
 	echo '</div >';
	?>
						

		
					</div>
				</div>
			</div>
					
					

						<!--end:: Widgets/Stats-->

						<!--Begin::Section-->
						

		<!-- end::Quick Sidebar -->

		<!-- begin::Scroll Top -->
		<div id="m_scroll_top" class="m-scroll-top">
			<i class="la la-arrow-up"></i>
		</div>

		<!-- end::Scroll Top -->

		<!-- begin::Quick Nav -->
		

		<!-- begin::Quick Nav -->
<script src="includes/vendors/owl.carousel/dist/owl.carousel.js" type="text/javascript"></script>

		<!--end::Page Scripts -->
	</body>

	<!-- end::Body -->
</html>
 
      
<?php



/*The module link codes are hard coded in a switch statement below to determine the options to show for each tab */
include('includes/MainMenuLinksArray.php');

if (isset($SupplierLogin) AND $SupplierLogin==1){
	echo '<table class="table_index">
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=1">' . _('View or Amend outstanding offers') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=2">' . _('Create a new offer') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SupplierTenders.php?TenderType=3">' . _('View any open tenders without an offer') . '</a></p>
			</td>
			</tr>
		</table>';
	include('includes/footer.inc');
	exit;
} elseif (isset($CustomerLogin) AND $CustomerLogin==1){
	echo '<table class="table_index">
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/CustomerInquiry.php?CustomerID=' . $_SESSION['CustomerID'] . '">' . _('Account Status') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SelectOrderItems.php?NewOrder=Yes">' . _('Place An Order') . '</a></p>
			</td>
			</tr>
			<tr>
			<td class="menu_group_item">
				<p>&bull; <a href="' . $RootPath . '/SelectCompletedOrder.php?SelectedCustomer=' . $_SESSION['CustomerID'] . '">' . _('Order Status') . '</a></p>
			</td>
			</tr>
		</table>';

	include('includes/footer.inc');
	exit;
}

if (isset($_GET['Application'])){ /*This is sent by this page (to itself) when the user clicks on a tab */
	$_SESSION['Module'] = $_GET['Application'];
}








//include('includes/footer.inc');

function GetRptLinks($GroupID) {
/*
This function retrieves the reports given a certain group id as defined in /reports/admin/defaults.php
in the acssociative array $ReportGroups[]. It will fetch the reports belonging solely to the group
specified to create a list of links for insertion into a table to choose a report. Two table sections will
be generated, one for standard reports and the other for custom reports.
*/
	global $db, $RootPath, $ReportList;
	require_once('reportwriter/languages/en_US/reports.php');
	require_once('reportwriter/admin/defaults.php');
	$GroupID=$ReportList[$GroupID];
	$Title= array(_('Custom Reports'), _('Standard Reports and Forms'));

	$sql= "SELECT id,
				reporttype,
				defaultreport,
				groupname,
				reportname
			FROM reports
			ORDER BY groupname,
					reportname";
	$Result=DB_query($sql,'','',false,true);
	$ReportList = '';
	while ($Temp = DB_fetch_array($Result)) $ReportList[] = $Temp;

	$RptLinks = '';
	for ($Def=1; $Def>=0; $Def--) {
        $RptLinks .= '<li class="menu_group_headers">';
        $RptLinks .= '<b>' .  $Title[$Def] . '</b>';
        $RptLinks .= '</li>';
		$NoEntries = true;
		if ($ReportList) { // then there are reports to show, show by grouping
			foreach ($ReportList as $Report) {
				if ($Report['groupname']==$GroupID AND $Report['defaultreport']==$Def) {
                    $RptLinks .= '<li class="menu_group_item">';
					$RptLinks .= '<p>&bull; <a href="' . $RootPath . '/reportwriter/ReportMaker.php?action=go&amp;reportid=' . $Report['id'] . '">' . _($Report['reportname']) . '</a></p>';
					$RptLinks .= '</li>';
					$NoEntries = false;
				}
			}
			// now fetch the form groups that are a part of this group (List after reports)
			$NoForms = true;
			foreach ($ReportList as $Report) {
				$Group=explode(':',$Report['groupname']); // break into main group and form group array
				if ($NoForms AND $Group[0]==$GroupID AND $Report['reporttype']=='frm' AND $Report['defaultreport']==$Def) {
                    $RptLinks .= '<li class="menu_group_item">';
					$RptLinks .= '<img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/folders.gif" width="16" height="13" alt="" />&nbsp;';
					$RptLinks .= '<p>&bull; <a href="' . $RootPath . '/reportwriter/FormMaker.php?id=' . $Report['groupname'] . '"></p>';
					$RptLinks .= $FormGroups[$Report['groupname']] . '</a>';
					$RptLinks .= '</li>';
					$NoForms = false;
					$NoEntries = false;
				}
			}
		}
		if ($NoEntries) $RptLinks .= '<li class="menu_group_item">' . _('There are no reports to show!') . '</li>';
	}
	return $RptLinks;
}
	
?>
<!-- Modal HTML embedded directly into document -->
<div id="ex1" class="modal">
  <p>Thanks for clicking. That felt good.</p>
  <a href="#" rel="modal:close">Close</a>
</div>


<!-- Modal -->
 <div class="modal fade" id="getCodeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog modal-lg">
      <div class="modal-content">
       <div class="modal-header">
         <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
         <h4 class="modal-title" id="myModalLabel"> API CODE </h4>
       </div>
       <div class="modal-body" id="getCode" style="overflow-x: scroll;">
       
          
          
       </div>
    </div>
   </div>
 </div>



<script type="text/javascript">
	
	
	
	jQuery(document).ready(function($){

   // event must be delegated from .xcrud
	

$(".xcrud").on("change","#payment_method",function(){ // !important, delegation from static container
     
	var payment_method = $("#payment_method").val();

	var v = parseInt(1);
	var z = parseInt(0);
	
	if (payment_method == "EFPOS") {
		
		 
		$("#banked").val(v);
		
		$("#electronic_bank_date").show();
		$("#electronic_bank_details").show();
		$("#electronic_bank_date").prop('required',true);
	
		$("#electronic_bank_details").prop('required',true);
		$("#drawer_bank").hide();
		$("#drawer_accountnumber").hide();
		
			$("#drawer_chqnumber").hide();
		
		alert("Since you selected EFPOS, please note next 2 fields will be compulsory to fill");
	}
		else if (payment_method == "Credit Card") {
		
		 
		$("#banked").val(v);
				$("#electronic_bank_date").show();
		$("#electronic_bank_details").show();
	
			$("#electronic_bank_date").prop('required',true);
	
		$("#electronic_bank_details").prop('required',true);
				$("#drawer_bank").hide();
		$("#drawer_accountnumber").hide();
		
			$("#drawer_chqnumber").hide();
		alert("Since you selected Credit Card, please note next 2 fields will be compulsory to fill");
	}
		else if (payment_method == "Direct Deposit") {
		
		 
		$("#banked").val(v);
				$("#electronic_bank_date").show();
		$("#electronic_bank_details").show();
		$("#electronic_bank_date").prop('required',true);
			
	
		$("#electronic_bank_details").prop('required',true);
				$("#drawer_bank").hide();
		$("#drawer_accountnumber").hide();
		
			$("#drawer_chqnumber").hide();
		alert("Since you selected Direct Deposit, please note next 2 fields will be compulsory to fill");
		
	}

	
	else{
		
	$("#banked").val(z);
		
		$("#electronic_bank_date").prop('required',false);
	
		$("#electronic_bank_details").prop('required',false);
			$("#electronic_bank_date").hide();
		$("#electronic_bank_details").hide();
		
			$("#drawer_bank").show();
		$("#drawer_accountnumber").show();
		
			$("#drawer_chqnumber").show();
		
		
	}
	
	
	
   });
	
	
	
	
	
	
	
   }); 
jQuery(document).on("ready xcrudafterrequest",function(){
    
});
</script>