Example #1
0
 /**
  * Function to get the Display Value, for the current field type with given DB Insert Value
  * @param <Object> $value
  * @return <Object>
  */
 public function getDisplayValue($value)
 {
     if ($this->get('field')->getFieldName() == 'sum_time') {
         $return = Vtiger_Functions::decimalTimeFormat($value);
         return $return['short'];
     } else {
         return decimalFormat($value);
     }
 }
Example #2
0
 /**
  * this function takes in an array of values for an user and sanitizes it for export
  * @param array $arr - the array of values
  */
 function sanitizeValues($arr)
 {
     $db = PearDatabase::getInstance();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $roleid = $currentUser->get('roleid');
     if (empty($this->fieldArray)) {
         $this->fieldArray = $this->moduleFieldInstances;
         foreach ($this->fieldArray as $fieldName => $fieldObj) {
             //In database we have same column name in two tables. - inventory modules only
             if ($fieldObj->get('table') == 'vtiger_inventoryproductrel' && ($fieldName == 'discount_amount' || $fieldName == 'discount_percent')) {
                 $fieldName = 'item_' . $fieldName;
                 $this->fieldArray[$fieldName] = $fieldObj;
             } else {
                 $columnName = $fieldObj->get('column');
                 $this->fieldArray[$columnName] = $fieldObj;
             }
         }
     }
     $moduleName = $this->moduleInstance->getName();
     foreach ($arr as $fieldName => &$value) {
         if (isset($this->fieldArray[$fieldName])) {
             $fieldInfo = $this->fieldArray[$fieldName];
         } else {
             unset($arr[$fieldName]);
             continue;
         }
         $value = trim(decode_html($value), "\"");
         $uitype = $fieldInfo->get('uitype');
         $fieldname = $fieldInfo->get('name');
         if (!$this->fieldDataTypeCache[$fieldName]) {
             $this->fieldDataTypeCache[$fieldName] = $fieldInfo->getFieldDataType();
         }
         $type = $this->fieldDataTypeCache[$fieldName];
         if ($fieldname != 'hdnTaxType' && ($uitype == 15 || $uitype == 16 || $uitype == 33)) {
             if (empty($this->picklistValues[$fieldname])) {
                 $this->picklistValues[$fieldname] = $this->fieldArray[$fieldname]->getPicklistValues();
             }
             // If the value being exported is accessible to current user
             // or the picklist is multiselect type.
             if ($uitype == 33 || $uitype == 16 || array_key_exists($value, $this->picklistValues[$fieldname])) {
                 // NOTE: multipicklist (uitype=33) values will be concatenated with |# delim
                 $value = trim($value);
             } else {
                 $value = '';
             }
         } elseif ($uitype == 52 || $type == 'owner') {
             $value = Vtiger_Util_Helper::getOwnerName($value);
         } elseif ($type == 'reference') {
             $value = trim($value);
             if (!empty($value)) {
                 $parent_module = getSalesEntityType($value);
                 $displayValueArray = getEntityName($parent_module, $value);
                 if (!empty($displayValueArray)) {
                     foreach ($displayValueArray as $k => $v) {
                         $displayValue = $v;
                     }
                 }
                 if (!empty($parent_module) && !empty($displayValue)) {
                     $value = $parent_module . "::::" . $displayValue;
                 } else {
                     $value = "";
                 }
             } else {
                 $value = '';
             }
         } elseif ($uitype == 72 || $uitype == 71) {
             $value = CurrencyField::convertToUserFormat($value, null, true, true);
         } elseif ($uitype == 7 && $fieldInfo->get('typeofdata') == 'N~O' || $uitype == 9) {
             $value = decimalFormat($value);
         } else {
             if ($type == 'date' || $type == 'datetime') {
                 $value = DateTimeField::convertToUserFormat($value);
             }
         }
         if ($moduleName == 'Documents' && $fieldname == 'description') {
             $value = strip_tags($value);
             $value = str_replace('&nbsp;', '', $value);
             array_push($new_arr, $value);
         }
     }
     return $arr;
 }
