[Vtigercrm-commits] [vtiger-commits] r10576 - in /vtigercrm/branches/5.0.3: Smarty/templates/ Smarty/templates/Settings/ include/utils/ install/ modules/CustomView/ modules/Invoice/ modules/Invoice/language/ modules/Invoice/pdf_templates/ modules/Settings/ modules/Settings/language/ modules/Users/ schema/ themes/alphagrey/images/ themes/bluelagoon/images/ themes/woodspice/images/ user_privileges/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri Apr 6 04:27:01 EDT 2007
Author: richie
Date: Fri Apr 6 02:26:21 2007
New Revision: 10576
Log:
* Custom Invoice Number has been added. Now we can configure our own Custom Invoice Number
Added:
vtigercrm/branches/5.0.3/Smarty/templates/Settings/CustomInvoiceNo.tpl (with props)
vtigercrm/branches/5.0.3/modules/Settings/CustomInvoiceNo.php (with props)
vtigercrm/branches/5.0.3/modules/Users/UpdateCustomInvoiceNo.php (with props)
vtigercrm/branches/5.0.3/themes/alphagrey/images/settingsInvNumber.gif (with props)
vtigercrm/branches/5.0.3/themes/bluelagoon/images/settingsInvNumber.gif (with props)
vtigercrm/branches/5.0.3/themes/woodspice/images/settingsInvNumber.gif (with props)
vtigercrm/branches/5.0.3/user_privileges/CustomInvoiceNo.php (with props)
Modified:
vtigercrm/branches/5.0.3/Smarty/templates/DetailViewUI.tpl
vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl
vtigercrm/branches/5.0.3/Smarty/templates/SetMenu.tpl
vtigercrm/branches/5.0.3/Smarty/templates/Settings.tpl
vtigercrm/branches/5.0.3/include/utils/InventoryUtils.php
vtigercrm/branches/5.0.3/install/populateSeedData.php
vtigercrm/branches/5.0.3/modules/CustomView/PopulateCustomView.php
vtigercrm/branches/5.0.3/modules/Invoice/CreatePDF.php
vtigercrm/branches/5.0.3/modules/Invoice/EditView.php
vtigercrm/branches/5.0.3/modules/Invoice/Invoice.php
vtigercrm/branches/5.0.3/modules/Invoice/language/en_us.lang.php
vtigercrm/branches/5.0.3/modules/Invoice/pdf_templates/header.php
vtigercrm/branches/5.0.3/modules/Settings/language/en_us.lang.php
vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php
vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml
Modified: vtigercrm/branches/5.0.3/Smarty/templates/DetailViewUI.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/DetailViewUI.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/DetailViewUI.tpl Fri Apr 6 02:26:21 2007
@@ -14,7 +14,11 @@
<!-- This file is used to display the fields based on the ui type in detailview -->
{if $keyid eq '1' || $keyid eq 2 || $keyid eq '11' || $keyid eq '7' || $keyid eq '9' || $keyid eq '55' || $keyid eq '71' || $keyid eq '72' || $keyid eq '103'} <!--TextBox-->
+ {if $label eq 'Invoice No'}
+ <td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}">
+ {else}
<td width=25% class="dvtCellInfo" align="left" id="mouseArea_{$label}" onmouseover="hndMouseOver({$keyid},'{$label|escape:'quotes'}');" onmouseout="fnhide('crmspanid');">
+ {/if}
{if $keyid eq '55'}<!--SalutationSymbol-->
{$keysalut}
{*elseif $keyid eq '71' || $keyid eq '72'} <!--CurrencySymbol-->
Modified: vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/DisplayFields.tpl Fri Apr 6 02:26:21 2007
@@ -46,6 +46,11 @@
<span id="vtbusy_info" style="display:none;">
<img src="{$IMAGE_PATH}vtbusy.gif" border="0"></span>
</td>
+ {elseif $fldname eq 'invoice_no' && $MODULE eq 'Invoice'}
+
+ <td width=30% align=left class="dvtCellInfo"><input readonly type="text" tabindex="{$vt_tab}" name="{$fldname}" id ="{$fldname}" {if $MODE eq 'edit'} value="{$fldvalue}" {else} value="{$inv_no}" {/if} class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
+
+
{else}
<td width=30% align=left class="dvtCellInfo"><input type="text" tabindex="{$vt_tab}" name="{$fldname}" id ="{$fldname}" value="{$fldvalue}" class=detailedViewTextBox onFocus="this.className='detailedViewTextBoxOn'" onBlur="this.className='detailedViewTextBox'"></td>
{/if}
Modified: vtigercrm/branches/5.0.3/Smarty/templates/SetMenu.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/SetMenu.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/SetMenu.tpl Fri Apr 6 02:26:21 2007
@@ -181,6 +181,16 @@
<tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=OrganizationTermsandConditions&parenttab=Settings">{$MOD.LBL_INVENTORY_TANDC}</a></td></tr>
{/if}
+<!-- Added For Custom Invoice Number #start -->
+
+ {if $smarty.request.action eq 'CustomInvoiceNo'}
+ <tr><td class="settingsTabSelected" nowrap><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}</a></td></tr>
+ {else}
+ <tr><td class="settingsTabList" nowrap><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}</a></td></tr>
+ {/if}
+
+<!-- Added For Custom Invoice Number #end -->
+
</table>
<!-- Left side navigation table ends -->
Modified: vtigercrm/branches/5.0.3/Smarty/templates/Settings.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/Settings.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/Settings.tpl Fri Apr 6 02:26:21 2007
@@ -490,6 +490,26 @@
</tr>
+ <!-- Added for Custom Invoice Number #start -->
+ <!-- icon for Invoice Number Configuration -->
+ <tr>
+ <td width=25% valign=top>
+ <!-- empty-->
+
+ <table border=0 cellspacing=0 cellpadding=5 width=100%>
+ <tr>
+ <td rowspan=2 valign=top><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings"><img src="{$IMAGE_PATH}settingsInvNumber.gif" alt="{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}" width="48" height="48" border=0 title="{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}"></a></td>
+ <td class=big valign=top><a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER}</a></td>
+ </tr>
+ <tr>
+ <td class="small" valign=top>{$MOD.LBL_CUSTOMIZE_INVOICE_NUMBER_DESCRIPTION}</td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+ <!-- Added for Custom Invoice Number #end -->
+
</table>
</td>
Modified: vtigercrm/branches/5.0.3/include/utils/InventoryUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/InventoryUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/InventoryUtils.php Fri Apr 6 02:26:21 2007
@@ -716,4 +716,88 @@
}
+/** function used to set invoice string and increment invoice id
+ * @param string $mode - mode should be configure_invoiceno or increment_incoiceno
+ * @param string $req_str - invoice string which is part of the invoice number, this may be alphanumeric characters
+ * @param int $req_no - This should be a number which will written in file and will be used as a next invoice number
+ * @return void. The invoice string and number are stored in the file CustomInvoiceNo.php so that concatenated string with number will be used as a next invoice number
+ */
+
+function setInventoryInvoiceNumber($mode, $req_str='', $req_no='')
+{
+ global $root_directory;
+ $filename = $root_directory.'user_privileges/CustomInvoiceNo.php';
+ $readhandle = fopen($filename, "r+");
+ $buffer = '';
+ $new_buffer = '';
+
+ //when we configure the invoice number in Settings this will be used
+ if ($mode == "configure_invoiceno" && $req_str != '' && $req_no != '')
+ {
+
+ while(!feof($readhandle))
+ {
+ $buffer = fgets($readhandle, 5200);
+ list($starter, $tmp) = explode(" = ", $buffer);
+
+ if($starter == '$inv_str')
+ {
+ $new_buffer .= "\$inv_str = '".$req_str."';\n";
+ }
+ elseif($starter == '$inv_no')
+ {
+ $new_buffer .= "\$inv_no = '".$req_no."';\n";
+ }
+ else
+ $new_buffer .= $buffer;
+ }
+ }
+ else if ($mode == "increment_invoiceno")//when we save new invoice we will increment the invoice id and write
+ {
+ require_once('user_privileges/CustomInvoiceNo.php');
+ while(!feof($readhandle))
+ {
+ $buffer = fgets($readhandle, 5200);
+ list($starter, $tmp) = explode(" = ", $buffer);
+
+ if($starter == '$inv_no')
+ {
+ //if number is 001, 002 like this (starting with zero) then when we increment 1, zeros will be striped out and result comes as 1,2, etc. So we have added 0 previously for the needed length ie., two zeros for 001, 002, etc.,
+ //If the value is less than 0, then we assign 0 to it(to avoid error).
+ $strip=strlen($inv_no)-strlen($inv_no+1);
+ if($strip<0)$strip=0;
+
+ $temp = str_repeat("0",$strip);
+ $new_buffer .= "\$inv_no = '".$temp.($inv_no+1)."';\n";
+ }
+ else
+ $new_buffer .= $buffer;
+
+ }
+ }
+
+ //we have the contents in buffer. Going to write the contents in file
+ fclose($readhandle);
+ $handle = fopen($filename, "w");
+ fputs($handle, $new_buffer);
+ fclose($handle);
+}
+
+/** Function used to check whether the provided invoicenumber is already available or not
+ * @param int $invoiceno - invoice number, which we are going to check for duplicate
+ * @return binary true or false. If invoice number is already available then return true else return false
+ */
+function CheckDuplicateInvoiceNumber($invoiceno)
+{
+ global $adb;
+ $result=$adb->query("select invoice_no from vtiger_invoice where invoice_no = '".$invoiceno."'");
+ $num_rows = $adb->num_rows($result);
+
+ if($num_rows > 0)
+ return true;
+ else
+ return false;
+}
+
+
?>
Modified: vtigercrm/branches/5.0.3/install/populateSeedData.php
==============================================================================
--- vtigercrm/branches/5.0.3/install/populateSeedData.php (original)
+++ vtigercrm/branches/5.0.3/install/populateSeedData.php Fri Apr 6 02:26:21 2007
@@ -798,6 +798,7 @@
//Populate Invoice Data
$isubj_array = array ("vtiger_invoice201", "zoho_inv7841", "vtiger5usrp_invoice71134", "vt100usrpk_inv113", "vendtl_inv214");
+$invoiceno_array = array ("INV2007_1","INV2007_2","INV2007_3","INV2007_4","INV2007_5");
$istatus_array = array ("Created", "Sent", "Approved" , "Credit Invoice", "Paid");
$itotal_array = array ("4842.000", "4842.000", "4842.000", "4842.000", "4842.000");
@@ -814,6 +815,7 @@
$invoice->column_fields["contactid"] = $contact_ids[$contact_key];
$rand = array_rand($num_array);
$invoice->column_fields["subject"] = $isubj_array[$i];
+ $invoice->column_fields["invoice_no"] = $invoiceno_array[$i];
$invoice->column_fields["invoicestatus"] = $istatus_array[$i];
$invoice->column_fields["hdnGrandTotal"] = $itotal_array[$i];
Modified: vtigercrm/branches/5.0.3/modules/CustomView/PopulateCustomView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/PopulateCustomView.php (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/PopulateCustomView.php Fri Apr 6 02:26:21 2007
@@ -296,7 +296,7 @@
'vtiger_crmentity:smownerid:assigned_user_id:Emails_Sender:V',
'vtiger_activity:date_start:date_start:Emails_Date_Sent:D'),
- Array('vtiger_crmentity:crmid::Invoice_Invoice_Id:I',
+ Array('vtiger_invoice:invoice_no:invoice_no:Invoice_invoice_no:V',
'vtiger_invoice:subject:subject:Invoice_Subject:V',
'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
@@ -386,14 +386,16 @@
'vtiger_purchaseorder:carrier:carrier:PurchaseOrder_Carrier:V',
'vtiger_poshipads:ship_street:ship_street:PurchaseOrder_Shipping_Address:V'),
- Array( 'vtiger_invoice:subject:subject:Invoice_Subject:V',
+ Array( 'vtiger_invoice:invoice_no:invoice_no:Invoice_invoice_no:V',
+ 'vtiger_invoice:subject:subject:Invoice_Subject:V',
'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I',
'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
'vtiger_crmentity:smownerid:assigned_user_id:Invoice_Assigned_To:V',
'vtiger_crmentity:createdtime:createdtime:Invoice_Created_Time:T'),
- Array( 'vtiger_invoice:subject:subject:Invoice_Subject:V',
+ Array( 'vtiger_invoice:invoice_no:invoice_no:Invoice_invoice_no:V',
+ 'vtiger_invoice:subject:subject:Invoice_Subject:V',
'vtiger_invoice:accountid:account_id:Invoice_Account_Name:I',
'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I',
'vtiger_invoice:invoicestatus:invoicestatus:Invoice_Status:V',
Modified: vtigercrm/branches/5.0.3/modules/Invoice/CreatePDF.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Invoice/CreatePDF.php (original)
+++ vtigercrm/branches/5.0.3/modules/Invoice/CreatePDF.php Fri Apr 6 02:26:21 2007
@@ -29,7 +29,7 @@
$focus = new Invoice();
$focus->retrieve_entity_info($_REQUEST['record'],"Invoice");
$account_name = getAccountName($focus->column_fields[account_id]);
-
+$invoice_no = $focus->column_fields[invoice_no];
// **************** BEGIN POPULATE DATA ********************
Modified: vtigercrm/branches/5.0.3/modules/Invoice/EditView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Invoice/EditView.php (original)
+++ vtigercrm/branches/5.0.3/modules/Invoice/EditView.php Fri Apr 6 02:26:21 2007
@@ -30,6 +30,8 @@
require_once('include/ComboUtil.php');
require_once('include/utils/utils.php');
require_once('include/FormValidationUtil.php');
+//Addded for Custom Invoice Number
+require_once('user_privileges/CustomInvoiceNo.php');
global $app_strings,$mod_strings,$currentModule,$log,$current_user;
@@ -349,6 +351,18 @@
$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']);
$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']);
+//Added for Custom Invoice Number
+//we have check the Invoice Number for duplicate only in create view
+if($focus->mode != 'edit')
+{
+ $invoiceno=$inv_str.$inv_no;
+ if(CheckDuplicateInvoiceNumber($invoiceno))
+ echo '<br><font color="#FF0000"><b>Duplicate Invoice Number - Click <a href="index.php?module=Settings&action=CustomInvoiceNo&parenttab=Settings">here</a> to Configure the Invoice Number</b></font>'.$num_rows;
+ else
+ $smarty->assign("inv_no",($inv_str.$inv_no));
+}
+
+
$check_button = Button_Check($module);
$smarty->assign("CHECK", $check_button);
$smarty->assign("DUPLICATE", $_REQUEST['isDuplicate']);
Modified: vtigercrm/branches/5.0.3/modules/Invoice/Invoice.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Invoice/Invoice.php (original)
+++ vtigercrm/branches/5.0.3/modules/Invoice/Invoice.php Fri Apr 6 02:26:21 2007
@@ -116,6 +116,13 @@
//Based on the total Number of rows we will save the product relationship with this entity
saveInventoryProductDetails(&$this, 'Invoice');
}
+ //Added For Custom Invoice Number
+ //Here we Incrementing the new InvoiceNumber
+ if($this->mode != 'edit')
+ {
+ setInventoryInvoiceNumber("increment_invoiceno");
+ }
+
}
Modified: vtigercrm/branches/5.0.3/modules/Invoice/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Invoice/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.0.3/modules/Invoice/language/en_us.lang.php Fri Apr 6 02:26:21 2007
@@ -182,7 +182,8 @@
'Sent'=>'Sent',
'Credit Invoice'=>'Credit Invoice',
'Paid'=>'Paid',
-
+//Added to Custom Invoice Number
+'invoice_no'=>'Invoice No',
);
?>
Modified: vtigercrm/branches/5.0.3/modules/Invoice/pdf_templates/header.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Invoice/pdf_templates/header.php (original)
+++ vtigercrm/branches/5.0.3/modules/Invoice/pdf_templates/header.php Fri Apr 6 02:26:21 2007
@@ -69,7 +69,7 @@
// vtiger_invoice number block
$invBlock=array("145","65");
-$pdf->addRecBlock($id, "Invoice Number",$invBlock);
+$pdf->addRecBlock($invoice_no, "Invoice Number",$invBlock);
/* ************ End Invoice Data ************************ */
Modified: vtigercrm/branches/5.0.3/modules/Settings/language/en_us.lang.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Settings/language/en_us.lang.php (original)
+++ vtigercrm/branches/5.0.3/modules/Settings/language/en_us.lang.php Fri Apr 6 02:26:21 2007
@@ -907,5 +907,14 @@
'FILESIZE_EXCEEDS_INFO' => 'Sorry, the uploaded file exceeds the maximum filesize limit. Please try a smaller file',
'PROBLEMS_IN_FILEUPLOAD' => 'Problems in file upload. Please try again!',
+//Added fields for Invoice Number labels
+'LBL_CUSTOMIZE_INVOICE_NUMBER'=>'Customize Invoice Number',
+'LBL_CUSTOMIZE_INVOICE_NUMBER_DESCRIPTION'=>'Invoice Number Customization',
+'LBL_CUSTOM_INVOICE_NUMBER_VIEW'=>'Invoice Number Customization',
+'LBL_CUSTOMINVOICE_STRING'=>'Custom Invoice String',
+'LBL_CUSTOMINVOICE_NUMBER'=>'Custom Invoice Number',
+'LBL_INVOICE_NUMBER_PREVIEW'=>'Preview',
+'LBL_INVOICE_NUMBER_BUTTON'=>'Update Invoice Number',
+
);
?>
Modified: vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php (original)
+++ vtigercrm/branches/5.0.3/modules/Users/DefaultDataPopulator.php Fri Apr 6 02:26:21 2007
@@ -866,7 +866,8 @@
$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,74,1,'V~O',1,null,'ADV')");
//Block74
$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,0,0,100,1,73,1,'V~O',1,null,'ADV')");
-
+//Added for Custom invoice Number
+$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'invoice_no','vtiger_invoice',1,'1','invoice_no','invoice_no',1,0,0,100,3,69,1,'V~M',1,null,'BAS')");
//Invoice Details -- END
//users Details Starts Block 79,80,81
Modified: vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml
==============================================================================
--- vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml (original)
+++ vtigercrm/branches/5.0.3/schema/DatabaseSchema.xml Fri Apr 6 02:26:21 2007
@@ -3999,6 +3999,10 @@
<field name="terms_conditions" type="X" />
<field name="purchaseorder" type="C" size='200' />
<field name="invoicestatus" type="C" size='200' />
+ <field name="invoice_no" type="C" size='100' >
+ <default value="NULL" />
+ <unique />
+ </field>
<index name="invoice_purchaseorderid_idx">
<col>invoiceid</col>
More information about the vtigercrm-commits
mailing list