[Vtigercrm-commits] [vtiger-commits] r10196 - in /vtigercrm/branches/5.0.3: Smarty/templates/salesEditView.tpl modules/Accounts/Account.js modules/Accounts/AddressChange.php modules/Accounts/Save.php modules/Contacts/EditView.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri Feb 16 11:16:03 EST 2007


Author: saraj
Date: Fri Feb 16 09:15:49 2007
New Revision: 10196

Log:
Contact account should chand for change in account address. Fixes #2812

Added:
    vtigercrm/branches/5.0.3/modules/Accounts/AddressChange.php
Modified:
    vtigercrm/branches/5.0.3/Smarty/templates/salesEditView.tpl
    vtigercrm/branches/5.0.3/modules/Accounts/Account.js
    vtigercrm/branches/5.0.3/modules/Accounts/Save.php
    vtigercrm/branches/5.0.3/modules/Contacts/EditView.php

Modified: vtigercrm/branches/5.0.3/Smarty/templates/salesEditView.tpl
==============================================================================
--- vtigercrm/branches/5.0.3/Smarty/templates/salesEditView.tpl (original)
+++ vtigercrm/branches/5.0.3/Smarty/templates/salesEditView.tpl Fri Feb 16 09:15:49 2007
@@ -41,6 +41,14 @@
                 );
         {rdelim}
 {rdelim}
+function AddressSync(Addform,id)
+{ldelim}
+        if(formValidate() == true)
+        {ldelim}  
+	      checkAddress(Addform,id);
+        {rdelim}
+{rdelim}
+
 </script>
 
 		{include file='Buttons_List1.tpl'}	
@@ -102,8 +110,10 @@
 											<div align="center">
 												{if $MODULE eq 'Webmails'}
 													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.module.value='Webmails';this.form.send_mail.value='true';this.form.record.value='{$ID}'" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+											{elseif $MODULE eq 'Accounts'}
+											<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted();  AddressSync(this.form,{$ID});"  type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
 												{else}
-													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted(); return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmButton small save" onclick="this.form.action.value='Save'; displaydeleted(); return formValidate() " type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
 												{/if}
 													<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 											</div>
@@ -171,16 +181,19 @@
 									   <tr>
 										<td  colspan=4 style="padding:5px">
 											<div align="center">
-												{if $MODULE eq 'Emails'}
-													<input title="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_KEY}" class="crmbutton small create" onclick="window.open('index.php?module=Users&action=lookupemailtemplates&entityid={$ENTITY_ID}&entity={$ENTITY_TYPE}','emailtemplate','top=100,left=200,height=400,width=300,menubar=no,addressbar=no,status=yes')" type="button" name="button" value="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL}">
-													<input title="{$MOD.LBL_SEND}" accessKey="{$MOD.LBL_SEND}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.send_mail.value='true'; return formValidate()" type="submit" name="button" value="  {$MOD.LBL_SEND}  " >
-												{/if}
-												{if $MODULE eq 'Webmails'}
-													<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.module.value='Webmails';this.form.send_mail.value='true';this.form.record.value='{$ID}'" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-												{else}
-                                				                                	<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  displaydeleted();return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
-												{/if}
-                                                                					<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
+										{if $MODULE eq 'Emails'}
+										<input title="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_TITLE}" accessKey="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_KEY}" class="crmbutton small create" onclick="window.open('index.php?module=Users&action=lookupemailtemplates&entityid={$ENTITY_ID}&entity={$ENTITY_TYPE}','emailtemplate','top=100,left=200,height=400,width=300,menubar=no,addressbar=no,status=yes')" type="button" name="button" value="{$APP.LBL_SELECTEMAILTEMPLATE_BUTTON_LABEL}">
+										<input title="{$MOD.LBL_SEND}" accessKey="{$MOD.LBL_SEND}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.send_mail.value='true'; return formValidate()" type="submit" name="button" value="  {$MOD.LBL_SEND}  " >
+										{/if}
+										{if $MODULE eq 'Webmails'}
+										<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';this.form.module.value='Webmails';this.form.send_mail.value='true';this.form.record.value='{$ID}'" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{elseif $MODULE eq 'Accounts'}
+                                		                     <input type='hidden'  name='address_change' value='no'>
+                                                                             <input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save'; displaydeleted();  AddressSync(this.form,{$ID}) " type="button" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >		
+										{else}
+              				                                	<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="crmbutton small save" onclick="this.form.action.value='Save';  displaydeleted();return formValidate()" type="submit" name="button" value="  {$APP.LBL_SAVE_BUTTON_LABEL}  " style="width:70px" >
+										{/if}
+                                               					<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="crmbutton small cancel" onclick="window.history.back()" type="button" name="button" value="  {$APP.LBL_CANCEL_BUTTON_LABEL}  " style="width:70px">
 											</div>
 										</td>
 									   </tr>

Modified: vtigercrm/branches/5.0.3/modules/Accounts/Account.js
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Accounts/Account.js (original)
+++ vtigercrm/branches/5.0.3/modules/Accounts/Account.js Fri Feb 16 09:15:49 2007
@@ -242,4 +242,52 @@
         window.opener.document.createTodo.task_parent_name.value = product_name;
         window.opener.document.createTodo.task_parent_id.value = product_id;
 }
-
+//Added for dinakaran---------STARTS----------
+//When changing the Account Address Information  it should also change the related contact address.
+function checkAddress(form,id)
+{
+		var bill_street = form.bill_street.value;
+                var ship_street = form.ship_street.value;
+                var bill_city   = form.bill_city.value;
+                var ship_city   = form.ship_city.value;
+                var bill_state  = form.bill_state.value;
+                var ship_state  = form.ship_state.value;
+                var bill_code   = form.bill_code.value;
+                var ship_code   = form.ship_code.value;
+                var bill_country= form.bill_country.value;
+                var ship_country= form.ship_country.value;
+                var bill_pobox  = form.bill_pobox.value;
+                var ship_pobox  = form.ship_pobox.value;
+		
+
+       var url = "bill_street="+bill_street+"&ship_street="+ship_street+"&bill_city="+bill_city+"&ship_city="+ship_city+"&bill_state="+bill_state+"&ship_state="+ship_state+"&bill_code="+bill_code+"&ship_code="+ship_code+"&bill_country="+bill_country+"&ship_country="+ship_country+"&bill_pobox="+bill_pobox+"&ship_pobox="+ship_pobox+"&record="+id;		
+	
+		$("status").style.display="inline";
+                        new Ajax.Request(
+                              'index.php',
+                                {queue: {position: 'end', scope: 'command'},
+                                        method: 'post',
+                                        postBody:"module=Accounts&action=AccountsAjax&ajax=true&file=AddressChange&"+url,
+                                        onComplete: function(response) {
+						if(response.responseText  == 'address_change')
+                                        	{
+                                            		if(confirm("Do you want to change the addresses of the Contacts related to this Account?") == true)
+								{
+									form.address_change.value='yes';
+									form.submit();	
+								}
+								else
+								{	
+	                                                                form.submit();
+								}
+						}
+						else
+						{
+							form.submit();	
+						}
+                      			}
+			}
+                        );
+
+}
+//Added for dinakaran --------ENDS ------------

Modified: vtigercrm/branches/5.0.3/modules/Accounts/Save.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Accounts/Save.php (original)
+++ vtigercrm/branches/5.0.3/modules/Accounts/Save.php Fri Feb 16 09:15:49 2007
@@ -95,6 +95,15 @@
 	}
 }*/
 
+//This is added dinakaran----------STARTS--------------
+//When changing the Account Address Information  it should also change the related contact address.
+if($focus->mode == 'edit' && $_REQUEST['address_change'] == 'yes')
+{
+                $query = "update vtiger_contactaddress set mailingcity='".$focus->column_fields['bill_city']."',mailingstreet='".$focus->column_fields['bill_street']."',mailingcountry='".$focus->column_fields['bill_country']."',mailingzip='".$focus->column_fields['bill_code']."',mailingpobox='".$focus->column_fields['bill_pobox']."',mailingstate='".$focus->column_fields['bill_state']."',othercountry='".$focus->column_fields['ship_country']."',othercity='".$focus->column_fields['ship_city']."',otherstate='".$focus->column_fields['ship_state']."',otherzip='".$focus->column_fields['ship_code']."',otherstreet='".$focus->column_fields['ship_street']."',otherpobox='".$focus->column_fields['ship_pobox']."'  where contactaddressid in (select contactid from vtiger_contactdetails where accountid=".$focus->id.")" ;
+                $adb->query($query);
+}
+//This is added dinakaran----------STARTS--------------
+
 //$focus->saveentity("Accounts");
 $focus->save("Accounts");
 //echo '<BR>';

Modified: vtigercrm/branches/5.0.3/modules/Contacts/EditView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Contacts/EditView.php (original)
+++ vtigercrm/branches/5.0.3/modules/Contacts/EditView.php Fri Feb 16 09:15:49 2007
@@ -84,6 +84,9 @@
         $focus->column_fields['otherzip']=$acct_focus->column_fields['ship_code'];
         $focus->column_fields['mailingcountry']=$acct_focus->column_fields['bill_country'];
         $focus->column_fields['othercountry']=$acct_focus->column_fields['ship_country'];
+	$focus->column_fields['mailingpobox']=$acct_focus->column_fields['bill_pobox'];
+	$focus->column_fields['otherpobox']=$acct_focus->column_fields['ship_pobox'];
+
         $log->debug("Accountid Id from the request is ".$_REQUEST['account_id']);
 
 }
@@ -101,7 +104,6 @@
 	$smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS'));
 	$smarty->assign("ADVBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'ADV'));
 }
-
 $smarty->assign("OP_MODE",$disp_view);
 
 //needed when creating a new contact with a default vtiger_account value passed in





More information about the vtigercrm-commits mailing list