Example #3
0
 function getAssociatedProducts($module, $focus, $seid = '')
 {
     $log = vglobal('log');
     $log->debug("Entering Calculations_Record_Model getAssociatedProducts(" . $module . "," . get_class($focus) . "," . $seid . "='') method ...");
     $adb = PearDatabase::getInstance();
     $output = '';
     global $theme;
     $no_of_decimal_places = getCurrencyDecimalPlaces();
     $theme_path = "themes/" . $theme . "/";
     $image_path = $theme_path . "images/";
     $product_Detail = array();
     if ($module == 'Calculations') {
         $query = "SELECT\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.productcode else vtiger_service.service_no end as productcode,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype,\n\t\t\t\t\t\t\t\t\tvtiger_calculationsproductrel.listprice,\n\t\t\t\t\t\t\t\t\tvtiger_calculationsproductrel.description AS product_description,\n\t\t\t\t\t\t\t\t\tvtiger_calculationsproductrel.*,vtiger_crmentity.deleted,\n\t\t\t\t\t\t\t\t\tvtiger_products.usageunit,\n\t\t\t\t\t\t\t\t\tvtiger_service.service_usageunit\n\t\t\t\t\t\t\t\t\tFROM vtiger_calculationsproductrel\n\t\t\t\t\t\t\t\t\tLEFT JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_calculationsproductrel.productid\n\t\t\t\t\t\t\t\t\tLEFT JOIN vtiger_products\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_products.productid=vtiger_calculationsproductrel.productid\n\t\t\t\t\t\t\t\t\tLEFT JOIN vtiger_service\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_service.serviceid=vtiger_calculationsproductrel.productid\n\t\t\t\t\t\t\t\t\tWHERE id=?\n\t\t\t\t\t\t\t\t\tORDER BY sequence_no";
         $params = array($focus->id);
     } elseif ($module == 'Products') {
         $query = "SELECT\n\t\t\t\t\t\t\t\t\tvtiger_products.productid,\n\t\t\t\t\t\t\t\t\tvtiger_products.productcode,\n\t\t\t\t\t\t\t\t\tvtiger_products.productname,\n\t\t\t\t\t\t\t\t\tvtiger_products.unit_price,\n\t\t\t\t\t\t\t\t\tvtiger_products.usageunit,\n\t\t\t\t\t\t\t\t\tvtiger_products.qtyinstock,vtiger_crmentity.deleted,\n\t\t\t\t\t\t\t\t\tvtiger_crmentity.description AS product_description,\n\t\t\t\t\t\t\t\t\t'Products' AS entitytype\n\t\t\t\t\t\t\t\t\tFROM vtiger_products\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_crmentity.crmid=vtiger_products.productid\n\t\t\t\t\t\t\t\t\tWHERE vtiger_crmentity.deleted=0\n\t\t\t\t\t\t\t\t\t\t\tAND productid=?";
         $params = array($seid);
     } elseif ($module == 'Services') {
         $query = "SELECT\n\t\t\t\t\t\t\t\t\tvtiger_service.serviceid AS productid,\n\t\t\t\t\t\t\t\t\t'NA' AS productcode,\n\t\t\t\t\t\t\t\t\tvtiger_service.servicename AS productname,\n\t\t\t\t\t\t\t\t\tvtiger_service.unit_price AS unit_price,\n\t\t\t\t\t\t\t\t\tvtiger_service.service_usageunit AS usageunit,\n\t\t\t\t\t\t\t\t\t'NA' AS qtyinstock,vtiger_crmentity.deleted,\n\t\t\t\t\t\t\t\t\tvtiger_crmentity.description AS product_description,\n\t\t\t\t\t\t\t\t\t'Services' AS entitytype\n\t\t\t\t\t\t\t\t\tFROM vtiger_service\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_crmentity.crmid=vtiger_service.serviceid\n\t\t\t\t\t\t\t\t\tWHERE vtiger_crmentity.deleted=0\n\t\t\t\t\t\t\t\t\t\t\tAND serviceid=?";
         $params = array($seid);
     }
     $result = $adb->pquery($query, $params);
     $num_rows = $adb->num_rows($result);
     for ($i = 1; $i <= $num_rows; $i++) {
         $deleted = $adb->query_result($result, $i - 1, 'deleted');
         $hdnProductId = $adb->query_result($result, $i - 1, 'productid');
         $hdnProductcode = $adb->query_result($result, $i - 1, 'productcode');
         $productname = $adb->query_result($result, $i - 1, 'productname');
         $productdescription = $adb->query_result($result, $i - 1, 'product_description');
         $comment = decode_html($adb->query_result($result, $i - 1, 'comment'));
         $qtyinstock = $adb->query_result($result, $i - 1, 'qtyinstock');
         $qty = $adb->query_result($result, $i - 1, 'quantity');
         $unitprice = $adb->query_result($result, $i - 1, 'unit_price');
         $listprice = $adb->query_result($result, $i - 1, 'listprice');
         $entitytype = $adb->query_result($result, $i - 1, 'entitytype');
         if ($entitytype == 'Services') {
             $usageunit = vtranslate($adb->query_result($result, $i - 1, 'service_usageunit'), $entitytype);
         } else {
             $usageunit = vtranslate($adb->query_result($result, $i - 1, 'usageunit'), $entitytype);
         }
         $rbh = $adb->query_result($result, $i - 1, 'rbh');
         $purchase = $adb->query_result($result, $i - 1, 'purchase');
         $margin = $adb->query_result($result, $i - 1, 'margin');
         $marginp = $adb->query_result($result, $i - 1, 'marginp');
         if ($deleted || !isset($deleted)) {
             $product_Detail[$i]['productDeleted' . $i] = true;
         } elseif (!$deleted) {
             $product_Detail[$i]['productDeleted' . $i] = false;
         }
         if (!empty($entitytype)) {
             $product_Detail[$i]['entityType' . $i] = $entitytype;
         }
         if ($listprice == '') {
             $listprice = $unitprice;
         }
         if ($qty == '') {
             $qty = 1;
         }
         //calculate productTotal
         $productTotal = $qty * $listprice;
         //Delete link in First column
         if ($i != 1) {
             $product_Detail[$i]['delRow' . $i] = "Del";
         }
         if (empty($focus->mode) && $seid != '') {
             $sub_prod_query = $adb->pquery("SELECT crmid as prod_id from vtiger_seproductsrel WHERE productid=? AND setype='Products'", array($seid));
         } else {
             $sub_prod_query = $adb->pquery("SELECT productid as prod_id from vtiger_inventorysubproductrel WHERE id=? AND sequence_no=?", array($focus->id, $i));
         }
         $subprodid_str = '';
         $subprodname_str = '';
         $subProductArray = array();
         if ($adb->num_rows($sub_prod_query) > 0) {
             for ($j = 0; $j < $adb->num_rows($sub_prod_query); $j++) {
                 $sprod_id = $adb->query_result($sub_prod_query, $j, 'prod_id');
                 $sprod_name = $subProductArray[] = getProductName($sprod_id);
                 $str_sep = "";
                 if ($j > 0) {
                     $str_sep = ":";
                 }
                 $subprodid_str .= $str_sep . $sprod_id;
                 $subprodname_str .= $str_sep . " - " . $sprod_name;
             }
         }
         $subprodname_str = str_replace(":", "<br>", $subprodname_str);
         $product_Detail[$i]['subProductArray' . $i] = $subProductArray;
         $product_Detail[$i]['hdnProductId' . $i] = $hdnProductId;
         $product_Detail[$i]['productName' . $i] = from_html($productname);
         /* Added to fix the issue Product Pop-up name display*/
         if ($_REQUEST['action'] == 'CreateSOPDF' || $_REQUEST['action'] == 'CreatePDF' || $_REQUEST['action'] == 'SendPDFMail') {
             $product_Detail[$i]['productName' . $i] = htmlspecialchars($product_Detail[$i]['productName' . $i]);
         }
         $product_Detail[$i]['hdnProductcode' . $i] = $hdnProductcode;
         $product_Detail[$i]['productDescription' . $i] = from_html($productdescription);
         if ($module == 'Potentials' || $module == 'Products' || $module == 'Services') {
             $product_Detail[$i]['comment' . $i] = $productdescription;
         } else {
             $product_Detail[$i]['comment' . $i] = $comment;
         }
         $listprice = number_format($listprice, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['qty' . $i] = decimalFormat($qty);
         $product_Detail[$i]['listPrice' . $i] = $listprice;
         $product_Detail[$i]['unitPrice' . $i] = number_format($unitprice, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['usageUnit' . $i] = $usageunit;
         $product_Detail[$i]['productTotal' . $i] = number_format($productTotal, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['subproduct_ids' . $i] = $subprodid_str;
         $product_Detail[$i]['subprod_names' . $i] = $subprodname_str;
         $product_Detail[$i]['rbh' . $i] = number_format($rbh, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['purchase' . $i] = number_format($purchase, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['margin' . $i] = number_format($margin, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['marginp' . $i] = number_format($marginp, $no_of_decimal_places, '.', '');
     }
     $log->debug("Exiting Calculations_Record_Model getAssociatedProducts method ...");
     return $product_Detail;
 }
    function content_566ea2dd5447a($_smarty_tpl)
    {
        ?>
<input type="hidden" id="view" value="<?php 
        echo $_smarty_tpl->tpl_vars['VIEW']->value;
        ?>
" /><input type="hidden" id="pageStartRange" value="<?php 
        echo $_smarty_tpl->tpl_vars['PAGING_MODEL']->value->getRecordStartRange();
        ?>
" /><input type="hidden" id="pageEndRange" value="<?php 
        echo $_smarty_tpl->tpl_vars['PAGING_MODEL']->value->getRecordEndRange();
        ?>
" /><input type="hidden" id="previousPageExist" value="<?php 
        echo $_smarty_tpl->tpl_vars['PAGING_MODEL']->value->isPrevPageExists();
        ?>
" /><input type="hidden" id="nextPageExist" value="<?php 
        echo $_smarty_tpl->tpl_vars['PAGING_MODEL']->value->isNextPageExists();
        ?>
" /><input type="hidden" id="alphabetSearchKey" value= "<?php 
        echo $_smarty_tpl->tpl_vars['MODULE_MODEL']->value->getAlphabetSearchField();
        ?>
" /><input type="hidden" id="Operator" value="<?php 
        echo $_smarty_tpl->tpl_vars['OPERATOR']->value;
        ?>
" /><input type="hidden" id="alphabetValue" value="<?php 
        echo $_smarty_tpl->tpl_vars['ALPHABET_VALUE']->value;
        ?>
" /><input type="hidden" id="totalCount" value="<?php 
        echo $_smarty_tpl->tpl_vars['LISTVIEW_COUNT']->value;
        ?>
" /><input type='hidden' value="<?php 
        echo $_smarty_tpl->tpl_vars['PAGE_NUMBER']->value;
        ?>
" id='pageNumber'><input type='hidden' value="<?php 
        echo $_smarty_tpl->tpl_vars['PAGING_MODEL']->value->getPageLimit();
        ?>
" id='pageLimit'><input type="hidden" value="<?php 
        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRIES_COUNT']->value;
        ?>
" id="noOfEntries"><?php 
        $_smarty_tpl->tpl_vars['ALPHABETS_LABEL'] = new Smarty_variable(vtranslate('LBL_ALPHABETS', 'Vtiger'), null, 0);
        $_smarty_tpl->tpl_vars['ALPHABETS'] = new Smarty_variable(explode(',', $_smarty_tpl->tpl_vars['ALPHABETS_LABEL']->value), null, 0);
        ?>
<div class="alphabetSorting noprint"><table width="100%" class="table-bordered" style="border: 1px solid #ddd;table-layout: fixed"><tbody><tr><?php 
        $_smarty_tpl->tpl_vars['ALPHABET'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['ALPHABET']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['ALPHABETS']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        foreach ($_from as $_smarty_tpl->tpl_vars['ALPHABET']->key => $_smarty_tpl->tpl_vars['ALPHABET']->value) {
            $_smarty_tpl->tpl_vars['ALPHABET']->_loop = true;
            ?>
<td class="alphabetSearch textAlignCenter cursorPointer <?php 
            if ($_smarty_tpl->tpl_vars['ALPHABET_VALUE']->value == $_smarty_tpl->tpl_vars['ALPHABET']->value) {
                ?>
 highlightBackgroundColor <?php 
            }
            ?>
" style="padding : 0px !important"><a id="<?php 
            echo $_smarty_tpl->tpl_vars['ALPHABET']->value;
            ?>
" href="#"><?php 
            echo $_smarty_tpl->tpl_vars['ALPHABET']->value;
            ?>
</a></td><?php 
        }
        ?>
</tr></tbody></table></div><div id="selectAllMsgDiv" class="alert-block msgDiv noprint"><strong><a id="selectAllMsg"><?php 
        echo vtranslate('LBL_SELECT_ALL', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
&nbsp;<?php 
        echo vtranslate($_smarty_tpl->tpl_vars['MODULE']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
&nbsp;(<span id="totalRecordsCount"></span>)</a></strong></div><div id="deSelectAllMsgDiv" class="alert-block msgDiv noprint"><strong><a id="deSelectAllMsg"><?php 
        echo vtranslate('LBL_DESELECT_ALL_RECORDS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
</a></strong></div><div class="contents-topscroll noprint"><div class="topscroll-div">&nbsp;</div></div><div class="listViewEntriesDiv contents-bottomscroll"><div class="bottomscroll-div"><input type="hidden" value="<?php 
        echo $_smarty_tpl->tpl_vars['ORDER_BY']->value;
        ?>
" id="orderBy"><input type="hidden" value="<?php 
        echo $_smarty_tpl->tpl_vars['SORT_ORDER']->value;
        ?>
" id="sortOrder"><span class="listViewLoadingImageBlock hide modal noprint" id="loadingListViewModal"><img class="listViewLoadingImage" src="<?php 
        echo vimage_path('loading.gif');
        ?>
" alt="no-image" title="<?php 
        echo vtranslate('LBL_LOADING', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
"/><p class="listViewLoadingMsg"><?php 
        echo vtranslate('LBL_LOADING_LISTVIEW_CONTENTS', $_smarty_tpl->tpl_vars['MODULE']->value);
        ?>
........</p></span><?php 
        $_smarty_tpl->tpl_vars['WIDTHTYPE'] = new Smarty_variable($_smarty_tpl->tpl_vars['CURRENT_USER_MODEL']->value->get('rowheight'), null, 0);
        ?>
<table class="table table-bordered listViewEntriesTable"><thead><tr class="listViewHeaders"><th width="5%"><input type="checkbox" id="listViewEntriesMainCheckBox" /></th><?php 
        $_smarty_tpl->tpl_vars['LISTVIEW_HEADER'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['LISTVIEW_HEADERS']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->total = $_smarty_tpl->_count($_from);
        $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration = 0;
        foreach ($_from as $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->key => $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value) {
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->_loop = true;
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration++;
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->last = $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration === $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->total;
            ?>
<th nowrap <?php 
            if ($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->last) {
                ?>
 colspan="2" <?php 
            }
            ?>
><a href="javascript:void(0);" class="listViewHeaderValues" data-nextsortorderval="<?php 
            if ($_smarty_tpl->tpl_vars['COLUMN_NAME']->value == $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('column')) {
                echo $_smarty_tpl->tpl_vars['NEXT_SORT_ORDER']->value;
            } else {
                ?>
ASC<?php 
            }
            ?>
" data-columnname="<?php 
            echo $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('column');
            ?>
"><?php 
            echo vtranslate($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('label'), $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
&nbsp;&nbsp;<?php 
            if ($_smarty_tpl->tpl_vars['COLUMN_NAME']->value == $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('column')) {
                ?>
<img class="<?php 
                echo $_smarty_tpl->tpl_vars['SORT_IMAGE']->value;
                ?>
 icon-white"><?php 
            }
            ?>
</a></th><?php 
        }
        ?>
</tr></thead><?php 
        if ($_smarty_tpl->tpl_vars['MODULE_MODEL']->value->isQuickSearchEnabled()) {
            ?>
<tr><td></td><?php 
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->_loop = false;
            $_from = $_smarty_tpl->tpl_vars['LISTVIEW_HEADERS']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->total = $_smarty_tpl->_count($_from);
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration = 0;
            foreach ($_from as $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->key => $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value) {
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->_loop = true;
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration++;
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->last = $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration === $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->total;
                ?>
<td><?php 
                $_smarty_tpl->tpl_vars['FIELD_UI_TYPE_MODEL'] = new Smarty_variable($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->getUITypeModel(), null, 0);
                echo $_smarty_tpl->getSubTemplate(vtemplate_path($_smarty_tpl->tpl_vars['FIELD_UI_TYPE_MODEL']->value->getListSearchTemplateName(), $_smarty_tpl->tpl_vars['MODULE_NAME']->value), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array('FIELD_MODEL' => $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value, 'SEARCH_INFO' => $_smarty_tpl->tpl_vars['SEARCH_DETAILS']->value[$_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->getName()], 'USER_MODEL' => $_smarty_tpl->tpl_vars['CURRENT_USER_MODEL']->value), 0);
                ?>
</td><?php 
            }
            ?>
<td><button class="btn" data-trigger="listSearch"><?php 
            echo vtranslate('LBL_SEARCH', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</button></td></tr><?php 
        }
        $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY'] = new Smarty_Variable();
        $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->_loop = false;
        $_from = $_smarty_tpl->tpl_vars['LISTVIEW_ENTRIES']->value;
        if (!is_array($_from) && !is_object($_from)) {
            settype($_from, 'array');
        }
        $_smarty_tpl->tpl_vars['smarty']->value['foreach']['listview']['index'] = -1;
        foreach ($_from as $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->key => $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value) {
            $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->_loop = true;
            $_smarty_tpl->tpl_vars['smarty']->value['foreach']['listview']['index']++;
            ?>
<tr class="listViewEntries" data-id='<?php 
            echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->getId();
            ?>
' data-recordUrl='<?php 
            echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->getDetailViewUrl();
            ?>
' id="<?php 
            echo $_smarty_tpl->tpl_vars['MODULE']->value;
            ?>
_listView_row_<?php 
            echo $_smarty_tpl->getVariable('smarty')->value['foreach']['listview']['index'] + 1;
            ?>
"><td  width="5%" class="<?php 
            echo $_smarty_tpl->tpl_vars['WIDTHTYPE']->value;
            ?>
"><input type="checkbox" value="<?php 
            echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->getId();
            ?>
" class="listViewEntriesCheckBox"/></td><?php 
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->_loop = false;
            $_from = $_smarty_tpl->tpl_vars['LISTVIEW_HEADERS']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->total = $_smarty_tpl->_count($_from);
            $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration = 0;
            foreach ($_from as $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->key => $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value) {
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->_loop = true;
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration++;
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->last = $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->iteration === $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->total;
                $_smarty_tpl->tpl_vars['LISTVIEW_HEADERNAME'] = new Smarty_variable($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('name'), null, 0);
                ?>
<td class="listViewEntryValue <?php 
                echo $_smarty_tpl->tpl_vars['WIDTHTYPE']->value;
                ?>
" data-field-type="<?php 
                echo $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->getFieldDataType();
                ?>
" nowrap><?php 
                if (($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->isNameField() == true || $_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('uitype') == '4') && $_smarty_tpl->tpl_vars['MODULE_MODEL']->value->isListViewNameFieldNavigationEnabled() == true) {
                    ?>
<a href="<?php 
                    echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->getDetailViewUrl();
                    ?>
"><?php 
                    echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get($_smarty_tpl->tpl_vars['LISTVIEW_HEADERNAME']->value);
                    ?>
</a><?php 
                } elseif ($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->get('uitype') == '72') {
                    ob_start();
                    echo $_smarty_tpl->tpl_vars['CURRENT_USER_MODEL']->value->get('currency_symbol_placement');
                    $_tmp1 = ob_get_clean();
                    $_smarty_tpl->tpl_vars['CURRENCY_SYMBOL_PLACEMENT'] = new Smarty_variable($_tmp1, null, 0);
                    if ($_smarty_tpl->tpl_vars['CURRENCY_SYMBOL_PLACEMENT']->value == '1.0$') {
                        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get($_smarty_tpl->tpl_vars['LISTVIEW_HEADERNAME']->value);
                        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get('currencySymbol');
                    } else {
                        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get('currencySymbol');
                        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get($_smarty_tpl->tpl_vars['LISTVIEW_HEADERNAME']->value);
                    }
                } else {
                    if ($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->value->getFieldDataType() == 'double') {
                        echo decimalFormat($_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get($_smarty_tpl->tpl_vars['LISTVIEW_HEADERNAME']->value));
                    } else {
                        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->get($_smarty_tpl->tpl_vars['LISTVIEW_HEADERNAME']->value);
                    }
                }
                if ($_smarty_tpl->tpl_vars['LISTVIEW_HEADER']->last) {
                    ?>
</td><td nowrap class="<?php 
                    echo $_smarty_tpl->tpl_vars['WIDTHTYPE']->value;
                    ?>
"><div class="actions pull-right"><span class="actionImages"><a href="<?php 
                    echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->getFullDetailViewUrl();
                    ?>
"><i title="<?php 
                    echo vtranslate('LBL_SHOW_COMPLETE_DETAILS', $_smarty_tpl->tpl_vars['MODULE']->value);
                    ?>
" class="icon-th-list alignMiddle"></i></a>&nbsp;<?php 
                    if ($_smarty_tpl->tpl_vars['IS_MODULE_EDITABLE']->value) {
                        ?>
<a href='<?php 
                        echo $_smarty_tpl->tpl_vars['LISTVIEW_ENTRY']->value->getEditViewUrl();
                        ?>
'><i title="<?php 
                        echo vtranslate('LBL_EDIT', $_smarty_tpl->tpl_vars['MODULE']->value);
                        ?>
" class="icon-pencil alignMiddle"></i></a>&nbsp;<?php 
                    }
                    if ($_smarty_tpl->tpl_vars['IS_MODULE_DELETABLE']->value) {
                        ?>
<a class="deleteRecordButton"><i title="<?php 
                        echo vtranslate('LBL_DELETE', $_smarty_tpl->tpl_vars['MODULE']->value);
                        ?>
" class="icon-trash alignMiddle"></i></a><?php 
                    }
                    ?>
</span></div></td><?php 
                }
                ?>
</td><?php 
            }
            ?>
</tr><?php 
        }
        ?>
</table><!--added this div for Temporarily --><?php 
        if ($_smarty_tpl->tpl_vars['LISTVIEW_ENTRIES_COUNT']->value == '0') {
            ?>
<table class="emptyRecordsDiv"><tbody><tr><td><?php 
            $_smarty_tpl->tpl_vars['SINGLE_MODULE'] = new Smarty_variable("SINGLE_" . $_smarty_tpl->tpl_vars['MODULE']->value, null, 0);
            echo vtranslate('LBL_EQ_ZERO');
            ?>
 <?php 
            echo vtranslate($_smarty_tpl->tpl_vars['MODULE']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
 <?php 
            echo vtranslate('LBL_FOUND');
            ?>
.<?php 
            if ($_smarty_tpl->tpl_vars['IS_MODULE_EDITABLE']->value) {
                ?>
 <?php 
                echo vtranslate('LBL_CREATE');
                ?>
 <a href="<?php 
                echo $_smarty_tpl->tpl_vars['MODULE_MODEL']->value->getCreateRecordUrl();
                ?>
"><?php 
                echo vtranslate($_smarty_tpl->tpl_vars['SINGLE_MODULE']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</a><?php 
            }
            ?>
</td></tr></tbody></table><?php 
        }
        ?>
</div></div>
<?php 
    }
Example #5
0
 public function getPDFMakerFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
 {
     global $current_user, $default_charset;
     $db = PearDatabase::getInstance();
     $value = $valueArray[$fieldName];
     $fld_type = $dbField->type;
     list($module, $fieldLabel) = explode('_', $dbField->name, 2);
     $fieldInfo = $this->getFieldByPDFMakerLabel($module, $fieldLabel);
     $fieldType = null;
     $fieldvalue = $value;
     if (!empty($fieldInfo)) {
         $field = WebserviceField::fromArray($db, $fieldInfo);
         $fieldType = $field->getFieldDataType();
     }
     if ($fieldType == 'currency' && $value != '') {
         // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
         if ($field->getUIType() == '72') {
             $curid_value = explode("::", $value);
             $currency_id = $curid_value[0];
             $currency_value = $curid_value[1];
             $cur_sym_rate = getCurrencySymbolandCRate($currency_id);
             if ($value != '') {
                 if ($dbField->name == 'Products_Unit_Price') {
                     // need to do this only for Products Unit Price
                     if ($currency_id != 1) {
                         $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
                     }
                 }
                 $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
                 $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
             }
         } else {
             $currencyField = new CurrencyField($value);
             $fieldvalue = $currencyField->getDisplayValue();
         }
     } elseif ($dbField->name == "PurchaseOrder_Currency" || $dbField->name == "SalesOrder_Currency" || $dbField->name == "Invoice_Currency" || $dbField->name == "Quotes_Currency" || $dbField->name == "PriceBooks_Currency") {
         if ($value != '') {
             $fieldvalue = getTranslatedCurrencyString($value);
         }
     } elseif (in_array($dbField->name, $this->ui101_fields) && !empty($value)) {
         $entityNames = getEntityName('Users', $value);
         $fieldvalue = $entityNames[$value];
     } elseif ($fieldType == 'date' && !empty($value)) {
         if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
             $endTime = $valueArray['calendar_end_time'];
             if (empty($endTime)) {
                 $recordId = $valueArray['calendar_id'];
                 $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
             }
             $date = new DateTimeField($value . ' ' . $endTime);
             $fieldvalue = $date->getDisplayDate();
         } else {
             $fieldvalue = DateTimeField::convertToUserFormat($value);
         }
     } elseif ($fieldType == "datetime" && !empty($value)) {
         $date = new DateTimeField($value);
         $fieldvalue = $date->getDisplayDateTimeValue();
     } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
         if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
             $date = new DateTimeField($value);
             $fieldvalue = $date->getDisplayTime();
         } else {
             $fieldvalue = $value;
         }
     } elseif ($fieldType == "picklist" && !empty($value)) {
         if (is_array($picklistArray)) {
             if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
                 $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
             } else {
                 $fieldvalue = $this->getTranslatedString($value, $module);
             }
         } else {
             $fieldvalue = $this->getTranslatedString($value, $module);
         }
     } elseif ($fieldType == "multipicklist" && !empty($value)) {
         if (is_array($picklistArray[1])) {
             $valueList = explode(' |##| ', $value);
             $translatedValueList = array();
             foreach ($valueList as $value) {
                 if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
                     $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
                 } else {
                     $translatedValueList[] = $this->getTranslatedString($value, $module);
                 }
             }
         }
         if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
             $fieldvalue = str_replace(' |##| ', ', ', $value);
         } else {
             implode(', ', $translatedValueList);
         }
     } elseif ($fieldType == 'double') {
         if ($current_user->truncate_trailing_zeros == true) {
             $fieldvalue = decimalFormat($fieldvalue);
         }
     }
     if ($fieldvalue == "") {
         return "-";
     }
     $fieldvalue = str_replace("<", "&lt;", $fieldvalue);
     $fieldvalue = str_replace(">", "&gt;", $fieldvalue);
     $fieldvalue = decode_html($fieldvalue);
     if (stristr($fieldvalue, "|##|") && empty($fieldType)) {
         $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue);
     } elseif ($fld_type == "date" && empty($fieldType)) {
         $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue);
     } elseif ($fld_type == "datetime" && empty($fieldType)) {
         $date = new DateTimeField($fieldvalue);
         $fieldvalue = $date->getDisplayDateTimeValue();
     }
     // Added to render html tag for description fields
     if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) {
         return $fieldvalue;
     }
     return htmlentities($fieldvalue, ENT_QUOTES, $default_charset);
 }
Example #6
0
 /**
  * this function takes in an array of values for an user and sanitizes it for export
  * @param array $arr - the array of values
  */
 function sanitizeValues($arr)
 {
     global $current_user, $adb;
     $roleid = fetchUserRole($current_user->id);
     foreach ($arr as $fieldlabel => &$value) {
         $fieldInfo = $this->fieldsArr[$fieldlabel];
         $uitype = $fieldInfo['uitype'];
         $fieldname = $fieldInfo['fieldname'];
         if ($uitype == 15 || $uitype == 16 || $uitype == 33) {
             //picklists
             if (empty($this->picklistValues[$fieldname])) {
                 $this->picklistValues[$fieldname] = getAssignedPicklistValues($fieldname, $roleid, $adb);
             }
             $value = trim($value);
         } elseif ($uitype == 10) {
             //have to handle uitype 10
             $value = trim($value);
             if (!empty($value)) {
                 $parent_module = getSalesEntityType($value);
                 $displayValueArray = getEntityName($parent_module, $value);
                 if (!empty($displayValueArray)) {
                     foreach ($displayValueArray as $k => $v) {
                         $displayValue = $v;
                     }
                 }
                 if (!empty($parent_module) && !empty($displayValue)) {
                     $value = $parent_module . "::::" . $displayValue;
                 } else {
                     $value = "";
                 }
             } else {
                 $value = '';
             }
         } elseif ($uitype == 71) {
             $value = CurrencyField::convertToUserFormat($value);
         } elseif ($uitype == 72) {
             $value = CurrencyField::convertToUserFormat($value, null, true, true);
         } elseif ($uitype == 7 && $fieldInfo['typeofdata'] == 'N~O' || $uitype == 9) {
             $value = decimalFormat($value);
         }
     }
     return $arr;
 }
 function calculateProgress()
 {
     $updateCols = array();
     $updateParams = array();
     $startDate = $this->column_fields['start_date'];
     $dueDate = $this->column_fields['due_date'];
     $endDate = $this->column_fields['end_date'];
     $usedUnits = decimalFormat($this->column_fields['used_units']);
     $totalUnits = decimalFormat($this->column_fields['total_units']);
     $contractStatus = $this->column_fields['contract_status'];
     // Update the End date if the status is Complete or if the Used Units reaches/exceeds Total Units
     // We need to do this first to make sure Actual duration is computed properly
     if ($contractStatus == 'Complete' || !empty($usedUnits) && !empty($totalUnits) && $usedUnits >= $totalUnits) {
         if (empty($endDate)) {
             $endDate = date('Y-m-d');
             $this->db->pquery('UPDATE vtiger_servicecontracts SET end_date=? WHERE servicecontractsid = ?', array(date('Y-m-d'), $this->id));
         }
     } else {
         $endDate = null;
         $this->db->pquery('UPDATE vtiger_servicecontracts SET end_date=? WHERE servicecontractsid = ?', array(null, $this->id));
     }
     // Calculate the Planned Duration based on Due date and Start date. (in days)
     if (!empty($dueDate) && !empty($startDate)) {
         $plannedDurationUpdate = " planned_duration = (TO_DAYS(due_date)-TO_DAYS(start_date)+1)";
     } else {
         $plannedDurationUpdate = " planned_duration = ''";
     }
     array_push($updateCols, $plannedDurationUpdate);
     // Calculate the Actual Duration based on End date and Start date. (in days)
     if (!empty($endDate) && !empty($startDate)) {
         $actualDurationUpdate = "actual_duration = (TO_DAYS(end_date)-TO_DAYS(start_date)+1)";
     } else {
         $actualDurationUpdate = "actual_duration = ''";
     }
     array_push($updateCols, $actualDurationUpdate);
     // Update the Progress based on Used Units and Total Units (in percentage)
     if (!empty($usedUnits) && !empty($totalUnits)) {
         $progressUpdate = 'progress = ?';
         $progressUpdateParams = floatval($usedUnits * 100 / $totalUnits);
     } else {
         $progressUpdate = 'progress = ?';
         $progressUpdateParams = null;
     }
     array_push($updateCols, $progressUpdate);
     array_push($updateParams, $progressUpdateParams);
     if (count($updateCols) > 0) {
         $updateQuery = 'UPDATE vtiger_servicecontracts SET ' . implode(",", $updateCols) . ' WHERE servicecontractsid = ?';
         array_push($updateParams, $this->id);
         $this->db->pquery($updateQuery, $updateParams);
     }
 }
/** 	function to get the product's taxpercentage
 * 	@param string $type       - tax type (VAT or Sales or Service)
 * 	@param id  $productid     - productid to which we want the tax percentage
 * 	@param id  $default       - if 'default' then first look for product's tax percentage and product's tax is empty then it will return the default configured tax percentage, else it will return the product's tax (not look for default value)
 * 	return int $taxpercentage - taxpercentage corresponding to the Tax type from vtiger_inventorytaxinfo vtiger_table
 */
function getProductTaxPercentage($type, $productid, $default = '')
{
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    $current_user = vglobal('current_user');
    $log->debug("Entering into getProductTaxPercentage({$type},{$productid}) function.");
    $taxpercentage = '';
    $res = $adb->pquery("SELECT taxpercentage\n\t\t\tFROM vtiger_inventorytaxinfo\n\t\t\tINNER JOIN vtiger_producttaxrel\n\t\t\t\tON vtiger_inventorytaxinfo.taxid = vtiger_producttaxrel.taxid\n\t\t\tWHERE vtiger_producttaxrel.productid = ?\n\t\t\tAND vtiger_inventorytaxinfo.taxname = ?", array($productid, $type));
    $taxpercentage = $adb->query_result($res, 0, 'taxpercentage');
    //This is to retrive the default configured value if the taxpercentage related to product is empty
    if ($taxpercentage == '' && $default == 'default') {
        $taxpercentage = getTaxPercentage($type);
    }
    $log->debug("Exiting from getProductTaxPercentage({$productid},{$type}) function. return value={$taxpercentage}");
    if ($current_user->truncate_trailing_zeros == true) {
        return decimalFormat($taxpercentage);
    } else {
        return $taxpercentage;
    }
}
Example #9
0
/**
 *
 * @global Users $current_user
 * @param ReportRun $report
 * @param Array $picklistArray
 * @param ADOFieldObject $dbField
 * @param Array $valueArray
 * @param String $fieldName
 * @return String
 */
function getReportFieldValue($report, $picklistArray, $dbField, $valueArray, $fieldName)
{
    global $current_user, $default_charset;
    $db = PearDatabase::getInstance();
    $value = $valueArray[$fieldName];
    $fld_type = $dbField->type;
    list($module, $fieldLabel) = explode('__', $dbField->name, 2);
    $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
    $fieldType = null;
    $fieldvalue = $value;
    if (!empty($fieldInfo)) {
        $field = WebserviceField::fromArray($db, $fieldInfo);
        $fieldType = $field->getFieldDataType();
    }
    if ($fieldType == 'currency' && $value != '') {
        // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
        if ($field->getUIType() == '72') {
            $curid_value = explode("::", $value);
            $currency_id = $curid_value[0];
            $currency_value = $curid_value[1];
            $cur_sym_rate = getCurrencySymbolandCRate($currency_id);
            if ($value != '') {
                if ($dbField->name == 'Products_Unit_Price') {
                    // need to do this only for Products Unit Price
                    if ($currency_id != 1) {
                        $currency_value = (double) $cur_sym_rate['rate'] * (double) $currency_value;
                    }
                }
                $formattedCurrencyValue = CurrencyField::convertToUserFormat($currency_value, null, true);
                $fieldvalue = CurrencyField::appendCurrencySymbol($formattedCurrencyValue, $cur_sym_rate['symbol']);
            }
        } else {
            $currencyField = new CurrencyField($value);
            $fieldvalue = $currencyField->getDisplayValue();
        }
    } elseif ($dbField->name == "PriceBooks_Currency") {
        if ($value != '') {
            $fieldvalue = getTranslatedCurrencyString($value);
        }
    } elseif (in_array($dbField->name, $report->ui101_fields) && !empty($value)) {
        $entityNames = getEntityName('Users', $value);
        $fieldvalue = $entityNames[$value];
    } elseif ($fieldType == 'date' && !empty($value)) {
        if ($module == 'Calendar' && $field->getFieldName() == 'due_date') {
            $endTime = $valueArray['calendar_end_time'];
            if (empty($endTime)) {
                $recordId = $valueArray['calendar_id'];
                $endTime = getSingleFieldValue('vtiger_activity', 'time_end', 'activityid', $recordId);
            }
            $date = new DateTimeField($value . ' ' . $endTime);
            $fieldvalue = $date->getDisplayDate();
        } else {
            if (!($field->getUIType() == '5')) {
                $date = new DateTimeField($fieldvalue);
                $fieldvalue = $date->getDisplayDateTimeValue();
            }
        }
    } elseif ($fieldType == "datetime" && !empty($value)) {
        $date = new DateTimeField($value);
        $fieldvalue = $date->getDisplayDateTimeValue();
    } elseif ($fieldType == 'time' && !empty($value) && $field->getFieldName() != 'duration_hours') {
        if ($field->getFieldName() == "time_start" || $field->getFieldName() == "time_end") {
            $date = new DateTimeField($value);
            $fieldvalue = $date->getDisplayTime();
        } else {
            $userModel = Users_Privileges_Model::getCurrentUserModel();
            if ($userModel->get('hour_format') == '12') {
                $value = Vtiger_Time_UIType::getTimeValueInAMorPM($value);
            }
            $fieldvalue = $value;
        }
    } elseif ($fieldType == "picklist" && !empty($value)) {
        if (is_array($picklistArray)) {
            if (is_array($picklistArray[$dbField->name]) && $field->getFieldName() != 'activitytype' && !in_array($value, $picklistArray[$dbField->name])) {
                $fieldvalue = $app_strings['LBL_NOT_ACCESSIBLE'];
            } else {
                $fieldvalue = getTranslatedString($value, $module);
            }
        } else {
            $fieldvalue = getTranslatedString($value, $module);
        }
    } elseif ($fieldType == "multipicklist" && !empty($value)) {
        if (is_array($picklistArray[1])) {
            $valueList = explode(' |##| ', $value);
            $translatedValueList = array();
            foreach ($valueList as $value) {
                if (is_array($picklistArray[1][$dbField->name]) && !in_array($value, $picklistArray[1][$dbField->name])) {
                    $translatedValueList[] = $app_strings['LBL_NOT_ACCESSIBLE'];
                } else {
                    $translatedValueList[] = getTranslatedString($value, $module);
                }
            }
        }
        if (!is_array($picklistArray[1]) || !is_array($picklistArray[1][$dbField->name])) {
            $fieldvalue = str_replace(' |##| ', ', ', $value);
        } else {
            implode(', ', $translatedValueList);
        }
    } elseif ($fieldType == 'double') {
        if ($current_user->truncate_trailing_zeros == true) {
            $fieldvalue = decimalFormat($fieldvalue);
        }
    } elseif ($fieldType == 'boolean') {
        if (strtolower($value) === 'yes' || strtolower($value) === 'on' || $value == 1) {
            $fieldvalue = vtranslate('LBL_YES');
        } else {
            $fieldvalue = vtranslate('LBL_NO');
        }
    } elseif ($field && $field->getUIType() == 117 && $value != '') {
        if ($value != '0') {
            $currencyList = Settings_Currency_Record_Model::getAll();
            $fieldvalue = $currencyList[$value]->getName() . ' (' . $currencyList[$value]->get('currency_symbol') . ')';
        } else {
            $fieldvalue = '-';
        }
    }
    if ('vtiger_crmentity' == $dbField->table && false != strpos($dbField->name, 'Share__with__users')) {
        if ($value) {
            $listId = explode(',', $value);
            $usersSqlFullName = getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users');
            $getListUserSql = "select {$usersSqlFullName} as uname from vtiger_users WHERE id IN (" . generateQuestionMarks($listId) . ') ';
            $getListUserResult = $db->pquery($getListUserSql, array($listId), TRUE);
            $fieldvalue = '';
            $finalList = array();
            $listUsers = $getListUserResult->GetAll();
            for ($i = 0; $i < count($listUsers); $i++) {
                $finalList[] = $listUsers[$i][0];
            }
            $fieldvalue = implode(', ', $finalList);
        }
    }
    if ($fieldvalue == "") {
        return "-";
    }
    $fieldvalue = str_replace("<", "&lt;", $fieldvalue);
    $fieldvalue = str_replace(">", "&gt;", $fieldvalue);
    $fieldvalue = decode_html($fieldvalue);
    if (stristr($fieldvalue, "|##|") && empty($fieldType)) {
        $fieldvalue = str_ireplace(' |##| ', ', ', $fieldvalue);
    } elseif ($fld_type == "date" && empty($fieldType)) {
        $fieldvalue = DateTimeField::convertToUserFormat($fieldvalue);
    } elseif ($fld_type == "datetime" && empty($fieldType)) {
        $date = new DateTimeField($fieldvalue);
        $fieldvalue = $date->getDisplayDateTimeValue();
    }
    // Added to render html tag for description fields
    if ($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) {
        return $fieldvalue;
    }
    return htmlentities($fieldvalue, ENT_QUOTES, $default_charset);
}
Example #10
0
 function getAssociatedProducts($module, $focus, $seid = '')
 {
     $adb = PearDatabase::getInstance();
     $current_user = vglobal('current_user');
     $log = vglobal('log');
     $theme = vglobal('theme');
     $log->debug("Entering OSSCosts_Record_Model getAssociatedProducts(" . $module . "," . get_class($focus) . "," . $seid . "='') method ...");
     $output = '';
     $no_of_decimal_places = getCurrencyDecimalPlaces();
     $theme_path = "themes/" . $theme . "/";
     $image_path = $theme_path . "images/";
     $product_Detail = array();
     if ($module == 'OSSCosts') {
         $query = "SELECT\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.productcode else vtiger_service.service_no end as productcode,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock,\n\t\t\t\t\t\tcase when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype,\n\t\t\t\t\t\t\t\t\tvtiger_inventoryproductrel.listprice,\n\t\t\t\t\t\t\t\t\tvtiger_inventoryproductrel.description AS product_description,\n\t\t\t\t\t\t\t\t\tvtiger_inventoryproductrel.*,vtiger_crmentity.deleted,\n\t\t\t\t\t\t\t\t\tvtiger_products.usageunit,\n\t\t\t\t\t\t\t\t\tvtiger_service.service_usageunit\n\t\t\t\t\t\t\t\t\tFROM vtiger_inventoryproductrel\n\t\t\t\t\t\t\t\t\tLEFT JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid\n\t\t\t\t\t\t\t\t\tLEFT JOIN vtiger_products\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_products.productid=vtiger_inventoryproductrel.productid\n\t\t\t\t\t\t\t\t\tLEFT JOIN vtiger_service\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_service.serviceid=vtiger_inventoryproductrel.productid\n\t\t\t\t\t\t\t\t\tWHERE id=?\n\t\t\t\t\t\t\t\t\tORDER BY sequence_no";
         $params = array($focus->id);
     } elseif ($module == 'Products') {
         $query = "SELECT\n\t\t\t\t\t\t\t\t\tvtiger_products.productid,\n\t\t\t\t\t\t\t\t\tvtiger_products.productcode,\n\t\t\t\t\t\t\t\t\tvtiger_products.productname,\n\t\t\t\t\t\t\t\t\tvtiger_products.unit_price,\n\t\t\t\t\t\t\t\t\tvtiger_products.usageunit,\n\t\t\t\t\t\t\t\t\tvtiger_products.qtyinstock,vtiger_crmentity.deleted,\n\t\t\t\t\t\t\t\t\tvtiger_crmentity.description AS product_description,\n\t\t\t\t\t\t\t\t\t'Products' AS entitytype\n\t\t\t\t\t\t\t\t\tFROM vtiger_products\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_crmentity.crmid=vtiger_products.productid\n\t\t\t\t\t\t\t\t\tWHERE vtiger_crmentity.deleted=0\n\t\t\t\t\t\t\t\t\t\t\tAND productid=?";
         $params = array($seid);
     } elseif ($module == 'Services') {
         $query = "SELECT\n\t\t\t\t\t\t\t\t\tvtiger_service.serviceid AS productid,\n\t\t\t\t\t\t\t\t\t'NA' AS productcode,\n\t\t\t\t\t\t\t\t\tvtiger_service.servicename AS productname,\n\t\t\t\t\t\t\t\t\tvtiger_service.unit_price AS unit_price,\n\t\t\t\t\t\t\t\t\tvtiger_service.service_usageunit AS usageunit,\n\t\t\t\t\t\t\t\t\t'NA' AS qtyinstock,vtiger_crmentity.deleted,\n\t\t\t\t\t\t\t\t\tvtiger_crmentity.description AS product_description,\n\t\t\t\t\t\t\t\t\t'Services' AS entitytype\n\t\t\t\t\t\t\t\t\tFROM vtiger_service\n\t\t\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity\n\t\t\t\t\t\t\t\t\t\t\tON vtiger_crmentity.crmid=vtiger_service.serviceid\n\t\t\t\t\t\t\t\t\tWHERE vtiger_crmentity.deleted=0\n\t\t\t\t\t\t\t\t\t\t\tAND serviceid=?";
         $params = array($seid);
     }
     $result = $adb->pquery($query, $params);
     $num_rows = $adb->num_rows($result);
     $finalTaxTotal = '0.00';
     for ($i = 1; $i <= $num_rows; $i++) {
         $deleted = $adb->query_result($result, $i - 1, 'deleted');
         $hdnProductId = $adb->query_result($result, $i - 1, 'productid');
         $hdnProductcode = $adb->query_result($result, $i - 1, 'productcode');
         $productname = $adb->query_result($result, $i - 1, 'productname');
         $productdescription = $adb->query_result($result, $i - 1, 'product_description');
         $comment = $adb->query_result($result, $i - 1, 'comment');
         $qtyinstock = $adb->query_result($result, $i - 1, 'qtyinstock');
         $qty = $adb->query_result($result, $i - 1, 'quantity');
         $unitprice = $adb->query_result($result, $i - 1, 'unit_price');
         $listprice = $adb->query_result($result, $i - 1, 'listprice');
         $entitytype = $adb->query_result($result, $i - 1, 'entitytype');
         if ($entitytype == 'Services') {
             $usageunit = vtranslate($adb->query_result($result, $i - 1, 'service_usageunit'), $entitytype);
         } else {
             $usageunit = vtranslate($adb->query_result($result, $i - 1, 'usageunit'), $entitytype);
         }
         $tax = $adb->query_result($result, $i - 1, 'tax');
         if ($deleted || !isset($deleted)) {
             $product_Detail[$i]['productDeleted' . $i] = true;
         } elseif (!$deleted) {
             $product_Detail[$i]['productDeleted' . $i] = false;
         }
         if (!empty($entitytype)) {
             $product_Detail[$i]['entityType' . $i] = $entitytype;
         }
         if ($listprice == '') {
             $listprice = $unitprice;
         }
         if ($qty == '') {
             $qty = 1;
         }
         //calculate productTotal
         $productTotal = $qty * $listprice;
         //Delete link in First column
         if ($i != 1) {
             $product_Detail[$i]['delRow' . $i] = "Del";
         }
         if (empty($focus->mode) && $seid != '') {
             $sub_prod_query = $adb->pquery("SELECT crmid as prod_id from vtiger_seproductsrel WHERE productid=? AND setype='Products'", array($seid));
         } else {
             $sub_prod_query = $adb->pquery("SELECT productid as prod_id from vtiger_inventorysubproductrel WHERE id=? AND sequence_no=?", array($focus->id, $i));
         }
         $subprodid_str = '';
         $subprodname_str = '';
         $subProductArray = array();
         if ($adb->num_rows($sub_prod_query) > 0) {
             for ($j = 0; $j < $adb->num_rows($sub_prod_query); $j++) {
                 $sprod_id = $adb->query_result($sub_prod_query, $j, 'prod_id');
                 $sprod_name = $subProductArray[] = getProductName($sprod_id);
                 $str_sep = "";
                 if ($j > 0) {
                     $str_sep = ":";
                 }
                 $subprodid_str .= $str_sep . $sprod_id;
                 $subprodname_str .= $str_sep . " - " . $sprod_name;
             }
         }
         $subprodname_str = str_replace(":", "<br>", $subprodname_str);
         $product_Detail[$i]['subProductArray' . $i] = $subProductArray;
         $product_Detail[$i]['hdnProductId' . $i] = $hdnProductId;
         $product_Detail[$i]['productName' . $i] = from_html($productname);
         /* Added to fix the issue Product Pop-up name display*/
         if ($_REQUEST['action'] == 'CreateSOPDF' || $_REQUEST['action'] == 'CreatePDF' || $_REQUEST['action'] == 'SendPDFMail') {
             $product_Detail[$i]['productName' . $i] = htmlspecialchars($product_Detail[$i]['productName' . $i]);
         }
         $product_Detail[$i]['hdnProductcode' . $i] = $hdnProductcode;
         $product_Detail[$i]['productDescription' . $i] = from_html($productdescription);
         if ($module == 'Potentials' || $module == 'Products' || $module == 'Services') {
             $product_Detail[$i]['comment' . $i] = $productdescription;
         } else {
             $product_Detail[$i]['comment' . $i] = $comment;
         }
         if ($module != 'PurchaseOrder' && $focus->object_name != 'Order') {
             $product_Detail[$i]['qtyInStock' . $i] = decimalFormat($qtyinstock);
         }
         $listprice = number_format($listprice, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['qty' . $i] = decimalFormat($qty);
         $product_Detail[$i]['listPrice' . $i] = $listprice;
         $product_Detail[$i]['unitPrice' . $i] = number_format($unitprice, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['usageUnit' . $i] = $usageunit;
         $product_Detail[$i]['productTotal' . $i] = $productTotal;
         $product_Detail[$i]['subproduct_ids' . $i] = $subprodid_str;
         $product_Detail[$i]['subprod_names' . $i] = $subprodname_str;
         $product_Detail[$i]['tax' . $i] = $tax;
         $discount_percent = decimalFormat($adb->query_result($result, $i - 1, 'discount_percent'));
         $discount_amount = $adb->query_result($result, $i - 1, 'discount_amount');
         $discount_amount = decimalFormat(number_format($discount_amount, $no_of_decimal_places, '.', ''));
         $discountTotal = '0.00';
         //Based on the discount percent or amount we will show the discount details
         //To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(for Each Product)
         $product_Detail[$i]['discount_percent' . $i] = 0;
         $product_Detail[$i]['discount_amount' . $i] = 0;
         if ($discount_percent != 'NULL' && $discount_percent != '') {
             $product_Detail[$i]['discount_type' . $i] = "percentage";
             $product_Detail[$i]['discount_percent' . $i] = $discount_percent;
             $product_Detail[$i]['checked_discount_percent' . $i] = ' checked';
             $product_Detail[$i]['style_discount_percent' . $i] = ' style="visibility:visible"';
             $product_Detail[$i]['style_discount_amount' . $i] = ' style="visibility:hidden"';
             $discountTotal = $productTotal * $discount_percent / 100;
         } elseif ($discount_amount != 'NULL' && $discount_amount != '') {
             $product_Detail[$i]['discount_type' . $i] = "amount";
             $product_Detail[$i]['discount_amount' . $i] = $discount_amount;
             $product_Detail[$i]['checked_discount_amount' . $i] = ' checked';
             $product_Detail[$i]['style_discount_amount' . $i] = ' style="visibility:visible"';
             $product_Detail[$i]['style_discount_percent' . $i] = ' style="visibility:hidden"';
             $discountTotal = $discount_amount;
         } else {
             $product_Detail[$i]['checked_discount_zero' . $i] = ' checked';
         }
         $totalAfterDiscount = $productTotal - $discountTotal;
         $totalAfterDiscount = number_format($totalAfterDiscount, $no_of_decimal_places, '.', '');
         $discountTotal = number_format($discountTotal, $no_of_decimal_places, '.', '');
         $product_Detail[$i]['discountTotal' . $i] = $discountTotal;
         $product_Detail[$i]['totalAfterDiscount' . $i] = $totalAfterDiscount;
         $amount = '0.00';
         $tax_details = getTaxDetailsForProduct($hdnProductId, 'all');
         //First we should get all available taxes and then retrieve the corresponding tax values
         $allTaxes = getAllTaxes('available', '', 'edit', $focus->id);
         $taxtype = $this->getInventoryTaxType($module, $focus->id);
         for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
             $tax_name = $tax_details[$tax_count]['taxname'];
             $tax_label = $tax_details[$tax_count]['taxlabel'];
             $tax_value = '0.00';
             //condition to avoid this function call when create new PO/SO/Quotes/Invoice from Product module
             if ($focus->id != '') {
                 if ($taxtype == 'individual') {
                     //if individual then show the entered tax percentage
                     $tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
                 } else {
                     //if group tax then we have to show the default value when change to individual tax
                     $tax_value = $tax_details[$tax_count]['percentage'];
                 }
             } else {
                 //if the above function not called then assign the default associated value of the product
                 $tax_value = $tax_details[$tax_count]['percentage'];
             }
             $product_Detail[$i]['taxes'][$tax_count]['taxname'] = $tax_name;
             $product_Detail[$i]['taxes'][$tax_count]['taxlabel'] = $tax_label;
             $product_Detail[$i]['taxes'][$tax_count]['percentage'] = $tax_value;
             $amount = $totalAfterDiscount * $tax_value / 100;
             $amount = number_format($amount, $no_of_decimal_places, '.', '');
             $product_Detail[$i]['taxes'][$tax_count]['amount'] = $amount;
             if ($tax == $tax_name) {
                 $finalTaxTotal += $amount;
                 $product_Detail[$i]['taxTotal' . $i] = $amount;
             }
         }
         if ($taxtype == 'group') {
             foreach ($allTaxes as $key => $value) {
                 if ($tax == $value['taxname']) {
                     $amount = $totalAfterDiscount * $value['percentage'] / 100;
                     $amount = number_format($amount, $no_of_decimal_places, '.', '');
                     $product_Detail[$i]['taxes'][$tax]['amount'] = $amount;
                     $finalTaxTotal += $amount;
                     $product_Detail[$i]['taxTotal' . $i] = $amount;
                 }
             }
         }
         //Calculate netprice
         $netPrice = $totalAfterDiscount + number_format($product_Detail[$i]['taxTotal' . $i], $no_of_decimal_places, '.', '');
         //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
         $product_Detail[$i]['netPrice' . $i] = $netPrice;
     }
     //set the taxtype
     $product_Detail[1]['final_details']['taxtype'] = $taxtype;
     //Get the Final Discount, S&H charge, Tax for S&H  values
     //To set the Final Discount details
     $finalDiscount = '0.00';
     $product_Detail[1]['final_details']['discount_type_final'] = 'zero';
     $subTotal = $focus->column_fields['hdnSubTotal'] != '' ? $focus->column_fields['hdnSubTotal'] : '0.00';
     $subTotal = number_format($subTotal, $no_of_decimal_places, '.', '');
     $product_Detail[1]['final_details']['hdnSubTotal'] = $subTotal;
     $discountPercent = $focus->column_fields['hdnDiscountPercent'] != '' ? $focus->column_fields['hdnDiscountPercent'] : '0.00';
     $discountAmount = $focus->column_fields['hdnDiscountAmount'] != '' ? $focus->column_fields['hdnDiscountAmount'] : '0.00';
     if ($discountPercent != '0') {
         $discountAmount = $product_Detail[1]['final_details']['hdnSubTotal'] * $discountPercent / 100;
     }
     //To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(For Final Discount)
     $discount_amount_final = '0.00';
     $discount_amount_final = number_format($discount_amount_final, $no_of_decimal_places, '.', '');
     $product_Detail[1]['final_details']['discount_percentage_final'] = 0;
     $product_Detail[1]['final_details']['discount_amount_final'] = $discount_amount_final;
     if ($focus->column_fields['hdnDiscountPercent'] != '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 ($focus->column_fields['hdnDiscountAmount'] != '0' && $focus->column_fields['hdnDiscountAmount'] != '') {
         $finalDiscount = $focus->column_fields['hdnDiscountAmount'];
         $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"';
     }
     $finalDiscount = number_format($finalDiscount, $no_of_decimal_places, '.', '');
     $product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount;
     //To set the Final Tax values
     //we will get all taxes. if individual then show the product related taxes only else show all taxes
     //suppose user want to change individual to group or vice versa in edit time the we have to show all taxes. so that here we will store all the taxes and based on need we will show the corresponding taxes
     for ($tax_count = 0; $tax_count < count($allTaxes); $tax_count++) {
         $tax_name = $allTaxes[$tax_count]['taxname'];
         $tax_label = $allTaxes[$tax_count]['taxlabel'];
         //if taxtype is individual and want to change to group during edit time then we have to show the all available taxes and their default values
         //Also taxtype is group and want to change to individual during edit time then we have to provide the asspciated taxes and their default tax values for individual products
         if ($taxtype == 'group') {
             $tax_percent = $adb->query_result($result, 0, $tax_name);
         } else {
             $tax_percent = $allTaxes[$tax_count]['percentage'];
         }
         //$adb->query_result($result,0,$tax_name);
         if ($tax_percent == '' || $tax_percent == 'NULL') {
             $tax_percent = '0.00';
         }
         $taxamount = ($subTotal - $finalDiscount) * $tax_percent / 100;
         $taxamount = number_format($taxamount, $no_of_decimal_places, '.', '');
         $product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
         $product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
         $product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
         $product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
     }
     $product_Detail[1]['final_details']['tax_totalamount'] = $finalTaxTotal;
     $product_Detail[1]['final_details']['tax'] = $tax;
     //To set the grand total
     $grandTotal = $focus->column_fields['hdnGrandTotal'] != '' ? $focus->column_fields['hdnGrandTotal'] : '0.00';
     $grandTotal = number_format($grandTotal, $no_of_decimal_places, '.', '');
     $product_Detail[1]['final_details']['grandTotal'] = $grandTotal;
     $log->debug("Exiting OSSCosts_Record_Model getAssociatedProducts method ...");
     return $product_Detail;
 }
Example #11
0
 /**
  * Function to get the Display Value, for the current field type with given DB Insert Value
  * @param <Object> $value
  * @return <Object>
  */
 public function getDisplayValue($value)
 {
     return decimalFormat($value);
 }
Example #12
0
 /**
  * Function to get the Display Value, for the current field type with given DB Insert Value
  * @param <Object> $value
  * @return <Object>
  */
 public function getDisplayValue($value, $record = false, $recordInstance = false, $rawText = false)
 {
     return decimalFormat($value);
 }
Example #13
0
 /**
  * Function to get the Display Value, for the current field type with given DB Insert Value
  * @param <Object> $value
  * @return <Object>
  */
 public function getDisplayValue($value)
 {
     global $log;
     $log->debug("Entering ./uitypes/Double.php::getDisplayValue");
     return decimalFormat($value);
 }
/** This function returns the detailed list of vtiger_products associated to a 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 getAssociatedProducts($module, $focus, $seid = '')
{
    global $log;
    $log->debug("Entering getAssociatedProducts(" . $module . "," . get_class($focus) . "," . $seid . "='') method ...");
    global $adb;
    $output = '';
    global $theme, $current_user;
    $no_of_decimal_places = getCurrencyDecimalPlaces();
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $product_Detail = array();
    // DG 15 Aug 2006
    // Add "ORDER BY sequence_no" to retain add order on all inventoryproductrel items
    // SalesPlatform.ru begin Add Act and Consignment modules
    if ($module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice' || $module == 'Act' || $module == 'Consignment') {
        // SalesPlatform.ru begin
        $query = "SELECT \n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname,\n \t\t            case when vtiger_products.productid != '' then vtiger_products.productcode else vtiger_service.service_no end as productcode, \n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.usageunit else vtiger_service.service_usageunit end as usageunit,\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.unit_code else vtiger_service.unit_code end as unit_code,\n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price,\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.manuf_country else '--' end as manuf_country,\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.manuf_country_code else '--' end as manuf_country_code,\n\t\t\t\t\tcase when vtiger_products.productid != '' then vtiger_products.customs_id else '--' end as customs_id,\t\t\t\t\t\t\t\t\t\n \t\t            case when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock,\n \t\t            case when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype,\n \t\t                        vtiger_inventoryproductrel.listprice, \n \t\t                        vtiger_crmentity.description AS product_description, \n \t\t                        vtiger_inventoryproductrel.* , vtiger_crmentity.deleted\n                                    , attachments.attachment_id, attachments.attachment_name, attachments.attachment_path\n \t                            FROM vtiger_inventoryproductrel \n                                LEFT JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_inventoryproductrel.productid\n \t\t                        LEFT JOIN vtiger_products \n \t\t                                ON vtiger_products.productid=vtiger_inventoryproductrel.productid \n \t\t                        LEFT JOIN vtiger_service \n \t\t                                ON vtiger_service.serviceid=vtiger_inventoryproductrel.productid \n                                        LEFT JOIN (\n                                                    SELECT vtiger_attachments.attachmentsid AS attachment_id,\n                                                        vtiger_seattachmentsrel.crmid AS attachment_crmid, \n                                                        vtiger_attachments.name AS attachment_name, \n                                                        vtiger_attachments.path AS attachment_path \n                                                    FROM vtiger_seattachmentsrel, vtiger_attachments, vtiger_inventoryproductrel \n                                                    WHERE vtiger_seattachmentsrel.crmid=vtiger_inventoryproductrel.productid AND \n                                                        vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid \n                                                    GROUP BY attachment_crmid DESC\n                                                  ) attachments\n                                                ON attachments.attachment_crmid=vtiger_inventoryproductrel.productid                                                \n \t\t                        WHERE id=?\n \t\t                        ORDER BY sequence_no";
        /*		$query="SELECT 
            case when vtiger_products.productid != '' then vtiger_products.productname else vtiger_service.servicename end as productname,
            case when vtiger_products.productid != '' then vtiger_products.productcode else vtiger_service.service_no end as productcode, 
            case when vtiger_products.productid != '' then vtiger_products.usageunit else vtiger_service.service_usageunit end as usageunit,									
            case when vtiger_products.productid != '' then vtiger_products.unit_price else vtiger_service.unit_price end as unit_price,									
            case when vtiger_products.productid != '' then vtiger_products.qtyinstock else 'NA' end as qtyinstock,
            case when vtiger_products.productid != '' then 'Products' else 'Services' end as entitytype,
                        vtiger_inventoryproductrel.listprice, 
                        vtiger_inventoryproductrel.description AS product_description, 
                        vtiger_inventoryproductrel.* 
                        FROM vtiger_inventoryproductrel 
                        LEFT JOIN vtiger_products 
                                ON vtiger_products.productid=vtiger_inventoryproductrel.productid 
                        LEFT JOIN vtiger_service 
                                ON vtiger_service.serviceid=vtiger_inventoryproductrel.productid 
                        WHERE id=?
                        ORDER BY sequence_no"; */
        // SalesPlatform.ru end
        $params = array($focus->id);
    } elseif ($module == 'Potentials') {
        $query = "SELECT\n \t\t                        vtiger_products.productname,\n \t\t                        vtiger_products.productcode,\n \t\t                        vtiger_products.unit_price,\n \t\t                        vtiger_products.qtyinstock,\n \t\t                        vtiger_seproductsrel.*,vtiger_crmentity.deleted,\n \t\t                        vtiger_crmentity.description AS product_description\n \t\t                        FROM vtiger_products\n \t\t                        INNER JOIN vtiger_crmentity\n \t\t                                ON vtiger_crmentity.crmid=vtiger_products.productid\n \t\t                        INNER JOIN vtiger_seproductsrel\n \t\t                                ON vtiger_seproductsrel.productid=vtiger_products.productid\n \t\t                        WHERE vtiger_seproductsrel.crmid=?";
        $params = array($seid);
    } elseif ($module == 'Products') {
        $query = "SELECT\n \t\t                        vtiger_products.productid,\n \t\t                        vtiger_products.productcode,\n \t\t                        vtiger_products.productname,\n \t\t                        vtiger_products.unit_price,\n \t\t                        vtiger_products.qtyinstock,vtiger_crmentity.deleted,\n \t\t                        vtiger_crmentity.description AS product_description,\n \t\t                        'Products' AS entitytype\n \t\t                        FROM vtiger_products\n \t\t                        INNER JOIN vtiger_crmentity\n \t\t                                ON vtiger_crmentity.crmid=vtiger_products.productid\n \t\t                        WHERE vtiger_crmentity.deleted=0\n \t\t                                AND productid=?";
        $params = array($seid);
    } elseif ($module == 'Services') {
        $query = "SELECT\n \t\t                        vtiger_service.serviceid AS productid,\n \t\t                        'NA' AS productcode,\n \t\t                        vtiger_service.servicename AS productname,\n \t\t                        vtiger_service.unit_price AS unit_price,\n \t\t                        'NA' AS qtyinstock,vtiger_crmentity.deleted,\n \t\t                        vtiger_crmentity.description AS product_description,\n \t\t                       \t'Services' AS entitytype\n \t\t\t\t\t\t\t\tFROM vtiger_service\n \t\t                        INNER JOIN vtiger_crmentity\n \t\t                                ON vtiger_crmentity.crmid=vtiger_service.serviceid\n \t\t                        WHERE vtiger_crmentity.deleted=0\n \t\t                                AND serviceid=?";
        $params = array($seid);
    }
    $result = $adb->pquery($query, $params);
    $num_rows = $adb->num_rows($result);
    for ($i = 1; $i <= $num_rows; $i++) {
        $deleted = $adb->query_result($result, $i - 1, 'deleted');
        $hdnProductId = $adb->query_result($result, $i - 1, 'productid');
        $hdnProductcode = $adb->query_result($result, $i - 1, 'productcode');
        $productname = $adb->query_result($result, $i - 1, 'productname');
        $productdescription = $adb->query_result($result, $i - 1, 'product_description');
        $comment = $adb->query_result($result, $i - 1, 'comment');
        $qtyinstock = $adb->query_result($result, $i - 1, 'qtyinstock');
        $qty = $adb->query_result($result, $i - 1, 'quantity');
        $unitprice = $adb->query_result($result, $i - 1, 'unit_price');
        $listprice = $adb->query_result($result, $i - 1, 'listprice');
        $entitytype = $adb->query_result($result, $i - 1, 'entitytype');
        // SalesPlatform.ru begin
        if ($module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice' || $module == 'Act' || $module == 'Consignment') {
            $manuf_country = $adb->query_result($result, $i - 1, 'manuf_country');
            $customs_id = $adb->query_result($result, $i - 1, 'customs_id');
            $manuf_country_code = $adb->query_result($result, $i - 1, 'manuf_country_code');
            $unit_code = $adb->query_result($result, $i - 1, 'unit_code');
            $usageunit = $adb->query_result($result, $i - 1, 'usageunit');
            $attachment_id = $adb->query_result($result, $i - 1, 'attachment_id');
            $attachment_name = $adb->query_result($result, $i - 1, 'attachment_name');
            $attachment_path = $adb->query_result($result, $i - 1, 'attachment_path');
        }
        // SalesPlatform.ru end
        if ($deleted || !isset($deleted)) {
            $product_Detail[$i]['productDeleted' . $i] = true;
        } elseif (!$deleted) {
            $product_Detail[$i]['productDeleted' . $i] = false;
        }
        if (!empty($entitytype)) {
            $product_Detail[$i]['entityType' . $i] = $entitytype;
        }
        if ($listprice == '') {
            $listprice = $unitprice;
        }
        if ($qty == '') {
            $qty = 1;
        }
        //calculate productTotal
        $productTotal = $qty * $listprice;
        //Delete link in First column
        if ($i != 1) {
            $product_Detail[$i]['delRow' . $i] = "Del";
        }
        if (empty($focus->mode) && $seid != '') {
            $sub_prod_query = $adb->pquery("SELECT crmid as prod_id from vtiger_seproductsrel WHERE productid=? AND setype='Products'", array($seid));
        } else {
            $sub_prod_query = $adb->pquery("SELECT productid as prod_id from vtiger_inventorysubproductrel WHERE id=? AND sequence_no=?", array($focus->id, $i));
        }
        $subprodid_str = '';
        $subprodname_str = '';
        $subProductArray = array();
        if ($adb->num_rows($sub_prod_query) > 0) {
            for ($j = 0; $j < $adb->num_rows($sub_prod_query); $j++) {
                $sprod_id = $adb->query_result($sub_prod_query, $j, 'prod_id');
                $sprod_name = $subProductArray[] = getProductName($sprod_id);
                $str_sep = "";
                if ($j > 0) {
                    $str_sep = ":";
                }
                $subprodid_str .= $str_sep . $sprod_id;
                if (isset($sprod_name)) {
                    $subprodname_str .= $str_sep . " - " . $sprod_name;
                }
            }
        }
        $subprodname_str = str_replace(":", "<br>", $subprodname_str);
        $product_Detail[$i]['subProductArray' . $i] = $subProductArray;
        $product_Detail[$i]['hdnProductId' . $i] = $hdnProductId;
        $product_Detail[$i]['productName' . $i] = from_html($productname);
        /* Added to fix the issue Product Pop-up name display*/
        if ($_REQUEST['action'] == 'CreateSOPDF' || $_REQUEST['action'] == 'CreatePDF' || $_REQUEST['action'] == 'SendPDFMail') {
            $product_Detail[$i]['productName' . $i] = htmlspecialchars($product_Detail[$i]['productName' . $i]);
        }
        $product_Detail[$i]['hdnProductcode' . $i] = $hdnProductcode;
        $product_Detail[$i]['productDescription' . $i] = from_html($productdescription);
        if ($module == 'Potentials' || $module == 'Products' || $module == 'Services') {
            $product_Detail[$i]['comment' . $i] = $productdescription;
        } else {
            $product_Detail[$i]['comment' . $i] = $comment;
        }
        // SalesPlatform.ru begin Added acts and consignments
        if ($module != 'PurchaseOrder' && $focus->object_name != 'Order' && $module != 'Act' && $module != 'Consignment') {
            $product_Detail[$i]['qtyInStock' . $i] = decimalFormat($qtyinstock);
        }
        $listprice = number_format($listprice, $no_of_decimal_places, '.', '');
        $product_Detail[$i]['qty' . $i] = decimalFormat($qty);
        $product_Detail[$i]['listPrice' . $i] = $listprice;
        $product_Detail[$i]['unitPrice' . $i] = number_format($unitprice, $no_of_decimal_places, '.', '');
        $product_Detail[$i]['productTotal' . $i] = $productTotal;
        $product_Detail[$i]['subproduct_ids' . $i] = $subprodid_str;
        $product_Detail[$i]['subprod_names' . $i] = $subprodname_str;
        $discount_percent = decimalFormat($adb->query_result($result, $i - 1, 'discount_percent'));
        $discount_amount = $adb->query_result($result, $i - 1, 'discount_amount');
        $discount_amount = decimalFormat(number_format($discount_amount, $no_of_decimal_places, '.', ''));
        $discountTotal = '0';
        //Based on the discount percent or amount we will show the discount details
        //To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(for Each Product)
        $product_Detail[$i]['discount_percent' . $i] = 0;
        $product_Detail[$i]['discount_amount' . $i] = 0;
        if (!empty($discount_percent)) {
            $product_Detail[$i]['discount_type' . $i] = "percentage";
            $product_Detail[$i]['discount_percent' . $i] = $discount_percent;
            $product_Detail[$i]['checked_discount_percent' . $i] = ' checked';
            $product_Detail[$i]['style_discount_percent' . $i] = ' style="visibility:visible"';
            $product_Detail[$i]['style_discount_amount' . $i] = ' style="visibility:hidden"';
            $discountTotal = $productTotal * $discount_percent / 100;
        } elseif (!empty($discount_amount)) {
            $product_Detail[$i]['discount_type' . $i] = "amount";
            $product_Detail[$i]['discount_amount' . $i] = $discount_amount;
            $product_Detail[$i]['checked_discount_amount' . $i] = ' checked';
            $product_Detail[$i]['style_discount_amount' . $i] = ' style="visibility:visible"';
            $product_Detail[$i]['style_discount_percent' . $i] = ' style="visibility:hidden"';
            $discountTotal = $discount_amount;
        } else {
            $product_Detail[$i]['checked_discount_zero' . $i] = ' checked';
        }
        $totalAfterDiscount = $productTotal - $discountTotal;
        $totalAfterDiscount = number_format($totalAfterDiscount, $no_of_decimal_places, '.', '');
        $discountTotal = number_format($discountTotal, $no_of_decimal_places, '.', '');
        $product_Detail[$i]['discountTotal' . $i] = $discountTotal;
        $product_Detail[$i]['totalAfterDiscount' . $i] = $totalAfterDiscount;
        // SalesPlatform.ru begin
        if ($module == 'Quotes' || $module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Invoice' || $module == 'Act' || $module == 'Consignment') {
            $product_Detail[$i]['manufCountry' . $i] = $manuf_country;
            $product_Detail[$i]['customsId' . $i] = $customs_id;
            $product_Detail[$i]['manufCountryCode' . $i] = $manuf_country_code;
            $product_Detail[$i]['unitCode' . $i] = $unit_code;
            $product_Detail[$i]['usageunit' . $i] = $usageunit;
            $product_Detail[$i]['attachmentId' . $i] = $attachment_id;
            $product_Detail[$i]['attachmentName' . $i] = $attachment_name;
            $product_Detail[$i]['attachmentPath' . $i] = $attachment_path;
        }
        // SalesPlatform.ru end
        $taxTotal = '0.00';
        $taxTotal = number_format($taxTotal, $no_of_decimal_places, '.', '');
        $product_Detail[$i]['taxTotal' . $i] = $taxTotal;
        //Calculate netprice
        $netPrice = $totalAfterDiscount + $taxTotal;
        //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
        // SalesPlatform.ru begin Added acts and consignments
        if ($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice' || $module == 'Act' || $module == 'Consignment') {
            $taxtype = getInventoryTaxType($module, $focus->id);
            if ($taxtype == 'individual') {
                //Add the tax with product total and assign to netprice
                $netPrice = $netPrice + $taxTotal;
            }
        }
        $product_Detail[$i]['netPrice' . $i] = $netPrice;
        //First we will get all associated taxes as array
        $tax_details = getTaxDetailsForProduct($hdnProductId, 'all');
        //Now retrieve the tax values from the current query with the name
        for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
            $tax_name = $tax_details[$tax_count]['taxname'];
            $tax_label = $tax_details[$tax_count]['taxlabel'];
            $tax_value = '0';
            //condition to avoid this function call when create new PO/SO/Quotes/Invoice from Product module
            if ($focus->id != '') {
                if ($taxtype == 'individual') {
                    //if individual then show the entered tax percentage
                    $tax_value = getInventoryProductTaxValue($focus->id, $hdnProductId, $tax_name);
                } else {
                    //if group tax then we have to show the default value when change to individual tax
                    $tax_value = $tax_details[$tax_count]['percentage'];
                }
            } else {
                //if the above function not called then assign the default associated value of the product
                $tax_value = $tax_details[$tax_count]['percentage'];
            }
            $product_Detail[$i]['taxes'][$tax_count]['taxname'] = $tax_name;
            $product_Detail[$i]['taxes'][$tax_count]['taxlabel'] = $tax_label;
            $product_Detail[$i]['taxes'][$tax_count]['percentage'] = $tax_value;
        }
    }
    //set the taxtype
    $product_Detail[1]['final_details']['taxtype'] = $taxtype;
    //Get the Final Discount, S&H charge, Tax for S&H and Adjustment values
    //To set the Final Discount details
    $finalDiscount = '0';
    $product_Detail[1]['final_details']['discount_type_final'] = 'zero';
    $subTotal = $focus->column_fields['hdnSubTotal'] != '' ? $focus->column_fields['hdnSubTotal'] : '0';
    $subTotal = number_format($subTotal, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['hdnSubTotal'] = $subTotal;
    $discountPercent = $focus->column_fields['hdnDiscountPercent'] != '' ? $focus->column_fields['hdnDiscountPercent'] : '0';
    $discountAmount = $focus->column_fields['hdnDiscountAmount'] != '' ? $focus->column_fields['hdnDiscountAmount'] : '0';
    if ($discountPercent != '0') {
        $discountAmount = $product_Detail[1]['final_details']['hdnSubTotal'] * $discountPercent / 100;
    }
    //To avoid NaN javascript error, here we assign 0 initially to' %of price' and 'Direct Price reduction'(For Final Discount)
    $discount_amount_final = '0';
    $discount_amount_final = number_format($discount_amount_final, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['discount_percentage_final'] = 0;
    $product_Detail[1]['final_details']['discount_amount_final'] = $discount_amount_final;
    //fix for opensource issue not saving invoice data properly
    if (!empty($focus->column_fields['hdnDiscountPercent'])) {
        $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 (!empty($focus->column_fields['hdnDiscountAmount'])) {
        $finalDiscount = $focus->column_fields['hdnDiscountAmount'];
        $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"';
    }
    $finalDiscount = number_format($finalDiscount, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['discountTotal_final'] = $finalDiscount;
    //To set the Final Tax values
    //we will get all taxes. if individual then show the product related taxes only else show all taxes
    //suppose user want to change individual to group or vice versa in edit time the we have to show all taxes. so that here we will store all the taxes and based on need we will show the corresponding taxes
    $taxtotal = '0';
    //First we should get all available taxes and then retrieve the corresponding tax values
    $tax_details = getAllTaxes('available', '', 'edit', $focus->id);
    for ($tax_count = 0; $tax_count < count($tax_details); $tax_count++) {
        $tax_name = $tax_details[$tax_count]['taxname'];
        $tax_label = $tax_details[$tax_count]['taxlabel'];
        //if taxtype is individual and want to change to group during edit time then we have to show the all available taxes and their default values
        //Also taxtype is group and want to change to individual during edit time then we have to provide the asspciated taxes and their default tax values for individual products
        // SalesPlatform.ru begin
        if ($taxtype == 'group' || $taxtype == 'group_tax_inc') {
            //if($taxtype == 'group')
            // SalesPlatform.ru end
            $tax_percent = $adb->query_result($result, 0, $tax_name);
        } else {
            $tax_percent = $tax_details[$tax_count]['percentage'];
        }
        //$adb->query_result($result,0,$tax_name);
        if ($tax_percent == '' || $tax_percent == 'NULL') {
            $tax_percent = '0.00';
        }
        // SalesPlatform.ru begin
        if ($taxtype == 'group_tax_inc') {
            $taxamount = ($subTotal - $finalDiscount) * $tax_percent / (100.0 + $tax_percent);
        } else {
            // SalesPlatform.ru end
            $taxamount = ($subTotal - $finalDiscount) * $tax_percent / 100;
        }
        $taxamount = number_format($taxamount, $no_of_decimal_places, '.', '');
        $taxtotal = $taxtotal + $taxamount;
        $product_Detail[1]['final_details']['taxes'][$tax_count]['taxname'] = $tax_name;
        $product_Detail[1]['final_details']['taxes'][$tax_count]['taxlabel'] = $tax_label;
        $product_Detail[1]['final_details']['taxes'][$tax_count]['percentage'] = $tax_percent;
        $product_Detail[1]['final_details']['taxes'][$tax_count]['amount'] = $taxamount;
    }
    $product_Detail[1]['final_details']['tax_totalamount'] = $taxtotal;
    //To set the Shipping & Handling charge
    $shCharge = $focus->column_fields['hdnS_H_Amount'] != '' ? $focus->column_fields['hdnS_H_Amount'] : '0    ';
    $shCharge = number_format($shCharge, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['shipping_handling_charge'] = $shCharge;
    //To set the Shipping & Handling tax values
    //calculate S&H tax
    $shtaxtotal = '0';
    //First we should get all available taxes and then retrieve the corresponding tax values
    $shtax_details = getAllTaxes('available', 'sh', 'edit', $focus->id);
    //if taxtype is group then the tax should be same for all products in vtiger_inventoryproductrel table
    for ($shtax_count = 0; $shtax_count < count($shtax_details); $shtax_count++) {
        $shtax_name = $shtax_details[$shtax_count]['taxname'];
        $shtax_label = $shtax_details[$shtax_count]['taxlabel'];
        $shtax_percent = '0';
        //if condition is added to call this function when we create PO/SO/Quotes/Invoice from Product module
        // SalesPlatform.ru begin Added acts and consignments
        if ($module == 'PurchaseOrder' || $module == 'SalesOrder' || $module == 'Quotes' || $module == 'Invoice' || $module == 'Act' || $module == 'Consignment') {
            $shtax_percent = getInventorySHTaxPercent($focus->id, $shtax_name);
        }
        // SalesPlatform.ru begin
        if ($taxtype == 'group_tax_inc') {
            $shtaxamount = $shCharge * $shtax_percent / (100 + $shtax_percent);
        } else {
            // SalesPlatform.ru end
            $shtaxamount = $shCharge * $shtax_percent / 100;
        }
        $shtaxtotal = $shtaxtotal + $shtaxamount;
        $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['taxname'] = $shtax_name;
        $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['taxlabel'] = $shtax_label;
        $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['percentage'] = $shtax_percent;
        $product_Detail[1]['final_details']['sh_taxes'][$shtax_count]['amount'] = $shtaxamount;
    }
    $shtaxtotal = number_format($shtaxtotal, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['shtax_totalamount'] = $shtaxtotal;
    //To set the Adjustment value
    $adjustment = $focus->column_fields['txtAdjustment'] != '' ? $focus->column_fields['txtAdjustment'] : '0';
    $adjustment = number_format($adjustment, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['adjustment'] = $adjustment;
    //To set the grand total
    $grandTotal = $focus->column_fields['hdnGrandTotal'] != '' ? $focus->column_fields['hdnGrandTotal'] : '0';
    $grandTotal = number_format($grandTotal, $no_of_decimal_places, '.', '');
    $product_Detail[1]['final_details']['grandTotal'] = $grandTotal;
    $log->debug("Exiting getAssociatedProducts method ...");
    return $product_Detail;
}