[Vtigercrm-commits] [vtiger-commits] r9637 - in /vtigercrm/branches/5.0.2: Smarty/templates/Settings/TaxConfig.tpl include/js/Inventory.js modules/Settings/TaxConfig.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Mon Oct 16 13:38:55 EDT 2006
Author: richie
Date: Mon Oct 16 11:38:47 2006
New Revision: 9637
Log:
* Modified to provide the TaxLabel editing
Modified:
vtigercrm/branches/5.0.2/Smarty/templates/Settings/TaxConfig.tpl
vtigercrm/branches/5.0.2/include/js/Inventory.js
vtigercrm/branches/5.0.2/modules/Settings/TaxConfig.php
Modified: vtigercrm/branches/5.0.2/Smarty/templates/Settings/TaxConfig.tpl
==============================================================================
--- vtigercrm/branches/5.0.2/Smarty/templates/Settings/TaxConfig.tpl (original)
+++ vtigercrm/branches/5.0.2/Smarty/templates/Settings/TaxConfig.tpl Mon Oct 16 11:38:47 2006
@@ -13,6 +13,7 @@
<script language="JavaScript" type="text/javascript" src="include/js/menu.js"></script>
<script language="JavaScript" type="text/javascript" src="include/js/general.js"></script>
<script language="JavaScript" type="text/javascript" src="include/js/Inventory.js"></script>
+
{literal}
<style>
@@ -91,7 +92,7 @@
</td>
<td class="small" align=right nowrap>
{if $EDIT_MODE eq 'true'}
- <input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('tax_count')" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL} ">
+ <input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('tax_count');" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL} ">
<input class="crmButton small cancel" title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form.save_tax.value='false'; this.form.parenttab.value='Settings';" type="submit" name="button22" value=" {$APP.LBL_CANCEL_BUTTON_LABEL} ">
{elseif $TAX_COUNT > 0}
<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.edit_tax.value='true'; this.form.parenttab.value='Settings';" type="submit" name="button" value=" {$APP.LBL_EDIT_BUTTON_LABEL} " class="crmButton small edit">
@@ -114,8 +115,17 @@
{else}
<tr><!-- set color to taxes which are disabled now-->
{/if}
-
- <td width=35% class="cellLabel small">{$tax.taxlabel} </td>
+
+ <!--assinging tax label name for javascript validation-->
+ {assign var=tax_label value="taxlabel_"|cat:$tax.taxname}
+
+ <td width=35% class="cellLabel small" >
+ {if $EDIT_MODE eq 'true'}
+ <input name="{$tax.taxlabel}" id={$tax_label} type="text" value="{$tax.taxlabel}" class="detailedViewTextBox small">
+ {else}
+ {$tax.taxlabel}
+ {/if}
+ </td>
<td width=55% class="cellText small">
{if $EDIT_MODE eq 'true'}
<input name="{$tax.taxname}" id="{$tax.taxname}" type="text" value="{$tax.percentage}" class="detailedViewTextBox small"> %
@@ -165,7 +175,7 @@
</td>
<td class="small" align=right nowrap>
{if $SH_EDIT_MODE eq 'true'}
- <input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.sh_save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('sh_tax_count')" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL} ">
+ <input class="crmButton small save" title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.sh_save_tax.value='true'; this.form.parenttab.value='Settings'; return validateTaxes('sh_tax_count');" type="submit" name="button2" value=" {$APP.LBL_SAVE_BUTTON_LABEL} ">
<input class="crmButton small cancel" title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" onclick="this.form.action.value='TaxConfig'; this.form.module.value='Settings'; this.form.sh_save_tax.value='false'; this.form.parenttab.value='Settings';" type="submit" name="button22" value=" {$APP.LBL_CANCEL_BUTTON_LABEL} ">
{elseif $SH_TAX_COUNT > 0}
@@ -190,7 +200,15 @@
<tr><!-- set color to taxes which are disabled now-->
{/if}
- <td width=35% class="cellLabel small">{$tax.taxlabel} </td>
+ {assign var=tax_label value="taxlabel_"|cat:$tax.taxname}
+ <td width=35% class="cellLabel small">
+ {if $SH_EDIT_MODE eq 'true'}
+
+ <input name="{$tax.taxlabel}" id="{$tax_label}" type="text" value="{$tax.taxlabel}" class="detailedViewTextBox small">
+ {else}
+ {$tax.taxlabel}
+ {/if}
+ </td>
<td width=55% class="cellText small">
{if $SH_EDIT_MODE eq 'true'}
<input name="{$tax.taxname}" id="{$tax.taxname}" type="text" value="{$tax.percentage}" class="detailedViewTextBox small">
Modified: vtigercrm/branches/5.0.2/include/js/Inventory.js
==============================================================================
--- vtigercrm/branches/5.0.2/include/js/Inventory.js (original)
+++ vtigercrm/branches/5.0.2/include/js/Inventory.js Mon Oct 16 11:38:47 2006
@@ -414,13 +414,29 @@
taxcount = eval(document.getElementById(countname).value)+1;
if(countname == 'tax_count')
+ {
taxprefix = 'tax';
+ taxLabelPrefix = 'taxlabel_tax';
+ }
else
+ {
taxprefix = 'shtax';
+ taxLabelPrefix = 'taxlabel_shtax';
+ }
for(var i=1;i<=taxcount;i++)
{
taxval = document.getElementById(taxprefix+i).value;
+ taxLabelVal = document.getElementById(taxLabelPrefix+i).value;
+ document.getElementById(taxLabelPrefix+i).value = taxLabelVal.replace(/^\s*|\s*$/g,'').replace(/\s+/g,'');
+
+ if(document.getElementById(taxLabelPrefix+i).value.length == 0)
+ {
+ alert("The tax label name should not be empty");
+ return false
+ }
+
+ //Tax value - numeric validation
var temp = /^(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/.test(taxval);
if(!temp)
{
@@ -430,6 +446,7 @@
}
return true;
}
+
//Function used to add a new product row in PO, SO, Quotes and Invoice
Modified: vtigercrm/branches/5.0.2/modules/Settings/TaxConfig.php
==============================================================================
--- vtigercrm/branches/5.0.2/modules/Settings/TaxConfig.php (original)
+++ vtigercrm/branches/5.0.2/modules/Settings/TaxConfig.php Mon Oct 16 11:38:47 2006
@@ -1,214 +1,244 @@
-<?php
-/*********************************************************************************
-** The contents of this file are subject to the vtiger CRM Public License Version 1.0
- * ("License"); You may not use this file except in compliance with the License
- * The Original Code is: vtiger CRM Open Source
- * The Initial Developer of the Original Code is vtiger.
- * Portions created by vtiger are Copyright (C) vtiger.
- * All Rights Reserved.
-*
- ********************************************************************************/
-
-require_once('Smarty_setup.php');
-global $mod_strings;
-global $app_strings;
-global $adb;
-global $log;
-
-$smarty = new vtigerCRM_Smarty;
-global $theme;
-$theme_path="themes/".$theme."/";
-$image_path=$theme_path."images/";
-require_once($theme_path.'layout_utils.php');
-
-$tax_details = getAllTaxes();
-$sh_tax_details = getAllTaxes('all','sh');
-
-//To save the edited value
-if($_REQUEST['save_tax'] == 'true')
-{
- for($i=0;$i<count($tax_details);$i++)
- {
- $new_percentages[$tax_details[$i]['taxid']] = $_REQUEST[$tax_details[$i]['taxname']];
- }
- updateTaxPercentages($new_percentages);
- $getlist = true;
-}
-elseif($_REQUEST['sh_save_tax'] == 'true')
-{
- for($i=0;$i<count($sh_tax_details);$i++)
- {
- $new_percentages[$sh_tax_details[$i]['taxid']] = $_REQUEST[$sh_tax_details[$i]['taxname']];
- }
- updateTaxPercentages($new_percentages,'sh');
- $getlist = true;
-}
-
-//To edit
-if($_REQUEST['edit_tax'] == 'true')
-{
- $smarty->assign("EDIT_MODE", 'true');
-}
-elseif($_REQUEST['sh_edit_tax'] == 'true')
-{
- $smarty->assign("SH_EDIT_MODE", 'true');
-}
-
-//To add tax
-if($_REQUEST['add_tax_type'] == 'true')
-{
- //Add the given tax name and value as a new tax type
- echo addTaxType($_REQUEST['addTaxLabel'],$_REQUEST['addTaxValue']);
- $getlist = true;
-}
-elseif($_REQUEST['sh_add_tax_type'] == 'true')
-{
- echo addTaxType($_REQUEST['sh_addTaxLabel'],$_REQUEST['sh_addTaxValue'],'sh');
- $getlist = true;
-}
-
-//To Disable ie., delete or enable
-if(($_REQUEST['disable'] == 'true' || $_REQUEST['enable'] == 'true') && $_REQUEST['taxname'] != '')
-{
- if($_REQUEST['disable'] == 'true')
- changeDeleted($_REQUEST['taxname'],1);
- else
- changeDeleted($_REQUEST['taxname'],0);
- $getlist = true;
-}
-elseif(($_REQUEST['sh_disable'] == 'true' || $_REQUEST['sh_enable'] == 'true') && $_REQUEST['sh_taxname'] != '')
-{
- if($_REQUEST['sh_disable'] == 'true')
- changeDeleted($_REQUEST['sh_taxname'],1,'sh');
- else
- changeDeleted($_REQUEST['sh_taxname'],0,'sh');
- $getlist = true;
-}
-
-//after done save or enable/disable or added new tax the list will be retrieved again from db
-if($getlist)
-{
- $tax_details = getAllTaxes();
- $sh_tax_details = getAllTaxes('all','sh');
-}
-
-$smarty->assign("TAX_COUNT", count($tax_details));
-$smarty->assign("SH_TAX_COUNT", count($sh_tax_details));
-
-if(count($tax_details) == 0)
- $smarty->assign("TAX_COUNT", 0);
-if(count($sh_tax_details) == 0)
- $smarty->assign("SH_TAX_COUNT", 0);
-
-$smarty->assign("TAX_VALUES", $tax_details);
-$smarty->assign("SH_TAX_VALUES", $sh_tax_details);
-
-$smarty->assign("MOD", return_module_language($current_language,'Settings'));
-$smarty->assign("IMAGE_PATH",$image_path);
-$smarty->assign("APP", $app_strings);
-$smarty->assign("MOD", $mod_strings);
-$smarty->display("Settings/TaxConfig.tpl");
-
-
-/** Function to update the list of Tax percentages for the passed tax types
- * @param array $new_percentages - array of tax types and the values like [taxid]=new value ie., [1]=3.56, [2]=11.45
- * @param string $sh - sh or empty, if sh passed then update will be done in shipping and handling related table
- * @return void
- */
-function updateTaxPercentages($new_percentages, $sh='')
-{
- global $adb, $log;
- $log->debug("Entering into the function updateTaxPercentages");
-
- $tax_percentage = Array();
-
- foreach($new_percentages as $taxid => $new_val)
- {
- if($new_val != '')
- {
- if($sh != '' && $sh == 'sh')
- $query = "update vtiger_shippingtaxinfo set percentage = \"$new_val\" where taxid=\"$taxid\"";
- else
- $query = "update vtiger_inventorytaxinfo set percentage = \"$new_val\" where taxid=\"$taxid\"";
- $adb->query($query);
- }
- }
-
- $log->debug("Exiting from the function updateTaxPercentages");
-}
-
-/** Function used to add the tax type which will do database alterations
- * @param string $taxlabel - tax label name to be added
- * @param string $taxvalue - tax value to be added
- * @param string $sh - sh or empty , if sh passed then the tax will be added in shipping and handling related table
- * @return void
- */
-function addTaxType($taxlabel, $taxvalue, $sh='')
-{
- global $adb, $log;
- $log->debug("Entering into function addTaxType($taxlabel, $taxvalue, $sh)");
-
- //First we will check whether the tax is already available or not
- if($sh != '' && $sh == 'sh')
- $check_query = "select taxlabel from vtiger_shippingtaxinfo where taxlabel='".addslashes($taxlabel)."'";
- else
- $check_query = "select taxlabel from vtiger_inventorytaxinfo where taxlabel='".addslashes($taxlabel)."'";
- $check_res = $adb->query($check_query);
-
- if($adb->num_rows($check_res) > 0)
- return "<font color='red'>This tax is already available</font>";
-
- //if the tax is not available then add this tax.
- //Add this tax as a column in related table
- if($sh != '' && $sh == 'sh')
- {
- $taxid = $adb->getUniqueID("vtiger_shippingtaxinfo");
- $taxname = "shtax".$taxid;
-
- $query = "alter table vtiger_inventoryshippingrel add column $taxname decimal(7,3) default NULL";
- }
- else
- {
- $taxid = $adb->getUniqueID("vtiger_inventorytaxinfo");
- $taxname = "tax".$taxid;
- $query = "alter table vtiger_inventoryproductrel add column $taxname decimal(7,3) default NULL";
- }
- $res = $adb->query($query);
-
- //if the tax is added as a column then we should add this tax in the list of taxes
- if($res)
- {
- if($sh != '' && $sh == 'sh')
- $query1 = "insert into vtiger_shippingtaxinfo values($taxid,'".$taxname."','".$taxlabel."','".$taxvalue."',0)";
- else
- $query1 = "insert into vtiger_inventorytaxinfo values($taxid,'".$taxname."','".$taxlabel."','".$taxvalue."',0)";
-
- $res1 = $adb->query($query1);
- }
-
- $log->debug("Exit from function addTaxType($taxlabel, $taxvalue)");
- if($res1)
- return '';
- else
- return "There may be some problem in adding the Tax type. Please try again";
-}
-
-/** Function used to Enable or Disable the tax type
- * @param string $taxname - taxname to enable or disble
- * @param int $deleted - 0 or 1 where 0 to enable and 1 to disable
- * @param string $sh - sh or empty, if sh passed then the enable/disable will be done in shipping and handling tax table ie.,vtiger_shippingtaxinfo else this enable/disable will be done in Product tax table ie., in vtiger_inventorytaxinfo
- * @return void
- */
-function changeDeleted($taxname, $deleted, $sh='')
-{
- global $log, $adb;
- $log->debug("Entering into function changeDeleted($taxname, $deleted, $sh)");
-
- if($sh == 'sh')
- $adb->query("update vtiger_shippingtaxinfo set deleted=$deleted where taxname=\"$taxname\"");
- else
- $adb->query("update vtiger_inventorytaxinfo set deleted=$deleted where taxname=\"$taxname\"");
- $log->debug("Exit from function changeDeleted($taxname, $deleted, $sh)");
-}
-
-?>
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is: vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+*
+ ********************************************************************************/
+
+
+require_once('Smarty_setup.php');
+global $mod_strings;
+global $app_strings;
+global $adb;
+global $log;
+
+$smarty = new vtigerCRM_Smarty;
+global $theme;
+$theme_path="themes/".$theme."/";
+$image_path=$theme_path."images/";
+require_once($theme_path.'layout_utils.php');
+
+$tax_details = getAllTaxes();
+$sh_tax_details = getAllTaxes('all','sh');
+
+
+//To save the edited value
+if($_REQUEST['save_tax'] == 'true')
+{
+ for($i=0;$i<count($tax_details);$i++)
+ {
+ $new_labels[$tax_details[$i]['taxid']] = $_REQUEST[$tax_details[$i]['taxlabel']];
+ $new_percentages[$tax_details[$i]['taxid']] = $_REQUEST[$tax_details[$i]['taxname']];
+ }
+ updateTaxPercentages($new_percentages);
+ updateTaxLabels($new_labels);
+ $getlist = true;
+}
+elseif($_REQUEST['sh_save_tax'] == 'true')
+{
+
+ for($i=0;$i<count($sh_tax_details);$i++)
+ {
+ $new_labels[$sh_tax_details[$i]['taxid']] = $_REQUEST[$sh_tax_details[$i]['taxlabel']];
+ $new_percentages[$sh_tax_details[$i]['taxid']] = $_REQUEST[$sh_tax_details[$i]['taxname']];
+ }
+
+ updateTaxPercentages($new_percentages,'sh');
+ updateTaxLabels($new_labels,'sh');
+ $getlist = true;
+}
+
+//To edit
+if($_REQUEST['edit_tax'] == 'true')
+{
+ $smarty->assign("EDIT_MODE", 'true');
+}
+elseif($_REQUEST['sh_edit_tax'] == 'true')
+{
+ $smarty->assign("SH_EDIT_MODE", 'true');
+}
+
+//To add tax
+if($_REQUEST['add_tax_type'] == 'true')
+{
+ //Add the given tax name and value as a new tax type
+ echo addTaxType($_REQUEST['addTaxLabel'],$_REQUEST['addTaxValue']);
+ $getlist = true;
+}
+elseif($_REQUEST['sh_add_tax_type'] == 'true')
+{
+ echo addTaxType($_REQUEST['sh_addTaxLabel'],$_REQUEST['sh_addTaxValue'],'sh');
+ $getlist = true;
+}
+
+//To Disable ie., delete or enable
+if(($_REQUEST['disable'] == 'true' || $_REQUEST['enable'] == 'true') && $_REQUEST['taxname'] != '')
+{
+ if($_REQUEST['disable'] == 'true')
+ changeDeleted($_REQUEST['taxname'],1);
+ else
+ changeDeleted($_REQUEST['taxname'],0);
+ $getlist = true;
+}
+elseif(($_REQUEST['sh_disable'] == 'true' || $_REQUEST['sh_enable'] == 'true') && $_REQUEST['sh_taxname'] != '')
+{
+ if($_REQUEST['sh_disable'] == 'true')
+ changeDeleted($_REQUEST['sh_taxname'],1,'sh');
+ else
+ changeDeleted($_REQUEST['sh_taxname'],0,'sh');
+ $getlist = true;
+}
+
+//after done save or enable/disable or added new tax the list will be retrieved again from db
+if($getlist)
+{
+ $tax_details = getAllTaxes();
+ $sh_tax_details = getAllTaxes('all','sh');
+}
+
+$smarty->assign("TAX_COUNT", count($tax_details));
+$smarty->assign("SH_TAX_COUNT", count($sh_tax_details));
+
+if(count($tax_details) == 0)
+ $smarty->assign("TAX_COUNT", 0);
+if(count($sh_tax_details) == 0)
+ $smarty->assign("SH_TAX_COUNT", 0);
+
+$smarty->assign("TAX_VALUES", $tax_details);
+
+$smarty->assign("SH_TAX_VALUES", $sh_tax_details);
+
+$smarty->assign("MOD", return_module_language($current_language,'Settings'));
+$smarty->assign("IMAGE_PATH",$image_path);
+$smarty->assign("APP", $app_strings);
+$smarty->assign("MOD", $mod_strings);
+$smarty->display("Settings/TaxConfig.tpl");
+
+
+/** Function to update the list of Tax percentages for the passed tax types
+ * @param array $new_percentages - array of tax types and the values like [taxid]=new value ie., [1]=3.56, [2]=11.45
+ * @param string $sh - sh or empty, if sh passed then update will be done in shipping and handling related table
+ * @return void
+ */
+function updateTaxPercentages($new_percentages, $sh='')
+{
+ global $adb, $log;
+ $log->debug("Entering into the function updateTaxPercentages");
+
+ foreach($new_percentages as $taxid => $new_val)
+ {
+ if($new_val != '')
+ {
+ if($sh != '' && $sh == 'sh')
+ $query = "update vtiger_shippingtaxinfo set percentage=\"$new_val\" where taxid=\"$taxid\"";
+ else
+ $query = "update vtiger_inventorytaxinfo set percentage = \"$new_val\" where taxid=\"$taxid\"";
+ $adb->query($query);
+ }
+ }
+
+ $log->debug("Exiting from the function updateTaxPercentages");
+}
+
+/** Function to update the list of Tax Labels for the taxes
+ * @param array $new_labels - array of tax types and the values like [taxid]=new label ie., [1]=aa, [2]=bb
+ * @param string $sh - sh or empty, if sh passed then update will be done in shipping and handling related table
+ * @return void
+ */
+function updateTaxLabels($new_labels, $sh='')
+{
+ global $adb, $log;
+ $log->debug("Entering into the function updateTaxPercentages");
+
+ foreach($new_labels as $taxid => $new_val)
+ {
+ if($new_val != '')
+ {
+ if($sh != '' && $sh == 'sh')
+ $query = "update vtiger_shippingtaxinfo set taxlabel= \"$new_val\" where taxid=\"$taxid\"";
+ else
+ $query = "update vtiger_inventorytaxinfo set taxlabel = \"$new_val\" where taxid=\"$taxid\"";
+ $adb->query($query);
+ }
+ }
+
+ $log->debug("Exiting from the function updateTaxPercentages");
+}
+/** Function used to add the tax type which will do database alterations
+ * @param string $taxlabel - tax label name to be added
+ * @param string $taxvalue - tax value to be added
+ * @param string $sh - sh or empty , if sh passed then the tax will be added in shipping and handling related table
+ * @return void
+ */
+function addTaxType($taxlabel, $taxvalue, $sh='')
+{
+ global $adb, $log;
+ $log->debug("Entering into function addTaxType($taxlabel, $taxvalue, $sh)");
+
+ //First we will check whether the tax is already available or not
+ if($sh != '' && $sh == 'sh')
+ $check_query = "select taxlabel from vtiger_shippingtaxinfo where taxlabel='".addslashes($taxlabel)."'";
+ else
+ $check_query = "select taxlabel from vtiger_inventorytaxinfo where taxlabel='".addslashes($taxlabel)."'";
+ $check_res = $adb->query($check_query);
+
+ if($adb->num_rows($check_res) > 0)
+ return "<font color='red'>This tax is already available</font>";
+
+ //if the tax is not available then add this tax.
+ //Add this tax as a column in related table
+ if($sh != '' && $sh == 'sh')
+ {
+ $taxid = $adb->getUniqueID("vtiger_shippingtaxinfo");
+ $taxname = "shtax".$taxid;
+ $query = "alter table vtiger_inventoryshippingrel add column $taxname decimal(7,3) default NULL";
+ }
+ else
+ {
+ $taxid = $adb->getUniqueID("vtiger_inventorytaxinfo");
+ $taxname = "tax".$taxid;
+ $query = "alter table vtiger_inventoryproductrel add column $taxname decimal(7,3) default NULL";
+ }
+ $res = $adb->query($query);
+
+ //if the tax is added as a column then we should add this tax in the list of taxes
+ if($res)
+ {
+ if($sh != '' && $sh == 'sh')
+ $query1 = "insert into vtiger_shippingtaxinfo values($taxid,'".$taxname."','".$taxlabel."','".$taxvalue."',0)";
+ else
+ $query1 = "insert into vtiger_inventorytaxinfo values($taxid,'".$taxname."','".$taxlabel."','".$taxvalue."',0)";
+
+ $res1 = $adb->query($query1);
+ }
+
+ $log->debug("Exit from function addTaxType($taxlabel, $taxvalue)");
+ if($res1)
+ return '';
+ else
+ return "There may be some problem in adding the Tax type. Please try again";
+}
+
+/** Function used to Enable or Disable the tax type
+ * @param string $taxname - taxname to enable or disble
+ * @param int $deleted - 0 or 1 where 0 to enable and 1 to disable
+ * @param string $sh - sh or empty, if sh passed then the enable/disable will be done in shipping and handling tax table ie.,vtiger_shippingtaxinfo else this enable/disable will be done in Product tax table ie., in vtiger_inventorytaxinfo
+ * @return void
+ */
+function changeDeleted($taxname, $deleted, $sh='')
+{
+ global $log, $adb;
+ $log->debug("Entering into function changeDeleted($taxname, $deleted, $sh)");
+
+ if($sh == 'sh')
+ $adb->query("update vtiger_shippingtaxinfo set deleted=$deleted where taxname=\"$taxname\"");
+ else
+ $adb->query("update vtiger_inventorytaxinfo set deleted=$deleted where taxname=\"$taxname\"");
+ $log->debug("Exit from function changeDeleted($taxname, $deleted, $sh)");
+}
+
+?>
More information about the vtigercrm-commits
mailing list