[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* +********************************************************************************** 4 * The contents of this file are subject to the vtiger CRM Public License Version 1.1 5 * ("License"); You may not use this file except in compliance with the License 6 * The Original Code is: vtiger CRM Open Source 7 * The Initial Developer of the Original Code is vtiger. 8 * Portions created by vtiger are Copyright (C) vtiger. 9 * All Rights Reserved. 10 * ********************************************************************************** */ 11 12 class Settings_Vtiger_TaxAjax_Action extends Settings_Vtiger_Basic_Action { 13 14 function __construct() { 15 parent::__construct(); 16 $this->exposeMethod('checkDuplicateName'); 17 } 18 19 public function process(Vtiger_Request $request) { 20 $mode = $request->getMode(); 21 $currentUser = Users_Record_Model::getCurrentUserModel(); 22 if (!empty($mode)) { 23 echo $this->invokeExposedMethod($mode, $request); 24 return; 25 } 26 27 $taxId = $request->get('taxid'); 28 $type = $request->get('type'); 29 if (empty($taxId)) { 30 $taxRecordModel = new Settings_Vtiger_TaxRecord_Model(); 31 } else { 32 $taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type); 33 } 34 35 $fields = array('taxlabel','percentage','deleted'); 36 foreach($fields as $fieldName) { 37 if($request->has($fieldName)) { 38 $taxRecordModel->set($fieldName,$request->get($fieldName)); 39 } 40 } 41 42 $taxRecordModel->setType($type); 43 44 $response = new Vtiger_Response(); 45 try { 46 $taxId = $taxRecordModel->save(); 47 $recordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type); 48 $response->setResult(array_merge(array('_editurl' => $recordModel->getEditTaxUrl(), 'type' => $recordModel->getType(), 'row_type' => $currentUser->get('rowheight')), $recordModel->getData())); 49 } catch (Exception $e) { 50 $response->setError($e->getCode(), $e->getMessage()); 51 } 52 $response->emit(); 53 } 54 55 public function checkDuplicateName(Vtiger_Request $request) { 56 $moduleName = $request->getModule(); 57 $qualifiedModuleName = $request->getModule(false); 58 $taxId = $request->get('taxid'); 59 $taxLabel = $request->get('taxlabel'); 60 $type = $request->get('type'); 61 62 $exists = Settings_Vtiger_TaxRecord_Model::checkDuplicate($taxLabel, $taxId, $type); 63 64 if (!$exists) { 65 $result = array('success' => false); 66 } else { 67 $result = array('success' => true, 'message' => vtranslate('LBL_TAX_NAME_EXIST', $qualifiedModuleName)); 68 } 69 70 $response = new Vtiger_Response(); 71 $response->setResult($result); 72 $response->emit(); 73 } 74 75 public function validateRequest(Vtiger_Request $request) { 76 $request->validateWriteAccess(); 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |