";
// Under the Sugar Public License referenced above, you are required to leave in all copyright statements
diff --git a/install/CheckSystem.php b/install/CheckSystem.php
index 4220c19..016a73b 100644
--- a/install/CheckSystem.php
+++ b/install/CheckSystem.php
@@ -56,7 +56,7 @@ $check_mysql_extension = Common_Install_Wizard_Utils::check_mysql_extension();
-
+
@@ -69,7 +69,7 @@ $check_mysql_extension = Common_Install_Wizard_Utils::check_mysql_extension();
diff --git a/install/VerifyDBHealth.php b/install/VerifyDBHealth.php
index a61dbd6..719e8e4 100644
--- a/install/VerifyDBHealth.php
+++ b/install/VerifyDBHealth.php
@@ -63,7 +63,7 @@ if ($_REQUEST['viewDBReport'] == true) {
-
+
-fetch_array($result);
$fileContent = $temparray['data'];
$filename=html_entity_decode($temparray['filename'], ENT_QUOTES, $default_charset);
+$extension=GetFileExtension($filename);
// Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$filename= $randomfilename . "_word.doc";
+$filename= $randomfilename . "_mmrg.$extension";
$filesize=$temparray['filesize'];
$wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/";
@@ -62,6 +43,28 @@ $handle = fopen($wordtemplatedownloadpath.$filename,"wb");
fwrite($handle,base64_decode($fileContent),$filesize);
fclose($handle);
+if (GetFileExtension($filename)=="doc") {
+echo "
+
+";
+}
+
//<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
$mass_merge = $_REQUEST['allselectedboxes'];
$single_record = $_REQUEST['record'];
@@ -104,13 +107,14 @@ global $current_user;
require('user_privileges/user_privileges_'.$current_user->id.'.php');
if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0 || $module == "Users" || $module == "Emails")
{
- $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 75 and vtiger_field.presence in (0,2) order by vtiger_field.tablename";
+ // $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (6) and vtiger_field.block <> 75 and vtiger_field.presence in (0,2) order by vtiger_field.tablename";
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid where vtiger_field.tabid in (6) and vtiger_field.uitype <> 61 and block <> 75 and block <> 30 and vtiger_field.presence in (0,2) and vtiger_field.tablename <> 'vtiger_campaignrelstatus' order by vtiger_field.tablename";
$params1 = array();
}
else
{
$profileList = getCurrentUserProfileList();
- $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (4,6) and vtiger_field.block <> 75 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (". generateQuestionMarks($profileList) .") and vtiger_field.presence in (0,2) GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
+ $query1="select vtiger_tab.name,vtiger_field.tablename,vtiger_field.columnname,vtiger_field.fieldlabel from vtiger_field inner join vtiger_tab on vtiger_tab.tabid = vtiger_field.tabid INNER JOIN vtiger_profile2field ON vtiger_profile2field.fieldid=vtiger_field.fieldid INNER JOIN vtiger_def_org_field ON vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid in (6) and vtiger_field.uitype <> 61 and vtiger_field.block <> 75 AND vtiger_profile2field.visible=0 AND vtiger_def_org_field.visible=0 AND vtiger_profile2field.profileid IN (". generateQuestionMarks($profileList) .") and vtiger_field.presence in (0,2) and vtiger_field.tablename <> 'vtiger_campaignrelstatus' GROUP BY vtiger_field.fieldid order by vtiger_field.tablename";
$params1 = array($profileList);
//Postgres 8 fixes
if( $adb->dbType == "pgsql")
@@ -178,6 +182,18 @@ for ($x=0; $x<$y; $x++)
}
+// Ordena etiquetas más grandes primero para que no se sutituyan subcadenas en el documento
+// Por ejemplo, pongo LEAD_TIPOVIVIENDA delante de LEAD_TIPO, para que no se sustituya la subcadena LEAD_TIPO
+$labels_length=$field_label;
+function strlength($label,$clave) {
+ global $labels_length;
+ $labels_length[$clave] = strlen($label);
+}
+array_walk($labels_length,'strlength');
+array_multisort($labels_length, $field_label, $querycolumns);
+$field_label=array_reverse($field_label);
+$querycolumns=array_reverse($querycolumns);
+$labels_length=array_reverse($labels_length);
$csvheader = implode(",",$field_label);
//<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>
@@ -240,7 +256,20 @@ while($columnValues = $adb->fetch_array($result))
//if value contains any line feed or carriage return replace the value with ".value."
if (preg_match ("/(\r?\n)/", $actual_values[$x]))
{
- $actual_values[$x] = '"'.$actual_values[$x].'"';
+ // <<< pag 21-Sep-2011 >>>
+
+ // Replacement see: php.net/manual/en/function.str-replace.php
+ // $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
+ $order = array("\r\n", "\n", "\r"); // order of replacement matters
+ $replace = '!!'; // you choose your appropriate delimiters
+ // They'll be replaced by an OO/LO macro once the resulting document has been downloaded
+
+ // We now processes \r\n's first so they aren't converted twice.
+ // $newstr = str_replace($order, $replace, $str);
+ $actual_values[$x] = str_replace($order, $replace, $actual_values[$x]);
+ // <<< pag 21-Sep-2011 END >>>
+
+ // not needed ??? // $actual_values[$x] = '"'.$actual_values[$x].'"';
}
$actual_values[$x] = decode_html(str_replace(","," ",$actual_values[$x]));
}
@@ -251,14 +280,60 @@ $csvdata = implode($mergevalue,"###");
{
die("No fields to do Merge");
}
+echo "
";
+$extension = GetFileExtension($filename);
+if($extension == "doc")
+{
+ // Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
+ $datafilename = $randomfilename . "_data.csv";
-// Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$datafilename = $randomfilename . "_data.csv";
+ $handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
+ fwrite($handle,$csvheader."\r\n");
+ fwrite($handle,str_replace("###","\r\n",$csvdata));
+ fclose($handle);
+}
+else if($extension == "odt")
+{
+ //delete old .odt files in the wordtemplatedownload directory
+ foreach (glob("$wordtemplatedownloadpath/*.odt") as $delefile)
+ {
+ unlink($delefile);
+ }
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $temp_dir=entpack($filename,$wordtemplatedownloadpath,$fileContent);
+ $concontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ $new_filecontent=crmmerge($csvheader,$concontent,$idx,'htmlspecialchars');
+ $stycontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ $new_filestyle=crmmerge($csvheader,$stycontent,$idx,'htmlspecialchars');
+ packen($entityid.$filename,$wordtemplatedownloadpath,$temp_dir,$new_filecontent,$new_filestyle);
-$handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
-fwrite($handle,$csvheader."\r\n");
-fwrite($handle,str_replace("###","\r\n",$csvdata));
-fclose($handle);
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ remove_dir($wordtemplatedownloadpath.$temp_dir);
+ }
+}
+else if($extension == "rtf")
+{
+ foreach (glob("$wordtemplatedownloadpath/*.rtf") as $delefile)
+ {
+ unlink($delefile);
+ }
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ $filecontent = base64_decode($fileContent);
+ foreach($mass_merge as $idx => $entityid) {
+ $handle = fopen($wordtemplatedownloadpath.$entityid.$filename,"wb");
+ $new_filecontent = crmmerge($csvheader,$filecontent,$idx,'utf8Unicode');
+ fwrite($handle,$new_filecontent);
+ fclose($handle);
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ }
+}
+else
+{
+ die("unknown file format");
+}
?>
-fetch_array($result);
$fileContent = $temparray['data'];
$filename=html_entity_decode($temparray['filename'], ENT_QUOTES, $default_charset);
+$extension=GetFileExtension($filename);
// Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$filename= $randomfilename . "_word.doc";
+$filename= $randomfilename . "_mmrg.$extension";
$filesize=$temparray['filesize'];
$wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/";
@@ -60,6 +43,27 @@ $handle = fopen($wordtemplatedownloadpath .$filename,"wb");
fwrite($handle,base64_decode($fileContent),$filesize);
fclose($handle);
+if (GetFileExtension($filename)=="doc") {
+echo "
+
+";
+}
//<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>
$mass_merge = $_REQUEST['allselectedboxes'];
@@ -160,9 +164,30 @@ for ($x=0; $x<$y; $x++)
}
+// Ordena etiquetas más grandes primero para que no se sutituyan subcadenas en el documento
+// Por ejemplo, pongo LEAD_TIPOVIVIENDA delante de LEAD_TIPO, para que no se sustituya la subcadena LEAD_TIPO
+// Order larger labels to avoid first substring is substituted in the document
+// For example, LEAD_TIPOVIVIENDA before LEAD_TIPO should not replace the substring LEAD_TIPO
+//
+$labels_length=$field_label;
+function strlength($label,$clave) {
+ global $labels_length;
+ $labels_length[$clave] = strlen($label);
+}
+array_walk($labels_length,'strlength');
+array_multisort($labels_length, $field_label, $querycolumns);
+$field_label=array_reverse($field_label);
+$querycolumns=array_reverse($querycolumns);
+
+$labels_length=array_reverse($labels_length);
$csvheader = implode(",",$field_label);
//echo $csvheader;
//<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>
+
+
+// check if custom field CONTACT_MAILINGADDRESS exists and is not empty
+// if not empty remove all other relevant address fields fom $csvheader & query
+
if(count($querycolumns) > 0)
{
@@ -224,7 +249,20 @@ while($columnValues = $adb->fetch_array($result))
//if value contains any line feed or carriage return replace the value with ".value."
if (preg_match ("/(\r?\n)/", $actual_values[$x]))
{
- $actual_values[$x] = '"'.$actual_values[$x].'"';
+ // <<< pag 21-Sep-2011 >>>
+
+ // Replacement see: php.net/manual/en/function.str-replace.php
+ // $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
+ $order = array("\r\n", "\n", "\r"); // order of replacement matters
+ $replace = '!!'; // you choose your appropriate delimiters
+ // They'll be replaced by an OO/LO macro once the resulting document has been downloaded
+
+ // We now processes \r\n's first so they aren't converted twice.
+ // $newstr = str_replace($order, $replace, $str);
+ $actual_values[$x] = str_replace($order, $replace, $actual_values[$x]);
+ // <<< pag 21-Sep-2011 END >>>
+
+ // not needed ??? // $actual_values[$x] = '"'.$actual_values[$x].'"';
}
$actual_values[$x] = decode_html(str_replace(","," ",$actual_values[$x]));
}
@@ -235,52 +273,102 @@ $csvdata = implode($mergevalue,"###");
{
die("No fields to do Merge");
}
-// Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$datafilename = $randomfilename . "_data.csv";
-
-$handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
-fwrite($handle,$csvheader."\r\n");
-fwrite($handle,str_replace("###","\r\n",$csvdata));
-fclose($handle);
+echo "
";
+$extension = GetFileExtension($filename);
+if($extension == "doc")
+{
+ // Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
+ $datafilename = $randomfilename . "_data.csv";
+ $handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
+ fwrite($handle,$csvheader."\r\n");
+ fwrite($handle,str_replace("###","\r\n",$csvdata));
+ fclose($handle);
+}
+else if($extension == "odt")
+{
+ //delete old .odt files in the wordtemplatedownload directory
+ foreach (glob("$wordtemplatedownloadpath/*.odt") as $delefile)
+ {
+ unlink($delefile);
+ }
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $temp_dir=entpack($filename,$wordtemplatedownloadpath,$fileContent);
+ $concontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ $new_filecontent=crmmerge($csvheader,$concontent,$idx,'htmlspecialchars');
+ // die;
+ $stycontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ // die;
+ unlink($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ $new_filestyle=crmmerge($csvheader,$stycontent,$idx,'htmlspecialchars');
+ // die;
+ packen($entityid.$filename,$wordtemplatedownloadpath,$temp_dir,$new_filecontent,$new_filestyle);
+
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ remove_dir($wordtemplatedownloadpath.$temp_dir);
+ }
+}
+else if($extension == "rtf")
+{
+ foreach (glob("$wordtemplatedownloadpath/*.rtf") as $delefile)
+ {
+ unlink($delefile);
+ }
+ $filecontent = base64_decode($fileContent);
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $handle = fopen($wordtemplatedownloadpath.$entityid.$filename,"wb");
+ $new_filecontent = crmmerge($csvheader,$filecontent,$idx,'utf8Unicode');
+ fwrite($handle,$new_filecontent);
+ fclose($handle);
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ }
+}
+else
+{
+ die("unknown file format");
+}
?>
-
-
diff --git a/modules/CustomView/CustomView.php b/modules/CustomView/CustomView.php
index 0166a38..d34b880 100644
--- a/modules/CustomView/CustomView.php
+++ b/modules/CustomView/CustomView.php
@@ -1081,8 +1081,8 @@ class CustomView extends CRMEntity {
// Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/5423
if ($columns[1] == 'birthday') {
$tableColumnSql = "DATE_FORMAT(" . $columns[0] . "." . $columns[1] . ", '%m%d')";
- $startDateTime = "DATE_FORMAT('$startDate', '%m%d')";
- $endDateTime = "DATE_FORMAT('$endDate', '%m%d')";
+ $startDateTime = "DATE_FORMAT('$startDateTime', '%m%d')";
+ $endDateTime = "DATE_FORMAT('$endDateTime', '%m%d')";
$stdfiltersql = $tableColumnSql . " BETWEEN " . $startDateTime . " and " . $endDateTime;
} else {
if ($this->customviewmodule == 'Calendar' && ($columns[1] == 'date_start' || $columns[1] == 'due_date')) {
diff --git a/modules/CustomView/Save.php b/modules/CustomView/Save.php
index 4ee0d82..305d1ba 100644
--- a/modules/CustomView/Save.php
+++ b/modules/CustomView/Save.php
@@ -13,6 +13,8 @@ global $adb;
global $log, $current_user;
$cvid = (int) vtlib_purify($_REQUEST["record"]);
+$buttonname = vtlib_purify($_REQUEST["newsave"]);
+if ($buttonname) unset($cvid);
$cvmodule = vtlib_purify($_REQUEST["cvmodule"]);
$parenttab = getParentTab();
$return_action = vtlib_purify($_REQUEST["return_action"]);
diff --git a/modules/Documents/ListView.php b/modules/Documents/ListView.php
index 1c02414..0b9c527 100644
--- a/modules/Documents/ListView.php
+++ b/modules/Documents/ListView.php
@@ -100,7 +100,7 @@ $smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH",$image_path);
$smarty->assign("MODULE",$currentModule);
-$smarty->assign("SINGLE_MOD",getTranslatedString('SINGLE_'.$currentModule, $currentModule));
+$smarty->assign("SINGLE_MOD",'SINGLE_'.$currentModule);
$smarty->assign("BUTTONS",$other_text);
$smarty->assign("CATEGORY",$category);
$smarty->assign('MAX_RECORDS', $list_max_entries_per_page);
diff --git a/modules/Emails/EditView.php b/modules/Emails/EditView.php
index c21b351..1ca952b 100644
--- a/modules/Emails/EditView.php
+++ b/modules/Emails/EditView.php
@@ -87,6 +87,43 @@ elseif(isset($_REQUEST['sendmail']) && $_REQUEST['sendmail'] !='')
$smarty->assign('IDLISTS',$mailids['idlists']);
$focus->mode = '';
}
+elseif(!empty($_REQUEST['invmodid']))
+{
+ $crmid = vtlib_purify($_REQUEST['invmodid']);
+ switch (getSalesEntityType($crmid)) {
+ case 'Invoice':
+ $emailcrmid=$adb->query_result($adb->pquery('select case accountid when 0 then contactid else accountid end from vtiger_invoice where invoiceid=?',array($crmid)),0,0);
+ break;
+ case 'Quotes':
+ $emailcrmid=$adb->query_result($adb->pquery('select case accountid when 0 then contactid else accountid end from vtiger_quotes where quoteid=?',array($crmid)),0,0);
+ break;
+ case 'SalesOrder':
+ $emailcrmid=$adb->query_result($adb->pquery('select case accountid when 0 then contactid else accountid end from vtiger_salesorder where salesorderid=?',array($crmid)),0,0);
+ break;
+ case 'PurchaseOrder':
+ $emailcrmid=$adb->query_result($adb->pquery('select case vendorid when 0 then contactid else vendorid end from vtiger_purchaseorder where purchaseorderid=?',array($crmid)),0,0);
+ break;
+ }
+ $pmodule = getSalesEntityType($emailcrmid);
+ switch ($pmodule) {
+ case 'Accounts':
+ $_REQUEST["field_lists"]=9;
+ break;
+ case 'Contacts':
+ $_REQUEST["field_lists"]=80;
+ break;
+ case 'Vendors':
+ $_REQUEST["field_lists"]=292;
+ break;
+ }
+ $_REQUEST["idlist"]=$emailcrmid;
+ $mailids = get_to_emailids($pmodule);
+ if($mailids['mailds'] != '')
+ $to_add = trim($mailids['mailds'],",").",";
+ $smarty->assign('TO_MAIL',$to_add);
+ $smarty->assign('IDLISTS',$mailids['idlists']);
+ $focus->mode = '';
+}
// INTERNAL MAILER
if($_REQUEST["internal_mailer"] == "true") {
diff --git a/modules/Emails/Emails.php b/modules/Emails/Emails.php
index a393992..89a909b 100644
--- a/modules/Emails/Emails.php
+++ b/modules/Emails/Emails.php
@@ -511,7 +511,7 @@ class Emails extends CRMEntity {
/** Function to get the emailids for the given ids form the request parameters
* It returns an array which contains the mailids and the parentidlists
*/
-function get_to_emailids($module) {global $log;$log->fatal($_REQUEST);
+function get_to_emailids($module) {
global $adb, $current_user, $log;
require_once 'include/Webservices/Query.php';
//$idlists1 = "";
@@ -551,11 +551,16 @@ function get_to_emailids($module) {global $log;$log->fatal($_REQUEST);
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_contactdetails.contactid
LEFT JOIN vtiger_contactscf ON vtiger_contactdetails.contactid = vtiger_contactscf.contactid
WHERE vtiger_crmentity.deleted=0 AND vtiger_contactdetails.contactid IN ('.generateQuestionMarks($idlist).') AND vtiger_contactdetails.emailoptout=0';
- } else {
+ } else if ($module == 'Accounts'){
$query = 'SELECT vtiger_account.accountname, '.implode(",", $emailFields).',vtiger_account.accountid as id FROM vtiger_account
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_account.accountid
LEFT JOIN vtiger_accountscf ON vtiger_accountscf.accountid= vtiger_account.accountid
WHERE vtiger_crmentity.deleted=0 AND vtiger_account.accountid IN ('.generateQuestionMarks($idlist).') AND vtiger_account.emailoptout=0';
+ } else { // vendors
+ $query = 'SELECT vtiger_vendor.vendorname, '.implode(",", $emailFields).',vtiger_vendor.vendorid as id FROM vtiger_vendor
+ INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_vendor.vendorid
+ LEFT JOIN vtiger_vendorcf ON vtiger_vendorcf.vendorid= vtiger_vendor.vendorid
+ WHERE vtiger_crmentity.deleted=0 AND vtiger_vendor.vendorid IN ('.generateQuestionMarks($idlist).')';
}
$result = $adb->pquery($query,$idlist);
diff --git a/modules/Emails/SaveBookmarklet.php b/modules/Emails/SaveBookmarklet.php
index db71fa1..bb568b4 100644
--- a/modules/Emails/SaveBookmarklet.php
+++ b/modules/Emails/SaveBookmarklet.php
@@ -76,6 +76,6 @@ $smarty->assign("types",$wsFieldDetails['type']['refersTo']);
$smarty->assign("entityNameFields",$json->encode($moduleEntityNameDetails));
$smarty->assign("emailFields",$json->encode($moduleEmailFieldDetails));
$smarty->assign("userEmail",$current_user->column_fields['email1']);
-
+$smarty->assign("MODULE",$currentModule);
$smarty->display("modules/Bookmarklet/Bookmarklet.tpl");
?>
\ No newline at end of file
diff --git a/modules/Emails/language/en_us.lang.php b/modules/Emails/language/en_us.lang.php
index 8f9a296..1af2d58 100644
--- a/modules/Emails/language/en_us.lang.php
+++ b/modules/Emails/language/en_us.lang.php
@@ -145,10 +145,10 @@ $mod_strings = Array(
'LBL_MAILSELECT_INFO2'=>'Select the Email ID types to which,the email should be sent',
'LBL_MULTIPLE'=>'Multiple',
'LBL_COMPOSE_EMAIL'=>'Compose E-Mail',
-'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Webmail Client',
+'LBL_VTIGER_EMAIL_CLIENT'=>'Webmail Client',
//Added for 5.0.3
-'TITLE_VTIGERCRM_MAIL'=>'vtigerCRM Mail',
+'TITLE_VTIGERCRM_MAIL'=>'Mail',
'TITLE_COMPOSE_MAIL'=>'Compose Mail',
'MESSAGE_MAIL_COULD_NOT_BE_SEND'=>'Mail could not be sent to the assigned to user.',
@@ -160,7 +160,6 @@ $mod_strings = Array(
'LBL_BCC_EMAIL_ERROR'=>'Your bcc mailid is not proper',
'LBL_NO_RCPTS_EMAIL_ERROR'=>'No recepients specified',
'LBL_CONF_MAILSERVER_ERROR'=>'Please configure your outgoing mailserver under Settings ---> Outgoing Server link',
-'LBL_VTIGER_EMAIL_CLIENT'=>'vtiger Webmail Client',
'LBL_MAILSELECT_INFO3'=>'You don\'t have permission to view email id(s) of the selected Record(s).',
//Added for script alerts
'FEATURE_AVAILABLE_INFO' => 'This feature is currently only available for Microsoft Internet Explorer 5.5+ users\n\nWait f
diff --git a/modules/Emails/mail.php b/modules/Emails/mail.php
old mode 100644
new mode 100755
index ad1e291..24af176
--- a/modules/Emails/mail.php
+++ b/modules/Emails/mail.php
@@ -192,7 +192,7 @@ function setMailerProperties($mail,$subject,$contents,$from_email,$from_name,$to
$mail->FromName = decode_html($from_name);
- $mail->Sender= getReturnPath($mail->Host);
+ $mail->Sender= getReturnPath($mail->Host, $from_email);
if($to_email != '')
{
@@ -559,8 +559,8 @@ function getDefaultAssigneeEmailIds($groupId) {
$userGroups = new GetGroupUsers();
$userGroups->getAllUsersInGroup($groupId);
$result = $adb->pquery('SELECT email1,email2,secondaryemail FROM vtiger_users WHERE vtiger_users.id IN
- ('. generateQuestionMarks($userGroups->group_users).') AND vtiger_users.status= ?',
- array($userGroups->group_users, 'Active'));
+ ('. generateQuestionMarks($userGroups->group_users).')',
+ array($userGroups->group_users));
$rows = $adb->num_rows($result);
for($i = 0;$i < $rows; $i++) {
$email = $adb->query_result($result,$i,'email1');
diff --git a/modules/HelpDesk/HelpDesk.php b/modules/HelpDesk/HelpDesk.php
index c780df0..89268da 100644
--- a/modules/HelpDesk/HelpDesk.php
+++ b/modules/HelpDesk/HelpDesk.php
@@ -785,7 +785,7 @@ case when (vtiger_users.user_name not like '') then $userNameSql else vtiger_gro
$desc .= getTicketComments($entityId);
$sql = "SELECT * FROM vtiger_ticketcf WHERE ticketid = ?";
- $result = $adb->pquery($sql, array($id));
+ $result = $adb->pquery($sql, array($entityId));
$cffields = $adb->getFieldsArray($result);
foreach ($cffields as $cfOneField) {
if ($cfOneField != 'ticketid') {
diff --git a/modules/HelpDesk/Merge.php b/modules/HelpDesk/Merge.php
index a4483b2..d452878 100755
--- a/modules/HelpDesk/Merge.php
+++ b/modules/HelpDesk/Merge.php
@@ -8,26 +8,11 @@
* All Rights Reserved.
*
********************************************************************************/
-?>
-
-
-
-fetch_array($result);
$fileContent = $temparray['data'];
$filename=html_entity_decode($temparray['filename'], ENT_QUOTES, $default_charset);
+$extension=GetFileExtension($filename);
// Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$filename= $randomfilename . "_word.doc";
+$filename= $randomfilename . "_mmrg.$extension";
$filesize=$temparray['filesize'];
$wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/";
@@ -57,6 +43,28 @@ $handle = fopen($wordtemplatedownloadpath .$filename,"wb");
fwrite($handle,base64_decode($fileContent),$filesize);
fclose($handle);
+if (GetFileExtension($filename)=="doc") {
+echo "
+
+";
+}
+
//<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>
$mass_merge = $_REQUEST['allselectedboxes'];
$single_record = $_REQUEST['record'];
@@ -184,6 +192,19 @@ for ($x=0; $x<$y; $x++)
}
}
+
+// Ordena etiquetas más grandes primero para que no se sutituyan subcadenas en el documento
+// Por ejemplo, pongo LEAD_TIPOVIVIENDA delante de LEAD_TIPO, para que no se sustituya la subcadena LEAD_TIPO
+$labels_length=$field_label;
+function strlength($label,$clave) {
+ global $labels_length;
+ $labels_length[$clave] = strlen($label);
+}
+array_walk($labels_length,'strlength');
+array_multisort($labels_length, $field_label, $querycolumns);
+$field_label=array_reverse($field_label);
+$querycolumns=array_reverse($querycolumns);
+$labels_length=array_reverse($labels_length);
$csvheader = implode(",",$field_label);
//<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>
@@ -253,13 +274,26 @@ if(count($querycolumns) > 0)
//<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>
$actual_values[$x] = $value;
$actual_values[$x] = str_replace('"'," ",$actual_values[$x]);
- //if value contains any line feed or carriage return replace the value with ".value."
- if (preg_match ("/(\r?\n)/", $actual_values[$x]))
- {
- $actual_values[$x] = '"'.$actual_values[$x].'"';
- }
- $actual_values[$x] = decode_html(str_replace(","," ",$actual_values[$x]));
+ //if value contains any line feed or carriage return replace the value with ".value."
+ if (preg_match ("/(\r?\n)/", $actual_values[$x]))
+ {
+ // <<< pag 21-Sep-2011 >>>
+
+ // Replacement see: php.net/manual/en/function.str-replace.php
+ // $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
+ $order = array("\r\n", "\n", "\r"); // order of replacement matters
+ $replace = '!!'; // you choose your appropriate delimiters
+ // They'll be replaced by an OO/LO macro once the resulting document has been downloaded
+
+ // We now processes \r\n's first so they aren't converted twice.
+ // $newstr = str_replace($order, $replace, $str);
+ $actual_values[$x] = str_replace($order, $replace, $actual_values[$x]);
+ // <<< pag 21-Sep-2011 END >>>
+
+ // not needed ??? // $actual_values[$x] = '"'.$actual_values[$x].'"';
}
+ $actual_values[$x] = decode_html(str_replace(","," ",$actual_values[$x]));
+ }
$mergevalue[] = implode($actual_values,",");
}
$csvdata = implode($mergevalue,"###");
@@ -271,10 +305,60 @@ else
// Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
$datafilename = $randomfilename . "_data.csv";
-$handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
-fwrite($handle,$csvheader."\r\n");
-fwrite($handle,str_replace("###","\r\n",$csvdata));
-fclose($handle);
+echo "
";
+$extension = GetFileExtension($filename);
+if($extension == "doc")
+{
+ // Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
+ $datafilename = $randomfilename . "_data.csv";
+
+ $handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
+ fwrite($handle,$csvheader."\r\n");
+ fwrite($handle,str_replace("###","\r\n",$csvdata));
+ fclose($handle);
+}
+else if($extension == "odt")
+{
+ //delete old .odt files in the wordtemplatedownload directory
+ foreach (glob("$wordtemplatedownloadpath/*.odt") as $delefile)
+ {
+ unlink($delefile);
+ }
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $temp_dir=entpack($filename,$wordtemplatedownloadpath,$fileContent);
+ $concontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ $new_filecontent=crmmerge($csvheader,$concontent,$idx,'htmlspecialchars');
+ $stycontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ $new_filestyle=crmmerge($csvheader,$stycontent,$idx,'htmlspecialchars');
+ packen($entityid.$filename,$wordtemplatedownloadpath,$temp_dir,$new_filecontent,$new_filestyle);
+
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ remove_dir($wordtemplatedownloadpath.$temp_dir);
+ }
+}
+else if($extension == "rtf")
+{
+ foreach (glob("$wordtemplatedownloadpath/*.rtf") as $delefile)
+ {
+ unlink($delefile);
+ }
+ $filecontent = base64_decode($fileContent);
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $handle = fopen($wordtemplatedownloadpath.$entityid.$filename,"wb");
+ $new_filecontent = crmmerge($csvheader,$filecontent,$idx,'utf8Unicode');
+ fwrite($handle,$new_filecontent);
+ fclose($handle);
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ }
+}
+else
+{
+ die("unknown file format");
+}
?>
";
+ }
+
//Added to display the Total record count
if(empty($_REQUEST['ajax'])) {
?>
diff --git a/modules/Invoice/Invoice.php b/modules/Invoice/Invoice.php
index d47111f..7ddac8d 100755
--- a/modules/Invoice/Invoice.php
+++ b/modules/Invoice/Invoice.php
@@ -333,11 +333,14 @@ class Invoice extends CRMEntity {
left join vtiger_currency_info as vtiger_currency_info$secmodule on vtiger_currency_info$secmodule.id = vtiger_invoice.currency_id
left join vtiger_salesorder as vtiger_salesorderInvoice on vtiger_salesorderInvoice.salesorderid=vtiger_invoice.salesorderid
left join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid
- left join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid
- left join vtiger_inventoryproductrel as vtiger_inventoryproductrelInvoice on vtiger_invoice.invoiceid = vtiger_inventoryproductrelInvoice.id
+ left join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid ";
+ if($module == 'Products' || $module == 'Services')
+ {
+ $query .= "left join vtiger_inventoryproductrel as vtiger_inventoryproductrelInvoice on vtiger_invoice.invoiceid = vtiger_inventoryproductrelInvoice.id
left join vtiger_products as vtiger_productsInvoice on vtiger_productsInvoice.productid = vtiger_inventoryproductrelInvoice.productid
- left join vtiger_service as vtiger_serviceInvoice on vtiger_serviceInvoice.serviceid = vtiger_inventoryproductrelInvoice.productid
- left join vtiger_groups as vtiger_groupsInvoice on vtiger_groupsInvoice.groupid = vtiger_crmentityInvoice.smownerid
+ left join vtiger_service as vtiger_serviceInvoice on vtiger_serviceInvoice.serviceid = vtiger_inventoryproductrelInvoice.productid ";
+ }
+ $query .= "left join vtiger_groups as vtiger_groupsInvoice on vtiger_groupsInvoice.groupid = vtiger_crmentityInvoice.smownerid
left join vtiger_users as vtiger_usersInvoice on vtiger_usersInvoice.id = vtiger_crmentityInvoice.smownerid
left join vtiger_contactdetails as vtiger_contactdetailsInvoice on vtiger_invoice.contactid = vtiger_contactdetailsInvoice.contactid
left join vtiger_account as vtiger_accountInvoice on vtiger_accountInvoice.accountid = vtiger_invoice.accountid
diff --git a/modules/Leads/Merge.php b/modules/Leads/Merge.php
index f88b815..d421a97 100755
--- a/modules/Leads/Merge.php
+++ b/modules/Leads/Merge.php
@@ -8,30 +8,10 @@
* All Rights Reserved.
*
********************************************************************************/
-?>
-
-
-
-fetch_array($result);
$fileContent = $temparray['data'];
$filename=html_entity_decode($temparray['filename'], ENT_QUOTES, $default_charset);
-
+$extension=GetFileExtension($filename);
// Fix For: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$filename= $randomfilename . "_word.doc";
+$filename= $randomfilename . "_mmrg.$extension";
$filesize=$temparray['filesize'];
$wordtemplatedownloadpath =$root_directory ."/test/wordtemplatedownload/";
@@ -63,6 +43,28 @@ $handle = fopen($wordtemplatedownloadpath .$filename,"wb");
fwrite($handle,base64_decode($fileContent),$filesize);
fclose($handle);
+if (GetFileExtension($filename)=="doc") {
+echo "
+
+";
+}
+
//for mass merge
$mass_merge = $_REQUEST['allselectedboxes'];
$single_record = $_REQUEST['record'];
@@ -122,6 +124,18 @@ for ($x=0; $x<$y; $x++)
$field_label[$x] = $field_label[$x].",USER_FIRSTNAME,USER_LASTNAME,USER_USERNAME,USER_SECONDARYEMAIL,USER_TITLE,USER_OFFICEPHONE,USER_DEPARTMENT,USER_MOBILE,USER_OTHERPHONE,USER_FAX,USER_EMAIL,USER_HOMEPHONE,USER_OTHEREMAIL,USER_PRIMARYADDRESS,USER_CITY,USER_STATE,USER_POSTALCODE,USER_COUNTRY";
}
}
+// Ordena etiquetas más grandes primero para que no se sutituyan subcadenas en el documento
+// Por ejemplo, pongo LEAD_TIPOVIVIENDA delante de LEAD_TIPO, para que no se sustituya la subcadena LEAD_TIPO
+$labels_length=$field_label;
+function strlength($label,$clave) {
+ global $labels_length;
+ $labels_length[$clave] = strlen($label);
+}
+array_walk($labels_length,'strlength');
+array_multisort($labels_length, $field_label, $querycolumns);
+$field_label=array_reverse($field_label);
+$querycolumns=array_reverse($querycolumns);
+$labels_length=array_reverse($labels_length);
$csvheader = implode(",",$field_label);
//<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>
@@ -173,7 +187,20 @@ while($columnValues = $adb->fetch_array($result))
//if value contains any line feed or carriage return replace the value with ".value."
if (preg_match ("/(\r?\n)/", $actual_values[$x]))
{
- $actual_values[$x] = '"'.$actual_values[$x].'"';
+ // <<< pag 21-Sep-2011 >>>
+
+ // Replacement see: php.net/manual/en/function.str-replace.php
+ // $str = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
+ $order = array("\r\n", "\n", "\r"); // order of replacement matters
+ $replace = '!!'; // you choose your appropriate delimiters
+ // They'll be replaced by an OO/LO macro once the resulting document has been downloaded
+
+ // We now processes \r\n's first so they aren't converted twice.
+ // $newstr = str_replace($order, $replace, $str);
+ $actual_values[$x] = str_replace($order, $replace, $actual_values[$x]);
+ // <<< pag 21-Sep-2011 END >>>
+
+ // not needed ??? // $actual_values[$x] = '"'.$actual_values[$x].'"';
}
$actual_values[$x] = decode_html(str_replace(","," ",$actual_values[$x]));
}
@@ -184,13 +211,68 @@ $csvdata = implode($mergevalue,"###");
{
die("No vtiger_fields to do Merge");
}
-// Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
-$datafilename = $randomfilename . "_data.csv";
-
-$handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
-fwrite($handle,$csvheader."\r\n");
-fwrite($handle,str_replace("###","\r\n",$csvdata));
-fclose($handle);
+echo "
";
+$extension = GetFileExtension($filename);
+if($extension == "doc")
+{
+ // Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/2107
+ $datafilename = $randomfilename . "_data.csv";
+
+ $handle = fopen($wordtemplatedownloadpath.$datafilename,"wb");
+ fwrite($handle,$csvheader."\r\n");
+ fwrite($handle,str_replace("###","\r\n",$csvdata));
+ fclose($handle);
+}
+else if($extension == "odt")
+{
+ //delete old .odt files in the wordtemplatedownload directory
+ foreach (glob("$wordtemplatedownloadpath/*.odt") as $delefile)
+ {
+ unlink($delefile);
+ }
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $temp_dir=entpack($filename,$wordtemplatedownloadpath,$fileContent);
+ $concontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/content.xml');
+ $new_filecontent=crmmerge($csvheader,$concontent,$idx,'htmlspecialchars');
+ $stycontent=file_get_contents($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ unlink($wordtemplatedownloadpath.$temp_dir.'/styles.xml');
+ $new_filestyle=crmmerge($csvheader,$stycontent,$idx,'htmlspecialchars');
+ packen($entityid.$filename,$wordtemplatedownloadpath,$temp_dir,$new_filecontent,$new_filestyle);
+
+ //Send Document to the Browser
+
+ //header("Content-Type: $mimetype");
+ //header("Content-Disposition: attachment; filename=$filename");
+
+ //echo file_get_contents($wordtemplatedownloadpath .$filename);
+ //readfile($root_directory .$wordtemplatedownloadpath .$filename);
+
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ remove_dir($wordtemplatedownloadpath.$temp_dir);
+ }
+}
+else if($extension == "rtf")
+{
+ foreach (glob("$wordtemplatedownloadpath/*.rtf") as $delefile)
+ {
+ unlink($delefile);
+ }
+ $filecontent = base64_decode($fileContent);
+ if (!is_array($mass_merge)) $mass_merge = array($mass_merge);
+ foreach($mass_merge as $idx => $entityid) {
+ $handle = fopen($wordtemplatedownloadpath.$entityid.$filename,"wb");
+ $new_filecontent = crmmerge($csvheader,$filecontent,$idx,'utf8Unicode');
+ fwrite($handle,$new_filecontent);
+ fclose($handle);
+ echo " ".$app_strings['DownloadMergeFile']." ";
+ }
+}
+else
+{
+ die("unknown file format");
+}
?>
diff --git a/modules/Migration/language/en_us.lang.php b/modules/Migration/language/en_us.lang.php
index 3c4dec9..fe52265 100644
--- a/modules/Migration/language/en_us.lang.php
+++ b/modules/Migration/language/en_us.lang.php
@@ -71,7 +71,7 @@ $mod_strings = Array(
Then you can give this Database name in config.inc.php file to use this Database ie., $dbconfig[\'db_name\'] = \'new db name\';',
'LBL_ENTER_MYSQL_SERVER_PATH'=>'Enter MySQL Server Path',
-'LBL_SERVER_PATH_DESC'=>'MySQL path in the server like /home/5beta/vtigerCRM5_beta/mysql/bin or c:\Program Files\mysql\bin',
+'LBL_SERVER_PATH_DESC'=>'MySQL path in the server like /usr/bin or c:\Program Files\mysql\bin',
'LBL_MYSQL_SERVER_PATH'=>'MySQL Server Path : ',
'LBL_MIGRATE_BUTTON'=>'Migrate',
'LBL_CANCEL_BUTTON'=>'Cancel',
diff --git a/modules/Products/Save.php b/modules/Products/Save.php
index 00efc27..ae78dfb 100644
--- a/modules/Products/Save.php
+++ b/modules/Products/Save.php
@@ -52,7 +52,7 @@ if($_REQUEST['return_action'] != '') {
}
if($_REQUEST['return_id'] != '') $return_id = vtlib_purify($_REQUEST['return_id']);
-if(isset($_request['activity_mode']))
+if(isset($_REQUEST['activity_mode']))
$return_action .= '&activity_mode='.$activity_mode;
if($image_error=="true") { //If there is any error in the file upload then moving all the data to EditView.
diff --git a/modules/Reports/ReportRun.php b/modules/Reports/ReportRun.php
index 87b1f81..d34fc7d 100644
--- a/modules/Reports/ReportRun.php
+++ b/modules/Reports/ReportRun.php
@@ -98,7 +98,7 @@ class ReportRun extends CRMEntity
$fieldcolname = $columnslistrow["columnname"];
list($tablename,$colname,$module_field,$fieldname,$single) = split(":",$fieldcolname);
list($module,$field) = split("_",$module_field,2);
- $inventory_fields = array('quantity','listprice','serviceid','productid','discount','comment');
+ $inventory_fields = array('quantity','listprice','serviceid','productid','discount_amount','comment');
$inventory_modules = array('SalesOrder','Quotes','PurchaseOrder','Invoice');
require('user_privileges/user_privileges_'.$current_user->id.'.php');
if(sizeof($permitted_fields[$module]) == 0 && $is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1)
@@ -106,7 +106,7 @@ class ReportRun extends CRMEntity
$permitted_fields[$module] = $this->getaccesfield($module);
}
if(in_array($module,$inventory_modules)){
- $permitted_fields = array_merge($permitted_fields,$inventory_fields);
+ $permitted_fields[$module] = array_merge($permitted_fields[$module],$inventory_fields);
}
$selectedfields = explode(":",$fieldcolname);
if($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1
@@ -216,7 +216,7 @@ class ReportRun extends CRMEntity
}
elseif($selectedfields[0] == 'vtiger_inventoryproductrel')//handled for product fields in Campaigns Module Reports
{
- if($selectedfields[1] == 'discount'){
+ if($selectedfields[1] == 'discount_amount'){
$columnslist[$fieldcolname] = " case when (vtiger_inventoryproductrel{$module}.discount_amount != '') then vtiger_inventoryproductrel{$module}.discount_amount else ROUND((vtiger_inventoryproductrel{$module}.listprice * vtiger_inventoryproductrel{$module}.quantity * (vtiger_inventoryproductrel{$module}.discount_percent/100)),3) end as '" . $header_label ."'";
} else if($selectedfields[1] == 'productid'){
$columnslist[$fieldcolname] = "vtiger_products{$module}.productname as '" . $header_label ."'";
@@ -226,6 +226,18 @@ class ReportRun extends CRMEntity
$columnslist[$fieldcolname] = $selectedfields[0].$module.".".$selectedfields[1]." as '".$header_label."'";
}
}
+ elseif($selectedfields[0] == 'vtiger_inventoryproductrel'.$module)//handled for product fields in Campaigns Module Reports
+ {
+ if($selectedfields[1] == 'discount_amount'){
+ $columnslist[$fieldcolname] = " case when (vtiger_inventoryproductrel{$module}.discount_amount != '') then vtiger_inventoryproductrel{$module}.discount_amount else ROUND((vtiger_inventoryproductrel{$module}.listprice * vtiger_inventoryproductrel{$module}.quantity * (vtiger_inventoryproductrel{$module}.discount_percent/100)),3) end as '" . $header_label ."'";
+ } else if($selectedfields[1] == 'productid'){
+ $columnslist[$fieldcolname] = "vtiger_products{$module}.productname as '" . $header_label ."'";
+ } else if($selectedfields[1] == 'serviceid'){
+ $columnslist[$fieldcolname] = "vtiger_service{$module}.servicename as '" . $header_label ."'";
+ } else {
+ $columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." as '".$header_label."'";
+ }
+ }
elseif(stristr($selectedfields[1],'cf_')==true && stripos($selectedfields[1],'cf_')==0)
{
$columnslist[$fieldcolname] = $selectedfields[0].".".$selectedfields[1]." AS '".$adb->sql_escape_string(decode_html($header_label))."'";
@@ -688,6 +700,12 @@ class ReportRun extends CRMEntity
} else if($selectedfields[1] == 'serviceid'){
$fieldvalue = "vtiger_service{$this->primarymodule}.servicename ".$this->getAdvComparator($comparator,trim($value),$datatype);
}
+ } elseif($selectedfields[0] == 'vtiger_inventoryproductrel'.$this->primarymodule && ($selectedfields[1] == 'productid' || $selectedfields[1] == 'serviceid')) {
+ if($selectedfields[1] == 'productid'){
+ $fieldvalue = "vtiger_products{$this->primarymodule}.productname ".$this->getAdvComparator($comparator,trim($value),$datatype);
+ } else if($selectedfields[1] == 'serviceid'){
+ $fieldvalue = "vtiger_service{$this->primarymodule}.servicename ".$this->getAdvComparator($comparator,trim($value),$datatype);
+ }
} elseif($fieldInfo['uitype'] == '10' || isReferenceUIType($fieldInfo['uitype'])) {
$comparatorValue = $this->getAdvComparator($comparator,trim($value),$datatype);
@@ -1446,7 +1464,7 @@ class ReportRun extends CRMEntity
* this returns join query for the given module
*/
- function getReportsQuery($module, $type='')
+ function getReportsQuery($module, $type='', $where_condition = '')
{
global $log, $current_user;
$secondary_module ="'";
@@ -1607,7 +1625,7 @@ class ReportRun extends CRMEntity
inner join vtiger_quotesbillads on vtiger_quotes.quoteid=vtiger_quotesbillads.quotebilladdressid
inner join vtiger_quotesshipads on vtiger_quotes.quoteid=vtiger_quotesshipads.quoteshipaddressid
left join vtiger_currency_info as vtiger_currency_info$module on vtiger_currency_info$module.id = vtiger_quotes.currency_id";
- if($type !== 'COLUMNSTOTOTAL') {
+ if(($type !== 'COLUMNSTOTOTAL') || ($type == 'COLUMNSTOTOTAL' && $where_condition == 'add')) {
$query .= " left join vtiger_inventoryproductrel as vtiger_inventoryproductrelQuotes on vtiger_quotes.quoteid = vtiger_inventoryproductrelQuotes.id
left join vtiger_products as vtiger_productsQuotes on vtiger_productsQuotes.productid = vtiger_inventoryproductrelQuotes.productid
left join vtiger_service as vtiger_serviceQuotes on vtiger_serviceQuotes.serviceid = vtiger_inventoryproductrelQuotes.productid";
@@ -1634,7 +1652,7 @@ class ReportRun extends CRMEntity
inner join vtiger_pobillads on vtiger_purchaseorder.purchaseorderid=vtiger_pobillads.pobilladdressid
inner join vtiger_poshipads on vtiger_purchaseorder.purchaseorderid=vtiger_poshipads.poshipaddressid
left join vtiger_currency_info as vtiger_currency_info$module on vtiger_currency_info$module.id = vtiger_purchaseorder.currency_id";
- if($type !== 'COLUMNSTOTOTAL') {
+ if(($type !== 'COLUMNSTOTOTAL') || ($type == 'COLUMNSTOTOTAL' && $where_condition == 'add')) {
$query .= " left join vtiger_inventoryproductrel as vtiger_inventoryproductrelPurchaseOrder on vtiger_purchaseorder.purchaseorderid = vtiger_inventoryproductrelPurchaseOrder.id
left join vtiger_products as vtiger_productsPurchaseOrder on vtiger_productsPurchaseOrder.productid = vtiger_inventoryproductrelPurchaseOrder.productid
left join vtiger_service as vtiger_servicePurchaseOrder on vtiger_servicePurchaseOrder.serviceid = vtiger_inventoryproductrelPurchaseOrder.productid";
@@ -1659,7 +1677,7 @@ class ReportRun extends CRMEntity
inner join vtiger_invoicebillads on vtiger_invoice.invoiceid=vtiger_invoicebillads.invoicebilladdressid
inner join vtiger_invoiceshipads on vtiger_invoice.invoiceid=vtiger_invoiceshipads.invoiceshipaddressid
left join vtiger_currency_info as vtiger_currency_info$module on vtiger_currency_info$module.id = vtiger_invoice.currency_id";
- if($type !== 'COLUMNSTOTOTAL') {
+ if(($type !== 'COLUMNSTOTOTAL') || ($type == 'COLUMNSTOTOTAL' && $where_condition == 'add')) {
$query .=" left join vtiger_inventoryproductrel as vtiger_inventoryproductrelInvoice on vtiger_invoice.invoiceid = vtiger_inventoryproductrelInvoice.id
left join vtiger_products as vtiger_productsInvoice on vtiger_productsInvoice.productid = vtiger_inventoryproductrelInvoice.productid
left join vtiger_service as vtiger_serviceInvoice on vtiger_serviceInvoice.serviceid = vtiger_inventoryproductrelInvoice.productid";
@@ -1684,7 +1702,7 @@ class ReportRun extends CRMEntity
inner join vtiger_sobillads on vtiger_salesorder.salesorderid=vtiger_sobillads.sobilladdressid
inner join vtiger_soshipads on vtiger_salesorder.salesorderid=vtiger_soshipads.soshipaddressid
left join vtiger_currency_info as vtiger_currency_info$module on vtiger_currency_info$module.id = vtiger_salesorder.currency_id";
- if($type !== 'COLUMNSTOTOTAL') {
+ if(($type !== 'COLUMNSTOTOTAL') || ($type == 'COLUMNSTOTOTAL' && $where_condition == 'add')) {
$query .= " left join vtiger_inventoryproductrel as vtiger_inventoryproductrelSalesOrder on vtiger_salesorder.salesorderid = vtiger_inventoryproductrelSalesOrder.id
left join vtiger_products as vtiger_productsSalesOrder on vtiger_productsSalesOrder.productid = vtiger_inventoryproductrelSalesOrder.productid
left join vtiger_service as vtiger_serviceSalesOrder on vtiger_serviceSalesOrder.serviceid = vtiger_inventoryproductrelSalesOrder.productid";
@@ -1795,11 +1813,18 @@ class ReportRun extends CRMEntity
if(isset($filtersql) && $filtersql !== false) {
$advfiltersql = $filtersql;
}
+ $where_condition = '';
if($advfiltersql != "") {
+ if($type == 'COLUMNSTOTOTAL')
+ {
+ if (strstr($advfiltersql,'vtiger_products'.$this->primarymodule))
+ $where_condition='add';
+ }
$wheresql .= " and ".$advfiltersql;
}
- $reportquery = $this->getReportsQuery($this->primarymodule, $type);
+
+ $reportquery = $this->getReportsQuery($this->primarymodule, $type,$where_condition);
// If we don't have access to any columns, let us select one column and limit result to shown we have not results
// Fix for: http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/4758 - Prasad
diff --git a/modules/Reports/Reports.php b/modules/Reports/Reports.php
index 4a4cd1d..19975a1 100644
--- a/modules/Reports/Reports.php
+++ b/modules/Reports/Reports.php
@@ -199,8 +199,7 @@ class Reports extends CRMEntity{
";
@@ -106,7 +105,7 @@ if($_REQUEST['changepassword'] == 'true') {
$focus->retrieve_entity_info($_REQUEST['record'],'Users');
$focus->id = vtlib_purify($_REQUEST['record']);
if (isset($_REQUEST['new_password'])) {
- if (!$focus->change_password($_REQUEST['old_password'], $_REQUEST['new_password'])) {
+ if (!$focus->change_password(vtlib_purify($_REQUEST['old_password']), vtlib_purify($_REQUEST['new_password']))) {
header("Location: index.php?action=Error&module=Users&error_string=".urlencode($focus->error_string));
exit;
}
@@ -215,4 +214,4 @@ if ($error_str != '') {
header($location);
-?>
\ No newline at end of file
+?>
diff --git a/modules/Users/Users.php b/modules/Users/Users.php
index 7605027..bb38b4c 100644
--- a/modules/Users/Users.php
+++ b/modules/Users/Users.php
@@ -578,7 +578,11 @@ class Users extends CRMEntity {
global $adb;
$query = "SELECT id from vtiger_users where user_name=? AND deleted=0";
$result =$adb->pquery($query, array($user_name));
+ if ($result and $adb->num_rows($result)>0) {
$userid = $adb->query_result($result,0,'id');
+ } else {
+ $userid = 0;
+ }
return $userid;
}
@@ -1411,6 +1415,9 @@ class Users extends CRMEntity {
//delete from user vtiger_table;
$sql = "delete from vtiger_users where id=?";
$adb->pquery($sql, array($userId));
+ //Delete user extension in asterisk.
+ $sql = "delete from vtiger_asteriskextensions where userid=?";
+ $adb->pquery($sql, array($userId));
}
/**
diff --git a/modules/Users/about_us.php b/modules/Users/about_us.php
index c60b30c..00bc220 100644
--- a/modules/Users/about_us.php
+++ b/modules/Users/about_us.php
@@ -35,7 +35,11 @@ global $mod_strings;
-
+
";
echo "";
diff --git a/modules/com_vtiger_workflow/VTSimpleTemplate.inc b/modules/com_vtiger_workflow/VTSimpleTemplate.inc
index bd22f99..87db3f4 100644
--- a/modules/com_vtiger_workflow/VTSimpleTemplate.inc
+++ b/modules/com_vtiger_workflow/VTSimpleTemplate.inc
@@ -80,7 +80,7 @@ class VTSimpleTemplate{
}
function parseTemplate(){
- return preg_replace_callback('/\\$(\w+|\((\w+) : \(([_\w]+)\) (\w+)\)),?/', array($this,"matchHandler"), $this->template);
+ return preg_replace_callback('/\\$(\w+|\((\w+) : \(([_\w]+)\) (\w+)\))/', array($this,"matchHandler"), $this->template);
}
function getMetaValue($fieldname){
diff --git a/modules/com_vtiger_workflow/VTTaskManager.inc b/modules/com_vtiger_workflow/VTTaskManager.inc
index 659f1c7..cd24b7f 100644
--- a/modules/com_vtiger_workflow/VTTaskManager.inc
+++ b/modules/com_vtiger_workflow/VTTaskManager.inc
@@ -172,9 +172,11 @@
}
public function formatTimeForTimePicker($time) {
+ $AM_PM = array('am', 'pm');
+ if (in_array(strtolower(substr($time, -2)),$AM_PM))
+ return $time; // ya tiene el formato correcto, devolverlo sin más
list($h, $m, $s) = explode(':', $time);
$mn = str_pad($m - $m % 15, 2, 0, STR_PAD_LEFT);
- $AM_PM = array('am', 'pm');
return str_pad(($h%12), 2, 0, STR_PAD_LEFT).':'.$mn.$AM_PM[($h/12)%2];
}
diff --git a/modules/com_vtiger_workflow/deletetask.php b/modules/com_vtiger_workflow/deletetask.php
index db34a21..df98b9a 100644
--- a/modules/com_vtiger_workflow/deletetask.php
+++ b/modules/com_vtiger_workflow/deletetask.php
@@ -18,7 +18,7 @@ require_once('VTWorkflowUtils.php');
$util = new VTWorkflowUtils();
$module = new VTWorkflowApplication("deltetask");
$mod = return_module_language($current_language, $module->name);
-
+ $request = vtlib_purify($request); // this cleans all values of the array
if(!$util->checkAdminAccess()){
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
@@ -29,7 +29,7 @@ require_once('VTWorkflowUtils.php');
$wm->deleteTask($request['task_id']);
if(isset($request["return_url"])){
- $returnUrl= vtlib_purify($request["return_url"]);
+ $returnUrl=$request["return_url"];
}else{
$returnUrl=$module->editWorkflowUrl($wf->id);
}
diff --git a/modules/com_vtiger_workflow/edittask.php b/modules/com_vtiger_workflow/edittask.php
index 43e60a9..c4d7831 100644
--- a/modules/com_vtiger_workflow/edittask.php
+++ b/modules/com_vtiger_workflow/edittask.php
@@ -20,6 +20,7 @@ require_once("VTWorkflowUtils.php");
function vtTaskEdit($adb, $request, $current_language, $app_strings){
global $theme;
$util = new VTWorkflowUtils();
+ $request = vtlib_purify($request); // this cleans all values of the array
$image_path = "themes/$theme/images/";
$module = new VTWorkflowApplication('edittask');
@@ -37,11 +38,10 @@ require_once("VTWorkflowUtils.php");
$smarty->assign('edit',isset($request["task_id"]));
if(isset($request["task_id"])){
$task = $tm->retrieveTask($request["task_id"]);
- $taskClass = get_class($task);
$workflowId=$task->workflowId;
}else{
$workflowId = $request["workflow_id"];
- $taskClass = vtlib_purifyForSql($request["task_type"]);
+ $taskClass = $request["task_type"];
$task = $tm->createTask($taskClass, $workflowId);
}
@@ -61,15 +61,12 @@ require_once("VTWorkflowUtils.php");
$smarty->assign("workflow", $workflow);
- $smarty->assign("returnUrl", vtlib_purify($request["return_url"]));
+ $smarty->assign("returnUrl", $request["return_url"]);
$smarty->assign("task", $task);
$smarty->assign("taskType", $taskClass);
- $smarty->assign("saveType", vtlib_purify($request['save_type']));
-
- $taskTypeInstance = VTTaskType::getInstanceFromTaskType($taskClass);
- $taskTemplateClass = $tm->retrieveTemplatePath($module->name, $taskTypeInstance);
- $smarty->assign("taskTemplate", $taskTemplateClass);
-
+ $smarty->assign("saveType", $request['save_type']);
+ $taskClass = get_class($task);
+ $smarty->assign("taskTemplate", "{$module->name}/taskforms/$taskClass.tpl");
$et = VTWSEntityType::usingGlobalCurrentUser($workflow->moduleName);
$smarty->assign("entityType", $et);
$smarty->assign('entityName', $workflow->moduleName);
@@ -123,13 +120,6 @@ require_once("VTWorkflowUtils.php");
$smarty->assign("PAGE_NAME", $mod['LBL_EDIT_TASK']);
$smarty->assign("PAGE_TITLE", $mod['LBL_EDIT_TASK_TITLE']);
- $users = $group = array();
- $users = get_user_array();
- $group = get_group_array();
- foreach($group as $id => $name) {
- $users[$id] = $name;
- }
- $smarty->assign('ASSIGNED_TO', $users);
$smarty->assign("module", $module);
$smarty->display("{$module->name}/EditTask.tpl");
}
diff --git a/modules/com_vtiger_workflow/editworkflow.php b/modules/com_vtiger_workflow/editworkflow.php
index b4547c1..2537ecd 100644
--- a/modules/com_vtiger_workflow/editworkflow.php
+++ b/modules/com_vtiger_workflow/editworkflow.php
@@ -19,11 +19,10 @@ require_once("VTTaskManager.inc");
require_once("VTWorkflowApplication.inc");
require_once "VTWorkflowTemplateManager.inc";
require_once "VTWorkflowUtils.php";
-require_once 'config.help.link.php';
function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_strings){
- global $theme, $helpLinks;
+ global $theme;
$util = new VTWorkflowUtils();
$image_path = "themes/$theme/images/";
@@ -83,7 +82,7 @@ function vtWorkflowEdit($adb, $request, $requestUrl, $current_language, $app_str
$smarty->assign("saveType", isset($workflow->id)?"edit":"new");
$smarty->assign("module", $module);
- $smarty->assign("WORKFLOW_TRIGGER_TYPES_HELP_LINK", $helpLinks['WORKFLOW_TRIGGER_TYPES']);
+ $smarty->assign("WORKFLOW_TRIGGER_TYPES_HELP_LINK", WORKFLOW_TRIGGER_TYPES);
$smarty->display("{$module->name}/EditWorkflow.tpl");
}
diff --git a/modules/com_vtiger_workflow/savetask.php b/modules/com_vtiger_workflow/savetask.php
index ae334b3..f0af66d 100644
--- a/modules/com_vtiger_workflow/savetask.php
+++ b/modules/com_vtiger_workflow/savetask.php
@@ -18,7 +18,7 @@ require_once("VTWorkflowApplication.inc");
$util = new VTWorkflowUtils();
$module = new VTWorkflowApplication("savetask");
$mod = return_module_language($current_language, $module->name);
-
+ $request = vtlib_purify($request); // this cleans all values of the array
if(!$util->checkAdminAccess()){
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
@@ -29,7 +29,7 @@ require_once("VTWorkflowApplication.inc");
if(isset($request["task_id"])){
$task = $tm->retrieveTask($request["task_id"]);
}else{
- $taskType = vtlib_purifyForSql($request["task_type"]);
+ $taskType = $request["task_type"];
$workflowId = $request["workflow_id"];
$task = $tm->createTask($taskType, $workflowId);
}
@@ -59,8 +59,8 @@ require_once("VTWorkflowApplication.inc");
}
$tm->saveTask($task);
- if(isset(vtlib_purify($request["return_url"]))) {
- $returnUrl= vtlib_purify($request["return_url"]);
+ if(isset($request["return_url"])){
+ $returnUrl=$request["return_url"];
}else{
$returnUrl=$module->editTaskUrl($task->id);
}
diff --git a/modules/com_vtiger_workflow/savetemplate.php b/modules/com_vtiger_workflow/savetemplate.php
index 0275e0c..d5a4769 100644
--- a/modules/com_vtiger_workflow/savetemplate.php
+++ b/modules/com_vtiger_workflow/savetemplate.php
@@ -20,21 +20,21 @@ function vtSaveWorkflowTemplate($adb, $request){
$util = new VTWorkflowUtils();
$module = new VTWorkflowApplication("savetemplate");
$mod = return_module_language($current_language, $module->name);
-
+ $request = vtlib_purify($request); // this cleans all values of the array
if(!$util->checkAdminAccess()){
$errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
$util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
return;
}
- $title = vtlib_purifyForSql($request['title']);
+ $title = $request['title'];
$workflowId = $request['workflow_id'];
$wfs = new VTworkflowManager($adb);
$workflow = $wfs->retrieve($workflowId);
$tm = new VTWorkflowTemplateManager($adb);
$tpl = $tm->newTemplate($title, $workflow);
$tm->saveTemplate($tpl);
- $returnUrl = vtlib_purify($request['return_url']);
+ $returnUrl = $request['return_url'];
?>
Return
\ No newline at end of file
diff --git a/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc b/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc
index efbb1de..b45bcf5 100644
--- a/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc
+++ b/modules/com_vtiger_workflow/tasks/VTCreateTodoTask.inc
@@ -64,9 +64,8 @@ class VTCreateTodoTask extends VTTask{
'taskpriority'=>$this->priority,
'taskstatus'=>$this->status,
'assigned_user_id'=>$userId,
- 'time_start'=> $startDate->getDisplayTime(),
- 'sendnotification'=>($this->sendNotification!='' && $this->sendNotification!='N')?
- true: false,
+ 'time_start'=> self::conv12to24hour($this->time),
+ 'sendnotification'=>($this->sendNotification!='' && $this->sendNotification!='N')? true: false,
'date_start'=>$date,
'due_date'=>$date,
'visibility'=>'all',
diff --git a/phpversionfail.php b/phpversionfail.php
index 2b335f7..172ddf6 100644
--- a/phpversionfail.php
+++ b/phpversionfail.php
@@ -7,13 +7,13 @@
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
********************************************************************************/
-
+include_once 'vtigerversion.php';
?>
- vtiger CRM 5 - PHP Version Check
+ - PHP Version Check
@@ -23,7 +23,7 @@
-
+
@@ -36,7 +36,7 @@
- PHP 5.2.x or above is required. Your current PHP version is
+ PHP 5.2.x or PHP 5.3.x is required. Your current PHP version is
- Kindly upgrade the PHP installation, and try again!
+ Kindly adapt your PHP installation, and try again!