Frontaccounting Handle Attachments - Kvcodes
X

Congrats, You are Subscribed to Receive Updates.

Frontaccounting Handle Attachments


Frontaccounting Handle Attachments . Handling attachment is important function, while handling custom attachments and custom image handling, may be you can extend it to store customer profile picture and informations. Let’s start writing your custom Upload handler function. Lets begin with necessary inclusions.

<?php
/**********************************************************************
 AuthoR : Kvvaradha
 
 Work : Upload Customization
 
Date: 28-07-2914

File: custom_uploads.php
 
***********************************************************************/
$path_to_root="..";
$page_security = 'KV_CUSTOM_UPLOAD';

include_once($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/admin/db/attachments_db.inc");

and now, We need to use the following code to show the existing customer image.

if (isset($_GET['vw']))
	$view_id = $_GET['vw'];
else
	$view_id = find_submit('view');

we need form to handle the uploaded file,

if ($view_id != -1)
{
	$row = get_attachment($view_id);
	if ($row['filename'] != "")
	{
		if(in_ajax()) {
			$Ajax->popup($_SERVER['PHP_SELF'].'?vw='.$view_id);
		} else {
			$type = ($row['filetype']) ? $row['filetype'] : 'application/octet-stream';	
    		header("Content-type: ".$type);
    		header('Content-Length: '.$row['filesize']);
	    	//if ($type == 'application/octet-stream')
    		//	header('Content-Disposition: attachment; filename='.$row['filename']);
    		//else
	 			header("Content-Disposition: inline");
	    	echo file_get_contents(company_path(). "/attachments/".$row['unique_name']);
    		exit();
		}
	}	
}

And here is our page title.

page(_($help_context = "Attach Documents"), false, false, "", $js);

 

start_form(true);

viewing_controls();

start_table(TABLESTYLE2);
if ($selected_id != -1)
{
	if ($Mode == 'Edit')
	{
		$row = get_attachment($selected_id);
		$_POST['trans_no']  = $row["trans_no"];
		$_POST['description']  = $row["description"];
		hidden('trans_no', $row['trans_no']);
		hidden('unique_name', $row['unique_name']);
		label_row(_("Transaction #"), $row['trans_no']);
	}	
	hidden('selected_id', $selected_id);
}

file_row(_("Attached File") . ":", 'filename', 'filename');  //shows image chooser 

end_table(1);

submit_add_or_update_center($selected_id == -1, '', 'process');

end_form();

 

 

 

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts