$image_array[$img_itr],'path'=>$image_path_array[$img_itr].$image_id_array[$img_itr]."_","orgname"=>$image_orgname_array[$img_itr]);
}
else
$fieldvalue[] = '';
}
else
$fieldvalue[] = '';
}
elseif($uitype == 62)
{
if(isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '')
$value = $_REQUEST['parent_id'];
if($value != '')
$parent_module = getSalesEntityType($value);
if(isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '')
{
$parent_module = "Accounts";
$value = $_REQUEST['account_id'];
}
if($parent_module != 'Contacts')
{
if($parent_module == "Leads")
{
$parent_name = getLeadName($value);
$lead_selected = "selected";
}
elseif($parent_module == "Accounts")
{
$sql = "select * from ".$table_prefix."_account where accountid=?";
$result = $adb->pquery($sql, array($value));
$parent_name = $adb->query_result($result,0,"accountname");
$account_selected = "selected";
}
elseif($parent_module == "Potentials")
{
$sql = "select * from ".$table_prefix."_potential where potentialid=?";
$result = $adb->pquery($sql, array($value));
$parent_name = $adb->query_result($result,0,"potentialname");
$potential_selected = "selected";
}
elseif($parent_module == "Products")
{
$sql = "select * from ".$table_prefix."_products where productid=?";
$result = $adb->pquery($sql, array($value));
$parent_name= $adb->query_result($result,0,"productname");
$product_selected = "selected";
}
elseif($parent_module == "PurchaseOrder")
{
$sql = "select * from ".$table_prefix."_purchaseorder where purchaseorderid=?";
$result = $adb->pquery($sql, array($value));
$parent_name= $adb->query_result($result,0,"subject");
$porder_selected = "selected";
}
elseif($parent_module == "SalesOrder")
{
$sql = "select * from ".$table_prefix."_salesorder where salesorderid=?";
$result = $adb->pquery($sql, array($value));
$parent_name= $adb->query_result($result,0,"subject");
$sorder_selected = "selected";
}
elseif($parent_module == "Invoice")
{
$sql = "select * from ".$table_prefix."_invoice where invoiceid=?";
$result = $adb->pquery($sql, array($value));
$parent_name= $adb->query_result($result,0,"subject");
$invoice_selected = "selected";
}
elseif($parent_module == "Quotes")
{
$sql = "select * from ".$table_prefix."_quotes where quoteid=?";
$result = $adb->pquery($sql, array($value));
$parent_name= $adb->query_result($result,0,"subject");
$quote_selected = "selected";
}elseif($parent_module == "HelpDesk")
{
$sql = "select * from ".$table_prefix."_troubletickets where ticketid=?";
$result = $adb->pquery($sql, array($value));
$parent_name= $adb->query_result($result,0,"title");
$ticket_selected = "selected";
}
}
//ds@33
if(isPermitted('Leads','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_LEADS'];
$array2[] = $lead_selected;
$array3[] = "Leads&action=Popup";
}
if(isPermitted('Accounts','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_ACCOUNTS'];
$array2[] = $account_selected;
$array3[] = "Accounts&action=Popup";
}
if(isPermitted('Potentials','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_POTENTIALS'];
$array2[] = $potential_selected;
$array3[] = "Potentials&action=Popup";
}
if(isPermitted('Products','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_PRODUCTS'];
$array2[] = $product_selected;
$array3[] = "Products&action=Popup";
}
if(isPermitted('Invoice','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_INVOICES'];
$array2[] = $invoice_selected;
$array3[] = "Invoice&action=Popup";
}
if(isPermitted('PurchaseOrder','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_PORDER'];
$array2[] = $porder_selected;
$array3[] = "PurchaseOrder&action=Popup";
}
if(isPermitted('SalesOrder','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_SORDER'];
$array2[] = $sorder_selected;
$array3[] = "SalesOrder&action=Popup";
}
if(isPermitted('Quotes','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_QUOTES'];
$array2[] = $quote_selected;
$array3[] = "Quotes&action=Popup";
}
if(isPermitted('HelpDesk','EditView',$_REQUEST['record']) == 'yes')
{
$array1[] = $app_strings['COMBO_HELPDESK'];
$array2[] = $ticket_selected;
$array3[] = "HelpDesk&action=Popup";
}
$editview_label[] = $array1;
$editview_label[] = $array2;
$editview_label[] = $array3;
/*
$editview_label[] = array($app_strings['COMBO_LEADS'],
$app_strings['COMBO_ACCOUNTS'],
$app_strings['COMBO_POTENTIALS'],
$app_strings['COMBO_PRODUCTS'],
$app_strings['COMBO_INVOICES'],
$app_strings['COMBO_PORDER'],
$app_strings['COMBO_SORDER'],
$app_strings['COMBO_QUOTES'],
$app_strings['COMBO_HELPDESK']
);
$editview_label[] = array($lead_selected,
$account_selected,
$potential_selected,
$product_selected,
$invoice_selected,
$porder_selected,
$sorder_selected,
$quote_selected,
$ticket_selected
);
*/
//ds@33e
$fieldvalue[] =$parent_name;
$fieldvalue[] =$value;
}
//added by rdhital/Raju for better email support
elseif($uitype == 357)
{
if($_REQUEST['pmodule'] == 'Contacts')
{
$contact_selected = 'selected';
}
elseif($_REQUEST['pmodule'] == 'Accounts')
{
$account_selected = 'selected';
}
elseif($_REQUEST['pmodule'] == 'Leads')
{
$lead_selected = 'selected';
}
if(isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '')
{
$parent_id = $_REQUEST['emailids'];
$parent_name='';
$pmodule=$_REQUEST['pmodule'];
$myids=explode("|",$parent_id);
for ($i=0;$i<(count($myids)-1);$i++)
{
$realid=explode("@",$myids[$i]);
$entityid=$realid[0];
$nemail=count($realid);
if ($pmodule=='Accounts'){
$myfocus = CRMEntity::getInstance('Accounts');
$myfocus->retrieve_entity_info($entityid,"Accounts");
$fullname=br2nl($myfocus->column_fields['accountname']);
$account_selected = 'selected';
}
elseif ($pmodule=='Contacts'){
$myfocus = CRMEntity::getInstance('Contacts');
$myfocus->retrieve_entity_info($entityid,"Contacts");
$fname=br2nl($myfocus->column_fields['firstname']);
$lname=br2nl($myfocus->column_fields['lastname']);
$fullname=$lname.' '.$fname;
$contact_selected = 'selected';
}
elseif ($pmodule=='Leads'){
$myfocus = CRMEntity::getInstance('Leads');
$myfocus->retrieve_entity_info($entityid,"Leads");
$fname=br2nl($myfocus->column_fields['firstname']);
$lname=br2nl($myfocus->column_fields['lastname']);
$fullname=$lname.' '.$fname;
$lead_selected = 'selected';
}
for ($j=1;$j<$nemail;$j++){
$querystr='select columnname from '.$table_prefix.'_field where fieldid=?';
$result=$adb->pquery($querystr, array($realid[$j]));
$temp=$adb->query_result($result,0,'columnname');
$temp1=br2nl($myfocus->column_fields[$temp]);
//Modified to display the entities in red which don't have email id
if(!empty($temp_parent_name) && strlen($temp_parent_name) > 150)
{
$parent_name .= '
';
$temp_parent_name = '';
}
if($temp1 != '')
{
$parent_name .= $fullname.'<'.$temp1.'>; ';
$temp_parent_name .= $fullname.'<'.$temp1.'>; ';
}
else
{
$parent_name .= "".$fullname.'<'.$temp1.'>; '."";
$temp_parent_name .= "".$fullname.'<'.$temp1.'>; '."";
}
}
}
}
else
{
if($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL)
{
$parent_name='';
$parent_id='';
$myemailid= $_REQUEST['record'];
$mysql = "select crmid from ".$table_prefix."_seactivityrel where activityid=?";
$myresult = $adb->pquery($mysql, array($myemailid));
$mycount=$adb->num_rows($myresult);
if($mycount >0)
{
for ($i=0;$i<$mycount;$i++)
{
$mycrmid=$adb->query_result($myresult,$i,'crmid');
$parent_module = getSalesEntityType($mycrmid);
if($parent_module == "Leads")
{
$sql = "select firstname,lastname,email from ".$table_prefix."_leaddetails where leadid=?";
$result = $adb->pquery($sql, array($mycrmid));
$full_name = getFullNameFromQResult($result,0,"Leads");
$myemail=$adb->query_result($result,0,"email");
$parent_id .=$mycrmid.'@0|' ; //make it such that the email adress sent is remebered and only that one is retrived
$parent_name .= $full_name.'<'.$myemail.'>; ';
$lead_selected = 'selected';
}
elseif($parent_module == "Contacts")
{
$sql = "select * from ".$table_prefix."_contactdetails where contactid=?";
$result = $adb->pquery($sql, array($mycrmid));
$full_name = getFullNameFromQResult($result,0,"Contacts");
$myemail=$adb->query_result($result,0,"email");
$parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
$parent_name .= $full_name.'<'.$myemail.'>; ';
$contact_selected = 'selected';
}
elseif($parent_module == "Accounts")
{
$sql = "select * from ".$table_prefix."_account where accountid=?";
$result = $adb->pquery($sql, array($mycrmid));
$account_name = $adb->query_result($result,0,"accountname");
$myemail=$adb->query_result($result,0,"email1");
$parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
$parent_name .= $account_name.'<'.$myemail.'>; ';
$account_selected = 'selected';
}elseif($parent_module == "Users")
{
$sql = "select user_name,email1 from ".$table_prefix."_users where id=?";
$result = $adb->pquery($sql, array($mycrmid));
$account_name = $adb->query_result($result,0,"user_name");
$myemail=$adb->query_result($result,0,"email1");
$parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
$parent_name .= $account_name.'<'.$myemail.'>; ';
$user_selected = 'selected';
}
elseif($parent_module == "Vendors")
{
$sql = "select * from ".$table_prefix."_vendor where vendorid=?";
$result = $adb->pquery($sql, array($mycrmid));
$vendor_name = $adb->query_result($result,0,"vendorname");
$myemail=$adb->query_result($result,0,"email");
$parent_id .=$mycrmid.'@0|' ;//make it such that the email adress sent is remebered and only that one is retrived
$parent_name .= $vendor_name.'<'.$myemail.'>; ';
$vendor_selected = 'selected';
}
}
}
}
$custfld .= ''.$app_strings['To'].' | ';
$custfld .= ' debug("Exiting getOutputHtml method ..."); openPopup("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'> | ';//crmv@21048m
//crmv@7217
if ($module_name != "Sms"){
$editview_label[] = array(
'Contacts'=>$contact_selected,
'Accounts'=>$account_selected,
'Vendors'=>$vendor_selected,
'Leads'=>$lead_selected,
'Users'=>$user_selected
);
}
else{
$editview_label[] = array(
'Contacts'=>$contact_selected,
'Leads'=>$lead_selected,
'Users'=>$user_selected
);
}
//crmv@7217e
$fieldvalue[] =$parent_name;
$fieldvalue[] = $parent_id;
}
}
//end of rdhital/Raju
elseif($uitype == 71 || $uitype == 72)
{
// crmv@92112
if($col_fields['record_id'] != '' && $fieldname == 'unit_price') {
$rate_symbol=getCurrencySymbolandCRate($InventoryUtils->getProductBaseCurrency($col_fields['record_id'],$module_name)); // crmv@42024
} else {
$currency_id = fetchCurrency($current_user->id);
$rate_symbol=getCurrencySymbolandCRate($currency_id);
$rate = $rate_symbol['rate'];
if ($value !== '' && $value !== null) {
$value = convertFromMasterCurrency($value,$rate); //crmv@92519
}
}
if ($value !== '' && $value !== null) {
$fieldvalue[] = formatUserNumber(floatval($value)); //crmv@83877 crmv@92824
} else {
$fieldvalue[] = '';
}
// crmv@92112
$currency = $rate_symbol['symbol'];
$editview_label[]=getTranslatedString($fieldlabel, $module_name).': ('.$currency.')';
// crmv@83877
} elseif($uitype == 7 || $uitype == 9) { // crmv@92112
$editview_label[] = getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = (!empty($value) ? formatUserNumber(floatval($value), true) : ''); //crmv@95900
// crmv@83877e
} elseif($uitype == 79)
{
if($value != '')
{
$purchaseorder_name = getPoName($value);
}
elseif(isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '')
{
$value = $_REQUEST['purchaseorder_id'];
$purchaseorder_name = getPoName($value);
}
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $purchaseorder_name;
$fieldvalue[] = $value;
}
elseif($uitype == 30)
{
$rem_days = 0;
$rem_hrs = 0;
$rem_min = 0;
if($value!='')
$SET_REM = "CHECKED";
if(!empty($col_fields[$fieldname])){ //crmv@167234
$rem_days = floor($col_fields[$fieldname]/(24*60));
$rem_hrs = floor(($col_fields[$fieldname]-$rem_days*24*60)/60);
$rem_min = ($col_fields[$fieldname]-$rem_days*24*60)%60;
}// crmv@167234
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$day_options = getReminderSelectOption(0,31,'remdays',$rem_days);
$hr_options = getReminderSelectOption(0,23,'remhrs',$rem_hrs);
$min_options = getReminderSelectOption(5,59,'remmin',$rem_min); // crmv@114646
$fieldvalue[] = array(array(0,32,'remdays',getTranslatedString('LBL_DAYS'),$rem_days),array(0,24,'remhrs',getTranslatedString('LBL_HOURS'),$rem_hrs),array(5,60,'remmin',getTranslatedString('LBL_MINUTES'),$rem_min)); // crmv@98866 crmv@114646
$fieldvalue[] = array($SET_REM,getTranslatedString('LBL_YES'),getTranslatedString('LBL_NO'));
$SET_REM = '';
}
elseif($uitype == 115)
{
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$pick_query="select * from ".$table_prefix."_$fieldname";
$pickListResult = $adb->pquery($pick_query, array());
$noofpickrows = $adb->num_rows($pickListResult);
//Mikecrowe fix to correctly default for custom pick lists
$options = array();
$found = false;
for($j = 0; $j < $noofpickrows; $j++)
{
$pickListValue=$adb->query_result($pickListResult,$j,strtolower($fieldname));
if($value == $pickListValue)
{
$chk_val = "selected";
$found = true;
}
else
{
$chk_val = '';
}
$options[] = array(getTranslatedString($pickListValue),$pickListValue,$chk_val );
}
$fieldvalue [] = $options;
$fieldvalue [] = $is_admin;
}
elseif($uitype == 116 || $uitype == 117)
{
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$pick_query="select * from ".$table_prefix."_currency_info where currency_status = 'Active' and deleted=0";
$pickListResult = $adb->pquery($pick_query, array());
$noofpickrows = $adb->num_rows($pickListResult);
//Mikecrowe fix to correctly default for custom pick lists
$options = array();
$found = false;
for($j = 0; $j < $noofpickrows; $j++)
{
$pickListValue=$adb->query_result($pickListResult,$j,'currency_name');
$currency_id=$adb->query_result($pickListResult,$j,'id');
if($value == $currency_id)
{
$chk_val = "selected";
$found = true;
}
else
{
$chk_val = '';
}
$options[$currency_id] = array($pickListValue=>$chk_val );
}
$fieldvalue [] = $options;
$fieldvalue [] = $is_admin;
}
elseif($uitype ==98)
{
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
$fieldvalue[]=$value;
$fieldvalue[]=getRoleName($value);
$fieldvalue[]=$is_admin;
}
elseif($uitype == 105)
{
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
if( isset( $col_fields['record_id']) && $col_fields['record_id'] != '') {
$query = "select ".$table_prefix."_attachments.path, ".$table_prefix."_attachments.name from ".$table_prefix."_contactdetails left join ".$table_prefix."_seattachmentsrel on ".$table_prefix."_seattachmentsrel.crmid=".$table_prefix."_contactdetails.contactid inner join ".$table_prefix."_attachments on ".$table_prefix."_attachments.attachmentsid=".$table_prefix."_seattachmentsrel.attachmentsid where ".$table_prefix."_contactdetails.imagename=".$table_prefix."_attachments.name and contactid=?";
$result_image = $adb->pquery($query, array($col_fields['record_id']));
for($image_iter=0;$image_iter < $adb->num_rows($result_image);$image_iter++)
{
$image_array[] = $adb->query_result($result_image,$image_iter,'name');
$image_path_array[] = $adb->query_result($result_image,$image_iter,'path');
}
}
if(is_array($image_array))
for($img_itr=0;$img_itr$image_array[$img_itr],'path'=>$image_path_array[$img_itr]);
}
else
$fieldvalue[] = '';
}
//vtc
elseif($uitype == 26){
$editview_label[]=getTranslatedString($fieldlabel);
$folderid=$col_fields['folderid'];
// crmv@30967
$foldername_query = 'select foldername from '.$table_prefix.'_crmentityfolder where tabid = ? and folderid = ?';
$res = $adb->pquery($foldername_query,array(getTabId($module_name), $folderid));
// crmv@30967e
$foldername = $adb->query_result($res,0,'foldername');
if($foldername != '' && $folderid != ''){
$fldr_name[$folderid]=$foldername;
}
// crmv@30967
$sql="select foldername,folderid from ".$table_prefix."_crmentityfolder where tabid = ? order by foldername";
$res=$adb->pquery($sql,array(getTabId($module_name)));
// crmv@30967e
for($i=0;$i<$adb->num_rows($res);$i++)
{
$fid=$adb->query_result($res,$i,"folderid");
$fldr_name[$fid]=$adb->query_result($res,$i,"foldername");
}
$fieldvalue[] = $fldr_name;
}
elseif($uitype == 27){
// crmv@95157
if ($value == 'E'){
$external_selected = "selected";
} elseif ($value == 'I') {
$internal_selected = "selected";
$legacyInternal = true;
} elseif ($value == 'B') {
$internal_selected = "selected";
}
$editview_label[] = array(getTranslatedString('LBL_INTERNAL','Documents'),getTranslatedString('LBL_EXTERNAL','Documents'));
$editview_label[] = array($internal_selected,$external_selected);
$editview_label[] = array($legacyInternal ? "I" : "B", "E");
$editview_label[] = getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $value;
$fieldvalue[] = $col_fields['filename'];
// crmv@95157e
}
//crmv@16265 crmv@43764
elseif($uitype == 199){
(!empty($col_fields[$fieldname])) ? $fakeValue = '********' : $fakeValue = '';
$editview_label[] = getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $fakeValue;
//$fieldvalue[] = $col_fields[$fieldname]; // real value
}
//crmv@16265e crmv@43764e
//crmv@18338
elseif($uitype == 1020){
$editview_label[] = getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $value;
$temp_val = $value;
//crmv@36509
switch ($sla_config_global['time_measure']){ // crmv@172864
case 'minutes':
$temp_val = $temp_val*60;
break;
case 'hours':
$temp_val = $temp_val*3600;
break;
case 'days':
$temp_val = $temp_val*86400;
break;
}
//crmv@36509 e
$value=time_duration(abs($temp_val));
if (strpos($fieldname,"remaining")!==false || strpos($fieldname,"_out_")!==false){
if (strpos($fieldname,"remaining")!==false){
if ($temp_val<=0)
$color = "red";
else
$color = "green";
}
if (strpos($fieldname,"_out_")!==false){
if ($temp_val>0)
$color = "red";
else
$color = "green";
}
$value = "$value";
}
$fieldvalue[] = $value;
}
elseif($uitype == 1021){
$editview_label[] = getTranslatedString($fieldlabel, $module_name);
$fieldvalue[] = $value;
$fieldvalue[] = getDisplayDate($value);
}
//crmv@18338 end
//crmv@146461
elseif($uitype == 70)
{
$editview_label[] = getTranslatedString($fieldlabel, $module_name);
if ($value == '') {
$fieldvalue[] = '';
} else {
$fieldvalue[] = getDisplayDate($value);
}
$dformat = getTranslatedString($current_user->date_format,'Users');
$hformat = 'HH:mm:ss';
$fieldvalue[] = array(
'date_format_string'=>$dformat." ".$hformat,
'date_format'=>strtoupper($dformat)." ".$hformat,
);
}
//crmv@146461e
else
{
//Added condition to set the subject if click Reply All from web mail
if($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '')
{
$value = $_REQUEST['mg_subject'];
}
$editview_label[]=getTranslatedString($fieldlabel, $module_name);
if($uitype == 1 && ($fieldname=='expectedrevenue' || $fieldname=='budgetcost' || $fieldname=='actualcost' || $fieldname=='expectedroi' || $fieldname=='actualroi' ) && ($module_name=='Campaigns'))
{
$rate_symbol = getCurrencySymbolandCRate($user_info['currency_id']);
$fieldvalue[] = convertFromDollar($value,$rate_symbol['rate']);
}
elseif($fieldname == 'fileversion'){
if(empty($value)){
$value = '';
}
else{
$fieldvalue[] = $value;
}
}
else
$fieldvalue[] = $value;
}
// Mike Crowe Mod --------------------------------------------------------force numerics right justified.
if ( !preg_match("/id=/i",$custfld) )
$custfld = preg_replace("/debug("Exiting getOutputHtml method ...");
return $final_arr;
}
/** This function returns the vte_invoice object populated with the details from sales order object.
* Param $focus - Invoice object
* Param $so_focus - Sales order focus
* Param $soid - sales order id
* Return type is an object array
*/
function getConvertSoToInvoice($focus,$so_focus,$soid)
{
global $log,$current_user;
$log->debug("Entering getConvertSoToInvoice(focus,focus,".$soid.") method ...");
$log->info("in getConvertSoToInvoice ".$soid);
$xyz=array('bill_street','bill_city','bill_code','bill_pobox','bill_country','bill_state','ship_street','ship_city','ship_code','ship_pobox','ship_country','ship_state');
for($i=0;$iid,$xyz[$i]) == '0'){
$so_focus->column_fields[$xyz[$i]] = $so_focus->column_fields[$xyz[$i]];
}
else
$so_focus->column_fields[$xyz[$i]] = '';
}
$focus->column_fields['salesorder_id'] = $soid;
$focus->column_fields['subject'] = $so_focus->column_fields['subject'];
$focus->column_fields['customerno'] = $so_focus->column_fields['customerno'];
$focus->column_fields['duedate'] = $so_focus->column_fields['duedate'];
$focus->column_fields['contact_id'] = $so_focus->column_fields['contact_id'];//to include contact name in Invoice
$focus->column_fields['account_id'] = $so_focus->column_fields['account_id'];
$focus->column_fields['exciseduty'] = $so_focus->column_fields['exciseduty'];
$focus->column_fields['salescommission'] = $so_focus->column_fields['salescommission'];
$focus->column_fields['purchaseorder'] = $so_focus->column_fields['purchaseorder'];
$focus->column_fields['bill_street'] = $so_focus->column_fields['bill_street'];
$focus->column_fields['ship_street'] = $so_focus->column_fields['ship_street'];
$focus->column_fields['bill_city'] = $so_focus->column_fields['bill_city'];
$focus->column_fields['ship_city'] = $so_focus->column_fields['ship_city'];
$focus->column_fields['bill_state'] = $so_focus->column_fields['bill_state'];
$focus->column_fields['ship_state'] = $so_focus->column_fields['ship_state'];
$focus->column_fields['bill_code'] = $so_focus->column_fields['bill_code'];
$focus->column_fields['ship_code'] = $so_focus->column_fields['ship_code'];
$focus->column_fields['bill_country'] = $so_focus->column_fields['bill_country'];
$focus->column_fields['ship_country'] = $so_focus->column_fields['ship_country'];
$focus->column_fields['bill_pobox'] = $so_focus->column_fields['bill_pobox'];
$focus->column_fields['ship_pobox'] = $so_focus->column_fields['ship_pobox'];
$focus->column_fields['description'] = $so_focus->column_fields['description'];
$focus->column_fields['terms_conditions'] = $so_focus->column_fields['terms_conditions'];
$focus->column_fields['currency_id'] = $so_focus->column_fields['currency_id'];
$focus->column_fields['conversion_rate'] = $so_focus->column_fields['conversion_rate'];
$log->debug("Exiting getConvertSoToInvoice method ...");
return $focus;
}
/** This function returns the vte_invoice object populated with the details from quote object.
* Param $focus - Invoice object
* Param $quote_focus - Quote order focus
* Param $quoteid - quote id
* Return type is an object array
*/
function getConvertQuoteToInvoice($focus,$quote_focus,$quoteid)
{
global $log,$current_user;
$log->debug("Entering getConvertQuoteToInvoice(focus,focus,".$quoteid.") method ...");
$log->info("in getConvertQuoteToInvoice ".$quoteid);
$xyz=array('bill_street','bill_city','bill_code','bill_pobox','bill_country','bill_state','ship_street','ship_city','ship_code','ship_pobox','ship_country','ship_state');
for($i=0;$i<12;$i++){
if (getFieldVisibilityPermission('Quotes', $current_user->id,$xyz[$i]) == '0'){
$quote_focus->column_fields[$xyz[$i]] = $quote_focus->column_fields[$xyz[$i]];
}
else
$quote_focus->column_fields[$xyz[$i]] = '';
}
$focus->column_fields['subject'] = $quote_focus->column_fields['subject'];
$focus->column_fields['account_id'] = $quote_focus->column_fields['account_id'];
$focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street'];
$focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street'];
$focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city'];
$focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city'];
$focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state'];
$focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state'];
$focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code'];
$focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code'];
$focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country'];
$focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country'];
$focus->column_fields['bill_pobox'] = $quote_focus->column_fields['bill_pobox'];
$focus->column_fields['ship_pobox'] = $quote_focus->column_fields['ship_pobox'];
$focus->column_fields['description'] = $quote_focus->column_fields['description'];
$focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions'];
$focus->column_fields['currency_id'] = $quote_focus->column_fields['currency_id'];
$focus->column_fields['conversion_rate'] = $quote_focus->column_fields['conversion_rate'];
if (isset($quote_focus->column_fields['bu_mc'])) $focus->column_fields['bu_mc'] = $quote_focus->column_fields['bu_mc']; //crmv@78395
$log->debug("Exiting getConvertQuoteToInvoice method ...");
return $focus;
}
/** This function returns the sales order object populated with the details from quote object.
* Param $focus - Sales order object
* Param $quote_focus - Quote order focus
* Param $quoteid - quote id
* Return type is an object array
*/
function getConvertQuoteToSoObject($focus,$quote_focus,$quoteid)
{
global $log,$current_user;
$log->debug("Entering getConvertQuoteToSoObject(focus,focus,".$quoteid.") method ...");
$log->info("in getConvertQuoteToSoObject ".$quoteid);
$xyz=array('bill_street','bill_city','bill_code','bill_pobox','bill_country','bill_state','ship_street','ship_city','ship_code','ship_pobox','ship_country','ship_state');
for($i=0;$i<12;$i++){
if (getFieldVisibilityPermission('Quotes', $current_user->id,$xyz[$i]) == '0'){
$quote_focus->column_fields[$xyz[$i]] = $quote_focus->column_fields[$xyz[$i]];
}
else
$quote_focus->column_fields[$xyz[$i]] = '';
}
$focus->column_fields['quote_id'] = $quoteid;
$focus->column_fields['subject'] = $quote_focus->column_fields['subject'];
$focus->column_fields['contact_id'] = $quote_focus->column_fields['contact_id'];
$focus->column_fields['potential_id'] = $quote_focus->column_fields['potential_id'];
$focus->column_fields['account_id'] = $quote_focus->column_fields['account_id'];
$focus->column_fields['carrier'] = $quote_focus->column_fields['carrier'];
$focus->column_fields['bill_street'] = $quote_focus->column_fields['bill_street'];
$focus->column_fields['ship_street'] = $quote_focus->column_fields['ship_street'];
$focus->column_fields['bill_city'] = $quote_focus->column_fields['bill_city'];
$focus->column_fields['ship_city'] = $quote_focus->column_fields['ship_city'];
$focus->column_fields['bill_state'] = $quote_focus->column_fields['bill_state'];
$focus->column_fields['ship_state'] = $quote_focus->column_fields['ship_state'];
$focus->column_fields['bill_code'] = $quote_focus->column_fields['bill_code'];
$focus->column_fields['ship_code'] = $quote_focus->column_fields['ship_code'];
$focus->column_fields['bill_country'] = $quote_focus->column_fields['bill_country'];
$focus->column_fields['ship_country'] = $quote_focus->column_fields['ship_country'];
$focus->column_fields['bill_pobox'] = $quote_focus->column_fields['bill_pobox'];
$focus->column_fields['ship_pobox'] = $quote_focus->column_fields['ship_pobox'];
$focus->column_fields['description'] = $quote_focus->column_fields['description'];
$focus->column_fields['terms_conditions'] = $quote_focus->column_fields['terms_conditions'];
$focus->column_fields['currency_id'] = $quote_focus->column_fields['currency_id'];
$focus->column_fields['conversion_rate'] = $quote_focus->column_fields['conversion_rate'];
if (isset($quote_focus->column_fields['bu_mc'])) $focus->column_fields['bu_mc'] = $quote_focus->column_fields['bu_mc']; //crmv@78395
$log->debug("Exiting getConvertQuoteToSoObject method ...");
return $focus;
}
/** This function returns the no of vte_products associated to the given entity or a record.
* Param $module - module name
* Param $focus - module object
* Param $seid - sales entity id
* Return type is an object array
*/
function getNoOfAssocProducts($module,$focus,$seid='')
{
global $log,$table_prefix;
$log->debug("Entering getNoOfAssocProducts(".$module.",focus,".$seid."='') method ...");
global $adb;
$output = '';
if($module == 'Quotes')
{
$query="select ".$table_prefix."_products.productname, ".$table_prefix."_products.unit_price, ".$table_prefix."_inventoryproductrel.* from ".$table_prefix."_inventoryproductrel inner join ".$table_prefix."_products on ".$table_prefix."_products.productid=".$table_prefix."_inventoryproductrel.productid where id=?";
$params = array($focus->id);
}
elseif($module == 'PurchaseOrder')
{
$query="select ".$table_prefix."_products.productname, ".$table_prefix."_products.unit_price, ".$table_prefix."_inventoryproductrel.* from ".$table_prefix."_inventoryproductrel inner join ".$table_prefix."_products on ".$table_prefix."_products.productid=".$table_prefix."_inventoryproductrel.productid where id=?";
$params = array($focus->id);
}
elseif($module == 'SalesOrder')
{
$query="select ".$table_prefix."_products.productname, ".$table_prefix."_products.unit_price, ".$table_prefix."_inventoryproductrel.* from ".$table_prefix."_inventoryproductrel inner join ".$table_prefix."_products on ".$table_prefix."_products.productid=".$table_prefix."_inventoryproductrel.productid where id=?";
$params = array($focus->id);
}
elseif($module == 'Invoice')
{
$query="select ".$table_prefix."_products.productname, ".$table_prefix."_products.unit_price, ".$table_prefix."_inventoryproductrel.* from ".$table_prefix."_inventoryproductrel inner join ".$table_prefix."_products on ".$table_prefix."_products.productid=".$table_prefix."_inventoryproductrel.productid where id=?";
$params = array($focus->id);
}
elseif($module == 'Potentials')
{
$query="select ".$table_prefix."_products.productname,".$table_prefix."_products.unit_price,".$table_prefix."_seproductsrel.* from ".$table_prefix."_products inner join ".$table_prefix."_seproductsrel on ".$table_prefix."_seproductsrel.productid=".$table_prefix."_products.productid where crmid=?";
$params = array($seid);
}
//crmv@7214
elseif($module == 'HelpDesk')
{
$query="SELECT ".$table_prefix."_products.productname, ".$table_prefix."_products.product_description, ".$table_prefix."_products.unit_price," .
" ".$table_prefix."_products.qtyinstock, ".$table_prefix."_inventoryproductrel.* " .
" FROM ".$table_prefix."_inventoryproductrel " .
" INNER JOIN ".$table_prefix."_products ON ".$table_prefix."_products.productid=".$table_prefix."_inventoryproductrel.productid " .
" WHERE id=".$focus->id." ORDER BY sequence_no";
}
//crmv@7214e
elseif($module == 'Products')
{
$query="select ".$table_prefix."_products.productname,".$table_prefix."_products.unit_price, ".$table_prefix."_crmentity.* from ".$table_prefix."_products inner join ".$table_prefix."_crmentity on ".$table_prefix."_crmentity.crmid=".$table_prefix."_products.productid where ".$table_prefix."_crmentity.deleted=0 and productid=?";
$params = array($seid);
}
$result = $adb->pquery($query, $params);
$num_rows=$adb->num_rows($result);
$log->debug("Exiting getNoOfAssocProducts method ...");
return $num_rows;
}
/** This function returns the detail block information of a record for given block id.
* Param $module - module name
* Param $block - block name
* Param $mode - view type (detail/edit/create)
* Param $col_fields - vte_fields array
* Param $tabid - vte_tab id
* Param $info_type - information type (basic/advance) default ""
* Return type is an object array
*/
function getBlockInformation($module, $result, $col_fields,$tabid,$blockdata,$mode,&$aBlockStatus='',&$blockVisibility='') //crmv@96450 crmv@99316 crmv@104568
{
global $log;
$log->debug("Entering getBlockInformation(".$module.",". $result.",". $col_fields.",".$tabid.",".$blockdata.") method ..."); // crmv@104568
global $adb;
$editview_arr = Array();
global $current_user,$mod_strings,$processMakerView; //crmv@161211
$noofrows = $adb->num_rows($result);
if (($module == 'Accounts' || $module == 'Contacts' || $module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder'|| $module == 'Invoice') && $block == 2)
{
global $log;
$log->info("module is ".$module);
$mvAdd_flag = true;
$moveAddress = "
| ";
}
//crmv@9434+31357
if (vtlib_isModuleActive('Transitions')){
$transitions_obj = CRMEntity::getInstance('Transitions');
$transitions_obj->Initialize($module,$current_user->roleid);
}
//crmv@9434+31357 end
//crmv@9433
if (vtlib_isModuleActive('Conditionals')){
//crmv@36505
$conditionals_obj = CRMEntity::getInstance('Conditionals');
$conditionals_obj->Initialize($module,$tabid,$col_fields);
//crmv@36505 e
}
//crmv@9433 end
for($i=0; $i<$noofrows; $i++)
{
$fieldtablename = $adb->query_result($result,$i,"tablename");
$fieldcolname = $adb->query_result($result,$i,"columnname");
$uitype = $adb->query_result($result,$i,"uitype");
$fieldname = $adb->query_result($result,$i,"fieldname");
$fieldlabel = $adb->query_result($result,$i,"fieldlabel");
$block = $adb->query_result($result,$i,"block");
$maxlength = $adb->query_result($result,$i,"maximumlength");
$generatedtype = $adb->query_result($result,$i,"generatedtype");
$readonly = $adb->query_result($result,$i,"readonly");
$fieldid = $adb->query_result($result,$i,"fieldid"); // crmv@37679
$typeofdata = getFinalTypeOfData($adb->query_result($result,$i,"typeofdata"), $adb->query_result($result,$i,"mandatory")); //crmv@49510
//crmv@9434
if (vtlib_isModuleActive('Transitions'))
$transitions_obj->handle_managed_fields($fieldname,$fieldcolname,$readonly,$col_fields,$mode,'EditView');
//crmv@9434 end
//crmv@9433
if (vtlib_isModuleActive('Conditionals')){
$fieldid = $adb->query_result($result,$i,"fieldid");
if (is_array($conditionals_obj->permissions[$fieldid])){
if ($conditionals_obj->permissions[$fieldid]["f2fp_visible"] == 0)
$readonly = 100;
elseif ($conditionals_obj->permissions[$fieldid]["f2fp_editable"] == 0)
$readonly = 99;
if ($conditionals_obj->permissions[$fieldid]["f2fp_mandatory"] == 1) $typeofdata = getFinalTypeOfData($typeofdata, '0'); //crmv@114144
}
}
//crmv@9433 e
//crmv@sdk-18508
$sdk_files = SDK::getViews($module,$mode);
if (!empty($sdk_files)) {
foreach($sdk_files as $sdk_file) {
$success = false;
$readonly_old = $readonly;
include($sdk_file['src']);
SDK::checkReadonly($readonly_old,$readonly,$sdk_file['mode']);
if ($success && $sdk_file['on_success'] == 'stop') {
break;
}
}
}
//crmv@sdk-18508 e
//crmv@103373 crmv@106857 crmv@161211
// NB. same code in InsertTableRow.php and in include/CustomFieldUtil.php
if ($processMakerView) {
$readonly = 1;
// TODO creare un metodo o degli array per gestire questi casi
if (in_array($uitype,array(69,220))) $readonly = 100; // hide table fields
if ($uitype == 300) $uitype = 15; //crmv@111091
if (in_array($uitype,array(7,9,71,72))) $uitype = 1; //crmv@96450
if ($_REQUEST['tablerow_mode'] == '1' && in_array($fieldname,array('parent_id','seq','assigned_user_id'))) $readonly = 100; //crmv@115268 hide some fields from table fields
}
//crmv@103373e crmv@106857e crmv@161211e
$custfld = getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields,$generatedtype,$module,$mode,$readonly,$typeofdata);
$custfld[] = $fieldid; // crmv@37679
$editview_arr[$block][]=$custfld;
}
//crmv@96450
if ($module == 'Processes' && !empty($col_fields['record_id'])) { //crmv@170707
require_once('modules/Settings/ProcessMaker/ProcessDynaForm.php');
$processDynaFormObj = ProcessDynaForm::getInstance();
$processDynaFormObj->addBlockInformation($col_fields,'edit',$editview_arr,$blockdata,$aBlockStatus); // crmv@104568
}
//crmv@96450e
// crmv@198024
if ($module == 'Products' && $view != 'summary') {
$prodFocus = CRMEntity::getInstance('Products');
$prodFocus->addAttributesBlock($col_fields, 'edit', $editview_arr, $blockdata, $aBlockStatus);
}
// crmv@198024e
//crmv@99316
foreach($editview_arr as $headerid=>$editview_value) {
foreach($editview_value as $i => $arr) {
if ($arr[4] == 100) unset($editview_value[$i]); // skip field
}
if (empty($editview_value)) $blockVisibility[$headerid] = 0; // skip block if empty // crmv@104568 crmv@112297
}
//crmv@99316e
foreach($editview_arr as $headerid=>$editview_value)
{
$editview_data = Array();
for ($i=0,$j=0;$i $key1,1 => $key2);
$i+=2;
}
else{
$editview_data[$j]=array(0 => $key1);
$i++;
}
}
$editview_arr[$headerid] = $editview_data;
}
// crmv@104568
$returndata = array();
foreach($blockdata as $blockid=>$blockinfo) {
$label = $blockinfo['label'];
if ($label != '') {
$curBlock = $label;
}
$blocklabel = getTranslatedString($curBlock,$module);
$key = $blocklabel;
if(is_array($editview_arr[$blockid])) {
if (!is_array($returndata[$key])) {
$returndata[$key] = array(
'blockid' => $blockid,
'panelid' => $blockinfo['panelid'],
'label' => $blocklabel,
'fields' => array()
);
}
$returndata[$key]['fields'] = array_merge((array)$returndata[$key]['fields'], (array)$editview_arr[$blockid]);
}
}
// crmv@104568e
$log->debug("Exiting getBlockInformation method ...");
return $returndata;
}
/** This function returns the data type of the vte_fields, with vte_field label, which is used for javascript validation.
* Param $validationData - array of vte_fieldnames with datatype
* Return type array
*/
//crmv@112297
function split_validationdataArray($validationData, $otherInfo=array())
{
global $log;
$log->debug("Entering split_validationdataArray(".$validationData.") method ...");
$fieldName = '';
$fieldLabel = '';
$fldDataType = '';
$rows = count($validationData);
foreach($validationData as $fldName => $fldLabel_array)
{
if($fieldName == '')
{
$fieldName="'".$fldName."'";
}
else
{
$fieldName .= ",'".$fldName ."'";
}
foreach($fldLabel_array as $fldLabel => $datatype)
{
if($fieldLabel == '')
{
$fieldLabel = "'".addslashes($fldLabel)."'";
}
else
{
$fieldLabel .= ",'".addslashes($fldLabel)."'";
}
if($fldDataType == '')
{
$fldDataType = "'".$datatype ."'";
}
else
{
$fldDataType .= ",'".$datatype ."'";
}
}
}
$data['fieldname'] = $fieldName;
$data['fieldlabel'] = $fieldLabel;
$data['datatype'] = $fldDataType;
if (!empty($otherInfo)) {
$data['fielduitype'] = implode(',', $otherInfo['fielduitype']);
$data['fieldwstype'] = implode(',',array_map(function($v){ return "\"$v\""; }, $otherInfo['fieldwstype']));
}
$log->debug("Exiting split_validationdataArray method ...");
return $data;
}
function getValidationdataArray($validationData, $otherInfo=array(), $preserveKeys=false) {
$data['fieldname'] = array();
$data['fieldlabel'] = array();
$data['datatype'] = array();
foreach($validationData as $fldName => $fldLabel_array) {
foreach($fldLabel_array as $fldLabel => $datatype) {
$data['fieldname'][$fldName] = $fldName;
$data['fieldlabel'][$fldName] = $fldLabel;
$data['datatype'][$fldName] = $datatype;
}
}
if (!empty($otherInfo)) {
$data['fielduitype'] = $otherInfo['fielduitype'];
$data['fieldwstype'] = $otherInfo['fieldwstype'];
}
if (!$preserveKeys && !empty($data)) {
foreach($data as $info => $arr) $data[$info] = array_values($arr);
}
return $data;
}