vtigerCRM-Spain

vtigerCRM-Spain::Añadir Merge a Modulo

  • Permitir subir plantillas asociadas al nuevo modulo
    • modules/Settings/upload.php, alrededor linea 57 añadir módulo al vector $template
    • Smarty/templates/CreateWordTemplate.tpl, alrededor línea 71 añadir módulo a caja selección. Seleccionar la etiqueta del fichero include/language/idioma.php correspondiente, están casi todos.
  • Activar elementos de seleccion de combinar en vista de lista y detalle del módulo
    • Editar module/[module]/ListView.php y añadir el siguiente bloque antes de la línea
      $record_string= $app_strings[LBL_SHOWING]." " .$start_rec." - ".$end_rec." " .$app_strings[LBL_LIST_OF] ." ".$noofrows;
//mass merge for word templates -- *TSolucio Joe Bordes* 07-May-02
while($row = $adb->fetch_array($list_result))
{
	$ids[] = $row["crmid"];
}
if(isset($ids))
{
	$smarty->assign("ALLIDS", implode($ids,";"));
}
if(isPermitted('PurchaseOrder','Merge') == 'yes') 
{
	$wordTemplateResult = fetchWordTemplateList('PurchaseOrder');
	$tempCount = $adb->num_rows($wordTemplateResult);
	$tempVal = $adb->fetch_array($wordTemplateResult);
	for($templateCount=0;$templateCount<$tempCount;$templateCount++)
	{
		$optionString .="<option value=\"".$tempVal["templateid"]."\">" .$tempVal["filename"] ."</option>";
		$tempVal = $adb->fetch_array($wordTemplateResult);
	}
	if($tempCount > 0)
	{
		$smarty->assign("WORDTEMPLATEOPTIONS","<td>".$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']."</td><td style=\"padding-left:5px;padding-right:5px\"><select class=\"small\" name=\"mergefile\">".$optionString."</select></td>");

		$smarty->assign("MERGEBUTTON","<td><input title=\"$app_strings[LBL_MERGE_BUTTON_TITLE]\" accessKey=\"$app_strings[LBL_MERGE_BUTTON_KEY]\" class=\"crmbutton small create\" onclick=\"return massMerge('Accounts')\" type=\"submit\" name=\"Merge\" value=\" $app_strings[LBL_MERGE_BUTTON_LABEL]\"></td>");
	}
	else
        {
                require("user_privileges/user_privileges_1.php");
                if($is_admin == true)
                {
		$smarty->assign("MERGEBUTTON",'<td><a href=index.php?module=Settings&action=upload&tempModule='.$currentModule.'>'. $app_strings["LBL_CREATE_MERGE_TEMPLATE"].'</td>');
                }
        }
}

//mass merge for word templates
  • Editar module/[module]/DetailView.php y añadir el siguiente bloque antes de la línea
    $tabid = getTabid("SalesOrder");
if(isPermitted('SalesOrder','Merge','') == 'yes')
{
	$smarty->assign("MERGEBUTTON","permitted");
	require_once('include/utils/UserInfoUtil.php');
	$wordTemplateResult = fetchWordTemplateList('SalesOrder');
	$tempCount = $adb->num_rows($wordTemplateResult);
	$tempVal = $adb->fetch_array($wordTemplateResult);
	for($templateCount=0;$templateCount<$tempCount;$templateCount++)
	{
		$optionString[$tempVal["templateid"]]=$tempVal["filename"];
		$tempVal = $adb->fetch_array($wordTemplateResult);
	}
	$smarty->assign("TEMPLATECOUNT",$tempCount);
	$smarty->assign("WORDTEMPLATEOPTIONS",$app_strings['LBL_SELECT_TEMPLATE_TO_MAIL_MERGE']);
        $smarty->assign("TOPTIONS",$optionString);
}
  • Si es un modulo de Inventario hay que añadir el siguiente codigo a la plantilla Smarty/templates/Inventory/InventoryDetailView.tpl, despues del bloque de TagCloud y antes de cerrar la celda (/td)
<!-- Document Merge-->
<br>
{if $MERGEBUTTON eq 'permitted'}
<form action="index.php" method="post" name="TemplateMerge" id="form">
<input type="hidden" name="module" value="{$MODULE}">
<input type="hidden" name="parenttab" value="{$CATEGORY}">
<input type="hidden" name="record" value="{$ID}">
<input type="hidden" name="action">
  				<table border=0 cellspacing=0 cellpadding=0 width=100% class="rightMailMerge">
  				<tr>
  					   <td class="rightMailMergeHeader"><b>{$WORDTEMPLATEOPTIONS}</b></td>
  				</tr>
  				<tr style="height:25px">
	<td class="rightMailMergeContent">
		{if $TEMPLATECOUNT neq 0}
		<select name="mergefile">{foreach key=templid item=tempflname from=$TOPTIONS}<option value="{$templid}">{$tempflname}</option>{/foreach}</select>
                                   <input class="crmbutton small create" value="{$APP.LBL_MERGE_BUTTON_LABEL}" onclick="this.form.action.value='Merge';" type="submit"></input> 
		{else}
		<a href=index.php?module=Settings&action=upload&tempModule={$MODULE}>{$APP.LBL_CREATE_MERGE_TEMPLATE}</a>
		{/if}
	</td>
  				</tr>
  				</table>
</form>
{/if}
  • Añadir la utilidad y el modulo a cada perfil. El siguiente script ejecutado como administrador hará el trabajo:
    <?php
    /*********************************************************************************
    ** The contents of this file are subject to the Mozilla Public License. You may
    * not use this file except in compliance with the License The Original Code is:
    * JPLTSolucio, S,L, Open Source based on vtigerCRM The Initial Developer of the
    * Original Code is JPL TSolucio, S.L. Portions created by vtiger are Copyright
    * (C) vtiger. All Rights Reserved.
    *
    * This script adds Merge capacity to the SalesOrder entity for all profiles
    * 
    * *******************************************************************************/
    
    require_once('include/database/PearDatabase.php');
    require_once('include/utils/CommonUtils.php');
    require_once('modules/Users/CreateUserPrivilegeFile.php');
    
      $ModuleMerge=22; // SalesOrder
      // Get profile information once for all
      $profile_query  = 'select distinct profileid from vtiger_profile;';
      $profile_result = $adb->query($profile_query);
      $num_profiles   = $adb->num_rows($profile_result);
      // For each existing profile add merge
      for($p=0; $p<$num_profiles; $p++)
      {
        $profid = $adb->query_result($profile_result,$p,'profileid');
        $insp2utility ="INSERT INTO `vtiger_profile2utility` ";
        $insp2utility.="(`profileid`, `tabid`, `activityid`, `permission`) VALUES ($profid, $ModuleMerge, 8, 1);";
        $adb->query($insp2utility);
      }
    
      // regenerate tabdata.php and sharing/privileges files
      create_tab_data_file();
      RecalculateSharingRules();
    ?>
  • Copiar el script Merge.php de Cuentas o Contactos al directorio principal del modulo
  • Añadir los campos y etiquetas en el bucle for que llena la variable $csvheader
  • Modificar las consultas SQL para conseguir tener disponibles los campos necesarios
  • Añadir la siguiente línea al script [module].js
    document.write("<script type='text/javascript' src='include/js/Merge.js'></"+"script>");