query($query.')'); $i=-1; while(($row=$db->fetchByAssoc($result)) != null) { $i++; $rows[$i] = $row; } if ($i==-1) return null; return $rows; } return null; } function buildTableForm($rows, $mod='Opportunities'){ if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); }else global $mod_strings; global $app_strings; $cols = sizeof($rows[0]) * 2 + 1; $form = '
'.$mod_strings['MSG_DUPLICATE']. '
'; $form .= "
"; $form .= ""; $form .= ""; $form .= ""; require_once('include/formbase.php'); $form .= getPostToForm(); if(isset($rows[0])){ foreach ($rows[0] as $key=>$value){ if($key != 'id'){ $form .= ""; }} $form .= ""; } $rowColor = 'oddListRowS1'; foreach($rows as $row){ $form .= ""; $form .= ""; $wasSet = false; foreach ($row as $key=>$value){ if($key != 'id'){ if(!$wasSet){ $form .= ""; $wasSet = true; }else{ $form .= ""; } }} if($rowColor == 'evenListRowS1'){ $rowColor = 'oddListRowS1'; }else{ $rowColor = 'evenListRowS1'; } $form .= ""; } $form .= ""; $form .= "
 ". $mod_strings[$mod_strings['db_'.$key]]. "
[${app_strings['LBL_SELECT_BUTTON_LABEL']}]  $value$value

"; return $form; } function getForm($prefix, $mod='Opportunities'){ if(!ACLController::checkAccess('Opportunities', 'edit', true)){ return ''; } if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); }else global $mod_strings; global $app_strings; global $sugar_version, $sugar_config; $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE']; $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY']; $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL']; $the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']); $the_form .= << EOQ; $the_form .= $this->getFormBody($prefix, $mod, "{$prefix}OppSave"); $the_form .= << EOQ; $the_form .= get_left_form_footer(); $the_form .= get_validate_record_js(); return $the_form; } function getWideFormBody($prefix, $mod='Opportunities', $formname='', $lead='', $showaccount = true){ if(!ACLController::checkAccess('Opportunities', 'edit', true)){ return ''; } if(empty($lead)){ $lead = new Lead(); } global $mod_strings, $sugar_config; $showaccount = $showaccount && $sugar_config['require_accounts']; $temp_strings = $mod_strings; if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); } global $app_strings; global $app_list_strings; global $theme; global $current_user; global $timedate; // Unimplemented until jscalendar language files are fixed // global $current_language; // global $default_language; // global $cal_codes; $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL']; $lbl_opportunity_name = $mod_strings['LBL_OPPORTUNITY_NAME']; $lbl_sales_stage = $mod_strings['LBL_SALES_STAGE']; $lbl_date_closed = $mod_strings['LBL_DATE_CLOSED']; $lbl_amount = $mod_strings['LBL_AMOUNT']; $lbl_probability = $mod_strings['LBL_PROBABILITY']; $json = getJSONobj(); $prob_array = $json->encode($app_list_strings['sales_probability_dom']); //$prePopProb = ''; //if(empty($this->bean->id)) $prePopProb = 'document.getElementsByName(\''.$prefix.'sales_stage\')[0].onchange();'; $probability_script=<< prob_array = $prob_array; document.getElementsByName('{$prefix}sales_stage')[0].onchange = function() { if(typeof(document.getElementsByName('{$prefix}sales_stage')[0].value) != "undefined" && prob_array[document.getElementsByName('{$prefix}sales_stage')[0].value]) { document.getElementsByName('{$prefix}probability')[0].value = prob_array[document.getElementsByName('{$prefix}sales_stage')[0].value]; } }; $prePopProb EOQ; $ntc_date_format = $timedate->get_user_date_format(); $cal_dateformat = $timedate->get_cal_date_format(); if (isset($lead->assigned_user_id)) { $user_id=$lead->assigned_user_id; } else { $user_id = $current_user->id; } // Unimplemented until jscalendar language files are fixed // $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]; $cal_lang = "en"; $the_form=""; if (isset($lead->opportunity_amount)) { $opp_amount=$lead->opportunity_amount; } else { $opp_amount=''; } $jsCalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif'); $the_form .= << EOQ; if($showaccount){ $the_form .= << EOQ; } $the_form .= << EOQ; //carry forward custom lead fields to opportunities during Lead Conversion $tempOpp = new Opportunity(); if (method_exists($lead, 'convertCustomFieldsForm')) $lead->convertCustomFieldsForm($the_form, $tempOpp, $prefix); unset($tempOpp); $the_form .= << EOQ; $javascript = new javascript(); $javascript->setFormName($formname); $javascript->setSugarBean(new Opportunity()); $javascript->addRequiredFields($prefix); $the_form .=$javascript->getScript(); $mod_strings = $temp_strings; return $the_form; } // end getWideFormBody function getFormBody($prefix, $mod='Opportunities', $formname=''){ if(!ACLController::checkAccess('Opportunities', 'edit', true)){ return ''; } if(!empty($mod)){ global $current_language; $mod_strings = return_module_language($current_language, $mod); }else global $mod_strings; global $app_strings; global $app_list_strings; global $theme; global $current_user; global $sugar_config; global $timedate; // Unimplemented until jscalendar language files are fixed // global $current_language; // global $default_language; // global $cal_codes; $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL']; $lbl_opportunity_name = $mod_strings['LBL_OPPORTUNITY_NAME']; $lbl_sales_stage = $mod_strings['LBL_SALES_STAGE']; $lbl_date_closed = $mod_strings['LBL_DATE_CLOSED']; $lbl_amount = $mod_strings['LBL_AMOUNT']; $ntc_date_format = $timedate->get_user_date_format(); $cal_dateformat = $timedate->get_cal_date_format(); $user_id = $current_user->id; // Unimplemented until jscalendar language files are fixed // $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language]; $cal_lang = "en"; $the_form = << $lbl_opportunity_name $lbl_required_symbol
EOQ; if($sugar_config['require_accounts']){ /////////////////////////////////////// /// /// SETUP ACCOUNT POPUP $popup_request_data = array( 'call_back_function' => 'set_return', 'form_name' => "{$prefix}OppSave", 'field_to_name_array' => array( 'id' => 'account_id', 'name' => 'account_name', ), ); $json = getJSONobj(); $encoded_popup_request_data = $json->encode($popup_request_data); // /////////////////////////////////////// $the_form .= <<${lbl_required_symbol}
 
EOQ; } $jsCalendarImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif'); $the_form .= <<$lbl_required_symbol
$ntc_date_format
{$app_strings['LBL_ENTER_DATE']}
$lbl_sales_stage $lbl_required_symbol

