function getAssociatedProducts() { global $log; $log->debug("Entering getAssociatedProducts() method ..."); $product_Detail = array(); $query = "select ec_products.*,ec_inventoryproductrel.*,ec_products.productid as crmid,ec_catalog.catalogname,ec_vendor.vendorname from ec_inventoryproductrel inner join ec_products on ec_products.productid=ec_inventoryproductrel.productid left join ec_catalog on ec_catalog.catalogid=ec_products.catalogid left join ec_vendor on ec_vendor.vendorid=ec_products.vendor_id where ec_inventoryproductrel.id=" . $this->id . " ORDER BY sequence_no"; $fieldlist = getProductFieldList("Relsettings"); $result = $this->db->query($query); $num_rows = $this->db->num_rows($result); for ($i = 1; $i <= $num_rows; $i++) { $productid = $this->db->query_result($result, $i - 1, 'crmid'); $product_Detail[$i]['delRow' . $i] = "Del"; $product_Detail[$i]['hdnProductId' . $i] = $productid; foreach ($fieldlist as $fieldname) { if ($fieldname != "imagename") { $fieldvalue = $this->db->query_result($result, $i - 1, $fieldname); if (strpos($fieldname, "price")) { $fieldvalue = convertFromDollar($fieldvalue, 1); } } else { $image_query = 'select ec_attachments.path, ec_attachments.attachmentsid, ec_attachments.name from ec_products left join ec_seattachmentsrel on ec_seattachmentsrel.crmid=ec_products.productid inner join ec_attachments on ec_attachments.attachmentsid=ec_seattachmentsrel.attachmentsid where productid=' . $productid; $result_image = $this->db->query($image_query); $nums = $this->db->num_rows($result_image); if ($nums > 0) { $image_id = $this->db->query_result($result_image, 0, 'attachmentsid'); $image_name = $this->db->query_result($result_image, 0, 'name'); $image_path = $this->db->query_result($result_image, 0, 'path'); $imagename = $image_path . $image_id . "_" . base64_encode_filename($image_name); } else { $imagename = ""; } } $product_Detail[$i][$fieldname . $i] = $fieldvalue; } $comment = $this->db->query_result($result, $i - 1, 'comment'); $qty = $this->db->query_result($result, $i - 1, 'quantity'); $listprice = $this->db->query_result($result, $i - 1, 'listprice'); $discountPercent = $this->db->query_result($result, $i - 1, 'discount_percent'); $discountAmount = $this->db->query_result($result, $i - 1, 'discount_amount'); if (is_numeric($discountPercent)) { $discountPercent = $discountPercent * 100; } //calculate productTotal if (is_numeric($discountAmount)) { $productTotal = $qty * $discountAmount; } else { $productTotal = $qty * $listprice; } $listprice = getConvertedPriceFromDollar($listprice); $productTotal = getConvertedPriceFromDollar($productTotal); $qty = convertFromDollar($qty, 1); $product_Detail[$i]['qty' . $i] = $qty; $product_Detail[$i]['listPrice' . $i] = $listprice; $product_Detail[$i]['comment' . $i] = $comment; $product_Detail[$i]['productTotal' . $i] = $productTotal; $product_Detail[$i]['netPrice' . $i] = $productTotal; } $log->debug("Exiting getAssociatedProducts method ..."); return $product_Detail; }
********************************************************************************/ require_once 'config.php'; require_once 'include/database/PearDatabase.php'; global $adb; global $fileId; global $mod_strings; $attachmentsid = $_REQUEST['fileid']; $entityid = $_REQUEST['entityid']; $returnmodule = $_REQUEST['return_module']; $dbQuery = "SELECT * FROM ec_attachments WHERE attachmentsid = " . $attachmentsid; $result = $adb->query($dbQuery) or die("Couldn't get file list"); if ($adb->num_rows($result) == 1) { $fileType = @$adb->query_result($result, 0, "type"); $name = @$adb->query_result($result, 0, "name"); $filepath = @$adb->query_result($result, 0, "path"); $encode_filename = base64_encode_filename($name); $saved_filename = $attachmentsid . "_" . $encode_filename; if (!is_file($filepath . $saved_filename)) { echo $mod_strings["NOT_EXIST"]; exit; } // $filesize = filesize($filepath.$saved_filename); // $fp = fopen($filepath.$saved_filename, "rb"); // // $name = iconv_ec("UTF-8","GB2312",$name); // // ob_end_clean(); // header('Cache-control: max-age=31536000'); // header('Expires: '.gmdate('D, d M Y H:i:s', time() + 31536000).' GMT'); // header('Content-Encoding: none'); // header("Content-Type: application/force-download");
/** Function used to send email * $module -- current module * $to_email -- to email address * $from_name -- currently loggedin user name * $from_email -- currently loggedin ec_users's email id. you can give as '' if you are not in HelpDesk module * $subject -- subject of the email you want to send * $contents -- body of the email you want to send * $cc -- add email ids with comma seperated. - optional * $bcc -- add email ids with comma seperated. - optional. * $attachment -- whether we want to attach the currently selected file or all ec_files.[values = current,all] - optional * $emailid -- id of the email object which will be used to get the ec_attachments */ function send_webmail($module, $to_email, $from_name, $from_email, $subject, $contents, $cc = '', $bcc = '', $attachment = '', $emailid = '') { global $adb, $log; $log->debug("Entering send_webmail() method ..."); $smtphandle = new SMTPMailer(); if (!isset($_SESSION["MAILLIST_PLAINTEXT"])) { $smtphandle->UseHTML(1); // set email format to HTML $headertag = "<HEAD><META http-equiv=\"Content-Type\" content=\"text/html; charset=GBK\"></HEAD>"; $contents = from_html($contents); $contents = eregi_replace('<BODY', $headertag . '<BODY', $contents); } $smtphandle->charset = 'GBK'; //convert UTF-8 to GBK $subject = iconv_ec("UTF-8", "GBK", $subject); $contents = iconv_ec("UTF-8", "GBK", $contents); $emailid = iconv_ec("UTF-8", "GBK", $emailid); //$from_email = ""; $smtphandle->subject = $subject; $smtphandle->body = $contents; $res = $adb->query("select * from ec_systems where server_type='email'"); $rownum = $adb->num_rows($res); if ($rownum == 0) { return "No Smtp Server!"; } $server = $adb->query_result($res, 0, 'server'); $username = $adb->query_result($res, 0, 'server_username'); $password = $adb->query_result($res, 0, 'server_password'); $smtp_auth = $adb->query_result($res, 0, 'smtp_auth'); $server_port = $adb->query_result($res, 0, 'server_port'); if ($from_email == '') { $from_email = $adb->query_result($res, 0, 'from_email'); } if ($from_name == '') { $from_name = $adb->query_result($res, 0, 'from_name'); } $from_name = iconv_ec("UTF-8", "GBK", $from_name); $from_email = iconv_ec("UTF-8", "GBK", $from_email); $smtphandle->SetHost($server, $server_port); $smtphandle->UseAuthLogin($username, $password); $smtphandle->SetFrom($from_email, $from_name); $smtphandle->AddReplyTo($from_email, $from_name); if ($to_email != '') { if (is_array($to_email)) { for ($j = 0, $num = count($to_email); $j < $num; $j++) { $smtphandle->AddTo($to_email[$j]); } } else { $_tmp = explode(",", $to_email); for ($j = 0, $num = count($_tmp); $j < $num; $j++) { $smtphandle->AddTo($_tmp[$j]); } } } if ($cc != '') { if (is_array($cc)) { for ($j = 0, $num = count($cc); $j < $num; $j++) { $smtphandle->AddCc($cc[$j]); } } else { $_tmp = explode(",", $cc); for ($j = 0, $num = count($_tmp); $j < $num; $j++) { $smtphandle->AddCc($_tmp[$j]); } } } if ($bcc != '') { if (is_array($bcc)) { for ($j = 0, $num = count($bcc); $j < $num; $j++) { $smtphandle->AddBcc($bcc[$j]); } } else { $_tmp = explode(",", $bcc); for ($j = 0, $num = count($_tmp); $j < $num; $j++) { $smtphandle->AddBcc($_tmp[$j]); } } } if ($attachment != "") { $query = "select * from ec_attachments where attachmentsid='" . $attachment . "'"; $result = $adb->query($query); $rownum = $adb->num_rows($result); if ($rownum > 0) { $attachmentsid = $adb->query_result($result, 0, 'attachmentsid'); $filename = $adb->query_result($result, 0, 'name'); $filename = iconv_ec("UTF-8", "GBK", $filename); $encode_filename = base64_encode_filename($adb->query_result($result, 0, 'name')); $filepath = $adb->query_result($result, 0, 'path'); $filetype = $adb->query_result($result, 0, 'type'); global $root_directory; $fullpath = $root_directory . $filepath . $attachmentsid . "_" . $encode_filename; $log->info("send_webmail :: fullpath:" . $fullpath); if (file_exists($fullpath)) { $attachment_status = $smtphandle->AddAttachment($fullpath, $filename, $filetype); if (!$attachment_status) { $log->info("send_webmail :: errormsg:" . $smtphandle->errormsg); } } } } $errMsg = ""; $sentmsg = $smtphandle->Send(); if ($sentmsg === false) { $errMsg = $smtphandle->errormsg . '<br>'; $log->info("send_webmail :: errormsg:" . $smtphandle->errormsg); } $log->debug("Exit send_webmail() method ..."); return $errMsg; }
$ext = substr($binFile, $ext_pos + 1); if (in_array($ext, $upload_badext)) { $binFile .= ".txt"; } // Vulnerability fix ends $current_id = $adb->getUniqueID("ec_crmentity"); $filename = explode_basename($binFile); $filetype = $file_details['type']; $filesize = $file_details['size']; $filetmp_name = $file_details['tmp_name']; //get the file path inwhich folder we want to upload the file $upload_file_path = decideFilePath(); //upload the file in server $upload_status = false; if (is_uploaded_file($filetmp_name)) { $encode_file = base64_encode_filename($binFile); $upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . "_" . $encode_file); } if ($upload_status) { $description = ""; $adb->query("insert into ec_crmentity (crmid,setype) values('" . $current_id . "','Maillists Attachment')"); $sql = "insert into ec_attachments(attachmentsid,name,description,type,setype,path,smcreatorid,createdtime) values("; $sql .= $current_id . ",'" . $filename . "','" . $description . "','" . $filetype . "','Maillists','" . $upload_file_path . "','" . $current_user->id . "'," . $date_var . ")"; $adb->query($sql); $query_attachment = "delete from ec_seattachmentsrel where crmid = " . $sjid; $adb->query($query_attachment); $query_attachment = 'insert into ec_seattachmentsrel values(' . $sjid . ',' . $current_id . ')'; $adb->query($query_attachment); $insertsjidsql = 'insert into ec_attachmentsjrel values(' . $sjid . ',' . $current_id . ')'; $adb->query($insertsjidsql); }
function send_webmail($to_email, $from_name, $from_email, $subject, $contents, $sjid = '') { ini_set('date.timezone', 'Asia/Shanghai'); global $adb, $log; global $current_user; $log->debug("Entering send_webmail() method ..."); $smtphandle = new SMTPMailer(); if (!isset($_SESSION["MAILLIST_PLAINTEXT"])) { $smtphandle->UseHTML(1); // set email format to HTML $headertag = "<HEAD><META http-equiv=\"Content-Type\" content=\"text/html; charset=GBK\"></HEAD>"; $contents = from_html($contents); $contents = eregi_replace('<BODY', $headertag . '<BODY', $contents); } $smtphandle->charset = 'GBK'; //convert UTF-8 to GBK $subject = iconv_ec("UTF-8", "GBK", $subject); $contents = iconv_ec("UTF-8", "GBK", $contents); //$from_name = iconv_ec("UTF-8","GBK",$from_name); //$from_email = ""; $smtphandle->subject = $subject; $smtphandle->body = $contents; $res = $adb->query("select * from ec_systems where server_type='email' and smownerid='" . $current_user->id . "'"); $rownum = $adb->num_rows($res); if ($rownum == 0) { return "No Smtp Server!"; } $server = $adb->query_result($res, 0, 'server'); $username = $adb->query_result($res, 0, 'server_username'); $password = $adb->query_result($res, 0, 'server_password'); $smtp_auth = $adb->query_result($res, 0, 'smtp_auth'); $server_port = $adb->query_result($res, 0, 'server_port'); $from_email = $adb->query_result($res, 0, 'from_email'); $from_name = $adb->query_result($res, 0, 'from_name'); $from_name = iconv_ec("UTF-8", "GBK", $from_name); $from_email = iconv_ec("UTF-8", "GBK", $from_email); $smtphandle->SetHost($server, $server_port); $smtphandle->UseAuthLogin($username, $password); $smtphandle->SetFrom($from_email, $from_name); $smtphandle->AddReplyTo($from_email, $from_name); if ($to_email != '') { $smtphandle->AddTo($to_email); } if ($sjid != "") { $query = "select ec_attachments.* from ec_attachments " . " inner join ec_attachmentsjrel on ec_attachmentsjrel.attachmentsid = ec_attachments.attachmentsid " . "where ec_attachmentsjrel.sjid={$sjid} and ec_attachments.deleted=0 order by ec_attachments.attachmentsid asc"; $result = $adb->query($query); $rownum = $adb->num_rows($result); if ($rownum > 0) { while ($row = $adb->fetch_array($result)) { $attachmentsid = $row['attachmentsid']; $filename = $row['name']; $filename = iconv_ec("UTF-8", "GBK", $filename); $encode_filename = base64_encode_filename($row['name']); $filepath = $row['path']; $filetype = $row['type']; global $root_directory; $fullpath = $root_directory . $filepath . $attachmentsid . "_" . $encode_filename; $log->info("send_webmail :: fullpath:" . $fullpath); if (file_exists($fullpath)) { $attachment_status = $smtphandle->AddAttachment($fullpath, $filename, $filetype); if (!$attachment_status) { $log->info("send_webmail :: errormsg:" . $smtphandle->errormsg); } } } } } $errMsg = ""; $sentmsg = $smtphandle->Send(); if ($sentmsg === false) { $errMsg = $smtphandle->errormsg . '<br>'; $log->info("send_webmail :: errormsg:" . $smtphandle->errormsg); } $log->debug("Exit send_webmail() method ..."); return $errMsg; }
/** * This function is used to upload the attachment in the server and save that attachment information in db. * @param int $id - entity id to which the file to be uploaded * @param string $module - the current module name * @param array $file_details - array which contains the file information(name, type, size, tmp_name and error) * return void */ function uploadAndSaveFile($id, $module, $file_details) { global $log; $log->debug("Entering into uploadAndSaveFile({$id},{$module},{$file_details}) method."); global $current_user; global $upload_badext; $date_var = date('Y-m-d H:i:s'); //to get the owner id $ownerid = isset($this->column_fields['assigned_user_id']) ? $this->column_fields['assigned_user_id'] : ''; if (!isset($ownerid) || $ownerid == '') { $ownerid = $current_user->id; } // Arbitrary File Upload Vulnerability fix - Philip $binFile = $file_details['name']; $ext_pos = strrpos($binFile, "."); $ext = substr($binFile, $ext_pos + 1); if (in_array($ext, $upload_badext)) { $binFile .= ".txt"; } // Vulnerability fix ends $current_id = $this->db->getUniqueID("ec_crmentity"); $filename = explode_basename($binFile); $filetype = $file_details['type']; $filesize = $file_details['size']; $filetmp_name = $file_details['tmp_name']; //get the file path inwhich folder we want to upload the file $upload_file_path = decideFilePath(); //upload the file in server if (is_uploaded_file($filetmp_name)) { $encode_file = base64_encode_filename($binFile); $upload_status = move_uploaded_file($filetmp_name, $upload_file_path . $current_id . "_" . $encode_file); } $save_file = 'true'; //only images are allowed for these modules if ($module == 'Contacts' || $module == 'Products') { echo "222"; $save_file = validateImageFile($file_details); } if ($save_file == 'true' && $upload_status == 'true') { //This is only to update the attached filename in the ec_notes ec_table for the Notes module if ($module == 'Notes') { $sql = "update ec_notes set filename='" . $filename . "' where notesid = " . $id; $this->db->query($sql); } else { if ($module == 'Documents') { $sql = "update ec_documents set filename='" . $filename . "' where documentsid = " . $id; $this->db->query($sql); } } $description = ""; if (isset($this->column_fields['description'])) { $description = $this->column_fields['description']; } $sql1 = "insert into ec_crmentity (crmid,setype) values(" . $current_id . ",'" . $module . " Attachment')"; $this->db->query($sql1); $sql = "insert into ec_attachments(attachmentsid,name,description,type,setype,path,smcreatorid,createdtime) values("; $sql .= $current_id . ",'" . $filename . "','" . $description . "','" . $filetype . "','" . $module . "','" . $upload_file_path . "','" . $ownerid . "','" . $date_var . "')"; $result = $this->db->query($sql); if (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'edit') { if ($id != '' && isset($_REQUEST['fileid']) && $_REQUEST['fileid'] != '') { $delquery = 'delete from ec_seattachmentsrel where crmid = ' . $id . ' and attachmentsid = ' . $_REQUEST['fileid']; $this->db->query($delquery); } } if ($module == 'Notes' || $module == 'Documents') { $query = "delete from ec_seattachmentsrel where crmid = " . $id; $this->db->query($query); } $sql3 = 'insert into ec_seattachmentsrel values(' . $id . ',' . $current_id . ')'; $this->db->query($sql3); return true; } else { $log->debug("Skip the save attachment process."); return false; } }
function getAssociatedProductsFromQuote($quoteid) { global $log; $log->debug("Entering getAssociatedProductsFromQuote() method ..."); $output = ''; global $current_user; $product_Detail = array(); $query = "select ec_products.*,ec_inventoryproductrel.*,ec_products.productid as crmid from ec_inventoryproductrel inner join ec_products on ec_products.productid=ec_inventoryproductrel.productid where ec_inventoryproductrel.id=" . $quoteid . " ORDER BY sequence_no"; $fieldlist = getProductFieldList("SalesOrder"); $result = $this->db->query($query); $num_rows = $this->db->num_rows($result); for ($i = 1; $i <= $num_rows; $i++) { $productid = $this->db->query_result($result, $i - 1, 'crmid'); $product_Detail[$i]['delRow' . $i] = "Del"; $product_Detail[$i]['hdnProductId' . $i] = $productid; foreach ($fieldlist as $fieldname) { if ($fieldname == "productname") { $output .= '<td class="crmTableRow small lineOnTop" nowrap> <a href="index.php?action=DetailView&module=Products&record=' . $productid . '" target="_blank">' . $fieldvalue . '</a></td>'; } elseif (strpos($fieldname, "price")) { $fieldvalue = convertFromDollar($fieldvalue, 1); $output .= '<td class="crmTableRow small lineOnTop" nowrap> ' . $fieldvalue . '</td>'; } else { $output .= '<td class="crmTableRow small lineOnTop" nowrap> ' . $fieldvalue . '</td>'; } if ($fieldname != "imagename") { $fieldvalue = $this->db->query_result($result, $i - 1, $fieldname); if (strpos($fieldname, "price")) { $fieldvalue = convertFromDollar($fieldvalue, 1); } } else { $image_query = 'select ec_attachments.path, ec_attachments.attachmentsid, ec_attachments.name from ec_products left join ec_seattachmentsrel on ec_seattachmentsrel.crmid=ec_products.productid inner join ec_attachments on ec_attachments.attachmentsid=ec_seattachmentsrel.attachmentsid where productid=' . $productid; $result_image = $this->db->query($image_query); $nums = $this->db->num_rows($result_image); if ($nums > 0) { $image_id = $this->db->query_result($result_image, 0, 'attachmentsid'); $image_name = $this->db->query_result($result_image, 0, 'name'); $image_path = $this->db->query_result($result_image, 0, 'path'); $imagename = $image_path . $image_id . "_" . base64_encode_filename($image_name); } else { $imagename = ""; } } $product_Detail[$i][$fieldname . $i] = $fieldvalue; } $comment = $this->db->query_result($result, $i - 1, 'comment'); $qty = $this->db->query_result($result, $i - 1, 'quantity'); $listprice = $this->db->query_result($result, $i - 1, 'listprice'); $discountPercent = $this->db->query_result($result, $i - 1, 'discount_percent'); $discountAmount = $this->db->query_result($result, $i - 1, 'discount_amount'); if (is_numeric($discountPercent)) { $discountPercent = $discountPercent * 100; } //calculate productTotal if (is_numeric($discountAmount)) { $productTotal = $qty * $discountAmount; } else { $productTotal = $qty * $listprice; } $listprice = getConvertedPriceFromDollar($listprice); $productTotal = getConvertedPriceFromDollar($productTotal); $qty = convertFromDollar($qty, 1); $product_Detail[$i]['qty' . $i] = $qty; $product_Detail[$i]['listPrice' . $i] = $discountAmount; $product_Detail[$i]['comment' . $i] = $comment; $product_Detail[$i]['productTotal' . $i] = $productTotal; $product_Detail[$i]['netPrice' . $i] = $productTotal; } //Get the Final Discount, S&H charge, Tax for S&H and Adjustment values //To set the Final Discount details $finalDiscount = '0.00'; $product_Detail[1]['final_details']['discount_type_final'] = 'zero'; $subTotal = $this->column_fields['hdnSubTotal'] != '' ? $this->column_fields['hdnSubTotal'] : '0.00'; $subTotal = getConvertedPriceFromDollar($subTotal); $discountPercent = $this->column_fields['hdnDiscountPercent'] != '' ? $this->column_fields['hdnDiscountPercent'] : '0.00'; $discountAmount = $this->column_fields['hdnDiscountAmount'] != '' ? $this->column_fields['hdnDiscountAmount'] : '0.00'; if ($this->column_fields['hdnDiscountPercent'] != '' && $this->column_fields['hdnDiscountPercent'] != '0.0') { $finalDiscount = $subTotal * $discountPercent / 100; $product_Detail[1]['final_details']['discount_type_final'] = 'percentage'; $product_Detail[1]['final_details']['discount_percentage_final'] = $discountPercent; $product_Detail[1]['final_details']['checked_discount_percentage_final'] = ' checked'; $product_Detail[1]['final_details']['style_discount_percentage_final'] = ' style="visibility:visible"'; $product_Detail[1]['final_details']['style_discount_amount_final'] = ' style="visibility:hidden"'; } elseif ($this->column_fields['hdnDiscountAmount'] != '') { $finalDiscount = $this->column_fields['hdnDiscountAmount']; $finalDiscount = getConvertedPriceFromDollar($finalDiscount); $discountAmount = getConvertedPriceFromDollar($discountAmount); $product_Detail[1]['final_details']['discount_type_final'] = 'amount'; $product_Detail[1]['final_details']['discount_amount_final'] = $discountAmount; $product_Detail[1]['final_details']['checked_discount_amount_final'] = ' checked'; $product_Detail[1]['final_details']['style_discount_amount_final'] = ' style="visibility:visible"'; $product_Detail[1]['final_details']['style_discount_percentage_final'] = ' style="visibility:hidden"'; } $product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount; //To set the Shipping & Handling charge $shCharge = $this->column_fields['hdnS_H_Amount'] != '' ? $this->column_fields['hdnS_H_Amount'] : '0.00'; $shCharge = getConvertedPriceFromDollar($shCharge); $product_Detail[1]['final_details']['shipping_handling_charge'] = $shCharge; //To set the Adjustment value $adjustment = $this->column_fields['txtAdjustment'] != '' ? $this->column_fields['txtAdjustment'] : '0.00'; $adjustment = getConvertedPriceFromDollar($adjustment); $product_Detail[1]['final_details']['adjustment'] = $adjustment; //To set the grand total $grandTotal = $this->column_fields['hdnGrandTotal'] != '' ? $this->column_fields['hdnGrandTotal'] : '0.00'; $grandTotal = getConvertedPriceFromDollar($grandTotal); $product_Detail[1]['final_details']['grandTotal'] = $grandTotal; $log->debug("Exiting getAssociatedProductsFromQuote method ..."); return $product_Detail; }
/** This function returns the detail view form ec_field and and its properties in array format. * Param $uitype - UI type of the ec_field * Param $fieldname - Form ec_field name * Param $fieldlabel - Form ec_field label name * Param $col_fields - array contains the ec_fieldname and values * Param $generatedtype - Field generated type (default is 1) * Param $tabid - ec_tab id to which the Field belongs to (default is "") * Return type is an array */ function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '') { global $log; $log->debug("Entering getDetailViewOutputHtml() method ..."); global $adb; global $mod_strings; global $app_strings; global $current_user; //$fieldlabel = from_html($fieldlabel); $custfld = ''; $value = ''; $arr_data = array(); $label_fld = array(); $data_fld = array(); if ($generatedtype == 2) { $mod_strings[$fieldlabel] = $fieldlabel; } if (!isset($mod_strings[$fieldlabel])) { $mod_strings[$fieldlabel] = $fieldlabel; } if ($col_fields[$fieldname] == '--None--') { $col_fields[$fieldname] = ''; } if ($uitype == 116) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 13) { $label_fld[] = $mod_strings[$fieldlabel]; $temp_val = $col_fields[$fieldname]; $label_fld[] = $temp_val; $linkvalue = getComposeMailUrl($temp_val); $label_fld["link"] = $linkvalue; } elseif ($uitype == 15 || $uitype == 16 || $uitype == 115 || $uitype == 111) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 10) { if (isset($app_strings[$fieldlabel])) { $label_fld[] = $app_strings[$fieldlabel]; } elseif (isset($mod_strings[$fieldlabel])) { $label_fld[] = $mod_strings[$fieldlabel]; } else { $label_fld[] = $fieldlabel; } $value = $col_fields[$fieldname]; $module_entityname = ""; if ($value != '') { $query = "SELECT ec_entityname.* FROM ec_crmentityrel inner join ec_entityname on ec_entityname.modulename=ec_crmentityrel.relmodule inner join ec_tab on ec_tab.name=ec_crmentityrel.module WHERE ec_tab.tabid='" . $tabid . "' and ec_entityname.entityidfield='" . $fieldname . "'"; $fldmod_result = $adb->query($query); $rownum = $adb->num_rows($fldmod_result); if ($rownum > 0) { $rel_modulename = $adb->query_result($fldmod_result, 0, 'modulename'); $rel_tablename = $adb->query_result($fldmod_result, 0, 'tablename'); $rel_entityname = $adb->query_result($fldmod_result, 0, 'fieldname'); $rel_entityid = $adb->query_result($fldmod_result, 0, 'entityidfield'); $module_entityname = getEntityNameForTen($rel_tablename, $rel_entityname, $fieldname, $value); } } $label_fld[] = $module_entityname; $label_fld["secid"] = $value; $label_fld["link"] = "index.php?module=" . $rel_modulename . "&action=DetailView&record=" . $value; } elseif ($uitype == 33) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]); } elseif ($uitype == 17) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; //$label_fld[] = '<a href="http://'.$col_fields[$fieldname].'" target="_blank">'.$col_fields[$fieldname].'</a>'; } elseif ($uitype == 19) { //$tmp_value = str_replace("<","<",nl2br($col_fields[$fieldname])); //$tmp_value = str_replace(">",">",$tmp_value); //$col_fields[$fieldname]= make_clickable($tmp_value); $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) { //$col_fields[$fieldname]=nl2br($col_fields[$fieldname]); $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) { $account_id = $col_fields[$fieldname]; $account_name = ""; if ($account_id != '') { $account_name = getAccountName($account_id); } //Account Name View $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $account_name; $label_fld["secid"] = $account_id; $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id; } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) { $label_fld[] = $mod_strings[$fieldlabel]; $user_id = $col_fields[$fieldname]; $user_name = getUserName($user_id); $label_fld[] = $user_name; } elseif ($uitype == 53) { $user_id = $col_fields[$fieldname]; $user_name = getUserName($user_id); $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $user_name; } elseif ($uitype == 1004) { if (isset($mod_strings[$fieldlabel])) { $label_fld[] = $mod_strings[$fieldlabel]; } else { $label_fld[] = $fieldlabel; } $value = $col_fields[$fieldname]; $label_fld[] = getUserName($value); } elseif ($uitype == 55) { if ($tabid == 4) { $query = "select ec_contactdetails.imagename from ec_contactdetails where contactid=" . $col_fields['record_id']; $result = $adb->query($query); $imagename = $adb->query_result($result, 0, 'imagename'); if ($imagename != '') { $imgpath = "test/contact/" . $imagename; $label_fld[] = $mod_strings[$fieldlabel]; //This is used to show the contact image as a thumbnail near First Name field //$label_fld["cntimage"] ='<div style="position:absolute;height=100px"><img class="thumbnail" src="'.$imgpath.'" width="60" height="60" border="0"></div> '.$mod_strings[$fieldlabel]; } else { $label_fld[] = $mod_strings[$fieldlabel]; } } else { $label_fld[] = $mod_strings[$fieldlabel]; } $value = $col_fields[$fieldname]; $sal_value = $col_fields["salutationtype"]; if ($sal_value == '--None--') { $sal_value = ''; } $label_fld["salut"] = $sal_value; $label_fld[] = $value; //$label_fld[] =$sal_value.' '.$value; } elseif ($uitype == 56) { $label_fld[] = $mod_strings[$fieldlabel]; $value = $col_fields[$fieldname]; if ($value == 1) { //Since "yes" is not been translated it is given as app strings here.. $display_val = $app_strings['yes']; } else { $display_val = ''; } $label_fld[] = $display_val; } elseif ($uitype == 57) { $label_fld[] = $mod_strings[$fieldlabel]; $contact_id = $col_fields[$fieldname]; $contact_name = ""; if (trim($contact_id) != '') { $contact_name = getContactName($contact_id); } $label_fld[] = $contact_name; $label_fld["secid"] = $contact_id; $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id; } elseif ($uitype == 154) { $label_fld[] = $mod_strings[$fieldlabel]; $cangkusid = $col_fields[$fieldname]; $cangkuname = ""; if (trim($cangkusid) != '') { $cangkuname = getCangkuName($cangkusid); } $label_fld[] = $cangkuname; $label_fld["secid"] = $cangkusid; $label_fld["link"] = "index.php?module=Cangkus&action=DetailView&record=" . $cangkusid; } elseif ($uitype == 155) { $label_fld[] = $mod_strings[$fieldlabel]; $cangkusid = $col_fields[$fieldname]; $cangkuname = ""; if (trim($cangkusid) != '') { $cangkuname = getCangkuName($cangkusid); } $label_fld[] = $cangkuname; $label_fld["secid"] = $cangkusid; // $label_fld["link"] = "index.php?module=Cangkus&action=DetailView&record=".$cangkusid; } elseif ($uitype == 58) { $label_fld[] = $mod_strings[$fieldlabel]; $campaign_id = $col_fields[$fieldname]; if ($campaign_id != '') { $campaign_name = getCampaignName($campaign_id); } $label_fld[] = $campaign_name; $label_fld["secid"] = $campaign_id; $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id; } elseif ($uitype == 59) { $label_fld[] = $mod_strings[$fieldlabel]; $product_id = $col_fields[$fieldname]; if ($product_id != '') { $product_name = getProductName($product_id); } //Account Name View $label_fld[] = $product_name; $label_fld["secid"] = $product_id; $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id; } elseif ($uitype == 61) { global $adb; $label_fld[] = $mod_strings[$fieldlabel]; if ($tabid == 10) { $attach_result = $adb->query("select * from ec_seattachmentsrel where crmid = " . $col_fields['record_id']); for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) { $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid'); if ($attachmentid != '') { $attachquery = "select * from ec_attachments where attachmentsid=" . $attachmentid; $result = $adb->query($attachquery); $attachmentsname = $adb->query_result($result, 0, 'name'); if ($attachmentsname != '') { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>'; } else { $custfldval = ''; } } $label_fld['options'][] = $custfldval; } } else { $result = $adb->query("select * from ec_seattachmentsrel where crmid = " . $col_fields['record_id']); $attachmentid = $adb->query_result($result, 0, 'attachmentsid'); if ($col_fields[$fieldname] == '' && $attachmentid != '') { $attachquery = "select * from ec_attachments where attachmentsid=" . $attachmentid; $result = $adb->query($attachquery); $col_fields[$fieldname] = $adb->query_result($result, 0, 'name'); } //This is added to strip the crmid and _ from the file name and show the original filename $org_filename = ltrim($col_fields[$fieldname], $col_fields['record_id'] . '_'); if ($org_filename != '') { $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $org_filename . '</a>'; } else { $custfldval = ''; } } $label_fld[] = $custfldval; } elseif ($uitype == 69) { $label_fld[] = $mod_strings[$fieldlabel]; if ($tabid == 14) { $images = array(); $image_array = array(); $imagepath_array = array(); $query = "select productname, ec_attachments.path, ec_attachments.attachmentsid, ec_attachments.name from ec_products left join ec_seattachmentsrel on ec_seattachmentsrel.crmid=ec_products.productid inner join ec_attachments on ec_attachments.attachmentsid=ec_seattachmentsrel.attachmentsid where (ec_attachments.type like '%image%' or ec_attachments.type like '%img%') and productid=" . $col_fields['record_id']; $result_image = $adb->query($query); for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) { $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid'); $image_array[] = $adb->query_result($result_image, $image_iter, 'name'); $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path'); } if (count($image_array) > 1) { // if(count($image_array) < 4) // $sides=count($image_array)*2; // else // $sides=8; // // $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;"> // <img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;"> // </div><script>var Car_NoOfSides='.$sides.'; Car_Image_Sources=new Array('; // // for($image_iter=0;$image_iter < count($image_array);$image_iter++) // { // $images[]='"'.$imagepath_array[$image_iter].$image_id_array[$image_iter]."_".base64_encode_filename($image_array[$image_iter]).'","'.$imagepath_array[$image_iter].$image_id_array[$image_iter]."_".base64_encode_filename($image_array[$image_iter]).'"'; // } // $image_lists .=implode(',',$images).'); /**</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>';**/ // $label_fld[] =$image_lists; $num = count($image_array); for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) { $images[] = $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . base64_encode_filename($image_array[$image_iter]); } for ($i = 0; $i < $num; $i++) { $image_lists .= '<a href="' . $images[$i] . '" target="_blank"><img src="' . $images[$i] . '" border="0" width="150" height="150" ></a> '; } //end $label_fld[] = $image_lists; } elseif (count($image_array) == 1) { $label_fld[] = '<a href="' . $imagepath_array[0] . $image_id_array[0] . "_" . base64_encode_filename($image_array[0]) . '" target="_blank" ><img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . base64_encode_filename($image_array[0]) . '" border="0" width="150" height="150"></a>'; } else { $label_fld[] = ''; } } if ($tabid == 4) { //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname]; $sql = "select ec_attachments.* from ec_attachments inner join ec_seattachmentsrel on ec_seattachmentsrel.attachmentsid = ec_attachments.attachmentsid where (ec_attachments.type like '%image%' or ec_attachments.type like '%img%') and ec_seattachmentsrel.crmid='" . $col_fields['record_id'] . "'"; $image_res = $adb->query($sql); $image_id = $adb->query_result($image_res, 0, 'attachmentsid'); $image_path = $adb->query_result($image_res, 0, 'path'); $image_name = $adb->query_result($image_res, 0, 'name'); $imgpath = $image_path . $image_id . "_" . base64_encode_filename($image_name); $width = 160; $height = get_scale_height($imgpath, $width); if ($image_name != '') { $label_fld[] = '<img src="' . $imgpath . '" width="' . $width . '" height="' . $height . '" class="reflect" alt="">'; } else { $label_fld[] = ''; } } } elseif ($uitype == 63) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname] . 'h ' . $col_fields['duration_minutes'] . 'm'; } elseif ($uitype == 6) { $label_fld[] = $mod_strings[$fieldlabel]; if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } if ($col_fields['time_start'] != '') { $start_time = $col_fields['time_start']; } if (!isValidDate($col_fields[$fieldname])) { $displ_date = ''; } else { $displ_date = getDisplayDate($col_fields[$fieldname]); } $label_fld[] = $displ_date . ' ' . $start_time; } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) { $label_fld[] = $mod_strings[$fieldlabel]; $cur_date_val = $col_fields[$fieldname]; $end_time = ""; if (isset($col_fields['time_end']) && $col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) { $end_time = $col_fields['time_end']; } if (!isValidDate($cur_date_val)) { $display_val = ''; } else { $display_val = getDisplayDate($cur_date_val); } $label_fld[] = $display_val . ' ' . $end_time; } elseif ($uitype == 1007) { $label_fld[] = isset($mod_strings[$fieldlabel]) ? $mod_strings[$fieldlabel] : $fieldlabel; $cur_approve_val = $col_fields[$fieldname]; $label_fld[] = getApproveStatusById($cur_approve_val); } elseif ($uitype == 1008) { if (isset($mod_strings[$fieldlabel])) { $label_fld[] = $mod_strings[$fieldlabel]; } else { $label_fld[] = $fieldlabel; } $value = $col_fields[$fieldname]; $label_fld[] = getUserName($value); } elseif ($uitype == 71 || $uitype == 72) { $label_fld[] = $mod_strings[$fieldlabel]; $display_val = $col_fields[$fieldname]; $label_fld[] = $display_val; } elseif ($uitype == 75 || $uitype == 81) { $vendor_name = ""; $label_fld[] = $mod_strings[$fieldlabel]; $vendor_id = $col_fields[$fieldname]; if ($vendor_id != '') { $vendor_name = getVendorName($vendor_id); } $label_fld[] = $vendor_name; $label_fld["secid"] = $vendor_id; $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id; //$label_fld[] = '<a href="index.php?module=Products&action=VendorDetailView&record='.$vendor_id.'">'.$vendor_name.'</a>'; } elseif ($uitype == 76) { $label_fld[] = $mod_strings[$fieldlabel]; $potential_id = $col_fields[$fieldname]; if ($potential_id != '') { $potential_name = getPotentialName($potential_id); } $label_fld[] = $potential_name; $label_fld["secid"] = $potential_id; $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id; } elseif ($uitype == 78) { $label_fld[] = $mod_strings[$fieldlabel]; $quote_id = $col_fields[$fieldname]; if ($quote_id != '') { $quote_name = getQuoteName($quote_id); } $label_fld[] = $quote_name; $label_fld["secid"] = $quote_id; $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id; } elseif ($uitype == 79) { $label_fld[] = $mod_strings[$fieldlabel]; $purchaseorder_id = $col_fields[$fieldname]; if ($purchaseorder_id != '') { $purchaseorder_name = getPoName($purchaseorder_id); } $label_fld[] = $purchaseorder_name; $label_fld["secid"] = $purchaseorder_id; $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id; } elseif ($uitype == 80) { $label_fld[] = $mod_strings[$fieldlabel]; $salesorder_id = $col_fields[$fieldname]; if ($salesorder_id != '') { $salesorder_name = getSoName($salesorder_id); } $label_fld[] = $salesorder_name; $label_fld["secid"] = $salesorder_id; $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id; } elseif ($uitype == 1010) { $label_fld[] = $mod_strings[$fieldlabel]; $invoice_id = $col_fields[$fieldname]; $invoice_name = ""; if ($invoice_id != '') { $invoice_name = getInvoiceName($invoice_id); } $label_fld[] = $invoice_name; $label_fld["secid"] = $invoice_id; $label_fld["link"] = "index.php?module=Invoice&action=DetailView&record=" . $invoice_id; } elseif ($uitype == 30) { $rem_days = 0; $rem_hrs = 0; $rem_min = 0; $reminder_str = ""; $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; $label_fld[] = $mod_strings[$fieldlabel]; if ($col_fields[$fieldname]) { $reminder_str = $rem_days . ' ' . $mod_strings['LBL_DAYS'] . ' ' . $rem_hrs . ' ' . $mod_strings['LBL_HOURS'] . ' ' . $rem_min . ' ' . $mod_strings['LBL_MINUTES'] . ' ' . $mod_strings['LBL_BEFORE_EVENT']; } $label_fld[] = ' ' . $reminder_str; } elseif ($uitype == 85) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 86) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 87) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 88) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 89) { $label_fld[] = $mod_strings[$fieldlabel]; $label_fld[] = $col_fields[$fieldname]; } elseif ($uitype == 1006) { //added by dingjianting on 2007-1-27 for new module Exhibitions $catalog_name = ""; $label_fld[] = $mod_strings[$fieldlabel]; $catalogid = $col_fields[$fieldname]; if ($catalogid != '') { $catalog_name = getCatalogName($catalogid); } $label_fld[] = $catalog_name; $label_fld["secid"] = $catalogid; $label_fld["link"] = "index.php?module=Catalogs&action=CatalogDetailView&parenttab=Product&catalogid=" . $catalogid; } elseif ($uitype == 1009) { $vcontact_name = ""; $label_fld[] = $mod_strings[$fieldlabel]; $vcontactsid = $col_fields[$fieldname]; if ($vcontactsid != '') { $vcontact_name = getVcontactName($vcontactsid); } $label_fld[] = $vcontact_name; $label_fld["secid"] = $vcontactsid; $label_fld["link"] = "index.php?module=Vcontacts&action=DetailView&record=" . $vcontactsid; } elseif ($uitype == 1013) { $faqcategory_name = ""; $label_fld[] = $mod_strings[$fieldlabel]; $faqcategoryid = $col_fields[$fieldname]; if ($faqcategoryid != '') { $faqcategory_name = getFaqcategoryName($faqcategoryid); } $label_fld[] = $faqcategory_name; $label_fld["secid"] = $faqcategoryid; $label_fld["link"] = "index.php?module=Faqcategorys&action=FaqcategoryDetailView&faqcategoryid=" . $faqcategoryid; } else { $label_fld[] = $mod_strings[$fieldlabel]; if ($col_fields[$fieldname] == '0') { $col_fields[$fieldname] = ''; } $label_fld[] = $col_fields[$fieldname]; } $label_fld[] = $uitype; $log->debug("Exiting getDetailViewOutputHtml method ..."); return $label_fld; }