Beispiel #1
0
	public function process(Vtiger_Request $request) {
		$mode = $request->getMode();
		if (!empty($mode)) {
			echo $this->invokeExposedMethod($mode, $request);
			return;
		}

		$taxId = $request->get('taxid');
		$type = $request->get('type');
		if (empty($taxId)) {
			$taxRecordModel = new Settings_Vtiger_TaxRecord_Model();
		} else {
			$taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
		}
		
		$fields = array('taxlabel','percentage','deleted');
		foreach($fields as $fieldName) {
			if($request->has($fieldName)) {
				$taxRecordModel->set($fieldName,$request->get($fieldName));
			}
		}
		
		$taxRecordModel->setType($type);

		$response = new Vtiger_Response();
		try {
			$taxId = $taxRecordModel->save();
			$recordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
			$response->setResult(array_merge(array('_editurl' => $recordModel->getEditTaxUrl(), 'type' => $recordModel->getType()),$recordModel->getData()));
		} catch (Exception $e) {
			$response->setError($e->getCode(), $e->getMessage());
		}
		$response->emit();
	}
Beispiel #2
0
 public function process(Vtiger_Request $request)
 {
     $viewer = $this->getViewer($request);
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $taxId = $request->get('taxid');
     $type = $request->get('type');
     if (empty($taxId)) {
         $taxRecordModel = new Settings_Vtiger_TaxRecord_Model();
     } else {
         $taxRecordModel = Settings_Vtiger_TaxRecord_Model::getInstanceById($taxId, $type);
     }
     $viewer->assign('TAX_TYPE', $type);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('TAX_RECORD_MODEL', $taxRecordModel);
     echo $viewer->view('EditTax.tpl', $qualifiedModuleName, true);
 }