[Vtigercrm-commits] [vtiger-commits] r6165 - in /vtigercrm/trunk: Smarty/templates/ data/ include/language/ include/utils/ modules/Products/ modules/Users/ schema/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu May 18 16:40:48 EDT 2006
Author: saraj
Date: Thu May 18 14:40:29 2006
New Revision: 6165
Log:
* Modified to handle the Tax information in Products module
Modified:
vtigercrm/trunk/Smarty/templates/DisplayFields.tpl
vtigercrm/trunk/Smarty/templates/InventoryDetailView.tpl
vtigercrm/trunk/data/CRMEntity.php
vtigercrm/trunk/include/language/en_us.lang.php
vtigercrm/trunk/include/utils/InventoryUtils.php
vtigercrm/trunk/modules/Products/DetailView.php
vtigercrm/trunk/modules/Products/EditView.php
vtigercrm/trunk/modules/Products/Product.php
vtigercrm/trunk/modules/Users/Security.php
vtigercrm/trunk/schema/DatabaseSchema.xml
Modified: vtigercrm/trunk/Smarty/templates/DisplayFields.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/DisplayFields.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/DisplayFields.tpl Thu May 18 14:40:29 2006
@@ -468,9 +468,75 @@
{$disp_text}
{/foreach}
</td>
-
+ {elseif $uitype eq 83} <!-- Handle the Tax in Inventory -->
+ {if $VAT_CHECK eq 1}
+ {assign var=vat_check value="checked"}
+ {assign var=vat_show value="visible"}
+ {else}
+ {assign var=vat_check value=""}
+ {assign var=vat_show value="hidden"}
+ {/if}
+ {if $SALES_CHECK eq 1}
+ {assign var=sales_check value="checked"}
+ {assign var=sales_show value="visible"}
+ {else}
+ {assign var=sales_check value=""}
+ {assign var=sales_show value="hidden"}
+ {/if}
+ {if $SERVICE_CHECK eq 1}
+ {assign var=service_check value="checked"}
+ {assign var=service_show value="visible"}
+ {else}
+ {assign var=service_check value=""}
+ {assign var=service_show value="hidden"}
+ {/if}
+
+ <td align="right" class="dvtCellLabel" style="border:0px solid red;">
+ {$APP.LBL_VAT} :
+ <input type="checkbox" name="vat_check" id="vat_check" class="small" onclick="fnshowHide(this,'vat_tax')" {$vat_check}>
+ </td>
+ <td class="dvtCellInfo" align="left" style="border:0px solid red;">
+ <input type="text" class="detailedViewTextBox" name="vat_tax" id="vat_tax" value="{$VAT_TAX}" style="visibility:{$vat_show};" onBlur="fntaxValidation('vat_tax')">
+ </td>
+ <td colspan="2" class="dvtCellInfo" style="border:0px solid red;"> </td>
+ </tr>
+ <tr>
+ <td align="right" class="dvtCellLabel" style="border:0px solid red;">
+ {$APP.LBL_SALES} :
+ <input type="checkbox" name="sales_check" id="sales_check" class="small" onClick="fnshowHide(this,'sales_tax')" {$sales_check}>
+ </td>
+ <td class="dvtCellInfo" align="left" style="border:0px solid red;">
+ <input type="text" class="detailedViewTextBox" name="sales_tax" id="sales_tax" value="{$SALES_TAX}" style="visibility:{$sales_show};" onBlur="fntaxValidation('sales_tax')">
+ </td>
+ <td colspan="2" class="dvtCellInfo" style="border:0px solid red;"> </td>
+ </tr>
+ <tr>
+ <td align="right" class="dvtCellLabel">
+ {$APP.LBL_SERVICE} :
+ <input type="checkbox" name="service_check" id="service_check" class="small" onClick="fnshowHide(this,'service_tax')" {$service_check}>
+ </td>
+ <td class="dvtCellInfo" align="left">
+ <input type="text" class="detailedViewTextBox" name="service_tax" id="service_tax" value="{$SERVICE_TAX}" style="visibility:{$service_show};" onBlur="fntaxValidation('service_tax')">
+ </td>
+ <td colspan="2" class="dvtCellInfo"> </td>
{/if}
{/foreach}
</tr>
{/foreach}
+<script language="javascript">
+ function fnshowHide(currObj,txtObj)
+ {ldelim}
+ if(currObj.checked == true)
+ document.getElementById(txtObj).style.visibility = 'visible';
+ else
+ document.getElementById(txtObj).style.visibility = 'hidden';
+ {rdelim}
+
+ function fntaxValidation(txtObj)
+ {ldelim}
+ temp= /^\d+\.\d+$/.test(document.getElementById(txtObj).value);
+ if(temp == false)
+ alert("Please enter Valid TAX value");
+ {rdelim}
+</script>
Modified: vtigercrm/trunk/Smarty/templates/InventoryDetailView.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/InventoryDetailView.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/InventoryDetailView.tpl Thu May 18 14:40:29 2006
@@ -173,7 +173,7 @@
{if $label ne ''}
{if $keycntimage ne ''}
<td class="dvtCellLabel" align=right width=25%>{$keycntimage}</td>
- {else}
+ {elseif $label neq 'Tax Class'}<!-- Avoid to display the label Tax Class -->
<td class="dvtCellLabel" align=right width=25%>{$label}</td>
{/if}
@@ -342,6 +342,33 @@
<a href="javascript:;" onclick="hndCancel('dtlview_{$label}','editarea_{$label}','{$label}')" class="link">Cancel</a>
</div>
</td>
+ {elseif $keyid eq 83}<!-- Handle the Tax in Inventory -->
+ <td align="right" class="dvtCellLabel">
+ {$APP.LBL_VAT} :
+
+ </td>
+ <td class="dvtCellInfo" align="left">
+ {$VAT_TAX}
+ </td>
+ <td colspan="2" class="dvtCellInfo"> </td>
+ </tr>
+ <tr>
+ <td align="right" class="dvtCellLabel">
+ {$APP.LBL_SALES} :
+ </td>
+ <td class="dvtCellInfo" align="left">
+ {$SALES_TAX}
+ </td>
+ <td colspan="2" class="dvtCellInfo"> </td>
+ </tr>
+ <tr>
+ <td align="right" class="dvtCellLabel">
+ {$APP.LBL_SERVICE} :
+ </td>
+ <td class="dvtCellInfo" align="left" >
+ {$SERVICE_TAX}
+ </td>
+
{else}
<td class="dvtCellInfo" align="left" width=25%">{$keyval}</td>
{/if}
Modified: vtigercrm/trunk/data/CRMEntity.php
==============================================================================
--- vtigercrm/trunk/data/CRMEntity.php (original)
+++ vtigercrm/trunk/data/CRMEntity.php Thu May 18 14:40:29 2006
@@ -188,6 +188,10 @@
}
}
// Code included by Minnie - Ends
+ elseif($table_name == 'producttaxrel')
+ {
+ $this->insertTaxInformation($table_name, $module);
+ }
else
{
$this->insertIntoEntityTable($table_name, $module);
@@ -1375,7 +1379,62 @@
}
return $sql3;
- }
+ }
+
+
+ /** function to save the product tax information in producttarel table
+ * @param string $tablename - tablename to save the product tax relationship (producttaxrel)
+ * @param string $module - current module name
+ * $return void
+ */
+ function insertTaxInformation($tablename, $module)
+ {
+ global $adb, $log;
+ $log->debug("Entering into insertTaxInformation($tablename, $module) method ...");
+
+ $tax_per = '';
+ //Save the Product - VAT tax relationship if VAT tax check box is enabled
+ if($_REQUEST['vat_check'] == 'on' || $_REQUEST['vat_check'] == 1)
+ {
+ $taxid = getTaxId('VAT');
+ $tax_per = $_REQUEST['vat_tax'];
+ if($tax_per == '')
+ $tax_per = getTaxPercentage('VAT');
+
+ $log->debug("Going to save the Product - VAT tax relationship");
+
+ $sql = "insert into producttaxrel values($this->id,$taxid,$tax_per)";
+ $adb->query($sql);
+ }
+ //Save the Product - Sales tax relationship if Sales tax check box is enabled
+ if($_REQUEST['sales_check'] == 'on' || $_REQUEST['sales_check'] == 1)
+ {
+ $taxid = getTaxId('Sales');
+ $tax_per = $_REQUEST['sales_tax'];
+ if($tax_per == '')
+ $tax_per = getTaxPercentage('Sales');
+
+ $log->debug("Going to save the Product - Sales tax relationship");
+
+ $sql = "insert into producttaxrel values($this->id,$taxid,$tax_per)";
+ $adb->query($sql);
+ }
+ //Save the Product - Service tax relationship if Service tax check box is enabled
+ if($_REQUEST['service_check'] == 'on' || $_REQUEST['service_check'] == 1)
+ {
+ $taxid = getTaxId('Service');
+ $tax_per = $_REQUEST['service_tax'];
+ if($tax_per == '')
+ $tax_per = getTaxPercentage('Service');
+
+ $log->debug("Going to save the Product - Service tax relationship");
+
+ $sql = "insert into producttaxrel values($this->id,$taxid,$tax_per)";
+ $adb->query($sql);
+ }
+
+ $log->debug("Exiting from insertTaxInformation($tablename, $module) method ...");
+ }
}
?>
Modified: vtigercrm/trunk/include/language/en_us.lang.php
==============================================================================
--- vtigercrm/trunk/include/language/en_us.lang.php (original)
+++ vtigercrm/trunk/include/language/en_us.lang.php Thu May 18 14:40:29 2006
@@ -865,6 +865,10 @@
'Campaign Name'=>'Campaign Name',
'LBL_ACTIONS'=>'Actions',
'LBL_SEND'=>'Send',
+'LBL_VAT'=>'VAT',
+'LBL_SALES'=>'Sales',
+'LBL_SERVICE'=>'Service',
+
);
Modified: vtigercrm/trunk/include/utils/InventoryUtils.php
==============================================================================
--- vtigercrm/trunk/include/utils/InventoryUtils.php (original)
+++ vtigercrm/trunk/include/utils/InventoryUtils.php Thu May 18 14:40:29 2006
@@ -251,5 +251,58 @@
return $handler;
}
+/** function to get the taxid
+ * @param string $type - tax type (VAT or Sales or Service)
+ * return int $taxid - taxid corresponding to the Tax type from inventorytaxinfo table
+ */
+function getTaxId($type)
+{
+ global $adb, $log;
+ $log->debug("Entering into getTaxId($type) function.");
+
+ $res = $adb->query("select taxid from inventorytaxinfo where taxname=\"$type\"");
+ $taxid = $adb->query_result($res,0,'taxid');
+
+ $log->debug("Exiting from getTaxId($type) function. return value=$taxid");
+ return $taxid;
+}
+
+/** function to get the taxpercentage
+ * @param string $type - tax type (VAT or Sales or Service)
+ * return int $taxpercentage - taxpercentage corresponding to the Tax type from inventorytaxinfo table
+ */
+function getTaxPercentage($type)
+{
+ global $adb, $log;
+ $log->debug("Entering into getTaxPercentage($type) function.");
+
+ $taxpercentage = '';
+
+ $res = $adb->query("select percentage from inventorytaxinfo where taxname=\"$type\"");
+ $taxpercentage = $adb->query_result($res,0,'percentage');
+
+ $log->debug("Exiting from getTaxPercentage($type) function. return value=$taxpercentage");
+ return $taxpercentage;
+}
+
+/** function to get the product's taxpercentage
+ * @param string $type - tax type (VAT or Sales or Service)
+ * @param id $productid - productid to which we want the tax percentage
+ * return int $taxpercentage - taxpercentage corresponding to the Tax type from inventorytaxinfo table
+ */
+function getProductTaxPercentage($type,$productid)
+{
+ global $adb, $log;
+ $log->debug("Entering into getProductTaxPercentage($type,$productid) function.");
+
+ $taxpercentage = '';
+
+ $res = $adb->query("select percentage from inventorytaxinfo inner join producttaxrel on inventorytaxinfo.taxid=producttaxrel.taxid where producttaxrel.productid=$productid and inventorytaxinfo.taxname=\"$type\"");
+ $taxpercentage = $adb->query_result($res,0,'percentage');
+
+ $log->debug("Exiting from getProductTaxPercentage($productid,$type) function. return value=$taxpercentage");
+ return $taxpercentage;
+}
+
?>
Modified: vtigercrm/trunk/modules/Products/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Products/DetailView.php (original)
+++ vtigercrm/trunk/modules/Products/DetailView.php Thu May 18 14:40:29 2006
@@ -60,6 +60,15 @@
$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
$smarty->assign("ID", $_REQUEST['record']);
+//Added to display the Tax informations
+$vat_tax = getProductTaxPercentage('VAT',$focus->id);
+$sales_tax = getProductTaxPercentage('Sales',$focus->id);
+$service_tax = getProductTaxPercentage('Service',$focus->id);
+
+$smarty->assign("VAT_TAX", $vat_tax);
+$smarty->assign("SALES_TAX", $sales_tax);
+$smarty->assign("SERVICE_TAX", $service_tax);
+
$check_button = Button_Check($module);
$smarty->assign("CHECK", $check_button);
//Security check for related list
Modified: vtigercrm/trunk/modules/Products/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Products/EditView.php (original)
+++ vtigercrm/trunk/modules/Products/EditView.php Thu May 18 14:40:29 2006
@@ -118,8 +118,40 @@
if($focus->mode == 'edit')
{
$smarty->assign("UPDATEINFO",updateInfo($focus->id));
- $smarty->assign("MODE", $focus->mode);
-}
+ $smarty->assign("MODE", $focus->mode);
+
+ $vat_tax = getProductTaxPercentage('VAT',$focus->id);
+ $sales_tax = getProductTaxPercentage('Sales',$focus->id);
+ $service_tax = getProductTaxPercentage('Service',$focus->id);
+}
+
+$vat_check = 1;
+$sales_check = 1;
+$service_check = 1;
+if($vat_tax == '')
+{
+ $vat_tax = getTaxPercentage('VAT');
+ $vat_check = 0;
+}
+if($sales_tax == '')
+{
+ $sales_tax = getTaxPercentage('Sales');
+ $sales_check = 0;
+}
+if($service_tax == '')
+{
+ $service_tax = getTaxPercentage('Service');
+ $service_check = 0;
+}
+
+//Following values has been added to display the Tax information
+$smarty->assign("VAT_TAX", $vat_tax);
+$smarty->assign("SALES_TAX", $sales_tax);
+$smarty->assign("SERVICE_TAX", $service_tax);
+
+$smarty->assign("VAT_CHECK", $vat_check);
+$smarty->assign("SALES_CHECK", $sales_check);
+$smarty->assign("SERVICE_CHECK", $service_check);
if(isset($_REQUEST['return_module'])) $smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
if(isset($_REQUEST['return_action'])) $smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
Modified: vtigercrm/trunk/modules/Products/Product.php
==============================================================================
--- vtigercrm/trunk/modules/Products/Product.php (original)
+++ vtigercrm/trunk/modules/Products/Product.php Thu May 18 14:40:29 2006
@@ -42,8 +42,8 @@
);
- var $tab_name = Array('crmentity','products','productcf','seproductsrel');
- var $tab_name_index = Array('crmentity'=>'crmid','products'=>'productid','productcf'=>'productid','seproductsrel'=>'productid');
+ var $tab_name = Array('crmentity','products','productcf','seproductsrel','producttaxrel');
+ var $tab_name_index = Array('crmentity'=>'crmid','products'=>'productid','productcf'=>'productid','seproductsrel'=>'productid','producttaxrel'=>'productid');
var $column_fields = Array();
var $sortby_fields = Array('productname','productcode','commissionrate');
Modified: vtigercrm/trunk/modules/Users/Security.php
==============================================================================
--- vtigercrm/trunk/modules/Users/Security.php (original)
+++ vtigercrm/trunk/modules/Users/Security.php Thu May 18 14:40:29 2006
@@ -447,7 +447,7 @@
$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'unit_price','products',1,'71','unit_price','Unit Price',1,0,0,100,1,32,1,'N~O',1,null,'BAS')");
$this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'commissionrate','products',1,'9','commissionrate','Commission Rate',1,0,0,100,2,32,1,'N~O',1,null,'BAS')");
- $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'taxclass','products',1,'15','taxclass','Tax Class',1,0,0,100,4,32,1,'V~O',1,null,'BAS')");
+ $this->db->query("insert into field values (14,".$this->db->getUniqueID("field").",'taxclass','producttaxrel',1,'83','taxclass','Tax Class',1,0,0,100,4,32,1,'V~O',1,null,'BAS')");
//Block 33 stock info
@@ -2106,6 +2106,11 @@
$this->db->query("insert into parenttabrel values (2,26,1)");
$this->db->query("insert into parenttabrel values (2,6,2)");
$this->db->query("insert into parenttabrel values (2,4,3)");
+
+ //Added to populate the default inventory tax informations
+ $this->db->query("insert into inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'VAT','4.5')");
+ $this->db->query("insert into inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'Sales','10')");
+ $this->db->query("insert into inventorytaxinfo values(".$this->db->getUniqueID("inventorytaxinfo").",'Service','12.5')");
}
}
Modified: vtigercrm/trunk/schema/DatabaseSchema.xml
==============================================================================
--- vtigercrm/trunk/schema/DatabaseSchema.xml (original)
+++ vtigercrm/trunk/schema/DatabaseSchema.xml Thu May 18 14:40:29 2006
@@ -5077,4 +5077,43 @@
</field>
</table>
+ <table name="inventorytaxinfo">
+ <field name="taxid" type="I" size="3">
+ <KEY/>
+ <notnull />
+ <autoincrement />
+ </field>
+ <field name="taxname" type="C" size="50">
+ </field>
+ <field name="percentage" type="N" size="7.3">
+ </field>
+
+ <index name="inventorytaxinfo_taxname_idx">
+ <col>taxname</col>
+ </index>
+
+ <opt platform="mysql">Type=InnoDB</opt>
+ </table>
+
+ <table name="producttaxrel">
+ <field name="productid" type="I" size="11">
+ <notnull />
+ <constraint>REFERENCES products(productid) ON DELETE CASCADE</constraint>
+ </field>
+ <field name="taxid" type="I" size="3">
+ <notnull />
+ </field>
+ <field name="taxpercentage" type="N" size="7.3">
+ </field>
+
+ <index name="producttaxrel_productid_idx">
+ <col>productid</col>
+ </index>
+ <index name="producttaxrel_taxid_idx">
+ <col>taxid</col>
+ </index>
+
+ <opt platform="mysql">Type=InnoDB</opt>
+ </table>
+
</schema>
More information about the vtigercrm-commits
mailing list