EOQ; require_once('include/QuickSearchDefaults.php'); $qsd = new QuickSearchDefaults(); $sqs_objects = array('qc_account_name' => $qsd->getQSParent()); $sqs_objects['qc_account_name']['populate_list'] = array('qc_account_name', 'qc_account_id'); $quicksearch_js = ''; $the_form .= $quicksearch_js; $javascript = new javascript(); $javascript->setFormName($formname); $javascript->setSugarBean(new Opportunity()); $javascript->addRequiredFields($prefix); $the_form .=$javascript->getScript(); return $the_form; } function handleSave($prefix,$redirect=true, $useRequired=false){ global $current_user; require_once('include/formbase.php'); $focus = new Opportunity(); if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))){ return null; } if(empty($_POST['currency_id'])){ $currency_id = $current_user->getPreference('currency'); if(isset($currency_id)){ $focus->currency_id = $currency_id; } } $focus = populateFromPost($prefix, $focus); if( !ACLController::checkAccess($focus->module_dir, 'edit', $focus->isOwner($current_user->id))){ ACLController::displayNoAccess(true); } $check_notify = FALSE; if (isset($GLOBALS['check_notify'])) { $check_notify = $GLOBALS['check_notify']; } $focus->save($check_notify); if(!empty($_POST['duplicate_parent_id'])){ clone_relationship($focus->db, array('opportunities_contacts'),'opportunity_id', $_POST['duplicate_parent_id'], $focus->id); } $return_id = $focus->id; $GLOBALS['log']->debug("Saved record with id of ".$return_id); if($redirect){ handleRedirect($return_id,"Opportunities" ); }else{ return $focus; } } } ?>
$lbl_opportunity_name $lbl_required_symbol {$mod_strings['LBL_DESCRIPTION']}
$lbl_date_closed $lbl_required_symbol
 {$app_strings['LBL_ENTER_DATE']}
${mod_strings['LBL_ACCOUNT_NAME']} ${lbl_required_symbol}
 
$lbl_sales_stage $lbl_required_symbol
$lbl_amount $lbl_required_symbol