From 4d16fc224be5049669f2e9e48f8acfd85eb4a18a Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Tue, 16 Nov 2010 15:40:44 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=B0=205.2=20=E6=AD=A3?= =?UTF-8?q?=E5=BC=8F=E7=89=88=E5=90=8E=E7=AC=AC=E4=B8=80=E6=AC=A1=20SVN=20?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit yuchenghu@hawebs.net git-svn-id: https://svn.code.sf.net/p/hawebs/svn@630 a2543c7e-f6e9-4f8a-8bff-1ffc34733512 --- .../modules/Potentials/CallRelatedList.php | 85 ++ .../trunk/modules/Potentials/Charts.php | 1241 +++++++++++++++++ .../trunk/modules/Potentials/CustomView.php | 14 + .../trunk/modules/Potentials/Delete.php | 35 + .../trunk/modules/Potentials/DetailView.php | 142 ++ .../modules/Potentials/DetailViewAjax.php | 52 + .../trunk/modules/Potentials/EditView.php | 164 +++ .../modules/Potentials/ExportRecords.php | 13 + .../Potentials/FindDuplicateRecords.php | 106 ++ .../trunk/modules/Potentials/Import.php | 45 + .../trunk/modules/Potentials/ListView.php | 267 ++++ .../modules/Potentials/ListViewPagging.php | 11 + .../trunk/modules/Potentials/ListViewTop.php | 104 ++ .../trunk/modules/Potentials/MassEdit.php | 45 + .../trunk/modules/Potentials/MassEditSave.php | 67 + oss/vtiger/trunk/modules/Potentials/Popup.php | 17 + .../trunk/modules/Potentials/Potentials.js | 89 ++ .../trunk/modules/Potentials/Potentials.php | 737 ++++++++++ .../modules/Potentials/PotentialsAjax.php | 12 + .../modules/Potentials/ProcessDuplicates.php | 134 ++ .../trunk/modules/Potentials/QuickCreate.php | 12 + oss/vtiger/trunk/modules/Potentials/Save.php | 69 + .../trunk/modules/Potentials/Settings.php | 13 + .../trunk/modules/Potentials/TagCloud.php | 12 + .../modules/Potentials/UnifiedSearch.php | 11 + oss/vtiger/trunk/modules/Potentials/index.php | 30 + .../Potentials/language/en_us.lang.php | 157 +++ .../Potentials/language/zh_cn.lang.php | 156 +++ .../modules/Potentials/updateRelations.php | 55 + 29 files changed, 3895 insertions(+) create mode 100644 oss/vtiger/trunk/modules/Potentials/CallRelatedList.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Charts.php create mode 100644 oss/vtiger/trunk/modules/Potentials/CustomView.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Delete.php create mode 100644 oss/vtiger/trunk/modules/Potentials/DetailView.php create mode 100644 oss/vtiger/trunk/modules/Potentials/DetailViewAjax.php create mode 100644 oss/vtiger/trunk/modules/Potentials/EditView.php create mode 100644 oss/vtiger/trunk/modules/Potentials/ExportRecords.php create mode 100644 oss/vtiger/trunk/modules/Potentials/FindDuplicateRecords.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Import.php create mode 100644 oss/vtiger/trunk/modules/Potentials/ListView.php create mode 100644 oss/vtiger/trunk/modules/Potentials/ListViewPagging.php create mode 100644 oss/vtiger/trunk/modules/Potentials/ListViewTop.php create mode 100644 oss/vtiger/trunk/modules/Potentials/MassEdit.php create mode 100644 oss/vtiger/trunk/modules/Potentials/MassEditSave.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Popup.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Potentials.js create mode 100644 oss/vtiger/trunk/modules/Potentials/Potentials.php create mode 100644 oss/vtiger/trunk/modules/Potentials/PotentialsAjax.php create mode 100644 oss/vtiger/trunk/modules/Potentials/ProcessDuplicates.php create mode 100644 oss/vtiger/trunk/modules/Potentials/QuickCreate.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Save.php create mode 100644 oss/vtiger/trunk/modules/Potentials/Settings.php create mode 100644 oss/vtiger/trunk/modules/Potentials/TagCloud.php create mode 100644 oss/vtiger/trunk/modules/Potentials/UnifiedSearch.php create mode 100644 oss/vtiger/trunk/modules/Potentials/index.php create mode 100644 oss/vtiger/trunk/modules/Potentials/language/en_us.lang.php create mode 100644 oss/vtiger/trunk/modules/Potentials/language/zh_cn.lang.php create mode 100644 oss/vtiger/trunk/modules/Potentials/updateRelations.php diff --git a/oss/vtiger/trunk/modules/Potentials/CallRelatedList.php b/oss/vtiger/trunk/modules/Potentials/CallRelatedList.php new file mode 100644 index 00000000..a9a4b0fd --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/CallRelatedList.php @@ -0,0 +1,85 @@ +retrieve_entity_info($RECORD,$currentmodule); + $focus->id = $RECORD; + $focus->name=$focus->column_fields['potentialname']; + $log->debug("id is ".$focus->id); + $log->debug("name is ".$focus->name); + } + + global $mod_strings; + global $app_strings; + global $currentModule; + global $theme; + $theme_path="themes/".$theme."/"; + $image_path=$theme_path."images/"; + + $smarty = new vtigerCRM_Smarty; + + if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { + $focus->id = ""; + } + if(isset($_REQUEST['mode']) && $_REQUEST['mode'] != ' ') { + $smarty->assign("OP_MODE",vtlib_purify($_REQUEST['mode'])); + } + if (isset($focus->name)) $smarty->assign("NAME", $focus->name); + $related_array = getRelatedLists($currentModule,$focus); + $smarty->assign("RELATEDLISTS", $related_array); + + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + $relationId = vtlib_purify($_REQUEST['relation_id']); + RelatedListViewSession::addRelatedModuleToSession($relationId, + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); + + $smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar')); + $smarty->assign("EVENT_PERMISSION",CheckFieldPermission('parent_id','Events')); + $smarty->assign("CATEGORY",$category); + $smarty->assign("UPDATEINFO",updateInfo($focus->id)); + $smarty->assign("ID",$focus->id); + $smarty->assign("MODULE",$currentModule); + $smarty->assign("SINGLE_MOD",$app_strings['Potential']); + $smarty->assign("MOD",$mod_strings); + $smarty->assign("APP",$app_strings); + $smarty->assign("THEME", $theme); + $smarty->assign("IMAGE_PATH", $image_path); + //$smarty->assign("ACCOUNTID",$focus->column_fields['account_id']); + + // Module Sequence Numbering + $mod_seq_field = getModuleSequenceField($currentModule); + if ($mod_seq_field != null) { + $mod_seq_id = $focus->column_fields[$mod_seq_field['name']]; + } else { + $mod_seq_id = $focus->id; + } + $smarty->assign('MOD_SEQ_ID', $mod_seq_id); + // END + + $check_button = Button_Check($module); + $smarty->assign("CHECK", $check_button); + $smarty->display("RelatedLists.tpl"); +} +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/Charts.php b/oss/vtiger/trunk/modules/Potentials/Charts.php new file mode 100644 index 00000000..7ad527e1 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Charts.php @@ -0,0 +1,1241 @@ +debug("Entering outcome_by_month(".$date_start.",". $date_end.",". $user_id.") method ..."); + global $app_strings,$lang_crm, $app_list_strings, $current_module_strings,$current_user, $log, $charset, $tmp_dir; + global $theme; + include_once ('Image/Graph.php'); + include_once ('Image/Canvas.php'); + + $log =& LoggerManager::getLogger('outcome_by_month chart'); + // Set the basic parameters of the graph + $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); + $imagemap = $canvas->getImageMap(); + $graph =& Image_Graph::factory('graph', $canvas); + $log->debug("graph object created"); + + // add a TrueType font + $font =& $graph->addNew('font', calculate_font_name($lang_crm)); + // set the font size to 11 pixels + $font->setSize(8); + + $graph->setFont($font); + // create the plotarea layout + $title =& Image_Graph::factory('title', array('Title',10)); + $plotarea =& Image_Graph::factory('plotarea',array( + 'axis', + 'axis' + )); + $footer =& Image_Graph::factory('title', array('Footer',8)); + $graph->add( + Image_Graph::vertical($title, + Image_Graph::vertical( + $plotarea, + $footer, + 90 + ), + 5 + ) + ); + + //$graph->SetScale("textlin"); + + if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) { + //$font = calculate_font_family($lang_crm); + + $log->debug("date_start is: $date_start"); + $log->debug("date_end is: $date_end"); + $log->debug("user_id is: "); + $log->debug($user_id); + $log->debug("cache_file_name is: $cache_file_name"); + + //build the where clause for the query that matches $user + $where = ""; + $first = true; + $current = 0; + + //build the where clause for the query that matches $date_start and $date_end + $where .= " closingdate >= '$date_start' AND closingdate <= '$date_end'"; + $subtitle = $current_module_strings['LBL_DATE_RANGE']." ".getDisplayDate($date_start)." ".$current_module_strings['LBL_DATE_RANGE_TO']." ".getDisplayDate($date_end)."\n"; + + //Now do the db queries + //query for opportunity data that matches $datay and $user + $opp = new Potentials(); + $opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where); + + //build pipeline by sales stage data + $total = 0; + $count = array(); + $sum = array(); + $months = array(); + $other = $current_module_strings['LBL_LEAD_SOURCE_OTHER']; + if (isset($opp_list)) { + foreach ($opp_list as $record) { + $month = substr_replace($record->column_fields['closingdate'],'',-3); + if (!in_array($month, $months)) { array_push($months, $month); } + if ($record->column_fields['sales_stage'] == 'Closed Won' || $record->column_fields['sales_stage'] == 'Closed Lost') { + $sales_stage=$record->column_fields['sales_stage']; + } + else { + $sales_stage=$other; + } + + if (!isset($sum[$month][$sales_stage][$record->column_fields['assigned_user_id']])) + { + $sum[$month][$sales_stage][$record->column_fields['assigned_user_id']] = 0; + } + if (isset($record->column_fields['amount']) && in_array($record->column_fields['assigned_user_id'],$user_id)) { + // Strip all non numbers from this string. + $amount = convertFromMasterCurrency(preg_replace('/[^0-9]/', '', floor($record->column_fields['amount'])),$current_user->conv_rate); + $sum[$month][$sales_stage][$record->column_fields['assigned_user_id']] = $sum[$month][$sales_stage][$record->column_fields['assigned_user_id']] + $amount; + if (isset($count[$month][$sales_stage][$record->column_fields['assigned_user_id']])) { + + $count[$month][$sales_stage][$record->column_fields['assigned_user_id']]++; + } else { + + $count[$month][$sales_stage][$record->column_fields['assigned_user_id']] = 1; + } + $total = $total + ($amount/1000); + } + } + } + + $legend = array(); + $datax = array(); + $aTargets = array(); + $aAlts = array(); + $stages = array($other, 'Closed Lost', 'Closed Won'); + //sort the months or push a bogus month on the array so that an empty chart is drawn + if (empty($months)) { + array_push($months, date('Y-m',time())); + } + else{ + sort($months); + } + foreach($months as $month) { + foreach($stages as $stage) { + $log->debug("stage is $stage"); + foreach ($user_id as $the_id) { + $the_user = get_assigned_user_name($the_id); + if (!isset($datax[$stage][$the_id])) { + $datax[$stage][$the_id] = array(); + } + if (!isset($aAlts[$stage][$the_id])) { + $aAlts[$stage][$the_id] = array(); + } + if (!isset($aTargets[$stage][$the_id])) { + $aTargets[$stage][$the_id] = array(); + } + + if (isset($sum[$month][$stage][$the_id])) { + array_push($datax[$stage][$the_id], $sum[$month][$stage][$the_id]/1000); + array_push($aAlts[$stage][$the_id], $the_user.' - '.$count[$month][$stage][$the_id]." ".$current_module_strings['LBL_OPPS_OUTCOME']." $stage"); + } + else { + array_push($datax[$stage][$the_id], 0); + array_push($aAlts[$stage][$the_id], ""); + } + $cvid = getCvIdOfAll("Potentials"); + array_push($aTargets[$stage][$the_id], "index.php?module=Potentials&action=ListView&date_closed=$month&sales_stage=".urlencode($stage)."&query=true&type=dbrd&owner=".$the_user."&viewname=".$cvid); + } + } + array_push($legend,$month); + } + $log->debug("datax is:"); + $log->debug($datax); + $log->debug("aAlts is:"); + $log->debug($aAlts); + $log->debug("aTargets is:"); + $log->debug($aTargets); + $log->debug("sum is:"); + $log->debug($sum); + $log->debug("count is:"); + $log->debug($count); + + //now build the bar plots for each user across the sales stages + $index = 0; + $datasets = array(); + $xlabels = array(); + $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); + $color = array('Closed Lost'=>'#FF9900','Closed Won'=>'#009933', $other=>'#0066CC'); + foreach($stages as $stage) { + $datasets[$index] = & Image_Graph::factory('dataset'); + foreach($datax[$stage] as $ownerid=>$owner_amt) { + foreach($owner_amt as $i=>$y) { + $x = 1+2*$i; + $datasets[$index]->addPoint( + $x, + $y, + array( + 'url' => $aTargets[$stage][$ownerid][$i], + 'alt' => $aAlts[$stage][$ownerid][$i] + ) + ); + } + } + // Set fill colors for bars + $fills->addColor($color[$stage]); + $index++; + } + + for($i=0;$i$m) { + $monthSum = 0; + foreach($user_id as $the_id) { + foreach($stages as $stage) $monthSum += $datax[$stage][$the_id][$num]; + } + if($monthSum > $maximum) $maximum = $monthSum; + $log->debug('maximum = '.$maximum.' month = '.$m.' sum = '.$monthSum); + } + + if($theme == "blue") + { + $font_color = "#212473"; + } + else + { + $font_color = "#000000"; + } + $font->setColor($font_color); + + // Create the grouped bar plot + $gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked')); + $gbplot->setFillStyle($fills); + + //You can change the width of the bars if you like + $gbplot->setBarWidth(50/count($months),"%"); + + // set margin + $plotarea->setPadding(array('top'=>0,'bottom'=>0,'left'=>10,'right'=>30)); + + // Set white margin color + $graph->setBackgroundColor('#F5F5F5'); + + // Use a box around the plot area + $gbplot->setBorderColor('black'); + + // Use a gradient to fill the plot area + $gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', '#E5E5E5'))); + + // Setup title + $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL']; + //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total; + + $title->setText($titlestr); + + // Create the xaxis labels + $array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', + array($xlabels) + ); + + // Setup X-axis + $xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X); + $xaxis->setDataPreprocessor($array_data); + $xaxis->forceMinimum(0); + $xaxis->forceMaximum(2*count($months)); + $xaxis->setLabelInterval(1); + $xaxis->setTickOptions(0,0); + $xaxis->setLabelInterval(2,2); + $xaxis->setTickOptions(5,0,2); + + // set grid + $gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y); + $gridY->setLineColor('#E5E5E5@0.5'); + + + // Add some grace to y-axis so the bars doesn't go + // all the way to the end of the plot area + $yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + $yaxis->forceMaximum($maximum * 1.1); + $ticks = get_tickspacing($maximum); + + // Setup the Y-axis to be displayed in the bottom of the + // graph. We also finetune the exact layout of the title, + // ticks and labels to make them look nice. + $yaxis->setAxisIntersection('max'); + + // Then fix the tick marks + $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d"); + $yaxis->setFontSize(8); + $yaxis->setDataPreprocessor($valueproc); + // Arrange Y-Axis tick marks inside + $yaxis->setLabelInterval($ticks[0]); + $yaxis->setTickOptions(-5,0); + $yaxis->setLabelInterval($ticks[1],2); + $yaxis->setTickOptions(-2,0,2); + $yaxis->setLabelOption('position','inside'); + + // Finally setup the title + $yaxis->setLabelOption('position','inside'); + + // eliminate zero values + $gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros')); + + // set markers + $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); + $marker->setDataPreprocessor($valueproc); + $marker->setFillColor('000000@0.0'); + $marker->setBorderColor('000000@0.0'); + $marker->setFontColor('white'); + $marker->setFontSize(8); + $gbplot->setMarker($marker); + + $subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; + $footer->setText($subtitle); + $footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT); + + // .. and stroke the graph + $imgMap = $graph->done( + array( + 'tohtml' => true, + 'border' => 0, + 'filename' => $cache_file_name, + 'filepath' => './', + 'urlpath' => '' + )); + //$imgMap = htmlspecialchars($output); + save_image_map($cache_file_name.'.map', $imgMap); + } + else { + $imgMap_fp = fopen($cache_file_name.'.map', "rb"); + $imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map')); + fclose($imgMap_fp); + } + $fileModTime = filemtime($cache_file_name.'.map'); + $return = "\n$imgMap"; + $log->debug("Exiting outcome_by_month method ..."); + return $return; + } + + /** + * Creates lead_source_by_outcome pipeline image as a horizontal accumlated bar graph for multiple vtiger_users. + * param $datay- the lead source data to display in the x-axis + * param $date_start- the begin date of opps to find + * param $date_end- the end date of opps to find + * param $ids - list of assigned vtiger_users of opps to find + * param $cache_file_name - file name to write image to + * param $refresh - boolean whether to rebuild image if exists + * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. + * All Rights Reserved.. + * Contributor(s): ______________________________________.. + */ + function lead_source_by_outcome($datay=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){ + global $log,$current_user; + $log->debug("Entering lead_source_by_outcome(".$datay.",".$user_id.",".$cache_file_name.",".$refresh.") method ..."); + global $app_strings,$lang_crm, $current_module_strings,$charset, $tmp_dir; + global $theme; + + include_once ('Image/Graph.php'); + include_once ('Image/Canvas.php'); + + $log =& LoggerManager::getLogger('lead_source_by_outcome chart'); + // Set the basic parameters of the graph + $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); + $imagemap = $canvas->getImageMap(); + $graph =& Image_Graph::factory('graph', $canvas); + $log->debug("graph object created"); + // add a TrueType font + $font =& $graph->addNew('font', calculate_font_name($lang_crm)); + // set the font size to 11 pixels + $font->setSize(8); + + $graph->setFont($font); + // create the plotarea layout + $title =& Image_Graph::factory('title', array('Test',10)); + $plotarea =& Image_Graph::factory('plotarea',array( + 'axis', + 'axis', + 'horizontal' + )); + $footer =& Image_Graph::factory('title', array('Footer',8)); + $graph->add( + Image_Graph::vertical($title, + Image_Graph::vertical( + $plotarea, + $footer, + 90 + ), + 5 + ) + ); + + if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) { + + $log->debug("datay is:"); + $log->debug($datay); + $log->debug("user_id is: "); + $log->debug($user_id); + $log->debug("cache_file_name is: $cache_file_name"); + + $where=""; + //build the where clause for the query that matches $datay + $count = count($datay); + if ($count>0) { + $where .= " leadsource in ( "; + $ls_i = 0; + foreach ($datay as $key=>$value) { + if($ls_i != 0) $where .= ", "; + $where .= "'".addslashes($key)."'"; + $ls_i++; + } + $where .= ")"; + } + + //Now do the db queries + //query for opportunity data that matches $datay and $user + $opp = new Potentials(); + $opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where); + + //build pipeline by sales stage data + $total = 0; + $count = array(); + $sum = array(); + $other = $current_module_strings['LBL_LEAD_SOURCE_OTHER']; + if (isset($opp_list)) { + foreach ($opp_list as $record) { + //if lead source is blank, set it to the language's "none" value + if (isset($record->column_fields['leadsource']) && $record->column_fields['leadsource'] != '') { + $lead_source = $record->column_fields['leadsource']; + } + else { + $lead_source = $current_module_strings['NTC_NO_LEGENDS']; + } + + if ($record->column_fields['sales_stage'] == 'Closed Won' || $record->column_fields['sales_stage'] == 'Closed Lost') { + $sales_stage=$record->column_fields['sales_stage']; + } + else { + $sales_stage=$other; + } + + if (!isset($sum[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']])) { + $sum[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']] = 0; + } + if (isset($record->column_fields['amount']) && in_array($record->column_fields['assigned_user_id'],$user_id)) { + // Strip all non numbers from this string. + $amount = convertFromMasterCurrency(preg_replace('/[^0-9]/', '', floor($record->column_fields['amount'])),$current_user->conv_rate); + $sum[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']] = $sum[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']] + $amount; + if (isset($count[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']])) { + $count[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']]++; + } + else { + $count[$lead_source][$sales_stage][$record->column_fields['assigned_user_id']] = 1; + } + $total = $total + ($amount/1000); + } + } + } + $legend = array(); + $datax = array(); + $aTargets = array(); + $aAlts = array(); + $stages = array($other,'Closed Lost', 'Closed Won'); + foreach($datay as $lead=>$translation) { + if ($lead == '') { + $lead = $current_module_strings['NTC_NO_LEGENDS']; + $translation = $current_module_strings['NTC_NO_LEGENDS']; + } + foreach($stages as $stage) { + foreach ($user_id as $the_id) { + $the_user = get_assigned_user_name($the_id); + $log->debug("stage_key is $stage"); + if (!isset($datax[$stage][$the_id])) { + $datax[$stage][$the_id] = array(); + } + if (!isset($aAlts[$stage][$the_id])) { + $aAlts[$stage][$the_id] = array(); + } + if (!isset($aTargets[$stage][$the_id])) { + $aTargets[$stage][$the_id] = array(); + } + + if (isset($sum[$lead][$stage][$the_id])) { + array_push($datax[$stage][$the_id], $sum[$lead][$stage][$the_id]/1000); + array_push($aAlts[$stage][$the_id], $the_user.' - '.$count[$lead][$stage][$the_id]." ".$current_module_strings['LBL_OPPS_OUTCOME']." $stage"); + } + else { + array_push($datax[$stage][$the_id], 0); + array_push($aAlts[$stage][$the_id], ""); + } + $cvid = getCvIdOfAll("Potentials"); + array_push($aTargets[$stage][$the_id], "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead)."&sales_stage=".urlencode($stage)."&query=true&type=dbrd&owner=".$the_user."&viewname=".$cvid); + } + } + array_push($legend,$translation); + } + + $log->debug("datax is:"); + $log->debug($datax); + $log->debug("aAlts is:"); + $log->debug($aAlts); + $log->debug("aTargets is:"); + $log->debug($aTargets); + $log->debug("sum is:"); + $log->debug($sum); + $log->debug("count is:"); + $log->debug($count); + + //now build the bar plots for each user across the sales stages + $color = array('Closed Lost'=>'FF9900','Closed Won'=>'009933', $other=>'0066CC'); + $index = 0; + $xlabels = array(); + $datasets = array(); + $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); + foreach($stages as $stage) { + // Now create a bar pot + $datasets[$index] = & Image_Graph::factory('dataset'); + foreach($datax[$stage] as $ownerid=>$owner_amt) { + foreach($owner_amt as $i=>$y) { + $x = 1+2*$i; + $datasets[$index]->addPoint( + //$datay[$legend[$x]], + $x, + $y, + array( + 'url' => $aTargets[$stage][$ownerid][$i], + 'alt' => $aAlts[$stage][$ownerid][$i], + 'target' => '' + ) + ); + } + } + // Set fill colors for bars + $fills->addColor("#".$color[$stage]); + $log->debug("datax[$stage] is: "); + $log->debug($datax[$stage]); + $index++; + } + + for($i=0;$i$legend_text) { + $dataxSum = 0; + foreach($user_id as $the_id) { + foreach($stages as $stage) $dataxSum += $datax[$stage][$the_id][$legendidx]; + } + if($dataxSum > $maximum) $maximum = $dataxSum; + } + + if($theme == "blue") + { + $font_color = "#212473"; + } + else + { + $font_color = "#000000"; + } + $font->setColor($font_color); + + // Create the grouped bar plot + $gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked')); + $gbplot->setFillStyle($fills); + + //You can change the width of the bars if you like + $gbplot->setBarWidth(50/count($legend),"%"); + + // Set white margin color + $graph->setBackgroundColor('#F5F5F5'); + + // Use a box around the plot area + $gbplot->setBorderColor('black'); + + // Use a gradient to fill the plot area + $gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5'))); + + // Setup title + $titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL']; + //$titlestr = $current_module_strings['LBL_ALL_OPPORTUNITIES'].$current_user->currency_symbol.$total; + $title->setText($titlestr); + + // Create the xaxis labels + $array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', + array($xlabels) + ); + + // Setup X-axis + $xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X); + $xaxis->setDataPreprocessor($array_data); + $xaxis->forceMinimum(0); + $xaxis->forceMaximum(2*count($legend)); + $xaxis->setLabelInterval(1); + $xaxis->setTickOptions(0,0); + $xaxis->setLabelInterval(2,2); + $xaxis->setTickOptions(5,0,2); + $xaxis->setInverted(true); + + // set grid + $gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y); + $gridY->setLineColor('#E5E5E5@0.5'); + + // Add some grace to y-axis so the bars doesn't go + // all the way to the end of the plot area + $yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + $yaxis->forceMaximum($maximum * 1.1); + $ticks = get_tickspacing($maximum); + + // Then fix the tick marks + $yaxis->setFontSize(8); + $yaxis->setAxisIntersection('max'); + $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d"); + $yaxis->setDataPreprocessor($valueproc); + $yaxis->setLabelInterval($ticks[0]); + $yaxis->setTickOptions(-5,0); + $yaxis->setLabelInterval($ticks[1],2); + $yaxis->setTickOptions(-2,0,2); + + // eliminate zero values + $gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros')); + + // set markers + $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); + $marker->setDataPreprocessor($valueproc); + $marker->setFillColor('#000000@0.0'); + $marker->setBorderColor('#000000@0.0'); + $marker->setFontColor('white'); + $marker->setFontSize(8); + $gbplot->setMarker($marker); + + // Finally setup the title + $subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; + $footer->setText($subtitle); + $footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT); + + // .. and stroke the graph + $imgMap = $graph->done( + array( + 'tohtml' => true, + 'border' => 0, + 'filename' => $cache_file_name, + 'filepath' => './', + 'urlpath' => '' + )); + //$imgMap = htmlspecialchars($output); + save_image_map($cache_file_name.'.map', $imgMap); + } + else { + $imgMap_fp = fopen($cache_file_name.'.map', "rb"); + $imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map')); + fclose($imgMap_fp); + } + $fileModTime = filemtime($cache_file_name.'.map'); + $return = "\n$imgMap"; + $log->debug("Exiting lead_source_by_outcome method ..."); + return $return; + } + + /** + * Creates opportunity pipeline image as a horizontal accumlated bar graph for multiple vtiger_users. + * param $datax- the sales stage data to display in the x-axis + * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. + * All Rights Reserved.. + * Contributor(s): ______________________________________.. + */ + function pipeline_by_sales_stage($datax=array('foo','bar'), $date_start='2071-10-15', $date_end='2071-10-15', $user_id=array('1'), $cache_file_name='a_file', $refresh=false,$width=900,$height=500){ + global $log,$current_user; + $log->debug("Entering pipeline_by_sales_stage(".$datax.",".$date_start.",".$date_end.",".$user_id.",".$cache_file_name.",".$refresh.") method ..."); + global $app_strings,$lang_crm, $current_module_strings, $charset, $tmp_dir; + global $theme; + include_once ('Image/Graph.php'); + include_once ('Image/Canvas.php'); + + $log =& LoggerManager::getLogger('opportunity charts'); + // Set the basic parameters of the graph + + + $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); + $imagemap = $canvas->getImageMap(); + $graph =& Image_Graph::factory('graph', $canvas); + //$log->debug("graph object created"); + // add a TrueType font + //$font =& $graph->addNew('font', calculate_font_name($lang_crm)); + $font =& $graph->addNew('font', calculate_font_name($lang_crm)); + // set the font size to 11 pixels + $font->setSize(8); + + $graph->setFont($font); + $title =& Image_Graph::factory('title', array('Test',10)); + $plotarea =& Image_Graph::factory('plotarea',array( + 'axis', + 'axis', + 'horizontal' + )); + $footer =& Image_Graph::factory('title', array('Footer',8)); + $graph->add( + Image_Graph::vertical($title, + Image_Graph::vertical( + $plotarea, + $footer, + 90 + ), + 5 + ) + ); + $log->debug("graph object created"); + + + if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) { + + $log->debug("starting pipeline chart"); + $log->debug("datax is:"); + $log->debug($datax); + $log->debug("user_id is: "); + $log->debug($user_id); + $log->debug("cache_file_name is: $cache_file_name"); + + $where=""; + //build the where clause for the query that matches $datax + $count = count($datax); + if ($count>0) { + $where .= " sales_stage in ( "; + $ss_i = 0; + foreach ($datax as $key=>$value) { + if($ss_i != 0) $where .= ", "; + $where .= "'".addslashes($key)."'"; + $ss_i++; + } + $where .= ")"; + } + + //build the where clause for the query that matches $date_start and $date_end + $where .= " AND closingdate >= '$date_start' AND closingdate <= '$date_end'"; + $subtitle = $current_module_strings['LBL_DATE_RANGE']." ".getDisplayDate($date_start)." ".$current_module_strings['LBL_DATE_RANGE_TO']." ".getDisplayDate($date_end)."\n"; + + //Now do the db queries + //query for opportunity data that matches $datax and $user + $opp = new Potentials(); + $opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where); + + //build pipeline by sales stage data + $total = 0; + $count = array(); + $sum = array(); + if (isset($opp_list)) { + foreach ($opp_list as $record) { + if (!isset($sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) { + $sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = 0; + } + if (isset($record->column_fields['amount']) && in_array($record->column_fields['assigned_user_id'],$user_id)) { + // Strip all non numbers from this string. + $amount = convertFromMasterCurrency(preg_replace('/[^0-9]/', '', floor($record->column_fields['amount'])),$current_user->conv_rate); + $sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = $sum[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] + $amount; + if (isset($count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']])) { + $count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']]++; + } + else { + $count[$record->column_fields['sales_stage']][$record->column_fields['assigned_user_id']] = 1; + } + $total = $total + ($amount/1000); + } + } + } + $legend = array(); + $datay = array(); + $aTargets = array(); + $aAlts = array(); + foreach ($datax as $stage_key=>$stage_translation) { + foreach ($user_id as $the_id) { + $the_user = get_assigned_user_name($the_id); + if (!isset($datay[$the_id])) { + $datay[$the_id] = array(); + } + if (!isset($aAlts[$the_id])) { + $aAlts[$the_id] = array(); + } + if (!isset($aTargets[$the_id])) { + $aTargets[$the_id] = array(); + } + + if (isset($sum[$stage_key][$the_id])) { + array_push($datay[$the_id], $sum[$stage_key][$the_id]/1000); + array_push($aAlts[$the_id], $the_user.' - '.$count[$stage_key][$the_id]." ".$current_module_strings['LBL_OPPS_IN_STAGE']." $stage_translation"); + } + else { + array_push($datay[$the_id], 0); + array_push($aAlts[$the_id], ""); + } + $cvid = getCvIdOfAll("Potentials"); + array_push($aTargets[$the_id], "index.php?module=Potentials&action=ListView&sales_stage=".urlencode($stage_key)."&closingdate_start=".urlencode($date_start)."&closingdate_end=".urlencode($date_end)."&query=true&type=dbrd&owner=".$the_user."&viewname=".$cvid); + } + array_push($legend,$stage_translation); + } + + $log->debug("datay is:"); + $log->debug($datay); + $log->debug("aAlts is:"); + $log->debug($aAlts); + $log->debug("aTargets is:"); + $log->debug($aTargets); + $log->debug("sum is:"); + $log->debug($sum); + $log->debug("count is:"); + $log->debug($count); + + //now build the bar plots for each user across the sales stages + $colors = color_generator(count($user_id),'#D50100','#002222'); + $index = 0; + $datasets = array(); + $xlabels = array(); + $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); + foreach($user_id as $the_id) { + // Now create a bar pot + $datasets[$index] = & Image_Graph::factory('dataset'); + foreach($datay[$the_id] as $i => $y) { + $x = 1+2*$i; + $datasets[$index]->addPoint( + $x, + $y, + array( + 'url' => $aTargets[$the_id][$i], + 'alt' => $aAlts[$the_id][$i] + ) + ); + } + + // Set fill colors for bars + $fills->addColor($colors[$index]); + + $index++; + } + for($i=0;$i$legend_text) { + $legendsum = 0; + foreach($user_id as $the_id) $legendsum += $datay[$the_id][$legendidx]; + if($legendsum > $maximum) $maximum = $legendsum; + } + // Create the grouped bar plot + $gbplot = & $plotarea->addNew('bar', array($datasets, 'stacked')); + $gbplot->setFillStyle($fills); + + //You can change the width of the bars if you like + $gbplot->setBarWidth(50/count($legend),"%"); + + + // Set white margin color + $graph->setBackgroundColor('#F5F5F5'); + + // Use a box around the plot area + $gbplot->setBorderColor('black'); + + // Use a gradient to fill the plot area + $gbplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5'))); + + if($theme == "blue") + { + $font_color = "#212473"; + } + else + { + $font_color = "#000000"; + } + $font->setColor($font_color); + + // Setup title + $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL']; + //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total; + $title->setText($titlestr); + + // Create the xaxis labels + $array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', + array($xlabels) + ); + + + // Setup X-axis + $xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X); + $xaxis->setDataPreprocessor($array_data); + $xaxis->forceMinimum(0); + $xaxis->forceMaximum(2*count($legend)); + $xaxis->setLabelInterval(1); + $xaxis->setTickOptions(0,0); + $xaxis->setLabelInterval(2,2); + $xaxis->setTickOptions(5,0,2); + $xaxis->setInverted(true); + + // Setup Y-axis + $yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + $yaxis->setFontSize(8); + $yaxis->setAxisIntersection('max'); + + // Add some grace to y-axis so the bars doesn't go + // all the way to the end of the plot area + $yaxis->forceMaximum($maximum * 1.1); + $ticks = get_tickspacing($maximum); + + // set grid + $gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y); + $gridY->setLineColor('#E5E5E5@0.5'); + + // First make the labels look right + $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d"); + $yaxis->setDataPreprocessor($valueproc); + $yaxis->setLabelInterval($ticks[0]); + $yaxis->setTickOptions(-5,0); + $yaxis->setLabelInterval($ticks[1],2); + $yaxis->setTickOptions(-2,0,2); + + // eliminate zero values + $gbplot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros')); + + // set markers + $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); + $marker->setDataPreprocessor($valueproc); + $marker->setFillColor('000000@0.0'); + $marker->setBorderColor('000000@0.0'); + $marker->setFontColor('white'); + $marker->setFontSize(8); + $gbplot->setMarker($marker); + + // Finally setup the title + + $subtitle .= $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; + $footer->setText($subtitle); + $footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_RIGHT); + + // .. and stroke the graph + $imgMap = $graph->done( + array( + 'tohtml' => true, + 'border' => 0, + 'filename' => $cache_file_name, + 'filepath' => './', + 'urlpath' => '' + )); + //$imgMap = $graph->GetHTMLImageMap('pipeline'); + save_image_map($cache_file_name.'.map', $imgMap); + } + else { + $imgMap_fp = fopen($cache_file_name.'.map', "rb"); + $imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map')); + fclose($imgMap_fp); + } + $fileModTime = filemtime($cache_file_name.'.map'); + $return = "\n$imgMap"; + $log->debug("Exiting pipeline_by_sales_stage method ..."); + return $return; + } + + /** + * Creates pie chart image of opportunities by lead_source. + * param $datax- the sales stage data to display in the x-axis + * param $datay- the sum of opportunity amounts for each opportunity in each sales stage + * to display in the y-axis + * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. + * All Rights Reserved.. + * Contributor(s): ______________________________________.. + */ + function pipeline_by_lead_source($legends=array('foo','bar'), $user_id=array('1'), $cache_file_name='a_file', $refresh=true,$width=900,$height=500){ + global $log,$current_user; + $log->debug("Entering pipeline_by_lead_source(".$legends.") method ..."); + global $app_strings,$lang_crm, $current_module_strings, $log, $charset, $tmp_dir; + global $theme; + + include_once ('Image/Graph.php'); + include_once ('Image/Canvas.php'); + + $font = calculate_font_name($lang_crm); + if (!file_exists($cache_file_name) || !file_exists($cache_file_name.'.map') || $refresh == true) { + $log =& LoggerManager::getLogger('opportunity charts'); + $log->debug("starting pipeline chart"); + $log->debug("legends is:"); + $log->debug($legends); + $log->debug("user_id is: "); + $log->debug($user_id); + $log->debug("cache_file_name is: $cache_file_name"); + + //Now do the db queries + //query for opportunity data that matches $legends and $user + $where=""; + //build the where clause for the query that matches $datax + $count = count($legends); + if ($count>0) { + $where .= " leadsource in ( "; + $ls_i = 0; + foreach ($legends as $key=>$value) { + if($ls_i != 0) $where .= ", "; + $where .= "'".addslashes($key)."'"; + $ls_i++; + } + $where .= ")"; + } + + $opp = new Potentials(); + $opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where); + + //build pipeline by lead source data + $total = 0; + $count = array(); + $sum = array(); + if (isset($opp_list)) { + foreach ($opp_list as $record) { + if (!isset($sum[$record->column_fields['leadsource']])) $sum[$record->column_fields['leadsource']] = 0; + if (isset($record->column_fields['amount']) && isset($record->column_fields['leadsource'])) { + // Strip all non numbers from this string. + $amount = convertFromMasterCurrency(preg_replace('/[^0-9]/', '', floor($record->column_fields['amount'])),$current_user->conv_rate); + $sum[$record->column_fields['leadsource']] = $sum[$record->column_fields['leadsource']] + ($amount/1000); + if (isset($count[$record->column_fields['leadsource']])) $count[$record->column_fields['leadsource']]++; + else $count[$record->column_fields['leadsource']] = 1; + $total = $total + ($amount/1000); + } + } + } + + $visible_legends = array(); + $data= array(); + $aTargets = array(); + $aAlts = array(); + foreach ($legends as $lead_source_key=>$lead_source_translation) { + if (isset($sum[$lead_source_key])) + { + array_push($data, $sum[$lead_source_key]); + if($lead_source_key != '') + { + array_push($visible_legends, $lead_source_translation); + } + else + { + // put none in if the vtiger_field is blank. + array_push($visible_legends, $current_module_strings['NTC_NO_LEGENDS']); + } + $cvid = getCvIdOfAll("Potentials"); + array_push($aTargets, "index.php?module=Potentials&action=ListView&leadsource=".urlencode($lead_source_key)."&query=true&type=dbrd&viewname=".$cvid); + array_push($aAlts, $count[$lead_source_key]." ".$current_module_strings['LBL_OPPS_IN_LEAD_SOURCE']." $lead_source_translation "); + } + } + + $log->debug("sum is:"); + $log->debug($sum); + $log->debug("count is:"); + $log->debug($count); + $log->debug("total is: $total"); + if ($total == 0) { +$log->debug("Exiting pipeline_by_lead_source method ..."); + return ($current_module_strings['ERR_NO_OPPS']); + } + + if($theme == "blue") + { + $font_color = "#212473"; + } + else + { + $font_color = "#000000"; + } + + + $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); + $imagemap = $canvas->getImageMap(); + $graph =& Image_Graph::factory('graph', $canvas); + + $font =& $graph->addNew('font', calculate_font_name($lang_crm)); + // set the font size to 11 pixels + $font->setSize(8); + $font->setColor($font_color); + + $graph->setFont($font); + // create the plotarea layout + $title =& Image_Graph::factory('title', array('Test',10)); + $plotarea =& Image_Graph::factory('plotarea',array( + 'category', + 'axis' + )); + $footer =& Image_Graph::factory('title', array('Footer',8)); + $graph->add( + Image_Graph::vertical($title, + Image_Graph::vertical( + $plotarea, + $footer, + 90 + ), + 5 + ) + ); + + // Generate colours + $colors = color_generator(count($visible_legends),'#33CCFF','#3322FF'); + $index = 0; + $dataset = & Image_Graph::factory('dataset'); + $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); + foreach($visible_legends as $legend) { + $dataset->addPoint( + $legend, + $data[$index], + array( + 'url' => $aTargets[$index], + 'alt' => $aAlts[$index] + ) + ); + $fills->addColor($colors[$index]); + $log->debug('point ='.$legend.','.$data[$index]); + + $index++; + } + + // create the pie chart and associate the filling colours + $gbplot = & $plotarea->addNew('pie', $dataset); + $plotarea->hideAxis(); + $gbplot->setFillStyle($fills); + + // Setup title + $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total.$app_strings['LBL_THOUSANDS_SYMBOL']; + //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total; + + $title->setText($titlestr); + + // format the data values + $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol."%d"); + + // set markers + $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); + $marker->setDataPreprocessor($valueproc); + $marker->setFillColor('#FFFFFF'); + $marker->setBorderColor($font_color); + $marker->setFontColor($font_color); + $marker->setFontSize(8); + $pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker)); + $gbplot->setMarker($pointingMarker); + + // set legend + $legend_box =& $plotarea->addNew('legend'); + $legend_box->setPadding(array('top'=>20,'bottom'=>0,'left'=>0,'right'=>0)); + $legend_box->setFillColor('#F5F5F5'); + $legend_box->showShadow(); + + $subtitle = $current_module_strings['LBL_OPP_SIZE'].$current_user->currency_symbol.$current_module_strings['LBL_OPP_SIZE_VALUE']; + $footer->setText($subtitle); + $footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_LEFT); + + $imgMap = $graph->done( + array( + 'tohtml' => true, + 'border' => 0, + 'filename' => $cache_file_name, + 'filepath' => './', + 'urlpath' => '' + )); + //$imgMap = htmlspecialchars($output); + save_image_map($cache_file_name.'.map', $imgMap); + } + else { + $imgMap_fp = fopen($cache_file_name.'.map', "rb"); + $imgMap = fread($imgMap_fp, filesize($cache_file_name.'.map')); + fclose($imgMap_fp); + } + $fileModTime = filemtime($cache_file_name.'.map'); + $return = "\n$imgMap"; + $log->debug("Exiting pipeline_by_lead_source method ..."); + return $return; + + } + +} + + +/** + * Creates a file with the image map + * param $filename - file name to save to + * param $image_map - image map string to save + * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. + * All Rights Reserved. + * Contributor(s): ______________________________________.. + */ +function save_image_map($filename,$image_map) +{ + global $log; + $log->debug("Entering save_image_map(".$filename.",".$image_map.") method ..."); + // save the image map to file + $log =& LoggerManager::getLogger('save_image_file'); + + if (!$handle = fopen($filename, 'w')) { + $log->debug("Cannot open file ($filename)"); + $log->debug("Exiting save_image_map method ..."); + return; + } + + // Write $somecontent to our opened file. + if (fwrite($handle, $image_map) === FALSE) { + $log->debug("Cannot write to file ($filename)"); + $log->debug("Exiting save_image_map method ..."); + return false; + } + + $log->debug("Success, wrote ($image_map) to file ($filename)"); + + fclose($handle); + $log->debug("Exiting save_image_map method ..."); + return true; + +} + +// retrieve the translated strings. +$app_strings = return_application_language($current_language); + +if(isset($app_strings['LBL_CHARSET'])) +{ + $charset = $app_strings['LBL_CHARSET']; +} +else +{ + $charset = $default_charset; +} + + +?> diff --git a/oss/vtiger/trunk/modules/Potentials/CustomView.php b/oss/vtiger/trunk/modules/Potentials/CustomView.php new file mode 100644 index 00000000..93231ed6 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/CustomView.php @@ -0,0 +1,14 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/Delete.php b/oss/vtiger/trunk/modules/Potentials/Delete.php new file mode 100644 index 00000000..e9046f54 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Delete.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/DetailView.php b/oss/vtiger/trunk/modules/Potentials/DetailView.php new file mode 100644 index 00000000..a1b78b82 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/DetailView.php @@ -0,0 +1,142 @@ +retrieve_entity_info($_REQUEST['record'],"Potentials"); + $focus->id = $_REQUEST['record']; + $focus->name=$focus->column_fields['potentialname']; +} +if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { + $focus->id = ""; +} + +global $theme; +$theme_path="themes/".$theme."/"; +$image_path=$theme_path."images/"; + +$log->info("Potential detail view"); + +$smarty->assign("MOD", $mod_strings); +$smarty->assign("APP", $app_strings); + +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH", $image_path); +$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']); +$smarty->assign("ID", $focus->id); + +// Module Sequence Numbering +$mod_seq_field = getModuleSequenceField($currentModule); +if ($mod_seq_field != null) { + $mod_seq_id = $focus->column_fields[$mod_seq_field['name']]; +} else { + $mod_seq_id = $focus->id; +} +$smarty->assign('MOD_SEQ_ID', $mod_seq_id); +// END + +$smarty->assign("UPDATEINFO",updateInfo($focus->id)); + +if (isset($focus->name)) $smarty->assign("NAME", $focus->name); +else $smarty->assign("NAME", ""); + +$smarty->assign("BLOCKS", getBlocks($currentModule,"detail_view",'',$focus->column_fields)); + +$smarty->assign("CUSTOMFIELD", $cust_fld); +$smarty->assign("SINGLE_MOD", 'Opportunity'); +$category = getParentTab(); +$smarty->assign("CATEGORY",$category); + + +if(isPermitted("Potentials","EditView",$_REQUEST['record']) == 'yes') + $smarty->assign("EDIT_DUPLICATE","permitted"); +if(isPermitted("Invoice","EditView",$_REQUEST['record']) == 'yes') + $smarty->assign("CONVERTINVOICE","permitted"); +if(isPermitted("Potentials","Delete",$_REQUEST['record']) == 'yes') + $smarty->assign("DELETE","permitted"); + +$tabid = getTabid("Potentials"); +$validationData = getDBValidationData($focus->tab_name,$tabid); +$data = split_validationdataArray($validationData); + +$smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']); +$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']); +$smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']); + +$check_button = Button_Check($module); +$smarty->assign("CHECK", $check_button); + +$smarty->assign("CONVERTMODE",'potentoinvoice'); +$smarty->assign("MODULE","Potentials"); +$smarty->assign("EDIT_PERMISSION",isPermitted($currentModule,'EditView',$_REQUEST['record'])); + +if($singlepane_view == 'true') +{ + $related_array = getRelatedLists($currentModule,$focus); + $smarty->assign("RELATEDLISTS", $related_array); + + require_once('include/ListView/RelatedListViewSession.php'); + if(!empty($_REQUEST['selected_header']) && !empty($_REQUEST['relation_id'])) { + RelatedListViewSession::addRelatedModuleToSession(vtlib_purify($_REQUEST['relation_id']), + vtlib_purify($_REQUEST['selected_header'])); + } + $open_related_modules = RelatedListViewSession::getRelatedModulesFromSession(); + $smarty->assign("SELECTEDHEADERS", $open_related_modules); +} + +$smarty->assign("IS_REL_LIST",isPresentRelatedLists($currentModule)); + +$smarty->assign("SinglePane_View", $singlepane_view); +$smarty->assign("TODO_PERMISSION",CheckFieldPermission('parent_id','Calendar')); +$smarty->assign("EVENT_PERMISSION",CheckFieldPermission('parent_id','Events')); + +if(PerformancePrefs::getBoolean('DETAILVIEW_RECORD_NAVIGATION', true) && isset($_SESSION[$currentModule.'_listquery'])){ + $recordNavigationInfo = ListViewSession::getListViewNavigation($focus->id); + VT_detailViewNavigation($smarty,$recordNavigationInfo,$focus->id); +} + +// Record Change Notification +$focus->markAsViewed($current_user->id); +// END + +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'RECORD'=>$focus->id, 'ACTION'=>vtlib_purify($_REQUEST['action'])); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('DETAILVIEWBASIC','DETAILVIEW','DETAILVIEWWIDGET'), $customlink_params)); +// END + +$smarty->assign('DETAILVIEW_AJAX_EDIT', PerformancePrefs::getBoolean('DETAILVIEW_AJAX_EDIT', true)); + +$smarty->display("DetailView.tpl"); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/DetailViewAjax.php b/oss/vtiger/trunk/modules/Potentials/DetailViewAjax.php new file mode 100644 index 00000000..51627f81 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/DetailViewAjax.php @@ -0,0 +1,52 @@ +retrieve_entity_info($crmid,"Potentials"); + $modObj->column_fields[$fieldname] = $fieldvalue; + $_REQUEST[$fieldname] = $fieldvalue; + if($fieldname == 'amount')//amount converted to dollar value while saving + { + $modObj->column_fields[$fieldname] = getConvertedPrice($fieldvalue); + } + $modObj->id = $crmid; + $modObj->mode = "edit"; + $modObj->save("Potentials"); + if($modObj->id != "") + { + echo ":#:SUCCESS"; + }else + { + echo ":#:FAILURE"; + } + }else + { + echo ":#:FAILURE"; + } +} elseif($ajaxaction == "LOADRELATEDLIST" || $ajaxaction == "DISABLEMODULE") { + require_once 'include/ListView/RelatedListViewContents.php'; +} +?> diff --git a/oss/vtiger/trunk/modules/Potentials/EditView.php b/oss/vtiger/trunk/modules/Potentials/EditView.php new file mode 100644 index 00000000..aaf62107 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/EditView.php @@ -0,0 +1,164 @@ +assign("SEARCH", $searchurl); +//4600 ends + +if(isset($_REQUEST['record']) && $_REQUEST['record'] != ''){ + $focus->id = $_REQUEST['record']; + $focus->mode = 'edit'; + $focus->retrieve_entity_info($_REQUEST['record'],"Potentials"); + $focus->name=$focus->column_fields['potentialname']; +} + +//adding support for uitype 10 +if(!empty($_REQUEST['contact_id'])){ + $focus->column_fields['related_to'] = $_REQUEST['contact_id']; +}elseif(!empty($_REQUEST['account_id'])){ + $focus->column_fields['related_to'] = $_REQUEST['account_id']; +} + +if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') { + $focus->id = ""; + $focus->mode = ''; +} +if(empty($_REQUEST['record']) && $focus->mode != 'edit'){ + setObjectValuesFromRequest($focus); +} + +$disp_view = getView($focus->mode); +if($disp_view == 'edit_view') + $smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields)); +else +{ + $smarty->assign("BASBLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields,'BAS')); +} +$smarty->assign("OP_MODE",$disp_view); +$category = getParentTab(); +$smarty->assign("CATEGORY",$category); + +//needed when creating a new opportunity with a default vtiger_account value passed in +if (isset($_REQUEST['accountname']) && is_null($focus->accountname)) { + $focus->accountname = $_REQUEST['accountname']; +} +if (isset($_REQUEST['accountid']) && is_null($focus->related_to)) { + $focus->related_to = $_REQUEST['accountid']; +} +if (isset($_REQUEST['contactid']) && is_null($focus->related_to)) { + $focus->related_to = $_REQUEST['contactid']; +} + +global $theme; +$theme_path="themes/".$theme."/"; +$image_path=$theme_path."images/"; + +$log->info("Potential detail view"); +$smarty->assign("MOD", $mod_strings); +$smarty->assign("APP", $app_strings); + +if (isset($focus->name)) +$smarty->assign("NAME", $focus->name); +else +$smarty->assign("NAME", ""); + +if(isset($cust_fld)) +{ + $smarty->assign("CUSTOMFIELD", $cust_fld); +} +if($focus->mode == 'edit') +{ + $smarty->assign("UPDATEINFO",updateInfo($focus->id)); + $smarty->assign("MODE", $focus->mode); +} + + + +// Unimplemented until jscalendar language vtiger_files are fixed +$smarty->assign("CALENDAR_LANG", $app_strings['LBL_JSCALENDAR_LANG']); +$smarty->assign("CALENDAR_DATEFORMAT", parse_calendardate($app_strings['NTC_DATE_FORMAT'])); + +if (isset($_REQUEST['return_module'])) +$smarty->assign("RETURN_MODULE", vtlib_purify($_REQUEST['return_module'])); +if (isset($_REQUEST['return_action'])) +$smarty->assign("RETURN_ACTION", vtlib_purify($_REQUEST['return_action'])); +if (isset($_REQUEST['return_id'])) +$smarty->assign("RETURN_ID", vtlib_purify($_REQUEST['return_id'])); +if (isset($_REQUEST['return_viewname'])) +$smarty->assign("RETURN_VIEWNAME", vtlib_purify($_REQUEST['return_viewname'])); +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH", $image_path);$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']); +$smarty->assign("ID", $focus->id); +$smarty->assign("MODULE",$currentModule); +$smarty->assign("SINGLE_MOD",'Potential'); + + + $tabid = getTabid("Potentials"); + $validationData = getDBValidationData($focus->tab_name,$tabid); + $data = split_validationdataArray($validationData); + + $smarty->assign("VALIDATION_DATA_FIELDNAME",$data['fieldname']); + $smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$data['datatype']); + $smarty->assign("VALIDATION_DATA_FIELDLABEL",$data['fieldlabel']); + +//fix for potential duplicate header +$smarty->assign("DUPLICATE",vtlib_purify($_REQUEST['isDuplicate'])); + +$check_button = Button_Check($module); +$smarty->assign("CHECK", $check_button); + +global $adb; +// Module Sequence Numbering +$mod_seq_field = getModuleSequenceField($currentModule); +if($focus->mode != 'edit' && $mod_seq_field != null) { + $autostr = getTranslatedString('MSG_AUTO_GEN_ON_SAVE'); + $mod_seq_string = $adb->pquery("SELECT prefix, cur_id from vtiger_modentity_num where semodule = ? and active=1",array($currentModule)); + $mod_seq_prefix = $adb->query_result($mod_seq_string,0,'prefix'); + $mod_seq_no = $adb->query_result($mod_seq_string,0,'cur_id'); + if($adb->num_rows($mod_seq_string) == 0 || $focus->checkModuleSeqNumber($focus->table_name, $mod_seq_field['column'], $mod_seq_prefix.$mod_seq_no)) + echo '
'. getTranslatedString('LBL_DUPLICATE'). ' '. getTranslatedString($mod_seq_field['label']) + .' - '. getTranslatedString('LBL_CLICK') .' '.getTranslatedString('LBL_HERE').' ' + . getTranslatedString('LBL_TO_CONFIGURE'). ' '. getTranslatedString($mod_seq_field['label']) .''; + else + $smarty->assign("MOD_SEQ_ID",$autostr); +} else { + $smarty->assign("MOD_SEQ_ID", $focus->column_fields[$mod_seq_field['name']]); +} +// END + +if($focus->mode == 'edit') +$smarty->display("salesEditView.tpl"); +else +$smarty->display("CreateView.tpl"); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/ExportRecords.php b/oss/vtiger/trunk/modules/Potentials/ExportRecords.php new file mode 100644 index 00000000..dcbf10eb --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/ExportRecords.php @@ -0,0 +1,13 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/FindDuplicateRecords.php b/oss/vtiger/trunk/modules/Potentials/FindDuplicateRecords.php new file mode 100644 index 00000000..a1ff9757 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/FindDuplicateRecords.php @@ -0,0 +1,106 @@ +pquery($sql, array($id)); + DeleteEntity($req_module,$return_module,$focus,$id,""); + } + else { + $ids_list[] = $id; + } +} + if(count($ids_list) > 0) { + $ret = getEntityName($req_module,$ids_list); + if(count($ret) > 0) + { + $errormsg = implode(',',$ret); + } + echo "
"; + echo "
+ + + + + + + + + +
+ $app_strings[LBL_DUP_PERMISSION] $req_module $errormsg
+ $app_strings[LBL_GO_BACK]
+
+
"; + echo "
"; + exit; + } +} + +include("include/saveMergeCriteria.php"); +$ret_arr=getDuplicateRecordsArr($req_module); + +$fld_values=$ret_arr[0]; +$total_num_group=count($fld_values); +$fld_name=$ret_arr[1]; +$ui_type=$ret_arr[2]; + +$smarty->assign("NAVIGATION",$ret_arr["navigation"]);//Added for page navigation +$smarty->assign("MODULE",$req_module); +$smarty->assign("NUM_GROUP",$total_num_group); +$smarty->assign("FIELD_NAMES",$fld_name); +$smarty->assign("CATEGORY",$parenttab); +$smarty->assign("ALL_VALUES",$fld_values); +if(isPermitted($req_module,'Delete','') == 'yes') + $button_del = $app_strings['LBL_MASS_DELETE']; +$smarty->assign("DELETE",$button_del); + +$smarty->assign("MOD", return_module_language($current_language,$req_module)); +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH",$image_path); +$smarty->assign("APP", $app_strings); +$smarty->assign("CMOD", $mod_strings); +$smarty->assign("MODE",'view'); +if(isset($_REQUEST['button_view'])) +{ + $smarty->assign("VIEW",'true'); +} +if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') + $smarty->display("FindDuplicateAjax.tpl"); +else + $smarty->display('FindDuplicateDisplay.tpl'); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/Import.php b/oss/vtiger/trunk/modules/Potentials/Import.php new file mode 100644 index 00000000..71867d63 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Import.php @@ -0,0 +1,45 @@ + + diff --git a/oss/vtiger/trunk/modules/Potentials/ListView.php b/oss/vtiger/trunk/modules/Potentials/ListView.php new file mode 100644 index 00000000..a3331f59 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/ListView.php @@ -0,0 +1,267 @@ +initSortbyField('Potentials'); +// END +$smarty = new vtigerCRM_Smarty(); +$other_text = Array(); + +if(!$_SESSION['lvs'][$currentModule]) +{ + unset($_SESSION['lvs']); + $modObj = new ListViewSession(); + $modObj->sorder = $sorder; + $modObj->sortby = $order_by; + $_SESSION['lvs'][$currentModule] = get_object_vars($modObj); +} + +if($_REQUEST['errormsg'] != '') +{ + $errormsg = vtlib_purify($_REQUEST['errormsg']); + $smarty->assign("ERROR","The User does not have permission to Change/Delete ".$errormsg." ".$currentModule); +}else +{ + $smarty->assign("ERROR",""); +} +//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>> +$sorder = $focus->getSortOrder(); +$order_by = $focus->getOrderBy(); + +$_SESSION['POTENTIALS_ORDER_BY'] = $order_by; +$_SESSION['POTENTIALS_SORT_ORDER'] = $sorder; +//<<<<<<<<<<<<<<<<<<< sorting - stored in session >>>>>>>>>>>>>>>>>>>> + +//<<<>>>>>> +$oCustomView = new CustomView("Potentials"); +$viewid = $oCustomView->getViewId($currentModule); +$customviewcombo_html = $oCustomView->getCustomViewCombo($viewid); +$viewnamedesc = $oCustomView->getCustomViewByCvid($viewid); + +//To check if a user is able to edit/delete a customview +$edit_permit = $oCustomView->isPermittedCustomView($viewid,'EditView',$currentModule); +$delete_permit = $oCustomView->isPermittedCustomView($viewid,'Delete',$currentModule); +$smarty->assign("CV_EDIT_PERMIT",$edit_permit); +$smarty->assign("CV_DELETE_PERMIT",$delete_permit); + +//Added to handle approving or denying status-public by the admin in CustomView +$statusdetails = $oCustomView->isPermittedChangeStatus($viewnamedesc['status']); +$smarty->assign("CUSTOMVIEW_PERMISSION",$statusdetails); + +//<<<<>>>> +$smarty->assign("CHANGE_OWNER",getUserslist()); +$smarty->assign("CHANGE_GROUP_OWNER",getGroupslist()); +if(isPermitted('Potentials','Delete','') == 'yes') +{ + $other_text['del'] = $app_strings[LBL_MASS_DELETE]; +} +if(isPermitted('Potentials','EditView','') == 'yes') +{ + $other_text['mass_edit'] = $app_strings[LBL_MASS_EDIT]; + $other_text['c_owner'] = $app_strings[LBL_CHANGE_OWNER]; +} + +if($viewnamedesc['viewname'] == 'All') +{ + $smarty->assign("ALL", 'All'); +} + +//Retreive the list from Database +//<<<<<<<<>>>>>>>> +global $current_user; +$queryGenerator = new QueryGenerator($currentModule, $current_user); +if ($viewid != "0") { + $queryGenerator->initForCustomViewById($viewid); +} else { + $queryGenerator->initForDefaultCustomView(); +} +//<<<<<<<>>>>>>>> +if(isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') { + $queryGenerator->addUserSearchConditions($_REQUEST); + $ustring = getSearchURL($_REQUEST); + // we have a query + $url_string .="&query=true".$ustring; + $smarty->assign("SEARCH_URL",$url_string); +} +$list_query = $queryGenerator->getQuery(); +$where = $queryGenerator->getConditionalWhere(); +if(isset($where) && $where != '') +{ + if(isset($_REQUEST['from_dashboard']) && $_REQUEST['from_dashboard'] == 'true') + $list_query .= " AND vtiger_potential.sales_stage = '".$mod_strings['Closed Won']."' AND ".$where; + elseif(isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') + $list_query .= " AND vtiger_potential.sales_stage not in( '".$mod_strings['Closed Won']."' , '".$mod_strings['Closed Lost']."' )AND ".$where; + + $_SESSION['export_where'] = $where; +} +else + unset($_SESSION['export_where']); + + +if(isset($order_by) && $order_by != '') +{ + if($order_by == 'smownerid') + { + if( $adb->dbType == "pgsql") + $list_query .= ' GROUP BY user_name'; + $list_query .= ' ORDER BY user_name '.$sorder; + } + else + { + $tablename = getTableNameForField('Potentials',$order_by); + $tablename = (($tablename != '')?($tablename."."):''); + + if( $adb->dbType == "pgsql") + $list_query .= ' GROUP BY '.$tablename.$order_by; + + $list_query .= ' ORDER BY '.$tablename.$order_by.' '.$sorder; + } +} +if($viewid ==0) +{ + echo "
"; + echo "
+ + + + + + + + + +
$app_strings[LBL_PERMISSION]
+ $app_strings[LBL_GO_BACK]
+
+
"; + echo "
"; + exit; +} +//Constructing the list view + +$smarty->assign("MOD", $mod_strings); +$smarty->assign("APP", $app_strings); +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH",$image_path); +$smarty->assign("CUSTOMVIEW_OPTION",$customviewcombo_html); +$smarty->assign("VIEWID", $viewid); +$smarty->assign("MODULE",$currentModule); +$smarty->assign("SINGLE_MOD",'Opportunity'); +$smarty->assign("BUTTONS",$other_text); +$smarty->assign("CATEGORY",$category); + +//Postgres 8 fixes +if( $adb->dbType == "pgsql") + $list_query = fixPostgresQuery( $list_query, $log, 0); + +if(PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true){ + $count_result = $adb->query( mkCountQuery( $list_query)); + $noofrows = $adb->query_result($count_result,0,"count"); +}else{ + $noofrows = null; +} + +$queryMode = (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true'); +$start = ListViewSession::getRequestCurrentPage($currentModule, $list_query, $viewid, $queryMode); + +$navigation_array = VT_getSimpleNavigationValues($start,$list_max_entries_per_page,$noofrows); + +$limit_start_rec = ($start-1) * $list_max_entries_per_page; + +if( $adb->dbType == "pgsql") + $list_result = $adb->pquery($list_query. " OFFSET $limit_start_rec LIMIT $list_max_entries_per_page", array()); +else + $list_result = $adb->pquery($list_query. " LIMIT $limit_start_rec, $list_max_entries_per_page", array()); + +$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec,$noofrows); +$smarty->assign('recordListRange',$recordListRangeMsg); + +//Retreive the List View Table Header +if($viewid !='') +$url_string .="&viewname=".$viewid; + +$controller = new ListViewController($adb, $current_user, $queryGenerator); +$listview_header = $controller->getListViewHeader($focus,$currentModule,$url_string,$sorder, + $order_by); +$smarty->assign("LISTHEADER", $listview_header); + +$listview_header_search = $controller->getBasicSearchFieldInfoList(); +$smarty->assign("SEARCHLISTHEADER", $listview_header_search); + + +$listview_entries = $controller->getListViewEntries($focus,$currentModule,$list_result, + $navigation_array); +$smarty->assign("LISTHEADER", $listview_header); +$smarty->assign("LISTENTITY", $listview_entries); + +$smarty->assign("AVALABLE_FIELDS", getMergeFields($currentModule,"available_fields")); +$smarty->assign("FIELDS_TO_MERGE", getMergeFields($currentModule,"fileds_to_merge")); + +//Added to select Multiple records in multiple pages +$smarty->assign("SELECTEDIDS", vtlib_purify($_REQUEST['selobjs'])); +$smarty->assign("ALLSELECTEDIDS", vtlib_purify($_REQUEST['allselobjs'])); +$smarty->assign("CURRENT_PAGE_BOXES", implode(array_keys($listview_entries),";")); + +$navigationOutput = getTableHeaderSimpleNavigation($navigation_array, $url_string,"Potentials","index",$viewid); +$alphabetical = AlphabeticalSearch($currentModule,'index','potentialname','true','basic',"","","","",$viewid); +$fieldnames = $controller->getAdvancedSearchOptionString(); +$criteria = getcriteria_options(); +$smarty->assign("CRITERIA", $criteria); +$smarty->assign("FIELDNAMES", $fieldnames); +$smarty->assign("ALPHABETICAL", $alphabetical); +$smarty->assign("NAVIGATION", $navigationOutput); +$smarty->assign("SELECT_SCRIPT", $view_script); + +$check_button = Button_Check($currentModule); +$smarty->assign("CHECK", $check_button); + +ListViewSession::setSessionQuery($currentModule,$list_query,$viewid); + +// Gather the custom link information to display +include_once('vtlib/Vtiger/Link.php'); +$customlink_params = Array('MODULE'=>$currentModule, 'ACTION'=>vtlib_purify($_REQUEST['action']), 'CATEGORY'=> $category); +$smarty->assign('CUSTOM_LINKS', Vtiger_Link::getAllByType(getTabid($currentModule), Array('LISTVIEWBASIC','LISTVIEW'), $customlink_params)); +// END + +if(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '') + $smarty->display("ListViewEntries.tpl"); +else + $smarty->display("ListView.tpl"); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/ListViewPagging.php b/oss/vtiger/trunk/modules/Potentials/ListViewPagging.php new file mode 100644 index 00000000..333f1768 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/ListViewPagging.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/ListViewTop.php b/oss/vtiger/trunk/modules/Potentials/ListViewTop.php new file mode 100644 index 00000000..4973cf76 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/ListViewTop.php @@ -0,0 +1,104 @@ +$title,'Header'=>$listview_header,'Entries'=>$listview_entries) where as listview_header and listview_entries are arrays of header and entity values which are returned from function getListViewHeader and getListViewEntries +*/ +function getTopPotentials($maxval,$calCnt) +{ + $log = LoggerManager::getLogger('top opportunity_list'); + $log->debug("Entering getTopPotentials() method ..."); + require_once("data/Tracker.php"); + require_once('modules/Potentials/Potentials.php'); + require_once('include/logging.php'); + require_once('include/ListView/ListView.php'); + + global $app_strings; + global $adb; + global $current_language; + global $current_user; + $current_module_strings = return_module_language($current_language, "Potentials"); + + $title=array(); + $title[]='myTopOpenPotentials.gif'; + $title[]=$current_module_strings['LBL_TOP_OPPORTUNITIES']; + $title[]='home_mypot'; + $where = "AND vtiger_potential.potentialid > 0 AND vtiger_potential.sales_stage not in ('Closed Won','Closed Lost','".$current_module_strings['Closed Won']."','".$current_module_strings['Closed Lost']."') AND vtiger_crmentity.smownerid='".$current_user->id."' AND vtiger_potential.amount > 0"; + $header=array(); + $header[]=$current_module_strings['LBL_LIST_OPPORTUNITY_NAME']; + //$header[]=$current_module_strings['LBL_LIST_ACCOUNT_NAME']; + $currencyid=fetchCurrency($current_user->id); + $rate_symbol = getCurrencySymbolandCRate($currencyid); + $rate = $rate_symbol['rate']; + $curr_symbol = $rate_symbol['symbol']; + $header[]=$current_module_strings['LBL_LIST_AMOUNT'].'('.$curr_symbol.')'; + $list_query = "SELECT vtiger_crmentity.crmid, vtiger_potential.potentialname, + vtiger_potential.amount, potentialid + FROM vtiger_potential + IGNORE INDEX(PRIMARY) INNER JOIN vtiger_crmentity + ON vtiger_crmentity.crmid = vtiger_potential.potentialid"; + $list_query .= getNonAdminAccessControlQuery('Potentials',$current_user); + $list_query .= "WHERE vtiger_crmentity.deleted = 0 ".$where; + $list_query .=" ORDER BY amount DESC"; + + $list_query .=" LIMIT " . $adb->sql_escape_string($maxval); + + if($calCnt == 'calculateCnt') { + $list_result_rows = $adb->query(mkCountQuery($list_query)); + return $adb->query_result($list_result_rows, 0, 'count'); + } + + $list_result = $adb->query($list_query); + + $open_potentials_list = array(); + $noofrows = $adb->num_rows($list_result); + + $entries=array(); + if ($noofrows) { + for($i=0;$i<$noofrows;$i++) + { + $open_potentials_list[] = Array('name' => $adb->query_result($list_result,$i,'potentialname'), + 'id' => $adb->query_result($list_result,$i,'potentialid'), + 'amount' => $adb->query_result($list_result,$i,'amount'), + ); + $potentialid=$adb->query_result($list_result,$i,'potentialid'); + $potentialname = $adb->query_result($list_result,$i,'potentialname'); + $Top_Potential = (strlen($potentialname) > 20) ? (substr($potentialname,0,20).'...') : $potentialname; + $value=array(); + $value[]=''.$Top_Potential.''; + + $value[]=convertFromDollar($adb->query_result($list_result,$i,'amount'),$rate); + $entries[$potentialid]=$value; + } + } + + $search_qry = "&query=true&Fields0=assigned_user_id&Condition0=e&Srch_value0=".$current_user->column_fields['user_name']."&Fields1=sales_stage&Condition1=k&Srch_value1=closed&searchtype=advance&search_cnt=2&matchtype=all"; + + $values=Array('ModuleName'=>'Potentials','Title'=>$title,'Header'=>$header,'Entries'=>$entries,'search_qry'=>$search_qry); + + if ( ($display_empty_home_blocks && count($open_potentials_list) == 0 ) || (count($open_potentials_list)>0) ) + { + $log->debug("Exiting getTopPotentials method ..."); + return $values; + } +} +?> diff --git a/oss/vtiger/trunk/modules/Potentials/MassEdit.php b/oss/vtiger/trunk/modules/Potentials/MassEdit.php new file mode 100644 index 00000000..348dab37 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/MassEdit.php @@ -0,0 +1,45 @@ +mode = ''; +$mode = 'mass_edit'; +$disp_view = getView($focus->mode); + +$smarty = new vtigerCRM_Smarty; +$smarty->assign("BLOCKS",getBlocks($currentModule,$disp_view,$mode,$focus->column_fields)); +$smarty->assign("IDS",$_REQUEST['idstring']); +$smarty->assign("MASS_EDIT","1"); +$smarty->assign("MODULE",$currentModule); +$smarty->assign("APP",$app_strings); +$smarty->assign("CATEGORY",getParentTab()); + +$theme_path="themes/".$theme."/"; +$image_path=$theme_path."images/"; +$smarty->assign("THEME", $theme); +$smarty->assign("IMAGE_PATH", $image_path); + +// Field Validation Information +$tabid = getTabid($currentModule); +$validationData = getDBValidationData($focus->tab_name,$tabid); +$validationArray = split_validationdataArray($validationData); + +$smarty->assign("VALIDATION_DATA_FIELDNAME",$validationArray['fieldname']); +$smarty->assign("VALIDATION_DATA_FIELDDATATYPE",$validationArray['datatype']); +$smarty->assign("VALIDATION_DATA_FIELDLABEL",$validationArray['fieldlabel']); + +$smarty->display('MassEditForm.tpl'); + +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/MassEditSave.php b/oss/vtiger/trunk/modules/Potentials/MassEditSave.php new file mode 100644 index 00000000..0e1f2a6f --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/MassEditSave.php @@ -0,0 +1,67 @@ +retrieve_entity_info($recordid, $currentModule); + $focus->mode = 'edit'; + $focus->id = $recordid; + foreach($focus->column_fields as $fieldname => $val) + { + if(isset($_REQUEST[$fieldname."_mass_edit_check"])) + { + if($fieldname == 'assigned_user_id'){ + if($_REQUEST['assigntype'] == 'U') { + $value = $_REQUEST['assigned_user_id']; + } elseif($_REQUEST['assigntype'] == 'T') { + $value = $_REQUEST['assigned_group_id']; + } + } else { + if(is_array($_REQUEST[$fieldname])) + $value = $_REQUEST[$fieldname]; + else + $value = trim($_REQUEST[$fieldname]); + } + $focus->column_fields[$fieldname] = $value; + } + else{ + $focus->column_fields[$fieldname] = decode_html($focus->column_fields[$fieldname]); + } + } + $focus->save($currentModule); + } + } +} + +$parenttab = getParentTab(); +header("Location: index.php?module=$return_module&action=$return_action&parenttab=$parenttab$rstart"); +?> \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/Popup.php b/oss/vtiger/trunk/modules/Potentials/Popup.php new file mode 100644 index 00000000..491b56b5 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Popup.php @@ -0,0 +1,17 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/Potentials.js b/oss/vtiger/trunk/modules/Potentials/Potentials.js new file mode 100644 index 00000000..9f2bd778 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Potentials.js @@ -0,0 +1,89 @@ +/********************************************************************************* +** The contents of this file are subject to the vtiger CRM Public License Version 1.0 + * ("License"); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + * + ********************************************************************************/ + + +document.write(" +assign("EDIT_DUPLICATE",""); + if($record_count == 2) { + if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes' + && isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes') + $smarty->assign("EDIT_DUPLICATE","permitted"); + } + else { + if(isPermitted($currentModule,"EditView",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"EditView",$exploded_id[2]) == 'yes' + && isPermitted($currentModule,"Delete",$exploded_id[0]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[1]) == 'yes' && isPermitted($currentModule,"Delete",$exploded_id[2]) == 'yes') + $smarty->assign("EDIT_DUPLICATE","permitted"); + } + + $all_values_array=getRecordValues($exploded_id,$module); + $all_values=$all_values_array[0]; + $js_arr_val=$all_values_array[1]; + $fld_array=$all_values_array[2]; + $js_arr=implode(",",$js_arr_val); + + $imported_records = Array(); + $sql="select bean_id from vtiger_users_last_import where bean_type=? and deleted=0"; + $result = $adb->pquery($sql, array($module)); + $num_rows=$adb->num_rows($result); + $count=0; + for($i=0; $i<$num_rows;$i++) + { + foreach($exploded_id as $value) + if($value == $adb->query_result($result,$i,"bean_id")) + $count++; + array_push($imported_records,$adb->query_result($result,$i,"bean_id")); + } + + if ($record_count == $count) + $no_existing=1; + else + $no_existing=0; + + $smarty->assign("MOD", $mod_strings); + $smarty->assign("APP", $app_strings); + $smarty->assign("RECORD_COUNT",$record_count); + $smarty->assign("THEME", $theme); + $smarty->assign("IMAGE_PATH", $image_path); + $smarty->assign("MODULENAME", $module); + $smarty->assign("PARENT_TAB", $parent_tab); + $smarty->assign("JS_ARRAY", $js_arr); + $smarty->assign("ID_ARRAY", $exploded_id); + $smarty->assign("IDSTRING",$idstring); + $smarty->assign("ALLVALUES", $all_values); + $smarty->assign("FIELD_ARRAY", $fld_array); + $smarty->assign("IMPORTED_RECORDS", $imported_records); + $smarty->assign("NO_EXISTING", $no_existing); + $smarty->display("MergeFields.tpl"); +} + +?> diff --git a/oss/vtiger/trunk/modules/Potentials/QuickCreate.php b/oss/vtiger/trunk/modules/Potentials/QuickCreate.php new file mode 100644 index 00000000..8d5998b8 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/QuickCreate.php @@ -0,0 +1,12 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/Save.php b/oss/vtiger/trunk/modules/Potentials/Save.php new file mode 100644 index 00000000..d1bdede7 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Save.php @@ -0,0 +1,69 @@ +id); +$rate_symbol = getCurrencySymbolandCRate($currencyid); +$rate = $rate_symbol['rate']; +$curr_symbol= $rate_symbol['symbol']; + +setObjectValuesFromRequest($focus); + +if(isset($_REQUEST['amount'])) +{ + $value = convertToDollar($_REQUEST['amount'],$rate); + $focus->column_fields['amount'] = $value; +} + +if($_REQUEST['assigntype'] == 'U') { + $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_user_id']; +} elseif($_REQUEST['assigntype'] == 'T') { + $focus->column_fields['assigned_user_id'] = $_REQUEST['assigned_group_id']; +} +$focus->save("Potentials"); +$pot_id = $return_id = $focus->id; + +$parenttab = getParentTab(); +if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = vtlib_purify($_REQUEST['return_module']); +else $return_module = "Potentials"; +if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = vtlib_purify($_REQUEST['return_action']); +else $return_action = "DetailView"; +if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = vtlib_purify($_REQUEST['return_id']); + +$local_log->debug("Saved record with id of ".$return_id); + +//code added for returning back to the current view after edit from list view +if($_REQUEST['return_viewname'] == '') $return_viewname='0'; +if($_REQUEST['return_viewname'] != '')$return_viewname=vtlib_purify($_REQUEST['return_viewname']); + +header("Location: index.php?action=$return_action&module=$return_module&parenttab=$parenttab&record=$return_id&pot_id=$pot_id&viewname=$return_viewname&start=".vtlib_purify($_REQUEST['pagenumber']).$search); +?> diff --git a/oss/vtiger/trunk/modules/Potentials/Settings.php b/oss/vtiger/trunk/modules/Potentials/Settings.php new file mode 100644 index 00000000..980dd078 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/Settings.php @@ -0,0 +1,13 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/TagCloud.php b/oss/vtiger/trunk/modules/Potentials/TagCloud.php new file mode 100644 index 00000000..859b11ff --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/TagCloud.php @@ -0,0 +1,12 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/UnifiedSearch.php b/oss/vtiger/trunk/modules/Potentials/UnifiedSearch.php new file mode 100644 index 00000000..9a37320c --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/UnifiedSearch.php @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/oss/vtiger/trunk/modules/Potentials/index.php b/oss/vtiger/trunk/modules/Potentials/index.php new file mode 100644 index 00000000..c31a5646 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/index.php @@ -0,0 +1,30 @@ + diff --git a/oss/vtiger/trunk/modules/Potentials/language/en_us.lang.php b/oss/vtiger/trunk/modules/Potentials/language/en_us.lang.php new file mode 100644 index 00000000..5255e165 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/language/en_us.lang.php @@ -0,0 +1,157 @@ +'Potentials', +'LBL_MODULE_TITLE'=>'Potentials: Home', +'LBL_SEARCH_FORM_TITLE'=>'Potential Search', +'LBL_LIST_FORM_TITLE'=>'Potential List', +'LBL_OPPORTUNITY_NAME'=>'Potential Name:', +'LBL_OPPORTUNITY'=>'Potential:', +'LBL_NAME'=>'Potential Name', +'LBL_INVITEE'=>'Contacts', +'LBL_LIST_OPPORTUNITY_NAME'=>'Potential', +'LBL_LIST_ACCOUNT_NAME'=>'Account Name', +'LBL_PRODUCT_NAME'=>'Product Name', +'LBL_LIST_AMOUNT'=>'Amount', +'LBL_LIST_DATE_CLOSED'=>'Expected Close', +'LBL_LIST_SALES_STAGE'=>'Sales Stage', + +'LBL_OPPORTUNITY_NAME'=>'Potential Name:', +'LBL_ACCOUNT_NAME'=>'Account Name:', +'LBL_AMOUNT'=>'Amount:', +'LBL_DATE_CLOSED'=>'Expected Close Date:', +'LBL_TYPE'=>'Type:', +'LBL_NEXT_STEP'=>'Next Step:', +'LBL_LEAD_SOURCE'=>'Lead Source:', +'LBL_SALES_STAGE'=>'Sales Stage:', +'LBL_PROBABILITY'=>'Probability (%):', +'LBL_DESCRIPTION'=>'Description:', +'LBL_OPPORTUNITY_INFORMATION'=>'Potential Information:', +'LBL_DESCRIPTION_INFORMATION'=>'Description Information:', +'LBL_CUSTOM_INFORMATION'=>'Custom Information', + +'LBL_NEW_FORM_TITLE'=>'New Potential', + +'ERR_DELETE_RECORD'=>"A record number must be specified to delete the opportunity.", +'LBL_TOP_OPPORTUNITIES'=>"My Top Open Potentials", + +'NTC_REMOVE_OPP_CONFIRMATION'=>'Are you sure you want to remove this contact from this opportunity?', + +'NTC_NONE_SCHEDULED'=>'None scheduled.', + +'LBL_SELECT_OPPOPTUNITY'=>'Select Potential', +'LBL_GENERAL_INFORMATION'=>'General Information', + + + +//for v4 release added +'LBL_NEW_POTENTIAL'=>'New Potential', +'LBL_POTENTIAL_TITLE'=>'Potentials', + +'LBL_NEW_TASK'=>'New Task', +'LBL_TASK_TITLE'=>'Tasks', +'LBL_NEW_CALL'=>'New Call', +'LBL_CALL_TITLE'=>'Calls', +'LBL_NEW_MEETING'=>'New Meeting', +'LBL_MEETING_TITLE'=>'Meetings', +'LBL_NEW_EMAIL'=>'New Email', +'LBL_EMAIL_TITLE'=>'Emails', +'LBL_NEW_NOTE'=>'New Document', +'LBL_NOTE_TITLE'=>'Documents', + +'LBL_NEW_ATTACHMENT'=>'New Attachment', +'LBL_ATTACHMENT_TITLE'=>'Attachments', + +'LBL_NEW_CONTACT'=>'New Contact', +'LBL_CONTACT_TITLE'=>'Contacts', + +//Added vtiger_fields after RC1 - Release +'LBL_ALL'=>'All', +'LBL_WON'=>'Won', +'LBL_LOST'=>'Lost', +'LBL_VALUE_PROPOSITION'=>'Value Proposition', +'LBL_PROSPECTING'=>'Prospecting', + +// Added for 4GA +'LBL_TOOL_FORM_TITLE'=>'Potential Tools', +//Added for 4GA +'Potential Name'=>'Potential Name', +'Amount'=>'Amount', +'Account Name'=>'Account Name', +'Currency'=>'Currency', +'Expected Close Date'=>'Expected Close Date', +'Opportunity Type'=>'Opportunity Type', +'Type'=>'Type', +'Next Step'=>'Next Step', +'Lead Source'=>'Lead Source', +'Sales Stage'=>'Sales Stage', +'Assigned To'=>'Assigned To', +'Probability'=>'Probability (%)', +'Campaign Source'=>'Campaign Source', +'Description'=>'Description', +'Created Time'=>'Created Time', +'Modified Time'=>'Modified Time', +//Added for 4.2 Release -- CustomView +'Potential'=>'Potential', +'Expected Close'=>'Expected Close', + +//Added for Existing Picklist Strings + +'Prospecting'=>'Prospecting', +'Qualification'=>'Qualification', +'Needs Analysis'=>'Needs Analysis', +'Value Proposition'=>'Value Proposition', +'Id. Decision Makers'=>'Id. Decision Makers', +'Perception Analysis'=>'Perception Analysis', +'Proposal/Price Quote'=>'Proposal/Price Quote', +'Negotiation/Review'=>'Negotiation/Review', +'Closed Won'=>'Closed Won', +'Closed Lost'=>'Closed Lost', + +'Cold Call'=>'Cold Call', +'Existing Customer'=>'Existing Customer', +'Self Generated'=>'Self Generated', +'Employee'=>'Employee', +'Partner'=>'Partner', +'Public Relations'=>'Public Relations', +'Direct Mail'=>'Direct Mail', +'Conference'=>'Conference', +'Trade Show'=>'Trade Show', +'Web Site'=>'Web Site', +'Word of mouth'=>'Word of mouth', +'Other'=>'Other', + +'--None--'=>'--None--', +'Existing Business'=>'Existing Business', +'New Business'=>'New Business', + +// Added after 5.0.4 GA + +// Module Sequence Numbering +'Potential No' => 'Potential No', +// END + +'Related To' => 'Related To', +); + +?> diff --git a/oss/vtiger/trunk/modules/Potentials/language/zh_cn.lang.php b/oss/vtiger/trunk/modules/Potentials/language/zh_cn.lang.php new file mode 100644 index 00000000..8ed6390b --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/language/zh_cn.lang.php @@ -0,0 +1,156 @@ + '业务', +'LBL_MODULE_TITLE' => '业务: 首页', +'LBL_SEARCH_FORM_TITLE' => '搜寻业务', +'LBL_LIST_FORM_TITLE' => '业务列表', +'LBL_OPPORTUNITY_NAME' => '机会名称:', +'LBL_OPPORTUNITY' => '机会:', +'LBL_NAME' => '业务名称', +'LBL_INVITEE' => '联系人', +'LBL_LIST_OPPORTUNITY_NAME' => '可能性', +'LBL_LIST_ACCOUNT_NAME' => '客户名称', +'LBL_PRODUCT_NAME' => '业务类型', +'LBL_LIST_AMOUNT' => '合计', +'LBL_LIST_DATE_CLOSED' => '预期结束', +'LBL_LIST_SALES_STAGE' => '销售策略', + +'LBL_OPPORTUNITY_NAME'=>'潜在客户名称:', +'LBL_ACCOUNT_NAME' => '客户名称:', +'LBL_AMOUNT' => '合计:', +'LBL_DATE_CLOSED' => '预期结束日期:', +'LBL_TYPE' => '类型:', +'LBL_NEXT_STEP' => '下一步:', +'LBL_LEAD_SOURCE' => '接触来源:', +'LBL_SALES_STAGE' => '客服场景:', +'LBL_PROBABILITY' => '可能性 (%):', +'LBL_DESCRIPTION' => '描述:', +'LBL_OPPORTUNITY_INFORMATION' => '业务信息:', +'LBL_DESCRIPTION_INFORMATION' => '描述信息:', +'LBL_CUSTOM_INFORMATION' => '自订信息', + +'LBL_NEW_FORM_TITLE' => '新增业务', + +'ERR_DELETE_RECORD' => '删除业务必须指定记录编号.', +'LBL_TOP_OPPORTUNITIES' => '最佳业务', + +'NTC_REMOVE_OPP_CONFIRMATION' => '您确定要从业务中删除这位联系人?', + +'NTC_NONE_SCHEDULED' => '未安排行程', + +'LBL_SELECT_OPPOPTUNITY' => '选择业务', +'LBL_GENERAL_INFORMATION' => '一般信息', + + + +//for v4 release added +'LBL_NEW_POTENTIAL' => '新增业务', +'LBL_POTENTIAL_TITLE' => '业务', + +'LBL_NEW_TASK' => '新增任务', +'LBL_TASK_TITLE' => '任务', +'LBL_NEW_CALL' => '新增电话记录', +'LBL_CALL_TITLE' => '电话记录', +'LBL_NEW_MEETING' => '新增会议', +'LBL_MEETING_TITLE' => '会议', +'LBL_NEW_EMAIL' => '新增电子邮件', +'LBL_EMAIL_TITLE' => '电子邮件', +'LBL_NEW_NOTE' => '新增备忘录', +'LBL_NOTE_TITLE' => '备忘录', + +'LBL_NEW_ATTACHMENT' => '新增附件', +'LBL_ATTACHMENT_TITLE' => '附件', + +'LBL_NEW_CONTACT' => '新增联系人', +'LBL_CONTACT_TITLE' => '联系人', + +//Added vtiger_fields after RC1 - Release +'LBL_ALL' => '全部', +'LBL_WON' => '获得', +'LBL_LOST' => '失去', +'LBL_VALUE_PROPOSITION' => '价值建议', +'LBL_PROSPECTING' => '预期值', + +// Added for 4GA +'LBL_TOOL_FORM_TITLE' => '业务编辑器', +//Added for 4GA +'Potential Name' => '业务名称', +'Amount' => '合计', +'Account Name' => '客户名称', +'Currency' => '货币', +'Expected Close Date' => '预定结束日期', +'Opportunity Type' => '机会类型', +'Type' => '类型', +'Next Step' => '下一步', +'Lead Source' => '接触来源', +'Sales Stage' => '销售策略', +'Assigned To' => '负责人', +'Probability' => '可能性 (%)', +'Campaign Source' => '活动来源', +'Description' => '描述', +'Created Time' => '建立时间', +'Modified Time' => '修改时间', +//Added for 4.2 Release -- CustomView +'Potential' => '业务', +'Expected Close' => '预期结案日期', + +//Added for Existing Picklist Strings + +'Prospecting' => '潜在客户', +'Qualification' => '具有资格', +'Needs Analysis' => '需要分析', +'Value Proposition' => '价值主张', +'Id. Decision Makers' => '决策者', +'Perception Analysis' => '感觉分析', +'Proposal/Price Quote' => '建议书/报价单', +'Negotiation/Review' => '交涉/审阅', +'Closed Won' => '成功结案', +'Closed Lost' => '失败结案', + +'Cold Call' => '陌生拜访', +'Existing Customer' => '既有客户', +'Self Generated' => '自动产生', +'Employee' => '员工', +'Partner' => '伙伴', +'Public Relations' => '公众关系', +'Direct Mail' => '邮件营销', +'Conference' => '研讨会', +'Trade Show' => '贸易展览', +'Web Site' => '网站', +'Word of mouth' => '朋友介绍', +'Other' => '其它', + +'--None--' => '-- 无 --', +'Existing Business' => '已有商务往来', +'New Business' => '新客户', + +// Added after 5.0.4 GA + +// Module Sequence Numbering +'Potential No' => '潜在机会序列号', +// END + +); + +?> diff --git a/oss/vtiger/trunk/modules/Potentials/updateRelations.php b/oss/vtiger/trunk/modules/Potentials/updateRelations.php new file mode 100644 index 00000000..040b46d0 --- /dev/null +++ b/oss/vtiger/trunk/modules/Potentials/updateRelations.php @@ -0,0 +1,55 @@ +pquery($sql, array($id, $forCRMRecord)); + } elseif($dest_mod == 'Products') {//when we select product from potential related list + $sql = "insert into vtiger_seproductsrel values (?,?,?)"; + $adb->pquery($sql, array($forCRMRecord, $id,'Potentials')); + } elseif($dest_mod == 'Documents') { + $sql = "insert into vtiger_senotesrel values (?,?)"; + $adb->pquery($sql, array($forCRMRecord, $id)); + } else { + $focus->save_related_module($currentModule, $forCRMRecord, $dest_mod, $id); + } + } +} + +header("Location: index.php?action=$action&module=$currentModule&record=".$forCRMRecord."&parenttab=".$parenttab); + +?> \ No newline at end of file