<?php
 /*+*******************************************************************************
 * The content of this file is subject to the CRMTiger Pro license.
 * ("License"); You may not use this file except in compliance with the License
 * The Initial Developer of the Original Code is vTiger
 * The Modified Code of the Original Code owned by https://crmtiger.com/
 * Portions created by CRMTiger.com are Copyright(C) CRMTiger.com
 * All Rights Reserved.
  ***************************************************************************** */

class CTMobile_WS_DownloadPDF extends CTMobile_WS_Controller {

	function process(CTMobile_API_Request $request) {
		global $adb,$current_user,$currentModule; // Required for vtws_update API
		$record = $request->get('record');
		$moduleName = $request->get('module');
		$currentModule = $moduleName;
		$current_user = $this->getActiveUser();
		
		if($moduleName == 'Invoice'){
			vimport('~~/modules/Invoice/InvoicePDFController.php');
		}else if ($moduleName == 'Quotes'){
			vimport('~~/modules/Quotes/QuotePDFController.php');
		}else if($moduleName == 'PurchaseOrder'){
			vimport('~~/modules/PurchaseOrder/PurchaseOrderPDFController.php');
		}else if ($moduleName == 'SalesOrder'){
			vimport('~~/modules/SalesOrder/SalesOrderPDFController.php');
		}

		$idComponents = explode('x', $record);
		$recordId = $idComponents[1];
		
		$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
		$recordModel->getPDF();
		exit;
	}
}

?>
