[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/modules/Utilities/ -> Merge.php (source)

   1  <html>
   2  <body>
   3  <?php
   4  /*+********************************************************************************
   5   * The contents of this file are subject to the vtiger CRM Public License Version 1.0
   6   * ("License"); You may not use this file except in compliance with the License
   7   * The Original Code is:  vtiger CRM Open Source
   8   * The Initial Developer of the Original Code is vtiger.
   9   * Portions created by vtiger are Copyright (C) vtiger.
  10   * All Rights Reserved.
  11   ********************************************************************************/
  12  
  13  require_once ('include/database/PearDatabase.php');
  14  global $default_charset;
  15  
  16  // Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
  17  $randomfilename = "vt_" . str_replace(array("."," "), "", microtime());
  18  
  19  $mergeFileName = vtlib_purify($_REQUEST['mergefile']);
  20  //get the particular file from db and store it in the local hard disk.
  21  //store the path to the location where the file is stored and pass it  as parameter to the method 
  22  $sql = "select filename,data,filesize from vtiger_wordtemplatestorage where filename=?";
  23  $result = $adb->pquery($sql, array($mergeFileName));
  24  $temparray = $adb->fetch_array($result);
  25  
  26  $fileContent = $temparray['data'];
  27  $filename=html_entity_decode($temparray['filename'], ENT_QUOTES, $default_charset);
  28  // Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
  29  $filename= $randomfilename . "_word.doc";
  30  
  31  $filesize=$temparray['filesize'];
  32  $wordtemplatedownloadpath =$_SERVER['DOCUMENT_ROOT'] ."/test/wordtemplatedownload/";
  33  checkFileAccess($wordtemplatedownloadpath);
  34  $handle = fopen($wordtemplatedownloadpath .$filename,"wb") ;
  35  fwrite($handle,base64_decode($fileContent),$filesize);
  36  fclose($handle);
  37  
  38  
  39  $query = "SELECT * FROM " .$adb->sql_escape_string($_REQUEST["module"]) ." WHERE id = ?";
  40  $result = $adb->pquery($query, array($_REQUEST['record']));
  41  
  42  $y=$adb->num_fields($result);
  43  
  44  for ($x=0; $x<$y; $x++)
  45  {
  46      $columnNames[$x] = "CONTACT_".strtoupper($adb->field_name($result, $x));
  47  } 
  48  
  49  $columnValues = $adb->fetch_array($result);
  50  for ($x=0; $x<$y; $x++)
  51  {
  52      $columnValString[$x] = $columnValues[$x];
  53  }
  54  
  55  $columnString = implode(",",$columnNames);
  56  $columnValString = implode(",",$columnValString);
  57  
  58  echo"<script type=\"text/javascript\">
  59  var dHdr = '$columnString';
  60  var dSrc = '$columnValString';
  61  </script>";
  62  ?>
  63  
  64  <OBJECT Name="vtigerVM" codebase="http://<?php echo $_SERVER["HTTP_HOST"] ?>/modules/Settings/vtigerVM.CAB#Version1,0,0,1"
  65  id="objMMPage" classid="clsid:42C50C38-1984-4393-A736-890357E7112B" width=0 height=0></object><!--METADATA TYPE="MsHtmlPageDesigner" endspan-->
  66  <Script>
  67          if(objMMPage.bDLTempDoc("http://"+"<?php echo $_SERVER["HTTP_HOST"] ?>/test/wordtemplatedownload/"+"<?php echo $filename?>","MMTemplate.doc"))
  68  {
  69      try
  70      {
  71          if(objMMPage.Init())
  72          {
  73              objMMPage.vLTemplateDoc();
  74              //objMMPage.vGetHDSrc(dHdr,dSrc);
  75              objMMPage.vBulkHDSrc(dHdr,dSrc);
  76             //objMMPage.vOpenDoc();
  77              objMMPage.vBulkOpenDoc();
  78              objMMPage.UnInit()
  79              document.write("Template Document Merged with selected contacts data");
  80          }        
  81      }catch(errorObject)
  82      {
  83      }
  84  }
  85  </Script>
  86  </body>
  87  </html>
  88  


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1